moved classes to packages

This commit is contained in:
mfnalex 2021-05-30 20:52:40 +02:00
parent e3921c8347
commit 8abe5206d6
17 changed files with 172 additions and 137 deletions

View File

@ -28,10 +28,24 @@
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.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.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.utils.Utils;
import de.jeff_media.jefflib.JeffLib;
@ -45,7 +59,6 @@ import org.bukkit.Material;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.bukkit.inventory.Inventory;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
@ -54,33 +67,33 @@ import java.util.*;
public class ChestSortPlugin extends JavaPlugin {
private static double updateCheckInterval = 4 * 60 * 60; // in seconds. We check on startup and every 4 hours
final int currentConfigVersion = 50;
final boolean hotkeyGUI = true;
public static double updateCheckInterval = 4 * 60 * 60; // in seconds. We check on startup and every 4 hours
public final int currentConfigVersion = 50;
public final boolean hotkeyGUI = true;
public EnderContainersHook enderContainersHook;
public GenericGUIHook genericHook;
public boolean hookCrackShot = false;
public boolean hookInventoryPages = false;
public boolean hookMinepacks = false;
public PlayerVaultsHook playerVaultsHook;
protected boolean debug = false;
ArrayList<String> disabledWorlds;
HashMap<UUID, Long> hotkeyCooldown;
ChestSortLogger lgr;
ChestSortListener listener;
public boolean debug = false;
public ArrayList<String> disabledWorlds;
public HashMap<UUID, Long> hotkeyCooldown;
public ChestSortLogger lgr;
public ChestSortListener listener;
// 1.14.4 = 1_14_R1
// 1.8.0 = 1_8_R1
int mcMinorVersion; // 14 for 1.14, 13 for 1.13, ...
String mcVersion; // 1.13.2 = 1_13_R2
ChestSortMessages messages;
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;
Map<String, ChestSortPlayerSetting> perPlayerSettings = new HashMap<>();
ChestSortPermissionsHandler permissionsHandler;
ChestSortSettingsGUI settingsGUI;
String sortingMethod;
UpdateChecker updateChecker;
boolean usingMatchingConfig = true;
boolean verbose = true;
public Map<String, ChestSortPlayerSetting> perPlayerSettings = new HashMap<>();
public ChestSortPermissionsHandler permissionsHandler;
public ChestSortSettingsGUI settingsGUI;
public String sortingMethod;
public UpdateChecker updateChecker;
public boolean usingMatchingConfig = true;
public boolean verbose = true;
private static ChestSortPlugin instance;
public static ChestSortPlugin getInstance() {
@ -209,11 +222,11 @@ public class ChestSortPlugin extends JavaPlugin {
if (perPlayerSettings == null) {
perPlayerSettings = new HashMap<>();
}
listener.plugin.registerPlayerIfNeeded(p);
registerPlayerIfNeeded(p);
return perPlayerSettings.get(p.getUniqueId().toString()).sortingEnabled;
}
void load(boolean reload) {
public void load(boolean reload) {
if (reload) {
unregisterAllPlayers();
@ -248,7 +261,7 @@ public class ChestSortPlugin extends JavaPlugin {
verbose = getConfig().getBoolean("verbose");
lgr = new ChestSortLogger(this, getConfig().getBoolean("log"));
messages = new ChestSortMessages(this);
messages = new Messages(this);
organizer = new ChestSortOrganizer(this);
settingsGUI = new ChestSortSettingsGUI(this);
try {
@ -423,7 +436,7 @@ public class ChestSortPlugin extends JavaPlugin {
}
void registerPlayerIfNeeded(Player p) {
public void registerPlayerIfNeeded(Player p) {
// Players are stored by their UUID, so that name changes don't break player's
// settings
UUID uniqueId = p.getUniqueId();
@ -652,7 +665,7 @@ public class ChestSortPlugin extends JavaPlugin {
}
// Unregister a player and save their settings in the playerdata folder
void unregisterPlayer(Player p) {
public void unregisterPlayer(Player p) {
// File will be named by the player's uuid. This will prevent problems on player
// name changes.
UUID uniqueId = p.getUniqueId();

View File

@ -1,5 +1,6 @@
package de.jeff_media.chestsort;
package de.jeff_media.chestsort.commands;
import de.jeff_media.chestsort.ChestSortPlugin;
import de.jeff_media.jefflib.NBTAPI;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;

View File

@ -1,5 +1,9 @@
package de.jeff_media.chestsort;
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.ChestSortPlugin;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
@ -10,9 +14,9 @@ import org.jetbrains.annotations.NotNull;
public class ChestSortChestSortCommand implements CommandExecutor {
final ChestSortPlugin plugin;
private final ChestSortPlugin plugin;
ChestSortChestSortCommand(ChestSortPlugin plugin) {
public ChestSortChestSortCommand(ChestSortPlugin plugin) {
this.plugin = plugin;
}
@ -63,7 +67,7 @@ public class ChestSortChestSortCommand implements CommandExecutor {
}
}
sender.sendMessage(plugin.messages.MSG_PLAYERSONLY);
sender.sendMessage(Messages.MSG_PLAYERSONLY);
return true;
}
@ -79,7 +83,7 @@ public class ChestSortChestSortCommand implements CommandExecutor {
if(args[0].equalsIgnoreCase("hotkey") || args[0].equalsIgnoreCase("hotkeys")) {
if(!plugin.hotkeyGUI) {
p.sendMessage(plugin.messages.MSG_ERR_HOTKEYSDISABLED);
p.sendMessage(Messages.MSG_ERR_HOTKEYSDISABLED);
return true;
}
@ -97,7 +101,7 @@ public class ChestSortChestSortCommand implements CommandExecutor {
&& !args[0].equalsIgnoreCase("toggle")
&& !args[0].equalsIgnoreCase("on")
&& !args[0].equalsIgnoreCase("off")) {
p.sendMessage(String.format(plugin.messages.MSG_INVALIDOPTIONS,"\""+args[0]+"\"","\"toggle\", \"on\", \"off\", \"hotkeys\""));
p.sendMessage(String.format(Messages.MSG_INVALIDOPTIONS,"\""+args[0]+"\"","\"toggle\", \"on\", \"off\", \"hotkeys\""));
return true;
}
if(args.length==0 || args[0].equalsIgnoreCase("toggle")) {
@ -112,9 +116,9 @@ public class ChestSortChestSortCommand implements CommandExecutor {
setting.hasSeenMessage=true;
if (setting.sortingEnabled) {
p.sendMessage(plugin.messages.MSG_ACTIVATED);
p.sendMessage(Messages.MSG_ACTIVATED);
} else {
p.sendMessage(plugin.messages.MSG_DEACTIVATED);
p.sendMessage(Messages.MSG_DEACTIVATED);
}
return true;

View File

@ -1,5 +1,9 @@
package de.jeff_media.chestsort;
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.ChestSortPlugin;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
@ -11,7 +15,7 @@ public class ChestSortInvSortCommand implements CommandExecutor {
final ChestSortPlugin plugin;
ChestSortInvSortCommand(ChestSortPlugin plugin) {
public ChestSortInvSortCommand(ChestSortPlugin plugin) {
this.plugin = plugin;
}
@ -27,7 +31,7 @@ public class ChestSortInvSortCommand implements CommandExecutor {
if (!(sender instanceof Player)) {
if(args.length==0) {
sender.sendMessage(plugin.messages.MSG_PLAYERSONLY);
sender.sendMessage(Messages.MSG_PLAYERSONLY);
return true;
}
// Console can sort player's inventories
@ -44,7 +48,7 @@ public class ChestSortInvSortCommand implements CommandExecutor {
args = new String[0];
}
//sender.sendMessage(plugin.messages.MSG_PLAYERSONLY);
//sender.sendMessage(Messages.MSG_PLAYERSONLY);
//return true;
}
@ -73,29 +77,29 @@ public class ChestSortInvSortCommand implements CommandExecutor {
end=35;
} else if(args[0].equalsIgnoreCase("on")) {
setting.enableInvSorting();
p.sendMessage(plugin.messages.MSG_INVACTIVATED);
p.sendMessage(Messages.MSG_INVACTIVATED);
return true;
} else if(args[0].equalsIgnoreCase("off")) {
setting.disableInvSorting();
p.sendMessage(plugin.messages.MSG_INVDEACTIVATED);
p.sendMessage(Messages.MSG_INVDEACTIVATED);
return true;
} else if(args[0].equalsIgnoreCase("toggle")) {
setting.toggleInvSorting();
if(setting.invSortingEnabled) {
p.sendMessage(plugin.messages.MSG_INVACTIVATED);
p.sendMessage(Messages.MSG_INVACTIVATED);
} else {
p.sendMessage(plugin.messages.MSG_INVDEACTIVATED);
p.sendMessage(Messages.MSG_INVDEACTIVATED);
}
return true;
}
else {
p.sendMessage(String.format(plugin.messages.MSG_INVALIDOPTIONS,"\""+args[0]+"\"","\"on\", \"off\", \"toggle\", \"inv\", \"hotbar\", \"all\""));
p.sendMessage(String.format(Messages.MSG_INVALIDOPTIONS,"\""+args[0]+"\"","\"on\", \"off\", \"toggle\", \"inv\", \"hotbar\", \"all\""));
return true;
}
}
plugin.lgr.logSort(p, ChestSortLogger.SortCause.CMD_ISORT);
plugin.organizer.sortInventory(p.getInventory(), start, end);
p.sendMessage(plugin.messages.MSG_PLAYERINVSORTED);
p.sendMessage(Messages.MSG_PLAYERINVSORTED);
return true;

View File

@ -1,4 +1,4 @@
package de.jeff_media.chestsort;
package de.jeff_media.chestsort.commands;
import java.util.ArrayList;
import java.util.List;

View File

@ -1,4 +1,4 @@
package de.jeff_media.chestsort;
package de.jeff_media.chestsort.config;
import java.io.*;
import java.nio.charset.StandardCharsets;
@ -7,6 +7,7 @@ import java.util.ArrayList;
import java.util.Map;
import java.util.Scanner;
import de.jeff_media.chestsort.ChestSortPlugin;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
@ -25,7 +26,7 @@ public class ChestSortConfigUpdater {
// config version
// Don't worry! Your changes will be kept
void updateConfig() {
public void updateConfig() {
// hotkeys has been renamed to sorting-hotkeys
if(plugin.getConfig().isSet("hotkeys.middle-click")) {

View File

@ -1,9 +1,10 @@
package de.jeff_media.chestsort;
package de.jeff_media.chestsort.config;
import de.jeff_media.chestsort.ChestSortPlugin;
import org.bukkit.ChatColor;
public class ChestSortMessages {
final String MSG_GUI_LEFTCLICKOUTSIDE, MSG_CONTAINER_SORTED;
public class Messages {
public static String MSG_GUI_LEFTCLICKOUTSIDE, MSG_CONTAINER_SORTED;
// Messages can be customized in the config.yml
// To avoid problems with missing messages in the config, the default messages
@ -12,18 +13,18 @@ public class ChestSortMessages {
// When creating pull requests that feature a message to the player, please
// stick to this scheme
final ChestSortPlugin plugin;
public static ChestSortPlugin plugin;
final String MSG_ACTIVATED, MSG_DEACTIVATED, MSG_INVACTIVATED, MSG_INVDEACTIVATED, MSG_COMMANDMESSAGE, MSG_COMMANDMESSAGE2, MSG_PLAYERSONLY,
public static String MSG_ACTIVATED, MSG_DEACTIVATED, MSG_INVACTIVATED, MSG_INVDEACTIVATED, MSG_COMMANDMESSAGE, MSG_COMMANDMESSAGE2, MSG_PLAYERSONLY,
MSG_PLAYERINVSORTED, MSG_INVALIDOPTIONS;
final String MSG_GUI_ENABLED, MSG_GUI_DISABLED;
final String MSG_GUI_MIDDLECLICK, MSG_GUI_SHIFTCLICK, MSG_GUI_DOUBLECLICK, MSG_GUI_SHIFTRIGHTCLICK, MSG_GUI_LEFTCLICK, MSG_GUI_RIGHTCLICK;
final String MSG_ERR_HOTKEYSDISABLED;
public static String MSG_GUI_ENABLED, MSG_GUI_DISABLED;
ChestSortMessages(ChestSortPlugin plugin) {
public static String MSG_GUI_MIDDLECLICK, MSG_GUI_SHIFTCLICK, MSG_GUI_DOUBLECLICK, MSG_GUI_SHIFTRIGHTCLICK, MSG_GUI_LEFTCLICK, MSG_GUI_RIGHTCLICK;
public static String MSG_ERR_HOTKEYSDISABLED;
public Messages(ChestSortPlugin plugin) {
this.plugin = plugin;
MSG_CONTAINER_SORTED = ChatColor.translateAlternateColorCodes('&', plugin.getConfig()

View File

@ -1,6 +1,8 @@
package de.jeff_media.chestsort.utils;
package de.jeff_media.chestsort.data;
import de.jeff_media.chestsort.utils.Utils;
public class CategoryLinePair {
final String categoryName;
final String formattedPosition;
@ -13,7 +15,7 @@ public class CategoryLinePair {
public CategoryLinePair(String categoryName,short position,boolean sticky) {
this.categoryName=categoryName;
this.formattedPosition=Utils.shortToStringWithLeadingZeroes(position);
this.formattedPosition= Utils.shortToStringWithLeadingZeroes(position);
this.position=position;
this.sticky=sticky;
}

View File

@ -1,4 +1,4 @@
package de.jeff_media.chestsort;
package de.jeff_media.chestsort.data;
import de.jeff_media.chestsort.utils.TypeMatchPositionPair;
@ -12,16 +12,16 @@ public class ChestSortCategory implements Comparable<ChestSortCategory>{
// "COARSE_DIRT" will not match the typeMatch "dirt"
// "COARSE_DIRT" will match the typeMatch "*dirt"
final String name;
public final String name;
boolean sticky = false;
final TypeMatchPositionPair[] typeMatches;
public final TypeMatchPositionPair[] typeMatches;
ChestSortCategory(String name, TypeMatchPositionPair[] typeMatchPositionPairs) {
public ChestSortCategory(String name, TypeMatchPositionPair[] typeMatchPositionPairs) {
this.name = name;
this.typeMatches = typeMatchPositionPairs;
}
void setSticky() {
public void setSticky() {
this.sticky=true;
}
@ -31,7 +31,7 @@ public class ChestSortCategory implements Comparable<ChestSortCategory>{
// Checks whether a the given itemname fits into this category and returns the line number. 0 means not found
short matches(String itemname) {
public short matches(String itemname) {
// Very, very simple wildcard checks
for (TypeMatchPositionPair typeMatchPositionPair : typeMatches) {

View File

@ -1,5 +1,6 @@
package de.jeff_media.chestsort;
package de.jeff_media.chestsort.data;
import de.jeff_media.chestsort.ChestSortPlugin;
import org.bukkit.Bukkit;
import org.bukkit.inventory.Inventory;
@ -17,23 +18,29 @@ public class ChestSortPlayerSetting {
public boolean invSortingEnabled;
// Hotkey settings
boolean middleClick, shiftClick, doubleClick, shiftRightClick, leftClick, rightClick, leftClickOutside;
public boolean middleClick;
public boolean shiftClick;
public boolean doubleClick;
public boolean shiftRightClick;
public boolean leftClick;
public boolean rightClick;
public boolean leftClickOutside;
Inventory guiInventory = null;
public Inventory guiInventory = null;
// Did we already show the message how to activate sorting?
boolean hasSeenMessage = false;
public boolean hasSeenMessage = false;
// Do we have to save these settings?
boolean changed;
public boolean changed;
DoubleClickType currentDoubleClick = DoubleClickType.NONE;
enum DoubleClickType {
public enum DoubleClickType {
NONE, RIGHT_CLICK, LEFT_CLICK
}
ChestSortPlayerSetting(boolean sortingEnabled, boolean invSortingEnabled, boolean middleClick, boolean shiftClick, boolean doubleClick, boolean shiftRightClick, boolean leftClick, boolean rightClick, boolean leftCLickOutside, boolean changed) {
public ChestSortPlayerSetting(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;
@ -46,7 +53,7 @@ public class ChestSortPlayerSetting {
this.changed = changed;
}
DoubleClickType getCurrentDoubleClick(ChestSortPlugin plugin, DoubleClickType click) {
public DoubleClickType getCurrentDoubleClick(ChestSortPlugin plugin, DoubleClickType click) {
if(click == DoubleClickType.NONE) return DoubleClickType.NONE;
if(currentDoubleClick == click) {
currentDoubleClick = DoubleClickType.NONE;
@ -60,55 +67,55 @@ public class ChestSortPlayerSetting {
return DoubleClickType.NONE;
}
void toggleMiddleClick() {
public void toggleMiddleClick() {
middleClick = !middleClick;
changed = true;
}
void toggleShiftClick() {
public void toggleShiftClick() {
shiftClick = !shiftClick;
changed = true;
}
void toggleDoubleClick() {
public void toggleDoubleClick() {
doubleClick = !doubleClick;
changed = true;
}
void toggleShiftRightClick() {
public void toggleShiftRightClick() {
shiftRightClick = !shiftRightClick;
changed = true;
}
void toggleLeftClickOutside() {
public void toggleLeftClickOutside() {
leftClickOutside = !leftClickOutside;
changed = true;
}
void toggleLeftClick() {
public void toggleLeftClick() {
leftClick = !leftClick;
changed = true;
}
void toggleRightClick() {
public void toggleRightClick() {
rightClick = !rightClick;
changed = true;
}
void enableChestSorting() {
public void enableChestSorting() {
sortingEnabled = true;
changed = true;
}
void disableChestSorting() {
public void disableChestSorting() {
sortingEnabled = false;
changed = true;
}
void toggleChestSorting() {
public void toggleChestSorting() {
sortingEnabled = !sortingEnabled;
changed = true;
}
void enableInvSorting() {
public void enableInvSorting() {
invSortingEnabled = true;
changed = true;
}
void disableInvSorting() {
public void disableInvSorting() {
invSortingEnabled = false;
changed = true;
}
void toggleInvSorting() {
public void toggleInvSorting() {
invSortingEnabled = !invSortingEnabled;
changed = true;
}

View File

@ -1,5 +1,8 @@
package de.jeff_media.chestsort;
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 org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
@ -32,7 +35,7 @@ public class ChestSortSettingsGUI implements Listener {
MiddleClick, ShiftClick, DoubleClick, ShiftRightClick, LeftClick, RightClick, LeftClickOutside
}
ChestSortSettingsGUI(ChestSortPlugin plugin) {
public ChestSortSettingsGUI(ChestSortPlugin plugin) {
this.plugin=plugin;
}
@ -42,36 +45,36 @@ public class ChestSortSettingsGUI implements Listener {
if(active) {
is = new ItemStack(green);
suffix = plugin.messages.MSG_GUI_ENABLED;
suffix = Messages.MSG_GUI_ENABLED;
}
else {
is = new ItemStack(red);
suffix = plugin.messages.MSG_GUI_DISABLED;
suffix = Messages.MSG_GUI_DISABLED;
}
ItemMeta meta = is.getItemMeta();
switch(hotkey) {
case MiddleClick:
meta.setDisplayName(ChatColor.RESET + plugin.messages.MSG_GUI_MIDDLECLICK + ": " + suffix);
meta.setDisplayName(ChatColor.RESET + Messages.MSG_GUI_MIDDLECLICK + ": " + suffix);
break;
case ShiftClick:
meta.setDisplayName(ChatColor.RESET + plugin.messages.MSG_GUI_SHIFTCLICK + ": " + suffix);
meta.setDisplayName(ChatColor.RESET + Messages.MSG_GUI_SHIFTCLICK + ": " + suffix);
break;
case DoubleClick:
meta.setDisplayName(ChatColor.RESET + plugin.messages.MSG_GUI_DOUBLECLICK + ": " + suffix);
meta.setDisplayName(ChatColor.RESET + Messages.MSG_GUI_DOUBLECLICK + ": " + suffix);
break;
case ShiftRightClick:
meta.setDisplayName(ChatColor.RESET + plugin.messages.MSG_GUI_SHIFTRIGHTCLICK + ": " + suffix);
meta.setDisplayName(ChatColor.RESET + Messages.MSG_GUI_SHIFTRIGHTCLICK + ": " + suffix);
break;
case LeftClickOutside:
meta.setDisplayName(ChatColor.RESET + plugin.messages.MSG_GUI_LEFTCLICKOUTSIDE + ": " + suffix);
meta.setDisplayName(ChatColor.RESET + Messages.MSG_GUI_LEFTCLICKOUTSIDE + ": " + suffix);
break;
case LeftClick:
meta.setDisplayName(ChatColor.RESET + plugin.messages.MSG_GUI_LEFTCLICK + ": "+ suffix);
meta.setDisplayName(ChatColor.RESET + Messages.MSG_GUI_LEFTCLICK + ": "+ suffix);
break;
case RightClick:
meta.setDisplayName(ChatColor.RESET + plugin.messages.MSG_GUI_RIGHTCLICK + ": "+ suffix);
meta.setDisplayName(ChatColor.RESET + Messages.MSG_GUI_RIGHTCLICK + ": "+ suffix);
break;
default:
break;
@ -82,7 +85,7 @@ public class ChestSortSettingsGUI implements Listener {
return is;
}
void openGUI(Player player) {
public void openGUI(Player player) {
Inventory inventory = createGUI("ChestSort", player);
ChestSortPlayerSetting setting = plugin.perPlayerSettings.get(player.getUniqueId().toString());
@ -118,7 +121,7 @@ public class ChestSortSettingsGUI implements Listener {
return;
}
Player p = (Player) event.getWhoClicked();
plugin.listener.plugin.registerPlayerIfNeeded(p);
plugin.registerPlayerIfNeeded(p);
ChestSortPlayerSetting setting = plugin.perPlayerSettings.get(p.getUniqueId().toString());
if(setting.guiInventory==null) {

View File

@ -1,5 +1,6 @@
package de.jeff_media.chestsort;
package de.jeff_media.chestsort.handlers;
import de.jeff_media.chestsort.ChestSortPlugin;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
@ -10,7 +11,7 @@ public class ChestSortDebugger implements @NotNull Listener {
private final ChestSortPlugin plugin;
ChestSortDebugger(ChestSortPlugin plugin) {
public ChestSortDebugger(ChestSortPlugin plugin) {
plugin.getLogger().warning("=======================================");
plugin.getLogger().warning(" CHESTSORT DEBUG MODE ACTIVATED!");
plugin.getLogger().warning("Only use this for development purposes!");

View File

@ -1,5 +1,7 @@
package de.jeff_media.chestsort;
package de.jeff_media.chestsort.handlers;
import de.jeff_media.chestsort.ChestSortPlugin;
import de.jeff_media.chestsort.data.ChestSortPlayerSetting;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.Nullable;
@ -15,7 +17,7 @@ public class ChestSortLogger {
boolean log;
Logger logger;
ChestSortLogger(ChestSortPlugin plugin, boolean log) {
public ChestSortLogger(ChestSortPlugin plugin, boolean log) {
if(!log) return;
plugin.getLogger().info("=======================================");
plugin.getLogger().info(" CHESTSORT LOGGER ACTIVATED!");
@ -50,18 +52,18 @@ public class ChestSortLogger {
logger.info(s);
}
void logSort(Player p, @Nullable SortCause cause) {
public void logSort(Player p, @Nullable SortCause cause) {
if(!log) return;
String settings = getPlayerSettings(p);
if(cause==null) cause = SortCause.UNKNOWN;
log(String.format("SORT: Player: %s, Cause: %s, Settings: {%s}",p.getName(),cause.name(),settings));
}
enum SortCause {
public enum SortCause {
UNKNOWN, INV_CLOSE, CONT_CLOSE, CONT_OPEN, EC_OPEN, H_MIDDLE, H_SHIFT, H_DOUBLE, H_SHIFTRIGHT, H_LEFT, H_RIGHT, CMD_ISORT
}
void logPlayerJoin(Player p) {
public void logPlayerJoin(Player p) {
if(!log) return;
String settings = getPlayerSettings(p);
log(String.format("JOIN: Player: %s, Settings: {%s}",p.getName(),settings));

View File

@ -1,12 +1,14 @@
package de.jeff_media.chestsort;
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.hooks.CrackShotHook;
import de.jeff_media.chestsort.hooks.InventoryPagesHook;
import de.jeff_media.chestsort.hooks.SlimeFunHook;
import de.jeff_media.chestsort.utils.CategoryLinePair;
import de.jeff_media.chestsort.data.CategoryLinePair;
import de.jeff_media.chestsort.utils.TypeMatchPositionPair;
import de.jeff_media.chestsort.utils.Utils;
import de.jeff_media.chestsort.ChestSortEvent;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
@ -55,10 +57,10 @@ public class ChestSortOrganizer {
final CrackShotHook crackShotHook;
final InventoryPagesHook inventoryPagesHook;
// We store a list of all Category objects
final ArrayList<ChestSortCategory> categories = new ArrayList<>();
public final ArrayList<ChestSortCategory> categories = new ArrayList<>();
final ArrayList<String> stickyCategoryNames = new ArrayList<>();
ChestSortOrganizer(ChestSortPlugin plugin) {
public ChestSortOrganizer(ChestSortPlugin plugin) {
this.plugin = plugin;
// Load Categories
@ -333,7 +335,7 @@ public class ChestSortOrganizer {
// This method takes a sortable item name and checks all categories for a match
// If none, matches, return "<none>" (it will be put behind all categorized
// items when sorting by category)
CategoryLinePair getCategoryLinePair(String typeName) {
public CategoryLinePair getCategoryLinePair(String typeName) {
typeName = typeName.toLowerCase();
for (ChestSortCategory cat : categories) {
short matchingLineNumber = cat.matches(typeName);
@ -345,7 +347,7 @@ public class ChestSortOrganizer {
}
// Generate a map of "{placeholder}", "sortString" pairs for an ItemStack
Map<String, String> getSortableMap(ItemStack item) {
public Map<String, String> getSortableMap(ItemStack item) {
if (item == null) {
// Empty map for non-item
return new HashMap<String, String>();

View File

@ -1,8 +1,9 @@
package de.jeff_media.chestsort;
package de.jeff_media.chestsort.handlers;
import java.util.HashMap;
import java.util.UUID;
import de.jeff_media.chestsort.ChestSortPlugin;
import org.bukkit.entity.Player;
import org.bukkit.permissions.PermissionAttachment;
@ -11,12 +12,12 @@ public class ChestSortPermissionsHandler {
final HashMap<UUID,PermissionAttachment> permissions;
final ChestSortPlugin plugin;
ChestSortPermissionsHandler(ChestSortPlugin plugin) {
public ChestSortPermissionsHandler(ChestSortPlugin plugin) {
this.plugin = plugin;
this.permissions = new HashMap<>();
}
void addPermissions(Player p) {
public void addPermissions(Player p) {
if(plugin.getConfig().getBoolean("use-permissions")) return;
if(permissions.containsKey(p.getUniqueId())) return;
PermissionAttachment attachment = p.addAttachment(plugin);
@ -25,7 +26,7 @@ public class ChestSortPermissionsHandler {
permissions.put(p.getUniqueId(), attachment);
}
void removePermissions(Player p) {
public void removePermissions(Player p) {
if(plugin.getConfig().getBoolean("use-permissions")) return;
if(!permissions.containsKey(p.getUniqueId())) return;
PermissionAttachment attachment = permissions.get(p.getUniqueId());

View File

@ -1,5 +1,11 @@
package de.jeff_media.chestsort;
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.ChestSortPlugin;
import de.jeff_media.chestsort.ISortable;
import de.jeff_media.chestsort.data.ChestSortPlayerSetting;
import de.jeff_media.chestsort.hooks.*;
import de.jeff_media.chestsort.utils.LlamaUtils;
import net.md_5.bungee.api.ChatMessageType;
@ -33,12 +39,12 @@ import java.util.Map;
public class ChestSortListener implements Listener {
final ChestSortPlugin plugin;
final MinepacksHook minepacksHook;
public final MinepacksHook minepacksHook;
final HeadDatabaseHook headDatabaseHook;
final CrateReloadedHook crateReloadedHook;
final GoldenCratesHook goldenCratesHook;
ChestSortListener(ChestSortPlugin plugin) {
public ChestSortListener(ChestSortPlugin plugin) {
this.plugin = plugin;
this.minepacksHook = new MinepacksHook(plugin);
this.headDatabaseHook = new HeadDatabaseHook(plugin);
@ -60,7 +66,7 @@ public class ChestSortListener implements Listener {
Container containerState = (Container) clickedBlock.getState();
Inventory inventory = containerState.getInventory();
plugin.organizer.sortInventory(inventory);
event.getPlayer().spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(plugin.messages.MSG_CONTAINER_SORTED));
event.getPlayer().spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(Messages.MSG_CONTAINER_SORTED));
}
@EventHandler
@ -323,7 +329,7 @@ public class ChestSortListener implements Listener {
if (!setting.hasSeenMessage) {
setting.hasSeenMessage = true;
if (plugin.getConfig().getBoolean("show-message-when-using-chest")) {
p.sendMessage(plugin.messages.MSG_COMMANDMESSAGE);
p.sendMessage(Messages.MSG_COMMANDMESSAGE);
}
}
return false;
@ -340,7 +346,7 @@ public class ChestSortListener implements Listener {
if (!setting.hasSeenMessage) {
setting.hasSeenMessage = true;
if (plugin.getConfig().getBoolean("show-message-when-using-chest-and-sorting-is-enabled")) {
p.sendMessage(plugin.messages.MSG_COMMANDMESSAGE2);
p.sendMessage(Messages.MSG_COMMANDMESSAGE2);
}
}
}
@ -634,7 +640,7 @@ public class ChestSortListener implements Listener {
chestSortEvent.setPlayer(e.getWhoClicked());
chestSortEvent.setLocation(e.getWhoClicked().getLocation());
chestSortEvent.setSortableMaps(new HashMap<ItemStack, Map<String, String>>());
chestSortEvent.setSortableMaps(new HashMap<>());
for (ItemStack item : e.getInventory().getContents()) {
chestSortEvent.getSortableMaps().put(item, plugin.organizer.getSortableMap(item));
}

View File

@ -73,19 +73,6 @@ public class ChestSortPlaceholders extends PlaceholderExpansion {
return main.getDescription().getVersion();
}
/**
* This is the method called when a placeholder with our identifier
* is found and needs a value.
* <br>We specify the value identifier in this method.
* <br>Since version 2.9.1 can you use OfflinePlayers in your requests.
*
* @param player
* A {@link org.bukkit.Player Player}.
* @param identifier
* A String containing the identifier/value.
*
* @return possibly-null String of the requested identifier.
*/
@Override
public String onPlaceholderRequest(Player player, String identifier){