Finish up with initial round of i18zation

master
rarkenin 2014-04-23 16:30:31 -04:00
parent 539e401398
commit ecb32a40b2
29 changed files with 351 additions and 228 deletions

View File

@ -0,0 +1,5 @@
<root>
<item name='java.util.HashMap V put(K, V) 0'>
<annotation name='org.jetbrains.annotations.NonNls'/>
</item>
</root>

View File

@ -1,8 +1,8 @@
package net.mosstest.launcher;
import net.mosstest.servercore.*;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.log4j.Logger;
import org.jetbrains.annotations.NonNls;
import javax.swing.*;
import javax.swing.table.AbstractTableModel;
@ -90,7 +90,7 @@ public class GUIClientsideLauncher {
* @throws InterruptedException the interrupted exception
*/
public static void main(String[] args) throws InvocationTargetException, InterruptedException {
logger.info("Mosstest client starting...");
logger.info(Messages.getString("MOSS_CLIENT_STARTING"));
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (ClassNotFoundException | InstantiationException
@ -166,7 +166,7 @@ public class GUIClientsideLauncher {
int row = GUIClientsideLauncher.this.table.getSelectedRow();
if (row < 0) {
logger.warn("An attempt was made to start gameplay without selecting a world.");
logger.warn(Messages.getString("GAMEPLAY_NO_WORLD"));
JOptionPane.showMessageDialog(
null,
Messages.getString("GUIClientsideLauncher.ERR_NO_WORLD_SELECTED"), //$NON-NLS-1$
@ -184,10 +184,10 @@ public class GUIClientsideLauncher {
MossWorld w = new MossWorld((String) GUIClientsideLauncher.this.table.getModel().getValueAt(row, 0), -16511);
} catch (MossWorldLoadException | MapDatabaseException | IOException e) {
logger.error("Uncaught exception in game code, opening bug reporter.");
logger.error(Messages.getString("GAME_UNCAUGHT_EXCEPT"));
String fname = MossDebugUtils.writeStracktrace(e);
logger.error(MessageFormat.format("Stracktrace has been written to {0}", fname));
logger.error(MessageFormat.format(Messages.getString("STACKTRACE_WRITTEN"), fname));
GUIBugReportDialog bg = new GUIBugReportDialog(
MossDebugUtils.getDebugInformation(e));
bg.setVisible(true);
@ -208,7 +208,7 @@ public class GUIClientsideLauncher {
// TODO actually create world
} else
logger.info("World creation cancelled");
logger.info(Messages.getString("WORLD_CREATION_CXLD"));
}
});
@ -225,7 +225,7 @@ public class GUIClientsideLauncher {
int row = GUIClientsideLauncher.this.table.getSelectedRow();
if (row < 0) {
logger.warn("An attempt was made to delete a world, but none was selected.");
logger.warn(Messages.getString("NO_WORLD_TO_DELETE"));
JOptionPane.showMessageDialog(
null,
Messages.getString("GUIClientsideLauncher.DLG_NO_WORLD_TO_DELETE"), //$NON-NLS-1$
@ -286,7 +286,7 @@ public class GUIClientsideLauncher {
btnVisitForums.setEnabled(false);
communityToolsButtonPanel.add(btnVisitForums);
JTextArea textArea = new JTextArea();
@NonNls JTextArea textArea = new JTextArea();
aboutTab.add(textArea);
textArea.setText(" __ __ ____ _____ _____ _______ ______ _____ _______ \r\n"
+ " | \\/ |/ __ \\ / ____/ ____|__ __| ____|/ ____|__ __|\r\n"

View File

@ -44,3 +44,8 @@ GUIWorldDeletionDialog.DLG_TITLE=Delete singleplayer world...
GUIWorldDeletionDialog.NO=No
GUIWorldDeletionDialog.QUESTIONMARK_CANNOT_UNDO=? This operation cannot be undone.
GUIWorldDeletionDialog.YES=Yes
GAMEPLAY_NO_WORLD=An attempt was made to start gameplay without selecting a world.
GAME_UNCAUGHT_EXCEPT=Uncaught exception in game code, opening bug reporter.
STACKTRACE_WRITTEN=Stracktrace has been written to {0}
WORLD_CREATION_CXLD=World creation cancelled
NO_WORLD_TO_DELETE=An attempt was made to delete a world, but none was selected.

View File

@ -61,7 +61,7 @@ public class MapChunk extends AbstractMapChunk {
try {
loadBytes_(light);
} catch (IOException e){
logger.fatal("IOException caught constructing a MapChunk, and being rethrown as a MosstestFatalDeathException. The world is GOING DOWN NOW.");
logger.fatal(Messages.getString("FAIL_BUILD_MAPCHUNK_FATAL"));
throw new MosstestFatalDeathException(e);
}
@ -197,7 +197,7 @@ public class MapChunk extends AbstractMapChunk {
bos.flush();
} catch (IOException e) {
// should never happen
logger.warn("IOException writing light chunk data");
logger.warn(Messages.getString("LIGHT_DATA_IOEXCEPTION"));
}
return bos.toByteArray();

View File

@ -2,6 +2,8 @@ package net.mosstest.scripting;
// TODO: Auto-generated Javadoc
import org.jetbrains.annotations.NonNls;
import java.util.Arrays;
/**
@ -172,7 +174,7 @@ public class MapNode {
* @param texture the texture to use for each side
* @param lightEmission the light emission
*/
public MapNode(String nodeName, String userFacingName, String texture,
public MapNode(@NonNls String nodeName, String userFacingName, @NonNls String texture,
int lightEmission) {
this.nodeparams = new DefaultNodeParams();

View File

@ -67,7 +67,7 @@ public class MossInventory implements IByteArrayWriteable, IManaged<ItemManager>
bos.flush();
} catch (IOException e) {
// This should never happen in real life
logger.fatal("IOException serializing an inventory. THE WORLD IS GOING DOWN SHORTLY.");
logger.fatal(Messages.getString("INV_IOEXCEPTION_FATAL"));
throw new MosstestFatalDeathException(e);
}
return bos.toByteArray();

View File

@ -1,5 +1,7 @@
package net.mosstest.scripting;
import org.jetbrains.annotations.NonNls;
public class MossItemBuilder {
private String invTex;
private String wieldTex;
@ -13,7 +15,7 @@ public class MossItemBuilder {
return this;
}
public MossItemBuilder setWieldTex(String wieldTex) {
public MossItemBuilder setWieldTex(@NonNls String wieldTex) {
this.wieldTex = wieldTex;
return this;
}
@ -52,12 +54,12 @@ public class MossItemBuilder {
return internalName;
}
public MossItemBuilder setDisplayName(String displayName) {
public MossItemBuilder setDisplayName(@NonNls String displayName) {
this.displayName = displayName;
return this;
}
public MossItemBuilder setInternalName(String internalName) {
public MossItemBuilder setInternalName(@NonNls String internalName) {
this.internalName = internalName;
return this;
}

View File

@ -12,6 +12,7 @@ import org.apache.commons.lang3.StringUtils;
import net.mosstest.servercore.PlayerCommunicator;
import net.mosstest.servercore.RenderProcessor;
import org.jetbrains.annotations.NonNls;
// TODO: Auto-generated Javadoc
@ -144,7 +145,7 @@ public class Player {
* @param maxStack the max stack
* @return the moss inventory
*/
public MossInventory getInventory(String name, int rows, int cols,
public MossInventory getInventory(@NonNls String name, int rows, int cols,
int maxStack) {
// todo inventory caching
MossInventory inv = inventories.get(name);

View File

@ -1,6 +1,7 @@
package net.mosstest.scripting;
import net.mosstest.servercore.serialization.IByteArrayWriteable;
import org.jetbrains.annotations.NonNls;
import java.io.IOException;
@ -9,7 +10,8 @@ import java.io.IOException;
*/
public class Position implements IByteArrayWriteable{
public static final int SERIALIZED_LENGTH = 16;
@Override
@NonNls
@Override
public String toString() {
return "Position [x=" + x + ", y=" + y + ", z=" + z + ", realm="
+ realm + ", hashCode()=" + hashCode() + "]";

View File

@ -1,16 +0,0 @@
package net.mosstest.scripting;
import org.apache.log4j.Logger;
public class ScriptDebugUtils {
public static boolean primed = false;
private static final Logger logger = Logger.getLogger(ScriptDebugUtils.class);
public static void hitBreakpoint(String s){
logger.warn("Hit breakpoint "+s);
System.currentTimeMillis(); // dummy for breakpoint
}
public static void primeBreakpoint(){
primed = true;
}
}

View File

@ -89,6 +89,7 @@ public class MossNodeChangeEvent implements IMossEvent{
this.wieldItem = wieldItem;
}
@SuppressWarnings("HardCodedStringLiteral")
@Override
public String toString() {
return new ToStringBuilder(this)

View File

@ -1,3 +1,4 @@
AntiCheatController.THREAD_NAME=anticheat
MossEvent.MSG_CROSS_DMZ_SECURITY_WARNING=Attempt to access controlled resources in the script DMZ.
ScriptableDatabase.DB_NAME_INVALID=Invalid database name.
INV_IOEXCEPTION_FATAL=IOException serializing an inventory. THE WORLD IS GOING DOWN SHORTLY.

View File

@ -3,6 +3,7 @@ package net.mosstest.servercore;
// TODO: Auto-generated Javadoc
import org.apache.log4j.Logger;
import org.jetbrains.annotations.NonNls;
/**
* The Class EngineSettings.
@ -17,8 +18,8 @@ private static final Logger logger = Logger.getLogger(EngineSettings.class);
* @param def the def
* @return the int
*/
public static int getInt(String name, int def){
logger.error("Hit fixme section. Please file a bug report or otherwise remind the devs sharply.");
public static int getInt(@NonNls String name, int def){
logger.error(Messages.getString("FIXME_MESSAGE"));
if("forced".equals("false")){ //$NON-NLS-1$ //$NON-NLS-2$
return 0; //TODO this case
}
@ -33,7 +34,7 @@ private static final Logger logger = Logger.getLogger(EngineSettings.class);
* @return the bool
*/
public static boolean getBool(String string, boolean def) {
logger.error("Hit fixme section. Please file a bug report or otherwise remind the devs sharply.");
logger.error(Messages.getString("FIXME_MESSAGE"));
if("forced".equals("false")){ //$NON-NLS-1$ //$NON-NLS-2$
return false; //TODO this case
}

View File

@ -111,7 +111,7 @@ public class EventProcessor {
}
DefaultEventHandlers.processEvent(evt, this.ev);
} catch (MossScriptException | IllegalArgumentException e) {
logger.warn(MessageFormat.format("Caught {0} upon processing an event of type {1}. The exception message was {2}.", e.getClass().getName(), evt.getClass().getName(), e.getLocalizedMessage()));
logger.warn(MessageFormat.format(Messages.getString("EVENT_PROCESS_EXCEPTION"), e.getClass().getName(), evt.getClass().getName(), e.getLocalizedMessage()));
}
}
@ -226,35 +226,6 @@ public class EventProcessor {
}
/**
* Tests the event processor
*/
public static void main(String... args) throws ConfigurationException, MossWorldLoadException, MapDatabaseException, IOException, InterruptedException {
MossWorld mw = new MossWorld("test", -1);
EventProcessor evp = mw.getEvp();
MossNodeChangeHandler handler = new MossNodeChangeHandler() {
@Override
public boolean onAction(MossNodeChangeEvent evt) {
logger.info("Received test event " + evt.toString());
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
return false;
}
};
mw.getMossEnv().registerHandler(handler, MossNodeChangeEvent.class);
long s = 0;
while (true) {
logger.debug("Enqueueing!");
evp.eventQueue.put(new MossNodeChangeEvent(
null,
new NodePosition(0, 1, 2, 3, (byte) 4, (byte) 5, (byte) 6),
s++, MossNodeChangeEvent.NodeActionType.NODE_ACTION_REPLACE,
new MapNode("test", "Test", "test/test.png", 0), null));
//Thread.sleep(1000);
}
}
}

View File

@ -38,7 +38,7 @@ public class FuturesProcessor {
try {
task = queue.take();
} catch (InterruptedException e) {
logger.error("InterruptedException in futures processor trying to take from queue.");
logger.error(Messages.getString("FUTURES_QUEUE_INTERRUPTED"));
Thread.currentThread().interrupt(); // in case caller requires detecting interrupts
continue rLoop;
}

View File

@ -3,6 +3,7 @@ package net.mosstest.servercore;
import net.mosstest.scripting.MapNode;
import net.mosstest.scripting.MossItem;
import net.mosstest.scripting.MossItemBuilder;
import org.jetbrains.annotations.NonNls;
import java.util.ArrayList;
import java.util.HashMap;
@ -26,6 +27,7 @@ public class ItemManager {
/**
* The unknown fallback item.
*/
@NonNls
private final MossItem unknownFallbackItem = new MossItemBuilder().setInvTex("item_unknown.png").setWieldTex("sys_hand.png").setInvWeight(1).setStackMode(MossItem.StackMode.STACK_UNIT).setDisplayName("An unidentifiable item").setInternalName("sys:unknown").createMossItem();

View File

@ -23,7 +23,7 @@ public class LocalAssetLocator implements AssetLocator {
return new LocalAssetInfo(manager, key,
this.lfm.getFile(key.getName()));
} catch (IOException ex) {
throw new AssetLoadException(MessageFormat.format("Failed to open file: {0}",
throw new AssetLoadException(MessageFormat.format(Messages.getString("FILE_OPEN_FAILED"),
key.getName(), ex));
}
@ -49,7 +49,7 @@ public class LocalAssetLocator implements AssetLocator {
try {
return this.file.getInputStream();
} catch (IOException ex) {
throw new AssetLoadException(MessageFormat.format("Failed to open file: {0}", this.file.getFilename()), ex);
throw new AssetLoadException(MessageFormat.format(Messages.getString("FILE_OPEN_FAILED"), this.file.getFilename()), ex);
}
}
}

View File

@ -48,9 +48,9 @@ public class LocalFile implements IMossFile {
/ ((double) IMossFile.CHUNK_SIZE));
try {
this.sha256 = LocalFileManager.getHash(f);
logger.info(MessageFormat.format("Hashed {0} as {1}", f.getAbsolutePath(), this.sha256));
logger.info(MessageFormat.format(Messages.getString("HASH_SUCCESS"), f.getAbsolutePath(), this.sha256));
} catch (NoSuchAlgorithmException e) {
logger.error(MessageFormat.format("Could not find algorithm SHA-256 while hashing {0}", f.getAbsolutePath()));
logger.error(MessageFormat.format(Messages.getString("ALGO_NOT_FOUND"), f.getAbsolutePath()));
throw new IOException("Hashing failed while preparing file", e);
}
}

View File

@ -22,11 +22,14 @@ import java.text.MessageFormat;
import java.util.*;
public class LocalFileManager implements IFileManager {
@NonNls
private static final String XML_DEPENDENCY_KEY = "dependencies.dependency";
private HashSet<String> visitedScripts = new HashSet<>();
protected HashSet<AbstractMossScript> executed = new HashSet<>();
public static final LocalFileManager scriptsInstance;
public static final int HASHING_BUFFER_SIZE = 8192;
public static final int BYTE_CAST_MASK = 0xFF;
@NonNls
@SuppressWarnings("StaticCollection")
private static HashMap<String, LocalFileManager> managers = new HashMap<>();
@ -38,7 +41,7 @@ public class LocalFileManager implements IFileManager {
private HashMap<String, LocalFile> files = new HashMap<>();
public static final IOFileFilter CVS_FILTER = FileFilterUtils.makeCVSAware(null);
public static LocalFileManager getFileManager(String key) {
public static LocalFileManager getFileManager(@NonNls String key) {
return managers.get(key);
}
@ -47,15 +50,15 @@ public class LocalFileManager implements IFileManager {
static Logger logger = Logger.getLogger(LocalFileManager.class);
@Override
public LocalFile getFile(String name) throws IOException, FileNotFoundException {
public LocalFile getFile(@NonNls String name) throws IOException, FileNotFoundException {
String normalized = FilenameUtils.normalize(name);
if (normalized == null) {
logger.warn(MessageFormat.format("Failed to normalize game resource filename: {0}", name));
logger.warn(MessageFormat.format(Messages.getString("NORMALIZE_FAILED"), name));
throw new FileNotFoundException(MessageFormat.format("Failed to normalize game resource filename: {0}", name));
throw new FileNotFoundException(MessageFormat.format(Messages.getString("NORMALIZE_FAILED"), name));
}
File f = new File(this.basedir, normalized);
logger.info(MessageFormat.format("Got local file {0} as {1}", name, f.getAbsolutePath()));
logger.info(MessageFormat.format(Messages.getString("GOT_LOCAL_FILE"), name, f.getAbsolutePath()));
return new LocalFile(name, f);
}
@ -94,7 +97,7 @@ public class LocalFileManager implements IFileManager {
NoSuchAlgorithmException, FileNotFoundException {
MessageDigest md = MessageDigest.getInstance("SHA-256");
MessageDigest md = MessageDigest.getInstance("SHA-256"); //NON-NLS
try (FileInputStream fis = new FileInputStream(f)) {
try (FileChannel fc = fis.getChannel()) {
@ -145,7 +148,7 @@ public class LocalFileManager implements IFileManager {
while ((line = idxR.readLine()) != null) {
String normalizedLine = FilenameUtils.normalize(line.trim());
if (normalizedLine == null) {
logger.warn(MessageFormat.format("Failed to normalize game resource filename from index: {0}", line));
logger.warn(MessageFormat.format(Messages.getString("INDEXED_NORMALIZE_FAILURE"), line));
continue;
}
@ -155,12 +158,12 @@ public class LocalFileManager implements IFileManager {
final LocalFile file = getFile(filename);
this.registerFile(filename, file);
} catch (FileNotFoundException e) {
logger.warn(MessageFormat.format("File was in index but not on disk: {0}", name));
logger.warn(MessageFormat.format(Messages.getString("INDEXED_NOT_ON_DISK"), name));
}
}
} catch (FileNotFoundException e) {
logger.warn("No index file found; all files will be served to the client.");
logger.warn(Messages.getString("NO_INDEX"));
File base = new File(basedir, normalized);
Path basePath = Paths.get(basedir.getAbsolutePath());
for (File f : FileUtils.listFiles(base, CVS_FILTER, CVS_FILTER)) {
@ -168,11 +171,11 @@ public class LocalFileManager implements IFileManager {
Path path = Paths.get(f.getAbsolutePath());
final String resolvedName = basePath.relativize(path).toFile().getPath();
LocalFile file = this.getFile(resolvedName);
logger.debug(MessageFormat.format("Got file via recursive directory listing: {0}", resolvedName));
logger.debug(MessageFormat.format(Messages.getString("FOUND_RECURSIVELY"), resolvedName));
this.registerFile(resolvedName, file);
} catch (FileNotFoundException fnfe2) {
// should not happen
logger.warn("Could not find file from recursive directory listing. This should never happen.");
logger.warn(Messages.getString("RECURSIVE_LISTED_BUT_NOT_FOUND"));
}
}
}
@ -182,23 +185,23 @@ public class LocalFileManager implements IFileManager {
XMLConfiguration scriptCfg = new XMLConfiguration(scriptXml);
String[] scNames = scriptCfg.getStringArray("dependencies.dependency");
String[] scNames = scriptCfg.getStringArray(XML_DEPENDENCY_KEY);
for (@NonNls String sc : scNames) {
if (sc.equals(name)) continue;
if (visitedScripts.contains(sc)) {
logger.fatal(MessageFormat.format("A circular dependency was found. {0} depends on {1} but the latter depends directly or indirectly on the former", name, sc));
throw new MossWorldLoadException(MessageFormat.format("A circular dependency was found. {0} depends on {1} but the latter depends directly or indirectly on the former", name, sc));
logger.fatal(MessageFormat.format(Messages.getString("CIRCULAR_DEPENDENCY_ISSUE"), name, sc));
throw new MossWorldLoadException(MessageFormat.format(Messages.getString("CIRCULAR_DEPENDENCY_ISSUE"), name, sc));
}
try {
dependencies.add(this.getScript(sc));
} catch (StackOverflowError e) {
// should never happen
logger.fatal("FIXME The stack overflowed while resolving dependencies. Either there is an undetected dependency issue, or there is simply an extreme number of dependencies.");
logger.fatal(Messages.getString("DEPFIND_STACK_OVERFLOW"));
throw new MossWorldLoadException("FIXME The stack overflowed while resolving dependencies. Either there is an undetected dependency issue, or there is simply an extreme number of dependencies.");
}
}
} catch (ConfigurationException | FileNotFoundException e) {
logger.warn("No script.xml has been given, assuming no dependencies and defaults for all other script settings.");
logger.warn(Messages.getString("SCRIPT_XML_MISSING"));
}
return new LocalScript(name, dependencies);
@ -207,9 +210,9 @@ public class LocalFileManager implements IFileManager {
public IMossFile getScriptInitFile(String scName) throws IOException, FileNotFoundException {
String normalized = FilenameUtils.normalize(scName);
if (normalized == null) {
logger.warn(MessageFormat.format("Failed to normalize game resource filename: {0}", scName));
logger.warn(MessageFormat.format(Messages.getString("FAILED_NORMALIZE_RSRC"), scName));
throw new FileNotFoundException(MessageFormat.format("Failed to normalize game resource filename: {0}", scName));
throw new FileNotFoundException(MessageFormat.format(Messages.getString("FAILED_NORMALIZE_RSRC"), scName));
}
@NonNls final String scriptName = normalized + "/init.js";
LocalFile scriptFile = getFile(scriptName);

View File

@ -52,7 +52,7 @@ public class MapCache {
try {
chk = chunkCache.get(pos);
} catch (ExecutionException e) {
logger.error(MessageFormat.format("Chunk loader threw ExecutionException with message {0}", e.getMessage()));
logger.error(MessageFormat.format(Messages.getString("CHUNK_LDR_EXECUTION_EXCEPTION"), e.getMessage()));
}
if (chk == null) {
// loading from DB is still done if no chunk exists after an async load
@ -128,12 +128,12 @@ public class MapCache {
public void onRemoval(RemovalNotification<Position, MapChunk> notification) {
switch (notification.getCause()) {
case COLLECTED:
logger.warn(MessageFormat.format("Un-caching {0} due to garbage collection. Memory may be low.", notification.getKey().toString()));
logger.warn(MessageFormat.format(Messages.getString("GC_EVICT"), notification.getKey().toString()));
break;
case EXPIRED:
logger.info(MessageFormat.format("Un-caching {0} as it has expired.", notification.getKey().toString()));
logger.info(MessageFormat.format(Messages.getString("UNCACHE_EXPIRE"), notification.getKey().toString()));
case SIZE:
logger.warn(MessageFormat.format("Un-caching {0} due to a size constraint.", notification.getKey().toString()));
logger.warn(MessageFormat.format(Messages.getString("EVICT_SIZE"), notification.getKey().toString()));
}
}
@ -142,7 +142,7 @@ public class MapCache {
private class PositionMapChunkCacheLoader extends CacheLoader<Position, MapChunk> {
@Override
public MapChunk load(Position position) throws Exception {
logger.info(MessageFormat.format("Re-loading {0} into cache.", position.toString()));
logger.info(MessageFormat.format(Messages.getString("RELOADING_INTO_CACHE"), position.toString()));
MapChunk chk = MapCache.this.db.getChunk(position);
if (chk == null) {
chk = MapGenerators.getDefaultMapgen().generateChunk(position);

View File

@ -80,11 +80,11 @@ public class MapDatabase {
this.players = factory.open(new File(dbDir, "players"), options); //$NON-NLS-1$
this.nodes = factory.open(new File(dbDir, "nodes"), options); //$NON-NLS-1$
} catch (IOException e) {
logger.error(MessageFormat.format("IOException in database loading: {0}", e.getMessage()));
logger.error(MessageFormat.format(Messages.getString("DB_LOAD_IOEXCEPTION"), e.getMessage()));
throw new MossWorldLoadException(Messages.getString("MapDatabase.ERR_DB_FAIL"), e); //$NON-NLS-1$
}
logger.info("Database loaded normally.");
logger.info(Messages.getString("DB_NORMAL_LOAD"));
}
@ -95,7 +95,7 @@ public class MapDatabase {
*/
public void close() throws MapDatabaseException {
logger.info("Database shutting down (normally)");
logger.info(Messages.getString("DB_SHUTDOWN_NORMAL"));
try {
this.map.close();
this.entities.close();
@ -123,14 +123,13 @@ public class MapDatabase {
try {
return new MapChunk(chunk);
} catch (MosstestFatalDeathException e) {
logger.warn("Map database performed emergency shutdown after catching MosstestFatalDeathException");
try {
this.close();
} catch (MapDatabaseException e1) {
logger.error(MessageFormat.format("Map database failed emergency shutdown: {0}", e1.getMessage()));
logger.error(MessageFormat.format(Messages.getString("DB_EMERGENCY_SHUTDOWN_FAIL"), e1.getMessage()));
throw new MosstestFatalDeathException(e1);
}
logger.warn("Map database performed emergency shutdown after catching MosstestFatalDeathException");
logger.warn(Messages.getString("DB_SHUTDOWN_EMERGENCY"));
// MUST rethrow
throw e;

View File

@ -53,7 +53,7 @@ public class MossDebugUtils {
writer.close();
}
} catch (IOException e1) {
logger.fatal(MessageFormat.format("{0} caught trying to write stacktrace of an existing exception. Message: {1}", e1.getClass().getName(), e1.getMessage()));
logger.fatal(MessageFormat.format(Messages.getString("CAUGHT_EXCEPTION_WRITING_STACKTRACE"), e1.getClass().getName(), e1.getMessage()));
}
return write.getAbsolutePath();
}

View File

@ -9,6 +9,7 @@ import net.mosstest.servercore.MosstestSecurityManager.ThreadContext;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.XMLConfiguration;
import org.apache.log4j.Logger;
import org.jetbrains.annotations.NonNls;
import java.io.File;
import java.io.IOException;
@ -69,7 +70,7 @@ public class MossWorld {
* @throws ConfigurationException
*/
@SuppressWarnings("nls")
public MossWorld(String name, int port) throws MossWorldLoadException,
public MossWorld(@NonNls String name, int port) throws MossWorldLoadException,
MapDatabaseException, IOException {
//Thread.currentThread().setContextClassLoader(
// MosstestSecurityManager.instance.getScriptClassLoader(Thread
@ -91,7 +92,7 @@ public class MossWorld {
try {
this.worldCfg = new XMLConfiguration(this.cfgFile);
} catch (ConfigurationException e) {
logger.fatal("The configuration data for the game could not be found, or is empty.");
logger.fatal(Messages.getString("GAME_CFG_DATA_GONE"));
}
if (!this.worldCfg.containsKey("gameid")) { //$NON-NLS-1$
throw new MossWorldLoadException(

View File

@ -1,7 +1,6 @@
package net.mosstest.servercore;
import net.mosstest.scripting.MossScriptEnv;
import net.mosstest.scripting.ScriptDebugUtils;
import org.apache.log4j.Logger;
import java.io.File;
@ -11,10 +10,7 @@ import java.io.IOException;
import java.net.InetAddress;
import java.security.AccessController;
import java.security.Permission;
import java.security.SecureClassLoader;
import java.text.MessageFormat;
import java.util.Arrays;
import java.util.List;
// TODO: Auto-generated Javadoc
@ -36,7 +32,7 @@ public class MosstestSecurityManager extends SecurityManager {
public MosstestSecurityManager(boolean testMode) {
this.testMode = testMode;
if (testMode) logger.warn("WARNING! The security manager is running in test mode. Security may be diminished.");
if (testMode) logger.warn(Messages.getString("SECURITY_MANAGER_TESTMODE"));
File classDir = null;
try {
classDir = new File(MossScriptEnv.class.getProtectionDomain()
@ -44,7 +40,7 @@ public class MosstestSecurityManager extends SecurityManager {
.getParentFile() // net.mosstest.scripting
.getCanonicalFile();
} catch (IOException e) {
logger.warn("Failed to obtain a class directory for the security manager, spurious classloading failures may result.");
logger.warn(Messages.getString("NO_CLASSDIR"));
} finally {
this.classDirectory = classDir;
}
@ -55,12 +51,12 @@ public class MosstestSecurityManager extends SecurityManager {
public void checkPermission(Permission perm) {
if (this.threadContext.get() != ThreadContext.CONTEXT_ENGINE) {
logger.fatal(MessageFormat.format("Requested permssion ", perm));
if (testMode && perm.getName().equals("setIO")) return;
logger.warn("MosstestSecurityManager prevented the use of arbitrary permissions outside engine contexts.");
logger.fatal(MessageFormat.format(Messages.getString("PERMISSION_REQUESTED"), perm));
if (testMode && perm.getName().equals("setIO")) return; //NON-NLS
logger.warn(Messages.getString("ARBITRARY_PERMISSIONS"));
throw new SecurityException(
"MosstestSecurityManager prevented the use of arbitrary permissions outside engine contexts.");
Messages.getString("ARBITRARY_PERMISSIONS"));
}
}
@ -73,7 +69,6 @@ public class MosstestSecurityManager extends SecurityManager {
*/
@Override
public void checkPermission(Permission perm, Object context) {
System.err.println(perm.toString() + ":" + context.toString());
checkPermission(perm);
}
@ -102,8 +97,8 @@ public class MosstestSecurityManager extends SecurityManager {
public void setTrustedBasedir(File basedir) throws SecurityException,
IOException {
if (this.threadContext.get() != ThreadContext.CONTEXT_ENGINE) {
logger.error("The security manager prevented an attempt to set the trusted base directory.");
throw new SecurityException("Cannot set base directory.");
logger.error(Messages.getString("SECURITY_TRUSTED_BASEDIR"));
throw new SecurityException(Messages.getString("NO_SET_BASEDIR"));
}
this.baseDirectory = basedir.getCanonicalFile();
}
@ -117,9 +112,9 @@ public class MosstestSecurityManager extends SecurityManager {
public void lock(Object key, ThreadContext tc) {
if ((this.lock.get() != null)
|| this.threadContext.get() != ThreadContext.CONTEXT_ENGINE) {
logger.error("The security manager prevented an attempt to lock it on an already-locked thread.");
logger.error(Messages.getString("THREAD_LOCKED"));
throw new SecurityException(
"The security manager is already locked for this thread.");
Messages.getString("ALREADY_LOCKED"));
}
this.lock.set(key);
this.threadContext.set(tc);
@ -140,9 +135,9 @@ public class MosstestSecurityManager extends SecurityManager {
*/
public void unlock(Object key) {
if (this.lock.get() != key) {
logger.error("The security manager prevented an attempt to unlock it using a mismatched key.");
logger.error(Messages.getString("SECURITY_MISMATCHED_KEY"));
throw new SecurityException(
"A mismatched key has been used to unlock this thread.");
Messages.getString("SECURITY_BAD_KEY"));
}
this.threadContext.set(ThreadContext.CONTEXT_ENGINE);
}
@ -154,7 +149,7 @@ public class MosstestSecurityManager extends SecurityManager {
*/
public void setConnectedPeer(String connectedPeer) {
if (this.threadContext.get() != ThreadContext.CONTEXT_ENGINE) {
logger.warn("MosstestSecurityManager prevented a non-engine-context thread from changing the connected peer.");
logger.warn(Messages.getString("SECURITY_PEER_CHANGE"));
throw new SecurityException(
"Attempted to set the connected peer from outside engine code");
}
@ -178,7 +173,7 @@ public class MosstestSecurityManager extends SecurityManager {
*/
public void setThreadContext(ThreadContext tc) {
if (this.threadContext.get() == null) {
logger.warn("A thread has started without inheriting a thread context and has been elevated");
logger.warn(Messages.getString("THREAD_ELEVATED"));
this.threadContext.set(tc);
return;
@ -188,9 +183,8 @@ public class MosstestSecurityManager extends SecurityManager {
this.threadContext.set(tc);
}
if (old != ThreadContext.CONTEXT_ENGINE) {
logger.warn("Attempted to set the thread context type from non-engine code");
throw new SecurityException(
"Attempted to set the thread context type from non-engine code");
logger.warn(Messages.getString("THREAD_CONTEXT_NON_ENGINE_CODE"));
throw new SecurityException(Messages.getString("THREAD_CONTEXT_NON_ENGINE_CODE"));
}
}
@ -228,7 +222,7 @@ public class MosstestSecurityManager extends SecurityManager {
private InheritableThreadLocal<ThreadContext> threadContext = new InheritableThreadLocal<MosstestSecurityManager.ThreadContext>() {
@Override
protected ThreadContext initialValue() {
logger.warn("A thread has started without inheriting a thread context and has been elevated");
logger.warn(Messages.getString("THREAD_ELEVATED"));
return ThreadContext.CONTEXT_ENGINE;
}
};
@ -247,9 +241,9 @@ public class MosstestSecurityManager extends SecurityManager {
public void checkCreateClassLoader() {
if (this.threadContext.get() != ThreadContext.CONTEXT_ENGINE) {
logger.warn("MosstestSecurityManager stopped an attempt to create a classloader");
logger.warn(Messages.getString("SECURITY_CLASSLOADER"));
throw new SecurityException(
"MosstestSecurityManager stopped an attempt to create a classloader");
Messages.getString("SECURITY_CLASSLOADER"));
} else {
super.checkCreateClassLoader();
@ -264,12 +258,12 @@ public class MosstestSecurityManager extends SecurityManager {
*/
@Override
public void checkAccess(Thread t) {
if(testMode) return;
if (testMode) return;
if (this.threadContext.get() != ThreadContext.CONTEXT_ENGINE) {
logger.warn("MosstestSecurityManager stopped an attempt to stop or modify a thread");
logger.warn(Messages.getString("SECURITY_THREAD"));
throw new SecurityException(
"MosstestSecurityManager stopped an attempt to stop or modify a thread");
Messages.getString("SECURITY_THREAD"));
} else {
}
@ -282,12 +276,12 @@ public class MosstestSecurityManager extends SecurityManager {
*/
@Override
public void checkAccess(ThreadGroup g) {
if(testMode) return;
if (testMode) return;
if (this.threadContext.get() != ThreadContext.CONTEXT_ENGINE) {
logger.warn("MosstestSecurityManager stopped an attempt to modify a ThreadGroup");
logger.warn(Messages.getString("SECURITY_THREADGROUP"));
throw new SecurityException(
"MosstestSecurityManager stopped an attempt to modify a ThreadGroup");
Messages.getString("SECURITY_THREADGROUP"));
} else {
}
@ -303,9 +297,9 @@ public class MosstestSecurityManager extends SecurityManager {
if (testMode) return;
if (this.threadContext.get() != ThreadContext.CONTEXT_ENGINE) {
logger.warn("MosstestSecurityManager stopped an attempt to exit Mosstest improperly from a script");
logger.warn(Messages.getString("SECURITY_EXIT"));
throw new SecurityException(
"MosstestSecurityManager stopped an attempt to exit Mosstest improperly from a script");
Messages.getString("SECURITY_EXIT"));
}
super.checkExit(status);
@ -320,9 +314,9 @@ public class MosstestSecurityManager extends SecurityManager {
@Override
public void checkExec(String cmd) {
logger.warn("MosstestSecurityManager does not allow any script or portion of the engine to start a new process");
logger.warn(Messages.getString("SECURITY_SPAWN_PROC"));
throw new SecurityException(
"MosstestSecurityManager does not allow any script or portion of the engine to start a new process");
Messages.getString("SECURITY_SPAWN_PROC"));
}
/*
@ -334,9 +328,9 @@ public class MosstestSecurityManager extends SecurityManager {
public void checkLink(String lib) {
if (this.threadContext.get() != ThreadContext.CONTEXT_ENGINE) {
logger.warn("MosstestSecurityManager stopped an attempt to link to a JN library from insecure code");
logger.warn(Messages.getString("SECURITY_LINK"));
throw new SecurityException(
"MosstestSecurityManager stopped an attempt to link to a JN library from insecure code");
Messages.getString("SECURITY_LINK"));
}
@ -351,10 +345,11 @@ public class MosstestSecurityManager extends SecurityManager {
public void checkRead(FileDescriptor fd) {
if (this.threadContext.get() != ThreadContext.CONTEXT_ENGINE) {
logger.warn("1MosstestSecurityManager stopped an attempt to read a file from non-core code "
+ fd.toString());
logger.warn(MessageFormat.format(Messages.getString("SECURITY_READFILE")
, fd.toString()));
throw new SecurityException(
"MosstestSecurityManager stopped an attempt to read a file from non-core code");
MessageFormat.format(Messages.getString("SECURITY_READFILE"), fd.toString())
);
}
}
@ -366,9 +361,7 @@ public class MosstestSecurityManager extends SecurityManager {
*/
@Override
public void checkRead(String file) {
if(file.contains("testtest")){
System.currentTimeMillis();
}
if (this.threadContext.get() != ThreadContext.CONTEXT_ENGINE) {
// List<File> safeDirectories = Arrays.asList(this.baseDirectory, this.classDirectory);
ThreadContext oldTc = MosstestSecurityManager.this
@ -392,7 +385,7 @@ public class MosstestSecurityManager extends SecurityManager {
// tested = tested.getParentFile();
// } while (tested != null);
try {
AccessController.checkPermission(new FilePermission(file, "read"));
AccessController.checkPermission(new FilePermission(file, "read")); //NON-NLS
} catch (SecurityException e) {
// lock
this.lock(oldLock, oldTc);
@ -416,10 +409,12 @@ public class MosstestSecurityManager extends SecurityManager {
public void checkRead(String file, Object context) {
if (this.threadContext.get() != ThreadContext.CONTEXT_ENGINE) {
logger.warn("3MosstestSecurityManager stopped an attempt to read a file from non-core code: "
+ file);
logger.warn(MessageFormat.format(Messages.getString("SECURITY_READ")
, file));
throw new SecurityException(
"MosstestSecurityManager stopped an attempt to read a file from non-core code");
MessageFormat.format(Messages.getString("SECURITY_READ")
, file)
);
}
}
@ -433,9 +428,9 @@ public class MosstestSecurityManager extends SecurityManager {
public void checkWrite(FileDescriptor fd) {
if (this.threadContext.get() != ThreadContext.CONTEXT_ENGINE) {
logger.warn("MosstestSecurityManager stopped an attempt to write to a file from non-core code");
logger.warn(Messages.getString("SECURITY_WRITE"));
throw new SecurityException(
"MosstestSecurityManager stopped an attempt to write to a file from non-core code");
Messages.getString("SECURITY_WRITE"));
}
}
@ -449,9 +444,9 @@ public class MosstestSecurityManager extends SecurityManager {
public void checkWrite(String file) {
if (this.threadContext.get() != ThreadContext.CONTEXT_ENGINE) {
logger.warn("MosstestSecurityManager stopped an attempt to write to a file from non-core code");
logger.warn(Messages.getString("SECURITY_WRITE"));
throw new SecurityException(
"MosstestSecurityManager stopped an attempt to write to a file from non-core code");
Messages.getString("SECURITY_WRITE"));
}
}
@ -465,7 +460,7 @@ public class MosstestSecurityManager extends SecurityManager {
public void checkDelete(String file) {
if (this.threadContext.get() != ThreadContext.CONTEXT_ENGINE) {
logger.warn("MosstestSecurityManager stopped an attempt to delete a file from non-core code");
logger.warn(Messages.getString("SECURITY_DELETE"));
throw new SecurityException(
"MosstestSecurityManager stopped an attempt to delete a file from non-core code");
@ -480,11 +475,9 @@ public class MosstestSecurityManager extends SecurityManager {
@Override
public void checkConnect(String host, int port) {
if (this.threadContext.get() != ThreadContext.CONTEXT_ENGINE) {
if ((port != PORT_HTTP && port != PORT_HTTPS) && (port > MIN_SCRIPT_PORT || port < MAX_SCRIPT_PORT))
logger.warn("MosstestSecurityManager stopped an attempt to connect to a network port other than 80, 443, or any port in the range 16512-16600");
throw new SecurityException(
"MosstestSecurityManager stopped an attempt to connect to a network port other than 80, 443, or any port in the range 16512-16600");
logger.warn(Messages.getString("SECURITY_CONNECT"));
throw new SecurityException(Messages.getString("SECURITY_CONNECT"));
}
}
@ -498,22 +491,11 @@ public class MosstestSecurityManager extends SecurityManager {
@Override
public void checkConnect(String host, int port, Object context) {
if (this.threadContext.get() == ThreadContext.CONTEXT_CLIENT) {
if ((port != PORT_HTTP && port != PORT_HTTPS) && (port > MIN_SCRIPT_PORT || port < MAX_SCRIPT_PORT)) {
logger.warn("MosstestSecurityManager stopped an attempt to connect to a network port other than 80, 443, or any port in the range 16512-16600");
throw new SecurityException(
"MosstestSecurityManager stopped an attempt to connect to a network port other than 80, 443, or any port in the range 16512-16600");
}
if (!host.equals(this.connectedPeer)) {
throw new SecurityException(
"MosstestSecurityManager stopped an attempt for the client to connect to a peer other than the server currently played");
}
} else if (this.threadContext.get() == ThreadContext.CONTEXT_LOCKDOWN) {
logger.warn("MosstestSecurityManager has denied a thread in lockdown to open a network connection");
logger.warn(Messages.getString("SECURITY_LISTEN"));
throw new SecurityException(
"MosstestSecurityManager has denied a thread in lockdown to open a network connection");
"MosstestSecurityManager stopped an attempt to listen directly on a network port.");
}
}
@ -525,18 +507,11 @@ public class MosstestSecurityManager extends SecurityManager {
@Override
public void checkListen(int port) {
if (this.threadContext.get() == ThreadContext.CONTEXT_SCRIPT) {
if ((port > MIN_SCRIPT_PORT || port < MAX_SCRIPT_PORT))
logger.warn("MosstestSecurityManager stopped an attempt to listen on a port not in the range 16512-16600");
logger.warn(Messages.getString("SECURITY_LISTEN"));
throw new SecurityException(
"MosstestSecurityManager stopped an attempt to listen on a port not in the range 16512-16600");
} else if (this.threadContext.get() == ThreadContext.CONTEXT_LOCKDOWN
|| this.threadContext.get() == ThreadContext.CONTEXT_CLIENT) {
logger.warn("MosstestSecurityManager has denied a thread in lockdown or running a client script to listen on a port");
throw new SecurityException(
"MosstestSecurityManager has denied a thread in lockdown or running a client script to listen on a port");
Messages.getString("SECURITY_LISTEN"));
}
}
@ -548,18 +523,10 @@ public class MosstestSecurityManager extends SecurityManager {
@Override
public void checkAccept(String host, int port) {
if (this.threadContext.get() == ThreadContext.CONTEXT_SCRIPT) {
if ((port > MIN_SCRIPT_PORT || port < MAX_SCRIPT_PORT))
logger.warn("MosstestSecurityManager stopped an attempt to listen on a port not in the range 16512-16600");
logger.warn(Messages.getString("SECURITY_LISTEN"));
throw new SecurityException(
"MosstestSecurityManager stopped an attempt to listen on a port not in the range 16512-16600");
} else if (this.threadContext.get() == ThreadContext.CONTEXT_LOCKDOWN
|| this.threadContext.get() == ThreadContext.CONTEXT_CLIENT) {
logger.warn("MosstestSecurityManager has denied a thread in lockdown or running a client script to listen on a port");
throw new SecurityException(
"MosstestSecurityManager has denied a thread in lockdown or running a client script to listen on a port");
Messages.getString("SECURITY_LISTEN"));
}
}
@ -572,9 +539,9 @@ public class MosstestSecurityManager extends SecurityManager {
public void checkMulticast(InetAddress maddr) {
if (this.threadContext.get() != ThreadContext.CONTEXT_ENGINE) {
logger.warn("MosstestSecurityManager has denied a script use of multicast directly without use of loadbalancing facilities");
logger.warn(Messages.getString("MULTICAST"));
throw new SecurityException(
"Scripts may not use mutlicast under any circumstances, except through the engine loadbalancing facilities");
Messages.getString("MULTICAST2"));
}
}
@ -588,9 +555,9 @@ public class MosstestSecurityManager extends SecurityManager {
public void checkMulticast(InetAddress maddr, byte ttl) {
if (this.threadContext.get() != ThreadContext.CONTEXT_ENGINE) {
logger.warn("MosstestSecurityManager has denied a script use of multicast directly without use of loadbalancing facilities");
logger.warn(Messages.getString("MULTICAST"));
throw new SecurityException(
"Scripts may not use mutlicast under any circumstances, except through the engine loadbalancing facilities");
Messages.getString("MULTICAST2"));
}
}
@ -602,12 +569,12 @@ public class MosstestSecurityManager extends SecurityManager {
*/
@Override
public void checkPropertiesAccess() {
if(testMode) return;
if (testMode) return;
if (this.threadContext.get() != ThreadContext.CONTEXT_ENGINE) {
logger.warn("MosstestSecurityManager has denied a thread running outside the engine context the right to access system properties.");
logger.warn(Messages.getString("SYS_PROPERTIES"));
throw new SecurityException(
"Scripts may not access system properties");
Messages.getString("SYS_PROPERTIES_SHORT"));
}
}
@ -619,12 +586,12 @@ public class MosstestSecurityManager extends SecurityManager {
*/
@Override
public void checkPropertyAccess(String key) {
if(testMode) return;
if (testMode) return;
if (this.threadContext.get() != ThreadContext.CONTEXT_ENGINE) {
logger.warn("MosstestSecurityManager has denied a thread running outside the engine context the right to access system properties.");
logger.warn(Messages.getString("SYS_PROPERTIES"));
throw new SecurityException(
"Scripts may not access system properties. Attempt was to access "+key);
MessageFormat.format(Messages.getString("SYS_PROPERTIES_SHORT_NAMED"), key));
}
}
@ -638,9 +605,9 @@ public class MosstestSecurityManager extends SecurityManager {
public boolean checkTopLevelWindow(Object window) {
if (this.threadContext.get() == ThreadContext.CONTEXT_LOCKDOWN) {
logger.warn("MosstestSecurityManager has blocked a thread running outside the engine context frop opening a top-level window.");
logger.warn(Messages.getString("TOP_LEVEL"));
throw new SecurityException(
"Threads in lockdown may not create top-level windows");
Messages.getString("TOP_LEVEL_SHORT"));
}
return true;
}
@ -653,9 +620,9 @@ public class MosstestSecurityManager extends SecurityManager {
@Override
public void checkPrintJobAccess() {
logger.warn("MosstestSecurityManager has denied a thread running outside the engine context the right to access system print jobs.");
logger.warn(Messages.getString("PRINT"));
throw new SecurityException(
"Print job access is not allowed for the engine or scripts");
Messages.getString("PRINT_SHORT"));
}
/*
@ -667,9 +634,9 @@ public class MosstestSecurityManager extends SecurityManager {
public void checkSystemClipboardAccess() {
if (this.threadContext.get() == ThreadContext.CONTEXT_LOCKDOWN) {
logger.warn("MosstestSecurityManager has prevented a thread in lockdown from accessing the system clipboard.");
logger.warn(Messages.getString("CLIPBOARD"));
throw new SecurityException(
"Threads in lockdown may not access the system clipboard");
Messages.getString("CLIPBOARD_SHORT"));
}
}
@ -682,9 +649,9 @@ public class MosstestSecurityManager extends SecurityManager {
public void checkAwtEventQueueAccess() {
if (this.threadContext.get() == ThreadContext.CONTEXT_LOCKDOWN) {
logger.warn("MosstestSecurityManager has prevented a thread in lockdown from accessing the AWT queue.");
logger.warn(Messages.getString("AWT_QUEUE"));
throw new SecurityException(
"Threads in lockdown may not access the AWT queue");
Messages.getString("AWT_QUEUE_SHORT"));
}
}
@ -717,9 +684,9 @@ public class MosstestSecurityManager extends SecurityManager {
public void checkSetFactory() {
if (this.threadContext.get() != ThreadContext.CONTEXT_ENGINE) {
logger.warn("MosstestSecurityManager has prevented a thread in lockdown from setting a Java system factory.");
logger.warn(Messages.getString("SYS_FACTORY"));
throw new SecurityException(
"Non-engine threads may not set java system factories");
Messages.getString("SYS_FACTORY_SHORT"));
}
super.checkSetFactory();
}
@ -760,9 +727,9 @@ public class MosstestSecurityManager extends SecurityManager {
public void checkMosstestControl() {
if (this.threadContext.get() != ThreadContext.CONTEXT_ENGINE) {
logger.warn("MosstestSecurityManager has prevented a plugin from controlling certain portions of the Mosstest engine.");
logger.warn(Messages.getString("PLUGIN_CTRL"));
throw new SecurityException(
"Non-engine threads may not control Mosstest execution");
Messages.getString("CTRL_SHORT"));
}
super.checkSetFactory();
}

View File

@ -6,6 +6,7 @@ import org.apache.log4j.Logger;
import org.mozilla.javascript.*;
import java.io.IOException;
import java.text.MessageFormat;
// TODO: Auto-generated Javadoc
@ -71,20 +72,18 @@ public class ScriptEnv {
Object lock = new Object();
MosstestSecurityManager.instance.lock(lock,
ThreadContext.CONTEXT_SCRIPT);
logger.fatal("Preexec");
sc.exec(this.cx, this.globalScope);
logger.fatal("postexec");
MosstestSecurityManager.instance.unlock(lock);
} catch (IOException e) {
logger.fatal("An IOException has resulted while running "+script.getName()+": "+e);
logger.fatal(MessageFormat.format(Messages.getString("SCRIPT_IOEXCEPTION"), script.getName(), e.getLocalizedMessage()));
return ScriptResult.RESULT_ERROR;
} catch (RhinoException e) {
logger.error("A script error has occured: " + e.getMessage());
logger.error(MessageFormat.format(Messages.getString("SCRIPT_ERR"), e.getMessage()));
throw new MossWorldLoadException(
Messages.getString("ScriptEnv.ERR_SCRIPT_ERR") + e.getMessage() + "\r\n" + e.getScriptStackTrace(), e); //$NON-NLS-1$ //$NON-NLS-2$
MessageFormat.format(Messages.getString("ScriptEnv.ERR_SCRIPT_ERR"), e.getMessage()) + "\r\n" + e.getScriptStackTrace(), e); //$NON-NLS-1$ //$NON-NLS-2$
} catch (Error e) {
// We are really screwed with classloading if we reach this block
logger.fatal("Caught error of type " + e.getClass().getName() + " with toString() of: " + e.toString() + ". This should not happen and implies a severe classloading error.");
logger.fatal(MessageFormat.format(Messages.getString("CLASSLOADER_FAIL"), e.getClass().getName(), e.getLocalizedMessage()));
}
return ScriptResult.RESULT_EXECUTED;
}

View File

@ -44,9 +44,88 @@ MossWorld.MG_SELECT_FAILURE=The map generator could not be seeded.
MossWorld.NO_GAME_ID=The game ID is not specified. The game ID must be specified in game.xml as <gameid>foo</gameid> where data/games/foo is a directory with a valid game.
MossWorld.NO_NETWORKING_NOW=Networking is not complete in this version.
NodeManager.DESC_UNKNWN_NODE=An unknown piece of the world
ScriptEnv.ERR_SCRIPT_ERR=Script error has occurred. Wrapped exception: \n
ScriptEnv.ERR_SCRIPT_ERR=Script error has occurred. Wrapped exception: {0} \n
ServerNetworkingManager.ACCEPT_THREAD=svrNetAccept
ServerNetworkingManager.CONN_THREAD_NAME=connection thread
ServerNetworkingManager.THREADGROUP=SvrNetGroup
PACKET_INVALID_MAGIC=A packet was received with an invalid magic number and has been dropped.
SERVER_CONN_TIMEOUT=The connection to the server has timed out or otherwise failed.
FIXME_MESSAGE=Hit a block of code that represents missing functionality. Please file a bug report or otherwise sharply emind the devs.
EVENT_PROCESS_EXCEPTION=Caught {0} upon processing an event of type {1}. The exception message was {2}.
FUTURES_QUEUE_INTERRUPTED=InterruptedException in futures processor trying to take from queue.
MOSS_CLIENT_STARTING=Mosstest client starting...
LDR_EXEC_EXCEPTION=Loader threw ExecutionException with message {0}
LDR_EXCEPTION=Loader threw Exception with message {0}
GC_EVICT=Un-caching {0} due to garbage collection. Memory may be low.
UNCACHE_EXPIRE=Un-caching {0} as it has expired.
EVICT_SIZE=Un-caching {0} due to a size constraint.
FILE_OPEN_FAILED=Failed to open file\: {0}
HASH_SUCCESS=Hashed {0} as {1}
ALGO_NOT_FOUND=Could not find algorithm SHA-256 while hashing {0}
NORMALIZE_FAILED=Failed to normalize game resource filename\: {0}
GOT_LOCAL_FILE=Got local file {0} as {1}
INDEXED_NORMALIZE_FAILURE=Failed to normalize game resource filename from index\: {0}
INDEXED_NOT_ON_DISK=File was in index but not on disk\: {0}
NO_INDEX=No index file found; all files will be served to the client.
FOUND_RECURSIVELY=Got file via recursive directory listing\: {0}
RECURSIVE_LISTED_BUT_NOT_FOUND=Could not find file from recursive directory listing. This should never happen.
CIRCULAR_DEPENDENCY_ISSUE=A circular dependency was found. {0} depends on {1} but the latter depends directly or indirectly on the former
DEPFIND_STACK_OVERFLOW=FIXME The stack overflowed while resolving dependencies. Either there is an undetected dependency issue, or there is simply an extreme number of dependencies.
SCRIPT_XML_MISSING=No script.xml has been given, assuming no dependencies and defaults for all other script settings.
FAILED_NORMALIZE_RSRC=Failed to normalize game resource filename\: {0}
CHUNK_LDR_EXECUTION_EXCEPTION=Chunk loader threw ExecutionException with message {0}
RELOADING_INTO_CACHE=Re-loading {0} into cache.
FAIL_BUILD_MAPCHUNK_FATAL=IOException caught constructing a MapChunk, and being rethrown as a MosstestFatalDeathException. The world is GOING DOWN NOW.
LIGHT_DATA_IOEXCEPTION=IOException writing light chunk data
DB_LOAD_IOEXCEPTION=IOException in database loading\: {0}
DB_NORMAL_LOAD=Database loaded normally.
DB_SHUTDOWN_NORMAL=Database shutting down (normally)
DB_SHUTDOWN_EMERGENCY=Map database performed emergency shutdown after catching MosstestFatalDeathException
DB_EMERGENCY_SHUTDOWN_FAIL=Map database failed emergency shutdown\: {0}
CAUGHT_EXCEPTION_WRITING_STACKTRACE={0} caught trying to write stacktrace of an existing exception. Message\: {1}
SECURITY_MANAGER_TESTMODE=WARNING\! The security manager is running in test mode. Security may be diminished.
NO_CLASSDIR=Failed to obtain a class directory for the security manager, spurious classloading failures may result.
PERMISSION_REQUESTED=Requested permssion {0}
ARBITRARY_PERMISSIONS=MosstestSecurityManager prevented the use of arbitrary permissions outside engine contexts.
SECURITY_TRUSTED_BASEDIR=The security manager prevented an attempt to set the trusted base directory.
THREAD_LOCKED=The security manager prevented an attempt to lock it on an already-locked thread.
SECURITY_MISMATCHED_KEY=The security manager prevented an attempt to unlock it using a mismatched key.
SECURITY_PEER_CHANGE=MosstestSecurityManager prevented a non-engine-context thread from changing the connected peer.
THREAD_ELEVATED=A thread has started without inheriting a thread context and has been elevated
THREAD_CONTEXT_NON_ENGINE_CODE=Attempted to set the thread context type from non-engine code
SECURITY_CLASSLOADER=MosstestSecurityManager stopped an attempt to create a classloader
SECURITY_THREAD=MosstestSecurityManager stopped an attempt to stop or modify a thread
SECURITY_THREADGROUP=MosstestSecurityManager stopped an attempt to modify a ThreadGroup
SECURITY_EXIT=MosstestSecurityManager stopped an attempt to exit Mosstest improperly from a script
SECURITY_SPAWN_PROC=MosstestSecurityManager does not allow any script or portion of the engine to start a new process
SECURITY_LINK=MosstestSecurityManager stopped an attempt to link to a JNI library from insecure code
SECURITY_READFILE=MosstestSecurityManager stopped an attempt to read {0} from non-core code
SECURITY_READ=MosstestSecurityManager stopped an attempt to read {0} from non-core code
SECURITY_WRITE=MosstestSecurityManager stopped an attempt to write to a file from non-core code
SECURITY_DELETE=MosstestSecurityManager stopped an attempt to delete a file from non-core code
SECURITY_CONNECT=MosstestSecurityManager stopped an attempt to connect directly to a network port.
SECURITY_LISTEN=MosstestSecurityManager stopped an attempt to listen directly on a network port.
SECURITY_BAD_KEY=A mismatched key has been used to unlock this thread.
ALREADY_LOCKED=The security manager is already locked for this thread.
NO_SET_BASEDIR=Cannot set base directory.
MULTICAST=MosstestSecurityManager has denied a script use of multicast directly without use of loadbalancing features
MULTICAST2=Scripts may not use mutlicast under any circumstances, except through the engine loadbalancing features
SYS_PROPERTIES=MosstestSecurityManager has denied a thread running outside the engine context the right to access system properties.
SYS_PROPERTIES_SHORT=Scripts may not access system properties
SYS_PROPERTIES_SHORT_NAMED=Scripts may not access system properties. Attempt was to access {0}.
TOP_LEVEL=MosstestSecurityManager has blocked a thread running outside the engine context from opening a top-level window.
TOP_LEVEL_SHORT=Threads in lockdown may not create top-level windows
PRINT=MosstestSecurityManager has denied a thread running outside the engine context the right to access system print jobs.
PRINT_SHORT=Print job access is not allowed for the engine or scripts
CLIPBOARD=MosstestSecurityManager has prevented a thread in lockdown from accessing the system clipboard.
CLIPBOARD_SHORT=Threads in lockdown may not access the system clipboard
AWT_QUEUE=MosstestSecurityManager has prevented a thread in lockdown from accessing the AWT queue.
AWT_QUEUE_SHORT=Threads in lockdown may not access the AWT queue
SYS_FACTORY=MosstestSecurityManager has prevented a thread from setting a Java system factory.
SYS_FACTORY_SHORT=Non-engine threads may not set java system factories
PLUGIN_CTRL=MosstestSecurityManager has prevented a plugin from controlling certain portions of the Mosstest engine.
CTRL_SHORT=Non-engine threads may not control Mosstest execution
GAME_CFG_DATA_GONE=The configuration data for the game could not be found, or is empty.
SCRIPT_IOEXCEPTION=An IOException has resulted while running {0}. The message was\: {1}
SCRIPT_ERR=A script error has occured\: {0}
CLASSLOADER_FAIL=Caught error of type {0} with message of\: {1}. This should not happen and implies a severe classloading error.

View File

@ -1,6 +1,7 @@
package net.mosstest.servercore.serialization;
import com.google.common.cache.*;
import net.mosstest.servercore.Messages;
import org.apache.log4j.Logger;
import org.iq80.leveldb.*;
@ -59,13 +60,13 @@ public class LevelDBBackedMap<K extends IByteArrayWriteable, V extends IByteArra
try {
v = memoryBackingCache.get((K) key);
} catch (ExecutionException e) {
logger.error(MessageFormat.format("Loader threw ExecutionException with message {0}", e.getMessage()));
logger.error(MessageFormat.format(Messages.getString("LDR_EXEC_EXCEPTION"), e.getMessage()));
}
if (v == null) {
try {
v = loader.load((K) key);
} catch (Exception e) {
logger.error(MessageFormat.format("Loader threw Exception with message {0}", e.getMessage()));
logger.error(MessageFormat.format(Messages.getString("LDR_EXCEPTION"), e.getMessage()));
}
@ -188,12 +189,12 @@ public class LevelDBBackedMap<K extends IByteArrayWriteable, V extends IByteArra
public void onRemoval(RemovalNotification<K, V> notification) {
switch (notification.getCause()) {
case COLLECTED:
logger.warn(MessageFormat.format("Un-caching {0} due to garbage collection. Memory may be low.", notification.getKey().toString()));
logger.warn(MessageFormat.format(Messages.getString("GC_EVICT"), notification.getKey().toString()));
break;
case EXPIRED:
logger.info(MessageFormat.format("Un-caching {0} as it has expired.", notification.getKey().toString()));
logger.info(MessageFormat.format(Messages.getString("UNCACHE_EXPIRE"), notification.getKey().toString()));
case SIZE:
logger.warn(MessageFormat.format("Un-caching {0} due to a size constraint.", notification.getKey().toString()));
logger.warn(MessageFormat.format(Messages.getString("EVICT_SIZE"), notification.getKey().toString()));
}
}

View File

@ -16,7 +16,7 @@ public class MockNodeManager implements INodeManager {
* The Constant MOCK_SOLID_MAPNODE.
*/
private static final MapNode MOCK_SOLID_MAPNODE = new MapNode(
new DefaultNodeParams(), "mock.png", "!mock:mock", "Mock node", 1);
new DefaultNodeParams(), "mock.png", "!mock:mock", "Mock node", 1); //NON-NLS NON-NLS NON-NLS
/* (non-Javadoc)
* @see net.mosstest.servercore.INodeManager#getNode(short)

97
zanata.xml Normal file
View File

@ -0,0 +1,97 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<config xmlns="http://zanata.org/namespace/config/">
<url>https://translate.zanata.org/zanata/</url>
<project>mosstest</project>
<project-version>initial</project-version>
<project-type>properties</project-type>
<locales>
<locale>ar</locale>
<locale>as</locale>
<locale>bg</locale>
<locale>bn-IN</locale>
<locale>ca</locale>
<locale>cs</locale>
<locale>da</locale>
<locale>de-CH</locale>
<locale>de-DE</locale>
<locale>el</locale>
<locale>en-GB</locale>
<locale>es-ES</locale>
<locale>es-MX</locale>
<locale>fa</locale>
<locale>fi</locale>
<locale>fr</locale>
<locale>gu</locale>
<locale>he</locale>
<locale>hi</locale>
<locale>hr</locale>
<locale>hu</locale>
<locale>id</locale>
<locale>is</locale>
<locale>it</locale>
<locale>ja</locale>
<locale>kn</locale>
<locale>ko</locale>
<locale>lv</locale>
<locale>ml</locale>
<locale>mr</locale>
<locale>ms</locale>
<locale>nb</locale>
<locale>nl</locale>
<locale>or</locale>
<locale>pl</locale>
<locale>pt-PT</locale>
<locale>pt-BR</locale>
<locale>ru</locale>
<locale>si</locale>
<locale>sk</locale>
<locale>sr-Cyrl</locale>
<locale>sr-Latn</locale>
<locale>sv</locale>
<locale>ta-IN</locale>
<locale>te</locale>
<locale>th</locale>
<locale>tr</locale>
<locale>uk</locale>
<locale>zh-Hans-CN</locale>
<locale>zh-Hant-TW</locale>
<locale>af</locale>
<locale>am</locale>
<locale>az</locale>
<locale>bn-BD</locale>
<locale>cy</locale>
<locale>eo</locale>
<locale>et</locale>
<locale>eu</locale>
<locale>ga</locale>
<locale>gl</locale>
<locale>ka</locale>
<locale>lt</locale>
<locale>nn</locale>
<locale>ro</locale>
<locale>sl</locale>
<locale>sq</locale>
<locale>vi</locale>
<locale>ast</locale>
<locale>bs</locale>
<locale>nds</locale>
<locale>ky</locale>
<locale>la</locale>
<locale>mn</locale>
<locale>tl</locale>
<locale>xh</locale>
<locale>pa</locale>
<locale>mai</locale>
<locale>es</locale>
<locale>de</locale>
<locale>brx</locale>
<locale>ta</locale>
<locale>zh-CN</locale>
<locale>zh-TW</locale>
<locale>br</locale>
<locale>kk</locale>
<locale>anp</locale>
</locales>
</config>