mirror of
https://github.com/JEFF-Media-GbR/ChestSort.git
synced 2024-12-03 08:03:26 +01:00
idea's "encapsulate fields"
This commit is contained in:
parent
36d502f355
commit
79a9580692
@ -67,39 +67,47 @@ import java.util.*;
|
||||
|
||||
public class ChestSortPlugin extends JavaPlugin {
|
||||
|
||||
public static double updateCheckInterval = 4 * 60 * 60; // in seconds. We check on startup and every 4 hours
|
||||
public final int currentConfigVersion = 50;
|
||||
public final boolean hotkeyGUI = true;
|
||||
public EnderContainersHook enderContainersHook;
|
||||
public GenericGUIHook genericHook;
|
||||
public boolean hookCrackShot = false;
|
||||
public boolean hookInventoryPages = false;
|
||||
public boolean hookMinepacks = false;
|
||||
public PlayerVaultsHook playerVaultsHook;
|
||||
public boolean debug = false;
|
||||
public ArrayList<String> disabledWorlds;
|
||||
public HashMap<UUID, Long> hotkeyCooldown;
|
||||
public Logger lgr;
|
||||
public Listener listener;
|
||||
private static double updateCheckInterval = 4 * 60 * 60; // in seconds. We check on startup and every 4 hours
|
||||
private final int currentConfigVersion = 50;
|
||||
private final boolean hotkeyGUI = true;
|
||||
private EnderContainersHook enderContainersHook;
|
||||
private GenericGUIHook genericHook;
|
||||
private boolean hookCrackShot = false;
|
||||
private boolean hookInventoryPages = false;
|
||||
private boolean hookMinepacks = false;
|
||||
private PlayerVaultsHook playerVaultsHook;
|
||||
private boolean debug = false;
|
||||
private ArrayList<String> disabledWorlds;
|
||||
private HashMap<UUID, Long> hotkeyCooldown;
|
||||
private Logger lgr;
|
||||
private Listener listener;
|
||||
// 1.14.4 = 1_14_R1
|
||||
// 1.8.0 = 1_8_R1
|
||||
public int mcMinorVersion; // 14 for 1.14, 13 for 1.13, ...
|
||||
public String mcVersion; // 1.13.2 = 1_13_R2
|
||||
public Messages messages;
|
||||
public ChestSortOrganizer organizer;
|
||||
public Map<String, PlayerSetting> perPlayerSettings = new HashMap<>();
|
||||
public ChestSortPermissionsHandler permissionsHandler;
|
||||
public SettingsGUI settingsGUI;
|
||||
public String sortingMethod;
|
||||
public UpdateChecker updateChecker;
|
||||
public boolean usingMatchingConfig = true;
|
||||
public boolean verbose = true;
|
||||
private int mcMinorVersion; // 14 for 1.14, 13 for 1.13, ...
|
||||
private String mcVersion; // 1.13.2 = 1_13_R2
|
||||
private Messages messages;
|
||||
private ChestSortOrganizer organizer;
|
||||
private Map<String, PlayerSetting> perPlayerSettings = new HashMap<>();
|
||||
private ChestSortPermissionsHandler permissionsHandler;
|
||||
private SettingsGUI settingsGUI;
|
||||
private String sortingMethod;
|
||||
private UpdateChecker updateChecker;
|
||||
private boolean usingMatchingConfig = true;
|
||||
private boolean verbose = true;
|
||||
private static ChestSortPlugin instance;
|
||||
|
||||
public static ChestSortPlugin getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public static double getUpdateCheckInterval() {
|
||||
return updateCheckInterval;
|
||||
}
|
||||
|
||||
public static void setUpdateCheckInterval(double updateCheckInterval) {
|
||||
ChestSortPlugin.updateCheckInterval = updateCheckInterval;
|
||||
}
|
||||
|
||||
// Creates the default configuration file
|
||||
// Also checks the config-version of an already existing file. If the existing
|
||||
// config is too
|
||||
@ -121,7 +129,7 @@ public class ChestSortPlugin extends JavaPlugin {
|
||||
|
||||
// Load disabled-worlds. If it does not exist in the config, it returns null.
|
||||
// That's no problem
|
||||
disabledWorlds = (ArrayList<String>) getConfig().getStringList("disabled-worlds");
|
||||
setDisabledWorlds((ArrayList<String>) getConfig().getStringList("disabled-worlds"));
|
||||
|
||||
// Config version prior to 5? Then it must have been generated by ChestSort 1.x
|
||||
/*if (getConfig().getInt("config-version", 0) < 5) {
|
||||
@ -132,11 +140,11 @@ public class ChestSortPlugin extends JavaPlugin {
|
||||
|
||||
} else*/
|
||||
|
||||
if (getConfig().getInt("config-version", 0) != currentConfigVersion) {
|
||||
if (getConfig().getInt("config-version", 0) != getCurrentConfigVersion()) {
|
||||
showOldConfigWarning();
|
||||
ConfigUpdater configUpdater = new ConfigUpdater(this);
|
||||
configUpdater.updateConfig();
|
||||
usingMatchingConfig = true;
|
||||
setUsingMatchingConfig(true);
|
||||
//createConfig();
|
||||
}
|
||||
|
||||
@ -163,7 +171,7 @@ public class ChestSortPlugin extends JavaPlugin {
|
||||
}
|
||||
|
||||
public void debug(String t) {
|
||||
if (debug) getLogger().warning("[DEBUG] " + t);
|
||||
if (isDebug()) getLogger().warning("[DEBUG] " + t);
|
||||
}
|
||||
|
||||
public void debug2(String t) {
|
||||
@ -178,7 +186,7 @@ public class ChestSortPlugin extends JavaPlugin {
|
||||
fos = new FileOutputStream(file);
|
||||
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(fos));
|
||||
for (Material mat : Material.values()) {
|
||||
bw.write(mat.name() + "," + organizer.getCategoryLinePair(mat.name()).getCategoryName());
|
||||
bw.write(mat.name() + "," + getOrganizer().getCategoryLinePair(mat.name()).getCategoryName());
|
||||
bw.newLine();
|
||||
}
|
||||
bw.close();
|
||||
@ -191,7 +199,7 @@ public class ChestSortPlugin extends JavaPlugin {
|
||||
|
||||
private String getCategoryList() {
|
||||
StringBuilder list = new StringBuilder();
|
||||
Category[] categories = organizer.categories.toArray(new Category[0]);
|
||||
Category[] categories = getOrganizer().categories.toArray(new Category[0]);
|
||||
Arrays.sort(categories);
|
||||
for (Category category : categories) {
|
||||
list.append(category.name).append(" (");
|
||||
@ -202,28 +210,124 @@ public class ChestSortPlugin extends JavaPlugin {
|
||||
|
||||
}
|
||||
|
||||
public int getCurrentConfigVersion() {
|
||||
return currentConfigVersion;
|
||||
}
|
||||
|
||||
public ArrayList<String> getDisabledWorlds() {
|
||||
return disabledWorlds;
|
||||
}
|
||||
|
||||
public EnderContainersHook getEnderContainersHook() {
|
||||
return enderContainersHook;
|
||||
}
|
||||
|
||||
public GenericGUIHook getGenericHook() {
|
||||
return genericHook;
|
||||
}
|
||||
|
||||
public HashMap<UUID, Long> getHotkeyCooldown() {
|
||||
return hotkeyCooldown;
|
||||
}
|
||||
|
||||
public Logger getLgr() {
|
||||
return lgr;
|
||||
}
|
||||
|
||||
public Listener getListener() {
|
||||
return listener;
|
||||
}
|
||||
|
||||
public int getMcMinorVersion() {
|
||||
return mcMinorVersion;
|
||||
}
|
||||
|
||||
public String getMcVersion() {
|
||||
return mcVersion;
|
||||
}
|
||||
|
||||
public Messages getMessages() {
|
||||
return messages;
|
||||
}
|
||||
|
||||
public ChestSortOrganizer getOrganizer() {
|
||||
return organizer;
|
||||
}
|
||||
|
||||
public Map<String, PlayerSetting> getPerPlayerSettings() {
|
||||
return perPlayerSettings;
|
||||
}
|
||||
|
||||
public ChestSortPermissionsHandler getPermissionsHandler() {
|
||||
return permissionsHandler;
|
||||
}
|
||||
|
||||
public PlayerSetting getPlayerSetting(Player p) {
|
||||
registerPlayerIfNeeded(p);
|
||||
return perPlayerSettings.get(p.getUniqueId().toString());
|
||||
return getPerPlayerSettings().get(p.getUniqueId().toString());
|
||||
}
|
||||
|
||||
public PlayerVaultsHook getPlayerVaultsHook() {
|
||||
return playerVaultsHook;
|
||||
}
|
||||
|
||||
public SettingsGUI getSettingsGUI() {
|
||||
return settingsGUI;
|
||||
}
|
||||
|
||||
public String getSortingMethod() {
|
||||
return sortingMethod;
|
||||
}
|
||||
|
||||
public UpdateChecker getUpdateChecker() {
|
||||
return updateChecker;
|
||||
}
|
||||
|
||||
public boolean isDebug() {
|
||||
return debug;
|
||||
}
|
||||
|
||||
public boolean isHookCrackShot() {
|
||||
return hookCrackShot;
|
||||
}
|
||||
|
||||
public boolean isHookInventoryPages() {
|
||||
return hookInventoryPages;
|
||||
}
|
||||
|
||||
public boolean isHookMinepacks() {
|
||||
return hookMinepacks;
|
||||
}
|
||||
|
||||
public boolean isHotkeyGUI() {
|
||||
return hotkeyGUI;
|
||||
}
|
||||
|
||||
public boolean isInHotkeyCooldown(UUID uuid) {
|
||||
double cooldown = getConfig().getDouble(Config.HOTKEY_COOLDOWN) * 1000;
|
||||
if (cooldown == 0) return false;
|
||||
long lastUsage = hotkeyCooldown.containsKey(uuid) ? hotkeyCooldown.get(uuid) : 0;
|
||||
long lastUsage = getHotkeyCooldown().containsKey(uuid) ? getHotkeyCooldown().get(uuid) : 0;
|
||||
long currentTime = System.currentTimeMillis();
|
||||
long difference = currentTime - lastUsage;
|
||||
hotkeyCooldown.put(uuid, currentTime);
|
||||
getHotkeyCooldown().put(uuid, currentTime);
|
||||
debug("Difference: " + difference);
|
||||
return difference <= cooldown;
|
||||
}
|
||||
|
||||
public boolean isSortingEnabled(Player p) {
|
||||
if (perPlayerSettings == null) {
|
||||
perPlayerSettings = new HashMap<>();
|
||||
if (getPerPlayerSettings() == null) {
|
||||
setPerPlayerSettings(new HashMap<>());
|
||||
}
|
||||
registerPlayerIfNeeded(p);
|
||||
return perPlayerSettings.get(p.getUniqueId().toString()).sortingEnabled;
|
||||
return getPerPlayerSettings().get(p.getUniqueId().toString()).sortingEnabled;
|
||||
}
|
||||
|
||||
public boolean isUsingMatchingConfig() {
|
||||
return usingMatchingConfig;
|
||||
}
|
||||
|
||||
public boolean isVerbose() {
|
||||
return verbose;
|
||||
}
|
||||
|
||||
public void load(boolean reload) {
|
||||
@ -231,45 +335,45 @@ public class ChestSortPlugin extends JavaPlugin {
|
||||
if (reload) {
|
||||
unregisterAllPlayers();
|
||||
reloadConfig();
|
||||
if (updateChecker != null) {
|
||||
updateChecker.stop();
|
||||
if (getUpdateChecker() != null) {
|
||||
getUpdateChecker().stop();
|
||||
}
|
||||
}
|
||||
|
||||
createConfig();
|
||||
debug = getConfig().getBoolean("debug");
|
||||
setDebug(getConfig().getBoolean("debug"));
|
||||
|
||||
HandlerList.unregisterAll(this);
|
||||
|
||||
if (debug) {
|
||||
if (isDebug()) {
|
||||
Debugger debugger = new Debugger(this);
|
||||
getServer().getPluginManager().registerEvents(debugger, this);
|
||||
}
|
||||
|
||||
hookCrackShot = getConfig().getBoolean("hook-crackshot")
|
||||
&& Bukkit.getPluginManager().getPlugin("CrackShot") instanceof Plugin;
|
||||
setHookCrackShot(getConfig().getBoolean("hook-crackshot")
|
||||
&& Bukkit.getPluginManager().getPlugin("CrackShot") instanceof Plugin);
|
||||
|
||||
hookInventoryPages = getConfig().getBoolean("hook-inventorypages")
|
||||
&& Bukkit.getPluginManager().getPlugin("InventoryPages") instanceof Plugin;
|
||||
setHookInventoryPages(getConfig().getBoolean("hook-inventorypages")
|
||||
&& Bukkit.getPluginManager().getPlugin("InventoryPages") instanceof Plugin);
|
||||
|
||||
hookMinepacks = getConfig().getBoolean("hook-minepacks")
|
||||
&& Bukkit.getPluginManager().getPlugin("Minepacks") instanceof MinepacksPlugin;
|
||||
setHookMinepacks(getConfig().getBoolean("hook-minepacks")
|
||||
&& Bukkit.getPluginManager().getPlugin("Minepacks") instanceof MinepacksPlugin);
|
||||
|
||||
genericHook = new GenericGUIHook(this, getConfig().getBoolean("hook-generic"));
|
||||
setGenericHook(new GenericGUIHook(this, getConfig().getBoolean("hook-generic")));
|
||||
|
||||
saveDefaultCategories();
|
||||
|
||||
verbose = getConfig().getBoolean("verbose");
|
||||
lgr = new Logger(this, getConfig().getBoolean("log"));
|
||||
messages = new Messages(this);
|
||||
organizer = new ChestSortOrganizer(this);
|
||||
settingsGUI = new SettingsGUI(this);
|
||||
setVerbose(getConfig().getBoolean("verbose"));
|
||||
setLgr(new Logger(this, getConfig().getBoolean("log")));
|
||||
setMessages(new Messages(this));
|
||||
setOrganizer(new ChestSortOrganizer(this));
|
||||
setSettingsGUI(new SettingsGUI(this));
|
||||
try {
|
||||
if (Class.forName("net.md_5.bungee.api.chat.BaseComponent") != null) {
|
||||
updateChecker = UpdateChecker.init(this, "https://api.jeff-media.de/chestsort/chestsort-latest-version.txt")
|
||||
setUpdateChecker(UpdateChecker.init(this, "https://api.jeff-media.de/chestsort/chestsort-latest-version.txt")
|
||||
.setChangelogLink("https://www.chestsort.de/changelog")
|
||||
.setDonationLink("https://paypal.me/mfnalex")
|
||||
.setDownloadLink("https://www.chestsort.de");
|
||||
.setDownloadLink("https://www.chestsort.de"));
|
||||
} else {
|
||||
getLogger().severe("You are using an unsupported server software! Consider switching to Spigot or Paper!");
|
||||
getLogger().severe("The Update Checker will NOT work when using CraftBukkit instead of Spigot/Paper!");
|
||||
@ -280,15 +384,15 @@ public class ChestSortPlugin extends JavaPlugin {
|
||||
getLogger().severe("The Update Checker will NOT work when using CraftBukkit instead of Spigot/Paper!");
|
||||
PaperLib.suggestPaper(this);
|
||||
}
|
||||
listener = new Listener(this);
|
||||
hotkeyCooldown = new HashMap<>();
|
||||
permissionsHandler = new ChestSortPermissionsHandler(this);
|
||||
updateCheckInterval = getConfig().getDouble("check-interval");
|
||||
sortingMethod = getConfig().getString("sorting-method");
|
||||
playerVaultsHook = new PlayerVaultsHook(this);
|
||||
enderContainersHook = new EnderContainersHook(this);
|
||||
getServer().getPluginManager().registerEvents(listener, this);
|
||||
getServer().getPluginManager().registerEvents(settingsGUI, this);
|
||||
setListener(new Listener(this));
|
||||
setHotkeyCooldown(new HashMap<>());
|
||||
setPermissionsHandler(new ChestSortPermissionsHandler(this));
|
||||
setUpdateCheckInterval(getConfig().getDouble("check-interval"));
|
||||
setSortingMethod(getConfig().getString("sorting-method"));
|
||||
setPlayerVaultsHook(new PlayerVaultsHook(this));
|
||||
setEnderContainersHook(new EnderContainersHook(this));
|
||||
getServer().getPluginManager().registerEvents(getListener(), this);
|
||||
getServer().getPluginManager().registerEvents(getSettingsGUI(), this);
|
||||
ChestSortCommand chestsortCommandExecutor = new ChestSortCommand(this);
|
||||
TabCompleter tabCompleter = new TabCompleter();
|
||||
this.getCommand("sort").setExecutor(chestsortCommandExecutor);
|
||||
@ -298,9 +402,9 @@ public class ChestSortPlugin extends JavaPlugin {
|
||||
this.getCommand("invsort").setTabCompleter(tabCompleter);
|
||||
this.getCommand("chestsortadmin").setExecutor(new AdminCommand(this));
|
||||
|
||||
if (verbose) {
|
||||
if (isVerbose()) {
|
||||
getLogger().info("Use permissions: " + getConfig().getBoolean("use-permissions"));
|
||||
getLogger().info("Current sorting method: " + sortingMethod);
|
||||
getLogger().info("Current sorting method: " + getSortingMethod());
|
||||
getLogger().info("Allow automatic chest sorting:" + getConfig().getBoolean("allow-automatic-sorting"));
|
||||
getLogger().info(" |- Chest sorting enabled by default: " + getConfig().getBoolean("sorting-enabled-by-default"));
|
||||
getLogger().info(" |- Sort time: " + getConfig().getString("sort-time"));
|
||||
@ -323,22 +427,22 @@ public class ChestSortPlugin extends JavaPlugin {
|
||||
}
|
||||
getLogger().info("Check for updates: " + getConfig().getString("check-for-updates"));
|
||||
if (getConfig().getString("check-for-updates").equalsIgnoreCase("true")) {
|
||||
getLogger().info("Check interval: " + getConfig().getString("check-interval") + " hours (" + updateCheckInterval + " seconds)");
|
||||
getLogger().info("Check interval: " + getConfig().getString("check-interval") + " hours (" + getUpdateCheckInterval() + " seconds)");
|
||||
}
|
||||
getLogger().info("Categories: " + getCategoryList());
|
||||
}
|
||||
|
||||
if (updateChecker != null) {
|
||||
if (getUpdateChecker() != null) {
|
||||
if (getConfig().getString("check-for-updates", "true").equalsIgnoreCase("true")) {
|
||||
updateChecker.checkEveryXHours(updateCheckInterval).checkNow();
|
||||
getUpdateChecker().checkEveryXHours(getUpdateCheckInterval()).checkNow();
|
||||
} // When set to on-startup, we check right now (delay 0)
|
||||
else if (getConfig().getString("check-for-updates", "true").equalsIgnoreCase("on-startup")) {
|
||||
updateChecker.checkNow();
|
||||
getUpdateChecker().checkNow();
|
||||
}
|
||||
}
|
||||
|
||||
if(getConfig().getString("check-for-updates").equalsIgnoreCase("false")) {
|
||||
updateChecker.setNotifyOpsOnJoin(false);
|
||||
getUpdateChecker().setNotifyOpsOnJoin(false);
|
||||
}
|
||||
|
||||
registerMetrics();
|
||||
@ -348,7 +452,7 @@ public class ChestSortPlugin extends JavaPlugin {
|
||||
}
|
||||
|
||||
for (Player p : getServer().getOnlinePlayers()) {
|
||||
permissionsHandler.addPermissions(p);
|
||||
getPermissionsHandler().addPermissions(p);
|
||||
}
|
||||
|
||||
// End Reload
|
||||
@ -360,7 +464,7 @@ public class ChestSortPlugin extends JavaPlugin {
|
||||
// We have to unregister every player to save their perPlayerSettings
|
||||
for (Player p : getServer().getOnlinePlayers()) {
|
||||
unregisterPlayer(p);
|
||||
permissionsHandler.removePermissions(p);
|
||||
getPermissionsHandler().removePermissions(p);
|
||||
}
|
||||
}
|
||||
|
||||
@ -372,9 +476,9 @@ public class ChestSortPlugin extends JavaPlugin {
|
||||
JeffLib.init(this);
|
||||
|
||||
String tmpVersion = getServer().getClass().getPackage().getName();
|
||||
mcVersion = tmpVersion.substring(tmpVersion.lastIndexOf('.') + 1);
|
||||
tmpVersion = mcVersion.substring(mcVersion.indexOf("_") + 1);
|
||||
mcMinorVersion = Integer.parseInt(tmpVersion.substring(0, tmpVersion.indexOf("_")));
|
||||
setMcVersion(tmpVersion.substring(tmpVersion.lastIndexOf('.') + 1));
|
||||
tmpVersion = getMcVersion().substring(getMcVersion().indexOf("_") + 1);
|
||||
setMcMinorVersion(Integer.parseInt(tmpVersion.substring(0, tmpVersion.indexOf("_"))));
|
||||
|
||||
load(false);
|
||||
|
||||
@ -387,13 +491,13 @@ public class ChestSortPlugin extends JavaPlugin {
|
||||
// Metrics will need json-simple with 1.14 API.
|
||||
Metrics bStats = new Metrics(this, 3089);
|
||||
|
||||
bStats.addCustomChart(new Metrics.SimplePie("sorting_method", ()->sortingMethod));
|
||||
bStats.addCustomChart(new Metrics.SimplePie("sorting_method", ()->getSortingMethod()));
|
||||
bStats.addCustomChart(new Metrics.SimplePie("config_version",
|
||||
()->Integer.toString(getConfig().getInt("config-version", 0))));
|
||||
bStats.addCustomChart(
|
||||
new Metrics.SimplePie("check_for_updates", ()->getConfig().getString("check-for-updates", "true")));
|
||||
bStats.addCustomChart(
|
||||
new Metrics.SimplePie("update_interval", ()->Double.toString(updateCheckInterval)));
|
||||
new Metrics.SimplePie("update_interval", ()->Double.toString(getUpdateCheckInterval())));
|
||||
|
||||
bStats.addCustomChart(new Metrics.SimplePie("allow_automatic_sorting",
|
||||
()->Boolean.toString(getConfig().getBoolean("allow-automatic-sorting"))));
|
||||
@ -411,7 +515,7 @@ public class ChestSortPlugin extends JavaPlugin {
|
||||
bStats.addCustomChart(new Metrics.SimplePie("inv_sorting_enabled_by_default",
|
||||
()->Boolean.toString(getConfig().getBoolean("inv-sorting-enabled-by-default"))));
|
||||
bStats.addCustomChart(
|
||||
new Metrics.SimplePie("using_matching_config_version", ()->Boolean.toString(usingMatchingConfig)));
|
||||
new Metrics.SimplePie("using_matching_config_version", ()->Boolean.toString(isUsingMatchingConfig())));
|
||||
bStats.addCustomChart(new Metrics.SimplePie("sort_time", ()->getConfig().getString("sort-time")));
|
||||
bStats.addCustomChart(new Metrics.SimplePie("auto_generate_category_files",
|
||||
()->Boolean.toString(getConfig().getBoolean("auto-generate-category-files"))));
|
||||
@ -442,7 +546,7 @@ public class ChestSortPlugin extends JavaPlugin {
|
||||
UUID uniqueId = p.getUniqueId();
|
||||
|
||||
// Add player to map only if they aren't registered already
|
||||
if (!perPlayerSettings.containsKey(uniqueId.toString())) {
|
||||
if (!getPerPlayerSettings().containsKey(uniqueId.toString())) {
|
||||
|
||||
// Player settings are stored in a file named after the player's UUID
|
||||
File playerFile = new File(getDataFolder() + File.separator + "playerdata",
|
||||
@ -521,7 +625,7 @@ public class ChestSortPlugin extends JavaPlugin {
|
||||
}
|
||||
|
||||
// Finally add the PlayerSetting object to the map
|
||||
perPlayerSettings.put(uniqueId.toString(), newSettings);
|
||||
getPerPlayerSettings().put(uniqueId.toString(), newSettings);
|
||||
|
||||
}
|
||||
}
|
||||
@ -601,6 +705,10 @@ public class ChestSortPlugin extends JavaPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
public void setDebug(boolean debug) {
|
||||
this.debug = debug;
|
||||
}
|
||||
|
||||
private void setDefaultConfigValues() {
|
||||
// If you use an old config file with missing options, the following default
|
||||
// values will be used instead
|
||||
@ -642,6 +750,90 @@ public class ChestSortPlugin extends JavaPlugin {
|
||||
getConfig().addDefault("verbose", true); // Prints some information in onEnable()
|
||||
}
|
||||
|
||||
public void setDisabledWorlds(ArrayList<String> disabledWorlds) {
|
||||
this.disabledWorlds = disabledWorlds;
|
||||
}
|
||||
|
||||
public void setEnderContainersHook(EnderContainersHook enderContainersHook) {
|
||||
this.enderContainersHook = enderContainersHook;
|
||||
}
|
||||
|
||||
public void setGenericHook(GenericGUIHook genericHook) {
|
||||
this.genericHook = genericHook;
|
||||
}
|
||||
|
||||
public void setHookCrackShot(boolean hookCrackShot) {
|
||||
this.hookCrackShot = hookCrackShot;
|
||||
}
|
||||
|
||||
public void setHookInventoryPages(boolean hookInventoryPages) {
|
||||
this.hookInventoryPages = hookInventoryPages;
|
||||
}
|
||||
|
||||
public void setHookMinepacks(boolean hookMinepacks) {
|
||||
this.hookMinepacks = hookMinepacks;
|
||||
}
|
||||
|
||||
public void setHotkeyCooldown(HashMap<UUID, Long> hotkeyCooldown) {
|
||||
this.hotkeyCooldown = hotkeyCooldown;
|
||||
}
|
||||
|
||||
public void setLgr(Logger lgr) {
|
||||
this.lgr = lgr;
|
||||
}
|
||||
|
||||
public void setListener(Listener listener) {
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
public void setMcMinorVersion(int mcMinorVersion) {
|
||||
this.mcMinorVersion = mcMinorVersion;
|
||||
}
|
||||
|
||||
public void setMcVersion(String mcVersion) {
|
||||
this.mcVersion = mcVersion;
|
||||
}
|
||||
|
||||
public void setMessages(Messages messages) {
|
||||
this.messages = messages;
|
||||
}
|
||||
|
||||
public void setOrganizer(ChestSortOrganizer organizer) {
|
||||
this.organizer = organizer;
|
||||
}
|
||||
|
||||
public void setPerPlayerSettings(Map<String, PlayerSetting> perPlayerSettings) {
|
||||
this.perPlayerSettings = perPlayerSettings;
|
||||
}
|
||||
|
||||
public void setPermissionsHandler(ChestSortPermissionsHandler permissionsHandler) {
|
||||
this.permissionsHandler = permissionsHandler;
|
||||
}
|
||||
|
||||
public void setPlayerVaultsHook(PlayerVaultsHook playerVaultsHook) {
|
||||
this.playerVaultsHook = playerVaultsHook;
|
||||
}
|
||||
|
||||
public void setSettingsGUI(SettingsGUI settingsGUI) {
|
||||
this.settingsGUI = settingsGUI;
|
||||
}
|
||||
|
||||
public void setSortingMethod(String sortingMethod) {
|
||||
this.sortingMethod = sortingMethod;
|
||||
}
|
||||
|
||||
public void setUpdateChecker(UpdateChecker updateChecker) {
|
||||
this.updateChecker = updateChecker;
|
||||
}
|
||||
|
||||
public void setUsingMatchingConfig(boolean usingMatchingConfig) {
|
||||
this.usingMatchingConfig = usingMatchingConfig;
|
||||
}
|
||||
|
||||
public void setVerbose(boolean verbose) {
|
||||
this.verbose = verbose;
|
||||
}
|
||||
|
||||
private void showOldConfigWarning() {
|
||||
getLogger().warning("==============================================");
|
||||
getLogger().warning("You were using an old config file. ChestSort");
|
||||
@ -651,8 +843,8 @@ public class ChestSortPlugin extends JavaPlugin {
|
||||
}
|
||||
|
||||
void unregisterAllPlayers() {
|
||||
if (perPlayerSettings != null && perPlayerSettings.size() > 0) {
|
||||
Iterator<String> it = perPlayerSettings.keySet().iterator();
|
||||
if (getPerPlayerSettings() != null && getPerPlayerSettings().size() > 0) {
|
||||
Iterator<String> it = getPerPlayerSettings().keySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
Player p = getServer().getPlayer(it.next());
|
||||
if (p != null) {
|
||||
@ -660,7 +852,7 @@ public class ChestSortPlugin extends JavaPlugin {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
perPlayerSettings = new HashMap<>();
|
||||
setPerPlayerSettings(new HashMap<>());
|
||||
}
|
||||
}
|
||||
|
||||
@ -673,8 +865,8 @@ public class ChestSortPlugin extends JavaPlugin {
|
||||
// When using /reload or some other obscure features, it can happen that players
|
||||
// are online
|
||||
// but not registered. So, we only continue when the player has been registered
|
||||
if (perPlayerSettings.containsKey(uniqueId.toString())) {
|
||||
PlayerSetting setting = perPlayerSettings.get(p.getUniqueId().toString());
|
||||
if (getPerPlayerSettings().containsKey(uniqueId.toString())) {
|
||||
PlayerSetting setting = getPerPlayerSettings().get(p.getUniqueId().toString());
|
||||
|
||||
if (VersionUtil.getServerBukkitVersion().isHigherThanOrEqualTo(VersionUtil.v1_14_4_R01)) {
|
||||
NBTAPI.addNBT(p, "sortingEnabled", String.valueOf(setting.sortingEnabled));
|
||||
@ -705,7 +897,7 @@ public class ChestSortPlugin extends JavaPlugin {
|
||||
try {
|
||||
// Only saved if the config has been changed
|
||||
if (setting.changed) {
|
||||
if (debug) {
|
||||
if (isDebug()) {
|
||||
getLogger().info("PlayerSettings for " + p.getName() + " have changed, saving to file.");
|
||||
}
|
||||
playerConfig.save(playerFile);
|
||||
@ -716,7 +908,7 @@ public class ChestSortPlugin extends JavaPlugin {
|
||||
|
||||
}
|
||||
|
||||
perPlayerSettings.remove(uniqueId.toString());
|
||||
getPerPlayerSettings().remove(uniqueId.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -46,7 +46,7 @@ public class ChestSortCommand implements CommandExecutor {
|
||||
sender.sendMessage(plugin.getCommand("chestsort").getPermissionMessage());
|
||||
}
|
||||
sender.sendMessage(ChatColor.RED+"ChestSort Debug mode enabled - I hope you know what you are doing!");
|
||||
plugin.debug=true;
|
||||
plugin.setDebug(true);
|
||||
Debugger debugger = new Debugger(plugin);
|
||||
plugin.getServer().getPluginManager().registerEvents(debugger, plugin);
|
||||
plugin.debug("Debug mode activated through command by "+sender.getName());
|
||||
@ -61,7 +61,7 @@ public class ChestSortCommand implements CommandExecutor {
|
||||
|
||||
if(args.length!=0) {
|
||||
if(args[0].equalsIgnoreCase("debug")) {
|
||||
plugin.debug=true;
|
||||
plugin.setDebug(true);
|
||||
plugin.getLogger().info("ChestSort debug mode enabled.");
|
||||
return true;
|
||||
}
|
||||
@ -82,12 +82,12 @@ public class ChestSortCommand implements CommandExecutor {
|
||||
if(args.length>0) {
|
||||
if(args[0].equalsIgnoreCase("hotkey") || args[0].equalsIgnoreCase("hotkeys")) {
|
||||
|
||||
if(!plugin.hotkeyGUI) {
|
||||
if(!plugin.isHotkeyGUI()) {
|
||||
p.sendMessage(Messages.MSG_ERR_HOTKEYSDISABLED);
|
||||
return true;
|
||||
}
|
||||
|
||||
plugin.settingsGUI.openGUI(p);
|
||||
plugin.getSettingsGUI().openGUI(p);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -95,7 +95,7 @@ public class ChestSortCommand implements CommandExecutor {
|
||||
}
|
||||
// Settings GUI End
|
||||
|
||||
PlayerSetting setting = plugin.perPlayerSettings.get(p.getUniqueId().toString());
|
||||
PlayerSetting setting = plugin.getPerPlayerSettings().get(p.getUniqueId().toString());
|
||||
|
||||
if(args.length>0
|
||||
&& !args[0].equalsIgnoreCase("toggle")
|
||||
|
@ -57,7 +57,7 @@ public class InvSortCommand implements CommandExecutor {
|
||||
int start = 9;
|
||||
int end = 35;
|
||||
|
||||
PlayerSetting setting = plugin.perPlayerSettings.get(p.getUniqueId().toString());
|
||||
PlayerSetting setting = plugin.getPerPlayerSettings().get(p.getUniqueId().toString());
|
||||
|
||||
if(!plugin.getConfig().getBoolean("allow-automatic-inventory-sorting")) {
|
||||
if(args.length==0 || args[0].equalsIgnoreCase("on") || args[0].equalsIgnoreCase("off") || args[0].equalsIgnoreCase("toggle") ) {
|
||||
@ -97,8 +97,8 @@ public class InvSortCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
plugin.lgr.logSort(p, Logger.SortCause.CMD_ISORT);
|
||||
plugin.organizer.sortInventory(p.getInventory(), start, end);
|
||||
plugin.getLgr().logSort(p, Logger.SortCause.CMD_ISORT);
|
||||
plugin.getOrganizer().sortInventory(p.getInventory(), start, end);
|
||||
p.sendMessage(Messages.MSG_PLAYERINVSORTED);
|
||||
|
||||
return true;
|
||||
|
@ -47,10 +47,10 @@ public class ConfigUpdater {
|
||||
|
||||
}
|
||||
|
||||
if (plugin.debug)
|
||||
if (plugin.isDebug())
|
||||
plugin.getLogger().info("rename config.yml -> config.old.yml");
|
||||
Utils.renameFileInPluginDir(plugin, "config.yml", "config.old.yml");
|
||||
if (plugin.debug)
|
||||
if (plugin.isDebug())
|
||||
plugin.getLogger().info("saving new config.yml");
|
||||
plugin.saveDefaultConfig();
|
||||
|
||||
@ -87,8 +87,8 @@ public class ConfigUpdater {
|
||||
} else if (line.startsWith("disabled-worlds:")) {
|
||||
newline = null;
|
||||
newLines.add("disabled-worlds:");
|
||||
if (plugin.disabledWorlds != null) {
|
||||
for (String disabledWorld : plugin.disabledWorlds) {
|
||||
if (plugin.getDisabledWorlds() != null) {
|
||||
for (String disabledWorld : plugin.getDisabledWorlds()) {
|
||||
newLines.add("- " + disabledWorld);
|
||||
}
|
||||
}
|
||||
@ -118,7 +118,7 @@ public class ConfigUpdater {
|
||||
quotes = "\"";
|
||||
|
||||
newline = node + ": " + quotes + oldValues.get(node).toString() + quotes;
|
||||
if (plugin.debug)
|
||||
if (plugin.isDebug())
|
||||
plugin.getLogger().info("Updating config node " + newline);
|
||||
break;
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ public class SettingsGUI implements Listener {
|
||||
public void openGUI(Player player) {
|
||||
Inventory inventory = createGUI("ChestSort", player);
|
||||
|
||||
PlayerSetting setting = plugin.perPlayerSettings.get(player.getUniqueId().toString());
|
||||
PlayerSetting setting = plugin.getPerPlayerSettings().get(player.getUniqueId().toString());
|
||||
|
||||
if(plugin.getConfig().getBoolean("allow-sorting-hotkeys")) {
|
||||
inventory.setItem(slotMiddleClick, getItem(setting.middleClick, Hotkey.MiddleClick));
|
||||
@ -114,7 +114,7 @@ public class SettingsGUI implements Listener {
|
||||
|
||||
@EventHandler
|
||||
void onGUIInteract(InventoryClickEvent event) {
|
||||
if(!plugin.hotkeyGUI) {
|
||||
if(!plugin.isHotkeyGUI()) {
|
||||
return;
|
||||
}
|
||||
if(!(event.getWhoClicked() instanceof Player)) {
|
||||
@ -122,7 +122,7 @@ public class SettingsGUI implements Listener {
|
||||
}
|
||||
Player p = (Player) event.getWhoClicked();
|
||||
plugin.registerPlayerIfNeeded(p);
|
||||
PlayerSetting setting = plugin.perPlayerSettings.get(p.getUniqueId().toString());
|
||||
PlayerSetting setting = plugin.getPerPlayerSettings().get(p.getUniqueId().toString());
|
||||
|
||||
if(setting.guiInventory==null) {
|
||||
return;
|
||||
@ -148,26 +148,26 @@ public class SettingsGUI implements Listener {
|
||||
|
||||
if(event.getSlot() == SettingsGUI.slotMiddleClick) {
|
||||
setting.toggleMiddleClick();
|
||||
plugin.settingsGUI.openGUI(p);
|
||||
plugin.getSettingsGUI().openGUI(p);
|
||||
}
|
||||
else if(event.getSlot() == SettingsGUI.slotShiftClick) {
|
||||
setting.toggleShiftClick();
|
||||
plugin.settingsGUI.openGUI(p);
|
||||
plugin.getSettingsGUI().openGUI(p);
|
||||
} else if(event.getSlot() == SettingsGUI.slotDoubleClick) {
|
||||
setting.toggleDoubleClick();
|
||||
plugin.settingsGUI.openGUI(p);
|
||||
plugin.getSettingsGUI().openGUI(p);
|
||||
} else if(event.getSlot() == SettingsGUI.slotLeftClickFromOutside) {
|
||||
setting.toggleLeftClickOutside();
|
||||
plugin.settingsGUI.openGUI(p);
|
||||
plugin.getSettingsGUI().openGUI(p);
|
||||
} else if(event.getSlot() == SettingsGUI.slotShiftRightClick) {
|
||||
setting.toggleShiftRightClick();
|
||||
plugin.settingsGUI.openGUI(p);
|
||||
plugin.getSettingsGUI().openGUI(p);
|
||||
} else if(event.getSlot() == SettingsGUI.slotLeftClick) {
|
||||
setting.toggleLeftClick();
|
||||
plugin.settingsGUI.openGUI(p);
|
||||
plugin.getSettingsGUI().openGUI(p);
|
||||
} else if(event.getSlot() == SettingsGUI.slotRightClick) {
|
||||
setting.toggleRightClick();
|
||||
plugin.settingsGUI.openGUI(p);
|
||||
plugin.getSettingsGUI().openGUI(p);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -79,13 +79,13 @@ public class ChestSortOrganizer {
|
||||
// Category name is the filename without .txt
|
||||
String categoryName = file.getName().replaceFirst(".txt", "");
|
||||
|
||||
if (plugin.debug) {
|
||||
if (plugin.isDebug()) {
|
||||
plugin.getLogger().info("Loading category file " + file.getName());
|
||||
}
|
||||
try {
|
||||
Category category = new Category(categoryName, loadCategoryFile(file));
|
||||
categories.add(category);
|
||||
if (plugin.debug) {
|
||||
if (plugin.isDebug()) {
|
||||
plugin.getLogger().info("Loaded category file " + file.getName() + " ("
|
||||
+ category.typeMatches.length + " items)");
|
||||
}
|
||||
@ -170,7 +170,7 @@ public class ChestSortOrganizer {
|
||||
}
|
||||
|
||||
boolean doesInventoryContain(Inventory inv, Material mat) {
|
||||
for (ItemStack item : Utils.getStorageContents(inv,plugin.mcMinorVersion)) {
|
||||
for (ItemStack item : Utils.getStorageContents(inv, plugin.getMcMinorVersion())) {
|
||||
if (item == null) continue;
|
||||
if (item.getType() == mat) {
|
||||
return true;
|
||||
@ -210,13 +210,13 @@ public class ChestSortOrganizer {
|
||||
if (currentLine.toLowerCase().endsWith("=true")) {
|
||||
appendLineNumber = true;
|
||||
makeCategoryStickyByFileName(file.getName());
|
||||
if (plugin.debug)
|
||||
if (plugin.isDebug())
|
||||
plugin.getLogger().info("Sticky set to true in " + file.getName());
|
||||
}
|
||||
} else {
|
||||
//if (currentLine != null) {
|
||||
lines.add(new TypeMatchPositionPair(currentLine, currentLineNumber, appendLineNumber));
|
||||
if (plugin.debug)
|
||||
if (plugin.isDebug())
|
||||
plugin.getLogger().info("Added typeMatch to category file: " + currentLine);
|
||||
//}
|
||||
}
|
||||
@ -246,7 +246,7 @@ public class ChestSortOrganizer {
|
||||
// [0] = Sortable Item name
|
||||
// [1] = Color/Wood
|
||||
|
||||
String myColor = (plugin.debug) ? "~color~" : emptyPlaceholderString;
|
||||
String myColor = (plugin.isDebug()) ? "~color~" : emptyPlaceholderString;
|
||||
|
||||
// Only work with lowercase
|
||||
typeName = typeName.toLowerCase();
|
||||
@ -343,7 +343,7 @@ public class ChestSortOrganizer {
|
||||
return new CategoryLinePair(cat.name, matchingLineNumber);
|
||||
}
|
||||
}
|
||||
return new CategoryLinePair((plugin.debug) ? "~category~" : emptyPlaceholderString, (short) 0);
|
||||
return new CategoryLinePair((plugin.isDebug()) ? "~category~" : emptyPlaceholderString, (short) 0);
|
||||
}
|
||||
|
||||
// Generate a map of "{placeholder}", "sortString" pairs for an ItemStack
|
||||
@ -394,7 +394,7 @@ public class ChestSortOrganizer {
|
||||
String hookChangedName = item.getType().name();
|
||||
|
||||
// CrackShot Support Start
|
||||
if (plugin.hookCrackShot) {
|
||||
if (plugin.isHookCrackShot()) {
|
||||
if (crackShotHook.getCrackShotWeaponName(item) != null) {
|
||||
typeName = plugin.getConfig().getString("hook-crackshot-prefix") + "_" + crackShotHook.getCrackShotWeaponName(item);
|
||||
color = "";
|
||||
@ -411,11 +411,11 @@ public class ChestSortOrganizer {
|
||||
categorySticky = categoryName + "~" + lineNumber;
|
||||
}
|
||||
|
||||
String customName = (plugin.debug) ? "~customName~" : emptyPlaceholderString;
|
||||
String customName = (plugin.isDebug()) ? "~customName~" : emptyPlaceholderString;
|
||||
if (item.getItemMeta().hasDisplayName() && item.getItemMeta().getDisplayName() != null) {
|
||||
customName = item.getItemMeta().getDisplayName();
|
||||
}
|
||||
String lore = (plugin.debug) ? "~lore~" : emptyPlaceholderString;
|
||||
String lore = (plugin.isDebug()) ? "~lore~" : emptyPlaceholderString;
|
||||
if (item.getItemMeta().hasLore() && item.getItemMeta().getLore() != null
|
||||
&& item.getItemMeta().getLore().size() != 0) {
|
||||
String[] loreArray = item.getItemMeta().getLore().toArray(new String[0]);
|
||||
@ -443,7 +443,7 @@ public class ChestSortOrganizer {
|
||||
// This puts together the sortable item name, the category, the color, and
|
||||
// whether the item is a block or a "regular item"
|
||||
String getSortableString(ItemStack item, Map<String, String> sortableMap) {
|
||||
String sortableString = plugin.sortingMethod.replaceAll(",", "|");
|
||||
String sortableString = plugin.getSortingMethod().replaceAll(",", "|");
|
||||
|
||||
for (Map.Entry<String, String> entry : sortableMap.entrySet()) {
|
||||
String placeholder = entry.getKey();
|
||||
@ -499,7 +499,7 @@ public class ChestSortOrganizer {
|
||||
}
|
||||
|
||||
|
||||
if (plugin.debug) {
|
||||
if (plugin.isDebug()) {
|
||||
System.out.println(" ");
|
||||
System.out.println(" ");
|
||||
}
|
||||
@ -531,8 +531,8 @@ public class ChestSortOrganizer {
|
||||
// - Inventorypages buttons
|
||||
// - ItemStacks with more than 64 items
|
||||
for (int i = startSlot; i <= endSlot; i++) {
|
||||
if ((plugin.hookMinepacks && plugin.listener.minepacksHook.isMinepacksBackpack(items[i]))
|
||||
|| (plugin.hookInventoryPages && inventoryPagesHook.isButton(items[i], i, inv))
|
||||
if ((plugin.isHookMinepacks() && plugin.getListener().minepacksHook.isMinepacksBackpack(items[i]))
|
||||
|| (plugin.isHookInventoryPages() && inventoryPagesHook.isButton(items[i], i, inv))
|
||||
|| (plugin.getConfig().getBoolean("dont-move-slimefun-backpacks") && SlimeFunHook.isSlimefunBackpack(items[i]))
|
||||
|| isOversizedStack(items[i])
|
||||
|| chestSortEvent.isUnmovable(i)
|
||||
@ -582,7 +582,7 @@ public class ChestSortOrganizer {
|
||||
Inventory tempInventory = Bukkit.createInventory(null, maxInventorySize); // cannot be bigger than 54 as of 1.14
|
||||
|
||||
for (ItemStack item : nonNullItems) {
|
||||
if (plugin.debug)
|
||||
if (plugin.isDebug())
|
||||
System.out.println(getSortableString(item, chestSortEvent.getSortableMaps().get(item)));
|
||||
// Add the item to the temporary inventory
|
||||
tempInventory.addItem(item);
|
||||
@ -698,10 +698,10 @@ public class ChestSortOrganizer {
|
||||
/*if(plugin.hookMinepacks && plugin.listener.minepacksHook.isMinepacksBackpack(destination)
|
||||
&& plugin.listener.minepacksHook.isMinepacksBackpack(currentItem)) continue;*/
|
||||
// This prevents Minepacks from being moved at all
|
||||
if (plugin.hookMinepacks && plugin.listener.minepacksHook.isMinepacksBackpack(currentItem)) continue;
|
||||
if (plugin.isHookMinepacks() && plugin.getListener().minepacksHook.isMinepacksBackpack(currentItem)) continue;
|
||||
|
||||
if (plugin.hookInventoryPages
|
||||
&& plugin.organizer.inventoryPagesHook.isButton(currentItem, i, source)) continue;
|
||||
if (plugin.isHookInventoryPages()
|
||||
&& plugin.getOrganizer().inventoryPagesHook.isButton(currentItem, i, source)) continue;
|
||||
|
||||
if (destinationIsShulkerBox && currentItem.getType().name().endsWith("SHULKER_BOX")) continue;
|
||||
|
||||
|
@ -21,7 +21,7 @@ public class Debugger implements @NotNull Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onInventoryClickEvent(InventoryClickEvent e) {
|
||||
if(plugin.debug) {
|
||||
if(plugin.isDebug()) {
|
||||
// Debug
|
||||
plugin.debug(" ");
|
||||
plugin.debug("InventoryClickEvent:");
|
||||
|
@ -37,8 +37,8 @@ public class Logger {
|
||||
}
|
||||
|
||||
private String getPlayerSettings(Player p) {
|
||||
if(plugin.perPlayerSettings.containsKey(p.getUniqueId().toString())) {
|
||||
PlayerSetting s = plugin.perPlayerSettings.get(p.getUniqueId().toString());
|
||||
if(plugin.getPerPlayerSettings().containsKey(p.getUniqueId().toString())) {
|
||||
PlayerSetting s = plugin.getPerPlayerSettings().get(p.getUniqueId().toString());
|
||||
return String.format("sorting: %s, invsorting: %s, middle-click: %s, shift-click: %s, double-click: %s, shift-right-click: %s, left-click: %s, right-click: %s, seen-msg: %s",
|
||||
s.sortingEnabled, s.invSortingEnabled, s.middleClick, s.shiftClick, s.doubleClick, s.shiftRightClick, s.leftClick, s.rightClick, s.hasSeenMessage);
|
||||
} else {
|
||||
|
@ -14,7 +14,7 @@ public class CrackShotHook {
|
||||
public CrackShotHook(ChestSortPlugin plugin) {
|
||||
this.plugin=plugin;
|
||||
|
||||
if(plugin.hookCrackShot) {
|
||||
if(plugin.isHookCrackShot()) {
|
||||
crackShotUtility = new CSUtility();
|
||||
plugin.getLogger().info("Succesfully hooked into CrackShot");
|
||||
}
|
||||
@ -22,7 +22,7 @@ public class CrackShotHook {
|
||||
|
||||
// Will return when not a weapon
|
||||
public String getCrackShotWeaponName(ItemStack item) {
|
||||
if(crackShotUtility == null || !plugin.hookCrackShot) {
|
||||
if(crackShotUtility == null || !plugin.isHookCrackShot()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@ public class InventoryPagesHook {
|
||||
public InventoryPagesHook(ChestSortPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
|
||||
if(!plugin.hookInventoryPages) {
|
||||
if(!plugin.isHookInventoryPages()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -51,7 +51,7 @@ public class InventoryPagesHook {
|
||||
|
||||
public boolean isButton(@NotNull ItemStack item, int slot, @NotNull Inventory inv) {
|
||||
|
||||
if(!plugin.hookInventoryPages) {
|
||||
if(!plugin.isHookInventoryPages()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,7 @@ public class MinepacksHook {
|
||||
public MinepacksHook(ChestSortPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
Plugin bukkitPlugin = Bukkit.getPluginManager().getPlugin("Minepacks");
|
||||
if(plugin.hookMinepacks && bukkitPlugin instanceof MinepacksPlugin) {
|
||||
if(plugin.isHookMinepacks() && bukkitPlugin instanceof MinepacksPlugin) {
|
||||
minepacks = (MinepacksPlugin) bukkitPlugin;
|
||||
plugin.getLogger().info("Succesfully hooked into Minepacks");
|
||||
}
|
||||
@ -35,7 +35,7 @@ public class MinepacksHook {
|
||||
} catch (NoSuchMethodException | SecurityException e) {
|
||||
plugin.getLogger().warning("You are using a version of Minepacks that is too old and does not implement every API method needed by ChestSort. Minepacks hook will be disabled.");
|
||||
minepacks = null;
|
||||
plugin.hookMinepacks=false;
|
||||
plugin.setHookMinepacks(false);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -63,25 +63,25 @@ public class Listener implements org.bukkit.event.Listener {
|
||||
if(!playerSetting.leftClickOutside) return;
|
||||
Container containerState = (Container) clickedBlock.getState();
|
||||
Inventory inventory = containerState.getInventory();
|
||||
plugin.organizer.sortInventory(inventory);
|
||||
plugin.getOrganizer().sortInventory(inventory);
|
||||
event.getPlayer().spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(Messages.MSG_CONTAINER_SORTED));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
|
||||
plugin.permissionsHandler.addPermissions(event.getPlayer());
|
||||
plugin.getPermissionsHandler().addPermissions(event.getPlayer());
|
||||
|
||||
// Put player into our perPlayerSettings map
|
||||
plugin.registerPlayerIfNeeded(event.getPlayer());
|
||||
|
||||
plugin.lgr.logPlayerJoin(event.getPlayer());
|
||||
plugin.getLgr().logPlayerJoin(event.getPlayer());
|
||||
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
plugin.permissionsHandler.removePermissions(event.getPlayer());
|
||||
plugin.getPermissionsHandler().removePermissions(event.getPlayer());
|
||||
plugin.unregisterPlayer(event.getPlayer());
|
||||
}
|
||||
|
||||
@ -105,9 +105,9 @@ public class Listener implements org.bukkit.event.Listener {
|
||||
if (!minepacksHook.isMinepacksBackpack(inv)) return;
|
||||
if (!p.hasPermission("chestsort.use")) return;
|
||||
plugin.registerPlayerIfNeeded(p);
|
||||
PlayerSetting setting = plugin.perPlayerSettings.get(p.getUniqueId().toString());
|
||||
PlayerSetting setting = plugin.getPerPlayerSettings().get(p.getUniqueId().toString());
|
||||
if (!setting.sortingEnabled) return;
|
||||
plugin.organizer.sortInventory(inv);
|
||||
plugin.getOrganizer().sortInventory(inv);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -148,15 +148,15 @@ public class Listener implements org.bukkit.event.Listener {
|
||||
}
|
||||
plugin.registerPlayerIfNeeded(p);
|
||||
|
||||
PlayerSetting setting = plugin.perPlayerSettings.get(p.getUniqueId().toString());
|
||||
PlayerSetting setting = plugin.getPerPlayerSettings().get(p.getUniqueId().toString());
|
||||
if (!setting.invSortingEnabled) {
|
||||
plugin.debug("auto inv sorting not enabled for player "+p.getName());
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.lgr.logSort(p, Logger.SortCause.INV_CLOSE);
|
||||
plugin.getLgr().logSort(p, Logger.SortCause.INV_CLOSE);
|
||||
|
||||
plugin.organizer.sortInventory(p.getInventory(), 9, 35);
|
||||
plugin.getOrganizer().sortInventory(p.getInventory(), 9, 35);
|
||||
|
||||
}
|
||||
|
||||
@ -183,7 +183,7 @@ public class Listener implements org.bukkit.event.Listener {
|
||||
|
||||
if (!isAPICall(inventory)
|
||||
&& !belongsToChestLikeBlock(inventory)
|
||||
&& !plugin.enderContainersHook.isEnderchest(inventory)
|
||||
&& !plugin.getEnderContainersHook().isEnderchest(inventory)
|
||||
&& !LlamaUtils.belongsToLlama(inventory)) {
|
||||
return;
|
||||
}
|
||||
@ -194,17 +194,17 @@ public class Listener implements org.bukkit.event.Listener {
|
||||
|
||||
// Finally call the Organizer to sort the inventory
|
||||
|
||||
plugin.lgr.logSort(p, Logger.SortCause.CONT_CLOSE);
|
||||
plugin.getLgr().logSort(p, Logger.SortCause.CONT_CLOSE);
|
||||
|
||||
// Llama inventories need special start/end slots
|
||||
if (LlamaUtils.belongsToLlama(event.getInventory())) {
|
||||
ChestedHorse llama = (ChestedHorse) event.getInventory().getHolder();
|
||||
plugin.organizer.sortInventory(event.getInventory(), 2, LlamaUtils.getLlamaChestSize(llama) + 1);
|
||||
plugin.getOrganizer().sortInventory(event.getInventory(), 2, LlamaUtils.getLlamaChestSize(llama) + 1);
|
||||
return;
|
||||
}
|
||||
|
||||
// Normal container inventories can be sorted completely
|
||||
plugin.organizer.sortInventory(event.getInventory());
|
||||
plugin.getOrganizer().sortInventory(event.getInventory());
|
||||
|
||||
}
|
||||
|
||||
@ -233,7 +233,7 @@ public class Listener implements org.bukkit.event.Listener {
|
||||
|
||||
if (!isAPICall(inventory)
|
||||
&& !belongsToChestLikeBlock(inventory)
|
||||
&& !plugin.enderContainersHook.isEnderchest(inventory)
|
||||
&& !plugin.getEnderContainersHook().isEnderchest(inventory)
|
||||
&& !LlamaUtils.belongsToLlama(inventory)) {
|
||||
return;
|
||||
}
|
||||
@ -244,18 +244,18 @@ public class Listener implements org.bukkit.event.Listener {
|
||||
|
||||
// Finally call the Organizer to sort the inventory
|
||||
|
||||
plugin.lgr.logSort(p, Logger.SortCause.CONT_OPEN);
|
||||
plugin.getLgr().logSort(p, Logger.SortCause.CONT_OPEN);
|
||||
|
||||
|
||||
// Llama inventories need special start/end slots
|
||||
if (LlamaUtils.belongsToLlama(event.getInventory())) {
|
||||
ChestedHorse llama = (ChestedHorse) event.getInventory().getHolder();
|
||||
plugin.organizer.sortInventory(event.getInventory(), 2, LlamaUtils.getLlamaChestSize(llama) + 1);
|
||||
plugin.getOrganizer().sortInventory(event.getInventory(), 2, LlamaUtils.getLlamaChestSize(llama) + 1);
|
||||
return;
|
||||
}
|
||||
|
||||
// Normal container inventories can be sorted completely
|
||||
plugin.organizer.sortInventory(event.getInventory());
|
||||
plugin.getOrganizer().sortInventory(event.getInventory());
|
||||
|
||||
}
|
||||
|
||||
@ -298,7 +298,7 @@ public class Listener implements org.bukkit.event.Listener {
|
||||
}
|
||||
|
||||
// checking in lower case for lazy admins
|
||||
if (plugin.disabledWorlds.contains(p.getWorld().getName().toLowerCase())) {
|
||||
if (plugin.getDisabledWorlds().contains(p.getWorld().getName().toLowerCase())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -314,7 +314,7 @@ public class Listener implements org.bukkit.event.Listener {
|
||||
// Get the current player's settings
|
||||
// We do not immediately cancel when sorting is disabled because we might want
|
||||
// to show the hint message
|
||||
PlayerSetting setting = plugin.perPlayerSettings.get(p.getUniqueId().toString());
|
||||
PlayerSetting setting = plugin.getPerPlayerSettings().get(p.getUniqueId().toString());
|
||||
|
||||
// Show "how to enable ChestSort" message when ALL of the following criteria are
|
||||
// met:
|
||||
@ -371,9 +371,9 @@ public class Listener implements org.bukkit.event.Listener {
|
||||
|
||||
// Finally call the Organizer to sort the inventory
|
||||
|
||||
plugin.lgr.logSort(p, Logger.SortCause.EC_OPEN);
|
||||
plugin.getLgr().logSort(p, Logger.SortCause.EC_OPEN);
|
||||
|
||||
plugin.organizer.sortInventory(event.getInventory());
|
||||
plugin.getOrganizer().sortInventory(event.getInventory());
|
||||
}
|
||||
}
|
||||
|
||||
@ -415,8 +415,8 @@ public class Listener implements org.bukkit.event.Listener {
|
||||
|
||||
// Detect generic GUIs
|
||||
if(!isAPICall &&
|
||||
(plugin.genericHook.isPluginGUI(event.getInventory())
|
||||
|| plugin.genericHook.isPluginGUI(event.getInventory()))) {
|
||||
(plugin.getGenericHook().isPluginGUI(event.getInventory())
|
||||
|| plugin.getGenericHook().isPluginGUI(event.getInventory()))) {
|
||||
plugin.debug("Aborting hotkey sorting: no API call & generic GUI detected");
|
||||
return;
|
||||
}
|
||||
@ -436,7 +436,7 @@ public class Listener implements org.bukkit.event.Listener {
|
||||
boolean sort = false;
|
||||
Logger.SortCause cause = null;
|
||||
|
||||
PlayerSetting setting = plugin.perPlayerSettings.get(p.getUniqueId().toString());
|
||||
PlayerSetting setting = plugin.getPerPlayerSettings().get(p.getUniqueId().toString());
|
||||
|
||||
// Do not sort the GUI inventory
|
||||
if (event.getClickedInventory() == setting.guiInventory) {
|
||||
@ -515,8 +515,8 @@ public class Listener implements org.bukkit.event.Listener {
|
||||
|| belongsToChestLikeBlock(event.getClickedInventory())
|
||||
|| LlamaUtils.belongsToLlama(event.getClickedInventory())
|
||||
|| minepacksHook.isMinepacksBackpack(event.getClickedInventory())
|
||||
|| plugin.playerVaultsHook.isPlayerVault(event.getClickedInventory())
|
||||
|| plugin.enderContainersHook.isEnderchest(event.getClickedInventory())) {
|
||||
|| plugin.getPlayerVaultsHook().isPlayerVault(event.getClickedInventory())
|
||||
|| plugin.getEnderContainersHook().isEnderchest(event.getClickedInventory())) {
|
||||
|
||||
|
||||
if (!p.hasPermission("chestsort.use")) {
|
||||
@ -525,16 +525,16 @@ public class Listener implements org.bukkit.event.Listener {
|
||||
|
||||
if (LlamaUtils.belongsToLlama(event.getClickedInventory())) {
|
||||
|
||||
plugin.lgr.logSort(p,cause);
|
||||
plugin.getLgr().logSort(p,cause);
|
||||
ChestedHorse llama = (ChestedHorse) event.getInventory().getHolder();
|
||||
plugin.organizer.sortInventory(event.getClickedInventory(), 2, LlamaUtils.getLlamaChestSize(llama) + 1);
|
||||
plugin.organizer.updateInventoryView(event);
|
||||
plugin.getOrganizer().sortInventory(event.getClickedInventory(), 2, LlamaUtils.getLlamaChestSize(llama) + 1);
|
||||
plugin.getOrganizer().updateInventoryView(event);
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.lgr.logSort(p,cause);
|
||||
plugin.organizer.sortInventory(event.getClickedInventory());
|
||||
plugin.organizer.updateInventoryView(event);
|
||||
plugin.getLgr().logSort(p,cause);
|
||||
plugin.getOrganizer().sortInventory(event.getClickedInventory());
|
||||
plugin.getOrganizer().updateInventoryView(event);
|
||||
} else if (holder instanceof Player) {
|
||||
|
||||
if (!p.hasPermission("chestsort.use.inventory")) {
|
||||
@ -542,14 +542,14 @@ public class Listener implements org.bukkit.event.Listener {
|
||||
}
|
||||
|
||||
if (event.getSlotType() == SlotType.QUICKBAR) {
|
||||
plugin.lgr.logSort(p,cause);
|
||||
plugin.organizer.sortInventory(p.getInventory(), 0, 8);
|
||||
plugin.organizer.updateInventoryView(event);
|
||||
plugin.getLgr().logSort(p,cause);
|
||||
plugin.getOrganizer().sortInventory(p.getInventory(), 0, 8);
|
||||
plugin.getOrganizer().updateInventoryView(event);
|
||||
|
||||
} else if (event.getSlotType() == SlotType.CONTAINER) {
|
||||
plugin.lgr.logSort(p,cause);
|
||||
plugin.organizer.sortInventory(p.getInventory(), 9, 35);
|
||||
plugin.organizer.updateInventoryView(event);
|
||||
plugin.getLgr().logSort(p,cause);
|
||||
plugin.getOrganizer().sortInventory(p.getInventory(), 9, 35);
|
||||
plugin.getOrganizer().updateInventoryView(event);
|
||||
|
||||
}
|
||||
}
|
||||
@ -618,8 +618,8 @@ public class Listener implements org.bukkit.event.Listener {
|
||||
|
||||
// Detect generic GUIs
|
||||
if(!isAPICall(e.getInventory()) && !isAPICall(e.getClickedInventory()) &&
|
||||
(plugin.genericHook.isPluginGUI(e.getInventory())
|
||||
|| plugin.genericHook.isPluginGUI(e.getInventory()))) {
|
||||
(plugin.getGenericHook().isPluginGUI(e.getInventory())
|
||||
|| plugin.getGenericHook().isPluginGUI(e.getInventory()))) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -631,7 +631,7 @@ public class Listener implements org.bukkit.event.Listener {
|
||||
if (!p.hasPermission("chestsort.use")) return;
|
||||
|
||||
plugin.registerPlayerIfNeeded(p);
|
||||
PlayerSetting setting = plugin.perPlayerSettings.get(p.getUniqueId().toString());
|
||||
PlayerSetting setting = plugin.getPerPlayerSettings().get(p.getUniqueId().toString());
|
||||
|
||||
|
||||
ChestSortEvent chestSortEvent = new ChestSortEvent(e.getInventory());
|
||||
@ -640,7 +640,7 @@ public class Listener implements org.bukkit.event.Listener {
|
||||
|
||||
chestSortEvent.setSortableMaps(new HashMap<>());
|
||||
for (ItemStack item : e.getInventory().getContents()) {
|
||||
chestSortEvent.getSortableMaps().put(item, plugin.organizer.getSortableMap(item));
|
||||
chestSortEvent.getSortableMaps().put(item, plugin.getOrganizer().getSortableMap(item));
|
||||
}
|
||||
|
||||
Bukkit.getPluginManager().callEvent(chestSortEvent);
|
||||
@ -649,33 +649,33 @@ public class Listener implements org.bukkit.event.Listener {
|
||||
}
|
||||
|
||||
if (e.isLeftClick() && setting.leftClick) {
|
||||
plugin.lgr.logSort(p, Logger.SortCause.H_LEFT);
|
||||
plugin.getLgr().logSort(p, Logger.SortCause.H_LEFT);
|
||||
if (setting.getCurrentDoubleClick(plugin, PlayerSetting.DoubleClickType.LEFT_CLICK)
|
||||
== PlayerSetting.DoubleClickType.LEFT_CLICK) {
|
||||
// Left double click: put everything into destination
|
||||
plugin.organizer.stuffPlayerInventoryIntoAnother(p.getInventory(), e.getInventory(), false, chestSortEvent);
|
||||
plugin.organizer.sortInventory(e.getInventory());
|
||||
plugin.getOrganizer().stuffPlayerInventoryIntoAnother(p.getInventory(), e.getInventory(), false, chestSortEvent);
|
||||
plugin.getOrganizer().sortInventory(e.getInventory());
|
||||
} else {
|
||||
// Left single click: put only matching items into destination
|
||||
plugin.organizer.stuffPlayerInventoryIntoAnother(p.getInventory(), e.getInventory(), true, chestSortEvent);
|
||||
plugin.getOrganizer().stuffPlayerInventoryIntoAnother(p.getInventory(), e.getInventory(), true, chestSortEvent);
|
||||
}
|
||||
|
||||
} else if (e.isRightClick() && setting.rightClick) {
|
||||
plugin.lgr.logSort(p, Logger.SortCause.H_RIGHT);
|
||||
plugin.getLgr().logSort(p, Logger.SortCause.H_RIGHT);
|
||||
if (setting.getCurrentDoubleClick(plugin, PlayerSetting.DoubleClickType.RIGHT_CLICK)
|
||||
== PlayerSetting.DoubleClickType.RIGHT_CLICK) {
|
||||
// Right double click: put everything into player inventory
|
||||
plugin.organizer.stuffInventoryIntoAnother(e.getInventory(), p.getInventory(), e.getInventory(), false);
|
||||
plugin.organizer.sortInventory(p.getInventory(),9,35);
|
||||
plugin.getOrganizer().stuffInventoryIntoAnother(e.getInventory(), p.getInventory(), e.getInventory(), false);
|
||||
plugin.getOrganizer().sortInventory(p.getInventory(),9,35);
|
||||
} else {
|
||||
// Right single click: put only matching items into player inventory
|
||||
plugin.organizer.stuffInventoryIntoAnother(e.getInventory(), p.getInventory(), e.getInventory(), true);
|
||||
plugin.getOrganizer().stuffInventoryIntoAnother(e.getInventory(), p.getInventory(), e.getInventory(), true);
|
||||
}
|
||||
|
||||
}
|
||||
//plugin.organizer.sortInventory(e.getInventory());
|
||||
plugin.organizer.updateInventoryView(e.getInventory());
|
||||
plugin.organizer.updateInventoryView(p.getInventory());
|
||||
plugin.getOrganizer().updateInventoryView(e.getInventory());
|
||||
plugin.getOrganizer().updateInventoryView(p.getInventory());
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user