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