First work on converting the old global config file to the new one.

For #23
This commit is contained in:
graywolf336 2014-03-14 15:15:30 -05:00
parent 065f273c14
commit 060bb125a4
15 changed files with 584 additions and 32 deletions

View File

@ -9,37 +9,47 @@ Beta 2 Changes
*Changes since Beta 1* *Changes since Beta 1*
* Fix the default Jail Stick not being loaded correctly, [#21](https://github.com/graywolf336/Jail/issues/21) * Fix the default Jail Stick not being loaded correctly, [#21](https://github.com/graywolf336/Jail/issues/21)
* Implement Scoreboards, with title and time configurable. ([#15](https://github.com/graywolf336/Jail/issues/15)) * Implement Scoreboards, with title and time configurable. ([#15](https://github.com/graywolf336/Jail/issues/15))
* Convert old data and config values, only some are done and if you don't want the old data delete your `global.yml`
* Add config option to disallow the usage of Jail Sticks
Beta 1 Changes Beta 1 Changes
=== ===
*Changes since alpha* *Changes since alpha*
- MySQL storage is now a valid option for storage ([#18](https://github.com/graywolf336/Jail/issues/18)) * MySQL storage is now a valid option for storage ([#18](https://github.com/graywolf336/Jail/issues/18))
- MySQL data validation, basically if a cell or prisoner reference a jail which no longer exists they are removed * MySQL data validation, basically if a cell or prisoner reference a jail which no longer exists they are removed
- Fix a bug with not being able to unjail someone forcefully if they were in a cell ([#17](https://github.com/graywolf336/Jail/issues/17)) * Fix a bug with not being able to unjail someone forcefully if they were in a cell ([#17](https://github.com/graywolf336/Jail/issues/17))
- Add the record keeping system ([#12](https://github.com/graywolf336/Jail/issues/12)) * Add the record keeping system ([#12](https://github.com/graywolf336/Jail/issues/12))
- Added Jail Sticks, format of them has slightly changed ([#16](https://github.com/graywolf336/Jail/issues/16)) * Added Jail Sticks, format of them has slightly changed ([#16](https://github.com/graywolf336/Jail/issues/16))
Changes Changes
=== ===
*With this being version 3 of this plugin, a couple things have changed but the core concept is still the exact same. Here are some drastic changes:* *With this being version 3 of this plugin, a couple things have changed but the core concept is still the exact same. Here are some drastic changes:*
- Time can now be entered different formats, 3hours or 15mins or 4days * Time can now be entered different formats, 3hours or 15mins or 4days
- New language system * New language system
- New config system (per jail configs are going to make a come back) * New config system (per jail configs are going to make a come back)
- Items in the config use item names now, **not** the ids * Items in the config use item names now, **not** the ids
* All commands are prevented by default, now there is **only** a whitelist
* All interactions are prevented by default, add to the whitelist what you want
* If store inventory is not enabled, inventories are deleted upon jailing
* Sign text has a new format, old format will not be converted
* Max reason length has been removed, might be added back in if needed
ToDo ToDo
=== ===
- Guards * Jail pay
* Jail set
* Jail vote
* Jailing for swearing
* Guards (PlayerMoveProtectionAction - when they try to move do we teleport them back, let the guards get them, or nothing)
* Storing permissions
* Update Notifications
* Pages on jail list
Done Notice
=== ===
- Muted Prisoners are now muted * Old messages (language) will not be converted
- Implemented counting down time **always use the bukkit scheduler, unless your tick rate is slow as the other way we do it is not always stable** * MaximumAFKTime setting will not convert over, the format isn't clear and the old version didn't provide a way to get values with decimal places
- New command system, internally we handle commands a lot better * EnableLogging has been removed, we are always going to be logging (unless major request to control this)
- Delete commands are now remove
- Language system (adding language strings as I use them, be patient with me)
- Handcuffs are now implemented
- The time passed can be represented by time shorthand, aka "3hours" or "15minutes" or etc (defaults to minutes)
[Jail 3.0 JavaDoc](http://ci.graywolf336.com/job/Jail/javadoc) [Jail 3.0 JavaDoc](http://ci.graywolf336.com/job/Jail/javadoc)
==== ====

View File

@ -161,6 +161,13 @@ public class JailMain extends JavaPlugin {
} }
} }
/** Reloads the Jail Sticks, so the new ones can be loaded from the config. */
public void reloadJailSticks() {
this.jsm.removeAllStickUsers();
this.jsm = null;
this.jsm = new JailStickManager(this);
}
/** Gets the {@link HandCuffManager} instance. */ /** Gets the {@link HandCuffManager} instance. */
public HandCuffManager getHandCuffManager() { public HandCuffManager getHandCuffManager() {
return this.hcm; return this.hcm;

View File

@ -8,12 +8,13 @@ import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import com.graywolf336.jail.beans.Stick; import com.graywolf336.jail.beans.Stick;
import com.graywolf336.jail.enums.Settings;
/** /**
* Manages the jail stick users. * Manages the jail stick users.
* *
* @author graywolf336 * @author graywolf336
* @version 1.0.0 * @version 1.0.1
* @since 3.0.0 * @since 3.0.0
* *
*/ */
@ -32,7 +33,7 @@ public class JailStickManager {
FileConfiguration config = pl.getConfig(); FileConfiguration config = pl.getConfig();
//item name,time,jail name,reason //item name,time,jail name,reason
for(String s : config.getStringList("jailstick")) { for(String s : config.getStringList(Settings.JAILSTICKSTICKS.getPath())) {
String[] a = s.split(","); String[] a = s.split(",");
//Check if the jail given, if any, exists //Check if the jail given, if any, exists
@ -161,4 +162,11 @@ public class JailStickManager {
return true; return true;
} }
} }
/** Removes all the users currently using the sticks. */
public void removeAllStickUsers() {
for(String s: stickers) {
this.removeUsingStick(s);
}
}
} }

View File

@ -96,7 +96,7 @@ public class PrisonerManager {
} }
//Log the message, if it is enabled //Log the message, if it is enabled
if(pl.getConfig().getBoolean(Settings.LOGJAILING.getPath(), true) && !broadcasted) { if(pl.getConfig().getBoolean(Settings.LOGJAILINGTOCONSOLE.getPath(), true) && !broadcasted) {
pl.getServer().getConsoleSender().sendMessage(msg); pl.getServer().getConsoleSender().sendMessage(msg);
} }
} }

View File

@ -51,7 +51,7 @@ public class UnJailCommand implements Command {
} }
} }
if(jm.getPlugin().getConfig().getBoolean(Settings.LOGJAILING.getPath())) { if(jm.getPlugin().getConfig().getBoolean(Settings.LOGJAILINGTOCONSOLE.getPath())) {//TODO: Fix this setting, as this is wrong
jm.getPlugin().getLogger().info(jm.getPlugin().getJailIO().getLanguageString(LangString.BROADCASTUNJAILING, new String[] { args[0], sender.getName() })); jm.getPlugin().getLogger().info(jm.getPlugin().getJailIO().getLanguageString(LangString.BROADCASTUNJAILING, new String[] { args[0], sender.getName() }));
} }
}else { }else {

View File

@ -24,7 +24,7 @@ public class UnJailForceCommand implements Command {
jm.getPlugin().getPrisonerManager().forceRelease(jm.getPrisoner(args[0])); jm.getPlugin().getPrisonerManager().forceRelease(jm.getPrisoner(args[0]));
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.FORCEUNJAILED, args[0])); sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.FORCEUNJAILED, args[0]));
if(jm.getPlugin().getConfig().getBoolean(Settings.LOGJAILING.getPath())) { if(jm.getPlugin().getConfig().getBoolean(Settings.LOGJAILINGTOCONSOLE.getPath())) {//TODO: Fix this setting being used wrongly
jm.getPlugin().getLogger().info(jm.getPlugin().getJailIO().getLanguageString(LangString.BROADCASTUNJAILING, new String[] { args[0], sender.getName() })); jm.getPlugin().getLogger().info(jm.getPlugin().getJailIO().getLanguageString(LangString.BROADCASTUNJAILING, new String[] { args[0], sender.getName() }));
} }
}else { }else {

View File

@ -6,6 +6,7 @@ import com.graywolf336.jail.JailManager;
import com.graywolf336.jail.command.Command; import com.graywolf336.jail.command.Command;
import com.graywolf336.jail.command.CommandInfo; import com.graywolf336.jail.command.CommandInfo;
import com.graywolf336.jail.enums.LangString; import com.graywolf336.jail.enums.LangString;
import com.graywolf336.jail.enums.Settings;
@CommandInfo( @CommandInfo(
maxArgs = 0, maxArgs = 0,
@ -17,6 +18,7 @@ import com.graywolf336.jail.enums.LangString;
) )
public class JailStickCommand implements Command { public class JailStickCommand implements Command {
public boolean execute(JailManager jm, CommandSender sender, String... args) throws Exception { public boolean execute(JailManager jm, CommandSender sender, String... args) throws Exception {
if(jm.getPlugin().getConfig().getBoolean(Settings.JAILSTICKENABLED.getPath())) {
boolean using = jm.getPlugin().getJailStickManager().toggleUsingStick(sender.getName()); boolean using = jm.getPlugin().getJailStickManager().toggleUsingStick(sender.getName());
if(using) { if(using) {
@ -24,6 +26,9 @@ public class JailStickCommand implements Command {
}else { }else {
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.JAILSTICKDISABLED)); sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.JAILSTICKDISABLED));
} }
}else {
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.JAILSTICKUSAGEDISABLED));
}
return true; return true;
} }

