This commit is contained in:
Sekwah 2021-01-24 03:08:14 +00:00
parent f8e5cced9e
commit 41643caff2
No known key found for this signature in database
GPG Key ID: C3BE2E6C861A461A
15 changed files with 39 additions and 44 deletions

View File

@ -31,11 +31,11 @@ import java.util.stream.Collectors;
public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter { public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
private final List<String> blockMaterialList; private final List<String> blockMaterialList;
private AdvancedPortalsPlugin plugin; private final AdvancedPortalsPlugin plugin;
private int portalArgsStringLength = 0; private int portalArgsStringLength = 0;
private HashSet<String> ignoreExtras = new HashSet<>(Arrays.asList("command.1", "permission")); private final HashSet<String> ignoreExtras = new HashSet<>(Arrays.asList("command.1", "permission"));
// TODO recode the portal args to be put into a hashmap and use a string array // TODO recode the portal args to be put into a hashmap and use a string array
// to store all possible portal arguments. Makes code shorter and possibly more // to store all possible portal arguments. Makes code shorter and possibly more
@ -465,7 +465,7 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
case "gui": case "gui":
// /portal gui remove testarg // /portal gui remove testarg
if (args.length > 1) { if (args.length > 1) {
if (args[1].toLowerCase().equals("remove") && args.length > 2) { if (args[1].equalsIgnoreCase("remove") && args.length > 2) {
sender.sendMessage(""); sender.sendMessage("");
sender.sendMessage(PluginMessages.customPrefixFail sender.sendMessage(PluginMessages.customPrefixFail
+ " Are you sure you would like to remove the portal \u00A7e" + args[2] + " Are you sure you would like to remove the portal \u00A7e" + args[2]
@ -560,7 +560,7 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
String portalName = player.getMetadata("selectedPortal").get(0).asString(); String portalName = player.getMetadata("selectedPortal").get(0).asString();
if (args.length > 1) { if (args.length > 1) {
// TODO add the command autocompletes, add, remove and show // TODO add the command autocompletes, add, remove and show
if (args[1].toLowerCase().equals("add")) { if (args[1].equalsIgnoreCase("add")) {
if (args.length > 2) { if (args.length > 2) {
StringBuilder portalCommand = new StringBuilder(args[2]); StringBuilder portalCommand = new StringBuilder(args[2]);
for (int i = 3; i < args.length; i++) { for (int i = 3; i < args.length; i++) {
@ -579,9 +579,9 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
+ " You must actually specify a command to execute!"); + " You must actually specify a command to execute!");
} }
} else if (args[1].toLowerCase().equals("remove")) { } else if (args[1].equalsIgnoreCase("remove")) {
// Specify what line to remove // Specify what line to remove
} else if (args[1].toLowerCase().equals("show")) { } else if (args[1].equalsIgnoreCase("show")) {
} else { } else {
sender.sendMessage(PluginMessages.customPrefixFail sender.sendMessage(PluginMessages.customPrefixFail
+ " You must specify to \u00A7eadd\u00A7c or \u00A7eremove a command!"); + " You must specify to \u00A7eadd\u00A7c or \u00A7eremove a command!");
@ -728,18 +728,18 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
"\u00A76/" + command + " warp <name> \u00A7a- teleport to warp name", "\u00A76/" + command + " warp <name> \u00A7a- teleport to warp name",
"\u00A76/" + command + " variables \u00A7a- lists all available tags"); "\u00A76/" + command + " variables \u00A7a- lists all available tags");
} else if (args.length > 1) { } else if (args.length > 1) {
if (args[1].toLowerCase().equals("help")) { if (args[1].equalsIgnoreCase("help")) {
sendMenu(sender, "Help Command", sendMenu(sender, "Help Command",
"Shows the help section. You can also use a single argument after it to show the " "Shows the help section. You can also use a single argument after it to show the "
+ "help section for the corresponding command."); + "help section for the corresponding command.");
} else if (args[1].toLowerCase().equals("portalblock")) { } else if (args[1].equalsIgnoreCase("portalblock")) {
sendMenu(sender, "Help Command", "Gives you a special wool block to place portal blocks.", "", sendMenu(sender, "Help Command", "Gives you a special wool block to place portal blocks.", "",
"\u00A7eLeft Click: \u00A76Rotates the hit portal block", "\u00A7eLeft Click: \u00A76Rotates the hit portal block",
"\u00A7eRight Click: \u00A76Placed a portal block"); "\u00A7eRight Click: \u00A76Placed a portal block");
} else if (args[1].toLowerCase().equals("endportalblock")) { } else if (args[1].equalsIgnoreCase("endportalblock")) {
sendMenu(sender, "Help Command", "Gives you a special wool block to place end portal blocks.", "", sendMenu(sender, "Help Command", "Gives you a special wool block to place end portal blocks.", "",
"\u00A7eRight Click: \u00A76Placed a end portal block"); "\u00A7eRight Click: \u00A76Placed a end portal block");
} else if (args[1].toLowerCase().equals("gatewayblock")) { } else if (args[1].equalsIgnoreCase("gatewayblock")) {
sendMenu(sender, "Help Command", "Gives you a special wool block to place gateway blocks.", "", sendMenu(sender, "Help Command", "Gives you a special wool block to place gateway blocks.", "",
"\u00A7eRight Click: \u00A76Placed a gateway block"); "\u00A7eRight Click: \u00A76Placed a gateway block");
} else { } else {
@ -882,11 +882,11 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
autoComplete.add("warp"); autoComplete.add("warp");
} }
if (sender.hasPermission("advancedportals.createportal")) { if (sender.hasPermission("advancedportals.createportal")) {
if (args.length == 1 || (args.length == 2 && args[0].toLowerCase().equals("help"))) { if (args.length == 1 || (args.length == 2 && args[0].equalsIgnoreCase("help"))) {
autoComplete.addAll(Arrays.asList("create", "list", "portalblock", "select", "unselect", "command", autoComplete.addAll(Arrays.asList("create", "list", "portalblock", "select", "unselect", "command",
"selector", "show", "gatewayblock", "endportalblock", "variables", "wand", "disablebeacon", "remove", "rename", "selector", "show", "gatewayblock", "endportalblock", "variables", "wand", "disablebeacon", "remove", "rename",
"help", "bukkitpage", "helppage")); "help", "bukkitpage", "helppage"));
} else if (args[0].toLowerCase().equals("create")) { } else if (args[0].equalsIgnoreCase("create")) {
boolean hasName = false; boolean hasName = false;
boolean hasTriggerBlock = false; boolean hasTriggerBlock = false;
@ -1002,7 +1002,7 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
if (args[args.length - 1].startsWith("desti:") || args[args.length - 1].startsWith("destination:")) { if (args[args.length - 1].startsWith("desti:") || args[args.length - 1].startsWith("destination:")) {
String tagStart = args[args.length - 1].startsWith("desti:") ? "desti:" : "destination:"; String tagStart = args[args.length - 1].startsWith("desti:") ? "desti:" : "destination:";
ConfigAccessor destiConfig = new ConfigAccessor(plugin, "destinations.yml"); ConfigAccessor destiConfig = new ConfigAccessor(plugin, "destinations.yml");
List<Object> destiObj = Arrays.asList(destiConfig.getConfig().getKeys(false).toArray()); Object[] destiObj = destiConfig.getConfig().getKeys(false).toArray();
for (Object object : destiObj) { for (Object object : destiObj) {
autoComplete.add(tagStart + object.toString()); autoComplete.add(tagStart + object.toString());
} }

View File

@ -4,7 +4,7 @@ import com.sekwah.advancedportals.bukkit.config.ConfigAccessor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
public class PluginMessages { public class PluginMessages {
private AdvancedPortalsPlugin plugin; private final AdvancedPortalsPlugin plugin;
public boolean useCustomPrefix = false; public boolean useCustomPrefix = false;
public static String customPrefix = "\u00A7a[\u00A7eAdvancedPortals\u00A7a]"; public static String customPrefix = "\u00A7a[\u00A7eAdvancedPortals\u00A7a]";
public static String customPrefixFail = "\u00A7c[\u00A77AdvancedPortals\u00A7c]"; public static String customPrefixFail = "\u00A7c[\u00A77AdvancedPortals\u00A7c]";

View File

@ -16,10 +16,10 @@ public final class WarpEvent extends Event implements Cancellable {
private boolean cancelled = false; private boolean cancelled = false;
private Player player; private final Player player;
@SuppressWarnings("unused") @SuppressWarnings("unused")
private AdvancedPortal portalData; private final AdvancedPortal portalData;
private boolean hasWarped = false; private boolean hasWarped = false;
@ -75,4 +75,4 @@ public final class WarpEvent extends Event implements Cancellable {
public HandlerList getHandlers() { public HandlerList getHandlers() {
return handlers; return handlers;
} }
} }

View File

@ -11,13 +11,13 @@ public class TagRegistry {
private final AdvancedPortalsPlugin plugin; private final AdvancedPortalsPlugin plugin;
private ArrayList<String> tags = new ArrayList<String>(); private final ArrayList<String> tags = new ArrayList<String>();
private Map<String, TagHandler.Activation> tagActivation = new HashMap<String, TagHandler.Activation>(); private final Map<String, TagHandler.Activation> tagActivation = new HashMap<String, TagHandler.Activation>();
private Map<String, TagHandler.Creation> tagCreation = new HashMap<String, TagHandler.Creation>(); private final Map<String, TagHandler.Creation> tagCreation = new HashMap<String, TagHandler.Creation>();
private Map<String, TagHandler.TagStatus> tagStatus = new HashMap<String, TagHandler.TagStatus>(); private final Map<String, TagHandler.TagStatus> tagStatus = new HashMap<String, TagHandler.TagStatus>();
// TODO the event can be used for general data detection and management, but use a TagHandler to make it so they can register // TODO the event can be used for general data detection and management, but use a TagHandler to make it so they can register
// the individual class to handle. // the individual class to handle.

View File

@ -8,7 +8,7 @@ public class ActivationData {
private WarpedStatus warpStatus = WarpedStatus.INACTIVE; private WarpedStatus warpStatus = WarpedStatus.INACTIVE;
private Portal activePortal; private final Portal activePortal;
public ActivationData(Portal portal){ public ActivationData(Portal portal){
this.activePortal = portal; this.activePortal = portal;
@ -56,7 +56,7 @@ public class ActivationData {
/** /**
* Nothing has activated on the portal. * Nothing has activated on the portal.
*/ */
INACTIVE; INACTIVE
} }
} }

View File

@ -12,7 +12,7 @@ public class ConfigHelper {
public static String DISABLE_GATEWAY_BEAM = "DisableGatewayBeam"; public static String DISABLE_GATEWAY_BEAM = "DisableGatewayBeam";
private FileConfiguration config; private final FileConfiguration config;
public ConfigHelper(FileConfiguration config) { public ConfigHelper(FileConfiguration config) {
this.config = config; this.config = config;

View File

@ -16,7 +16,7 @@ import java.util.List;
public class DestinationCommand implements CommandExecutor, TabCompleter { public class DestinationCommand implements CommandExecutor, TabCompleter {
private AdvancedPortalsPlugin plugin; private final AdvancedPortalsPlugin plugin;
public DestinationCommand(AdvancedPortalsPlugin plugin) { public DestinationCommand(AdvancedPortalsPlugin plugin) {
this.plugin = plugin; this.plugin = plugin;
@ -71,7 +71,7 @@ public class DestinationCommand implements CommandExecutor, TabCompleter {
break; break;
case "list": case "list":
String message = PluginMessages.customPrefix + " \u00A77Destinations \u00A7c:\u00A7a"; String message = PluginMessages.customPrefix + " \u00A77Destinations \u00A7c:\u00A7a";
List<Object> destiObj = Arrays.asList(config.getConfig().getKeys(false).toArray()); Object[] destiObj = config.getConfig().getKeys(false).toArray();
LinkedList<String> destis = new LinkedList<>(); LinkedList<String> destis = new LinkedList<>();
for (Object object : destiObj) { for (Object object : destiObj) {
destis.add(object.toString()); destis.add(object.toString());

View File

@ -6,7 +6,7 @@ import org.bukkit.plugin.messaging.PluginMessageListener;
public class BungeeListener implements PluginMessageListener { public class BungeeListener implements PluginMessageListener {
private AdvancedPortalsPlugin plugin; private final AdvancedPortalsPlugin plugin;
public BungeeListener(AdvancedPortalsPlugin plugin) { public BungeeListener(AdvancedPortalsPlugin plugin) {
this.plugin = plugin; this.plugin = plugin;

View File

@ -223,7 +223,7 @@ public class Listeners implements Listener {
// These are here because java 7 can only take finals straight into a runnable // These are here because java 7 can only take finals straight into a runnable
class RemoveLavaData implements Runnable { class RemoveLavaData implements Runnable {
private Player player; private final Player player;
public RemoveLavaData(Player player) { public RemoveLavaData(Player player) {
this.player = player; this.player = player;
@ -236,11 +236,9 @@ public class Listeners implements Listener {
} }
} }
;
class RemoveWarpData implements Runnable { class RemoveWarpData implements Runnable {
private Player player; private final Player player;
public RemoveWarpData(Player player) { public RemoveWarpData(Player player) {
this.player = player; this.player = player;

View File

@ -12,7 +12,7 @@ import java.util.UUID;
public class PluginMessageReceiver implements PluginMessageListener { public class PluginMessageReceiver implements PluginMessageListener {
private AdvancedPortalsPlugin plugin; private final AdvancedPortalsPlugin plugin;
public PluginMessageReceiver(AdvancedPortalsPlugin plugin) { public PluginMessageReceiver(AdvancedPortalsPlugin plugin) {
this.plugin = plugin; this.plugin = plugin;

View File

@ -50,7 +50,7 @@ public class Metrics {
private static final String URL = "https://bStats.org/submitData/bukkit"; private static final String URL = "https://bStats.org/submitData/bukkit";
// Is bStats enabled on this server? // Is bStats enabled on this server?
private boolean enabled; private final boolean enabled;
// Should failed requests be logged? // Should failed requests be logged?
private static boolean logFailedRequests; private static boolean logFailedRequests;
@ -715,4 +715,4 @@ public class Metrics {
} }
} }
} }

View File

@ -39,7 +39,7 @@ public class Portal {
private static boolean blockSpectatorMode; private static boolean blockSpectatorMode;
private static int joinCooldownDelay; private static int joinCooldownDelay;
private static boolean commandLog; private static boolean commandLog;
private static Random random = new Random(); private static final Random random = new Random();
public static void init(AdvancedPortalsPlugin plugin) { public static void init(AdvancedPortalsPlugin plugin) {
ConfigAccessor config = new ConfigAccessor(plugin, "config.yml"); ConfigAccessor config = new ConfigAccessor(plugin, "config.yml");
@ -300,9 +300,7 @@ public class Portal {
private static boolean checkOverLapPortal(Location pos1, Location pos2, int posX, int posY, int posZ) { private static boolean checkOverLapPortal(Location pos1, Location pos2, int posX, int posY, int posZ) {
if (pos1.getX() >= posX && pos1.getY() >= posX && pos1.getZ() >= posZ) { if (pos1.getX() >= posX && pos1.getY() >= posX && pos1.getZ() >= posZ) {
if ((pos2.getX()) <= posX && pos2.getY() <= posY && pos2.getZ() <= posZ) { return (pos2.getX()) <= posX && pos2.getY() <= posY && pos2.getZ() <= posZ;
return true;
}
} }
return false; return false;
} }
@ -707,10 +705,9 @@ public class Portal {
if ((portal.getPos1().getX() + 1 + additionalArea) >= loc.getX() if ((portal.getPos1().getX() + 1 + additionalArea) >= loc.getX()
&& (portal.getPos1().getY() + 1 + additionalArea) > loc.getY() && (portal.getPos1().getY() + 1 + additionalArea) > loc.getY()
&& (portal.getPos1().getZ() + 1 + additionalArea) >= loc.getZ()) && (portal.getPos1().getZ() + 1 + additionalArea) >= loc.getZ())
if (portal.getPos2().getX() - additionalArea <= loc.getX() return portal.getPos2().getX() - additionalArea <= loc.getX()
&& portal.getPos2().getY() - additionalArea <= loc.getY() && portal.getPos2().getY() - additionalArea <= loc.getY()
&& portal.getPos2().getZ() - additionalArea <= loc.getZ()) && portal.getPos2().getZ() - additionalArea <= loc.getZ();
return true;
return false; return false;
} }

View File

@ -9,7 +9,7 @@ import net.md_5.bungee.api.plugin.Listener;
import net.md_5.bungee.event.EventHandler; import net.md_5.bungee.event.EventHandler;
public class EventListener implements Listener { public class EventListener implements Listener {
private AdvancedPortalsPlugin plugin; private final AdvancedPortalsPlugin plugin;
public EventListener(AdvancedPortalsPlugin plugin) { this.plugin = plugin; } public EventListener(AdvancedPortalsPlugin plugin) { this.plugin = plugin; }

View File

@ -12,7 +12,7 @@ import net.md_5.bungee.event.EventHandler;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
public class PluginMessageReceiver implements Listener { public class PluginMessageReceiver implements Listener {
private AdvancedPortalsPlugin plugin; private final AdvancedPortalsPlugin plugin;
public PluginMessageReceiver(AdvancedPortalsPlugin plugin) { this.plugin = plugin; } public PluginMessageReceiver(AdvancedPortalsPlugin plugin) { this.plugin = plugin; }

View File

@ -29,7 +29,7 @@ public class AdvancedPortalsPlugin {
public HashMap<String, String[]> PlayerDestiMap = new HashMap<>(); public HashMap<String, String[]> PlayerDestiMap = new HashMap<>();
private final Logger logger; private final Logger logger;
private ProxyServer proxy; private final ProxyServer proxy;
private LegacyChannelIdentifier AP_CHANNEL; private LegacyChannelIdentifier AP_CHANNEL;
@Inject @Inject