From 5a3732039778a28223fe45ea9a7c706004950153 Mon Sep 17 00:00:00 2001 From: Driftay Date: Sun, 10 Feb 2019 23:57:45 -0500 Subject: [PATCH] Code Cleanup/Added Configurable option to deny and remove homes in ANY factions land. More Soon.. --- src/main/assembly/package.xml | 4 +- .../java/com/massivecraft/factions/Conf.java | 2 +- .../com/massivecraft/factions/FLocation.java | 2 +- .../com/massivecraft/factions/FPlayer.java | 2 +- .../com/massivecraft/factions/Faction.java | 14 +- .../massivecraft/factions/MassiveStats.java | 6 +- .../massivecraft/factions/SavageFactions.java | 248 +-- .../massivecraft/factions/cmd/CmdAdmin.java | 2 +- .../massivecraft/factions/cmd/CmdBanner.java | 2 +- .../massivecraft/factions/cmd/CmdChat.java | 33 +- .../massivecraft/factions/cmd/CmdChest.java | 2 +- .../massivecraft/factions/cmd/CmdClaim.java | 9 +- .../massivecraft/factions/cmd/CmdClaimAt.java | 2 +- .../factions/cmd/CmdClaimLine.java | 2 +- .../factions/cmd/CmdColeader.java | 2 +- .../massivecraft/factions/cmd/CmdConfig.java | 4 +- .../massivecraft/factions/cmd/CmdConvert.java | 2 +- .../massivecraft/factions/cmd/CmdCoords.java | 2 +- .../factions/cmd/CmdDeinvite.java | 2 +- .../massivecraft/factions/cmd/CmdDemote.java | 2 +- .../factions/cmd/CmdDescription.java | 2 +- .../massivecraft/factions/cmd/CmdDisband.java | 7 +- .../massivecraft/factions/cmd/CmdFWarp.java | 2 +- .../com/massivecraft/factions/cmd/CmdFly.java | 20 +- .../massivecraft/factions/cmd/CmdFocus.java | 16 +- .../factions/cmd/CmdGetVault.java | 2 +- .../massivecraft/factions/cmd/CmdHome.java | 2 +- .../massivecraft/factions/cmd/CmdInspect.java | 2 +- .../massivecraft/factions/cmd/CmdInvite.java | 2 +- .../massivecraft/factions/cmd/CmdJoin.java | 2 +- .../massivecraft/factions/cmd/CmdKick.java | 2 +- .../massivecraft/factions/cmd/CmdLeave.java | 2 +- .../massivecraft/factions/cmd/CmdList.java | 6 +- .../massivecraft/factions/cmd/CmdLock.java | 2 +- .../massivecraft/factions/cmd/CmdLogins.java | 2 +- .../factions/cmd/CmdLowPower.java | 2 +- .../com/massivecraft/factions/cmd/CmdMap.java | 2 +- .../factions/cmd/CmdMapHeight.java | 2 +- .../com/massivecraft/factions/cmd/CmdMod.java | 2 +- .../factions/cmd/CmdMoneyBalance.java | 2 +- .../factions/cmd/CmdMoneyDeposit.java | 2 +- .../factions/cmd/CmdMoneyTransferFf.java | 2 +- .../factions/cmd/CmdMoneyTransferFp.java | 2 +- .../factions/cmd/CmdMoneyTransferPf.java | 2 +- .../factions/cmd/CmdMoneyWithdraw.java | 2 +- .../massivecraft/factions/cmd/CmdNear.java | 2 +- .../massivecraft/factions/cmd/CmdOpen.java | 2 +- .../factions/cmd/CmdOwnerList.java | 2 +- .../massivecraft/factions/cmd/CmdReload.java | 6 +- .../factions/cmd/CmdSeeChunk.java | 6 +- .../factions/cmd/CmdSetDefaultRole.java | 2 +- .../factions/cmd/CmdSetFWarp.java | 4 +- .../factions/cmd/CmdSetMaxVaults.java | 2 +- .../massivecraft/factions/cmd/CmdShow.java | 4 +- .../factions/cmd/CmdShowClaims.java | 3 +- .../massivecraft/factions/cmd/CmdStatus.java | 2 +- .../com/massivecraft/factions/cmd/CmdTnt.java | 2 +- .../massivecraft/factions/cmd/CmdTntFill.java | 2 +- .../com/massivecraft/factions/cmd/CmdTop.java | 14 +- .../massivecraft/factions/cmd/CmdUnban.java | 2 +- .../massivecraft/factions/cmd/FCommand.java | 13 +- .../factions/cmd/FPromoteCommand.java | 2 +- .../factions/cmd/FRelationCommand.java | 4 +- .../factions/event/FactionDisbandEvent.java | 10 +- .../factions/event/PowerRegenEvent.java | 3 +- .../factions/iface/EconomyParticipator.java | 22 +- .../factions/iface/RelationParticipator.java | 34 +- .../factions/integration/Econ.java | 14 +- .../factions/integration/Essentials.java | 6 +- .../factions/integration/Worldguard.java | 276 +-- .../integration/dynmap/EngineDynmap.java | 9 +- .../integration/dynmap/TempAreaMarker.java | 6 +- .../listeners/FactionsBlockListener.java | 60 +- .../listeners/FactionsChatListener.java | 4 +- .../listeners/FactionsEntityListener.java | 32 +- .../listeners/FactionsExploitListener.java | 4 +- .../listeners/FactionsPlayerListener.java | 1774 +++++++++-------- .../player/PlayerFactionExpression.java | 120 +- .../player/PlayerPowerExpression.java | 116 +- .../player/PlayerRoleExpression.java | 112 +- .../factions/struct/Relation.java | 22 +- .../massivecraft/factions/struct/Role.java | 22 +- .../util/ClipPlaceholderAPIManager.java | 6 +- .../factions/util/EnumTypeAdapter.java | 132 +- .../factions/util/FactionGUI.java | 4 +- .../factions/util/LazyLocation.java | 2 +- .../massivecraft/factions/util/MiscUtil.java | 20 +- .../factions/util/MultiversionMaterials.java | 18 +- .../util/Particles/ParticleEffect.java | 97 +- .../util/Particles/ReflectionUtils.java | 10 +- .../factions/util/RelationUtil.java | 222 +-- .../factions/util/SpiralTask.java | 16 +- .../massivecraft/factions/util/UtilFly.java | 114 ++ .../factions/util/VisualizeUtil.java | 144 +- .../factions/util/WarmUpUtil.java | 2 +- .../massivecraft/factions/util/WarpGUI.java | 4 +- .../massivecraft/factions/zcore/MCommand.java | 9 +- .../massivecraft/factions/zcore/MPlugin.java | 678 +++---- .../zcore/MPluginSecretPlayerListener.java | 104 +- .../factions/zcore/fperms/Permissable.java | 6 +- .../zcore/fperms/PermissableAction.java | 15 +- .../fperms/gui/PermissableActionGUI.java | 4 +- .../fperms/gui/PermissableRelationGUI.java | 2 +- .../zcore/fupgrades/CropUpgrades.java | 51 +- .../factions/zcore/fupgrades/EXPUpgrade.java | 39 +- .../zcore/fupgrades/FUpgradesGUI.java | 214 +- .../zcore/fupgrades/SpawnerUpgrades.java | 23 +- .../factions/zcore/fupgrades/Upgrade.java | 18 +- .../factions/zcore/nbtapi/NBTCompound.java | 6 +- .../factions/zcore/nbtapi/NBTList.java | 2 +- .../zcore/nbtapi/NBTListCompound.java | 2 +- .../zcore/nbtapi/NBTReflectionUtil.java | 188 +- .../zcore/nbtapi/utils/MethodNames.java | 6 +- .../zcore/nbtapi/utils/MinecraftVersion.java | 43 +- .../factions/zcore/persist/MemoryBoard.java | 16 +- .../factions/zcore/persist/MemoryFPlayer.java | 42 +- .../factions/zcore/persist/MemoryFaction.java | 20 +- .../factions/zcore/util/PermUtil.java | 148 +- .../factions/zcore/util/Persist.java | 306 +-- .../massivecraft/factions/zcore/util/TL.java | 5 +- .../factions/zcore/util/TagReplacer.java | 2 +- .../factions/zcore/util/TagUtil.java | 10 +- .../factions/zcore/util/TextUtil.java | 462 ++--- src/main/resources/config.yml | 717 +++---- src/main/resources/plugin.yml | 2 + 125 files changed, 3676 insertions(+), 3410 deletions(-) create mode 100644 src/main/java/com/massivecraft/factions/util/UtilFly.java diff --git a/src/main/assembly/package.xml b/src/main/assembly/package.xml index 8f3491cb..b7f3d9f3 100644 --- a/src/main/assembly/package.xml +++ b/src/main/assembly/package.xml @@ -1,5 +1,5 @@ - bin false diff --git a/src/main/java/com/massivecraft/factions/Conf.java b/src/main/java/com/massivecraft/factions/Conf.java index fca62d9e..9c9746fd 100644 --- a/src/main/java/com/massivecraft/factions/Conf.java +++ b/src/main/java/com/massivecraft/factions/Conf.java @@ -35,7 +35,7 @@ public class Conf { public static ChatColor colorWar = ChatColor.DARK_RED; // Power public static double powerPlayerMax = 10.0; - public static double powerPlayerMin = - 10.0; + public static double powerPlayerMin = -10.0; public static double powerPlayerStarting = 0.0; public static double powerPerMinute = 0.2; // Default health rate... it takes 5 min to heal one power public static double powerPerDeath = 4.0; // A death makes you lose 4 power diff --git a/src/main/java/com/massivecraft/factions/FLocation.java b/src/main/java/com/massivecraft/factions/FLocation.java index 15bb0712..1c684ce0 100644 --- a/src/main/java/com/massivecraft/factions/FLocation.java +++ b/src/main/java/com/massivecraft/factions/FLocation.java @@ -11,7 +11,7 @@ import java.util.LinkedHashSet; import java.util.Set; public class FLocation implements Serializable { - private static final long serialVersionUID = - 8292915234027387983L; + private static final long serialVersionUID = -8292915234027387983L; private static final boolean worldBorderSupport; static { diff --git a/src/main/java/com/massivecraft/factions/FPlayer.java b/src/main/java/com/massivecraft/factions/FPlayer.java index bf1a15aa..48d1a44a 100644 --- a/src/main/java/com/massivecraft/factions/FPlayer.java +++ b/src/main/java/com/massivecraft/factions/FPlayer.java @@ -60,7 +60,7 @@ public interface FPlayer extends EconomyParticipator { /** * Sets the faction of the FPlayer * - * @param faction faction to set. + * @param faction faction to set. */ void setFaction(Faction faction); diff --git a/src/main/java/com/massivecraft/factions/Faction.java b/src/main/java/com/massivecraft/factions/Faction.java index 0ca31a88..a24ef6fb 100644 --- a/src/main/java/com/massivecraft/factions/Faction.java +++ b/src/main/java/com/massivecraft/factions/Faction.java @@ -55,7 +55,7 @@ public interface Faction extends EconomyParticipator { String getFocused(); - void setFocused(String setFocused); + void setFocused(String setFocused); String getId(); @@ -65,9 +65,9 @@ public interface Faction extends EconomyParticipator { void deinvite(FPlayer fplayer); - void setUpgrade(Upgrade upgrade, int level); + void setUpgrade(Upgrade upgrade, int level); - int getUpgrade(Upgrade upgrade); + int getUpgrade(Upgrade upgrade); boolean isInvited(FPlayer fplayer); @@ -205,7 +205,7 @@ public interface Faction extends EconomyParticipator { void resetPerms(); void disband(Player disbander); - + void disband(Player disbander, PlayerDisbandReason reason); // ------------------------------- @@ -273,9 +273,9 @@ public interface Faction extends EconomyParticipator { FPlayer getFPlayerAdmin(); - FPlayer getFPlayerLeader(); + FPlayer getFPlayerLeader(); - ArrayList getFPlayersWhereRole(Role role); + ArrayList getFPlayersWhereRole(Role role); ArrayList getOnlinePlayers(); @@ -288,7 +288,7 @@ public interface Faction extends EconomyParticipator { // used when current leader is about to be removed from the faction; // promotes new leader, or disbands faction if no other members left void promoteNewLeader(); - + void promoteNewLeader(boolean autoLeave); Role getDefaultRole(); diff --git a/src/main/java/com/massivecraft/factions/MassiveStats.java b/src/main/java/com/massivecraft/factions/MassiveStats.java index bf4880b4..babb89a8 100644 --- a/src/main/java/com/massivecraft/factions/MassiveStats.java +++ b/src/main/java/com/massivecraft/factions/MassiveStats.java @@ -31,7 +31,7 @@ import java.net.URL; * @author Sam Jakob Harker, Brianna Hazel O'Keefe * @version 3.0 */ -@SuppressWarnings ("all") +@SuppressWarnings("all") public class MassiveStats implements Listener { /* START: MASSIVESTATS SETTINGS */ @@ -258,7 +258,7 @@ class MassiveStatsUpdateTask extends BukkitRunnable { } @Override - @SuppressWarnings ("all") + @SuppressWarnings("all") public void run() { try { // Generate the request payload and serialize it as JSON. @@ -431,7 +431,7 @@ class MassiveStatsDataRequest { } } - @SuppressWarnings ("all") + @SuppressWarnings("all") public String serialize() { //return object.toString(); try { diff --git a/src/main/java/com/massivecraft/factions/SavageFactions.java b/src/main/java/com/massivecraft/factions/SavageFactions.java index 9ed98fc9..c580400f 100644 --- a/src/main/java/com/massivecraft/factions/SavageFactions.java +++ b/src/main/java/com/massivecraft/factions/SavageFactions.java @@ -2,12 +2,12 @@ package com.massivecraft.factions; import ch.njol.skript.Skript; import ch.njol.skript.SkriptAddon; +import com.earth2me.essentials.Essentials; import com.google.gson.GsonBuilder; import com.google.gson.reflect.TypeToken; import com.massivecraft.factions.cmd.CmdAutoHelp; import com.massivecraft.factions.cmd.FCmdRoot; import com.massivecraft.factions.integration.Econ; -import com.massivecraft.factions.integration.Essentials; import com.massivecraft.factions.integration.Worldguard; import com.massivecraft.factions.integration.dynmap.EngineDynmap; import com.massivecraft.factions.listeners.*; @@ -56,7 +56,9 @@ public class SavageFactions extends MPlugin { // Single 4 life. public static SavageFactions plugin; public static Permission perms = null; - + // Persistence related + public static ArrayList playersFlying = new ArrayList(); + public Essentials ess; public boolean PlaceholderApi; // Commands public FCmdRoot cmdBase; @@ -72,17 +74,14 @@ public class SavageFactions extends MPlugin { SOIL, MOB_SPANWER, THIN_GLASS, IRON_FENCE, NETHER_FENCE, FENCE, WOODEN_DOOR, TRAP_DOOR, FENCE_GATE, BURNING_FURNACE, DIODE_BLOCK_OFF, DIODE_BLOCK_ON, ENCHANTMENT_TABLE, FIREBALL; - // Persistence related + SkriptAddon skriptAddon; private boolean locked = false; private Integer AutoLeaveTask = null; private boolean hookedPlayervaults; private ClipPlaceholderAPIManager clipPlaceholderAPIManager; private boolean mvdwPlaceholderAPIManager = false; - - SkriptAddon skriptAddon; - private Listener[] eventsListener; - + public SavageFactions() { plugin = this; } @@ -157,11 +156,11 @@ public class SavageFactions extends MPlugin { // Load Conf from disk Conf.load(); - Essentials.setup(); + com.massivecraft.factions.integration.Essentials.setup(); hookedPlayervaults = setupPlayervaults(); FPlayers.getInstance().load(); Factions.getInstance().load(); - + for (FPlayer fPlayer : FPlayers.getInstance().getAllFPlayers()) { Faction faction = Factions.getInstance().getFactionById(fPlayer.getFactionId()); if (faction == null) { @@ -171,7 +170,12 @@ public class SavageFactions extends MPlugin { } faction.addFPlayer(fPlayer); } - + playersFlying.clear(); + for (FPlayer fPlayer : FPlayers.getInstance().getAllFPlayers()) { + playersFlying.add(fPlayer); + } + UtilFly.run(); + Board.getInstance().load(); Board.getInstance().clean(); @@ -206,38 +210,40 @@ public class SavageFactions extends MPlugin { factionsFlight = true; } - if (getServer().getPluginManager().getPlugin("Skript") != null) { - log("Skript was found! Registering SavageFactions Addon..."); - skriptAddon = Skript.registerAddon(this); - try { - skriptAddon.loadClasses("com.massivecraft.factions.skript", "expressions"); - } catch (IOException ex) { - ex.printStackTrace(); - } - log("Skript addon registered!"); - } + if (getServer().getPluginManager().getPlugin("Skript") != null) { + log("Skript was found! Registering SavageFactions Addon..."); + skriptAddon = Skript.registerAddon(this); + try { + skriptAddon.loadClasses("com.massivecraft.factions.skript", "expressions"); + } catch (IOException ex) { + ex.printStackTrace(); + } + log("Skript addon registered!"); + } // Register Event Handlers - eventsListener = new Listener[] { - new FactionsPlayerListener(), - new FactionsChatListener(), - new FactionsEntityListener(), - new FactionsExploitListener(), - new FactionsBlockListener(), - new FUpgradesGUI(), - new EXPUpgrade(), - new CropUpgrades(), - new SpawnerUpgrades(), - }; - - for (Listener eventListener: eventsListener) - getServer().getPluginManager().registerEvents(eventListener, this); - + eventsListener = new Listener[]{ + new FactionsPlayerListener(), + new FactionsChatListener(), + new FactionsEntityListener(), + new FactionsExploitListener(), + new FactionsBlockListener(), + new FUpgradesGUI(), + new EXPUpgrade(), + new CropUpgrades(), + new SpawnerUpgrades(), + }; + + for (Listener eventListener : eventsListener) + getServer().getPluginManager().registerEvents(eventListener, this); + // since some other plugins execute commands directly through this command interface, provide it getCommand(this.refCommand).setExecutor(this); getCommand(this.refCommand).setTabCompleter(this); + setupEssentials(); + if (getDescription().getFullName().contains("BETA")) { divider(); System.out.println("You are using a BETA version of the plugin!"); @@ -251,9 +257,9 @@ public class SavageFactions extends MPlugin { this.loadSuccessful = true; } - public SkriptAddon getSkriptAddon() { - return skriptAddon; - } + public SkriptAddon getSkriptAddon() { + return skriptAddon; + } private void setupMultiversionMaterials() { if (mc113) { @@ -330,35 +336,35 @@ public class SavageFactions extends MPlugin { } } - private void migrateFPlayerLeaders() { - List lines = new ArrayList<>(); - File fplayerFile = new File("plugins\\Factions\\players.json"); - - try { - BufferedReader br = new BufferedReader(new FileReader(fplayerFile)); - System.out.println("Migrating old players.json file."); + private void migrateFPlayerLeaders() { + List lines = new ArrayList<>(); + File fplayerFile = new File("plugins\\Factions\\players.json"); - String line; - while ((line = br.readLine()) != null) { - if (line.contains("\"role\": \"ADMIN\"")) { - line = line.replace("\"role\": \"ADMIN\"", "\"role\": " + "\"LEADER\""); + try { + BufferedReader br = new BufferedReader(new FileReader(fplayerFile)); + System.out.println("Migrating old players.json file."); + + String line; + while ((line = br.readLine()) != null) { + if (line.contains("\"role\": \"ADMIN\"")) { + line = line.replace("\"role\": \"ADMIN\"", "\"role\": " + "\"LEADER\""); + } + lines.add(line); + } + br.close(); + BufferedWriter bw = new BufferedWriter(new FileWriter(fplayerFile)); + for (String newLine : lines) { + bw.write(newLine + "\n"); + } + bw.flush(); + bw.close(); + } catch (IOException ex) { + System.out.println("File was not found for players.json, assuming" + + " there is no need to migrate old players.json file."); } - lines.add(line); - } - br.close(); - BufferedWriter bw = new BufferedWriter(new FileWriter(fplayerFile)); - for (String newLine : lines) { - bw.write(newLine + "\n"); - } - bw.flush(); - bw.close(); - } catch (IOException ex) { - System.out.println("File was not found for players.json, assuming" - + " there is no need to migrate old players.json file."); } - } - public void changeItemIDSInConfig() { + public void changeItemIDSInConfig() { log("Starting conversion of legacy material in config to 1.13 materials."); replaceStringInConfig("fperm-gui.relation.materials.recruit", "WOOD_SWORD", "WOODEN_SWORD"); @@ -380,7 +386,7 @@ public class SavageFactions extends MPlugin { replaceStringInConfig("fupgrades.MainMenu.DummyItem.Type", "STAINED_GLASS_PANE", "GRAY_STAINED_GLASS_PANE"); replaceStringInConfig("fupgrades.MainMenu.EXP.EXPItem.Type", "EXP_BOTTLE", "EXPERIENCE_BOTTLE"); replaceStringInConfig("fupgrades.MainMenu.Spawners.SpawnerItem.Type", "MOB_SPAWNER", "SPAWNER"); - + replaceStringInConfig("fperm-gui.action.access.allow", "LIME", "LIME_STAINED_GLASS"); replaceStringInConfig("fperm-gui.action.access.deny", "RED", "RED_STAINED_GLASS"); replaceStringInConfig("fperm-gui.action.access.undefined", "CYAN", "CYAN_STAINED_GLASS"); @@ -388,8 +394,8 @@ public class SavageFactions extends MPlugin { public void replaceStringInConfig(String path, String stringToReplace, String replacementString) { if (getConfig().getString(path).equals(stringToReplace)) { - // SavageFactions.plugin.log("Replacing legacy material '" + stringToReplace + "' with '" + replacementString + "' for config node '" + path + "'."); - // log("Replacing legacy material '" + stringToReplace + "' with '" + replacementString + "' for config node '" + path + "'."); + // SavageFactions.plugin.log("Replacing legacy material '" + stringToReplace + "' with '" + replacementString + "' for config node '" + path + "'."); + // log("Replacing legacy material '" + stringToReplace + "' with '" + replacementString + "' for config node '" + path + "'."); getConfig().set(path, replacementString); } @@ -447,10 +453,10 @@ public class SavageFactions extends MPlugin { public void onDisable() { // only save data if plugin actually completely loaded successfully if (this.loadSuccessful) { - // Dont save, as this is kind of pointless, as the /f config command manually saves. - // So any edits done are saved, this way manual edits to json can go through. + // Dont save, as this is kind of pointless, as the /f config command manually saves. + // So any edits done are saved, this way manual edits to json can go through. - // Conf.save(); + // Conf.save(); } if (AutoLeaveTask != null) { @@ -505,6 +511,11 @@ public class SavageFactions extends MPlugin { return econ; } + private boolean setupEssentials() { + SavageFactions.plugin.ess = (Essentials) this.getServer().getPluginManager().getPlugin("Essentials"); + return SavageFactions.plugin.ess == null; + } + @Override public boolean logPlayerCommands() { return Conf.logPlayerCommands; @@ -525,58 +536,53 @@ public class SavageFactions extends MPlugin { String cmd = Conf.baseCommandAliases.isEmpty() ? "/f" : "/" + Conf.baseCommandAliases.get(0); return handleCommand(sender, cmd + " " + TextUtil.implode(Arrays.asList(split), " "), false); } - + @Override public List onTabComplete(CommandSender sender, Command command, String alias, String[] args) { - FPlayer fPlayer = FPlayers.getInstance().getByPlayer((Player) sender); - List completions = new ArrayList<>(); - String cmd = Conf.baseCommandAliases.isEmpty() ? "/f" : "/" + Conf.baseCommandAliases.get(0); - List argsList = new ArrayList<>(Arrays.asList(args)); - argsList.remove(argsList.size() - 1); - String cmdValid = (cmd + " " + TextUtil.implode(argsList, " ")).trim(); - MCommand commandEx = cmdBase; - List> commandsList = cmdBase.subCommands; - - if (Board.getInstance().getFactionAt(new FLocation(fPlayer.getPlayer().getLocation())) == Factions.getInstance().getWarZone()) { - sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&cYou cannot use autocomplete in warzone.")); - return new ArrayList<>(); + FPlayer fPlayer = FPlayers.getInstance().getByPlayer((Player) sender); + List completions = new ArrayList<>(); + String cmd = Conf.baseCommandAliases.isEmpty() ? "/f" : "/" + Conf.baseCommandAliases.get(0); + List argsList = new ArrayList<>(Arrays.asList(args)); + argsList.remove(argsList.size() - 1); + String cmdValid = (cmd + " " + TextUtil.implode(argsList, " ")).trim(); + MCommand commandEx = cmdBase; + List> commandsList = cmdBase.subCommands; + + if (Board.getInstance().getFactionAt(new FLocation(fPlayer.getPlayer().getLocation())) == Factions.getInstance().getWarZone()) { + sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&cYou cannot use autocomplete in warzone.")); + return new ArrayList<>(); } - for (; !commandsList.isEmpty() && !argsList.isEmpty(); argsList.remove(0)) - { - String cmdName = argsList.get(0).toLowerCase(); - MCommand commandFounded = commandsList.stream() - .filter(c -> c.aliases.contains(cmdName)) - .findFirst().orElse(null); + for (; !commandsList.isEmpty() && !argsList.isEmpty(); argsList.remove(0)) { + String cmdName = argsList.get(0).toLowerCase(); + MCommand commandFounded = commandsList.stream() + .filter(c -> c.aliases.contains(cmdName)) + .findFirst().orElse(null); - if (commandFounded != null) - { - commandEx = commandFounded; - commandsList = commandFounded.subCommands; - } - else break; - } - - if (argsList.isEmpty()) - { - for (MCommand subCommand: commandEx.subCommands) - { - subCommand.setCommandSender(sender); - if (handleCommand(sender, cmdValid + " " + subCommand.aliases.get(0), true) - && subCommand.visibility != CommandVisibility.INVISIBLE - && subCommand.validSenderType(sender, false) - && subCommand.validSenderPermissions(sender, false)) - completions.addAll(subCommand.aliases); - } - } - - String lastArg = args[args.length - 1].toLowerCase(); - - completions = completions.stream() - .filter(m -> m.toLowerCase().startsWith(lastArg)) - .collect(Collectors.toList()); - - return completions; + if (commandFounded != null) { + commandEx = commandFounded; + commandsList = commandFounded.subCommands; + } else break; + } + + if (argsList.isEmpty()) { + for (MCommand subCommand : commandEx.subCommands) { + subCommand.setCommandSender(sender); + if (handleCommand(sender, cmdValid + " " + subCommand.aliases.get(0), true) + && subCommand.visibility != CommandVisibility.INVISIBLE + && subCommand.validSenderType(sender, false) + && subCommand.validSenderPermissions(sender, false)) + completions.addAll(subCommand.aliases); + } + } + + String lastArg = args[args.length - 1].toLowerCase(); + + completions = completions.stream() + .filter(m -> m.toLowerCase().startsWith(lastArg)) + .collect(Collectors.toList()); + + return completions; } public void createTimedHologram(final Location location, String text, Long timeout) { @@ -587,12 +593,12 @@ public class SavageFactions extends MPlugin { as.setCustomName(SavageFactions.plugin.color(text)); //Set this to the text you want as.setCustomNameVisible(true); //This makes the text appear no matter if your looking at the entity or not final ArmorStand armorStand = as; - + Bukkit.getScheduler().scheduleSyncDelayedTask(SavageFactions.plugin, () -> { - armorStand.remove(); - getLogger().info("Removing Hologram."); - } - , timeout * 20); + armorStand.remove(); + getLogger().info("Removing Hologram."); + } + , timeout * 20); } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdAdmin.java b/src/main/java/com/massivecraft/factions/cmd/CmdAdmin.java index 64dc592b..ed21beb0 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdAdmin.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdAdmin.java @@ -25,7 +25,7 @@ public class CmdAdmin extends FCommand { this.disableOnLock = true; - senderMustBePlayer = false; + senderMustBePlayer = false; senderMustBeMember = false; senderMustBeModerator = false; senderMustBeAdmin = false; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdBanner.java b/src/main/java/com/massivecraft/factions/cmd/CmdBanner.java index 57713e42..7f8e6fa6 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdBanner.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdBanner.java @@ -23,7 +23,7 @@ public class CmdBanner extends FCommand { this.disableOnLock = false; - senderMustBePlayer = true; + senderMustBePlayer = true; senderMustBeMember = false; senderMustBeModerator = false; senderMustBeColeader = true; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdChat.java b/src/main/java/com/massivecraft/factions/cmd/CmdChat.java index c6d7b97f..983868c0 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdChat.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdChat.java @@ -41,12 +41,10 @@ public class CmdChat extends FCommand { modeString = modeString.toLowerCase(); // Only allow Mods and higher rank to switch to this channel. if (modeString.startsWith("m")) { - if (!fme.getRole().isAtLeast(Role.MODERATOR)) - { - msg(TL.COMMAND_CHAT_MOD_ONLY); - return; - } - else modeTarget = ChatMode.MOD; + if (!fme.getRole().isAtLeast(Role.MODERATOR)) { + msg(TL.COMMAND_CHAT_MOD_ONLY); + return; + } else modeTarget = ChatMode.MOD; } else if (modeString.startsWith("p")) { modeTarget = ChatMode.PUBLIC; } else if (modeString.startsWith("a")) { @@ -63,13 +61,22 @@ public class CmdChat extends FCommand { fme.setChatMode(modeTarget); - switch (fme.getChatMode()) - { - case MOD: msg(TL.COMMAND_CHAT_MODE_MOD); break; - case PUBLIC: msg(TL.COMMAND_CHAT_MODE_PUBLIC); break; - case ALLIANCE: msg(TL.COMMAND_CHAT_MODE_ALLIANCE); break; - case TRUCE: msg(TL.COMMAND_CHAT_MODE_TRUCE); break; - default: msg(TL.COMMAND_CHAT_MODE_FACTION); break; + switch (fme.getChatMode()) { + case MOD: + msg(TL.COMMAND_CHAT_MODE_MOD); + break; + case PUBLIC: + msg(TL.COMMAND_CHAT_MODE_PUBLIC); + break; + case ALLIANCE: + msg(TL.COMMAND_CHAT_MODE_ALLIANCE); + break; + case TRUCE: + msg(TL.COMMAND_CHAT_MODE_TRUCE); + break; + default: + msg(TL.COMMAND_CHAT_MODE_FACTION); + break; } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdChest.java b/src/main/java/com/massivecraft/factions/cmd/CmdChest.java index 0f9be022..f007b99b 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdChest.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdChest.java @@ -20,7 +20,7 @@ public class CmdChest extends FCommand { this.disableOnLock = false; - senderMustBePlayer = true; + senderMustBePlayer = true; senderMustBeMember = true; senderMustBeModerator = false; senderMustBeAdmin = false; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdClaim.java b/src/main/java/com/massivecraft/factions/cmd/CmdClaim.java index 544b645f..f0e4077d 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdClaim.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdClaim.java @@ -46,11 +46,10 @@ public class CmdClaim extends FCommand { } } - if (forFaction.isWilderness()) - { - CmdUnclaim cmdUnclaim = SavageFactions.plugin.cmdBase.cmdUnclaim; - cmdUnclaim.execute(sender, args.size() > 1 ? args.subList(0, 1):args); - return; + if (forFaction.isWilderness()) { + CmdUnclaim cmdUnclaim = SavageFactions.plugin.cmdBase.cmdUnclaim; + cmdUnclaim.execute(sender, args.size() > 1 ? args.subList(0, 1) : args); + return; } if (radius < 1) { diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdClaimAt.java b/src/main/java/com/massivecraft/factions/cmd/CmdClaimAt.java index fd5f6b9c..feee8c76 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdClaimAt.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdClaimAt.java @@ -18,7 +18,7 @@ public class CmdClaimAt extends FCommand { this.disableOnLock = true; - senderMustBePlayer = true; + senderMustBePlayer = true; senderMustBeMember = true; senderMustBeModerator = false; senderMustBeColeader = false; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdClaimLine.java b/src/main/java/com/massivecraft/factions/cmd/CmdClaimLine.java index 61919ead..e3507db5 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdClaimLine.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdClaimLine.java @@ -26,7 +26,7 @@ public class CmdClaimLine extends FCommand { this.disableOnLock = true; - senderMustBePlayer = true; + senderMustBePlayer = true; senderMustBeMember = false; senderMustBeModerator = false; senderMustBeColeader = false; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdColeader.java b/src/main/java/com/massivecraft/factions/cmd/CmdColeader.java index 38823f9a..f1aaefca 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdColeader.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdColeader.java @@ -24,7 +24,7 @@ public class CmdColeader extends FCommand { this.disableOnLock = true; - senderMustBePlayer = false; + senderMustBePlayer = false; senderMustBeMember = true; senderMustBeModerator = false; senderMustBeAdmin = true; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdConfig.java b/src/main/java/com/massivecraft/factions/cmd/CmdConfig.java index 14b1c392..6717b53e 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdConfig.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdConfig.java @@ -174,7 +174,7 @@ public class CmdConfig extends FCommand { return; } - @SuppressWarnings ("unchecked") Set matSet = (Set) target.get(null); + @SuppressWarnings("unchecked") Set matSet = (Set) target.get(null); // Material already present, so remove it if (matSet.contains(newMat)) { @@ -192,7 +192,7 @@ public class CmdConfig extends FCommand { // Set else if (innerType == String.class) { - @SuppressWarnings ("unchecked") Set stringSet = (Set) target.get(null); + @SuppressWarnings("unchecked") Set stringSet = (Set) target.get(null); // String already present, so remove it if (stringSet.contains(value.toString())) { diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdConvert.java b/src/main/java/com/massivecraft/factions/cmd/CmdConvert.java index fc265b43..bc923ec6 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdConvert.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdConvert.java @@ -13,7 +13,7 @@ public class CmdConvert extends FCommand { this.aliases.add("convert"); this.permission = Permission.CONVERT.node; - + this.requiredArgs.add("[MYSQL|JSON]"); } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdCoords.java b/src/main/java/com/massivecraft/factions/cmd/CmdCoords.java index f5b05c44..e6b3bad3 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdCoords.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdCoords.java @@ -16,7 +16,7 @@ public class CmdCoords extends FCommand { this.disableOnLock = true; - senderMustBePlayer = true; + senderMustBePlayer = true; senderMustBeMember = true; senderMustBeModerator = false; senderMustBeColeader = false; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdDeinvite.java b/src/main/java/com/massivecraft/factions/cmd/CmdDeinvite.java index 8cce707f..62c2b72e 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdDeinvite.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdDeinvite.java @@ -25,7 +25,7 @@ public class CmdDeinvite extends FCommand { this.disableOnLock = true; - senderMustBePlayer = true; + senderMustBePlayer = true; senderMustBeMember = false; senderMustBeModerator = true; senderMustBeColeader = false; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdDemote.java b/src/main/java/com/massivecraft/factions/cmd/CmdDemote.java index bec033a4..2890d2f5 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdDemote.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdDemote.java @@ -4,6 +4,6 @@ public class CmdDemote extends FPromoteCommand { public CmdDemote() { aliases.add("demote"); - this.relative = - 1; + this.relative = -1; } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdDescription.java b/src/main/java/com/massivecraft/factions/cmd/CmdDescription.java index e37f3c06..a0e6d00a 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdDescription.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdDescription.java @@ -22,7 +22,7 @@ public class CmdDescription extends FCommand { this.disableOnLock = true; - senderMustBePlayer = true; + senderMustBePlayer = true; senderMustBeMember = false; senderMustBeModerator = false; senderMustBeColeader = true; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdDisband.java b/src/main/java/com/massivecraft/factions/cmd/CmdDisband.java index d0b9e91d..2ad00c4d 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdDisband.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdDisband.java @@ -1,12 +1,10 @@ package com.massivecraft.factions.cmd; -import com.massivecraft.factions.FPlayer; -import com.massivecraft.factions.FPlayers; -import com.massivecraft.factions.Faction; -import com.massivecraft.factions.SavageFactions; +import com.massivecraft.factions.*; import com.massivecraft.factions.event.FactionDisbandEvent.PlayerDisbandReason; import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Role; +import com.massivecraft.factions.util.UtilFly; import com.massivecraft.factions.zcore.fperms.Access; import com.massivecraft.factions.zcore.fperms.PermissableAction; import com.massivecraft.factions.zcore.util.TL; @@ -93,6 +91,7 @@ public class CmdDisband extends FCommand { if (SavageFactions.plugin.getConfig().getBoolean("faction-disband-broadcast", true)) { for (FPlayer follower : FPlayers.getInstance().getOnlinePlayers()) { String amountString = senderIsConsole ? TL.GENERIC_SERVERADMIN.toString() : fme.describeTo(follower); + UtilFly.checkFly(this.fme, Board.getInstance().getFactionAt(new FLocation(follower))); if (follower.getFaction() == faction) { follower.msg(TL.COMMAND_DISBAND_BROADCAST_YOURS, amountString); } else { diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFWarp.java b/src/main/java/com/massivecraft/factions/cmd/CmdFWarp.java index 63fd1e60..21a4bac4 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFWarp.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFWarp.java @@ -24,7 +24,7 @@ public class CmdFWarp extends FCommand { this.optionalArgs.put("password", "password"); - this.permission = Permission.WARP.node; + this.permission = Permission.WARP.node; this.senderMustBeMember = true; this.senderMustBeModerator = false; } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFly.java b/src/main/java/com/massivecraft/factions/cmd/CmdFly.java index 6b84c016..b9f737b6 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFly.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFly.java @@ -23,8 +23,8 @@ public class CmdFly extends FCommand { public static ConcurrentHashMap flyMap = new ConcurrentHashMap(); - public static int id = - 1; - public static int flyid = - 1; + public static int id = -1; + public static int flyid = -1; public CmdFly() { super(); @@ -33,7 +33,7 @@ public class CmdFly extends FCommand { this.optionalArgs.put("on/off", "flip"); - this.permission = Permission.FLY.node; + this.permission = Permission.FLY.node; this.senderMustBeMember = true; this.senderMustBeModerator = false; } @@ -73,15 +73,15 @@ public class CmdFly extends FCommand { // 1.9+ based servers will use the built in particleAPI instead of packet based. // any particle amount higher than 0 made them go everywhere, and the offset at 0 was not working. // So setting the amount to 0 spawns 1 in the precise location - player.getWorld().spawnParticle(Particle.CLOUD, player.getLocation().add(0, - 0.35, 0), 0); + player.getWorld().spawnParticle(Particle.CLOUD, player.getLocation().add(0, -0.35, 0), 0); } else { - ParticleEffect.CLOUD.display((float) 0, (float) 0, (float) 0, (float) 0, 3, player.getLocation().add(0, - 0.35, 0), 16); + ParticleEffect.CLOUD.display((float) 0, (float) 0, (float) 0, (float) 0, 3, player.getLocation().add(0, -0.35, 0), 16); } } if (flyMap.keySet().size() == 0) { Bukkit.getScheduler().cancelTask(id); - id = - 1; + id = -1; } } }, 10L, 3L); @@ -178,7 +178,7 @@ public class CmdFly extends FCommand { public static void checkTaskState() { if (flyMap.keySet().size() == 0) { Bukkit.getScheduler().cancelTask(flyid); - flyid = - 1; + flyid = -1; } } @@ -199,7 +199,7 @@ public class CmdFly extends FCommand { if (!checkBypassPerms(fme, me, toFac)) return; List entities = this.me.getNearbyEntities(16.0D, 256.0D, 16.0D); - for (int i = 0; i <= entities.size() - 1; ++ i) { + for (int i = 0; i <= entities.size() - 1; ++i) { if (entities.get(i) instanceof Player) { Player eplayer = (Player) entities.get(i); FPlayer efplayer = FPlayers.getInstance().getByPlayer(eplayer); @@ -231,12 +231,12 @@ public class CmdFly extends FCommand { public void run() { fme.setFlying(true); flyMap.put(player.getName(), true); - if (id == - 1) { + if (id == -1) { if (SavageFactions.plugin.getConfig().getBoolean("ffly.Particles.Enabled")) { startParticles(); } } - if (flyid == - 1) { + if (flyid == -1) { startFlyCheck(); } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFocus.java b/src/main/java/com/massivecraft/factions/cmd/CmdFocus.java index af1b816e..b01ceb6e 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFocus.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFocus.java @@ -9,18 +9,18 @@ import com.massivecraft.factions.zcore.util.TL; public class CmdFocus extends FCommand { public CmdFocus() { - aliases.add("focus"); + aliases.add("focus"); - requiredArgs.add("player"); + requiredArgs.add("player"); - permission = Permission.FOCUS.node; + permission = Permission.FOCUS.node; - senderMustBePlayer = true; - senderMustBeMember = false; - senderMustBeModerator = true; - senderMustBeColeader = false; - senderMustBeAdmin = false; + senderMustBePlayer = true; + senderMustBeMember = false; + senderMustBeModerator = true; + senderMustBeColeader = false; + senderMustBeAdmin = false; } public void perform() { diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdGetVault.java b/src/main/java/com/massivecraft/factions/cmd/CmdGetVault.java index 1b295b92..a2029688 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdGetVault.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdGetVault.java @@ -18,7 +18,7 @@ public class CmdGetVault extends FCommand { this.disableOnLock = true; - senderMustBePlayer = true; + senderMustBePlayer = true; senderMustBeMember = true; senderMustBeModerator = false; senderMustBeColeader = false; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdHome.java b/src/main/java/com/massivecraft/factions/cmd/CmdHome.java index f508953b..1ec5fed7 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdHome.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdHome.java @@ -31,7 +31,7 @@ public class CmdHome extends FCommand { this.disableOnLock = false; - senderMustBePlayer = true; + senderMustBePlayer = true; senderMustBeMember = true; senderMustBeModerator = false; senderMustBeColeader = false; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdInspect.java b/src/main/java/com/massivecraft/factions/cmd/CmdInspect.java index 5bfdc23e..5e465e4a 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdInspect.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdInspect.java @@ -13,7 +13,7 @@ public class CmdInspect extends FCommand { this.disableOnLock = true; - senderMustBePlayer = true; + senderMustBePlayer = true; senderMustBeMember = true; senderMustBeModerator = false; senderMustBeColeader = false; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdInvite.java b/src/main/java/com/massivecraft/factions/cmd/CmdInvite.java index 61fe711b..a177d8f7 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdInvite.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdInvite.java @@ -24,7 +24,7 @@ public class CmdInvite extends FCommand { this.disableOnLock = true; - senderMustBePlayer = true; + senderMustBePlayer = true; senderMustBeMember = false; senderMustBeModerator = false; senderMustBeColeader = false; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdJoin.java b/src/main/java/com/massivecraft/factions/cmd/CmdJoin.java index 68ed91cc..f34a2bf2 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdJoin.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdJoin.java @@ -19,7 +19,7 @@ public class CmdJoin extends FCommand { this.disableOnLock = true; - senderMustBePlayer = true; + senderMustBePlayer = true; senderMustBeMember = false; senderMustBeModerator = false; senderMustBeColeader = false; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdKick.java b/src/main/java/com/massivecraft/factions/cmd/CmdKick.java index 062abecd..dcdb74ff 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdKick.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdKick.java @@ -27,7 +27,7 @@ public class CmdKick extends FCommand { this.disableOnLock = false; - senderMustBePlayer = true; + senderMustBePlayer = true; senderMustBeMember = false; senderMustBeModerator = false; senderMustBeAdmin = false; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdLeave.java b/src/main/java/com/massivecraft/factions/cmd/CmdLeave.java index a769f87b..b28f4ab6 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdLeave.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdLeave.java @@ -16,7 +16,7 @@ public class CmdLeave extends FCommand { this.disableOnLock = true; - senderMustBePlayer = true; + senderMustBePlayer = true; senderMustBeMember = true; senderMustBeModerator = false; senderMustBeColeader = false; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdList.java b/src/main/java/com/massivecraft/factions/cmd/CmdList.java index f7d828d9..7c6793e1 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdList.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdList.java @@ -53,7 +53,7 @@ public class CmdList extends FCommand { if (fme != null && fme.getPlayer() != null && !fme.getPlayer().hasPermission("factions.show.bypassexempt")) { List exemptFactions = SavageFactions.plugin.getConfig().getStringList("show-exempt"); Iterator factionIterator = factionList.iterator(); - + while (factionIterator.hasNext()) { Faction next = factionIterator.next(); if (exemptFactions.contains(next.getTag())) @@ -70,7 +70,7 @@ public class CmdList extends FCommand { if (f1Size < f2Size) { return 1; } else if (f1Size > f2Size) { - return - 1; + return -1; } return 0; } @@ -85,7 +85,7 @@ public class CmdList extends FCommand { if (f1Size < f2Size) { return 1; } else if (f1Size > f2Size) { - return - 1; + return -1; } return 0; } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdLock.java b/src/main/java/com/massivecraft/factions/cmd/CmdLock.java index 5d08429d..37c1bdac 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdLock.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdLock.java @@ -23,7 +23,7 @@ public class CmdLock extends FCommand { this.disableOnLock = false; - senderMustBePlayer = false; + senderMustBePlayer = false; senderMustBeMember = false; senderMustBeModerator = false; senderMustBeColeader = false; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdLogins.java b/src/main/java/com/massivecraft/factions/cmd/CmdLogins.java index d792627b..b310cbd0 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdLogins.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdLogins.java @@ -13,7 +13,7 @@ public class CmdLogins extends FCommand { this.aliases.add("logouts"); this.senderMustBePlayer = true; - this.senderMustBeMember = true; + this.senderMustBeMember = true; this.permission = Permission.MONITOR_LOGINS.node; } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdLowPower.java b/src/main/java/com/massivecraft/factions/cmd/CmdLowPower.java index 51ba4162..9d40fbe6 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdLowPower.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdLowPower.java @@ -15,7 +15,7 @@ public class CmdLowPower extends FCommand { senderMustBePlayer = true; - senderMustBeMember = true; + senderMustBeMember = true; senderMustBeModerator = false; senderMustBeColeader = true; senderMustBeAdmin = false; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdMap.java b/src/main/java/com/massivecraft/factions/cmd/CmdMap.java index 52f6f7a1..14ec1fce 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdMap.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdMap.java @@ -20,7 +20,7 @@ public class CmdMap extends FCommand { this.disableOnLock = false; - senderMustBePlayer = true; + senderMustBePlayer = true; senderMustBeMember = false; senderMustBeModerator = false; senderMustBeColeader = false; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdMapHeight.java b/src/main/java/com/massivecraft/factions/cmd/CmdMapHeight.java index 72365fb2..eac2f9b2 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdMapHeight.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdMapHeight.java @@ -16,7 +16,7 @@ public class CmdMapHeight extends FCommand { this.permission = Permission.MAPHEIGHT.node; - this.senderMustBePlayer = true; + this.senderMustBePlayer = true; } @Override diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdMod.java b/src/main/java/com/massivecraft/factions/cmd/CmdMod.java index 0aaa25f0..978d4428 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdMod.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdMod.java @@ -25,7 +25,7 @@ public class CmdMod extends FCommand { this.disableOnLock = true; - senderMustBePlayer = false; + senderMustBePlayer = false; senderMustBeMember = true; senderMustBeModerator = false; senderMustBeColeader = true; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdMoneyBalance.java b/src/main/java/com/massivecraft/factions/cmd/CmdMoneyBalance.java index fc3c86a9..bce68b8a 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdMoneyBalance.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdMoneyBalance.java @@ -19,7 +19,7 @@ public class CmdMoneyBalance extends FCommand { this.setHelpShort(TL.COMMAND_MONEYBALANCE_SHORT.toString()); - senderMustBePlayer = false; + senderMustBePlayer = false; senderMustBeMember = false; senderMustBeModerator = false; senderMustBeAdmin = false; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdMoneyDeposit.java b/src/main/java/com/massivecraft/factions/cmd/CmdMoneyDeposit.java index 258ab9e7..cdf79595 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdMoneyDeposit.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdMoneyDeposit.java @@ -22,7 +22,7 @@ public class CmdMoneyDeposit extends FCommand { this.permission = Permission.MONEY_DEPOSIT.node; - senderMustBePlayer = true; + senderMustBePlayer = true; senderMustBeMember = false; senderMustBeModerator = false; senderMustBeColeader = false; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdMoneyTransferFf.java b/src/main/java/com/massivecraft/factions/cmd/CmdMoneyTransferFf.java index 5b4edaab..75d5884d 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdMoneyTransferFf.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdMoneyTransferFf.java @@ -24,7 +24,7 @@ public class CmdMoneyTransferFf extends FCommand { this.permission = Permission.MONEY_F2F.node; - senderMustBePlayer = false; + senderMustBePlayer = false; senderMustBeMember = false; senderMustBeModerator = false; senderMustBeColeader = false; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdMoneyTransferFp.java b/src/main/java/com/massivecraft/factions/cmd/CmdMoneyTransferFp.java index c16114f3..17eb50bb 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdMoneyTransferFp.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdMoneyTransferFp.java @@ -23,7 +23,7 @@ public class CmdMoneyTransferFp extends FCommand { this.permission = Permission.MONEY_F2P.node; - senderMustBePlayer = false; + senderMustBePlayer = false; senderMustBeMember = false; senderMustBeModerator = false; senderMustBeColeader = false; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdMoneyTransferPf.java b/src/main/java/com/massivecraft/factions/cmd/CmdMoneyTransferPf.java index 7adb3d27..474cb70e 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdMoneyTransferPf.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdMoneyTransferPf.java @@ -23,7 +23,7 @@ public class CmdMoneyTransferPf extends FCommand { this.permission = Permission.MONEY_P2F.node; - senderMustBePlayer = false; + senderMustBePlayer = false; senderMustBeMember = false; senderMustBeModerator = false; senderMustBeColeader = false; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdMoneyWithdraw.java b/src/main/java/com/massivecraft/factions/cmd/CmdMoneyWithdraw.java index da6d7332..32f4e07e 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdMoneyWithdraw.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdMoneyWithdraw.java @@ -23,7 +23,7 @@ public class CmdMoneyWithdraw extends FCommand { this.permission = Permission.MONEY_WITHDRAW.node; - senderMustBePlayer = true; + senderMustBePlayer = true; senderMustBeMember = false; senderMustBeModerator = false; senderMustBeColeader = false; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdNear.java b/src/main/java/com/massivecraft/factions/cmd/CmdNear.java index 55216d26..0a6208c8 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdNear.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdNear.java @@ -17,7 +17,7 @@ public class CmdNear extends FCommand { this.disableOnLock = true; - senderMustBePlayer = true; + senderMustBePlayer = true; senderMustBeMember = true; senderMustBeModerator = false; senderMustBeColeader = false; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdOpen.java b/src/main/java/com/massivecraft/factions/cmd/CmdOpen.java index a2a28143..0d3dabe3 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdOpen.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdOpen.java @@ -19,7 +19,7 @@ public class CmdOpen extends FCommand { this.disableOnLock = false; - senderMustBePlayer = true; + senderMustBePlayer = true; senderMustBeMember = false; senderMustBeModerator = false; senderMustBeColeader = true; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdOwnerList.java b/src/main/java/com/massivecraft/factions/cmd/CmdOwnerList.java index 0d7ab2ef..ee49571e 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdOwnerList.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdOwnerList.java @@ -20,7 +20,7 @@ public class CmdOwnerList extends FCommand { this.disableOnLock = false; - senderMustBePlayer = true; + senderMustBePlayer = true; senderMustBeMember = false; senderMustBeModerator = false; senderMustBeColeader = false; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdReload.java b/src/main/java/com/massivecraft/factions/cmd/CmdReload.java index f9ba777d..7cf4b193 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdReload.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdReload.java @@ -26,9 +26,9 @@ public class CmdReload extends FCommand { public void perform() { long timeInitStart = System.currentTimeMillis(); Conf.load(); - Conf.save(); - SavageFactions.plugin.reloadConfig(); - SavageFactions.plugin.changeItemIDSInConfig(); + Conf.save(); + SavageFactions.plugin.reloadConfig(); + SavageFactions.plugin.changeItemIDSInConfig(); SavageFactions.plugin.loadLang(); int version = Integer.parseInt(ReflectionUtils.PackageType.getServerVersion().split("_")[1]); diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdSeeChunk.java b/src/main/java/com/massivecraft/factions/cmd/CmdSeeChunk.java index a270efbc..72327d6e 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdSeeChunk.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdSeeChunk.java @@ -21,7 +21,7 @@ public class CmdSeeChunk extends FCommand { private boolean useParticles; private int length; private ParticleEffect effect; - private int taskID = - 1; + private int taskID = -1; //I remade it cause of people getting mad that I had the same seechunk as drtshock @@ -61,10 +61,10 @@ public class CmdSeeChunk extends FCommand { } private void manageTask() { - if (taskID != - 1) { + if (taskID != -1) { if (seeChunkMap.keySet().size() == 0) { Bukkit.getScheduler().cancelTask(taskID); - taskID = - 1; + taskID = -1; } } else { startTask(); diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdSetDefaultRole.java b/src/main/java/com/massivecraft/factions/cmd/CmdSetDefaultRole.java index 52593ebb..9735f1c0 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdSetDefaultRole.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdSetDefaultRole.java @@ -20,7 +20,7 @@ public class CmdSetDefaultRole extends FCommand { senderMustBeColeader = false; - this.permission = Permission.DEFAULTRANK.node; + this.permission = Permission.DEFAULTRANK.node; } @Override diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdSetFWarp.java b/src/main/java/com/massivecraft/factions/cmd/CmdSetFWarp.java index 7646b54d..6914ac0b 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdSetFWarp.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdSetFWarp.java @@ -24,7 +24,7 @@ public class CmdSetFWarp extends FCommand { this.senderMustBeMember = true; this.senderMustBeModerator = false; - this.senderMustBePlayer = true; + this.senderMustBePlayer = true; this.permission = Permission.SETWARP.node; } @@ -45,7 +45,7 @@ public class CmdSetFWarp extends FCommand { return; } } - + String warp = argAsString(0); // Checks if warp with same name already exists and ignores maxWarp check if it does. diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdSetMaxVaults.java b/src/main/java/com/massivecraft/factions/cmd/CmdSetMaxVaults.java index fbf64c3a..1f3a98f9 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdSetMaxVaults.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdSetMaxVaults.java @@ -28,7 +28,7 @@ public class CmdSetMaxVaults extends FCommand { @Override public void perform() { Faction targetFaction = argAsFaction(0); - int value = argAsInt(1, - 1); + int value = argAsInt(1, -1); if (value < 0) { sender.sendMessage(ChatColor.RED + "Number must be greater than 0."); return; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdShow.java b/src/main/java/com/massivecraft/factions/cmd/CmdShow.java index 48421bb7..66ae2ee8 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdShow.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdShow.java @@ -49,7 +49,7 @@ public class CmdShow extends FCommand { Faction faction = myFaction; if (this.argIsSet(0)) faction = this.argAsFaction(0); - + if (faction == null) return; @@ -94,7 +94,7 @@ public class CmdShow extends FCommand { List fancy = TagUtil.parseFancy(faction, fme, parsed); if (fancy != null) sendFancyMessage(fancy); - + continue; } if (!parsed.contains("{notFrozen}") && !parsed.contains("{notPermanent}")) { diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdShowClaims.java b/src/main/java/com/massivecraft/factions/cmd/CmdShowClaims.java index d5180a63..10c0492b 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdShowClaims.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdShowClaims.java @@ -21,7 +21,6 @@ public class CmdShowClaims extends FCommand { this.senderMustBePlayer = true; - } @Override @@ -35,7 +34,7 @@ public class CmdShowClaims extends FCommand { for (String world : chunkMap.keySet()) { String message = TL.COMMAND_SHOWCLAIMS_FORMAT.toString().replace("{world}", world); sendMessage(message.replace("{chunks}", "")); // made {chunks} blank as I removed the placeholder and people wont update their config :shrug: - StringBuilder chunks = new StringBuilder(); + StringBuilder chunks = new StringBuilder(); for (String chunkString : chunkMap.get(world)) { chunks.append(chunkString + ", "); if (chunks.toString().length() >= 2000) { diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdStatus.java b/src/main/java/com/massivecraft/factions/cmd/CmdStatus.java index bf65781c..4dfec779 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdStatus.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdStatus.java @@ -30,7 +30,7 @@ public class CmdStatus extends FCommand { for (FPlayer fp : myFaction.getFPlayers()) { String humanized = DurationFormatUtils.formatDurationWords(System.currentTimeMillis() - fp.getLastLoginTime(), true, true) + TL.COMMAND_STATUS_AGOSUFFIX; String last = fp.isOnline() ? ChatColor.GREEN + TL.COMMAND_STATUS_ONLINE.toString() : (System.currentTimeMillis() - fp.getLastLoginTime() < 432000000 ? ChatColor.YELLOW + humanized : ChatColor.RED + humanized); - String power = ChatColor.YELLOW + String.valueOf(fp.getPowerRounded()) + " / " + fp.getPowerMaxRounded() + ChatColor.RESET; + String power = ChatColor.YELLOW + String.valueOf(fp.getPowerRounded()) + " / " + fp.getPowerMaxRounded() + ChatColor.RESET; ret.add(String.format(TL.COMMAND_STATUS_FORMAT.toString(), ChatColor.GOLD + fp.getRole().getPrefix() + fp.getName() + ChatColor.RESET, power, last).trim()); } fme.sendMessage(ret); diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdTnt.java b/src/main/java/com/massivecraft/factions/cmd/CmdTnt.java index 9b4bc266..6bb42301 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdTnt.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdTnt.java @@ -99,7 +99,7 @@ public class CmdTnt extends FCommand { return; } if (fme.getFaction().getTnt() < amount) { - fme.msg(TL.COMMAND_TNT_WIDTHDRAW_NOTENOUGH); + fme.msg(TL.COMMAND_TNT_WIDTHDRAW_NOTENOUGH.toString()); return; } int fullStacks = amount / 64; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdTntFill.java b/src/main/java/com/massivecraft/factions/cmd/CmdTntFill.java index 820a627d..915cb06c 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdTntFill.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdTntFill.java @@ -55,7 +55,7 @@ public class CmdTntFill extends FCommand { fme.msg(TL.COMMAND_TNTFILL_AMOUNTMAX.toString().replace("{max}", SavageFactions.plugin.getConfig().getInt("Tntfill.max-amount") + "")); return; } - + try { Integer.parseInt(args.get(1)); } catch (NumberFormatException e) { diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdTop.java b/src/main/java/com/massivecraft/factions/cmd/CmdTop.java index 8749a24c..cd083606 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdTop.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdTop.java @@ -34,7 +34,7 @@ public class CmdTop extends FCommand { } - @Override + @Override public void perform() { // Can sort by: money, members, online, allies, enemies, power, land. // Get all Factions and remove non player ones. @@ -55,7 +55,7 @@ public class CmdTop extends FCommand { if (f1Size < f2Size) { return 1; } else if (f1Size > f2Size) { - return - 1; + return -1; } return 0; } @@ -70,7 +70,7 @@ public class CmdTop extends FCommand { if (f1start > f2start) { return 1; } else if (f1start < f2start) { - return - 1; + return -1; } return 0; } @@ -84,7 +84,7 @@ public class CmdTop extends FCommand { if (f1Size < f2Size) { return 1; } else if (f1Size > f2Size) { - return - 1; + return -1; } return 0; } @@ -98,7 +98,7 @@ public class CmdTop extends FCommand { if (f1Size < f2Size) { return 1; } else if (f1Size > f2Size) { - return - 1; + return -1; } return 0; } @@ -112,7 +112,7 @@ public class CmdTop extends FCommand { if (f1Size < f2Size) { return 1; } else if (f1Size > f2Size) { - return - 1; + return -1; } return 0; } @@ -133,7 +133,7 @@ public class CmdTop extends FCommand { if (f1Size < f2Size) { return 1; } else if (f1Size > f2Size) { - return - 1; + return -1; } return 0; } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdUnban.java b/src/main/java/com/massivecraft/factions/cmd/CmdUnban.java index 349afe93..86ba4be7 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdUnban.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdUnban.java @@ -22,7 +22,7 @@ public class CmdUnban extends FCommand { senderMustBeMember = false; senderMustBeModerator = false; - senderMustBeAdmin = false; + senderMustBeAdmin = false; } @Override diff --git a/src/main/java/com/massivecraft/factions/cmd/FCommand.java b/src/main/java/com/massivecraft/factions/cmd/FCommand.java index db49bdbf..e8e9d635 100644 --- a/src/main/java/com/massivecraft/factions/cmd/FCommand.java +++ b/src/main/java/com/massivecraft/factions/cmd/FCommand.java @@ -45,10 +45,9 @@ public abstract class FCommand extends MCommand { } @Override - public void setCommandSender(CommandSender sender) - { - super.setCommandSender(sender); - if (sender instanceof Player) { + public void setCommandSender(CommandSender sender) { + super.setCommandSender(sender); + if (sender instanceof Player) { this.fme = FPlayers.getInstance().getByPlayer((Player) sender); this.myFaction = this.fme.getFaction(); } else { @@ -56,7 +55,7 @@ public abstract class FCommand extends MCommand { this.myFaction = null; } } - + @Override public void execute(CommandSender sender, List args, List> commandChain) { setCommandSender(sender); @@ -312,9 +311,9 @@ public abstract class FCommand extends MCommand { } if (Conf.bankEnabled && Conf.bankFactionPaysCosts && fme.hasFaction()) { - return Econ.modifyMoney(myFaction, - cost, toDoThis, forDoingThis); + return Econ.modifyMoney(myFaction, -cost, toDoThis, forDoingThis); } else { - return Econ.modifyMoney(fme, - cost, toDoThis, forDoingThis); + return Econ.modifyMoney(fme, -cost, toDoThis, forDoingThis); } } diff --git a/src/main/java/com/massivecraft/factions/cmd/FPromoteCommand.java b/src/main/java/com/massivecraft/factions/cmd/FPromoteCommand.java index 052fadd3..d36779ed 100644 --- a/src/main/java/com/massivecraft/factions/cmd/FPromoteCommand.java +++ b/src/main/java/com/massivecraft/factions/cmd/FPromoteCommand.java @@ -39,7 +39,7 @@ public class FPromoteCommand extends FCommand { } Role current = target.getRole(); - Role promotion = Role.getRelative(current, + relative); + Role promotion = Role.getRelative(current, +relative); // Now it ain't that messy if (!fme.isAdminBypassing()) { diff --git a/src/main/java/com/massivecraft/factions/cmd/FRelationCommand.java b/src/main/java/com/massivecraft/factions/cmd/FRelationCommand.java index 15450bb0..bf1ee120 100644 --- a/src/main/java/com/massivecraft/factions/cmd/FRelationCommand.java +++ b/src/main/java/com/massivecraft/factions/cmd/FRelationCommand.java @@ -103,9 +103,9 @@ public abstract class FRelationCommand extends FCommand { } private boolean hasMaxRelations(Faction them, Relation targetRelation) { - int max = SavageFactions.plugin.getConfig().getInt("max-relations." + targetRelation.toString(), - 1); + int max = SavageFactions.plugin.getConfig().getInt("max-relations." + targetRelation.toString(), -1); if (SavageFactions.plugin.getConfig().getBoolean("max-relations.enabled", false)) { - if (max != - 1) { + if (max != -1) { if (myFaction.getRelationCount(targetRelation) >= max) { msg(TL.COMMAND_RELATIONS_EXCEEDS_ME, max, targetRelation.getPluralTranslation()); return true; diff --git a/src/main/java/com/massivecraft/factions/event/FactionDisbandEvent.java b/src/main/java/com/massivecraft/factions/event/FactionDisbandEvent.java index 49f54e42..1d810c27 100644 --- a/src/main/java/com/massivecraft/factions/event/FactionDisbandEvent.java +++ b/src/main/java/com/massivecraft/factions/event/FactionDisbandEvent.java @@ -11,9 +11,9 @@ import org.bukkit.event.Cancellable; */ public class FactionDisbandEvent extends FactionEvent implements Cancellable { - private boolean cancelled = false; private final Player sender; private final PlayerDisbandReason reason; + private boolean cancelled = false; public FactionDisbandEvent(Player sender, String factionId, PlayerDisbandReason reason) { super(Factions.getInstance().getFactionById(factionId)); @@ -30,10 +30,10 @@ public class FactionDisbandEvent extends FactionEvent implements Cancellable { } public PlayerDisbandReason getReason() { - return reason; - } + return reason; + } - @Override + @Override public boolean isCancelled() { return cancelled; } @@ -42,7 +42,7 @@ public class FactionDisbandEvent extends FactionEvent implements Cancellable { public void setCancelled(boolean c) { cancelled = c; } - + public enum PlayerDisbandReason { COMMAND, PLUGIN, diff --git a/src/main/java/com/massivecraft/factions/event/PowerRegenEvent.java b/src/main/java/com/massivecraft/factions/event/PowerRegenEvent.java index e037f7ed..b9a7ec2c 100644 --- a/src/main/java/com/massivecraft/factions/event/PowerRegenEvent.java +++ b/src/main/java/com/massivecraft/factions/event/PowerRegenEvent.java @@ -1,9 +1,8 @@ package com.massivecraft.factions.event; -import org.bukkit.event.Cancellable; - import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.Faction; +import org.bukkit.event.Cancellable; /** * Event called when a player regenerate power. diff --git a/src/main/java/com/massivecraft/factions/iface/EconomyParticipator.java b/src/main/java/com/massivecraft/factions/iface/EconomyParticipator.java index 30f4bc6c..9ceeb827 100644 --- a/src/main/java/com/massivecraft/factions/iface/EconomyParticipator.java +++ b/src/main/java/com/massivecraft/factions/iface/EconomyParticipator.java @@ -1,12 +1,12 @@ -package com.massivecraft.factions.iface; - -import com.massivecraft.factions.zcore.util.TL; - -public interface EconomyParticipator extends RelationParticipator { - - public String getAccountId(); - - public void msg(String str, Object... args); - - public void msg(TL translation, Object... args); +package com.massivecraft.factions.iface; + +import com.massivecraft.factions.zcore.util.TL; + +public interface EconomyParticipator extends RelationParticipator { + + String getAccountId(); + + void msg(String str, Object... args); + + void msg(TL translation, Object... args); } \ No newline at end of file diff --git a/src/main/java/com/massivecraft/factions/iface/RelationParticipator.java b/src/main/java/com/massivecraft/factions/iface/RelationParticipator.java index 3bc3f669..a536c43b 100644 --- a/src/main/java/com/massivecraft/factions/iface/RelationParticipator.java +++ b/src/main/java/com/massivecraft/factions/iface/RelationParticipator.java @@ -1,17 +1,17 @@ -package com.massivecraft.factions.iface; - -import com.massivecraft.factions.struct.Relation; -import org.bukkit.ChatColor; - -public interface RelationParticipator { - - public String describeTo(RelationParticipator that); - - public String describeTo(RelationParticipator that, boolean ucfirst); - - public Relation getRelationTo(RelationParticipator that); - - public Relation getRelationTo(RelationParticipator that, boolean ignorePeaceful); - - public ChatColor getColorTo(RelationParticipator to); -} +package com.massivecraft.factions.iface; + +import com.massivecraft.factions.struct.Relation; +import org.bukkit.ChatColor; + +public interface RelationParticipator { + + String describeTo(RelationParticipator that); + + String describeTo(RelationParticipator that, boolean ucfirst); + + Relation getRelationTo(RelationParticipator that); + + Relation getRelationTo(RelationParticipator that, boolean ignorePeaceful); + + ChatColor getColorTo(RelationParticipator to); +} diff --git a/src/main/java/com/massivecraft/factions/integration/Econ.java b/src/main/java/com/massivecraft/factions/integration/Econ.java index e5ce225c..064a150c 100644 --- a/src/main/java/com/massivecraft/factions/integration/Econ.java +++ b/src/main/java/com/massivecraft/factions/integration/Econ.java @@ -141,7 +141,7 @@ public class Econ { // The amount must be positive. // If the amount is negative we must flip and multiply amount with -1. if (amount < 0) { - amount *= - 1; + amount *= -1; EconomyParticipator temp = from; from = to; to = temp; @@ -308,7 +308,7 @@ public class Econ { // The account might not have enough space EconomyResponse er = econ.depositPlayer(acc, delta); if (er.transactionSuccess()) { - modifyUniverseMoney(- delta); + modifyUniverseMoney(-delta); if (forDoingThis != null && !forDoingThis.isEmpty()) { ep.msg("%s gained %s %s.", You, moneyString(delta), forDoingThis); } @@ -324,17 +324,17 @@ public class Econ { // The player should loose money // The player might not have enough. - if (econ.has(acc, - delta) && econ.withdrawPlayer(acc, - delta).transactionSuccess()) { + if (econ.has(acc, -delta) && econ.withdrawPlayer(acc, -delta).transactionSuccess()) { // There is enough money to pay - modifyUniverseMoney(- delta); + modifyUniverseMoney(-delta); if (forDoingThis != null && !forDoingThis.isEmpty()) { - ep.msg("%s lost %s %s.", You, moneyString(- delta), forDoingThis); + ep.msg("%s lost %s %s.", You, moneyString(-delta), forDoingThis); } return true; } else { // There was not enough money to pay if (toDoThis != null && !toDoThis.isEmpty()) { - ep.msg("%s can't afford %s %s.", You, moneyString(- delta), toDoThis); + ep.msg("%s can't afford %s %s.", You, moneyString(-delta), toDoThis); } return false; } @@ -410,7 +410,7 @@ public class Econ { public static boolean modifyBalance(String account, double amount) { if (amount < 0) { - return econ.withdrawPlayer(account, - amount).transactionSuccess(); + return econ.withdrawPlayer(account, -amount).transactionSuccess(); } else { return econ.depositPlayer(account, amount).transactionSuccess(); } diff --git a/src/main/java/com/massivecraft/factions/integration/Essentials.java b/src/main/java/com/massivecraft/factions/integration/Essentials.java index 665f18be..8b0f8222 100644 --- a/src/main/java/com/massivecraft/factions/integration/Essentials.java +++ b/src/main/java/com/massivecraft/factions/integration/Essentials.java @@ -3,11 +3,7 @@ package com.massivecraft.factions.integration; import com.earth2me.essentials.Teleport; import com.earth2me.essentials.Trade; import com.massivecraft.factions.Conf; - import net.ess3.api.IEssentials; - -import java.math.BigDecimal; - import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Location; @@ -15,6 +11,8 @@ import org.bukkit.entity.Player; import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; import org.bukkit.plugin.Plugin; +import java.math.BigDecimal; + public class Essentials { private static IEssentials essentials; diff --git a/src/main/java/com/massivecraft/factions/integration/Worldguard.java b/src/main/java/com/massivecraft/factions/integration/Worldguard.java index ae08e3b5..0e429077 100644 --- a/src/main/java/com/massivecraft/factions/integration/Worldguard.java +++ b/src/main/java/com/massivecraft/factions/integration/Worldguard.java @@ -1,139 +1,139 @@ -package com.massivecraft.factions.integration; - -import com.massivecraft.factions.FLocation; -import com.massivecraft.factions.SavageFactions; -import com.sk89q.worldedit.BlockVector; -import com.sk89q.worldedit.Vector; -import com.sk89q.worldguard.bukkit.WorldGuardPlugin; -import com.sk89q.worldguard.protection.ApplicableRegionSet; -import com.sk89q.worldguard.protection.flags.DefaultFlag; -import com.sk89q.worldguard.protection.managers.RegionManager; -import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion; -import com.sk89q.worldguard.protection.regions.ProtectedRegion; -import org.bukkit.Chunk; -import org.bukkit.Location; -import org.bukkit.World; -import org.bukkit.entity.Player; -import org.bukkit.plugin.Plugin; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -import static com.sk89q.worldguard.bukkit.BukkitUtil.toVector; - -/* - * Worldguard Region Checking - * Author: Spathizilla - */ - -public class Worldguard { - - private static WorldGuardPlugin wg; - private static boolean enabled = false; - - public static void init(Plugin plugin) { - Plugin wgplug = plugin.getServer().getPluginManager().getPlugin("WorldGuard"); - if (wgplug == null || !(wgplug instanceof WorldGuardPlugin)) { - enabled = false; - wg = null; - SavageFactions.plugin.log("Could not hook to WorldGuard. WorldGuard checks are disabled."); - } else { - wg = (WorldGuardPlugin) wgplug; - enabled = true; - SavageFactions.plugin.log("Successfully hooked to WorldGuard."); - } - } - - public static boolean isEnabled() { - return enabled; - } - - // PVP Flag check - // Returns: - // True: PVP is allowed - // False: PVP is disallowed - @SuppressWarnings("deprecation") - public static boolean isPVP(Player player) { - if (!enabled) { - // No WG hooks so we'll always bypass this check. - return true; - } - - Location loc = player.getLocation(); - World world = loc.getWorld(); - Vector pt = toVector(loc); - - RegionManager regionManager = wg.getRegionManager(world); - ApplicableRegionSet set = regionManager.getApplicableRegions(pt); - return set.allows(DefaultFlag.PVP); - } - - // Check if player can build at location by worldguards rules. - // Returns: - // True: Player can build in the region. - // False: Player can not build in the region. - public static boolean playerCanBuild(Player player, Location loc) { - if (!enabled) { - // No WG hooks so we'll always bypass this check. - return false; - } - - World world = loc.getWorld(); - Vector pt = toVector(loc); - - return wg.getRegionManager(world).getApplicableRegions(pt).size() > 0 && wg.canBuild(player, loc); - } - - // Check for Regions in chunk the chunk - // Returns: - // True: Regions found within chunk - // False: No regions found within chunk - - public static boolean checkForRegionsInChunk(FLocation floc) { - Chunk chunk = floc.getWorld().getChunkAt((int) floc.getX(), (int) floc.getZ()); - - return checkForRegionsInChunk(chunk); - } - - public static boolean checkForRegionsInChunk(Location loc) { - Chunk chunk = loc.getWorld().getChunkAt(loc); - - return checkForRegionsInChunk(chunk); - } - - public static boolean checkForRegionsInChunk(Chunk chunk) { - if (!enabled) { - // No WG hooks so we'll always bypass this check. - return false; - } - - World world = chunk.getWorld(); - int minChunkX = chunk.getX() << 4; - int minChunkZ = chunk.getZ() << 4; - int maxChunkX = minChunkX + 15; - int maxChunkZ = minChunkZ + 15; - - int worldHeight = world.getMaxHeight(); // Allow for heights other than default - - BlockVector minChunk = new BlockVector(minChunkX, 0, minChunkZ); - BlockVector maxChunk = new BlockVector(maxChunkX, worldHeight, maxChunkZ); - - RegionManager regionManager = wg.getRegionManager(world); - ProtectedCuboidRegion region = new ProtectedCuboidRegion("wgfactionoverlapcheck", minChunk, maxChunk); - Map allregions = regionManager.getRegions(); - Collection allregionslist = new ArrayList<>(allregions.values()); - List overlaps; - boolean foundregions = false; - - try { - overlaps = region.getIntersectingRegions(allregionslist); - foundregions = overlaps != null && !overlaps.isEmpty(); - } catch (Exception e) { - e.printStackTrace(); - } - - return foundregions; - } +package com.massivecraft.factions.integration; + +import com.massivecraft.factions.FLocation; +import com.massivecraft.factions.SavageFactions; +import com.sk89q.worldedit.BlockVector; +import com.sk89q.worldedit.Vector; +import com.sk89q.worldguard.bukkit.WorldGuardPlugin; +import com.sk89q.worldguard.protection.ApplicableRegionSet; +import com.sk89q.worldguard.protection.flags.DefaultFlag; +import com.sk89q.worldguard.protection.managers.RegionManager; +import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion; +import com.sk89q.worldguard.protection.regions.ProtectedRegion; +import org.bukkit.Chunk; +import org.bukkit.Location; +import org.bukkit.World; +import org.bukkit.entity.Player; +import org.bukkit.plugin.Plugin; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Map; + +import static com.sk89q.worldguard.bukkit.BukkitUtil.toVector; + +/* + * Worldguard Region Checking + * Author: Spathizilla + */ + +public class Worldguard { + + private static WorldGuardPlugin wg; + private static boolean enabled = false; + + public static void init(Plugin plugin) { + Plugin wgplug = plugin.getServer().getPluginManager().getPlugin("WorldGuard"); + if (wgplug == null || !(wgplug instanceof WorldGuardPlugin)) { + enabled = false; + wg = null; + SavageFactions.plugin.log("Could not hook to WorldGuard. WorldGuard checks are disabled."); + } else { + wg = (WorldGuardPlugin) wgplug; + enabled = true; + SavageFactions.plugin.log("Successfully hooked to WorldGuard."); + } + } + + public static boolean isEnabled() { + return enabled; + } + + // PVP Flag check + // Returns: + // True: PVP is allowed + // False: PVP is disallowed + @SuppressWarnings("deprecation") + public static boolean isPVP(Player player) { + if (!enabled) { + // No WG hooks so we'll always bypass this check. + return true; + } + + Location loc = player.getLocation(); + World world = loc.getWorld(); + Vector pt = toVector(loc); + + RegionManager regionManager = wg.getRegionManager(world); + ApplicableRegionSet set = regionManager.getApplicableRegions(pt); + return set.allows(DefaultFlag.PVP); + } + + // Check if player can build at location by worldguards rules. + // Returns: + // True: Player can build in the region. + // False: Player can not build in the region. + public static boolean playerCanBuild(Player player, Location loc) { + if (!enabled) { + // No WG hooks so we'll always bypass this check. + return false; + } + + World world = loc.getWorld(); + Vector pt = toVector(loc); + + return wg.getRegionManager(world).getApplicableRegions(pt).size() > 0 && wg.canBuild(player, loc); + } + + // Check for Regions in chunk the chunk + // Returns: + // True: Regions found within chunk + // False: No regions found within chunk + + public static boolean checkForRegionsInChunk(FLocation floc) { + Chunk chunk = floc.getWorld().getChunkAt((int) floc.getX(), (int) floc.getZ()); + + return checkForRegionsInChunk(chunk); + } + + public static boolean checkForRegionsInChunk(Location loc) { + Chunk chunk = loc.getWorld().getChunkAt(loc); + + return checkForRegionsInChunk(chunk); + } + + public static boolean checkForRegionsInChunk(Chunk chunk) { + if (!enabled) { + // No WG hooks so we'll always bypass this check. + return false; + } + + World world = chunk.getWorld(); + int minChunkX = chunk.getX() << 4; + int minChunkZ = chunk.getZ() << 4; + int maxChunkX = minChunkX + 15; + int maxChunkZ = minChunkZ + 15; + + int worldHeight = world.getMaxHeight(); // Allow for heights other than default + + BlockVector minChunk = new BlockVector(minChunkX, 0, minChunkZ); + BlockVector maxChunk = new BlockVector(maxChunkX, worldHeight, maxChunkZ); + + RegionManager regionManager = wg.getRegionManager(world); + ProtectedCuboidRegion region = new ProtectedCuboidRegion("wgfactionoverlapcheck", minChunk, maxChunk); + Map allregions = regionManager.getRegions(); + Collection allregionslist = new ArrayList<>(allregions.values()); + List overlaps; + boolean foundregions = false; + + try { + overlaps = region.getIntersectingRegions(allregionslist); + foundregions = overlaps != null && !overlaps.isEmpty(); + } catch (Exception e) { + e.printStackTrace(); + } + + return foundregions; + } } \ No newline at end of file diff --git a/src/main/java/com/massivecraft/factions/integration/dynmap/EngineDynmap.java b/src/main/java/com/massivecraft/factions/integration/dynmap/EngineDynmap.java index f512a3be..6aad4390 100644 --- a/src/main/java/com/massivecraft/factions/integration/dynmap/EngineDynmap.java +++ b/src/main/java/com/massivecraft/factions/integration/dynmap/EngineDynmap.java @@ -45,7 +45,8 @@ public class EngineDynmap { public MarkerAPI markerApi; public MarkerSet markerset; - private EngineDynmap() {} + private EngineDynmap() { + } public static EngineDynmap getInstance() { return i; @@ -63,7 +64,7 @@ public class EngineDynmap { } public static String getHtmlPlayerName(FPlayer fplayer) { - return fplayer != null ? escapeHtml(fplayer.getName()):"none"; + return fplayer != null ? escapeHtml(fplayer.getName()) : "none"; } public static String escapeHtml(String string) { @@ -72,8 +73,8 @@ public class EngineDynmap { char c = string.charAt(i); if (c > 127 || c == '"' || c == '<' || c == '>' || c == '&') { out.append("&#") - .append((int) c) - .append(';'); + .append((int) c) + .append(';'); } else { out.append(c); } diff --git a/src/main/java/com/massivecraft/factions/integration/dynmap/TempAreaMarker.java b/src/main/java/com/massivecraft/factions/integration/dynmap/TempAreaMarker.java index 1346aad8..ec346d53 100644 --- a/src/main/java/com/massivecraft/factions/integration/dynmap/TempAreaMarker.java +++ b/src/main/java/com/massivecraft/factions/integration/dynmap/TempAreaMarker.java @@ -10,8 +10,8 @@ public class TempAreaMarker { public String label; public String world; - public double x[]; - public double z[]; + public double[] x; + public double[] z; public String description; public int lineColor; @@ -27,7 +27,7 @@ public class TempAreaMarker { // CREATE // -------------------------------------------- // - public static boolean equals(AreaMarker marker, double x[], double z[]) { + public static boolean equals(AreaMarker marker, double[] x, double[] z) { int length = marker.getCornerCount(); if (x.length != length) { diff --git a/src/main/java/com/massivecraft/factions/listeners/FactionsBlockListener.java b/src/main/java/com/massivecraft/factions/listeners/FactionsBlockListener.java index ee9acf6d..0d2ef465 100644 --- a/src/main/java/com/massivecraft/factions/listeners/FactionsBlockListener.java +++ b/src/main/java/com/massivecraft/factions/listeners/FactionsBlockListener.java @@ -9,7 +9,6 @@ import com.massivecraft.factions.util.Particles.ParticleEffect; import com.massivecraft.factions.zcore.fperms.Access; import com.massivecraft.factions.zcore.fperms.PermissableAction; import com.massivecraft.factions.zcore.util.TL; - import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; @@ -39,7 +38,7 @@ public class FactionsBlockListener implements Listener { public static boolean playerCanBuildDestroyBlock(Player player, Location location, String action, boolean justCheck) { String name = player.getName(); - + if (Conf.playersWhoBypassAllProtection.contains(name)) return true; @@ -84,7 +83,7 @@ public class FactionsBlockListener implements Listener { return false; } - + if (SavageFactions.plugin.getConfig().getBoolean("hcf.raidable", false) && otherFaction.getLandRounded() > otherFaction.getPowerRounded()) return true; @@ -138,19 +137,19 @@ public class FactionsBlockListener implements Listener { if (access != Access.ALLOW && me.getRole() != Role.LEADER) { // TODO: Update this once new access values are added other than just allow / deny. if (access == Access.DENY) { - if (!justCheck) - me.msg(TL.GENERIC_NOPERMISSION, action); + if (!justCheck) + me.msg(TL.GENERIC_NOPERMISSION, action); return false; } else if (myFaction.getOwnerListString(loc) != null && !myFaction.getOwnerListString(loc).isEmpty() && !myFaction.getOwnerListString(loc).contains(player.getName())) { - if (!justCheck) - me.msg("You can't " + action + " in this territory, it is owned by: " + myFaction.getOwnerListString(loc)); + if (!justCheck) + me.msg("You can't " + action + " in this territory, it is owned by: " + myFaction.getOwnerListString(loc)); return false; } } return true; } - @EventHandler (priority = EventPriority.NORMAL, ignoreCancelled = true) + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void onBlockPlace(BlockPlaceEvent event) { if (!event.canBuild()) { return; @@ -166,7 +165,7 @@ public class FactionsBlockListener implements Listener { } } - @EventHandler (priority = EventPriority.NORMAL, ignoreCancelled = true) + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void onBlockFromTo(BlockFromToEvent event) { if (!Conf.handleExploitLiquidFlow) { return; @@ -190,14 +189,14 @@ public class FactionsBlockListener implements Listener { } } - @EventHandler (priority = EventPriority.NORMAL, ignoreCancelled = true) + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void onBlockDamage(BlockDamageEvent event) { if (event.getInstaBreak() && !playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), "destroy", false)) { event.setCancelled(true); } } - @EventHandler (priority = EventPriority.NORMAL, ignoreCancelled = true) + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void onBlockPistonExtend(BlockPistonExtendEvent event) { if (!Conf.pistonProtectionThroughDenyBuild) { return; @@ -219,7 +218,7 @@ public class FactionsBlockListener implements Listener { * only the final target block as done above */ } - + @EventHandler public void onVaultPlace(BlockPlaceEvent e) { if (e.getItemInHand().getType() == Material.CHEST) { @@ -304,7 +303,7 @@ public class FactionsBlockListener implements Listener { } - @EventHandler (priority = EventPriority.NORMAL, ignoreCancelled = true) + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void onBlockPistonRetract(BlockPistonRetractEvent event) { // if not a sticky piston, retraction should be fine if (!event.isSticky() || !Conf.pistonProtectionThroughDenyBuild) { @@ -372,7 +371,7 @@ public class FactionsBlockListener implements Listener { // if (fplayer == fme) { continue; } //Idk if I wanna not send the title to the player fplayer.getPlayer().sendTitle(SavageFactions.plugin.color(fme.getTag() + " Placed A WarBanner!"), SavageFactions.plugin.color("&7use &c/f tpbanner&7 to tp to the banner!"), 10, 70, 20); } - + bannerCooldownMap.put(fme.getTag(), true); bannerLocations.put(fme.getTag(), e.getBlockPlaced().getLocation()); final int bannerCooldown = SavageFactions.plugin.getConfig().getInt("fbanners.Banner-Place-Cooldown"); @@ -439,7 +438,7 @@ public class FactionsBlockListener implements Listener { } } - @EventHandler (priority = EventPriority.NORMAL, ignoreCancelled = true) + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void onFrostWalker(EntityBlockFormEvent event) { if (event.getEntity() == null || event.getEntity().getType() != EntityType.PLAYER || event.getBlock() == null) { return; @@ -485,7 +484,7 @@ public class FactionsBlockListener implements Listener { return !rel.confDenyBuild(otherFaction.hasPlayersOnline()); } - @EventHandler (priority = EventPriority.NORMAL, ignoreCancelled = true) + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void onBlockBreak(BlockBreakEvent event) { if (!playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), "destroy", false)) { event.setCancelled(true); @@ -505,22 +504,19 @@ public class FactionsBlockListener implements Listener { } } } - + @EventHandler - public void onFarmLandDamage(EntityChangeBlockEvent event) - { - if (event.getEntity() instanceof Player) - { - Player player = (Player) event.getEntity(); - if (!playerCanBuildDestroyBlock(player, event.getBlock().getLocation(), PermissableAction.DESTROY.name(), true)) - { - FPlayer me = FPlayers.getInstance().getById(player.getUniqueId().toString()); - Faction otherFaction = Board.getInstance().getFactionAt(new FLocation(event.getBlock().getLocation())); - Faction myFaction = me.getFaction(); - - me.msg("You can't jump on farmland in the territory of " + otherFaction.getTag(myFaction)); - event.setCancelled(true); - } - } + public void onFarmLandDamage(EntityChangeBlockEvent event) { + if (event.getEntity() instanceof Player) { + Player player = (Player) event.getEntity(); + if (!playerCanBuildDestroyBlock(player, event.getBlock().getLocation(), PermissableAction.DESTROY.name(), true)) { + FPlayer me = FPlayers.getInstance().getById(player.getUniqueId().toString()); + Faction otherFaction = Board.getInstance().getFactionAt(new FLocation(event.getBlock().getLocation())); + Faction myFaction = me.getFaction(); + + me.msg("You can't jump on farmland in the territory of " + otherFaction.getTag(myFaction)); + event.setCancelled(true); + } + } } } diff --git a/src/main/java/com/massivecraft/factions/listeners/FactionsChatListener.java b/src/main/java/com/massivecraft/factions/listeners/FactionsChatListener.java index 8ce537a9..ff710b86 100644 --- a/src/main/java/com/massivecraft/factions/listeners/FactionsChatListener.java +++ b/src/main/java/com/massivecraft/factions/listeners/FactionsChatListener.java @@ -20,7 +20,7 @@ import java.util.logging.Level; public class FactionsChatListener implements Listener { // this is for handling slashless command usage and faction/alliance chat, set at lowest priority so Factions gets to them first - @EventHandler (priority = EventPriority.LOW, ignoreCancelled = true) + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onPlayerEarlyChat(AsyncPlayerChatEvent event) { Player talkingPlayer = event.getPlayer(); String msg = event.getMessage(); @@ -127,7 +127,7 @@ public class FactionsChatListener implements Listener { // this is for handling insertion of the player's faction tag, set at highest priority to give other plugins a chance to modify chat first - @EventHandler (priority = EventPriority.HIGHEST, ignoreCancelled = true) + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onPlayerChat(AsyncPlayerChatEvent event) { // Are we to insert the Faction tag into the format? // If we are not to insert it - we are done. diff --git a/src/main/java/com/massivecraft/factions/listeners/FactionsEntityListener.java b/src/main/java/com/massivecraft/factions/listeners/FactionsEntityListener.java index 0d00bb1a..7ba67a2d 100644 --- a/src/main/java/com/massivecraft/factions/listeners/FactionsEntityListener.java +++ b/src/main/java/com/massivecraft/factions/listeners/FactionsEntityListener.java @@ -33,7 +33,7 @@ public class FactionsEntityListener implements Listener { private static final Set badPotionEffects = new LinkedHashSet<>(Arrays.asList(PotionEffectType.BLINDNESS, PotionEffectType.CONFUSION, PotionEffectType.HARM, PotionEffectType.HUNGER, PotionEffectType.POISON, PotionEffectType.SLOW, PotionEffectType.SLOW_DIGGING, PotionEffectType.WEAKNESS, PotionEffectType.WITHER)); - @EventHandler (priority = EventPriority.NORMAL) + @EventHandler(priority = EventPriority.NORMAL) public void onEntityDeath(EntityDeathEvent event) { Entity entity = event.getEntity(); if (!(entity instanceof Player)) { @@ -86,7 +86,7 @@ public class FactionsEntityListener implements Listener { * Who can I hurt? I can never hurt members or allies. I can always hurt enemies. I can hurt neutrals as long as * they are outside their own territory. */ - @EventHandler (priority = EventPriority.NORMAL, ignoreCancelled = true) + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void onEntityDamage(EntityDamageEvent event) { if (event instanceof EntityDamageByEntityEvent) { EntityDamageByEntityEvent sub = (EntityDamageByEntityEvent) event; @@ -233,7 +233,7 @@ public class FactionsEntityListener implements Listener { } } - @EventHandler (priority = EventPriority.NORMAL, ignoreCancelled = true) + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void onEntityExplode(EntityExplodeEvent event) { Entity boomer = event.getEntity(); @@ -270,12 +270,12 @@ public class FactionsEntityListener implements Listener { // a single surrounding block in all 6 directions is broken if the material is weak enough List targets = new ArrayList<>(); targets.add(center.getRelative(0, 0, 1)); - targets.add(center.getRelative(0, 0, - 1)); + targets.add(center.getRelative(0, 0, -1)); targets.add(center.getRelative(0, 1, 0)); - targets.add(center.getRelative(0, - 1, 0)); + targets.add(center.getRelative(0, -1, 0)); targets.add(center.getRelative(1, 0, 0)); - targets.add(center.getRelative(- 1, 0, 0)); - + targets.add(center.getRelative(-1, 0, 0)); + for (Block target : targets) { @SuppressWarnings("deprecation") int id = target.getType().getId(); @@ -322,7 +322,7 @@ public class FactionsEntityListener implements Listener { } // mainly for flaming arrows; don't want allies or people in safe zones to be ignited even after damage event is cancelled - @EventHandler (priority = EventPriority.NORMAL, ignoreCancelled = true) + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void onEntityCombustByEntity(EntityCombustByEntityEvent event) { EntityDamageByEntityEvent sub = new EntityDamageByEntityEvent(event.getCombuster(), event.getEntity(), EntityDamageEvent.DamageCause.FIRE, 0d); if (!this.canDamagerHurtDamagee(sub, false)) { @@ -330,7 +330,7 @@ public class FactionsEntityListener implements Listener { } } - @EventHandler (priority = EventPriority.NORMAL, ignoreCancelled = true) + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void onPotionSplashEvent(PotionSplashEvent event) { // see if the potion has a harmful effect boolean badjuju = false; @@ -544,7 +544,7 @@ public class FactionsEntityListener implements Listener { return true; } - @EventHandler (priority = EventPriority.NORMAL, ignoreCancelled = true) + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void onCreatureSpawn(CreatureSpawnEvent event) { if (event.getLocation() == null) { return; @@ -555,7 +555,7 @@ public class FactionsEntityListener implements Listener { } } - @EventHandler (priority = EventPriority.NORMAL, ignoreCancelled = true) + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void onEntityTarget(EntityTargetEvent event) { // if there is a target Entity target = event.getTarget(); @@ -574,7 +574,7 @@ public class FactionsEntityListener implements Listener { } } - @EventHandler (priority = EventPriority.NORMAL, ignoreCancelled = true) + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void onPaintingBreak(HangingBreakEvent event) { if (event.getCause() == RemoveCause.EXPLOSION) { Location loc = event.getEntity().getLocation(); @@ -610,7 +610,7 @@ public class FactionsEntityListener implements Listener { } } - @EventHandler (priority = EventPriority.NORMAL, ignoreCancelled = true) + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void onPaintingPlace(HangingPlaceEvent event) { if (!FactionsBlockListener.playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), "place paintings", false)) { event.setCancelled(true); @@ -619,7 +619,7 @@ public class FactionsEntityListener implements Listener { } } - @EventHandler (priority = EventPriority.NORMAL, ignoreCancelled = true) + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void onEntityChangeBlock(EntityChangeBlockEvent event) { Entity entity = event.getEntity(); @@ -715,7 +715,7 @@ public class FactionsEntityListener implements Listener { } // For disabling interactions with item frames in another faction's territory - @EventHandler (priority = EventPriority.NORMAL, ignoreCancelled = true) + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void onPlayerInteractEntity(PlayerInteractEntityEvent event) { // only need to check for item frames if (event.getRightClicked().getType() != EntityType.ITEM_FRAME) { @@ -731,7 +731,7 @@ public class FactionsEntityListener implements Listener { } // For disabling interactions with armor stands in another faction's territory - @EventHandler (priority = EventPriority.NORMAL, ignoreCancelled = true) + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void onPlayerInteractAtEntity(PlayerInteractAtEntityEvent event) { Entity entity = event.getRightClicked(); diff --git a/src/main/java/com/massivecraft/factions/listeners/FactionsExploitListener.java b/src/main/java/com/massivecraft/factions/listeners/FactionsExploitListener.java index 31d7986a..0639d02c 100644 --- a/src/main/java/com/massivecraft/factions/listeners/FactionsExploitListener.java +++ b/src/main/java/com/massivecraft/factions/listeners/FactionsExploitListener.java @@ -19,7 +19,7 @@ public class FactionsExploitListener implements Listener { } @SuppressWarnings("deprecation") - @EventHandler (priority = EventPriority.NORMAL, ignoreCancelled = true) + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void obsidianGenerator(BlockFromToEvent event) { if (!Conf.handleExploitObsidianGenerators) { return; @@ -34,7 +34,7 @@ public class FactionsExploitListener implements Listener { } } - @EventHandler (priority = EventPriority.NORMAL, ignoreCancelled = true) + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void enderPearlTeleport(PlayerTeleportEvent event) { if (!Conf.handleExploitEnderPearlClipping) { return; diff --git a/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java b/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java index 58d52c90..be484d89 100644 --- a/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java +++ b/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java @@ -1,5 +1,6 @@ package com.massivecraft.factions.listeners; +import com.earth2me.essentials.User; import com.massivecraft.factions.*; import com.massivecraft.factions.cmd.CmdFly; import com.massivecraft.factions.cmd.CmdSeeChunk; @@ -23,6 +24,7 @@ import com.massivecraft.factions.zcore.util.TextUtil; import net.coreprotect.CoreProtect; import net.coreprotect.CoreProtectAPI; import org.bukkit.Bukkit; +import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; @@ -45,763 +47,850 @@ import java.util.logging.Level; public class FactionsPlayerListener implements Listener { - HashMap fallMap = new HashMap<>(); + HashMap fallMap = new HashMap<>(); - // Holds the next time a player can have a map shown. - private HashMap showTimes = new HashMap<>(); - // for handling people who repeatedly spam attempts to open a door (or similar) in another faction's territory - private Map interactSpammers = new HashMap<>(); + // Holds the next time a player can have a map shown. + private HashMap showTimes = new HashMap<>(); + // for handling people who repeatedly spam attempts to open a door (or similar) in another faction's territory + private Map interactSpammers = new HashMap<>(); - public FactionsPlayerListener() { - for (Player player : SavageFactions.plugin.getServer().getOnlinePlayers()) { - initPlayer(player); - } - } - - public static Boolean isSystemFaction(Faction faction) { - return faction.isSafeZone() || - faction.isWarZone() || - faction.isWilderness(); - } - - public static boolean playerCanUseItemHere(Player player, Location location, Material material, boolean justCheck) { - String name = player.getName(); - if (Conf.playersWhoBypassAllProtection.contains(name)) { - return true; + public FactionsPlayerListener() { + for (Player player : SavageFactions.plugin.getServer().getOnlinePlayers()) { + initPlayer(player); + } } - - FPlayer me = FPlayers.getInstance().getByPlayer(player); - if (me.isAdminBypassing()) { - return true; + public static Boolean isSystemFaction(Faction faction) { + return faction.isSafeZone() || + faction.isWarZone() || + faction.isWilderness(); } - FLocation loc = new FLocation(location); - Faction otherFaction = Board.getInstance().getFactionAt(loc); - Faction myFaction = me.getFaction(); - Relation rel = myFaction.getRelationTo(otherFaction); + public static boolean playerCanUseItemHere(Player player, Location location, Material material, boolean justCheck) { + String name = player.getName(); + if (Conf.playersWhoBypassAllProtection.contains(name)) { + return true; + } - // Also cancel if player doesn't have ownership rights for this claim - if (Conf.ownedAreasEnabled && myFaction == otherFaction && !myFaction.playerHasOwnershipRights(me, loc)) { - if (!justCheck) { - me.msg("You can't use that in this territory, it is owned by: " + otherFaction.getOwnerListString(loc)); - } - return false; - } - - if (SavageFactions.plugin.getConfig().getBoolean("hcf.raidable", false) && otherFaction.getLandRounded() > otherFaction.getPowerRounded()) { - return true; - } - if (otherFaction.hasPlayersOnline()) { - if (!Conf.territoryDenyUseageMaterials.contains(material)) { - return true; // Item isn't one we're preventing for online factions. - } - } else { - if (!Conf.territoryDenyUseageMaterialsWhenOffline.contains(material)) { - return true; // Item isn't one we're preventing for offline factions. - } - } + FPlayer me = FPlayers.getInstance().getByPlayer(player); + if (me.isAdminBypassing()) { + return true; + } - if (otherFaction.isWilderness()) { - if (!Conf.wildernessDenyUseage || Conf.worldsNoWildernessProtection.contains(location.getWorld().getName())) { - return true; // This is not faction territory. Use whatever you like here. - } + FLocation loc = new FLocation(location); + Faction otherFaction = Board.getInstance().getFactionAt(loc); + Faction myFaction = me.getFaction(); + Relation rel = myFaction.getRelationTo(otherFaction); - if (!justCheck) { - me.msg(TL.PLAYER_USE_WILDERNESS, TextUtil.getMaterialName(material)); - } + // Also cancel if player doesn't have ownership rights for this claim + if (Conf.ownedAreasEnabled && myFaction == otherFaction && !myFaction.playerHasOwnershipRights(me, loc)) { + if (!justCheck) { + me.msg("You can't use that in this territory, it is owned by: " + otherFaction.getOwnerListString(loc)); + } + return false; + } + + if (SavageFactions.plugin.getConfig().getBoolean("hcf.raidable", false) && otherFaction.getLandRounded() > otherFaction.getPowerRounded()) { + return true; + } + + if (otherFaction.hasPlayersOnline()) { + if (!Conf.territoryDenyUseageMaterials.contains(material)) { + return true; // Item isn't one we're preventing for online factions. + } + } else { + if (!Conf.territoryDenyUseageMaterialsWhenOffline.contains(material)) { + return true; // Item isn't one we're preventing for offline factions. + } + } + + if (otherFaction.isWilderness()) { + if (!Conf.wildernessDenyUseage || Conf.worldsNoWildernessProtection.contains(location.getWorld().getName())) { + return true; // This is not faction territory. Use whatever you like here. + } + + if (!justCheck) { + me.msg(TL.PLAYER_USE_WILDERNESS, TextUtil.getMaterialName(material)); + } + + return false; + } else if (otherFaction.isSafeZone()) { + if (!Conf.safeZoneDenyUseage || Permission.MANAGE_SAFE_ZONE.has(player)) { + return true; + } + + if (!justCheck) { + me.msg(TL.PLAYER_USE_SAFEZONE, TextUtil.getMaterialName(material)); + } + + return false; + } else if (otherFaction.isWarZone()) { + if (!Conf.warZoneDenyUseage || Permission.MANAGE_WAR_ZONE.has(player)) { + return true; + } + + if (!justCheck) { + me.msg(TL.PLAYER_USE_WARZONE, TextUtil.getMaterialName(material)); + } + + return false; + } + + // Cancel if we are not in our own territory + if (rel.confDenyUseage()) { + if (!justCheck) { + me.msg(TL.PLAYER_USE_TERRITORY, TextUtil.getMaterialName(material), otherFaction.getTag(myFaction)); + } + + return false; + } + + Access access = otherFaction.getAccess(me, PermissableAction.ITEM); + if (access != null && access != Access.UNDEFINED) { + // TODO: Update this once new access values are added other than just allow / deny. + if ((myFaction.getOwnerListString(loc) != null && !myFaction.getOwnerListString(loc).isEmpty() && myFaction.getOwnerListString(loc).contains(player.getName()))) { + return true; + } else if (myFaction.getOwnerListString(loc) != null && !myFaction.getOwnerListString(loc).isEmpty() && !myFaction.getOwnerListString(loc).contains(player.getName())) { + me.msg("You can't use items in this territory, it is owned by: " + myFaction.getOwnerListString(loc)); + return false; + } else if (access == Access.DENY) { + me.msg(TL.GENERIC_NOPERMISSION, PermissableAction.ITEM); + return false; + } + } - return false; - } else if (otherFaction.isSafeZone()) { - if (!Conf.safeZoneDenyUseage || Permission.MANAGE_SAFE_ZONE.has(player)) { return true; - } + } - if (!justCheck) { - me.msg(TL.PLAYER_USE_SAFEZONE, TextUtil.getMaterialName(material)); - } + @SuppressWarnings("deprecation") + public static boolean canPlayerUseBlock(Player player, Block block, boolean justCheck) { + if (Conf.playersWhoBypassAllProtection.contains(player.getName())) + return true; - return false; - } else if (otherFaction.isWarZone()) { - if (!Conf.warZoneDenyUseage || Permission.MANAGE_WAR_ZONE.has(player)) { + FPlayer me = FPlayers.getInstance().getByPlayer(player); + if (me.isAdminBypassing()) + return true; + + Material material = block.getType(); + // Dupe fix. + FLocation loc = new FLocation(block); + Faction otherFaction = Board.getInstance().getFactionAt(loc); + Faction myFaction = me.getFaction(); + Relation rel = myFaction.getRelationTo(otherFaction); + + // no door/chest/whatever protection in wilderness, war zones, or safe zones + if (!otherFaction.isNormal()) + return true; + + if (SavageFactions.plugin.getConfig().getBoolean("hcf.raidable", false) && otherFaction.getLandRounded() > otherFaction.getPowerRounded()) + return true; + + if (!rel.isMember() || !otherFaction.playerHasOwnershipRights(me, loc) && player.getItemInHand().getType() != null) { + + if (player.getItemInHand().getType().toString().toUpperCase().contains("DOOR")) + return false; + } + + PermissableAction action = null; + + if (SavageFactions.plugin.mc113) { + switch (block.getType()) { + case LEVER: + action = PermissableAction.LEVER; + break; + + case ACACIA_BUTTON: + case BIRCH_BUTTON: + case DARK_OAK_BUTTON: + case JUNGLE_BUTTON: + case OAK_BUTTON: + case SPRUCE_BUTTON: + case STONE_BUTTON: + action = PermissableAction.BUTTON; + break; + + case ACACIA_DOOR: + case BIRCH_DOOR: + case IRON_DOOR: + case JUNGLE_DOOR: + case OAK_DOOR: + case SPRUCE_DOOR: + case DARK_OAK_DOOR: + + case ACACIA_TRAPDOOR: + case BIRCH_TRAPDOOR: + case DARK_OAK_TRAPDOOR: + case IRON_TRAPDOOR: + case JUNGLE_TRAPDOOR: + case OAK_TRAPDOOR: + case SPRUCE_TRAPDOOR: + + case ACACIA_FENCE_GATE: + case BIRCH_FENCE_GATE: + case DARK_OAK_FENCE_GATE: + case JUNGLE_FENCE_GATE: + case OAK_FENCE_GATE: + case SPRUCE_FENCE_GATE: + action = PermissableAction.DOOR; + break; + + case CHEST: + case TRAPPED_CHEST: + case CHEST_MINECART: + + case SHULKER_BOX: + case BLACK_SHULKER_BOX: + case BLUE_SHULKER_BOX: + case BROWN_SHULKER_BOX: + case CYAN_SHULKER_BOX: + case GRAY_SHULKER_BOX: + case GREEN_SHULKER_BOX: + case LIGHT_BLUE_SHULKER_BOX: + case LIGHT_GRAY_SHULKER_BOX: + case LIME_SHULKER_BOX: + case MAGENTA_SHULKER_BOX: + case ORANGE_SHULKER_BOX: + case PINK_SHULKER_BOX: + case PURPLE_SHULKER_BOX: + case RED_SHULKER_BOX: + case WHITE_SHULKER_BOX: + case YELLOW_SHULKER_BOX: + + case FURNACE: + case DROPPER: + case DISPENSER: + case ENCHANTING_TABLE: + case BREWING_STAND: + case CAULDRON: + case HOPPER: + case BEACON: + case JUKEBOX: + + case ANVIL: + case CHIPPED_ANVIL: + case DAMAGED_ANVIL: + action = PermissableAction.CONTAINER; + break; + default: + // Check for doors that might have diff material name in old version. + if (block.getType().name().contains("DOOR")) { + action = PermissableAction.DOOR; + } + break; + } + } else { + if (block.getType().toString().toUpperCase().contains("BUTTON")) { + action = PermissableAction.BUTTON; + } + + switch (block.getType()) { + case LEVER: + action = PermissableAction.LEVER; + break; + case DARK_OAK_DOOR: + case ACACIA_DOOR: + case BIRCH_DOOR: + case IRON_DOOR: + case JUNGLE_DOOR: + case SPRUCE_DOOR: + case ACACIA_FENCE_GATE: + case BIRCH_FENCE_GATE: + case DARK_OAK_FENCE_GATE: + case JUNGLE_FENCE_GATE: + case SPRUCE_FENCE_GATE: + action = PermissableAction.DOOR; + break; + case CHEST: + case ENDER_CHEST: + case TRAPPED_CHEST: + case DISPENSER: + case ENCHANTING_TABLE: + case DROPPER: + case FURNACE: + case HOPPER: + case ANVIL: + case CHIPPED_ANVIL: + case DAMAGED_ANVIL: + case BREWING_STAND: + action = PermissableAction.CONTAINER; + break; + default: + // Check for doors that might have diff material name in old version. + if (block.getType().name().contains("DOOR")) + action = PermissableAction.DOOR; + break; + } + } + + // We only care about some material types. + if (otherFaction.hasPlayersOnline()) { + if (!Conf.territoryProtectedMaterials.contains(material)) + return true; + } else { + if (!Conf.territoryProtectedMaterialsWhenOffline.contains(material)) + return true; + } + + // Move up access check to check for exceptions + Access access = otherFaction.getAccess(me, action); + boolean doTerritoryEnemyProtectedCheck = true; + + if (action != null && (action.equals(PermissableAction.CONTAINER) || + action.equals(PermissableAction.DOOR))) { + if (access == Access.ALLOW) { + doTerritoryEnemyProtectedCheck = false; + } + } + + // Did not nest the boolean so that it stands out when Im looking + // through the code later. + if (doTerritoryEnemyProtectedCheck) { + // You may use any block unless it is another faction's territory... + if (rel.isNeutral() || (rel.isEnemy() && Conf.territoryEnemyProtectMaterials) || (rel.isAlly() && Conf.territoryAllyProtectMaterials) || (rel.isTruce() && Conf.territoryTruceProtectMaterials)) { + if (!justCheck) { + me.msg(TL.PLAYER_USE_TERRITORY, (material == SavageFactions.plugin.SOIL ? "trample " : "use ") + TextUtil.getMaterialName(material), otherFaction.getTag(myFaction)); + } + return false; + } + } + + if (access != Access.ALLOW && me.getRole() != Role.LEADER) { + // TODO: Update this once new access values are added other than just allow / deny. + if ((myFaction.getOwnerListString(loc) != null && !myFaction.getOwnerListString(loc).isEmpty() && myFaction.getOwnerListString(loc).contains(player.getName()))) { + return true; + } else if (myFaction.getOwnerListString(loc) != null && !myFaction.getOwnerListString(loc).isEmpty() && !myFaction.getOwnerListString(loc).contains(player.getName())) { + me.msg("You can't " + action + " in this territory, it is owned by: " + myFaction.getOwnerListString(loc)); + return false; + } else if (access == Access.DENY) { + me.msg(TL.GENERIC_NOPERMISSION, action); + return false; + } + } return true; - } - - if (!justCheck) { - me.msg(TL.PLAYER_USE_WARZONE, TextUtil.getMaterialName(material)); - } - - return false; } - // Cancel if we are not in our own territory - if (rel.confDenyUseage()) { - if (!justCheck) { - me.msg(TL.PLAYER_USE_TERRITORY, TextUtil.getMaterialName(material), otherFaction.getTag(myFaction)); - } + public static boolean preventCommand(String fullCmd, Player player) { + if ((Conf.territoryNeutralDenyCommands.isEmpty() && Conf.territoryEnemyDenyCommands.isEmpty() && Conf.permanentFactionMemberDenyCommands.isEmpty() && Conf.warzoneDenyCommands.isEmpty())) { + return false; + } - return false; - } + fullCmd = fullCmd.toLowerCase(); - Access access = otherFaction.getAccess(me, PermissableAction.ITEM); - if (access != null && access != Access.UNDEFINED) { - // TODO: Update this once new access values are added other than just allow / deny. - if ((myFaction.getOwnerListString(loc) != null && !myFaction.getOwnerListString(loc).isEmpty() && myFaction.getOwnerListString(loc).contains(player.getName()))) { - return true; - } else if (myFaction.getOwnerListString(loc) != null && !myFaction.getOwnerListString(loc).isEmpty() && !myFaction.getOwnerListString(loc).contains(player.getName())) { - me.msg("You can't use items in this territory, it is owned by: " + myFaction.getOwnerListString(loc)); - return false; - } else if (access == Access.DENY) { - me.msg(TL.GENERIC_NOPERMISSION, PermissableAction.ITEM); - return false; - } - } + FPlayer me = FPlayers.getInstance().getByPlayer(player); - return true; - } - - @SuppressWarnings("deprecation") - public static boolean canPlayerUseBlock(Player player, Block block, boolean justCheck) { - if (Conf.playersWhoBypassAllProtection.contains(player.getName())) - return true; + String shortCmd; // command without the slash at the beginning + if (fullCmd.startsWith("/")) { + shortCmd = fullCmd.substring(1); + } else { + shortCmd = fullCmd; + fullCmd = "/" + fullCmd; + } - FPlayer me = FPlayers.getInstance().getByPlayer(player); - if (me.isAdminBypassing()) - return true; + if (me.hasFaction() && + !me.isAdminBypassing() && + !Conf.permanentFactionMemberDenyCommands.isEmpty() && + me.getFaction().isPermanent() && + isCommandInList(fullCmd, shortCmd, Conf.permanentFactionMemberDenyCommands.iterator())) { + me.msg(TL.PLAYER_COMMAND_PERMANENT, fullCmd); + return true; + } - Material material = block.getType(); - // Dupe fix. - FLocation loc = new FLocation(block); - Faction otherFaction = Board.getInstance().getFactionAt(loc); - Faction myFaction = me.getFaction(); - Relation rel = myFaction.getRelationTo(otherFaction); + Faction at = Board.getInstance().getFactionAt(new FLocation(player.getLocation())); + if (at.isWilderness() && !Conf.wildernessDenyCommands.isEmpty() && !me.isAdminBypassing() && isCommandInList(fullCmd, shortCmd, Conf.wildernessDenyCommands.iterator())) { + me.msg(TL.PLAYER_COMMAND_WILDERNESS, fullCmd); + return true; + } - // no door/chest/whatever protection in wilderness, war zones, or safe zones - if (!otherFaction.isNormal()) - return true; + Relation rel = at.getRelationTo(me); + if (at.isNormal() && rel.isAlly() && !Conf.territoryAllyDenyCommands.isEmpty() && !me.isAdminBypassing() && isCommandInList(fullCmd, shortCmd, Conf.territoryAllyDenyCommands.iterator())) { + me.msg(TL.PLAYER_COMMAND_ALLY, fullCmd); + return false; + } - if (SavageFactions.plugin.getConfig().getBoolean("hcf.raidable", false) && otherFaction.getLandRounded() > otherFaction.getPowerRounded()) - return true; + if (at.isNormal() && rel.isNeutral() && !Conf.territoryNeutralDenyCommands.isEmpty() && !me.isAdminBypassing() && isCommandInList(fullCmd, shortCmd, Conf.territoryNeutralDenyCommands.iterator())) { + me.msg(TL.PLAYER_COMMAND_NEUTRAL, fullCmd); + return true; + } - if (!rel.isMember() || !otherFaction.playerHasOwnershipRights(me, loc) && player.getItemInHand().getType() != null) { + if (at.isNormal() && rel.isEnemy() && !Conf.territoryEnemyDenyCommands.isEmpty() && !me.isAdminBypassing() && isCommandInList(fullCmd, shortCmd, Conf.territoryEnemyDenyCommands.iterator())) { + me.msg(TL.PLAYER_COMMAND_ENEMY, fullCmd); + return true; + } + + if (at.isWarZone() && !Conf.warzoneDenyCommands.isEmpty() && !me.isAdminBypassing() && isCommandInList(fullCmd, shortCmd, Conf.warzoneDenyCommands.iterator())) { + me.msg(TL.PLAYER_COMMAND_WARZONE, fullCmd); + return true; + } - if (player.getItemInHand().getType().toString().toUpperCase().contains("DOOR")) return false; } - PermissableAction action = null; + private static boolean isCommandInList(String fullCmd, String shortCmd, Iterator iter) { + String cmdCheck; + while (iter.hasNext()) { + cmdCheck = iter.next(); + if (cmdCheck == null) { + iter.remove(); + continue; + } - if (SavageFactions.plugin.mc113) { - switch (block.getType()) { - case LEVER: - action = PermissableAction.LEVER; - break; - - case ACACIA_BUTTON: - case BIRCH_BUTTON: - case DARK_OAK_BUTTON: - case JUNGLE_BUTTON: - case OAK_BUTTON: - case SPRUCE_BUTTON: - case STONE_BUTTON: - action = PermissableAction.BUTTON; - break; - - case ACACIA_DOOR: - case BIRCH_DOOR: - case IRON_DOOR: - case JUNGLE_DOOR: - case OAK_DOOR: - case SPRUCE_DOOR: - case DARK_OAK_DOOR: - - case ACACIA_TRAPDOOR: - case BIRCH_TRAPDOOR: - case DARK_OAK_TRAPDOOR: - case IRON_TRAPDOOR: - case JUNGLE_TRAPDOOR: - case OAK_TRAPDOOR: - case SPRUCE_TRAPDOOR: - - case ACACIA_FENCE_GATE: - case BIRCH_FENCE_GATE: - case DARK_OAK_FENCE_GATE: - case JUNGLE_FENCE_GATE: - case OAK_FENCE_GATE: - case SPRUCE_FENCE_GATE: - action = PermissableAction.DOOR; - break; - - case CHEST: - case TRAPPED_CHEST: - case CHEST_MINECART: - - case SHULKER_BOX: - case BLACK_SHULKER_BOX: - case BLUE_SHULKER_BOX: - case BROWN_SHULKER_BOX: - case CYAN_SHULKER_BOX: - case GRAY_SHULKER_BOX: - case GREEN_SHULKER_BOX: - case LIGHT_BLUE_SHULKER_BOX: - case LIGHT_GRAY_SHULKER_BOX: - case LIME_SHULKER_BOX: - case MAGENTA_SHULKER_BOX: - case ORANGE_SHULKER_BOX: - case PINK_SHULKER_BOX: - case PURPLE_SHULKER_BOX: - case RED_SHULKER_BOX: - case WHITE_SHULKER_BOX: - case YELLOW_SHULKER_BOX: - - case FURNACE: - case DROPPER: - case DISPENSER: - case ENCHANTING_TABLE: - case BREWING_STAND: - case CAULDRON: - case HOPPER: - case BEACON: - case JUKEBOX: - - case ANVIL: - case CHIPPED_ANVIL: - case DAMAGED_ANVIL: - action = PermissableAction.CONTAINER; - break; - default: - // Check for doors that might have diff material name in old version. - if (block.getType().name().contains("DOOR")) { - action = PermissableAction.DOOR; - } - break; - } - } else { - if (block.getType().toString().toUpperCase().contains("BUTTON")) { - action = PermissableAction.BUTTON; - } - - switch (block.getType()) { - case LEVER: - action = PermissableAction.LEVER; - break; - case DARK_OAK_DOOR: - case ACACIA_DOOR: - case BIRCH_DOOR: - case IRON_DOOR: - case JUNGLE_DOOR: - case SPRUCE_DOOR: - case ACACIA_FENCE_GATE: - case BIRCH_FENCE_GATE: - case DARK_OAK_FENCE_GATE: - case JUNGLE_FENCE_GATE: - case SPRUCE_FENCE_GATE: - action = PermissableAction.DOOR; - break; - case CHEST: - case ENDER_CHEST: - case TRAPPED_CHEST: - case DISPENSER: - case ENCHANTING_TABLE: - case DROPPER: - case FURNACE: - case HOPPER: - case ANVIL: - case CHIPPED_ANVIL: - case DAMAGED_ANVIL: - case BREWING_STAND: - action = PermissableAction.CONTAINER; - break; - default: - // Check for doors that might have diff material name in old version. - if (block.getType().name().contains("DOOR")) - action = PermissableAction.DOOR; - break; - } - } - - // We only care about some material types. - if (otherFaction.hasPlayersOnline()) { - if (!Conf.territoryProtectedMaterials.contains(material)) - return true; - } else { - if (!Conf.territoryProtectedMaterialsWhenOffline.contains(material)) - return true; - } - - // Move up access check to check for exceptions - Access access = otherFaction.getAccess(me, action); - boolean doTerritoryEnemyProtectedCheck = true; - - if (action != null && (action.equals(PermissableAction.CONTAINER) || - action.equals(PermissableAction.DOOR))) { - if (access == Access.ALLOW) { - doTerritoryEnemyProtectedCheck = false; - } - } - - // Did not nest the boolean so that it stands out when Im looking - // through the code later. - if (doTerritoryEnemyProtectedCheck) { - // You may use any block unless it is another faction's territory... - if (rel.isNeutral() || (rel.isEnemy() && Conf.territoryEnemyProtectMaterials) || (rel.isAlly() && Conf.territoryAllyProtectMaterials) || (rel.isTruce() && Conf.territoryTruceProtectMaterials)) { - if (!justCheck) { - me.msg(TL.PLAYER_USE_TERRITORY, (material == SavageFactions.plugin.SOIL ? "trample " : "use ") + TextUtil.getMaterialName(material), otherFaction.getTag(myFaction)); + cmdCheck = cmdCheck.toLowerCase(); + if (fullCmd.startsWith(cmdCheck) || shortCmd.startsWith(cmdCheck)) { + return true; + } } return false; - } } - if (access != Access.ALLOW && me.getRole() != Role.LEADER) { - // TODO: Update this once new access values are added other than just allow / deny. - if ((myFaction.getOwnerListString(loc) != null && !myFaction.getOwnerListString(loc).isEmpty() && myFaction.getOwnerListString(loc).contains(player.getName()))) { - return true; - } else if (myFaction.getOwnerListString(loc) != null && !myFaction.getOwnerListString(loc).isEmpty() && !myFaction.getOwnerListString(loc).contains(player.getName())) { - me.msg("You can't " + action + " in this territory, it is owned by: " + myFaction.getOwnerListString(loc)); - return false; - } else if (access == Access.DENY) { - me.msg(TL.GENERIC_NOPERMISSION, action); - return false; - } - } - return true; - } - - public static boolean preventCommand(String fullCmd, Player player) { - if ((Conf.territoryNeutralDenyCommands.isEmpty() && Conf.territoryEnemyDenyCommands.isEmpty() && Conf.permanentFactionMemberDenyCommands.isEmpty() && Conf.warzoneDenyCommands.isEmpty())) { - return false; + @EventHandler(priority = EventPriority.NORMAL) + public void onPlayerJoin(PlayerJoinEvent event) { + initPlayer(event.getPlayer()); } - fullCmd = fullCmd.toLowerCase(); + private void initPlayer(Player player) { + // Make sure that all online players do have a fplayer. + final FPlayer me = FPlayers.getInstance().getByPlayer(player); + ((MemoryFPlayer) me).setName(player.getName()); - FPlayer me = FPlayers.getInstance().getByPlayer(player); + // Update the lastLoginTime for this fplayer + me.setLastLoginTime(System.currentTimeMillis()); - String shortCmd; // command without the slash at the beginning - if (fullCmd.startsWith("/")) { - shortCmd = fullCmd.substring(1); - } else { - shortCmd = fullCmd; - fullCmd = "/" + fullCmd; - } + // Store player's current FLocation and notify them where they are + me.setLastStoodAt(new FLocation(player.getLocation())); - if (me.hasFaction() && - !me.isAdminBypassing() && - !Conf.permanentFactionMemberDenyCommands.isEmpty() && - me.getFaction().isPermanent() && - isCommandInList(fullCmd, shortCmd, Conf.permanentFactionMemberDenyCommands.iterator())) { - me.msg(TL.PLAYER_COMMAND_PERMANENT, fullCmd); - return true; - } - - Faction at = Board.getInstance().getFactionAt(new FLocation(player.getLocation())); - if (at.isWilderness() && !Conf.wildernessDenyCommands.isEmpty() && !me.isAdminBypassing() && isCommandInList(fullCmd, shortCmd, Conf.wildernessDenyCommands.iterator())) { - me.msg(TL.PLAYER_COMMAND_WILDERNESS, fullCmd); - return true; - } - - Relation rel = at.getRelationTo(me); - if (at.isNormal() && rel.isAlly() && !Conf.territoryAllyDenyCommands.isEmpty() && !me.isAdminBypassing() && isCommandInList(fullCmd, shortCmd, Conf.territoryAllyDenyCommands.iterator())) { - me.msg(TL.PLAYER_COMMAND_ALLY, fullCmd); - return false; - } - - if (at.isNormal() && rel.isNeutral() && !Conf.territoryNeutralDenyCommands.isEmpty() && !me.isAdminBypassing() && isCommandInList(fullCmd, shortCmd, Conf.territoryNeutralDenyCommands.iterator())) { - me.msg(TL.PLAYER_COMMAND_NEUTRAL, fullCmd); - return true; - } - - if (at.isNormal() && rel.isEnemy() && !Conf.territoryEnemyDenyCommands.isEmpty() && !me.isAdminBypassing() && isCommandInList(fullCmd, shortCmd, Conf.territoryEnemyDenyCommands.iterator())) { - me.msg(TL.PLAYER_COMMAND_ENEMY, fullCmd); - return true; - } - - if (at.isWarZone() && !Conf.warzoneDenyCommands.isEmpty() && !me.isAdminBypassing() && isCommandInList(fullCmd, shortCmd, Conf.warzoneDenyCommands.iterator())) { - me.msg(TL.PLAYER_COMMAND_WARZONE, fullCmd); - return true; - } - - return false; - } - - private static boolean isCommandInList(String fullCmd, String shortCmd, Iterator iter) { - String cmdCheck; - while (iter.hasNext()) { - cmdCheck = iter.next(); - if (cmdCheck == null) { - iter.remove(); - continue; - } - - cmdCheck = cmdCheck.toLowerCase(); - if (fullCmd.startsWith(cmdCheck) || shortCmd.startsWith(cmdCheck)) { - return true; - } - } - return false; - } - - @EventHandler (priority = EventPriority.NORMAL) - public void onPlayerJoin(PlayerJoinEvent event) { - initPlayer(event.getPlayer()); - } - - private void initPlayer(Player player) { - // Make sure that all online players do have a fplayer. - final FPlayer me = FPlayers.getInstance().getByPlayer(player); - ((MemoryFPlayer) me).setName(player.getName()); - - // Update the lastLoginTime for this fplayer - me.setLastLoginTime(System.currentTimeMillis()); - - // Store player's current FLocation and notify them where they are - me.setLastStoodAt(new FLocation(player.getLocation())); - - me.login(); // set kills / deaths - - // Check for Faction announcements. Let's delay this so they actually see it. - Bukkit.getScheduler().runTaskLater(SavageFactions.plugin, new Runnable() { - @Override - public void run() { - if (me.isOnline()) { - me.getFaction().sendUnreadAnnouncements(me); - } - } - }, 33L); // Don't ask me why. - - if (SavageFactions.plugin.getConfig().getBoolean("scoreboard.default-enabled", false)) { - FScoreboard.init(me); - FScoreboard.get(me).setDefaultSidebar(new FDefaultSidebar(), SavageFactions.plugin.getConfig().getInt("scoreboard.default-update-interval", 20)); - FScoreboard.get(me).setSidebarVisibility(me.showScoreboard()); - } - - Faction myFaction = me.getFaction(); - if (!myFaction.isWilderness()) { - for (FPlayer other : myFaction.getFPlayersWhereOnline(true)) { - if (other != me && other.isMonitoringJoins()) { - other.msg(TL.FACTION_LOGIN, me.getName()); - } - } - } - - - fallMap.put(me.getPlayer(), false); - Bukkit.getScheduler().scheduleSyncDelayedTask(SavageFactions.plugin, new Runnable() { - @Override - public void run() { - fallMap.remove(me.getPlayer()); - - } - }, 180L); - - - if (me.isSpyingChat() && !player.hasPermission(Permission.CHATSPY.node)) { - me.setSpyingChat(false); - SavageFactions.plugin.log(Level.INFO, "Found %s spying chat without permission on login. Disabled their chat spying.", player.getName()); - } - - if (me.isAdminBypassing() && !player.hasPermission(Permission.BYPASS.node)) { - me.setIsAdminBypassing(false); - SavageFactions.plugin.log(Level.INFO, "Found %s on admin Bypass without permission on login. Disabled it for them.", player.getName()); - } - - - // If they have the permission, don't let them autoleave. Bad inverted setter :\ - me.setAutoLeave(!player.hasPermission(Permission.AUTO_LEAVE_BYPASS.node)); - me.setTakeFallDamage(true); - } - - @EventHandler - public void onPlayerFall(EntityDamageEvent e) { - if (e.getEntity() instanceof Player) { - if (e.getCause() == EntityDamageEvent.DamageCause.FALL) { - Player player = (Player) e.getEntity(); - if (fallMap.containsKey(player)) { - e.setCancelled(true); - fallMap.remove(player); - } - } - } - } - - @EventHandler (priority = EventPriority.NORMAL) - public void onPlayerQuit(PlayerQuitEvent event) { - FPlayer me = FPlayers.getInstance().getByPlayer(event.getPlayer()); - - // Make sure player's power is up to date when they log off. - me.getPower(); - // and update their last login time to point to when the logged off, for auto-remove routine - me.setLastLoginTime(System.currentTimeMillis()); - - me.logout(); // cache kills / deaths - - // if player is waiting for fstuck teleport but leaves, remove - if (SavageFactions.plugin.getStuckMap().containsKey(me.getPlayer().getUniqueId())) { - FPlayers.getInstance().getByPlayer(me.getPlayer()).msg(TL.COMMAND_STUCK_CANCELLED); - SavageFactions.plugin.getStuckMap().remove(me.getPlayer().getUniqueId()); - SavageFactions.plugin.getTimers().remove(me.getPlayer().getUniqueId()); - } - - Faction myFaction = me.getFaction(); - if (!myFaction.isWilderness()) { - myFaction.memberLoggedOff(); - } - - if (!myFaction.isWilderness()) { - for (FPlayer player : myFaction.getFPlayersWhereOnline(true)) { - if (player != me && player.isMonitoringJoins()) { - player.msg(TL.FACTION_LOGOUT, me.getName()); - } - } - } - - CmdSeeChunk.seeChunkMap.remove(event.getPlayer().getName()); - - FScoreboard.remove(me); - } - - public String parseAllPlaceholders(String string, Faction faction, Player player) { - string = TagUtil.parsePlaceholders(player, string); - - string = string.replace("{Faction}", faction.getTag()) - .replace("{online}", faction.getOnlinePlayers().size() + "") - .replace("{offline}", faction.getFPlayers().size() - faction.getOnlinePlayers().size() + "") - .replace("{chunks}", faction.getAllClaims().size() + "") - .replace("{power}", faction.getPower() + "") - .replace("{leader}", faction.getFPlayerAdmin() + ""); - - return string; - } - - public void enableFly(FPlayer me) { - if (SavageFactions.plugin.getConfig().getBoolean("ffly.AutoEnable")) { - - me.setFlying(true); - CmdFly.flyMap.put(me.getName(), true); - if (CmdFly.id == - 1) { - if (SavageFactions.plugin.getConfig().getBoolean("ffly.Particles.Enabled")) { - CmdFly.startParticles(); - } - } - if (CmdFly.flyid == - 1) { - CmdFly.startFlyCheck(); - } - } - } - - //inspect - @EventHandler - public void onInspect(PlayerInteractEvent e) { - if (e.getAction().name().contains("BLOCK")) { - FPlayer fplayer = FPlayers.getInstance().getByPlayer(e.getPlayer()); - if (!fplayer.isInspectMode()) { - return; - } - e.setCancelled(true); - if (!fplayer.isAdminBypassing()) { - if (!fplayer.hasFaction()) { - fplayer.setInspectMode(false); - fplayer.msg(TL.COMMAND_INSPECT_DISABLED_NOFAC); - return; - } - if (fplayer.getFaction() != Board.getInstance().getFactionAt(new FLocation(e.getPlayer().getLocation()))) { - fplayer.msg(TL.COMMAND_INSPECT_NOTINCLAIM); - return; - } - } else { - fplayer.msg(TL.COMMAND_INSPECT_BYPASS); - } - List info = CoreProtect.getInstance().getAPI().blockLookup(e.getClickedBlock(), 0); - if (info.size() == 0) { - e.getPlayer().sendMessage(TL.COMMAND_INSPECT_NODATA.toString()); - return; - } - Player player = e.getPlayer(); - CoreProtectAPI coAPI = CoreProtect.getInstance().getAPI(); - player.sendMessage(TL.COMMAND_INSPECT_HEADER.toString().replace("{x}", e.getClickedBlock().getX() + "") - .replace("{y}", e.getClickedBlock().getY() + "") - .replace("{z}", e.getClickedBlock().getZ() + "")); - String rowFormat = TL.COMMAND_INSPECT_ROW.toString(); - for (int i = 0; i < info.size(); i++) { - CoreProtectAPI.ParseResult row = coAPI.parseResult(info.get(0)); - player.sendMessage(rowFormat - .replace("{time}", convertTime(row.getTime())) - .replace("{action}", row.getActionString()) - .replace("{player}", row.getPlayer()) - .replace("{block-type}", row.getType().toString().toLowerCase())); - } - } - } - - //For disabling enderpearl throws - @EventHandler - public void onPearl(PlayerInteractEvent e) { - Player player = e.getPlayer(); - if (player.getItemInHand().getType() == Material.ENDER_PEARL) { - FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player); - if (fPlayer.isFlying()) { - if (Conf.noEnderpearlsInFly) { - fPlayer.msg(TL.COMMAND_FLY_NO_EPEARL); - e.setCancelled(true); - } - } - } - } - - private String convertTime(int time) { - String result = String.valueOf(Math.round((System.currentTimeMillis() / 1000L - time) / 36.0D) / 100.0D); - return (result.length() == 3 ? result + "0" : result) + "/hrs ago"; - } - - - @EventHandler (priority = EventPriority.MONITOR, ignoreCancelled = true) - public void onPlayerMove(PlayerMoveEvent event) { - Player player = event.getPlayer(); - FPlayer me = FPlayers.getInstance().getByPlayer(player); - - // clear visualization - if (event.getFrom().getBlockX() != event.getTo().getBlockX() || event.getFrom().getBlockY() != event.getTo().getBlockY() || event.getFrom().getBlockZ() != event.getTo().getBlockZ()) { - VisualizeUtil.clear(event.getPlayer()); - if (me.isWarmingUp()) { - me.clearWarmup(); - me.msg(TL.WARMUPS_CANCELLED); - } - } - - // quick check to make sure player is moving between chunks; good performance boost - if (event.getFrom().getBlockX() >> 4 == event.getTo().getBlockX() >> 4 && event.getFrom().getBlockZ() >> 4 == event.getTo().getBlockZ() >> 4 && event.getFrom().getWorld() == event.getTo().getWorld()) { - return; - } - - - // Did we change coord? - FLocation from = me.getLastStoodAt(); - FLocation to = new FLocation(event.getTo()); - - if (from.equals(to)) { - return; - } - - // Yes we did change coord (: - - me.setLastStoodAt(to); - - // Did we change "host"(faction)? - Faction factionFrom = Board.getInstance().getFactionAt(from); - Faction factionTo = Board.getInstance().getFactionAt(to); - boolean changedFaction = (factionFrom != factionTo); - - - if (changedFaction) { - Bukkit.getServer().getPluginManager().callEvent(new FPlayerEnteredFactionEvent(factionTo, factionFrom, me)); - if (SavageFactions.plugin.getConfig().getBoolean("Title.Show-Title")) { - String title = SavageFactions.plugin.getConfig().getString("Title.Format.Title"); - title = title.replace("{Faction}", factionTo.getColorTo(me) + factionTo.getTag()); - title = parseAllPlaceholders(title, factionTo, player); - String subTitle = SavageFactions.plugin.getConfig().getString("Title.Format.Subtitle").replace("{Description}", factionTo.getDescription()).replace("{Faction}", factionTo.getColorTo(me) + factionTo.getTag()); - subTitle = parseAllPlaceholders(subTitle, factionTo, player); - if (!SavageFactions.plugin.mc17) { - if (!SavageFactions.plugin.mc18) { - me.getPlayer().sendTitle(SavageFactions.plugin.color(title), SavageFactions.plugin.color(subTitle), SavageFactions.plugin.getConfig().getInt("Title.Options.FadeInTime"), - SavageFactions.plugin.getConfig().getInt("Title.Options.ShowTime"), - SavageFactions.plugin.getConfig().getInt("Title.Options.FadeOutTime")); - } else { - me.getPlayer().sendTitle(SavageFactions.plugin.color(title), SavageFactions.plugin.color(subTitle)); - } + me.login(); // set kills / deaths + // Check for Faction announcements. Let's delay this so they actually see it. + Bukkit.getScheduler().runTaskLater(SavageFactions.plugin, new Runnable() { + @Override + public void run() { + if (me.isOnline()) { + me.getFaction().sendUnreadAnnouncements(me); + } + } + }, 33L); // Don't ask me why. + if (SavageFactions.plugin.getConfig().getBoolean("scoreboard.default-enabled", false)) { + FScoreboard.init(me); + FScoreboard.get(me).setDefaultSidebar(new FDefaultSidebar(), SavageFactions.plugin.getConfig().getInt("scoreboard.default-update-interval", 20)); + FScoreboard.get(me).setSidebarVisibility(me.showScoreboard()); } - } - - if (!SavageFactions.plugin.factionsFlight) { - return; - } - - - // enable fly :) - if (me.hasFaction() && !me.isFlying()) { - if (factionTo == me.getFaction()) { - enableFly(me); - } - // bypass checks - Relation relationTo = factionTo.getRelationTo(me); - if ((factionTo.isWilderness() && me.canflyinWilderness()) || - (factionTo.isWarZone() && me.canflyinWarzone()) || - (factionTo.isSafeZone() && me.canflyinSafezone()) || - (relationTo == Relation.ENEMY && me.canflyinEnemy()) || - (relationTo == Relation.ALLY && me.canflyinAlly()) || - (relationTo == Relation.TRUCE && me.canflyinTruce()) || - (relationTo == Relation.NEUTRAL && me.canflyinNeutral() && !isSystemFaction(factionTo))) { - enableFly(me); + Faction myFaction = me.getFaction(); + if (!myFaction.isWilderness()) { + for (FPlayer other : myFaction.getFPlayersWhereOnline(true)) { + if (other != me && other.isMonitoringJoins()) { + other.msg(TL.FACTION_LOGIN, me.getName()); + } + } } - } + + fallMap.put(me.getPlayer(), false); + Bukkit.getScheduler().scheduleSyncDelayedTask(SavageFactions.plugin, new Runnable() { + @Override + public void run() { + fallMap.remove(me.getPlayer()); + + } + }, 180L); + + + if (me.isSpyingChat() && !player.hasPermission(Permission.CHATSPY.node)) { + me.setSpyingChat(false); + SavageFactions.plugin.log(Level.INFO, "Found %s spying chat without permission on login. Disabled their chat spying.", player.getName()); + } + + if (me.isAdminBypassing() && !player.hasPermission(Permission.BYPASS.node)) { + me.setIsAdminBypassing(false); + SavageFactions.plugin.log(Level.INFO, "Found %s on admin Bypass without permission on login. Disabled it for them.", player.getName()); + } + + + // If they have the permission, don't let them autoleave. Bad inverted setter :\ + me.setAutoLeave(!player.hasPermission(Permission.AUTO_LEAVE_BYPASS.node)); + me.setTakeFallDamage(true); + } + + @EventHandler + public void onPlayerFall(EntityDamageEvent e) { + if (e.getEntity() instanceof Player) { + if (e.getCause() == EntityDamageEvent.DamageCause.FALL) { + Player player = (Player) e.getEntity(); + if (fallMap.containsKey(player)) { + e.setCancelled(true); + fallMap.remove(player); + } + } + } + } + + @EventHandler(priority = EventPriority.NORMAL) + public void onPlayerQuit(PlayerQuitEvent event) { + FPlayer me = FPlayers.getInstance().getByPlayer(event.getPlayer()); + + // Make sure player's power is up to date when they log off. + me.getPower(); + // and update their last login time to point to when the logged off, for auto-remove routine + me.setLastLoginTime(System.currentTimeMillis()); + + me.logout(); // cache kills / deaths + + // if player is waiting for fstuck teleport but leaves, remove + if (SavageFactions.plugin.getStuckMap().containsKey(me.getPlayer().getUniqueId())) { + FPlayers.getInstance().getByPlayer(me.getPlayer()).msg(TL.COMMAND_STUCK_CANCELLED); + SavageFactions.plugin.getStuckMap().remove(me.getPlayer().getUniqueId()); + SavageFactions.plugin.getTimers().remove(me.getPlayer().getUniqueId()); + } + + Faction myFaction = me.getFaction(); + if (!myFaction.isWilderness()) { + myFaction.memberLoggedOff(); + } + + if (!myFaction.isWilderness()) { + for (FPlayer player : myFaction.getFPlayersWhereOnline(true)) { + if (player != me && player.isMonitoringJoins()) { + player.msg(TL.FACTION_LOGOUT, me.getName()); + } + } + } + + CmdSeeChunk.seeChunkMap.remove(event.getPlayer().getName()); + + FScoreboard.remove(me); + } + + public String parseAllPlaceholders(String string, Faction faction, Player player) { + string = TagUtil.parsePlaceholders(player, string); + + string = string.replace("{Faction}", faction.getTag()) + .replace("{online}", faction.getOnlinePlayers().size() + "") + .replace("{offline}", faction.getFPlayers().size() - faction.getOnlinePlayers().size() + "") + .replace("{chunks}", faction.getAllClaims().size() + "") + .replace("{power}", faction.getPower() + "") + .replace("{leader}", faction.getFPlayerAdmin() + ""); + + return string; + } + + public void enableFly(FPlayer me) { + if (SavageFactions.plugin.getConfig().getBoolean("ffly.AutoEnable")) { + + me.setFlying(true); + CmdFly.flyMap.put(me.getName(), true); + if (CmdFly.id == -1) { + if (SavageFactions.plugin.getConfig().getBoolean("ffly.Particles.Enabled")) { + CmdFly.startParticles(); + } + } + if (CmdFly.flyid == -1) { + CmdFly.startFlyCheck(); + } + } + } + + //inspect + @EventHandler + public void onInspect(PlayerInteractEvent e) { + if (e.getAction().name().contains("BLOCK")) { + FPlayer fplayer = FPlayers.getInstance().getByPlayer(e.getPlayer()); + if (!fplayer.isInspectMode()) { + return; + } + e.setCancelled(true); + if (!fplayer.isAdminBypassing()) { + if (!fplayer.hasFaction()) { + fplayer.setInspectMode(false); + fplayer.msg(TL.COMMAND_INSPECT_DISABLED_NOFAC); + return; + } + if (fplayer.getFaction() != Board.getInstance().getFactionAt(new FLocation(e.getPlayer().getLocation()))) { + fplayer.msg(TL.COMMAND_INSPECT_NOTINCLAIM); + return; + } + } else { + fplayer.msg(TL.COMMAND_INSPECT_BYPASS); + } + List info = CoreProtect.getInstance().getAPI().blockLookup(e.getClickedBlock(), 0); + if (info.size() == 0) { + e.getPlayer().sendMessage(TL.COMMAND_INSPECT_NODATA.toString()); + return; + } + Player player = e.getPlayer(); + CoreProtectAPI coAPI = CoreProtect.getInstance().getAPI(); + player.sendMessage(TL.COMMAND_INSPECT_HEADER.toString().replace("{x}", e.getClickedBlock().getX() + "") + .replace("{y}", e.getClickedBlock().getY() + "") + .replace("{z}", e.getClickedBlock().getZ() + "")); + String rowFormat = TL.COMMAND_INSPECT_ROW.toString(); + for (int i = 0; i < info.size(); i++) { + CoreProtectAPI.ParseResult row = coAPI.parseResult(info.get(0)); + player.sendMessage(rowFormat + .replace("{time}", convertTime(row.getTime())) + .replace("{action}", row.getActionString()) + .replace("{player}", row.getPlayer()) + .replace("{block-type}", row.getType().toString().toLowerCase())); + } + } + } + + //For disabling enderpearl throws + @EventHandler + public void onPearl(PlayerInteractEvent e) { + Player player = e.getPlayer(); + if (player.getItemInHand().getType() == Material.ENDER_PEARL) { + FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player); + if (fPlayer.isFlying()) { + if (Conf.noEnderpearlsInFly) { + fPlayer.msg(TL.COMMAND_FLY_NO_EPEARL); + e.setCancelled(true); + } + } + } + } + + //For Blocking Homes and Blocking Teleportation To Homes + @EventHandler + public void onPlayerHomeCheck(PlayerTeleportEvent event) throws Exception { + if (event.getPlayer().hasPermission("factions.homes.bypass")) { + return; + } + boolean isHome = false; + for (String str : SavageFactions.plugin.ess.getUser(event.getPlayer()).getHomes()) { + Location home = SavageFactions.plugin.ess.getUser(event.getPlayer()).getHome(str); + if (home.getBlockX() == event.getTo().getBlockX() && home.getBlockY() == event.getTo().getBlockY() && home.getBlockZ() == event.getTo().getBlockZ()) { + isHome = true; + } + } + if (!isHome) { + return; + } + Location loc = event.getTo(); + FLocation floc = new FLocation(event.getTo()); + Faction fac = Board.getInstance().getFactionAt(floc); + Player player = event.getPlayer(); + FPlayer fplayer = FPlayers.getInstance().getByPlayer(player); + User user = SavageFactions.plugin.ess.getUser(event.getPlayer()); + List homes = user.getHomes(); + if (fac.isWilderness() || FPlayers.getInstance().getByPlayer(event.getPlayer()).getFactionId().equals(fac.getId())) { + return; + } + //Warzone and SafeZone Home Initializers + if (fac.isWarZone() || fac.isSafeZone() && SavageFactions.plugin.getConfig().getBoolean("deny-homes-in-system-factions")) { + event.setCancelled(true); + fplayer.msg(TL.COMMAND_HOME_BLOCKED, fac.getTag()); + if (SavageFactions.plugin.getConfig().getBoolean("remove-homes-in-system-factions")) + for (String s : homes) { + if (user.getHome(s).getBlock().getLocation().getChunk().equals(loc.getChunk())) { + user.delHome(s); + } + } + } + + if (fplayer.getFaction().getRelationTo(fac) == Relation.ENEMY && SavageFactions.plugin.getConfig().getBoolean("deny-homes-in-enemy-factions")) { + event.setCancelled(true); + fplayer.msg(TL.COMMAND_HOME_BLOCKED, fac.getTag()); + if (SavageFactions.plugin.getConfig().getBoolean("remove-homes-in-enemy-factions")) + for (String s : homes) { + if (user.getHome(s).getBlock().getLocation().getChunk().equals(loc.getChunk())) { + user.delHome(s); + } + } + } + if (fplayer.getFaction().getRelationTo(fac) == Relation.NEUTRAL && SavageFactions.plugin.getConfig().getBoolean("deny-homes-in-neutral-factions")) { + event.setCancelled(true); + fplayer.msg(TL.COMMAND_HOME_BLOCKED, fac.getTag()); + if (SavageFactions.plugin.getConfig().getBoolean("remove-homes-in-neutral-factions")) + for (String s : homes) { + if (user.getHome(s).getBlock().getLocation().getChunk().equals(loc.getChunk())) { + user.delHome(s); + } + } + } + if (fplayer.getFaction().getRelationTo(fac) == Relation.ALLY && SavageFactions.plugin.getConfig().getBoolean("deny-homes-in-ally-factions")) { + event.setCancelled(true); + fplayer.msg(TL.COMMAND_HOME_BLOCKED, fac.getTag()); + if (SavageFactions.plugin.getConfig().getBoolean("remove-homes-in-ally-factions")) + for (String s : homes) { + if (user.getHome(s).getBlock().getLocation().getChunk().equals(loc.getChunk())) { + user.delHome(s); + } + } + } + if (fplayer.getFaction().getRelationTo(fac) == Relation.TRUCE && SavageFactions.plugin.getConfig().getBoolean("deny-homes-in-truce-factions")) { + event.setCancelled(true); + fplayer.msg(TL.COMMAND_HOME_BLOCKED, fac.getTag()); + if (SavageFactions.plugin.getConfig().getBoolean("remove-homes-in-truce-factions")) + for (String s : homes) { + if (user.getHome(s).getBlock().getLocation().getChunk().equals(loc.getChunk())) { + user.delHome(s); + } + } + } } - if (me.isMapAutoUpdating()) { - if (showTimes.containsKey(player.getUniqueId()) && (showTimes.get(player.getUniqueId()) > System.currentTimeMillis())) { - if (SavageFactions.plugin.getConfig().getBoolean("findfactionsexploit.log", false)) { - SavageFactions.plugin.log(Level.WARNING, "%s tried to show a faction map too soon and triggered exploit blocker.", player.getName()); - } - } else { - me.sendFancyMessage(Board.getInstance().getMap(me, to, player.getLocation().getYaw())); - showTimes.put(player.getUniqueId(), System.currentTimeMillis() + SavageFactions.plugin.getConfig().getLong("findfactionsexploit.cooldown", 2000)); - } - } else { - Faction myFaction = me.getFaction(); - String ownersTo = myFaction.getOwnerListString(to); - if (changedFaction) { - me.sendFactionHereMessage(factionFrom); - if (Conf.ownedAreasEnabled && Conf.ownedMessageOnBorder && myFaction == factionTo && !ownersTo.isEmpty()) { - me.sendMessage(TL.GENERIC_OWNERS.format(ownersTo)); - } - } else if (Conf.ownedAreasEnabled && Conf.ownedMessageInsideTerritory && myFaction == factionTo && !myFaction.isWilderness()) { - String ownersFrom = myFaction.getOwnerListString(from); - if (Conf.ownedMessageByChunk || !ownersFrom.equals(ownersTo)) { - if (!ownersTo.isEmpty()) { - me.sendMessage(TL.GENERIC_OWNERS.format(ownersTo)); - } else if (!TL.GENERIC_PUBLICLAND.toString().isEmpty()) { - me.sendMessage(TL.GENERIC_PUBLICLAND.toString()); - } - } - } + //Colors a String + public String color(String s) { + return ChatColor.translateAlternateColorCodes('&', s); } - if (me.getAutoClaimFor() != null) { - me.attemptClaim(me.getAutoClaimFor(), event.getTo(), true); - } else if (me.isAutoSafeClaimEnabled()) { - if (!Permission.MANAGE_SAFE_ZONE.has(player)) { - me.setIsAutoSafeClaimEnabled(false); - } else { - if (!Board.getInstance().getFactionAt(to).isSafeZone()) { - Board.getInstance().setFactionAt(Factions.getInstance().getSafeZone(), to); - me.msg(TL.PLAYER_SAFEAUTO); - } - } - } else if (me.isAutoWarClaimEnabled()) { - if (!Permission.MANAGE_WAR_ZONE.has(player)) { - me.setIsAutoWarClaimEnabled(false); - } else { - if (!Board.getInstance().getFactionAt(to).isWarZone()) { - Board.getInstance().setFactionAt(Factions.getInstance().getWarZone(), to); - me.msg(TL.PLAYER_WARAUTO); - } - } + + private String convertTime(int time) { + String result = String.valueOf(Math.round((System.currentTimeMillis() / 1000L - time) / 36.0D) / 100.0D); + return (result.length() == 3 ? result + "0" : result) + "/hrs ago"; } - } - @EventHandler - public void onClose(InventoryCloseEvent e) { - FPlayer fme = FPlayers.getInstance().getById(e.getPlayer().getUniqueId().toString()); - if (fme.isInVault()) - fme.setInVault(false); - } - @EventHandler (priority = EventPriority.NORMAL, ignoreCancelled = true) - public void onPlayerInteract(PlayerInteractEvent event) { - /// Prevents the use of montster eggs in oned land. + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onPlayerMove(PlayerMoveEvent event) { + Player player = event.getPlayer(); + FPlayer me = FPlayers.getInstance().getByPlayer(player); + + // clear visualization + if (event.getFrom().getBlockX() != event.getTo().getBlockX() || event.getFrom().getBlockY() != event.getTo().getBlockY() || event.getFrom().getBlockZ() != event.getTo().getBlockZ()) { + VisualizeUtil.clear(event.getPlayer()); + if (me.isWarmingUp()) { + me.clearWarmup(); + me.msg(TL.WARMUPS_CANCELLED); + } + } + + // quick check to make sure player is moving between chunks; good performance boost + if (event.getFrom().getBlockX() >> 4 == event.getTo().getBlockX() >> 4 && event.getFrom().getBlockZ() >> 4 == event.getTo().getBlockZ() >> 4 && event.getFrom().getWorld() == event.getTo().getWorld()) { + return; + } + + + // Did we change coord? + FLocation from = me.getLastStoodAt(); + FLocation to = new FLocation(event.getTo()); + + if (from.equals(to)) { + return; + } + + // Yes we did change coord (: + + me.setLastStoodAt(to); + + // Did we change "host"(faction)? + Faction factionFrom = Board.getInstance().getFactionAt(from); + Faction factionTo = Board.getInstance().getFactionAt(to); + boolean changedFaction = (factionFrom != factionTo); + + + if (changedFaction) { + Bukkit.getServer().getPluginManager().callEvent(new FPlayerEnteredFactionEvent(factionTo, factionFrom, me)); + if (SavageFactions.plugin.getConfig().getBoolean("Title.Show-Title")) { + String title = SavageFactions.plugin.getConfig().getString("Title.Format.Title"); + title = title.replace("{Faction}", factionTo.getColorTo(me) + factionTo.getTag()); + title = parseAllPlaceholders(title, factionTo, player); + String subTitle = SavageFactions.plugin.getConfig().getString("Title.Format.Subtitle").replace("{Description}", factionTo.getDescription()).replace("{Faction}", factionTo.getColorTo(me) + factionTo.getTag()); + subTitle = parseAllPlaceholders(subTitle, factionTo, player); + if (!SavageFactions.plugin.mc17) { + if (!SavageFactions.plugin.mc18) { + me.getPlayer().sendTitle(SavageFactions.plugin.color(title), SavageFactions.plugin.color(subTitle), SavageFactions.plugin.getConfig().getInt("Title.Options.FadeInTime"), + SavageFactions.plugin.getConfig().getInt("Title.Options.ShowTime"), + SavageFactions.plugin.getConfig().getInt("Title.Options.FadeOutTime")); + } else { + me.getPlayer().sendTitle(SavageFactions.plugin.color(title), SavageFactions.plugin.color(subTitle)); + } + + + } + + } + + if (!SavageFactions.plugin.factionsFlight) { + return; + } + + + // enable fly :) + if (me.hasFaction() && !me.isFlying()) { + if (factionTo == me.getFaction()) { + enableFly(me); + } + // bypass checks + Relation relationTo = factionTo.getRelationTo(me); + if ((factionTo.isWilderness() && me.canflyinWilderness()) || + (factionTo.isWarZone() && me.canflyinWarzone()) || + (factionTo.isSafeZone() && me.canflyinSafezone()) || + (relationTo == Relation.ENEMY && me.canflyinEnemy()) || + (relationTo == Relation.ALLY && me.canflyinAlly()) || + (relationTo == Relation.TRUCE && me.canflyinTruce()) || + (relationTo == Relation.NEUTRAL && me.canflyinNeutral() && !isSystemFaction(factionTo))) { + enableFly(me); + } + + } + } + + + if (me.isMapAutoUpdating()) { + if (showTimes.containsKey(player.getUniqueId()) && (showTimes.get(player.getUniqueId()) > System.currentTimeMillis())) { + if (SavageFactions.plugin.getConfig().getBoolean("findfactionsexploit.log", false)) { + SavageFactions.plugin.log(Level.WARNING, "%s tried to show a faction map too soon and triggered exploit blocker.", player.getName()); + } + } else { + me.sendFancyMessage(Board.getInstance().getMap(me, to, player.getLocation().getYaw())); + showTimes.put(player.getUniqueId(), System.currentTimeMillis() + SavageFactions.plugin.getConfig().getLong("findfactionsexploit.cooldown", 2000)); + } + } else { + Faction myFaction = me.getFaction(); + String ownersTo = myFaction.getOwnerListString(to); + if (changedFaction) { + me.sendFactionHereMessage(factionFrom); + if (Conf.ownedAreasEnabled && Conf.ownedMessageOnBorder && myFaction == factionTo && !ownersTo.isEmpty()) { + me.sendMessage(TL.GENERIC_OWNERS.format(ownersTo)); + } + } else if (Conf.ownedAreasEnabled && Conf.ownedMessageInsideTerritory && myFaction == factionTo && !myFaction.isWilderness()) { + String ownersFrom = myFaction.getOwnerListString(from); + if (Conf.ownedMessageByChunk || !ownersFrom.equals(ownersTo)) { + if (!ownersTo.isEmpty()) { + me.sendMessage(TL.GENERIC_OWNERS.format(ownersTo)); + } else if (!TL.GENERIC_PUBLICLAND.toString().isEmpty()) { + me.sendMessage(TL.GENERIC_PUBLICLAND.toString()); + } + } + } + } + + if (me.getAutoClaimFor() != null) { + me.attemptClaim(me.getAutoClaimFor(), event.getTo(), true); + } else if (me.isAutoSafeClaimEnabled()) { + if (!Permission.MANAGE_SAFE_ZONE.has(player)) { + me.setIsAutoSafeClaimEnabled(false); + } else { + if (!Board.getInstance().getFactionAt(to).isSafeZone()) { + Board.getInstance().setFactionAt(Factions.getInstance().getSafeZone(), to); + me.msg(TL.PLAYER_SAFEAUTO); + } + } + } else if (me.isAutoWarClaimEnabled()) { + if (!Permission.MANAGE_WAR_ZONE.has(player)) { + me.setIsAutoWarClaimEnabled(false); + } else { + if (!Board.getInstance().getFactionAt(to).isWarZone()) { + Board.getInstance().setFactionAt(Factions.getInstance().getWarZone(), to); + me.msg(TL.PLAYER_WARAUTO); + } + } + } + } + + @EventHandler + public void onClose(InventoryCloseEvent e) { + FPlayer fme = FPlayers.getInstance().getById(e.getPlayer().getUniqueId().toString()); + if (fme.isInVault()) + fme.setInVault(false); + } + + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void onPlayerInteract(PlayerInteractEvent event) { + /// Prevents the use of montster eggs in oned land. /*if (event.getAction() == Action.RIGHT_CLICK_BLOCK) { if (event.hasItem() || event.hasBlock()) { ItemStack itemStack = event.getItem(); @@ -819,162 +908,159 @@ public class FactionsPlayerListener implements Listener { } } }*/ - // only need to check right-clicks and physical as of MC 1.4+; good performance boost - if (event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.PHYSICAL) - return; + // only need to check right-clicks and physical as of MC 1.4+; good performance boost + if (event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.PHYSICAL) + return; - Block block = event.getClickedBlock(); - Player player = event.getPlayer(); + Block block = event.getClickedBlock(); + Player player = event.getPlayer(); - if (block == null) - return; // clicked in air, apparently + if (block == null) + return; // clicked in air, apparently - if (!canPlayerUseBlock(player, block, false)) { - event.setCancelled(true); - if (Conf.handleExploitInteractionSpam) { - String name = player.getName(); - InteractAttemptSpam attempt = interactSpammers.get(name); - if (attempt == null) { - attempt = new InteractAttemptSpam(); - interactSpammers.put(name, attempt); + if (!canPlayerUseBlock(player, block, false)) { + event.setCancelled(true); + if (Conf.handleExploitInteractionSpam) { + String name = player.getName(); + InteractAttemptSpam attempt = interactSpammers.get(name); + if (attempt == null) { + attempt = new InteractAttemptSpam(); + interactSpammers.put(name, attempt); + } + + int count = attempt.increment(); + if (count >= 10) { + FPlayer me = FPlayers.getInstance().getByPlayer(player); + me.msg(TL.PLAYER_OUCH); + player.damage(NumberConversions.floor((double) count / 10)); + } + } + return; } - - int count = attempt.increment(); - if (count >= 10) { - FPlayer me = FPlayers.getInstance().getByPlayer(player); - me.msg(TL.PLAYER_OUCH); - player.damage(NumberConversions.floor((double) count / 10)); + + if (event.getAction() != Action.RIGHT_CLICK_BLOCK) { + return; // only interested on right-clicks for below + } + + if (!playerCanUseItemHere(player, block.getLocation(), event.getMaterial(), false)) { + event.setCancelled(true); } - } - return; } - if (event.getAction() != Action.RIGHT_CLICK_BLOCK) { - return; // only interested on right-clicks for below + @EventHandler + public void onPlayerBoneMeal(PlayerInteractEvent event) { + Block block = event.getClickedBlock(); + + if (event.getAction() == Action.RIGHT_CLICK_BLOCK && block.getType() == Material.GRASS_BLOCK + && event.hasItem() && event.getItem().getType() == Material.BONE_MEAL) { + if (!FactionsBlockListener.playerCanBuildDestroyBlock(event.getPlayer(), block.getLocation(), PermissableAction.BUILD.name(), true)) { + FPlayer me = FPlayers.getInstance().getById(event.getPlayer().getUniqueId().toString()); + Faction otherFaction = Board.getInstance().getFactionAt(new FLocation(block.getLocation())); + Faction myFaction = me.getFaction(); + + me.msg("You can't use bone meal in the territory of " + otherFaction.getTag(myFaction)); + event.setCancelled(true); + } + } } - if (!playerCanUseItemHere(player, block.getLocation(), event.getMaterial(), false)) { - event.setCancelled(true); - } - } - - @EventHandler - public void onPlayerBoneMeal(PlayerInteractEvent event) - { - Block block = event.getClickedBlock(); - - if (event.getAction() == Action.RIGHT_CLICK_BLOCK && block.getType() == Material.GRASS_BLOCK - && event.hasItem() && event.getItem().getType() == Material.BONE_MEAL) - { - if (!FactionsBlockListener.playerCanBuildDestroyBlock(event.getPlayer(), block.getLocation(), PermissableAction.BUILD.name(), true)) - { - FPlayer me = FPlayers.getInstance().getById(event.getPlayer().getUniqueId().toString()); - Faction otherFaction = Board.getInstance().getFactionAt(new FLocation(block.getLocation())); - Faction myFaction = me.getFaction(); - - me.msg("You can't use bone meal in the territory of " + otherFaction.getTag(myFaction)); - event.setCancelled(true); - } - } - } + @EventHandler(priority = EventPriority.HIGH) + public void onPlayerRespawn(PlayerRespawnEvent event) { + FPlayer me = FPlayers.getInstance().getByPlayer(event.getPlayer()); - @EventHandler (priority = EventPriority.HIGH) - public void onPlayerRespawn(PlayerRespawnEvent event) { - FPlayer me = FPlayers.getInstance().getByPlayer(event.getPlayer()); + me.getPower(); // update power, so they won't have gained any while dead - me.getPower(); // update power, so they won't have gained any while dead - - Location home = me.getFaction().getHome(); - if (Conf.homesEnabled && - Conf.homesTeleportToOnDeath && - home != null && - (Conf.homesRespawnFromNoPowerLossWorlds || !Conf.worldsNoPowerLoss.contains(event.getPlayer().getWorld().getName()))) { - event.setRespawnLocation(home); - } - } - - // For some reason onPlayerInteract() sometimes misses bucket events depending on distance (something like 2-3 blocks away isn't detected), - // but these separate bucket events below always fire without fail - @EventHandler (priority = EventPriority.NORMAL, ignoreCancelled = true) - public void onPlayerBucketEmpty(PlayerBucketEmptyEvent event) { - Block block = event.getBlockClicked(); - Player player = event.getPlayer(); - - if (!playerCanUseItemHere(player, block.getLocation(), event.getBucket(), false)) { - event.setCancelled(true); - } - } - - @EventHandler (priority = EventPriority.NORMAL, ignoreCancelled = true) - public void onPlayerBucketFill(PlayerBucketFillEvent event) { - Block block = event.getBlockClicked(); - Player player = event.getPlayer(); - - if (!playerCanUseItemHere(player, block.getLocation(), event.getBucket(), false)) { - event.setCancelled(true); - } - } - - @EventHandler (priority = EventPriority.HIGH) - public void onPlayerInteractGUI(InventoryClickEvent event) { - if (event.getClickedInventory() == null) { - return; - } - if (event.getClickedInventory().getHolder() instanceof FactionGUI) { - event.setCancelled(true); - ((FactionGUI) event.getClickedInventory().getHolder()).onClick(event.getRawSlot(), event.getClick()); - } - } - - @EventHandler (priority = EventPriority.HIGH) - public void onPlayerMoveGUI(InventoryDragEvent event) { - if (event.getInventory().getHolder() instanceof FactionGUI) { - event.setCancelled(true); - } - } - - @EventHandler (priority = EventPriority.NORMAL, ignoreCancelled = true) - public void onPlayerKick(PlayerKickEvent event) { - FPlayer badGuy = FPlayers.getInstance().getByPlayer(event.getPlayer()); - if (badGuy == null) { - return; + Location home = me.getFaction().getHome(); + if (Conf.homesEnabled && + Conf.homesTeleportToOnDeath && + home != null && + (Conf.homesRespawnFromNoPowerLossWorlds || !Conf.worldsNoPowerLoss.contains(event.getPlayer().getWorld().getName()))) { + event.setRespawnLocation(home); + } } - // if player was banned (not just kicked), get rid of their stored info - if (Conf.removePlayerDataWhenBanned && event.getReason().equals("Banned by admin.")) { - if (badGuy.getRole() == Role.LEADER) { - badGuy.getFaction().promoteNewLeader(); - } + // For some reason onPlayerInteract() sometimes misses bucket events depending on distance (something like 2-3 blocks away isn't detected), + // but these separate bucket events below always fire without fail + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void onPlayerBucketEmpty(PlayerBucketEmptyEvent event) { + Block block = event.getBlockClicked(); + Player player = event.getPlayer(); - badGuy.leave(false); - badGuy.remove(); + if (!playerCanUseItemHere(player, block.getLocation(), event.getBucket(), false)) { + event.setCancelled(true); + } } - } - @EventHandler (priority = EventPriority.MONITOR, ignoreCancelled = true) - final public void onFactionJoin(FPlayerJoinEvent event) { - FTeamWrapper.applyUpdatesLater(event.getFaction()); - } + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void onPlayerBucketFill(PlayerBucketFillEvent event) { + Block block = event.getBlockClicked(); + Player player = event.getPlayer(); - @EventHandler (priority = EventPriority.MONITOR, ignoreCancelled = true) - public void onFactionLeave(FPlayerLeaveEvent event) { - FTeamWrapper.applyUpdatesLater(event.getFaction()); - } - - private static class InteractAttemptSpam { - private int attempts = 0; - private long lastAttempt = System.currentTimeMillis(); - - // returns the current attempt count - public int increment() { - long now = System.currentTimeMillis(); - if (now > lastAttempt + 2000) { - attempts = 1; - } else { - attempts++; - } - lastAttempt = now; - return attempts; + if (!playerCanUseItemHere(player, block.getLocation(), event.getBucket(), false)) { + event.setCancelled(true); + } + } + + @EventHandler(priority = EventPriority.HIGH) + public void onPlayerInteractGUI(InventoryClickEvent event) { + if (event.getClickedInventory() == null) { + return; + } + if (event.getClickedInventory().getHolder() instanceof FactionGUI) { + event.setCancelled(true); + ((FactionGUI) event.getClickedInventory().getHolder()).onClick(event.getRawSlot(), event.getClick()); + } + } + + @EventHandler(priority = EventPriority.HIGH) + public void onPlayerMoveGUI(InventoryDragEvent event) { + if (event.getInventory().getHolder() instanceof FactionGUI) { + event.setCancelled(true); + } + } + + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void onPlayerKick(PlayerKickEvent event) { + FPlayer badGuy = FPlayers.getInstance().getByPlayer(event.getPlayer()); + if (badGuy == null) { + return; + } + + // if player was banned (not just kicked), get rid of their stored info + if (Conf.removePlayerDataWhenBanned && event.getReason().equals("Banned by admin.")) { + if (badGuy.getRole() == Role.LEADER) { + badGuy.getFaction().promoteNewLeader(); + } + + badGuy.leave(false); + badGuy.remove(); + } + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + final public void onFactionJoin(FPlayerJoinEvent event) { + FTeamWrapper.applyUpdatesLater(event.getFaction()); + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onFactionLeave(FPlayerLeaveEvent event) { + FTeamWrapper.applyUpdatesLater(event.getFaction()); + } + + private static class InteractAttemptSpam { + private int attempts = 0; + private long lastAttempt = System.currentTimeMillis(); + + // returns the current attempt count + public int increment() { + long now = System.currentTimeMillis(); + if (now > lastAttempt + 2000) { + attempts = 1; + } else { + attempts++; + } + lastAttempt = now; + return attempts; + } } - } } diff --git a/src/main/java/com/massivecraft/factions/skript/expressions/player/PlayerFactionExpression.java b/src/main/java/com/massivecraft/factions/skript/expressions/player/PlayerFactionExpression.java index 39113271..037a9c03 100644 --- a/src/main/java/com/massivecraft/factions/skript/expressions/player/PlayerFactionExpression.java +++ b/src/main/java/com/massivecraft/factions/skript/expressions/player/PlayerFactionExpression.java @@ -18,80 +18,80 @@ import org.bukkit.event.Event; public class PlayerFactionExpression extends SimpleExpression { - static { - Skript.registerExpression(PlayerFactionExpression.class, String.class, ExpressionType.SIMPLE, "[the] faction of %player%", "[the] %player%['s] faction"); - } + static { + Skript.registerExpression(PlayerFactionExpression.class, String.class, ExpressionType.SIMPLE, "[the] faction of %player%", "[the] %player%['s] faction"); + } - Expression playerExpression; + Expression playerExpression; - @Override - public Class getReturnType() { - return String.class; - } + @Override + public Class getReturnType() { + return String.class; + } - @Override - public boolean isSingle() { - return true; - } + @Override + public boolean isSingle() { + return true; + } - @SuppressWarnings("unchecked") - @Override - public boolean init(Expression[] exprs, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parser) { - playerExpression = (Expression) exprs[0]; - return true; - } + @SuppressWarnings("unchecked") + @Override + public boolean init(Expression[] exprs, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parser) { + playerExpression = (Expression) exprs[0]; + return true; + } - @Override - public String toString(Event event, boolean debug) { - return "Player Faction Name Expression with expression player" + playerExpression.toString(event, debug); - } + @Override + public String toString(Event event, boolean debug) { + return "Player Faction Name Expression with expression player" + playerExpression.toString(event, debug); + } - @Override - protected String[] get(Event event) { - Player player = playerExpression.getSingle(event); + @Override + protected String[] get(Event event) { + Player player = playerExpression.getSingle(event); - if (player != null) { - FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player); - return new String[]{fPlayer.getFaction().getTag()}; - } + if (player != null) { + FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player); + return new String[]{fPlayer.getFaction().getTag()}; + } - return null; + return null; - } + } - @Override - public Class[] acceptChange(final Changer.ChangeMode mode) { - if (mode == Changer.ChangeMode.DELETE || mode == Changer.ChangeMode.RESET || mode == Changer.ChangeMode.SET) { - return CollectionUtils.array(String.class); - } - return null; - } + @Override + public Class[] acceptChange(final Changer.ChangeMode mode) { + if (mode == Changer.ChangeMode.DELETE || mode == Changer.ChangeMode.RESET || mode == Changer.ChangeMode.SET) { + return CollectionUtils.array(String.class); + } + return null; + } - @Override - public void change(Event event, Object[] delta, Changer.ChangeMode mode) { - Player player = playerExpression.getSingle(event); - if (player == null) { - return; - } + @Override + public void change(Event event, Object[] delta, Changer.ChangeMode mode) { + Player player = playerExpression.getSingle(event); + if (player == null) { + return; + } - FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player); - switch (mode) { - case DELETE: - case RESET: - fPlayer.setFaction(Factions.getInstance().getWilderness()); - break; - case SET: - Faction faction = Factions.getInstance().getByTag((String) delta[0]); - if (faction == null) { - faction = Factions.getInstance().getWilderness(); - } - fPlayer.setFaction(faction); - break; - default: - } + FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player); + switch (mode) { + case DELETE: + case RESET: + fPlayer.setFaction(Factions.getInstance().getWilderness()); + break; + case SET: + Faction faction = Factions.getInstance().getByTag((String) delta[0]); + if (faction == null) { + faction = Factions.getInstance().getWilderness(); + } + fPlayer.setFaction(faction); + break; + default: + } - } + } } diff --git a/src/main/java/com/massivecraft/factions/skript/expressions/player/PlayerPowerExpression.java b/src/main/java/com/massivecraft/factions/skript/expressions/player/PlayerPowerExpression.java index dd397780..928da2e5 100644 --- a/src/main/java/com/massivecraft/factions/skript/expressions/player/PlayerPowerExpression.java +++ b/src/main/java/com/massivecraft/factions/skript/expressions/player/PlayerPowerExpression.java @@ -16,80 +16,80 @@ import org.bukkit.event.Event; public class PlayerPowerExpression extends SimpleExpression { - static { - Skript.registerExpression(PlayerPowerExpression.class, Number.class, ExpressionType.SIMPLE, "[the] power of %player%", "[the] %player%['s] power"); - } + static { + Skript.registerExpression(PlayerPowerExpression.class, Number.class, ExpressionType.SIMPLE, "[the] power of %player%", "[the] %player%['s] power"); + } - Expression playerExpression; + Expression playerExpression; - @Override - public Class getReturnType() { - return Double.class; - } + @Override + public Class getReturnType() { + return Double.class; + } - @Override - public boolean isSingle() { - return true; - } + @Override + public boolean isSingle() { + return true; + } - @SuppressWarnings("unchecked") - @Override - public boolean init(Expression[] exprs, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parser) { - playerExpression = (Expression) exprs[0]; - return true; - } + @SuppressWarnings("unchecked") + @Override + public boolean init(Expression[] exprs, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parser) { + playerExpression = (Expression) exprs[0]; + return true; + } - @Override - public String toString(Event event, boolean debug) { - return "Player Power with expression player" + playerExpression.toString(event, debug); - } + @Override + public String toString(Event event, boolean debug) { + return "Player Power with expression player" + playerExpression.toString(event, debug); + } - @Override - protected Double[] get(Event event) { - Player player = playerExpression.getSingle(event); + @Override + protected Double[] get(Event event) { + Player player = playerExpression.getSingle(event); - if (player != null) { - FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player); - return new Double[]{fPlayer.getFaction().getPower()}; - } + if (player != null) { + FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player); + return new Double[]{fPlayer.getFaction().getPower()}; + } - return null; + return null; - } + } - @Override - public Class[] acceptChange(final Changer.ChangeMode mode) { - if (mode == Changer.ChangeMode.RESET || mode == Changer.ChangeMode.ADD || mode == Changer.ChangeMode.REMOVE) { - return CollectionUtils.array(Number.class); - } - return null; - } + @Override + public Class[] acceptChange(final Changer.ChangeMode mode) { + if (mode == Changer.ChangeMode.RESET || mode == Changer.ChangeMode.ADD || mode == Changer.ChangeMode.REMOVE) { + return CollectionUtils.array(Number.class); + } + return null; + } - @Override - public void change(Event event, Object[] delta, Changer.ChangeMode mode) { - Player player = playerExpression.getSingle(event); - if (player == null) { - return; - } + @Override + public void change(Event event, Object[] delta, Changer.ChangeMode mode) { + Player player = playerExpression.getSingle(event); + if (player == null) { + return; + } - FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player); - switch (mode) { - case ADD: - fPlayer.alterPower(Double.valueOf((Long) delta[0])); - break; - case REMOVE: - fPlayer.alterPower(Double.valueOf((Long) delta[0]) * -1); - break; - case RESET: - fPlayer.alterPower(fPlayer.getPowerMax() * -1); - break; - default: - } + FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player); + switch (mode) { + case ADD: + fPlayer.alterPower(Double.valueOf((Long) delta[0])); + break; + case REMOVE: + fPlayer.alterPower(Double.valueOf((Long) delta[0]) * -1); + break; + case RESET: + fPlayer.alterPower(fPlayer.getPowerMax() * -1); + break; + default: + } - } + } } diff --git a/src/main/java/com/massivecraft/factions/skript/expressions/player/PlayerRoleExpression.java b/src/main/java/com/massivecraft/factions/skript/expressions/player/PlayerRoleExpression.java index c0bacef6..13d96ade 100644 --- a/src/main/java/com/massivecraft/factions/skript/expressions/player/PlayerRoleExpression.java +++ b/src/main/java/com/massivecraft/factions/skript/expressions/player/PlayerRoleExpression.java @@ -16,77 +16,77 @@ import org.bukkit.event.Event; public class PlayerRoleExpression extends SimpleExpression { - static { - Skript.registerExpression(PlayerRoleExpression.class, String.class, ExpressionType.SIMPLE, "[the] role of %player%", "[the] %player%['s] role"); - } + static { + Skript.registerExpression(PlayerRoleExpression.class, String.class, ExpressionType.SIMPLE, "[the] role of %player%", "[the] %player%['s] role"); + } - Expression playerExpression; + Expression playerExpression; - @Override - public Class getReturnType() { - return String.class; - } + @Override + public Class getReturnType() { + return String.class; + } - @Override - public boolean isSingle() { - return true; - } + @Override + public boolean isSingle() { + return true; + } - @SuppressWarnings("unchecked") - @Override - public boolean init(Expression[] exprs, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parser) { - playerExpression = (Expression) exprs[0]; - return true; - } + @SuppressWarnings("unchecked") + @Override + public boolean init(Expression[] exprs, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parser) { + playerExpression = (Expression) exprs[0]; + return true; + } - @Override - public String toString(Event event, boolean debug) { - return "Player Faction Name Expression with expression player" + playerExpression.toString(event, debug); - } + @Override + public String toString(Event event, boolean debug) { + return "Player Faction Name Expression with expression player" + playerExpression.toString(event, debug); + } - @Override - protected String[] get(Event event) { - Player player = playerExpression.getSingle(event); + @Override + protected String[] get(Event event) { + Player player = playerExpression.getSingle(event); - if (player != null) { - FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player); - return new String[]{fPlayer.getRole().toString()}; - } + if (player != null) { + FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player); + return new String[]{fPlayer.getRole().toString()}; + } - return null; + return null; - } + } - @Override - public Class[] acceptChange(final Changer.ChangeMode mode) { - if (mode == Changer.ChangeMode.DELETE || mode == Changer.ChangeMode.RESET || mode == Changer.ChangeMode.SET) { - return CollectionUtils.array(String.class); - } - return null; - } + @Override + public Class[] acceptChange(final Changer.ChangeMode mode) { + if (mode == Changer.ChangeMode.DELETE || mode == Changer.ChangeMode.RESET || mode == Changer.ChangeMode.SET) { + return CollectionUtils.array(String.class); + } + return null; + } - @Override - public void change(Event event, Object[] delta, Changer.ChangeMode mode) { - Player player = playerExpression.getSingle(event); - if (player == null) { - return; - } + @Override + public void change(Event event, Object[] delta, Changer.ChangeMode mode) { + Player player = playerExpression.getSingle(event); + if (player == null) { + return; + } - FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player); - switch (mode) { - case DELETE: - case RESET: - fPlayer.setRole(Role.RECRUIT); - break; - case SET: - fPlayer.setRole(Role.fromString(((String) delta[0]).toLowerCase())); - break; - default: - } + FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player); + switch (mode) { + case DELETE: + case RESET: + fPlayer.setRole(Role.RECRUIT); + break; + case SET: + fPlayer.setRole(Role.fromString(((String) delta[0]).toLowerCase())); + break; + default: + } - } + } } diff --git a/src/main/java/com/massivecraft/factions/struct/Relation.java b/src/main/java/com/massivecraft/factions/struct/Relation.java index 647be7e4..2072352b 100644 --- a/src/main/java/com/massivecraft/factions/struct/Relation.java +++ b/src/main/java/com/massivecraft/factions/struct/Relation.java @@ -95,15 +95,19 @@ public enum Relation implements Permissable { } public ChatColor getColor() { - - switch (this) - { - case MEMBER: return Conf.colorMember; - case ALLY: return Conf.colorAlly; - case NEUTRAL: return Conf.colorNeutral; - case TRUCE: return Conf.colorTruce; - default: return Conf.colorEnemy; - } + + switch (this) { + case MEMBER: + return Conf.colorMember; + case ALLY: + return Conf.colorAlly; + case NEUTRAL: + return Conf.colorNeutral; + case TRUCE: + return Conf.colorTruce; + default: + return Conf.colorEnemy; + } } // return appropriate Conf setting for DenyBuild based on this relation and their online status diff --git a/src/main/java/com/massivecraft/factions/struct/Role.java b/src/main/java/com/massivecraft/factions/struct/Role.java index 076d678f..92a94629 100644 --- a/src/main/java/com/massivecraft/factions/struct/Role.java +++ b/src/main/java/com/massivecraft/factions/struct/Role.java @@ -92,15 +92,19 @@ public enum Role implements Permissable { } public String getPrefix() { - - switch (this) - { - case LEADER: return Conf.prefixLeader; - case COLEADER: return Conf.prefixCoLeader; - case MODERATOR: return Conf.prefixMod; - case NORMAL: return Conf.prefixNormal; - case RECRUIT: return Conf.prefixRecruit; - } + + switch (this) { + case LEADER: + return Conf.prefixLeader; + case COLEADER: + return Conf.prefixCoLeader; + case MODERATOR: + return Conf.prefixMod; + case NORMAL: + return Conf.prefixNormal; + case RECRUIT: + return Conf.prefixRecruit; + } return ""; } diff --git a/src/main/java/com/massivecraft/factions/util/ClipPlaceholderAPIManager.java b/src/main/java/com/massivecraft/factions/util/ClipPlaceholderAPIManager.java index 0ae41292..f83b7328 100644 --- a/src/main/java/com/massivecraft/factions/util/ClipPlaceholderAPIManager.java +++ b/src/main/java/com/massivecraft/factions/util/ClipPlaceholderAPIManager.java @@ -107,7 +107,7 @@ public class ClipPlaceholderAPIManager extends PlaceholderExpansion implements R case "faction_claims": return String.valueOf(faction.getAllClaims().size()); case "faction_founded": - return String.valueOf(TL.sdf.format(faction.getFoundedDate())); + return TL.sdf.format(faction.getFoundedDate()); case "faction_joining": return (faction.getOpen() ? TL.COMMAND_SHOW_UNINVITED.toString() : TL.COMMAND_SHOW_INVITATION.toString()); case "faction_peaceful": @@ -156,8 +156,8 @@ public class ClipPlaceholderAPIManager extends PlaceholderExpansion implements R case "faction_maxvaults": return String.valueOf(faction.getMaxVaults()); case "faction_name_at_location": - Faction factionAtLocation = Board.getInstance().getFactionAt(new FLocation(player.getLocation())); - return factionAtLocation != null ? factionAtLocation.getTag():Factions.getInstance().getWilderness().getTag(); + Faction factionAtLocation = Board.getInstance().getFactionAt(new FLocation(player.getLocation())); + return factionAtLocation != null ? factionAtLocation.getTag() : Factions.getInstance().getWilderness().getTag(); } return null; diff --git a/src/main/java/com/massivecraft/factions/util/EnumTypeAdapter.java b/src/main/java/com/massivecraft/factions/util/EnumTypeAdapter.java index 796fe5e5..f5b2b975 100644 --- a/src/main/java/com/massivecraft/factions/util/EnumTypeAdapter.java +++ b/src/main/java/com/massivecraft/factions/util/EnumTypeAdapter.java @@ -1,66 +1,66 @@ -package com.massivecraft.factions.util; - -import com.google.gson.Gson; -import com.google.gson.TypeAdapter; -import com.google.gson.TypeAdapterFactory; -import com.google.gson.annotations.SerializedName; -import com.google.gson.reflect.TypeToken; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonToken; -import com.google.gson.stream.JsonWriter; - -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; - -public final class EnumTypeAdapter> extends TypeAdapter { - - public static final TypeAdapterFactory ENUM_FACTORY = newEnumTypeHierarchyFactory(); - private final Map nameToConstant = new HashMap<>(); - private final Map constantToName = new HashMap<>(); - - public EnumTypeAdapter(Class classOfT) { - try { - for (T constant : classOfT.getEnumConstants()) { - String name = constant.name(); - SerializedName annotation = classOfT.getField(name).getAnnotation(SerializedName.class); - if (annotation != null) { - name = annotation.value(); - } - nameToConstant.put(name, constant); - constantToName.put(constant, name); - } - } catch (NoSuchFieldException e) { - // ignore since it could be a modified enum - } - } - - public static TypeAdapterFactory newEnumTypeHierarchyFactory() { - return new TypeAdapterFactory() { - @SuppressWarnings ({"rawtypes", "unchecked"}) - public TypeAdapter create(Gson gson, TypeToken typeToken) { - Class rawType = typeToken.getRawType(); - if (!Enum.class.isAssignableFrom(rawType) || rawType == Enum.class) { - return null; - } - if (!rawType.isEnum()) { - rawType = rawType.getSuperclass(); // handle anonymous subclasses - } - return (TypeAdapter) new EnumTypeAdapter(rawType); - } - }; - } - - public T read(JsonReader in) throws IOException { - if (in.peek() == JsonToken.NULL) { - in.nextNull(); - return null; - } - return nameToConstant.get(in.nextString()); - } - - public void write(JsonWriter out, T value) throws IOException { - out.value(value == null ? null : constantToName.get(value)); - } - -} +package com.massivecraft.factions.util; + +import com.google.gson.Gson; +import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.annotations.SerializedName; +import com.google.gson.reflect.TypeToken; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonToken; +import com.google.gson.stream.JsonWriter; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; + +public final class EnumTypeAdapter> extends TypeAdapter { + + public static final TypeAdapterFactory ENUM_FACTORY = newEnumTypeHierarchyFactory(); + private final Map nameToConstant = new HashMap<>(); + private final Map constantToName = new HashMap<>(); + + public EnumTypeAdapter(Class classOfT) { + try { + for (T constant : classOfT.getEnumConstants()) { + String name = constant.name(); + SerializedName annotation = classOfT.getField(name).getAnnotation(SerializedName.class); + if (annotation != null) { + name = annotation.value(); + } + nameToConstant.put(name, constant); + constantToName.put(constant, name); + } + } catch (NoSuchFieldException e) { + // ignore since it could be a modified enum + } + } + + public static TypeAdapterFactory newEnumTypeHierarchyFactory() { + return new TypeAdapterFactory() { + @SuppressWarnings({"rawtypes", "unchecked"}) + public TypeAdapter create(Gson gson, TypeToken typeToken) { + Class rawType = typeToken.getRawType(); + if (!Enum.class.isAssignableFrom(rawType) || rawType == Enum.class) { + return null; + } + if (!rawType.isEnum()) { + rawType = rawType.getSuperclass(); // handle anonymous subclasses + } + return (TypeAdapter) new EnumTypeAdapter(rawType); + } + }; + } + + public T read(JsonReader in) throws IOException { + if (in.peek() == JsonToken.NULL) { + in.nextNull(); + return null; + } + return nameToConstant.get(in.nextString()); + } + + public void write(JsonWriter out, T value) throws IOException { + out.value(value == null ? null : constantToName.get(value)); + } + +} diff --git a/src/main/java/com/massivecraft/factions/util/FactionGUI.java b/src/main/java/com/massivecraft/factions/util/FactionGUI.java index 077a3f08..d4b181bf 100644 --- a/src/main/java/com/massivecraft/factions/util/FactionGUI.java +++ b/src/main/java/com/massivecraft/factions/util/FactionGUI.java @@ -4,8 +4,8 @@ import org.bukkit.event.inventory.ClickType; public interface FactionGUI { - public void onClick(int slot, ClickType action); + void onClick(int slot, ClickType action); - public void build(); + void build(); } diff --git a/src/main/java/com/massivecraft/factions/util/LazyLocation.java b/src/main/java/com/massivecraft/factions/util/LazyLocation.java index 898a700f..a141bbc7 100644 --- a/src/main/java/com/massivecraft/factions/util/LazyLocation.java +++ b/src/main/java/com/massivecraft/factions/util/LazyLocation.java @@ -12,7 +12,7 @@ import java.io.Serializable; */ public class LazyLocation implements Serializable { - private static final long serialVersionUID = - 6049901271320963314L; + private static final long serialVersionUID = -6049901271320963314L; private transient Location location = null; private String worldName; private double x; diff --git a/src/main/java/com/massivecraft/factions/util/MiscUtil.java b/src/main/java/com/massivecraft/factions/util/MiscUtil.java index d5d27344..07ff1b49 100644 --- a/src/main/java/com/massivecraft/factions/util/MiscUtil.java +++ b/src/main/java/com/massivecraft/factions/util/MiscUtil.java @@ -100,11 +100,21 @@ public class MiscUtil { } switch (player.getRole()) { - case LEADER: admins.add(player); break; - case COLEADER: admins.add(player); break; - case MODERATOR: moderators.add(player); break; - case NORMAL: normal.add(player); break; - case RECRUIT: recruit.add(player); break; + case LEADER: + admins.add(player); + break; + case COLEADER: + admins.add(player); + break; + case MODERATOR: + moderators.add(player); + break; + case NORMAL: + normal.add(player); + break; + case RECRUIT: + recruit.add(player); + break; } } diff --git a/src/main/java/com/massivecraft/factions/util/MultiversionMaterials.java b/src/main/java/com/massivecraft/factions/util/MultiversionMaterials.java index 874307ba..df243e72 100644 --- a/src/main/java/com/massivecraft/factions/util/MultiversionMaterials.java +++ b/src/main/java/com/massivecraft/factions/util/MultiversionMaterials.java @@ -858,8 +858,8 @@ public enum MultiversionMaterials { ZOMBIE_VILLAGER_SPAWN_EGG("MONSTER_EGG", 0), ZOMBIE_WALL_HEAD("SKULL", 0), ; - - static int newV = - 1; + + static int newV = -1; private static HashMap cachedSearch = new HashMap<>(); String m; int data; @@ -872,13 +872,13 @@ public enum MultiversionMaterials { public static boolean isNewVersion() { if (newV == 0) return false; if (newV == 1) return true; - + Material mat = Material.matchMaterial("RED_WOOL"); if (mat != null) { newV = 1; return true; } - + newV = 0; return false; } @@ -898,11 +898,11 @@ public enum MultiversionMaterials { public static MultiversionMaterials fromString(String key) { try { - return MultiversionMaterials.valueOf(key); + return MultiversionMaterials.valueOf(key); } catch (IllegalArgumentException e) { String[] split = key.split(":"); - - return split.length == 1 ? requestXMaterial(key, (byte) 0):requestXMaterial(split[0], (byte) Integer.parseInt(split[1])); + + return split.length == 1 ? requestXMaterial(key, (byte) 0) : requestXMaterial(split[0], (byte) Integer.parseInt(split[1])); } } @@ -944,7 +944,7 @@ public enum MultiversionMaterials { public boolean isDamageable(MultiversionMaterials type) { String[] split = type.toString().split("_"); - + switch (split[split.length - 1]) { case "HELMET": case "CHESTPLATE": @@ -968,7 +968,7 @@ public enum MultiversionMaterials { public Material parseMaterial() { Material mat = Material.matchMaterial(this.toString()); - return mat != null ? mat:Material.matchMaterial(m); + return mat != null ? mat : Material.matchMaterial(m); } } \ No newline at end of file diff --git a/src/main/java/com/massivecraft/factions/util/Particles/ParticleEffect.java b/src/main/java/com/massivecraft/factions/util/Particles/ParticleEffect.java index e57ffb74..ab152c08 100644 --- a/src/main/java/com/massivecraft/factions/util/Particles/ParticleEffect.java +++ b/src/main/java/com/massivecraft/factions/util/Particles/ParticleEffect.java @@ -20,7 +20,7 @@ import java.util.Map.Entry; /** * ParticleEffect Library * This library was created by @DarkBlade12 and allows you to display all Minecraft particle effects on a Bukkit server - * + *

* You are welcome to use it, modify it and redistribute it under the following conditions: *

    *
  • Don't claim this class as your own @@ -47,7 +47,7 @@ public enum ParticleEffect { *
  • The speed value influences the velocity at which the particle flies off *
*/ - EXPLOSION_NORMAL("explode", 0, - 1, ParticleProperty.DIRECTIONAL), + EXPLOSION_NORMAL("explode", 0, -1, ParticleProperty.DIRECTIONAL), /** * A particle effect which is displayed by exploding ghast fireballs and wither skulls: *
    @@ -55,7 +55,7 @@ public enum ParticleEffect { *
  • The speed value slightly influences the size of this particle effect *
*/ - EXPLOSION_LARGE("largeexplode", 1, - 1), + EXPLOSION_LARGE("largeexplode", 1, -1), /** * A particle effect which is displayed by exploding tnt and creepers: *
    @@ -63,7 +63,7 @@ public enum ParticleEffect { *
  • The speed value has no influence on this particle effect *
*/ - EXPLOSION_HUGE("hugeexplosion", 2, - 1), + EXPLOSION_HUGE("hugeexplosion", 2, -1), /** * A particle effect which is displayed by launching fireworks: *
    @@ -71,7 +71,7 @@ public enum ParticleEffect { *
  • The speed value influences the velocity at which the particle flies off *
*/ - FIREWORKS_SPARK("fireworksSpark", 3, - 1, ParticleProperty.DIRECTIONAL), + FIREWORKS_SPARK("fireworksSpark", 3, -1, ParticleProperty.DIRECTIONAL), /** * A particle effect which is displayed by swimming entities and arrows in water: *
    @@ -79,7 +79,7 @@ public enum ParticleEffect { *
  • The speed value influences the velocity at which the particle flies off *
*/ - WATER_BUBBLE("bubble", 4, - 1, ParticleProperty.DIRECTIONAL, ParticleProperty.REQUIRES_WATER), + WATER_BUBBLE("bubble", 4, -1, ParticleProperty.DIRECTIONAL, ParticleProperty.REQUIRES_WATER), /** * A particle effect which is displayed by swimming entities and shaking wolves: *
    @@ -87,7 +87,7 @@ public enum ParticleEffect { *
  • The speed value has no influence on this particle effect *
*/ - WATER_SPLASH("splash", 5, - 1, ParticleProperty.DIRECTIONAL), + WATER_SPLASH("splash", 5, -1, ParticleProperty.DIRECTIONAL), /** * A particle effect which is displayed on water when fishing: *
    @@ -103,7 +103,7 @@ public enum ParticleEffect { *
  • The speed value has no influence on this particle effect *
*/ - SUSPENDED("suspended", 7, - 1, ParticleProperty.REQUIRES_WATER), + SUSPENDED("suspended", 7, -1, ParticleProperty.REQUIRES_WATER), /** * A particle effect which is displayed by air when close to bedrock and the in the void: *
    @@ -111,7 +111,7 @@ public enum ParticleEffect { *
  • The speed value has no influence on this particle effect *
*/ - SUSPENDED_DEPTH("depthSuspend", 8, - 1, ParticleProperty.DIRECTIONAL), + SUSPENDED_DEPTH("depthSuspend", 8, -1, ParticleProperty.DIRECTIONAL), /** * A particle effect which is displayed when landing a critical hit and by arrows: *
    @@ -119,7 +119,7 @@ public enum ParticleEffect { *
  • The speed value influences the velocity at which the particle flies off *
*/ - CRIT("crit", 9, - 1, ParticleProperty.DIRECTIONAL), + CRIT("crit", 9, -1, ParticleProperty.DIRECTIONAL), /** * A particle effect which is displayed when landing a hit with an enchanted weapon: *
    @@ -127,7 +127,7 @@ public enum ParticleEffect { *
  • The speed value influences the velocity at which the particle flies off *
*/ - CRIT_MAGIC("magicCrit", 10, - 1, ParticleProperty.DIRECTIONAL), + CRIT_MAGIC("magicCrit", 10, -1, ParticleProperty.DIRECTIONAL), /** * A particle effect which is displayed by primed tnt, torches, droppers, dispensers, end portals, brewing stands and monster spawners: *
    @@ -135,7 +135,7 @@ public enum ParticleEffect { *
  • The speed value influences the velocity at which the particle flies off *
*/ - SMOKE_NORMAL("smoke", 11, - 1, ParticleProperty.DIRECTIONAL), + SMOKE_NORMAL("smoke", 11, -1, ParticleProperty.DIRECTIONAL), /** * A particle effect which is displayed by fire, minecarts with furnace and blazes: *
    @@ -143,7 +143,7 @@ public enum ParticleEffect { *
  • The speed value influences the velocity at which the particle flies off *
*/ - SMOKE_LARGE("largesmoke", 12, - 1, ParticleProperty.DIRECTIONAL), + SMOKE_LARGE("largesmoke", 12, -1, ParticleProperty.DIRECTIONAL), /** * A particle effect which is displayed when splash potions or bottles o' enchanting hit something: *
    @@ -152,7 +152,7 @@ public enum ParticleEffect { *
  • Only the motion on the y-axis can be controlled, the motion on the x- and z-axis are multiplied by 0.1 when setting the values to 0 *
*/ - SPELL("spell", 13, - 1), + SPELL("spell", 13, -1), /** * A particle effect which is displayed when instant splash potions hit something: *
    @@ -161,7 +161,7 @@ public enum ParticleEffect { *
  • Only the motion on the y-axis can be controlled, the motion on the x- and z-axis are multiplied by 0.1 when setting the values to 0 *
*/ - SPELL_INSTANT("instantSpell", 14, - 1), + SPELL_INSTANT("instantSpell", 14, -1), /** * A particle effect which is displayed by entities with active potion effects: *
    @@ -170,7 +170,7 @@ public enum ParticleEffect { *
  • The particle color gets lighter when increasing the speed and darker when decreasing the speed *
*/ - SPELL_MOB("mobSpell", 15, - 1, ParticleProperty.COLORABLE), + SPELL_MOB("mobSpell", 15, -1, ParticleProperty.COLORABLE), /** * A particle effect which is displayed by entities with active potion effects applied through a beacon: *
    @@ -179,7 +179,7 @@ public enum ParticleEffect { *
  • The particle color gets lighter when increasing the speed and darker when decreasing the speed *
*/ - SPELL_MOB_AMBIENT("mobSpellAmbient", 16, - 1, ParticleProperty.COLORABLE), + SPELL_MOB_AMBIENT("mobSpellAmbient", 16, -1, ParticleProperty.COLORABLE), /** * A particle effect which is displayed by witches: *
    @@ -188,7 +188,7 @@ public enum ParticleEffect { *
  • Only the motion on the y-axis can be controlled, the motion on the x- and z-axis are multiplied by 0.1 when setting the values to 0 *
*/ - SPELL_WITCH("witchMagic", 17, - 1), + SPELL_WITCH("witchMagic", 17, -1), /** * A particle effect which is displayed by blocks beneath a water source: *
    @@ -196,7 +196,7 @@ public enum ParticleEffect { *
  • The speed value has no influence on this particle effect *
*/ - DRIP_WATER("dripWater", 18, - 1), + DRIP_WATER("dripWater", 18, -1), /** * A particle effect which is displayed by blocks beneath a lava source: *
    @@ -204,7 +204,7 @@ public enum ParticleEffect { *
  • The speed value has no influence on this particle effect *
*/ - DRIP_LAVA("dripLava", 19, - 1), + DRIP_LAVA("dripLava", 19, -1), /** * A particle effect which is displayed when attacking a villager in a village: *
    @@ -212,7 +212,7 @@ public enum ParticleEffect { *
  • The speed value has no influence on this particle effect *
*/ - VILLAGER_ANGRY("angryVillager", 20, - 1), + VILLAGER_ANGRY("angryVillager", 20, -1), /** * A particle effect which is displayed when using bone meal and trading with a villager in a village: *
    @@ -220,7 +220,7 @@ public enum ParticleEffect { *
  • The speed value has no influence on this particle effect *
*/ - VILLAGER_HAPPY("happyVillager", 21, - 1, ParticleProperty.DIRECTIONAL), + VILLAGER_HAPPY("happyVillager", 21, -1, ParticleProperty.DIRECTIONAL), /** * A particle effect which is displayed by mycelium: *
    @@ -228,7 +228,7 @@ public enum ParticleEffect { *
  • The speed value has no influence on this particle effect *
*/ - TOWN_AURA("townaura", 22, - 1, ParticleProperty.DIRECTIONAL), + TOWN_AURA("townaura", 22, -1, ParticleProperty.DIRECTIONAL), /** * A particle effect which is displayed by note blocks: *
    @@ -236,7 +236,7 @@ public enum ParticleEffect { *
  • The speed value causes the particle to be colored green when set to 0 *
*/ - NOTE("note", 23, - 1, ParticleProperty.COLORABLE), + NOTE("note", 23, -1, ParticleProperty.COLORABLE), /** * A particle effect which is displayed by nether portals, endermen, ender pearls, eyes of ender, ender chests and dragon eggs: *
    @@ -244,7 +244,7 @@ public enum ParticleEffect { *
  • The speed value influences the spread of this particle effect *
*/ - PORTAL("portal", 24, - 1, ParticleProperty.DIRECTIONAL), + PORTAL("portal", 24, -1, ParticleProperty.DIRECTIONAL), /** * A particle effect which is displayed by enchantment tables which are nearby bookshelves: *
    @@ -252,7 +252,7 @@ public enum ParticleEffect { *
  • The speed value influences the spread of this particle effect *
*/ - ENCHANTMENT_TABLE("enchantmenttable", 25, - 1, ParticleProperty.DIRECTIONAL), + ENCHANTMENT_TABLE("enchantmenttable", 25, -1, ParticleProperty.DIRECTIONAL), /** * A particle effect which is displayed by torches, active furnaces, magma cubes and monster spawners: *
    @@ -260,7 +260,7 @@ public enum ParticleEffect { *
  • The speed value influences the velocity at which the particle flies off *
*/ - FLAME("flame", 26, - 1, ParticleProperty.DIRECTIONAL), + FLAME("flame", 26, -1, ParticleProperty.DIRECTIONAL), /** * A particle effect which is displayed by lava: *
    @@ -268,7 +268,7 @@ public enum ParticleEffect { *
  • The speed value has no influence on this particle effect *
*/ - LAVA("lava", 27, - 1), + LAVA("lava", 27, -1), /** * A particle effect which is currently unused: *
    @@ -276,7 +276,7 @@ public enum ParticleEffect { *
  • The speed value has no influence on this particle effect *
*/ - FOOTSTEP("footstep", 28, - 1), + FOOTSTEP("footstep", 28, -1), /** * A particle effect which is displayed when a mob dies: *
    @@ -284,7 +284,7 @@ public enum ParticleEffect { *
  • The speed value influences the velocity at which the particle flies off *
*/ - CLOUD("cloud", 29, - 1, ParticleProperty.DIRECTIONAL), + CLOUD("cloud", 29, -1, ParticleProperty.DIRECTIONAL), /** * A particle effect which is displayed by redstone ore, powered redstone, redstone torches and redstone repeaters: *
    @@ -292,7 +292,7 @@ public enum ParticleEffect { *
  • The speed value causes the particle to be colored red when set to 0 *
*/ - REDSTONE("reddust", 30, - 1, ParticleProperty.COLORABLE), + REDSTONE("reddust", 30, -1, ParticleProperty.COLORABLE), /** * A particle effect which is displayed when snowballs hit a block: *
    @@ -300,7 +300,7 @@ public enum ParticleEffect { *
  • The speed value has no influence on this particle effect *
*/ - SNOWBALL("snowballpoof", 31, - 1), + SNOWBALL("snowballpoof", 31, -1), /** * A particle effect which is currently unused: *
    @@ -308,7 +308,7 @@ public enum ParticleEffect { *
  • The speed value influences the velocity at which the particle flies off *
*/ - SNOW_SHOVEL("snowshovel", 32, - 1, ParticleProperty.DIRECTIONAL), + SNOW_SHOVEL("snowshovel", 32, -1, ParticleProperty.DIRECTIONAL), /** * A particle effect which is displayed by slimes: *
    @@ -316,7 +316,7 @@ public enum ParticleEffect { *
  • The speed value has no influence on this particle effect *
*/ - SLIME("slime", 33, - 1), + SLIME("slime", 33, -1), /** * A particle effect which is displayed when breeding and taming animals: *
    @@ -324,7 +324,7 @@ public enum ParticleEffect { *
  • The speed value has no influence on this particle effect *
*/ - HEART("heart", 34, - 1), + HEART("heart", 34, -1), /** * A particle effect which is displayed by barriers: *
    @@ -339,7 +339,7 @@ public enum ParticleEffect { *
  • It looks like a little piece with an item texture *
*/ - ITEM_CRACK("iconcrack", 36, - 1, ParticleProperty.DIRECTIONAL, ParticleProperty.REQUIRES_DATA), + ITEM_CRACK("iconcrack", 36, -1, ParticleProperty.DIRECTIONAL, ParticleProperty.REQUIRES_DATA), /** * A particle effect which is displayed when breaking blocks or sprinting: *
    @@ -347,7 +347,7 @@ public enum ParticleEffect { *
  • The speed value has no influence on this particle effect *
*/ - BLOCK_CRACK("blockcrack", 37, - 1, ParticleProperty.REQUIRES_DATA), + BLOCK_CRACK("blockcrack", 37, -1, ParticleProperty.REQUIRES_DATA), /** * A particle effect which is displayed when falling: *
    @@ -524,7 +524,6 @@ public enum ParticleEffect { /** * Determine if this particle effect has a specific property * - * * @param property - property to check. * @return Whether it has the property or not */ @@ -538,7 +537,7 @@ public enum ParticleEffect { * @return Whether the particle effect is supported or not */ public boolean isSupported() { - if (requiredVersion == - 1) { + if (requiredVersion == -1) { return true; } return ParticlePacket.getVersion() >= requiredVersion; @@ -946,7 +945,7 @@ public enum ParticleEffect { * @param material Material of the item/block * @param data Data value of the item/block */ - @SuppressWarnings ("deprecation") + @SuppressWarnings("deprecation") public ParticleData(Material material, byte data) { this.material = material; this.data = data; @@ -1177,7 +1176,7 @@ public enum ParticleEffect { /** * Represents the color for the {@link ParticleEffect#NOTE} effect - * + *

    * This class is part of the ParticleEffect Library and follows the same usage conditions * * @author DarkBlade12 @@ -1236,7 +1235,7 @@ public enum ParticleEffect { /** * Represents a runtime exception that is thrown either if the displayed particle effect requires data and has none or vice-versa or if the data type is incorrect - * + *

    * This class is part of the ParticleEffect Library and follows the same usage conditions * * @author DarkBlade12 @@ -1257,7 +1256,7 @@ public enum ParticleEffect { /** * Represents a runtime exception that is thrown either if the displayed particle effect is not colorable or if the particle color type is incorrect - * + *

    * This class is part of the ParticleEffect Library and follows the same usage conditions * * @author DarkBlade12 @@ -1278,7 +1277,7 @@ public enum ParticleEffect { /** * Represents a runtime exception that is thrown if the displayed particle effect requires a newer version - * + *

    * This class is part of the ParticleEffect Library and follows the same usage conditions * * @author DarkBlade12 @@ -1299,7 +1298,7 @@ public enum ParticleEffect { /** * Represents a particle effect packet with all attributes which is used for sending packets to the players - * + *

    * This class is part of the ParticleEffect Library and follows the same usage conditions * * @author DarkBlade12 @@ -1385,7 +1384,7 @@ public enum ParticleEffect { /** * Initializes {@link #packetConstructor}, {@link #getHandle}, {@link #playerConnection} and {@link #sendPacket} and sets {@link #initialized} to true if it succeeds - * + * * Note: These fields only have to be initialized once, so it will return if {@link #initialized} is already set to true * * @throws VersionIncompatibleException if your bukkit version is not supported by this library @@ -1532,7 +1531,7 @@ public enum ParticleEffect { /** * Represents a runtime exception that is thrown if a bukkit version is not compatible with this library - * + *

    * This class is part of the ParticleEffect Library and follows the same usage conditions * * @author DarkBlade12 @@ -1554,7 +1553,7 @@ public enum ParticleEffect { /** * Represents a runtime exception that is thrown if packet instantiation fails - * + *

    * This class is part of the ParticleEffect Library and follows the same usage conditions * * @author DarkBlade12 @@ -1576,7 +1575,7 @@ public enum ParticleEffect { /** * Represents a runtime exception that is thrown if packet sending fails - * + *

    * This class is part of the ParticleEffect Library and follows the same usage conditions * * @author DarkBlade12 diff --git a/src/main/java/com/massivecraft/factions/util/Particles/ReflectionUtils.java b/src/main/java/com/massivecraft/factions/util/Particles/ReflectionUtils.java index d4fe7a29..e3923367 100644 --- a/src/main/java/com/massivecraft/factions/util/Particles/ReflectionUtils.java +++ b/src/main/java/com/massivecraft/factions/util/Particles/ReflectionUtils.java @@ -11,15 +11,15 @@ import java.util.Map; /** * ReflectionUtils - * + *

    * This class provides useful methods which makes dealing with reflection much easier, especially when working with Bukkit - * + *

    * You are welcome to use it, modify it and redistribute it under the following conditions: *

      *
    • Don't claim this class as your own *
    • Don't remove this disclaimer *
    - * + * * It would be nice if you provide credit to me if you use this class in a published project * * @author DarkBlade12 @@ -346,7 +346,7 @@ public final class ReflectionUtils { /** * Represents an enumeration of dynamic packages of NMS and CraftBukkit - * + *

    * This class is part of the ReflectionUtils and follows the same usage conditions * * @author DarkBlade12 @@ -433,7 +433,7 @@ public final class ReflectionUtils { /** * Represents an enumeration of Java data types with corresponding classes - * + *

    * This class is part of the ReflectionUtils and follows the same usage conditions * * @author DarkBlade12 diff --git a/src/main/java/com/massivecraft/factions/util/RelationUtil.java b/src/main/java/com/massivecraft/factions/util/RelationUtil.java index 6e0c0b6b..4c656f84 100644 --- a/src/main/java/com/massivecraft/factions/util/RelationUtil.java +++ b/src/main/java/com/massivecraft/factions/util/RelationUtil.java @@ -1,111 +1,111 @@ -package com.massivecraft.factions.util; - -import com.massivecraft.factions.Conf; -import com.massivecraft.factions.FPlayer; -import com.massivecraft.factions.Faction; -import com.massivecraft.factions.iface.RelationParticipator; -import com.massivecraft.factions.struct.Relation; -import com.massivecraft.factions.zcore.util.TL; -import com.massivecraft.factions.zcore.util.TextUtil; -import org.bukkit.ChatColor; - -public class RelationUtil { - - public static String describeThatToMe(RelationParticipator that, RelationParticipator me, boolean ucfirst) { - String ret = ""; - - Faction thatFaction = getFaction(that); - if (thatFaction == null) { - return "ERROR"; // ERROR - } - - Faction myFaction = getFaction(me); -// if (myFaction == null) return that.describeTo(null); // no relation, but can show basic name or tag - - if (that instanceof Faction) { - if (me instanceof FPlayer && myFaction == thatFaction) { - ret = TL.GENERIC_YOURFACTION.toString(); - } else { - ret = thatFaction.getTag(); - } - } else if (that instanceof FPlayer) { - FPlayer fplayerthat = (FPlayer) that; - if (that == me) { - ret = TL.GENERIC_YOU.toString(); - } else if (thatFaction == myFaction) { - ret = fplayerthat.getNameAndTitle(); - } else { - ret = fplayerthat.getNameAndTag(); - } - } - - if (ucfirst) { - ret = TextUtil.upperCaseFirst(ret); - } - - return "" + getColorOfThatToMe(that, me) + ret; - } - - public static String describeThatToMe(RelationParticipator that, RelationParticipator me) { - return describeThatToMe(that, me, false); - } - - public static Relation getRelationTo(RelationParticipator me, RelationParticipator that) { - return getRelationTo(that, me, false); - } - - public static Relation getRelationTo(RelationParticipator me, RelationParticipator that, boolean ignorePeaceful) { - Faction fthat = getFaction(that); - Faction fme = getFaction(me); - - if (fthat == null || fme == null) { - return Relation.NEUTRAL; // ERROR - } - - if (!fthat.isNormal() || !fme.isNormal()) { - return Relation.NEUTRAL; - } - - if (fthat.equals(fme)) { - return Relation.MEMBER; - } - - if (!ignorePeaceful && (fme.isPeaceful() || fthat.isPeaceful())) { - return Relation.NEUTRAL; - } - - if (fme.getRelationWish(fthat).value >= fthat.getRelationWish(fme).value) { - return fthat.getRelationWish(fme); - } - - return fme.getRelationWish(fthat); - } - - public static Faction getFaction(RelationParticipator rp) { - if (rp instanceof Faction) { - return (Faction) rp; - } - - if (rp instanceof FPlayer) { - return ((FPlayer) rp).getFaction(); - } - - // ERROR - return null; - } - - public static ChatColor getColorOfThatToMe(RelationParticipator that, RelationParticipator me) { - Faction thatFaction = getFaction(that); - - if (thatFaction != null && thatFaction != getFaction(me)) { - if (thatFaction.isPeaceful()) - return Conf.colorPeaceful; - else if (thatFaction.isSafeZone()) - return Conf.colorPeaceful; - else if (thatFaction.isWarZone()) - return Conf.colorWar; - } - - return getRelationTo(that, me).getColor(); - } -} +package com.massivecraft.factions.util; + +import com.massivecraft.factions.Conf; +import com.massivecraft.factions.FPlayer; +import com.massivecraft.factions.Faction; +import com.massivecraft.factions.iface.RelationParticipator; +import com.massivecraft.factions.struct.Relation; +import com.massivecraft.factions.zcore.util.TL; +import com.massivecraft.factions.zcore.util.TextUtil; +import org.bukkit.ChatColor; + +public class RelationUtil { + + public static String describeThatToMe(RelationParticipator that, RelationParticipator me, boolean ucfirst) { + String ret = ""; + + Faction thatFaction = getFaction(that); + if (thatFaction == null) { + return "ERROR"; // ERROR + } + + Faction myFaction = getFaction(me); +// if (myFaction == null) return that.describeTo(null); // no relation, but can show basic name or tag + + if (that instanceof Faction) { + if (me instanceof FPlayer && myFaction == thatFaction) { + ret = TL.GENERIC_YOURFACTION.toString(); + } else { + ret = thatFaction.getTag(); + } + } else if (that instanceof FPlayer) { + FPlayer fplayerthat = (FPlayer) that; + if (that == me) { + ret = TL.GENERIC_YOU.toString(); + } else if (thatFaction == myFaction) { + ret = fplayerthat.getNameAndTitle(); + } else { + ret = fplayerthat.getNameAndTag(); + } + } + + if (ucfirst) { + ret = TextUtil.upperCaseFirst(ret); + } + + return "" + getColorOfThatToMe(that, me) + ret; + } + + public static String describeThatToMe(RelationParticipator that, RelationParticipator me) { + return describeThatToMe(that, me, false); + } + + public static Relation getRelationTo(RelationParticipator me, RelationParticipator that) { + return getRelationTo(that, me, false); + } + + public static Relation getRelationTo(RelationParticipator me, RelationParticipator that, boolean ignorePeaceful) { + Faction fthat = getFaction(that); + Faction fme = getFaction(me); + + if (fthat == null || fme == null) { + return Relation.NEUTRAL; // ERROR + } + + if (!fthat.isNormal() || !fme.isNormal()) { + return Relation.NEUTRAL; + } + + if (fthat.equals(fme)) { + return Relation.MEMBER; + } + + if (!ignorePeaceful && (fme.isPeaceful() || fthat.isPeaceful())) { + return Relation.NEUTRAL; + } + + if (fme.getRelationWish(fthat).value >= fthat.getRelationWish(fme).value) { + return fthat.getRelationWish(fme); + } + + return fme.getRelationWish(fthat); + } + + public static Faction getFaction(RelationParticipator rp) { + if (rp instanceof Faction) { + return (Faction) rp; + } + + if (rp instanceof FPlayer) { + return ((FPlayer) rp).getFaction(); + } + + // ERROR + return null; + } + + public static ChatColor getColorOfThatToMe(RelationParticipator that, RelationParticipator me) { + Faction thatFaction = getFaction(that); + + if (thatFaction != null && thatFaction != getFaction(me)) { + if (thatFaction.isPeaceful()) + return Conf.colorPeaceful; + else if (thatFaction.isSafeZone()) + return Conf.colorPeaceful; + else if (thatFaction.isWarZone()) + return Conf.colorWar; + } + + return getRelationTo(that, me).getColor(); + } +} diff --git a/src/main/java/com/massivecraft/factions/util/SpiralTask.java b/src/main/java/com/massivecraft/factions/util/SpiralTask.java index b5a9d40a..1124bf8b 100644 --- a/src/main/java/com/massivecraft/factions/util/SpiralTask.java +++ b/src/main/java/com/massivecraft/factions/util/SpiralTask.java @@ -27,7 +27,7 @@ public abstract class SpiralTask implements Runnable { // general task-related reference data private transient World world = null; private transient boolean readyToGo = false; - private transient int taskID = - 1; + private transient int taskID = -1; private transient int limit = 0; // values for the spiral pattern routine @@ -35,10 +35,10 @@ public abstract class SpiralTask implements Runnable { private transient int z = 0; private transient boolean isZLeg = false; private transient boolean isNeg = false; - private transient int length = - 1; + private transient int length = -1; private transient int current = 0; - @SuppressWarnings ("LeakingThisInConstructor") + @SuppressWarnings("LeakingThisInConstructor") public SpiralTask(FLocation fLocation, int radius) { // limit is determined based on spiral leg length for given radius; see insideRadius() this.limit = (radius - 1) * 2; @@ -103,7 +103,7 @@ public abstract class SpiralTask implements Runnable { } public final void setTaskID(int ID) { - if (ID == - 1) { + if (ID == -1) { this.stop(); } taskID = ID; @@ -169,9 +169,9 @@ public abstract class SpiralTask implements Runnable { // move one chunk further in the appropriate direction if (isZLeg) { - z += (isNeg) ? - 1 : 1; + z += (isNeg) ? -1 : 1; } else { - x += (isNeg) ? - 1 : 1; + x += (isNeg) ? -1 : 1; } return true; @@ -199,11 +199,11 @@ public abstract class SpiralTask implements Runnable { readyToGo = false; Bukkit.getServer().getScheduler().cancelTask(taskID); - taskID = - 1; + taskID = -1; } // is this task still valid/workable? public final boolean valid() { - return taskID != - 1; + return taskID != -1; } } diff --git a/src/main/java/com/massivecraft/factions/util/UtilFly.java b/src/main/java/com/massivecraft/factions/util/UtilFly.java new file mode 100644 index 00000000..4a8a11f0 --- /dev/null +++ b/src/main/java/com/massivecraft/factions/util/UtilFly.java @@ -0,0 +1,114 @@ +package com.massivecraft.factions.util; + +import com.massivecraft.factions.FPlayer; +import com.massivecraft.factions.Faction; +import com.massivecraft.factions.SavageFactions; +import com.massivecraft.factions.struct.Relation; +import com.massivecraft.factions.zcore.util.TL; +import org.bukkit.Bukkit; + +import java.util.ArrayList; +import java.util.Iterator; + +public class UtilFly { + + public static ArrayList playersFlying; + + static { + playersFlying = SavageFactions.playersFlying; + } + + public UtilFly() { + } + + public static void run() { + if (SavageFactions.plugin.getConfig().getBoolean("enable-faction-flight")) { + playersFlying.clear(); + Bukkit.getScheduler().scheduleSyncRepeatingTask(SavageFactions.plugin, new Runnable() { + public void run() { + Iterator var2 = UtilFly.playersFlying.iterator(); + + while (var2.hasNext()) { + FPlayer fp = (FPlayer) var2.next(); + if (fp != null) { + fp.checkIfNearbyEnemies(); + } + } + + } + }, 0L, (long) SavageFactions.plugin.getConfig().getInt("fly-task-interval", 10)); + } + } + + public static void setFly(FPlayer fp, boolean fly, boolean silent, boolean damage) { + if (SavageFactions.plugin.getConfig().getBoolean("enable-faction-flight")) { + fp.getPlayer().setAllowFlight(fly); + fp.getPlayer().setFlying(fly); + fp.setFlying(fly); + if (fly) { + playersFlying.add(fp); + } else { + playersFlying.remove(fp); + } + + if (!silent) { + if (!damage) { + fp.msg(TL.COMMAND_FLY_CHANGE, fly ? "enabled" : "disabled"); + } else { + fp.msg(TL.COMMAND_FLY_DAMAGE); + } + } + + setFallDamage(fp, fly, damage); + } + } + + public static void checkFly(FPlayer me, Faction factionTo) { + if (SavageFactions.plugin.getConfig().getBoolean("enable-faction-flight")) { + if (!me.isAdminBypassing() || !me.isFlying()) { + Relation relationTo; + if (!me.isFlying()) { + if (me.isAdminBypassing()) { + setFly(me, true, false, false); + return; + } + + if (factionTo == me.getFaction() && me.getPlayer().hasPermission("factions.fly")) { + setFly(me, true, false, false); + } else { + relationTo = factionTo.getRelationTo(me); + if (factionTo.isWilderness() && me.canflyinWilderness() || factionTo.isWarZone() && me.canflyinWarzone() || factionTo.isSafeZone() && me.canflyinSafezone() || relationTo == Relation.ENEMY && me.canflyinEnemy() || relationTo == Relation.ALLY && me.canflyinAlly() || relationTo == Relation.TRUCE && me.canflyinTruce() || relationTo == Relation.NEUTRAL && me.canflyinNeutral()) { + setFly(me, true, false, false); + } + } + } else { + relationTo = factionTo.getRelationTo(me); + if (factionTo.equals(me.getFaction()) && !me.getPlayer().hasPermission("factions.fly") || factionTo.isWilderness() && !me.canflyinWilderness() || factionTo.isWarZone() && !me.canflyinWarzone() || factionTo.isSafeZone() && !me.canflyinSafezone() || relationTo == Relation.ENEMY && !me.canflyinEnemy() || relationTo == Relation.ALLY && !me.canflyinAlly() || relationTo == Relation.TRUCE && !me.canflyinTruce() || relationTo == Relation.NEUTRAL && !me.canflyinNeutral()) { + setFly(me, false, false, false); + } + } + + } + } + } + + public static void setFallDamage(final FPlayer fp, boolean fly, boolean damage) { + if (!fly) { + if (!damage) { + fp.sendMessage(TL.COMMAND_FLY_COOLDOWN.toString().replace("{amount}", String.valueOf(SavageFactions.plugin.getConfig().getInt("fly-falldamage-cooldown", 3)))); + } + + int cooldown = SavageFactions.plugin.getConfig().getInt("fly-falldamage-cooldown", 3); + if (cooldown > 0) { + fp.setTakeFallDamage(false); + Bukkit.getScheduler().runTaskLater(SavageFactions.plugin, new Runnable() { + public void run() { + fp.setTakeFallDamage(true); + } + }, 20L * (long) cooldown); + } + } + + } +} + diff --git a/src/main/java/com/massivecraft/factions/util/VisualizeUtil.java b/src/main/java/com/massivecraft/factions/util/VisualizeUtil.java index a400ff6d..a817e166 100644 --- a/src/main/java/com/massivecraft/factions/util/VisualizeUtil.java +++ b/src/main/java/com/massivecraft/factions/util/VisualizeUtil.java @@ -1,72 +1,72 @@ -package com.massivecraft.factions.util; - -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.block.Block; -import org.bukkit.entity.Player; - -import java.util.*; - -public class VisualizeUtil { - - protected static Map> playerLocations = new HashMap<>(); - - public static Set getPlayerLocations(Player player) { - return getPlayerLocations(player.getUniqueId()); - } - - public static Set getPlayerLocations(UUID uuid) { - Set ret = playerLocations.get(uuid); - if (ret == null) { - ret = new HashSet<>(); - playerLocations.put(uuid, ret); - } - return ret; - } - - @SuppressWarnings ("deprecation") - public static void addLocation(Player player, Location location, Material type, byte data) { - getPlayerLocations(player).add(location); - player.sendBlockChange(location, type, data); - } - - @SuppressWarnings ("deprecation") - public static void addLocation(Player player, Location location, Material material) { - getPlayerLocations(player).add(location); - player.sendBlockChange(location, material, (byte) 0); - } - - - @SuppressWarnings ("deprecation") - public static void addLocations(Player player, Collection locations, Material material) { - Set ploc = getPlayerLocations(player); - for (Location location : locations) { - ploc.add(location); - player.sendBlockChange(location, material, (byte) 0); - } - } - - @SuppressWarnings ("deprecation") - public static void addBlocks(Player player, Collection blocks, Material material) { - Set ploc = getPlayerLocations(player); - for (Block block : blocks) { - Location location = block.getLocation(); - ploc.add(location); - player.sendBlockChange(location, material, (byte) 0); - } - } - - @SuppressWarnings ("deprecation") - public static void clear(Player player) { - Set locations = getPlayerLocations(player); - if (locations == null) { - return; - } - for (Location location : locations) { - Block block = location.getWorld().getBlockAt(location); - player.sendBlockChange(location, block.getType(), block.getData()); - } - locations.clear(); - } - -} +package com.massivecraft.factions.util; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; + +import java.util.*; + +public class VisualizeUtil { + + protected static Map> playerLocations = new HashMap<>(); + + public static Set getPlayerLocations(Player player) { + return getPlayerLocations(player.getUniqueId()); + } + + public static Set getPlayerLocations(UUID uuid) { + Set ret = playerLocations.get(uuid); + if (ret == null) { + ret = new HashSet<>(); + playerLocations.put(uuid, ret); + } + return ret; + } + + @SuppressWarnings("deprecation") + public static void addLocation(Player player, Location location, Material type, byte data) { + getPlayerLocations(player).add(location); + player.sendBlockChange(location, type, data); + } + + @SuppressWarnings("deprecation") + public static void addLocation(Player player, Location location, Material material) { + getPlayerLocations(player).add(location); + player.sendBlockChange(location, material, (byte) 0); + } + + + @SuppressWarnings("deprecation") + public static void addLocations(Player player, Collection locations, Material material) { + Set ploc = getPlayerLocations(player); + for (Location location : locations) { + ploc.add(location); + player.sendBlockChange(location, material, (byte) 0); + } + } + + @SuppressWarnings("deprecation") + public static void addBlocks(Player player, Collection blocks, Material material) { + Set ploc = getPlayerLocations(player); + for (Block block : blocks) { + Location location = block.getLocation(); + ploc.add(location); + player.sendBlockChange(location, material, (byte) 0); + } + } + + @SuppressWarnings("deprecation") + public static void clear(Player player) { + Set locations = getPlayerLocations(player); + if (locations == null) { + return; + } + for (Location location : locations) { + Block block = location.getWorld().getBlockAt(location); + player.sendBlockChange(location, block.getType(), block.getData()); + } + locations.clear(); + } + +} diff --git a/src/main/java/com/massivecraft/factions/util/WarmUpUtil.java b/src/main/java/com/massivecraft/factions/util/WarmUpUtil.java index 5422aeb2..8de53dff 100644 --- a/src/main/java/com/massivecraft/factions/util/WarmUpUtil.java +++ b/src/main/java/com/massivecraft/factions/util/WarmUpUtil.java @@ -12,7 +12,7 @@ public class WarmUpUtil { * @param action The action, inserted into the notification message. * @param runnable The task to run after the delay. If the delay is 0, the task is instantly ran. * @param delay The time used, in seconds, for the delay. - * + *

    * note: for translations: %s = action, %d = delay */ public static void process(final FPlayer player, Warmup warmup, TL translationKey, String action, final Runnable runnable, long delay) { diff --git a/src/main/java/com/massivecraft/factions/util/WarpGUI.java b/src/main/java/com/massivecraft/factions/util/WarpGUI.java index abfe6ffc..7936ffe1 100644 --- a/src/main/java/com/massivecraft/factions/util/WarpGUI.java +++ b/src/main/java/com/massivecraft/factions/util/WarpGUI.java @@ -140,9 +140,9 @@ public class WarpGUI implements InventoryHolder, FactionGUI { } if (Conf.bankEnabled && Conf.bankFactionPaysCosts && fme.hasFaction()) { - return Econ.modifyMoney(fme.getFaction(), - cost, TL.COMMAND_FWARP_TOWARP.toString(), TL.COMMAND_FWARP_FORWARPING.toString()); + return Econ.modifyMoney(fme.getFaction(), -cost, TL.COMMAND_FWARP_TOWARP.toString(), TL.COMMAND_FWARP_FORWARPING.toString()); } else { - return Econ.modifyMoney(fme, - cost, TL.COMMAND_FWARP_TOWARP.toString(), TL.COMMAND_FWARP_FORWARPING.toString()); + return Econ.modifyMoney(fme, -cost, TL.COMMAND_FWARP_TOWARP.toString(), TL.COMMAND_FWARP_FORWARPING.toString()); } } diff --git a/src/main/java/com/massivecraft/factions/zcore/MCommand.java b/src/main/java/com/massivecraft/factions/zcore/MCommand.java index 74bbf4ac..94919da4 100644 --- a/src/main/java/com/massivecraft/factions/zcore/MCommand.java +++ b/src/main/java/com/massivecraft/factions/zcore/MCommand.java @@ -76,7 +76,7 @@ public abstract class MCommand { } public String getHelpShort() { - return this.helpShort != null ? this.helpShort:getUsageTranslation().toString(); + return this.helpShort != null ? this.helpShort : getUsageTranslation().toString(); } public void setHelpShort(String val) { @@ -85,9 +85,8 @@ public abstract class MCommand { public abstract TL getUsageTranslation(); - public void setCommandSender(CommandSender sender) - { - this.sender = sender; + public void setCommandSender(CommandSender sender) { + this.sender = sender; if (sender instanceof Player) { this.me = (Player) sender; this.senderIsConsole = false; @@ -96,7 +95,7 @@ public abstract class MCommand { this.senderIsConsole = true; } } - + // The commandChain is a list of the parent command chain used to get to this command. public void execute(CommandSender sender, List args, List> commandChain) { // Set the execution-time specific variables diff --git a/src/main/java/com/massivecraft/factions/zcore/MPlugin.java b/src/main/java/com/massivecraft/factions/zcore/MPlugin.java index c3a30c1e..1b6bdac2 100644 --- a/src/main/java/com/massivecraft/factions/zcore/MPlugin.java +++ b/src/main/java/com/massivecraft/factions/zcore/MPlugin.java @@ -1,339 +1,339 @@ -package com.massivecraft.factions.zcore; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.reflect.TypeToken; -import com.massivecraft.factions.Board; -import com.massivecraft.factions.Conf; -import com.massivecraft.factions.FPlayers; -import com.massivecraft.factions.Factions; -import com.massivecraft.factions.zcore.persist.SaveTask; -import com.massivecraft.factions.zcore.util.PermUtil; -import com.massivecraft.factions.zcore.util.Persist; -import com.massivecraft.factions.zcore.util.TL; -import com.massivecraft.factions.zcore.util.TextUtil; -import org.bukkit.Bukkit; -import org.bukkit.command.CommandSender; -import org.bukkit.configuration.file.YamlConfiguration; -import org.bukkit.plugin.java.JavaPlugin; - -import java.io.*; -import java.lang.reflect.Modifier; -import java.lang.reflect.Type; -import java.util.*; -import java.util.Map.Entry; -import java.util.logging.Level; - - -public abstract class MPlugin extends JavaPlugin { - - // Persist related - public final Gson gson = this.getGsonBuilder().create(); - // Some utils - public Persist persist; - public TextUtil txt; - public PermUtil perm; - public String refCommand = ""; - //holds f stuck taskids - public Map stuckMap = new HashMap<>(); - // These are not supposed to be used directly. - // They are loaded and used through the TextUtil instance for the plugin. - public Map rawTags = new LinkedHashMap<>(); - protected boolean loadSuccessful = false; - private Integer saveTask = null; - private boolean autoSave = true; - // Listeners - private MPluginSecretPlayerListener mPluginSecretPlayerListener; - - // Our stored base commands - private List> baseCommands = new ArrayList<>(); - // holds f stuck start times - private Map timers = new HashMap<>(); - // -------------------------------------------- // - // ENABLE - // -------------------------------------------- // - private long timeEnableStart; - - public boolean getAutoSave() { - return this.autoSave; - } - - public void setAutoSave(boolean val) { - this.autoSave = val; - } - - public List> getBaseCommands() { - return this.baseCommands; - } - - public boolean preEnable() { - log("=== ENABLE START ==="); - timeEnableStart = System.currentTimeMillis(); - - // Ensure basefolder exists! - this.getDataFolder().mkdirs(); - - // Create Utility Instances - this.perm = new PermUtil(this); - this.persist = new Persist(this); - - this.txt = new TextUtil(); - initTXT(); - - // attempt to get first command defined in plugin.yml as reference command, if any commands are defined in there - // reference command will be used to prevent "unknown command" console messages - try { - Map> refCmd = this.getDescription().getCommands(); - if (refCmd != null && !refCmd.isEmpty()) { - this.refCommand = (String) (refCmd.keySet().toArray()[0]); - } - } catch (ClassCastException ex) { - } - - // Create and register player command listener - this.mPluginSecretPlayerListener = new MPluginSecretPlayerListener(this); - getServer().getPluginManager().registerEvents(this.mPluginSecretPlayerListener, this); - - // Register recurring tasks - if (saveTask == null && Conf.saveToFileEveryXMinutes > 0.0) { - long saveTicks = (long) (20 * 60 * Conf.saveToFileEveryXMinutes); // Approximately every 30 min by default - saveTask = Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, new SaveTask(this), saveTicks, saveTicks); - } - - loadLang(); - - loadSuccessful = true; - return true; - } - - public void postEnable() { - log("=== ENABLE DONE (Took " + (System.currentTimeMillis() - timeEnableStart) + "ms) ==="); - } - - public void loadLang() { - File lang = new File(getDataFolder(), "lang.yml"); - OutputStream out = null; - InputStream defLangStream = this.getResource("lang.yml"); - if (!lang.exists()) { - try { - getDataFolder().mkdir(); - lang.createNewFile(); - if (defLangStream != null) { - out = new FileOutputStream(lang); - int read; - byte[] bytes = new byte[1024]; - - while ((read = defLangStream.read(bytes)) != - 1) { - out.write(bytes, 0, read); - } - YamlConfiguration defConfig = YamlConfiguration.loadConfiguration(new BufferedReader(new InputStreamReader(defLangStream))); - TL.setFile(defConfig); - } - } catch (IOException e) { - e.printStackTrace(); // So they notice - getLogger().severe("[Factions] Couldn't create language file."); - getLogger().severe("[Factions] This is a fatal error. Now disabling"); - this.setEnabled(false); // Without it loaded, we can't send them messages - } finally { - if (defLangStream != null) { - try { - defLangStream.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - if (out != null) { - try { - out.close(); - } catch (IOException e) { - e.printStackTrace(); - } - - } - } - } - - YamlConfiguration conf = YamlConfiguration.loadConfiguration(lang); - for (TL item : TL.values()) { - if (conf.getString(item.getPath()) == null) { - conf.set(item.getPath(), item.getDefault()); - } - } - - // Remove this here because I'm sick of dealing with bug reports due to bad decisions on my part. - if (conf.getString(TL.COMMAND_SHOW_POWER.getPath(), "").contains("%5$s")) { - conf.set(TL.COMMAND_SHOW_POWER.getPath(), TL.COMMAND_SHOW_POWER.getDefault()); - log(Level.INFO, "Removed errant format specifier from f show power."); - } - - TL.setFile(conf); - try { - conf.save(lang); - } catch (IOException e) { - getLogger().log(Level.WARNING, "Factions: Failed to save lang.yml."); - getLogger().log(Level.WARNING, "Factions: Report this stack trace to prosavage."); - e.printStackTrace(); - } - } - - public void onDisable() { - if (saveTask != null) { - this.getServer().getScheduler().cancelTask(saveTask); - saveTask = null; - } - // only save data if plugin actually loaded successfully - if (loadSuccessful) { - Factions.getInstance().forceSave(); - FPlayers.getInstance().forceSave(); - Board.getInstance().forceSave(); - } - log("Disabled"); - } - - // -------------------------------------------- // - // Some inits... - // You are supposed to override these in the plugin if you aren't satisfied with the defaults - // The goal is that you always will be satisfied though. - // -------------------------------------------- // - - public void suicide() { - log("Now I suicide!"); - this.getServer().getPluginManager().disablePlugin(this); - } - - // -------------------------------------------- // - // LANG AND TAGS - // -------------------------------------------- // - - public GsonBuilder getGsonBuilder() { - return new GsonBuilder().setPrettyPrinting().disableHtmlEscaping().serializeNulls().excludeFieldsWithModifiers(Modifier.TRANSIENT, Modifier.VOLATILE); - } - - public void addRawTags() { - this.rawTags.put("l", ""); // logo - this.rawTags.put("a", ""); // art - this.rawTags.put("n", ""); // notice - this.rawTags.put("i", ""); // info - this.rawTags.put("g", ""); // good - this.rawTags.put("b", ""); // bad - this.rawTags.put("h", ""); // highligh - this.rawTags.put("c", ""); // command - this.rawTags.put("plugin", ""); // parameter - } - - public void initTXT() { - this.addRawTags(); - - Type type = new TypeToken>() { - }.getType(); - - Map tagsFromFile = this.persist.load(type, "tags"); - if (tagsFromFile != null) { - this.rawTags.putAll(tagsFromFile); - } - this.persist.save(this.rawTags, "tags"); - - for (Entry rawTag : this.rawTags.entrySet()) { - this.txt.tags.put(rawTag.getKey(), TextUtil.parseColor(rawTag.getValue())); - } - } - - // -------------------------------------------- // - // COMMAND HANDLING - // -------------------------------------------- // - - // can be overridden by SavageFactions method, to provide option - public boolean logPlayerCommands() { - return true; - } - - public boolean handleCommand(CommandSender sender, String commandString, boolean testOnly) { - return handleCommand(sender, commandString, testOnly, false); - } - - public boolean handleCommand(final CommandSender sender, String commandString, boolean testOnly, boolean async) { - boolean noSlash = true; - if (commandString.startsWith("/")) { - noSlash = false; - commandString = commandString.substring(1); - } - - for (final MCommand command : this.getBaseCommands()) { - if (noSlash && !command.allowNoSlashAccess) { - continue; - } - - for (String alias : command.aliases) { - // disallow double-space after alias, so specific commands can be prevented (preventing "f home" won't prevent "f home") - if (commandString.startsWith(alias + " ")) { - return false; - } - - if (commandString.startsWith(alias + " ") || commandString.equals(alias)) { - final List args = new ArrayList<>(Arrays.asList(commandString.split("\\s+"))); - args.remove(0); - - if (testOnly) { - return true; - } - - if (async) { - Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable() { - @Override - public void run() { - command.execute(sender, args); - } - }); - } else { - command.execute(sender, args); - } - - return true; - } - } - } - return false; - } - - public boolean handleCommand(CommandSender sender, String commandString) { - return this.handleCommand(sender, commandString, false); - } - - // -------------------------------------------- // - // HOOKS - // -------------------------------------------- // - public void preAutoSave() { - - } - - public void postAutoSave() { - - } - - public Map getStuckMap() { - return this.stuckMap; - } - - public Map getTimers() { - return this.timers; - } - - // -------------------------------------------- // - // LOGGING - // -------------------------------------------- // - public void log(Object msg) { - log(Level.INFO, msg); - } - - public void log(String str, Object... args) { - log(Level.INFO, this.txt.parse(str, args)); - } - - public void log(Level level, String str, Object... args) { - log(level, this.txt.parse(str, args)); - } - - public void log(Level level, Object msg) { - getLogger().log(level, "[" + this.getDescription().getFullName() + "] " + msg); - } -} +package com.massivecraft.factions.zcore; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.reflect.TypeToken; +import com.massivecraft.factions.Board; +import com.massivecraft.factions.Conf; +import com.massivecraft.factions.FPlayers; +import com.massivecraft.factions.Factions; +import com.massivecraft.factions.zcore.persist.SaveTask; +import com.massivecraft.factions.zcore.util.PermUtil; +import com.massivecraft.factions.zcore.util.Persist; +import com.massivecraft.factions.zcore.util.TL; +import com.massivecraft.factions.zcore.util.TextUtil; +import org.bukkit.Bukkit; +import org.bukkit.command.CommandSender; +import org.bukkit.configuration.file.YamlConfiguration; +import org.bukkit.plugin.java.JavaPlugin; + +import java.io.*; +import java.lang.reflect.Modifier; +import java.lang.reflect.Type; +import java.util.*; +import java.util.Map.Entry; +import java.util.logging.Level; + + +public abstract class MPlugin extends JavaPlugin { + + // Persist related + public final Gson gson = this.getGsonBuilder().create(); + // Some utils + public Persist persist; + public TextUtil txt; + public PermUtil perm; + public String refCommand = ""; + //holds f stuck taskids + public Map stuckMap = new HashMap<>(); + // These are not supposed to be used directly. + // They are loaded and used through the TextUtil instance for the plugin. + public Map rawTags = new LinkedHashMap<>(); + protected boolean loadSuccessful = false; + private Integer saveTask = null; + private boolean autoSave = true; + // Listeners + private MPluginSecretPlayerListener mPluginSecretPlayerListener; + + // Our stored base commands + private List> baseCommands = new ArrayList<>(); + // holds f stuck start times + private Map timers = new HashMap<>(); + // -------------------------------------------- // + // ENABLE + // -------------------------------------------- // + private long timeEnableStart; + + public boolean getAutoSave() { + return this.autoSave; + } + + public void setAutoSave(boolean val) { + this.autoSave = val; + } + + public List> getBaseCommands() { + return this.baseCommands; + } + + public boolean preEnable() { + log("=== ENABLE START ==="); + timeEnableStart = System.currentTimeMillis(); + + // Ensure basefolder exists! + this.getDataFolder().mkdirs(); + + // Create Utility Instances + this.perm = new PermUtil(this); + this.persist = new Persist(this); + + this.txt = new TextUtil(); + initTXT(); + + // attempt to get first command defined in plugin.yml as reference command, if any commands are defined in there + // reference command will be used to prevent "unknown command" console messages + try { + Map> refCmd = this.getDescription().getCommands(); + if (refCmd != null && !refCmd.isEmpty()) { + this.refCommand = (String) (refCmd.keySet().toArray()[0]); + } + } catch (ClassCastException ex) { + } + + // Create and register player command listener + this.mPluginSecretPlayerListener = new MPluginSecretPlayerListener(this); + getServer().getPluginManager().registerEvents(this.mPluginSecretPlayerListener, this); + + // Register recurring tasks + if (saveTask == null && Conf.saveToFileEveryXMinutes > 0.0) { + long saveTicks = (long) (20 * 60 * Conf.saveToFileEveryXMinutes); // Approximately every 30 min by default + saveTask = Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, new SaveTask(this), saveTicks, saveTicks); + } + + loadLang(); + + loadSuccessful = true; + return true; + } + + public void postEnable() { + log("=== ENABLE DONE (Took " + (System.currentTimeMillis() - timeEnableStart) + "ms) ==="); + } + + public void loadLang() { + File lang = new File(getDataFolder(), "lang.yml"); + OutputStream out = null; + InputStream defLangStream = this.getResource("lang.yml"); + if (!lang.exists()) { + try { + getDataFolder().mkdir(); + lang.createNewFile(); + if (defLangStream != null) { + out = new FileOutputStream(lang); + int read; + byte[] bytes = new byte[1024]; + + while ((read = defLangStream.read(bytes)) != -1) { + out.write(bytes, 0, read); + } + YamlConfiguration defConfig = YamlConfiguration.loadConfiguration(new BufferedReader(new InputStreamReader(defLangStream))); + TL.setFile(defConfig); + } + } catch (IOException e) { + e.printStackTrace(); // So they notice + getLogger().severe("[Factions] Couldn't create language file."); + getLogger().severe("[Factions] This is a fatal error. Now disabling"); + this.setEnabled(false); // Without it loaded, we can't send them messages + } finally { + if (defLangStream != null) { + try { + defLangStream.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + if (out != null) { + try { + out.close(); + } catch (IOException e) { + e.printStackTrace(); + } + + } + } + } + + YamlConfiguration conf = YamlConfiguration.loadConfiguration(lang); + for (TL item : TL.values()) { + if (conf.getString(item.getPath()) == null) { + conf.set(item.getPath(), item.getDefault()); + } + } + + // Remove this here because I'm sick of dealing with bug reports due to bad decisions on my part. + if (conf.getString(TL.COMMAND_SHOW_POWER.getPath(), "").contains("%5$s")) { + conf.set(TL.COMMAND_SHOW_POWER.getPath(), TL.COMMAND_SHOW_POWER.getDefault()); + log(Level.INFO, "Removed errant format specifier from f show power."); + } + + TL.setFile(conf); + try { + conf.save(lang); + } catch (IOException e) { + getLogger().log(Level.WARNING, "Factions: Failed to save lang.yml."); + getLogger().log(Level.WARNING, "Factions: Report this stack trace to prosavage."); + e.printStackTrace(); + } + } + + public void onDisable() { + if (saveTask != null) { + this.getServer().getScheduler().cancelTask(saveTask); + saveTask = null; + } + // only save data if plugin actually loaded successfully + if (loadSuccessful) { + Factions.getInstance().forceSave(); + FPlayers.getInstance().forceSave(); + Board.getInstance().forceSave(); + } + log("Disabled"); + } + + // -------------------------------------------- // + // Some inits... + // You are supposed to override these in the plugin if you aren't satisfied with the defaults + // The goal is that you always will be satisfied though. + // -------------------------------------------- // + + public void suicide() { + log("Now I suicide!"); + this.getServer().getPluginManager().disablePlugin(this); + } + + // -------------------------------------------- // + // LANG AND TAGS + // -------------------------------------------- // + + public GsonBuilder getGsonBuilder() { + return new GsonBuilder().setPrettyPrinting().disableHtmlEscaping().serializeNulls().excludeFieldsWithModifiers(Modifier.TRANSIENT, Modifier.VOLATILE); + } + + public void addRawTags() { + this.rawTags.put("l", ""); // logo + this.rawTags.put("a", ""); // art + this.rawTags.put("n", ""); // notice + this.rawTags.put("i", ""); // info + this.rawTags.put("g", ""); // good + this.rawTags.put("b", ""); // bad + this.rawTags.put("h", ""); // highligh + this.rawTags.put("c", ""); // command + this.rawTags.put("plugin", ""); // parameter + } + + public void initTXT() { + this.addRawTags(); + + Type type = new TypeToken>() { + }.getType(); + + Map tagsFromFile = this.persist.load(type, "tags"); + if (tagsFromFile != null) { + this.rawTags.putAll(tagsFromFile); + } + this.persist.save(this.rawTags, "tags"); + + for (Entry rawTag : this.rawTags.entrySet()) { + this.txt.tags.put(rawTag.getKey(), TextUtil.parseColor(rawTag.getValue())); + } + } + + // -------------------------------------------- // + // COMMAND HANDLING + // -------------------------------------------- // + + // can be overridden by SavageFactions method, to provide option + public boolean logPlayerCommands() { + return true; + } + + public boolean handleCommand(CommandSender sender, String commandString, boolean testOnly) { + return handleCommand(sender, commandString, testOnly, false); + } + + public boolean handleCommand(final CommandSender sender, String commandString, boolean testOnly, boolean async) { + boolean noSlash = true; + if (commandString.startsWith("/")) { + noSlash = false; + commandString = commandString.substring(1); + } + + for (final MCommand command : this.getBaseCommands()) { + if (noSlash && !command.allowNoSlashAccess) { + continue; + } + + for (String alias : command.aliases) { + // disallow double-space after alias, so specific commands can be prevented (preventing "f home" won't prevent "f home") + if (commandString.startsWith(alias + " ")) { + return false; + } + + if (commandString.startsWith(alias + " ") || commandString.equals(alias)) { + final List args = new ArrayList<>(Arrays.asList(commandString.split("\\s+"))); + args.remove(0); + + if (testOnly) { + return true; + } + + if (async) { + Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable() { + @Override + public void run() { + command.execute(sender, args); + } + }); + } else { + command.execute(sender, args); + } + + return true; + } + } + } + return false; + } + + public boolean handleCommand(CommandSender sender, String commandString) { + return this.handleCommand(sender, commandString, false); + } + + // -------------------------------------------- // + // HOOKS + // -------------------------------------------- // + public void preAutoSave() { + + } + + public void postAutoSave() { + + } + + public Map getStuckMap() { + return this.stuckMap; + } + + public Map getTimers() { + return this.timers; + } + + // -------------------------------------------- // + // LOGGING + // -------------------------------------------- // + public void log(Object msg) { + log(Level.INFO, msg); + } + + public void log(String str, Object... args) { + log(Level.INFO, this.txt.parse(str, args)); + } + + public void log(Level level, String str, Object... args) { + log(level, this.txt.parse(str, args)); + } + + public void log(Level level, Object msg) { + getLogger().log(level, "[" + this.getDescription().getFullName() + "] " + msg); + } +} diff --git a/src/main/java/com/massivecraft/factions/zcore/MPluginSecretPlayerListener.java b/src/main/java/com/massivecraft/factions/zcore/MPluginSecretPlayerListener.java index efb3fb7e..ea4474c9 100644 --- a/src/main/java/com/massivecraft/factions/zcore/MPluginSecretPlayerListener.java +++ b/src/main/java/com/massivecraft/factions/zcore/MPluginSecretPlayerListener.java @@ -1,52 +1,52 @@ -package com.massivecraft.factions.zcore; - -import com.massivecraft.factions.FPlayers; -import com.massivecraft.factions.listeners.FactionsPlayerListener; -import org.bukkit.Bukkit; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; -import org.bukkit.event.player.AsyncPlayerChatEvent; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; -import org.bukkit.event.player.PlayerLoginEvent; - -public class MPluginSecretPlayerListener implements Listener { - - private MPlugin p; - - public MPluginSecretPlayerListener(MPlugin p) { - this.p = p; - } - - @EventHandler (priority = EventPriority.LOW, ignoreCancelled = true) - public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) { - if (FactionsPlayerListener.preventCommand(event.getMessage(), event.getPlayer())) { - if (p.logPlayerCommands()) { - Bukkit.getLogger().info("[PLAYER_COMMAND] " + event.getPlayer().getName() + ": " + event.getMessage()); - } - event.setCancelled(true); - } - } - - @EventHandler (priority = EventPriority.LOW, ignoreCancelled = true) - public void onPlayerChat(AsyncPlayerChatEvent event) { - if (p.handleCommand(event.getPlayer(), event.getMessage(), false, true)) { - if (p.logPlayerCommands()) { - Bukkit.getLogger().info("[PLAYER_COMMAND] " + event.getPlayer().getName() + ": " + event.getMessage()); - } - event.setCancelled(true); - } - - /* Should be handled by stuff in FactionsChatListener - Player speaker = event.getPlayer(); - String format = event.getFormat(); - format = format.replace(Conf.chatTagReplaceString, SavageFactions.plugin.getPlayerFactionTag(speaker)).replace("[FACTION_TITLE]", SavageFactions.plugin.getPlayerTitle(speaker)); - event.setFormat(format); - */ - } - - @EventHandler (priority = EventPriority.LOWEST) - public void onPlayerPreLogin(PlayerLoginEvent event) { - FPlayers.getInstance().getByPlayer(event.getPlayer()); - } -} +package com.massivecraft.factions.zcore; + +import com.massivecraft.factions.FPlayers; +import com.massivecraft.factions.listeners.FactionsPlayerListener; +import org.bukkit.Bukkit; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.player.AsyncPlayerChatEvent; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.event.player.PlayerLoginEvent; + +public class MPluginSecretPlayerListener implements Listener { + + private MPlugin p; + + public MPluginSecretPlayerListener(MPlugin p) { + this.p = p; + } + + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) + public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) { + if (FactionsPlayerListener.preventCommand(event.getMessage(), event.getPlayer())) { + if (p.logPlayerCommands()) { + Bukkit.getLogger().info("[PLAYER_COMMAND] " + event.getPlayer().getName() + ": " + event.getMessage()); + } + event.setCancelled(true); + } + } + + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) + public void onPlayerChat(AsyncPlayerChatEvent event) { + if (p.handleCommand(event.getPlayer(), event.getMessage(), false, true)) { + if (p.logPlayerCommands()) { + Bukkit.getLogger().info("[PLAYER_COMMAND] " + event.getPlayer().getName() + ": " + event.getMessage()); + } + event.setCancelled(true); + } + + /* Should be handled by stuff in FactionsChatListener + Player speaker = event.getPlayer(); + String format = event.getFormat(); + format = format.replace(Conf.chatTagReplaceString, SavageFactions.plugin.getPlayerFactionTag(speaker)).replace("[FACTION_TITLE]", SavageFactions.plugin.getPlayerTitle(speaker)); + event.setFormat(format); + */ + } + + @EventHandler(priority = EventPriority.LOWEST) + public void onPlayerPreLogin(PlayerLoginEvent event) { + FPlayers.getInstance().getByPlayer(event.getPlayer()); + } +} diff --git a/src/main/java/com/massivecraft/factions/zcore/fperms/Permissable.java b/src/main/java/com/massivecraft/factions/zcore/fperms/Permissable.java index ea7a4c37..3441f9d3 100644 --- a/src/main/java/com/massivecraft/factions/zcore/fperms/Permissable.java +++ b/src/main/java/com/massivecraft/factions/zcore/fperms/Permissable.java @@ -4,10 +4,10 @@ import org.bukkit.inventory.ItemStack; public interface Permissable { - public ItemStack buildItem(); + ItemStack buildItem(); - public String replacePlaceholders(String string); + String replacePlaceholders(String string); - public String name(); + String name(); } diff --git a/src/main/java/com/massivecraft/factions/zcore/fperms/PermissableAction.java b/src/main/java/com/massivecraft/factions/zcore/fperms/PermissableAction.java index a7fe22ea..2f8a77be 100644 --- a/src/main/java/com/massivecraft/factions/zcore/fperms/PermissableAction.java +++ b/src/main/java/com/massivecraft/factions/zcore/fperms/PermissableAction.java @@ -109,11 +109,16 @@ public enum PermissableAction { String accessValue = null; - switch (access) - { - case ALLOW: accessValue = "allow"; break; - case DENY: accessValue = "deny"; break; - case UNDEFINED: accessValue = "undefined"; break; + switch (access) { + case ALLOW: + accessValue = "allow"; + break; + case DENY: + accessValue = "deny"; + break; + case UNDEFINED: + accessValue = "undefined"; + break; } // If under the 1.13 version we will use the colorable option. diff --git a/src/main/java/com/massivecraft/factions/zcore/fperms/gui/PermissableActionGUI.java b/src/main/java/com/massivecraft/factions/zcore/fperms/gui/PermissableActionGUI.java index bfe97a44..c26ad9a4 100644 --- a/src/main/java/com/massivecraft/factions/zcore/fperms/gui/PermissableActionGUI.java +++ b/src/main/java/com/massivecraft/factions/zcore/fperms/gui/PermissableActionGUI.java @@ -58,7 +58,7 @@ public class PermissableActionGUI implements InventoryHolder, FactionGUI { boolean disabled = false; for (String key : section.getConfigurationSection("slots").getKeys(false)) { int slot = section.getInt("slots." + key); - if (slot == - 1) { + if (slot == -1) { disabled = true; continue; } @@ -97,7 +97,7 @@ public class PermissableActionGUI implements InventoryHolder, FactionGUI { actionSlots.put(slot, action); } else { int slot = actionGUI.firstEmpty(); - if (slot != - 1) { + if (slot != -1) { actionSlots.put(slot, action); } } diff --git a/src/main/java/com/massivecraft/factions/zcore/fperms/gui/PermissableRelationGUI.java b/src/main/java/com/massivecraft/factions/zcore/fperms/gui/PermissableRelationGUI.java index c780e02e..871ee281 100644 --- a/src/main/java/com/massivecraft/factions/zcore/fperms/gui/PermissableRelationGUI.java +++ b/src/main/java/com/massivecraft/factions/zcore/fperms/gui/PermissableRelationGUI.java @@ -58,7 +58,7 @@ public class PermissableRelationGUI implements InventoryHolder, FactionGUI { for (String key : section.getConfigurationSection("slots").getKeys(false)) { int slot = section.getInt("slots." + key); - if (slot == - 1) { + if (slot == -1) { continue; } if (slot + 1 > guiSize && slot > 0) { diff --git a/src/main/java/com/massivecraft/factions/zcore/fupgrades/CropUpgrades.java b/src/main/java/com/massivecraft/factions/zcore/fupgrades/CropUpgrades.java index 664a5eaf..a12f496d 100644 --- a/src/main/java/com/massivecraft/factions/zcore/fupgrades/CropUpgrades.java +++ b/src/main/java/com/massivecraft/factions/zcore/fupgrades/CropUpgrades.java @@ -16,30 +16,34 @@ import org.bukkit.material.Crops; import java.util.concurrent.ThreadLocalRandom; public class CropUpgrades implements Listener { - + @EventHandler public void onCropGrow(BlockGrowEvent e) { FLocation floc = new FLocation(e.getBlock().getLocation()); Faction factionAtLoc = Board.getInstance().getFactionAt(floc); - + if (!factionAtLoc.isWilderness()) { - int level = factionAtLoc.getUpgrade(Upgrade.CROP); + int level = factionAtLoc.getUpgrade(Upgrade.CROP); if (level != 0) { - int chance = -1; - - switch (level) - { - case 1: chance = SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Crops.Crop-Boost.level-1"); break; - case 2: chance = SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Crops.Crop-Boost.level-2"); break; - case 3: chance = SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Crops.Crop-Boost.level-3"); break; - } - - if (chance >= 0) - { - int randomNum = ThreadLocalRandom.current().nextInt(1, 100 + 1); - if (randomNum <= chance) - growCrop(e); - } + int chance = -1; + + switch (level) { + case 1: + chance = SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Crops.Crop-Boost.level-1"); + break; + case 2: + chance = SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Crops.Crop-Boost.level-2"); + break; + case 3: + chance = SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Crops.Crop-Boost.level-3"); + break; + } + + if (chance >= 0) { + int randomNum = ThreadLocalRandom.current().nextInt(1, 100 + 1); + if (randomNum <= chance) + growCrop(e); + } } } } @@ -53,21 +57,20 @@ public class CropUpgrades implements Listener { bs.setData(c); bs.update(); } - + Block below = e.getBlock().getLocation().subtract(0, 1, 0).getBlock(); if (below.getType() == SavageFactions.plugin.SUGAR_CANE_BLOCK) { Block above = e.getBlock().getLocation().add(0, 1, 0).getBlock(); - - if (above.getType() == Material.AIR && above.getLocation().add(0, - 2, 0).getBlock().getType() != Material.AIR) { + + if (above.getType() == Material.AIR && above.getLocation().add(0, -2, 0).getBlock().getType() != Material.AIR) { above.setType(SavageFactions.plugin.SUGAR_CANE_BLOCK); } - } - else if (below.getType() == Material.CACTUS) { + } else if (below.getType() == Material.CACTUS) { Block above = e.getBlock().getLocation().add(0, 1, 0).getBlock(); - if (above.getType() == Material.AIR && above.getLocation().add(0, - 2, 0).getBlock().getType() != Material.AIR) { + if (above.getType() == Material.AIR && above.getLocation().add(0, -2, 0).getBlock().getType() != Material.AIR) { above.setType(Material.CACTUS); } } diff --git a/src/main/java/com/massivecraft/factions/zcore/fupgrades/EXPUpgrade.java b/src/main/java/com/massivecraft/factions/zcore/fupgrades/EXPUpgrade.java index bc184ca6..473f70f0 100644 --- a/src/main/java/com/massivecraft/factions/zcore/fupgrades/EXPUpgrade.java +++ b/src/main/java/com/massivecraft/factions/zcore/fupgrades/EXPUpgrade.java @@ -11,32 +11,37 @@ import org.bukkit.event.Listener; import org.bukkit.event.entity.EntityDeathEvent; public class EXPUpgrade implements Listener { - + @EventHandler public void onDeath(EntityDeathEvent e) { Entity killer = e.getEntity().getKiller(); - + if (killer == null || !(killer instanceof Player)) return; - + FLocation floc = new FLocation(e.getEntity().getLocation()); Faction faction = Board.getInstance().getFactionAt(floc); - + if (!faction.isWilderness()) { - int level = faction.getUpgrade(Upgrade.EXP); + int level = faction.getUpgrade(Upgrade.EXP); if (level != 0) { - - double multiplier = -1; - - switch (level) - { - case 1: multiplier = SavageFactions.plugin.getConfig().getDouble("fupgrades.MainMenu.EXP.EXP-Boost.level-1"); break; - case 2: multiplier = SavageFactions.plugin.getConfig().getDouble("fupgrades.MainMenu.EXP.EXP-Boost.level-2"); break; - case 3: multiplier = SavageFactions.plugin.getConfig().getDouble("fupgrades.MainMenu.EXP.EXP-Boost.level-3"); break; - } - - if (multiplier >= 0) - spawnMoreExp(e, multiplier); + + double multiplier = -1; + + switch (level) { + case 1: + multiplier = SavageFactions.plugin.getConfig().getDouble("fupgrades.MainMenu.EXP.EXP-Boost.level-1"); + break; + case 2: + multiplier = SavageFactions.plugin.getConfig().getDouble("fupgrades.MainMenu.EXP.EXP-Boost.level-2"); + break; + case 3: + multiplier = SavageFactions.plugin.getConfig().getDouble("fupgrades.MainMenu.EXP.EXP-Boost.level-3"); + break; + } + + if (multiplier >= 0) + spawnMoreExp(e, multiplier); } } } diff --git a/src/main/java/com/massivecraft/factions/zcore/fupgrades/FUpgradesGUI.java b/src/main/java/com/massivecraft/factions/zcore/fupgrades/FUpgradesGUI.java index 4ddcc31e..0e14eb6e 100644 --- a/src/main/java/com/massivecraft/factions/zcore/fupgrades/FUpgradesGUI.java +++ b/src/main/java/com/massivecraft/factions/zcore/fupgrades/FUpgradesGUI.java @@ -31,17 +31,17 @@ public class FUpgradesGUI implements Listener { dummyData, SavageFactions.plugin.color(SavageFactions.plugin.getConfig().getString("fupgrades.MainMenu.DummyItem.Name")), SavageFactions.plugin.colorList(SavageFactions.plugin.getConfig().getStringList("fupgrades.MainMenu.DummyItem.Lore"))); - + for (int i = 0; i <= dummySlots.size() - 1; i++) { inventory.setItem(dummySlots.get(i), dummyItem); } - + ItemStack[] items = buildItems(fme); List cropSlots = SavageFactions.plugin.getConfig().getIntegerList("fupgrades.MainMenu.Crops.CropItem.slots"); List spawnerSlots = SavageFactions.plugin.getConfig().getIntegerList("fupgrades.MainMenu.Spawners.SpawnerItem.slots"); List expSlots = SavageFactions.plugin.getConfig().getIntegerList("fupgrades.MainMenu.EXP.EXPItem.slots"); List chestSlots = SavageFactions.plugin.getConfig().getIntegerList("fupgrades.MainMenu.Chest.ChestItem.slots"); - + for (int i = 0; i < cropSlots.size(); i++) inventory.setItem(cropSlots.get(i), items[2]); @@ -61,7 +61,7 @@ public class FUpgradesGUI implements Listener { public void onClick(InventoryClickEvent e) { if (e.getClickedInventory() == null || e.getCurrentItem() == null || e.getCurrentItem().getItemMeta() == null || e.getCursor() == null) return; - + FPlayer fme = FPlayers.getInstance().getByPlayer((Player) e.getWhoClicked()); if (e.getClickedInventory().getTitle().equalsIgnoreCase(SavageFactions.plugin.color(SavageFactions.plugin.getConfig().getString("fupgrades.MainMenu.Title").replace("{faction}", fme.getFaction().getTag())))) { e.setCancelled(true); @@ -70,103 +70,102 @@ public class FUpgradesGUI implements Listener { ItemStack expItem = items[0]; ItemStack chestitem = items[3]; ItemStack spawnerItem = items[1]; - + if (e.getCurrentItem().equals(cropItem)) { - int cropLevel = fme.getFaction().getUpgrade(Upgrade.CROP); - - switch (cropLevel) - { - case 3: return; - case 2: - upgradeItem(fme, Upgrade.CROP, 3, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Crops.Cost.level-3")); - break; - case 1: - upgradeItem(fme, Upgrade.CROP, 2, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Crops.Cost.level-2")); - break; - case 0: - upgradeItem(fme, Upgrade.CROP, 1, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Crops.Cost.level-1")); - break; - } - } - else if (e.getCurrentItem().equals(spawnerItem)) { - int spawnerLevel = fme.getFaction().getUpgrade(Upgrade.SPAWNER); - - switch(spawnerLevel) - { - case 3: return; - case 2: - upgradeItem(fme, Upgrade.SPAWNER, 3, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Spawners.Cost.level-3")); - break; - case 1: - upgradeItem(fme, Upgrade.SPAWNER, 2, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Spawners.Cost.level-2")); - break; - case 0: - upgradeItem(fme, Upgrade.SPAWNER, 1, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Spawners.Cost.level-1")); - break; - } - } - else if (e.getCurrentItem().equals(expItem)) { - int expLevel = fme.getFaction().getUpgrade(Upgrade.EXP); - - switch (expLevel) - { - case 3: return; - case 2: - upgradeItem(fme, Upgrade.EXP, 3, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.EXP.Cost.level-3")); - break; - case 1: - upgradeItem(fme, Upgrade.EXP, 2, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.EXP.Cost.level-2")); - break; - case 0: - upgradeItem(fme, Upgrade.EXP, 1, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.EXP.Cost.level-1")); - break; - } - } - else if (e.getCurrentItem().equals(chestitem)) { - int chestLevel = fme.getFaction().getUpgrade(Upgrade.CHEST); - - switch (chestLevel) - { - case 3: return; - case 2: - { - if (upgradeItem(fme, Upgrade.CHEST, 3, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Chest.Cost.level-3"))) - updateChests(fme.getFaction()); + int cropLevel = fme.getFaction().getUpgrade(Upgrade.CROP); + + switch (cropLevel) { + case 3: + return; + case 2: + upgradeItem(fme, Upgrade.CROP, 3, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Crops.Cost.level-3")); break; - } - case 1: - { - if (upgradeItem(fme, Upgrade.CHEST, 2, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Chest.Cost.level-2"))) - updateChests(fme.getFaction()); + case 1: + upgradeItem(fme, Upgrade.CROP, 2, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Crops.Cost.level-2")); break; - } - case 0: - { - if (upgradeItem(fme, Upgrade.CHEST, 1, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Chest.Cost.level-1"))) - updateChests(fme.getFaction()); + case 0: + upgradeItem(fme, Upgrade.CROP, 1, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Crops.Cost.level-1")); break; - } - } + } + } else if (e.getCurrentItem().equals(spawnerItem)) { + int spawnerLevel = fme.getFaction().getUpgrade(Upgrade.SPAWNER); + + switch (spawnerLevel) { + case 3: + return; + case 2: + upgradeItem(fme, Upgrade.SPAWNER, 3, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Spawners.Cost.level-3")); + break; + case 1: + upgradeItem(fme, Upgrade.SPAWNER, 2, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Spawners.Cost.level-2")); + break; + case 0: + upgradeItem(fme, Upgrade.SPAWNER, 1, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Spawners.Cost.level-1")); + break; + } + } else if (e.getCurrentItem().equals(expItem)) { + int expLevel = fme.getFaction().getUpgrade(Upgrade.EXP); + + switch (expLevel) { + case 3: + return; + case 2: + upgradeItem(fme, Upgrade.EXP, 3, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.EXP.Cost.level-3")); + break; + case 1: + upgradeItem(fme, Upgrade.EXP, 2, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.EXP.Cost.level-2")); + break; + case 0: + upgradeItem(fme, Upgrade.EXP, 1, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.EXP.Cost.level-1")); + break; + } + } else if (e.getCurrentItem().equals(chestitem)) { + int chestLevel = fme.getFaction().getUpgrade(Upgrade.CHEST); + + switch (chestLevel) { + case 3: + return; + case 2: { + if (upgradeItem(fme, Upgrade.CHEST, 3, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Chest.Cost.level-3"))) + updateChests(fme.getFaction()); + break; + } + case 1: { + if (upgradeItem(fme, Upgrade.CHEST, 2, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Chest.Cost.level-2"))) + updateChests(fme.getFaction()); + break; + } + case 0: { + if (upgradeItem(fme, Upgrade.CHEST, 1, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Chest.Cost.level-1"))) + updateChests(fme.getFaction()); + break; + } + } } } } private void updateChests(Faction faction) { - String invName = SavageFactions.plugin.color(SavageFactions.plugin.getConfig().getString("fchest.Inventory-Title")); - + String invName = SavageFactions.plugin.color(SavageFactions.plugin.getConfig().getString("fchest.Inventory-Title")); + for (Player player : faction.getOnlinePlayers()) { if (player.getInventory().getTitle() != null && player.getInventory().getTitle().equalsIgnoreCase(invName)) - player.closeInventory(); + player.closeInventory(); } - int level = faction.getUpgrade(Upgrade.CHEST); + int level = faction.getUpgrade(Upgrade.CHEST); int size = 1; - - switch (level) - { - case 1: size = SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Chest.Chest-Size.level-1"); break; - case 2: size = SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Chest.Chest-Size.level-2"); break; - case 3: size = SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Chest.Chest-Size.level-3"); break; + + switch (level) { + case 1: + size = SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Chest.Chest-Size.level-1"); + break; + case 2: + size = SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Chest.Chest-Size.level-2"); + break; + case 3: + size = SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Chest.Chest-Size.level-3"); + break; } faction.setChestSize(size * 9); } @@ -177,20 +176,20 @@ public class FUpgradesGUI implements Listener { short expData = Short.parseShort(SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.EXP.EXPItem.Damage") + ""); String expName = SavageFactions.plugin.color(SavageFactions.plugin.getConfig().getString("fupgrades.MainMenu.EXP.EXPItem.Name")); List expLore = SavageFactions.plugin.colorList(SavageFactions.plugin.getConfig().getStringList("fupgrades.MainMenu.EXP.EXPItem.Lore")); - int expLevel = fme.getFaction().getUpgrade(Upgrade.EXP); - + int expLevel = fme.getFaction().getUpgrade(Upgrade.EXP); + for (int i = 0; i <= expLore.size() - 1; i++) expLore.set(i, expLore.get(i).replace("{level}", expLevel + "")); ItemStack expItem = SavageFactions.plugin.createItem(expMaterial, expAmt, expData, expName, expLore); - + if (expLevel >= 1) { ItemMeta itemMeta = expItem.getItemMeta(); if (!SavageFactions.plugin.mc17) { itemMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS); } itemMeta.addEnchant(Enchantment.DURABILITY, 3, true); - + expItem.setItemMeta(itemMeta); expItem.setAmount(expLevel); } @@ -202,28 +201,28 @@ public class FUpgradesGUI implements Listener { List spawnerLore = SavageFactions.plugin.colorList(SavageFactions.plugin.getConfig().getStringList("fupgrades.MainMenu.Spawners.SpawnerItem.Lore")); List spawnerSlots = SavageFactions.plugin.getConfig().getIntegerList("fupgrades.MainMenu.Spawners.SpawnerItem.slots"); - int spawnerLevel = fme.getFaction().getUpgrade(Upgrade.SPAWNER); + int spawnerLevel = fme.getFaction().getUpgrade(Upgrade.SPAWNER); for (int i = 0; i <= spawnerLore.size() - 1; i++) { spawnerLore.set(i, spawnerLore.get(i).replace("{level}", spawnerLevel + "")); } - + Material cropMaterial = Material.getMaterial(SavageFactions.plugin.getConfig().getString("fupgrades.MainMenu.Crops.CropItem.Type")); int cropAmt = SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Crops.CropItem.Amount"); short cropData = Short.parseShort(SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Crops.CropItem.Damage") + ""); String cropName = SavageFactions.plugin.color(SavageFactions.plugin.getConfig().getString("fupgrades.MainMenu.Crops.CropItem.Name")); List cropLore = SavageFactions.plugin.colorList(SavageFactions.plugin.getConfig().getStringList("fupgrades.MainMenu.Crops.CropItem.Lore")); - int cropLevel = fme.getFaction().getUpgrade(Upgrade.CROP); - + int cropLevel = fme.getFaction().getUpgrade(Upgrade.CROP); + for (int i = 0; i <= cropLore.size() - 1; i++) { String line = cropLore.get(i); line = line.replace("{level}", cropLevel + ""); cropLore.set(i, line); } - + ItemStack cropItem = SavageFactions.plugin.createItem(cropMaterial, cropAmt, cropData, cropName, cropLore); cropItem.getItemMeta().setLore(cropLore); - + if (cropLevel >= 1) { ItemMeta itemMeta = cropItem.getItemMeta(); if (!SavageFactions.plugin.mc17) { @@ -231,10 +230,10 @@ public class FUpgradesGUI implements Listener { } itemMeta.addEnchant(Enchantment.DURABILITY, 3, true); cropItem.setItemMeta(itemMeta); - + cropItem.setAmount(cropLevel); } - + ItemStack spawnerItem = SavageFactions.plugin.createItem(spawnerMaterial, spawnerAmt, spawnerData, spawnerName, spawnerLore); spawnerItem.getItemMeta().setLore(spawnerLore); if (spawnerLevel >= 1) { @@ -243,18 +242,18 @@ public class FUpgradesGUI implements Listener { itemMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS); } itemMeta.addEnchant(Enchantment.DURABILITY, 3, true); - + spawnerItem.setItemMeta(itemMeta); spawnerItem.setAmount(spawnerLevel); } - + Material chestMaterial = Material.getMaterial(SavageFactions.plugin.getConfig().getString("fupgrades.MainMenu.Chest.ChestItem.Type")); int chesttAmt = SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Chest.ChestItem.Amount"); short chestData = Short.parseShort(SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Chest.ChestItem.Damage") + ""); String chestName = SavageFactions.plugin.color(SavageFactions.plugin.getConfig().getString("fupgrades.MainMenu.Chest.ChestItem.Name", "&e&lUpgrade Chest Size")); List chestLore = SavageFactions.plugin.colorList(SavageFactions.plugin.getConfig().getStringList("fupgrades.MainMenu.Chest.ChestItem.Lore")); - int chestlevel = fme.getFaction().getUpgrade(Upgrade.CHEST); - + int chestlevel = fme.getFaction().getUpgrade(Upgrade.CHEST); + for (int i = 0; i <= chestLore.size() - 1; i++) { String line = chestLore.get(i); line = line.replace("{level}", chestlevel + ""); @@ -269,7 +268,7 @@ public class FUpgradesGUI implements Listener { itemMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS); } itemMeta.addEnchant(Enchantment.DURABILITY, 3, true); - + chestItem.setItemMeta(itemMeta); chestItem.setAmount(chestlevel); } @@ -286,11 +285,10 @@ public class FUpgradesGUI implements Listener { fme.takeMoney(amt); } - private boolean upgradeItem(FPlayer fme, Upgrade upgrade, int level, int cost) - { + private boolean upgradeItem(FPlayer fme, Upgrade upgrade, int level, int cost) { if (hasMoney(fme, cost)) { - takeMoney(fme, cost); - fme.getFaction().setUpgrade(upgrade, level); + takeMoney(fme, cost); + fme.getFaction().setUpgrade(upgrade, level); fme.getPlayer().closeInventory(); return true; } diff --git a/src/main/java/com/massivecraft/factions/zcore/fupgrades/SpawnerUpgrades.java b/src/main/java/com/massivecraft/factions/zcore/fupgrades/SpawnerUpgrades.java index b6351577..209859f5 100644 --- a/src/main/java/com/massivecraft/factions/zcore/fupgrades/SpawnerUpgrades.java +++ b/src/main/java/com/massivecraft/factions/zcore/fupgrades/SpawnerUpgrades.java @@ -9,21 +9,26 @@ import org.bukkit.event.Listener; import org.bukkit.event.entity.SpawnerSpawnEvent; public class SpawnerUpgrades implements Listener { - + @EventHandler public void onSpawn(SpawnerSpawnEvent e) { FLocation floc = new FLocation(e.getLocation()); Faction factionAtLoc = Board.getInstance().getFactionAt(floc); - + if (!factionAtLoc.isWilderness()) { - int level = factionAtLoc.getUpgrade(Upgrade.SPAWNER); + int level = factionAtLoc.getUpgrade(Upgrade.SPAWNER); if (level != 0) { - switch (level) - { - case 1: lowerSpawnerDelay(e, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Spawners.Spawner-Boost.level-1")); break; - case 2: lowerSpawnerDelay(e, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Spawners.Spawner-Boost.level-2")); break; - case 3: lowerSpawnerDelay(e, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Spawners.Spawner-Boost.level-3")); break; - } + switch (level) { + case 1: + lowerSpawnerDelay(e, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Spawners.Spawner-Boost.level-1")); + break; + case 2: + lowerSpawnerDelay(e, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Spawners.Spawner-Boost.level-2")); + break; + case 3: + lowerSpawnerDelay(e, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Spawners.Spawner-Boost.level-3")); + break; + } } } } diff --git a/src/main/java/com/massivecraft/factions/zcore/fupgrades/Upgrade.java b/src/main/java/com/massivecraft/factions/zcore/fupgrades/Upgrade.java index 2d05002f..98e02172 100644 --- a/src/main/java/com/massivecraft/factions/zcore/fupgrades/Upgrade.java +++ b/src/main/java/com/massivecraft/factions/zcore/fupgrades/Upgrade.java @@ -2,17 +2,17 @@ package com.massivecraft.factions.zcore.fupgrades; public enum Upgrade { - CHEST("Chest"), SPAWNER("Spawner"), EXP("Exp"), CROP("Crop"); + CHEST("Chest"), SPAWNER("Spawner"), EXP("Exp"), CROP("Crop"); - private String id; + private String id; - Upgrade(String id) { - this.id = id; - } + Upgrade(String id) { + this.id = id; + } - @Override - public String toString() { - return this.id; - } + @Override + public String toString() { + return this.id; + } } diff --git a/src/main/java/com/massivecraft/factions/zcore/nbtapi/NBTCompound.java b/src/main/java/com/massivecraft/factions/zcore/nbtapi/NBTCompound.java index c758542c..8cec2e41 100644 --- a/src/main/java/com/massivecraft/factions/zcore/nbtapi/NBTCompound.java +++ b/src/main/java/com/massivecraft/factions/zcore/nbtapi/NBTCompound.java @@ -10,9 +10,9 @@ public class NBTCompound { private String compundName; private NBTCompound parent; - protected NBTCompound() - {} - + protected NBTCompound() { + } + protected NBTCompound(NBTCompound owner, String name) { this.compundName = name; this.parent = owner; diff --git a/src/main/java/com/massivecraft/factions/zcore/nbtapi/NBTList.java b/src/main/java/com/massivecraft/factions/zcore/nbtapi/NBTList.java index 9a2a1b1c..a3d5a985 100644 --- a/src/main/java/com/massivecraft/factions/zcore/nbtapi/NBTList.java +++ b/src/main/java/com/massivecraft/factions/zcore/nbtapi/NBTList.java @@ -115,7 +115,7 @@ public class NBTList { } catch (Exception ex) { ex.printStackTrace(); } - return - 1; + return -1; } public NBTType getType() { diff --git a/src/main/java/com/massivecraft/factions/zcore/nbtapi/NBTListCompound.java b/src/main/java/com/massivecraft/factions/zcore/nbtapi/NBTListCompound.java index f7c52a2b..e3d92716 100644 --- a/src/main/java/com/massivecraft/factions/zcore/nbtapi/NBTListCompound.java +++ b/src/main/java/com/massivecraft/factions/zcore/nbtapi/NBTListCompound.java @@ -81,7 +81,7 @@ public class NBTListCompound { return false; } - @SuppressWarnings ("unchecked") + @SuppressWarnings("unchecked") public Set getKeys() { try { return (Set) compound.getClass().getMethod("c").invoke(compound); diff --git a/src/main/java/com/massivecraft/factions/zcore/nbtapi/NBTReflectionUtil.java b/src/main/java/com/massivecraft/factions/zcore/nbtapi/NBTReflectionUtil.java index d2192722..a35684ef 100644 --- a/src/main/java/com/massivecraft/factions/zcore/nbtapi/NBTReflectionUtil.java +++ b/src/main/java/com/massivecraft/factions/zcore/nbtapi/NBTReflectionUtil.java @@ -24,7 +24,7 @@ public class NBTReflectionUtil { private static Class getCraftItemStack() { try { - return Class.forName("org.bukkit.craftbukkit." + version + ".inventory.CraftItemStack"); + return Class.forName("org.bukkit.craftbukkit." + version + ".inventory.CraftItemStack"); } catch (Exception ex) { System.out.println("Error in ItemNBTAPI!(Outdated plugin?)"); ex.printStackTrace(); @@ -34,7 +34,7 @@ public class NBTReflectionUtil { private static Class getCraftEntity() { try { - return Class.forName("org.bukkit.craftbukkit." + version + ".entity.CraftEntity"); + return Class.forName("org.bukkit.craftbukkit." + version + ".entity.CraftEntity"); } catch (Exception ex) { System.out.println("Error in ItemNBTAPI!(Outdated plugin?)"); ex.printStackTrace(); @@ -44,7 +44,7 @@ public class NBTReflectionUtil { protected static Class getNBTBase() { try { - return Class.forName("net.minecraft.server." + version + ".NBTBase"); + return Class.forName("net.minecraft.server." + version + ".NBTBase"); } catch (Exception ex) { System.out.println("Error in ItemNBTAPI!(Outdated plugin?)"); ex.printStackTrace(); @@ -54,7 +54,7 @@ public class NBTReflectionUtil { protected static Class getNBTTagString() { try { - return Class.forName("net.minecraft.server." + version + ".NBTTagString"); + return Class.forName("net.minecraft.server." + version + ".NBTTagString"); } catch (Exception ex) { System.out.println("Error in ItemNBTAPI!(Outdated plugin?)"); ex.printStackTrace(); @@ -64,7 +64,7 @@ public class NBTReflectionUtil { protected static Class getNMSItemStack() { try { - return Class.forName("net.minecraft.server." + version + ".ItemStack"); + return Class.forName("net.minecraft.server." + version + ".ItemStack"); } catch (Exception ex) { System.out.println("Error in ItemNBTAPI!(Outdated plugin?)"); ex.printStackTrace(); @@ -74,7 +74,7 @@ public class NBTReflectionUtil { protected static Class getNBTTagCompound() { try { - return Class.forName("net.minecraft.server." + version + ".NBTTagCompound"); + return Class.forName("net.minecraft.server." + version + ".NBTTagCompound"); } catch (Exception ex) { System.out.println("Error in ItemNBTAPI!(Outdated plugin?)"); ex.printStackTrace(); @@ -84,7 +84,7 @@ public class NBTReflectionUtil { protected static Class getNBTCompressedStreamTools() { try { - return Class.forName("net.minecraft.server." + version + ".NBTCompressedStreamTools"); + return Class.forName("net.minecraft.server." + version + ".NBTCompressedStreamTools"); } catch (Exception ex) { System.out.println("Error in ItemNBTAPI!(Outdated plugin?)"); ex.printStackTrace(); @@ -94,7 +94,7 @@ public class NBTReflectionUtil { protected static Class getMojangsonParser() { try { - return Class.forName("net.minecraft.server." + version + ".MojangsonParser"); + return Class.forName("net.minecraft.server." + version + ".MojangsonParser"); } catch (Exception ex) { System.out.println("Error in ItemNBTAPI!(Outdated plugin?)"); ex.printStackTrace(); @@ -104,7 +104,7 @@ public class NBTReflectionUtil { protected static Class getTileEntity() { try { - return Class.forName("net.minecraft.server." + version + ".TileEntity"); + return Class.forName("net.minecraft.server." + version + ".TileEntity"); } catch (Exception ex) { System.out.println("Error in ItemNBTAPI!(Outdated plugin?)"); ex.printStackTrace(); @@ -114,7 +114,7 @@ public class NBTReflectionUtil { protected static Class getCraftWorld() { try { - return Class.forName("org.bukkit.craftbukkit." + version + ".CraftWorld"); + return Class.forName("org.bukkit.craftbukkit." + version + ".CraftWorld"); } catch (Exception ex) { System.out.println("Error in ItemNBTAPI!(Outdated plugin?)"); ex.printStackTrace(); @@ -148,7 +148,7 @@ public class NBTReflectionUtil { public static Object setNBTTag(Object NBTTag, Object NMSItem) { try { - Method method = NMSItem.getClass().getMethod("setTag", NBTTag.getClass()); + Method method = NMSItem.getClass().getMethod("setTag", NBTTag.getClass()); method.invoke(NMSItem, NBTTag); return NMSItem; } catch (Exception ex) { @@ -159,9 +159,9 @@ public class NBTReflectionUtil { public static Object getNMSItemStack(ItemStack item) { Class clazz = getCraftItemStack(); - + try { - Method method = clazz.getMethod("asNMSCopy", ItemStack.class); + Method method = clazz.getMethod("asNMSCopy", ItemStack.class); return method.invoke(clazz, item); } catch (Exception e) { e.printStackTrace(); @@ -171,9 +171,9 @@ public class NBTReflectionUtil { public static Object getNMSEntity(Entity entity) { Class clazz = getCraftEntity(); - + try { - Method method = clazz.getMethod("getHandle"); + Method method = clazz.getMethod("getHandle"); return method.invoke(getCraftEntity().cast(entity)); } catch (Exception e) { e.printStackTrace(); @@ -183,9 +183,9 @@ public class NBTReflectionUtil { public static Object parseNBT(String json) { Class cis = getMojangsonParser(); - + try { - Method method = cis.getMethod("parse", String.class); + Method method = cis.getMethod("parse", String.class); return method.invoke(null, json); } catch (Exception e) { e.printStackTrace(); @@ -195,9 +195,9 @@ public class NBTReflectionUtil { public static Object readNBTFile(FileInputStream stream) { Class clazz = getNBTCompressedStreamTools(); - + try { - Method method = clazz.getMethod("a", InputStream.class); + Method method = clazz.getMethod("a", InputStream.class); return method.invoke(clazz, stream); } catch (Exception e) { e.printStackTrace(); @@ -207,9 +207,9 @@ public class NBTReflectionUtil { public static Object saveNBTFile(Object nbt, FileOutputStream stream) { Class clazz = getNBTCompressedStreamTools(); - + try { - Method method = clazz.getMethod("a", getNBTTagCompound(), OutputStream.class); + Method method = clazz.getMethod("a", getNBTTagCompound(), OutputStream.class); return method.invoke(clazz, nbt, stream); } catch (Exception e) { e.printStackTrace(); @@ -219,9 +219,9 @@ public class NBTReflectionUtil { public static ItemStack getBukkitItemStack(Object item) { Class clazz = getCraftItemStack(); - + try { - Method method = clazz.getMethod("asCraftMirror", item.getClass()); + Method method = clazz.getMethod("asCraftMirror", item.getClass()); return (ItemStack) method.invoke(clazz, item); } catch (Exception e) { e.printStackTrace(); @@ -231,10 +231,10 @@ public class NBTReflectionUtil { public static Object getItemRootNBTTagCompound(Object nmsitem) { Class clazz = nmsitem.getClass(); - + try { - Method method = clazz.getMethod("getTag"); - return method.invoke(nmsitem); + Method method = clazz.getMethod("getTag"); + return method.invoke(nmsitem); } catch (Exception e) { e.printStackTrace(); } @@ -244,7 +244,7 @@ public class NBTReflectionUtil { public static Object convertNBTCompoundtoNMSItem(NBTCompound nbtcompound) { Class clazz = getNMSItemStack(); try { - return clazz.getConstructor(getNBTTagCompound()).newInstance(gettoCompount(nbtcompound.getCompound(), nbtcompound)); + return clazz.getConstructor(getNBTTagCompound()).newInstance(gettoCompount(nbtcompound.getCompound(), nbtcompound)); } catch (Exception e) { e.printStackTrace(); } @@ -253,9 +253,9 @@ public class NBTReflectionUtil { public static NBTContainer convertNMSItemtoNBTCompound(Object nmsitem) { Class clazz = nmsitem.getClass(); - + try { - Method method = clazz.getMethod("save", getNBTTagCompound()); + Method method = clazz.getMethod("save", getNBTTagCompound()); Object answer = method.invoke(nmsitem, getNewNBTTag()); return new NBTContainer(answer); } catch (Exception e) { @@ -266,12 +266,12 @@ public class NBTReflectionUtil { public static Object getEntityNBTTagCompound(Object nmsitem) { Class c = nmsitem.getClass(); - + try { - Method method = c.getMethod(MethodNames.getEntityNbtGetterMethodName(), getNBTTagCompound()); + Method method = c.getMethod(MethodNames.getEntityNbtGetterMethodName(), getNBTTagCompound()); Object nbt = getNBTTagCompound().newInstance(); Object answer = method.invoke(nmsitem, nbt); - return answer != null ? answer:nbt; + return answer != null ? answer : nbt; } catch (Exception e) { e.printStackTrace(); } @@ -299,8 +299,8 @@ public class NBTReflectionUtil { Method method = getTileEntity().getMethod(MethodNames.getTileDataMethodName(), getNBTTagCompound()); Object tag = getNBTTagCompound().newInstance(); Object answer = method.invoke(o, tag); - - return answer != null ? answer:tag; + + return answer != null ? answer : tag; } catch (Exception e) { e.printStackTrace(); } @@ -322,9 +322,9 @@ public class NBTReflectionUtil { public static Object getSubNBTTagCompound(Object compound, String name) { Class c = compound.getClass(); - + try { - Method method = c.getMethod("getCompound", String.class); + Method method = c.getMethod("getCompound", String.class); return method.invoke(compound, name); } catch (Exception e) { e.printStackTrace(); @@ -343,9 +343,9 @@ public class NBTReflectionUtil { } if (!valideCompound(comp)) return; Object workingtag = gettoCompount(nbttag, comp); - + try { - Method method = workingtag.getClass().getMethod("set", String.class, getNBTBase()); + Method method = workingtag.getClass().getMethod("set", String.class, getNBTBase()); method.invoke(workingtag, name, getNBTTagCompound().newInstance()); comp.setCompound(nbttag); return; @@ -385,9 +385,9 @@ public class NBTReflectionUtil { } if (!valideCompound(comp)) return; Object workingtag = gettoCompount(rootnbttag, comp); - + try { - Method method = workingtag.getClass().getMethod("a", getNBTTagCompound()); + Method method = workingtag.getClass().getMethod("a", getNBTTagCompound()); method.invoke(workingtag, nbtcompound.getCompound()); comp.setCompound(rootnbttag); } catch (Exception ex) { @@ -406,9 +406,9 @@ public class NBTReflectionUtil { } if (!valideCompound(comp)) return; Object workingtag = gettoCompount(rootnbttag, comp); - + try { - Method method = workingtag.getClass().getMethod("setString", String.class, String.class); + Method method = workingtag.getClass().getMethod("setString", String.class, String.class); method.invoke(workingtag, key, text); comp.setCompound(rootnbttag); } catch (Exception ex) { @@ -423,9 +423,9 @@ public class NBTReflectionUtil { } if (!valideCompound(comp)) return null; Object workingtag = gettoCompount(rootnbttag, comp); - + try { - Method method = workingtag.getClass().getMethod("getString", String.class); + Method method = workingtag.getClass().getMethod("getString", String.class); return (String) method.invoke(workingtag, key); } catch (Exception ex) { ex.printStackTrace(); @@ -440,9 +440,9 @@ public class NBTReflectionUtil { } if (!valideCompound(comp)) return null; Object workingtag = gettoCompount(rootnbttag, comp); - + try { - Method method = workingtag.getClass().getMethod("get", String.class); + Method method = workingtag.getClass().getMethod("get", String.class); return method.invoke(workingtag, key).toString(); } catch (Exception ex) { ex.printStackTrace(); @@ -461,9 +461,9 @@ public class NBTReflectionUtil { } if (!valideCompound(comp)) return; Object workingtag = gettoCompount(rootnbttag, comp); - + try { - Method method = workingtag.getClass().getMethod("setInt", String.class, int.class); + Method method = workingtag.getClass().getMethod("setInt", String.class, int.class); method.invoke(workingtag, key, i); comp.setCompound(rootnbttag); } catch (Exception ex) { @@ -478,9 +478,9 @@ public class NBTReflectionUtil { } if (!valideCompound(comp)) return null; Object workingtag = gettoCompount(rootnbttag, comp); - + try { - Method method = workingtag.getClass().getMethod("getInt", String.class); + Method method = workingtag.getClass().getMethod("getInt", String.class); return (Integer) method.invoke(workingtag, key); } catch (Exception ex) { ex.printStackTrace(); @@ -499,9 +499,9 @@ public class NBTReflectionUtil { } if (!valideCompound(comp)) return; Object workingtag = gettoCompount(rootnbttag, comp); - + try { - Method method = workingtag.getClass().getMethod("setByteArray", String.class, byte[].class); + Method method = workingtag.getClass().getMethod("setByteArray", String.class, byte[].class); method.invoke(workingtag, key, b); comp.setCompound(rootnbttag); } catch (Exception ex) { @@ -517,9 +517,9 @@ public class NBTReflectionUtil { } if (!valideCompound(comp)) return null; Object workingtag = gettoCompount(rootnbttag, comp); - + try { - Method method = workingtag.getClass().getMethod("getByteArray", String.class); + Method method = workingtag.getClass().getMethod("getByteArray", String.class); return (byte[]) method.invoke(workingtag, key); } catch (Exception ex) { ex.printStackTrace(); @@ -538,9 +538,9 @@ public class NBTReflectionUtil { } if (!valideCompound(comp)) return; Object workingtag = gettoCompount(rootnbttag, comp); - + try { - Method method = workingtag.getClass().getMethod("setIntArray", String.class, int[].class); + Method method = workingtag.getClass().getMethod("setIntArray", String.class, int[].class); method.invoke(workingtag, key, i); comp.setCompound(rootnbttag); } catch (Exception ex) { @@ -555,9 +555,9 @@ public class NBTReflectionUtil { } if (!valideCompound(comp)) return null; Object workingtag = gettoCompount(rootnbttag, comp); - + try { - Method method = workingtag.getClass().getMethod("getIntArray", String.class); + Method method = workingtag.getClass().getMethod("getIntArray", String.class); return (int[]) method.invoke(workingtag, key); } catch (Exception ex) { ex.printStackTrace(); @@ -576,9 +576,9 @@ public class NBTReflectionUtil { } if (!valideCompound(comp)) return; Object workingtag = gettoCompount(rootnbttag, comp); - + try { - Method method = workingtag.getClass().getMethod("setFloat", String.class, float.class); + Method method = workingtag.getClass().getMethod("setFloat", String.class, float.class); method.invoke(workingtag, key, f); comp.setCompound(rootnbttag); } catch (Exception ex) { @@ -593,9 +593,9 @@ public class NBTReflectionUtil { } if (!valideCompound(comp)) return null; Object workingtag = gettoCompount(rootnbttag, comp); - + try { - Method method = workingtag.getClass().getMethod("getFloat", String.class); + Method method = workingtag.getClass().getMethod("getFloat", String.class); return (Float) method.invoke(workingtag, key); } catch (Exception ex) { ex.printStackTrace(); @@ -614,9 +614,9 @@ public class NBTReflectionUtil { } if (!valideCompound(comp)) return; Object workingtag = gettoCompount(rootnbttag, comp); - + try { - Method method = workingtag.getClass().getMethod("setLong", String.class, long.class); + Method method = workingtag.getClass().getMethod("setLong", String.class, long.class); method.invoke(workingtag, key, f); comp.setCompound(rootnbttag); } catch (Exception ex) { @@ -631,9 +631,9 @@ public class NBTReflectionUtil { } if (!valideCompound(comp)) return null; Object workingtag = gettoCompount(rootnbttag, comp); - + try { - Method method = workingtag.getClass().getMethod("getLong", String.class); + Method method = workingtag.getClass().getMethod("getLong", String.class); return (Long) method.invoke(workingtag, key); } catch (Exception ex) { ex.printStackTrace(); @@ -652,9 +652,9 @@ public class NBTReflectionUtil { } if (!valideCompound(comp)) return; Object workingtag = gettoCompount(rootnbttag, comp); - + try { - Method method = workingtag.getClass().getMethod("setShort", String.class, short.class); + Method method = workingtag.getClass().getMethod("setShort", String.class, short.class); method.invoke(workingtag, key, f); comp.setCompound(rootnbttag); } catch (Exception ex) { @@ -669,9 +669,9 @@ public class NBTReflectionUtil { } if (!valideCompound(comp)) return null; Object workingtag = gettoCompount(rootnbttag, comp); - + try { - Method method = workingtag.getClass().getMethod("getShort", String.class); + Method method = workingtag.getClass().getMethod("getShort", String.class); return (Short) method.invoke(workingtag, key); } catch (Exception ex) { ex.printStackTrace(); @@ -690,9 +690,9 @@ public class NBTReflectionUtil { } if (!valideCompound(comp)) return; Object workingtag = gettoCompount(rootnbttag, comp); - + try { - Method method = workingtag.getClass().getMethod("setByte", String.class, byte.class); + Method method = workingtag.getClass().getMethod("setByte", String.class, byte.class); method.invoke(workingtag, key, f); comp.setCompound(rootnbttag); } catch (Exception ex) { @@ -707,9 +707,9 @@ public class NBTReflectionUtil { } if (!valideCompound(comp)) return null; Object workingtag = gettoCompount(rootnbttag, comp); - + try { - Method method = workingtag.getClass().getMethod("getByte", String.class); + Method method = workingtag.getClass().getMethod("getByte", String.class); return (Byte) method.invoke(workingtag, key); } catch (Exception ex) { ex.printStackTrace(); @@ -728,9 +728,9 @@ public class NBTReflectionUtil { } if (!valideCompound(comp)) return; Object workingtag = gettoCompount(rootnbttag, comp); - + try { - Method method = workingtag.getClass().getMethod("setDouble", String.class, double.class); + Method method = workingtag.getClass().getMethod("setDouble", String.class, double.class); method.invoke(workingtag, key, d); comp.setCompound(rootnbttag); } catch (Exception ex) { @@ -745,9 +745,9 @@ public class NBTReflectionUtil { } if (!valideCompound(comp)) return null; Object workingtag = gettoCompount(rootnbttag, comp); - + try { - Method method = workingtag.getClass().getMethod("getDouble", String.class); + Method method = workingtag.getClass().getMethod("getDouble", String.class); return (Double) method.invoke(workingtag, key); } catch (Exception ex) { ex.printStackTrace(); @@ -762,9 +762,9 @@ public class NBTReflectionUtil { } if (!valideCompound(comp)) return 0; Object workingtag = gettoCompount(rootnbttag, comp); - + try { - Method method = workingtag.getClass().getMethod(MethodNames.getTypeMethodName(), String.class); + Method method = workingtag.getClass().getMethod(MethodNames.getTypeMethodName(), String.class); return (byte) method.invoke(workingtag, key); } catch (Exception ex) { ex.printStackTrace(); @@ -783,9 +783,9 @@ public class NBTReflectionUtil { } if (!valideCompound(comp)) return; Object workingtag = gettoCompount(rootnbttag, comp); - + try { - Method method = workingtag.getClass().getMethod("setBoolean", String.class, boolean.class); + Method method = workingtag.getClass().getMethod("setBoolean", String.class, boolean.class); method.invoke(workingtag, key, d); comp.setCompound(rootnbttag); } catch (Exception ex) { @@ -800,9 +800,9 @@ public class NBTReflectionUtil { } if (!valideCompound(comp)) return null; Object workingtag = gettoCompount(rootnbttag, comp); - + try { - Method method = workingtag.getClass().getMethod("getBoolean", String.class); + Method method = workingtag.getClass().getMethod("getBoolean", String.class); return (Boolean) method.invoke(workingtag, key); } catch (Exception ex) { ex.printStackTrace(); @@ -825,7 +825,7 @@ public class NBTReflectionUtil { } Object workingtag = gettoCompount(rootnbttag, comp); try { - Method method = workingtag.getClass().getMethod("set", String.class, getNBTBase()); + Method method = workingtag.getClass().getMethod("set", String.class, getNBTBase()); method.invoke(workingtag, key, val); comp.setCompound(rootnbttag); } catch (Exception ex) { @@ -840,9 +840,9 @@ public class NBTReflectionUtil { } if (!valideCompound(comp)) return null; Object workingtag = gettoCompount(rootnbttag, comp); - + try { - Method method = workingtag.getClass().getMethod("getList", String.class, int.class); + Method method = workingtag.getClass().getMethod("getList", String.class, int.class); return new NBTList(comp, key, type, method.invoke(workingtag, key, type.getId())); } catch (Exception ex) { ex.printStackTrace(); @@ -863,8 +863,8 @@ public class NBTReflectionUtil { public static T getObject(NBTCompound comp, String key, Class type) { if (!MinecraftVersion.hasGsonSupport()) return null; String json = getString(comp, key); - - return json != null ? GsonWrapper.deserializeJson(json, type):null; + + return json != null ? GsonWrapper.deserializeJson(json, type) : null; } public static void remove(NBTCompound comp, String key) { @@ -874,9 +874,9 @@ public class NBTReflectionUtil { } if (!valideCompound(comp)) return; Object workingtag = gettoCompount(rootnbttag, comp); - + try { - Method method = workingtag.getClass().getMethod("remove", String.class); + Method method = workingtag.getClass().getMethod("remove", String.class); method.invoke(workingtag, key); comp.setCompound(rootnbttag); } catch (Exception ex) { @@ -891,9 +891,9 @@ public class NBTReflectionUtil { } if (!valideCompound(comp)) return null; Object workingtag = gettoCompount(rootnbttag, comp); - + try { - Method method = workingtag.getClass().getMethod("hasKey", String.class); + Method method = workingtag.getClass().getMethod("hasKey", String.class); return (Boolean) method.invoke(workingtag, key); } catch (Exception ex) { ex.printStackTrace(); @@ -901,7 +901,7 @@ public class NBTReflectionUtil { return null; } - @SuppressWarnings ("unchecked") + @SuppressWarnings("unchecked") public static Set getKeys(NBTCompound comp) { Object rootnbttag = comp.getCompound(); if (rootnbttag == null) { diff --git a/src/main/java/com/massivecraft/factions/zcore/nbtapi/utils/MethodNames.java b/src/main/java/com/massivecraft/factions/zcore/nbtapi/utils/MethodNames.java index 0a746027..126ad031 100644 --- a/src/main/java/com/massivecraft/factions/zcore/nbtapi/utils/MethodNames.java +++ b/src/main/java/com/massivecraft/factions/zcore/nbtapi/utils/MethodNames.java @@ -5,11 +5,11 @@ public class MethodNames { private final static MinecraftVersion MINECRAFT_VERSION = MinecraftVersion.getVersion(); public static String getTileDataMethodName() { - return MINECRAFT_VERSION == MinecraftVersion.MC1_8_R3 ? "b":"save"; + return MINECRAFT_VERSION == MinecraftVersion.MC1_8_R3 ? "b" : "save"; } public static String getTypeMethodName() { - return MINECRAFT_VERSION == MinecraftVersion.MC1_8_R3 ? "b":"d"; + return MINECRAFT_VERSION == MinecraftVersion.MC1_8_R3 ? "b" : "d"; } public static String getEntityNbtGetterMethodName() { @@ -21,6 +21,6 @@ public class MethodNames { } public static String getRemoveMethodName() { - return MINECRAFT_VERSION == MinecraftVersion.MC1_8_R3 ? "a":"remove"; + return MINECRAFT_VERSION == MinecraftVersion.MC1_8_R3 ? "a" : "remove"; } } diff --git a/src/main/java/com/massivecraft/factions/zcore/nbtapi/utils/MinecraftVersion.java b/src/main/java/com/massivecraft/factions/zcore/nbtapi/utils/MinecraftVersion.java index 307b271e..372610c1 100644 --- a/src/main/java/com/massivecraft/factions/zcore/nbtapi/utils/MinecraftVersion.java +++ b/src/main/java/com/massivecraft/factions/zcore/nbtapi/utils/MinecraftVersion.java @@ -22,34 +22,33 @@ public enum MinecraftVersion { } public static MinecraftVersion getVersion() { - if (version == null) - { - final String ver = Bukkit.getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3]; - System.out.println("[NBTAPI] Found Spigot: " + ver + "!Trying to find NMS support"); - - try { - version = MinecraftVersion.valueOf(ver.replace("v", "MC")); - } catch (IllegalArgumentException ex) { - version = MinecraftVersion.Unknown; - } - - if (version != Unknown) { - System.out.println("[NBTAPI] NMS support '" + version.name() + "' loaded!"); - } else { - System.out.println("[NBTAPI] Wasn't able to find NMS Support!Some functions will not work!"); - } + if (version == null) { + final String ver = Bukkit.getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3]; + System.out.println("[NBTAPI] Found Spigot: " + ver + "!Trying to find NMS support"); + + try { + version = MinecraftVersion.valueOf(ver.replace("v", "MC")); + } catch (IllegalArgumentException ex) { + version = MinecraftVersion.Unknown; + } + + if (version != Unknown) { + System.out.println("[NBTAPI] NMS support '" + version.name() + "' loaded!"); + } else { + System.out.println("[NBTAPI] Wasn't able to find NMS Support!Some functions will not work!"); + } } return version; } public static boolean hasGsonSupport() { if (hasGsonSupport == null) { - try { - System.out.println("Found Gson: " + Class.forName("com.google.gson.Gson")); - hasGsonSupport = true; - } catch (Exception ex) { - hasGsonSupport = false; - } + try { + System.out.println("Found Gson: " + Class.forName("com.google.gson.Gson")); + hasGsonSupport = true; + } catch (Exception ex) { + hasGsonSupport = false; + } } return hasGsonSupport; } diff --git a/src/main/java/com/massivecraft/factions/zcore/persist/MemoryBoard.java b/src/main/java/com/massivecraft/factions/zcore/persist/MemoryBoard.java index b748e90c..8dd916e6 100644 --- a/src/main/java/com/massivecraft/factions/zcore/persist/MemoryBoard.java +++ b/src/main/java/com/massivecraft/factions/zcore/persist/MemoryBoard.java @@ -111,18 +111,18 @@ public abstract class MemoryBoard extends Board { public boolean isBorderLocation(FLocation flocation) { Faction faction = getFactionAt(flocation); FLocation a = flocation.getRelative(1, 0); - FLocation b = flocation.getRelative(- 1, 0); + FLocation b = flocation.getRelative(-1, 0); FLocation c = flocation.getRelative(0, 1); - FLocation d = flocation.getRelative(0, - 1); + FLocation d = flocation.getRelative(0, -1); return faction != getFactionAt(a) || faction != getFactionAt(b) || faction != getFactionAt(c) || faction != getFactionAt(d); } // Is this coord connected to any coord claimed by the specified faction? public boolean isConnectedLocation(FLocation flocation, Faction faction) { FLocation a = flocation.getRelative(1, 0); - FLocation b = flocation.getRelative(- 1, 0); + FLocation b = flocation.getRelative(-1, 0); FLocation c = flocation.getRelative(0, 1); - FLocation d = flocation.getRelative(0, - 1); + FLocation d = flocation.getRelative(0, -1); return faction == getFactionAt(a) || faction == getFactionAt(b) || faction == getFactionAt(c) || faction == getFactionAt(d); } @@ -136,8 +136,8 @@ public abstract class MemoryBoard extends Board { * @return true if another Faction is within the radius, otherwise false. */ public boolean hasFactionWithin(FLocation flocation, Faction faction, int radius) { - for (int x = - radius; x <= radius; x++) { - for (int z = - radius; z <= radius; z++) { + for (int x = -radius; x <= radius; x++) { + for (int z = -radius; z <= radius; z++) { if (x == 0 && z == 0) { continue; } @@ -210,7 +210,7 @@ public abstract class MemoryBoard extends Board { int halfWidth = Conf.mapWidth / 2; // Use player's value for height int halfHeight = fplayer.getMapHeight() / 2; - FLocation topLeft = flocation.getRelative(- halfWidth, - halfHeight); + FLocation topLeft = flocation.getRelative(-halfWidth, -halfHeight); int width = halfWidth * 2 + 1; int height = halfHeight * 2 + 1; @@ -345,7 +345,7 @@ public abstract class MemoryBoard extends Board { public abstract void convertFrom(MemoryBoard old); public class MemoryBoardMap extends HashMap { - private static final long serialVersionUID = - 6689617828610585368L; + private static final long serialVersionUID = -6689617828610585368L; Multimap factionToLandMap = HashMultimap.create(); diff --git a/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFPlayer.java b/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFPlayer.java index e64aeea6..380cd548 100644 --- a/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFPlayer.java +++ b/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFPlayer.java @@ -2,11 +2,7 @@ package com.massivecraft.factions.zcore.persist; import com.massivecraft.factions.*; import com.massivecraft.factions.cmd.CmdFly; -import com.massivecraft.factions.event.FPlayerLeaveEvent; -import com.massivecraft.factions.event.FPlayerStoppedFlying; -import com.massivecraft.factions.event.FactionDisbandEvent; -import com.massivecraft.factions.event.LandClaimEvent; -import com.massivecraft.factions.event.PowerRegenEvent; +import com.massivecraft.factions.event.*; import com.massivecraft.factions.event.FactionDisbandEvent.PlayerDisbandReason; import com.massivecraft.factions.iface.EconomyParticipator; import com.massivecraft.factions.iface.RelationParticipator; @@ -549,7 +545,7 @@ public abstract class MemoryFPlayer implements FPlayer { } else if (hasFaction() && getFaction().isPowerFrozen()) { return; // Don't let power regen if faction power is frozen. } - + long now = System.currentTimeMillis(); long millisPassed = now - this.lastPowerUpdateTime; this.lastPowerUpdateTime = now; @@ -561,9 +557,9 @@ public abstract class MemoryFPlayer implements FPlayer { PowerRegenEvent powerRegenEvent = new PowerRegenEvent(getFaction(), this); Bukkit.getServer().getPluginManager().callEvent(powerRegenEvent); - + if (!powerRegenEvent.isCancelled()) - this.alterPower(millisPassed * Conf.powerPerMinute / 60000); // millisPerMinute : 60 * 1000 + this.alterPower(millisPassed * Conf.powerPerMinute / 60000); // millisPerMinute : 60 * 1000 } public void losePowerFromBeingOffline() { @@ -576,13 +572,13 @@ public abstract class MemoryFPlayer implements FPlayer { if (this.power - loss < Conf.powerOfflineLossLimit) { loss = this.power; } - this.alterPower(- loss); + this.alterPower(-loss); } } public void onDeath() { this.updatePower(); - this.alterPower(- Conf.powerPerDeath); + this.alterPower(-Conf.powerPerDeath); if (hasFaction()) { getFaction().setLastDeath(System.currentTimeMillis()); } @@ -714,7 +710,7 @@ public abstract class MemoryFPlayer implements FPlayer { FactionDisbandEvent disbandEvent = new FactionDisbandEvent(null, getId(), PlayerDisbandReason.LEAVE); Bukkit.getPluginManager().callEvent(disbandEvent); - + Factions.getInstance().removeFaction(myFaction.getId()); if (Conf.logFactionDisband) { SavageFactions.plugin.log(TL.LEAVE_DISBANDEDLOG.format(myFaction.getTag(), myFaction.getId(), this.getName())); @@ -1194,16 +1190,20 @@ public abstract class MemoryFPlayer implements FPlayer { @Override public String getRolePrefix() { - - switch (getRole()) - { - case RECRUIT: return Conf.prefixRecruit; - case NORMAL: return Conf.prefixNormal; - case MODERATOR: return Conf.prefixMod; - case COLEADER: return Conf.prefixCoLeader; - case LEADER: return Conf.prefixLeader; - } - + + switch (getRole()) { + case RECRUIT: + return Conf.prefixRecruit; + case NORMAL: + return Conf.prefixNormal; + case MODERATOR: + return Conf.prefixMod; + case COLEADER: + return Conf.prefixCoLeader; + case LEADER: + return Conf.prefixLeader; + } + return null; } diff --git a/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFaction.java b/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFaction.java index 80b10357..f1c4030b 100644 --- a/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFaction.java +++ b/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFaction.java @@ -196,9 +196,13 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator { this.maxVaults = value; } - public String getFocused() { return this.player; } + public String getFocused() { + return this.player; + } - public void setFocused(String fp) { this.player = fp; } + public void setFocused(String fp) { + this.player = fp; + } public Set getInvites() { return invites; @@ -240,7 +244,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator { @Override public void disband(Player disbander) { - disband(disbander, PlayerDisbandReason.PLUGIN); + disband(disbander, PlayerDisbandReason.PLUGIN); } @Override @@ -987,9 +991,9 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator { // promotes new leader, or disbands faction if no other members left @Override public void promoteNewLeader() { - promoteNewLeader(false); + promoteNewLeader(false); } - + @Override public void promoteNewLeader(boolean autoLeave) { if (!this.isNormal()) { @@ -1017,16 +1021,16 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator { // no members left and faction isn't permanent, so disband it if (Conf.logFactionDisband) { - SavageFactions.plugin.log("The faction " + this.getTag() + " (" + this.getId() + ") has been disbanded since it has no members left" + (autoLeave ? " and by inactivity":"")+ "."); + SavageFactions.plugin.log("The faction " + this.getTag() + " (" + this.getId() + ") has been disbanded since it has no members left" + (autoLeave ? " and by inactivity" : "") + "."); } for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers()) { fplayer.msg("The faction %s was disbanded.", this.getTag(fplayer)); } - FactionDisbandEvent disbandEvent = new FactionDisbandEvent(null, getId(), autoLeave ? PlayerDisbandReason.INACTIVITY:PlayerDisbandReason.LEAVE); + FactionDisbandEvent disbandEvent = new FactionDisbandEvent(null, getId(), autoLeave ? PlayerDisbandReason.INACTIVITY : PlayerDisbandReason.LEAVE); Bukkit.getPluginManager().callEvent(disbandEvent); - + Factions.getInstance().removeFaction(getId()); } else { // promote new faction admin if (oldLeader != null) { diff --git a/src/main/java/com/massivecraft/factions/zcore/util/PermUtil.java b/src/main/java/com/massivecraft/factions/zcore/util/PermUtil.java index fd9c3597..3d8a8933 100644 --- a/src/main/java/com/massivecraft/factions/zcore/util/PermUtil.java +++ b/src/main/java/com/massivecraft/factions/zcore/util/PermUtil.java @@ -1,74 +1,74 @@ -package com.massivecraft.factions.zcore.util; - -import com.massivecraft.factions.zcore.MPlugin; -import org.bukkit.command.CommandSender; -import org.bukkit.permissions.Permission; - -import java.util.HashMap; -import java.util.Map; -import java.util.Map.Entry; - -public class PermUtil { - - public Map permissionDescriptions = new HashMap<>(); - - protected MPlugin p; - - public PermUtil(MPlugin p) { - this.p = p; - this.setup(); - } - - public String getForbiddenMessage(String perm) { - return p.txt.parse(TL.GENERIC_NOPERMISSION.toString(), getPermissionDescription(perm)); - } - - /** - * This method hooks into all permission plugins we are supporting - */ - public final void setup() { - for (Permission permission : p.getDescription().getPermissions()) { - //plugin.log("\""+permission.getName()+"\" = \""+permission.getDescription()+"\""); - this.permissionDescriptions.put(permission.getName(), permission.getDescription()); - } - } - - public String getPermissionDescription(String perm) { - String desc = permissionDescriptions.get(perm); - - return desc != null ? desc:TL.GENERIC_DOTHAT.toString(); - } - - /** - * This method tests if me has a certain permission and returns true if me has. Otherwise false - */ - public boolean has(CommandSender me, String perm) { - return me != null ? me.hasPermission(perm):false; - } - - public boolean has(CommandSender me, String perm, boolean informSenderIfNot) { - if (has(me, perm)) { - return true; - } else if (informSenderIfNot && me != null) { - me.sendMessage(this.getForbiddenMessage(perm)); - } - return false; - } - - public T pickFirstVal(CommandSender me, Map perm2val) { - if (perm2val == null) { - return null; - } - T ret = null; - - for (Entry entry : perm2val.entrySet()) { - ret = entry.getValue(); - if (has(me, entry.getKey())) { - break; - } - } - - return ret; - } - -} +package com.massivecraft.factions.zcore.util; + +import com.massivecraft.factions.zcore.MPlugin; +import org.bukkit.command.CommandSender; +import org.bukkit.permissions.Permission; + +import java.util.HashMap; +import java.util.Map; +import java.util.Map.Entry; + +public class PermUtil { + + public Map permissionDescriptions = new HashMap<>(); + + protected MPlugin p; + + public PermUtil(MPlugin p) { + this.p = p; + this.setup(); + } + + public String getForbiddenMessage(String perm) { + return p.txt.parse(TL.GENERIC_NOPERMISSION.toString(), getPermissionDescription(perm)); + } + + /** + * This method hooks into all permission plugins we are supporting + */ + public final void setup() { + for (Permission permission : p.getDescription().getPermissions()) { + //plugin.log("\""+permission.getName()+"\" = \""+permission.getDescription()+"\""); + this.permissionDescriptions.put(permission.getName(), permission.getDescription()); + } + } + + public String getPermissionDescription(String perm) { + String desc = permissionDescriptions.get(perm); + + return desc != null ? desc : TL.GENERIC_DOTHAT.toString(); + } + + /** + * This method tests if me has a certain permission and returns true if me has. Otherwise false + */ + public boolean has(CommandSender me, String perm) { + return me != null && me.hasPermission(perm); + } + + public boolean has(CommandSender me, String perm, boolean informSenderIfNot) { + if (has(me, perm)) { + return true; + } else if (informSenderIfNot && me != null) { + me.sendMessage(this.getForbiddenMessage(perm)); + } + return false; + } + + public T pickFirstVal(CommandSender me, Map perm2val) { + if (perm2val == null) { + return null; + } + T ret = null; + + for (Entry entry : perm2val.entrySet()) { + ret = entry.getValue(); + if (has(me, entry.getKey())) { + break; + } + } + + return ret; + } + +} diff --git a/src/main/java/com/massivecraft/factions/zcore/util/Persist.java b/src/main/java/com/massivecraft/factions/zcore/util/Persist.java index 7a56bcaa..65042cb2 100644 --- a/src/main/java/com/massivecraft/factions/zcore/util/Persist.java +++ b/src/main/java/com/massivecraft/factions/zcore/util/Persist.java @@ -1,153 +1,153 @@ -package com.massivecraft.factions.zcore.util; - -import com.massivecraft.factions.zcore.MPlugin; - -import java.io.File; -import java.lang.reflect.Type; -import java.util.logging.Level; - -// TODO: Give better name and place to differentiate from the entity-orm-ish system in "com.massivecraft.core.persist". - -public class Persist { - - private MPlugin p; - - public Persist(MPlugin p) { - this.p = p; - } - - // ------------------------------------------------------------ // - // GET NAME - What should we call this type of object? - // ------------------------------------------------------------ // - - public static String getName(Class clazz) { - return clazz.getSimpleName().toLowerCase(); - } - - public static String getName(Object o) { - return getName(o.getClass()); - } - - public static String getName(Type type) { - return getName(type.getClass()); - } - - // ------------------------------------------------------------ // - // GET FILE - In which file would we like to store this object? - // ------------------------------------------------------------ // - - public File getFile(String name) { - return new File(p.getDataFolder(), name + ".json"); - } - - public File getFile(Class clazz) { - return getFile(getName(clazz)); - } - - public File getFile(Object obj) { - return getFile(getName(obj)); - } - - public File getFile(Type type) { - return getFile(getName(type)); - } - - - // NICE WRAPPERS - - public T loadOrSaveDefault(T def, Class clazz) { - return loadOrSaveDefault(def, clazz, getFile(clazz)); - } - - public T loadOrSaveDefault(T def, Class clazz, String name) { - return loadOrSaveDefault(def, clazz, getFile(name)); - } - - public T loadOrSaveDefault(T def, Class clazz, File file) { - if (!file.exists()) { - p.log("Creating default: " + file); - this.save(def, file); - return def; - } - - T loaded = this.load(clazz, file); - - if (loaded == null) { - p.log(Level.WARNING, "Using default as I failed to load: " + file); - - // backup bad file, so user can attempt to recover their changes from it - File backup = new File(file.getPath() + "_bad"); - if (backup.exists()) { - backup.delete(); - } - p.log(Level.WARNING, "Backing up copy of bad file to: " + backup); - file.renameTo(backup); - - return def; - } - - return loaded; - } - - // SAVE - - public boolean save(Object instance) { - return save(instance, getFile(instance)); - } - - public boolean save(Object instance, String name) { - return save(instance, getFile(name)); - } - - public boolean save(Object instance, File file) { - return DiscUtil.writeCatch(file, p.gson.toJson(instance), true); - } - - // LOAD BY CLASS - - public T load(Class clazz) { - return load(clazz, getFile(clazz)); - } - - public T load(Class clazz, String name) { - return load(clazz, getFile(name)); - } - - public T load(Class clazz, File file) { - String content = DiscUtil.readCatch(file); - if (content == null) { - return null; - } - - try { - return p.gson.fromJson(content, clazz); - } catch (Exception ex) { // output the error message rather than full stack trace; error parsing the file, most likely - p.log(Level.WARNING, ex.getMessage()); - } - - return null; - } - - - // LOAD BY TYPE - @SuppressWarnings ("unchecked") - public T load(Type typeOfT, String name) { - return (T) load(typeOfT, getFile(name)); - } - - @SuppressWarnings ("unchecked") - public T load(Type typeOfT, File file) { - String content = DiscUtil.readCatch(file); - if (content == null) { - return null; - } - - try { - return (T) p.gson.fromJson(content, typeOfT); - } catch (Exception ex) { // output the error message rather than full stack trace; error parsing the file, most likely - p.log(Level.WARNING, ex.getMessage()); - } - - return null; - } -} +package com.massivecraft.factions.zcore.util; + +import com.massivecraft.factions.zcore.MPlugin; + +import java.io.File; +import java.lang.reflect.Type; +import java.util.logging.Level; + +// TODO: Give better name and place to differentiate from the entity-orm-ish system in "com.massivecraft.core.persist". + +public class Persist { + + private MPlugin p; + + public Persist(MPlugin p) { + this.p = p; + } + + // ------------------------------------------------------------ // + // GET NAME - What should we call this type of object? + // ------------------------------------------------------------ // + + public static String getName(Class clazz) { + return clazz.getSimpleName().toLowerCase(); + } + + public static String getName(Object o) { + return getName(o.getClass()); + } + + public static String getName(Type type) { + return getName(type.getClass()); + } + + // ------------------------------------------------------------ // + // GET FILE - In which file would we like to store this object? + // ------------------------------------------------------------ // + + public File getFile(String name) { + return new File(p.getDataFolder(), name + ".json"); + } + + public File getFile(Class clazz) { + return getFile(getName(clazz)); + } + + public File getFile(Object obj) { + return getFile(getName(obj)); + } + + public File getFile(Type type) { + return getFile(getName(type)); + } + + + // NICE WRAPPERS + + public T loadOrSaveDefault(T def, Class clazz) { + return loadOrSaveDefault(def, clazz, getFile(clazz)); + } + + public T loadOrSaveDefault(T def, Class clazz, String name) { + return loadOrSaveDefault(def, clazz, getFile(name)); + } + + public T loadOrSaveDefault(T def, Class clazz, File file) { + if (!file.exists()) { + p.log("Creating default: " + file); + this.save(def, file); + return def; + } + + T loaded = this.load(clazz, file); + + if (loaded == null) { + p.log(Level.WARNING, "Using default as I failed to load: " + file); + + // backup bad file, so user can attempt to recover their changes from it + File backup = new File(file.getPath() + "_bad"); + if (backup.exists()) { + backup.delete(); + } + p.log(Level.WARNING, "Backing up copy of bad file to: " + backup); + file.renameTo(backup); + + return def; + } + + return loaded; + } + + // SAVE + + public boolean save(Object instance) { + return save(instance, getFile(instance)); + } + + public boolean save(Object instance, String name) { + return save(instance, getFile(name)); + } + + public boolean save(Object instance, File file) { + return DiscUtil.writeCatch(file, p.gson.toJson(instance), true); + } + + // LOAD BY CLASS + + public T load(Class clazz) { + return load(clazz, getFile(clazz)); + } + + public T load(Class clazz, String name) { + return load(clazz, getFile(name)); + } + + public T load(Class clazz, File file) { + String content = DiscUtil.readCatch(file); + if (content == null) { + return null; + } + + try { + return p.gson.fromJson(content, clazz); + } catch (Exception ex) { // output the error message rather than full stack trace; error parsing the file, most likely + p.log(Level.WARNING, ex.getMessage()); + } + + return null; + } + + + // LOAD BY TYPE + @SuppressWarnings("unchecked") + public T load(Type typeOfT, String name) { + return (T) load(typeOfT, getFile(name)); + } + + @SuppressWarnings("unchecked") + public T load(Type typeOfT, File file) { + String content = DiscUtil.readCatch(file); + if (content == null) { + return null; + } + + try { + return (T) p.gson.fromJson(content, typeOfT); + } catch (Exception ex) { // output the error message rather than full stack trace; error parsing the file, most likely + p.log(Level.WARNING, ex.getMessage()); + } + + return null; + } +} diff --git a/src/main/java/com/massivecraft/factions/zcore/util/TL.java b/src/main/java/com/massivecraft/factions/zcore/util/TL.java index f435fc44..6b1b6bb0 100644 --- a/src/main/java/com/massivecraft/factions/zcore/util/TL.java +++ b/src/main/java/com/massivecraft/factions/zcore/util/TL.java @@ -317,6 +317,7 @@ public enum TL { COMMAND_HOME_TOTELEPORT("to teleport to your faction home"), COMMAND_HOME_FORTELEPORT("for teleporting to your faction home"), COMMAND_HOME_DESCRIPTION("Teleport to the faction home"), + COMMAND_HOME_BLOCKED("&c&l[!] You may not teleport to a home that is claimed by &b%1$s"), COMMAND_INSPECT_DISABLED_MSG("&c&l[!]&7 Inspect mode is now &cdisabled."), COMMAND_INSPECT_DISABLED_NOFAC("&c&l[!]&7 Inspect mode is now &cdisabled,&7 because you &cdo not have a faction!"), @@ -841,7 +842,7 @@ public enum TL { WARBANNER_NOFACTION("&cYou need a faction to use a warbanner!"), WARBANNER_COOLDOWN("&cThe warbanner is on cooldown for your faction!"), WARBANNER_INVALIDLOC("&cYou can only use warbanners in enemy land or the warzone"), - + /** * ASCII compass (for chat map) */ @@ -1013,7 +1014,7 @@ public enum TL { @Override public String toString() { - return ChatColor.translateAlternateColorCodes('&', LANG.getString(this.path, def)) + (this == TITLE ? " ":""); + return ChatColor.translateAlternateColorCodes('&', LANG.getString(this.path, def)) + (this == TITLE ? " " : ""); } public String format(Object... args) { diff --git a/src/main/java/com/massivecraft/factions/zcore/util/TagReplacer.java b/src/main/java/com/massivecraft/factions/zcore/util/TagReplacer.java index 8e1fede7..6d726ab6 100644 --- a/src/main/java/com/massivecraft/factions/zcore/util/TagReplacer.java +++ b/src/main/java/com/massivecraft/factions/zcore/util/TagReplacer.java @@ -184,7 +184,7 @@ public enum TagReplacer { default: } } - + switch (this) { case DESCRIPTION: return fac.getDescription(); diff --git a/src/main/java/com/massivecraft/factions/zcore/util/TagUtil.java b/src/main/java/com/massivecraft/factions/zcore/util/TagUtil.java index b19f4eb1..da621d69 100644 --- a/src/main/java/com/massivecraft/factions/zcore/util/TagUtil.java +++ b/src/main/java/com/massivecraft/factions/zcore/util/TagUtil.java @@ -147,7 +147,7 @@ public class TagUtil { String s = otherFaction.getTag(fme); if (otherFaction.getRelationTo(target).isAlly()) { currentAllies.then(firstAlly ? s : ", " + s); - currentAllies.tooltip(tipFaction(otherFaction)).color(fme != null ? fme.getColorTo(otherFaction):Relation.NEUTRAL.getColor()); + currentAllies.tooltip(tipFaction(otherFaction)).color(fme != null ? fme.getColorTo(otherFaction) : Relation.NEUTRAL.getColor()); firstAlly = false; if (currentAllies.toJSONString().length() > ARBITRARY_LIMIT) { fancyMessages.add(currentAllies); @@ -167,7 +167,7 @@ public class TagUtil { String s = otherFaction.getTag(fme); if (otherFaction.getRelationTo(target).isEnemy()) { currentEnemies.then(firstEnemy ? s : ", " + s); - currentEnemies.tooltip(tipFaction(otherFaction)).color(fme != null ? fme.getColorTo(otherFaction):Relation.NEUTRAL.getColor()); + currentEnemies.tooltip(tipFaction(otherFaction)).color(fme != null ? fme.getColorTo(otherFaction) : Relation.NEUTRAL.getColor()); firstEnemy = false; if (currentEnemies.toJSONString().length() > ARBITRARY_LIMIT) { fancyMessages.add(currentEnemies); @@ -187,7 +187,7 @@ public class TagUtil { String s = otherFaction.getTag(fme); if (otherFaction.getRelationTo(target).isTruce()) { currentTruces.then(firstTruce ? s : ", " + s); - currentTruces.tooltip(tipFaction(otherFaction)).color(fme != null ? fme.getColorTo(otherFaction):Relation.NEUTRAL.getColor()); + currentTruces.tooltip(tipFaction(otherFaction)).color(fme != null ? fme.getColorTo(otherFaction) : Relation.NEUTRAL.getColor()); firstTruce = false; if (currentTruces.toJSONString().length() > ARBITRARY_LIMIT) { fancyMessages.add(currentTruces); @@ -206,7 +206,7 @@ public class TagUtil { } String name = p.getNameAndTitle(); currentOnline.then(firstOnline ? name : ", " + name); - currentOnline.tooltip(tipPlayer(p)).color(fme != null ? fme.getColorTo(p):Relation.NEUTRAL.getColor()); + currentOnline.tooltip(tipPlayer(p)).color(fme != null ? fme.getColorTo(p) : Relation.NEUTRAL.getColor()); firstOnline = false; if (currentOnline.toJSONString().length() > ARBITRARY_LIMIT) { fancyMessages.add(currentOnline); @@ -223,7 +223,7 @@ public class TagUtil { // Also make sure to add players that are online BUT can't be seen. if (!p.isOnline() || (fme != null && fme.getPlayer() != null && !fme.getPlayer().canSee(p.getPlayer()))) { currentOffline.then(firstOffline ? name : ", " + name); - currentOffline.tooltip(tipPlayer(p)).color(fme != null ? fme.getColorTo(p):Relation.NEUTRAL.getColor()); + currentOffline.tooltip(tipPlayer(p)).color(fme != null ? fme.getColorTo(p) : Relation.NEUTRAL.getColor()); firstOffline = false; if (currentOffline.toJSONString().length() > ARBITRARY_LIMIT) { fancyMessages.add(currentOffline); diff --git a/src/main/java/com/massivecraft/factions/zcore/util/TextUtil.java b/src/main/java/com/massivecraft/factions/zcore/util/TextUtil.java index b8bd3147..6b58ff69 100644 --- a/src/main/java/com/massivecraft/factions/zcore/util/TextUtil.java +++ b/src/main/java/com/massivecraft/factions/zcore/util/TextUtil.java @@ -1,232 +1,232 @@ -package com.massivecraft.factions.zcore.util; - -import mkremins.fanciful.FancyMessage; -import org.bukkit.ChatColor; -import org.bukkit.Material; - -import java.util.*; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -public class TextUtil { - - public static final transient Pattern patternTag = Pattern.compile("<([a-zA-Z0-9_]*)>"); - private final static String titleizeLine = repeat("-", 52); - - // -------------------------------------------- // - // Top-level parsing functions. - // -------------------------------------------- // - private final static int titleizeBalance = - 1; - public Map tags; - - // -------------------------------------------- // - // Tag parsing - // -------------------------------------------- // - - public TextUtil() { - this.tags = new HashMap<>(); - } - - public static String replaceTags(String str, Map tags) { - StringBuffer ret = new StringBuffer(); - Matcher matcher = patternTag.matcher(str); - while (matcher.find()) { - String tag = matcher.group(1); - String repl = tags.get(tag); - if (repl == null) { - matcher.appendReplacement(ret, "<" + tag + ">"); - } else { - matcher.appendReplacement(ret, repl); - } - } - matcher.appendTail(ret); - return ret.toString(); - } - - public static FancyMessage toFancy(String first) { - String text = ""; - FancyMessage message = new FancyMessage(text); - ChatColor color = null; - char[] chars = first.toCharArray(); - - for (int i = 0; i < chars.length; i++) { - // changed this so javadocs wont throw an error - String compareChar = chars[i] + ""; - if (compareChar.equals("§")) { - if (color != null) { - if (color.isColor()) { - message.then(text).color(color); - } else { - message.then(text).style(color); - } - text = ""; - color = ChatColor.getByChar(chars[i + 1]); - } else { - color = ChatColor.getByChar(chars[i + 1]); - } - i++; // skip color char - } else { - text += chars[i]; - } - } - if (text.length() > 0) { - if (color != null) { - if (color.isColor()) { - message.then(text).color(color); - } else { - message.then(text).style(color); - } - } else { - message.text(text); - } - } - return message; - } - - // -------------------------------------------- // - // Fancy parsing - // -------------------------------------------- // - - public static String parseColor(String string) { - string = parseColorAmp(string); - string = parseColorAcc(string); - string = parseColorTags(string); - return ChatColor.translateAlternateColorCodes('&', string); - } - - public static String parseColorAmp(String string) { - string = string.replaceAll("(§([a-z0-9]))", "\u00A7$2"); - string = string.replaceAll("(&([a-z0-9]))", "\u00A7$2"); - string = string.replace("&&", "&"); - return string; - } - - // -------------------------------------------- // - // Color parsing - // -------------------------------------------- // - - public static String parseColorAcc(String string) { - return string.replace("`e", "").replace("`r", ChatColor.RED.toString()).replace("`R", ChatColor.DARK_RED.toString()).replace("`y", ChatColor.YELLOW.toString()).replace("`Y", ChatColor.GOLD.toString()).replace("`g", ChatColor.GREEN.toString()).replace("`G", ChatColor.DARK_GREEN.toString()).replace("`a", ChatColor.AQUA.toString()).replace("`A", ChatColor.DARK_AQUA.toString()).replace("`b", ChatColor.BLUE.toString()).replace("`B", ChatColor.DARK_BLUE.toString()).replace("`plugin", ChatColor.LIGHT_PURPLE.toString()).replace("`SavageFactions", ChatColor.DARK_PURPLE.toString()).replace("`k", ChatColor.BLACK.toString()).replace("`s", ChatColor.GRAY.toString()).replace("`S", ChatColor.DARK_GRAY.toString()).replace("`w", ChatColor.WHITE.toString()); - } - - public static String parseColorTags(String string) { - return string.replace("", "").replace("", "\u00A70").replace("", "\u00A71").replace("", "\u00A72").replace("", "\u00A73").replace("", "\u00A74").replace("", "\u00A75").replace("", "\u00A76").replace("", "\u00A77").replace("", "\u00A78").replace("", "\u00A79").replace("", "\u00A7a").replace("", "\u00A7b").replace("", "\u00A7c").replace("", "\u00A7d").replace("", "\u00A7e").replace("", "\u00A7f"); - } - - public static String upperCaseFirst(String string) { - return string.substring(0, 1).toUpperCase() + string.substring(1); - } - - public static String implode(List list, String glue) { - StringBuilder ret = new StringBuilder(); - for (int i = 0; i < list.size(); i++) - ret.append(glue).append(list.get(i)); - - return ret.length() > 0 ? ret.toString().substring(glue.length()):""; - } - - // -------------------------------------------- // - // Standard utils like UCFirst, implode and repeat. - // -------------------------------------------- // - - public static String repeat(String s, int times) { - return times > 0 ? s + repeat(s, times - 1):""; - } - - public static String getMaterialName(Material material) { - return material.toString().replace('_', ' ').toLowerCase(); - } - - - // -------------------------------------------- // - // Material name tools - // -------------------------------------------- // - - public static String getBestStartWithCI(Collection candidates, String start) { - String ret = null; - int best = 0; - - start = start.toLowerCase(); - int minlength = start.length(); - for (String candidate : candidates) { - if (candidate.length() < minlength) { - continue; - } - if (!candidate.toLowerCase().startsWith(start)) { - continue; - } - - // The closer to zero the better - int lendiff = candidate.length() - minlength; - if (lendiff == 0) { - return candidate; - } - if (lendiff < best || best == 0) { - best = lendiff; - ret = candidate; - } - } - return ret; - } - - public String parse(String str, Object... args) { - return String.format(this.parse(str), args); - } - - // -------------------------------------------- // - // Paging and chrome-tools like titleize - // -------------------------------------------- // - - public String parse(String str) { - return this.parseTags(parseColor(str)); - } - - public String parseTags(String str) { - return replaceTags(str, this.tags); - } - - public FancyMessage parseFancy(String prefix) { - return toFancy(parse(prefix)); - } - - public String titleize(String str) { - String center = ChatColor.DARK_GRAY + "< " + parseTags("") + str + parseTags("") + ChatColor.DARK_GRAY + " >"; - int centerlen = ChatColor.stripColor(center).length(); - int pivot = titleizeLine.length() / 2; - int eatLeft = (centerlen / 2) - titleizeBalance; - int eatRight = (centerlen - eatLeft) + titleizeBalance; - - if (eatLeft < pivot) { - return parseTags("") + ChatColor.DARK_GRAY + ChatColor.STRIKETHROUGH + titleizeLine.substring(0, pivot - eatLeft) + center + ChatColor.DARK_GRAY + ChatColor.STRIKETHROUGH + titleizeLine.substring(pivot + eatRight); - } else { - return parseTags("") + center; - } - } - - public ArrayList getPage(List lines, int pageHumanBased, String title) { - ArrayList ret = new ArrayList<>(); - int pageZeroBased = pageHumanBased - 1; - int pageheight = 9; - int pagecount = (lines.size() / pageheight) + 1; - - ret.add(this.titleize(title + " " + pageHumanBased + "/" + pagecount)); - - if (pagecount == 0) { - ret.add(this.parseTags(TL.NOPAGES.toString())); - return ret; - } else if (pageZeroBased < 0 || pageHumanBased > pagecount) { - ret.add(this.parseTags(TL.INVALIDPAGE.format(pagecount))); - return ret; - } - - int from = pageZeroBased * pageheight; - int to = from + pageheight; - if (to > lines.size()) { - to = lines.size(); - } - - ret.addAll(lines.subList(from, to)); - - return ret; - } +package com.massivecraft.factions.zcore.util; + +import mkremins.fanciful.FancyMessage; +import org.bukkit.ChatColor; +import org.bukkit.Material; + +import java.util.*; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class TextUtil { + + public static final transient Pattern patternTag = Pattern.compile("<([a-zA-Z0-9_]*)>"); + private final static String titleizeLine = repeat("-", 52); + + // -------------------------------------------- // + // Top-level parsing functions. + // -------------------------------------------- // + private final static int titleizeBalance = -1; + public Map tags; + + // -------------------------------------------- // + // Tag parsing + // -------------------------------------------- // + + public TextUtil() { + this.tags = new HashMap<>(); + } + + public static String replaceTags(String str, Map tags) { + StringBuffer ret = new StringBuffer(); + Matcher matcher = patternTag.matcher(str); + while (matcher.find()) { + String tag = matcher.group(1); + String repl = tags.get(tag); + if (repl == null) { + matcher.appendReplacement(ret, "<" + tag + ">"); + } else { + matcher.appendReplacement(ret, repl); + } + } + matcher.appendTail(ret); + return ret.toString(); + } + + public static FancyMessage toFancy(String first) { + String text = ""; + FancyMessage message = new FancyMessage(text); + ChatColor color = null; + char[] chars = first.toCharArray(); + + for (int i = 0; i < chars.length; i++) { + // changed this so javadocs wont throw an error + String compareChar = chars[i] + ""; + if (compareChar.equals("§")) { + if (color != null) { + if (color.isColor()) { + message.then(text).color(color); + } else { + message.then(text).style(color); + } + text = ""; + color = ChatColor.getByChar(chars[i + 1]); + } else { + color = ChatColor.getByChar(chars[i + 1]); + } + i++; // skip color char + } else { + text += chars[i]; + } + } + if (text.length() > 0) { + if (color != null) { + if (color.isColor()) { + message.then(text).color(color); + } else { + message.then(text).style(color); + } + } else { + message.text(text); + } + } + return message; + } + + // -------------------------------------------- // + // Fancy parsing + // -------------------------------------------- // + + public static String parseColor(String string) { + string = parseColorAmp(string); + string = parseColorAcc(string); + string = parseColorTags(string); + return ChatColor.translateAlternateColorCodes('&', string); + } + + public static String parseColorAmp(String string) { + string = string.replaceAll("(§([a-z0-9]))", "\u00A7$2"); + string = string.replaceAll("(&([a-z0-9]))", "\u00A7$2"); + string = string.replace("&&", "&"); + return string; + } + + // -------------------------------------------- // + // Color parsing + // -------------------------------------------- // + + public static String parseColorAcc(String string) { + return string.replace("`e", "").replace("`r", ChatColor.RED.toString()).replace("`R", ChatColor.DARK_RED.toString()).replace("`y", ChatColor.YELLOW.toString()).replace("`Y", ChatColor.GOLD.toString()).replace("`g", ChatColor.GREEN.toString()).replace("`G", ChatColor.DARK_GREEN.toString()).replace("`a", ChatColor.AQUA.toString()).replace("`A", ChatColor.DARK_AQUA.toString()).replace("`b", ChatColor.BLUE.toString()).replace("`B", ChatColor.DARK_BLUE.toString()).replace("`plugin", ChatColor.LIGHT_PURPLE.toString()).replace("`SavageFactions", ChatColor.DARK_PURPLE.toString()).replace("`k", ChatColor.BLACK.toString()).replace("`s", ChatColor.GRAY.toString()).replace("`S", ChatColor.DARK_GRAY.toString()).replace("`w", ChatColor.WHITE.toString()); + } + + public static String parseColorTags(String string) { + return string.replace("", "").replace("", "\u00A70").replace("", "\u00A71").replace("", "\u00A72").replace("", "\u00A73").replace("", "\u00A74").replace("", "\u00A75").replace("", "\u00A76").replace("", "\u00A77").replace("", "\u00A78").replace("", "\u00A79").replace("", "\u00A7a").replace("", "\u00A7b").replace("", "\u00A7c").replace("", "\u00A7d").replace("", "\u00A7e").replace("", "\u00A7f"); + } + + public static String upperCaseFirst(String string) { + return string.substring(0, 1).toUpperCase() + string.substring(1); + } + + public static String implode(List list, String glue) { + StringBuilder ret = new StringBuilder(); + for (int i = 0; i < list.size(); i++) + ret.append(glue).append(list.get(i)); + + return ret.length() > 0 ? ret.toString().substring(glue.length()) : ""; + } + + // -------------------------------------------- // + // Standard utils like UCFirst, implode and repeat. + // -------------------------------------------- // + + public static String repeat(String s, int times) { + return times > 0 ? s + repeat(s, times - 1) : ""; + } + + public static String getMaterialName(Material material) { + return material.toString().replace('_', ' ').toLowerCase(); + } + + + // -------------------------------------------- // + // Material name tools + // -------------------------------------------- // + + public static String getBestStartWithCI(Collection candidates, String start) { + String ret = null; + int best = 0; + + start = start.toLowerCase(); + int minlength = start.length(); + for (String candidate : candidates) { + if (candidate.length() < minlength) { + continue; + } + if (!candidate.toLowerCase().startsWith(start)) { + continue; + } + + // The closer to zero the better + int lendiff = candidate.length() - minlength; + if (lendiff == 0) { + return candidate; + } + if (lendiff < best || best == 0) { + best = lendiff; + ret = candidate; + } + } + return ret; + } + + public String parse(String str, Object... args) { + return String.format(this.parse(str), args); + } + + // -------------------------------------------- // + // Paging and chrome-tools like titleize + // -------------------------------------------- // + + public String parse(String str) { + return this.parseTags(parseColor(str)); + } + + public String parseTags(String str) { + return replaceTags(str, this.tags); + } + + public FancyMessage parseFancy(String prefix) { + return toFancy(parse(prefix)); + } + + public String titleize(String str) { + String center = ChatColor.DARK_GRAY + "< " + parseTags("") + str + parseTags("") + ChatColor.DARK_GRAY + " >"; + int centerlen = ChatColor.stripColor(center).length(); + int pivot = titleizeLine.length() / 2; + int eatLeft = (centerlen / 2) - titleizeBalance; + int eatRight = (centerlen - eatLeft) + titleizeBalance; + + if (eatLeft < pivot) { + return parseTags("") + ChatColor.DARK_GRAY + ChatColor.STRIKETHROUGH + titleizeLine.substring(0, pivot - eatLeft) + center + ChatColor.DARK_GRAY + ChatColor.STRIKETHROUGH + titleizeLine.substring(pivot + eatRight); + } else { + return parseTags("") + center; + } + } + + public ArrayList getPage(List lines, int pageHumanBased, String title) { + ArrayList ret = new ArrayList<>(); + int pageZeroBased = pageHumanBased - 1; + int pageheight = 9; + int pagecount = (lines.size() / pageheight) + 1; + + ret.add(this.titleize(title + " " + pageHumanBased + "/" + pagecount)); + + if (pagecount == 0) { + ret.add(this.parseTags(TL.NOPAGES.toString())); + return ret; + } else if (pageZeroBased < 0 || pageHumanBased > pagecount) { + ret.add(this.parseTags(TL.INVALIDPAGE.format(pagecount))); + return ret; + } + + int from = pageZeroBased * pageheight; + int to = from + pageheight; + if (to > lines.size()) { + to = lines.size(); + } + + ret.addAll(lines.subList(from, to)); + + return ret; + } } \ No newline at end of file diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 49630e5f..8765ef82 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -90,10 +90,10 @@ tooltips: # It will not sure up for factionless of course, just actual factions. # You can use color codes here. list: - - "&6&l* &eLeader: &7{leader}" - - "&6&l* &eClaims: &7{chunks}" - - "&6&l* &ePower: &7{power}/{maxPower}" - - "&6&l* &eMembers: &7{online}/{members}" + - "&6&l* &eLeader: &7{leader}" + - "&6&l* &eClaims: &7{chunks}" + - "&6&l* &ePower: &7{power}/{maxPower}" + - "&6&l* &eMembers: &7{online}/{members}" # Show # This shows up when someone does /f show. @@ -102,11 +102,11 @@ tooltips: # {balance} will show their balance if you have vault installed. # {lastSeen} will show human readable info on when the player was last seen, or online. show: - - "&6&l* &eUsername: &7{name}" - - "&6&l* &eRank: &7{group}" - - "&6&l* &eBalance: &7${balance}" - - "&6&l* &eLast Seen:&7 {lastSeen}" - - "&6&l* &ePower: &7{player-power}/{player-maxpower}" + - "&6&l* &eUsername: &7{name}" + - "&6&l* &eRank: &7{group}" + - "&6&l* &eBalance: &7${balance}" + - "&6&l* &eLast Seen:&7 {lastSeen}" + - "&6&l* &ePower: &7{player-power}/{player-maxpower}" # Configuration section for Scoreboards # This will allow you to completely customize how your scoreboards look. @@ -132,14 +132,14 @@ scoreboard: # SUPPORTS PLACEHOLDERS finfo: - - "&6Power" - - "{power}" - - "&3Members" - - "{online}/{members}" - - "&4Leader" - - "{leader}" - - "&bTerritory" - - "{chunks}" + - "&6Power" + - "{power}" + - "&3Members" + - "{online}/{members}" + - "&4Leader" + - "{leader}" + - "&bTerritory" + - "{chunks}" # Default board that will always show up if a player wants it to. # This can show any arbitrary text or you can use a lot of variables to replace things. @@ -159,32 +159,32 @@ scoreboard: # SUPPORTS PLACEHOLDERS default: - - "&7&m--------------------------" - - "&4&lFaction Info &8»" - - " &8> &cLeader&7: &f{leader}" - - " &8> &cMembers&7: &f{online}&7/&f{members}" - - " &8> &cPower&7: &f{power}&7/&f{maxPower}" - - "&m" - - "&4&lFaction Stats &8»" - - " &8> &cKills&7: &f{faction-kills}" - - " &8> &cDeaths&7: &f{faction-deaths}" - - " &8> &cBalance&7: &f{faction-balance}" - - "" - - " &8> &cYour Balance&7: &f{balance}" - - "&7&m---------------------------" + - "&7&m--------------------------" + - "&4&lFaction Info &8»" + - " &8> &cLeader&7: &f{leader}" + - " &8> &cMembers&7: &f{online}&7/&f{members}" + - " &8> &cPower&7: &f{power}&7/&f{maxPower}" + - "&m" + - "&4&lFaction Stats &8»" + - " &8> &cKills&7: &f{faction-kills}" + - " &8> &cDeaths&7: &f{faction-deaths}" + - " &8> &cBalance&7: &f{faction-balance}" + - "" + - " &8> &cYour Balance&7: &f{balance}" + - "&7&m---------------------------" factionless-enabled: true factionless: - - "&7&m--------------------------" - - "&4&lInformation &8»" - - " &8> &cPlayer&7: &f{name}" - - " &8> &cRank&7: &f{group}" - - " &8> &cBalance&7: &f${balance}" - - "&m" - - "&4&lServer Info &8» " - - " &8» &cIFaction: &fN/A" - - " &8» &cOnline Players&7: &f{total-online}" - - "&7&m---------------------------" + - "&7&m--------------------------" + - "&4&lInformation &8»" + - " &8> &cPlayer&7: &f{name}" + - " &8> &cRank&7: &f{group}" + - " &8> &cBalance&7: &f${balance}" + - "&m" + - "&4&lServer Info &8» " + - " &8» &cIFaction: &fN/A" + - " &8» &cOnline Players&7: &f{total-online}" + - "&7&m---------------------------" # Configration section for warmups. @@ -275,26 +275,26 @@ hcf: # SUPPORTS PLACEHOLDERS show: -# First line can be {header} for default header, or any string (we recommend &m for smooth lines ;plugin) -- '&8&m--------------&7 &8<&e{faction}&8> &8&m--------------' -- '&6 * &eOwner &7{leader}' -- '&6 * &eDescription &7{description}' -- '&6 * &eLand / Power / Max Power: &7{chunks} &8/ &7{power} &8/ &7{maxPower}' -- '&6 * &eFounded &7{create-date}' -- '&6 * &eBalance &f{faction-balance}' -- '&6 * &eAllies &c{allies-list}' -- '&6 * &eEnemies &c{enemies-list}' -- '&6 * &eOnline Members &8(&7{online}/{members}&8) &7{online-list}' -- '&6 * &eOffline Members &8(&7{offline}/{members}&8) &7{offline-list}' -- '&6 * &eBans &7{faction-bancount}' -- '&8&m----------------------------------------' + # First line can be {header} for default header, or any string (we recommend &m for smooth lines ;plugin) + - '&8&m--------------&7 &8<&e{faction}&8> &8&m--------------' + - '&6 * &eOwner &7{leader}' + - '&6 * &eDescription &7{description}' + - '&6 * &eLand / Power / Max Power: &7{chunks} &8/ &7{power} &8/ &7{maxPower}' + - '&6 * &eFounded &7{create-date}' + - '&6 * &eBalance &f{faction-balance}' + - '&6 * &eAllies &c{allies-list}' + - '&6 * &eEnemies &c{enemies-list}' + - '&6 * &eOnline Members &8(&7{online}/{members}&8) &7{online-list}' + - '&6 * &eOffline Members &8(&7{offline}/{members}&8) &7{offline-list}' + - '&6 * &eBans &7{faction-bancount}' + - '&8&m----------------------------------------' # For a /f show that does not display fancy messages that are essentially empty, use minimal-show minimal-show: false # Factions that should be exempt from /f show, case sensitive, useful for a # serverteam faction, since the command shows vanished players otherwise show-exempt: -- Wilderness + - Wilderness # THIS IS FOR /f map tool tips. @@ -302,14 +302,14 @@ show-exempt: # You can use any variable here, including fancy messages. Color codes and or tags work fine. # Lines that arent defined wont be sent (home not set, faction not peaceful / permanent, dtr freeze) map: -# First line can be {header} for default header, or any string (we recommend &m for smooth lines ;plugin) -- '&6* &eFaction &7{faction}' -- '&6* &eOwner &7{leader}' -- '&6* &eLand / Power / Max Power: &7{chunks} &8/ &7{power} &8/ &7{maxPower}' -- '&6* &eAllies &c{allies-list}' -- '&6* &eEnemies &c{enemies-list}' -- '&6* &eOnline Members &8(&7{online}/{members}&8) {online-list}' -- '&6* &eOffline Members &7{offline-list}' + # First line can be {header} for default header, or any string (we recommend &m for smooth lines ;plugin) + - '&6* &eFaction &7{faction}' + - '&6* &eOwner &7{leader}' + - '&6* &eLand / Power / Max Power: &7{chunks} &8/ &7{power} &8/ &7{maxPower}' + - '&6* &eAllies &c{allies-list}' + - '&6* &eEnemies &c{enemies-list}' + - '&6* &eOnline Members &8(&7{online}/{members}&8) {online-list}' + - '&6* &eOffline Members &7{offline-list}' ############################################################ # +------------------------------------------------------+ # @@ -340,50 +340,50 @@ help: # You can change the page name to whatever you like # We use '1' to preserve default functionality of /f help 1 '1': - - '&7&m----------------------------------------------------' - - '&6&lFactions Help &8- &f(1/2) ' - - '&7&m----------------------------------------------------' - - '&e/f create &f &8- &7Create your own faction.' - - '&e/f who &f &8- &7Show faction information.' - - '&e/f tag &f &8- &7Change your faction name.' - - '&e/f join &f &8- &7Join to the faction.' - - '&e/f list &8- &7List all factions.' - - '&e/f top &8- &7View the richest factions.' - - '&e/f map &8- &7Map of the surrounding area, click chunks to claim.' - - '&e/f sethome &8- &7Set your faction home.' - - '&e/f home &8- &7Go to your faction home.' - - '&e/f title &f &8- &7Set a player''s title, color codes supported.' - - '&e/f ban &8- &7Ban a member from your faction.' - - '&e/f unban &8- &7Unban a member from your faction.' - - '&e/f banlist &8- &7List banned players from your faction.' - - '&e/f lowpower &8- &7List player with power under max from your faction.' - - '&e/f coords &8- &7Broadcast your location to your faction.' - - '&e/f showclaims &8- &7List all claims from your faction.' - - '&7&m--------------------&r &e/f help 2 &7&m-----------------------' + - '&7&m----------------------------------------------------' + - '&6&lFactions Help &8- &f(1/2) ' + - '&7&m----------------------------------------------------' + - '&e/f create &f<name> &8- &7Create your own faction.' + - '&e/f who &f<name> &8- &7Show faction information.' + - '&e/f tag &f<name> &8- &7Change your faction name.' + - '&e/f join &f<name> &8- &7Join to the faction.' + - '&e/f list &8- &7List all factions.' + - '&e/f top &8- &7View the richest factions.' + - '&e/f map &8- &7Map of the surrounding area, click chunks to claim.' + - '&e/f sethome &8- &7Set your faction home.' + - '&e/f home &8- &7Go to your faction home.' + - '&e/f title &f<playername> <title> &8- &7Set a player''s title, color codes supported.' + - '&e/f ban &8- &7Ban a member from your faction.' + - '&e/f unban &8- &7Unban a member from your faction.' + - '&e/f banlist &8- &7List banned players from your faction.' + - '&e/f lowpower &8- &7List player with power under max from your faction.' + - '&e/f coords &8- &7Broadcast your location to your faction.' + - '&e/f showclaims &8- &7List all claims from your faction.' + - '&7&m--------------------&r &e/f help 2 &7&m-----------------------' '2': - - '&7&m----------------------------------------------------' - - '&6&lFactions Help &8- &f(2/2) ' - - '&7&m----------------------------------------------------' - - '&e/f leave &8- &7Leave your faction.' - - '&e/f invite &f<playerName> &8- &7Invite a player to your faction.' - - '&e/f deinvite &f<playerName> &8- &7Revoke invitation to player.' - - '&e/f claim &8- &7Claim a land for your faction.' - - '&e/f unclaim &8- &7Unclaim land from your faction.' - - '&e/f kick &f<playerName> &8- &7Kick player from your faction.' - - '&e/f mod &f<playerName> &8- &7Set player to mod role in faction.' - - '&e/f coleader &f<playerName> &8- &7Set player to coleader role in faction.' - - '&e/f leader &f<playerName> &8- &7Set player role to leader in faction.' - - '&e/f chat &f<Faction | Ally | Public> &8- &7Switch to Faction/Ally/Public chat.' - - '&e/f warp &8- &7Opens the warp menu.' - - '&e/f setwarp &8- &7Set a warp.' - - '&e/f perms &8- &7Change what players can do in your claims.' - - '&e/f upgrades &8- &7Upgrade various perks in your faction.' - - '&e/f checkpoint &8- &7Set a faction checkpoint.' - - '&e/f tnt add/take &f<amount> &8- &7Faction Based TNT Bank.' - - '&e/f tntfill &f<radius> <amount> &8- &7Tnt fill integrated into the tntbank!' - - '&e/f chest &8- &7Open a virtual faction chest! ' - - '&e/f version &8- &7Display current faction version.' - - '&7&m--------------------&r &e/f help 3 &7&m-----------------------' + - '&7&m----------------------------------------------------' + - '&6&lFactions Help &8- &f(2/2) ' + - '&7&m----------------------------------------------------' + - '&e/f leave &8- &7Leave your faction.' + - '&e/f invite &f<playerName> &8- &7Invite a player to your faction.' + - '&e/f deinvite &f<playerName> &8- &7Revoke invitation to player.' + - '&e/f claim &8- &7Claim a land for your faction.' + - '&e/f unclaim &8- &7Unclaim land from your faction.' + - '&e/f kick &f<playerName> &8- &7Kick player from your faction.' + - '&e/f mod &f<playerName> &8- &7Set player to mod role in faction.' + - '&e/f coleader &f<playerName> &8- &7Set player to coleader role in faction.' + - '&e/f leader &f<playerName> &8- &7Set player role to leader in faction.' + - '&e/f chat &f<Faction | Ally | Public> &8- &7Switch to Faction/Ally/Public chat.' + - '&e/f warp &8- &7Opens the warp menu.' + - '&e/f setwarp &8- &7Set a warp.' + - '&e/f perms &8- &7Change what players can do in your claims.' + - '&e/f upgrades &8- &7Upgrade various perks in your faction.' + - '&e/f checkpoint &8- &7Set a faction checkpoint.' + - '&e/f tnt add/take &f<amount> &8- &7Faction Based TNT Bank.' + - '&e/f tntfill &f<radius> <amount> &8- &7Tnt fill integrated into the tntbank!' + - '&e/f chest &8- &7Open a virtual faction chest! ' + - '&e/f version &8- &7Display current faction version.' + - '&7&m--------------------&r &e/f help 3 &7&m-----------------------' ############################################################ # +------------------------------------------------------+ # # | F Permission GUI | # @@ -440,44 +440,44 @@ fperm-gui: # Dummy items using the Items lower down dummy-items: '0': - - 0 - - 1 - - 2 - - 3 - - 4 - - 5 - - 6 - - 7 - - 8 - - 9 - - 11 - - 13 - - 15 - - 17 - - 20 - - 22 - - 24 - - 26 - - 17 - - 18 - - 19 - - 26 - - 27 - - 28 - - 29 - - 30 - - 31 - - 32 - - 33 - - 34 - - 35 + - 0 + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + - 7 + - 8 + - 9 + - 11 + - 13 + - 15 + - 17 + - 20 + - 22 + - 24 + - 26 + - 17 + - 18 + - 19 + - 26 + - 27 + - 28 + - 29 + - 30 + - 31 + - 32 + - 33 + - 34 + - 35 # This is the item that all relation items are based off of # Replacing {relation} with relation name eg: Moderator, Ally # also replaces {relation-color} with relation color eg: Enemy;RED placeholder-item: name: '&8[{relation-color}{relation}&8]' lore: - - + - action: name: 'Faction Permissions' rows: 6 @@ -552,24 +552,117 @@ fperm-gui: # Same dummy items format as above dummy-items: '0': + - 1 + - 2 + - 3 + - 5 + - 6 + - 7 + - 8 + - 9 + - 10 + - 11 + - 12 + - 13 + - 14 + - 15 + - 16 + - 17 + - 18 + - 10 + - 20 + - 21 + - 22 + - 23 + - 24 + - 25 + - 26 + - 27 + - 28 + - 29 + - 30 + - 34 + - 35 + - 36 + - 37 + - 38 + - 39 + - 40 + - 41 + - 42 + - 43 + - 44 + - 45 + - 46 + - 47 + - 48 + - 49 + - 50 + - 51 + - 52 + - 53 + # {action} Action name eg: Setwarp, Kick + # {action-access} Access name eg: Allow, Deny + # {action-access-color} Access color eg: Allow;GREEN + placeholder-item: + name: '&e&l(!) &ePermission: &6&n{action}' + lore: + - '' + - '&6&l * &eStatus: &8[{action-access-color}{action-access}&8]' + - '' + - '&7Left click to &a&nAllow&7.' + - '&7Right click to &c&nDeny&7.' + - '&7Middle click to &7&nUndefine&7.' + # Back item will be take you to the previous GUI + back-item: + name: '&c&l<- Back' + material: ARROW + lore: + - '&7Click to return to previous menu.' + # Dummy Items + dummy-items: + # Dummy Item id, used to set the slots above + '0': + material: STAINED_GLASS_PANE + # Color will only work on colorable materials + color: BLACK + name: ' ' + lore: + - + +############################################################ +# +------------------------------------------------------+ # +# | Faction Warp GUI | # +# +------------------------------------------------------+ # +############################################################ + +fwarp-gui: + name: "Faction Warps" + rows: 3 + password-timeout: 5 + warp-slots: + - 11 + - 12 + - 13 + - 14 + - 15 + dummy-slots: + '0': + - 0 - 1 - 2 - 3 + - 4 - 5 - 6 - 7 - 8 - 9 - 10 - - 11 - - 12 - - 13 - - 14 - - 15 - 16 - 17 - 18 - - 10 + - 19 - 20 - 21 - 22 @@ -577,110 +670,18 @@ fperm-gui: - 24 - 25 - 26 - - 27 - - 28 - - 29 - - 30 - - 34 - - 35 - - 36 - - 37 - - 38 - - 39 - - 40 - - 41 - - 42 - - 43 - - 44 - - 45 - - 46 - - 47 - - 48 - - 49 - - 50 - - 51 - - 52 - - 53 - # {action} Action name eg: Setwarp, Kick - # {action-access} Access name eg: Allow, Deny - # {action-access-color} Access color eg: Allow;GREEN - placeholder-item: - name: '&e&l(!) &ePermission: &6&n{action}' - lore: - - '' - - '&6&l * &eStatus: &8[{action-access-color}{action-access}&8]' - - '' - - '&7Left click to &a&nAllow&7.' - - '&7Right click to &c&nDeny&7.' - - '&7Middle click to &7&nUndefine&7.' - # Back item will be take you to the previous GUI - back-item: - name: '&c&l<- Back' - material: ARROW - lore: - - '&7Click to return to previous menu.' - # Dummy Items - dummy-items: - # Dummy Item id, used to set the slots above - '0': - material: STAINED_GLASS_PANE - # Color will only work on colorable materials - color: BLACK - name: ' ' - lore: - - - ############################################################ - # +------------------------------------------------------+ # - # | Faction Warp GUI | # - # +------------------------------------------------------+ # - ############################################################ - -fwarp-gui: - name: "Faction Warps" - rows: 3 - password-timeout: 5 - warp-slots: - - 11 - - 12 - - 13 - - 14 - - 15 - dummy-slots: - '0': - - 0 - - 1 - - 2 - - 3 - - 4 - - 5 - - 6 - - 7 - - 8 - - 9 - - 10 - - 16 - - 17 - - 18 - - 19 - - 20 - - 21 - - 22 - - 23 - - 24 - - 25 - - 26 warp-item: material: EYE_OF_ENDER name: "&e&l(!) &eFaction Warp: &6&n{warp}" # {warp-protected} Warp protection by password, Enabled & Disabled # {warp-cost} Warp cost lore: - - "" - - "&6&l * &ePassword: &7{warp-protected}" - - "&6&l * &eCost: &7{warp-cost}" - - "" - - "&c&lNote: &7You need pay to teleport to" - - "&7a faction warp. Unless it's &nDisabled&7." + - "" + - "&6&l * &ePassword: &7{warp-protected}" + - "&6&l * &eCost: &7{warp-cost}" + - "" + - "&c&lNote: &7You need pay to teleport to" + - "&7a faction warp. Unless it's &nDisabled&7." # Dummy Items dummy-items: # Dummy Item id, used to set the slots above @@ -690,7 +691,31 @@ fwarp-gui: color: BLACK name: ' ' lore: - - + - + + +############################################################ +# +------------------------------------------------------+ # +# | Faction Homes Essentials | # +# +------------------------------------------------------+ # +############################################################ +# Warzone/SafeZone +deny-homes-in-system-factions: false +remove-homes-in-system-factions: false + +deny-homes-in-enemy-factions: false +remove-homes-in-enemy-factions: false + +deny-homes-in-neutral-factions: false +remove-homes-in-neutral-factions: false + +deny-homes-in-ally-factions: false +remove-homes-in-ally-factions: false + +deny-homes-in-truce-factions: false +remove-homes-in-truce-factions: false + + ############################################################ # +------------------------------------------------------+ # @@ -715,8 +740,8 @@ See-Invisible-Faction-Members: false frules: Enabled: true default-rules: - - '&cDefault Faction Rules :(' - - '&cUse /f rules add <rule> to add a rule' + - '&cDefault Faction Rules :(' + - '&cUse /f rules add <rule> to add a rule' ############################################################ # +------------------------------------------------------+ # # | Faction TNT Bank | # @@ -773,11 +798,11 @@ fvault: Item: Name: '&e&l*&f&l*&e&l* &e&lFaction Vault &7(Place) &e&l*&f&l*&e&l*' Lore: - - '&7Place this vault in your Faction claim, You will' - - '&7then be able to access it.' - - '' - - '&c&lNote: &7Once you have placed your' - - '&7faction vault, Access it by doing /f vault.' + - '&7Place this vault in your Faction claim, You will' + - '&7then be able to access it.' + - '' + - '&c&lNote: &7Once you have placed your' + - '&7faction vault, Access it by doing /f vault.' ############################################################ # +------------------------------------------------------+ # @@ -804,36 +829,36 @@ fupgrades: Amount: 1 Damage: 7 Lore: - - '' + - '' rows: 3 slots: - - 0 - - 1 - - 2 - - 3 - - 4 - - 5 - - 6 - - 7 - - 8 - - 9 - - 10 - - 11 - - 12 - - 13 - - 14 - - 15 - - 16 - - 17 - - 18 - - 19 - - 20 - - 21 - - 22 - - 23 - - 24 - - 25 - - 26 + - 0 + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + - 7 + - 8 + - 9 + - 10 + - 11 + - 12 + - 13 + - 14 + - 15 + - 16 + - 17 + - 18 + - 19 + - 20 + - 21 + - 22 + - 23 + - 24 + - 25 + - 26 Crops: Crop-Boost: level-1: 10 @@ -849,23 +874,23 @@ fupgrades: Amount: 1 Damage: 0 Lore: - - '&7Increase growth speed of crops in claims.' - - '&7&o(Chance to Grow Two Levels)' - - '' - - '&e&lTier' - - '&f&l* &7Current Level: &n{level}' - - '' - - '&e&lPerks' - - '&f&l* &7Level 1 - &f10% Chance' - - '&7 - Cost: $250,000' - - '&f&l* &7Level 2 - &f20% Chance' - - '&7 - Cost: $500,000' - - '&f&l* &7Level 3 - &f30% Chance' - - '&7 - Cost: $750,000' - - '' - - '&e&lClick to &nUnlock' + - '&7Increase growth speed of crops in claims.' + - '&7&o(Chance to Grow Two Levels)' + - '' + - '&e&lTier' + - '&f&l* &7Current Level: &n{level}' + - '' + - '&e&lPerks' + - '&f&l* &7Level 1 - &f10% Chance' + - '&7 - Cost: $250,000' + - '&f&l* &7Level 2 - &f20% Chance' + - '&7 - Cost: $500,000' + - '&f&l* &7Level 3 - &f30% Chance' + - '&7 - Cost: $750,000' + - '' + - '&e&lClick to &nUnlock' slots: - - 10 + - 10 EXP: EXP-Boost: level-1: 1.5 @@ -881,22 +906,22 @@ fupgrades: Amount: 1 Damage: 0 Lore: - - '&7Increased Vanilla XP gained from monsters.' - - '' - - '&e&lTier' - - '&f&l* &7Current Level: &n{level}' - - '' - - '&e&lPerks' - - '&f&l* &7Level 1 - &f1.5x Multiplier' - - '&7 - Cost: $2,000,000' - - '&f&l* &7Level 2 - &f2.0x Multiplier' - - '&7 - Cost: $4,000,000' - - '&f&l* &7Level 3 - &f2.5x Multiplier' - - '&7 - Cost: $6,000,000' - - '' - - '&e&lClick to &nUnlock' + - '&7Increased Vanilla XP gained from monsters.' + - '' + - '&e&lTier' + - '&f&l* &7Current Level: &n{level}' + - '' + - '&e&lPerks' + - '&f&l* &7Level 1 - &f1.5x Multiplier' + - '&7 - Cost: $2,000,000' + - '&f&l* &7Level 2 - &f2.0x Multiplier' + - '&7 - Cost: $4,000,000' + - '&f&l* &7Level 3 - &f2.5x Multiplier' + - '&7 - Cost: $6,000,000' + - '' + - '&e&lClick to &nUnlock' slots: - - 13 + - 13 Spawners: Spawner-Boost: # This is a Percentage so .10 means 10% lowered spawner delay! @@ -913,22 +938,22 @@ fupgrades: Amount: 1 Damage: 0 Lore: - - '&7Decreased mob spawner delay in claims.' - - '' - - '&e&lTier' - - '&f&l* &7Current Level: &n{level}' - - '' - - '&e&lPerks' - - '&f&l* &7Level 1 - &f10% Lower Delay' - - '&7 - Cost: $1,000,000' - - '&f&l* &7Level 2 - &f20% Lower Delay' - - '&7 - Cost: $2,000,000' - - '&f&l* &7Level 3 - &f30% Lower Delay' - - '&7 - Cost: $3,000,000' - - '' - - '&e&lClick to &nUnlock' + - '&7Decreased mob spawner delay in claims.' + - '' + - '&e&lTier' + - '&f&l* &7Current Level: &n{level}' + - '' + - '&e&lPerks' + - '&f&l* &7Level 1 - &f10% Lower Delay' + - '&7 - Cost: $1,000,000' + - '&f&l* &7Level 2 - &f20% Lower Delay' + - '&7 - Cost: $2,000,000' + - '&f&l* &7Level 3 - &f30% Lower Delay' + - '&7 - Cost: $3,000,000' + - '' + - '&e&lClick to &nUnlock' slots: - - 16 + - 16 Chest: Chest-Size: # This is rows @@ -945,22 +970,22 @@ fupgrades: Amount: 1 Damage: 0 Lore: - - '&7Increased Faction Chest Size.' - - '' - - '&e&lTier' - - '&f&l* &7Current Level: &n{level}' - - '' - - '&e&lPerks' - - '&f&l* &7Level 1 - &f2 Rows' - - '&7 - Cost: $1,000,000' - - '&f&l* &7Level 2 - &f3 Rows' - - '&7 - Cost: $2,000,000' - - '&f&l* &7Level 3 - &f4 Rows' - - '&7 - Cost: $3,000,000' - - '' - - '&e&lClick to &nUnlock' + - '&7Increased Faction Chest Size.' + - '' + - '&e&lTier' + - '&f&l* &7Current Level: &n{level}' + - '' + - '&e&lPerks' + - '&f&l* &7Level 1 - &f2 Rows' + - '&7 - Cost: $1,000,000' + - '&f&l* &7Level 2 - &f3 Rows' + - '&7 - Cost: $2,000,000' + - '&f&l* &7Level 3 - &f4 Rows' + - '&7 - Cost: $3,000,000' + - '' + - '&e&lClick to &nUnlock' slots: - - 22 + - 22 ############################################################ # +------------------------------------------------------+ # @@ -972,19 +997,19 @@ fbanners: Item: Name: '&e&l*&f&l*&e&l* &e&lWar Banner &7(Place) &e&l*&f&l*&e&l*' Lore: - - '&7Place this banner in the &nWarzone.&7 This' - - '&7will create a &nWarp Point&7 for your faction members.' - - '' - - '&e&lEffects' - - '&e&l* &fStrength II' - - '&e&l* &fSpeed II' + - '&7Place this banner in the &nWarzone.&7 This' + - '&7will create a &nWarp Point&7 for your faction members.' + - '' + - '&e&lEffects' + - '&e&l* &fStrength II' + - '&e&l* &fSpeed II' Banner-Cost: 5000 #The amount charged to change a banner into a War Banner Banner-Time: 60 #IN SECONDS - This is how long the banner will last. Banner-Place-Cooldown: 300 Banner-Effect-Radius: 16 Effects: - - INCREASE_DAMAGE:2 - - SPEED:2 + - INCREASE_DAMAGE:2 + - SPEED:2 BannerHolo: '&c{Faction}''s War Banner' Placeable: Warzone: true diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 39c338e7..91adbad8 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -150,6 +150,8 @@ permissions: description: display a help page factions.home: description: teleport to the faction home + factions.homes.bypass: + description: bypass all home teleports factions.invite: description: invite a player to your faction factions.join: