Protect some of the constructors since we don't need more than one.
This commit is contained in:
parent
9ecfb92252
commit
3570a4b0ee
@ -30,7 +30,7 @@ public class HandCuffManager {
|
|||||||
private HashMap<UUID, Location> locs;
|
private HashMap<UUID, Location> locs;
|
||||||
|
|
||||||
/** Constructs a new HandCuff Manager, for handling all the handcuffing. */
|
/** Constructs a new HandCuff Manager, for handling all the handcuffing. */
|
||||||
public HandCuffManager() {
|
protected HandCuffManager() {
|
||||||
this.handcuffed = new HashMap<UUID, Long>();
|
this.handcuffed = new HashMap<UUID, Long>();
|
||||||
this.locs = new HashMap<UUID, Location>();
|
this.locs = new HashMap<UUID, Location>();
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ public class JailIO {
|
|||||||
private int storage; //0 = flatfile, 1 = sqlite, 2 = mysql
|
private int storage; //0 = flatfile, 1 = sqlite, 2 = mysql
|
||||||
private String prefix;
|
private String prefix;
|
||||||
|
|
||||||
public JailIO(JailMain plugin) {
|
protected JailIO(JailMain plugin) {
|
||||||
this.pl = plugin;
|
this.pl = plugin;
|
||||||
|
|
||||||
String st = pl.getConfig().getString("storage.type", "flatfile");
|
String st = pl.getConfig().getString("storage.type", "flatfile");
|
||||||
@ -60,7 +60,7 @@ public class JailIO {
|
|||||||
|
|
||||||
/** Loads the language file from disk, if there is none then we save the default one. */
|
/** Loads the language file from disk, if there is none then we save the default one. */
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public void loadLanguage() {
|
protected void loadLanguage() {
|
||||||
String language = pl.getConfig().getString(Settings.LANGUAGE.getPath());
|
String language = pl.getConfig().getString(Settings.LANGUAGE.getPath());
|
||||||
boolean save = false;
|
boolean save = false;
|
||||||
File langFile = new File(pl.getDataFolder(), language + ".yml");
|
File langFile = new File(pl.getDataFolder(), language + ".yml");
|
||||||
@ -97,7 +97,7 @@ public class JailIO {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Prepares the storage engine to be used, returns true if everything went good. */
|
/** Prepares the storage engine to be used, returns true if everything went good. */
|
||||||
public boolean prepareStorage(boolean doInitialCreations) {
|
protected boolean prepareStorage(boolean doInitialCreations) {
|
||||||
switch(storage) {
|
switch(storage) {
|
||||||
case 1:
|
case 1:
|
||||||
try {
|
try {
|
||||||
@ -161,7 +161,7 @@ public class JailIO {
|
|||||||
*
|
*
|
||||||
* @return The connection for the sql database.
|
* @return The connection for the sql database.
|
||||||
*/
|
*/
|
||||||
public Connection getConnection() {
|
private Connection getConnection() {
|
||||||
switch(storage) {
|
switch(storage) {
|
||||||
case 1:
|
case 1:
|
||||||
case 2:
|
case 2:
|
||||||
@ -181,7 +181,7 @@ public class JailIO {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Closes the sql connection. */
|
/** Closes the sql connection. */
|
||||||
public void closeConnection() {
|
protected void closeConnection() {
|
||||||
switch(storage) {
|
switch(storage) {
|
||||||
case 1:
|
case 1:
|
||||||
case 2:
|
case 2:
|
||||||
@ -386,7 +386,7 @@ public class JailIO {
|
|||||||
/**
|
/**
|
||||||
* Loads the jails, this should <strong>only</strong> be called after {@link #prepareStorage(boolean)}.
|
* Loads the jails, this should <strong>only</strong> be called after {@link #prepareStorage(boolean)}.
|
||||||
*/
|
*/
|
||||||
public void loadJails() {
|
protected void loadJails() {
|
||||||
switch(storage) {
|
switch(storage) {
|
||||||
case 1:
|
case 1:
|
||||||
case 2:
|
case 2:
|
||||||
@ -721,7 +721,7 @@ public class JailIO {
|
|||||||
*
|
*
|
||||||
* @param j The jail to save.
|
* @param j The jail to save.
|
||||||
*/
|
*/
|
||||||
public void saveJail(Jail j) {
|
protected void saveJail(Jail j) {
|
||||||
if(j.isEnabled()) {
|
if(j.isEnabled()) {
|
||||||
switch(storage) {
|
switch(storage) {
|
||||||
case 1:
|
case 1:
|
||||||
@ -1010,7 +1010,7 @@ public class JailIO {
|
|||||||
* @param j the jail which the prisoner is in.
|
* @param j the jail which the prisoner is in.
|
||||||
* @param p the prisoner data
|
* @param p the prisoner data
|
||||||
*/
|
*/
|
||||||
public void removePrisoner(Jail j, Prisoner p) {
|
protected void removePrisoner(Jail j, Prisoner p) {
|
||||||
this.removePrisoner(j, null, p);
|
this.removePrisoner(j, null, p);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1021,7 +1021,7 @@ public class JailIO {
|
|||||||
* @param c the cell which the prisoner is in, null if none
|
* @param c the cell which the prisoner is in, null if none
|
||||||
* @param p the prisoner data
|
* @param p the prisoner data
|
||||||
*/
|
*/
|
||||||
public void removePrisoner(Jail j, Cell c, Prisoner p) {
|
protected void removePrisoner(Jail j, Cell c, Prisoner p) {
|
||||||
switch(storage) {
|
switch(storage) {
|
||||||
case 1:
|
case 1:
|
||||||
case 2:
|
case 2:
|
||||||
@ -1107,7 +1107,7 @@ public class JailIO {
|
|||||||
*
|
*
|
||||||
* @param j the jail instance to remove.
|
* @param j the jail instance to remove.
|
||||||
*/
|
*/
|
||||||
public void removeJail(Jail j) {
|
protected void removeJail(Jail j) {
|
||||||
String name = j.getName();
|
String name = j.getName();
|
||||||
|
|
||||||
switch(storage) {
|
switch(storage) {
|
||||||
|
@ -192,9 +192,20 @@ public class JailMain extends JavaPlugin {
|
|||||||
|
|
||||||
return true;//Always return true here, that way we can handle the help and command usage ourself.
|
return true;//Always return true here, that way we can handle the help and command usage ourself.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void reloadEverything() throws Exception {
|
||||||
|
reloadConfig();
|
||||||
|
getJailIO().loadLanguage();
|
||||||
|
getJailIO().loadJails();
|
||||||
|
reloadScoreBoardManager();
|
||||||
|
reloadJailSticks();
|
||||||
|
reloadJailPayManager();
|
||||||
|
reloadJailVoteManager();
|
||||||
|
reloadUpdateCheck();
|
||||||
|
}
|
||||||
|
|
||||||
/** Reloads the scoreboard manager class, useful when something is changed int he config about it. */
|
/** Reloads the scoreboard manager class, useful when something is changed int he config about it. */
|
||||||
public void reloadScoreBoardManager() {
|
private void reloadScoreBoardManager() {
|
||||||
this.sbm.removeAllScoreboards();
|
this.sbm.removeAllScoreboards();
|
||||||
this.sbm = null;
|
this.sbm = null;
|
||||||
this.sbm = new ScoreBoardManager(this);
|
this.sbm = new ScoreBoardManager(this);
|
||||||
@ -211,7 +222,7 @@ public class JailMain extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Reloads the Jail Sticks, so the new ones can be loaded from the config. */
|
/** Reloads the Jail Sticks, so the new ones can be loaded from the config. */
|
||||||
public void reloadJailSticks() {
|
private void reloadJailSticks() {
|
||||||
if(getConfig().getBoolean(Settings.JAILSTICKENABLED.getPath())) {
|
if(getConfig().getBoolean(Settings.JAILSTICKENABLED.getPath())) {
|
||||||
if(this.jsm != null) {
|
if(this.jsm != null) {
|
||||||
this.jsm.removeAllStickUsers();
|
this.jsm.removeAllStickUsers();
|
||||||
@ -223,7 +234,7 @@ public class JailMain extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Reloads the {@link JailPayManager}. */
|
/** Reloads the {@link JailPayManager}. */
|
||||||
public void reloadJailPayManager() {
|
private void reloadJailPayManager() {
|
||||||
this.jpm = null;
|
this.jpm = null;
|
||||||
|
|
||||||
if(getConfig().getBoolean(Settings.JAILPAYENABLED.getPath())) {
|
if(getConfig().getBoolean(Settings.JAILPAYENABLED.getPath())) {
|
||||||
@ -237,7 +248,7 @@ public class JailMain extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Reloads the {@link JailVoteManager}. */
|
/** Reloads the {@link JailVoteManager}. */
|
||||||
public void reloadJailVoteManager() throws Exception {
|
private void reloadJailVoteManager() throws Exception {
|
||||||
if(this.jvm != null) {
|
if(this.jvm != null) {
|
||||||
for(Integer i : this.jvm.getRunningTasks().values()) {
|
for(Integer i : this.jvm.getRunningTasks().values()) {
|
||||||
this.getServer().getScheduler().cancelTask(i);
|
this.getServer().getScheduler().cancelTask(i);
|
||||||
@ -252,7 +263,7 @@ public class JailMain extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Reloads the update checker, in case they changed a setting about it. */
|
/** Reloads the update checker, in case they changed a setting about it. */
|
||||||
public void reloadUpdateCheck() {
|
private void reloadUpdateCheck() {
|
||||||
getServer().getScheduler().cancelTask(updateCheckTask);
|
getServer().getScheduler().cancelTask(updateCheckTask);
|
||||||
update = new Update(this);
|
update = new Update(this);
|
||||||
if(getConfig().getBoolean(Settings.UPDATENOTIFICATIONS.getPath())) {
|
if(getConfig().getBoolean(Settings.UPDATENOTIFICATIONS.getPath())) {
|
||||||
|
@ -47,7 +47,7 @@ public class JailManager {
|
|||||||
private JailCreationSteps jcs;
|
private JailCreationSteps jcs;
|
||||||
private CellCreationSteps ccs;
|
private CellCreationSteps ccs;
|
||||||
|
|
||||||
public JailManager(JailMain plugin) {
|
protected JailManager(JailMain plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.jails = new HashMap<String, Jail>();
|
this.jails = new HashMap<String, Jail>();
|
||||||
this.jailCreators = new HashMap<String, CreationPlayer>();
|
this.jailCreators = new HashMap<String, CreationPlayer>();
|
||||||
|
@ -16,7 +16,7 @@ public class JailPayManager {
|
|||||||
private Material item;
|
private Material item;
|
||||||
private boolean infinite, timed;
|
private boolean infinite, timed;
|
||||||
|
|
||||||
public JailPayManager(JailMain plugin) {
|
protected JailPayManager(JailMain plugin) {
|
||||||
this.item = Material.getMaterial(plugin.getConfig().getString(Settings.JAILPAYITEM.getPath().toUpperCase()));
|
this.item = Material.getMaterial(plugin.getConfig().getString(Settings.JAILPAYITEM.getPath().toUpperCase()));
|
||||||
if(this.item == null) this.item = Material.AIR;
|
if(this.item == null) this.item = Material.AIR;
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ public class JailStickManager {
|
|||||||
private ArrayList<UUID> stickers;
|
private ArrayList<UUID> stickers;
|
||||||
private HashMap<Material, Stick> sticks;
|
private HashMap<Material, Stick> sticks;
|
||||||
|
|
||||||
public JailStickManager(JailMain plugin) {
|
protected JailStickManager(JailMain plugin) {
|
||||||
this.stickers = new ArrayList<UUID>();
|
this.stickers = new ArrayList<UUID>();
|
||||||
this.sticks = new HashMap<Material, Stick>();
|
this.sticks = new HashMap<Material, Stick>();
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ public class JailTimer {
|
|||||||
private Long lastTime;
|
private Long lastTime;
|
||||||
private Long afkTime = 0L;
|
private Long afkTime = 0L;
|
||||||
|
|
||||||
public JailTimer(JailMain plugin) {
|
protected JailTimer(JailMain plugin) {
|
||||||
this.pl = plugin;
|
this.pl = plugin;
|
||||||
try {
|
try {
|
||||||
afkTime = Util.getTime(pl.getConfig().getString(Settings.MAXAFKTIME.getPath()));
|
afkTime = Util.getTime(pl.getConfig().getString(Settings.MAXAFKTIME.getPath()));
|
||||||
|
@ -32,7 +32,7 @@ public class JailVoteManager {
|
|||||||
*
|
*
|
||||||
* @throws Exception When it can't load the time correctly
|
* @throws Exception When it can't load the time correctly
|
||||||
*/
|
*/
|
||||||
public JailVoteManager(JailMain plugin) throws Exception {
|
protected JailVoteManager(JailMain plugin) throws Exception {
|
||||||
this.pl = plugin;
|
this.pl = plugin;
|
||||||
this.votes = new HashMap<String, JailVote>();
|
this.votes = new HashMap<String, JailVote>();
|
||||||
this.tasks = new HashMap<String, Integer>();
|
this.tasks = new HashMap<String, Integer>();
|
||||||
|
@ -15,7 +15,7 @@ package com.graywolf336.jail;
|
|||||||
public class JailsAPI {
|
public class JailsAPI {
|
||||||
private static JailMain pl;
|
private static JailMain pl;
|
||||||
|
|
||||||
public JailsAPI(JailMain plugin) {
|
protected JailsAPI(JailMain plugin) {
|
||||||
pl = plugin;
|
pl = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ public class PrisonerManager {
|
|||||||
private JailMain pl;
|
private JailMain pl;
|
||||||
private ArrayList<Prisoner> releases;
|
private ArrayList<Prisoner> releases;
|
||||||
|
|
||||||
public PrisonerManager(JailMain plugin) {
|
protected PrisonerManager(JailMain plugin) {
|
||||||
this.pl = plugin;
|
this.pl = plugin;
|
||||||
this.releases = new ArrayList<Prisoner>();
|
this.releases = new ArrayList<Prisoner>();
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ public class ScoreBoardManager {
|
|||||||
private HashMap<UUID, Scoreboard> boards;
|
private HashMap<UUID, Scoreboard> boards;
|
||||||
private OfflinePlayer time;
|
private OfflinePlayer time;
|
||||||
|
|
||||||
public ScoreBoardManager(JailMain plugin) {
|
protected ScoreBoardManager(JailMain plugin) {
|
||||||
this.pl = plugin;
|
this.pl = plugin;
|
||||||
this.man = plugin.getServer().getScoreboardManager();
|
this.man = plugin.getServer().getScoreboardManager();
|
||||||
this.boards = new HashMap<UUID, Scoreboard>();
|
this.boards = new HashMap<UUID, Scoreboard>();
|
||||||
|
@ -28,7 +28,7 @@ public class Update {
|
|||||||
// The url for the new file and file version
|
// The url for the new file and file version
|
||||||
private String fileUrl = "", version = "";
|
private String fileUrl = "", version = "";
|
||||||
|
|
||||||
public Update(JailMain plugin) {
|
protected Update(JailMain plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,15 +19,7 @@ import com.graywolf336.jail.enums.Lang;
|
|||||||
public class JailReloadCommand implements Command {
|
public class JailReloadCommand implements Command {
|
||||||
public boolean execute(JailManager jm, CommandSender sender, String... args) {
|
public boolean execute(JailManager jm, CommandSender sender, String... args) {
|
||||||
try {
|
try {
|
||||||
jm.getPlugin().reloadConfig();
|
jm.getPlugin().reloadEverything();
|
||||||
jm.getPlugin().getJailIO().loadLanguage();
|
|
||||||
jm.getPlugin().getJailIO().loadJails();
|
|
||||||
jm.getPlugin().reloadScoreBoardManager();
|
|
||||||
jm.getPlugin().reloadJailSticks();
|
|
||||||
jm.getPlugin().reloadJailPayManager();
|
|
||||||
jm.getPlugin().reloadJailVoteManager();
|
|
||||||
jm.getPlugin().reloadUpdateCheck();
|
|
||||||
|
|
||||||
sender.sendMessage(Lang.PLUGINRELOADED.get());
|
sender.sendMessage(Lang.PLUGINRELOADED.get());
|
||||||
}catch (Exception e) {
|
}catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
Loading…
Reference in New Issue
Block a user