View File

@ -128,6 +128,8 @@ public enum LangString {
JAILSTICKDISABLED ("general"), JAILSTICKDISABLED ("general"),
/** The message sent whenever a player toggles using jail stick to enabled. */ /** The message sent whenever a player toggles using jail stick to enabled. */
JAILSTICKENABLED ("general"), JAILSTICKENABLED ("general"),
/** The message sent whenever a player tries to toggle using jail stick but the config has it disabled. */
JAILSTICKUSAGEDISABLED ("general"),
/** Message sent when doing something that requires a cell but the given name of a cell doesn't exist. */ /** Message sent when doing something that requires a cell but the given name of a cell doesn't exist. */
NOCELL ("general"), NOCELL ("general"),
/** Message sent when needing a cell or something and there are no cells. */ /** Message sent when needing a cell or something and there are no cells. */

View File

@ -26,18 +26,20 @@ public enum Settings {
FOODCONTROLMAX("jailing.during.foodControlMax"), FOODCONTROLMAX("jailing.during.foodControlMax"),
FOODCONTROLMIN("jailing.during.foodControlMin"), FOODCONTROLMIN("jailing.during.foodControlMin"),
IGNORESLEEPINGSTATE("jailing.during.ignoreSleeping"), IGNORESLEEPINGSTATE("jailing.during.ignoreSleeping"),
JAILSTICKENABLED("jailstick.enabled"),
JAILSTICKSTICKS("jailstick.sticks"),
JAILDEFAULTTIME("jailing.jail.defaultTime"), JAILDEFAULTTIME("jailing.jail.defaultTime"),
JAILEDGAMEMODE("jailing.jail.gameMode"), JAILEDGAMEMODE("jailing.jail.gameMode"),
JAILEDSTOREINVENTORY("jailing.jail.storeInventory"), JAILEDSTOREINVENTORY("jailing.jail.storeInventory"),
LOGJAILING("jailing.jail.logToConsole"), LOGJAILINGTOCONSOLE("jailing.jail.logToConsole"),
MAXAFKTIME("jailing.during.maxAFKTime"), MAXAFKTIME("jailing.during.maxAFKTime"),
MOVEPENALTY("jailing.during.movePenalty"), MOVEPENALTY("jailing.during.movePenalty"),
MOVEPROTECTION("jailing.during.moveProtection"), MOVEPROTECTION("jailing.during.moveProtection"),
OPENCHEST("jailing.during.openChest"),
PREVENTINTERACTIONBLOCKS("jailing.during.preventInteractionBlocks"), PREVENTINTERACTIONBLOCKS("jailing.during.preventInteractionBlocks"),
PREVENTINTERACTIONBLOCKSPENALTY("jailing.during.preventInteractionBlocksPenalty"), PREVENTINTERACTIONBLOCKSPENALTY("jailing.during.preventInteractionBlocksPenalty"),
PREVENTINTERACTIONITEMS("jailing.during.preventInteractionItems"), PREVENTINTERACTIONITEMS("jailing.during.preventInteractionItems"),
PREVENTINTERACTIONITEMSPENALTY("jailing.during.preventInteractionItemsPenalty"), PREVENTINTERACTIONITEMSPENALTY("jailing.during.preventInteractionItemsPenalty"),
PRISONEROPENCHEST("jailing.during.openChest"),
RECIEVEMESSAGES("jailing.during.recieveMessages"), RECIEVEMESSAGES("jailing.during.recieveMessages"),
RELEASETOPREVIOUSPOSITION("jailing.release.backToPreviousPosition"), RELEASETOPREVIOUSPOSITION("jailing.release.backToPreviousPosition"),
RESTOREPREVIOUSGAMEMODE("jailing.release.restorePreviousGameMode"), RESTOREPREVIOUSGAMEMODE("jailing.release.restorePreviousGameMode"),

View File

@ -0,0 +1,380 @@
package com.graywolf336.jail.legacy;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.LinkedList;
import java.util.List;
import org.bukkit.Material;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import com.graywolf336.jail.JailMain;
import com.graywolf336.jail.enums.Settings;
/**
* Manages the old data from Jail 2.
*
* @author graywolf336
* @since 3.0.0
* @version 1.0.0
*/
public class LegacyManager {
private JailMain pl;
private YamlConfiguration global;
public LegacyManager(JailMain plugin) {
this.pl = plugin;
}
/** Returns true/false if the old config, global.yml, exists and needs to be converted. */
public boolean doWeNeedToConvert() {
File f = new File(pl.getDataFolder(), "global.yml");
return f.exists();
}
public boolean loadOldData() {
File f = new File(pl.getDataFolder(), "global.yml");
if(f.exists()) {
global = new YamlConfiguration();
try {
global.load(f);
} catch (FileNotFoundException e) {
//e.printStackTrace();
pl.getLogger().severe("Unable to load the old global config, file not found.");
} catch (IOException e) {
//e.printStackTrace();
pl.getLogger().severe("Unable to load the old global config: " + e.getMessage());
} catch (InvalidConfigurationException e) {
//e.printStackTrace();
pl.getLogger().severe("Unable to load the old global config: " + e.getMessage());
}finally {
}
}else {
pl.debug("The old config file, global.yml, was not found so not laoding anything.");
return false;
}
try {
loadOldConfig();
}catch (Exception e) {
pl.getLogger().severe("Failed to load the old configuration for some reason.");
return false;
}
return false;
}
@SuppressWarnings("deprecation")
private void loadOldConfig() {
FileConfiguration c = pl.getConfig();
int count = 0;
for(OldSetting s : OldSetting.values()) {
switch(s) {
case Debug:
if(global.contains(s.getString())) {
c.set(Settings.DEBUG.getPath(), OldSettings.getGlobalBoolean(global, s));
pl.debug(Settings.DEBUG.getPath() + " <-- " + s.getString());
count++;
}
break;
case BroadcastJailMessage:
if(global.contains(s.getString())) {
c.set(Settings.BROADCASTJAILING.getPath(), OldSettings.getGlobalBoolean(global, s));
pl.debug(Settings.BROADCASTJAILING.getPath() + " <-- " + s.getString());
count++;
}
break;
case AllowUpdateNotifications:
if(global.contains(s.getString())) {
c.set(Settings.UPDATENOTIFICATIONS.getPath(), OldSettings.getGlobalBoolean(global, s));
pl.debug(Settings.UPDATENOTIFICATIONS.getPath() + " <-- " + s.getString());
count++;
}
break;
case ExecutedCommandsOnJail:
if(global.contains(s.getString())) {
c.set(Settings.COMMANDSONJAIL.getPath(), OldSettings.getGlobalList(global, s));
pl.debug(Settings.COMMANDSONJAIL.getPath() + " <-- " + s.getString());
count++;
}
break;
case ExecutedCommandsOnRelease:
if(global.contains(s.getString())) {
c.set(Settings.COMMANDSONRELEASE.getPath(), OldSettings.getGlobalList(global, s));
pl.debug(Settings.COMMANDSONRELEASE.getPath() + " <-- " + s.getString());
count++;
}
break;
case AutomaticMute:
if(global.contains(s.getString())) {
c.set(Settings.AUTOMATICMUTE.getPath(), OldSettings.getGlobalBoolean(global, s));
pl.debug(Settings.AUTOMATICMUTE.getPath() + " <-- " + s.getString());
count++;
}
break;
case StoreInventory:
if(global.contains(s.getString())) {
c.set(Settings.JAILEDSTOREINVENTORY.getPath(), OldSettings.getGlobalBoolean(global, s));
pl.debug(Settings.JAILEDSTOREINVENTORY.getPath() + " <-- " + s.getString());
count++;
}
break;
case CanPrisonerOpenHisChest:
if(global.contains(s.getString())) {
c.set(Settings.PRISONEROPENCHEST.getPath(), OldSettings.getGlobalBoolean(global, s));
pl.debug(Settings.PRISONEROPENCHEST.getPath() + " <-- " + s.getString());
count++;
}
break;
case LogJailingIntoConsole:
if(global.contains(s.getString())) {
c.set(Settings.LOGJAILINGTOCONSOLE.getPath(), OldSettings.getGlobalBoolean(global, s));
pl.debug(Settings.LOGJAILINGTOCONSOLE.getPath() + " <-- " + s.getString());
count++;
}
break;
case CountdownTimeWhenOffline:
if(global.contains(s.getString())) {
c.set(Settings.COUNTDOWNTIMEOFFLINE.getPath(), OldSettings.getGlobalBoolean(global, s));
pl.debug(Settings.COUNTDOWNTIMEOFFLINE.getPath() + " <-- " + s.getString());
count++;
}
break;
case ReleaseBackToPreviousPosition:
if(global.contains(s.getString())) {
c.set(Settings.RELEASETOPREVIOUSPOSITION.getPath(), OldSettings.getGlobalBoolean(global, s));
pl.debug(Settings.RELEASETOPREVIOUSPOSITION.getPath() + " <-- " + s.getString());
count++;
}
break;
case IgnorePrisonersSleepingState:
if(global.contains(s.getString())) {
c.set(Settings.IGNORESLEEPINGSTATE.getPath(), OldSettings.getGlobalBoolean(global, s));
pl.debug(Settings.IGNORESLEEPINGSTATE.getPath() + " <-- " + s.getString());
count++;
}
break;
case TeleportPrisonerOnRelease:
if(global.contains(s.getString())) {
c.set(Settings.TELEPORTONRELEASE.getPath(), OldSettings.getGlobalBoolean(global, s));
pl.debug(Settings.TELEPORTONRELEASE.getPath() + " <-- " + s.getString());
count++;
}
break;
case DefaultJailTime:
if(global.contains(s.getString())) {
c.set(Settings.JAILDEFAULTTIME.getPath(), OldSettings.getGlobalInt(global, s));
pl.debug(Settings.JAILDEFAULTTIME.getPath() + " <-- " + s.getString());
count++;
}
break;
case UseBukkitSchedulerTimer:
if(global.contains(s.getString())) {
c.set(Settings.USEBUKKITTIMER.getPath(), OldSettings.getGlobalBoolean(global, s));
pl.debug(Settings.USEBUKKITTIMER.getPath() + " <-- " + s.getString());
count++;
}
break;
case EnableJailStick:
if(global.contains(s.getString())) {
c.set(Settings.JAILSTICKENABLED.getPath(), OldSettings.getGlobalBoolean(global, s));
pl.debug(Settings.JAILSTICKENABLED.getPath() + " <-- " + s.getString());
count++;
}
break;
case JailStickParameters:
if(global.contains(s.getString())) {
LinkedList<String> sticks = new LinkedList<String>();
for (String i : OldSettings.getGlobalString(global, s).split(";")) {
String[] info = i.split(",");
//item id,range,time,jail name,reason
Material m = Material.getMaterial(Integer.valueOf(info[0]).intValue());
//item name,time,jail name,reason
sticks.push(m.toString().toLowerCase() + "," + info[2] + "," + info[3] + "," + info[4]);
}
c.set(Settings.JAILSTICKSTICKS.getPath(), sticks);
pl.debug(Settings.JAILSTICKSTICKS.getPath() + " <-- " + s.getString());
count++;
}
break;
case EnableBlockDestroyProtection:
if(global.contains(s.getString())) {
c.set(Settings.BLOCKBREAKPROTECTION.getPath(), OldSettings.getGlobalBoolean(global, s));
pl.debug(Settings.BLOCKBREAKPROTECTION.getPath() + " <-- " + s.getString());
count++;
}
break;
case BlockDestroyPenalty:
if(global.contains(s.getString())) {
c.set(Settings.BLOCKBREAKPENALTY.getPath(), OldSettings.getGlobalInt(global, s));
pl.debug(Settings.BLOCKBREAKPENALTY.getPath() + " <-- " + s.getString());
count++;
}
break;
case BlockDestroyProtectionExceptions:
if(global.contains(s.getString())) {
@SuppressWarnings("unchecked")
List<String> exceptions = (List<String>) OldSettings.getGlobalList(global, s);
LinkedList<String> whitelist = new LinkedList<String>();
for(String e : exceptions) {
whitelist.add(Material.getMaterial(Integer.valueOf(e).intValue()).toString().toLowerCase());
}
c.set(Settings.BLOCKBREAKWHITELIST.getPath(), whitelist);
pl.debug(Settings.BLOCKBREAKWHITELIST.getPath() + " <-- " + s.getString());
count++;
}
break;
case EnableBlockPlaceProtection:
if(global.contains(s.getString())) {
c.set(Settings.BLOCKPLACEPROTECTION.getPath(), OldSettings.getGlobalBoolean(global, s));
pl.debug(Settings.BLOCKPLACEPROTECTION.getPath() + " <-- " + s.getString());
count++;
}
break;
case BlockPlacePenalty:
if(global.contains(s.getString())) {
c.set(Settings.BLOCKPLACEPENALTY.getPath(), OldSettings.getGlobalInt(global, s));
pl.debug(Settings.BLOCKPLACEPENALTY.getPath() + " <-- " + s.getString());
count++;
}
break;
case BlockPlaceProtectionExceptions:
if(global.contains(s.getString())) {
@SuppressWarnings("unchecked")
List<String> exceptions = (List<String>) OldSettings.getGlobalList(global, s);
LinkedList<String> whitelist = new LinkedList<String>();
for(String e : exceptions) {
whitelist.add(Material.getMaterial(Integer.valueOf(e).intValue()).toString().toLowerCase());
}
c.set(Settings.BLOCKPLACEWHITELIST.getPath(), whitelist);
pl.debug(Settings.BLOCKPLACEWHITELIST.getPath() + " <-- " + s.getString());
count++;
}
break;
case EnablePlayerMoveProtection:
if(global.contains(s.getString())) {
c.set(Settings.MOVEPROTECTION.getPath(), OldSettings.getGlobalBoolean(global, s));
pl.debug(Settings.MOVEPROTECTION.getPath() + " <-- " + s.getString());
count++;
}
break;
case PlayerMoveProtectionPenalty:
if(global.contains(s.getString())) {
c.set(Settings.MOVEPENALTY.getPath(), OldSettings.getGlobalInt(global, s));
pl.debug(Settings.MOVEPENALTY.getPath() + " <-- " + s.getString());
count++;
}
break;
case WhitelistedCommands:
if(global.contains(s.getString())) {
c.set(Settings.COMMANDWHITELIST.getPath(), OldSettings.getGlobalList(global, s));
pl.debug(Settings.COMMANDWHITELIST.getPath() + " <-- " + s.getString());
count++;
}
break;
case CommandProtectionPenalty:
if(global.contains(s.getString())) {
c.set(Settings.COMMANDPENALTY.getPath(), OldSettings.getGlobalInt(global, s));
pl.debug(Settings.COMMANDPENALTY.getPath() + " <-- " + s.getString());
count++;
}
break;
case InteractionPenalty:
if(global.contains(s.getString())) {
c.set(Settings.PREVENTINTERACTIONITEMSPENALTY.getPath(), OldSettings.getGlobalInt(global, s));
pl.debug(Settings.PREVENTINTERACTIONITEMSPENALTY.getPath() + " <-- " + s.getString());
count++;
}
break;
case EnableExplosionProtection:
if(global.contains(s.getString())) {
c.set(Settings.EXPLOSIONPROTECTION.getPath(), OldSettings.getGlobalBoolean(global, s));
pl.debug(Settings.EXPLOSIONPROTECTION.getPath() + " <-- " + s.getString());
count++;
}
break;
case EnableFoodControl:
if(global.contains(s.getString())) {
c.set(Settings.FOODCONTROL.getPath(), OldSettings.getGlobalBoolean(global, s));
pl.debug(Settings.FOODCONTROL.getPath() + " <-- " + s.getString());
count++;
}
break;
case FoodControlMinimumFood:
if(global.contains(s.getString())) {
c.set(Settings.FOODCONTROLMIN.getPath(), OldSettings.getGlobalInt(global, s));
pl.debug(Settings.FOODCONTROLMIN.getPath() + " <-- " + s.getString());
count++;
}
break;
case FoodControlMaximumFood:
if(global.contains(s.getString())) {
c.set(Settings.FOODCONTROLMAX.getPath(), OldSettings.getGlobalInt(global, s));
pl.debug(Settings.FOODCONTROLMAX.getPath() + " <-- " + s.getString());
count++;
}
break;
case PrisonersRecieveMessages:
if(global.contains(s.getString())) {
c.set(Settings.RECIEVEMESSAGES.getPath(), OldSettings.getGlobalBoolean(global, s));
pl.debug(Settings.RECIEVEMESSAGES.getPath() + " <-- " + s.getString());
count++;
}
break;
case UseMySQL:
if(global.contains(s.getString())) {
c.set("storage.type", OldSettings.getGlobalBoolean(global, s) ? "mysql" : "sqlite");
pl.debug(Settings.RECIEVEMESSAGES.getPath() + " <-- " + s.getString());
count++;
}
break;
case MySQLConn:
if(global.contains(s.getString())) {
//jdbc:mysql://localhost:3306/minecraft
String con = OldSettings.getGlobalString(global, s);
String a = con.split("//")[1];
//localhost 3306/minecraft
String[] b1 = a.split(":");
//3306 minecraft
String[] b2 = b1[1].split("/");
c.set("storage.mysql.host", b1[0]);
c.set("storage.mysql.port", b2[0]);
c.set("storage.mysql.database", b2[1]);
pl.debug("storage.mysql <-- " + s.getString());
count++;
}
break;
case MySQLUsername:
if(global.contains(s.getString())) {
c.set("storage.mysql.username", OldSettings.getGlobalString(global, s));
pl.debug("storage.mysql.username <-- " + s.getString());
count++;
}
break;
case MySQLPassword:
if(global.contains(s.getString())) {
c.set("storage.mysql.password", OldSettings.getGlobalString(global, s));
pl.debug("storage.mysql.password <-- " + s.getString());
count++;
}
break;
default:
break;
}
}
pl.getLogger().info("Converted " + count + " old config value" + (count == 1 ? "" : "s") + ".");
}
}

View File

@ -0,0 +1,102 @@
package com.graywolf336.jail.legacy;
import java.util.ArrayList;
import java.util.Arrays;
public enum OldSetting {
Debug("Debug", false),//done
BroadcastJailMessage("Broadcast Jail Message", false),//done
AllowUpdateNotifications("AllowUpdateNotifications", true),//done
ExecutedCommandsOnJail("ExecutedCommandsOnJail", new ArrayList<String>()),//done
ExecutedCommandsOnRelease("ExecutedCommandsOnRelease", new ArrayList<String>()),//done
AutomaticMute("AutomaticMute", false),//done
StoreInventory("StoreInventory", true),//done
CanPrisonerOpenHisChest("CanPrisonerOpenHisChest", true),//done
LogJailingIntoConsole("LogJailingIntoConsole", false),//done
CountdownTimeWhenOffline("CountdownTimeWhenOffline", false),//done
ReleaseBackToPreviousPosition("ReleaseBackToPreviousPosition", false),//done
IgnorePrisonersSleepingState("IgnorePrisonersSleepingState", true),//done
TeleportPrisonerOnRelease("TeleportPrisonerOnRelease", true),//done
DefaultJailTime("DefaultJailTime", -1),//done
UseBukkitSchedulerTimer("UseBukkitSchedulerTimer", true),//done
JailCheckPrisonersPerPage("JailCheckPrisonersPerPage", 15),//TODO
//JailStick
EnableJailStick("EnableJailStick", false),//done
JailStickParameters("JailStickParameters", "280,5,10,,police;50,5,20,,admin"),//done
//Protections
EnableBlockDestroyProtection("Protections.EnableBlockDestroyProtection", true),//done
BlockDestroyPenalty("Protections.BlockDestroyPenalty", 15),//done
BlockDestroyProtectionExceptions("Protections.BlockDestroyProtectionExceptions", Arrays.asList(new String[]{"59"})),//done
EnableBlockPlaceProtection("Protections.EnableBlockPlaceProtection", true),//done
BlockPlacePenalty("Protections.BlockPlacePenalty", 10),//done
BlockPlaceProtectionExceptions("Protections.BlockPlaceProtectionExceptions", Arrays.asList(new String[]{"59"})),//done
EnablePlayerMoveProtection("Protections.EnablePlayerMoveProtection", true),//done
PlayerMoveProtectionPenalty("Protections.PlayerMoveProtectionPenalty", 30),//done
PlayerMoveProtectionAction("Protections.PlayerMoveProtectionAction", "teleport"),//TODO
WhitelistedCommands("Protections.WhitelistedCommands", new ArrayList<String>()),//done
CommandProtectionPenalty("Protections.CommandProtectionPenalty", 10),//done
InteractionPenalty("Protections.InteractionPenalty", 10),//done
EnableExplosionProtection("Protections.EnableExplosionProtection", true),//done
EnablePVPProtection("Protections.EnablePVPProtection", true),//TODO: ??? I haven't even tested this out!!!!
EnableChangingPermissions("Protections.EnableChangingPermissions", false),//TODO
PrisonersPermissionsGroups("Protections.PrisonersPermissionsGroups", Arrays.asList("prisoners")),//TODO
RestorePermissionsToEscapedPrisoners("Protections.RestorePermissionsToEscapedPrisoners", true),//TODO
EnableFoodControl("Protections.EnableFoodControl", true),//done
FoodControlMinimumFood("Protections.FoodControlMinimumFood", 10),//done
FoodControlMaximumFood("Protections.FoodControlMaximumFood", 20),//done
PrisonersRecieveMessages("Protections.PlayerRecievesMessages", true), //done
//JailPay
PricePerMinute("JailPay.PricePerMinute", 10),//TODO
PriceForInfiniteJail("JailPay.PriceForInfiniteJail", 9999),//TODO
JailPayCurrency("JailPay.Currency", 0),//TODO
//Guards
GuardHealth("Guards.GuardHealth", 8),//TODO
GuardArmor("Guards.GuardArmor", 0),//TODO
GuardDamage("Guards.GuardDamage", 2),//TODO
NumbefOfGuards("Guards.NumberOfGuards", 3),//TODO
GuardInvincibility("Guards.GuardInvincibility", false),//TODO
GuardAttackSpeedPercent("Guards.GuardAttackSpeedPercent", 100),//TODO
RespawnGuards("Guards.RespawnGuards", true),//TODO
GuardTeleportDistance("Guards.GuardTeleportDistance", 10),//TODO
GuardTypes("Guards.GuardTypes", Arrays.asList(new String[] { "Zombie", "Silverfish" })),//TODO
//Database
UseMySQL("Database.UseMySQL", false),//done
MySQLConn("Database.MySQLConn", "jdbc:mysql://localhost:3306/minecraft"),//done
MySQLUsername("Database.MySQLUSername", "root"),//done
MySQLPassword("Database.MySQLPassword", "password"),//done
//Jail Vote
VoteJailEnabled("Jail Vote.Enabled", true),//TODO
VoteJailTime("Jail Vote.Time", 5),//TODO
VoteJailReason("Jail Vote.Reason", "Jailed by players"),//TODO
VoteJailVoteTime("Jail Vote.Vote Time", 60),//TODO
//Jail swearing
EnableJailSwear("Jail Swear.Enabled", false),//TODO
JailSwearTime("Jail Swear.Time", 10),//TODO
BannedWords("Jail Swear.Banned Words", Arrays.asList(new String[] {"shit", "crap", "fuck", "cunt"}));//TODO
private String name;
private Object def;
private OldSetting(String Name, Object Def) {
name = Name;
def = Def;
}
/** The string of the node the value is stored at in the config. */
public String getString() {
return name;
}
/** The default value for this config. */
public Object getDefault() {
return def;
}
}

View File

@ -0,0 +1,33 @@
package com.graywolf336.jail.legacy;
import java.util.List;
import org.bukkit.configuration.file.YamlConfiguration;
public class OldSettings {
public static Object getGlobalProperty(YamlConfiguration config, OldSetting setting) {
Object property = config.get(setting.getString());
if (property == null) {
property = setting.getDefault();
}
return property;
}
public static Boolean getGlobalBoolean(YamlConfiguration config, OldSetting setting) {
return (Boolean) getGlobalProperty(config, setting);
}
public static Integer getGlobalInt(YamlConfiguration config, OldSetting setting) {
return (Integer) getGlobalProperty(config, setting);
}
public static String getGlobalString(YamlConfiguration config, OldSetting setting) {
return (String) getGlobalProperty(config, setting);
}
public static List<?> getGlobalList(YamlConfiguration config, OldSetting setting) {
return (List<?>) getGlobalProperty(config, setting);
}
}

View File

@ -170,7 +170,7 @@ public class ProtectionListener implements Listener {
if(event.getAction() == Action.RIGHT_CLICK_BLOCK && event.getClickedBlock().getType() == Material.CHEST) { if(event.getAction() == Action.RIGHT_CLICK_BLOCK && event.getClickedBlock().getType() == Material.CHEST) {
//Let's get the cell the player is in, then check if it is null or not. //Let's get the cell the player is in, then check if it is null or not.
if(pl.getJailManager().getJailPlayerIsIn(event.getPlayer().getName()).isJailedInACell(event.getPlayer().getName())) { if(pl.getJailManager().getJailPlayerIsIn(event.getPlayer().getName()).isJailedInACell(event.getPlayer().getName())) {
if(pl.getConfig().getBoolean(Settings.OPENCHEST.getPath())) { if(pl.getConfig().getBoolean(Settings.PRISONEROPENCHEST.getPath())) {
//The prisoner is in a cell, so let's check if it is a couple chest. //The prisoner is in a cell, so let's check if it is a couple chest.
Material bpos1 = event.getClickedBlock().getLocation().add(-1, 0, 0).getBlock().getType(); Material bpos1 = event.getClickedBlock().getLocation().add(-1, 0, 0).getBlock().getType();
Material bpos2 = event.getClickedBlock().getLocation().add(+1, 0, 0).getBlock().getType(); Material bpos2 = event.getClickedBlock().getLocation().add(+1, 0, 0).getBlock().getType();

View File

@ -63,4 +63,6 @@ jailing:
jails: jails:
endermenProtection: true endermenProtection: true
explosionProtection: true explosionProtection: true
jailstick: ["stick,30,,Running away"] jailstick:
enabled: true
sticks: ["stick,30,,Running away"]

View File

@ -21,6 +21,7 @@ language:
jailremoved: '&9Jail %0% has been successfully deleted.' jailremoved: '&9Jail %0% has been successfully deleted.'
jailstickdisabled: '&3Jail stick usage: &cdisabled' jailstickdisabled: '&3Jail stick usage: &cdisabled'
jailstickenabled: '&3Jail stick usage: &aenabled' jailstickenabled: '&3Jail stick usage: &aenabled'
jailstickusagedisabled: '&cThe usage of Jail Sticks has been disabled by the Administrator.'
nocell: '&cNo cell found by the name of %0% in the jail %1%.' nocell: '&cNo cell found by the name of %0% in the jail %1%.'
nocells: '&cNo cells found in the jail %0%.' nocells: '&cNo cells found in the jail %0%.'
nojail: '&cNo jail found by the name of %0%.' nojail: '&cNo jail found by the name of %0%.'