renamed classes

This commit is contained in:
mfnalex 2021-05-30 20:55:43 +02:00
parent 8abe5206d6
commit 36d502f355
14 changed files with 105 additions and 109 deletions

View File

@ -28,25 +28,25 @@
package de.jeff_media.chestsort;
import at.pcgamingfreaks.Minepacks.Bukkit.API.MinepacksPlugin;
import de.jeff_media.chestsort.commands.ChestSortAdminCommand;
import de.jeff_media.chestsort.commands.ChestSortChestSortCommand;
import de.jeff_media.chestsort.commands.ChestSortInvSortCommand;
import de.jeff_media.chestsort.commands.ChestSortTabCompleter;
import de.jeff_media.chestsort.config.ChestSortConfigUpdater;
import de.jeff_media.chestsort.commands.AdminCommand;
import de.jeff_media.chestsort.commands.ChestSortCommand;
import de.jeff_media.chestsort.commands.InvSortCommand;
import de.jeff_media.chestsort.commands.TabCompleter;
import de.jeff_media.chestsort.config.ConfigUpdater;
import de.jeff_media.chestsort.config.Messages;
import de.jeff_media.chestsort.config.Config;
import de.jeff_media.chestsort.data.ChestSortCategory;
import de.jeff_media.chestsort.data.ChestSortPlayerSetting;
import de.jeff_media.chestsort.gui.ChestSortSettingsGUI;
import de.jeff_media.chestsort.handlers.ChestSortDebugger;
import de.jeff_media.chestsort.handlers.ChestSortLogger;
import de.jeff_media.chestsort.data.Category;
import de.jeff_media.chestsort.data.PlayerSetting;
import de.jeff_media.chestsort.gui.SettingsGUI;
import de.jeff_media.chestsort.handlers.Debugger;
import de.jeff_media.chestsort.handlers.Logger;
import de.jeff_media.chestsort.handlers.ChestSortOrganizer;
import de.jeff_media.chestsort.handlers.ChestSortPermissionsHandler;
import de.jeff_media.chestsort.hooks.EnderContainersHook;
import de.jeff_media.chestsort.hooks.GenericGUIHook;
import de.jeff_media.chestsort.hooks.PlayerVaultsHook;
import de.jeff_media.chestsort.listeners.ChestSortListener;
import de.jeff_media.chestsort.placeholders.ChestSortPlaceholders;
import de.jeff_media.chestsort.listeners.Listener;
import de.jeff_media.chestsort.placeholders.Placeholders;
import de.jeff_media.chestsort.utils.Utils;
import de.jeff_media.jefflib.JeffLib;
import de.jeff_media.jefflib.NBTAPI;
@ -79,17 +79,17 @@ public class ChestSortPlugin extends JavaPlugin {
public boolean debug = false;
public ArrayList<String> disabledWorlds;
public HashMap<UUID, Long> hotkeyCooldown;
public ChestSortLogger lgr;
public ChestSortListener listener;
public Logger lgr;
public 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, ChestSortPlayerSetting> perPlayerSettings = new HashMap<>();
public Map<String, PlayerSetting> perPlayerSettings = new HashMap<>();
public ChestSortPermissionsHandler permissionsHandler;
public ChestSortSettingsGUI settingsGUI;
public SettingsGUI settingsGUI;
public String sortingMethod;
public UpdateChecker updateChecker;
public boolean usingMatchingConfig = true;
@ -134,7 +134,7 @@ public class ChestSortPlugin extends JavaPlugin {
if (getConfig().getInt("config-version", 0) != currentConfigVersion) {
showOldConfigWarning();
ChestSortConfigUpdater configUpdater = new ChestSortConfigUpdater(this);
ConfigUpdater configUpdater = new ConfigUpdater(this);
configUpdater.updateConfig();
usingMatchingConfig = true;
//createConfig();
@ -191,9 +191,9 @@ public class ChestSortPlugin extends JavaPlugin {
private String getCategoryList() {
StringBuilder list = new StringBuilder();
ChestSortCategory[] categories = organizer.categories.toArray(new ChestSortCategory[0]);
Category[] categories = organizer.categories.toArray(new Category[0]);
Arrays.sort(categories);
for (ChestSortCategory category : categories) {
for (Category category : categories) {
list.append(category.name).append(" (");
list.append(category.typeMatches.length).append("), ");
}
@ -202,7 +202,7 @@ public class ChestSortPlugin extends JavaPlugin {
}
public ChestSortPlayerSetting getPlayerSetting(Player p) {
public PlayerSetting getPlayerSetting(Player p) {
registerPlayerIfNeeded(p);
return perPlayerSettings.get(p.getUniqueId().toString());
}
@ -242,7 +242,7 @@ public class ChestSortPlugin extends JavaPlugin {
HandlerList.unregisterAll(this);
if (debug) {
ChestSortDebugger debugger = new ChestSortDebugger(this);
Debugger debugger = new Debugger(this);
getServer().getPluginManager().registerEvents(debugger, this);
}
@ -260,10 +260,10 @@ public class ChestSortPlugin extends JavaPlugin {
saveDefaultCategories();
verbose = getConfig().getBoolean("verbose");
lgr = new ChestSortLogger(this, getConfig().getBoolean("log"));
lgr = new Logger(this, getConfig().getBoolean("log"));
messages = new Messages(this);
organizer = new ChestSortOrganizer(this);
settingsGUI = new ChestSortSettingsGUI(this);
settingsGUI = 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")
@ -280,7 +280,7 @@ 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 ChestSortListener(this);
listener = new Listener(this);
hotkeyCooldown = new HashMap<>();
permissionsHandler = new ChestSortPermissionsHandler(this);
updateCheckInterval = getConfig().getDouble("check-interval");
@ -289,14 +289,14 @@ public class ChestSortPlugin extends JavaPlugin {
enderContainersHook = new EnderContainersHook(this);
getServer().getPluginManager().registerEvents(listener, this);
getServer().getPluginManager().registerEvents(settingsGUI, this);
ChestSortChestSortCommand chestsortCommandExecutor = new ChestSortChestSortCommand(this);
ChestSortTabCompleter tabCompleter = new ChestSortTabCompleter();
ChestSortCommand chestsortCommandExecutor = new ChestSortCommand(this);
TabCompleter tabCompleter = new TabCompleter();
this.getCommand("sort").setExecutor(chestsortCommandExecutor);
this.getCommand("sort").setTabCompleter(tabCompleter);
ChestSortInvSortCommand invsortCommandExecutor = new ChestSortInvSortCommand(this);
InvSortCommand invsortCommandExecutor = new InvSortCommand(this);
this.getCommand("invsort").setExecutor(invsortCommandExecutor);
this.getCommand("invsort").setTabCompleter(tabCompleter);
this.getCommand("chestsortadmin").setExecutor(new ChestSortAdminCommand(this));
this.getCommand("chestsortadmin").setExecutor(new AdminCommand(this));
if (verbose) {
getLogger().info("Use permissions: " + getConfig().getBoolean("use-permissions"));
@ -379,7 +379,7 @@ public class ChestSortPlugin extends JavaPlugin {
load(false);
if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
new ChestSortPlaceholders(this).register();
new Placeholders(this).register();
}
}
@ -508,7 +508,7 @@ public class ChestSortPlugin extends JavaPlugin {
changed = true;
}
ChestSortPlayerSetting newSettings = new ChestSortPlayerSetting(activeForThisPlayer, invActiveForThisPlayer, middleClick, shiftClick, doubleClick, shiftRightClick, leftClick, rightClick, leftClickFromOutside, changed);
PlayerSetting newSettings = new PlayerSetting(activeForThisPlayer, invActiveForThisPlayer, middleClick, shiftClick, doubleClick, shiftRightClick, leftClick, rightClick, leftClickFromOutside, changed);
// when "show-message-again-after-logout" is enabled, we don't care if the
// player already saw the message
@ -674,7 +674,7 @@ public class ChestSortPlugin extends JavaPlugin {
// are online
// but not registered. So, we only continue when the player has been registered
if (perPlayerSettings.containsKey(uniqueId.toString())) {
ChestSortPlayerSetting setting = perPlayerSettings.get(p.getUniqueId().toString());
PlayerSetting setting = perPlayerSettings.get(p.getUniqueId().toString());
if (VersionUtil.getServerBukkitVersion().isHigherThanOrEqualTo(VersionUtil.v1_14_4_R01)) {
NBTAPI.addNBT(p, "sortingEnabled", String.valueOf(setting.sortingEnabled));

View File

@ -9,11 +9,11 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
public class ChestSortAdminCommand implements CommandExecutor {
public class AdminCommand implements CommandExecutor {
private final ChestSortPlugin plugin;
public ChestSortAdminCommand(ChestSortPlugin plugin) {
public AdminCommand(ChestSortPlugin plugin) {
this.plugin = plugin;
}

View File

@ -1,8 +1,8 @@
package de.jeff_media.chestsort.commands;
import de.jeff_media.chestsort.config.Messages;
import de.jeff_media.chestsort.handlers.ChestSortDebugger;
import de.jeff_media.chestsort.data.ChestSortPlayerSetting;
import de.jeff_media.chestsort.handlers.Debugger;
import de.jeff_media.chestsort.data.PlayerSetting;
import de.jeff_media.chestsort.ChestSortPlugin;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
@ -12,11 +12,11 @@ import org.bukkit.entity.Player;
import net.md_5.bungee.api.ChatColor;
import org.jetbrains.annotations.NotNull;
public class ChestSortChestSortCommand implements CommandExecutor {
public class ChestSortCommand implements CommandExecutor {
private final ChestSortPlugin plugin;
public ChestSortChestSortCommand(ChestSortPlugin plugin) {
public ChestSortCommand(ChestSortPlugin plugin) {
this.plugin = plugin;
}
@ -47,7 +47,7 @@ public class ChestSortChestSortCommand implements CommandExecutor {
}
sender.sendMessage(ChatColor.RED+"ChestSort Debug mode enabled - I hope you know what you are doing!");
plugin.debug=true;
ChestSortDebugger debugger = new ChestSortDebugger(plugin);
Debugger debugger = new Debugger(plugin);
plugin.getServer().getPluginManager().registerEvents(debugger, plugin);
plugin.debug("Debug mode activated through command by "+sender.getName());
return true;
@ -95,7 +95,7 @@ public class ChestSortChestSortCommand implements CommandExecutor {
}
// Settings GUI End
ChestSortPlayerSetting setting = plugin.perPlayerSettings.get(p.getUniqueId().toString());
PlayerSetting setting = plugin.perPlayerSettings.get(p.getUniqueId().toString());
if(args.length>0
&& !args[0].equalsIgnoreCase("toggle")

View File

@ -1,8 +1,8 @@
package de.jeff_media.chestsort.commands;
import de.jeff_media.chestsort.config.Messages;
import de.jeff_media.chestsort.handlers.ChestSortLogger;
import de.jeff_media.chestsort.data.ChestSortPlayerSetting;
import de.jeff_media.chestsort.handlers.Logger;
import de.jeff_media.chestsort.data.PlayerSetting;
import de.jeff_media.chestsort.ChestSortPlugin;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
@ -11,11 +11,11 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
public class ChestSortInvSortCommand implements CommandExecutor {
public class InvSortCommand implements CommandExecutor {
final ChestSortPlugin plugin;
public ChestSortInvSortCommand(ChestSortPlugin plugin) {
public InvSortCommand(ChestSortPlugin plugin) {
this.plugin = plugin;
}
@ -57,7 +57,7 @@ public class ChestSortInvSortCommand implements CommandExecutor {
int start = 9;
int end = 35;
ChestSortPlayerSetting setting = plugin.perPlayerSettings.get(p.getUniqueId().toString());
PlayerSetting setting = plugin.perPlayerSettings.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,7 +97,7 @@ public class ChestSortInvSortCommand implements CommandExecutor {
return true;
}
}
plugin.lgr.logSort(p, ChestSortLogger.SortCause.CMD_ISORT);
plugin.lgr.logSort(p, Logger.SortCause.CMD_ISORT);
plugin.organizer.sortInventory(p.getInventory(), start, end);
p.sendMessage(Messages.MSG_PLAYERINVSORTED);

View File

@ -5,10 +5,9 @@ import java.util.List;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.jetbrains.annotations.NotNull;
public class ChestSortTabCompleter implements TabCompleter {
public class TabCompleter implements org.bukkit.command.TabCompleter {
static final String[] chestsortOptions = { "toggle","on","off","hotkeys","help" };
static final String[] invsortOptions = { "toggle","on","off","all", "hotbar", "inv","help" };

View File

@ -14,11 +14,11 @@ import org.bukkit.configuration.file.YamlConfiguration;
import de.jeff_media.chestsort.utils.Utils;
public class ChestSortConfigUpdater {
public class ConfigUpdater {
final ChestSortPlugin plugin;
public ChestSortConfigUpdater(ChestSortPlugin jeffChestSortPlugin) {
public ConfigUpdater(ChestSortPlugin jeffChestSortPlugin) {
this.plugin = jeffChestSortPlugin;
}

View File

@ -2,7 +2,7 @@ package de.jeff_media.chestsort.data;
import de.jeff_media.chestsort.utils.TypeMatchPositionPair;
public class ChestSortCategory implements Comparable<ChestSortCategory>{
public class Category implements Comparable<Category>{
// Represents a sorting category
// Includes an array of strings called typeMatches
@ -16,7 +16,7 @@ public class ChestSortCategory implements Comparable<ChestSortCategory>{
boolean sticky = false;
public final TypeMatchPositionPair[] typeMatches;
public ChestSortCategory(String name, TypeMatchPositionPair[] typeMatchPositionPairs) {
public Category(String name, TypeMatchPositionPair[] typeMatchPositionPairs) {
this.name = name;
this.typeMatches = typeMatchPositionPairs;
}
@ -71,7 +71,7 @@ public class ChestSortCategory implements Comparable<ChestSortCategory>{
return 0;
}
public int compareTo(ChestSortCategory compareCategory) {
public int compareTo(Category compareCategory) {
return this.name.compareTo(compareCategory.name);
}

View File

@ -4,7 +4,7 @@ import de.jeff_media.chestsort.ChestSortPlugin;
import org.bukkit.Bukkit;
import org.bukkit.inventory.Inventory;
public class ChestSortPlayerSetting {
public class PlayerSetting {
// Represents the information regarding a player
// That includes:
@ -40,7 +40,7 @@ public class ChestSortPlayerSetting {
NONE, RIGHT_CLICK, LEFT_CLICK
}
public ChestSortPlayerSetting(boolean sortingEnabled, boolean invSortingEnabled, boolean middleClick, boolean shiftClick, boolean doubleClick, boolean shiftRightClick, boolean leftClick, boolean rightClick, boolean leftCLickOutside, boolean changed) {
public PlayerSetting(boolean sortingEnabled, boolean invSortingEnabled, boolean middleClick, boolean shiftClick, boolean doubleClick, boolean shiftRightClick, boolean leftClick, boolean rightClick, boolean leftCLickOutside, boolean changed) {
this.sortingEnabled = sortingEnabled;
this.middleClick = middleClick;
this.shiftClick = shiftClick;

View File

@ -2,7 +2,7 @@ package de.jeff_media.chestsort.gui;
import de.jeff_media.chestsort.ChestSortPlugin;
import de.jeff_media.chestsort.config.Messages;
import de.jeff_media.chestsort.data.ChestSortPlayerSetting;
import de.jeff_media.chestsort.data.PlayerSetting;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
@ -16,7 +16,7 @@ import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
public class ChestSortSettingsGUI implements Listener {
public class SettingsGUI implements Listener {
final ChestSortPlugin plugin;
@ -35,7 +35,7 @@ public class ChestSortSettingsGUI implements Listener {
MiddleClick, ShiftClick, DoubleClick, ShiftRightClick, LeftClick, RightClick, LeftClickOutside
}
public ChestSortSettingsGUI(ChestSortPlugin plugin) {
public SettingsGUI(ChestSortPlugin plugin) {
this.plugin=plugin;
}
@ -88,7 +88,7 @@ public class ChestSortSettingsGUI implements Listener {
public void openGUI(Player player) {
Inventory inventory = createGUI("ChestSort", player);
ChestSortPlayerSetting setting = plugin.perPlayerSettings.get(player.getUniqueId().toString());
PlayerSetting setting = plugin.perPlayerSettings.get(player.getUniqueId().toString());
if(plugin.getConfig().getBoolean("allow-sorting-hotkeys")) {
inventory.setItem(slotMiddleClick, getItem(setting.middleClick, Hotkey.MiddleClick));
@ -122,7 +122,7 @@ public class ChestSortSettingsGUI implements Listener {
}
Player p = (Player) event.getWhoClicked();
plugin.registerPlayerIfNeeded(p);
ChestSortPlayerSetting setting = plugin.perPlayerSettings.get(p.getUniqueId().toString());
PlayerSetting setting = plugin.perPlayerSettings.get(p.getUniqueId().toString());
if(setting.guiInventory==null) {
return;
@ -146,26 +146,26 @@ public class ChestSortSettingsGUI implements Listener {
}
if(event.getSlot() == ChestSortSettingsGUI.slotMiddleClick) {
if(event.getSlot() == SettingsGUI.slotMiddleClick) {
setting.toggleMiddleClick();
plugin.settingsGUI.openGUI(p);
}
else if(event.getSlot() == ChestSortSettingsGUI.slotShiftClick) {
else if(event.getSlot() == SettingsGUI.slotShiftClick) {
setting.toggleShiftClick();
plugin.settingsGUI.openGUI(p);
} else if(event.getSlot() == ChestSortSettingsGUI.slotDoubleClick) {
} else if(event.getSlot() == SettingsGUI.slotDoubleClick) {
setting.toggleDoubleClick();
plugin.settingsGUI.openGUI(p);
} else if(event.getSlot() == ChestSortSettingsGUI.slotLeftClickFromOutside) {
} else if(event.getSlot() == SettingsGUI.slotLeftClickFromOutside) {
setting.toggleLeftClickOutside();
plugin.settingsGUI.openGUI(p);
} else if(event.getSlot() == ChestSortSettingsGUI.slotShiftRightClick) {
} else if(event.getSlot() == SettingsGUI.slotShiftRightClick) {
setting.toggleShiftRightClick();
plugin.settingsGUI.openGUI(p);
} else if(event.getSlot() == ChestSortSettingsGUI.slotLeftClick) {
} else if(event.getSlot() == SettingsGUI.slotLeftClick) {
setting.toggleLeftClick();
plugin.settingsGUI.openGUI(p);
} else if(event.getSlot() == ChestSortSettingsGUI.slotRightClick) {
} else if(event.getSlot() == SettingsGUI.slotRightClick) {
setting.toggleRightClick();
plugin.settingsGUI.openGUI(p);
}

View File

@ -2,7 +2,7 @@ package de.jeff_media.chestsort.handlers;
import de.jeff_media.chestsort.ChestSortEvent;
import de.jeff_media.chestsort.ChestSortPlugin;
import de.jeff_media.chestsort.data.ChestSortCategory;
import de.jeff_media.chestsort.data.Category;
import de.jeff_media.chestsort.hooks.CrackShotHook;
import de.jeff_media.chestsort.hooks.InventoryPagesHook;
import de.jeff_media.chestsort.hooks.SlimeFunHook;
@ -57,7 +57,7 @@ public class ChestSortOrganizer {
final CrackShotHook crackShotHook;
final InventoryPagesHook inventoryPagesHook;
// We store a list of all Category objects
public final ArrayList<ChestSortCategory> categories = new ArrayList<>();
public final ArrayList<Category> categories = new ArrayList<>();
final ArrayList<String> stickyCategoryNames = new ArrayList<>();
public ChestSortOrganizer(ChestSortPlugin plugin) {
@ -83,7 +83,7 @@ public class ChestSortOrganizer {
plugin.getLogger().info("Loading category file " + file.getName());
}
try {
ChestSortCategory category = new ChestSortCategory(categoryName, loadCategoryFile(file));
Category category = new Category(categoryName, loadCategoryFile(file));
categories.add(category);
if (plugin.debug) {
plugin.getLogger().info("Loaded category file " + file.getName() + " ("
@ -98,7 +98,7 @@ public class ChestSortOrganizer {
// Make categories sticky
for (String catName : stickyCategoryNames) {
for (ChestSortCategory cat : categories) {
for (Category cat : categories) {
if (catName.equalsIgnoreCase(cat.name)) {
cat.setSticky();
}
@ -337,7 +337,7 @@ public class ChestSortOrganizer {
// items when sorting by category)
public CategoryLinePair getCategoryLinePair(String typeName) {
typeName = typeName.toLowerCase();
for (ChestSortCategory cat : categories) {
for (Category cat : categories) {
short matchingLineNumber = cat.matches(typeName);
if (matchingLineNumber != 0) {
return new CategoryLinePair(cat.name, matchingLineNumber);

View File

@ -7,11 +7,11 @@ import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.jetbrains.annotations.NotNull;
public class ChestSortDebugger implements @NotNull Listener {
public class Debugger implements @NotNull Listener {
private final ChestSortPlugin plugin;
public ChestSortDebugger(ChestSortPlugin plugin) {
public Debugger(ChestSortPlugin plugin) {
plugin.getLogger().warning("=======================================");
plugin.getLogger().warning(" CHESTSORT DEBUG MODE ACTIVATED!");
plugin.getLogger().warning("Only use this for development purposes!");

View File

@ -1,30 +1,29 @@
package de.jeff_media.chestsort.handlers;
import de.jeff_media.chestsort.ChestSortPlugin;
import de.jeff_media.chestsort.data.ChestSortPlayerSetting;
import de.jeff_media.chestsort.data.PlayerSetting;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.Nullable;
import java.io.File;
import java.io.IOException;
import java.util.logging.FileHandler;
import java.util.logging.Logger;
import java.util.logging.SimpleFormatter;
public class ChestSortLogger {
public class Logger {
ChestSortPlugin plugin;
boolean log;
Logger logger;
java.util.logging.Logger logger;
public ChestSortLogger(ChestSortPlugin plugin, boolean log) {
public Logger(ChestSortPlugin plugin, boolean log) {
if(!log) return;
plugin.getLogger().info("=======================================");
plugin.getLogger().info(" CHESTSORT LOGGER ACTIVATED!");
plugin.getLogger().info("=======================================");
this.plugin=plugin;
this.log=log;
logger = Logger.getLogger("ChestSortLogger");
logger = java.util.logging.Logger.getLogger("ChestSortLogger");
logger.setUseParentHandlers(false);
FileHandler fh;
try {
@ -39,7 +38,7 @@ public class ChestSortLogger {
private String getPlayerSettings(Player p) {
if(plugin.perPlayerSettings.containsKey(p.getUniqueId().toString())) {
ChestSortPlayerSetting s = plugin.perPlayerSettings.get(p.getUniqueId().toString());
PlayerSetting s = plugin.perPlayerSettings.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 {

View File

@ -2,10 +2,10 @@ package de.jeff_media.chestsort.listeners;
import de.jeff_media.chestsort.ChestSortEvent;
import de.jeff_media.chestsort.config.Messages;
import de.jeff_media.chestsort.handlers.ChestSortLogger;
import de.jeff_media.chestsort.handlers.Logger;
import de.jeff_media.chestsort.ChestSortPlugin;
import de.jeff_media.chestsort.ISortable;
import de.jeff_media.chestsort.data.ChestSortPlayerSetting;
import de.jeff_media.chestsort.data.PlayerSetting;
import de.jeff_media.chestsort.hooks.*;
import de.jeff_media.chestsort.utils.LlamaUtils;
import net.md_5.bungee.api.ChatMessageType;
@ -18,7 +18,6 @@ import org.bukkit.entity.ChestedHorse;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryCloseEvent;
@ -34,9 +33,8 @@ import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack;
import java.util.HashMap;
import java.util.Map;
public class ChestSortListener implements Listener {
public class Listener implements org.bukkit.event.Listener {
final ChestSortPlugin plugin;
public final MinepacksHook minepacksHook;
@ -44,7 +42,7 @@ public class ChestSortListener implements Listener {
final CrateReloadedHook crateReloadedHook;
final GoldenCratesHook goldenCratesHook;
public ChestSortListener(ChestSortPlugin plugin) {
public Listener(ChestSortPlugin plugin) {
this.plugin = plugin;
this.minepacksHook = new MinepacksHook(plugin);
this.headDatabaseHook = new HeadDatabaseHook(plugin);
@ -61,7 +59,7 @@ public class ChestSortListener implements Listener {
Block clickedBlock = event.getClickedBlock();
if(!(clickedBlock.getState() instanceof Container)) return;
plugin.registerPlayerIfNeeded(event.getPlayer());
ChestSortPlayerSetting playerSetting = plugin.getPlayerSetting(event.getPlayer());
PlayerSetting playerSetting = plugin.getPlayerSetting(event.getPlayer());
if(!playerSetting.leftClickOutside) return;
Container containerState = (Container) clickedBlock.getState();
Inventory inventory = containerState.getInventory();
@ -107,7 +105,7 @@ public class ChestSortListener implements Listener {
if (!minepacksHook.isMinepacksBackpack(inv)) return;
if (!p.hasPermission("chestsort.use")) return;
plugin.registerPlayerIfNeeded(p);
ChestSortPlayerSetting setting = plugin.perPlayerSettings.get(p.getUniqueId().toString());
PlayerSetting setting = plugin.perPlayerSettings.get(p.getUniqueId().toString());
if (!setting.sortingEnabled) return;
plugin.organizer.sortInventory(inv);
}
@ -150,13 +148,13 @@ public class ChestSortListener implements Listener {
}
plugin.registerPlayerIfNeeded(p);
ChestSortPlayerSetting setting = plugin.perPlayerSettings.get(p.getUniqueId().toString());
PlayerSetting setting = plugin.perPlayerSettings.get(p.getUniqueId().toString());
if (!setting.invSortingEnabled) {
plugin.debug("auto inv sorting not enabled for player "+p.getName());
return;
}
plugin.lgr.logSort(p, ChestSortLogger.SortCause.INV_CLOSE);
plugin.lgr.logSort(p, Logger.SortCause.INV_CLOSE);
plugin.organizer.sortInventory(p.getInventory(), 9, 35);
@ -196,7 +194,7 @@ public class ChestSortListener implements Listener {
// Finally call the Organizer to sort the inventory
plugin.lgr.logSort(p, ChestSortLogger.SortCause.CONT_CLOSE);
plugin.lgr.logSort(p, Logger.SortCause.CONT_CLOSE);
// Llama inventories need special start/end slots
if (LlamaUtils.belongsToLlama(event.getInventory())) {
@ -246,7 +244,7 @@ public class ChestSortListener implements Listener {
// Finally call the Organizer to sort the inventory
plugin.lgr.logSort(p, ChestSortLogger.SortCause.CONT_OPEN);
plugin.lgr.logSort(p, Logger.SortCause.CONT_OPEN);
// Llama inventories need special start/end slots
@ -316,7 +314,7 @@ public class ChestSortListener implements 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
ChestSortPlayerSetting setting = plugin.perPlayerSettings.get(p.getUniqueId().toString());
PlayerSetting setting = plugin.perPlayerSettings.get(p.getUniqueId().toString());
// Show "how to enable ChestSort" message when ALL of the following criteria are
// met:
@ -373,7 +371,7 @@ public class ChestSortListener implements Listener {
// Finally call the Organizer to sort the inventory
plugin.lgr.logSort(p, ChestSortLogger.SortCause.EC_OPEN);
plugin.lgr.logSort(p, Logger.SortCause.EC_OPEN);
plugin.organizer.sortInventory(event.getInventory());
}
@ -436,9 +434,9 @@ public class ChestSortListener implements Listener {
InventoryHolder holder = event.getClickedInventory().getHolder();
boolean sort = false;
ChestSortLogger.SortCause cause = null;
Logger.SortCause cause = null;
ChestSortPlayerSetting setting = plugin.perPlayerSettings.get(p.getUniqueId().toString());
PlayerSetting setting = plugin.perPlayerSettings.get(p.getUniqueId().toString());
// Do not sort the GUI inventory
if (event.getClickedInventory() == setting.guiInventory) {
@ -455,7 +453,7 @@ public class ChestSortListener implements Listener {
switch (event.getClick()) {
case MIDDLE:
cause = ChestSortLogger.SortCause.H_MIDDLE;
cause = Logger.SortCause.H_MIDDLE;
//if(plugin.getConfig().getBoolean("hotkeys.middle-click")) {
if (setting.middleClick) {
if (event.getWhoClicked().getGameMode() != GameMode.CREATIVE) {
@ -469,7 +467,7 @@ public class ChestSortListener implements Listener {
break;
case DOUBLE_CLICK:
if(event.isShiftClick()) return;
cause = ChestSortLogger.SortCause.H_DOUBLE;
cause = Logger.SortCause.H_DOUBLE;
//if(plugin.getConfig().getBoolean("hotkeys.double-click")) {
if (setting.doubleClick) {
// We need getCursor() instead of getCurrentItem(), because after picking up the item, it is gone into the cursor
@ -479,7 +477,7 @@ public class ChestSortListener implements Listener {
}
break;
case SHIFT_LEFT:
cause = ChestSortLogger.SortCause.H_SHIFT;
cause = Logger.SortCause.H_SHIFT;
//if(plugin.getConfig().getBoolean("hotkeys.shift-click")) {
if (setting.shiftClick) {
if (event.getCurrentItem() == null || (event.getCurrentItem() != null && event.getCurrentItem().getType() == Material.AIR)) {
@ -488,7 +486,7 @@ public class ChestSortListener implements Listener {
}
break;
case SHIFT_RIGHT:
cause = ChestSortLogger.SortCause.H_SHIFTRIGHT;
cause = Logger.SortCause.H_SHIFTRIGHT;
//if(plugin.getConfig().getBoolean("hotkeys.shift-right-click")) {
if (setting.shiftRightClick) {
if (event.getCurrentItem() == null || (event.getCurrentItem() != null && event.getCurrentItem().getType() == Material.AIR)) {
@ -633,7 +631,7 @@ public class ChestSortListener implements Listener {
if (!p.hasPermission("chestsort.use")) return;
plugin.registerPlayerIfNeeded(p);
ChestSortPlayerSetting setting = plugin.perPlayerSettings.get(p.getUniqueId().toString());
PlayerSetting setting = plugin.perPlayerSettings.get(p.getUniqueId().toString());
ChestSortEvent chestSortEvent = new ChestSortEvent(e.getInventory());
@ -651,9 +649,9 @@ public class ChestSortListener implements Listener {
}
if (e.isLeftClick() && setting.leftClick) {
plugin.lgr.logSort(p, ChestSortLogger.SortCause.H_LEFT);
if (setting.getCurrentDoubleClick(plugin, ChestSortPlayerSetting.DoubleClickType.LEFT_CLICK)
== ChestSortPlayerSetting.DoubleClickType.LEFT_CLICK) {
plugin.lgr.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());
@ -663,9 +661,9 @@ public class ChestSortListener implements Listener {
}
} else if (e.isRightClick() && setting.rightClick) {
plugin.lgr.logSort(p, ChestSortLogger.SortCause.H_RIGHT);
if (setting.getCurrentDoubleClick(plugin, ChestSortPlayerSetting.DoubleClickType.RIGHT_CLICK)
== ChestSortPlayerSetting.DoubleClickType.RIGHT_CLICK) {
plugin.lgr.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);

View File

@ -4,11 +4,11 @@ import de.jeff_media.chestsort.ChestSortPlugin;
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import org.bukkit.entity.Player;
public class ChestSortPlaceholders extends PlaceholderExpansion {
public class Placeholders extends PlaceholderExpansion {
private ChestSortPlugin main;
public ChestSortPlaceholders(ChestSortPlugin main){
public Placeholders(ChestSortPlugin main){
this.main = main;
}