protected static boolean processStationCommand(MinecartManiaMinecart minecart, String str) { boolean valid = false; if (!str.toLowerCase().contains("st-")) { return false; } String[] val = str.toLowerCase() .split( ":"); // Will doing a toLowerCase here mess up regular expressions? Probably not // since we lower case the station name anyway. String[] keys = val[0].split( "-| ?: ?", 2); // Split the st- from the station name. the ",2" limits it to the first "-" followed // by zero or one non-capturing spaces. // The ",2" is needed because regular expressions can have a "-" in them. example "st-[g-z].*" // Without the limit, we would have the following array in keys: "st", "[g", "z].*" and then // only work with the "[g" portion which is wrong. String st = keys[1]; // Get the station name/simple pattern/regular expression String station = MinecartManiaWorld.getMinecartManiaPlayer(minecart.getPlayerPassenger()) .getLastStation() .toLowerCase(); int parseSetting = (Integer) MinecartManiaWorld.getConfigurationValue("StationSignParsingMethod"); MinecartManiaLogger.getInstance() .debug("Given Sign Line: " + str + " Given Station setting: " + station); switch (parseSetting) { case 0: // default with no pattern matching valid = station.equalsIgnoreCase(st); break; case 1: // simple pattern matching st = st.replace("\\", "\\\\") // escapes backslashes in case people use them in station names .replace(".", "\\.") // escapes period .replace("*", ".*") // converts * .replace("?", ".") // converts ? .replace("#", "\\d") // converts # .replace( "@", "[a-zA-Z]"); // converts @ NOTE:[A-Z] is probably not needed here since // everything is lower case anyway, but left for completeness. case 2: // full regex //note the lack of break before this, case 1 comes down here after // converting valid = station.matches(st); break; } if (valid && MinecartManiaWorld.getMinecartManiaPlayer(minecart.getPlayerPassenger()) .getDataValue("Reset Station Data") == null) { if (!StationUtil.isStationCommandNeverResets()) { MinecartManiaWorld.getMinecartManiaPlayer(minecart.getPlayerPassenger()).setLastStation(""); } } return valid; }
public static boolean useOldDirections() { return (Boolean) MinecartManiaWorld.getConfigurationValue("UseOldDirections"); }
public static int getMaximumMinecartSpeedPercent() { return (Integer) MinecartManiaWorld.getConfigurationValue("MaximumMinecartSpeedPercent"); }
public static boolean isLimitedSignRange() { return (Boolean) MinecartManiaWorld.getConfigurationValue("LimitedSignRange"); }
public static boolean isDisappearOnDisconnect() { return (Boolean) MinecartManiaWorld.getConfigurationValue("DisappearOnDisconnect"); }
public static boolean isReturnMinecartToOwner() { return (Boolean) MinecartManiaWorld.getConfigurationValue("MinecartsReturnToOwner"); }
public static boolean isStackAllItems() { return (Boolean) MinecartManiaWorld.getConfigurationValue("StackAllItems"); }
public static boolean isMinecartsKillMobs() { return (Boolean) MinecartManiaWorld.getConfigurationValue("MinecartsKillMobs"); }
public static boolean isKeepMinecartsLoaded() { return (Boolean) MinecartManiaWorld.getConfigurationValue("KeepMinecartsLoaded"); }
public static int getMinecartMaximumRange() { return (Integer) MinecartManiaWorld.getConfigurationValue("MaximumRange"); }
public static int getMinecartRangeY() { return (Integer) MinecartManiaWorld.getConfigurationValue("RangeY"); }
public static int getMinecartsClearRailsSetting() { return (Integer) MinecartManiaWorld.getConfigurationValue("MinecartsClearRails"); }