From 72f76aeb712339ffd737f8ec5a0381c28c5fc23f Mon Sep 17 00:00:00 2001 From: Driftay Date: Sat, 24 Aug 2019 13:18:50 -0400 Subject: [PATCH] Check System Added and Massive Reformat --- .../java/com/massivecraft/factions/Board.java | 104 +- .../java/com/massivecraft/factions/Conf.java | 787 ++--- .../com/massivecraft/factions/FLocation.java | 387 +- .../com/massivecraft/factions/FPlayer.java | 424 +-- .../com/massivecraft/factions/FPlayers.java | 38 +- .../com/massivecraft/factions/Faction.java | 382 +- .../com/massivecraft/factions/Factions.java | 56 +- .../java/com/massivecraft/factions/P.java | 1240 +++---- .../massivecraft/factions/cmd/CmdAHome.java | 72 +- .../massivecraft/factions/cmd/CmdAdmin.java | 146 +- .../factions/cmd/CmdAnnounce.java | 60 +- .../factions/cmd/CmdAutoHelp.java | 52 +- .../com/massivecraft/factions/cmd/CmdBan.java | 134 +- .../massivecraft/factions/cmd/CmdBanlist.java | 92 +- .../massivecraft/factions/cmd/CmdBoom.java | 68 +- .../massivecraft/factions/cmd/CmdBypass.java | 58 +- .../massivecraft/factions/cmd/CmdChat.java | 132 +- .../massivecraft/factions/cmd/CmdChatSpy.java | 54 +- .../massivecraft/factions/cmd/CmdCheck.java | 56 + .../factions/cmd/CmdCheckpoint.java | 98 +- .../factions/cmd/CmdColeader.java | 138 +- .../massivecraft/factions/cmd/CmdConfig.java | 396 +-- .../massivecraft/factions/cmd/CmdConvert.java | 54 +- .../massivecraft/factions/cmd/CmdCoords.java | 50 +- .../massivecraft/factions/cmd/CmdCreate.java | 173 +- .../factions/cmd/CmdDeinvite.java | 94 +- .../factions/cmd/CmdDelFWarp.java | 62 +- .../factions/cmd/CmdDescription.java | 78 +- .../massivecraft/factions/cmd/CmdDisband.java | 158 +- .../massivecraft/factions/cmd/CmdFGlobal.java | 10 +- .../massivecraft/factions/cmd/CmdFWarp.java | 110 +- .../com/massivecraft/factions/cmd/CmdFly.java | 373 +- .../massivecraft/factions/cmd/CmdFocus.java | 74 +- .../factions/cmd/CmdGetVault.java | 102 +- .../massivecraft/factions/cmd/CmdHelp.java | 360 +- .../massivecraft/factions/cmd/CmdHome.java | 255 +- .../massivecraft/factions/cmd/CmdInspect.java | 52 +- .../massivecraft/factions/cmd/CmdInvite.java | 130 +- .../massivecraft/factions/cmd/CmdJoin.java | 231 +- .../massivecraft/factions/cmd/CmdKick.java | 218 +- .../factions/cmd/CmdKillHolograms.java | 42 +- .../massivecraft/factions/cmd/CmdLeave.java | 42 +- .../massivecraft/factions/cmd/CmdList.java | 176 +- .../massivecraft/factions/cmd/CmdLock.java | 46 +- .../massivecraft/factions/cmd/CmdLogins.java | 40 +- .../factions/cmd/CmdLowPower.java | 50 +- .../com/massivecraft/factions/cmd/CmdMap.java | 92 +- .../factions/cmd/CmdMapHeight.java | 44 +- .../com/massivecraft/factions/cmd/CmdMod.java | 132 +- .../factions/cmd/CmdModifyPower.java | 66 +- .../massivecraft/factions/cmd/CmdNear.java | 70 +- .../massivecraft/factions/cmd/CmdOpen.java | 80 +- .../massivecraft/factions/cmd/CmdOwner.java | 148 +- .../factions/cmd/CmdOwnerList.java | 94 +- .../factions/cmd/CmdPaypalSee.java | 91 +- .../factions/cmd/CmdPeaceful.java | 82 +- .../massivecraft/factions/cmd/CmdPerm.java | 160 +- .../factions/cmd/CmdPermanent.java | 84 +- .../factions/cmd/CmdPermanentPower.java | 80 +- .../massivecraft/factions/cmd/CmdPower.java | 70 +- .../factions/cmd/CmdPowerBoost.java | 132 +- .../massivecraft/factions/cmd/CmdReload.java | 56 +- .../massivecraft/factions/cmd/CmdRules.java | 138 +- .../com/massivecraft/factions/cmd/CmdSB.java | 44 +- .../massivecraft/factions/cmd/CmdSaveAll.java | 52 +- .../factions/cmd/CmdSeeChunk.java | 202 +- .../factions/cmd/CmdSetBanner.java | 42 +- .../factions/cmd/CmdSetDefaultRole.java | 60 +- .../factions/cmd/CmdSetFWarp.java | 106 +- .../factions/cmd/CmdSetMaxVaults.java | 64 +- .../massivecraft/factions/cmd/CmdSethome.java | 102 +- .../massivecraft/factions/cmd/CmdShow.java | 174 +- .../factions/cmd/CmdShowClaims.java | 72 +- .../factions/cmd/CmdShowInvites.java | 42 +- .../massivecraft/factions/cmd/CmdSpam.java | 3 +- .../massivecraft/factions/cmd/CmdStatus.java | 50 +- .../massivecraft/factions/cmd/CmdStealth.java | 47 +- .../massivecraft/factions/cmd/CmdStrike.java | 4 +- .../massivecraft/factions/cmd/CmdStuck.java | 160 +- .../com/massivecraft/factions/cmd/CmdTag.java | 130 +- .../massivecraft/factions/cmd/CmdTitle.java | 70 +- .../factions/cmd/CmdToggleAllianceChat.java | 54 +- .../com/massivecraft/factions/cmd/CmdTop.java | 298 +- .../factions/cmd/CmdTpBanner.java | 54 +- .../massivecraft/factions/cmd/CmdUnban.java | 74 +- .../factions/cmd/CmdUpgrades.java | 50 +- .../massivecraft/factions/cmd/CmdVault.java | 102 +- .../massivecraft/factions/cmd/CmdVersion.java | 42 +- .../massivecraft/factions/cmd/FCmdRoot.java | 543 +-- .../massivecraft/factions/cmd/FCommand.java | 666 ++-- .../factions/cmd/alts/CmdAlts.java | 2 +- .../factions/cmd/alts/CmdAltsList.java | 8 +- .../factions/cmd/alts/CmdInviteAlt.java | 2 +- .../factions/cmd/chest/ChestLogsHandler.java | 2 +- .../factions/cmd/chest/CmdChest.java | 62 +- .../factions/cmd/claim/CmdAutoClaim.java | 74 +- .../factions/cmd/claim/CmdClaimAt.java | 56 +- .../factions/cmd/claim/CmdClaimLine.java | 106 +- .../factions/cmd/claim/CmdSafeunclaimall.java | 70 +- .../factions/cmd/claim/CmdUnclaim.java | 268 +- .../factions/cmd/claim/CmdUnclaimall.java | 82 +- .../factions/cmd/claim/CmdWarunclaimall.java | 68 +- .../factions/cmd/econ/CmdMoney.java | 70 +- .../factions/cmd/econ/CmdMoneyBalance.java | 72 +- .../factions/cmd/econ/CmdMoneyDeposit.java | 60 +- .../factions/cmd/econ/CmdMoneyTransferFf.java | 78 +- .../factions/cmd/econ/CmdMoneyTransferFp.java | 76 +- .../factions/cmd/econ/CmdMoneyTransferPf.java | 76 +- .../factions/cmd/econ/CmdMoneyWithdraw.java | 76 +- .../factions/cmd/grace/CmdGrace.java | 5 +- .../factions/cmd/logout/CmdLogout.java | 8 +- .../factions/cmd/logout/LogoutHandler.java | 16 +- .../factions/cmd/points/CmdPoints.java | 2 +- .../factions/cmd/points/CmdPointsAdd.java | 5 +- .../factions/cmd/points/CmdPointsRemove.java | 2 +- .../factions/cmd/points/CmdPointsSet.java | 2 +- .../cmd/relational/CmdRelationAlly.java | 8 +- .../cmd/relational/CmdRelationEnemy.java | 8 +- .../cmd/relational/CmdRelationNeutral.java | 8 +- .../cmd/relational/CmdRelationTruce.java | 8 +- .../cmd/relational/FRelationCommand.java | 184 +- .../factions/cmd/roles/CmdDemote.java | 8 +- .../factions/cmd/roles/CmdPromote.java | 10 +- .../factions/cmd/roles/FPromoteCommand.java | 142 +- .../massivecraft/factions/cmd/tnt/CmdTnt.java | 6 +- .../event/FPlayerEnteredFactionEvent.java | 52 +- .../factions/event/FPlayerJoinEvent.java | 50 +- .../factions/event/FPlayerLeaveEvent.java | 52 +- .../factions/event/FPlayerStoppedFlying.java | 32 +- .../factions/event/FactionCreateEvent.java | 58 +- .../factions/event/FactionDisbandEvent.java | 62 +- .../factions/event/FactionEvent.java | 40 +- .../factions/event/FactionPlayerEvent.java | 16 +- .../factions/event/FactionRelationEvent.java | 58 +- .../event/FactionRelationWishEvent.java | 54 +- .../factions/event/FactionRenameEvent.java | 84 +- .../factions/event/LandClaimEvent.java | 106 +- .../factions/event/LandUnclaimAllEvent.java | 84 +- .../factions/event/LandUnclaimEvent.java | 96 +- .../factions/event/PowerLossEvent.java | 118 +- .../factions/event/PowerRegenEvent.java | 24 +- .../factions/iface/EconomyParticipator.java | 6 +- .../factions/iface/RelationParticipator.java | 10 +- .../factions/integration/Econ.java | 698 ++-- .../factions/integration/Essentials.java | 66 +- .../factions/integration/Worldguard.java | 172 +- .../listeners/FactionsBlockListener.java | 91 +- .../listeners/FactionsChatListener.java | 312 +- .../listeners/FactionsEntityListener.java | 1364 ++++---- .../listeners/FactionsExploitListener.java | 102 +- .../listeners/FactionsPlayerListener.java | 411 ++- .../factions/missions/MissionHandler.java | 2 +- .../scoreboards/BufferedObjective.java | 242 +- .../factions/scoreboards/FScoreboard.java | 216 +- .../scoreboards/FSidebarProvider.java | 44 +- .../factions/scoreboards/FTeamWrapper.java | 344 +- .../massivecraft/factions/shop/CmdShop.java | 24 +- .../factions/shop/ShopClickPersistence.java | 16 +- .../factions/shop/ShopConfig.java | 2 + .../massivecraft/factions/shop/ShopGUI.java | 3 +- .../massivecraft/factions/struct/BanInfo.java | 66 +- .../factions/struct/ChatMode.java | 60 +- .../factions/struct/Permission.java | 257 +- .../factions/struct/Relation.java | 370 +- .../massivecraft/factions/struct/Role.java | 216 +- .../factions/util/AsciiCompass.java | 172 +- .../factions/util/AutoLeaveProcessTask.java | 132 +- .../factions/util/AutoLeaveTask.java | 32 +- .../factions/util/CheckWallTask.java | 23 + .../util/ClipPlaceholderAPIManager.java | 292 +- .../factions/util/EnumTypeAdapter.java | 86 +- .../factions/util/FactionGUI.java | 4 +- .../factions/util/FactionWarpsFrame.java | 18 +- .../factions/util/InventoryTypeAdapter.java | 22 +- .../factions/util/InventoryUtil.java | 130 +- .../factions/util/LazyLocation.java | 140 +- .../factions/util/LocationTypeAdapter.java | 60 +- .../util/MapFLocToStringSetTypeAdapter.java | 138 +- .../massivecraft/factions/util/MiscUtil.java | 176 +- .../factions/util/MyLocationTypeAdapter.java | 80 +- .../util/Particles/ParticleEffect.java | 3110 ++++++++--------- .../util/Particles/ReflectionUtils.java | 1078 +++--- .../util/PermissionsMapTypeAdapter.java | 138 +- .../factions/util/RelationUtil.java | 152 +- .../factions/util/SpiralTask.java | 296 +- .../massivecraft/factions/util/UtilFly.java | 136 +- .../factions/util/VisualizeUtil.java | 94 +- .../factions/util/WarmUpUtil.java | 56 +- .../massivecraft/factions/util/XMaterial.java | 6 +- .../factions/zcore/CommandVisibility.java | 6 +- .../massivecraft/factions/zcore/MCommand.java | 918 ++--- .../massivecraft/factions/zcore/MPlugin.java | 506 +-- .../zcore/MPluginSecretPlayerListener.java | 52 +- .../zcore/fperms/DefaultPermissions.java | 8 + .../zcore/fperms/PermissableAction.java | 1 + .../factions/zcore/persist/MemoryFaction.java | 18 + .../massivecraft/factions/zcore/util/TL.java | 2271 ++++++------ src/main/resources/config.yml | 4 +- src/main/resources/plugin.yml | 2 + 199 files changed, 15584 insertions(+), 15463 deletions(-) create mode 100644 src/main/java/com/massivecraft/factions/cmd/CmdCheck.java create mode 100644 src/main/java/com/massivecraft/factions/util/CheckWallTask.java diff --git a/src/main/java/com/massivecraft/factions/Board.java b/src/main/java/com/massivecraft/factions/Board.java index 9fda53df..bfd3b94d 100644 --- a/src/main/java/com/massivecraft/factions/Board.java +++ b/src/main/java/com/massivecraft/factions/Board.java @@ -9,82 +9,82 @@ import java.util.Set; public abstract class Board { - protected static Board instance = getBoardImpl(); + protected static Board instance = getBoardImpl(); - private static Board getBoardImpl() { - switch (Conf.backEnd) { - case JSON: - return new JSONBoard(); - } - return null; - } + private static Board getBoardImpl() { + switch (Conf.backEnd) { + case JSON: + return new JSONBoard(); + } + return null; + } - public static Board getInstance() { - return instance; - } + public static Board getInstance() { + return instance; + } - //----------------------------------------------// - // Get and Set - //----------------------------------------------// - public abstract String getIdAt(FLocation flocation); + //----------------------------------------------// + // Get and Set + //----------------------------------------------// + public abstract String getIdAt(FLocation flocation); - public abstract Faction getFactionAt(FLocation flocation); + public abstract Faction getFactionAt(FLocation flocation); - public abstract void setIdAt(String id, FLocation flocation); + public abstract void setIdAt(String id, FLocation flocation); - public abstract void setFactionAt(Faction faction, FLocation flocation); + public abstract void setFactionAt(Faction faction, FLocation flocation); - public abstract void removeAt(FLocation flocation); + public abstract void removeAt(FLocation flocation); - public abstract Set getAllClaims(String factionId); + public abstract Set getAllClaims(String factionId); - public abstract Set getAllClaims(Faction faction); + public abstract Set getAllClaims(Faction faction); - // not to be confused with claims, ownership referring to further member-specific ownership of a claim - public abstract void clearOwnershipAt(FLocation flocation); + // not to be confused with claims, ownership referring to further member-specific ownership of a claim + public abstract void clearOwnershipAt(FLocation flocation); - public abstract void unclaimAll(String factionId); + public abstract void unclaimAll(String factionId); - public abstract void unclaimAllInWorld(String factionId, World world); + public abstract void unclaimAllInWorld(String factionId, World world); - // Is this coord NOT completely surrounded by coords claimed by the same faction? - // Simpler: Is there any nearby coord with a faction other than the faction here? - public abstract boolean isBorderLocation(FLocation flocation); + // Is this coord NOT completely surrounded by coords claimed by the same faction? + // Simpler: Is there any nearby coord with a faction other than the faction here? + public abstract boolean isBorderLocation(FLocation flocation); - // Is this coord connected to any coord claimed by the specified faction? - public abstract boolean isConnectedLocation(FLocation flocation, Faction faction); + // Is this coord connected to any coord claimed by the specified faction? + public abstract boolean isConnectedLocation(FLocation flocation, Faction faction); - public abstract boolean hasFactionWithin(FLocation flocation, Faction faction, int radius); + public abstract boolean hasFactionWithin(FLocation flocation, Faction faction, int radius); - //----------------------------------------------// - // Cleaner. Remove orphaned foreign keys - //----------------------------------------------// + //----------------------------------------------// + // Cleaner. Remove orphaned foreign keys + //----------------------------------------------// - public abstract void clean(); + public abstract void clean(); - //----------------------------------------------// - // Coord count - //----------------------------------------------// + //----------------------------------------------// + // Coord count + //----------------------------------------------// - public abstract int getFactionCoordCount(String factionId); + public abstract int getFactionCoordCount(String factionId); - public abstract int getFactionCoordCount(Faction faction); + public abstract int getFactionCoordCount(Faction faction); - public abstract int getFactionCoordCountInWorld(Faction faction, String worldName); + public abstract int getFactionCoordCountInWorld(Faction faction, String worldName); - //----------------------------------------------// - // Map generation - //----------------------------------------------// + //----------------------------------------------// + // Map generation + //----------------------------------------------// - /* - * The map is relative to a coord and a faction north is in the direction of decreasing x east is in the direction - * of decreasing z - */ - public abstract List getMap(FPlayer fPlayer, FLocation flocation, double inDegrees); + /* + * The map is relative to a coord and a faction north is in the direction of decreasing x east is in the direction + * of decreasing z + */ + public abstract List getMap(FPlayer fPlayer, FLocation flocation, double inDegrees); - public abstract void forceSave(); + public abstract void forceSave(); - public abstract void forceSave(boolean sync); + public abstract void forceSave(boolean sync); - public abstract boolean load(); + public abstract boolean load(); } diff --git a/src/main/java/com/massivecraft/factions/Conf.java b/src/main/java/com/massivecraft/factions/Conf.java index 32f00e78..c7a78c2a 100644 --- a/src/main/java/com/massivecraft/factions/Conf.java +++ b/src/main/java/com/massivecraft/factions/Conf.java @@ -4,7 +4,6 @@ import com.google.common.collect.ImmutableMap; import com.massivecraft.factions.integration.dynmap.DynmapStyle; import com.massivecraft.factions.util.XMaterial; import com.massivecraft.factions.zcore.fperms.DefaultPermissions; -import com.massivecraft.factions.zcore.fperms.Permissable; import com.massivecraft.factions.zcore.fperms.PermissableAction; import org.bukkit.ChatColor; import org.bukkit.Material; @@ -14,429 +13,431 @@ import java.util.*; public class Conf { - // Region Style - public static final transient String DYNMAP_STYLE_LINE_COLOR = "#00FF00"; - public static final transient double DYNMAP_STYLE_LINE_OPACITY = 0.8D; - public static final transient int DYNMAP_STYLE_LINE_WEIGHT = 3; - public static final transient String DYNMAP_STYLE_FILL_COLOR = "#00FF00"; - public static final transient double DYNMAP_STYLE_FILL_OPACITY = 0.35D; - public static final transient String DYNMAP_STYLE_HOME_MARKER = "greenflag"; - public static final transient boolean DYNMAP_STYLE_BOOST = false; - public static List baseCommandAliases = new ArrayList<>(); - public static boolean allowNoSlashCommand = true; + // Region Style + public static final transient String DYNMAP_STYLE_LINE_COLOR = "#00FF00"; + public static final transient double DYNMAP_STYLE_LINE_OPACITY = 0.8D; + public static final transient int DYNMAP_STYLE_LINE_WEIGHT = 3; + public static final transient String DYNMAP_STYLE_FILL_COLOR = "#00FF00"; + public static final transient double DYNMAP_STYLE_FILL_OPACITY = 0.35D; + public static final transient String DYNMAP_STYLE_HOME_MARKER = "greenflag"; + public static final transient boolean DYNMAP_STYLE_BOOST = false; + public static List baseCommandAliases = new ArrayList<>(); + public static boolean allowNoSlashCommand = true; - // Colors - public static ChatColor colorMember = ChatColor.GREEN; - public static ChatColor colorAlly = ChatColor.LIGHT_PURPLE; - public static ChatColor colorTruce = ChatColor.DARK_PURPLE; - public static ChatColor colorNeutral = ChatColor.WHITE; - public static ChatColor colorEnemy = ChatColor.RED; - public static ChatColor colorPeaceful = ChatColor.GOLD; - public static ChatColor colorWilderness = ChatColor.GRAY; - public static ChatColor colorSafezone = ChatColor.GOLD; - public static ChatColor colorWar = ChatColor.DARK_RED; - // Power - public static double powerPlayerMax = 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 - public static boolean powerRegenOffline = false; // does player power regenerate even while they're offline? - public static double powerOfflineLossPerDay = 0.0; // players will lose this much power per day offline - public static double powerOfflineLossLimit = 0.0; // players will no longer lose power from being offline once their power drops to this amount or less - public static double powerFactionMax = 0.0; // if greater than 0, the cap on how much power a faction can have (additional power from players beyond that will act as a "buffer" of sorts) - public static String prefixLeader = "***"; - public static String prefixCoLeader = "**"; - public static String prefixMod = "*"; - public static String prefixRecruit = "-"; - public static String prefixNormal = "+"; - public static int factionTagLengthMin = 3; - public static int factionTagLengthMax = 10; - public static boolean factionTagForceUpperCase = false; - public static boolean newFactionsDefaultOpen = false; - // when faction membership hits this limit, players will no longer be able to join using /f join; default is 0, no limit - public static int factionMemberLimit = 0; - public static int factionAltMemberLimit = 0; - // what faction ID to start new players in when they first join the server; default is 0, "no faction" - public static String newPlayerStartingFactionID = "0"; - public static boolean showMapFactionKey = true; - public static boolean showNeutralFactionsOnMap = true; - public static boolean showEnemyFactionsOnMap = true; - public static boolean showTrucesFactionsOnMap = true; - // Disallow joining/leaving/kicking while power is negative - public static boolean canLeaveWithNegativePower = true; - // Configuration for faction-only chat - public static boolean factionOnlyChat = true; - // Configuration on the Faction tag in chat messages. - public static boolean chatTagEnabled = true; - public static transient boolean chatTagHandledByAnotherPlugin = false; - public static boolean chatTagRelationColored = true; - public static String chatTagReplaceString = "[FACTION]"; - public static String chatTagInsertAfterString = ""; - public static String chatTagInsertBeforeString = ""; - public static int chatTagInsertIndex = 0; - public static boolean chatTagPadBefore = false; - public static boolean chatTagPadAfter = true; - public static String chatTagFormat = "%s" + ChatColor.WHITE; - public static String factionChatFormat = "%s:" + ChatColor.WHITE + " %s"; - public static String allianceChatFormat = ChatColor.LIGHT_PURPLE + "%s:" + ChatColor.WHITE + " %s"; - public static String truceChatFormat = ChatColor.DARK_PURPLE + "%s:" + ChatColor.WHITE + " %s"; - public static String modChatFormat = ChatColor.RED + "%s:" + ChatColor.WHITE + " %s"; - public static int stealthFlyCheckRadius = 32; - public static int factionBufferSize = 20; - public static boolean removeHomesOnLeave = true; - public static boolean gracePeriod = false; - public static boolean noEnderpearlsInFly = false; - public static boolean broadcastDescriptionChanges = false; - public static boolean broadcastTagChanges = false; - public static double saveToFileEveryXMinutes = 30.0; - public static double autoLeaveAfterDaysOfInactivity = 10.0; - public static double autoLeaveRoutineRunsEveryXMinutes = 5.0; - public static int autoLeaveRoutineMaxMillisecondsPerTick = 5; // 1 server tick is roughly 50ms, so default max 10% of a tick - public static boolean removePlayerDataWhenBanned = true; - public static boolean autoLeaveDeleteFPlayerData = true; // Let them just remove player from Faction. - public static boolean worldGuardChecking = false; - public static boolean worldGuardBuildPriority = false; - // server logging options - public static boolean logFactionCreate = true; - public static boolean logFactionDisband = true; - public static boolean logFactionJoin = true; - public static boolean logFactionKick = true; - public static boolean logFactionLeave = true; - public static boolean logLandClaims = true; - public static boolean logLandUnclaims = true; - public static boolean logMoneyTransactions = true; - public static boolean logPlayerCommands = true; - // prevent some potential exploits - public static boolean handleExploitObsidianGenerators = true; - public static boolean handleExploitEnderPearlClipping = true; - public static boolean handleExploitInteractionSpam = true; - public static boolean handleExploitTNTWaterlog = false; - public static boolean handleExploitLiquidFlow = false; - public static boolean homesEnabled = true; - public static boolean homesMustBeInClaimedTerritory = true; - public static boolean homesTeleportToOnDeath = true; - public static boolean homesRespawnFromNoPowerLossWorlds = true; - public static boolean homesTeleportCommandEnabled = true; - public static boolean homesTeleportCommandEssentialsIntegration = true; - public static boolean homesTeleportCommandSmokeEffectEnabled = true; - public static float homesTeleportCommandSmokeEffectThickness = 3f; - public static boolean homesTeleportAllowedFromEnemyTerritory = true; - public static boolean homesTeleportAllowedFromDifferentWorld = true; - public static double homesTeleportAllowedEnemyDistance = 32.0; - public static boolean homesTeleportIgnoreEnemiesIfInOwnTerritory = true; - public static boolean disablePVPBetweenNeutralFactions = false; - public static boolean disablePVPForFactionlessPlayers = false; - public static boolean enablePVPAgainstFactionlessInAttackersLand = false; - public static int noPVPDamageToOthersForXSecondsAfterLogin = 3; - public static boolean peacefulTerritoryDisablePVP = true; - public static boolean peacefulTerritoryDisableMonsters = false; - public static boolean peacefulTerritoryDisableBoom = false; - public static boolean peacefulMembersDisablePowerLoss = true; - public static boolean permanentFactionsDisableLeaderPromotion = false; - public static boolean claimsMustBeConnected = false; - public static boolean claimsCanBeUnconnectedIfOwnedByOtherFaction = true; - public static int claimsRequireMinFactionMembers = 1; - public static int claimedLandsMax = 0; - public static int lineClaimLimit = 5; - // if someone is doing a radius claim and the process fails to claim land this many times in a row, it will exit - public static int radiusClaimFailureLimit = 9; - public static double considerFactionsReallyOfflineAfterXMinutes = 0.0; - public static int actionDeniedPainAmount = 1; - // commands which will be prevented if the player is a member of a permanent faction - public static Set permanentFactionMemberDenyCommands = new LinkedHashSet<>(); - // commands which will be prevented when in claimed territory of another faction - public static Set territoryNeutralDenyCommands = new LinkedHashSet<>(); - public static Set territoryEnemyDenyCommands = new LinkedHashSet<>(); - public static Set territoryAllyDenyCommands = new LinkedHashSet<>(); - public static Set warzoneDenyCommands = new LinkedHashSet<>(); - public static Set wildernessDenyCommands = new LinkedHashSet<>(); - public static boolean territoryDenyBuild = true; - public static boolean territoryDenyBuildWhenOffline = true; - public static boolean territoryPainBuild = false; - public static boolean territoryPainBuildWhenOffline = false; - public static boolean territoryDenyUseage = true; - public static boolean territoryEnemyDenyBuild = true; - public static boolean territoryEnemyDenyBuildWhenOffline = true; - public static boolean territoryEnemyPainBuild = false; - public static boolean territoryEnemyPainBuildWhenOffline = false; - public static boolean territoryEnemyDenyUseage = true; - public static boolean territoryAllyDenyBuild = true; - public static boolean territoryAllyDenyBuildWhenOffline = true; - public static boolean territoryAllyPainBuild = false; - public static boolean territoryAllyPainBuildWhenOffline = false; - public static boolean territoryAllyDenyUseage = true; - public static boolean territoryTruceDenyBuild = true; - public static boolean territoryTruceDenyBuildWhenOffline = true; - public static boolean territoryTrucePainBuild = false; - public static boolean territoryTrucePainBuildWhenOffline = false; - public static boolean territoryTruceDenyUseage = true; - public static boolean territoryBlockCreepers = false; - public static boolean territoryBlockCreepersWhenOffline = false; - public static boolean territoryBlockFireballs = false; - public static boolean territoryBlockFireballsWhenOffline = false; - public static boolean territoryBlockTNT = false; - public static boolean territoryBlockTNTWhenOffline = false; - public static boolean territoryDenyEndermanBlocks = true; - public static boolean territoryDenyEndermanBlocksWhenOffline = true; - public static boolean safeZoneDenyBuild = true; - public static boolean safeZoneDenyUseage = true; - public static boolean safeZoneBlockTNT = true; - public static boolean safeZonePreventAllDamageToPlayers = false; - public static boolean safeZoneDenyEndermanBlocks = true; - public static boolean warZoneDenyBuild = true; - public static boolean warZoneDenyUseage = true; - public static boolean warZoneBlockCreepers = false; - public static boolean warZoneBlockFireballs = false; - public static boolean warZoneBlockTNT = true; - public static boolean warZonePowerLoss = true; - public static boolean warZoneFriendlyFire = false; - public static boolean warZoneDenyEndermanBlocks = true; - public static boolean wildernessDenyBuild = false; - public static boolean wildernessDenyUseage = false; - public static boolean wildernessBlockCreepers = false; - public static boolean wildernessBlockFireballs = false; - public static boolean wildernessBlockTNT = false; - public static boolean wildernessPowerLoss = true; - public static boolean wildernessDenyEndermanBlocks = false; - // for claimed areas where further faction-member ownership can be defined - public static boolean ownedAreasEnabled = true; - public static int ownedAreasLimitPerFaction = 0; - public static boolean ownedAreasModeratorsCanSet = false; - public static boolean ownedAreaModeratorsBypass = true; - public static boolean ownedAreaDenyBuild = true; - public static boolean ownedAreaPainBuild = false; - public static boolean ownedMessageOnBorder = true; - public static boolean ownedMessageInsideTerritory = true; - public static boolean ownedMessageByChunk = false; - public static boolean pistonProtectionThroughDenyBuild = true; - public static Set territoryProtectedMaterials = EnumSet.noneOf(Material.class); - public static Set territoryDenyUseageMaterials = EnumSet.noneOf(Material.class); - public static Set territoryProtectedMaterialsWhenOffline = EnumSet.noneOf(Material.class); - public static Set territoryDenyUseageMaterialsWhenOffline = EnumSet.noneOf(Material.class); - public static transient Set safeZoneNerfedCreatureTypes = EnumSet.noneOf(EntityType.class); - /// - /// This defines a set of materials which should always be allowed to use, regardless of factions permissions. - /// Useful for HCF features. - /// - public static Set territoryBypassProtectedMaterials = EnumSet.noneOf(Material.class); + // Colors + public static ChatColor colorMember = ChatColor.GREEN; + public static ChatColor colorAlly = ChatColor.LIGHT_PURPLE; + public static ChatColor colorTruce = ChatColor.DARK_PURPLE; + public static ChatColor colorNeutral = ChatColor.WHITE; + public static ChatColor colorEnemy = ChatColor.RED; + public static ChatColor colorPeaceful = ChatColor.GOLD; + public static ChatColor colorWilderness = ChatColor.GRAY; + public static ChatColor colorSafezone = ChatColor.GOLD; + public static ChatColor colorWar = ChatColor.DARK_RED; + // Power + public static double powerPlayerMax = 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 + public static boolean powerRegenOffline = false; // does player power regenerate even while they're offline? + public static double powerOfflineLossPerDay = 0.0; // players will lose this much power per day offline + public static double powerOfflineLossLimit = 0.0; // players will no longer lose power from being offline once their power drops to this amount or less + public static double powerFactionMax = 0.0; // if greater than 0, the cap on how much power a faction can have (additional power from players beyond that will act as a "buffer" of sorts) + public static String prefixLeader = "***"; + public static String prefixCoLeader = "**"; + public static String prefixMod = "*"; + public static String prefixRecruit = "-"; + public static String prefixNormal = "+"; + public static int factionTagLengthMin = 3; + public static int factionTagLengthMax = 10; + public static boolean factionTagForceUpperCase = false; + public static boolean newFactionsDefaultOpen = false; + // when faction membership hits this limit, players will no longer be able to join using /f join; default is 0, no limit + public static int factionMemberLimit = 0; + public static int factionAltMemberLimit = 0; + // what faction ID to start new players in when they first join the server; default is 0, "no faction" + public static String newPlayerStartingFactionID = "0"; + public static boolean showMapFactionKey = true; + public static boolean showNeutralFactionsOnMap = true; + public static boolean showEnemyFactionsOnMap = true; + public static boolean showTrucesFactionsOnMap = true; + // Disallow joining/leaving/kicking while power is negative + public static boolean canLeaveWithNegativePower = true; + // Configuration for faction-only chat + public static boolean factionOnlyChat = true; + // Configuration on the Faction tag in chat messages. + public static boolean chatTagEnabled = true; + public static transient boolean chatTagHandledByAnotherPlugin = false; + public static boolean chatTagRelationColored = true; + public static String chatTagReplaceString = "[FACTION]"; + public static String chatTagInsertAfterString = ""; + public static String chatTagInsertBeforeString = ""; + public static int chatTagInsertIndex = 0; + public static boolean chatTagPadBefore = false; + public static boolean chatTagPadAfter = true; + public static String chatTagFormat = "%s" + ChatColor.WHITE; + public static String factionChatFormat = "%s:" + ChatColor.WHITE + " %s"; + public static String allianceChatFormat = ChatColor.LIGHT_PURPLE + "%s:" + ChatColor.WHITE + " %s"; + public static String truceChatFormat = ChatColor.DARK_PURPLE + "%s:" + ChatColor.WHITE + " %s"; + public static String modChatFormat = ChatColor.RED + "%s:" + ChatColor.WHITE + " %s"; + public static int stealthFlyCheckRadius = 32; + public static int factionBufferSize = 20; + public static boolean removeHomesOnLeave = true; + public static boolean useCheckSystem = true; + public static boolean gracePeriod = false; + public static boolean noEnderpearlsInFly = false; + public static boolean broadcastDescriptionChanges = false; + public static boolean broadcastTagChanges = false; + public static double saveToFileEveryXMinutes = 30.0; + public static double autoLeaveAfterDaysOfInactivity = 10.0; + public static double autoLeaveRoutineRunsEveryXMinutes = 5.0; + public static int autoLeaveRoutineMaxMillisecondsPerTick = 5; // 1 server tick is roughly 50ms, so default max 10% of a tick + public static boolean removePlayerDataWhenBanned = true; + public static boolean autoLeaveDeleteFPlayerData = true; // Let them just remove player from Faction. + public static boolean worldGuardChecking = false; + public static boolean worldGuardBuildPriority = false; + // server logging options + public static boolean logFactionCreate = true; + public static boolean logFactionDisband = true; + public static boolean logFactionJoin = true; + public static boolean logFactionKick = true; + public static boolean logFactionLeave = true; + public static boolean logLandClaims = true; + public static boolean logLandUnclaims = true; + public static boolean logMoneyTransactions = true; + public static boolean logPlayerCommands = true; + // prevent some potential exploits + public static boolean handleExploitObsidianGenerators = true; + public static boolean handleExploitEnderPearlClipping = true; + public static boolean handleExploitInteractionSpam = true; + public static boolean handleExploitTNTWaterlog = false; + public static boolean handleExploitLiquidFlow = false; + public static boolean homesEnabled = true; + public static boolean homesMustBeInClaimedTerritory = true; + public static boolean homesTeleportToOnDeath = true; + public static boolean homesRespawnFromNoPowerLossWorlds = true; + public static boolean homesTeleportCommandEnabled = true; + public static boolean homesTeleportCommandEssentialsIntegration = true; + public static boolean homesTeleportCommandSmokeEffectEnabled = true; + public static float homesTeleportCommandSmokeEffectThickness = 3f; + public static boolean homesTeleportAllowedFromEnemyTerritory = true; + public static boolean homesTeleportAllowedFromDifferentWorld = true; + public static double homesTeleportAllowedEnemyDistance = 32.0; + public static boolean homesTeleportIgnoreEnemiesIfInOwnTerritory = true; + public static boolean disablePVPBetweenNeutralFactions = false; + public static boolean disablePVPForFactionlessPlayers = false; + public static boolean enablePVPAgainstFactionlessInAttackersLand = false; + public static int noPVPDamageToOthersForXSecondsAfterLogin = 3; + public static boolean peacefulTerritoryDisablePVP = true; + public static boolean peacefulTerritoryDisableMonsters = false; + public static boolean peacefulTerritoryDisableBoom = false; + public static boolean peacefulMembersDisablePowerLoss = true; + public static boolean permanentFactionsDisableLeaderPromotion = false; + public static boolean claimsMustBeConnected = false; + public static boolean claimsCanBeUnconnectedIfOwnedByOtherFaction = true; + public static int claimsRequireMinFactionMembers = 1; + public static int claimedLandsMax = 0; + public static int lineClaimLimit = 5; + // if someone is doing a radius claim and the process fails to claim land this many times in a row, it will exit + public static int radiusClaimFailureLimit = 9; + public static double considerFactionsReallyOfflineAfterXMinutes = 0.0; + public static int actionDeniedPainAmount = 1; + // commands which will be prevented if the player is a member of a permanent faction + public static Set permanentFactionMemberDenyCommands = new LinkedHashSet<>(); + // commands which will be prevented when in claimed territory of another faction + public static Set territoryNeutralDenyCommands = new LinkedHashSet<>(); + public static Set territoryEnemyDenyCommands = new LinkedHashSet<>(); + public static Set territoryAllyDenyCommands = new LinkedHashSet<>(); + public static Set warzoneDenyCommands = new LinkedHashSet<>(); + public static Set wildernessDenyCommands = new LinkedHashSet<>(); + public static boolean territoryDenyBuild = true; + public static boolean territoryDenyBuildWhenOffline = true; + public static boolean territoryPainBuild = false; + public static boolean territoryPainBuildWhenOffline = false; + public static boolean territoryDenyUseage = true; + public static boolean territoryEnemyDenyBuild = true; + public static boolean territoryEnemyDenyBuildWhenOffline = true; + public static boolean territoryEnemyPainBuild = false; + public static boolean territoryEnemyPainBuildWhenOffline = false; + public static boolean territoryEnemyDenyUseage = true; + public static boolean territoryAllyDenyBuild = true; + public static boolean territoryAllyDenyBuildWhenOffline = true; + public static boolean territoryAllyPainBuild = false; + public static boolean territoryAllyPainBuildWhenOffline = false; + public static boolean territoryAllyDenyUseage = true; + public static boolean territoryTruceDenyBuild = true; + public static boolean territoryTruceDenyBuildWhenOffline = true; + public static boolean territoryTrucePainBuild = false; + public static boolean territoryTrucePainBuildWhenOffline = false; + public static boolean territoryTruceDenyUseage = true; + public static boolean territoryBlockCreepers = false; + public static boolean territoryBlockCreepersWhenOffline = false; + public static boolean territoryBlockFireballs = false; + public static boolean territoryBlockFireballsWhenOffline = false; + public static boolean territoryBlockTNT = false; + public static boolean territoryBlockTNTWhenOffline = false; + public static boolean territoryDenyEndermanBlocks = true; + public static boolean territoryDenyEndermanBlocksWhenOffline = true; + public static boolean safeZoneDenyBuild = true; + public static boolean safeZoneDenyUseage = true; + public static boolean safeZoneBlockTNT = true; + public static boolean safeZonePreventAllDamageToPlayers = false; + public static boolean safeZoneDenyEndermanBlocks = true; + public static boolean warZoneDenyBuild = true; + public static boolean warZoneDenyUseage = true; + public static boolean warZoneBlockCreepers = false; + public static boolean warZoneBlockFireballs = false; + public static boolean warZoneBlockTNT = true; + public static boolean warZonePowerLoss = true; + public static boolean warZoneFriendlyFire = false; + public static boolean warZoneDenyEndermanBlocks = true; + public static boolean wildernessDenyBuild = false; + public static boolean wildernessDenyUseage = false; + public static boolean wildernessBlockCreepers = false; + public static boolean wildernessBlockFireballs = false; + public static boolean wildernessBlockTNT = false; + public static boolean wildernessPowerLoss = true; + public static boolean wildernessDenyEndermanBlocks = false; + // for claimed areas where further faction-member ownership can be defined + public static boolean ownedAreasEnabled = true; + public static int ownedAreasLimitPerFaction = 0; + public static boolean ownedAreasModeratorsCanSet = false; + public static boolean ownedAreaModeratorsBypass = true; + public static boolean ownedAreaDenyBuild = true; + public static boolean ownedAreaPainBuild = false; + public static boolean ownedMessageOnBorder = true; + public static boolean ownedMessageInsideTerritory = true; + public static boolean ownedMessageByChunk = false; + public static boolean pistonProtectionThroughDenyBuild = true; + public static Set territoryProtectedMaterials = EnumSet.noneOf(Material.class); + public static Set territoryDenyUseageMaterials = EnumSet.noneOf(Material.class); + public static Set territoryProtectedMaterialsWhenOffline = EnumSet.noneOf(Material.class); + public static Set territoryDenyUseageMaterialsWhenOffline = EnumSet.noneOf(Material.class); + public static transient Set safeZoneNerfedCreatureTypes = EnumSet.noneOf(EntityType.class); + /// + /// This defines a set of materials which should always be allowed to use, regardless of factions permissions. + /// Useful for HCF features. + /// + public static Set territoryBypassProtectedMaterials = EnumSet.noneOf(Material.class); - // Economy settings - public static boolean econEnabled = false; - public static String econUniverseAccount = ""; - public static double econCostClaimWilderness = 30.0; - public static double econCostClaimFromFactionBonus = 30.0; - public static double econOverclaimRewardMultiplier = 0.0; - public static double econClaimAdditionalMultiplier = 0.5; - public static double econClaimRefundMultiplier = 0.7; - public static double econClaimUnconnectedFee = 0.0; - public static double econCostCreate = 100.0; - public static double econCostOwner = 15.0; - public static double econCostSethome = 30.0; - public static double econCostJoin = 0.0; - public static double econCostLeave = 0.0; - public static double econCostKick = 0.0; - public static double econCostInvite = 0.0; - public static double econCostHome = 0.0; - public static double econCostTag = 0.0; - public static double econCostDesc = 0.0; - public static double econCostTitle = 0.0; - public static double econCostList = 0.0; - public static double econCostMap = 0.0; - public static double econCostPower = 0.0; - public static double econCostShow = 0.0; - public static double econFactionStartingBalance = 0.0; - public static double econDenyWithdrawWhenMinutesAgeLessThan = 2880; // 2 days - public static String dateFormat = "HH:mm dd/MM/yyyy"; + // Economy settings + public static boolean econEnabled = false; + public static String econUniverseAccount = ""; + public static double econCostClaimWilderness = 30.0; + public static double econCostClaimFromFactionBonus = 30.0; + public static double econOverclaimRewardMultiplier = 0.0; + public static double econClaimAdditionalMultiplier = 0.5; + public static double econClaimRefundMultiplier = 0.7; + public static double econClaimUnconnectedFee = 0.0; + public static double econCostCreate = 100.0; + public static double econCostOwner = 15.0; + public static double econCostSethome = 30.0; + public static double econCostJoin = 0.0; + public static double econCostLeave = 0.0; + public static double econCostKick = 0.0; + public static double econCostInvite = 0.0; + public static double econCostHome = 0.0; + public static double econCostTag = 0.0; + public static double econCostDesc = 0.0; + public static double econCostTitle = 0.0; + public static double econCostList = 0.0; + public static double econCostMap = 0.0; + public static double econCostPower = 0.0; + public static double econCostShow = 0.0; + public static double econFactionStartingBalance = 0.0; + public static double econDenyWithdrawWhenMinutesAgeLessThan = 2880; // 2 days + public static String dateFormat = "HH:mm dd/MM/yyyy"; - // -------------------------------------------- // - // INTEGRATION: DYNMAP - // -------------------------------------------- // - public static double econCostStuck = 0.0; - public static double econCostOpen = 0.0; - public static double econCostAlly = 0.0; - public static double econCostTruce = 0.0; - public static double econCostEnemy = 0.0; - public static double econCostNeutral = 0.0; - public static double econCostNoBoom = 0.0; - // Should the dynmap intagration be used? - public static boolean dynmapUse = false; - // Name of the Factions layer - public static String dynmapLayerName = "Factions"; - // Should the layer be visible per default - public static boolean dynmapLayerVisible = true; - // Ordering priority in layer menu (low goes before high - default is 0) - public static int dynmapLayerPriority = 2; - // (optional) set minimum zoom level before layer is visible (0 = default, always visible) - public static int dynmapLayerMinimumZoom = 0; - // Format for popup - substitute values for macros - public static String dynmapDescription = - "
\n" - + "%name%
\n" - + "%description%
" - + "
\n" - + "Leader: %players.leader%
\n" - + "Admins: %players.admins.count%
\n" - + "Moderators: %players.moderators.count%
\n" - + "Members: %players.normals.count%
\n" - + "TOTAL: %players.count%
\n" - + "
\n" - + "Bank: %money%
\n" - + "
\n" - + "
"; - // Enable the %money% macro. Only do this if you know your economy manager is thread-safe. - public static boolean dynmapDescriptionMoney = false; - // Allow players in faction to see one another on Dynmap (only relevant if Dynmap has 'player-info-protected' enabled) - public static boolean dynmapVisibilityByFaction = true; - // Optional setting to limit which regions to show. - // If empty all regions are shown. - // Specify Faction either by name or UUID. - // To show all regions on a given world, add 'world:' to the list. - public static Set dynmapVisibleFactions = new HashSet<>(); - // Optional setting to hide specific Factions. - // Specify Faction either by name or UUID. - // To hide all regions on a given world, add 'world:' to the list. - public static Set dynmapHiddenFactions = new HashSet<>(); - public static DynmapStyle dynmapDefaultStyle = new DynmapStyle() - .setStrokeColor(DYNMAP_STYLE_LINE_COLOR) - .setLineOpacity(DYNMAP_STYLE_LINE_OPACITY) - .setLineWeight(DYNMAP_STYLE_LINE_WEIGHT) - .setFillColor(DYNMAP_STYLE_FILL_COLOR) - .setFillOpacity(DYNMAP_STYLE_FILL_OPACITY) - .setHomeMarker(DYNMAP_STYLE_HOME_MARKER) - .setBoost(DYNMAP_STYLE_BOOST); + // -------------------------------------------- // + // INTEGRATION: DYNMAP + // -------------------------------------------- // + public static double econCostStuck = 0.0; + public static double econCostOpen = 0.0; + public static double econCostAlly = 0.0; + public static double econCostTruce = 0.0; + public static double econCostEnemy = 0.0; + public static double econCostNeutral = 0.0; + public static double econCostNoBoom = 0.0; + // Should the dynmap intagration be used? + public static boolean dynmapUse = false; + // Name of the Factions layer + public static String dynmapLayerName = "Factions"; + // Should the layer be visible per default + public static boolean dynmapLayerVisible = true; + // Ordering priority in layer menu (low goes before high - default is 0) + public static int dynmapLayerPriority = 2; + // (optional) set minimum zoom level before layer is visible (0 = default, always visible) + public static int dynmapLayerMinimumZoom = 0; + // Format for popup - substitute values for macros + public static String dynmapDescription = + "
\n" + + "%name%
\n" + + "%description%
" + + "
\n" + + "Leader: %players.leader%
\n" + + "Admins: %players.admins.count%
\n" + + "Moderators: %players.moderators.count%
\n" + + "Members: %players.normals.count%
\n" + + "TOTAL: %players.count%
\n" + + "
\n" + + "Bank: %money%
\n" + + "
\n" + + "
"; + // Enable the %money% macro. Only do this if you know your economy manager is thread-safe. + public static boolean dynmapDescriptionMoney = false; + // Allow players in faction to see one another on Dynmap (only relevant if Dynmap has 'player-info-protected' enabled) + public static boolean dynmapVisibilityByFaction = true; + // Optional setting to limit which regions to show. + // If empty all regions are shown. + // Specify Faction either by name or UUID. + // To show all regions on a given world, add 'world:' to the list. + public static Set dynmapVisibleFactions = new HashSet<>(); + // Optional setting to hide specific Factions. + // Specify Faction either by name or UUID. + // To hide all regions on a given world, add 'world:' to the list. + public static Set dynmapHiddenFactions = new HashSet<>(); + public static DynmapStyle dynmapDefaultStyle = new DynmapStyle() + .setStrokeColor(DYNMAP_STYLE_LINE_COLOR) + .setLineOpacity(DYNMAP_STYLE_LINE_OPACITY) + .setLineWeight(DYNMAP_STYLE_LINE_WEIGHT) + .setFillColor(DYNMAP_STYLE_FILL_COLOR) + .setFillOpacity(DYNMAP_STYLE_FILL_OPACITY) + .setHomeMarker(DYNMAP_STYLE_HOME_MARKER) + .setBoost(DYNMAP_STYLE_BOOST); - // Optional per Faction style overrides. Any defined replace those in dynmapDefaultStyle. - // Specify Faction either by name or UUID. - public static Map dynmapFactionStyles = ImmutableMap.of( - "SafeZone", new DynmapStyle().setStrokeColor("#FF00FF").setFillColor("#FF00FF").setBoost(false), - "WarZone", new DynmapStyle().setStrokeColor("#FF0000").setFillColor("#FF0000").setBoost(false) - ); + // Optional per Faction style overrides. Any defined replace those in dynmapDefaultStyle. + // Specify Faction either by name or UUID. + public static Map dynmapFactionStyles = ImmutableMap.of( + "SafeZone", new DynmapStyle().setStrokeColor("#FF00FF").setFillColor("#FF00FF").setBoost(false), + "WarZone", new DynmapStyle().setStrokeColor("#FF0000").setFillColor("#FF0000").setBoost(false) + ); - //Faction banks, to pay for land claiming and other costs instead of individuals paying for them - public static boolean bankEnabled = true; - public static boolean bankMembersCanWithdraw = false; //Have to be at least moderator to withdraw or pay money to another faction - public static boolean bankFactionPaysCosts = true; //The faction pays for faction command costs, such as sethome - public static boolean bankFactionPaysLandCosts = true; //The faction pays for land claiming costs. + //Faction banks, to pay for land claiming and other costs instead of individuals paying for them + public static boolean bankEnabled = true; + public static boolean bankMembersCanWithdraw = false; //Have to be at least moderator to withdraw or pay money to another faction + public static boolean bankFactionPaysCosts = true; //The faction pays for faction command costs, such as sethome + public static boolean bankFactionPaysLandCosts = true; //The faction pays for land claiming costs. - // mainly for other plugins/mods that use a fake player to take actions, which shouldn't be subject to our protections - public static Set playersWhoBypassAllProtection = new LinkedHashSet<>(); + // mainly for other plugins/mods that use a fake player to take actions, which shouldn't be subject to our protections + public static Set playersWhoBypassAllProtection = new LinkedHashSet<>(); - public static boolean useWorldConfigurationsAsWhitelist = false; - public static Set worldsNoClaiming = new LinkedHashSet<>(); - public static Set worldsNoPowerLoss = new LinkedHashSet<>(); - public static Set worldsIgnorePvP = new LinkedHashSet<>(); - public static Set worldsNoWildernessProtection = new LinkedHashSet<>(); + public static boolean useWorldConfigurationsAsWhitelist = false; + public static Set worldsNoClaiming = new LinkedHashSet<>(); + public static Set worldsNoPowerLoss = new LinkedHashSet<>(); + public static Set worldsIgnorePvP = new LinkedHashSet<>(); + public static Set worldsNoWildernessProtection = new LinkedHashSet<>(); - // faction- - public static int defaultMaxVaults = 0; - public static boolean disableFlightOnFactionClaimChange = true; + // faction- + public static int defaultMaxVaults = 0; + public static boolean disableFlightOnFactionClaimChange = true; - public static Backend backEnd = Backend.JSON; + public static Backend backEnd = Backend.JSON; - // Taller and wider for "bigger f map" - public static int mapHeight = 17; - public static int mapWidth = 49; - public static transient char[] mapKeyChrs = "\\/#$%=&^ABCDEFGHJKLMNOPQRSTUVWXYZ1234567890abcdeghjmnopqrsuvwxyz?".toCharArray(); + // Taller and wider for "bigger f map" + public static int mapHeight = 17; + public static int mapWidth = 49; + public static transient char[] mapKeyChrs = "\\/#$%=&^ABCDEFGHJKLMNOPQRSTUVWXYZ1234567890abcdeghjmnopqrsuvwxyz?".toCharArray(); - //Cooldown for /f logout in seconds + //Cooldown for /f logout in seconds public static long logoutCooldown = 30; // Custom Ranks - Oof I forgot I was doing this _SvenjaReissaus_ - //public static boolean enableCustomRanks = false; // We will disable it by default to avoid any migration error - //public static int maxCustomRanks = 2; // Setting this to -1 will allow unlimited custom ranks - // -------------------------------------------- // - // Persistance - // ----------------------------------------- // + //public static boolean enableCustomRanks = false; // We will disable it by default to avoid any migration error + //public static int maxCustomRanks = 2; // Setting this to -1 will allow unlimited custom ranks + // -------------------------------------------- // + // Persistance + // ----------------------------------------- // - // Default Faction Permission Settings. - public static boolean useLockedPermissions = false; - public static boolean useCustomDefaultPermissions = true; - public static boolean usePermissionHints = false; - public static HashMap defaultFactionPermissions = new HashMap<>(); - public static HashSet lockedPermissions = new HashSet<>(); + // Default Faction Permission Settings. + public static boolean useLockedPermissions = false; + public static boolean useCustomDefaultPermissions = true; + public static boolean usePermissionHints = false; + public static HashMap defaultFactionPermissions = new HashMap<>(); + public static HashSet lockedPermissions = new HashSet<>(); - private static transient Conf i = new Conf(); + private static transient Conf i = new Conf(); - static { - lockedPermissions.add(PermissableAction.CHEST); - } - static { - baseCommandAliases.add("f"); + static { + lockedPermissions.add(PermissableAction.CHEST); + } - territoryEnemyDenyCommands.add("home"); - territoryEnemyDenyCommands.add("sethome"); - territoryEnemyDenyCommands.add("spawn"); - territoryEnemyDenyCommands.add("tpahere"); - territoryEnemyDenyCommands.add("tpaccept"); - territoryEnemyDenyCommands.add("tpa"); + static { + baseCommandAliases.add("f"); - /// TODO: Consider removing this in a future release, as permissions works just fine now - territoryProtectedMaterials.add(Material.BEACON); + territoryEnemyDenyCommands.add("home"); + territoryEnemyDenyCommands.add("sethome"); + territoryEnemyDenyCommands.add("spawn"); + territoryEnemyDenyCommands.add("tpahere"); + territoryEnemyDenyCommands.add("tpaccept"); + territoryEnemyDenyCommands.add("tpa"); - // Config is not loading if value is empty ??? - territoryBypassProtectedMaterials.add(Material.COOKIE); + /// TODO: Consider removing this in a future release, as permissions works just fine now + territoryProtectedMaterials.add(Material.BEACON); - territoryDenyUseageMaterials.add(XMaterial.FIRE_CHARGE.parseMaterial()); - territoryDenyUseageMaterials.add(Material.FLINT_AND_STEEL); - territoryDenyUseageMaterials.add(Material.BUCKET); - territoryDenyUseageMaterials.add(Material.WATER_BUCKET); - territoryDenyUseageMaterials.add(Material.LAVA_BUCKET); - if (!P.p.mc17) { - territoryDenyUseageMaterials.add(Material.ARMOR_STAND); - } + // Config is not loading if value is empty ??? + territoryBypassProtectedMaterials.add(Material.COOKIE); + + territoryDenyUseageMaterials.add(XMaterial.FIRE_CHARGE.parseMaterial()); + territoryDenyUseageMaterials.add(Material.FLINT_AND_STEEL); + territoryDenyUseageMaterials.add(Material.BUCKET); + territoryDenyUseageMaterials.add(Material.WATER_BUCKET); + territoryDenyUseageMaterials.add(Material.LAVA_BUCKET); + if (!P.p.mc17) { + territoryDenyUseageMaterials.add(Material.ARMOR_STAND); + } - territoryProtectedMaterialsWhenOffline.add(Material.BEACON); + territoryProtectedMaterialsWhenOffline.add(Material.BEACON); - territoryDenyUseageMaterialsWhenOffline.add(XMaterial.FIRE_CHARGE.parseMaterial()); - territoryDenyUseageMaterialsWhenOffline.add(Material.FLINT_AND_STEEL); - territoryDenyUseageMaterialsWhenOffline.add(Material.BUCKET); - territoryDenyUseageMaterialsWhenOffline.add(Material.WATER_BUCKET); - territoryDenyUseageMaterialsWhenOffline.add(Material.LAVA_BUCKET); - if (!P.p.mc17) { - territoryDenyUseageMaterialsWhenOffline.add(Material.ARMOR_STAND); - } - safeZoneNerfedCreatureTypes.add(EntityType.BLAZE); - safeZoneNerfedCreatureTypes.add(EntityType.CAVE_SPIDER); - safeZoneNerfedCreatureTypes.add(EntityType.CREEPER); - safeZoneNerfedCreatureTypes.add(EntityType.ENDER_DRAGON); - safeZoneNerfedCreatureTypes.add(EntityType.ENDERMAN); - safeZoneNerfedCreatureTypes.add(EntityType.GHAST); - safeZoneNerfedCreatureTypes.add(EntityType.MAGMA_CUBE); - safeZoneNerfedCreatureTypes.add(EntityType.PIG_ZOMBIE); - safeZoneNerfedCreatureTypes.add(EntityType.SILVERFISH); - safeZoneNerfedCreatureTypes.add(EntityType.SKELETON); - safeZoneNerfedCreatureTypes.add(EntityType.SPIDER); - safeZoneNerfedCreatureTypes.add(EntityType.SLIME); - safeZoneNerfedCreatureTypes.add(EntityType.WITCH); - safeZoneNerfedCreatureTypes.add(EntityType.WITHER); - safeZoneNerfedCreatureTypes.add(EntityType.ZOMBIE); + territoryDenyUseageMaterialsWhenOffline.add(XMaterial.FIRE_CHARGE.parseMaterial()); + territoryDenyUseageMaterialsWhenOffline.add(Material.FLINT_AND_STEEL); + territoryDenyUseageMaterialsWhenOffline.add(Material.BUCKET); + territoryDenyUseageMaterialsWhenOffline.add(Material.WATER_BUCKET); + territoryDenyUseageMaterialsWhenOffline.add(Material.LAVA_BUCKET); + if (!P.p.mc17) { + territoryDenyUseageMaterialsWhenOffline.add(Material.ARMOR_STAND); + } + safeZoneNerfedCreatureTypes.add(EntityType.BLAZE); + safeZoneNerfedCreatureTypes.add(EntityType.CAVE_SPIDER); + safeZoneNerfedCreatureTypes.add(EntityType.CREEPER); + safeZoneNerfedCreatureTypes.add(EntityType.ENDER_DRAGON); + safeZoneNerfedCreatureTypes.add(EntityType.ENDERMAN); + safeZoneNerfedCreatureTypes.add(EntityType.GHAST); + safeZoneNerfedCreatureTypes.add(EntityType.MAGMA_CUBE); + safeZoneNerfedCreatureTypes.add(EntityType.PIG_ZOMBIE); + safeZoneNerfedCreatureTypes.add(EntityType.SILVERFISH); + safeZoneNerfedCreatureTypes.add(EntityType.SKELETON); + safeZoneNerfedCreatureTypes.add(EntityType.SPIDER); + safeZoneNerfedCreatureTypes.add(EntityType.SLIME); + safeZoneNerfedCreatureTypes.add(EntityType.WITCH); + safeZoneNerfedCreatureTypes.add(EntityType.WITHER); + safeZoneNerfedCreatureTypes.add(EntityType.ZOMBIE); - // Is this called lazy load? - defaultFactionPermissions.put("LEADER", new DefaultPermissions(true)); - defaultFactionPermissions.put("COLEADER", new DefaultPermissions(true)); - defaultFactionPermissions.put("MODERATOR", new DefaultPermissions(true)); - defaultFactionPermissions.put("NORMAL MEMBER", new DefaultPermissions(false)); - defaultFactionPermissions.put("RECRUIT", new DefaultPermissions(false)); - } + // Is this called lazy load? + defaultFactionPermissions.put("LEADER", new DefaultPermissions(true)); + defaultFactionPermissions.put("COLEADER", new DefaultPermissions(true)); + defaultFactionPermissions.put("MODERATOR", new DefaultPermissions(true)); + defaultFactionPermissions.put("NORMAL MEMBER", new DefaultPermissions(false)); + defaultFactionPermissions.put("RECRUIT", new DefaultPermissions(false)); + } - public static void load() { - P.p.persist.loadOrSaveDefault(i, Conf.class, "conf"); - } + public static void load() { + P.p.persist.loadOrSaveDefault(i, Conf.class, "conf"); + } - public static void save() { - P.p.persist.save(i); - } + public static void save() { + P.p.persist.save(i); + } - public enum Backend { - JSON, - //MYSQL, TODO add MySQL storage - ; - } + public enum Backend { + JSON, + //MYSQL, TODO add MySQL storage + ; + } } diff --git a/src/main/java/com/massivecraft/factions/FLocation.java b/src/main/java/com/massivecraft/factions/FLocation.java index 672818bc..1073b3e2 100644 --- a/src/main/java/com/massivecraft/factions/FLocation.java +++ b/src/main/java/com/massivecraft/factions/FLocation.java @@ -12,246 +12,247 @@ import java.util.Objects; import java.util.Set; public class FLocation implements Serializable { - private static final long serialVersionUID = -8292915234027387983L; - private static final boolean worldBorderSupport; + private static final long serialVersionUID = -8292915234027387983L; + private static final boolean worldBorderSupport; - static { - boolean worldBorderClassPresent = false; - try { - Class.forName("org.bukkit.WorldBorder"); - worldBorderClassPresent = true; - } catch (ClassNotFoundException ignored) { - } + static { + boolean worldBorderClassPresent = false; + try { + Class.forName("org.bukkit.WorldBorder"); + worldBorderClassPresent = true; + } catch (ClassNotFoundException ignored) { + } - worldBorderSupport = worldBorderClassPresent; - } + worldBorderSupport = worldBorderClassPresent; + } - private String worldName = "world"; - private int x = 0; - private int z = 0; + private String worldName = "world"; + private int x = 0; + private int z = 0; - //----------------------------------------------// - // Constructors - //----------------------------------------------// + //----------------------------------------------// + // Constructors + //----------------------------------------------// - public FLocation() { + public FLocation() { - } + } - public FLocation(String worldName, int x, int z) { - this.worldName = worldName; - this.x = x; - this.z = z; - } + public FLocation(String worldName, int x, int z) { + this.worldName = worldName; + this.x = x; + this.z = z; + } - public FLocation(Location location) { - this(location.getWorld().getName(), blockToChunk(location.getBlockX()), blockToChunk(location.getBlockZ())); - } + public FLocation(Location location) { + this(location.getWorld().getName(), blockToChunk(location.getBlockX()), blockToChunk(location.getBlockZ())); + } - public FLocation(Player player) { - this(player.getLocation()); - } + public FLocation(Player player) { + this(player.getLocation()); + } - public FLocation(FPlayer fplayer) { - this(fplayer.getPlayer()); - } + public FLocation(FPlayer fplayer) { + this(fplayer.getPlayer()); + } - public FLocation(Block block) { - this(block.getLocation()); - } + public FLocation(Block block) { + this(block.getLocation()); + } - //----------------------------------------------// - // Getters and Setters - //----------------------------------------------// + //----------------------------------------------// + // Getters and Setters + //----------------------------------------------// - public static FLocation fromString(String string) { - int index = string.indexOf(","); - int start = 1; - String worldName = string.substring(start, index); - start = index + 1; - index = string.indexOf(",", start); - int x = Integer.valueOf(string.substring(start, index)); - int y = Integer.valueOf(string.substring(index + 1, string.length() - 1)); - return new FLocation(worldName, x, y); - } + public static FLocation fromString(String string) { + int index = string.indexOf(","); + int start = 1; + String worldName = string.substring(start, index); + start = index + 1; + index = string.indexOf(",", start); + int x = Integer.valueOf(string.substring(start, index)); + int y = Integer.valueOf(string.substring(index + 1, string.length() - 1)); + return new FLocation(worldName, x, y); + } - // bit-shifting is used because it's much faster than standard division and multiplication - public static int blockToChunk(int blockVal) { // 1 chunk is 16x16 blocks - return blockVal >> 4; // ">> 4" == "/ 16" - } - public static int blockToRegion(int blockVal) { // 1 region is 512x512 blocks - return blockVal >> 9; // ">> 9" == "/ 512" - } + // bit-shifting is used because it's much faster than standard division and multiplication + public static int blockToChunk(int blockVal) { // 1 chunk is 16x16 blocks + return blockVal >> 4; // ">> 4" == "/ 16" + } - public static int chunkToRegion(int chunkVal) { // 1 region is 32x32 chunks - return chunkVal >> 5; // ">> 5" == "/ 32" - } + public static int blockToRegion(int blockVal) { // 1 region is 512x512 blocks + return blockVal >> 9; // ">> 9" == "/ 512" + } - public static int chunkToBlock(int chunkVal) { - return chunkVal << 4; // "<< 4" == "* 16" - } + public static int chunkToRegion(int chunkVal) { // 1 region is 32x32 chunks + return chunkVal >> 5; // ">> 5" == "/ 32" + } - public static int regionToBlock(int regionVal) { - return regionVal << 9; // "<< 9" == "* 512" - } + public static int chunkToBlock(int chunkVal) { + return chunkVal << 4; // "<< 4" == "* 16" + } - public static int regionToChunk(int regionVal) { - return regionVal << 5; // "<< 5" == "* 32" - } + public static int regionToBlock(int regionVal) { + return regionVal << 9; // "<< 9" == "* 512" + } - public static HashSet getArea(FLocation from, FLocation to) { - HashSet ret = new HashSet<>(); + public static int regionToChunk(int regionVal) { + return regionVal << 5; // "<< 5" == "* 32" + } - for (long x : MiscUtil.range(from.getX(), to.getX())) { - for (long z : MiscUtil.range(from.getZ(), to.getZ())) { - ret.add(new FLocation(from.getWorldName(), (int) x, (int) z)); - } - } + public static HashSet getArea(FLocation from, FLocation to) { + HashSet ret = new HashSet<>(); - return ret; - } + for (long x : MiscUtil.range(from.getX(), to.getX())) { + for (long z : MiscUtil.range(from.getZ(), to.getZ())) { + ret.add(new FLocation(from.getWorldName(), (int) x, (int) z)); + } + } - public Chunk getChunk() { - return Bukkit.getWorld(worldName).getChunkAt(x, z); - } + return ret; + } - public String getWorldName() { - return worldName; - } + public Chunk getChunk() { + return Bukkit.getWorld(worldName).getChunkAt(x, z); + } - public void setWorldName(String worldName) { - this.worldName = worldName; - } + public String getWorldName() { + return worldName; + } - //----------------------------------------------// - // Block/Chunk/Region Value Transformation - //----------------------------------------------// + public void setWorldName(String worldName) { + this.worldName = worldName; + } - public World getWorld() { - return Bukkit.getWorld(worldName); - } + //----------------------------------------------// + // Block/Chunk/Region Value Transformation + //----------------------------------------------// - public long getX() { - return x; - } + public World getWorld() { + return Bukkit.getWorld(worldName); + } - public void setX(int x) { - this.x = x; - } + public long getX() { + return x; + } - public long getZ() { - return z; - } + public void setX(int x) { + this.x = x; + } - public void setZ(int z) { - this.z = z; - } + public long getZ() { + return z; + } - public String getCoordString() { - return "" + x + "," + z; - } + public void setZ(int z) { + this.z = z; + } - //----------------------------------------------// - // Misc Geometry - //----------------------------------------------// + public String getCoordString() { + return "" + x + "," + z; + } - @Override - public String toString() { - return "[" + this.getWorldName() + "," + this.getCoordString() + "]"; - } + //----------------------------------------------// + // Misc Geometry + //----------------------------------------------// - public FLocation getRelative(int dx, int dz) { - return new FLocation(this.worldName, this.x + dx, this.z + dz); - } + @Override + public String toString() { + return "[" + this.getWorldName() + "," + this.getCoordString() + "]"; + } - public double getDistanceTo(FLocation that) { - double dx = that.x - this.x; - double dz = that.z - this.z; - return Math.sqrt(dx * dx + dz * dz); - } + public FLocation getRelative(int dx, int dz) { + return new FLocation(this.worldName, this.x + dx, this.z + dz); + } - public double getDistanceSquaredTo(FLocation that) { - double dx = that.x - this.x; - double dz = that.z - this.z; - return dx * dx + dz * dz; - } + public double getDistanceTo(FLocation that) { + double dx = that.x - this.x; + double dz = that.z - this.z; + return Math.sqrt(dx * dx + dz * dz); + } - public boolean isInChunk(Location loc) { - if (loc == null) { - return false; - } - Chunk chunk = loc.getChunk(); - return loc.getWorld().getName().equalsIgnoreCase(getWorldName()) && chunk.getX() == x && chunk.getZ() == z; - } + public double getDistanceSquaredTo(FLocation that) { + double dx = that.x - this.x; + double dz = that.z - this.z; + return dx * dx + dz * dz; + } - /** - * Checks if the chunk represented by this FLocation is outside the world border - * - * @param buffer the number of chunks from the border that will be treated as "outside" - * @return whether this location is outside of the border - */ - public boolean isOutsideWorldBorder(int buffer) { - if (!worldBorderSupport) { - return false; - } + public boolean isInChunk(Location loc) { + if (loc == null) { + return false; + } + Chunk chunk = loc.getChunk(); + return loc.getWorld().getName().equalsIgnoreCase(getWorldName()) && chunk.getX() == x && chunk.getZ() == z; + } - WorldBorder border = getWorld().getWorldBorder(); - Chunk chunk = border.getCenter().getChunk(); + /** + * Checks if the chunk represented by this FLocation is outside the world border + * + * @param buffer the number of chunks from the border that will be treated as "outside" + * @return whether this location is outside of the border + */ + public boolean isOutsideWorldBorder(int buffer) { + if (!worldBorderSupport) { + return false; + } - int lim = FLocation.chunkToRegion((int) border.getSize()) - buffer; - int diffX = chunk.getX() - x; - int diffZ = chunk.getZ() - z; - return diffX > lim || diffZ > lim || -diffX > lim - 1 || -diffZ > lim - 1; - } + WorldBorder border = getWorld().getWorldBorder(); + Chunk chunk = border.getCenter().getChunk(); - //----------------------------------------------// - // Some Geometry - //----------------------------------------------// - public Set getCircle(double radius) { - double radiusSquared = radius * radius; + int lim = FLocation.chunkToRegion((int) border.getSize()) - buffer; + int diffX = chunk.getX() - x; + int diffZ = chunk.getZ() - z; + return diffX > lim || diffZ > lim || -diffX > lim - 1 || -diffZ > lim - 1; + } - Set ret = new LinkedHashSet<>(); - if (radius <= 0) { - return ret; - } + //----------------------------------------------// + // Some Geometry + //----------------------------------------------// + public Set getCircle(double radius) { + double radiusSquared = radius * radius; - int xfrom = (int) Math.floor(this.x - radius); - int xto = (int) Math.ceil(this.x + radius); - int zfrom = (int) Math.floor(this.z - radius); - int zto = (int) Math.ceil(this.z + radius); + Set ret = new LinkedHashSet<>(); + if (radius <= 0) { + return ret; + } - for (int x = xfrom; x <= xto; x++) { - for (int z = zfrom; z <= zto; z++) { - FLocation potential = new FLocation(this.worldName, x, z); - if (this.getDistanceSquaredTo(potential) <= radiusSquared) { - ret.add(potential); - } - } - } + int xfrom = (int) Math.floor(this.x - radius); + int xto = (int) Math.ceil(this.x + radius); + int zfrom = (int) Math.floor(this.z - radius); + int zto = (int) Math.ceil(this.z + radius); - return ret; - } + for (int x = xfrom; x <= xto; x++) { + for (int z = zfrom; z <= zto; z++) { + FLocation potential = new FLocation(this.worldName, x, z); + if (this.getDistanceSquaredTo(potential) <= radiusSquared) { + ret.add(potential); + } + } + } - //----------------------------------------------// - // Comparison - //----------------------------------------------// + return ret; + } - @Override - public int hashCode() { - // should be fast, with good range and few hash collisions: (x * 512) + z + worldName.hashCode - return (this.x << 9) + this.z + (this.worldName != null ? this.worldName.hashCode() : 0); - } + //----------------------------------------------// + // Comparison + //----------------------------------------------// - @Override - public boolean equals(Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof FLocation)) { - return false; - } + @Override + public int hashCode() { + // should be fast, with good range and few hash collisions: (x * 512) + z + worldName.hashCode + return (this.x << 9) + this.z + (this.worldName != null ? this.worldName.hashCode() : 0); + } - FLocation that = (FLocation) obj; - return this.x == that.x && this.z == that.z && (Objects.equals(this.worldName, that.worldName)); - } + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof FLocation)) { + return false; + } + + FLocation that = (FLocation) obj; + return this.x == that.x && this.z == that.z && (Objects.equals(this.worldName, that.worldName)); + } } \ No newline at end of file diff --git a/src/main/java/com/massivecraft/factions/FPlayer.java b/src/main/java/com/massivecraft/factions/FPlayer.java index 555ee118..fd16466c 100644 --- a/src/main/java/com/massivecraft/factions/FPlayer.java +++ b/src/main/java/com/massivecraft/factions/FPlayer.java @@ -26,368 +26,368 @@ import java.util.List; public interface FPlayer extends EconomyParticipator { - void setNotificationsEnabled(boolean notifications); + void setNotificationsEnabled(boolean notifications); - boolean hasNotificationsEnabled(); + boolean hasNotificationsEnabled(); - void setAlt(boolean alt); + boolean isAlt(); - boolean isAlt(); + void setAlt(boolean alt); - /** - * Used to know if stealth is toggled on or off - * - * @return if stealth mode is on or not. - */ - boolean isStealthEnabled(); + /** + * Used to know if stealth is toggled on or off + * + * @return if stealth mode is on or not. + */ + boolean isStealthEnabled(); - /** - * Toggles the stealth of the FPlayer depending on the parameter - * - * @param stealthToggle - toggles stealth - */ - void setStealth(boolean stealthToggle); + /** + * Toggles the stealth of the FPlayer depending on the parameter + * + * @param stealthToggle - toggles stealth + */ + void setStealth(boolean stealthToggle); - /** - * Sets the kills and deaths of a player. - */ - void login(); + /** + * Sets the kills and deaths of a player. + */ + void login(); - /** - * Caches the kills and deaths of a player. - */ - void logout(); + /** + * Caches the kills and deaths of a player. + */ + void logout(); - /** - * gets the faction of a FPlayer. - * - * @return Faction of the FPlayer. - */ - Faction getFaction(); + /** + * gets the faction of a FPlayer. + * + * @return Faction of the FPlayer. + */ + Faction getFaction(); - /** - * Sets the faction of the FPlayer - * - * @param faction faction to set. - */ - void setFaction(Faction faction, boolean alt); + /** + * Sets the faction of the FPlayer + * + * @param faction faction to set. + */ + void setFaction(Faction faction, boolean alt); - /** - * Gets the faction ID of the player. - * - * @return FactionsID string - */ - String getFactionId(); + /** + * Gets the faction ID of the player. + * + * @return FactionsID string + */ + String getFactionId(); - /** - * Check if a player has a faction - * - * @return boolean - */ - boolean hasFaction(); + /** + * Check if a player has a faction + * + * @return boolean + */ + boolean hasFaction(); - /** - * Gets autoleave status - * - * @return boolean of the autoleave - */ - boolean willAutoLeave(); + /** + * Gets autoleave status + * + * @return boolean of the autoleave + */ + boolean willAutoLeave(); - void setAutoLeave(boolean autoLeave); + void setAutoLeave(boolean autoLeave); - long getLastFrostwalkerMessage(); + long getLastFrostwalkerMessage(); - void setLastFrostwalkerMessage(); + void setLastFrostwalkerMessage(); - void setMonitorJoins(boolean monitor); + void setMonitorJoins(boolean monitor); - boolean isMonitoringJoins(); + boolean isMonitoringJoins(); - Role getRole(); + Role getRole(); - void setRole(Role role); + void setRole(Role role); - boolean shouldTakeFallDamage(); + boolean shouldTakeFallDamage(); - void setTakeFallDamage(boolean fallDamage); + void setTakeFallDamage(boolean fallDamage); - double getPowerBoost(); + double getPowerBoost(); - void setPowerBoost(double powerBoost); + void setPowerBoost(double powerBoost); - Faction getAutoClaimFor(); + Faction getAutoClaimFor(); - void setAutoClaimFor(Faction faction); + void setAutoClaimFor(Faction faction); - boolean isAutoSafeClaimEnabled(); + boolean isAutoSafeClaimEnabled(); - void setIsAutoSafeClaimEnabled(boolean enabled); + void setIsAutoSafeClaimEnabled(boolean enabled); - boolean isAutoWarClaimEnabled(); + boolean isAutoWarClaimEnabled(); - void setIsAutoWarClaimEnabled(boolean enabled); + void setIsAutoWarClaimEnabled(boolean enabled); - boolean isAdminBypassing(); + boolean isAdminBypassing(); - boolean isVanished(); + boolean isVanished(); - void setIsAdminBypassing(boolean val); + void setIsAdminBypassing(boolean val); - ChatMode getChatMode(); + ChatMode getChatMode(); - void setChatMode(ChatMode chatMode); + void setChatMode(ChatMode chatMode); - boolean isIgnoreAllianceChat(); + boolean isIgnoreAllianceChat(); - void setIgnoreAllianceChat(boolean ignore); + void setIgnoreAllianceChat(boolean ignore); - boolean isSpyingChat(); + boolean isSpyingChat(); - void setSpyingChat(boolean chatSpying); + void setSpyingChat(boolean chatSpying); - boolean showScoreboard(); + boolean showScoreboard(); - void setShowScoreboard(boolean show); + void setShowScoreboard(boolean show); - // FIELD: account - String getAccountId(); + // FIELD: account + String getAccountId(); - void resetFactionData(boolean doSpoutUpdate); + void resetFactionData(boolean doSpoutUpdate); - void resetFactionData(); + void resetFactionData(); - long getLastLoginTime(); + long getLastLoginTime(); - void setLastLoginTime(long lastLoginTime); + void setLastLoginTime(long lastLoginTime); - boolean isMapAutoUpdating(); + boolean isMapAutoUpdating(); - void setMapAutoUpdating(boolean mapAutoUpdating); + void setMapAutoUpdating(boolean mapAutoUpdating); - boolean hasLoginPvpDisabled(); + boolean hasLoginPvpDisabled(); - FLocation getLastStoodAt(); + FLocation getLastStoodAt(); - void setLastStoodAt(FLocation flocation); + void setLastStoodAt(FLocation flocation); - String getTitle(); + String getTitle(); - void setTitle(CommandSender sender, String title); + void setTitle(CommandSender sender, String title); - String getName(); + String getName(); - String getTag(); + String getTag(); - // Base concatenations: + // Base concatenations: - String getNameAndSomething(String something); + String getNameAndSomething(String something); - String getNameAndTitle(); + String getNameAndTitle(); - String getNameAndTag(); + String getNameAndTag(); - // Colored concatenations: - // These are used in information messages + // Colored concatenations: + // These are used in information messages - String getNameAndTitle(Faction faction); + String getNameAndTitle(Faction faction); - String getNameAndTitle(FPlayer fplayer); + String getNameAndTitle(FPlayer fplayer); - // Chat Tag: - // These are injected into the format of global chat messages. + // Chat Tag: + // These are injected into the format of global chat messages. - String getChatTag(); + String getChatTag(); - // Colored Chat Tag - String getChatTag(Faction faction); + // Colored Chat Tag + String getChatTag(Faction faction); - String getChatTag(FPlayer fplayer); + String getChatTag(FPlayer fplayer); - int getKills(); + int getKills(); - int getDeaths(); + int getDeaths(); - void takeMoney(int amt); + void takeMoney(int amt); - boolean hasMoney(int amt); + boolean hasMoney(int amt); - //inspect Stuff + //inspect Stuff - boolean isInspectMode(); + boolean isInspectMode(); - void setInspectMode(boolean status); + void setInspectMode(boolean status); - // Fly Checks + // Fly Checks - Boolean canflyinWilderness(); + Boolean canflyinWilderness(); - Boolean canflyinWarzone(); + Boolean canflyinWarzone(); - Boolean canflyinSafezone(); + Boolean canflyinSafezone(); - Boolean canflyinEnemy(); + Boolean canflyinEnemy(); - Boolean canflyinAlly(); + Boolean canflyinAlly(); - Boolean canflyinTruce(); + Boolean canflyinTruce(); - Boolean canflyinNeutral(); + Boolean canflyinNeutral(); - // ------------------------------- - // Relation and relation colors - // ------------------------------- + // ------------------------------- + // Relation and relation colors + // ------------------------------- - @Override - String describeTo(RelationParticipator that, boolean ucfirst); + @Override + String describeTo(RelationParticipator that, boolean ucfirst); - @Override - String describeTo(RelationParticipator that); + @Override + String describeTo(RelationParticipator that); - @Override - Relation getRelationTo(RelationParticipator rp); + @Override + Relation getRelationTo(RelationParticipator rp); - @Override - Relation getRelationTo(RelationParticipator rp, boolean ignorePeaceful); + @Override + Relation getRelationTo(RelationParticipator rp, boolean ignorePeaceful); - Relation getRelationToLocation(); + Relation getRelationToLocation(); - @Override - ChatColor getColorTo(RelationParticipator rp); + @Override + ChatColor getColorTo(RelationParticipator rp); - String getRolePrefix(); + String getRolePrefix(); - //----------------------------------------------// - // Health - //----------------------------------------------// - void heal(int amnt); + //----------------------------------------------// + // Health + //----------------------------------------------// + void heal(int amnt); - //----------------------------------------------// - // Power - //----------------------------------------------// - double getPower(); + //----------------------------------------------// + // Power + //----------------------------------------------// + double getPower(); - void alterPower(double delta); + void alterPower(double delta); - double getPowerMax(); + double getPowerMax(); - double getPowerMin(); + double getPowerMin(); - int getPowerRounded(); + int getPowerRounded(); - int getPowerMaxRounded(); + int getPowerMaxRounded(); - int getPowerMinRounded(); + int getPowerMinRounded(); - void updatePower(); + void updatePower(); - void losePowerFromBeingOffline(); + void losePowerFromBeingOffline(); - void onDeath(); + void onDeath(); - //----------------------------------------------// - // Territory - //----------------------------------------------// - boolean isInOwnTerritory(); + //----------------------------------------------// + // Territory + //----------------------------------------------// + boolean isInOwnTerritory(); - boolean isInOthersTerritory(); + boolean isInOthersTerritory(); - boolean isInAllyTerritory(); + boolean isInAllyTerritory(); - boolean isInNeutralTerritory(); + boolean isInNeutralTerritory(); - boolean isInEnemyTerritory(); + boolean isInEnemyTerritory(); - void sendFactionHereMessage(Faction from); + void sendFactionHereMessage(Faction from); - // ------------------------------- - // Actions - // ------------------------------- + // ------------------------------- + // Actions + // ------------------------------- - void leave(boolean makePay); + void leave(boolean makePay); - boolean canClaimForFaction(Faction forFaction); + boolean canClaimForFaction(Faction forFaction); - boolean canClaimForFactionAtLocation(Faction forFaction, Location location, boolean notifyFailure); + boolean canClaimForFactionAtLocation(Faction forFaction, Location location, boolean notifyFailure); - boolean canClaimForFactionAtLocation(Faction forFaction, FLocation location, boolean notifyFailure); + boolean canClaimForFactionAtLocation(Faction forFaction, FLocation location, boolean notifyFailure); - boolean attemptClaim(Faction forFaction, Location location, boolean notifyFailure); + boolean attemptClaim(Faction forFaction, Location location, boolean notifyFailure); - boolean attemptClaim(Faction forFaction, FLocation location, boolean notifyFailure); + boolean attemptClaim(Faction forFaction, FLocation location, boolean notifyFailure); - boolean isInVault(); + boolean isInVault(); - void setInVault(boolean status); + void setInVault(boolean status); - void msg(String str, Object... args); + void msg(String str, Object... args); - String getId(); + String getId(); - void setId(String id); + void setId(String id); - Player getPlayer(); + Player getPlayer(); - boolean isOnline(); + boolean isOnline(); - void sendMessage(String message); + void sendMessage(String message); - void sendMessage(List messages); + void sendMessage(List messages); - void sendFancyMessage(FancyMessage message); + void sendFancyMessage(FancyMessage message); - void sendFancyMessage(List message); + void sendFancyMessage(List message); - int getMapHeight(); + int getMapHeight(); - void setMapHeight(int height); + void setMapHeight(int height); - boolean isOnlineAndVisibleTo(Player me); + boolean isOnlineAndVisibleTo(Player me); - void remove(); + void remove(); - boolean isOffline(); + boolean isOffline(); - boolean isFlying(); + boolean isFlying(); - void setFlying(boolean fly); + void setFlying(boolean fly); - void setFFlying(boolean fly, boolean damage); + void setFFlying(boolean fly, boolean damage); - boolean canFlyAtLocation(); + boolean canFlyAtLocation(); - boolean canFlyAtLocation(FLocation location); + boolean canFlyAtLocation(FLocation location); - boolean isEnteringPassword(); + boolean isEnteringPassword(); - void setEnteringPassword(boolean toggle, String warp); + void setEnteringPassword(boolean toggle, String warp); - String getEnteringWarp(); + String getEnteringWarp(); - boolean checkIfNearbyEnemies(); + boolean checkIfNearbyEnemies(); - int getCooldown(String cmd); + int getCooldown(String cmd); - void setCooldown(String cmd, long cooldown); + void setCooldown(String cmd, long cooldown); - boolean isCooldownEnded(String cmd); + boolean isCooldownEnded(String cmd); - // ------------------------------- - // Warmups - // ------------------------------- + // ------------------------------- + // Warmups + // ------------------------------- - boolean isWarmingUp(); + boolean isWarmingUp(); - WarmUpUtil.Warmup getWarmupType(); + WarmUpUtil.Warmup getWarmupType(); - void addWarmup(WarmUpUtil.Warmup warmup, int taskId); + void addWarmup(WarmUpUtil.Warmup warmup, int taskId); - void stopWarmup(); + void stopWarmup(); - void clearWarmup(); + void clearWarmup(); } \ No newline at end of file diff --git a/src/main/java/com/massivecraft/factions/FPlayers.java b/src/main/java/com/massivecraft/factions/FPlayers.java index 4faf210c..894ab326 100644 --- a/src/main/java/com/massivecraft/factions/FPlayers.java +++ b/src/main/java/com/massivecraft/factions/FPlayers.java @@ -7,34 +7,34 @@ import org.bukkit.entity.Player; import java.util.Collection; public abstract class FPlayers { - protected static FPlayers instance = getFPlayersImpl(); + protected static FPlayers instance = getFPlayersImpl(); - public static FPlayers getInstance() { - return instance; - } + public static FPlayers getInstance() { + return instance; + } - private static FPlayers getFPlayersImpl() { - if (Conf.backEnd == Conf.Backend.JSON) { - return new JSONFPlayers(); - } - return null; - } + private static FPlayers getFPlayersImpl() { + if (Conf.backEnd == Conf.Backend.JSON) { + return new JSONFPlayers(); + } + return null; + } - public abstract void clean(); + public abstract void clean(); - public abstract Collection getOnlinePlayers(); + public abstract Collection getOnlinePlayers(); - public abstract FPlayer getByPlayer(Player player); + public abstract FPlayer getByPlayer(Player player); - public abstract Collection getAllFPlayers(); + public abstract Collection getAllFPlayers(); - public abstract void forceSave(); + public abstract void forceSave(); - public abstract void forceSave(boolean sync); + public abstract void forceSave(boolean sync); - public abstract FPlayer getByOfflinePlayer(OfflinePlayer player); + public abstract FPlayer getByOfflinePlayer(OfflinePlayer player); - public abstract FPlayer getById(String string); + public abstract FPlayer getById(String string); - public abstract void load(); + public abstract void load(); } diff --git a/src/main/java/com/massivecraft/factions/Faction.java b/src/main/java/com/massivecraft/factions/Faction.java index 79b46497..f18ca326 100644 --- a/src/main/java/com/massivecraft/factions/Faction.java +++ b/src/main/java/com/massivecraft/factions/Faction.java @@ -23,350 +23,358 @@ import java.util.concurrent.ConcurrentHashMap; public interface Faction extends EconomyParticipator { - boolean altInvited(FPlayer fplayer); + long getCheckNotifier(); - Map getMissions(); + void setCheckNotifier(long minutes); - void deinviteAlt(FPlayer alt); + void sendCheckNotify(); - void deinviteAllAlts(); + boolean altInvited(FPlayer fplayer); - void altInvite(FPlayer fplayer); + Map getMissions(); - boolean addAltPlayer(FPlayer fplayer); + void deinviteAlt(FPlayer alt); - boolean removeAltPlayer(FPlayer fplayer); + void deinviteAllAlts(); - Set getAltPlayers(); + void altInvite(FPlayer fplayer); - HashMap> getAnnouncements(); + boolean addAltPlayer(FPlayer fplayer); - ConcurrentHashMap getWarps(); + boolean removeAltPlayer(FPlayer fplayer); - LazyLocation getWarp(String name); + Set getAltPlayers(); - void setWarp(String name, LazyLocation loc); + HashMap> getAnnouncements(); - boolean isWarp(String name); + ConcurrentHashMap getWarps(); - boolean hasWarpPassword(String warp); + LazyLocation getWarp(String name); - boolean isWarpPassword(String warp, String password); + void setWarp(String name, LazyLocation loc); - void setWarpPassword(String warp, String password); + boolean isWarp(String name); - boolean removeWarp(String name); + boolean hasWarpPassword(String warp); - void clearWarps(); + boolean isWarpPassword(String warp, String password); - int getMaxVaults(); + void setWarpPassword(String warp, String password); - void setMaxVaults(int value); + boolean removeWarp(String name); - void addAnnouncement(FPlayer fPlayer, String msg); + void clearWarps(); - void sendUnreadAnnouncements(FPlayer fPlayer); + int getMaxVaults(); - void removeAnnouncements(FPlayer fPlayer); + void setMaxVaults(int value); - Set getInvites(); + void addAnnouncement(FPlayer fPlayer, String msg); - String getFocused(); + void sendUnreadAnnouncements(FPlayer fPlayer); - void setFocused(String setFocused); + void removeAnnouncements(FPlayer fPlayer); - String getId(); + Set getInvites(); - void setId(String id); + String getFocused(); - void invite(FPlayer fplayer); + void setFocused(String setFocused); - void deinvite(FPlayer fplayer); + String getId(); - void setUpgrade(UpgradeType upgrade, int level); + void setId(String id); - int getUpgrade(UpgradeType upgrade); + void invite(FPlayer fplayer); - boolean isInvited(FPlayer fplayer); + void deinvite(FPlayer fplayer); - void ban(FPlayer target, FPlayer banner); + void setUpgrade(UpgradeType upgrade, int level); - int getPoints(); + int getUpgrade(UpgradeType upgrade); - void setPoints(int points); + boolean isInvited(FPlayer fplayer); - int getStrikes(); + void ban(FPlayer target, FPlayer banner); - void setStrikes(int strikes); + int getPoints(); - void unban(FPlayer player); + void setPoints(int points); - boolean isBanned(FPlayer player); + int getStrikes(); - Set getBannedPlayers(); + void setStrikes(int strikes); - HashMap getRulesMap(); + void unban(FPlayer player); - void addRule(String rule); + boolean isBanned(FPlayer player); - void removeRule(int index); + Set getBannedPlayers(); - void clearRules(); + HashMap getRulesMap(); - Location getCheckpoint(); + void addRule(String rule); - void setCheckpoint(Location location); + void removeRule(int index); - void addTnt(int amt); + void clearRules(); - void takeTnt(int amt); + Location getCheckpoint(); - Location getVault(); + void setCheckpoint(Location location); - void setVault(Location vaultLocation); + void addTnt(int amt); - Inventory getChestInventory(); + void takeTnt(int amt); - void setChestSize(int chestSize); + Location getVault(); - void setBannerPattern(ItemStack banner); + void setVault(Location vaultLocation); - ItemStack getBanner(); + Inventory getChestInventory(); - int getTnt(); + void setChestSize(int chestSize); - String getRule(int index); + void setBannerPattern(ItemStack banner); - boolean getOpen(); + ItemStack getBanner(); - void setOpen(boolean isOpen); + int getTnt(); - boolean isPeaceful(); + String getRule(int index); - void setPeaceful(boolean isPeaceful); + boolean getOpen(); - boolean getPeacefulExplosionsEnabled(); + void setOpen(boolean isOpen); - void setPeacefulExplosionsEnabled(boolean val); + boolean isPeaceful(); - boolean noExplosionsInTerritory(); + void setPeaceful(boolean isPeaceful); - boolean isPermanent(); + boolean getPeacefulExplosionsEnabled(); - void setPermanent(boolean isPermanent); + void setPeacefulExplosionsEnabled(boolean val); - String getTag(); + boolean noExplosionsInTerritory(); - void setTag(String str); + boolean isPermanent(); - String getTag(String prefix); + void setPermanent(boolean isPermanent); - String getTag(Faction otherFaction); + String getTag(); - String getTag(FPlayer otherFplayer); + void setTag(String str); - String getComparisonTag(); + String getTag(String prefix); - String getDescription(); + String getTag(Faction otherFaction); - void setDescription(String value); + String getTag(FPlayer otherFplayer); - boolean hasHome(); + String getComparisonTag(); - Location getHome(); + String getDescription(); - void setHome(Location home); + void setDescription(String value); - long getFoundedDate(); + boolean hasHome(); - void setFoundedDate(long newDate); + Location getHome(); - void confirmValidHome(); + void setHome(Location home); - String getAccountId(); + long getFoundedDate(); - Integer getPermanentPower(); + void setFoundedDate(long newDate); - void setPermanentPower(Integer permanentPower); + void confirmValidHome(); - boolean hasPermanentPower(); + String getAccountId(); - double getPowerBoost(); + Integer getPermanentPower(); - void setPowerBoost(double powerBoost); + void setPermanentPower(Integer permanentPower); - boolean noPvPInTerritory(); + boolean hasPermanentPower(); - boolean noMonstersInTerritory(); + double getPowerBoost(); - boolean isNormal(); - boolean isSystemFaction(); - @Deprecated - boolean isNone(); + void setPowerBoost(double powerBoost); - boolean isWilderness(); + boolean noPvPInTerritory(); - boolean isSafeZone(); + boolean noMonstersInTerritory(); - boolean isWarZone(); + boolean isNormal(); - boolean isPlayerFreeType(); + boolean isSystemFaction(); - boolean isPowerFrozen(); + @Deprecated + boolean isNone(); - void setLastDeath(long time); + boolean isWilderness(); - int getKills(); + boolean isSafeZone(); - int getDeaths(); + boolean isWarZone(); - Access getAccess(Permissable permissable, PermissableAction permissableAction); + boolean isPlayerFreeType(); - Access getAccess(FPlayer player, PermissableAction permissableAction); + boolean isPowerFrozen(); - boolean setPermission(Permissable permissable, PermissableAction permissableAction, Access access); + void setLastDeath(long time); - void resetPerms(); + int getKills(); - void setDefaultPerms(); + int getDeaths(); - void disband(Player disbander); + Access getAccess(Permissable permissable, PermissableAction permissableAction); - void disband(Player disbander, PlayerDisbandReason reason); + Access getAccess(FPlayer player, PermissableAction permissableAction); - // ------------------------------- - // Relation and relation colors - // ------------------------------- + boolean setPermission(Permissable permissable, PermissableAction permissableAction, Access access); - Map> getPermissions(); + void resetPerms(); - @Override - String describeTo(RelationParticipator that, boolean ucfirst); + void setDefaultPerms(); - @Override - String describeTo(RelationParticipator that); + void disband(Player disbander); - @Override - Relation getRelationTo(RelationParticipator rp); + void disband(Player disbander, PlayerDisbandReason reason); - @Override - Relation getRelationTo(RelationParticipator rp, boolean ignorePeaceful); + // ------------------------------- + // Relation and relation colors + // ------------------------------- - @Override - ChatColor getColorTo(RelationParticipator rp); + Map> getPermissions(); - Relation getRelationWish(Faction otherFaction); + @Override + String describeTo(RelationParticipator that, boolean ucfirst); - void setRelationWish(Faction otherFaction, Relation relation); + @Override + String describeTo(RelationParticipator that); - int getRelationCount(Relation relation); + @Override + Relation getRelationTo(RelationParticipator rp); - // ----------------------------------------------// - // Power - // ----------------------------------------------// - double getPower(); + @Override + Relation getRelationTo(RelationParticipator rp, boolean ignorePeaceful); - double getPowerMax(); + @Override + ChatColor getColorTo(RelationParticipator rp); - int getPowerRounded(); + Relation getRelationWish(Faction otherFaction); - int getPowerMaxRounded(); + void setRelationWish(Faction otherFaction, Relation relation); - int getLandRounded(); + int getRelationCount(Relation relation); - int getLandRoundedInWorld(String worldName); + // ----------------------------------------------// + // Power + // ----------------------------------------------// + double getPower(); - // ------------------------------- - // FPlayers - // ------------------------------- + double getPowerMax(); - boolean hasLandInflation(); + int getPowerRounded(); - // maintain the reference list of FPlayers in this faction - void refreshFPlayers(); + int getPowerMaxRounded(); - boolean addFPlayer(FPlayer fplayer); + int getLandRounded(); - boolean removeFPlayer(FPlayer fplayer); + int getLandRoundedInWorld(String worldName); - int getSize(); + // ------------------------------- + // FPlayers + // ------------------------------- - Set getFPlayers(); + boolean hasLandInflation(); - Set getFPlayersWhereOnline(boolean online); + // maintain the reference list of FPlayers in this faction + void refreshFPlayers(); - Set getFPlayersWhereOnline(boolean online, FPlayer viewer); + boolean addFPlayer(FPlayer fplayer); - FPlayer getFPlayerAdmin(); + boolean removeFPlayer(FPlayer fplayer); - FPlayer getFPlayerLeader(); + int getSize(); - ArrayList getFPlayersWhereRole(Role role); + Set getFPlayers(); - ArrayList getOnlinePlayers(); + Set getFPlayersWhereOnline(boolean online); - // slightly faster check than getOnlinePlayers() if you just want to see if - // there are any players online - boolean hasPlayersOnline(); + Set getFPlayersWhereOnline(boolean online, FPlayer viewer); - void memberLoggedOff(); + FPlayer getFPlayerAdmin(); - // 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(); + FPlayer getFPlayerLeader(); - void promoteNewLeader(boolean autoLeave); + ArrayList getFPlayersWhereRole(Role role); - Role getDefaultRole(); + ArrayList getOnlinePlayers(); - void setDefaultRole(Role role); + // slightly faster check than getOnlinePlayers() if you just want to see if + // there are any players online + boolean hasPlayersOnline(); - // ----------------------------------------------// - // Messages - // ----------------------------------------------// - void msg(String message, Object... args); + void memberLoggedOff(); - void sendMessage(String message); + // 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(); - // ----------------------------------------------// - // Ownership of specific claims - // ----------------------------------------------// + void promoteNewLeader(boolean autoLeave); - void sendMessage(List messages); + Role getDefaultRole(); - Map> getClaimOwnership(); + void setDefaultRole(Role role); - void clearAllClaimOwnership(); + // ----------------------------------------------// + // Messages + // ----------------------------------------------// + void msg(String message, Object... args); - void clearClaimOwnership(FLocation loc); + void sendMessage(String message); - void clearClaimOwnership(FPlayer player); + // ----------------------------------------------// + // Ownership of specific claims + // ----------------------------------------------// - int getCountOfClaimsWithOwners(); + void sendMessage(List messages); - boolean doesLocationHaveOwnersSet(FLocation loc); + Map> getClaimOwnership(); - boolean isPlayerInOwnerList(FPlayer player, FLocation loc); + void clearAllClaimOwnership(); - void setPlayerAsOwner(FPlayer player, FLocation loc); + void clearClaimOwnership(FLocation loc); - void removePlayerAsOwner(FPlayer player, FLocation loc); + void clearClaimOwnership(FPlayer player); - Set getOwnerList(FLocation loc); + int getCountOfClaimsWithOwners(); - String getOwnerListString(FLocation loc); + boolean doesLocationHaveOwnersSet(FLocation loc); - boolean playerHasOwnershipRights(FPlayer fplayer, FLocation loc); + boolean isPlayerInOwnerList(FPlayer player, FLocation loc); - // ----------------------------------------------// - // Persistance and entity management - // ----------------------------------------------// - void remove(); + void setPlayerAsOwner(FPlayer player, FLocation loc); - Set getAllClaims(); + void removePlayerAsOwner(FPlayer player, FLocation loc); - String getPaypal(); + Set getOwnerList(FLocation loc); - void paypalSet(String paypal); + String getOwnerListString(FLocation loc); + + boolean playerHasOwnershipRights(FPlayer fplayer, FLocation loc); + + // ----------------------------------------------// + // Persistance and entity management + // ----------------------------------------------// + void remove(); + + Set getAllClaims(); + + String getPaypal(); + + void paypalSet(String paypal); } diff --git a/src/main/java/com/massivecraft/factions/Factions.java b/src/main/java/com/massivecraft/factions/Factions.java index b573c3cf..09a2c722 100644 --- a/src/main/java/com/massivecraft/factions/Factions.java +++ b/src/main/java/com/massivecraft/factions/Factions.java @@ -6,50 +6,50 @@ import java.util.ArrayList; import java.util.Set; public abstract class Factions { - protected static Factions instance = getFactionsImpl(); + protected static Factions instance = getFactionsImpl(); - public static Factions getInstance() { - return instance; - } + public static Factions getInstance() { + return instance; + } - private static Factions getFactionsImpl() { - switch (Conf.backEnd) { - case JSON: - return new JSONFactions(); - } - return null; - } + private static Factions getFactionsImpl() { + switch (Conf.backEnd) { + case JSON: + return new JSONFactions(); + } + return null; + } - public abstract Faction getFactionById(String id); + public abstract Faction getFactionById(String id); - public abstract Faction getByTag(String str); + public abstract Faction getByTag(String str); - public abstract Faction getBestTagMatch(String start); + public abstract Faction getBestTagMatch(String start); - public abstract boolean isTagTaken(String str); + public abstract boolean isTagTaken(String str); - public abstract boolean isValidFactionId(String id); + public abstract boolean isValidFactionId(String id); - public abstract Faction createFaction(); + public abstract Faction createFaction(); - public abstract void removeFaction(String id); + public abstract void removeFaction(String id); - public abstract Set getFactionTags(); + public abstract Set getFactionTags(); - public abstract ArrayList getAllFactions(); + public abstract ArrayList getAllFactions(); - @Deprecated - public abstract Faction getNone(); + @Deprecated + public abstract Faction getNone(); - public abstract Faction getWilderness(); + public abstract Faction getWilderness(); - public abstract Faction getSafeZone(); + public abstract Faction getSafeZone(); - public abstract Faction getWarZone(); + public abstract Faction getWarZone(); - public abstract void forceSave(); + public abstract void forceSave(); - public abstract void forceSave(boolean sync); + public abstract void forceSave(boolean sync); - public abstract void load(); + public abstract void load(); } diff --git a/src/main/java/com/massivecraft/factions/P.java b/src/main/java/com/massivecraft/factions/P.java index a3a34285..a3087d3e 100644 --- a/src/main/java/com/massivecraft/factions/P.java +++ b/src/main/java/com/massivecraft/factions/P.java @@ -17,7 +17,6 @@ import com.massivecraft.factions.missions.MissionHandler; import com.massivecraft.factions.shop.ShopClickPersistence; import com.massivecraft.factions.shop.ShopConfig; import com.massivecraft.factions.struct.ChatMode; -import com.massivecraft.factions.util.Placeholder; import com.massivecraft.factions.util.*; import com.massivecraft.factions.util.Particles.ReflectionUtils; import com.massivecraft.factions.zcore.CommandVisibility; @@ -55,659 +54,662 @@ import java.util.stream.Collectors; public class P extends MPlugin { - // Our single plugin instance. - // Single 4 life. - public static P p; - public static Permission perms = null; - // This plugin sets the boolean true when fully enabled. - // Plugins can check this boolean while hooking in have - // a green light to use the api. - public static boolean startupFinished = false; - private FactionsPlayerListener factionsPlayerListener; - - - public boolean PlaceholderApi; - // Commands - public FCmdRoot cmdBase; - public CmdAutoHelp cmdAutoHelp; - public boolean mc17 = false; - public boolean mc18 = false; - public boolean mc112 = false; - public boolean mc113 = false; - public boolean mc114 = false; - public boolean useNonPacketParticles = false; - public boolean factionsFlight = false; - SkriptAddon skriptAddon; - private boolean locked = false; - private boolean spam = false; - private Integer AutoLeaveTask = null; - private boolean hookedPlayervaults; - private ClipPlaceholderAPIManager clipPlaceholderAPIManager; - private boolean mvdwPlaceholderAPIManager = false; - private Listener[] eventsListener; - public static Economy econ = null; - - - public P() { - p = this; - } - - public boolean getLocked() { - return this.locked; - } - - public void setLocked(boolean val) { - this.locked = val; - this.setAutoSave(val); - } - - public boolean getSpam() { - return this.spam; - } - - public void setSpam(boolean val) { - this.spam = val; - this.setAutoSave(val); - } - - public void playSoundForAll(String sound) { - for (Player pl : Bukkit.getOnlinePlayers()) { - playSound(pl, sound); - } - } - - public void playSoundForAll(List sounds) { - for (Player pl : Bukkit.getOnlinePlayers()) { - playSound(pl, sounds); - } - } - - public void playSound(Player p, List sounds) { - for (String sound : sounds) { - playSound(p, sound); - } - } - - public void playSound(Player p, String sound) { - float pitch = Float.valueOf(sound.split(":")[1]); - sound = sound.split(":")[0]; - p.playSound(p.getLocation(), Sound.valueOf(sound), pitch, 5.0F); - } - - @Override - public void onEnable() { - log("==== Setup ===="); - - - // Vault dependency check. - if (getServer().getPluginManager().getPlugin("Vault") == null) { - log("Vault is not present, the plugin will not run properly."); - getServer().getPluginManager().disablePlugin(p); - return; - } - - int version = Integer.parseInt(ReflectionUtils.PackageType.getServerVersion().split("_")[1]); - switch (version) { - case 7: - P.p.log("Minecraft Version 1.7 found, disabling banners, itemflags inside GUIs, and Titles."); - mc17 = true; - break; - case 8: - P.p.log("Minecraft Version 1.8 found, Title Fadeouttime etc will not be configurable."); - mc18 = true; - break; - case 12: - mc112 = true; - break; - case 13: - P.p.log("Minecraft Version 1.13 found, New Items will be used."); - mc113 = true; - break; - case 14: - P.p.log("Minecraft Version 1.14 found."); - mc114 = true; - break; - } - migrateFPlayerLeaders(); - log("==== End Setup ===="); - - if (!preEnable()) { - return; - } - this.loadSuccessful = false; - - saveDefaultConfig(); - - // Load Conf from disk - Conf.load(); - 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) { - log("Invalid faction id on " + fPlayer.getName() + ":" + fPlayer.getFactionId()); - fPlayer.resetFactionData(false); - continue; - } - if (fPlayer.isAlt()) { - faction.addAltPlayer(fPlayer); - } else { - faction.addFPlayer(fPlayer); - } - } - - if (getConfig().getBoolean("enable-faction-flight", true)) { - UtilFly.run(); - } - - Board.getInstance().load(); - Board.getInstance().clean(); - - // Add Base Commands - this.cmdBase = new FCmdRoot(); - this.cmdAutoHelp = new CmdAutoHelp(); - this.getBaseCommands().add(cmdBase); - - Econ.setup(); - setupPermissions(); - - if (Conf.worldGuardChecking || Conf.worldGuardBuildPriority) { - Worldguard.init(this); - } - - EngineDynmap.getInstance().init(); - - // start up task which runs the autoLeaveAfterDaysOfInactivity routine - startAutoLeaveTask(false); - - if (version > 8) { - useNonPacketParticles = true; - log("Minecraft Version 1.9 or higher found, using non packet based particle API"); - } - - if (getConfig().getBoolean("enable-faction-flight")) { - factionsFlight = true; - } - - if (getServer().getPluginManager().getPlugin("Skript") != null) { - log("Skript was found! Registering P Addon..."); - skriptAddon = Skript.registerAddon(this); - try { - skriptAddon.loadClasses("com.massivecraft.factions.skript", "expressions"); - } catch (IOException ex) { - ex.printStackTrace(); - } - log("Skript addon registered!"); - } - - ShopConfig.setup(); - - getServer().getPluginManager().registerEvents(factionsPlayerListener = new FactionsPlayerListener(), this); - - // Register Event Handlers - eventsListener = new Listener[]{ - new FactionsChatListener(), - new FactionsEntityListener(), - new FactionsExploitListener(), - new FactionsBlockListener(), - new FUpgradesGUI(), - new EXPUpgrade(), - new CropUpgrades(), - new RedstoneUpgrade(), - new ShopClickPersistence(), - new MissionHandler(this), - new ChestLogsHandler(), - new SpawnerUpgrades() - }; - - for (Listener eventListener : eventsListener) - getServer().getPluginManager().registerEvents(eventListener, this); - - IEssentials ess = Essentials.setup(); - - if(ess != null && Conf.removeHomesOnLeave){ - getServer().getPluginManager().registerEvents(new EssentialsHomeHandler(ess), this); - } - - // since some other plugins execute commands directly through this command interface, provide it - getCommand(this.refCommand).setExecutor(this); - getCommand(this.refCommand).setTabCompleter(this); - - - RegisteredServiceProvider rsp = P.this.getServer().getServicesManager().getRegistration(Economy.class); - P.econ = rsp.getProvider(); - - if (getDescription().getFullName().contains("BETA")) { - divider(); - System.out.println("You are using a BETA version of the plugin!"); - System.out.println("This comes with risks of small bugs in newer features!"); - System.out.println("For support head to: https://github.com/Driftay/Saber-Factions/issues"); - divider(); - } - - this.setupPlaceholderAPI(); - this.postEnable(); - this.loadSuccessful = true; - // Set startup finished to true. to give plugins hooking in a greenlight - P.startupFinished = true; - } - - public SkriptAddon getSkriptAddon() { - return skriptAddon; - } - - - - private void setupPlaceholderAPI() { - Plugin clip = getServer().getPluginManager().getPlugin("PlaceholderAPI"); - if (clip != null && clip.isEnabled()) { - this.clipPlaceholderAPIManager = new ClipPlaceholderAPIManager(); - if (this.clipPlaceholderAPIManager.register()) { - PlaceholderApi = true; - log(Level.INFO, "Successfully registered placeholders with PlaceholderAPI."); - } else { - PlaceholderApi = false; - } - } else { - PlaceholderApi = false; - } - - Plugin mvdw = getServer().getPluginManager().getPlugin("MVdWPlaceholderAPI"); - if (mvdw != null && mvdw.isEnabled()) { - this.mvdwPlaceholderAPIManager = true; - log(Level.INFO, "Found MVdWPlaceholderAPI. Adding hooks."); - } - } - - public List replacePlaceholders(List lore, Placeholder... placeholders) { - for (Placeholder placeholder : placeholders) { - for (int x = 0; x <= lore.size() - 1; x++) lore.set(x, lore.get(x).replace(placeholder.getTag(), placeholder.getReplace())); - } - return lore; - } - - private void migrateFPlayerLeaders() { - List lines = new ArrayList<>(); - File fplayerFile = new File("plugins" + File.pathSeparator + "Factions" + File.pathSeparator + "players.json"); - - 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."); - } - } - - public boolean isClipPlaceholderAPIHooked() { - return this.clipPlaceholderAPIManager != null; - } - - public boolean isMVdWPlaceholderAPIHooked() { - return this.mvdwPlaceholderAPIManager; - } - - private boolean setupPermissions() { - try { - RegisteredServiceProvider rsp = getServer().getServicesManager().getRegistration(Permission.class); - if (rsp != null) { - perms = rsp.getProvider(); - } - } catch (NoClassDefFoundError ex) { - return false; - } - return perms != null; - } - - private boolean setupPlayervaults() { - Plugin plugin = getServer().getPluginManager().getPlugin("PlayerVaults"); - return plugin != null && plugin.isEnabled(); - } - - @Override - public GsonBuilder getGsonBuilder() { - Type mapFLocToStringSetType = new TypeToken>>() { - }.getType(); - - Type accessTypeAdatper = new TypeToken>>() { - }.getType(); - - return new GsonBuilder().setPrettyPrinting().disableHtmlEscaping().enableComplexMapKeySerialization().excludeFieldsWithModifiers(Modifier.TRANSIENT, Modifier.VOLATILE) - .registerTypeAdapter(accessTypeAdatper, new PermissionsMapTypeAdapter()) - .registerTypeAdapter(LazyLocation.class, new MyLocationTypeAdapter()) - .registerTypeAdapter(mapFLocToStringSetType, new MapFLocToStringSetTypeAdapter()) - .registerTypeAdapter(Inventory.class, new InventoryTypeAdapter()) - .registerTypeAdapter(Location.class, new LocationTypeAdapter()) - .registerTypeAdapterFactory(EnumTypeAdapter.ENUM_FACTORY); - } - - private void divider() { - System.out.println(" .-.-. .-.-. .-.-. .-.-. .-.-. .-.-. .-.-. .-.-"); - System.out.println(" / / \\ \\ / / \\ \\ / / \\ \\ / / \\ \\ / / \\ \\ / / \\ \\ / / \\ \\ / / \\"); - System.out.println("`-' `-`-' `-`-' `-`-' `-`-' `-`-' `-`-' `-`-'"); - } - - @Override - 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. - - // Conf.save(); - } - - if (AutoLeaveTask != null) { - this.getServer().getScheduler().cancelTask(AutoLeaveTask); - AutoLeaveTask = null; - } - - super.onDisable(); - } - - public void startAutoLeaveTask(boolean restartIfRunning) { - if (AutoLeaveTask != null) { - if (!restartIfRunning) { - return; - } - this.getServer().getScheduler().cancelTask(AutoLeaveTask); - } - - if (Conf.autoLeaveRoutineRunsEveryXMinutes > 0.0) { - long ticks = (long) (20 * 60 * Conf.autoLeaveRoutineRunsEveryXMinutes); - AutoLeaveTask = getServer().getScheduler().scheduleSyncRepeatingTask(this, new AutoLeaveTask(), ticks, ticks); - } - } - - @Override - public void postAutoSave() { - //Board.getInstance().forceSave(); Not sure why this was there as it's called after the board is already saved. - Conf.save(); - } - - public ItemStack createItem(Material material, int amount, short datavalue, String name, List lore) { - ItemStack item = new ItemStack(XMaterial.matchXMaterial(material.toString()).parseMaterial(), amount, datavalue); - ItemMeta meta = item.getItemMeta(); - meta.setDisplayName(color(name)); - meta.setLore(colorList(lore)); - item.setItemMeta(meta); - return item; - } - - public ItemStack createLazyItem(Material material, int amount, short datavalue, String name, String lore) { - ItemStack item = new ItemStack(material, amount, datavalue); - ItemMeta meta = item.getItemMeta(); - meta.setDisplayName(color(P.p.getConfig().getString(name))); - meta.setLore(colorList(P.p.getConfig().getStringList(lore))); - item.setItemMeta(meta); - return item; - } - - public Economy getEcon() { - RegisteredServiceProvider rsp = P.p.getServer().getServicesManager().getRegistration(Economy.class); - Economy econ = rsp.getProvider(); - return econ; - } - - - @Override - public boolean logPlayerCommands() { - return Conf.logPlayerCommands; - } - - @Override - public boolean handleCommand(CommandSender sender, String commandString, boolean testOnly) { - return sender instanceof Player && FactionsPlayerListener.preventCommand(commandString, (Player) sender) || super.handleCommand(sender, commandString, testOnly); - } - - @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] split) { - if (split.length == 0) { - return handleCommand(sender, "/f help", false); - } - - // otherwise, needs to be handled; presumably another plugin directly ran the command - 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; - - 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(); + // Our single plugin instance. + // Single 4 life. + public static P p; + public static Permission perms = null; + // This plugin sets the boolean true when fully enabled. + // Plugins can check this boolean while hooking in have + // a green light to use the api. + public static boolean startupFinished = false; + public static Economy econ = null; + public boolean PlaceholderApi; + // Commands + public FCmdRoot cmdBase; + public CmdAutoHelp cmdAutoHelp; + public boolean mc17 = false; + public boolean mc18 = false; + public boolean mc112 = false; + public boolean mc113 = false; + public boolean mc114 = false; + public boolean useNonPacketParticles = false; + public boolean factionsFlight = false; + SkriptAddon skriptAddon; + private FactionsPlayerListener factionsPlayerListener; + private boolean locked = false; + private boolean spam = false; + private Integer AutoLeaveTask = null; + private boolean hookedPlayervaults; + private ClipPlaceholderAPIManager clipPlaceholderAPIManager; + private boolean mvdwPlaceholderAPIManager = false; + private Listener[] eventsListener; + + + public P() { + p = this; + } + + public boolean getLocked() { + return this.locked; + } + + public void setLocked(boolean val) { + this.locked = val; + this.setAutoSave(val); + } + + public boolean getSpam() { + return this.spam; + } + + public void setSpam(boolean val) { + this.spam = val; + this.setAutoSave(val); + } + + public void playSoundForAll(String sound) { + for (Player pl : Bukkit.getOnlinePlayers()) { + playSound(pl, sound); + } + } + + public void playSoundForAll(List sounds) { + for (Player pl : Bukkit.getOnlinePlayers()) { + playSound(pl, sounds); + } + } + + public void playSound(Player p, List sounds) { + for (String sound : sounds) { + playSound(p, sound); + } + } + + public void playSound(Player p, String sound) { + float pitch = Float.valueOf(sound.split(":")[1]); + sound = sound.split(":")[0]; + p.playSound(p.getLocation(), Sound.valueOf(sound), pitch, 5.0F); + } + + @Override + public void onEnable() { + log("==== Setup ===="); + + + // Vault dependency check. + if (getServer().getPluginManager().getPlugin("Vault") == null) { + log("Vault is not present, the plugin will not run properly."); + getServer().getPluginManager().disablePlugin(p); + return; + } + + int version = Integer.parseInt(ReflectionUtils.PackageType.getServerVersion().split("_")[1]); + switch (version) { + case 7: + P.p.log("Minecraft Version 1.7 found, disabling banners, itemflags inside GUIs, and Titles."); + mc17 = true; + break; + case 8: + P.p.log("Minecraft Version 1.8 found, Title Fadeouttime etc will not be configurable."); + mc18 = true; + break; + case 12: + mc112 = true; + break; + case 13: + P.p.log("Minecraft Version 1.13 found, New Items will be used."); + mc113 = true; + break; + case 14: + P.p.log("Minecraft Version 1.14 found."); + mc114 = true; + break; + } + migrateFPlayerLeaders(); + log("==== End Setup ===="); + + if (!preEnable()) { + return; + } + this.loadSuccessful = false; + + saveDefaultConfig(); + + // Load Conf from disk + Conf.load(); + 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) { + log("Invalid faction id on " + fPlayer.getName() + ":" + fPlayer.getFactionId()); + fPlayer.resetFactionData(false); + continue; + } + if (fPlayer.isAlt()) { + faction.addAltPlayer(fPlayer); + } else { + faction.addFPlayer(fPlayer); + } + } + if (Conf.useCheckSystem) { + new CheckWallTask().runTaskTimerAsynchronously(this, 0L, 1200L); + this.log(Level.INFO, "Enabling Check Wall Timers!"); + } + + if (getConfig().getBoolean("enable-faction-flight", true)) { + UtilFly.run(); + } + + Board.getInstance().load(); + Board.getInstance().clean(); + + // Add Base Commands + this.cmdBase = new FCmdRoot(); + this.cmdAutoHelp = new CmdAutoHelp(); + this.getBaseCommands().add(cmdBase); + + Econ.setup(); + setupPermissions(); + + if (Conf.worldGuardChecking || Conf.worldGuardBuildPriority) { + Worldguard.init(this); + } + + EngineDynmap.getInstance().init(); + + // start up task which runs the autoLeaveAfterDaysOfInactivity routine + startAutoLeaveTask(false); + + if (version > 8) { + useNonPacketParticles = true; + log("Minecraft Version 1.9 or higher found, using non packet based particle API"); + } + + if (getConfig().getBoolean("enable-faction-flight")) { + factionsFlight = true; + } + + if (getServer().getPluginManager().getPlugin("Skript") != null) { + log("Skript was found! Registering P Addon..."); + skriptAddon = Skript.registerAddon(this); + try { + skriptAddon.loadClasses("com.massivecraft.factions.skript", "expressions"); + } catch (IOException ex) { + ex.printStackTrace(); + } + log("Skript addon registered!"); + } + + ShopConfig.setup(); + + getServer().getPluginManager().registerEvents(factionsPlayerListener = new FactionsPlayerListener(), this); + + // Register Event Handlers + eventsListener = new Listener[]{ + new FactionsChatListener(), + new FactionsEntityListener(), + new FactionsExploitListener(), + new FactionsBlockListener(), + new FUpgradesGUI(), + new EXPUpgrade(), + new CropUpgrades(), + new RedstoneUpgrade(), + new ShopClickPersistence(), + new MissionHandler(this), + new ChestLogsHandler(), + new SpawnerUpgrades() + }; + + for (Listener eventListener : eventsListener) + getServer().getPluginManager().registerEvents(eventListener, this); + + IEssentials ess = Essentials.setup(); + + if (ess != null && Conf.removeHomesOnLeave) { + getServer().getPluginManager().registerEvents(new EssentialsHomeHandler(ess), this); + } + + // since some other plugins execute commands directly through this command interface, provide it + getCommand(this.refCommand).setExecutor(this); + getCommand(this.refCommand).setTabCompleter(this); + + + RegisteredServiceProvider rsp = P.this.getServer().getServicesManager().getRegistration(Economy.class); + P.econ = rsp.getProvider(); + + if (getDescription().getFullName().contains("BETA")) { + divider(); + System.out.println("You are using a BETA version of the plugin!"); + System.out.println("This comes with risks of small bugs in newer features!"); + System.out.println("For support head to: https://github.com/Driftay/Saber-Factions/issues"); + divider(); + } + + this.setupPlaceholderAPI(); + this.postEnable(); + this.loadSuccessful = true; + // Set startup finished to true. to give plugins hooking in a greenlight + P.startupFinished = true; + } + + public SkriptAddon getSkriptAddon() { + return skriptAddon; + } + + + private void setupPlaceholderAPI() { + Plugin clip = getServer().getPluginManager().getPlugin("PlaceholderAPI"); + if (clip != null && clip.isEnabled()) { + this.clipPlaceholderAPIManager = new ClipPlaceholderAPIManager(); + if (this.clipPlaceholderAPIManager.register()) { + PlaceholderApi = true; + log(Level.INFO, "Successfully registered placeholders with PlaceholderAPI."); + } else { + PlaceholderApi = false; + } + } else { + PlaceholderApi = false; + } + + Plugin mvdw = getServer().getPluginManager().getPlugin("MVdWPlaceholderAPI"); + if (mvdw != null && mvdw.isEnabled()) { + this.mvdwPlaceholderAPIManager = true; + log(Level.INFO, "Found MVdWPlaceholderAPI. Adding hooks."); + } + } + + public List replacePlaceholders(List lore, Placeholder... placeholders) { + for (Placeholder placeholder : placeholders) { + for (int x = 0; x <= lore.size() - 1; x++) + lore.set(x, lore.get(x).replace(placeholder.getTag(), placeholder.getReplace())); + } + return lore; + } + + private void migrateFPlayerLeaders() { + List lines = new ArrayList<>(); + File fplayerFile = new File("plugins" + File.pathSeparator + "Factions" + File.pathSeparator + "players.json"); + + 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."); + } + } + + public boolean isClipPlaceholderAPIHooked() { + return this.clipPlaceholderAPIManager != null; + } + + public boolean isMVdWPlaceholderAPIHooked() { + return this.mvdwPlaceholderAPIManager; + } + + private boolean setupPermissions() { + try { + RegisteredServiceProvider rsp = getServer().getServicesManager().getRegistration(Permission.class); + if (rsp != null) { + perms = rsp.getProvider(); + } + } catch (NoClassDefFoundError ex) { + return false; + } + return perms != null; + } + + private boolean setupPlayervaults() { + Plugin plugin = getServer().getPluginManager().getPlugin("PlayerVaults"); + return plugin != null && plugin.isEnabled(); + } + + @Override + public GsonBuilder getGsonBuilder() { + Type mapFLocToStringSetType = new TypeToken>>() { + }.getType(); + + Type accessTypeAdatper = new TypeToken>>() { + }.getType(); + + return new GsonBuilder().setPrettyPrinting().disableHtmlEscaping().enableComplexMapKeySerialization().excludeFieldsWithModifiers(Modifier.TRANSIENT, Modifier.VOLATILE) + .registerTypeAdapter(accessTypeAdatper, new PermissionsMapTypeAdapter()) + .registerTypeAdapter(LazyLocation.class, new MyLocationTypeAdapter()) + .registerTypeAdapter(mapFLocToStringSetType, new MapFLocToStringSetTypeAdapter()) + .registerTypeAdapter(Inventory.class, new InventoryTypeAdapter()) + .registerTypeAdapter(Location.class, new LocationTypeAdapter()) + .registerTypeAdapterFactory(EnumTypeAdapter.ENUM_FACTORY); + } + + private void divider() { + System.out.println(" .-.-. .-.-. .-.-. .-.-. .-.-. .-.-. .-.-. .-.-"); + System.out.println(" / / \\ \\ / / \\ \\ / / \\ \\ / / \\ \\ / / \\ \\ / / \\ \\ / / \\ \\ / / \\"); + System.out.println("`-' `-`-' `-`-' `-`-' `-`-' `-`-' `-`-' `-`-'"); + } + + @Override + 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. + + // Conf.save(); + } + + if (AutoLeaveTask != null) { + this.getServer().getScheduler().cancelTask(AutoLeaveTask); + AutoLeaveTask = null; + } + + super.onDisable(); + } + + public void startAutoLeaveTask(boolean restartIfRunning) { + if (AutoLeaveTask != null) { + if (!restartIfRunning) { + return; + } + this.getServer().getScheduler().cancelTask(AutoLeaveTask); + } + + if (Conf.autoLeaveRoutineRunsEveryXMinutes > 0.0) { + long ticks = (long) (20 * 60 * Conf.autoLeaveRoutineRunsEveryXMinutes); + AutoLeaveTask = getServer().getScheduler().scheduleSyncRepeatingTask(this, new AutoLeaveTask(), ticks, ticks); + } + } + + @Override + public void postAutoSave() { + //Board.getInstance().forceSave(); Not sure why this was there as it's called after the board is already saved. + Conf.save(); + } + + public ItemStack createItem(Material material, int amount, short datavalue, String name, List lore) { + ItemStack item = new ItemStack(XMaterial.matchXMaterial(material.toString()).parseMaterial(), amount, datavalue); + ItemMeta meta = item.getItemMeta(); + meta.setDisplayName(color(name)); + meta.setLore(colorList(lore)); + item.setItemMeta(meta); + return item; + } + + public ItemStack createLazyItem(Material material, int amount, short datavalue, String name, String lore) { + ItemStack item = new ItemStack(material, amount, datavalue); + ItemMeta meta = item.getItemMeta(); + meta.setDisplayName(color(P.p.getConfig().getString(name))); + meta.setLore(colorList(P.p.getConfig().getStringList(lore))); + item.setItemMeta(meta); + return item; + } + + public Economy getEcon() { + RegisteredServiceProvider rsp = P.p.getServer().getServicesManager().getRegistration(Economy.class); + Economy econ = rsp.getProvider(); + return econ; + } + + + @Override + public boolean logPlayerCommands() { + return Conf.logPlayerCommands; + } + + @Override + public boolean handleCommand(CommandSender sender, String commandString, boolean testOnly) { + return sender instanceof Player && FactionsPlayerListener.preventCommand(commandString, (Player) sender) || super.handleCommand(sender, commandString, testOnly); + } + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] split) { + if (split.length == 0) { + return handleCommand(sender, "/f help", false); + } + + // otherwise, needs to be handled; presumably another plugin directly ran the command + 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; + + 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(); for (Player player : Bukkit.getServer().getOnlinePlayers()) { completions.add(player.getName()); } - completions = completions.stream() - .filter(m -> m.toLowerCase().startsWith(lastArg)) - .collect(Collectors.toList()); + completions = completions.stream() + .filter(m -> m.toLowerCase().startsWith(lastArg)) + .collect(Collectors.toList()); return completions; - } + } - public void createTimedHologram(final Location location, String text, Long timeout) { - ArmorStand as = (ArmorStand) location.add(0.5, 1, 0.5).getWorld().spawnEntity(location, EntityType.ARMOR_STAND); //Spawn the ArmorStand - as.setVisible(false); //Makes the ArmorStand invisible - as.setGravity(false); //Make sure it doesn't fall - as.setCanPickupItems(false); //I'm not sure what happens if you leave this as it is, but you might as well disable it - as.setCustomName(P.p.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; + public void createTimedHologram(final Location location, String text, Long timeout) { + ArmorStand as = (ArmorStand) location.add(0.5, 1, 0.5).getWorld().spawnEntity(location, EntityType.ARMOR_STAND); //Spawn the ArmorStand + as.setVisible(false); //Makes the ArmorStand invisible + as.setGravity(false); //Make sure it doesn't fall + as.setCanPickupItems(false); //I'm not sure what happens if you leave this as it is, but you might as well disable it + as.setCustomName(P.p.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(P.p, () -> { - armorStand.remove(); - getLogger().info("Removing Hologram."); - } - , timeout * 20); - } + Bukkit.getScheduler().scheduleSyncDelayedTask(P.p, () -> { + armorStand.remove(); + getLogger().info("Removing Hologram."); + } + , timeout * 20); + } - // -------------------------------------------- // - // Functions for other plugins to hook into - // -------------------------------------------- // + // -------------------------------------------- // + // Functions for other plugins to hook into + // -------------------------------------------- // - // This value will be updated whenever new hooks are added - public int hookSupportVersion() { - return 3; - } + // This value will be updated whenever new hooks are added + public int hookSupportVersion() { + return 3; + } - // If another plugin is handling insertion of chat tags, this should be used to notify Factions - public void handleFactionTagExternally(boolean notByFactions) { - Conf.chatTagHandledByAnotherPlugin = notByFactions; - } + // If another plugin is handling insertion of chat tags, this should be used to notify Factions + public void handleFactionTagExternally(boolean notByFactions) { + Conf.chatTagHandledByAnotherPlugin = notByFactions; + } - // Simply put, should this chat event be left for Factions to handle? For now, that means players with Faction Chat - // enabled or use of the Factions f command without a slash; combination of isPlayerFactionChatting() and isFactionsCommand() + // Simply put, should this chat event be left for Factions to handle? For now, that means players with Faction Chat + // enabled or use of the Factions f command without a slash; combination of isPlayerFactionChatting() and isFactionsCommand() - public boolean shouldLetFactionsHandleThisChat(AsyncPlayerChatEvent event) { - return event != null && (isPlayerFactionChatting(event.getPlayer()) || isFactionsCommand(event.getMessage())); - } + public boolean shouldLetFactionsHandleThisChat(AsyncPlayerChatEvent event) { + return event != null && (isPlayerFactionChatting(event.getPlayer()) || isFactionsCommand(event.getMessage())); + } - // Does player have Faction Chat enabled? If so, chat plugins should preferably not do channels, - // local chat, or anything else which targets individual recipients, so Faction Chat can be done - public boolean isPlayerFactionChatting(Player player) { - if (player == null) { - return false; - } - FPlayer me = FPlayers.getInstance().getByPlayer(player); + // Does player have Faction Chat enabled? If so, chat plugins should preferably not do channels, + // local chat, or anything else which targets individual recipients, so Faction Chat can be done + public boolean isPlayerFactionChatting(Player player) { + if (player == null) { + return false; + } + FPlayer me = FPlayers.getInstance().getByPlayer(player); - return me != null && me.getChatMode().isAtLeast(ChatMode.ALLIANCE); - } + return me != null && me.getChatMode().isAtLeast(ChatMode.ALLIANCE); + } - // Is this chat message actually a Factions command, and thus should be left alone by other plugins? + // Is this chat message actually a Factions command, and thus should be left alone by other plugins? - // TODO: GET THIS BACK AND WORKING + // TODO: GET THIS BACK AND WORKING - public boolean isFactionsCommand(String check) { - return !(check == null || check.isEmpty()) && this.handleCommand(null, check, true); - } + public boolean isFactionsCommand(String check) { + return !(check == null || check.isEmpty()) && this.handleCommand(null, check, true); + } - // Get a player's faction tag (faction name), mainly for usage by chat plugins for local/channel chat - public String getPlayerFactionTag(Player player) { - return getPlayerFactionTagRelation(player, null); - } + // Get a player's faction tag (faction name), mainly for usage by chat plugins for local/channel chat + public String getPlayerFactionTag(Player player) { + return getPlayerFactionTagRelation(player, null); + } - // Same as above, but with relation (enemy/neutral/ally) coloring potentially added to the tag - public String getPlayerFactionTagRelation(Player speaker, Player listener) { - String tag = "~"; + // Same as above, but with relation (enemy/neutral/ally) coloring potentially added to the tag + public String getPlayerFactionTagRelation(Player speaker, Player listener) { + String tag = "~"; - if (speaker == null) { - return tag; - } + if (speaker == null) { + return tag; + } - FPlayer me = FPlayers.getInstance().getByPlayer(speaker); - if (me == null) { - return tag; - } + FPlayer me = FPlayers.getInstance().getByPlayer(speaker); + if (me == null) { + return tag; + } - // if listener isn't set, or config option is disabled, give back uncolored tag - if (listener == null || !Conf.chatTagRelationColored) { - tag = me.getChatTag().trim(); - } else { - FPlayer you = FPlayers.getInstance().getByPlayer(listener); - if (you == null) { - tag = me.getChatTag().trim(); - } else // everything checks out, give the colored tag - { - tag = me.getChatTag(you).trim(); - } - } - if (tag.isEmpty()) { - tag = "~"; - } + // if listener isn't set, or config option is disabled, give back uncolored tag + if (listener == null || !Conf.chatTagRelationColored) { + tag = me.getChatTag().trim(); + } else { + FPlayer you = FPlayers.getInstance().getByPlayer(listener); + if (you == null) { + tag = me.getChatTag().trim(); + } else // everything checks out, give the colored tag + { + tag = me.getChatTag(you).trim(); + } + } + if (tag.isEmpty()) { + tag = "~"; + } - return tag; - } + return tag; + } - // Get a player's title within their faction, mainly for usage by chat plugins for local/channel chat - public String getPlayerTitle(Player player) { - if (player == null) { - return ""; - } + // Get a player's title within their faction, mainly for usage by chat plugins for local/channel chat + public String getPlayerTitle(Player player) { + if (player == null) { + return ""; + } - FPlayer me = FPlayers.getInstance().getByPlayer(player); - if (me == null) { - return ""; - } + FPlayer me = FPlayers.getInstance().getByPlayer(player); + if (me == null) { + return ""; + } - return me.getTitle().trim(); - } + return me.getTitle().trim(); + } - public String color(String line) { - line = ChatColor.translateAlternateColorCodes('&', line); - return line; - } + public String color(String line) { + line = ChatColor.translateAlternateColorCodes('&', line); + return line; + } - //colors a string list - public List colorList(List lore) { - for (int i = 0; i <= lore.size() - 1; i++) { - lore.set(i, color(lore.get(i))); - } - return lore; - } + //colors a string list + public List colorList(List lore) { + for (int i = 0; i <= lore.size() - 1; i++) { + lore.set(i, color(lore.get(i))); + } + return lore; + } - // Get a list of all faction tags (names) - public Set getFactionTags() { - return Factions.getInstance().getFactionTags(); - } + // Get a list of all faction tags (names) + public Set getFactionTags() { + return Factions.getInstance().getFactionTags(); + } - // Get a list of all players in the specified faction - public Set getPlayersInFaction(String factionTag) { - Set players = new HashSet<>(); - Faction faction = Factions.getInstance().getByTag(factionTag); - if (faction != null) { - for (FPlayer fplayer : faction.getFPlayers()) { - players.add(fplayer.getName()); - } - } - return players; - } + // Get a list of all players in the specified faction + public Set getPlayersInFaction(String factionTag) { + Set players = new HashSet<>(); + Faction faction = Factions.getInstance().getByTag(factionTag); + if (faction != null) { + for (FPlayer fplayer : faction.getFPlayers()) { + players.add(fplayer.getName()); + } + } + return players; + } - // Get a list of all online players in the specified faction - public Set getOnlinePlayersInFaction(String factionTag) { - Set players = new HashSet<>(); - Faction faction = Factions.getInstance().getByTag(factionTag); - if (faction != null) { - for (FPlayer fplayer : faction.getFPlayersWhereOnline(true)) { - players.add(fplayer.getName()); - } - } - return players; - } + // Get a list of all online players in the specified faction + public Set getOnlinePlayersInFaction(String factionTag) { + Set players = new HashSet<>(); + Faction faction = Factions.getInstance().getByTag(factionTag); + if (faction != null) { + for (FPlayer fplayer : faction.getFPlayersWhereOnline(true)) { + players.add(fplayer.getName()); + } + } + return players; + } - public boolean isHookedPlayervaults() { - return hookedPlayervaults; - } + public boolean isHookedPlayervaults() { + return hookedPlayervaults; + } - public String getPrimaryGroup(OfflinePlayer player) { - AtomicReference primaryGroup = new AtomicReference<>(); + public String getPrimaryGroup(OfflinePlayer player) { + AtomicReference primaryGroup = new AtomicReference<>(); - if (perms == null || !perms.hasGroupSupport()) return " "; - else { - Bukkit.getScheduler().runTaskAsynchronously(this, () -> primaryGroup.set(perms.getPrimaryGroup(Bukkit.getWorlds().get(0).toString(), player))); - return primaryGroup.get(); - } - } + if (perms == null || !perms.hasGroupSupport()) return " "; + else { + Bukkit.getScheduler().runTaskAsynchronously(this, () -> primaryGroup.set(perms.getPrimaryGroup(Bukkit.getWorlds().get(0).toString(), player))); + return primaryGroup.get(); + } + } - public void debug(Level level, String s) { - if (getConfig().getBoolean("debug", false)) { - getLogger().log(level, s); - } - } - public FactionsPlayerListener getFactionsPlayerListener() { - return this.factionsPlayerListener; - } + public void debug(Level level, String s) { + if (getConfig().getBoolean("debug", false)) { + getLogger().log(level, s); + } + } - public void debug(String s) { - debug(Level.INFO, s); - } + public FactionsPlayerListener getFactionsPlayerListener() { + return this.factionsPlayerListener; + } + + public void debug(String s) { + debug(Level.INFO, s); + } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdAHome.java b/src/main/java/com/massivecraft/factions/cmd/CmdAHome.java index ceffd489..2e305f66 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdAHome.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdAHome.java @@ -8,46 +8,46 @@ import org.bukkit.event.player.PlayerTeleportEvent; public class CmdAHome extends FCommand { - public CmdAHome() { - super(); - this.aliases.add("ahome"); + public CmdAHome() { + super(); + this.aliases.add("ahome"); - this.requiredArgs.add("player name"); + this.requiredArgs.add("player name"); - this.permission = Permission.AHOME.node; - this.disableOnLock = false; - this.disableOnSpam = false; + this.permission = Permission.AHOME.node; + this.disableOnLock = false; + this.disableOnSpam = false; - senderMustBePlayer = false; - senderMustBeMember = false; - senderMustBeModerator = false; - senderMustBeAdmin = false; - } + senderMustBePlayer = false; + senderMustBeMember = false; + senderMustBeModerator = false; + senderMustBeAdmin = false; + } - @Override - public void perform() { - FPlayer target = argAsBestFPlayerMatch(0); - if (target == null) { - msg(TL.GENERIC_NOPLAYERMATCH, argAsString(0)); - return; - } + @Override + public void perform() { + FPlayer target = argAsBestFPlayerMatch(0); + if (target == null) { + msg(TL.GENERIC_NOPLAYERMATCH, argAsString(0)); + return; + } - if (target.isOnline()) { - Faction faction = target.getFaction(); - if (faction.hasHome()) { - target.getPlayer().teleport(faction.getHome(), PlayerTeleportEvent.TeleportCause.PLUGIN); - msg(TL.COMMAND_AHOME_SUCCESS, target.getName()); - target.msg(TL.COMMAND_AHOME_TARGET); - } else { - msg(TL.COMMAND_AHOME_NOHOME, target.getName()); - } - } else { - msg(TL.COMMAND_AHOME_OFFLINE, target.getName()); - } - } + if (target.isOnline()) { + Faction faction = target.getFaction(); + if (faction.hasHome()) { + target.getPlayer().teleport(faction.getHome(), PlayerTeleportEvent.TeleportCause.PLUGIN); + msg(TL.COMMAND_AHOME_SUCCESS, target.getName()); + target.msg(TL.COMMAND_AHOME_TARGET); + } else { + msg(TL.COMMAND_AHOME_NOHOME, target.getName()); + } + } else { + msg(TL.COMMAND_AHOME_OFFLINE, target.getName()); + } + } - @Override - public TL getUsageTranslation() { - return TL.COMMAND_AHOME_DESCRIPTION; - } + @Override + public TL getUsageTranslation() { + return TL.COMMAND_AHOME_DESCRIPTION; + } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdAdmin.java b/src/main/java/com/massivecraft/factions/cmd/CmdAdmin.java index 6a19b127..26be8ede 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdAdmin.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdAdmin.java @@ -12,95 +12,95 @@ import org.bukkit.ChatColor; public class CmdAdmin extends FCommand { - public CmdAdmin() { - super(); - this.aliases.add("admin"); - this.aliases.add("setadmin"); - this.aliases.add("leader"); - this.aliases.add("setleader"); + public CmdAdmin() { + super(); + this.aliases.add("admin"); + this.aliases.add("setadmin"); + this.aliases.add("leader"); + this.aliases.add("setleader"); - this.requiredArgs.add("player name"); + this.requiredArgs.add("player name"); - this.permission = Permission.ADMIN.node; - this.disableOnLock = true; - this.disableOnSpam = true; + this.permission = Permission.ADMIN.node; + this.disableOnLock = true; + this.disableOnSpam = true; - senderMustBePlayer = false; - senderMustBeMember = false; - senderMustBeModerator = false; - senderMustBeAdmin = false; - } + senderMustBePlayer = false; + senderMustBeMember = false; + senderMustBeModerator = false; + senderMustBeAdmin = false; + } - @Override - public void perform() { - FPlayer fyou = this.argAsBestFPlayerMatch(0); - if (fyou == null || fyou.getFaction().isWarZone() || fyou.getFaction().isWilderness() || fyou.getFaction().isSafeZone()) { - return; - } + @Override + public void perform() { + FPlayer fyou = this.argAsBestFPlayerMatch(0); + if (fyou == null || fyou.getFaction().isWarZone() || fyou.getFaction().isWilderness() || fyou.getFaction().isSafeZone()) { + return; + } - boolean permAny = Permission.ADMIN_ANY.has(sender, false); - Faction targetFaction = fyou.getFaction(); + boolean permAny = Permission.ADMIN_ANY.has(sender, false); + Faction targetFaction = fyou.getFaction(); - if(fyou.isAlt()){ - msg(ChatColor.RED + "You can not promote alt accounts."); - return; - } + if (fyou.isAlt()) { + msg(ChatColor.RED + "You can not promote alt accounts."); + return; + } - if (targetFaction != myFaction && !permAny) { - msg(TL.COMMAND_ADMIN_NOTMEMBER, fyou.describeTo(fme, true)); - return; - } + if (targetFaction != myFaction && !permAny) { + msg(TL.COMMAND_ADMIN_NOTMEMBER, fyou.describeTo(fme, true)); + return; + } - if (fme != null && fme.getRole() != Role.LEADER && !permAny) { - msg(TL.COMMAND_ADMIN_NOTADMIN); - return; - } + if (fme != null && fme.getRole() != Role.LEADER && !permAny) { + msg(TL.COMMAND_ADMIN_NOTADMIN); + return; + } - if (fyou == fme && !permAny) { - msg(TL.COMMAND_ADMIN_TARGETSELF); - return; - } + if (fyou == fme && !permAny) { + msg(TL.COMMAND_ADMIN_TARGETSELF); + return; + } - // only perform a FPlayerJoinEvent when newLeader isn't actually in the faction - if (fyou.getFaction() != targetFaction) { - FPlayerJoinEvent event = new FPlayerJoinEvent(FPlayers.getInstance().getByPlayer(me), targetFaction, FPlayerJoinEvent.PlayerJoinReason.LEADER); - Bukkit.getServer().getPluginManager().callEvent(event); - if (event.isCancelled()) { - return; - } - } + // only perform a FPlayerJoinEvent when newLeader isn't actually in the faction + if (fyou.getFaction() != targetFaction) { + FPlayerJoinEvent event = new FPlayerJoinEvent(FPlayers.getInstance().getByPlayer(me), targetFaction, FPlayerJoinEvent.PlayerJoinReason.LEADER); + Bukkit.getServer().getPluginManager().callEvent(event); + if (event.isCancelled()) { + return; + } + } - FPlayer admin = targetFaction.getFPlayerAdmin(); + FPlayer admin = targetFaction.getFPlayerAdmin(); - if (fyou == admin && fyou.getFaction().getSize() == 1) { - msg(TL.COMMAND_ADMIN_NOMEMBERS); - return; - } + if (fyou == admin && fyou.getFaction().getSize() == 1) { + msg(TL.COMMAND_ADMIN_NOMEMBERS); + return; + } - // if target player is currently admin, demote and replace him - if (fyou == admin) { - targetFaction.promoteNewLeader(); - msg(TL.COMMAND_ADMIN_DEMOTES, fyou.describeTo(fme, true)); - fyou.msg(TL.COMMAND_ADMIN_DEMOTED, senderIsConsole ? TL.GENERIC_SERVERADMIN.toString() : fme.describeTo(fyou, true)); - return; - } + // if target player is currently admin, demote and replace him + if (fyou == admin) { + targetFaction.promoteNewLeader(); + msg(TL.COMMAND_ADMIN_DEMOTES, fyou.describeTo(fme, true)); + fyou.msg(TL.COMMAND_ADMIN_DEMOTED, senderIsConsole ? TL.GENERIC_SERVERADMIN.toString() : fme.describeTo(fyou, true)); + return; + } - // promote target player, and demote existing admin if one exists - if (admin != null) { - admin.setRole(Role.COLEADER); - } - fyou.setRole(Role.LEADER); - msg(TL.COMMAND_ADMIN_PROMOTES, fyou.describeTo(fme, true)); + // promote target player, and demote existing admin if one exists + if (admin != null) { + admin.setRole(Role.COLEADER); + } + fyou.setRole(Role.LEADER); + msg(TL.COMMAND_ADMIN_PROMOTES, fyou.describeTo(fme, true)); - // Inform all players - for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers()) { - fplayer.msg(TL.COMMAND_ADMIN_PROMOTED, senderIsConsole ? TL.GENERIC_SERVERADMIN.toString() : fme.describeTo(fplayer, true), fyou.describeTo(fplayer), targetFaction.describeTo(fplayer)); - } - } + // Inform all players + for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers()) { + fplayer.msg(TL.COMMAND_ADMIN_PROMOTED, senderIsConsole ? TL.GENERIC_SERVERADMIN.toString() : fme.describeTo(fplayer, true), fyou.describeTo(fplayer), targetFaction.describeTo(fplayer)); + } + } - public TL getUsageTranslation() { - return TL.COMMAND_ADMIN_DESCRIPTION; - } + public TL getUsageTranslation() { + return TL.COMMAND_ADMIN_DESCRIPTION; + } } \ No newline at end of file diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdAnnounce.java b/src/main/java/com/massivecraft/factions/cmd/CmdAnnounce.java index a9eaa6bf..6924fcf2 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdAnnounce.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdAnnounce.java @@ -9,42 +9,42 @@ import org.bukkit.entity.Player; public class CmdAnnounce extends FCommand { - public CmdAnnounce() { - super(); - this.aliases.add("ann"); - this.aliases.add("announce"); + public CmdAnnounce() { + super(); + this.aliases.add("ann"); + this.aliases.add("announce"); - this.requiredArgs.add("message"); - this.errorOnToManyArgs = false; + this.requiredArgs.add("message"); + this.errorOnToManyArgs = false; - this.permission = Permission.ANNOUNCE.node; - this.disableOnLock = false; - this.disableOnSpam = false; + this.permission = Permission.ANNOUNCE.node; + this.disableOnLock = false; + this.disableOnSpam = false; - senderMustBePlayer = true; - senderMustBeMember = true; - senderMustBeModerator = false; - senderMustBeColeader = false; - } + senderMustBePlayer = true; + senderMustBeMember = true; + senderMustBeModerator = false; + senderMustBeColeader = false; + } - @Override - public void perform() { - String prefix = ChatColor.GREEN + myFaction.getTag() + ChatColor.YELLOW + " [" + ChatColor.GRAY + me.getName() + ChatColor.YELLOW + "] " + ChatColor.RESET; - String message = StringUtils.join(args, " "); + @Override + public void perform() { + String prefix = ChatColor.GREEN + myFaction.getTag() + ChatColor.YELLOW + " [" + ChatColor.GRAY + me.getName() + ChatColor.YELLOW + "] " + ChatColor.RESET; + String message = StringUtils.join(args, " "); - for (Player player : myFaction.getOnlinePlayers()) { - player.sendMessage(prefix + message); - } + for (Player player : myFaction.getOnlinePlayers()) { + player.sendMessage(prefix + message); + } - // Add for offline players. - for (FPlayer fp : myFaction.getFPlayersWhereOnline(false)) { - myFaction.addAnnouncement(fp, prefix + message); - } - } + // Add for offline players. + for (FPlayer fp : myFaction.getFPlayersWhereOnline(false)) { + myFaction.addAnnouncement(fp, prefix + message); + } + } - @Override - public TL getUsageTranslation() { - return TL.COMMAND_ANNOUNCE_DESCRIPTION; - } + @Override + public TL getUsageTranslation() { + return TL.COMMAND_ANNOUNCE_DESCRIPTION; + } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdAutoHelp.java b/src/main/java/com/massivecraft/factions/cmd/CmdAutoHelp.java index 193843fe..22b7653d 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdAutoHelp.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdAutoHelp.java @@ -9,38 +9,38 @@ import java.util.ArrayList; public class CmdAutoHelp extends MCommand

{ - public CmdAutoHelp() { - super(P.p); - this.aliases.add("?"); - this.aliases.add("h"); - this.aliases.add("help"); + public CmdAutoHelp() { + super(P.p); + this.aliases.add("?"); + this.aliases.add("h"); + this.aliases.add("help"); - this.setHelpShort(""); + this.setHelpShort(""); - this.optionalArgs.put("page", "1"); - } + this.optionalArgs.put("page", "1"); + } - @Override - public void perform() { + @Override + public void perform() { - if (this.commandChain.size() == 0) { - return; - } - MCommand pcmd = this.commandChain.get(this.commandChain.size() - 1); + if (this.commandChain.size() == 0) { + return; + } + MCommand pcmd = this.commandChain.get(this.commandChain.size() - 1); - ArrayList lines = new ArrayList<>(pcmd.helpLong); + ArrayList lines = new ArrayList<>(pcmd.helpLong); - for (MCommand scmd : pcmd.subCommands) { - if (scmd.visibility == CommandVisibility.VISIBLE || (scmd.visibility == CommandVisibility.SECRET && scmd.validSenderPermissions(sender, false))) { - lines.add(scmd.getUseageTemplate(this.commandChain, true)); - } - } + for (MCommand scmd : pcmd.subCommands) { + if (scmd.visibility == CommandVisibility.VISIBLE || (scmd.visibility == CommandVisibility.SECRET && scmd.validSenderPermissions(sender, false))) { + lines.add(scmd.getUseageTemplate(this.commandChain, true)); + } + } - sendMessage(p.txt.getPage(lines, this.argAsInt(0, 1), TL.COMMAND_AUTOHELP_HELPFOR.toString() + pcmd.aliases.get(0) + "\"")); - } + sendMessage(p.txt.getPage(lines, this.argAsInt(0, 1), TL.COMMAND_AUTOHELP_HELPFOR.toString() + pcmd.aliases.get(0) + "\"")); + } - @Override - public TL getUsageTranslation() { - return TL.COMMAND_HELP_DESCRIPTION; - } + @Override + public TL getUsageTranslation() { + return TL.COMMAND_HELP_DESCRIPTION; + } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdBan.java b/src/main/java/com/massivecraft/factions/cmd/CmdBan.java index 94305d1b..80cdd283 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdBan.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdBan.java @@ -15,88 +15,88 @@ import java.util.logging.Level; public class CmdBan extends FCommand { - public CmdBan() { - super(); - this.aliases.add("ban"); + public CmdBan() { + super(); + this.aliases.add("ban"); - this.requiredArgs.add("target"); + this.requiredArgs.add("target"); - this.permission = Permission.BAN.node; - this.disableOnLock = true; - this.disableOnSpam = false; + this.permission = Permission.BAN.node; + this.disableOnLock = true; + this.disableOnSpam = false; - senderMustBePlayer = true; - senderMustBeMember = false; - senderMustBeModerator = false; - senderMustBeColeader = false; - senderMustBeAdmin = false; - } + senderMustBePlayer = true; + senderMustBeMember = false; + senderMustBeModerator = false; + senderMustBeColeader = false; + senderMustBeAdmin = false; + } - @Override - public void perform() { + @Override + public void perform() { - // Adds bypass to admins and clean permission check - if (!fme.isAdminBypassing()) { - Access access = myFaction.getAccess(fme, PermissableAction.BAN); - if (access != Access.ALLOW && fme.getRole() != Role.LEADER) { - fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "ban"); - return; - } - } + // Adds bypass to admins and clean permission check + if (!fme.isAdminBypassing()) { + Access access = myFaction.getAccess(fme, PermissableAction.BAN); + if (access != Access.ALLOW && fme.getRole() != Role.LEADER) { + fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "ban"); + return; + } + } - // Good on permission checks. Now lets just ban the player. - FPlayer target = argAsFPlayer(0); - if (target == null) { - return; // the above method sends a message if fails to find someone. - } + // Good on permission checks. Now lets just ban the player. + FPlayer target = argAsFPlayer(0); + if (target == null) { + return; // the above method sends a message if fails to find someone. + } - if (fme == target) { - // You may not ban yourself - fme.msg(TL.COMMAND_BAN_SELF); - return; - } else if (target.getFaction() == myFaction && target.getRole().value >= fme.getRole().value) { - // You may not ban someone that has same or higher faction rank - fme.msg(TL.COMMAND_BAN_INSUFFICIENTRANK, target.getName()); - return; - } + if (fme == target) { + // You may not ban yourself + fme.msg(TL.COMMAND_BAN_SELF); + return; + } else if (target.getFaction() == myFaction && target.getRole().value >= fme.getRole().value) { + // You may not ban someone that has same or higher faction rank + fme.msg(TL.COMMAND_BAN_INSUFFICIENTRANK, target.getName()); + return; + } - for (BanInfo banInfo : myFaction.getBannedPlayers()) { - if (banInfo.getBanned().equals(target.getId())) { - msg(TL.COMMAND_BAN_ALREADYBANNED); - return; - } - } + for (BanInfo banInfo : myFaction.getBannedPlayers()) { + if (banInfo.getBanned().equals(target.getId())) { + msg(TL.COMMAND_BAN_ALREADYBANNED); + return; + } + } - // Ban the user. - myFaction.ban(target, fme); - myFaction.deinvite(target); // can't hurt + // Ban the user. + myFaction.ban(target, fme); + myFaction.deinvite(target); // can't hurt - // If in same Faction, lets make sure to kick them and throw an event. - if (target.getFaction() == myFaction) { + // If in same Faction, lets make sure to kick them and throw an event. + if (target.getFaction() == myFaction) { - FPlayerLeaveEvent event = new FPlayerLeaveEvent(target, myFaction, FPlayerLeaveEvent.PlayerLeaveReason.BANNED); - Bukkit.getServer().getPluginManager().callEvent(event); + FPlayerLeaveEvent event = new FPlayerLeaveEvent(target, myFaction, FPlayerLeaveEvent.PlayerLeaveReason.BANNED); + Bukkit.getServer().getPluginManager().callEvent(event); - if (event.isCancelled()) { - // if someone cancels a ban, we'll get people complaining here. So lets log it. - P.p.log(Level.WARNING, "Attempted to ban {0} but someone cancelled the kick event. This isn't good.", target.getName()); - return; - } + if (event.isCancelled()) { + // if someone cancels a ban, we'll get people complaining here. So lets log it. + P.p.log(Level.WARNING, "Attempted to ban {0} but someone cancelled the kick event. This isn't good.", target.getName()); + return; + } - // Didn't get cancelled so remove them and reset their invite. - myFaction.removeFPlayer(target); - target.resetFactionData(); - } + // Didn't get cancelled so remove them and reset their invite. + myFaction.removeFPlayer(target); + target.resetFactionData(); + } - // Lets inform the people! - target.msg(TL.COMMAND_BAN_TARGET, myFaction.getTag(target.getFaction())); - myFaction.msg(TL.COMMAND_BAN_BANNED, fme.getName(), target.getName()); - } + // Lets inform the people! + target.msg(TL.COMMAND_BAN_TARGET, myFaction.getTag(target.getFaction())); + myFaction.msg(TL.COMMAND_BAN_BANNED, fme.getName(), target.getName()); + } - @Override - public TL getUsageTranslation() { - return TL.COMMAND_BAN_DESCRIPTION; - } + @Override + public TL getUsageTranslation() { + return TL.COMMAND_BAN_DESCRIPTION; + } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdBanlist.java b/src/main/java/com/massivecraft/factions/cmd/CmdBanlist.java index 2c342705..c5586b35 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdBanlist.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdBanlist.java @@ -13,61 +13,61 @@ import java.util.List; public class CmdBanlist extends FCommand { - public CmdBanlist() { - super(); - this.aliases.add("banlist"); - this.aliases.add("bans"); - this.aliases.add("banl"); + public CmdBanlist() { + super(); + this.aliases.add("banlist"); + this.aliases.add("bans"); + this.aliases.add("banl"); - this.optionalArgs.put("faction", "faction"); + this.optionalArgs.put("faction", "faction"); - this.permission = Permission.BAN.node; - this.disableOnLock = true; - this.disableOnSpam = false; + this.permission = Permission.BAN.node; + this.disableOnLock = true; + this.disableOnSpam = false; - senderMustBePlayer = true; - senderMustBeMember = false; - senderMustBeModerator = false; - senderMustBeAdmin = false; - } + senderMustBePlayer = true; + senderMustBeMember = false; + senderMustBeModerator = false; + senderMustBeAdmin = false; + } - @Override - public void perform() { - Faction target = myFaction; - if (!args.isEmpty()) { - target = argAsFaction(0); - } + @Override + public void perform() { + Faction target = myFaction; + if (!args.isEmpty()) { + target = argAsFaction(0); + } - if (target == Factions.getInstance().getWilderness()) { - sender.sendMessage(TL.COMMAND_BANLIST_NOFACTION.toString()); - return; - } + if (target == Factions.getInstance().getWilderness()) { + sender.sendMessage(TL.COMMAND_BANLIST_NOFACTION.toString()); + return; + } - if (target == null) { - sender.sendMessage(TL.COMMAND_BANLIST_INVALID.format(argAsString(0))); - return; - } + if (target == null) { + sender.sendMessage(TL.COMMAND_BANLIST_INVALID.format(argAsString(0))); + return; + } - List lines = new ArrayList<>(); - lines.add(TL.COMMAND_BANLIST_HEADER.format(target.getBannedPlayers().size(), target.getTag(myFaction))); - int i = 1; + List lines = new ArrayList<>(); + lines.add(TL.COMMAND_BANLIST_HEADER.format(target.getBannedPlayers().size(), target.getTag(myFaction))); + int i = 1; - for (BanInfo info : target.getBannedPlayers()) { - FPlayer banned = FPlayers.getInstance().getById(info.getBanned()); - FPlayer banner = FPlayers.getInstance().getById(info.getBanner()); - String timestamp = TL.sdf.format(info.getTime()); + for (BanInfo info : target.getBannedPlayers()) { + FPlayer banned = FPlayers.getInstance().getById(info.getBanned()); + FPlayer banner = FPlayers.getInstance().getById(info.getBanner()); + String timestamp = TL.sdf.format(info.getTime()); - lines.add(TL.COMMAND_BANLIST_ENTRY.format(i, banned.getName(), banner.getName(), timestamp)); - i++; - } + lines.add(TL.COMMAND_BANLIST_ENTRY.format(i, banned.getName(), banner.getName(), timestamp)); + i++; + } - for (String s : lines) { - fme.sendMessage(s); - } - } + for (String s : lines) { + fme.sendMessage(s); + } + } - @Override - public TL getUsageTranslation() { - return TL.COMMAND_BANLIST_DESCRIPTION; - } + @Override + public TL getUsageTranslation() { + return TL.COMMAND_BANLIST_DESCRIPTION; + } } \ No newline at end of file diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdBoom.java b/src/main/java/com/massivecraft/factions/cmd/CmdBoom.java index 514a5c67..fcbe859f 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdBoom.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdBoom.java @@ -6,47 +6,47 @@ import com.massivecraft.factions.zcore.util.TL; public class CmdBoom extends FCommand { - public CmdBoom() { - super(); - this.aliases.add("noboom"); - this.aliases.add("explosions"); - this.aliases.add("toggleexplosions"); + public CmdBoom() { + super(); + this.aliases.add("noboom"); + this.aliases.add("explosions"); + this.aliases.add("toggleexplosions"); - //this.requiredArgs.add(""); - this.optionalArgs.put("on/off", "flip"); + //this.requiredArgs.add(""); + this.optionalArgs.put("on/off", "flip"); - this.permission = Permission.NO_BOOM.node; - this.disableOnLock = true; + this.permission = Permission.NO_BOOM.node; + this.disableOnLock = true; - senderMustBePlayer = true; - senderMustBeMember = false; - senderMustBeModerator = false; - senderMustBeColeader = true; - senderMustBeAdmin = false; - } + senderMustBePlayer = true; + senderMustBeMember = false; + senderMustBeModerator = false; + senderMustBeColeader = true; + senderMustBeAdmin = false; + } - @Override - public void perform() { - if (!myFaction.isPeaceful()) { - fme.msg(TL.COMMAND_BOOM_PEACEFULONLY); - return; - } + @Override + public void perform() { + if (!myFaction.isPeaceful()) { + fme.msg(TL.COMMAND_BOOM_PEACEFULONLY); + return; + } - // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay - if (!payForCommand(Conf.econCostNoBoom, TL.COMMAND_BOOM_TOTOGGLE, TL.COMMAND_BOOM_FORTOGGLE)) { - return; - } + // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay + if (!payForCommand(Conf.econCostNoBoom, TL.COMMAND_BOOM_TOTOGGLE, TL.COMMAND_BOOM_FORTOGGLE)) { + return; + } - myFaction.setPeacefulExplosionsEnabled(this.argAsBool(0, !myFaction.getPeacefulExplosionsEnabled())); + myFaction.setPeacefulExplosionsEnabled(this.argAsBool(0, !myFaction.getPeacefulExplosionsEnabled())); - String enabled = myFaction.noExplosionsInTerritory() ? TL.GENERIC_DISABLED.toString() : TL.GENERIC_ENABLED.toString(); + String enabled = myFaction.noExplosionsInTerritory() ? TL.GENERIC_DISABLED.toString() : TL.GENERIC_ENABLED.toString(); - // Inform - myFaction.msg(TL.COMMAND_BOOM_ENABLED, fme.describeTo(myFaction), enabled); - } + // Inform + myFaction.msg(TL.COMMAND_BOOM_ENABLED, fme.describeTo(myFaction), enabled); + } - @Override - public TL getUsageTranslation() { - return TL.COMMAND_BOOM_DESCRIPTION; - } + @Override + public TL getUsageTranslation() { + return TL.COMMAND_BOOM_DESCRIPTION; + } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdBypass.java b/src/main/java/com/massivecraft/factions/cmd/CmdBypass.java index 4899eef1..6c7ea644 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdBypass.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdBypass.java @@ -6,39 +6,39 @@ import com.massivecraft.factions.zcore.util.TL; public class CmdBypass extends FCommand { - public CmdBypass() { - super(); - this.aliases.add("bypass"); + public CmdBypass() { + super(); + this.aliases.add("bypass"); - //this.requiredArgs.add(""); - this.optionalArgs.put("on/off", "flip"); + //this.requiredArgs.add(""); + this.optionalArgs.put("on/off", "flip"); - this.permission = Permission.BYPASS.node; - this.disableOnLock = false; + this.permission = Permission.BYPASS.node; + this.disableOnLock = false; - senderMustBePlayer = true; - senderMustBeMember = false; - senderMustBeModerator = false; - senderMustBeColeader = false; - senderMustBeAdmin = false; - } + senderMustBePlayer = true; + senderMustBeMember = false; + senderMustBeModerator = false; + senderMustBeColeader = false; + senderMustBeAdmin = false; + } - @Override - public void perform() { - fme.setIsAdminBypassing(this.argAsBool(0, !fme.isAdminBypassing())); + @Override + public void perform() { + fme.setIsAdminBypassing(this.argAsBool(0, !fme.isAdminBypassing())); - // TODO: Move this to a transient field in the model?? - if (fme.isAdminBypassing()) { - fme.msg(TL.COMMAND_BYPASS_ENABLE.toString()); - P.p.log(fme.getName() + TL.COMMAND_BYPASS_ENABLELOG.toString()); - } else { - fme.msg(TL.COMMAND_BYPASS_DISABLE.toString()); - P.p.log(fme.getName() + TL.COMMAND_BYPASS_DISABLELOG.toString()); - } - } + // TODO: Move this to a transient field in the model?? + if (fme.isAdminBypassing()) { + fme.msg(TL.COMMAND_BYPASS_ENABLE.toString()); + P.p.log(fme.getName() + TL.COMMAND_BYPASS_ENABLELOG.toString()); + } else { + fme.msg(TL.COMMAND_BYPASS_DISABLE.toString()); + P.p.log(fme.getName() + TL.COMMAND_BYPASS_DISABLELOG.toString()); + } + } - @Override - public TL getUsageTranslation() { - return TL.COMMAND_BYPASS_DESCRIPTION; - } + @Override + public TL getUsageTranslation() { + return TL.COMMAND_BYPASS_DESCRIPTION; + } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdChat.java b/src/main/java/com/massivecraft/factions/cmd/CmdChat.java index ffda5965..983868c0 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdChat.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdChat.java @@ -8,80 +8,80 @@ import com.massivecraft.factions.zcore.util.TL; public class CmdChat extends FCommand { - public CmdChat() { - super(); - this.aliases.add("c"); - this.aliases.add("chat"); + public CmdChat() { + super(); + this.aliases.add("c"); + this.aliases.add("chat"); - //this.requiredArgs.add(""); - this.optionalArgs.put("mode", "next"); + //this.requiredArgs.add(""); + this.optionalArgs.put("mode", "next"); - this.permission = Permission.CHAT.node; - this.disableOnLock = false; + this.permission = Permission.CHAT.node; + this.disableOnLock = false; - senderMustBePlayer = true; - senderMustBeMember = true; - senderMustBeModerator = false; - senderMustBeColeader = false; - senderMustBeAdmin = false; - } + senderMustBePlayer = true; + senderMustBeMember = true; + senderMustBeModerator = false; + senderMustBeColeader = false; + senderMustBeAdmin = false; + } - @Override - public void perform() { - if (!Conf.factionOnlyChat) { - msg(TL.COMMAND_CHAT_DISABLED.toString()); - return; - } + @Override + public void perform() { + if (!Conf.factionOnlyChat) { + msg(TL.COMMAND_CHAT_DISABLED.toString()); + return; + } - String modeString = this.argAsString(0); - ChatMode modeTarget = fme.getChatMode().getNext(); + String modeString = this.argAsString(0); + ChatMode modeTarget = fme.getChatMode().getNext(); - if (modeString != null) { - 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; - } else if (modeString.startsWith("p")) { - modeTarget = ChatMode.PUBLIC; - } else if (modeString.startsWith("a")) { - modeTarget = ChatMode.ALLIANCE; - } else if (modeString.startsWith("f")) { - modeTarget = ChatMode.FACTION; - } else if (modeString.startsWith("t")) { - modeTarget = ChatMode.TRUCE; - } else { - msg(TL.COMMAND_CHAT_INVALIDMODE); - return; - } - } + if (modeString != null) { + 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; + } else if (modeString.startsWith("p")) { + modeTarget = ChatMode.PUBLIC; + } else if (modeString.startsWith("a")) { + modeTarget = ChatMode.ALLIANCE; + } else if (modeString.startsWith("f")) { + modeTarget = ChatMode.FACTION; + } else if (modeString.startsWith("t")) { + modeTarget = ChatMode.TRUCE; + } else { + msg(TL.COMMAND_CHAT_INVALIDMODE); + return; + } + } - fme.setChatMode(modeTarget); + 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; + } + } - @Override - public TL getUsageTranslation() { - return TL.COMMAND_CHAT_DESCRIPTION; - } + @Override + public TL getUsageTranslation() { + return TL.COMMAND_CHAT_DESCRIPTION; + } } \ No newline at end of file diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdChatSpy.java b/src/main/java/com/massivecraft/factions/cmd/CmdChatSpy.java index 1a087d32..97231e66 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdChatSpy.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdChatSpy.java @@ -6,37 +6,37 @@ import com.massivecraft.factions.zcore.util.TL; public class CmdChatSpy extends FCommand { - public CmdChatSpy() { - super(); - this.aliases.add("chatspy"); + public CmdChatSpy() { + super(); + this.aliases.add("chatspy"); - this.optionalArgs.put("on/off", "flip"); + this.optionalArgs.put("on/off", "flip"); - this.permission = Permission.CHATSPY.node; - this.disableOnLock = false; + this.permission = Permission.CHATSPY.node; + this.disableOnLock = false; - senderMustBePlayer = true; - senderMustBeMember = false; - senderMustBeModerator = false; - senderMustBeColeader = false; - senderMustBeAdmin = false; - } + senderMustBePlayer = true; + senderMustBeMember = false; + senderMustBeModerator = false; + senderMustBeColeader = false; + senderMustBeAdmin = false; + } - @Override - public void perform() { - fme.setSpyingChat(this.argAsBool(0, !fme.isSpyingChat())); + @Override + public void perform() { + fme.setSpyingChat(this.argAsBool(0, !fme.isSpyingChat())); - if (fme.isSpyingChat()) { - fme.msg(TL.COMMAND_CHATSPY_ENABLE); - P.p.log(fme.getName() + TL.COMMAND_CHATSPY_ENABLELOG.toString()); - } else { - fme.msg(TL.COMMAND_CHATSPY_DISABLE); - P.p.log(fme.getName() + TL.COMMAND_CHATSPY_DISABLELOG.toString()); - } - } + if (fme.isSpyingChat()) { + fme.msg(TL.COMMAND_CHATSPY_ENABLE); + P.p.log(fme.getName() + TL.COMMAND_CHATSPY_ENABLELOG.toString()); + } else { + fme.msg(TL.COMMAND_CHATSPY_DISABLE); + P.p.log(fme.getName() + TL.COMMAND_CHATSPY_DISABLELOG.toString()); + } + } - @Override - public TL getUsageTranslation() { - return TL.COMMAND_CHATSPY_DESCRIPTION; - } + @Override + public TL getUsageTranslation() { + return TL.COMMAND_CHATSPY_DESCRIPTION; + } } \ No newline at end of file diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdCheck.java b/src/main/java/com/massivecraft/factions/cmd/CmdCheck.java new file mode 100644 index 00000000..11586740 --- /dev/null +++ b/src/main/java/com/massivecraft/factions/cmd/CmdCheck.java @@ -0,0 +1,56 @@ +package com.massivecraft.factions.cmd; + +import com.massivecraft.factions.Conf; +import com.massivecraft.factions.struct.Permission; +import com.massivecraft.factions.struct.Role; +import com.massivecraft.factions.zcore.fperms.Access; +import com.massivecraft.factions.zcore.fperms.PermissableAction; +import com.massivecraft.factions.zcore.util.TL; + +public class CmdCheck extends FCommand { + + public CmdCheck() { + this.aliases.add("check"); + + this.requiredArgs.add("minutes"); + + this.permission = Permission.CHECK.node; + + this.disableOnLock = true; + this.disableOnSpam = false; + + this.senderMustBePlayer = true; + this.senderMustBeMember = true; + this.senderMustBeModerator = false; + this.senderMustBeColeader = false; + this.senderMustBeAdmin = false; + } + + + @Override + public void perform() { + if (!Conf.useCheckSystem) { + msg(TL.GENERIC_DISABLED); + return; + } + + Access access = myFaction.getAccess(fme, PermissableAction.CHECK); + if ((access == Access.DENY || (access == Access.UNDEFINED && !assertMinRole(Role.LEADER))) && !fme.isAdminBypassing()) { + fme.msg(TL.GENERIC_NOPERMISSION, "check"); + return; + } + int minutes = this.argAsInt(0); + if (minutes <= 0) { + msg(TL.COMMAND_CHECK_INVALID_NUMBER); + } else { + myFaction.setCheckNotifier(minutes); + msg(TL.COMMAND_CHECK_SUCCESSFUL.format(minutes)); + } + } + + @Override + public TL getUsageTranslation() { + return TL.COMMAND_CHECK_DESCRIPTION; + } +} + diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdCheckpoint.java b/src/main/java/com/massivecraft/factions/cmd/CmdCheckpoint.java index 15548424..da55d25b 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdCheckpoint.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdCheckpoint.java @@ -6,61 +6,61 @@ import com.massivecraft.factions.util.WarmUpUtil; import com.massivecraft.factions.zcore.util.TL; public class CmdCheckpoint extends FCommand { - public CmdCheckpoint() { - super(); - this.aliases.add("checkp"); - this.aliases.add("checkpoint"); - this.aliases.add("cpoint"); + public CmdCheckpoint() { + super(); + this.aliases.add("checkp"); + this.aliases.add("checkpoint"); + this.aliases.add("cpoint"); - this.optionalArgs.put("set", ""); + this.optionalArgs.put("set", ""); - this.permission = Permission.CHECKPOINT.node; - this.disableOnLock = false; + this.permission = Permission.CHECKPOINT.node; + this.disableOnLock = false; - senderMustBePlayer = true; - senderMustBeMember = true; - senderMustBeModerator = false; - senderMustBeColeader = false; - senderMustBeAdmin = false; - } + senderMustBePlayer = true; + senderMustBeMember = true; + senderMustBeModerator = false; + senderMustBeColeader = false; + senderMustBeAdmin = false; + } - @Override - public void perform() { - if (!P.p.getConfig().getBoolean("checkpoints.Enabled")) { - fme.msg(TL.COMMAND_CHECKPOINT_DISABLED); - return; - } - if (args.size() == 1) { - FLocation myLocation = new FLocation(fme.getPlayer().getLocation()); - Faction myLocFaction = Board.getInstance().getFactionAt(myLocation); - if (myLocFaction == Factions.getInstance().getWilderness() || myLocFaction == fme.getFaction()) { - fme.getFaction().setCheckpoint(fme.getPlayer().getLocation()); - fme.msg(TL.COMMAND_CHECKPOINT_SET); - return; - } else { - fme.msg(TL.COMMAND_CHECKPOINT_INVALIDLOCATION); - return; - } - } - if (fme.getFaction().getCheckpoint() == null) { - fme.msg(TL.COMMAND_CHECKPOINT_NOT_SET); - return; - } - FLocation checkLocation = new FLocation(fme.getFaction().getCheckpoint()); - Faction checkfaction = Board.getInstance().getFactionAt(checkLocation); + @Override + public void perform() { + if (!P.p.getConfig().getBoolean("checkpoints.Enabled")) { + fme.msg(TL.COMMAND_CHECKPOINT_DISABLED); + return; + } + if (args.size() == 1) { + FLocation myLocation = new FLocation(fme.getPlayer().getLocation()); + Faction myLocFaction = Board.getInstance().getFactionAt(myLocation); + if (myLocFaction == Factions.getInstance().getWilderness() || myLocFaction == fme.getFaction()) { + fme.getFaction().setCheckpoint(fme.getPlayer().getLocation()); + fme.msg(TL.COMMAND_CHECKPOINT_SET); + return; + } else { + fme.msg(TL.COMMAND_CHECKPOINT_INVALIDLOCATION); + return; + } + } + if (fme.getFaction().getCheckpoint() == null) { + fme.msg(TL.COMMAND_CHECKPOINT_NOT_SET); + return; + } + FLocation checkLocation = new FLocation(fme.getFaction().getCheckpoint()); + Faction checkfaction = Board.getInstance().getFactionAt(checkLocation); - if (checkfaction.getId().equals(Factions.getInstance().getWilderness().getId()) || checkfaction.getId().equals(fme.getFaction().getId())) { - fme.msg(TL.COMMAND_CHECKPOINT_GO); - this.doWarmUp(WarmUpUtil.Warmup.CHECKPOINT, TL.WARMUPS_NOTIFY_TELEPORT, "Checkpoint", () -> fme.getPlayer().teleport(fme.getFaction().getCheckpoint()), this.p.getConfig().getLong("warmups.f-checkpoint", 0)); - } else { - fme.msg(TL.COMMAND_CHECKPOINT_CLAIMED); - } + if (checkfaction.getId().equals(Factions.getInstance().getWilderness().getId()) || checkfaction.getId().equals(fme.getFaction().getId())) { + fme.msg(TL.COMMAND_CHECKPOINT_GO); + this.doWarmUp(WarmUpUtil.Warmup.CHECKPOINT, TL.WARMUPS_NOTIFY_TELEPORT, "Checkpoint", () -> fme.getPlayer().teleport(fme.getFaction().getCheckpoint()), this.p.getConfig().getLong("warmups.f-checkpoint", 0)); + } else { + fme.msg(TL.COMMAND_CHECKPOINT_CLAIMED); + } - } + } - @Override - public TL getUsageTranslation() { - return TL.COMMAND_CHECKPOINT_DESCRIPTION; - } + @Override + public TL getUsageTranslation() { + return TL.COMMAND_CHECKPOINT_DESCRIPTION; + } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdColeader.java b/src/main/java/com/massivecraft/factions/cmd/CmdColeader.java index 14967650..0a16ab94 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdColeader.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdColeader.java @@ -10,87 +10,87 @@ import mkremins.fanciful.FancyMessage; import org.bukkit.ChatColor; public class CmdColeader extends FCommand { - public CmdColeader() { - super(); - this.aliases.add("co"); - this.aliases.add("setcoleader"); - this.aliases.add("coleader"); - this.aliases.add("setco"); + public CmdColeader() { + super(); + this.aliases.add("co"); + this.aliases.add("setcoleader"); + this.aliases.add("coleader"); + this.aliases.add("setco"); - this.optionalArgs.put("player name", "name"); - //this.optionalArgs.put("", ""); + this.optionalArgs.put("player name", "name"); + //this.optionalArgs.put("", ""); - this.permission = Permission.COLEADER.node; - this.disableOnLock = true; + this.permission = Permission.COLEADER.node; + this.disableOnLock = true; - senderMustBePlayer = false; - senderMustBeMember = true; - senderMustBeModerator = false; - senderMustBeAdmin = true; - } + senderMustBePlayer = false; + senderMustBeMember = true; + senderMustBeModerator = false; + senderMustBeAdmin = true; + } - @Override - public void perform() { - FPlayer you = this.argAsBestFPlayerMatch(0); - if (you == null) { - FancyMessage msg = new FancyMessage(TL.COMMAND_COLEADER_CANDIDATES.toString()).color(ChatColor.GOLD); - for (FPlayer player : myFaction.getFPlayersWhereRole(Role.NORMAL)) { - String s = player.getName(); - msg.then(s + " ").color(ChatColor.WHITE).tooltip(TL.COMMAND_MOD_CLICKTOPROMOTE.toString() + s).command("/" + Conf.baseCommandAliases.get(0) + " coleader " + s); - } - for (FPlayer player : myFaction.getFPlayersWhereRole(Role.MODERATOR)) { - String s = player.getName(); - msg.then(s + " ").color(ChatColor.WHITE).tooltip(TL.COMMAND_MOD_CLICKTOPROMOTE.toString() + s).command("/" + Conf.baseCommandAliases.get(0) + " coleader " + s); - } + @Override + public void perform() { + FPlayer you = this.argAsBestFPlayerMatch(0); + if (you == null) { + FancyMessage msg = new FancyMessage(TL.COMMAND_COLEADER_CANDIDATES.toString()).color(ChatColor.GOLD); + for (FPlayer player : myFaction.getFPlayersWhereRole(Role.NORMAL)) { + String s = player.getName(); + msg.then(s + " ").color(ChatColor.WHITE).tooltip(TL.COMMAND_MOD_CLICKTOPROMOTE.toString() + s).command("/" + Conf.baseCommandAliases.get(0) + " coleader " + s); + } + for (FPlayer player : myFaction.getFPlayersWhereRole(Role.MODERATOR)) { + String s = player.getName(); + msg.then(s + " ").color(ChatColor.WHITE).tooltip(TL.COMMAND_MOD_CLICKTOPROMOTE.toString() + s).command("/" + Conf.baseCommandAliases.get(0) + " coleader " + s); + } - sendFancyMessage(msg); - return; - } + sendFancyMessage(msg); + return; + } - boolean permAny = Permission.COLEADER_ANY.has(sender, false); - Faction targetFaction = you.getFaction(); + boolean permAny = Permission.COLEADER_ANY.has(sender, false); + Faction targetFaction = you.getFaction(); - if(you.isAlt()){ - msg(ChatColor.RED + "You can not promote alt accounts."); - return; - } + if (you.isAlt()) { + msg(ChatColor.RED + "You can not promote alt accounts."); + return; + } - if (targetFaction != myFaction && !permAny) { - msg(TL.COMMAND_MOD_NOTMEMBER, you.describeTo(fme, true)); - return; - } + if (targetFaction != myFaction && !permAny) { + msg(TL.COMMAND_MOD_NOTMEMBER, you.describeTo(fme, true)); + return; + } - if (fme != null && fme.getRole() != Role.LEADER && !permAny) { - msg(TL.COMMAND_COLEADER_NOTADMIN); - return; - } + if (fme != null && fme.getRole() != Role.LEADER && !permAny) { + msg(TL.COMMAND_COLEADER_NOTADMIN); + return; + } - if (you == fme && !permAny) { - msg(TL.COMMAND_COLEADER_SELF); - return; - } + if (you == fme && !permAny) { + msg(TL.COMMAND_COLEADER_SELF); + return; + } - if (you.getRole() == Role.LEADER) { - msg(TL.COMMAND_COLEADER_TARGETISADMIN); - return; - } + if (you.getRole() == Role.LEADER) { + msg(TL.COMMAND_COLEADER_TARGETISADMIN); + return; + } - if (you.getRole() == Role.COLEADER) { - // Revoke - you.setRole(Role.MODERATOR); - targetFaction.msg(TL.COMMAND_COLEADER_REVOKED, you.describeTo(targetFaction, true)); - msg(TL.COMMAND_COLEADER_REVOKES, you.describeTo(fme, true)); - } else { - // Give - you.setRole(Role.COLEADER); - targetFaction.msg(TL.COMMAND_COLEADER_PROMOTED, you.describeTo(targetFaction, true)); - msg(TL.COMMAND_COLEADER_PROMOTES, you.describeTo(fme, true)); - } - } + if (you.getRole() == Role.COLEADER) { + // Revoke + you.setRole(Role.MODERATOR); + targetFaction.msg(TL.COMMAND_COLEADER_REVOKED, you.describeTo(targetFaction, true)); + msg(TL.COMMAND_COLEADER_REVOKES, you.describeTo(fme, true)); + } else { + // Give + you.setRole(Role.COLEADER); + targetFaction.msg(TL.COMMAND_COLEADER_PROMOTED, you.describeTo(targetFaction, true)); + msg(TL.COMMAND_COLEADER_PROMOTES, you.describeTo(fme, true)); + } + } - @Override - public TL getUsageTranslation() { - return TL.COMMAND_COLEADER_DESCRIPTION; - } + @Override + public TL getUsageTranslation() { + return TL.COMMAND_COLEADER_DESCRIPTION; + } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdConfig.java b/src/main/java/com/massivecraft/factions/cmd/CmdConfig.java index 0e13e754..8cf6179e 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdConfig.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdConfig.java @@ -16,234 +16,234 @@ import java.util.Set; public class CmdConfig extends FCommand { - private static HashMap properFieldNames = new HashMap<>(); + private static HashMap properFieldNames = new HashMap<>(); - public CmdConfig() { - super(); - this.aliases.add("config"); + public CmdConfig() { + super(); + this.aliases.add("config"); - this.requiredArgs.add("setting"); - this.requiredArgs.add("value"); - this.errorOnToManyArgs = false; + this.requiredArgs.add("setting"); + this.requiredArgs.add("value"); + this.errorOnToManyArgs = false; - this.permission = Permission.CONFIG.node; - this.disableOnLock = true; + this.permission = Permission.CONFIG.node; + this.disableOnLock = true; - senderMustBePlayer = false; - senderMustBeMember = false; - senderMustBeModerator = false; - senderMustBeColeader = false; - senderMustBeAdmin = false; - } + senderMustBePlayer = false; + senderMustBeMember = false; + senderMustBeModerator = false; + senderMustBeColeader = false; + senderMustBeAdmin = false; + } - @Override - public void perform() { - // store a lookup map of lowercase field names paired with proper capitalization field names - // that way, if the person using this command messes up the capitalization, we can fix that - if (properFieldNames.isEmpty()) { - Field[] fields = Conf.class.getDeclaredFields(); - for (Field field : fields) { - properFieldNames.put(field.getName().toLowerCase(), field.getName()); - } - } + @Override + public void perform() { + // store a lookup map of lowercase field names paired with proper capitalization field names + // that way, if the person using this command messes up the capitalization, we can fix that + if (properFieldNames.isEmpty()) { + Field[] fields = Conf.class.getDeclaredFields(); + for (Field field : fields) { + properFieldNames.put(field.getName().toLowerCase(), field.getName()); + } + } - String field = this.argAsString(0).toLowerCase(); - if (field.startsWith("\"") && field.endsWith("\"")) { - field = field.substring(1, field.length() - 1); - } - String fieldName = properFieldNames.get(field); + String field = this.argAsString(0).toLowerCase(); + if (field.startsWith("\"") && field.endsWith("\"")) { + field = field.substring(1, field.length() - 1); + } + String fieldName = properFieldNames.get(field); - if (fieldName == null || fieldName.isEmpty()) { - msg(TL.COMMAND_CONFIG_NOEXIST, field); - return; - } + if (fieldName == null || fieldName.isEmpty()) { + msg(TL.COMMAND_CONFIG_NOEXIST, field); + return; + } - String success; + String success; - StringBuilder value = new StringBuilder(args.get(1)); - for (int i = 2; i < args.size(); i++) { - value.append(' ').append(args.get(i)); - } + StringBuilder value = new StringBuilder(args.get(1)); + for (int i = 2; i < args.size(); i++) { + value.append(' ').append(args.get(i)); + } - try { - Field target = Conf.class.getField(fieldName); + try { + Field target = Conf.class.getField(fieldName); - // boolean - if (target.getType() == boolean.class) { - boolean targetValue = this.strAsBool(value.toString()); - target.setBoolean(null, targetValue); + // boolean + if (target.getType() == boolean.class) { + boolean targetValue = this.strAsBool(value.toString()); + target.setBoolean(null, targetValue); - if (targetValue) { - success = "\"" + fieldName + TL.COMMAND_CONFIG_SET_TRUE.toString(); - } else { - success = "\"" + fieldName + TL.COMMAND_CONFIG_SET_FALSE.toString(); - } - } + if (targetValue) { + success = "\"" + fieldName + TL.COMMAND_CONFIG_SET_TRUE.toString(); + } else { + success = "\"" + fieldName + TL.COMMAND_CONFIG_SET_FALSE.toString(); + } + } - // int - else if (target.getType() == int.class) { - try { - int intVal = Integer.parseInt(value.toString()); - target.setInt(null, intVal); - success = "\"" + fieldName + TL.COMMAND_CONFIG_OPTIONSET.toString() + intVal + "."; - } catch (NumberFormatException ex) { - sendMessage(TL.COMMAND_CONFIG_INTREQUIRED.format(fieldName)); - return; - } - } + // int + else if (target.getType() == int.class) { + try { + int intVal = Integer.parseInt(value.toString()); + target.setInt(null, intVal); + success = "\"" + fieldName + TL.COMMAND_CONFIG_OPTIONSET.toString() + intVal + "."; + } catch (NumberFormatException ex) { + sendMessage(TL.COMMAND_CONFIG_INTREQUIRED.format(fieldName)); + return; + } + } - // long - else if (target.getType() == long.class) { - try { - long longVal = Long.parseLong(value.toString()); - target.setLong(null, longVal); - success = "\"" + fieldName + TL.COMMAND_CONFIG_OPTIONSET.toString() + longVal + "."; - } catch (NumberFormatException ex) { - sendMessage(TL.COMMAND_CONFIG_LONGREQUIRED.format(fieldName)); - return; - } - } + // long + else if (target.getType() == long.class) { + try { + long longVal = Long.parseLong(value.toString()); + target.setLong(null, longVal); + success = "\"" + fieldName + TL.COMMAND_CONFIG_OPTIONSET.toString() + longVal + "."; + } catch (NumberFormatException ex) { + sendMessage(TL.COMMAND_CONFIG_LONGREQUIRED.format(fieldName)); + return; + } + } - // double - else if (target.getType() == double.class) { - try { - double doubleVal = Double.parseDouble(value.toString()); - target.setDouble(null, doubleVal); - success = "\"" + fieldName + TL.COMMAND_CONFIG_OPTIONSET.toString() + doubleVal + "."; - } catch (NumberFormatException ex) { - sendMessage(TL.COMMAND_CONFIG_DOUBLEREQUIRED.format(fieldName)); - return; - } - } + // double + else if (target.getType() == double.class) { + try { + double doubleVal = Double.parseDouble(value.toString()); + target.setDouble(null, doubleVal); + success = "\"" + fieldName + TL.COMMAND_CONFIG_OPTIONSET.toString() + doubleVal + "."; + } catch (NumberFormatException ex) { + sendMessage(TL.COMMAND_CONFIG_DOUBLEREQUIRED.format(fieldName)); + return; + } + } - // float - else if (target.getType() == float.class) { - try { - float floatVal = Float.parseFloat(value.toString()); - target.setFloat(null, floatVal); - success = "\"" + fieldName + TL.COMMAND_CONFIG_OPTIONSET.toString() + floatVal + "."; - } catch (NumberFormatException ex) { - sendMessage(TL.COMMAND_CONFIG_FLOATREQUIRED.format(fieldName)); - return; - } - } + // float + else if (target.getType() == float.class) { + try { + float floatVal = Float.parseFloat(value.toString()); + target.setFloat(null, floatVal); + success = "\"" + fieldName + TL.COMMAND_CONFIG_OPTIONSET.toString() + floatVal + "."; + } catch (NumberFormatException ex) { + sendMessage(TL.COMMAND_CONFIG_FLOATREQUIRED.format(fieldName)); + return; + } + } - // String - else if (target.getType() == String.class) { - target.set(null, value.toString()); - success = "\"" + fieldName + TL.COMMAND_CONFIG_OPTIONSET.toString() + value + "\"."; - } + // String + else if (target.getType() == String.class) { + target.set(null, value.toString()); + success = "\"" + fieldName + TL.COMMAND_CONFIG_OPTIONSET.toString() + value + "\"."; + } - // ChatColor - else if (target.getType() == ChatColor.class) { - ChatColor newColor = null; - try { - newColor = ChatColor.valueOf(value.toString().toUpperCase()); - } catch (IllegalArgumentException ex) { + // ChatColor + else if (target.getType() == ChatColor.class) { + ChatColor newColor = null; + try { + newColor = ChatColor.valueOf(value.toString().toUpperCase()); + } catch (IllegalArgumentException ex) { - } - if (newColor == null) { - sendMessage(TL.COMMAND_CONFIG_INVALID_COLOUR.format(fieldName, value.toString().toUpperCase())); - return; - } - target.set(null, newColor); - success = "\"" + fieldName + TL.COMMAND_CONFIG_COLOURSET.toString() + value.toString().toUpperCase() + "\"."; - } + } + if (newColor == null) { + sendMessage(TL.COMMAND_CONFIG_INVALID_COLOUR.format(fieldName, value.toString().toUpperCase())); + return; + } + target.set(null, newColor); + success = "\"" + fieldName + TL.COMMAND_CONFIG_COLOURSET.toString() + value.toString().toUpperCase() + "\"."; + } - // Set or other parameterized collection - else if (target.getGenericType() instanceof ParameterizedType) { - ParameterizedType targSet = (ParameterizedType) target.getGenericType(); - Type innerType = targSet.getActualTypeArguments()[0]; + // Set or other parameterized collection + else if (target.getGenericType() instanceof ParameterizedType) { + ParameterizedType targSet = (ParameterizedType) target.getGenericType(); + Type innerType = targSet.getActualTypeArguments()[0]; - // not a Set, somehow, and that should be the only collection we're using in Conf.java - if (targSet.getRawType() != Set.class) { - sendMessage(TL.COMMAND_CONFIG_INVALID_COLLECTION.format(fieldName)); - return; - } + // not a Set, somehow, and that should be the only collection we're using in Conf.java + if (targSet.getRawType() != Set.class) { + sendMessage(TL.COMMAND_CONFIG_INVALID_COLLECTION.format(fieldName)); + return; + } - // Set - else if (innerType == Material.class) { - Material newMat = null; - try { - newMat = Material.valueOf(value.toString().toUpperCase()); - } catch (IllegalArgumentException ex) { + // Set + else if (innerType == Material.class) { + Material newMat = null; + try { + newMat = Material.valueOf(value.toString().toUpperCase()); + } catch (IllegalArgumentException ex) { - } - if (newMat == null) { - sendMessage(TL.COMMAND_CONFIG_INVALID_MATERIAL.format(fieldName, value.toString().toUpperCase())); - return; - } + } + if (newMat == null) { + sendMessage(TL.COMMAND_CONFIG_INVALID_MATERIAL.format(fieldName, value.toString().toUpperCase())); + 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)) { - matSet.remove(newMat); - target.set(null, matSet); - success = TL.COMMAND_CONFIG_MATERIAL_REMOVED.format(fieldName, value.toString().toUpperCase()); - } - // Material not present yet, add it - else { - matSet.add(newMat); - target.set(null, matSet); - success = TL.COMMAND_CONFIG_MATERIAL_ADDED.format(fieldName, value.toString().toUpperCase()); - } - } + // Material already present, so remove it + if (matSet.contains(newMat)) { + matSet.remove(newMat); + target.set(null, matSet); + success = TL.COMMAND_CONFIG_MATERIAL_REMOVED.format(fieldName, value.toString().toUpperCase()); + } + // Material not present yet, add it + else { + matSet.add(newMat); + target.set(null, matSet); + success = TL.COMMAND_CONFIG_MATERIAL_ADDED.format(fieldName, value.toString().toUpperCase()); + } + } - // Set - else if (innerType == String.class) { - @SuppressWarnings("unchecked") Set stringSet = (Set) target.get(null); + // Set + else if (innerType == String.class) { + @SuppressWarnings("unchecked") Set stringSet = (Set) target.get(null); - // String already present, so remove it - if (stringSet.contains(value.toString())) { - stringSet.remove(value.toString()); - target.set(null, stringSet); - success = TL.COMMAND_CONFIG_SET_REMOVED.format(fieldName, value.toString()); - } - // String not present yet, add it - else { - stringSet.add(value.toString()); - target.set(null, stringSet); - success = TL.COMMAND_CONFIG_SET_ADDED.format(fieldName, value.toString()); - } - } + // String already present, so remove it + if (stringSet.contains(value.toString())) { + stringSet.remove(value.toString()); + target.set(null, stringSet); + success = TL.COMMAND_CONFIG_SET_REMOVED.format(fieldName, value.toString()); + } + // String not present yet, add it + else { + stringSet.add(value.toString()); + target.set(null, stringSet); + success = TL.COMMAND_CONFIG_SET_ADDED.format(fieldName, value.toString()); + } + } - // Set of unknown type - else { - sendMessage(TL.COMMAND_CONFIG_INVALID_TYPESET.format(fieldName)); - return; - } - } + // Set of unknown type + else { + sendMessage(TL.COMMAND_CONFIG_INVALID_TYPESET.format(fieldName)); + return; + } + } - // unknown type - else { - sendMessage(TL.COMMAND_CONFIG_ERROR_TYPE.format(fieldName, target.getClass().getName())); - return; - } - } catch (NoSuchFieldException ex) { - sendMessage(TL.COMMAND_CONFIG_ERROR_MATCHING.format(fieldName)); - return; - } catch (IllegalAccessException ex) { - sendMessage(TL.COMMAND_CONFIG_ERROR_SETTING.format(fieldName, value.toString())); - return; - } + // unknown type + else { + sendMessage(TL.COMMAND_CONFIG_ERROR_TYPE.format(fieldName, target.getClass().getName())); + return; + } + } catch (NoSuchFieldException ex) { + sendMessage(TL.COMMAND_CONFIG_ERROR_MATCHING.format(fieldName)); + return; + } catch (IllegalAccessException ex) { + sendMessage(TL.COMMAND_CONFIG_ERROR_SETTING.format(fieldName, value.toString())); + return; + } - if (!success.isEmpty()) { - if (sender instanceof Player) { - sendMessage(success); - P.p.log(success + TL.COMMAND_CONFIG_LOG.format((Player) sender)); - } else // using P.p.log() instead of sendMessage if run from server console so that "[Factions v#.#.#]" is prepended in server log - { - P.p.log(success); - } - } - // save change to disk - Conf.save(); - } + if (!success.isEmpty()) { + if (sender instanceof Player) { + sendMessage(success); + P.p.log(success + TL.COMMAND_CONFIG_LOG.format((Player) sender)); + } else // using P.p.log() instead of sendMessage if run from server console so that "[Factions v#.#.#]" is prepended in server log + { + P.p.log(success); + } + } + // save change to disk + Conf.save(); + } - @Override - public TL getUsageTranslation() { - return TL.COMMAND_CONFIG_DESCRIPTION; - } + @Override + public TL getUsageTranslation() { + return TL.COMMAND_CONFIG_DESCRIPTION; + } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdConvert.java b/src/main/java/com/massivecraft/factions/cmd/CmdConvert.java index 48bcbbaa..f2b780c9 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdConvert.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdConvert.java @@ -9,36 +9,36 @@ import org.bukkit.command.ConsoleCommandSender; public class CmdConvert extends FCommand { - public CmdConvert() { - this.aliases.add("convert"); + public CmdConvert() { + this.aliases.add("convert"); - this.permission = Permission.CONVERT.node; + this.permission = Permission.CONVERT.node; - this.requiredArgs.add("[MYSQL|JSON]"); - } + this.requiredArgs.add("[MYSQL|JSON]"); + } - @Override - public void perform() { - if (!(this.sender instanceof ConsoleCommandSender)) { - this.sender.sendMessage(TL.GENERIC_CONSOLEONLY.toString()); - } - Backend nb = Backend.valueOf(this.argAsString(0).toUpperCase()); - if (nb == Conf.backEnd) { - this.sender.sendMessage(TL.COMMAND_CONVERT_BACKEND_RUNNING.toString()); - return; - } - if (nb == Backend.JSON) { - FactionsJSON.convertTo(); - } else { - this.sender.sendMessage(TL.COMMAND_CONVERT_BACKEND_INVALID.toString()); - return; - } - Conf.backEnd = nb; - } + @Override + public void perform() { + if (!(this.sender instanceof ConsoleCommandSender)) { + this.sender.sendMessage(TL.GENERIC_CONSOLEONLY.toString()); + } + Backend nb = Backend.valueOf(this.argAsString(0).toUpperCase()); + if (nb == Conf.backEnd) { + this.sender.sendMessage(TL.COMMAND_CONVERT_BACKEND_RUNNING.toString()); + return; + } + if (nb == Backend.JSON) { + FactionsJSON.convertTo(); + } else { + this.sender.sendMessage(TL.COMMAND_CONVERT_BACKEND_INVALID.toString()); + return; + } + Conf.backEnd = nb; + } - @Override - public TL getUsageTranslation() { - return TL.COMMAND_CONVERT_DESCRIPTION; - } + @Override + public TL getUsageTranslation() { + return TL.COMMAND_CONVERT_DESCRIPTION; + } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdCoords.java b/src/main/java/com/massivecraft/factions/cmd/CmdCoords.java index 506ad1b0..e6b3bad3 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdCoords.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdCoords.java @@ -7,36 +7,36 @@ import org.bukkit.Location; public class CmdCoords extends FCommand { - public CmdCoords() { - super(); - this.aliases.add("coords"); - this.aliases.add("coord"); + public CmdCoords() { + super(); + this.aliases.add("coords"); + this.aliases.add("coord"); - this.permission = Permission.COORD.node; - this.disableOnLock = true; + this.permission = Permission.COORD.node; + this.disableOnLock = true; - senderMustBePlayer = true; - senderMustBeMember = true; - senderMustBeModerator = false; - senderMustBeColeader = false; - senderMustBeAdmin = false; - } + senderMustBePlayer = true; + senderMustBeMember = true; + senderMustBeModerator = false; + senderMustBeColeader = false; + senderMustBeAdmin = false; + } - @Override - public void perform() { - Location location = fme.getPlayer().getLocation(); - String message = TL.COMMAND_COORDS_MESSAGE.toString().replace("{player}", fme.getPlayer().getDisplayName()).replace("{x}", (int) location.getX() + "") - .replace("{y}", (int) location.getY() + "").replace("{z}", (int) location.getZ() + "").replace("{world}", location.getWorld().getName()); - for (FPlayer fPlayer : fme.getFaction().getFPlayers()) { - fPlayer.sendMessage(message); - } - } + @Override + public void perform() { + Location location = fme.getPlayer().getLocation(); + String message = TL.COMMAND_COORDS_MESSAGE.toString().replace("{player}", fme.getPlayer().getDisplayName()).replace("{x}", (int) location.getX() + "") + .replace("{y}", (int) location.getY() + "").replace("{z}", (int) location.getZ() + "").replace("{world}", location.getWorld().getName()); + for (FPlayer fPlayer : fme.getFaction().getFPlayers()) { + fPlayer.sendMessage(message); + } + } - @Override - public TL getUsageTranslation() { - return TL.COMMAND_COORDS_DESCRIPTION; - } + @Override + public TL getUsageTranslation() { + return TL.COMMAND_COORDS_DESCRIPTION; + } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdCreate.java b/src/main/java/com/massivecraft/factions/cmd/CmdCreate.java index 22e473c2..85513e51 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdCreate.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdCreate.java @@ -15,117 +15,116 @@ import java.util.ArrayList; public class CmdCreate extends FCommand { - public CmdCreate() { - super(); - this.aliases.add("create"); + public CmdCreate() { + super(); + this.aliases.add("create"); - this.requiredArgs.add("faction tag"); - //this.optionalArgs.put("", ""); + this.requiredArgs.add("faction tag"); + //this.optionalArgs.put("", ""); - this.permission = Permission.CREATE.node; - this.disableOnLock = true; - this.disableOnSpam = true; + this.permission = Permission.CREATE.node; + this.disableOnLock = true; + this.disableOnSpam = true; - senderMustBePlayer = true; - senderMustBeMember = false; - senderMustBeModerator = false; - senderMustBeColeader = false; - senderMustBeAdmin = false; - } + senderMustBePlayer = true; + senderMustBeMember = false; + senderMustBeModerator = false; + senderMustBeColeader = false; + senderMustBeAdmin = false; + } - @Override - public void perform() { - String tag = this.argAsString(0); + @Override + public void perform() { + String tag = this.argAsString(0); - if (fme.hasFaction()) { - msg(TL.COMMAND_CREATE_MUSTLEAVE); - return; - } + if (fme.hasFaction()) { + msg(TL.COMMAND_CREATE_MUSTLEAVE); + return; + } - if (!fme.isCooldownEnded("create")) { - fme.msg(TL.COMMAND_ONCOOOLDOWN, fme.getCooldown("create")); - return; - } + if (!fme.isCooldownEnded("create")) { + fme.msg(TL.COMMAND_ONCOOOLDOWN, fme.getCooldown("create")); + return; + } - if (Factions.getInstance().isTagTaken(tag)) { - msg(TL.COMMAND_CREATE_INUSE); - return; - } + if (Factions.getInstance().isTagTaken(tag)) { + msg(TL.COMMAND_CREATE_INUSE); + return; + } - ArrayList tagValidationErrors = MiscUtil.validateTag(tag); - if (tagValidationErrors.size() > 0) { - sendMessage(tagValidationErrors); - return; - } + ArrayList tagValidationErrors = MiscUtil.validateTag(tag); + if (tagValidationErrors.size() > 0) { + sendMessage(tagValidationErrors); + return; + } - // if economy is enabled, they're not on the bypass list, and this command has a cost set, make sure they can pay - if (!canAffordCommand(Conf.econCostCreate, TL.COMMAND_CREATE_TOCREATE.toString())) { - return; - } + // if economy is enabled, they're not on the bypass list, and this command has a cost set, make sure they can pay + if (!canAffordCommand(Conf.econCostCreate, TL.COMMAND_CREATE_TOCREATE.toString())) { + return; + } - // trigger the faction creation event (cancellable) - FactionCreateEvent createEvent = new FactionCreateEvent(me, tag); - Bukkit.getServer().getPluginManager().callEvent(createEvent); - if (createEvent.isCancelled()) { - return; - } + // trigger the faction creation event (cancellable) + FactionCreateEvent createEvent = new FactionCreateEvent(me, tag); + Bukkit.getServer().getPluginManager().callEvent(createEvent); + if (createEvent.isCancelled()) { + return; + } - // then make 'em pay (if applicable) - if (!payForCommand(Conf.econCostCreate, TL.COMMAND_CREATE_TOCREATE, TL.COMMAND_CREATE_FORCREATE)) { - return; - } + // then make 'em pay (if applicable) + if (!payForCommand(Conf.econCostCreate, TL.COMMAND_CREATE_TOCREATE, TL.COMMAND_CREATE_FORCREATE)) { + return; + } - Faction faction = Factions.getInstance().createFaction(); + Faction faction = Factions.getInstance().createFaction(); - // TODO: Why would this even happen??? Auto increment clash?? - if (faction == null) { - msg(TL.COMMAND_CREATE_ERROR); - return; - } + // TODO: Why would this even happen??? Auto increment clash?? + if (faction == null) { + msg(TL.COMMAND_CREATE_ERROR); + return; + } - // finish setting up the Faction - faction.setTag(tag); + // finish setting up the Faction + faction.setTag(tag); - // trigger the faction join event for the creator - FPlayerJoinEvent joinEvent = new FPlayerJoinEvent(FPlayers.getInstance().getByPlayer(me), faction, FPlayerJoinEvent.PlayerJoinReason.CREATE); - Bukkit.getServer().getPluginManager().callEvent(joinEvent); - // join event cannot be cancelled or you'll have an empty faction + // trigger the faction join event for the creator + FPlayerJoinEvent joinEvent = new FPlayerJoinEvent(FPlayers.getInstance().getByPlayer(me), faction, FPlayerJoinEvent.PlayerJoinReason.CREATE); + Bukkit.getServer().getPluginManager().callEvent(joinEvent); + // join event cannot be cancelled or you'll have an empty faction - // finish setting up the FPlayer - fme.setFaction(faction, false); - // We should consider adding the role just AFTER joining the faction. - // That way we don't have to mess up deleting more stuff. - // And prevent the user from being returned to NORMAL after deleting his old faction. - fme.setRole(Role.LEADER); - if (P.p.getConfig().getBoolean("faction-creation-broadcast", true)) { - for (FPlayer follower : FPlayers.getInstance().getOnlinePlayers()) { - follower.msg(TL.COMMAND_CREATE_CREATED, fme.describeTo(follower, true), faction.getTag(follower)); - } - } - msg(TL.COMMAND_CREATE_YOUSHOULD, p.cmdBase.cmdDescription.getUseageTemplate()); + // finish setting up the FPlayer + fme.setFaction(faction, false); + // We should consider adding the role just AFTER joining the faction. + // That way we don't have to mess up deleting more stuff. + // And prevent the user from being returned to NORMAL after deleting his old faction. + fme.setRole(Role.LEADER); + if (P.p.getConfig().getBoolean("faction-creation-broadcast", true)) { + for (FPlayer follower : FPlayers.getInstance().getOnlinePlayers()) { + follower.msg(TL.COMMAND_CREATE_CREATED, fme.describeTo(follower, true), faction.getTag(follower)); + } + } + msg(TL.COMMAND_CREATE_YOUSHOULD, p.cmdBase.cmdDescription.getUseageTemplate()); - if (Conf.econEnabled) - Econ.setBalance(faction.getAccountId(), Conf.econFactionStartingBalance); + if (Conf.econEnabled) + Econ.setBalance(faction.getAccountId(), Conf.econFactionStartingBalance); + if (Conf.logFactionCreate) + P.p.log(fme.getName() + TL.COMMAND_CREATE_CREATEDLOG.toString() + tag); - if (Conf.logFactionCreate) - P.p.log(fme.getName() + TL.COMMAND_CREATE_CREATEDLOG.toString() + tag); + if (P.p.getConfig().getBoolean("fpaypal.Enabled")) + this.fme.msg(TL.COMMAND_PAYPALSET_CREATED); - if (P.p.getConfig().getBoolean("fpaypal.Enabled")) - this.fme.msg(TL.COMMAND_PAYPALSET_CREATED); - - if (Conf.useCustomDefaultPermissions) faction.setDefaultPerms(); - if (Conf.usePermissionHints) fme.msg(TL.COMMAND_HINT_PERMISSION); + if (Conf.useCustomDefaultPermissions) faction.setDefaultPerms(); + if (Conf.usePermissionHints) fme.msg(TL.COMMAND_HINT_PERMISSION); - fme.setCooldown("create", System.currentTimeMillis() + (P.p.getConfig().getInt("fcooldowns.f-create") * 1000)); + fme.setCooldown("create", System.currentTimeMillis() + (P.p.getConfig().getInt("fcooldowns.f-create") * 1000)); - } + } - @Override - public TL getUsageTranslation() { - return TL.COMMAND_CREATE_DESCRIPTION; - } + @Override + public TL getUsageTranslation() { + return TL.COMMAND_CREATE_DESCRIPTION; + } } \ No newline at end of file diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdDeinvite.java b/src/main/java/com/massivecraft/factions/cmd/CmdDeinvite.java index 51948c2c..62c2b72e 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdDeinvite.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdDeinvite.java @@ -13,62 +13,62 @@ import org.bukkit.ChatColor; public class CmdDeinvite extends FCommand { - public CmdDeinvite() { - super(); - this.aliases.add("deinvite"); - this.aliases.add("deinv"); + public CmdDeinvite() { + super(); + this.aliases.add("deinvite"); + this.aliases.add("deinv"); - this.optionalArgs.put("player name", "name"); - //this.optionalArgs.put("", ""); + this.optionalArgs.put("player name", "name"); + //this.optionalArgs.put("", ""); - this.permission = Permission.DEINVITE.node; - this.disableOnLock = true; + this.permission = Permission.DEINVITE.node; + this.disableOnLock = true; - senderMustBePlayer = true; - senderMustBeMember = false; - senderMustBeModerator = true; - senderMustBeColeader = false; - senderMustBeAdmin = false; - } + senderMustBePlayer = true; + senderMustBeMember = false; + senderMustBeModerator = true; + senderMustBeColeader = false; + senderMustBeAdmin = false; + } - @Override - public void perform() { - FPlayer you = this.argAsBestFPlayerMatch(0); - if (!fme.isAdminBypassing()) { - Access access = myFaction.getAccess(fme, PermissableAction.INVITE); - if (access != Access.ALLOW && fme.getRole() != Role.LEADER) { - fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "manage invites"); - return; - } - } - if (you == null) { - FancyMessage msg = new FancyMessage(TL.COMMAND_DEINVITE_CANDEINVITE.toString()).color(ChatColor.GOLD); - for (String id : myFaction.getInvites()) { - FPlayer fp = FPlayers.getInstance().getById(id); - String name = fp != null ? fp.getName() : id; - msg.then(name + " ").color(ChatColor.WHITE).tooltip(TL.COMMAND_DEINVITE_CLICKTODEINVITE.format(name)).command("/" + Conf.baseCommandAliases.get(0) + " deinvite " + name); - } - sendFancyMessage(msg); - return; - } + @Override + public void perform() { + FPlayer you = this.argAsBestFPlayerMatch(0); + if (!fme.isAdminBypassing()) { + Access access = myFaction.getAccess(fme, PermissableAction.INVITE); + if (access != Access.ALLOW && fme.getRole() != Role.LEADER) { + fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "manage invites"); + return; + } + } + if (you == null) { + FancyMessage msg = new FancyMessage(TL.COMMAND_DEINVITE_CANDEINVITE.toString()).color(ChatColor.GOLD); + for (String id : myFaction.getInvites()) { + FPlayer fp = FPlayers.getInstance().getById(id); + String name = fp != null ? fp.getName() : id; + msg.then(name + " ").color(ChatColor.WHITE).tooltip(TL.COMMAND_DEINVITE_CLICKTODEINVITE.format(name)).command("/" + Conf.baseCommandAliases.get(0) + " deinvite " + name); + } + sendFancyMessage(msg); + return; + } - if (you.getFaction() == myFaction) { - msg(TL.COMMAND_DEINVITE_ALREADYMEMBER, you.getName(), myFaction.getTag()); - msg(TL.COMMAND_DEINVITE_MIGHTWANT, p.cmdBase.cmdKick.getUseageTemplate(false)); - return; - } + if (you.getFaction() == myFaction) { + msg(TL.COMMAND_DEINVITE_ALREADYMEMBER, you.getName(), myFaction.getTag()); + msg(TL.COMMAND_DEINVITE_MIGHTWANT, p.cmdBase.cmdKick.getUseageTemplate(false)); + return; + } - myFaction.deinvite(you); + myFaction.deinvite(you); - you.msg(TL.COMMAND_DEINVITE_REVOKED, fme.describeTo(you), myFaction.describeTo(you)); + you.msg(TL.COMMAND_DEINVITE_REVOKED, fme.describeTo(you), myFaction.describeTo(you)); - myFaction.msg(TL.COMMAND_DEINVITE_REVOKES, fme.describeTo(myFaction), you.describeTo(myFaction)); - } + myFaction.msg(TL.COMMAND_DEINVITE_REVOKES, fme.describeTo(myFaction), you.describeTo(myFaction)); + } - @Override - public TL getUsageTranslation() { - return TL.COMMAND_DEINVITE_DESCRIPTION; - } + @Override + public TL getUsageTranslation() { + return TL.COMMAND_DEINVITE_DESCRIPTION; + } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdDelFWarp.java b/src/main/java/com/massivecraft/factions/cmd/CmdDelFWarp.java index b9605fae..3103fef2 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdDelFWarp.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdDelFWarp.java @@ -7,39 +7,39 @@ import com.massivecraft.factions.zcore.util.TL; public class CmdDelFWarp extends FCommand { - public CmdDelFWarp() { - super(); - this.aliases.add("delwarp"); - this.aliases.add("dw"); - this.aliases.add("deletewarp"); - this.requiredArgs.add("warp name"); - this.senderMustBeMember = true; - this.senderMustBeModerator = true; - this.senderMustBePlayer = true; - this.permission = Permission.SETWARP.node; + public CmdDelFWarp() { + super(); + this.aliases.add("delwarp"); + this.aliases.add("dw"); + this.aliases.add("deletewarp"); + this.requiredArgs.add("warp name"); + this.senderMustBeMember = true; + this.senderMustBeModerator = true; + this.senderMustBePlayer = true; + this.permission = Permission.SETWARP.node; - } + } - @Override - public void perform() { - String warp = argAsString(0); - if (myFaction.isWarp(warp)) { - if (!transact(fme)) { - return; - } - myFaction.removeWarp(warp); - fme.msg(TL.COMMAND_DELFWARP_DELETED, warp); - } else { - fme.msg(TL.COMMAND_DELFWARP_INVALID, warp); - } - } + @Override + public void perform() { + String warp = argAsString(0); + if (myFaction.isWarp(warp)) { + if (!transact(fme)) { + return; + } + myFaction.removeWarp(warp); + fme.msg(TL.COMMAND_DELFWARP_DELETED, warp); + } else { + fme.msg(TL.COMMAND_DELFWARP_INVALID, warp); + } + } - private boolean transact(FPlayer player) { - return !P.p.getConfig().getBoolean("warp-cost.enabled", false) || player.isAdminBypassing() || payForCommand(P.p.getConfig().getDouble("warp-cost.delwarp", 5), TL.COMMAND_DELFWARP_TODELETE.toString(), TL.COMMAND_DELFWARP_FORDELETE.toString()); - } + private boolean transact(FPlayer player) { + return !P.p.getConfig().getBoolean("warp-cost.enabled", false) || player.isAdminBypassing() || payForCommand(P.p.getConfig().getDouble("warp-cost.delwarp", 5), TL.COMMAND_DELFWARP_TODELETE.toString(), TL.COMMAND_DELFWARP_FORDELETE.toString()); + } - @Override - public TL getUsageTranslation() { - return TL.COMMAND_DELFWARP_DESCRIPTION; - } + @Override + public TL getUsageTranslation() { + return TL.COMMAND_DELFWARP_DESCRIPTION; + } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdDescription.java b/src/main/java/com/massivecraft/factions/cmd/CmdDescription.java index fe272298..a0e6d00a 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdDescription.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdDescription.java @@ -9,53 +9,53 @@ import com.massivecraft.factions.zcore.util.TextUtil; public class CmdDescription extends FCommand { - public CmdDescription() { - super(); - this.aliases.add("desc"); - this.aliases.add("description"); + public CmdDescription() { + super(); + this.aliases.add("desc"); + this.aliases.add("description"); - this.requiredArgs.add("desc"); - this.errorOnToManyArgs = false; - //this.optionalArgs + this.requiredArgs.add("desc"); + this.errorOnToManyArgs = false; + //this.optionalArgs - this.permission = Permission.DESCRIPTION.node; - this.disableOnLock = true; + this.permission = Permission.DESCRIPTION.node; + this.disableOnLock = true; - senderMustBePlayer = true; - senderMustBeMember = false; - senderMustBeModerator = false; - senderMustBeColeader = true; - senderMustBeAdmin = false; - } + senderMustBePlayer = true; + senderMustBeMember = false; + senderMustBeModerator = false; + senderMustBeColeader = true; + senderMustBeAdmin = false; + } - @Override - public void perform() { - // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay - if (!payForCommand(Conf.econCostDesc, TL.COMMAND_DESCRIPTION_TOCHANGE, TL.COMMAND_DESCRIPTION_FORCHANGE)) { - return; - } + @Override + public void perform() { + // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay + if (!payForCommand(Conf.econCostDesc, TL.COMMAND_DESCRIPTION_TOCHANGE, TL.COMMAND_DESCRIPTION_FORCHANGE)) { + return; + } - // since "&" color tags seem to work even through plain old FPlayer.sendMessage() for some reason, we need to break those up - // And replace all the % because it messes with string formatting and this is easy way around that. - myFaction.setDescription(TextUtil.implode(args, " ").replaceAll("%", "").replaceAll("(&([a-f0-9klmnor]))", "& $2")); + // since "&" color tags seem to work even through plain old FPlayer.sendMessage() for some reason, we need to break those up + // And replace all the % because it messes with string formatting and this is easy way around that. + myFaction.setDescription(TextUtil.implode(args, " ").replaceAll("%", "").replaceAll("(&([a-f0-9klmnor]))", "& $2")); - if (!Conf.broadcastDescriptionChanges) { - fme.msg(TL.COMMAND_DESCRIPTION_CHANGED, myFaction.describeTo(fme)); - fme.sendMessage(myFaction.getDescription()); - return; - } + if (!Conf.broadcastDescriptionChanges) { + fme.msg(TL.COMMAND_DESCRIPTION_CHANGED, myFaction.describeTo(fme)); + fme.sendMessage(myFaction.getDescription()); + return; + } - // Broadcast the description to everyone - for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers()) { - fplayer.msg(TL.COMMAND_DESCRIPTION_CHANGES, myFaction.describeTo(fplayer)); - fplayer.sendMessage(myFaction.getDescription()); // players can inject "&" or "`" or "" or whatever in their description; &k is particularly interesting looking - } - } + // Broadcast the description to everyone + for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers()) { + fplayer.msg(TL.COMMAND_DESCRIPTION_CHANGES, myFaction.describeTo(fplayer)); + fplayer.sendMessage(myFaction.getDescription()); // players can inject "&" or "`" or "" or whatever in their description; &k is particularly interesting looking + } + } - @Override - public TL getUsageTranslation() { - return TL.COMMAND_DESCRIPTION_DESCRIPTION; - } + @Override + public TL getUsageTranslation() { + return TL.COMMAND_DESCRIPTION_DESCRIPTION; + } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdDisband.java b/src/main/java/com/massivecraft/factions/cmd/CmdDisband.java index 161474ea..4c113bec 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdDisband.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdDisband.java @@ -16,101 +16,101 @@ import java.util.HashMap; public class CmdDisband extends FCommand { - private static HashMap disbandMap = new HashMap<>(); + private static HashMap disbandMap = new HashMap<>(); - public CmdDisband() { - super(); - this.aliases.add("disband"); + public CmdDisband() { + super(); + this.aliases.add("disband"); - //this.requiredArgs.add(""); - this.optionalArgs.put("faction tag", "yours"); + //this.requiredArgs.add(""); + this.optionalArgs.put("faction tag", "yours"); - this.permission = Permission.DISBAND.node; - this.disableOnLock = true; - this.disableOnSpam = true; + this.permission = Permission.DISBAND.node; + this.disableOnLock = true; + this.disableOnSpam = true; - senderMustBePlayer = false; - senderMustBeMember = false; - senderMustBeModerator = false; - senderMustBeColeader = false; - senderMustBeAdmin = false; + senderMustBePlayer = false; + senderMustBeMember = false; + senderMustBeModerator = false; + senderMustBeColeader = false; + senderMustBeAdmin = false; - } + } - @Override - public void perform() { - // The faction, default to your own.. but null if console sender. - Faction faction = this.argAsFaction(0, fme == null ? null : myFaction); - if (faction == null) { - return; - } + @Override + public void perform() { + // The faction, default to your own.. but null if console sender. + Faction faction = this.argAsFaction(0, fme == null ? null : myFaction); + if (faction == null) { + return; + } - if (!fme.isCooldownEnded("disband")) { - fme.msg(TL.COMMAND_ONCOOOLDOWN, fme.getCooldown("disband")); - return; - } + if (!fme.isCooldownEnded("disband")) { + fme.msg(TL.COMMAND_ONCOOOLDOWN, fme.getCooldown("disband")); + return; + } - boolean isMyFaction = fme != null && faction == myFaction; + boolean isMyFaction = fme != null && faction == myFaction; - if (isMyFaction) { - if (!assertMinRole(Role.LEADER)) { - return; - } - } else { - if (!Permission.DISBAND_ANY.has(sender, true)) { - return; - } - } + if (isMyFaction) { + if (!assertMinRole(Role.LEADER)) { + return; + } + } else { + if (!Permission.DISBAND_ANY.has(sender, true)) { + return; + } + } - if (fme != null && !fme.isAdminBypassing()) { - Access access = faction.getAccess(fme, PermissableAction.DISBAND); - if (fme.getRole() != Role.LEADER && faction.getFPlayerLeader() != fme && access != Access.ALLOW) { - fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "disband " + faction.getTag()); - return; - } - } + if (fme != null && !fme.isAdminBypassing()) { + Access access = faction.getAccess(fme, PermissableAction.DISBAND); + if (fme.getRole() != Role.LEADER && faction.getFPlayerLeader() != fme && access != Access.ALLOW) { + fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "disband " + faction.getTag()); + return; + } + } - if (!faction.isNormal()) { - msg(TL.COMMAND_DISBAND_IMMUTABLE.toString()); - return; - } - if (faction.isPermanent()) { - msg(TL.COMMAND_DISBAND_MARKEDPERMANENT.toString()); - return; - } + if (!faction.isNormal()) { + msg(TL.COMMAND_DISBAND_IMMUTABLE.toString()); + return; + } + if (faction.isPermanent()) { + msg(TL.COMMAND_DISBAND_MARKEDPERMANENT.toString()); + return; + } - // check for tnt before disbanding. + // check for tnt before disbanding. - if ((fme!= null && !disbandMap.containsKey(me.getUniqueId().toString())) && faction.getTnt() > 0) { - msg(TL.COMMAND_DISBAND_CONFIRM.toString().replace("{tnt}", faction.getTnt() + "")); - disbandMap.put(me.getUniqueId().toString(), faction.getId()); - Bukkit.getScheduler().scheduleSyncDelayedTask(P.p, () -> disbandMap.remove(me.getUniqueId().toString()), 200L); - } else if (faction.getId().equals(disbandMap.get(me.getUniqueId().toString())) || faction.getTnt() == 0) { - if (P.p.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); - fme.setCooldown("disband", System.currentTimeMillis() + (P.p.getConfig().getInt("fcooldowns.f-disband") * 1000)); - } else { - follower.msg(TL.COMMAND_DISBAND_BROADCAST_NOTYOURS, amountString, faction.getTag(follower)); - } - } - faction.disband(me, PlayerDisbandReason.COMMAND); - } else { - faction.disband(me, PlayerDisbandReason.COMMAND); - me.sendMessage(String.valueOf(TL.COMMAND_DISBAND_PLAYER)); - } - } - } + if ((fme != null && !disbandMap.containsKey(me.getUniqueId().toString())) && faction.getTnt() > 0) { + msg(TL.COMMAND_DISBAND_CONFIRM.toString().replace("{tnt}", faction.getTnt() + "")); + disbandMap.put(me.getUniqueId().toString(), faction.getId()); + Bukkit.getScheduler().scheduleSyncDelayedTask(P.p, () -> disbandMap.remove(me.getUniqueId().toString()), 200L); + } else if (faction.getId().equals(disbandMap.get(me.getUniqueId().toString())) || faction.getTnt() == 0) { + if (P.p.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); + fme.setCooldown("disband", System.currentTimeMillis() + (P.p.getConfig().getInt("fcooldowns.f-disband") * 1000)); + } else { + follower.msg(TL.COMMAND_DISBAND_BROADCAST_NOTYOURS, amountString, faction.getTag(follower)); + } + } + faction.disband(me, PlayerDisbandReason.COMMAND); + } else { + faction.disband(me, PlayerDisbandReason.COMMAND); + me.sendMessage(String.valueOf(TL.COMMAND_DISBAND_PLAYER)); + } + } + } - @Override - public TL getUsageTranslation() { - return TL.COMMAND_DISBAND_DESCRIPTION; - } + @Override + public TL getUsageTranslation() { + return TL.COMMAND_DISBAND_DESCRIPTION; + } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFGlobal.java b/src/main/java/com/massivecraft/factions/cmd/CmdFGlobal.java index 869cf301..1a796ebb 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFGlobal.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFGlobal.java @@ -9,6 +9,8 @@ import java.util.UUID; public class CmdFGlobal extends FCommand { + public static List toggled = new ArrayList<>(); + public CmdFGlobal() { super(); @@ -26,18 +28,16 @@ public class CmdFGlobal extends FCommand { senderMustBeAdmin = false; } - public static List toggled = new ArrayList<>(); - @Override public void perform() { - Player p = (Player)sender; + Player p = (Player) sender; // /f global - if (toggled.contains(p.getUniqueId())){ + if (toggled.contains(p.getUniqueId())) { toggled.remove(p.getUniqueId()); - }else{ + } else { toggled.add(p.getUniqueId()); } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFWarp.java b/src/main/java/com/massivecraft/factions/cmd/CmdFWarp.java index 75ee1ec2..8f3b5ec8 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFWarp.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFWarp.java @@ -16,68 +16,70 @@ import java.util.UUID; public class CmdFWarp extends FCommand { - public CmdFWarp() { - super(); - this.aliases.add("warp"); - this.aliases.add("warps"); - this.optionalArgs.put("warpname", "warpname"); - this.optionalArgs.put("password", "password"); + public CmdFWarp() { + super(); + this.aliases.add("warp"); + this.aliases.add("warps"); + this.optionalArgs.put("warpname", "warpname"); + this.optionalArgs.put("password", "password"); - this.permission = Permission.WARP.node; - this.senderMustBeMember = true; - this.senderMustBeModerator = false; - } + this.permission = Permission.WARP.node; + this.senderMustBeMember = true; + this.senderMustBeModerator = false; + } - @Override - public void perform() { - //TODO: check if in combat. - if (!fme.isAdminBypassing()) { - Access access = myFaction.getAccess(fme, PermissableAction.WARP); - if (access != Access.ALLOW && fme.getRole() != Role.LEADER) { - fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "use warps"); - return; - } - } + @Override + public void perform() { + //TODO: check if in combat. + if (!fme.isAdminBypassing()) { + Access access = myFaction.getAccess(fme, PermissableAction.WARP); + if (access != Access.ALLOW && fme.getRole() != Role.LEADER) { + fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "use warps"); + return; + } + } - if (args.size() == 0) { - new FactionWarpsFrame(fme.getFaction()).buildGUI(fme); - } else if (args.size() > 2) { - fme.msg(TL.COMMAND_FWARP_COMMANDFORMAT); - } else { - final String warpName = argAsString(0); - final String passwordAttempt = argAsString(1); + if (args.size() == 0) { + new FactionWarpsFrame(fme.getFaction()).buildGUI(fme); + } else if (args.size() > 2) { + fme.msg(TL.COMMAND_FWARP_COMMANDFORMAT); + } else { + final String warpName = argAsString(0); + final String passwordAttempt = argAsString(1); - if (myFaction.isWarp(argAsString(0))) { + if (myFaction.isWarp(argAsString(0))) { - // Check if requires password and if so, check if valid. CASE SENSITIVE - if (myFaction.hasWarpPassword(warpName) && !myFaction.isWarpPassword(warpName, passwordAttempt)) { - fme.msg(TL.COMMAND_FWARP_INVALID_PASSWORD); - return; - } + // Check if requires password and if so, check if valid. CASE SENSITIVE + if (myFaction.hasWarpPassword(warpName) && !myFaction.isWarpPassword(warpName, passwordAttempt)) { + fme.msg(TL.COMMAND_FWARP_INVALID_PASSWORD); + return; + } - // Check transaction AFTER password check. - if (!transact(fme)) return; - final FPlayer fPlayer = fme; - final UUID uuid = fme.getPlayer().getUniqueId(); - this.doWarmUp(WarmUpUtil.Warmup.WARP, TL.WARMUPS_NOTIFY_TELEPORT, warpName, () -> { - Player player = Bukkit.getPlayer(uuid); - if (player != null) { - player.teleport(fPlayer.getFaction().getWarp(warpName).getLocation()); - fPlayer.msg(TL.COMMAND_FWARP_WARPED, warpName); - } - }, this.p.getConfig().getLong("warmups.f-warp", 0)); - } else { fme.msg(TL.COMMAND_FWARP_INVALID_WARP, warpName); } - } - } + // Check transaction AFTER password check. + if (!transact(fme)) return; + final FPlayer fPlayer = fme; + final UUID uuid = fme.getPlayer().getUniqueId(); + this.doWarmUp(WarmUpUtil.Warmup.WARP, TL.WARMUPS_NOTIFY_TELEPORT, warpName, () -> { + Player player = Bukkit.getPlayer(uuid); + if (player != null) { + player.teleport(fPlayer.getFaction().getWarp(warpName).getLocation()); + fPlayer.msg(TL.COMMAND_FWARP_WARPED, warpName); + } + }, this.p.getConfig().getLong("warmups.f-warp", 0)); + } else { + fme.msg(TL.COMMAND_FWARP_INVALID_WARP, warpName); + } + } + } - private boolean transact(FPlayer player) { - return !P.p.getConfig().getBoolean("warp-cost.enabled", false) || player.isAdminBypassing() || payForCommand(P.p.getConfig().getDouble("warp-cost.warp", 5), TL.COMMAND_FWARP_TOWARP.toString(), TL.COMMAND_FWARP_FORWARPING.toString()); - } + private boolean transact(FPlayer player) { + return !P.p.getConfig().getBoolean("warp-cost.enabled", false) || player.isAdminBypassing() || payForCommand(P.p.getConfig().getDouble("warp-cost.warp", 5), TL.COMMAND_FWARP_TOWARP.toString(), TL.COMMAND_FWARP_FORWARPING.toString()); + } - @Override - public TL getUsageTranslation() { - return TL.COMMAND_FWARP_DESCRIPTION; - } + @Override + public TL getUsageTranslation() { + return TL.COMMAND_FWARP_DESCRIPTION; + } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFly.java b/src/main/java/com/massivecraft/factions/cmd/CmdFly.java index 43a39e9b..529ba870 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFly.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFly.java @@ -21,216 +21,215 @@ import java.util.concurrent.ConcurrentHashMap; public class CmdFly extends FCommand { - public static ConcurrentHashMap flyMap = new ConcurrentHashMap(); - public static int id = -1; - public static int flyid = -1; + public static ConcurrentHashMap flyMap = new ConcurrentHashMap(); + public static int id = -1; + public static int flyid = -1; - public CmdFly() { - super(); - this.aliases.add("fly"); + public CmdFly() { + super(); + this.aliases.add("fly"); - this.optionalArgs.put("on/off", "flip"); + this.optionalArgs.put("on/off", "flip"); - this.permission = Permission.FLY.node; - this.senderMustBeMember = true; - this.senderMustBeModerator = false; - } + this.permission = Permission.FLY.node; + this.senderMustBeMember = true; + this.senderMustBeModerator = false; + } - public static void startParticles() { - // Just a secondary check. - if (!P.p.getConfig().getBoolean("ffly.Particles.Enabled")) { - return; - } + public static void startParticles() { + // Just a secondary check. + if (!P.p.getConfig().getBoolean("ffly.Particles.Enabled")) { + return; + } - id = Bukkit.getScheduler().scheduleSyncRepeatingTask(P.p, () -> { - for (String name : flyMap.keySet()) { - Player player = Bukkit.getPlayer(name); - if (player == null) { - continue; - } - if (!player.isFlying()) { - continue; - } - if (!P.p.mc17) { - if (player.getGameMode() == GameMode.SPECTATOR) { - continue; - } - } + id = Bukkit.getScheduler().scheduleSyncRepeatingTask(P.p, () -> { + for (String name : flyMap.keySet()) { + Player player = Bukkit.getPlayer(name); + if (player == null) { + continue; + } + if (!player.isFlying()) { + continue; + } + if (!P.p.mc17) { + if (player.getGameMode() == GameMode.SPECTATOR) { + continue; + } + } - if (FPlayers.getInstance().getByPlayer(player).isVanished()) { - // Actually, vanished players (such as admins) should not display particles to prevent others from knowing their vanished assistance for moderation. - // But we can keep it as a config. - if (P.p.getConfig().getBoolean("ffly.Particles.Enable-While-Vanished")) { - return; - } - continue; - } - if (P.p.useNonPacketParticles) { - // 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); - } else { - ParticleEffect.CLOUD.display((float) 0, (float) 0, (float) 0, (float) 0, 3, player.getLocation().add(0, -0.35, 0), 16); - } + if (FPlayers.getInstance().getByPlayer(player).isVanished()) { + // Actually, vanished players (such as admins) should not display particles to prevent others from knowing their vanished assistance for moderation. + // But we can keep it as a config. + if (P.p.getConfig().getBoolean("ffly.Particles.Enable-While-Vanished")) { + return; + } + continue; + } + if (P.p.useNonPacketParticles) { + // 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); + } else { + 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; - } - }, 10L, 3L); - } + } + if (flyMap.keySet().size() == 0) { + Bukkit.getScheduler().cancelTask(id); + id = -1; + } + }, 10L, 3L); + } - public static void startFlyCheck() { - flyid = Bukkit.getScheduler().scheduleSyncRepeatingTask(P.p, () -> { //threw the exception for now, until I recode fly :( Cringe. - checkTaskState(); - if (flyMap.keySet().size() != 0) { - for (String name : flyMap.keySet()) { - if (name == null) { - continue; - } - Player player = Bukkit.getPlayer(name); - if (player == null - || !player.isFlying() - || player.getGameMode() == GameMode.CREATIVE - || !P.p.mc17 && player.getGameMode() == GameMode.SPECTATOR) { - continue; - } - FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player); - Faction myFaction = fPlayer.getFaction(); - if (myFaction.isWilderness()) { - fPlayer.setFlying(false); - flyMap.remove(name); - continue; - } - if (fPlayer.checkIfNearbyEnemies()) { - continue; - } - FLocation myFloc = new FLocation(player.getLocation()); - if (Board.getInstance().getFactionAt(myFloc) != myFaction) { - if (!checkBypassPerms(fPlayer, player, Board.getInstance().getFactionAt(myFloc))) { - fPlayer.setFlying(false); - flyMap.remove(name); - } - } + public static void startFlyCheck() { + flyid = Bukkit.getScheduler().scheduleSyncRepeatingTask(P.p, () -> { //threw the exception for now, until I recode fly :( Cringe. + checkTaskState(); + if (flyMap.keySet().size() != 0) { + for (String name : flyMap.keySet()) { + if (name == null) { + continue; + } + Player player = Bukkit.getPlayer(name); + if (player == null + || !player.isFlying() + || player.getGameMode() == GameMode.CREATIVE + || !P.p.mc17 && player.getGameMode() == GameMode.SPECTATOR) { + continue; + } + FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player); + Faction myFaction = fPlayer.getFaction(); + if (myFaction.isWilderness()) { + fPlayer.setFlying(false); + flyMap.remove(name); + continue; + } + if (fPlayer.checkIfNearbyEnemies()) { + continue; + } + FLocation myFloc = new FLocation(player.getLocation()); + if (Board.getInstance().getFactionAt(myFloc) != myFaction) { + if (!checkBypassPerms(fPlayer, player, Board.getInstance().getFactionAt(myFloc))) { + fPlayer.setFlying(false); + flyMap.remove(name); + } + } - } - } + } + } - }, 20L, 20L); - } + }, 20L, 20L); + } - private static boolean checkBypassPerms(FPlayer fme, Player me, Faction toFac) { - if (toFac != fme.getFaction()) { - if (!me.hasPermission("factions.fly.wilderness") && toFac.isWilderness() || !me.hasPermission("factions.fly.safezone") && toFac.isSafeZone() || !me.hasPermission("factions.fly.warzone") && toFac.isWarZone()) { - fme.msg(TL.COMMAND_FLY_NO_ACCESS, toFac.getTag(fme)); - return false; - } - Access access = toFac.getAccess(fme, PermissableAction.FLY); - if ((!(me.hasPermission("factions.fly.enemy") || access == Access.ALLOW)) && toFac.getRelationTo(fme.getFaction()) == Relation.ENEMY) { - fme.msg(TL.COMMAND_FLY_NO_ACCESS, toFac.getTag(fme)); - return false; - } - if (!(me.hasPermission("factions.fly.ally") || access == Access.ALLOW) && toFac.getRelationTo(fme.getFaction()) == Relation.ALLY) { - fme.msg(TL.COMMAND_FLY_NO_ACCESS, toFac.getTag(fme)); - return false; - } - if (!(me.hasPermission("factions.fly.truce") || access == Access.ALLOW) && toFac.getRelationTo(fme.getFaction()) == Relation.TRUCE) { - fme.msg(TL.COMMAND_FLY_NO_ACCESS, toFac.getTag(fme)); - return false; - } + private static boolean checkBypassPerms(FPlayer fme, Player me, Faction toFac) { + if (toFac != fme.getFaction()) { + if (!me.hasPermission("factions.fly.wilderness") && toFac.isWilderness() || !me.hasPermission("factions.fly.safezone") && toFac.isSafeZone() || !me.hasPermission("factions.fly.warzone") && toFac.isWarZone()) { + fme.msg(TL.COMMAND_FLY_NO_ACCESS, toFac.getTag(fme)); + return false; + } + Access access = toFac.getAccess(fme, PermissableAction.FLY); + if ((!(me.hasPermission("factions.fly.enemy") || access == Access.ALLOW)) && toFac.getRelationTo(fme.getFaction()) == Relation.ENEMY) { + fme.msg(TL.COMMAND_FLY_NO_ACCESS, toFac.getTag(fme)); + return false; + } + if (!(me.hasPermission("factions.fly.ally") || access == Access.ALLOW) && toFac.getRelationTo(fme.getFaction()) == Relation.ALLY) { + fme.msg(TL.COMMAND_FLY_NO_ACCESS, toFac.getTag(fme)); + return false; + } + if (!(me.hasPermission("factions.fly.truce") || access == Access.ALLOW) && toFac.getRelationTo(fme.getFaction()) == Relation.TRUCE) { + fme.msg(TL.COMMAND_FLY_NO_ACCESS, toFac.getTag(fme)); + return false; + } - if (!(me.hasPermission("factions.fly.neutral") || access == Access.ALLOW) && toFac.getRelationTo(fme.getFaction()) == Relation.NEUTRAL && !isSystemFaction(toFac)) { - fme.msg(TL.COMMAND_FLY_NO_ACCESS, toFac.getTag(fme)); - return false; - } - return me.hasPermission("factions.fly") && access != Access.DENY; - } - return true; - } + if (!(me.hasPermission("factions.fly.neutral") || access == Access.ALLOW) && toFac.getRelationTo(fme.getFaction()) == Relation.NEUTRAL && !isSystemFaction(toFac)) { + fme.msg(TL.COMMAND_FLY_NO_ACCESS, toFac.getTag(fme)); + return false; + } + return me.hasPermission("factions.fly") && access != Access.DENY; + } + return true; + } - public static Boolean isSystemFaction(Faction faction) { - return faction.isSafeZone() || - faction.isWarZone() || - faction.isWilderness(); - } + public static Boolean isSystemFaction(Faction faction) { + return faction.isSafeZone() || + faction.isWarZone() || + faction.isWilderness(); + } - public static void checkTaskState() { - if (flyMap.keySet().size() == 0) { - Bukkit.getScheduler().cancelTask(flyid); - flyid = -1; - } - } + public static void checkTaskState() { + if (flyMap.keySet().size() == 0) { + Bukkit.getScheduler().cancelTask(flyid); + flyid = -1; + } + } - public boolean isInFlightChecker(Player player) { - return flyMap.containsKey(player.getName()); - } + public static void disableFlight(final FPlayer fme) { + fme.setFlying(false); + flyMap.remove(fme.getPlayer().getName()); + } - @Override - public void perform() { - // Disabled by default. - if (!P.p.getConfig().getBoolean("enable-faction-flight", false)) { - fme.msg(TL.COMMAND_FLY_DISABLED); - return; - } + public boolean isInFlightChecker(Player player) { + return flyMap.containsKey(player.getName()); + } - FLocation myfloc = new FLocation(me.getLocation()); - Faction toFac = Board.getInstance().getFactionAt(myfloc); - if (!checkBypassPerms(fme, me, toFac)) return; - List entities = this.me.getNearbyEntities(16.0D, 256.0D, 16.0D); + @Override + public void perform() { + // Disabled by default. + if (!P.p.getConfig().getBoolean("enable-faction-flight", false)) { + fme.msg(TL.COMMAND_FLY_DISABLED); + return; + } - 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); - if (efplayer.getRelationTo(this.fme) == Relation.ENEMY && !efplayer.isStealthEnabled()) { - this.fme.msg(TL.COMMAND_FLY_CHECK_ENEMY); - return; - } - } - } + FLocation myfloc = new FLocation(me.getLocation()); + Faction toFac = Board.getInstance().getFactionAt(myfloc); + 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) { + if (entities.get(i) instanceof Player) { + Player eplayer = (Player) entities.get(i); + FPlayer efplayer = FPlayers.getInstance().getByPlayer(eplayer); + if (efplayer.getRelationTo(this.fme) == Relation.ENEMY && !efplayer.isStealthEnabled()) { + this.fme.msg(TL.COMMAND_FLY_CHECK_ENEMY); + return; + } + } + } - if (args.size() == 0) { - toggleFlight(fme.isFlying(), me); - } else if (args.size() == 1) { - toggleFlight(argAsBool(0), me); - } - } + if (args.size() == 0) { + toggleFlight(fme.isFlying(), me); + } else if (args.size() == 1) { + toggleFlight(argAsBool(0), me); + } + } - private void toggleFlight(final boolean toggle, final Player player) { - if (toggle) { - fme.setFlying(false); - flyMap.remove(player.getName()); - return; - } + private void toggleFlight(final boolean toggle, final Player player) { + if (toggle) { + fme.setFlying(false); + flyMap.remove(player.getName()); + return; + } - if (fme.canFlyAtLocation()) - this.doWarmUp(WarmUpUtil.Warmup.FLIGHT, TL.WARMUPS_NOTIFY_FLIGHT, "Fly", () -> { - fme.setFlying(true); - flyMap.put(player.getName(), true); - if (id == -1) { - if (P.p.getConfig().getBoolean("ffly.Particles.Enabled")) { - startParticles(); - } - } - if (flyid == -1) { - startFlyCheck(); - } - }, this.p.getConfig().getLong("warmups.f-fly", 0)); - } + if (fme.canFlyAtLocation()) + this.doWarmUp(WarmUpUtil.Warmup.FLIGHT, TL.WARMUPS_NOTIFY_FLIGHT, "Fly", () -> { + fme.setFlying(true); + flyMap.put(player.getName(), true); + if (id == -1) { + if (P.p.getConfig().getBoolean("ffly.Particles.Enabled")) { + startParticles(); + } + } + if (flyid == -1) { + startFlyCheck(); + } + }, this.p.getConfig().getLong("warmups.f-fly", 0)); + } - public static void disableFlight(final FPlayer fme) { - fme.setFlying(false); - flyMap.remove(fme.getPlayer().getName()); - } - - - @Override - public TL getUsageTranslation() { - return TL.COMMAND_FLY_DESCRIPTION; - } + @Override + public TL getUsageTranslation() { + return TL.COMMAND_FLY_DESCRIPTION; + } } \ No newline at end of file diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFocus.java b/src/main/java/com/massivecraft/factions/cmd/CmdFocus.java index a6e4e4cb..e17b5661 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFocus.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFocus.java @@ -7,48 +7,48 @@ import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.zcore.util.TL; public class CmdFocus - extends FCommand { - public CmdFocus() { - aliases.add("focus"); + extends FCommand { + public CmdFocus() { + 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() { - if (!P.p.getConfig().getBoolean("ffocus.Enabled")) { - fme.msg(TL.GENERIC_DISABLED); - return; - } - FPlayer target = argAsFPlayer(0); - if (target == null) { - return; - } - if (target.getFaction().getId().equalsIgnoreCase(myFaction.getId())) { - fme.msg(TL.COMMAND_FOCUS_SAMEFACTION); - return; - } - if ((myFaction.getFocused() != null) && (myFaction.getFocused().equalsIgnoreCase(target.getName()))) { - myFaction.setFocused(null); - myFaction.msg(TL.COMMAND_FOCUS_NO_LONGER, target.getName()); - FTeamWrapper.updatePrefixes(target.getFaction()); - return; - } - myFaction.msg(TL.COMMAND_FOCUS_FOCUSING, target.getName()); - myFaction.setFocused(target.getName()); - FTeamWrapper.updatePrefixes(target.getFaction()); - } + public void perform() { + if (!P.p.getConfig().getBoolean("ffocus.Enabled")) { + fme.msg(TL.GENERIC_DISABLED); + return; + } + FPlayer target = argAsFPlayer(0); + if (target == null) { + return; + } + if (target.getFaction().getId().equalsIgnoreCase(myFaction.getId())) { + fme.msg(TL.COMMAND_FOCUS_SAMEFACTION); + return; + } + if ((myFaction.getFocused() != null) && (myFaction.getFocused().equalsIgnoreCase(target.getName()))) { + myFaction.setFocused(null); + myFaction.msg(TL.COMMAND_FOCUS_NO_LONGER, target.getName()); + FTeamWrapper.updatePrefixes(target.getFaction()); + return; + } + myFaction.msg(TL.COMMAND_FOCUS_FOCUSING, target.getName()); + myFaction.setFocused(target.getName()); + FTeamWrapper.updatePrefixes(target.getFaction()); + } - public TL getUsageTranslation() { - return TL.COMMAND_FOCUS_DESCRIPTION; - } + public TL getUsageTranslation() { + return TL.COMMAND_FOCUS_DESCRIPTION; + } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdGetVault.java b/src/main/java/com/massivecraft/factions/cmd/CmdGetVault.java index 452adc2d..937b4dc9 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdGetVault.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdGetVault.java @@ -9,70 +9,70 @@ import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; public class CmdGetVault extends FCommand { - public CmdGetVault() { - super(); + public CmdGetVault() { + super(); - this.aliases.add("getvault"); + this.aliases.add("getvault"); - this.permission = Permission.GETVAULT.node; - this.disableOnLock = true; + this.permission = Permission.GETVAULT.node; + this.disableOnLock = true; - senderMustBePlayer = true; - senderMustBeMember = true; - senderMustBeModerator = false; - senderMustBeColeader = false; - senderMustBeAdmin = false; - } + senderMustBePlayer = true; + senderMustBeMember = true; + senderMustBeModerator = false; + senderMustBeColeader = false; + senderMustBeAdmin = false; + } - @Override - public void perform() { - if (!P.p.getConfig().getBoolean("fvault.Enabled")) { - fme.sendMessage("This command is disabled!"); - return; - } - Location vaultLocation = fme.getFaction().getVault(); - ItemStack vault = P.p.createItem(Material.CHEST, 1, (short) 0, P.p.color(P.p.getConfig().getString("fvault.Item.Name")), P.p.colorList(P.p.getConfig().getStringList("fvault.Item.Lore"))); + @Override + public void perform() { + if (!P.p.getConfig().getBoolean("fvault.Enabled")) { + fme.sendMessage("This command is disabled!"); + return; + } + Location vaultLocation = fme.getFaction().getVault(); + ItemStack vault = P.p.createItem(Material.CHEST, 1, (short) 0, P.p.color(P.p.getConfig().getString("fvault.Item.Name")), P.p.colorList(P.p.getConfig().getStringList("fvault.Item.Lore"))); - //check if vault is set - if (vaultLocation != null) { - fme.msg(TL.COMMAND_GETVAULT_ALREADYSET); - return; - } + //check if vault is set + if (vaultLocation != null) { + fme.msg(TL.COMMAND_GETVAULT_ALREADYSET); + return; + } - //has enough money? - int amount = P.p.getConfig().getInt("fvault.Price"); - if (!fme.hasMoney(amount)) { - return; - } + //has enough money? + int amount = P.p.getConfig().getInt("fvault.Price"); + if (!fme.hasMoney(amount)) { + return; + } - //success :) - fme.takeMoney(amount); - me.getInventory().addItem(vault); - fme.msg(TL.COMMAND_GETVAULT_RECEIVE); + //success :) + fme.takeMoney(amount); + me.getInventory().addItem(vault); + fme.msg(TL.COMMAND_GETVAULT_RECEIVE); - } + } - public boolean inventoryContains(Inventory inventory, ItemStack item) { - int count = 0; - ItemStack[] items = inventory.getContents(); - for (int i = 0; i < items.length; i++) { - if (items[i] != null && items[i].getType() == item.getType() && items[i].getDurability() == item.getDurability()) { - count += items[i].getAmount(); - } - if (count >= item.getAmount()) { - return true; - } - } - return false; - } + public boolean inventoryContains(Inventory inventory, ItemStack item) { + int count = 0; + ItemStack[] items = inventory.getContents(); + for (int i = 0; i < items.length; i++) { + if (items[i] != null && items[i].getType() == item.getType() && items[i].getDurability() == item.getDurability()) { + count += items[i].getAmount(); + } + if (count >= item.getAmount()) { + return true; + } + } + return false; + } - @Override - public TL getUsageTranslation() { - return TL.COMMAND_GETVAULT_DESCRIPTION; - } + @Override + public TL getUsageTranslation() { + return TL.COMMAND_GETVAULT_DESCRIPTION; + } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdHelp.java b/src/main/java/com/massivecraft/factions/cmd/CmdHelp.java index beda0e84..ad4f741f 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdHelp.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdHelp.java @@ -13,207 +13,207 @@ import java.util.List; public class CmdHelp extends FCommand { - public ArrayList> helpPages; + public ArrayList> helpPages; - public CmdHelp() { - super(); - this.aliases.add("help"); - this.aliases.add("h"); - this.aliases.add("?"); + public CmdHelp() { + super(); + this.aliases.add("help"); + this.aliases.add("h"); + this.aliases.add("?"); - //this.requiredArgs.add(""); - this.optionalArgs.put("page", "1"); + //this.requiredArgs.add(""); + this.optionalArgs.put("page", "1"); - this.permission = Permission.HELP.node; - this.disableOnLock = false; + this.permission = Permission.HELP.node; + this.disableOnLock = false; - senderMustBePlayer = false; - senderMustBeMember = false; - senderMustBeModerator = false; - senderMustBeColeader = false; - senderMustBeAdmin = false; - } + senderMustBePlayer = false; + senderMustBeMember = false; + senderMustBeModerator = false; + senderMustBeColeader = false; + senderMustBeAdmin = false; + } - //----------------------------------------------// - // Build the help pages - //----------------------------------------------// + //----------------------------------------------// + // Build the help pages + //----------------------------------------------// - @Override - public void perform() { - if (P.p.getConfig().getBoolean("use-old-help", true)) { - if (helpPages == null) { - updateHelp(); - } + @Override + public void perform() { + if (P.p.getConfig().getBoolean("use-old-help", true)) { + if (helpPages == null) { + updateHelp(); + } - int page = this.argAsInt(0, 1); - sendMessage(p.txt.titleize("Factions Help (" + page + "/" + helpPages.size() + ")")); + int page = this.argAsInt(0, 1); + sendMessage(p.txt.titleize("Factions Help (" + page + "/" + helpPages.size() + ")")); - page -= 1; + page -= 1; - if (page < 0 || page >= helpPages.size()) { - msg(TL.COMMAND_HELP_404.format(String.valueOf(page))); - return; - } - sendMessage(helpPages.get(page)); - return; - } - ConfigurationSection help = P.p.getConfig().getConfigurationSection("help"); - if (help == null) { - help = P.p.getConfig().createSection("help"); // create new help section - List error = new ArrayList<>(); - error.add("&cUpdate help messages in config.yml!"); - error.add("&cSet use-old-help for legacy help messages"); - help.set("'1'", error); // add default error messages - } - String pageArg = this.argAsString(0, "1"); - List page = help.getStringList(pageArg); - if (page == null || page.isEmpty()) { - msg(TL.COMMAND_HELP_404.format(pageArg)); - return; - } - for (String helpLine : page) { - sendMessage(P.p.txt.parse(helpLine)); - } - } + if (page < 0 || page >= helpPages.size()) { + msg(TL.COMMAND_HELP_404.format(String.valueOf(page))); + return; + } + sendMessage(helpPages.get(page)); + return; + } + ConfigurationSection help = P.p.getConfig().getConfigurationSection("help"); + if (help == null) { + help = P.p.getConfig().createSection("help"); // create new help section + List error = new ArrayList<>(); + error.add("&cUpdate help messages in config.yml!"); + error.add("&cSet use-old-help for legacy help messages"); + help.set("'1'", error); // add default error messages + } + String pageArg = this.argAsString(0, "1"); + List page = help.getStringList(pageArg); + if (page == null || page.isEmpty()) { + msg(TL.COMMAND_HELP_404.format(pageArg)); + return; + } + for (String helpLine : page) { + sendMessage(P.p.txt.parse(helpLine)); + } + } - public void updateHelp() { - helpPages = new ArrayList<>(); - ArrayList pageLines; + public void updateHelp() { + helpPages = new ArrayList<>(); + ArrayList pageLines; - pageLines = new ArrayList<>(); - pageLines.add(p.cmdBase.cmdHelp.getUseageTemplate(true)); - pageLines.add(p.cmdBase.cmdList.getUseageTemplate(true)); - pageLines.add(p.cmdBase.cmdShow.getUseageTemplate(true)); - pageLines.add(p.cmdBase.cmdPower.getUseageTemplate(true)); - pageLines.add(p.cmdBase.cmdJoin.getUseageTemplate(true)); - pageLines.add(p.cmdBase.cmdLeave.getUseageTemplate(true)); - pageLines.add(p.cmdBase.cmdChat.getUseageTemplate(true)); - pageLines.add(p.cmdBase.cmdToggleAllianceChat.getUseageTemplate(true)); - pageLines.add(p.cmdBase.cmdHome.getUseageTemplate(true)); - pageLines.add(p.txt.parse(TL.COMMAND_HELP_NEXTCREATE.toString())); - helpPages.add(pageLines); + pageLines = new ArrayList<>(); + pageLines.add(p.cmdBase.cmdHelp.getUseageTemplate(true)); + pageLines.add(p.cmdBase.cmdList.getUseageTemplate(true)); + pageLines.add(p.cmdBase.cmdShow.getUseageTemplate(true)); + pageLines.add(p.cmdBase.cmdPower.getUseageTemplate(true)); + pageLines.add(p.cmdBase.cmdJoin.getUseageTemplate(true)); + pageLines.add(p.cmdBase.cmdLeave.getUseageTemplate(true)); + pageLines.add(p.cmdBase.cmdChat.getUseageTemplate(true)); + pageLines.add(p.cmdBase.cmdToggleAllianceChat.getUseageTemplate(true)); + pageLines.add(p.cmdBase.cmdHome.getUseageTemplate(true)); + pageLines.add(p.txt.parse(TL.COMMAND_HELP_NEXTCREATE.toString())); + helpPages.add(pageLines); - pageLines = new ArrayList<>(); - pageLines.add(p.cmdBase.cmdCreate.getUseageTemplate(true)); - pageLines.add(p.cmdBase.cmdDescription.getUseageTemplate(true)); - pageLines.add(p.cmdBase.cmdTag.getUseageTemplate(true)); - pageLines.add(p.txt.parse(TL.COMMAND_HELP_INVITATIONS.toString())); - pageLines.add(p.cmdBase.cmdOpen.getUseageTemplate(true)); - pageLines.add(p.cmdBase.cmdInvite.getUseageTemplate(true)); - pageLines.add(p.cmdBase.cmdDeinvite.getUseageTemplate(true)); - pageLines.add(p.txt.parse(TL.COMMAND_HELP_HOME.toString())); - pageLines.add(p.cmdBase.cmdSethome.getUseageTemplate(true)); - helpPages.add(pageLines); + pageLines = new ArrayList<>(); + pageLines.add(p.cmdBase.cmdCreate.getUseageTemplate(true)); + pageLines.add(p.cmdBase.cmdDescription.getUseageTemplate(true)); + pageLines.add(p.cmdBase.cmdTag.getUseageTemplate(true)); + pageLines.add(p.txt.parse(TL.COMMAND_HELP_INVITATIONS.toString())); + pageLines.add(p.cmdBase.cmdOpen.getUseageTemplate(true)); + pageLines.add(p.cmdBase.cmdInvite.getUseageTemplate(true)); + pageLines.add(p.cmdBase.cmdDeinvite.getUseageTemplate(true)); + pageLines.add(p.txt.parse(TL.COMMAND_HELP_HOME.toString())); + pageLines.add(p.cmdBase.cmdSethome.getUseageTemplate(true)); + helpPages.add(pageLines); - if (Econ.isSetup() && Conf.econEnabled && Conf.bankEnabled) { - pageLines = new ArrayList<>(); - pageLines.add(""); - pageLines.add(p.txt.parse(TL.COMMAND_HELP_BANK_1.toString())); - pageLines.add(p.txt.parse(TL.COMMAND_HELP_BANK_2.toString())); - pageLines.add(p.txt.parse(TL.COMMAND_HELP_BANK_3.toString())); - pageLines.add(""); - pageLines.add(p.cmdBase.cmdMoney.getUseageTemplate(true)); - pageLines.add(""); - pageLines.add(""); - pageLines.add(""); - helpPages.add(pageLines); - } + if (Econ.isSetup() && Conf.econEnabled && Conf.bankEnabled) { + pageLines = new ArrayList<>(); + pageLines.add(""); + pageLines.add(p.txt.parse(TL.COMMAND_HELP_BANK_1.toString())); + pageLines.add(p.txt.parse(TL.COMMAND_HELP_BANK_2.toString())); + pageLines.add(p.txt.parse(TL.COMMAND_HELP_BANK_3.toString())); + pageLines.add(""); + pageLines.add(p.cmdBase.cmdMoney.getUseageTemplate(true)); + pageLines.add(""); + pageLines.add(""); + pageLines.add(""); + helpPages.add(pageLines); + } - pageLines = new ArrayList<>(); - pageLines.add(p.cmdBase.cmdClaim.getUseageTemplate(true)); - pageLines.add(p.cmdBase.cmdAutoClaim.getUseageTemplate(true)); - pageLines.add(p.cmdBase.cmdUnclaim.getUseageTemplate(true)); - pageLines.add(p.cmdBase.cmdUnclaimall.getUseageTemplate(true)); - pageLines.add(p.cmdBase.cmdKick.getUseageTemplate(true)); - pageLines.add(p.cmdBase.cmdMod.getUseageTemplate(true)); - pageLines.add(p.cmdBase.cmdAdmin.getUseageTemplate(true)); - pageLines.add(p.cmdBase.cmdTitle.getUseageTemplate(true)); - pageLines.add(p.cmdBase.cmdSB.getUseageTemplate(true)); - pageLines.add(p.cmdBase.cmdSeeChunk.getUseageTemplate(true)); - pageLines.add(p.cmdBase.cmdStatus.getUseageTemplate(true)); - pageLines.add(p.txt.parse(TL.COMMAND_HELP_PLAYERTITLES.toString())); - helpPages.add(pageLines); + pageLines = new ArrayList<>(); + pageLines.add(p.cmdBase.cmdClaim.getUseageTemplate(true)); + pageLines.add(p.cmdBase.cmdAutoClaim.getUseageTemplate(true)); + pageLines.add(p.cmdBase.cmdUnclaim.getUseageTemplate(true)); + pageLines.add(p.cmdBase.cmdUnclaimall.getUseageTemplate(true)); + pageLines.add(p.cmdBase.cmdKick.getUseageTemplate(true)); + pageLines.add(p.cmdBase.cmdMod.getUseageTemplate(true)); + pageLines.add(p.cmdBase.cmdAdmin.getUseageTemplate(true)); + pageLines.add(p.cmdBase.cmdTitle.getUseageTemplate(true)); + pageLines.add(p.cmdBase.cmdSB.getUseageTemplate(true)); + pageLines.add(p.cmdBase.cmdSeeChunk.getUseageTemplate(true)); + pageLines.add(p.cmdBase.cmdStatus.getUseageTemplate(true)); + pageLines.add(p.txt.parse(TL.COMMAND_HELP_PLAYERTITLES.toString())); + helpPages.add(pageLines); - pageLines = new ArrayList<>(); - pageLines.add(p.cmdBase.cmdMap.getUseageTemplate(true)); - pageLines.add(p.cmdBase.cmdBoom.getUseageTemplate(true)); - pageLines.add(p.cmdBase.cmdOwner.getUseageTemplate(true)); - pageLines.add(p.cmdBase.cmdOwnerList.getUseageTemplate(true)); - pageLines.add(p.txt.parse(TL.COMMAND_HELP_OWNERSHIP_1.toString())); - pageLines.add(p.txt.parse(TL.COMMAND_HELP_OWNERSHIP_2.toString())); - pageLines.add(p.txt.parse(TL.COMMAND_HELP_OWNERSHIP_3.toString())); - helpPages.add(pageLines); + pageLines = new ArrayList<>(); + pageLines.add(p.cmdBase.cmdMap.getUseageTemplate(true)); + pageLines.add(p.cmdBase.cmdBoom.getUseageTemplate(true)); + pageLines.add(p.cmdBase.cmdOwner.getUseageTemplate(true)); + pageLines.add(p.cmdBase.cmdOwnerList.getUseageTemplate(true)); + pageLines.add(p.txt.parse(TL.COMMAND_HELP_OWNERSHIP_1.toString())); + pageLines.add(p.txt.parse(TL.COMMAND_HELP_OWNERSHIP_2.toString())); + pageLines.add(p.txt.parse(TL.COMMAND_HELP_OWNERSHIP_3.toString())); + helpPages.add(pageLines); - pageLines = new ArrayList<>(); - pageLines.add(p.cmdBase.cmdDisband.getUseageTemplate(true)); - pageLines.add(""); - pageLines.add(p.cmdBase.cmdRelationAlly.getUseageTemplate(true)); - pageLines.add(p.cmdBase.cmdRelationNeutral.getUseageTemplate(true)); - pageLines.add(p.cmdBase.cmdRelationEnemy.getUseageTemplate(true)); - pageLines.add(p.txt.parse(TL.COMMAND_HELP_RELATIONS_1.toString())); - pageLines.add(p.txt.parse(TL.COMMAND_HELP_RELATIONS_2.toString())); - pageLines.add(p.txt.parse(TL.COMMAND_HELP_RELATIONS_3.toString())); - pageLines.add(p.txt.parse(TL.COMMAND_HELP_RELATIONS_4.toString())); - helpPages.add(pageLines); + pageLines = new ArrayList<>(); + pageLines.add(p.cmdBase.cmdDisband.getUseageTemplate(true)); + pageLines.add(""); + pageLines.add(p.cmdBase.cmdRelationAlly.getUseageTemplate(true)); + pageLines.add(p.cmdBase.cmdRelationNeutral.getUseageTemplate(true)); + pageLines.add(p.cmdBase.cmdRelationEnemy.getUseageTemplate(true)); + pageLines.add(p.txt.parse(TL.COMMAND_HELP_RELATIONS_1.toString())); + pageLines.add(p.txt.parse(TL.COMMAND_HELP_RELATIONS_2.toString())); + pageLines.add(p.txt.parse(TL.COMMAND_HELP_RELATIONS_3.toString())); + pageLines.add(p.txt.parse(TL.COMMAND_HELP_RELATIONS_4.toString())); + helpPages.add(pageLines); - pageLines = new ArrayList<>(); - pageLines.add(p.txt.parse(TL.COMMAND_HELP_RELATIONS_5.toString())); - pageLines.add(p.txt.parse(TL.COMMAND_HELP_RELATIONS_6.toString())); - pageLines.add(p.txt.parse(TL.COMMAND_HELP_RELATIONS_7.toString())); - pageLines.add(TL.COMMAND_HELP_RELATIONS_8.toString()); - pageLines.add(p.txt.parse(TL.COMMAND_HELP_RELATIONS_9.toString())); - pageLines.add(p.txt.parse(TL.COMMAND_HELP_RELATIONS_10.toString())); - pageLines.add(p.txt.parse(TL.COMMAND_HELP_RELATIONS_11.toString())); - pageLines.add(p.txt.parse(TL.COMMAND_HELP_RELATIONS_12.toString())); - pageLines.add(p.txt.parse(TL.COMMAND_HELP_RELATIONS_13.toString())); - helpPages.add(pageLines); + pageLines = new ArrayList<>(); + pageLines.add(p.txt.parse(TL.COMMAND_HELP_RELATIONS_5.toString())); + pageLines.add(p.txt.parse(TL.COMMAND_HELP_RELATIONS_6.toString())); + pageLines.add(p.txt.parse(TL.COMMAND_HELP_RELATIONS_7.toString())); + pageLines.add(TL.COMMAND_HELP_RELATIONS_8.toString()); + pageLines.add(p.txt.parse(TL.COMMAND_HELP_RELATIONS_9.toString())); + pageLines.add(p.txt.parse(TL.COMMAND_HELP_RELATIONS_10.toString())); + pageLines.add(p.txt.parse(TL.COMMAND_HELP_RELATIONS_11.toString())); + pageLines.add(p.txt.parse(TL.COMMAND_HELP_RELATIONS_12.toString())); + pageLines.add(p.txt.parse(TL.COMMAND_HELP_RELATIONS_13.toString())); + helpPages.add(pageLines); - pageLines = new ArrayList<>(); - pageLines.add(p.txt.parse(TL.COMMAND_HELP_PERMISSIONS_1.toString())); - pageLines.add(p.txt.parse(TL.COMMAND_HELP_PERMISSIONS_2.toString())); - pageLines.add(p.txt.parse(TL.COMMAND_HELP_PERMISSIONS_3.toString())); - pageLines.add(TL.COMMAND_HELP_PERMISSIONS_4.toString()); - pageLines.add(p.txt.parse(TL.COMMAND_HELP_PERMISSIONS_5.toString())); - pageLines.add(p.txt.parse(TL.COMMAND_HELP_PERMISSIONS_6.toString())); - pageLines.add(p.txt.parse(TL.COMMAND_HELP_PERMISSIONS_7.toString())); - pageLines.add(p.txt.parse(TL.COMMAND_HELP_PERMISSIONS_8.toString())); - pageLines.add(p.txt.parse(TL.COMMAND_HELP_PERMISSIONS_9.toString())); - helpPages.add(pageLines); + pageLines = new ArrayList<>(); + pageLines.add(p.txt.parse(TL.COMMAND_HELP_PERMISSIONS_1.toString())); + pageLines.add(p.txt.parse(TL.COMMAND_HELP_PERMISSIONS_2.toString())); + pageLines.add(p.txt.parse(TL.COMMAND_HELP_PERMISSIONS_3.toString())); + pageLines.add(TL.COMMAND_HELP_PERMISSIONS_4.toString()); + pageLines.add(p.txt.parse(TL.COMMAND_HELP_PERMISSIONS_5.toString())); + pageLines.add(p.txt.parse(TL.COMMAND_HELP_PERMISSIONS_6.toString())); + pageLines.add(p.txt.parse(TL.COMMAND_HELP_PERMISSIONS_7.toString())); + pageLines.add(p.txt.parse(TL.COMMAND_HELP_PERMISSIONS_8.toString())); + pageLines.add(p.txt.parse(TL.COMMAND_HELP_PERMISSIONS_9.toString())); + helpPages.add(pageLines); - pageLines = new ArrayList<>(); - pageLines.add(TL.COMMAND_HELP_MOAR_1.toString()); - pageLines.add(p.cmdBase.cmdBypass.getUseageTemplate(true)); - pageLines.add(p.txt.parse(TL.COMMAND_HELP_ADMIN_1.toString())); - pageLines.add(p.txt.parse(TL.COMMAND_HELP_ADMIN_2.toString())); - pageLines.add(p.txt.parse(TL.COMMAND_HELP_ADMIN_3.toString())); - pageLines.add(p.cmdBase.cmdSafeunclaimall.getUseageTemplate(true)); - pageLines.add(p.cmdBase.cmdWarunclaimall.getUseageTemplate(true)); - //TODO:TL - pageLines.add(p.txt.parse("Note: " + p.cmdBase.cmdUnclaim.getUseageTemplate(false) + P.p.txt.parse("") + " works on safe/war zones as well.")); - pageLines.add(p.cmdBase.cmdPeaceful.getUseageTemplate(true)); - helpPages.add(pageLines); + pageLines = new ArrayList<>(); + pageLines.add(TL.COMMAND_HELP_MOAR_1.toString()); + pageLines.add(p.cmdBase.cmdBypass.getUseageTemplate(true)); + pageLines.add(p.txt.parse(TL.COMMAND_HELP_ADMIN_1.toString())); + pageLines.add(p.txt.parse(TL.COMMAND_HELP_ADMIN_2.toString())); + pageLines.add(p.txt.parse(TL.COMMAND_HELP_ADMIN_3.toString())); + pageLines.add(p.cmdBase.cmdSafeunclaimall.getUseageTemplate(true)); + pageLines.add(p.cmdBase.cmdWarunclaimall.getUseageTemplate(true)); + //TODO:TL + pageLines.add(p.txt.parse("Note: " + p.cmdBase.cmdUnclaim.getUseageTemplate(false) + P.p.txt.parse("") + " works on safe/war zones as well.")); + pageLines.add(p.cmdBase.cmdPeaceful.getUseageTemplate(true)); + helpPages.add(pageLines); - pageLines = new ArrayList<>(); - pageLines.add(p.txt.parse(TL.COMMAND_HELP_MOAR_2.toString())); - pageLines.add(p.cmdBase.cmdChatSpy.getUseageTemplate(true)); - pageLines.add(p.cmdBase.cmdPermanent.getUseageTemplate(true)); - pageLines.add(p.cmdBase.cmdPermanentPower.getUseageTemplate(true)); - pageLines.add(p.cmdBase.cmdPowerBoost.getUseageTemplate(true)); - pageLines.add(p.cmdBase.cmdConfig.getUseageTemplate(true)); - helpPages.add(pageLines); + pageLines = new ArrayList<>(); + pageLines.add(p.txt.parse(TL.COMMAND_HELP_MOAR_2.toString())); + pageLines.add(p.cmdBase.cmdChatSpy.getUseageTemplate(true)); + pageLines.add(p.cmdBase.cmdPermanent.getUseageTemplate(true)); + pageLines.add(p.cmdBase.cmdPermanentPower.getUseageTemplate(true)); + pageLines.add(p.cmdBase.cmdPowerBoost.getUseageTemplate(true)); + pageLines.add(p.cmdBase.cmdConfig.getUseageTemplate(true)); + helpPages.add(pageLines); - pageLines = new ArrayList<>(); - pageLines.add(p.txt.parse(TL.COMMAND_HELP_MOAR_3.toString())); - pageLines.add(p.cmdBase.cmdLock.getUseageTemplate(true)); - pageLines.add(p.cmdBase.cmdReload.getUseageTemplate(true)); - pageLines.add(p.cmdBase.cmdSaveAll.getUseageTemplate(true)); - pageLines.add(p.cmdBase.cmdVersion.getUseageTemplate(true)); - helpPages.add(pageLines); - } + pageLines = new ArrayList<>(); + pageLines.add(p.txt.parse(TL.COMMAND_HELP_MOAR_3.toString())); + pageLines.add(p.cmdBase.cmdLock.getUseageTemplate(true)); + pageLines.add(p.cmdBase.cmdReload.getUseageTemplate(true)); + pageLines.add(p.cmdBase.cmdSaveAll.getUseageTemplate(true)); + pageLines.add(p.cmdBase.cmdVersion.getUseageTemplate(true)); + helpPages.add(pageLines); + } - @Override - public TL getUsageTranslation() { - return TL.COMMAND_HELP_DESCRIPTION; - } + @Override + public TL getUsageTranslation() { + return TL.COMMAND_HELP_DESCRIPTION; + } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdHome.java b/src/main/java/com/massivecraft/factions/cmd/CmdHome.java index 92b5d786..0379f4b4 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdHome.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdHome.java @@ -1,7 +1,6 @@ package com.massivecraft.factions.cmd; import com.massivecraft.factions.*; -import com.massivecraft.factions.integration.Essentials; import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Relation; import com.massivecraft.factions.struct.Role; @@ -10,7 +9,6 @@ import com.massivecraft.factions.zcore.fperms.Access; import com.massivecraft.factions.zcore.fperms.PermissableAction; import com.massivecraft.factions.zcore.util.SmokeUtil; import com.massivecraft.factions.zcore.util.TL; -import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.World; import org.bukkit.entity.Player; @@ -21,165 +19,160 @@ import java.util.List; public class CmdHome extends FCommand { - public CmdHome() { - super(); - this.aliases.add("home"); + public CmdHome() { + super(); + this.aliases.add("home"); - this.optionalArgs.put("faction", "yours"); - //this.requiredArgs.add(""); - //this.optionalArgs.put("", ""); + this.optionalArgs.put("faction", "yours"); + //this.requiredArgs.add(""); + //this.optionalArgs.put("", ""); - this.permission = Permission.HOME.node; - this.disableOnLock = false; + this.permission = Permission.HOME.node; + this.disableOnLock = false; - senderMustBePlayer = true; - senderMustBeMember = false; - senderMustBeModerator = false; - senderMustBeColeader = false; - senderMustBeAdmin = false; - } + senderMustBePlayer = true; + senderMustBeMember = false; + senderMustBeModerator = false; + senderMustBeColeader = false; + senderMustBeAdmin = false; + } - @Override - public void perform() { - // TODO: Hide this command on help also. + @Override + public void perform() { + // TODO: Hide this command on help also. - if (!Conf.homesEnabled) { - fme.msg(TL.COMMAND_HOME_DISABLED); - return; - } + if (!Conf.homesEnabled) { + fme.msg(TL.COMMAND_HOME_DISABLED); + return; + } - if (!Conf.homesTeleportCommandEnabled) { - fme.msg(TL.COMMAND_HOME_TELEPORTDISABLED); - return; - } + if (!Conf.homesTeleportCommandEnabled) { + fme.msg(TL.COMMAND_HOME_TELEPORTDISABLED); + return; + } - Faction factionArg; + Faction factionArg; - if (args.isEmpty()) - factionArg = myFaction; - else - factionArg = argAsFaction(0); + if (args.isEmpty()) + factionArg = myFaction; + else + factionArg = argAsFaction(0); - if (factionArg.isSystemFaction()) { - fme.msg(TL.GENERIC_NOPERMISSION, "teleport to system faction home"); - return; - } + if (factionArg.isSystemFaction()) { + fme.msg(TL.GENERIC_NOPERMISSION, "teleport to system faction home"); + return; + } - myFaction = factionArg; + myFaction = factionArg; - if(myFaction.isWilderness()) - return; + if (myFaction.isWilderness()) + return; - if (!fme.isAdminBypassing()) { - Access access = myFaction.getAccess(fme, PermissableAction.HOME); - if (access != Access.ALLOW && fme.getRole() != Role.LEADER) { - fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "teleport home"); - return; - } - } + if (!fme.isAdminBypassing()) { + Access access = myFaction.getAccess(fme, PermissableAction.HOME); + if (access != Access.ALLOW && fme.getRole() != Role.LEADER) { + fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "teleport home"); + return; + } + } - - if (!myFaction.hasHome()) { - fme.msg(TL.COMMAND_HOME_NOHOME.toString() + (fme.getRole().value < Role.MODERATOR.value ? TL.GENERIC_ASKYOURLEADER.toString() : TL.GENERIC_YOUSHOULD.toString())); - fme.sendMessage(p.cmdBase.cmdSethome.getUseageTemplate()); - return; - } + if (!myFaction.hasHome()) { + fme.msg(TL.COMMAND_HOME_NOHOME.toString() + (fme.getRole().value < Role.MODERATOR.value ? TL.GENERIC_ASKYOURLEADER.toString() : TL.GENERIC_YOUSHOULD.toString())); + fme.sendMessage(p.cmdBase.cmdSethome.getUseageTemplate()); + return; + } + if (!Conf.homesTeleportAllowedFromEnemyTerritory && fme.isInEnemyTerritory()) { + fme.msg(TL.COMMAND_HOME_INENEMY); + return; + } + + if (!Conf.homesTeleportAllowedFromDifferentWorld && me.getWorld().getUID() != myFaction.getHome().getWorld().getUID()) { + fme.msg(TL.COMMAND_HOME_WRONGWORLD); + return; + } + + if (!fme.isAdminBypassing()) { + Access access = fme.getFaction().getAccess(fme, PermissableAction.HOME); + if (access != Access.ALLOW && fme.getRole() != Role.LEADER) { + fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "teleport home"); + return; + } + } + + Faction faction = Board.getInstance().getFactionAt(new FLocation(me.getLocation())); + final Location loc = me.getLocation().clone(); + + // if player is not in a safe zone or their own faction territory, only allow teleport if no enemies are nearby + if (Conf.homesTeleportAllowedEnemyDistance > 0 && !faction.isSafeZone() && (!fme.isInOwnTerritory() || !Conf.homesTeleportIgnoreEnemiesIfInOwnTerritory)) { + World w = loc.getWorld(); + double x = loc.getX(); + double y = loc.getY(); + double z = loc.getZ(); + + for (Player p : me.getServer().getOnlinePlayers()) { + if (p == null || !p.isOnline() || p.isDead() || p == me || p.getWorld() != w) { + continue; + } + + FPlayer fp = FPlayers.getInstance().getByPlayer(p); + if (fme.getRelationTo(fp) != Relation.ENEMY || fp.isVanished()) { + continue; + } + + Location l = p.getLocation(); + double dx = Math.abs(x - l.getX()); + double dy = Math.abs(y - l.getY()); + double dz = Math.abs(z - l.getZ()); + double max = Conf.homesTeleportAllowedEnemyDistance; + + // box-shaped distance check + if (dx > max || dy > max || dz > max) { + continue; + } + + fme.msg(TL.COMMAND_HOME_ENEMYNEAR, String.valueOf(Conf.homesTeleportAllowedEnemyDistance)); + return; + } + } - if (!Conf.homesTeleportAllowedFromEnemyTerritory && fme.isInEnemyTerritory()) { - fme.msg(TL.COMMAND_HOME_INENEMY); - return; - } + // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay + if (!payForCommand(Conf.econCostHome, TL.COMMAND_HOME_TOTELEPORT.toString(), TL.COMMAND_HOME_FORTELEPORT.toString())) { + return; + } - if (!Conf.homesTeleportAllowedFromDifferentWorld && me.getWorld().getUID() != myFaction.getHome().getWorld().getUID()) { - fme.msg(TL.COMMAND_HOME_WRONGWORLD); - return; - } - - if (!fme.isAdminBypassing()) { - Access access = fme.getFaction().getAccess(fme, PermissableAction.HOME); - if (access != Access.ALLOW && fme.getRole() != Role.LEADER) { - fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "teleport home"); - return; - } - } - - Faction faction = Board.getInstance().getFactionAt(new FLocation(me.getLocation())); - final Location loc = me.getLocation().clone(); - - // if player is not in a safe zone or their own faction territory, only allow teleport if no enemies are nearby - if (Conf.homesTeleportAllowedEnemyDistance > 0 && !faction.isSafeZone() && (!fme.isInOwnTerritory() || !Conf.homesTeleportIgnoreEnemiesIfInOwnTerritory)) { - World w = loc.getWorld(); - double x = loc.getX(); - double y = loc.getY(); - double z = loc.getZ(); - - for (Player p : me.getServer().getOnlinePlayers()) { - if (p == null || !p.isOnline() || p.isDead() || p == me || p.getWorld() != w) { - continue; - } - - FPlayer fp = FPlayers.getInstance().getByPlayer(p); - if (fme.getRelationTo(fp) != Relation.ENEMY || fp.isVanished()) { - continue; - } - - Location l = p.getLocation(); - double dx = Math.abs(x - l.getX()); - double dy = Math.abs(y - l.getY()); - double dz = Math.abs(z - l.getZ()); - double max = Conf.homesTeleportAllowedEnemyDistance; - - // box-shaped distance check - if (dx > max || dy > max || dz > max) { - continue; - } - - fme.msg(TL.COMMAND_HOME_ENEMYNEAR, String.valueOf(Conf.homesTeleportAllowedEnemyDistance)); - return; - } - } - - - - // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay - if (!payForCommand(Conf.econCostHome, TL.COMMAND_HOME_TOTELEPORT.toString(), TL.COMMAND_HOME_FORTELEPORT.toString())) { - return; - } - - // TODO: Need to document this better confusing everyone, removed for now. + // TODO: Need to document this better confusing everyone, removed for now. // // if Essentials teleport handling is enabled and available, pass the teleport off to it (for delay and cooldown) // if (Essentials.handleTeleport(me, myFaction.getHome())) { // return; // } + this.doWarmUp(WarmUpUtil.Warmup.HOME, TL.WARMUPS_NOTIFY_TELEPORT, "Home", () -> { + // Create a smoke effect + if (Conf.homesTeleportCommandSmokeEffectEnabled) { + List smokeLocations = new ArrayList<>(); + smokeLocations.add(loc); + smokeLocations.add(loc.add(0, 1, 0)); + smokeLocations.add(CmdHome.this.myFaction.getHome()); + smokeLocations.add(CmdHome.this.myFaction.getHome().clone().add(0, 1, 0)); + SmokeUtil.spawnCloudRandom(smokeLocations, Conf.homesTeleportCommandSmokeEffectThickness); + } - this.doWarmUp(WarmUpUtil.Warmup.HOME, TL.WARMUPS_NOTIFY_TELEPORT, "Home", () -> { - // Create a smoke effect - if (Conf.homesTeleportCommandSmokeEffectEnabled) { - List smokeLocations = new ArrayList<>(); - smokeLocations.add(loc); - smokeLocations.add(loc.add(0, 1, 0)); - smokeLocations.add(CmdHome.this.myFaction.getHome()); - smokeLocations.add(CmdHome.this.myFaction.getHome().clone().add(0, 1, 0)); - SmokeUtil.spawnCloudRandom(smokeLocations, Conf.homesTeleportCommandSmokeEffectThickness); - } + CmdHome.this.me.teleport(CmdHome.this.myFaction.getHome()); + }, this.p.getConfig().getLong("warmups.f-home", 0)); + } - CmdHome.this.me.teleport(CmdHome.this.myFaction.getHome()); - }, this.p.getConfig().getLong("warmups.f-home", 0)); - } - - @Override - public TL getUsageTranslation() { - return TL.COMMAND_HOME_DESCRIPTION; - } + @Override + public TL getUsageTranslation() { + return TL.COMMAND_HOME_DESCRIPTION; + } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdInspect.java b/src/main/java/com/massivecraft/factions/cmd/CmdInspect.java index 4660844f..5e465e4a 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdInspect.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdInspect.java @@ -4,37 +4,37 @@ import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.zcore.util.TL; public class CmdInspect extends FCommand { - public CmdInspect() { - super(); - this.aliases.add("inspect"); - this.aliases.add("ins"); + public CmdInspect() { + super(); + this.aliases.add("inspect"); + this.aliases.add("ins"); - this.permission = Permission.INSPECT.node; - this.disableOnLock = true; + this.permission = Permission.INSPECT.node; + this.disableOnLock = true; - senderMustBePlayer = true; - senderMustBeMember = true; - senderMustBeModerator = false; - senderMustBeColeader = false; - senderMustBeAdmin = false; - } + senderMustBePlayer = true; + senderMustBeMember = true; + senderMustBeModerator = false; + senderMustBeColeader = false; + senderMustBeAdmin = false; + } - @Override - public void perform() { - if (fme.isInspectMode()) { - fme.setInspectMode(false); - msg(TL.COMMAND_INSPECT_DISABLED_MSG); - } else { - fme.setInspectMode(true); - msg(TL.COMMAND_INSPECT_ENABLED); - } + @Override + public void perform() { + if (fme.isInspectMode()) { + fme.setInspectMode(false); + msg(TL.COMMAND_INSPECT_DISABLED_MSG); + } else { + fme.setInspectMode(true); + msg(TL.COMMAND_INSPECT_ENABLED); + } - } + } - @Override - public TL getUsageTranslation() { - return TL.COMMAND_INSPECT_DESCRIPTION; - } + @Override + public TL getUsageTranslation() { + return TL.COMMAND_INSPECT_DESCRIPTION; + } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdInvite.java b/src/main/java/com/massivecraft/factions/cmd/CmdInvite.java index 00a9197e..a177d8f7 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdInvite.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdInvite.java @@ -12,83 +12,83 @@ import org.bukkit.ChatColor; public class CmdInvite extends FCommand { - public CmdInvite() { - super(); - this.aliases.add("invite"); - this.aliases.add("inv"); + public CmdInvite() { + super(); + this.aliases.add("invite"); + this.aliases.add("inv"); - this.requiredArgs.add("player name"); - //this.optionalArgs.put("", ""); + this.requiredArgs.add("player name"); + //this.optionalArgs.put("", ""); - this.permission = Permission.INVITE.node; - this.disableOnLock = true; + this.permission = Permission.INVITE.node; + this.disableOnLock = true; - senderMustBePlayer = true; - senderMustBeMember = false; - senderMustBeModerator = false; - senderMustBeColeader = false; - senderMustBeAdmin = false; - } + senderMustBePlayer = true; + senderMustBeMember = false; + senderMustBeModerator = false; + senderMustBeColeader = false; + senderMustBeAdmin = false; + } - @Override - public void perform() { - FPlayer target = this.argAsBestFPlayerMatch(0); - if (target == null) { - return; - } + @Override + public void perform() { + FPlayer target = this.argAsBestFPlayerMatch(0); + if (target == null) { + return; + } - if (target.getFaction() == myFaction) { - msg(TL.COMMAND_INVITE_ALREADYMEMBER, target.getName(), myFaction.getTag()); - msg(TL.GENERIC_YOUMAYWANT.toString() + p.cmdBase.cmdKick.getUseageTemplate(false)); - return; - } + if (target.getFaction() == myFaction) { + msg(TL.COMMAND_INVITE_ALREADYMEMBER, target.getName(), myFaction.getTag()); + msg(TL.GENERIC_YOUMAYWANT.toString() + p.cmdBase.cmdKick.getUseageTemplate(false)); + return; + } - // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay - if (!payForCommand(Conf.econCostInvite, TL.COMMAND_INVITE_TOINVITE.toString(), TL.COMMAND_INVITE_FORINVITE.toString())) { - return; - } + // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay + if (!payForCommand(Conf.econCostInvite, TL.COMMAND_INVITE_TOINVITE.toString(), TL.COMMAND_INVITE_FORINVITE.toString())) { + return; + } - if (!fme.isAdminBypassing()) { - Access access = myFaction.getAccess(fme, PermissableAction.INVITE); - if (access != Access.ALLOW && fme.getRole() != Role.LEADER) { - fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "manage invites"); - return; - } - } + if (!fme.isAdminBypassing()) { + Access access = myFaction.getAccess(fme, PermissableAction.INVITE); + if (access != Access.ALLOW && fme.getRole() != Role.LEADER) { + fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "manage invites"); + return; + } + } - if (myFaction.isInvited(target)) { - fme.msg(TL.COMMAND_INVITE_ALREADYINVITED, target.getName()); - return; - } - if (myFaction.isBanned(target)) { - fme.msg(TL.COMMAND_INVITE_BANNED, target.getName()); - return; - } + if (myFaction.isInvited(target)) { + fme.msg(TL.COMMAND_INVITE_ALREADYINVITED, target.getName()); + return; + } + if (myFaction.isBanned(target)) { + fme.msg(TL.COMMAND_INVITE_BANNED, target.getName()); + return; + } - myFaction.invite(target); - // Send the invitation to the target player when online, otherwise just ignore - if (target.isOnline()) { - // Tooltips, colors, and commands only apply to the string immediately before it. - FancyMessage message = new FancyMessage(fme.describeTo(target, true)) - .tooltip(TL.COMMAND_INVITE_CLICKTOJOIN.toString()) - .command("/" + Conf.baseCommandAliases.get(0) + " join " + myFaction.getTag()) - .then(TL.COMMAND_INVITE_INVITEDYOU.toString()) - .color(ChatColor.YELLOW) - .tooltip(TL.COMMAND_INVITE_CLICKTOJOIN.toString()) - .command("/" + Conf.baseCommandAliases.get(0) + " join " + myFaction.getTag()) - .then(myFaction.describeTo(target)).tooltip(TL.COMMAND_INVITE_CLICKTOJOIN.toString()) - .command("/" + Conf.baseCommandAliases.get(0) + " join " + myFaction.getTag()); + myFaction.invite(target); + // Send the invitation to the target player when online, otherwise just ignore + if (target.isOnline()) { + // Tooltips, colors, and commands only apply to the string immediately before it. + FancyMessage message = new FancyMessage(fme.describeTo(target, true)) + .tooltip(TL.COMMAND_INVITE_CLICKTOJOIN.toString()) + .command("/" + Conf.baseCommandAliases.get(0) + " join " + myFaction.getTag()) + .then(TL.COMMAND_INVITE_INVITEDYOU.toString()) + .color(ChatColor.YELLOW) + .tooltip(TL.COMMAND_INVITE_CLICKTOJOIN.toString()) + .command("/" + Conf.baseCommandAliases.get(0) + " join " + myFaction.getTag()) + .then(myFaction.describeTo(target)).tooltip(TL.COMMAND_INVITE_CLICKTOJOIN.toString()) + .command("/" + Conf.baseCommandAliases.get(0) + " join " + myFaction.getTag()); - message.send(target.getPlayer()); - } + message.send(target.getPlayer()); + } - myFaction.msg(TL.COMMAND_INVITE_INVITED, fme.describeTo(myFaction, true), target.describeTo(myFaction)); - } + myFaction.msg(TL.COMMAND_INVITE_INVITED, fme.describeTo(myFaction, true), target.describeTo(myFaction)); + } - @Override - public TL getUsageTranslation() { - return TL.COMMAND_INVITE_DESCRIPTION; - } + @Override + public TL getUsageTranslation() { + return TL.COMMAND_INVITE_DESCRIPTION; + } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdJoin.java b/src/main/java/com/massivecraft/factions/cmd/CmdJoin.java index 055119f8..bfc4ddcb 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdJoin.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdJoin.java @@ -9,150 +9,149 @@ import org.bukkit.Bukkit; public class CmdJoin extends FCommand { - public CmdJoin() { - super(); - this.aliases.add("join"); + public CmdJoin() { + super(); + this.aliases.add("join"); - this.requiredArgs.add("faction name"); - this.optionalArgs.put("player", "you"); + this.requiredArgs.add("faction name"); + this.optionalArgs.put("player", "you"); - this.permission = Permission.JOIN.node; - this.disableOnLock = true; + this.permission = Permission.JOIN.node; + this.disableOnLock = true; - senderMustBePlayer = true; - senderMustBeMember = false; - senderMustBeModerator = false; - senderMustBeColeader = false; - senderMustBeAdmin = false; - } + senderMustBePlayer = true; + senderMustBeMember = false; + senderMustBeModerator = false; + senderMustBeColeader = false; + senderMustBeAdmin = false; + } - @Override - public void perform() { - Faction faction = this.argAsFaction(0); - if (faction == null) { - return; - } + @Override + public void perform() { + Faction faction = this.argAsFaction(0); + if (faction == null) { + return; + } - FPlayer fplayer = this.argAsBestFPlayerMatch(1, fme, false); - boolean samePlayer = fplayer == fme; + FPlayer fplayer = this.argAsBestFPlayerMatch(1, fme, false); + boolean samePlayer = fplayer == fme; - if (!samePlayer && !Permission.JOIN_OTHERS.has(sender, false)) { - msg(TL.COMMAND_JOIN_CANNOTFORCE); - return; - } + if (!samePlayer && !Permission.JOIN_OTHERS.has(sender, false)) { + msg(TL.COMMAND_JOIN_CANNOTFORCE); + return; + } - if (!faction.isNormal()) { - msg(TL.COMMAND_JOIN_SYSTEMFACTION); - return; - } + if (!faction.isNormal()) { + msg(TL.COMMAND_JOIN_SYSTEMFACTION); + return; + } - if (faction == fplayer.getFaction()) { - //TODO:TL - msg(TL.COMMAND_JOIN_ALREADYMEMBER, fplayer.describeTo(fme, true), (samePlayer ? "are" : "is"), faction.getTag(fme)); - return; - } + if (faction == fplayer.getFaction()) { + //TODO:TL + msg(TL.COMMAND_JOIN_ALREADYMEMBER, fplayer.describeTo(fme, true), (samePlayer ? "are" : "is"), faction.getTag(fme)); + return; + } - if (Conf.factionMemberLimit > 0 && faction.getFPlayers().size() >= Conf.factionMemberLimit) { - msg(TL.COMMAND_JOIN_ATLIMIT, faction.getTag(fme), Conf.factionMemberLimit, fplayer.describeTo(fme, false)); - return; - } + if (Conf.factionMemberLimit > 0 && faction.getFPlayers().size() >= Conf.factionMemberLimit) { + msg(TL.COMMAND_JOIN_ATLIMIT, faction.getTag(fme), Conf.factionMemberLimit, fplayer.describeTo(fme, false)); + return; + } - if (fplayer.hasFaction()) { - //TODO:TL - msg(TL.COMMAND_JOIN_INOTHERFACTION, fplayer.describeTo(fme, true), (samePlayer ? "your" : "their")); - return; - } + if (fplayer.hasFaction()) { + //TODO:TL + msg(TL.COMMAND_JOIN_INOTHERFACTION, fplayer.describeTo(fme, true), (samePlayer ? "your" : "their")); + return; + } - if (!Conf.canLeaveWithNegativePower && fplayer.getPower() < 0) { - msg(TL.COMMAND_JOIN_NEGATIVEPOWER, fplayer.describeTo(fme, true)); - return; - } + if (!Conf.canLeaveWithNegativePower && fplayer.getPower() < 0) { + msg(TL.COMMAND_JOIN_NEGATIVEPOWER, fplayer.describeTo(fme, true)); + return; + } - if (!(faction.getOpen() || faction.isInvited(fplayer) || fme.isAdminBypassing() || Permission.JOIN_ANY.has(sender, false))) { - msg(TL.COMMAND_JOIN_REQUIRESINVITATION); - if (samePlayer) { - faction.msg(TL.COMMAND_JOIN_ATTEMPTEDJOIN, fplayer.describeTo(faction, true)); - } - return; - } - int level = faction.getUpgrade(UpgradeType.MEMBERS); + if (!(faction.getOpen() || faction.isInvited(fplayer) || fme.isAdminBypassing() || Permission.JOIN_ANY.has(sender, false))) { + msg(TL.COMMAND_JOIN_REQUIRESINVITATION); + if (samePlayer) { + faction.msg(TL.COMMAND_JOIN_ATTEMPTEDJOIN, fplayer.describeTo(faction, true)); + } + return; + } + int level = faction.getUpgrade(UpgradeType.MEMBERS); - int limit = 0; + int limit = 0; - if (level == 0) { - limit = Conf.factionMemberLimit; - } else { - limit = P.p.getConfig().getInt("fupgrades.MainMenu.Members.Members-Limit.level-" + level); - } + if (level == 0) { + limit = Conf.factionMemberLimit; + } else { + limit = P.p.getConfig().getInt("fupgrades.MainMenu.Members.Members-Limit.level-" + level); + } - if (limit > 0 && faction.getFPlayers().size() >= limit && !faction.altInvited(fme)) { - msg(TL.COMMAND_JOIN_ATLIMIT, faction.getTag(fme), limit, fplayer.describeTo(fme, false)); - return; - } + if (limit > 0 && faction.getFPlayers().size() >= limit && !faction.altInvited(fme)) { + msg(TL.COMMAND_JOIN_ATLIMIT, faction.getTag(fme), limit, fplayer.describeTo(fme, false)); + return; + } - int altLimit = Conf.factionAltMemberLimit; + int altLimit = Conf.factionAltMemberLimit; - if (altLimit > 0 && faction.getAltPlayers().size() >= altLimit && !faction.altInvited(fme)) { - msg(TL.COMMAND_JOIN_ATLIMIT, faction.getTag(fme), altLimit, fplayer.describeTo(fme, false)); - return; - } + if (altLimit > 0 && faction.getAltPlayers().size() >= altLimit && !faction.altInvited(fme)) { + msg(TL.COMMAND_JOIN_ATLIMIT, faction.getTag(fme), altLimit, fplayer.describeTo(fme, false)); + return; + } + // if economy is enabled, they're not on the bypass list, and this command has a cost set, make sure they can pay + if (samePlayer && !canAffordCommand(Conf.econCostJoin, TL.COMMAND_JOIN_TOJOIN.toString())) { + return; + } - // if economy is enabled, they're not on the bypass list, and this command has a cost set, make sure they can pay - if (samePlayer && !canAffordCommand(Conf.econCostJoin, TL.COMMAND_JOIN_TOJOIN.toString())) { - return; - } + // Check for ban + if (!fme.isAdminBypassing() && faction.isBanned(fme)) { + fme.msg(TL.COMMAND_JOIN_BANNED, faction.getTag(fme)); + return; + } - // Check for ban - if (!fme.isAdminBypassing() && faction.isBanned(fme)) { - fme.msg(TL.COMMAND_JOIN_BANNED, faction.getTag(fme)); - return; - } + // trigger the join event (cancellable) + FPlayerJoinEvent joinEvent = new FPlayerJoinEvent(FPlayers.getInstance().getByPlayer(me), faction, FPlayerJoinEvent.PlayerJoinReason.COMMAND); + Bukkit.getServer().getPluginManager().callEvent(joinEvent); + if (joinEvent.isCancelled()) { + return; + } - // trigger the join event (cancellable) - FPlayerJoinEvent joinEvent = new FPlayerJoinEvent(FPlayers.getInstance().getByPlayer(me), faction, FPlayerJoinEvent.PlayerJoinReason.COMMAND); - Bukkit.getServer().getPluginManager().callEvent(joinEvent); - if (joinEvent.isCancelled()) { - return; - } + // then make 'em pay (if applicable) + if (samePlayer && !payForCommand(Conf.econCostJoin, TL.COMMAND_JOIN_TOJOIN.toString(), TL.COMMAND_JOIN_FORJOIN.toString())) { + return; + } - // then make 'em pay (if applicable) - if (samePlayer && !payForCommand(Conf.econCostJoin, TL.COMMAND_JOIN_TOJOIN.toString(), TL.COMMAND_JOIN_FORJOIN.toString())) { - return; - } + fme.msg(TL.COMMAND_JOIN_SUCCESS, fplayer.describeTo(fme, true), faction.getTag(fme)); - fme.msg(TL.COMMAND_JOIN_SUCCESS, fplayer.describeTo(fme, true), faction.getTag(fme)); + if (!samePlayer) { + fplayer.msg(TL.COMMAND_JOIN_MOVED, fme.describeTo(fplayer, true), faction.getTag(fplayer)); + } - if (!samePlayer) { - fplayer.msg(TL.COMMAND_JOIN_MOVED, fme.describeTo(fplayer, true), faction.getTag(fplayer)); - } + faction.msg(TL.COMMAND_JOIN_JOINED, fplayer.describeTo(faction, true)); - faction.msg(TL.COMMAND_JOIN_JOINED, fplayer.describeTo(faction, true)); + fplayer.resetFactionData(); - fplayer.resetFactionData(); + if (faction.altInvited(fplayer)) { + fplayer.setAlt(true); + fplayer.setFaction(faction, true); + } else { + fplayer.setFaction(faction, false); + } - if(faction.altInvited(fplayer)){ - fplayer.setAlt(true); - fplayer.setFaction(faction, true); - } else { - fplayer.setFaction(faction, false); - } + faction.deinvite(fplayer); + fplayer.setRole(faction.getDefaultRole()); + if (Conf.logFactionJoin) { + if (samePlayer) { + P.p.log(TL.COMMAND_JOIN_JOINEDLOG.toString(), fplayer.getName(), faction.getTag()); + } else { + P.p.log(TL.COMMAND_JOIN_MOVEDLOG.toString(), fme.getName(), fplayer.getName(), faction.getTag()); + } + } + } - faction.deinvite(fplayer); - fplayer.setRole(faction.getDefaultRole()); - if (Conf.logFactionJoin) { - if (samePlayer) { - P.p.log(TL.COMMAND_JOIN_JOINEDLOG.toString(), fplayer.getName(), faction.getTag()); - } else { - P.p.log(TL.COMMAND_JOIN_MOVEDLOG.toString(), fme.getName(), fplayer.getName(), faction.getTag()); - } - } - } - - @Override - public TL getUsageTranslation() { - return TL.COMMAND_JOIN_DESCRIPTION; - } + @Override + public TL getUsageTranslation() { + return TL.COMMAND_JOIN_DESCRIPTION; + } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdKick.java b/src/main/java/com/massivecraft/factions/cmd/CmdKick.java index 772338de..cd4ad712 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdKick.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdKick.java @@ -16,131 +16,131 @@ import org.bukkit.ChatColor; public class CmdKick extends FCommand { - public CmdKick() { - super(); - this.aliases.add("kick"); + public CmdKick() { + super(); + this.aliases.add("kick"); - this.optionalArgs.put("player name", "player name"); - //this.optionalArgs.put("", ""); + this.optionalArgs.put("player name", "player name"); + //this.optionalArgs.put("", ""); - this.permission = Permission.KICK.node; - this.disableOnLock = false; + this.permission = Permission.KICK.node; + this.disableOnLock = false; - senderMustBePlayer = true; - senderMustBeMember = false; - senderMustBeModerator = false; - senderMustBeAdmin = false; - } + senderMustBePlayer = true; + senderMustBeMember = false; + senderMustBeModerator = false; + senderMustBeAdmin = false; + } - @Override - public void perform() { - FPlayer toKick = this.argIsSet(0) ? this.argAsBestFPlayerMatch(0) : null; - if (toKick == null) { - FancyMessage msg = new FancyMessage(TL.COMMAND_KICK_CANDIDATES.toString()).color(ChatColor.GOLD); - for (FPlayer player : myFaction.getFPlayersWhereRole(Role.NORMAL)) { - String s = player.getName(); - msg.then(s + " ").color(ChatColor.WHITE).tooltip(TL.COMMAND_KICK_CLICKTOKICK.toString() + s).command("/" + Conf.baseCommandAliases.get(0) + " kick " + s); - } - if (fme.getRole().isAtLeast(Role.COLEADER)) { - // For both coleader and admin, add mods. - for (FPlayer player : myFaction.getFPlayersWhereRole(Role.MODERATOR)) { - String s = player.getName(); - msg.then(s + " ").color(ChatColor.GRAY).tooltip(TL.COMMAND_KICK_CLICKTOKICK.toString() + s).command("/" + Conf.baseCommandAliases.get(0) + " kick " + s); - } - if (fme.getRole() == Role.LEADER) { - // Only add coleader to this for the leader. - for (FPlayer player : myFaction.getFPlayersWhereRole(Role.COLEADER)) { - String s = player.getName(); - msg.then(s + " ").color(ChatColor.RED).tooltip(TL.COMMAND_KICK_CLICKTOKICK.toString() + s).command("/" + Conf.baseCommandAliases.get(0) + " kick " + s); - } - } - } + @Override + public void perform() { + FPlayer toKick = this.argIsSet(0) ? this.argAsBestFPlayerMatch(0) : null; + if (toKick == null) { + FancyMessage msg = new FancyMessage(TL.COMMAND_KICK_CANDIDATES.toString()).color(ChatColor.GOLD); + for (FPlayer player : myFaction.getFPlayersWhereRole(Role.NORMAL)) { + String s = player.getName(); + msg.then(s + " ").color(ChatColor.WHITE).tooltip(TL.COMMAND_KICK_CLICKTOKICK.toString() + s).command("/" + Conf.baseCommandAliases.get(0) + " kick " + s); + } + if (fme.getRole().isAtLeast(Role.COLEADER)) { + // For both coleader and admin, add mods. + for (FPlayer player : myFaction.getFPlayersWhereRole(Role.MODERATOR)) { + String s = player.getName(); + msg.then(s + " ").color(ChatColor.GRAY).tooltip(TL.COMMAND_KICK_CLICKTOKICK.toString() + s).command("/" + Conf.baseCommandAliases.get(0) + " kick " + s); + } + if (fme.getRole() == Role.LEADER) { + // Only add coleader to this for the leader. + for (FPlayer player : myFaction.getFPlayersWhereRole(Role.COLEADER)) { + String s = player.getName(); + msg.then(s + " ").color(ChatColor.RED).tooltip(TL.COMMAND_KICK_CLICKTOKICK.toString() + s).command("/" + Conf.baseCommandAliases.get(0) + " kick " + s); + } + } + } - sendFancyMessage(msg); - return; - } + sendFancyMessage(msg); + return; + } - if (fme == toKick) { - msg(TL.COMMAND_KICK_SELF); - msg(TL.GENERIC_YOUMAYWANT.toString() + p.cmdBase.cmdLeave.getUseageTemplate(false)); - return; - } + if (fme == toKick) { + msg(TL.COMMAND_KICK_SELF); + msg(TL.GENERIC_YOUMAYWANT.toString() + p.cmdBase.cmdLeave.getUseageTemplate(false)); + return; + } - if(toKick.isAlt()){ - msg(P.p.color("&cToo few arguments, &eUse like this:")); - msg(P.p.color("&b/f alts,alt kick &3")); - return; - } + if (toKick.isAlt()) { + msg(P.p.color("&cToo few arguments, &eUse like this:")); + msg(P.p.color("&b/f alts,alt kick &3")); + return; + } - Faction toKickFaction = toKick.getFaction(); + Faction toKickFaction = toKick.getFaction(); - if (toKickFaction.isWilderness()) { - sender.sendMessage(TL.COMMAND_KICK_NONE.toString()); - return; - } + if (toKickFaction.isWilderness()) { + sender.sendMessage(TL.COMMAND_KICK_NONE.toString()); + return; + } - // This permission check has been cleaned to be more understandable and logical - // Unless is admin, - // - Check for the kick permission. - // - Make sure the player is in the faction. - // - Make sure the kicked player has lower rank than the kicker. - if (!fme.isAdminBypassing()) { - Access access = myFaction.getAccess(fme, PermissableAction.KICK); - if (access != Access.ALLOW && fme.getRole() != Role.LEADER) { - fme.msg(TL.GENERIC_NOPERMISSION, "kick"); - return; - } - if (toKickFaction != myFaction) { - msg(TL.COMMAND_KICK_NOTMEMBER, toKick.describeTo(fme, true), myFaction.describeTo(fme)); - return; - } - if (toKick.getRole().value >= fme.getRole().value) { - msg(TL.COMMAND_KICK_INSUFFICIENTRANK); - return; - } - if (!Conf.canLeaveWithNegativePower && toKick.getPower() < 0) { - msg(TL.COMMAND_KICK_NEGATIVEPOWER); - return; - } - } + // This permission check has been cleaned to be more understandable and logical + // Unless is admin, + // - Check for the kick permission. + // - Make sure the player is in the faction. + // - Make sure the kicked player has lower rank than the kicker. + if (!fme.isAdminBypassing()) { + Access access = myFaction.getAccess(fme, PermissableAction.KICK); + if (access != Access.ALLOW && fme.getRole() != Role.LEADER) { + fme.msg(TL.GENERIC_NOPERMISSION, "kick"); + return; + } + if (toKickFaction != myFaction) { + msg(TL.COMMAND_KICK_NOTMEMBER, toKick.describeTo(fme, true), myFaction.describeTo(fme)); + return; + } + if (toKick.getRole().value >= fme.getRole().value) { + msg(TL.COMMAND_KICK_INSUFFICIENTRANK); + return; + } + if (!Conf.canLeaveWithNegativePower && toKick.getPower() < 0) { + msg(TL.COMMAND_KICK_NEGATIVEPOWER); + return; + } + } - // if economy is enabled, they're not on the bypass list, and this command has a cost set, make sure they can pay - if (!canAffordCommand(Conf.econCostKick, TL.COMMAND_KICK_TOKICK.toString())) { - return; - } + // if economy is enabled, they're not on the bypass list, and this command has a cost set, make sure they can pay + if (!canAffordCommand(Conf.econCostKick, TL.COMMAND_KICK_TOKICK.toString())) { + return; + } - // trigger the leave event (cancellable) [reason:kicked] - FPlayerLeaveEvent event = new FPlayerLeaveEvent(toKick, toKick.getFaction(), FPlayerLeaveEvent.PlayerLeaveReason.KICKED); - Bukkit.getServer().getPluginManager().callEvent(event); - if (event.isCancelled()) { - return; - } + // trigger the leave event (cancellable) [reason:kicked] + FPlayerLeaveEvent event = new FPlayerLeaveEvent(toKick, toKick.getFaction(), FPlayerLeaveEvent.PlayerLeaveReason.KICKED); + Bukkit.getServer().getPluginManager().callEvent(event); + if (event.isCancelled()) { + return; + } - // then make 'em pay (if applicable) - if (!payForCommand(Conf.econCostKick, TL.COMMAND_KICK_TOKICK.toString(), TL.COMMAND_KICK_FORKICK.toString())) { - return; - } + // then make 'em pay (if applicable) + if (!payForCommand(Conf.econCostKick, TL.COMMAND_KICK_TOKICK.toString(), TL.COMMAND_KICK_FORKICK.toString())) { + return; + } - toKickFaction.msg(TL.COMMAND_KICK_FACTION, fme.describeTo(toKickFaction, true), toKick.describeTo(toKickFaction, true)); + toKickFaction.msg(TL.COMMAND_KICK_FACTION, fme.describeTo(toKickFaction, true), toKick.describeTo(toKickFaction, true)); - toKick.msg(TL.COMMAND_KICK_KICKED, fme.describeTo(toKick, true), toKickFaction.describeTo(toKick)); - if (toKickFaction != myFaction) { - fme.msg(TL.COMMAND_KICK_KICKS, toKick.describeTo(fme), toKickFaction.describeTo(fme)); - } - if (Conf.logFactionKick) { - P.p.log((senderIsConsole ? "A console command" : fme.getName()) + " kicked " + toKick.getName() + " from the faction: " + toKickFaction.getTag()); - } - if (toKick.getRole() == Role.LEADER) { - toKickFaction.promoteNewLeader(); - } - toKickFaction.deinvite(toKick); - toKick.resetFactionData(); - } + toKick.msg(TL.COMMAND_KICK_KICKED, fme.describeTo(toKick, true), toKickFaction.describeTo(toKick)); + if (toKickFaction != myFaction) { + fme.msg(TL.COMMAND_KICK_KICKS, toKick.describeTo(fme), toKickFaction.describeTo(fme)); + } + if (Conf.logFactionKick) { + P.p.log((senderIsConsole ? "A console command" : fme.getName()) + " kicked " + toKick.getName() + " from the faction: " + toKickFaction.getTag()); + } + if (toKick.getRole() == Role.LEADER) { + toKickFaction.promoteNewLeader(); + } + toKickFaction.deinvite(toKick); + toKick.resetFactionData(); + } - @Override - public TL getUsageTranslation() { - return TL.COMMAND_KICK_DESCRIPTION; - } + @Override + public TL getUsageTranslation() { + return TL.COMMAND_KICK_DESCRIPTION; + } } \ No newline at end of file diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdKillHolograms.java b/src/main/java/com/massivecraft/factions/cmd/CmdKillHolograms.java index 4c3ec562..0ee95a2b 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdKillHolograms.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdKillHolograms.java @@ -4,32 +4,32 @@ import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.zcore.util.TL; public class CmdKillHolograms extends FCommand { - public CmdKillHolograms() { - super(); + public CmdKillHolograms() { + super(); - this.aliases.add("killholos"); + this.aliases.add("killholos"); - this.requiredArgs.add("radius"); + this.requiredArgs.add("radius"); - this.permission = Permission.KILLHOLOS.node; - this.disableOnLock = true; + this.permission = Permission.KILLHOLOS.node; + this.disableOnLock = true; - senderMustBePlayer = true; - senderMustBeMember = false; - senderMustBeModerator = false; - senderMustBeColeader = false; - senderMustBeAdmin = false; - } + senderMustBePlayer = true; + senderMustBeMember = false; + senderMustBeModerator = false; + senderMustBeColeader = false; + senderMustBeAdmin = false; + } - @Override - public void perform() { - me.sendMessage("Killing Invisible Armor Stands.."); - me.chat("/minecraft:kill @e[type=ArmorStand,r=" + argAsInt(0) + "]"); + @Override + public void perform() { + me.sendMessage("Killing Invisible Armor Stands.."); + me.chat("/minecraft:kill @e[type=ArmorStand,r=" + argAsInt(0) + "]"); - } + } - @Override - public TL getUsageTranslation() { - return TL.COMMAND_KILLHOLOGRAMS_DESCRIPTION; - } + @Override + public TL getUsageTranslation() { + return TL.COMMAND_KILLHOLOGRAMS_DESCRIPTION; + } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdLeave.java b/src/main/java/com/massivecraft/factions/cmd/CmdLeave.java index 8d9c5634..b28f4ab6 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdLeave.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdLeave.java @@ -5,32 +5,32 @@ import com.massivecraft.factions.zcore.util.TL; public class CmdLeave extends FCommand { - public CmdLeave() { - super(); - this.aliases.add("leave"); + public CmdLeave() { + super(); + this.aliases.add("leave"); - //this.requiredArgs.add(""); - //this.optionalArgs.put("", ""); + //this.requiredArgs.add(""); + //this.optionalArgs.put("", ""); - this.permission = Permission.LEAVE.node; - this.disableOnLock = true; + this.permission = Permission.LEAVE.node; + this.disableOnLock = true; - senderMustBePlayer = true; - senderMustBeMember = true; - senderMustBeModerator = false; - senderMustBeColeader = false; - senderMustBeAdmin = false; - } + senderMustBePlayer = true; + senderMustBeMember = true; + senderMustBeModerator = false; + senderMustBeColeader = false; + senderMustBeAdmin = false; + } - @Override - public void perform() { - fme.leave(true); - } + @Override + public void perform() { + fme.leave(true); + } - @Override - public TL getUsageTranslation() { - return TL.LEAVE_DESCRIPTION; - } + @Override + public TL getUsageTranslation() { + return TL.LEAVE_DESCRIPTION; + } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdList.java b/src/main/java/com/massivecraft/factions/cmd/CmdList.java index 487d7398..54504e88 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdList.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdList.java @@ -8,113 +8,115 @@ import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TagUtil; -import java.util.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; public class CmdList extends FCommand { - private String[] defaults = new String[3]; + private String[] defaults = new String[3]; - public CmdList() { - super(); - this.aliases.add("list"); - this.aliases.add("ls"); + public CmdList() { + super(); + this.aliases.add("list"); + this.aliases.add("ls"); - // default values in case user has old config - defaults[0] = "&e&m----------&r&e[ &2Faction List &9{pagenumber}&e/&9{pagecount} &e]&m----------"; - defaults[1] = "Factionless {factionless} online"; - defaults[2] = "{faction} {online} / {members} online, Land / Power / Maxpower: {chunks}/{power}/{maxPower}"; + // default values in case user has old config + defaults[0] = "&e&m----------&r&e[ &2Faction List &9{pagenumber}&e/&9{pagecount} &e]&m----------"; + defaults[1] = "Factionless {factionless} online"; + defaults[2] = "{faction} {online} / {members} online, Land / Power / Maxpower: {chunks}/{power}/{maxPower}"; - //this.requiredArgs.add(""); - this.optionalArgs.put("page", "1"); + //this.requiredArgs.add(""); + this.optionalArgs.put("page", "1"); - this.permission = Permission.LIST.node; - this.disableOnLock = false; + this.permission = Permission.LIST.node; + this.disableOnLock = false; - senderMustBePlayer = false; - senderMustBeMember = false; - senderMustBeModerator = false; - senderMustBeColeader = false; - senderMustBeAdmin = false; - } + senderMustBePlayer = false; + senderMustBeMember = false; + senderMustBeModerator = false; + senderMustBeColeader = false; + senderMustBeAdmin = false; + } - @Override - public void perform() { - // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay - if (!payForCommand(Conf.econCostList, "to list the factions", "for listing the factions")) - return; + @Override + public void perform() { + // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay + if (!payForCommand(Conf.econCostList, "to list the factions", "for listing the factions")) + return; - ArrayList factionList = Factions.getInstance().getAllFactions(); - factionList.remove(Factions.getInstance().getWilderness()); - factionList.remove(Factions.getInstance().getSafeZone()); - factionList.remove(Factions.getInstance().getWarZone()); + ArrayList factionList = Factions.getInstance().getAllFactions(); + factionList.remove(Factions.getInstance().getWilderness()); + factionList.remove(Factions.getInstance().getSafeZone()); + factionList.remove(Factions.getInstance().getWarZone()); - // remove exempt factions - if (fme != null && fme.getPlayer() != null && !fme.getPlayer().hasPermission("factions.show.bypassexempt")) { - List exemptFactions = P.p.getConfig().getStringList("show-exempt"); + // remove exempt factions + if (fme != null && fme.getPlayer() != null && !fme.getPlayer().hasPermission("factions.show.bypassexempt")) { + List exemptFactions = P.p.getConfig().getStringList("show-exempt"); - factionList.removeIf(next -> exemptFactions.contains(next.getTag())); - } + factionList.removeIf(next -> exemptFactions.contains(next.getTag())); + } - // Sort by total followers first - Collections.sort(factionList, (f1, f2) -> { - int f1Size = f1.getFPlayers().size(); - int f2Size = f2.getFPlayers().size(); - if (f1Size < f2Size) { - return 1; - } else if (f1Size > f2Size) { - return -1; - } - return 0; - }); + // Sort by total followers first + Collections.sort(factionList, (f1, f2) -> { + int f1Size = f1.getFPlayers().size(); + int f2Size = f2.getFPlayers().size(); + if (f1Size < f2Size) { + return 1; + } else if (f1Size > f2Size) { + return -1; + } + return 0; + }); - // Then sort by how many members are online now - factionList.sort((f1, f2) -> { - int f1Size = f1.getFPlayersWhereOnline(true).size(); - int f2Size = f2.getFPlayersWhereOnline(true).size(); - if (f1Size < f2Size) { - return 1; - } else if (f1Size > f2Size) { - return -1; - } - return 0; - }); + // Then sort by how many members are online now + factionList.sort((f1, f2) -> { + int f1Size = f1.getFPlayersWhereOnline(true).size(); + int f2Size = f2.getFPlayersWhereOnline(true).size(); + if (f1Size < f2Size) { + return 1; + } else if (f1Size > f2Size) { + return -1; + } + return 0; + }); - ArrayList lines = new ArrayList<>(); + ArrayList lines = new ArrayList<>(); - factionList.add(0, Factions.getInstance().getWilderness()); + factionList.add(0, Factions.getInstance().getWilderness()); - final int pageheight = 9; - int pagenumber = this.argAsInt(0, 1); - int pagecount = (factionList.size() / pageheight) + 1; - if (pagenumber > pagecount) { - pagenumber = pagecount; - } else if (pagenumber < 1) { - pagenumber = 1; - } - int start = (pagenumber - 1) * pageheight; - int end = start + pageheight; - if (end > factionList.size()) { - end = factionList.size(); - } + final int pageheight = 9; + int pagenumber = this.argAsInt(0, 1); + int pagecount = (factionList.size() / pageheight) + 1; + if (pagenumber > pagecount) { + pagenumber = pagecount; + } else if (pagenumber < 1) { + pagenumber = 1; + } + int start = (pagenumber - 1) * pageheight; + int end = start + pageheight; + if (end > factionList.size()) { + end = factionList.size(); + } - String header = p.getConfig().getString("list.header", defaults[0]); - header = header.replace("{pagenumber}", String.valueOf(pagenumber)).replace("{pagecount}", String.valueOf(pagecount)); - lines.add(p.txt.parse(header)); + String header = p.getConfig().getString("list.header", defaults[0]); + header = header.replace("{pagenumber}", String.valueOf(pagenumber)).replace("{pagecount}", String.valueOf(pagecount)); + lines.add(p.txt.parse(header)); - for (Faction faction : factionList.subList(start, end)) { - if (faction.isWilderness()) { - lines.add(p.txt.parse(TagUtil.parsePlain(faction, p.getConfig().getString("list.factionless", defaults[1])))); - continue; - } - lines.add(p.txt.parse(TagUtil.parsePlain(faction, fme, p.getConfig().getString("list.entry", defaults[2])))); - } - sendMessage(lines); - } + for (Faction faction : factionList.subList(start, end)) { + if (faction.isWilderness()) { + lines.add(p.txt.parse(TagUtil.parsePlain(faction, p.getConfig().getString("list.factionless", defaults[1])))); + continue; + } + lines.add(p.txt.parse(TagUtil.parsePlain(faction, fme, p.getConfig().getString("list.entry", defaults[2])))); + } + sendMessage(lines); + } - @Override - public TL getUsageTranslation() { - return TL.COMMAND_LIST_DESCRIPTION; - } + @Override + public TL getUsageTranslation() { + return TL.COMMAND_LIST_DESCRIPTION; + } } \ No newline at end of file diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdLock.java b/src/main/java/com/massivecraft/factions/cmd/CmdLock.java index e8872473..37c1bdac 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdLock.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdLock.java @@ -5,40 +5,40 @@ import com.massivecraft.factions.zcore.util.TL; public class CmdLock extends FCommand { - // TODO: This solution needs refactoring. + // TODO: This solution needs refactoring. /* factions.lock: description: use the /f lock [on/off] command to temporarily lock the data files from being overwritten default: op */ - public CmdLock() { - super(); - this.aliases.add("lock"); + public CmdLock() { + super(); + this.aliases.add("lock"); - //this.requiredArgs.add(""); - this.optionalArgs.put("on/off", "flip"); + //this.requiredArgs.add(""); + this.optionalArgs.put("on/off", "flip"); - this.permission = Permission.LOCK.node; - this.disableOnLock = false; + this.permission = Permission.LOCK.node; + this.disableOnLock = false; - senderMustBePlayer = false; - senderMustBeMember = false; - senderMustBeModerator = false; - senderMustBeColeader = false; - senderMustBeAdmin = false; - } + senderMustBePlayer = false; + senderMustBeMember = false; + senderMustBeModerator = false; + senderMustBeColeader = false; + senderMustBeAdmin = false; + } - @Override - public void perform() { - p.setLocked(this.argAsBool(0, !p.getLocked())); - msg(p.getLocked() ? TL.COMMAND_LOCK_LOCKED : TL.COMMAND_LOCK_UNLOCKED); - } + @Override + public void perform() { + p.setLocked(this.argAsBool(0, !p.getLocked())); + msg(p.getLocked() ? TL.COMMAND_LOCK_LOCKED : TL.COMMAND_LOCK_UNLOCKED); + } - @Override - public TL getUsageTranslation() { - return TL.COMMAND_LOCK_DESCRIPTION; - } + @Override + public TL getUsageTranslation() { + return TL.COMMAND_LOCK_DESCRIPTION; + } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdLogins.java b/src/main/java/com/massivecraft/factions/cmd/CmdLogins.java index ca0917cb..b310cbd0 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdLogins.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdLogins.java @@ -5,27 +5,27 @@ import com.massivecraft.factions.zcore.util.TL; public class CmdLogins extends FCommand { - public CmdLogins() { - super(); - this.aliases.add("login"); - this.aliases.add("logins"); - this.aliases.add("logout"); - this.aliases.add("logouts"); - this.senderMustBePlayer = true; + public CmdLogins() { + super(); + this.aliases.add("login"); + this.aliases.add("logins"); + this.aliases.add("logout"); + this.aliases.add("logouts"); + this.senderMustBePlayer = true; - this.senderMustBeMember = true; - this.permission = Permission.MONITOR_LOGINS.node; - } + this.senderMustBeMember = true; + this.permission = Permission.MONITOR_LOGINS.node; + } - @Override - public void perform() { - boolean monitor = fme.isMonitoringJoins(); - fme.msg(TL.COMMAND_LOGINS_TOGGLE, String.valueOf(!monitor)); - fme.setMonitorJoins(!monitor); - } + @Override + public void perform() { + boolean monitor = fme.isMonitoringJoins(); + fme.msg(TL.COMMAND_LOGINS_TOGGLE, String.valueOf(!monitor)); + fme.setMonitorJoins(!monitor); + } - @Override - public TL getUsageTranslation() { - return TL.COMMAND_LOGINS_DESCRIPTION; - } + @Override + public TL getUsageTranslation() { + return TL.COMMAND_LOGINS_DESCRIPTION; + } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdLowPower.java b/src/main/java/com/massivecraft/factions/cmd/CmdLowPower.java index ac02a91f..9d40fbe6 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdLowPower.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdLowPower.java @@ -6,38 +6,38 @@ import com.massivecraft.factions.zcore.util.TL; public class CmdLowPower extends FCommand { - public CmdLowPower() { - super(); - this.aliases.add("lowpower"); + public CmdLowPower() { + super(); + this.aliases.add("lowpower"); - this.disableOnLock = false; + this.disableOnLock = false; - senderMustBePlayer = true; + senderMustBePlayer = true; - senderMustBeMember = true; - senderMustBeModerator = false; - senderMustBeColeader = true; - senderMustBeAdmin = false; - } + senderMustBeMember = true; + senderMustBeModerator = false; + senderMustBeColeader = true; + senderMustBeAdmin = false; + } - @Override - public void perform() { - double maxPower = Conf.powerPlayerMax; - String format = TL.COMMAND_LOWPOWER_FORMAT.toString(); - msg(TL.COMMAND_LOWPOWER_HEADER.toString().replace("{maxpower}", (int) maxPower + "")); - for (FPlayer fPlayer : fme.getFaction().getFPlayers()) { - if (fPlayer.getPower() < maxPower) { - sendMessage(format.replace("{player}", fPlayer.getName()).replace("{player_power}", (int) fPlayer.getPower() + "").replace("{maxpower}", (int) maxPower + "")); - } - } - } + @Override + public void perform() { + double maxPower = Conf.powerPlayerMax; + String format = TL.COMMAND_LOWPOWER_FORMAT.toString(); + msg(TL.COMMAND_LOWPOWER_HEADER.toString().replace("{maxpower}", (int) maxPower + "")); + for (FPlayer fPlayer : fme.getFaction().getFPlayers()) { + if (fPlayer.getPower() < maxPower) { + sendMessage(format.replace("{player}", fPlayer.getName()).replace("{player_power}", (int) fPlayer.getPower() + "").replace("{maxpower}", (int) maxPower + "")); + } + } + } - @Override - public TL getUsageTranslation() { - return TL.COMMAND_LOWPOWER_DESCRIPTION; - } + @Override + public TL getUsageTranslation() { + return TL.COMMAND_LOWPOWER_DESCRIPTION; + } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdMap.java b/src/main/java/com/massivecraft/factions/cmd/CmdMap.java index ccbaffbd..14ec1fce 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdMap.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdMap.java @@ -9,62 +9,62 @@ import com.massivecraft.factions.zcore.util.TL; public class CmdMap extends FCommand { - public CmdMap() { - super(); - this.aliases.add("map"); + public CmdMap() { + super(); + this.aliases.add("map"); - //this.requiredArgs.add(""); - this.optionalArgs.put("on/off", "once"); + //this.requiredArgs.add(""); + this.optionalArgs.put("on/off", "once"); - this.permission = Permission.MAP.node; - this.disableOnLock = false; + this.permission = Permission.MAP.node; + this.disableOnLock = false; - senderMustBePlayer = true; - senderMustBeMember = false; - senderMustBeModerator = false; - senderMustBeColeader = false; - senderMustBeAdmin = false; - } + senderMustBePlayer = true; + senderMustBeMember = false; + senderMustBeModerator = false; + senderMustBeColeader = false; + senderMustBeAdmin = false; + } - @Override - public void perform() { - if (this.argIsSet(0)) { - if (this.argAsBool(0, !fme.isMapAutoUpdating())) { - // Turn on + @Override + public void perform() { + if (this.argIsSet(0)) { + if (this.argAsBool(0, !fme.isMapAutoUpdating())) { + // Turn on - // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay - if (!payForCommand(Conf.econCostMap, "to show the map", "for showing the map")) { - return; - } + // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay + if (!payForCommand(Conf.econCostMap, "to show the map", "for showing the map")) { + return; + } - fme.setMapAutoUpdating(true); - msg(TL.COMMAND_MAP_UPDATE_ENABLED); + fme.setMapAutoUpdating(true); + msg(TL.COMMAND_MAP_UPDATE_ENABLED); - // And show the map once - showMap(); - } else { - // Turn off - fme.setMapAutoUpdating(false); - msg(TL.COMMAND_MAP_UPDATE_DISABLED); - } - } else { - // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay - if (!payForCommand(Conf.econCostMap, TL.COMMAND_MAP_TOSHOW, TL.COMMAND_MAP_FORSHOW)) { - return; - } + // And show the map once + showMap(); + } else { + // Turn off + fme.setMapAutoUpdating(false); + msg(TL.COMMAND_MAP_UPDATE_DISABLED); + } + } else { + // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay + if (!payForCommand(Conf.econCostMap, TL.COMMAND_MAP_TOSHOW, TL.COMMAND_MAP_FORSHOW)) { + return; + } - showMap(); - } - } + showMap(); + } + } - public void showMap() { - sendFancyMessage(Board.getInstance().getMap(fme, new FLocation(fme), fme.getPlayer().getLocation().getYaw())); - } + public void showMap() { + sendFancyMessage(Board.getInstance().getMap(fme, new FLocation(fme), fme.getPlayer().getLocation().getYaw())); + } - @Override - public TL getUsageTranslation() { - return TL.COMMAND_MAP_DESCRIPTION; - } + @Override + public TL getUsageTranslation() { + return TL.COMMAND_MAP_DESCRIPTION; + } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdMapHeight.java b/src/main/java/com/massivecraft/factions/cmd/CmdMapHeight.java index 5588f828..eac2f9b2 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdMapHeight.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdMapHeight.java @@ -5,36 +5,36 @@ import com.massivecraft.factions.zcore.util.TL; public class CmdMapHeight extends FCommand { - public CmdMapHeight() { - super(); + public CmdMapHeight() { + super(); - this.aliases.add("mapheight"); - this.aliases.add("mh"); + this.aliases.add("mapheight"); + this.aliases.add("mh"); - this.optionalArgs.put("height", "height"); + this.optionalArgs.put("height", "height"); - this.permission = Permission.MAPHEIGHT.node; + this.permission = Permission.MAPHEIGHT.node; - this.senderMustBePlayer = true; - } + this.senderMustBePlayer = true; + } - @Override - public void perform() { - if (args.size() == 0) { - fme.sendMessage(TL.COMMAND_MAPHEIGHT_CURRENT.format(fme.getMapHeight())); - return; - } + @Override + public void perform() { + if (args.size() == 0) { + fme.sendMessage(TL.COMMAND_MAPHEIGHT_CURRENT.format(fme.getMapHeight())); + return; + } - int height = argAsInt(0); + int height = argAsInt(0); - fme.setMapHeight(height); - fme.sendMessage(TL.COMMAND_MAPHEIGHT_SET.format(fme.getMapHeight())); - } + fme.setMapHeight(height); + fme.sendMessage(TL.COMMAND_MAPHEIGHT_SET.format(fme.getMapHeight())); + } - @Override - public TL getUsageTranslation() { - return TL.COMMAND_MAPHEIGHT_DESCRIPTION; - } + @Override + public TL getUsageTranslation() { + return TL.COMMAND_MAPHEIGHT_DESCRIPTION; + } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdMod.java b/src/main/java/com/massivecraft/factions/cmd/CmdMod.java index 99d08453..a14a81f7 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdMod.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdMod.java @@ -11,85 +11,85 @@ import org.bukkit.ChatColor; public class CmdMod extends FCommand { - public CmdMod() { - super(); - this.aliases.add("mod"); - this.aliases.add("setmod"); - this.aliases.add("officer"); - this.aliases.add("setofficer"); + public CmdMod() { + super(); + this.aliases.add("mod"); + this.aliases.add("setmod"); + this.aliases.add("officer"); + this.aliases.add("setofficer"); - this.optionalArgs.put("player name", "name"); - //this.optionalArgs.put("", ""); + this.optionalArgs.put("player name", "name"); + //this.optionalArgs.put("", ""); - this.permission = Permission.MOD.node; - this.disableOnLock = true; + this.permission = Permission.MOD.node; + this.disableOnLock = true; - senderMustBePlayer = false; - senderMustBeMember = true; - senderMustBeModerator = false; - senderMustBeColeader = true; - senderMustBeAdmin = false; - } + senderMustBePlayer = false; + senderMustBeMember = true; + senderMustBeModerator = false; + senderMustBeColeader = true; + senderMustBeAdmin = false; + } - @Override - public void perform() { - FPlayer you = this.argAsBestFPlayerMatch(0); - if (you == null) { - FancyMessage msg = new FancyMessage(TL.COMMAND_MOD_CANDIDATES.toString()).color(ChatColor.GOLD); - for (FPlayer player : myFaction.getFPlayersWhereRole(Role.NORMAL)) { - String s = player.getName(); - msg.then(s + " ").color(ChatColor.WHITE).tooltip(TL.COMMAND_MOD_CLICKTOPROMOTE.toString() + s).command("/" + Conf.baseCommandAliases.get(0) + " mod " + s); - } + @Override + public void perform() { + FPlayer you = this.argAsBestFPlayerMatch(0); + if (you == null) { + FancyMessage msg = new FancyMessage(TL.COMMAND_MOD_CANDIDATES.toString()).color(ChatColor.GOLD); + for (FPlayer player : myFaction.getFPlayersWhereRole(Role.NORMAL)) { + String s = player.getName(); + msg.then(s + " ").color(ChatColor.WHITE).tooltip(TL.COMMAND_MOD_CLICKTOPROMOTE.toString() + s).command("/" + Conf.baseCommandAliases.get(0) + " mod " + s); + } - sendFancyMessage(msg); - return; - } + sendFancyMessage(msg); + return; + } - boolean permAny = Permission.MOD_ANY.has(sender, false); - Faction targetFaction = you.getFaction(); + boolean permAny = Permission.MOD_ANY.has(sender, false); + Faction targetFaction = you.getFaction(); - if(you.isAlt()){ - msg(ChatColor.RED + "You can not promote alt accounts."); - return; - } + if (you.isAlt()) { + msg(ChatColor.RED + "You can not promote alt accounts."); + return; + } - if (targetFaction != myFaction && !permAny) { - msg(TL.COMMAND_MOD_NOTMEMBER, you.describeTo(fme, true)); - return; - } + if (targetFaction != myFaction && !permAny) { + msg(TL.COMMAND_MOD_NOTMEMBER, you.describeTo(fme, true)); + return; + } - if (fme != null && fme.getRole() != Role.LEADER && !permAny) { - msg(TL.COMMAND_MOD_NOTADMIN); - return; - } + if (fme != null && fme.getRole() != Role.LEADER && !permAny) { + msg(TL.COMMAND_MOD_NOTADMIN); + return; + } - if (you == fme && !permAny) { - msg(TL.COMMAND_MOD_SELF); - return; - } + if (you == fme && !permAny) { + msg(TL.COMMAND_MOD_SELF); + return; + } - if (you.getRole() == Role.LEADER) { - msg(TL.COMMAND_MOD_TARGETISADMIN); - return; - } + if (you.getRole() == Role.LEADER) { + msg(TL.COMMAND_MOD_TARGETISADMIN); + return; + } - if (you.getRole() == Role.MODERATOR) { - // Revoke - you.setRole(Role.NORMAL); - targetFaction.msg(TL.COMMAND_MOD_REVOKED, you.describeTo(targetFaction, true)); - msg(TL.COMMAND_MOD_REVOKES, you.describeTo(fme, true)); - } else { - // Give - you.setRole(Role.MODERATOR); - targetFaction.msg(TL.COMMAND_MOD_PROMOTED, you.describeTo(targetFaction, true)); - msg(TL.COMMAND_MOD_PROMOTES, you.describeTo(fme, true)); - } - } + if (you.getRole() == Role.MODERATOR) { + // Revoke + you.setRole(Role.NORMAL); + targetFaction.msg(TL.COMMAND_MOD_REVOKED, you.describeTo(targetFaction, true)); + msg(TL.COMMAND_MOD_REVOKES, you.describeTo(fme, true)); + } else { + // Give + you.setRole(Role.MODERATOR); + targetFaction.msg(TL.COMMAND_MOD_PROMOTED, you.describeTo(targetFaction, true)); + msg(TL.COMMAND_MOD_PROMOTES, you.describeTo(fme, true)); + } + } - @Override - public TL getUsageTranslation() { - return TL.COMMAND_MOD_DESCRIPTION; - } + @Override + public TL getUsageTranslation() { + return TL.COMMAND_MOD_DESCRIPTION; + } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdModifyPower.java b/src/main/java/com/massivecraft/factions/cmd/CmdModifyPower.java index 1720bd91..361e632f 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdModifyPower.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdModifyPower.java @@ -6,45 +6,45 @@ import com.massivecraft.factions.zcore.util.TL; public class CmdModifyPower extends FCommand { - public CmdModifyPower() { - super(); + public CmdModifyPower() { + super(); - this.aliases.add("pm"); - this.aliases.add("mp"); - this.aliases.add("modifypower"); - this.aliases.add("modpower"); + this.aliases.add("pm"); + this.aliases.add("mp"); + this.aliases.add("modifypower"); + this.aliases.add("modpower"); - this.requiredArgs.add("name"); - this.requiredArgs.add("power"); + this.requiredArgs.add("name"); + this.requiredArgs.add("power"); - this.permission = Permission.MODIFY_POWER.node; // admin only perm. + this.permission = Permission.MODIFY_POWER.node; // admin only perm. - // Let's not require anything and let console modify this as well. - this.senderMustBeAdmin = false; - this.senderMustBePlayer = false; - this.senderMustBeMember = false; - senderMustBeColeader = false; - this.senderMustBeModerator = false; - } + // Let's not require anything and let console modify this as well. + this.senderMustBeAdmin = false; + this.senderMustBePlayer = false; + this.senderMustBeMember = false; + senderMustBeColeader = false; + this.senderMustBeModerator = false; + } - @Override - public void perform() { - // /f modify # - FPlayer player = argAsBestFPlayerMatch(0); - Double number = argAsDouble(1); // returns null if not a Double. + @Override + public void perform() { + // /f modify # + FPlayer player = argAsBestFPlayerMatch(0); + Double number = argAsDouble(1); // returns null if not a Double. - if (player == null || number == null) { - sender.sendMessage(getHelpShort()); - return; - } + if (player == null || number == null) { + sender.sendMessage(getHelpShort()); + return; + } - player.alterPower(number); - int newPower = player.getPowerRounded(); // int so we don't have super long doubles. - msg(TL.COMMAND_MODIFYPOWER_ADDED, number, player.getName(), newPower); - } + player.alterPower(number); + int newPower = player.getPowerRounded(); // int so we don't have super long doubles. + msg(TL.COMMAND_MODIFYPOWER_ADDED, number, player.getName(), newPower); + } - @Override - public TL getUsageTranslation() { - return TL.COMMAND_MODIFYPOWER_DESCRIPTION; - } + @Override + public TL getUsageTranslation() { + return TL.COMMAND_MODIFYPOWER_DESCRIPTION; + } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdNear.java b/src/main/java/com/massivecraft/factions/cmd/CmdNear.java index 2fd4fe38..2feeab45 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdNear.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdNear.java @@ -8,47 +8,47 @@ import org.bukkit.entity.Entity; import org.bukkit.entity.Player; public class CmdNear extends FCommand { - public CmdNear() { - super(); + public CmdNear() { + super(); - this.aliases.add("near"); - this.aliases.add("nearby"); + this.aliases.add("near"); + this.aliases.add("nearby"); - this.disableOnLock = true; + this.disableOnLock = true; - senderMustBePlayer = true; - senderMustBeMember = true; - senderMustBeModerator = false; - senderMustBeColeader = false; - senderMustBeAdmin = false; - } + senderMustBePlayer = true; + senderMustBeMember = true; + senderMustBeModerator = false; + senderMustBeColeader = false; + senderMustBeAdmin = false; + } - @Override - public void perform() { - if (!P.p.getConfig().getBoolean("fnear.Enabled")) { - fme.msg(TL.COMMAND_NEAR_DISABLED_MSG); - return; - } + @Override + public void perform() { + if (!P.p.getConfig().getBoolean("fnear.Enabled")) { + fme.msg(TL.COMMAND_NEAR_DISABLED_MSG); + return; + } - double range = P.p.getConfig().getInt("fnear.Radius"); - String format = TL.COMMAND_NEAR_FORMAT.toString(); - fme.msg(TL.COMMAND_NEAR_USE_MSG); - for (Entity e : me.getNearbyEntities(range, 255, range)) { - if (e instanceof Player) { - Player player = (((Player) e).getPlayer()); - FPlayer fplayer = FPlayers.getInstance().getByPlayer(player); - if (fme.getFaction() == fplayer.getFaction()) { - double distance = me.getLocation().distance(player.getLocation()); - fme.sendMessage(format.replace("{playername}", player.getDisplayName()).replace("{distance}", (int) distance + "")); - } - } + double range = P.p.getConfig().getInt("fnear.Radius"); + String format = TL.COMMAND_NEAR_FORMAT.toString(); + fme.msg(TL.COMMAND_NEAR_USE_MSG); + for (Entity e : me.getNearbyEntities(range, 255, range)) { + if (e instanceof Player) { + Player player = (((Player) e).getPlayer()); + FPlayer fplayer = FPlayers.getInstance().getByPlayer(player); + if (fme.getFaction() == fplayer.getFaction()) { + double distance = me.getLocation().distance(player.getLocation()); + fme.sendMessage(format.replace("{playername}", player.getDisplayName()).replace("{distance}", (int) distance + "")); + } + } - } - } + } + } - @Override - public TL getUsageTranslation() { - return TL.COMMAND_NEAR_DESCRIPTION; - } + @Override + public TL getUsageTranslation() { + return TL.COMMAND_NEAR_DESCRIPTION; + } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdOpen.java b/src/main/java/com/massivecraft/factions/cmd/CmdOpen.java index c5ba53d9..b7587b9e 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdOpen.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdOpen.java @@ -9,55 +9,55 @@ import com.massivecraft.factions.zcore.util.TL; public class CmdOpen extends FCommand { - public CmdOpen() { - super(); - this.aliases.add("open"); + public CmdOpen() { + super(); + this.aliases.add("open"); - //this.requiredArgs.add(""); - this.optionalArgs.put("yes/no", "flip"); + //this.requiredArgs.add(""); + this.optionalArgs.put("yes/no", "flip"); - this.permission = Permission.OPEN.node; - this.disableOnLock = false; - this.disableOnSpam = true; + this.permission = Permission.OPEN.node; + this.disableOnLock = false; + this.disableOnSpam = true; - senderMustBePlayer = true; - senderMustBeMember = false; - senderMustBeModerator = false; - senderMustBeColeader = true; - senderMustBeAdmin = false; - } + senderMustBePlayer = true; + senderMustBeMember = false; + senderMustBeModerator = false; + senderMustBeColeader = true; + senderMustBeAdmin = false; + } - @Override - public void perform() { - // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay - if (!payForCommand(Conf.econCostOpen, TL.COMMAND_OPEN_TOOPEN, TL.COMMAND_OPEN_FOROPEN)) { - return; - } + @Override + public void perform() { + // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay + if (!payForCommand(Conf.econCostOpen, TL.COMMAND_OPEN_TOOPEN, TL.COMMAND_OPEN_FOROPEN)) { + return; + } - if (!fme.isCooldownEnded("open")) { - fme.msg(TL.COMMAND_ONCOOOLDOWN, fme.getCooldown("open")); - return; - } + if (!fme.isCooldownEnded("open")) { + fme.msg(TL.COMMAND_ONCOOOLDOWN, fme.getCooldown("open")); + return; + } - myFaction.setOpen(this.argAsBool(0, !myFaction.getOpen())); + myFaction.setOpen(this.argAsBool(0, !myFaction.getOpen())); - String open = myFaction.getOpen() ? TL.COMMAND_OPEN_OPEN.toString() : TL.COMMAND_OPEN_CLOSED.toString(); + String open = myFaction.getOpen() ? TL.COMMAND_OPEN_OPEN.toString() : TL.COMMAND_OPEN_CLOSED.toString(); - // Inform - for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers()) { - if (fplayer.getFactionId().equals(myFaction.getId())) { - fplayer.msg(TL.COMMAND_OPEN_CHANGES, fme.getName(), open); - continue; - } - fplayer.msg(TL.COMMAND_OPEN_CHANGED, myFaction.getTag(fplayer.getFaction()), open); - } - fme.setCooldown("open", System.currentTimeMillis() + (P.p.getConfig().getInt("fcooldowns.f-open") * 1000)); - } + // Inform + for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers()) { + if (fplayer.getFactionId().equals(myFaction.getId())) { + fplayer.msg(TL.COMMAND_OPEN_CHANGES, fme.getName(), open); + continue; + } + fplayer.msg(TL.COMMAND_OPEN_CHANGED, myFaction.getTag(fplayer.getFaction()), open); + } + fme.setCooldown("open", System.currentTimeMillis() + (P.p.getConfig().getInt("fcooldowns.f-open") * 1000)); + } - @Override - public TL getUsageTranslation() { - return TL.COMMAND_OPEN_DESCRIPTION; - } + @Override + public TL getUsageTranslation() { + return TL.COMMAND_OPEN_DESCRIPTION; + } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdOwner.java b/src/main/java/com/massivecraft/factions/cmd/CmdOwner.java index beb69334..9811f02c 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdOwner.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdOwner.java @@ -8,100 +8,100 @@ import com.massivecraft.factions.zcore.util.TL; public class CmdOwner extends FCommand { - public CmdOwner() { - super(); - this.aliases.add("owner"); + public CmdOwner() { + super(); + this.aliases.add("owner"); - //this.requiredArgs.add(""); - this.optionalArgs.put("player name", "you"); + //this.requiredArgs.add(""); + this.optionalArgs.put("player name", "you"); - this.permission = Permission.OWNER.node; - this.disableOnLock = true; + this.permission = Permission.OWNER.node; + this.disableOnLock = true; - senderMustBePlayer = true; - senderMustBeMember = false; - senderMustBeModerator = false; - senderMustBeColeader = false; - senderMustBeAdmin = false; - } + senderMustBePlayer = true; + senderMustBeMember = false; + senderMustBeModerator = false; + senderMustBeColeader = false; + senderMustBeAdmin = false; + } - // TODO: Fix colors! + // TODO: Fix colors! - @Override - public void perform() { - boolean hasBypass = fme.isAdminBypassing(); + @Override + public void perform() { + boolean hasBypass = fme.isAdminBypassing(); - if (!hasBypass && !assertHasFaction()) { - return; - } + if (!hasBypass && !assertHasFaction()) { + return; + } - if (!Conf.ownedAreasEnabled) { - fme.msg(TL.COMMAND_OWNER_DISABLED); - return; - } + if (!Conf.ownedAreasEnabled) { + fme.msg(TL.COMMAND_OWNER_DISABLED); + return; + } - if (!hasBypass && Conf.ownedAreasLimitPerFaction > 0 && myFaction.getCountOfClaimsWithOwners() >= Conf.ownedAreasLimitPerFaction) { - fme.msg(TL.COMMAND_OWNER_LIMIT, Conf.ownedAreasLimitPerFaction); - return; - } + if (!hasBypass && Conf.ownedAreasLimitPerFaction > 0 && myFaction.getCountOfClaimsWithOwners() >= Conf.ownedAreasLimitPerFaction) { + fme.msg(TL.COMMAND_OWNER_LIMIT, Conf.ownedAreasLimitPerFaction); + return; + } - if (!hasBypass && !assertMinRole(Conf.ownedAreasModeratorsCanSet ? Role.MODERATOR : Role.LEADER)) { - return; - } + if (!hasBypass && !assertMinRole(Conf.ownedAreasModeratorsCanSet ? Role.MODERATOR : Role.LEADER)) { + return; + } - FLocation flocation = new FLocation(fme); + FLocation flocation = new FLocation(fme); - Faction factionHere = Board.getInstance().getFactionAt(flocation); - if (factionHere != myFaction) { - if (!factionHere.isNormal()) { - fme.msg(TL.COMMAND_OWNER_NOTCLAIMED); - return; - } + Faction factionHere = Board.getInstance().getFactionAt(flocation); + if (factionHere != myFaction) { + if (!factionHere.isNormal()) { + fme.msg(TL.COMMAND_OWNER_NOTCLAIMED); + return; + } - if (!hasBypass) { - fme.msg(TL.COMMAND_OWNER_WRONGFACTION); - return; - } - } + if (!hasBypass) { + fme.msg(TL.COMMAND_OWNER_WRONGFACTION); + return; + } + } - FPlayer target = this.argAsBestFPlayerMatch(0, fme); - if (target == null) { - return; - } + FPlayer target = this.argAsBestFPlayerMatch(0, fme); + if (target == null) { + return; + } - String playerName = target.getName(); + String playerName = target.getName(); - if (target.getFaction() != myFaction) { - fme.msg(TL.COMMAND_OWNER_NOTMEMBER, playerName); - return; - } + if (target.getFaction() != myFaction) { + fme.msg(TL.COMMAND_OWNER_NOTMEMBER, playerName); + return; + } - // if no player name was passed, and this claim does already have owners set, clear them - if (args.isEmpty() && myFaction.doesLocationHaveOwnersSet(flocation)) { - myFaction.clearClaimOwnership(flocation); - fme.msg(TL.COMMAND_OWNER_CLEARED); - return; - } + // if no player name was passed, and this claim does already have owners set, clear them + if (args.isEmpty() && myFaction.doesLocationHaveOwnersSet(flocation)) { + myFaction.clearClaimOwnership(flocation); + fme.msg(TL.COMMAND_OWNER_CLEARED); + return; + } - if (myFaction.isPlayerInOwnerList(target, flocation)) { - myFaction.removePlayerAsOwner(target, flocation); - fme.msg(TL.COMMAND_OWNER_REMOVED, playerName); - return; - } + if (myFaction.isPlayerInOwnerList(target, flocation)) { + myFaction.removePlayerAsOwner(target, flocation); + fme.msg(TL.COMMAND_OWNER_REMOVED, playerName); + return; + } - // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay - if (!payForCommand(Conf.econCostOwner, TL.COMMAND_OWNER_TOSET, TL.COMMAND_OWNER_FORSET)) { - return; - } + // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay + if (!payForCommand(Conf.econCostOwner, TL.COMMAND_OWNER_TOSET, TL.COMMAND_OWNER_FORSET)) { + return; + } - myFaction.setPlayerAsOwner(target, flocation); + myFaction.setPlayerAsOwner(target, flocation); - fme.msg(TL.COMMAND_OWNER_ADDED, playerName); - } + fme.msg(TL.COMMAND_OWNER_ADDED, playerName); + } - @Override - public TL getUsageTranslation() { - return TL.COMMAND_OWNER_DESCRIPTION; - } + @Override + public TL getUsageTranslation() { + return TL.COMMAND_OWNER_DESCRIPTION; + } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdOwnerList.java b/src/main/java/com/massivecraft/factions/cmd/CmdOwnerList.java index 4d0f77d1..ee49571e 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdOwnerList.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdOwnerList.java @@ -9,64 +9,64 @@ import com.massivecraft.factions.zcore.util.TL; public class CmdOwnerList extends FCommand { - public CmdOwnerList() { - super(); - this.aliases.add("ownerlist"); + public CmdOwnerList() { + super(); + this.aliases.add("ownerlist"); - //this.requiredArgs.add(""); - //this.optionalArgs.put("", ""); + //this.requiredArgs.add(""); + //this.optionalArgs.put("", ""); - this.permission = Permission.OWNERLIST.node; - this.disableOnLock = false; + this.permission = Permission.OWNERLIST.node; + this.disableOnLock = false; - senderMustBePlayer = true; - senderMustBeMember = false; - senderMustBeModerator = false; - senderMustBeColeader = false; - senderMustBeAdmin = false; - } + senderMustBePlayer = true; + senderMustBeMember = false; + senderMustBeModerator = false; + senderMustBeColeader = false; + senderMustBeAdmin = false; + } - @Override - public void perform() { - boolean hasBypass = fme.isAdminBypassing(); + @Override + public void perform() { + boolean hasBypass = fme.isAdminBypassing(); - if (!hasBypass && !assertHasFaction()) { - return; - } + if (!hasBypass && !assertHasFaction()) { + return; + } - if (!Conf.ownedAreasEnabled) { - fme.msg(TL.COMMAND_OWNERLIST_DISABLED); - return; - } + if (!Conf.ownedAreasEnabled) { + fme.msg(TL.COMMAND_OWNERLIST_DISABLED); + return; + } - FLocation flocation = new FLocation(fme); + FLocation flocation = new FLocation(fme); - if (Board.getInstance().getFactionAt(flocation) != myFaction) { - if (!hasBypass) { - fme.msg(TL.COMMAND_OWNERLIST_WRONGFACTION); - return; - } - //TODO: This code won't ever be called. - myFaction = Board.getInstance().getFactionAt(flocation); - if (!myFaction.isNormal()) { - fme.msg(TL.COMMAND_OWNERLIST_NOTCLAIMED); - return; - } - } + if (Board.getInstance().getFactionAt(flocation) != myFaction) { + if (!hasBypass) { + fme.msg(TL.COMMAND_OWNERLIST_WRONGFACTION); + return; + } + //TODO: This code won't ever be called. + myFaction = Board.getInstance().getFactionAt(flocation); + if (!myFaction.isNormal()) { + fme.msg(TL.COMMAND_OWNERLIST_NOTCLAIMED); + return; + } + } - String owners = myFaction.getOwnerListString(flocation); + String owners = myFaction.getOwnerListString(flocation); - if (owners == null || owners.isEmpty()) { - fme.msg(TL.COMMAND_OWNERLIST_NONE); - return; - } + if (owners == null || owners.isEmpty()) { + fme.msg(TL.COMMAND_OWNERLIST_NONE); + return; + } - fme.msg(TL.COMMAND_OWNERLIST_OWNERS, owners); - } + fme.msg(TL.COMMAND_OWNERLIST_OWNERS, owners); + } - @Override - public TL getUsageTranslation() { - return TL.COMMAND_OWNERLIST_DESCRIPTION; - } + @Override + public TL getUsageTranslation() { + return TL.COMMAND_OWNERLIST_DESCRIPTION; + } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdPaypalSee.java b/src/main/java/com/massivecraft/factions/cmd/CmdPaypalSee.java index 3cc4885d..672d2088 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdPaypalSee.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdPaypalSee.java @@ -6,58 +6,59 @@ import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.zcore.util.TL; public class CmdPaypalSee extends FCommand { - public CmdPaypalSee() { - aliases.add("seepaypal"); - aliases.add("paypal"); + public CmdPaypalSee() { + aliases.add("seepaypal"); + aliases.add("paypal"); - optionalArgs.put("faction", "yours"); + optionalArgs.put("faction", "yours"); - permission = Permission.PAYPAL.node; + permission = Permission.PAYPAL.node; - disableOnLock = false; + disableOnLock = false; - senderMustBePlayer = true; - senderMustBeMember = true; - senderMustBeModerator = false; - senderMustBeColeader = false; - senderMustBeAdmin = true; + senderMustBePlayer = true; + senderMustBeMember = true; + senderMustBeModerator = false; + senderMustBeColeader = false; + senderMustBeAdmin = true; - } - @Override - public void perform() { - if (!P.p.getConfig().getBoolean("fpaypal.Enabled")) { - fme.msg(TL.GENERIC_DISABLED); - return; - } + } - if (args.size() == 0) { - if (myFaction.getPaypal().isEmpty()) { - msg(TL.COMMAND_PAYPAL_NOTSET); - } else { - msg(TL.PAYPALSEE_PLAYER_PAYPAL, myFaction.getPaypal()); - } - } else if (args.size() == 1) { - if (fme.isAdminBypassing()) { - Faction faction = argAsFaction(0); - if (faction != null) { - if (faction.getPaypal().isEmpty()) { - msg(TL.COMMAND_PAYPALSEE_FACTION_NOTSET, faction.getTag()); - } else { - msg(TL.COMMAND_PAYPALSEE_FACTION_PAYPAL.toString(), faction.getTag(), faction.getPaypal()); - } - } - } else { - msg(TL.GENERIC_NOPERMISSION, "see another factions paypal."); - } - } else { - msg(P.p.cmdBase.cmdPaypalSee.getUseageTemplate()); - } - } + @Override + public void perform() { + if (!P.p.getConfig().getBoolean("fpaypal.Enabled")) { + fme.msg(TL.GENERIC_DISABLED); + return; + } - @Override - public TL getUsageTranslation() { - return TL.COMMAND_PAYPALSEE_DESCRIPTION; - } + if (args.size() == 0) { + if (myFaction.getPaypal().isEmpty()) { + msg(TL.COMMAND_PAYPAL_NOTSET); + } else { + msg(TL.PAYPALSEE_PLAYER_PAYPAL, myFaction.getPaypal()); + } + } else if (args.size() == 1) { + if (fme.isAdminBypassing()) { + Faction faction = argAsFaction(0); + if (faction != null) { + if (faction.getPaypal().isEmpty()) { + msg(TL.COMMAND_PAYPALSEE_FACTION_NOTSET, faction.getTag()); + } else { + msg(TL.COMMAND_PAYPALSEE_FACTION_PAYPAL.toString(), faction.getTag(), faction.getPaypal()); + } + } + } else { + msg(TL.GENERIC_NOPERMISSION, "see another factions paypal."); + } + } else { + msg(P.p.cmdBase.cmdPaypalSee.getUseageTemplate()); + } + } + + @Override + public TL getUsageTranslation() { + return TL.COMMAND_PAYPALSEE_DESCRIPTION; + } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdPeaceful.java b/src/main/java/com/massivecraft/factions/cmd/CmdPeaceful.java index 58151f98..02f6bb29 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdPeaceful.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdPeaceful.java @@ -8,55 +8,55 @@ import com.massivecraft.factions.zcore.util.TL; public class CmdPeaceful extends FCommand { - public CmdPeaceful() { - super(); - this.aliases.add("peaceful"); + public CmdPeaceful() { + super(); + this.aliases.add("peaceful"); - this.requiredArgs.add("faction tag"); - //this.optionalArgs.put("", ""); + this.requiredArgs.add("faction tag"); + //this.optionalArgs.put("", ""); - this.permission = Permission.SET_PEACEFUL.node; - this.disableOnLock = true; + this.permission = Permission.SET_PEACEFUL.node; + this.disableOnLock = true; - senderMustBePlayer = false; - senderMustBeMember = false; - senderMustBeModerator = false; - senderMustBeColeader = false; - senderMustBeAdmin = false; + senderMustBePlayer = false; + senderMustBeMember = false; + senderMustBeModerator = false; + senderMustBeColeader = false; + senderMustBeAdmin = false; - } + } - @Override - public void perform() { - Faction faction = this.argAsFaction(0); - if (faction == null) { - return; - } + @Override + public void perform() { + Faction faction = this.argAsFaction(0); + if (faction == null) { + return; + } - String change; - if (faction.isPeaceful()) { - change = TL.COMMAND_PEACEFUL_REVOKE.toString(); - faction.setPeaceful(false); - } else { - change = TL.COMMAND_PEACEFUL_GRANT.toString(); - faction.setPeaceful(true); - } + String change; + if (faction.isPeaceful()) { + change = TL.COMMAND_PEACEFUL_REVOKE.toString(); + faction.setPeaceful(false); + } else { + change = TL.COMMAND_PEACEFUL_GRANT.toString(); + faction.setPeaceful(true); + } - // Inform all players - for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers()) { - String blame = (fme == null ? TL.GENERIC_SERVERADMIN.toString() : fme.describeTo(fplayer, true)); - if (fplayer.getFaction() == faction) { - fplayer.msg(TL.COMMAND_PEACEFUL_YOURS, blame, change); - } else { - fplayer.msg(TL.COMMAND_PEACEFUL_OTHER, blame, change, faction.getTag(fplayer)); - } - } + // Inform all players + for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers()) { + String blame = (fme == null ? TL.GENERIC_SERVERADMIN.toString() : fme.describeTo(fplayer, true)); + if (fplayer.getFaction() == faction) { + fplayer.msg(TL.COMMAND_PEACEFUL_YOURS, blame, change); + } else { + fplayer.msg(TL.COMMAND_PEACEFUL_OTHER, blame, change, faction.getTag(fplayer)); + } + } - } + } - @Override - public TL getUsageTranslation() { - return TL.COMMAND_PEACEFUL_DESCRIPTION; - } + @Override + public TL getUsageTranslation() { + return TL.COMMAND_PEACEFUL_DESCRIPTION; + } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdPerm.java b/src/main/java/com/massivecraft/factions/cmd/CmdPerm.java index 12b7d516..8ec4856b 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdPerm.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdPerm.java @@ -16,104 +16,104 @@ import java.util.Set; public class CmdPerm extends FCommand { - public CmdPerm() { - super(); - this.aliases.add("perm"); - this.aliases.add("perms"); - this.aliases.add("permission"); - this.aliases.add("permissions"); + public CmdPerm() { + super(); + this.aliases.add("perm"); + this.aliases.add("perms"); + this.aliases.add("permission"); + this.aliases.add("permissions"); - this.optionalArgs.put("relation", "relation"); - this.optionalArgs.put("action", "action"); - this.optionalArgs.put("access", "access"); + this.optionalArgs.put("relation", "relation"); + this.optionalArgs.put("action", "action"); + this.optionalArgs.put("access", "access"); - this.disableOnLock = true; + this.disableOnLock = true; - senderMustBePlayer = true; - senderMustBeMember = true; - senderMustBeModerator = false; - senderMustBeColeader = false; - senderMustBeAdmin = true; + senderMustBePlayer = true; + senderMustBeMember = true; + senderMustBeModerator = false; + senderMustBeColeader = false; + senderMustBeAdmin = true; - } + } - @Override - public void perform() { - if (args.size() == 0) { - new PermissableRelationFrame(fme.getFaction()).buildGUI(fme); - return; - } else if (args.size() == 1 && getPermissable(argAsString(0)) != null) { - new PermissableActionFrame(fme.getFaction()).buildGUI(fme, getPermissable(argAsString(0))); - return; - } + @Override + public void perform() { + if (args.size() == 0) { + new PermissableRelationFrame(fme.getFaction()).buildGUI(fme); + return; + } else if (args.size() == 1 && getPermissable(argAsString(0)) != null) { + new PermissableActionFrame(fme.getFaction()).buildGUI(fme, getPermissable(argAsString(0))); + return; + } - // If not opening GUI, then setting the permission manually. - if (args.size() != 3) { - fme.msg(TL.COMMAND_PERM_DESCRIPTION); - return; - } + // If not opening GUI, then setting the permission manually. + if (args.size() != 3) { + fme.msg(TL.COMMAND_PERM_DESCRIPTION); + return; + } - Set permissables = new HashSet<>(); - Set permissableActions = new HashSet<>(); + Set permissables = new HashSet<>(); + Set permissableActions = new HashSet<>(); - boolean allRelations = argAsString(0).equalsIgnoreCase("all"); - boolean allActions = argAsString(1).equalsIgnoreCase("all"); + boolean allRelations = argAsString(0).equalsIgnoreCase("all"); + boolean allActions = argAsString(1).equalsIgnoreCase("all"); - if (allRelations) { - permissables.addAll(myFaction.getPermissions().keySet()); - } else { - Permissable permissable = getPermissable(argAsString(0)); + if (allRelations) { + permissables.addAll(myFaction.getPermissions().keySet()); + } else { + Permissable permissable = getPermissable(argAsString(0)); - if (permissable == null) { - fme.msg(TL.COMMAND_PERM_INVALID_RELATION); - return; - } + if (permissable == null) { + fme.msg(TL.COMMAND_PERM_INVALID_RELATION); + return; + } - permissables.add(permissable); - } + permissables.add(permissable); + } - if (allActions) { - permissableActions.addAll(Arrays.asList(PermissableAction.values())); - } else { - PermissableAction permissableAction = PermissableAction.fromString(argAsString(1)); - if (permissableAction == null) { - fme.msg(TL.COMMAND_PERM_INVALID_ACTION); - return; - } + if (allActions) { + permissableActions.addAll(Arrays.asList(PermissableAction.values())); + } else { + PermissableAction permissableAction = PermissableAction.fromString(argAsString(1)); + if (permissableAction == null) { + fme.msg(TL.COMMAND_PERM_INVALID_ACTION); + return; + } - permissableActions.add(permissableAction); - } + permissableActions.add(permissableAction); + } - Access access = Access.fromString(argAsString(2)); + Access access = Access.fromString(argAsString(2)); - if (access == null) { - fme.msg(TL.COMMAND_PERM_INVALID_ACCESS); - return; - } + if (access == null) { + fme.msg(TL.COMMAND_PERM_INVALID_ACCESS); + return; + } - for (Permissable permissable : permissables) { - for (PermissableAction permissableAction : permissableActions) { - fme.getFaction().setPermission(permissable, permissableAction, access); - } - } - fme.msg(TL.COMMAND_PERM_SET, argAsString(1), access.name(), argAsString(0)); - P.p.log(String.format(TL.COMMAND_PERM_SET.toString(), argAsString(1), access.name(), argAsString(0)) + " for faction " + fme.getTag()); - } + for (Permissable permissable : permissables) { + for (PermissableAction permissableAction : permissableActions) { + fme.getFaction().setPermission(permissable, permissableAction, access); + } + } + fme.msg(TL.COMMAND_PERM_SET, argAsString(1), access.name(), argAsString(0)); + P.p.log(String.format(TL.COMMAND_PERM_SET.toString(), argAsString(1), access.name(), argAsString(0)) + " for faction " + fme.getTag()); + } - private Permissable getPermissable(String name) { - if (Role.fromString(name.toUpperCase()) != null) { - return Role.fromString(name.toUpperCase()); - } else if (Relation.fromString(name.toUpperCase()) != null) { - return Relation.fromString(name.toUpperCase()); - } else { - return null; - } - } + private Permissable getPermissable(String name) { + if (Role.fromString(name.toUpperCase()) != null) { + return Role.fromString(name.toUpperCase()); + } else if (Relation.fromString(name.toUpperCase()) != null) { + return Relation.fromString(name.toUpperCase()); + } else { + return null; + } + } - @Override - public TL getUsageTranslation() { - return TL.COMMAND_PERM_DESCRIPTION; - } + @Override + public TL getUsageTranslation() { + return TL.COMMAND_PERM_DESCRIPTION; + } } \ No newline at end of file diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdPermanent.java b/src/main/java/com/massivecraft/factions/cmd/CmdPermanent.java index 5d80e4b4..b6cd5d22 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdPermanent.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdPermanent.java @@ -10,54 +10,54 @@ import com.massivecraft.factions.zcore.util.TL; public class CmdPermanent extends FCommand { - public CmdPermanent() { - super(); - this.aliases.add("permanent"); + public CmdPermanent() { + super(); + this.aliases.add("permanent"); - this.requiredArgs.add("faction tag"); - //this.optionalArgs.put("", ""); + this.requiredArgs.add("faction tag"); + //this.optionalArgs.put("", ""); - this.permission = Permission.SET_PERMANENT.node; - this.disableOnLock = true; + this.permission = Permission.SET_PERMANENT.node; + this.disableOnLock = true; - senderMustBePlayer = false; - senderMustBeMember = false; - senderMustBeModerator = false; - senderMustBeColeader = false; - senderMustBeAdmin = false; - } + senderMustBePlayer = false; + senderMustBeMember = false; + senderMustBeModerator = false; + senderMustBeColeader = false; + senderMustBeAdmin = false; + } - @Override - public void perform() { - Faction faction = this.argAsFaction(0); - if (faction == null) { - return; - } + @Override + public void perform() { + Faction faction = this.argAsFaction(0); + if (faction == null) { + return; + } - String change; - if (faction.isPermanent()) { - change = TL.COMMAND_PERMANENT_REVOKE.toString(); - faction.setPermanent(false); - } else { - change = TL.COMMAND_PERMANENT_GRANT.toString(); - faction.setPermanent(true); - } + String change; + if (faction.isPermanent()) { + change = TL.COMMAND_PERMANENT_REVOKE.toString(); + faction.setPermanent(false); + } else { + change = TL.COMMAND_PERMANENT_GRANT.toString(); + faction.setPermanent(true); + } - P.p.log((fme == null ? "A server admin" : fme.getName()) + " " + change + " the faction \"" + faction.getTag() + "\"."); + P.p.log((fme == null ? "A server admin" : fme.getName()) + " " + change + " the faction \"" + faction.getTag() + "\"."); - // Inform all players - for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers()) { - String blame = (fme == null ? TL.GENERIC_SERVERADMIN.toString() : fme.describeTo(fplayer, true)); - if (fplayer.getFaction() == faction) { - fplayer.msg(TL.COMMAND_PERMANENT_YOURS, blame, change); - } else { - fplayer.msg(TL.COMMAND_PERMANENT_OTHER, blame, change, faction.getTag(fplayer)); - } - } - } + // Inform all players + for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers()) { + String blame = (fme == null ? TL.GENERIC_SERVERADMIN.toString() : fme.describeTo(fplayer, true)); + if (fplayer.getFaction() == faction) { + fplayer.msg(TL.COMMAND_PERMANENT_YOURS, blame, change); + } else { + fplayer.msg(TL.COMMAND_PERMANENT_OTHER, blame, change, faction.getTag(fplayer)); + } + } + } - @Override - public TL getUsageTranslation() { - return TL.COMMAND_PERMANENT_DESCRIPTION; - } + @Override + public TL getUsageTranslation() { + return TL.COMMAND_PERMANENT_DESCRIPTION; + } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdPermanentPower.java b/src/main/java/com/massivecraft/factions/cmd/CmdPermanentPower.java index 5e985ea1..fdcd607c 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdPermanentPower.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdPermanentPower.java @@ -6,54 +6,54 @@ import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.zcore.util.TL; public class CmdPermanentPower extends FCommand { - public CmdPermanentPower() { - super(); - this.aliases.add("permanentpower"); + public CmdPermanentPower() { + super(); + this.aliases.add("permanentpower"); - this.requiredArgs.add("faction"); - this.requiredArgs.add("power"); + this.requiredArgs.add("faction"); + this.requiredArgs.add("power"); - this.permission = Permission.SET_PERMANENTPOWER.node; - this.disableOnLock = true; + this.permission = Permission.SET_PERMANENTPOWER.node; + this.disableOnLock = true; - senderMustBePlayer = false; - senderMustBeMember = false; - senderMustBeModerator = false; - senderMustBeColeader = false; - senderMustBeAdmin = false; - } + senderMustBePlayer = false; + senderMustBeMember = false; + senderMustBeModerator = false; + senderMustBeColeader = false; + senderMustBeAdmin = false; + } - @Override - public void perform() { - Faction targetFaction = this.argAsFaction(0); - if (targetFaction == null) { - return; - } + @Override + public void perform() { + Faction targetFaction = this.argAsFaction(0); + if (targetFaction == null) { + return; + } - Integer targetPower = this.argAsInt(1); + Integer targetPower = this.argAsInt(1); - targetFaction.setPermanentPower(targetPower); + targetFaction.setPermanentPower(targetPower); - String change = TL.COMMAND_PERMANENTPOWER_REVOKE.toString(); - if (targetFaction.hasPermanentPower()) { - change = TL.COMMAND_PERMANENTPOWER_GRANT.toString(); - } + String change = TL.COMMAND_PERMANENTPOWER_REVOKE.toString(); + if (targetFaction.hasPermanentPower()) { + change = TL.COMMAND_PERMANENTPOWER_GRANT.toString(); + } - // Inform sender - msg(TL.COMMAND_PERMANENTPOWER_SUCCESS, change, targetFaction.describeTo(fme)); + // Inform sender + msg(TL.COMMAND_PERMANENTPOWER_SUCCESS, change, targetFaction.describeTo(fme)); - // Inform all other players - for (FPlayer fplayer : targetFaction.getFPlayersWhereOnline(true)) { - if (fplayer == fme) { - continue; - } - String blame = (fme == null ? TL.GENERIC_SERVERADMIN.toString() : fme.describeTo(fplayer, true)); - fplayer.msg(TL.COMMAND_PERMANENTPOWER_FACTION, blame, change); - } - } + // Inform all other players + for (FPlayer fplayer : targetFaction.getFPlayersWhereOnline(true)) { + if (fplayer == fme) { + continue; + } + String blame = (fme == null ? TL.GENERIC_SERVERADMIN.toString() : fme.describeTo(fplayer, true)); + fplayer.msg(TL.COMMAND_PERMANENTPOWER_FACTION, blame, change); + } + } - @Override - public TL getUsageTranslation() { - return TL.COMMAND_PERMANENTPOWER_DESCRIPTION; - } + @Override + public TL getUsageTranslation() { + return TL.COMMAND_PERMANENTPOWER_DESCRIPTION; + } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdPower.java b/src/main/java/com/massivecraft/factions/cmd/CmdPower.java index 755ddbe0..985d8770 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdPower.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdPower.java @@ -7,50 +7,50 @@ import com.massivecraft.factions.zcore.util.TL; public class CmdPower extends FCommand { - public CmdPower() { - super(); - this.aliases.add("power"); - this.aliases.add("pow"); + public CmdPower() { + super(); + this.aliases.add("power"); + this.aliases.add("pow"); - //this.requiredArgs.add("faction tag"); - this.optionalArgs.put("player name", "you"); + //this.requiredArgs.add("faction tag"); + this.optionalArgs.put("player name", "you"); - this.permission = Permission.POWER.node; - this.disableOnLock = false; + this.permission = Permission.POWER.node; + this.disableOnLock = false; - senderMustBePlayer = false; - senderMustBeMember = false; - senderMustBeModerator = false; - senderMustBeColeader = false; - senderMustBeAdmin = false; + senderMustBePlayer = false; + senderMustBeMember = false; + senderMustBeModerator = false; + senderMustBeColeader = false; + senderMustBeAdmin = false; - } + } - @Override - public void perform() { - FPlayer target = this.argAsBestFPlayerMatch(0, fme); - if (target == null) { - return; - } + @Override + public void perform() { + FPlayer target = this.argAsBestFPlayerMatch(0, fme); + if (target == null) { + return; + } - if (target != fme && !Permission.POWER_ANY.has(sender, true)) { - return; - } + if (target != fme && !Permission.POWER_ANY.has(sender, true)) { + return; + } - // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay - if (!payForCommand(Conf.econCostPower, TL.COMMAND_POWER_TOSHOW, TL.COMMAND_POWER_FORSHOW)) { - return; - } + // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay + if (!payForCommand(Conf.econCostPower, TL.COMMAND_POWER_TOSHOW, TL.COMMAND_POWER_FORSHOW)) { + return; + } - double powerBoost = target.getPowerBoost(); - String boost = (powerBoost == 0.0) ? "" : (powerBoost > 0.0 ? TL.COMMAND_POWER_BONUS.toString() : TL.COMMAND_POWER_PENALTY.toString()) + powerBoost + ")"; - msg(TL.COMMAND_POWER_POWER, target.describeTo(fme, true), target.getPowerRounded(), target.getPowerMaxRounded(), boost); - } + double powerBoost = target.getPowerBoost(); + String boost = (powerBoost == 0.0) ? "" : (powerBoost > 0.0 ? TL.COMMAND_POWER_BONUS.toString() : TL.COMMAND_POWER_PENALTY.toString()) + powerBoost + ")"; + msg(TL.COMMAND_POWER_POWER, target.describeTo(fme, true), target.getPowerRounded(), target.getPowerMaxRounded(), boost); + } - @Override - public TL getUsageTranslation() { - return TL.COMMAND_POWER_DESCRIPTION; - } + @Override + public TL getUsageTranslation() { + return TL.COMMAND_POWER_DESCRIPTION; + } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdPowerBoost.java b/src/main/java/com/massivecraft/factions/cmd/CmdPowerBoost.java index 17259fb2..4a423812 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdPowerBoost.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdPowerBoost.java @@ -8,81 +8,81 @@ import com.massivecraft.factions.zcore.util.TL; public class CmdPowerBoost extends FCommand { - public CmdPowerBoost() { - super(); - this.aliases.add("powerboost"); + public CmdPowerBoost() { + super(); + this.aliases.add("powerboost"); - this.requiredArgs.add("plugin|f|player|faction"); - this.requiredArgs.add("name"); - this.requiredArgs.add("# or reset"); + this.requiredArgs.add("plugin|f|player|faction"); + this.requiredArgs.add("name"); + this.requiredArgs.add("# or reset"); - this.permission = Permission.POWERBOOST.node; - this.disableOnLock = true; + this.permission = Permission.POWERBOOST.node; + this.disableOnLock = true; - senderMustBePlayer = false; - senderMustBeMember = false; - senderMustBeModerator = false; - senderMustBeColeader = false; - senderMustBeAdmin = false; - } + senderMustBePlayer = false; + senderMustBeMember = false; + senderMustBeModerator = false; + senderMustBeColeader = false; + senderMustBeAdmin = false; + } - @Override - public void perform() { - String type = this.argAsString(0).toLowerCase(); - boolean doPlayer = true; - if (type.equals("f") || type.equals("faction")) { - doPlayer = false; - } else if (!type.equals("plugin") && !type.equals("player")) { - msg(TL.COMMAND_POWERBOOST_HELP_1); - msg(TL.COMMAND_POWERBOOST_HELP_2); - return; - } + @Override + public void perform() { + String type = this.argAsString(0).toLowerCase(); + boolean doPlayer = true; + if (type.equals("f") || type.equals("faction")) { + doPlayer = false; + } else if (!type.equals("plugin") && !type.equals("player")) { + msg(TL.COMMAND_POWERBOOST_HELP_1); + msg(TL.COMMAND_POWERBOOST_HELP_2); + return; + } - Double targetPower = this.argAsDouble(2); - if (targetPower == null) { - if (this.argAsString(2).equalsIgnoreCase("reset")) { - targetPower = 0D; - } else { - msg(TL.COMMAND_POWERBOOST_INVALIDNUM); - return; - } - } + Double targetPower = this.argAsDouble(2); + if (targetPower == null) { + if (this.argAsString(2).equalsIgnoreCase("reset")) { + targetPower = 0D; + } else { + msg(TL.COMMAND_POWERBOOST_INVALIDNUM); + return; + } + } - String target; + String target; - if (doPlayer) { - FPlayer targetPlayer = this.argAsBestFPlayerMatch(1); - if (targetPlayer == null) { - return; - } + if (doPlayer) { + FPlayer targetPlayer = this.argAsBestFPlayerMatch(1); + if (targetPlayer == null) { + return; + } - if (targetPower != 0) { - targetPower += targetPlayer.getPowerBoost(); - } - targetPlayer.setPowerBoost(targetPower); - target = TL.COMMAND_POWERBOOST_PLAYER.format(targetPlayer.getName()); - } else { - Faction targetFaction = this.argAsFaction(1); - if (targetFaction == null) { - return; - } + if (targetPower != 0) { + targetPower += targetPlayer.getPowerBoost(); + } + targetPlayer.setPowerBoost(targetPower); + target = TL.COMMAND_POWERBOOST_PLAYER.format(targetPlayer.getName()); + } else { + Faction targetFaction = this.argAsFaction(1); + if (targetFaction == null) { + return; + } - if (targetPower != 0) { - targetPower += targetFaction.getPowerBoost(); - } - targetFaction.setPowerBoost(targetPower); - target = TL.COMMAND_POWERBOOST_FACTION.format(targetFaction.getTag()); - } + if (targetPower != 0) { + targetPower += targetFaction.getPowerBoost(); + } + targetFaction.setPowerBoost(targetPower); + target = TL.COMMAND_POWERBOOST_FACTION.format(targetFaction.getTag()); + } - int roundedPower = (int) Math.round(targetPower); - msg(TL.COMMAND_POWERBOOST_BOOST, target, roundedPower); - if (!senderIsConsole) { - P.p.log(TL.COMMAND_POWERBOOST_BOOSTLOG.toString(), fme.getName(), target, roundedPower); - } - } + int roundedPower = (int) Math.round(targetPower); + msg(TL.COMMAND_POWERBOOST_BOOST, target, roundedPower); + if (!senderIsConsole) { + P.p.log(TL.COMMAND_POWERBOOST_BOOSTLOG.toString(), fme.getName(), target, roundedPower); + } + } - @Override - public TL getUsageTranslation() { - return TL.COMMAND_POWERBOOST_DESCRIPTION; - } + @Override + public TL getUsageTranslation() { + return TL.COMMAND_POWERBOOST_DESCRIPTION; + } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdReload.java b/src/main/java/com/massivecraft/factions/cmd/CmdReload.java index 160e2661..f67ceea4 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdReload.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdReload.java @@ -7,39 +7,39 @@ import com.massivecraft.factions.zcore.util.TL; public class CmdReload extends FCommand { - public CmdReload() { - super(); - this.aliases.add("reload"); + public CmdReload() { + super(); + this.aliases.add("reload"); - this.permission = Permission.RELOAD.node; - this.disableOnLock = false; + this.permission = Permission.RELOAD.node; + this.disableOnLock = false; - senderMustBePlayer = false; - senderMustBeMember = false; - senderMustBeModerator = false; - senderMustBeColeader = false; - senderMustBeAdmin = false; - } + senderMustBePlayer = false; + senderMustBeMember = false; + senderMustBeModerator = false; + senderMustBeColeader = false; + senderMustBeAdmin = false; + } - @Override - public void perform() { - long timeInitStart = System.currentTimeMillis(); - Conf.load(); - Conf.save(); - P.p.reloadConfig(); - P.p.loadLang(); + @Override + public void perform() { + long timeInitStart = System.currentTimeMillis(); + Conf.load(); + Conf.save(); + P.p.reloadConfig(); + P.p.loadLang(); - if (P.p.getConfig().getBoolean("enable-faction-flight")) { - P.p.factionsFlight = true; - } - long timeReload = (System.currentTimeMillis() - timeInitStart); + if (P.p.getConfig().getBoolean("enable-faction-flight")) { + P.p.factionsFlight = true; + } + long timeReload = (System.currentTimeMillis() - timeInitStart); - msg(TL.COMMAND_RELOAD_TIME, timeReload); - } + msg(TL.COMMAND_RELOAD_TIME, timeReload); + } - @Override - public TL getUsageTranslation() { - return TL.COMMAND_RELOAD_DESCRIPTION; - } + @Override + public TL getUsageTranslation() { + return TL.COMMAND_RELOAD_DESCRIPTION; + } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdRules.java b/src/main/java/com/massivecraft/factions/cmd/CmdRules.java index 71963ca7..ee9a2edd 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdRules.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdRules.java @@ -8,84 +8,84 @@ import java.util.HashMap; import java.util.List; public class CmdRules extends FCommand { - public CmdRules() { - super(); - aliases.add("r"); - aliases.add("rule"); - aliases.add("rules"); + public CmdRules() { + super(); + aliases.add("r"); + aliases.add("rule"); + aliases.add("rules"); - this.optionalArgs.put("add/remove/set/clear", ""); - this.errorOnToManyArgs = false; + this.optionalArgs.put("add/remove/set/clear", ""); + this.errorOnToManyArgs = false; - permission = Permission.RULES.node; + permission = Permission.RULES.node; - senderMustBePlayer = true; - senderMustBeMember = true; - senderMustBeModerator = false; - senderMustBeColeader = true; - senderMustBeAdmin = false; + senderMustBePlayer = true; + senderMustBeMember = true; + senderMustBeModerator = false; + senderMustBeColeader = true; + senderMustBeAdmin = false; - } + } - @Override - public void perform() { - if (!P.p.getConfig().getBoolean("frules.Enabled")) { - fme.msg(TL.COMMAND_RULES_DISABLED_MSG); - return; - } - if (this.args.size() == 0) { - HashMap rules = fme.getFaction().getRulesMap(); - if (rules.size() == 0) { - List ruleList = P.p.getConfig().getStringList("frules.default-rules"); - fme.sendMessage(P.p.colorList(ruleList)); + @Override + public void perform() { + if (!P.p.getConfig().getBoolean("frules.Enabled")) { + fme.msg(TL.COMMAND_RULES_DISABLED_MSG); + return; + } + if (this.args.size() == 0) { + HashMap rules = fme.getFaction().getRulesMap(); + if (rules.size() == 0) { + List ruleList = P.p.getConfig().getStringList("frules.default-rules"); + fme.sendMessage(P.p.colorList(ruleList)); - } else { - for (int i = 0; i <= rules.size() - 1; i++) { - fme.sendMessage(P.p.color(rules.get(i))); - } - } + } else { + for (int i = 0; i <= rules.size() - 1; i++) { + fme.sendMessage(P.p.color(rules.get(i))); + } + } - } - if (this.args.size() == 1) { - if (args.get(0).equalsIgnoreCase("add")) { - fme.msg(TL.COMMAND_RULES_ADD_INVALIDARGS); - } - if (args.get(0).equalsIgnoreCase("set")) { - fme.msg(TL.COMMAND_RULES_SET_INVALIDARGS); - } - if (args.get(0).equalsIgnoreCase("remove")) { - fme.msg(TL.COMMAND_RULES_REMOVE_INVALIDARGS); - } - if (args.get(0).equalsIgnoreCase("clear")) { - fme.getFaction().clearRules(); - fme.msg(TL.COMMAND_RULES_CLEAR_SUCCESS); - } + } + if (this.args.size() == 1) { + if (args.get(0).equalsIgnoreCase("add")) { + fme.msg(TL.COMMAND_RULES_ADD_INVALIDARGS); + } + if (args.get(0).equalsIgnoreCase("set")) { + fme.msg(TL.COMMAND_RULES_SET_INVALIDARGS); + } + if (args.get(0).equalsIgnoreCase("remove")) { + fme.msg(TL.COMMAND_RULES_REMOVE_INVALIDARGS); + } + if (args.get(0).equalsIgnoreCase("clear")) { + fme.getFaction().clearRules(); + fme.msg(TL.COMMAND_RULES_CLEAR_SUCCESS); + } - } - if (this.args.size() >= 2) { - if (args.get(0).equalsIgnoreCase("add")) { - String message = ""; - StringBuilder string = new StringBuilder(message); - for (int i = 1; i <= args.size() - 1; i++) { - string.append(" ").append(args.get(i)); - } - fme.getFaction().addRule(string.toString()); - fme.msg(TL.COMMAND_RULES_ADD_SUCCESS); - } + } + if (this.args.size() >= 2) { + if (args.get(0).equalsIgnoreCase("add")) { + String message = ""; + StringBuilder string = new StringBuilder(message); + for (int i = 1; i <= args.size() - 1; i++) { + string.append(" ").append(args.get(i)); + } + fme.getFaction().addRule(string.toString()); + fme.msg(TL.COMMAND_RULES_ADD_SUCCESS); + } - if (this.args.size() == 2) { - if (args.get(0).equalsIgnoreCase("remove")) { - int index = argAsInt(1); - fme.getFaction().removeRule(index - 1); - fme.msg(TL.COMMAND_RULES_REMOVE_SUCCESS); - } - } + if (this.args.size() == 2) { + if (args.get(0).equalsIgnoreCase("remove")) { + int index = argAsInt(1); + fme.getFaction().removeRule(index - 1); + fme.msg(TL.COMMAND_RULES_REMOVE_SUCCESS); + } + } - } - } + } + } - @Override - public TL getUsageTranslation() { - return TL.COMMAND_RULES_DESCRIPTION; - } + @Override + public TL getUsageTranslation() { + return TL.COMMAND_RULES_DESCRIPTION; + } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdSB.java b/src/main/java/com/massivecraft/factions/cmd/CmdSB.java index dedbfd9d..e0f18a3b 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdSB.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdSB.java @@ -6,28 +6,28 @@ import com.massivecraft.factions.zcore.util.TL; public class CmdSB extends FCommand { - public CmdSB() { - this.aliases.add("sb"); - this.aliases.add("scoreboard"); - this.permission = Permission.SCOREBOARD.node; - this.senderMustBePlayer = true; - } + public CmdSB() { + this.aliases.add("sb"); + this.aliases.add("scoreboard"); + this.permission = Permission.SCOREBOARD.node; + this.senderMustBePlayer = true; + } - @Override - public void perform() { - boolean toggleTo = !fme.showScoreboard(); - FScoreboard board = FScoreboard.get(fme); - if (board == null) { - me.sendMessage(TL.COMMAND_TOGGLESB_DISABLED.toString()); - } else { - me.sendMessage(TL.TOGGLE_SB.toString().replace("{value}", String.valueOf(toggleTo))); - board.setSidebarVisibility(toggleTo); - } - fme.setShowScoreboard(toggleTo); - } + @Override + public void perform() { + boolean toggleTo = !fme.showScoreboard(); + FScoreboard board = FScoreboard.get(fme); + if (board == null) { + me.sendMessage(TL.COMMAND_TOGGLESB_DISABLED.toString()); + } else { + me.sendMessage(TL.TOGGLE_SB.toString().replace("{value}", String.valueOf(toggleTo))); + board.setSidebarVisibility(toggleTo); + } + fme.setShowScoreboard(toggleTo); + } - @Override - public TL getUsageTranslation() { - return TL.COMMAND_SCOREBOARD_DESCRIPTION; - } + @Override + public TL getUsageTranslation() { + return TL.COMMAND_SCOREBOARD_DESCRIPTION; + } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdSaveAll.java b/src/main/java/com/massivecraft/factions/cmd/CmdSaveAll.java index 1d0e27b9..2a0de381 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdSaveAll.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdSaveAll.java @@ -9,36 +9,36 @@ import com.massivecraft.factions.zcore.util.TL; public class CmdSaveAll extends FCommand { - public CmdSaveAll() { - super(); - this.aliases.add("saveall"); - this.aliases.add("save"); + public CmdSaveAll() { + super(); + this.aliases.add("saveall"); + this.aliases.add("save"); - //this.requiredArgs.add(""); - //this.optionalArgs.put("", ""); + //this.requiredArgs.add(""); + //this.optionalArgs.put("", ""); - this.permission = Permission.SAVE.node; - this.disableOnLock = false; + this.permission = Permission.SAVE.node; + this.disableOnLock = false; - senderMustBePlayer = false; - senderMustBeMember = false; - senderMustBeModerator = false; - senderMustBeColeader = false; - senderMustBeAdmin = false; - } + senderMustBePlayer = false; + senderMustBeMember = false; + senderMustBeModerator = false; + senderMustBeColeader = false; + senderMustBeAdmin = false; + } - @Override - public void perform() { - FPlayers.getInstance().forceSave(false); - Factions.getInstance().forceSave(false); - Board.getInstance().forceSave(false); - Conf.save(); - msg(TL.COMMAND_SAVEALL_SUCCESS); - } + @Override + public void perform() { + FPlayers.getInstance().forceSave(false); + Factions.getInstance().forceSave(false); + Board.getInstance().forceSave(false); + Conf.save(); + msg(TL.COMMAND_SAVEALL_SUCCESS); + } - @Override - public TL getUsageTranslation() { - return TL.COMMAND_SAVEALL_DESCRIPTION; - } + @Override + public TL getUsageTranslation() { + return TL.COMMAND_SAVEALL_DESCRIPTION; + } } \ No newline at end of file diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdSeeChunk.java b/src/main/java/com/massivecraft/factions/cmd/CmdSeeChunk.java index 030e1107..68ba23ed 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdSeeChunk.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdSeeChunk.java @@ -15,131 +15,131 @@ import java.util.HashMap; public class CmdSeeChunk extends FCommand { - //Used a hashmap cuz imma make a particle selection gui later, will store it where the boolean is rn. - public static HashMap seeChunkMap = new HashMap<>(); - Long interval; - private boolean useParticles; - private ParticleEffect effect; - private int taskID = -1; + //Used a hashmap cuz imma make a particle selection gui later, will store it where the boolean is rn. + public static HashMap seeChunkMap = new HashMap<>(); + Long interval; + private boolean useParticles; + private ParticleEffect effect; + private int taskID = -1; - //I remade it cause of people getting mad that I had the same seechunk as drtshock + //I remade it cause of people getting mad that I had the same seechunk as drtshock - public CmdSeeChunk() { - super(); - aliases.add("seechunk"); - aliases.add("sc"); + public CmdSeeChunk() { + super(); + aliases.add("seechunk"); + aliases.add("sc"); - permission = Permission.SEECHUNK.node; + permission = Permission.SEECHUNK.node; - senderMustBePlayer = true; - senderMustBeMember = false; - senderMustBeModerator = false; - senderMustBeAdmin = false; + senderMustBePlayer = true; + senderMustBeMember = false; + senderMustBeModerator = false; + senderMustBeAdmin = false; - this.useParticles = p.getConfig().getBoolean("see-chunk.particles", true); - interval = P.p.getConfig().getLong("see-chunk.interval", 10L); - if (effect == null) { - effect = ParticleEffect.REDSTONE; - } + this.useParticles = p.getConfig().getBoolean("see-chunk.particles", true); + interval = P.p.getConfig().getLong("see-chunk.interval", 10L); + if (effect == null) { + effect = ParticleEffect.REDSTONE; + } - } + } - @Override - public void perform() { - if (seeChunkMap.containsKey(me.getName())) { - seeChunkMap.remove(me.getName()); - msg(TL.COMMAND_SEECHUNK_DISABLED); - } else { - seeChunkMap.put(me.getName(), true); - msg(TL.COMMAND_SEECHUNK_ENABLED); - manageTask(); - } - } + @Override + public void perform() { + if (seeChunkMap.containsKey(me.getName())) { + seeChunkMap.remove(me.getName()); + msg(TL.COMMAND_SEECHUNK_DISABLED); + } else { + seeChunkMap.put(me.getName(), true); + msg(TL.COMMAND_SEECHUNK_ENABLED); + manageTask(); + } + } - private void manageTask() { - if (taskID != -1) { - if (seeChunkMap.keySet().size() == 0) { - Bukkit.getScheduler().cancelTask(taskID); - taskID = -1; - } - } else { - startTask(); - } - } + private void manageTask() { + if (taskID != -1) { + if (seeChunkMap.keySet().size() == 0) { + Bukkit.getScheduler().cancelTask(taskID); + taskID = -1; + } + } else { + startTask(); + } + } - private void startTask() { - taskID = Bukkit.getScheduler().scheduleSyncRepeatingTask(P.p, () -> { - for (Object nameObject : seeChunkMap.keySet()) { - String name = nameObject + ""; - Player player = Bukkit.getPlayer(name); - showBorders(player); - } - manageTask(); - }, 0, interval); - } + private void startTask() { + taskID = Bukkit.getScheduler().scheduleSyncRepeatingTask(P.p, () -> { + for (Object nameObject : seeChunkMap.keySet()) { + String name = nameObject + ""; + Player player = Bukkit.getPlayer(name); + showBorders(player); + } + manageTask(); + }, 0, interval); + } - private void showBorders(Player me) { - World world = me.getWorld(); - FLocation flocation = new FLocation(me); - int chunkX = (int) flocation.getX(); - int chunkZ = (int) flocation.getZ(); + private void showBorders(Player me) { + World world = me.getWorld(); + FLocation flocation = new FLocation(me); + int chunkX = (int) flocation.getX(); + int chunkZ = (int) flocation.getZ(); - int blockX; - int blockZ; + int blockX; + int blockZ; - blockX = chunkX * 16; - blockZ = chunkZ * 16; - showPillar(me, world, blockX, blockZ); + blockX = chunkX * 16; + blockZ = chunkZ * 16; + showPillar(me, world, blockX, blockZ); - blockX = chunkX * 16 + 15; - blockZ = chunkZ * 16; - showPillar(me, world, blockX, blockZ); + blockX = chunkX * 16 + 15; + blockZ = chunkZ * 16; + showPillar(me, world, blockX, blockZ); - blockX = chunkX * 16; - blockZ = chunkZ * 16 + 15; - showPillar(me, world, blockX, blockZ); + blockX = chunkX * 16; + blockZ = chunkZ * 16 + 15; + showPillar(me, world, blockX, blockZ); - blockX = chunkX * 16 + 15; - blockZ = chunkZ * 16 + 15; - showPillar(me, world, blockX, blockZ); - } + blockX = chunkX * 16 + 15; + blockZ = chunkZ * 16 + 15; + showPillar(me, world, blockX, blockZ); + } - private void showPillar(Player player, World world, int blockX, int blockZ) { - for (int blockY = 0; blockY < player.getLocation().getBlockY() + 30; blockY++) { - Location loc = new Location(world, blockX, blockY, blockZ).add(0.5, 0, 0.5); - if (loc.getBlock().getType() != Material.AIR) { - continue; - } - if (useParticles) { - if (P.p.useNonPacketParticles) { - // Dust options only exists in the 1.13 API, so we use an - // alternative method to achieve this in lower versions. - if (P.p.mc113) { - player.spawnParticle(Particle.REDSTONE, loc, 0, new Particle.DustOptions(Color.RED, 1)); - } else { - player.getWorld().spawnParticle(Particle.REDSTONE, loc, 0, 255, 0, 0, 1); - } + private void showPillar(Player player, World world, int blockX, int blockZ) { + for (int blockY = 0; blockY < player.getLocation().getBlockY() + 30; blockY++) { + Location loc = new Location(world, blockX, blockY, blockZ).add(0.5, 0, 0.5); + if (loc.getBlock().getType() != Material.AIR) { + continue; + } + if (useParticles) { + if (P.p.useNonPacketParticles) { + // Dust options only exists in the 1.13 API, so we use an + // alternative method to achieve this in lower versions. + if (P.p.mc113) { + player.spawnParticle(Particle.REDSTONE, loc, 0, new Particle.DustOptions(Color.RED, 1)); + } else { + player.getWorld().spawnParticle(Particle.REDSTONE, loc, 0, 255, 0, 0, 1); + } - } else { - this.effect.display(0, 0, 0, 0, 1, loc, player); - } + } else { + this.effect.display(0, 0, 0, 0, 1, loc, player); + } - } else { - Material type = blockY % 5 == 0 ? XMaterial.REDSTONE_LAMP.parseMaterial() : XMaterial.BLACK_STAINED_GLASS.parseMaterial(); - VisualizeUtil.addLocation(player, loc, type); - } - } - } + } else { + Material type = blockY % 5 == 0 ? XMaterial.REDSTONE_LAMP.parseMaterial() : XMaterial.BLACK_STAINED_GLASS.parseMaterial(); + VisualizeUtil.addLocation(player, loc, type); + } + } + } - @Override - public TL getUsageTranslation() { - return TL.GENERIC_PLACEHOLDER; - } + @Override + public TL getUsageTranslation() { + return TL.GENERIC_PLACEHOLDER; + } } \ No newline at end of file diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdSetBanner.java b/src/main/java/com/massivecraft/factions/cmd/CmdSetBanner.java index ed4e0249..1558b54d 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdSetBanner.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdSetBanner.java @@ -5,35 +5,35 @@ import com.massivecraft.factions.zcore.util.TL; public class CmdSetBanner extends FCommand { - public CmdSetBanner() { - super(); - aliases.add("setbanner"); + public CmdSetBanner() { + super(); + aliases.add("setbanner"); - permission = Permission.BANNER.node; + permission = Permission.BANNER.node; - senderMustBePlayer = true; - senderMustBeMember = false; - senderMustBeModerator = false; - senderMustBeAdmin = true; + senderMustBePlayer = true; + senderMustBeMember = false; + senderMustBeModerator = false; + senderMustBeAdmin = true; - } + } - public void perform() { - if (!me.getItemInHand().getType().toString().contains("BANNER")) { - fme.msg(TL.COMMAND_SETBANNER_NOTBANNER); - return; - } + public void perform() { + if (!me.getItemInHand().getType().toString().contains("BANNER")) { + fme.msg(TL.COMMAND_SETBANNER_NOTBANNER); + return; + } - fme.getFaction().setBannerPattern(me.getItemInHand()); - fme.msg(TL.COMMAND_SETBANNER_SUCCESS); + fme.getFaction().setBannerPattern(me.getItemInHand()); + fme.msg(TL.COMMAND_SETBANNER_SUCCESS); - } + } - @Override - public TL getUsageTranslation() { - return TL.COMMAND_SETBANNER_DESCRIPTION; - } + @Override + public TL getUsageTranslation() { + return TL.COMMAND_SETBANNER_DESCRIPTION; + } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdSetDefaultRole.java b/src/main/java/com/massivecraft/factions/cmd/CmdSetDefaultRole.java index 8bd5a49d..9735f1c0 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdSetDefaultRole.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdSetDefaultRole.java @@ -6,43 +6,43 @@ import com.massivecraft.factions.zcore.util.TL; public class CmdSetDefaultRole extends FCommand { - public CmdSetDefaultRole() { - super(); + public CmdSetDefaultRole() { + super(); - this.aliases.add("defaultrole"); - this.aliases.add("defaultrank"); - this.aliases.add("default"); - this.aliases.add("def"); - this.requiredArgs.add("role"); + this.aliases.add("defaultrole"); + this.aliases.add("defaultrank"); + this.aliases.add("default"); + this.aliases.add("def"); + this.requiredArgs.add("role"); - this.senderMustBeAdmin = true; - this.senderMustBePlayer = true; - senderMustBeColeader = false; + this.senderMustBeAdmin = true; + this.senderMustBePlayer = true; + senderMustBeColeader = false; - this.permission = Permission.DEFAULTRANK.node; - } + this.permission = Permission.DEFAULTRANK.node; + } - @Override - public void perform() { - Role target = Role.fromString(argAsString(0).toUpperCase()); - if (target == null) { - msg(TL.COMMAND_SETDEFAULTROLE_INVALIDROLE, argAsString(0)); - return; - } + @Override + public void perform() { + Role target = Role.fromString(argAsString(0).toUpperCase()); + if (target == null) { + msg(TL.COMMAND_SETDEFAULTROLE_INVALIDROLE, argAsString(0)); + return; + } - if (target == Role.LEADER) { - msg(TL.COMMAND_SETDEFAULTROLE_NOTTHATROLE, argAsString(0)); - return; - } + if (target == Role.LEADER) { + msg(TL.COMMAND_SETDEFAULTROLE_NOTTHATROLE, argAsString(0)); + return; + } - myFaction.setDefaultRole(target); - msg(TL.COMMAND_SETDEFAULTROLE_SUCCESS, target.nicename); - } + myFaction.setDefaultRole(target); + msg(TL.COMMAND_SETDEFAULTROLE_SUCCESS, target.nicename); + } - @Override - public TL getUsageTranslation() { - return TL.COMMAND_SETDEFAULTROLE_DESCRIPTION; - } + @Override + public TL getUsageTranslation() { + return TL.COMMAND_SETDEFAULTROLE_DESCRIPTION; + } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdSetFWarp.java b/src/main/java/com/massivecraft/factions/cmd/CmdSetFWarp.java index 5b7cff3f..085b4be7 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdSetFWarp.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdSetFWarp.java @@ -12,72 +12,72 @@ import com.massivecraft.factions.zcore.util.TL; public class CmdSetFWarp extends FCommand { - public CmdSetFWarp() { - super(); + public CmdSetFWarp() { + super(); - this.aliases.add("setwarp"); - this.aliases.add("sw"); + this.aliases.add("setwarp"); + this.aliases.add("sw"); - this.requiredArgs.add("warp name"); - this.optionalArgs.put("password", "password"); + this.requiredArgs.add("warp name"); + this.optionalArgs.put("password", "password"); - this.senderMustBeMember = true; - this.senderMustBeModerator = false; + this.senderMustBeMember = true; + this.senderMustBeModerator = false; - this.senderMustBePlayer = true; + this.senderMustBePlayer = true; - this.permission = Permission.SETWARP.node; - } + this.permission = Permission.SETWARP.node; + } - @Override - public void perform() { - if (!(fme.getRelationToLocation() == Relation.MEMBER)) { - fme.msg(TL.COMMAND_SETFWARP_NOTCLAIMED); - return; - } + @Override + public void perform() { + if (!(fme.getRelationToLocation() == Relation.MEMBER)) { + fme.msg(TL.COMMAND_SETFWARP_NOTCLAIMED); + return; + } - // This statement allows us to check if they've specifically denied it, or default to - // the old setting of allowing moderators to set warps. - if (!fme.isAdminBypassing()) { - Access access = myFaction.getAccess(fme, PermissableAction.SETWARP); - if (access != Access.ALLOW && fme.getRole() != Role.LEADER) { - fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "set warps"); - return; - } - } + // This statement allows us to check if they've specifically denied it, or default to + // the old setting of allowing moderators to set warps. + if (!fme.isAdminBypassing()) { + Access access = myFaction.getAccess(fme, PermissableAction.SETWARP); + if (access != Access.ALLOW && fme.getRole() != Role.LEADER) { + fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "set warps"); + return; + } + } - String warp = argAsString(0); + String warp = argAsString(0); - // Checks if warp with same name already exists and ignores maxWarp check if it does. - boolean warpExists = myFaction.isWarp(warp); + // Checks if warp with same name already exists and ignores maxWarp check if it does. + boolean warpExists = myFaction.isWarp(warp); - int maxWarps = P.p.getConfig().getInt("max-warps", 5); - boolean tooManyWarps = maxWarps <= myFaction.getWarps().size(); - if (tooManyWarps && !warpExists) { - fme.msg(TL.COMMAND_SETFWARP_LIMIT, maxWarps); - return; - } + int maxWarps = P.p.getConfig().getInt("max-warps", 5); + boolean tooManyWarps = maxWarps <= myFaction.getWarps().size(); + if (tooManyWarps && !warpExists) { + fme.msg(TL.COMMAND_SETFWARP_LIMIT, maxWarps); + return; + } - if (!transact(fme)) { - return; - } + if (!transact(fme)) { + return; + } - String password = argAsString(1); + String password = argAsString(1); - LazyLocation loc = new LazyLocation(fme.getPlayer().getLocation()); - myFaction.setWarp(warp, loc); - if (password != null) { - myFaction.setWarpPassword(warp, password); - } - fme.msg(TL.COMMAND_SETFWARP_SET, warp, password != null ? password : ""); - } + LazyLocation loc = new LazyLocation(fme.getPlayer().getLocation()); + myFaction.setWarp(warp, loc); + if (password != null) { + myFaction.setWarpPassword(warp, password); + } + fme.msg(TL.COMMAND_SETFWARP_SET, warp, password != null ? password : ""); + } - private boolean transact(FPlayer player) { - return !P.p.getConfig().getBoolean("warp-cost.enabled", false) || player.isAdminBypassing() || payForCommand(P.p.getConfig().getDouble("warp-cost.setwarp", 5), TL.COMMAND_SETFWARP_TOSET.toString(), TL.COMMAND_SETFWARP_FORSET.toString()); - } + private boolean transact(FPlayer player) { + return !P.p.getConfig().getBoolean("warp-cost.enabled", false) || player.isAdminBypassing() || payForCommand(P.p.getConfig().getDouble("warp-cost.setwarp", 5), TL.COMMAND_SETFWARP_TOSET.toString(), TL.COMMAND_SETFWARP_FORSET.toString()); + } - @Override - public TL getUsageTranslation() { - return TL.COMMAND_SETFWARP_DESCRIPTION; - } + @Override + public TL getUsageTranslation() { + return TL.COMMAND_SETFWARP_DESCRIPTION; + } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdSetMaxVaults.java b/src/main/java/com/massivecraft/factions/cmd/CmdSetMaxVaults.java index de49364e..1f3a98f9 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdSetMaxVaults.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdSetMaxVaults.java @@ -7,44 +7,44 @@ import org.bukkit.ChatColor; public class CmdSetMaxVaults extends FCommand { - public CmdSetMaxVaults() { - this.aliases.add("setmaxvaults"); - this.aliases.add("smv"); + public CmdSetMaxVaults() { + this.aliases.add("setmaxvaults"); + this.aliases.add("smv"); - this.requiredArgs.add("faction"); - this.requiredArgs.add("number"); + this.requiredArgs.add("faction"); + this.requiredArgs.add("number"); - this.permission = Permission.SETMAXVAULTS.node; - this.disableOnLock = false; + this.permission = Permission.SETMAXVAULTS.node; + this.disableOnLock = false; - senderMustBePlayer = false; - senderMustBeMember = false; - senderMustBeModerator = false; - senderMustBeColeader = false; - senderMustBeAdmin = false; + senderMustBePlayer = false; + senderMustBeMember = false; + senderMustBeModerator = false; + senderMustBeColeader = false; + senderMustBeAdmin = false; - } + } - @Override - public void perform() { - Faction targetFaction = argAsFaction(0); - int value = argAsInt(1, -1); - if (value < 0) { - sender.sendMessage(ChatColor.RED + "Number must be greater than 0."); - return; - } + @Override + public void perform() { + Faction targetFaction = argAsFaction(0); + int value = argAsInt(1, -1); + if (value < 0) { + sender.sendMessage(ChatColor.RED + "Number must be greater than 0."); + return; + } - if (targetFaction == null) { - sender.sendMessage(ChatColor.RED + "Couldn't find Faction: " + ChatColor.YELLOW + argAsString(0)); - return; - } + if (targetFaction == null) { + sender.sendMessage(ChatColor.RED + "Couldn't find Faction: " + ChatColor.YELLOW + argAsString(0)); + return; + } - targetFaction.setMaxVaults(value); - sender.sendMessage(TL.COMMAND_SETMAXVAULTS_SUCCESS.format(targetFaction.getTag(), value)); - } + targetFaction.setMaxVaults(value); + sender.sendMessage(TL.COMMAND_SETMAXVAULTS_SUCCESS.format(targetFaction.getTag(), value)); + } - @Override - public TL getUsageTranslation() { - return TL.COMMAND_SETMAXVAULTS_DESCRIPTION; - } + @Override + public TL getUsageTranslation() { + return TL.COMMAND_SETMAXVAULTS_DESCRIPTION; + } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdSethome.java b/src/main/java/com/massivecraft/factions/cmd/CmdSethome.java index eaf2c94d..b9440e05 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdSethome.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdSethome.java @@ -12,68 +12,68 @@ import com.massivecraft.factions.zcore.util.TL; public class CmdSethome extends FCommand { - public CmdSethome() { - this.aliases.add("sethome"); + public CmdSethome() { + this.aliases.add("sethome"); - //this.requiredArgs.add(""); - this.optionalArgs.put("faction tag", "mine"); + //this.requiredArgs.add(""); + this.optionalArgs.put("faction tag", "mine"); - this.permission = Permission.SETHOME.node; - this.disableOnLock = true; + this.permission = Permission.SETHOME.node; + this.disableOnLock = true; - senderMustBePlayer = true; - senderMustBeMember = false; - senderMustBeModerator = false; - senderMustBeColeader = false; - senderMustBeAdmin = false; + senderMustBePlayer = true; + senderMustBeMember = false; + senderMustBeModerator = false; + senderMustBeColeader = false; + senderMustBeAdmin = false; - } + } - @Override - public void perform() { - if (!Conf.homesEnabled) { - fme.msg(TL.COMMAND_SETHOME_DISABLED); - return; - } + @Override + public void perform() { + if (!Conf.homesEnabled) { + fme.msg(TL.COMMAND_SETHOME_DISABLED); + return; + } - Faction faction = this.argAsFaction(0, myFaction); - if (faction == null) { - return; - } + Faction faction = this.argAsFaction(0, myFaction); + if (faction == null) { + return; + } - if (!fme.isAdminBypassing()) { - Access access = myFaction.getAccess(fme, PermissableAction.SETHOME); - if (access != Access.ALLOW && fme.getRole() != Role.LEADER && !Permission.SETHOME_ANY.has(sender, true)) { - fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "set home"); - return; - } - } + if (!fme.isAdminBypassing()) { + Access access = myFaction.getAccess(fme, PermissableAction.SETHOME); + if (access != Access.ALLOW && fme.getRole() != Role.LEADER && !Permission.SETHOME_ANY.has(sender, true)) { + fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "set home"); + return; + } + } - // Can the player set the faction home HERE? - if (!Permission.BYPASS.has(me) && - Conf.homesMustBeInClaimedTerritory && - Board.getInstance().getFactionAt(new FLocation(me)) != faction) { - fme.msg(TL.COMMAND_SETHOME_NOTCLAIMED); - return; - } + // Can the player set the faction home HERE? + if (!Permission.BYPASS.has(me) && + Conf.homesMustBeInClaimedTerritory && + Board.getInstance().getFactionAt(new FLocation(me)) != faction) { + fme.msg(TL.COMMAND_SETHOME_NOTCLAIMED); + return; + } - // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay - if (!payForCommand(Conf.econCostSethome, TL.COMMAND_SETHOME_TOSET, TL.COMMAND_SETHOME_FORSET)) { - return; - } + // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay + if (!payForCommand(Conf.econCostSethome, TL.COMMAND_SETHOME_TOSET, TL.COMMAND_SETHOME_FORSET)) { + return; + } - faction.setHome(me.getLocation()); + faction.setHome(me.getLocation()); - faction.msg(TL.COMMAND_SETHOME_SET, fme.describeTo(myFaction, true)); - faction.sendMessage(p.cmdBase.cmdHome.getUseageTemplate()); - if (faction != myFaction) { - fme.msg(TL.COMMAND_SETHOME_SETOTHER, faction.getTag(fme)); - } - } + faction.msg(TL.COMMAND_SETHOME_SET, fme.describeTo(myFaction, true)); + faction.sendMessage(p.cmdBase.cmdHome.getUseageTemplate()); + if (faction != myFaction) { + fme.msg(TL.COMMAND_SETHOME_SETOTHER, faction.getTag(fme)); + } + } - @Override - public TL getUsageTranslation() { - return TL.COMMAND_SETHOME_DESCRIPTION; - } + @Override + public TL getUsageTranslation() { + return TL.COMMAND_SETHOME_DESCRIPTION; + } } \ No newline at end of file diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdShow.java b/src/main/java/com/massivecraft/factions/cmd/CmdShow.java index c50128dc..268a2abd 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdShow.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdShow.java @@ -14,108 +14,108 @@ import java.util.List; public class CmdShow extends FCommand { - List defaults = new ArrayList<>(); + List defaults = new ArrayList<>(); - public CmdShow() { - this.aliases.add("show"); - this.aliases.add("who"); - this.aliases.add("f"); + public CmdShow() { + this.aliases.add("show"); + this.aliases.add("who"); + this.aliases.add("f"); - // add defaults to /f show in case config doesnt have it - defaults.add("{header}"); - defaults.add("Description: {description}"); - defaults.add("Joining: {joining} {peaceful}"); - defaults.add("Land / Power / Maxpower: {chunks} / {power} / {maxPower}"); - defaults.add("Faction Strikes: {strikes}"); - defaults.add("Founded: {create-date}"); - defaults.add("This faction is permanent, remaining even with no members."); - defaults.add("Land value: {land-value} {land-refund}"); - defaults.add("Balance: {faction-balance}"); - defaults.add("Allies({allies}/{max-allies}): {allies-list}"); - defaults.add("Online: ({online}/{members}): {online-list}"); - defaults.add("Offline: ({offline}/{members}): {offline-list}"); - defaults.add("Alt List: {alts}"); + // add defaults to /f show in case config doesnt have it + defaults.add("{header}"); + defaults.add("Description: {description}"); + defaults.add("Joining: {joining} {peaceful}"); + defaults.add("Land / Power / Maxpower: {chunks} / {power} / {maxPower}"); + defaults.add("Faction Strikes: {strikes}"); + defaults.add("Founded: {create-date}"); + defaults.add("This faction is permanent, remaining even with no members."); + defaults.add("Land value: {land-value} {land-refund}"); + defaults.add("Balance: {faction-balance}"); + defaults.add("Allies({allies}/{max-allies}): {allies-list}"); + defaults.add("Online: ({online}/{members}): {online-list}"); + defaults.add("Offline: ({offline}/{members}): {offline-list}"); + defaults.add("Alt List: {alts}"); - // this.requiredArgs.add(""); - this.optionalArgs.put("faction tag", "yours"); + // this.requiredArgs.add(""); + this.optionalArgs.put("faction tag", "yours"); - this.permission = Permission.SHOW.node; - this.disableOnLock = false; + this.permission = Permission.SHOW.node; + this.disableOnLock = false; - senderMustBeMember = false; - senderMustBeModerator = false; - senderMustBeAdmin = false; - } + senderMustBeMember = false; + senderMustBeModerator = false; + senderMustBeAdmin = false; + } - @Override - public void perform() { - Faction faction = myFaction; - if (this.argIsSet(0)) - faction = this.argAsFaction(0); + @Override + public void perform() { + Faction faction = myFaction; + if (this.argIsSet(0)) + faction = this.argAsFaction(0); - if (faction == null) - return; + if (faction == null) + return; - if (fme != null && !fme.getPlayer().hasPermission("factions.show.bypassexempt") - && P.p.getConfig().getStringList("show-exempt").contains(faction.getTag())) { - msg(TL.COMMAND_SHOW_EXEMPT); - return; - } + if (fme != null && !fme.getPlayer().hasPermission("factions.show.bypassexempt") + && P.p.getConfig().getStringList("show-exempt").contains(faction.getTag())) { + msg(TL.COMMAND_SHOW_EXEMPT); + return; + } - // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay - if (!payForCommand(Conf.econCostShow, TL.COMMAND_SHOW_TOSHOW, TL.COMMAND_SHOW_FORSHOW)) { - return; - } + // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay + if (!payForCommand(Conf.econCostShow, TL.COMMAND_SHOW_TOSHOW, TL.COMMAND_SHOW_FORSHOW)) { + return; + } - List show = P.p.getConfig().getStringList("show"); - if (show == null || show.isEmpty()) - show = defaults; + List show = P.p.getConfig().getStringList("show"); + if (show == null || show.isEmpty()) + show = defaults; - if (!faction.isNormal()) { - String tag = faction.getTag(fme); - // send header and that's all - String header = show.get(0); - if (TagReplacer.HEADER.contains(header)) { - msg(p.txt.titleize(tag)); - } else { - msg(p.txt.parse(TagReplacer.FACTION.replace(header, tag))); - } - return; // we only show header for non-normal factions - } + if (!faction.isNormal()) { + String tag = faction.getTag(fme); + // send header and that's all + String header = show.get(0); + if (TagReplacer.HEADER.contains(header)) { + msg(p.txt.titleize(tag)); + } else { + msg(p.txt.parse(TagReplacer.FACTION.replace(header, tag))); + } + return; // we only show header for non-normal factions + } - for (String raw : show) { - String parsed = TagUtil.parsePlain(faction, fme, raw); // use relations - if (parsed == null) { - continue; // Due to minimal f show. - } + for (String raw : show) { + String parsed = TagUtil.parsePlain(faction, fme, raw); // use relations + if (parsed == null) { + continue; // Due to minimal f show. + } - if (fme != null) { - parsed = TagUtil.parsePlaceholders(fme.getPlayer(), parsed); - } + if (fme != null) { + parsed = TagUtil.parsePlaceholders(fme.getPlayer(), parsed); + } - if (TagUtil.hasFancy(parsed)) { - List fancy = TagUtil.parseFancy(faction, fme, parsed); - if (fancy != null) - sendFancyMessage(fancy); + if (TagUtil.hasFancy(parsed)) { + List fancy = TagUtil.parseFancy(faction, fme, parsed); + if (fancy != null) + sendFancyMessage(fancy); - continue; - } - if (!parsed.contains("{notFrozen}") && !parsed.contains("{notPermanent}")) { - if (parsed.contains("{ig}")) { - // replaces all variables with no home TL - parsed = parsed.substring(0, parsed.indexOf("{ig}")) + TL.COMMAND_SHOW_NOHOME.toString(); - } - if (parsed.contains("%")) { - parsed = parsed.replaceAll("%", ""); // Just in case it got in there before we disallowed it. - } - msg(p.txt.parse(parsed)); - } - } - } + continue; + } + if (!parsed.contains("{notFrozen}") && !parsed.contains("{notPermanent}")) { + if (parsed.contains("{ig}")) { + // replaces all variables with no home TL + parsed = parsed.substring(0, parsed.indexOf("{ig}")) + TL.COMMAND_SHOW_NOHOME.toString(); + } + if (parsed.contains("%")) { + parsed = parsed.replaceAll("%", ""); // Just in case it got in there before we disallowed it. + } + msg(p.txt.parse(parsed)); + } + } + } - @Override - public TL getUsageTranslation() { - return TL.COMMAND_SHOW_COMMANDDESCRIPTION; - } + @Override + public TL getUsageTranslation() { + return TL.COMMAND_SHOW_COMMANDDESCRIPTION; + } } \ No newline at end of file diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdShowClaims.java b/src/main/java/com/massivecraft/factions/cmd/CmdShowClaims.java index ac0908b2..fc6b685e 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdShowClaims.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdShowClaims.java @@ -8,49 +8,49 @@ import com.massivecraft.factions.zcore.util.TL; public class CmdShowClaims extends FCommand { - public CmdShowClaims() { + public CmdShowClaims() { - this.aliases.add("showclaims"); - this.aliases.add("showclaim"); + this.aliases.add("showclaims"); + this.aliases.add("showclaim"); - permission = Permission.SHOWCLAIMS.node; + permission = Permission.SHOWCLAIMS.node; - this.senderMustBePlayer = true; - this.senderMustBeMember = true; - this.senderMustBeModerator = false; - } + this.senderMustBePlayer = true; + this.senderMustBeMember = true; + this.senderMustBeModerator = false; + } - @Override - public void perform() { - sendMessage(TL.COMMAND_SHOWCLAIMS_HEADER.toString().replace("{faction}", fme.getFaction().describeTo(fme))); - ListMultimap chunkMap = ArrayListMultimap.create(); - String format = TL.COMMAND_SHOWCLAIMS_CHUNKSFORMAT.toString(); - for (FLocation fLocation : fme.getFaction().getAllClaims()) { - chunkMap.put(fLocation.getWorldName(), format.replace("{x}", fLocation.getX() + "").replace("{z}", fLocation.getZ() + "")); - } - for (String world : chunkMap.keySet()) { - String message = TL.COMMAND_SHOWCLAIMS_FORMAT.toString().replace("{world}", world); - // made {chunks} blank as I removed the placeholder and people wont update their config :shrug: - sendMessage(message.replace("{chunks}", "")); - StringBuilder chunks = new StringBuilder(); - for (String chunkString : chunkMap.get(world)) { - chunks.append(chunkString).append(", "); - if (chunks.toString().length() >= 2000) { - sendMessage(chunks.toString()); - chunks.setLength(0); - } - } - if (chunks.length() != 0) sendMessage(chunks.toString()); - sendMessage(""); - } + @Override + public void perform() { + sendMessage(TL.COMMAND_SHOWCLAIMS_HEADER.toString().replace("{faction}", fme.getFaction().describeTo(fme))); + ListMultimap chunkMap = ArrayListMultimap.create(); + String format = TL.COMMAND_SHOWCLAIMS_CHUNKSFORMAT.toString(); + for (FLocation fLocation : fme.getFaction().getAllClaims()) { + chunkMap.put(fLocation.getWorldName(), format.replace("{x}", fLocation.getX() + "").replace("{z}", fLocation.getZ() + "")); + } + for (String world : chunkMap.keySet()) { + String message = TL.COMMAND_SHOWCLAIMS_FORMAT.toString().replace("{world}", world); + // made {chunks} blank as I removed the placeholder and people wont update their config :shrug: + sendMessage(message.replace("{chunks}", "")); + StringBuilder chunks = new StringBuilder(); + for (String chunkString : chunkMap.get(world)) { + chunks.append(chunkString).append(", "); + if (chunks.toString().length() >= 2000) { + sendMessage(chunks.toString()); + chunks.setLength(0); + } + } + if (chunks.length() != 0) sendMessage(chunks.toString()); + sendMessage(""); + } - } + } - @Override - public TL getUsageTranslation() { - return TL.COMMAND_SHOWCLAIMS_DESCRIPTION; - } + @Override + public TL getUsageTranslation() { + return TL.COMMAND_SHOWCLAIMS_DESCRIPTION; + } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdShowInvites.java b/src/main/java/com/massivecraft/factions/cmd/CmdShowInvites.java index 79f48b91..4666ff03 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdShowInvites.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdShowInvites.java @@ -10,32 +10,32 @@ import org.bukkit.ChatColor; public class CmdShowInvites extends FCommand { - public CmdShowInvites() { - super(); - aliases.add("showinvites"); - permission = Permission.SHOW_INVITES.node; + public CmdShowInvites() { + super(); + aliases.add("showinvites"); + permission = Permission.SHOW_INVITES.node; - senderMustBePlayer = true; - senderMustBeMember = true; + senderMustBePlayer = true; + senderMustBeMember = true; - } + } - @Override - public void perform() { - FancyMessage msg = new FancyMessage(TL.COMMAND_SHOWINVITES_PENDING.toString()).color(ChatColor.GOLD); - for (String id : myFaction.getInvites()) { - FPlayer fp = FPlayers.getInstance().getById(id); - String name = fp != null ? fp.getName() : id; - msg.then(name + " ").color(ChatColor.WHITE).tooltip(TL.COMMAND_SHOWINVITES_CLICKTOREVOKE.format(name)).command("/" + Conf.baseCommandAliases.get(0) + " deinvite " + name); - } + @Override + public void perform() { + FancyMessage msg = new FancyMessage(TL.COMMAND_SHOWINVITES_PENDING.toString()).color(ChatColor.GOLD); + for (String id : myFaction.getInvites()) { + FPlayer fp = FPlayers.getInstance().getById(id); + String name = fp != null ? fp.getName() : id; + msg.then(name + " ").color(ChatColor.WHITE).tooltip(TL.COMMAND_SHOWINVITES_CLICKTOREVOKE.format(name)).command("/" + Conf.baseCommandAliases.get(0) + " deinvite " + name); + } - sendFancyMessage(msg); - } + sendFancyMessage(msg); + } - @Override - public TL getUsageTranslation() { - return TL.COMMAND_SHOWINVITES_DESCRIPTION; - } + @Override + public TL getUsageTranslation() { + return TL.COMMAND_SHOWINVITES_DESCRIPTION; + } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdSpam.java b/src/main/java/com/massivecraft/factions/cmd/CmdSpam.java index 3a6925d6..49a10a7e 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdSpam.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdSpam.java @@ -1,12 +1,11 @@ package com.massivecraft.factions.cmd; -import com.massivecraft.factions.Conf; import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.zcore.util.TL; public class CmdSpam extends FCommand { - public CmdSpam(){ + public CmdSpam() { this.aliases.add("spam"); this.optionalArgs.put("on/off", "flip"); diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdStatus.java b/src/main/java/com/massivecraft/factions/cmd/CmdStatus.java index 1df3b189..4dfec779 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdStatus.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdStatus.java @@ -10,35 +10,35 @@ import java.util.ArrayList; public class CmdStatus extends FCommand { - public CmdStatus() { - super(); - this.aliases.add("status"); - this.aliases.add("s"); + public CmdStatus() { + super(); + this.aliases.add("status"); + this.aliases.add("s"); - this.permission = Permission.STATUS.node; + this.permission = Permission.STATUS.node; - senderMustBePlayer = true; - senderMustBeMember = true; - senderMustBeModerator = false; - senderMustBeAdmin = false; + senderMustBePlayer = true; + senderMustBeMember = true; + senderMustBeModerator = false; + senderMustBeAdmin = false; - } + } - @Override - public void perform() { - ArrayList ret = new ArrayList<>(); - 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; - ret.add(String.format(TL.COMMAND_STATUS_FORMAT.toString(), ChatColor.GOLD + fp.getRole().getPrefix() + fp.getName() + ChatColor.RESET, power, last).trim()); - } - fme.sendMessage(ret); - } + @Override + public void perform() { + ArrayList ret = new ArrayList<>(); + 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; + ret.add(String.format(TL.COMMAND_STATUS_FORMAT.toString(), ChatColor.GOLD + fp.getRole().getPrefix() + fp.getName() + ChatColor.RESET, power, last).trim()); + } + fme.sendMessage(ret); + } - @Override - public TL getUsageTranslation() { - return TL.COMMAND_STATUS_DESCRIPTION; - } + @Override + public TL getUsageTranslation() { + return TL.COMMAND_STATUS_DESCRIPTION; + } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdStealth.java b/src/main/java/com/massivecraft/factions/cmd/CmdStealth.java index 62f03ba6..277828e6 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdStealth.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdStealth.java @@ -5,35 +5,34 @@ import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.zcore.util.TL; public class CmdStealth extends FCommand { - public CmdStealth() { - this.aliases.add("ninja"); - this.aliases.add("stealth"); - this.permission = Permission.STEALTH.node; + public CmdStealth() { + this.aliases.add("ninja"); + this.aliases.add("stealth"); + this.permission = Permission.STEALTH.node; - this.disableOnLock = true; + this.disableOnLock = true; - this.senderMustBePlayer = true; - this.senderMustBeMember = false; - this.senderMustBeModerator = false; - this.senderMustBeColeader = false; - this.senderMustBeAdmin = false; + this.senderMustBePlayer = true; + this.senderMustBeMember = false; + this.senderMustBeModerator = false; + this.senderMustBeColeader = false; + this.senderMustBeAdmin = false; - } + } - public void perform() { + public void perform() { + Faction faction = fme.getFaction(); + if (faction != null && !faction.getId().equalsIgnoreCase("0") && !faction.getId().equalsIgnoreCase("none") && !faction.getId().equalsIgnoreCase("safezone") && !faction.getId().equalsIgnoreCase("warzone")) { + fme.setStealth(!fme.isStealthEnabled()); + fme.msg(fme.isStealthEnabled() ? TL.COMMAND_STEALTH_ENABLE : TL.COMMAND_STEALTH_DISABLE); + } else { + fme.msg(TL.COMMAND_STEALTH_MUSTBEMEMBER); + } + } - Faction faction = fme.getFaction(); - if (faction != null && !faction.getId().equalsIgnoreCase("0") && !faction.getId().equalsIgnoreCase("none") && !faction.getId().equalsIgnoreCase("safezone") && !faction.getId().equalsIgnoreCase("warzone")) { - fme.setStealth(!fme.isStealthEnabled()); - fme.msg(fme.isStealthEnabled() ? TL.COMMAND_STEALTH_ENABLE : TL.COMMAND_STEALTH_DISABLE); - } else { - fme.msg(TL.COMMAND_STEALTH_MUSTBEMEMBER); - } - } - - public TL getUsageTranslation() { - return TL.COMMAND_STEALTH_DESCRIPTION; - } + public TL getUsageTranslation() { + return TL.COMMAND_STEALTH_DESCRIPTION; + } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdStrike.java b/src/main/java/com/massivecraft/factions/cmd/CmdStrike.java index a512f13b..25677b87 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdStrike.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdStrike.java @@ -1,7 +1,7 @@ package com.massivecraft.factions.cmd; -import com.massivecraft.factions.*; -import com.massivecraft.factions.struct.Permission; +import com.massivecraft.factions.Faction; +import com.massivecraft.factions.Factions; import com.massivecraft.factions.zcore.util.TL; public class CmdStrike extends FCommand { diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdStuck.java b/src/main/java/com/massivecraft/factions/cmd/CmdStuck.java index 03a77e30..874b86f6 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdStuck.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdStuck.java @@ -14,98 +14,98 @@ import org.bukkit.scheduler.BukkitRunnable; public class CmdStuck extends FCommand { - public CmdStuck() { - super(); + public CmdStuck() { + super(); - this.aliases.add("stuck"); - this.aliases.add("halp!"); // halp!c: + this.aliases.add("stuck"); + this.aliases.add("halp!"); // halp!c: - this.permission = Permission.STUCK.node; - this.disableOnLock = true; + this.permission = Permission.STUCK.node; + this.disableOnLock = true; - senderMustBePlayer = false; - senderMustBeMember = false; - senderMustBeModerator = false; - senderMustBeAdmin = false; + senderMustBePlayer = false; + senderMustBeMember = false; + senderMustBeModerator = false; + senderMustBeAdmin = false; - } + } - @Override - public void perform() { - final Player player = fme.getPlayer(); - final Location sentAt = player.getLocation(); - final FLocation chunk = fme.getLastStoodAt(); - final long delay = P.p.getConfig().getLong("hcf.stuck.delay", 30); - final int radius = P.p.getConfig().getInt("hcf.stuck.radius", 10); + @Override + public void perform() { + final Player player = fme.getPlayer(); + final Location sentAt = player.getLocation(); + final FLocation chunk = fme.getLastStoodAt(); + final long delay = P.p.getConfig().getLong("hcf.stuck.delay", 30); + final int radius = P.p.getConfig().getInt("hcf.stuck.radius", 10); - if (P.p.getStuckMap().containsKey(player.getUniqueId())) { - long wait = P.p.getTimers().get(player.getUniqueId()) - System.currentTimeMillis(); - String time = DurationFormatUtils.formatDuration(wait, TL.COMMAND_STUCK_TIMEFORMAT.toString(), true); - msg(TL.COMMAND_STUCK_EXISTS, time); - } else { + if (P.p.getStuckMap().containsKey(player.getUniqueId())) { + long wait = P.p.getTimers().get(player.getUniqueId()) - System.currentTimeMillis(); + String time = DurationFormatUtils.formatDuration(wait, TL.COMMAND_STUCK_TIMEFORMAT.toString(), true); + msg(TL.COMMAND_STUCK_EXISTS, time); + } else { - // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay - if (!payForCommand(Conf.econCostStuck, TL.COMMAND_STUCK_TOSTUCK.format(fme.getName()), TL.COMMAND_STUCK_FORSTUCK.format(fme.getName()))) { - return; - } + // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay + if (!payForCommand(Conf.econCostStuck, TL.COMMAND_STUCK_TOSTUCK.format(fme.getName()), TL.COMMAND_STUCK_FORSTUCK.format(fme.getName()))) { + return; + } - final int id = Bukkit.getScheduler().runTaskLater(P.p, new BukkitRunnable() { + final int id = Bukkit.getScheduler().runTaskLater(P.p, new BukkitRunnable() { - @Override - public void run() { - if (!P.p.getStuckMap().containsKey(player.getUniqueId())) { - return; - } + @Override + public void run() { + if (!P.p.getStuckMap().containsKey(player.getUniqueId())) { + return; + } - // check for world difference or radius exceeding - final World world = chunk.getWorld(); - if (world.getUID() != player.getWorld().getUID() || sentAt.distance(player.getLocation()) > radius) { - msg(TL.COMMAND_STUCK_OUTSIDE.format(radius)); - P.p.getTimers().remove(player.getUniqueId()); - P.p.getStuckMap().remove(player.getUniqueId()); - return; - } + // check for world difference or radius exceeding + final World world = chunk.getWorld(); + if (world.getUID() != player.getWorld().getUID() || sentAt.distance(player.getLocation()) > radius) { + msg(TL.COMMAND_STUCK_OUTSIDE.format(radius)); + P.p.getTimers().remove(player.getUniqueId()); + P.p.getStuckMap().remove(player.getUniqueId()); + return; + } - final Board board = Board.getInstance(); - // spiral task to find nearest wilderness chunk - new SpiralTask(new FLocation(me), radius * 2) { + final Board board = Board.getInstance(); + // spiral task to find nearest wilderness chunk + new SpiralTask(new FLocation(me), radius * 2) { - @Override - public boolean work() { - FLocation chunk = currentFLocation(); - Faction faction = board.getFactionAt(chunk); - int buffer = P.p.getConfig().getInt("world-border.buffer", 0); - if (faction.isWilderness() && !chunk.isOutsideWorldBorder(buffer)) { - int cx = FLocation.chunkToBlock((int) chunk.getX()); - int cz = FLocation.chunkToBlock((int) chunk.getZ()); - int y = world.getHighestBlockYAt(cx, cz); - Location tp = new Location(world, cx, y, cz); - msg(TL.COMMAND_STUCK_TELEPORT, tp.getBlockX(), tp.getBlockY(), tp.getBlockZ()); - P.p.getTimers().remove(player.getUniqueId()); - P.p.getStuckMap().remove(player.getUniqueId()); - if (!Essentials.handleTeleport(player, tp)) { - player.teleport(tp); - P.p.debug("/f stuck used regular teleport, not essentials!"); - } - this.stop(); - return false; - } - return true; - } - }; - } - }, delay * 20).getTaskId(); + @Override + public boolean work() { + FLocation chunk = currentFLocation(); + Faction faction = board.getFactionAt(chunk); + int buffer = P.p.getConfig().getInt("world-border.buffer", 0); + if (faction.isWilderness() && !chunk.isOutsideWorldBorder(buffer)) { + int cx = FLocation.chunkToBlock((int) chunk.getX()); + int cz = FLocation.chunkToBlock((int) chunk.getZ()); + int y = world.getHighestBlockYAt(cx, cz); + Location tp = new Location(world, cx, y, cz); + msg(TL.COMMAND_STUCK_TELEPORT, tp.getBlockX(), tp.getBlockY(), tp.getBlockZ()); + P.p.getTimers().remove(player.getUniqueId()); + P.p.getStuckMap().remove(player.getUniqueId()); + if (!Essentials.handleTeleport(player, tp)) { + player.teleport(tp); + P.p.debug("/f stuck used regular teleport, not essentials!"); + } + this.stop(); + return false; + } + return true; + } + }; + } + }, delay * 20).getTaskId(); - P.p.getTimers().put(player.getUniqueId(), System.currentTimeMillis() + (delay * 1000)); - long wait = P.p.getTimers().get(player.getUniqueId()) - System.currentTimeMillis(); - String time = DurationFormatUtils.formatDuration(wait, TL.COMMAND_STUCK_TIMEFORMAT.toString(), true); - msg(TL.COMMAND_STUCK_START, time); - P.p.getStuckMap().put(player.getUniqueId(), id); - } - } + P.p.getTimers().put(player.getUniqueId(), System.currentTimeMillis() + (delay * 1000)); + long wait = P.p.getTimers().get(player.getUniqueId()) - System.currentTimeMillis(); + String time = DurationFormatUtils.formatDuration(wait, TL.COMMAND_STUCK_TIMEFORMAT.toString(), true); + msg(TL.COMMAND_STUCK_START, time); + P.p.getStuckMap().put(player.getUniqueId(), id); + } + } - @Override - public TL getUsageTranslation() { - return TL.COMMAND_STUCK_DESCRIPTION; - } + @Override + public TL getUsageTranslation() { + return TL.COMMAND_STUCK_DESCRIPTION; + } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdTag.java b/src/main/java/com/massivecraft/factions/cmd/CmdTag.java index eb6dc8e0..c8da8382 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdTag.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdTag.java @@ -12,87 +12,87 @@ import java.util.ArrayList; public class CmdTag extends FCommand { - public CmdTag() { - this.aliases.add("tag"); - this.aliases.add("rename"); + public CmdTag() { + this.aliases.add("tag"); + this.aliases.add("rename"); - this.requiredArgs.add("faction tag"); - //this.optionalArgs.put("", ""); + this.requiredArgs.add("faction tag"); + //this.optionalArgs.put("", ""); - this.permission = Permission.TAG.node; - this.disableOnLock = true; - this.disableOnSpam = true; + this.permission = Permission.TAG.node; + this.disableOnLock = true; + this.disableOnSpam = true; - senderMustBePlayer = true; - senderMustBeMember = false; - senderMustBeModerator = true; - senderMustBeAdmin = false; + senderMustBePlayer = true; + senderMustBeMember = false; + senderMustBeModerator = true; + senderMustBeAdmin = false; - } + } - @Override - public void perform() { - String tag = this.argAsString(0); + @Override + public void perform() { + String tag = this.argAsString(0); - if (!fme.isCooldownEnded("tag")) { - fme.msg(TL.COMMAND_ONCOOOLDOWN, fme.getCooldown("tag")); - return; - } + if (!fme.isCooldownEnded("tag")) { + fme.msg(TL.COMMAND_ONCOOOLDOWN, fme.getCooldown("tag")); + return; + } - // TODO does not first test cover selfcase? - if (Factions.getInstance().isTagTaken(tag) && !MiscUtil.getComparisonString(tag).equals(myFaction.getComparisonTag())) { - msg(TL.COMMAND_TAG_TAKEN); - return; - } + // TODO does not first test cover selfcase? + if (Factions.getInstance().isTagTaken(tag) && !MiscUtil.getComparisonString(tag).equals(myFaction.getComparisonTag())) { + msg(TL.COMMAND_TAG_TAKEN); + return; + } - ArrayList errors = MiscUtil.validateTag(tag); - if (errors.size() > 0) { - sendMessage(errors); - return; - } + ArrayList errors = MiscUtil.validateTag(tag); + if (errors.size() > 0) { + sendMessage(errors); + return; + } - // if economy is enabled, they're not on the bypass list, and this command has a cost set, make sure they can pay - if (!canAffordCommand(Conf.econCostTag, TL.COMMAND_TAG_TOCHANGE.toString())) { - return; - } + // if economy is enabled, they're not on the bypass list, and this command has a cost set, make sure they can pay + if (!canAffordCommand(Conf.econCostTag, TL.COMMAND_TAG_TOCHANGE.toString())) { + return; + } - // trigger the faction rename event (cancellable) - FactionRenameEvent renameEvent = new FactionRenameEvent(fme, tag); - Bukkit.getServer().getPluginManager().callEvent(renameEvent); - if (renameEvent.isCancelled()) { - return; - } + // trigger the faction rename event (cancellable) + FactionRenameEvent renameEvent = new FactionRenameEvent(fme, tag); + Bukkit.getServer().getPluginManager().callEvent(renameEvent); + if (renameEvent.isCancelled()) { + return; + } - // then make 'em pay (if applicable) - if (!payForCommand(Conf.econCostTag, TL.COMMAND_TAG_TOCHANGE, TL.COMMAND_TAG_FORCHANGE)) { - return; - } + // then make 'em pay (if applicable) + if (!payForCommand(Conf.econCostTag, TL.COMMAND_TAG_TOCHANGE, TL.COMMAND_TAG_FORCHANGE)) { + return; + } - String oldtag = myFaction.getTag(); - myFaction.setTag(tag); + String oldtag = myFaction.getTag(); + myFaction.setTag(tag); - // Inform - for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers()) { - if (fplayer.getFactionId().equals(myFaction.getId())) { - fplayer.msg(TL.COMMAND_TAG_FACTION, fme.describeTo(myFaction, true), myFaction.getTag(myFaction)); - continue; - } + // Inform + for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers()) { + if (fplayer.getFactionId().equals(myFaction.getId())) { + fplayer.msg(TL.COMMAND_TAG_FACTION, fme.describeTo(myFaction, true), myFaction.getTag(myFaction)); + continue; + } - // Broadcast the tag change (if applicable) - if (Conf.broadcastTagChanges) { - Faction faction = fplayer.getFaction(); - fplayer.msg(TL.COMMAND_TAG_CHANGED, fme.getColorTo(faction) + oldtag, myFaction.getTag(faction)); - } - } - fme.setCooldown("tag", System.currentTimeMillis() + (P.p.getConfig().getInt("fcooldowns.f-tag") * 1000)); - FTeamWrapper.updatePrefixes(myFaction); - } + // Broadcast the tag change (if applicable) + if (Conf.broadcastTagChanges) { + Faction faction = fplayer.getFaction(); + fplayer.msg(TL.COMMAND_TAG_CHANGED, fme.getColorTo(faction) + oldtag, myFaction.getTag(faction)); + } + } + fme.setCooldown("tag", System.currentTimeMillis() + (P.p.getConfig().getInt("fcooldowns.f-tag") * 1000)); + FTeamWrapper.updatePrefixes(myFaction); + } - @Override - public TL getUsageTranslation() { - return TL.COMMAND_TAG_DESCRIPTION; - } + @Override + public TL getUsageTranslation() { + return TL.COMMAND_TAG_DESCRIPTION; + } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdTitle.java b/src/main/java/com/massivecraft/factions/cmd/CmdTitle.java index 925055c7..7202927c 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdTitle.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdTitle.java @@ -8,52 +8,52 @@ import com.massivecraft.factions.zcore.util.TextUtil; public class CmdTitle extends FCommand { - public CmdTitle() { - this.aliases.add("title"); + public CmdTitle() { + this.aliases.add("title"); - this.requiredArgs.add("player name"); - this.optionalArgs.put("title", ""); + this.requiredArgs.add("player name"); + this.optionalArgs.put("title", ""); - this.permission = Permission.TITLE.node; - this.disableOnLock = true; + this.permission = Permission.TITLE.node; + this.disableOnLock = true; - senderMustBePlayer = true; - senderMustBeMember = false; - senderMustBeModerator = true; - senderMustBeAdmin = false; + senderMustBePlayer = true; + senderMustBeMember = false; + senderMustBeModerator = true; + senderMustBeAdmin = false; - } + } - @Override - public void perform() { - FPlayer you = this.argAsBestFPlayerMatch(0); - if (you == null) { - return; - } + @Override + public void perform() { + FPlayer you = this.argAsBestFPlayerMatch(0); + if (you == null) { + return; + } - args.remove(0); - String title = TextUtil.implode(args, " "); - title = title.replaceAll(",", ""); + args.remove(0); + String title = TextUtil.implode(args, " "); + title = title.replaceAll(",", ""); - if (!canIAdministerYou(fme, you)) { - return; - } + if (!canIAdministerYou(fme, you)) { + return; + } - // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay - if (!payForCommand(Conf.econCostTitle, TL.COMMAND_TITLE_TOCHANGE, TL.COMMAND_TITLE_FORCHANGE)) { - return; - } + // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay + if (!payForCommand(Conf.econCostTitle, TL.COMMAND_TITLE_TOCHANGE, TL.COMMAND_TITLE_FORCHANGE)) { + return; + } - you.setTitle(sender, title); + you.setTitle(sender, title); - // Inform - myFaction.msg(TL.COMMAND_TITLE_CHANGED, fme.describeTo(myFaction, true), you.describeTo(myFaction, true)); - } + // Inform + myFaction.msg(TL.COMMAND_TITLE_CHANGED, fme.describeTo(myFaction, true), you.describeTo(myFaction, true)); + } - @Override - public TL getUsageTranslation() { - return TL.COMMAND_TITLE_DESCRIPTION; - } + @Override + public TL getUsageTranslation() { + return TL.COMMAND_TITLE_DESCRIPTION; + } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdToggleAllianceChat.java b/src/main/java/com/massivecraft/factions/cmd/CmdToggleAllianceChat.java index 3f4d45ba..95664b6d 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdToggleAllianceChat.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdToggleAllianceChat.java @@ -6,39 +6,39 @@ import com.massivecraft.factions.zcore.util.TL; public class CmdToggleAllianceChat extends FCommand { - public CmdToggleAllianceChat() { - super(); - this.aliases.add("tac"); - this.aliases.add("togglealliancechat"); - this.aliases.add("ac"); + public CmdToggleAllianceChat() { + super(); + this.aliases.add("tac"); + this.aliases.add("togglealliancechat"); + this.aliases.add("ac"); - this.disableOnLock = false; + this.disableOnLock = false; - this.permission = Permission.TOGGLE_ALLIANCE_CHAT.node; - this.disableOnLock = false; + this.permission = Permission.TOGGLE_ALLIANCE_CHAT.node; + this.disableOnLock = false; - senderMustBePlayer = true; - senderMustBeMember = true; - senderMustBeModerator = false; - senderMustBeAdmin = false; + senderMustBePlayer = true; + senderMustBeMember = true; + senderMustBeModerator = false; + senderMustBeAdmin = false; - } + } - @Override - public TL getUsageTranslation() { - return TL.COMMAND_TOGGLEALLIANCECHAT_DESCRIPTION; - } + @Override + public TL getUsageTranslation() { + return TL.COMMAND_TOGGLEALLIANCECHAT_DESCRIPTION; + } - @Override - public void perform() { - if (!Conf.factionOnlyChat) { - msg(TL.COMMAND_CHAT_DISABLED.toString()); - return; - } + @Override + public void perform() { + if (!Conf.factionOnlyChat) { + msg(TL.COMMAND_CHAT_DISABLED.toString()); + return; + } - boolean ignoring = fme.isIgnoreAllianceChat(); + boolean ignoring = fme.isIgnoreAllianceChat(); - msg(ignoring ? TL.COMMAND_TOGGLEALLIANCECHAT_UNIGNORE : TL.COMMAND_TOGGLEALLIANCECHAT_IGNORE); - fme.setIgnoreAllianceChat(!ignoring); - } + msg(ignoring ? TL.COMMAND_TOGGLEALLIANCECHAT_UNIGNORE : TL.COMMAND_TOGGLEALLIANCECHAT_IGNORE); + fme.setIgnoreAllianceChat(!ignoring); + } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdTop.java b/src/main/java/com/massivecraft/factions/cmd/CmdTop.java index 74adfdc1..1ae8c5bb 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdTop.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdTop.java @@ -12,168 +12,168 @@ import java.util.ArrayList; public class CmdTop extends FCommand { - public CmdTop() { - super(); - this.aliases.add("top"); - this.aliases.add("t"); + public CmdTop() { + super(); + this.aliases.add("top"); + this.aliases.add("t"); - //this.requiredArgs.add(""); - this.requiredArgs.add("criteria"); - this.optionalArgs.put("page", "1"); + //this.requiredArgs.add(""); + this.requiredArgs.add("criteria"); + this.optionalArgs.put("page", "1"); - this.permission = Permission.TOP.node; - this.disableOnLock = false; + this.permission = Permission.TOP.node; + this.disableOnLock = false; - senderMustBePlayer = false; - senderMustBeMember = false; - senderMustBeModerator = false; - senderMustBeAdmin = false; + senderMustBePlayer = false; + senderMustBeMember = false; + senderMustBeModerator = false; + senderMustBeAdmin = false; - } + } - @Override - public void perform() { - // Can sort by: money, members, online, allies, enemies, power, land. - // Get all Factions and remove non player ones. - ArrayList factionList = Factions.getInstance().getAllFactions(); - factionList.remove(Factions.getInstance().getWilderness()); - factionList.remove(Factions.getInstance().getSafeZone()); - factionList.remove(Factions.getInstance().getWarZone()); + @Override + public void perform() { + // Can sort by: money, members, online, allies, enemies, power, land. + // Get all Factions and remove non player ones. + ArrayList factionList = Factions.getInstance().getAllFactions(); + factionList.remove(Factions.getInstance().getWilderness()); + factionList.remove(Factions.getInstance().getSafeZone()); + factionList.remove(Factions.getInstance().getWarZone()); - String criteria = argAsString(0); + String criteria = argAsString(0); - // TODO: Better way to sort? - if (criteria.equalsIgnoreCase("members")) { - factionList.sort((f1, f2) -> { - int f1Size = f1.getFPlayers().size(); - int f2Size = f2.getFPlayers().size(); - if (f1Size < f2Size) { - return 1; - } else if (f1Size > f2Size) { - return -1; - } - return 0; - }); - } else if (criteria.equalsIgnoreCase("start")) { - factionList.sort((f1, f2) -> { - long f1start = f1.getFoundedDate(); - long f2start = f2.getFoundedDate(); - // flip signs because a smaller date is farther in the past - if (f1start > f2start) { - return 1; - } else if (f1start < f2start) { - return -1; - } - return 0; - }); - } else if (criteria.equalsIgnoreCase("power")) { - factionList.sort((f1, f2) -> { - int f1Size = f1.getPowerRounded(); - int f2Size = f2.getPowerRounded(); - if (f1Size < f2Size) { - return 1; - } else if (f1Size > f2Size) { - return -1; - } - return 0; - }); - } else if (criteria.equalsIgnoreCase("land")) { - factionList.sort((f1, f2) -> { - int f1Size = f1.getLandRounded(); - int f2Size = f2.getLandRounded(); - if (f1Size < f2Size) { - return 1; - } else if (f1Size > f2Size) { - return -1; - } - return 0; - }); - } else if (criteria.equalsIgnoreCase("online")) { - factionList.sort((f1, f2) -> { - int f1Size = f1.getFPlayersWhereOnline(true).size(); - int f2Size = f2.getFPlayersWhereOnline(true).size(); - if (f1Size < f2Size) { - return 1; - } else if (f1Size > f2Size) { - return -1; - } - return 0; - }); - } else if (criteria.equalsIgnoreCase("money") || criteria.equalsIgnoreCase("balance") || criteria.equalsIgnoreCase("bal")) { - factionList.sort((f1, f2) -> { - double f1Size = Econ.getBalance(f1.getAccountId()); - // Lets get the balance of /all/ the players in the Faction. - for (FPlayer fp : f1.getFPlayers()) { - f1Size = f1Size + Econ.getBalance(fp.getAccountId()); - } - double f2Size = Econ.getBalance(f2.getAccountId()); - for (FPlayer fp : f2.getFPlayers()) { - f2Size = f2Size + Econ.getBalance(fp.getAccountId()); - } - if (f1Size < f2Size) { - return 1; - } else if (f1Size > f2Size) { - return -1; - } - return 0; - }); - } else { - msg(TL.COMMAND_TOP_INVALID, criteria); - return; - } + // TODO: Better way to sort? + if (criteria.equalsIgnoreCase("members")) { + factionList.sort((f1, f2) -> { + int f1Size = f1.getFPlayers().size(); + int f2Size = f2.getFPlayers().size(); + if (f1Size < f2Size) { + return 1; + } else if (f1Size > f2Size) { + return -1; + } + return 0; + }); + } else if (criteria.equalsIgnoreCase("start")) { + factionList.sort((f1, f2) -> { + long f1start = f1.getFoundedDate(); + long f2start = f2.getFoundedDate(); + // flip signs because a smaller date is farther in the past + if (f1start > f2start) { + return 1; + } else if (f1start < f2start) { + return -1; + } + return 0; + }); + } else if (criteria.equalsIgnoreCase("power")) { + factionList.sort((f1, f2) -> { + int f1Size = f1.getPowerRounded(); + int f2Size = f2.getPowerRounded(); + if (f1Size < f2Size) { + return 1; + } else if (f1Size > f2Size) { + return -1; + } + return 0; + }); + } else if (criteria.equalsIgnoreCase("land")) { + factionList.sort((f1, f2) -> { + int f1Size = f1.getLandRounded(); + int f2Size = f2.getLandRounded(); + if (f1Size < f2Size) { + return 1; + } else if (f1Size > f2Size) { + return -1; + } + return 0; + }); + } else if (criteria.equalsIgnoreCase("online")) { + factionList.sort((f1, f2) -> { + int f1Size = f1.getFPlayersWhereOnline(true).size(); + int f2Size = f2.getFPlayersWhereOnline(true).size(); + if (f1Size < f2Size) { + return 1; + } else if (f1Size > f2Size) { + return -1; + } + return 0; + }); + } else if (criteria.equalsIgnoreCase("money") || criteria.equalsIgnoreCase("balance") || criteria.equalsIgnoreCase("bal")) { + factionList.sort((f1, f2) -> { + double f1Size = Econ.getBalance(f1.getAccountId()); + // Lets get the balance of /all/ the players in the Faction. + for (FPlayer fp : f1.getFPlayers()) { + f1Size = f1Size + Econ.getBalance(fp.getAccountId()); + } + double f2Size = Econ.getBalance(f2.getAccountId()); + for (FPlayer fp : f2.getFPlayers()) { + f2Size = f2Size + Econ.getBalance(fp.getAccountId()); + } + if (f1Size < f2Size) { + return 1; + } else if (f1Size > f2Size) { + return -1; + } + return 0; + }); + } else { + msg(TL.COMMAND_TOP_INVALID, criteria); + return; + } - ArrayList lines = new ArrayList<>(); + ArrayList lines = new ArrayList<>(); - final int pageheight = 9; - int pagenumber = this.argAsInt(1, 1); - int pagecount = (factionList.size() / pageheight) + 1; - if (pagenumber > pagecount) { - pagenumber = pagecount; - } else if (pagenumber < 1) { - pagenumber = 1; - } - int start = (pagenumber - 1) * pageheight; - int end = start + pageheight; - if (end > factionList.size()) { - end = factionList.size(); - } + final int pageheight = 9; + int pagenumber = this.argAsInt(1, 1); + int pagecount = (factionList.size() / pageheight) + 1; + if (pagenumber > pagecount) { + pagenumber = pagecount; + } else if (pagenumber < 1) { + pagenumber = 1; + } + int start = (pagenumber - 1) * pageheight; + int end = start + pageheight; + if (end > factionList.size()) { + end = factionList.size(); + } - lines.add(TL.COMMAND_TOP_TOP.format(criteria.toUpperCase(), pagenumber, pagecount)); + lines.add(TL.COMMAND_TOP_TOP.format(criteria.toUpperCase(), pagenumber, pagecount)); - int rank = 1; - for (Faction faction : factionList.subList(start, end)) { - // Get the relation color if player is executing this. - String fac = sender instanceof Player ? faction.getRelationTo(fme).getColor() + faction.getTag() : faction.getTag(); - lines.add(TL.COMMAND_TOP_LINE.format(rank, fac, getValue(faction, criteria))); - rank++; - } + int rank = 1; + for (Faction faction : factionList.subList(start, end)) { + // Get the relation color if player is executing this. + String fac = sender instanceof Player ? faction.getRelationTo(fme).getColor() + faction.getTag() : faction.getTag(); + lines.add(TL.COMMAND_TOP_LINE.format(rank, fac, getValue(faction, criteria))); + rank++; + } - sendMessage(lines); - } + sendMessage(lines); + } - private String getValue(Faction faction, String criteria) { - if (criteria.equalsIgnoreCase("online")) { - return String.valueOf(faction.getFPlayersWhereOnline(true).size()); - } else if (criteria.equalsIgnoreCase("start")) { - return TL.sdf.format(faction.getFoundedDate()); - } else if (criteria.equalsIgnoreCase("members")) { - return String.valueOf(faction.getFPlayers().size()); - } else if (criteria.equalsIgnoreCase("land")) { - return String.valueOf(faction.getLandRounded()); - } else if (criteria.equalsIgnoreCase("power")) { - return String.valueOf(faction.getPowerRounded()); - } else { // Last one is balance, and it has 3 different things it could be. - double balance = Econ.getBalance(faction.getAccountId()); - for (FPlayer fp : faction.getFPlayers()) { - balance = Math.round(balance + Econ.getBalance(fp.getAccountId())); - } - return String.valueOf(balance); - } - } + private String getValue(Faction faction, String criteria) { + if (criteria.equalsIgnoreCase("online")) { + return String.valueOf(faction.getFPlayersWhereOnline(true).size()); + } else if (criteria.equalsIgnoreCase("start")) { + return TL.sdf.format(faction.getFoundedDate()); + } else if (criteria.equalsIgnoreCase("members")) { + return String.valueOf(faction.getFPlayers().size()); + } else if (criteria.equalsIgnoreCase("land")) { + return String.valueOf(faction.getLandRounded()); + } else if (criteria.equalsIgnoreCase("power")) { + return String.valueOf(faction.getPowerRounded()); + } else { // Last one is balance, and it has 3 different things it could be. + double balance = Econ.getBalance(faction.getAccountId()); + for (FPlayer fp : faction.getFPlayers()) { + balance = Math.round(balance + Econ.getBalance(fp.getAccountId())); + } + return String.valueOf(balance); + } + } - @Override - public TL getUsageTranslation() { - return TL.COMMAND_TOP_DESCRIPTION; - } + @Override + public TL getUsageTranslation() { + return TL.COMMAND_TOP_DESCRIPTION; + } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdTpBanner.java b/src/main/java/com/massivecraft/factions/cmd/CmdTpBanner.java index b7401da5..0e6c739f 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdTpBanner.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdTpBanner.java @@ -7,39 +7,39 @@ import com.massivecraft.factions.util.WarmUpUtil; import com.massivecraft.factions.zcore.util.TL; public class CmdTpBanner extends FCommand { - public CmdTpBanner() { - super(); + public CmdTpBanner() { + super(); - this.aliases.add("tpbanner"); + this.aliases.add("tpbanner"); - this.permission = Permission.TPBANNER.node; - this.disableOnLock = true; + this.permission = Permission.TPBANNER.node; + this.disableOnLock = true; - senderMustBePlayer = true; - senderMustBeMember = true; - senderMustBeModerator = false; - senderMustBeColeader = false; - senderMustBeAdmin = false; + senderMustBePlayer = true; + senderMustBeMember = true; + senderMustBeModerator = false; + senderMustBeColeader = false; + senderMustBeAdmin = false; - } + } - @Override - public void perform() { - if (!P.p.getConfig().getBoolean("fbanners.Enabled")) { - return; - } + @Override + public void perform() { + if (!P.p.getConfig().getBoolean("fbanners.Enabled")) { + return; + } - if (FactionsBlockListener.bannerLocations.containsKey(fme.getTag())) { - fme.msg(TL.COMMAND_TPBANNER_SUCCESS); - this.doWarmUp(WarmUpUtil.Warmup.BANNER, TL.WARMUPS_NOTIFY_TELEPORT, "Banner", () -> me.teleport(FactionsBlockListener.bannerLocations.get(fme.getTag())), this.p.getConfig().getLong("warmups.f-banner", 0)); - } else { - fme.msg(TL.COMMAND_TPBANNER_NOTSET); - } + if (FactionsBlockListener.bannerLocations.containsKey(fme.getTag())) { + fme.msg(TL.COMMAND_TPBANNER_SUCCESS); + this.doWarmUp(WarmUpUtil.Warmup.BANNER, TL.WARMUPS_NOTIFY_TELEPORT, "Banner", () -> me.teleport(FactionsBlockListener.bannerLocations.get(fme.getTag())), this.p.getConfig().getLong("warmups.f-banner", 0)); + } else { + fme.msg(TL.COMMAND_TPBANNER_NOTSET); + } - } + } - @Override - public TL getUsageTranslation() { - return TL.COMMAND_TPBANNER_DESCRIPTION; - } + @Override + public TL getUsageTranslation() { + return TL.COMMAND_TPBANNER_DESCRIPTION; + } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdUnban.java b/src/main/java/com/massivecraft/factions/cmd/CmdUnban.java index 26ac45db..86ba4be7 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdUnban.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdUnban.java @@ -9,51 +9,51 @@ import com.massivecraft.factions.zcore.util.TL; public class CmdUnban extends FCommand { - public CmdUnban() { - super(); - this.aliases.add("unban"); + public CmdUnban() { + super(); + this.aliases.add("unban"); - this.requiredArgs.add("target"); + this.requiredArgs.add("target"); - this.permission = Permission.BAN.node; - this.disableOnLock = true; + this.permission = Permission.BAN.node; + this.disableOnLock = true; - senderMustBePlayer = true; - senderMustBeMember = false; - senderMustBeModerator = false; + senderMustBePlayer = true; + senderMustBeMember = false; + senderMustBeModerator = false; - senderMustBeAdmin = false; - } + senderMustBeAdmin = false; + } - @Override - public void perform() { - if (!fme.isAdminBypassing()) { - Access access = myFaction.getAccess(fme, PermissableAction.BAN); - if (access != Access.ALLOW && fme.getRole() != Role.LEADER && !Permission.BAN.has(sender, true)) { - fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "manage bans"); - return; - } - } + @Override + public void perform() { + if (!fme.isAdminBypassing()) { + Access access = myFaction.getAccess(fme, PermissableAction.BAN); + if (access != Access.ALLOW && fme.getRole() != Role.LEADER && !Permission.BAN.has(sender, true)) { + fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "manage bans"); + return; + } + } - // Good on permission checks. Now lets just ban the player. - FPlayer target = argAsFPlayer(0); - if (target == null) { - return; // the above method sends a message if fails to find someone. - } + // Good on permission checks. Now lets just ban the player. + FPlayer target = argAsFPlayer(0); + if (target == null) { + return; // the above method sends a message if fails to find someone. + } - if (!myFaction.isBanned(target)) { - fme.msg(TL.COMMAND_UNBAN_NOTBANNED, target.getName()); - return; - } + if (!myFaction.isBanned(target)) { + fme.msg(TL.COMMAND_UNBAN_NOTBANNED, target.getName()); + return; + } - myFaction.unban(target); + myFaction.unban(target); - myFaction.msg(TL.COMMAND_UNBAN_UNBANNED, fme.getName(), target.getName()); - target.msg(TL.COMMAND_UNBAN_TARGET, myFaction.getTag(target)); - } + myFaction.msg(TL.COMMAND_UNBAN_UNBANNED, fme.getName(), target.getName()); + target.msg(TL.COMMAND_UNBAN_TARGET, myFaction.getTag(target)); + } - @Override - public TL getUsageTranslation() { - return TL.COMMAND_UNBAN_DESCRIPTION; - } + @Override + public TL getUsageTranslation() { + return TL.COMMAND_UNBAN_DESCRIPTION; + } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdUpgrades.java b/src/main/java/com/massivecraft/factions/cmd/CmdUpgrades.java index 5387856c..70ae131d 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdUpgrades.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdUpgrades.java @@ -6,36 +6,36 @@ import com.massivecraft.factions.zcore.fupgrades.FUpgradesGUI; import com.massivecraft.factions.zcore.util.TL; public class CmdUpgrades extends FCommand { - public CmdUpgrades() { - super(); - this.aliases.add("upgrades"); - this.aliases.add("upgrade"); + public CmdUpgrades() { + super(); + this.aliases.add("upgrades"); + this.aliases.add("upgrade"); - //this.requiredArgs.add(""); - this.optionalArgs.put("mobs/crops/exp/power", ""); + //this.requiredArgs.add(""); + this.optionalArgs.put("mobs/crops/exp/power", ""); - this.permission = Permission.UPGRADES.node; - this.disableOnLock = true; + this.permission = Permission.UPGRADES.node; + this.disableOnLock = true; - senderMustBePlayer = true; - senderMustBeMember = true; - senderMustBeModerator = false; - senderMustBeAdmin = false; + senderMustBePlayer = true; + senderMustBeMember = true; + senderMustBeModerator = false; + senderMustBeAdmin = false; - } + } - @Override - public void perform() { - if (!P.p.getConfig().getBoolean("fupgrades.Enabled")) { - fme.sendMessage("This command is disabled!"); - return; - } - new FUpgradesGUI().openMainMenu(fme); - } + @Override + public void perform() { + if (!P.p.getConfig().getBoolean("fupgrades.Enabled")) { + fme.sendMessage("This command is disabled!"); + return; + } + new FUpgradesGUI().openMainMenu(fme); + } - @Override - public TL getUsageTranslation() { - return TL.COMMAND_UPGRADES_DESCRIPTION; - } + @Override + public TL getUsageTranslation() { + return TL.COMMAND_UPGRADES_DESCRIPTION; + } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdVault.java b/src/main/java/com/massivecraft/factions/cmd/CmdVault.java index e4a6a7d4..ba5cf284 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdVault.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdVault.java @@ -14,66 +14,66 @@ import org.bukkit.inventory.Inventory; public class CmdVault extends FCommand { - public CmdVault() { - this.aliases.add("vault"); + public CmdVault() { + this.aliases.add("vault"); - //this.requiredArgs.add(""); + //this.requiredArgs.add(""); - this.permission = Permission.VAULT.node; - this.disableOnLock = false; + this.permission = Permission.VAULT.node; + this.disableOnLock = false; - senderMustBePlayer = true; - senderMustBeMember = true; - senderMustBeModerator = false; - senderMustBeAdmin = false; + senderMustBePlayer = true; + senderMustBeMember = true; + senderMustBeModerator = false; + senderMustBeAdmin = false; - } + } - @Override - public void perform() { + @Override + public void perform() { - if (!P.p.getConfig().getBoolean("fvault.Enabled")) { - fme.sendMessage("This command is disabled!"); - return; - } - Access access = fme.getFaction().getAccess(fme, PermissableAction.VAULT); - if (access.equals(Access.DENY)) { - fme.msg(TL.GENERIC_NOPERMISSION, "vault"); - return; - } + if (!P.p.getConfig().getBoolean("fvault.Enabled")) { + fme.sendMessage("This command is disabled!"); + return; + } + Access access = fme.getFaction().getAccess(fme, PermissableAction.VAULT); + if (access.equals(Access.DENY)) { + fme.msg(TL.GENERIC_NOPERMISSION, "vault"); + return; + } - if (fme.isInVault()) { - me.closeInventory(); - return; - } - fme.setInVault(true); - Location vaultLocation = fme.getFaction().getVault(); - if (vaultLocation == null) { - fme.msg(TL.COMMAND_VAULT_INVALID); - return; - } - FLocation vaultFLocation = new FLocation(vaultLocation); - if (Board.getInstance().getFactionAt(vaultFLocation) != fme.getFaction()) { - fme.getFaction().setVault(null); - fme.msg(TL.COMMAND_VAULT_INVALID); - return; - } - if (vaultLocation.getBlock().getType() != Material.CHEST) { - fme.getFaction().setVault(null); - fme.msg(TL.COMMAND_VAULT_INVALID); - return; - } - Chest chest = (Chest) vaultLocation.getBlock().getState(); - Inventory chestInv = chest.getBlockInventory(); - fme.msg(TL.COMMAND_VAULT_OPENING); - me.openInventory(chestInv); + if (fme.isInVault()) { + me.closeInventory(); + return; + } + fme.setInVault(true); + Location vaultLocation = fme.getFaction().getVault(); + if (vaultLocation == null) { + fme.msg(TL.COMMAND_VAULT_INVALID); + return; + } + FLocation vaultFLocation = new FLocation(vaultLocation); + if (Board.getInstance().getFactionAt(vaultFLocation) != fme.getFaction()) { + fme.getFaction().setVault(null); + fme.msg(TL.COMMAND_VAULT_INVALID); + return; + } + if (vaultLocation.getBlock().getType() != Material.CHEST) { + fme.getFaction().setVault(null); + fme.msg(TL.COMMAND_VAULT_INVALID); + return; + } + Chest chest = (Chest) vaultLocation.getBlock().getState(); + Inventory chestInv = chest.getBlockInventory(); + fme.msg(TL.COMMAND_VAULT_OPENING); + me.openInventory(chestInv); - } + } - @Override - public TL getUsageTranslation() { - return TL.COMMAND_VAULT_DESCRIPTION; - } + @Override + public TL getUsageTranslation() { + return TL.COMMAND_VAULT_DESCRIPTION; + } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdVersion.java b/src/main/java/com/massivecraft/factions/cmd/CmdVersion.java index 570638b4..376ddd66 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdVersion.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdVersion.java @@ -7,30 +7,30 @@ import com.massivecraft.factions.zcore.util.TL; public class CmdVersion extends FCommand { - public CmdVersion() { - this.aliases.add("version"); - this.aliases.add("ver"); + public CmdVersion() { + this.aliases.add("version"); + this.aliases.add("ver"); - //this.requiredArgs.add(""); - //this.optionalArgs.put("", ""); + //this.requiredArgs.add(""); + //this.optionalArgs.put("", ""); - this.permission = Permission.VERSION.node; - this.disableOnLock = false; + this.permission = Permission.VERSION.node; + this.disableOnLock = false; - senderMustBePlayer = false; - senderMustBeMember = false; - senderMustBeModerator = false; - senderMustBeAdmin = false; - } + senderMustBePlayer = false; + senderMustBeMember = false; + senderMustBeModerator = false; + senderMustBeAdmin = false; + } - @Override - public void perform() { - msg(TL.COMMAND_VERSION_NAME); // Did this so people can differentiate between P and FactionsUUID (( Requested Feature )) - msg(TL.COMMAND_VERSION_VERSION, P.p.getDescription().getFullName()); - } + @Override + public void perform() { + msg(TL.COMMAND_VERSION_NAME); // Did this so people can differentiate between P and FactionsUUID (( Requested Feature )) + msg(TL.COMMAND_VERSION_VERSION, P.p.getDescription().getFullName()); + } - @Override - public TL getUsageTranslation() { - return TL.COMMAND_VERSION_DESCRIPTION; - } + @Override + public TL getUsageTranslation() { + return TL.COMMAND_VERSION_DESCRIPTION; + } } diff --git a/src/main/java/com/massivecraft/factions/cmd/FCmdRoot.java b/src/main/java/com/massivecraft/factions/cmd/FCmdRoot.java index 2dd8c404..02b0f241 100644 --- a/src/main/java/com/massivecraft/factions/cmd/FCmdRoot.java +++ b/src/main/java/com/massivecraft/factions/cmd/FCmdRoot.java @@ -27,294 +27,299 @@ import java.util.logging.Level; public class FCmdRoot extends FCommand { - public CmdAdmin cmdAdmin = new CmdAdmin(); - public CmdAutoClaim cmdAutoClaim = new CmdAutoClaim(); - public CmdBoom cmdBoom = new CmdBoom(); - public CmdBypass cmdBypass = new CmdBypass(); - public CmdChat cmdChat = new CmdChat(); - public CmdChatSpy cmdChatSpy = new CmdChatSpy(); - public CmdClaim cmdClaim = new CmdClaim(); - public CmdConfig cmdConfig = new CmdConfig(); - public CmdCreate cmdCreate = new CmdCreate(); - public CmdDeinvite cmdDeinvite = new CmdDeinvite(); - public CmdDescription cmdDescription = new CmdDescription(); - public CmdDisband cmdDisband = new CmdDisband(); - public CmdFocus cmdFocus = new CmdFocus(); - public CmdGrace cmdGrace = new CmdGrace(); - public CmdHelp cmdHelp = new CmdHelp(); - public CmdHome cmdHome = new CmdHome(); - public CmdInvite cmdInvite = new CmdInvite(); - public CmdJoin cmdJoin = new CmdJoin(); - public CmdKick cmdKick = new CmdKick(); - public CmdLeave cmdLeave = new CmdLeave(); - public CmdList cmdList = new CmdList(); - public CmdLock cmdLock = new CmdLock(); - public CmdMap cmdMap = new CmdMap(); - public CmdMod cmdMod = new CmdMod(); - public CmdMoney cmdMoney = new CmdMoney(); - public CmdOpen cmdOpen = new CmdOpen(); - public CmdOwner cmdOwner = new CmdOwner(); - public CmdOwnerList cmdOwnerList = new CmdOwnerList(); - public CmdPeaceful cmdPeaceful = new CmdPeaceful(); - public CmdPermanent cmdPermanent = new CmdPermanent(); - public CmdPermanentPower cmdPermanentPower = new CmdPermanentPower(); - public CmdPowerBoost cmdPowerBoost = new CmdPowerBoost(); - public CmdPower cmdPower = new CmdPower(); - public CmdRelationAlly cmdRelationAlly = new CmdRelationAlly(); - public CmdRelationEnemy cmdRelationEnemy = new CmdRelationEnemy(); - public CmdRelationNeutral cmdRelationNeutral = new CmdRelationNeutral(); - public CmdRelationTruce cmdRelationTruce = new CmdRelationTruce(); - public CmdReload cmdReload = new CmdReload(); - public CmdSafeunclaimall cmdSafeunclaimall = new CmdSafeunclaimall(); - public CmdSaveAll cmdSaveAll = new CmdSaveAll(); - public CmdSethome cmdSethome = new CmdSethome(); - public CmdShow cmdShow = new CmdShow(); - public CmdStatus cmdStatus = new CmdStatus(); - public CmdStealth cmdStealth = new CmdStealth(); - public CmdStuck cmdStuck = new CmdStuck(); - public CmdTag cmdTag = new CmdTag(); - public CmdTitle cmdTitle = new CmdTitle(); - public CmdToggleAllianceChat cmdToggleAllianceChat = new CmdToggleAllianceChat(); - public CmdUnclaim cmdUnclaim = new CmdUnclaim(); - public CmdUnclaimall cmdUnclaimall = new CmdUnclaimall(); - public CmdVersion cmdVersion = new CmdVersion(); - public CmdWarunclaimall cmdWarunclaimall = new CmdWarunclaimall(); - public CmdSB cmdSB = new CmdSB(); - public CmdShowInvites cmdShowInvites = new CmdShowInvites(); - public CmdAnnounce cmdAnnounce = new CmdAnnounce(); - public CmdPaypalSet cmdPaypalSet = new CmdPaypalSet(); - public CmdPaypalSee cmdPaypalSee = new CmdPaypalSee(); - public CmdSeeChunk cmdSeeChunk = new CmdSeeChunk(); - public CmdConvert cmdConvert = new CmdConvert(); - public CmdFWarp cmdFWarp = new CmdFWarp(); - public CmdSetFWarp cmdSetFWarp = new CmdSetFWarp(); - public CmdDelFWarp cmdDelFWarp = new CmdDelFWarp(); - public CmdModifyPower cmdModifyPower = new CmdModifyPower(); - public CmdLogins cmdLogins = new CmdLogins(); - public CmdClaimLine cmdClaimLine = new CmdClaimLine(); - public CmdTop cmdTop = new CmdTop(); - public CmdAHome cmdAHome = new CmdAHome(); - public CmdPerm cmdPerm = new CmdPerm(); - public CmdPromote cmdPromote = new CmdPromote(); - public CmdDemote cmdDemote = new CmdDemote(); - public CmdSetDefaultRole cmdSetDefaultRole = new CmdSetDefaultRole(); - public CmdMapHeight cmdMapHeight = new CmdMapHeight(); - public CmdClaimAt cmdClaimAt = new CmdClaimAt(); - public CmdBan cmdban = new CmdBan(); - public CmdUnban cmdUnban = new CmdUnban(); - public CmdBanlist cmdbanlist = new CmdBanlist(); - public CmdRules cmdRules = new CmdRules(); - public CmdCheckpoint cmdCheckpoint = new CmdCheckpoint(); - public CmdTnt cmdTnt = new CmdTnt(); - public CmdNear cmdNear = new CmdNear(); - public CmdUpgrades cmdUpgrades = new CmdUpgrades(); - public CmdVault cmdVault = new CmdVault(); - public CmdGetVault cmdGetVault = new CmdGetVault(); - public CmdFly cmdFly = new CmdFly(); - public CmdColeader cmdColeader = new CmdColeader(); - public CmdBanner cmdBanner = new CmdBanner(); - public CmdTpBanner cmdTpBanner = new CmdTpBanner(); - public CmdKillHolograms cmdKillHolograms = new CmdKillHolograms(); - public CmdInspect cmdInspect = new CmdInspect(); - public CmdCoords cmdCoords = new CmdCoords(); - public CmdShowClaims cmdShowClaims = new CmdShowClaims(); - public CmdLowPower cmdLowPower = new CmdLowPower(); - public CmdTntFill cmdTntFill = new CmdTntFill(); - public CmdChest cmdChest = new CmdChest(); - public CmdSetBanner cmdSetBanner = new CmdSetBanner(); - public CmdStrike cmdStrike = new CmdStrike(); - public CmdStrikeSet cmdStrikeSet = new CmdStrikeSet(); - public CmdAlts cmdAlts = new CmdAlts(); - public CmdSpam cmdSpam = new CmdSpam(); - public CmdCorner cmdCorner = new CmdCorner(); - public CmdInventorySee cmdInventorySee = new CmdInventorySee(); - public CmdFGlobal cmdFGlobal = new CmdFGlobal(); - public CmdViewChest cmdViewChest = new CmdViewChest(); - public CmdPoints cmdPoints = new CmdPoints(); - public CmdLogout cmdLogout = new CmdLogout(); - public CmdNotifications cmdNotifications = new CmdNotifications(); - public CmdShop cmdShop = new CmdShop(); - public CmdMissions cmdMissions = new CmdMissions(); + public CmdAdmin cmdAdmin = new CmdAdmin(); + public CmdAutoClaim cmdAutoClaim = new CmdAutoClaim(); + public CmdBoom cmdBoom = new CmdBoom(); + public CmdBypass cmdBypass = new CmdBypass(); + public CmdChat cmdChat = new CmdChat(); + public CmdChatSpy cmdChatSpy = new CmdChatSpy(); + public CmdClaim cmdClaim = new CmdClaim(); + public CmdConfig cmdConfig = new CmdConfig(); + public CmdCreate cmdCreate = new CmdCreate(); + public CmdDeinvite cmdDeinvite = new CmdDeinvite(); + public CmdDescription cmdDescription = new CmdDescription(); + public CmdDisband cmdDisband = new CmdDisband(); + public CmdFocus cmdFocus = new CmdFocus(); + public CmdGrace cmdGrace = new CmdGrace(); + public CmdHelp cmdHelp = new CmdHelp(); + public CmdHome cmdHome = new CmdHome(); + public CmdInvite cmdInvite = new CmdInvite(); + public CmdJoin cmdJoin = new CmdJoin(); + public CmdKick cmdKick = new CmdKick(); + public CmdLeave cmdLeave = new CmdLeave(); + public CmdList cmdList = new CmdList(); + public CmdLock cmdLock = new CmdLock(); + public CmdMap cmdMap = new CmdMap(); + public CmdMod cmdMod = new CmdMod(); + public CmdMoney cmdMoney = new CmdMoney(); + public CmdOpen cmdOpen = new CmdOpen(); + public CmdOwner cmdOwner = new CmdOwner(); + public CmdOwnerList cmdOwnerList = new CmdOwnerList(); + public CmdPeaceful cmdPeaceful = new CmdPeaceful(); + public CmdPermanent cmdPermanent = new CmdPermanent(); + public CmdPermanentPower cmdPermanentPower = new CmdPermanentPower(); + public CmdPowerBoost cmdPowerBoost = new CmdPowerBoost(); + public CmdPower cmdPower = new CmdPower(); + public CmdRelationAlly cmdRelationAlly = new CmdRelationAlly(); + public CmdRelationEnemy cmdRelationEnemy = new CmdRelationEnemy(); + public CmdRelationNeutral cmdRelationNeutral = new CmdRelationNeutral(); + public CmdRelationTruce cmdRelationTruce = new CmdRelationTruce(); + public CmdReload cmdReload = new CmdReload(); + public CmdSafeunclaimall cmdSafeunclaimall = new CmdSafeunclaimall(); + public CmdSaveAll cmdSaveAll = new CmdSaveAll(); + public CmdSethome cmdSethome = new CmdSethome(); + public CmdShow cmdShow = new CmdShow(); + public CmdStatus cmdStatus = new CmdStatus(); + public CmdStealth cmdStealth = new CmdStealth(); + public CmdStuck cmdStuck = new CmdStuck(); + public CmdTag cmdTag = new CmdTag(); + public CmdTitle cmdTitle = new CmdTitle(); + public CmdToggleAllianceChat cmdToggleAllianceChat = new CmdToggleAllianceChat(); + public CmdUnclaim cmdUnclaim = new CmdUnclaim(); + public CmdUnclaimall cmdUnclaimall = new CmdUnclaimall(); + public CmdVersion cmdVersion = new CmdVersion(); + public CmdWarunclaimall cmdWarunclaimall = new CmdWarunclaimall(); + public CmdSB cmdSB = new CmdSB(); + public CmdShowInvites cmdShowInvites = new CmdShowInvites(); + public CmdAnnounce cmdAnnounce = new CmdAnnounce(); + public CmdPaypalSet cmdPaypalSet = new CmdPaypalSet(); + public CmdPaypalSee cmdPaypalSee = new CmdPaypalSee(); + public CmdSeeChunk cmdSeeChunk = new CmdSeeChunk(); + public CmdConvert cmdConvert = new CmdConvert(); + public CmdFWarp cmdFWarp = new CmdFWarp(); + public CmdSetFWarp cmdSetFWarp = new CmdSetFWarp(); + public CmdDelFWarp cmdDelFWarp = new CmdDelFWarp(); + public CmdModifyPower cmdModifyPower = new CmdModifyPower(); + public CmdLogins cmdLogins = new CmdLogins(); + public CmdClaimLine cmdClaimLine = new CmdClaimLine(); + public CmdTop cmdTop = new CmdTop(); + public CmdAHome cmdAHome = new CmdAHome(); + public CmdPerm cmdPerm = new CmdPerm(); + public CmdPromote cmdPromote = new CmdPromote(); + public CmdDemote cmdDemote = new CmdDemote(); + public CmdSetDefaultRole cmdSetDefaultRole = new CmdSetDefaultRole(); + public CmdMapHeight cmdMapHeight = new CmdMapHeight(); + public CmdClaimAt cmdClaimAt = new CmdClaimAt(); + public CmdBan cmdban = new CmdBan(); + public CmdUnban cmdUnban = new CmdUnban(); + public CmdBanlist cmdbanlist = new CmdBanlist(); + public CmdRules cmdRules = new CmdRules(); + public CmdCheckpoint cmdCheckpoint = new CmdCheckpoint(); + public CmdTnt cmdTnt = new CmdTnt(); + public CmdNear cmdNear = new CmdNear(); + public CmdUpgrades cmdUpgrades = new CmdUpgrades(); + public CmdVault cmdVault = new CmdVault(); + public CmdGetVault cmdGetVault = new CmdGetVault(); + public CmdFly cmdFly = new CmdFly(); + public CmdColeader cmdColeader = new CmdColeader(); + public CmdBanner cmdBanner = new CmdBanner(); + public CmdTpBanner cmdTpBanner = new CmdTpBanner(); + public CmdKillHolograms cmdKillHolograms = new CmdKillHolograms(); + public CmdInspect cmdInspect = new CmdInspect(); + public CmdCoords cmdCoords = new CmdCoords(); + public CmdShowClaims cmdShowClaims = new CmdShowClaims(); + public CmdLowPower cmdLowPower = new CmdLowPower(); + public CmdTntFill cmdTntFill = new CmdTntFill(); + public CmdChest cmdChest = new CmdChest(); + public CmdSetBanner cmdSetBanner = new CmdSetBanner(); + public CmdStrike cmdStrike = new CmdStrike(); + public CmdStrikeSet cmdStrikeSet = new CmdStrikeSet(); + public CmdAlts cmdAlts = new CmdAlts(); + public CmdSpam cmdSpam = new CmdSpam(); + public CmdCorner cmdCorner = new CmdCorner(); + public CmdInventorySee cmdInventorySee = new CmdInventorySee(); + public CmdFGlobal cmdFGlobal = new CmdFGlobal(); + public CmdViewChest cmdViewChest = new CmdViewChest(); + public CmdPoints cmdPoints = new CmdPoints(); + public CmdLogout cmdLogout = new CmdLogout(); + public CmdNotifications cmdNotifications = new CmdNotifications(); + public CmdShop cmdShop = new CmdShop(); + public CmdMissions cmdMissions = new CmdMissions(); + public CmdCheck cmdCheck = new CmdCheck(); - public FCmdRoot() { - super(); - this.aliases.addAll(Conf.baseCommandAliases); - this.aliases.removeAll(Collections.singletonList(null)); // remove any nulls from extra commas - this.allowNoSlashAccess = Conf.allowNoSlashCommand; + public FCmdRoot() { + super(); + this.aliases.addAll(Conf.baseCommandAliases); + this.aliases.removeAll(Collections.singletonList(null)); // remove any nulls from extra commas + this.allowNoSlashAccess = Conf.allowNoSlashCommand; - //this.requiredArgs.add(""); - //this.optionalArgs.put("","") + //this.requiredArgs.add(""); + //this.optionalArgs.put("","") - senderMustBePlayer = false; - senderMustBeMember = false; - senderMustBeModerator = false; - senderMustBeAdmin = false; + senderMustBePlayer = false; + senderMustBeMember = false; + senderMustBeModerator = false; + senderMustBeAdmin = false; - this.disableOnLock = false; + this.disableOnLock = false; - this.setHelpShort("The faction base command"); - this.helpLong.add(p.txt.parseTags("This command contains all faction stuff.")); + this.setHelpShort("The faction base command"); + this.helpLong.add(p.txt.parseTags("This command contains all faction stuff.")); - //this.subCommands.add(plugin.cmdHelp); + //this.subCommands.add(plugin.cmdHelp); - this.addSubCommand(this.cmdAdmin); - this.addSubCommand(this.cmdAutoClaim); - this.addSubCommand(this.cmdBoom); - this.addSubCommand(this.cmdBypass); - this.addSubCommand(this.cmdChat); - this.addSubCommand(this.cmdToggleAllianceChat); - this.addSubCommand(this.cmdChatSpy); - this.addSubCommand(this.cmdClaim); - this.addSubCommand(this.cmdConfig); - this.addSubCommand(this.cmdCreate); - this.addSubCommand(this.cmdDeinvite); - this.addSubCommand(this.cmdDescription); - this.addSubCommand(this.cmdDisband); - this.addSubCommand(this.cmdStrike); - this.addSubCommand(this.cmdHelp); - this.addSubCommand(this.cmdHome); - this.addSubCommand(this.cmdInvite); - this.addSubCommand(this.cmdJoin); - this.addSubCommand(this.cmdKick); - this.addSubCommand(this.cmdLeave); - this.addSubCommand(this.cmdList); - this.addSubCommand(this.cmdLock); - this.addSubCommand(this.cmdMap); - this.addSubCommand(this.cmdMod); - this.addSubCommand(this.cmdMoney); - this.addSubCommand(this.cmdNotifications); - this.addSubCommand(this.cmdOpen); - this.addSubCommand(this.cmdOwner); - this.addSubCommand(this.cmdOwnerList); - this.addSubCommand(this.cmdPeaceful); - this.addSubCommand(this.cmdPermanent); - this.addSubCommand(this.cmdPermanentPower); - this.addSubCommand(this.cmdPower); - this.addSubCommand(this.cmdPowerBoost); - this.addSubCommand(this.cmdRelationAlly); - this.addSubCommand(this.cmdRelationEnemy); - this.addSubCommand(this.cmdRelationNeutral); - this.addSubCommand(this.cmdRelationTruce); - this.addSubCommand(this.cmdReload); - this.addSubCommand(this.cmdSafeunclaimall); - this.addSubCommand(this.cmdSaveAll); - this.addSubCommand(this.cmdSethome); - this.addSubCommand(this.cmdShow); - this.addSubCommand(this.cmdStatus); - this.addSubCommand(this.cmdStealth); - this.addSubCommand(this.cmdStuck); - this.addSubCommand(this.cmdLogout); - this.addSubCommand(this.cmdTag); - this.addSubCommand(this.cmdTitle); - this.addSubCommand(this.cmdUnclaim); - this.addSubCommand(this.cmdUnclaimall); - this.addSubCommand(this.cmdVersion); - this.addSubCommand(this.cmdWarunclaimall); - this.addSubCommand(this.cmdSB); - this.addSubCommand(this.cmdShowInvites); - this.addSubCommand(this.cmdAnnounce); - this.addSubCommand(this.cmdSeeChunk); - this.addSubCommand(this.cmdConvert); - this.addSubCommand(this.cmdFWarp); - this.addSubCommand(this.cmdSetFWarp); - this.addSubCommand(this.cmdDelFWarp); - this.addSubCommand(this.cmdModifyPower); - this.addSubCommand(this.cmdLogins); - this.addSubCommand(this.cmdClaimLine); - this.addSubCommand(this.cmdAHome); - this.addSubCommand(this.cmdPerm); - this.addSubCommand(this.cmdPromote); - this.addSubCommand(this.cmdDemote); - this.addSubCommand(this.cmdSetDefaultRole); - this.addSubCommand(this.cmdMapHeight); - this.addSubCommand(this.cmdClaimAt); - this.addSubCommand(this.cmdban); - this.addSubCommand(this.cmdUnban); - this.addSubCommand(this.cmdbanlist); - this.addSubCommand(this.cmdRules); - this.addSubCommand(this.cmdCheckpoint); - this.addSubCommand(this.cmdTnt); - this.addSubCommand(this.cmdNear); - this.addSubCommand(this.cmdUpgrades); - this.addSubCommand(this.cmdVault); - this.addSubCommand(this.cmdGetVault); - this.addSubCommand(this.cmdColeader); - this.addSubCommand(this.cmdBanner); - this.addSubCommand(this.cmdTpBanner); - this.addSubCommand(this.cmdKillHolograms); - this.addSubCommand(this.cmdCoords); - this.addSubCommand(this.cmdShowClaims); - this.addSubCommand(this.cmdLowPower); - this.addSubCommand(this.cmdTntFill); - this.addSubCommand(this.cmdChest); - this.addSubCommand(this.cmdSetBanner); - this.addSubCommand(this.cmdStrikeSet); - this.addSubCommand(this.cmdSpam); - this.addSubCommand(this.cmdCorner); - this.addSubCommand(this.cmdFGlobal); - this.addSubCommand(this.cmdViewChest); + this.addSubCommand(this.cmdAdmin); + this.addSubCommand(this.cmdAutoClaim); + this.addSubCommand(this.cmdBoom); + this.addSubCommand(this.cmdBypass); + this.addSubCommand(this.cmdChat); + this.addSubCommand(this.cmdToggleAllianceChat); + this.addSubCommand(this.cmdChatSpy); + this.addSubCommand(this.cmdClaim); + this.addSubCommand(this.cmdConfig); + this.addSubCommand(this.cmdCreate); + this.addSubCommand(this.cmdDeinvite); + this.addSubCommand(this.cmdDescription); + this.addSubCommand(this.cmdDisband); + this.addSubCommand(this.cmdStrike); + this.addSubCommand(this.cmdHelp); + this.addSubCommand(this.cmdHome); + this.addSubCommand(this.cmdInvite); + this.addSubCommand(this.cmdJoin); + this.addSubCommand(this.cmdKick); + this.addSubCommand(this.cmdLeave); + this.addSubCommand(this.cmdList); + this.addSubCommand(this.cmdLock); + this.addSubCommand(this.cmdMap); + this.addSubCommand(this.cmdMod); + this.addSubCommand(this.cmdMoney); + this.addSubCommand(this.cmdNotifications); + this.addSubCommand(this.cmdOpen); + this.addSubCommand(this.cmdOwner); + this.addSubCommand(this.cmdOwnerList); + this.addSubCommand(this.cmdPeaceful); + this.addSubCommand(this.cmdPermanent); + this.addSubCommand(this.cmdPermanentPower); + this.addSubCommand(this.cmdPower); + this.addSubCommand(this.cmdPowerBoost); + this.addSubCommand(this.cmdRelationAlly); + this.addSubCommand(this.cmdRelationEnemy); + this.addSubCommand(this.cmdRelationNeutral); + this.addSubCommand(this.cmdRelationTruce); + this.addSubCommand(this.cmdReload); + this.addSubCommand(this.cmdSafeunclaimall); + this.addSubCommand(this.cmdSaveAll); + this.addSubCommand(this.cmdSethome); + this.addSubCommand(this.cmdShow); + this.addSubCommand(this.cmdStatus); + this.addSubCommand(this.cmdStealth); + this.addSubCommand(this.cmdStuck); + this.addSubCommand(this.cmdLogout); + this.addSubCommand(this.cmdTag); + this.addSubCommand(this.cmdTitle); + this.addSubCommand(this.cmdUnclaim); + this.addSubCommand(this.cmdUnclaimall); + this.addSubCommand(this.cmdVersion); + this.addSubCommand(this.cmdWarunclaimall); + this.addSubCommand(this.cmdSB); + this.addSubCommand(this.cmdShowInvites); + this.addSubCommand(this.cmdAnnounce); + this.addSubCommand(this.cmdSeeChunk); + this.addSubCommand(this.cmdConvert); + this.addSubCommand(this.cmdFWarp); + this.addSubCommand(this.cmdSetFWarp); + this.addSubCommand(this.cmdDelFWarp); + this.addSubCommand(this.cmdModifyPower); + this.addSubCommand(this.cmdLogins); + this.addSubCommand(this.cmdClaimLine); + this.addSubCommand(this.cmdAHome); + this.addSubCommand(this.cmdPerm); + this.addSubCommand(this.cmdPromote); + this.addSubCommand(this.cmdDemote); + this.addSubCommand(this.cmdSetDefaultRole); + this.addSubCommand(this.cmdMapHeight); + this.addSubCommand(this.cmdClaimAt); + this.addSubCommand(this.cmdban); + this.addSubCommand(this.cmdUnban); + this.addSubCommand(this.cmdbanlist); + this.addSubCommand(this.cmdRules); + this.addSubCommand(this.cmdCheckpoint); + this.addSubCommand(this.cmdTnt); + this.addSubCommand(this.cmdNear); + this.addSubCommand(this.cmdUpgrades); + this.addSubCommand(this.cmdVault); + this.addSubCommand(this.cmdGetVault); + this.addSubCommand(this.cmdColeader); + this.addSubCommand(this.cmdBanner); + this.addSubCommand(this.cmdTpBanner); + this.addSubCommand(this.cmdKillHolograms); + this.addSubCommand(this.cmdCoords); + this.addSubCommand(this.cmdShowClaims); + this.addSubCommand(this.cmdLowPower); + this.addSubCommand(this.cmdTntFill); + this.addSubCommand(this.cmdChest); + this.addSubCommand(this.cmdSetBanner); + this.addSubCommand(this.cmdStrikeSet); + this.addSubCommand(this.cmdSpam); + this.addSubCommand(this.cmdCorner); + this.addSubCommand(this.cmdFGlobal); + this.addSubCommand(this.cmdViewChest); - if(P.p.getConfig().getBoolean("Missions-Enabled")){ - this.addSubCommand(this.cmdMissions); - } + if (Conf.useCheckSystem) { + this.addSubCommand(this.cmdCheck); + } - if(P.p.getConfig().getBoolean("F-Shop.Enabled")){ - this.addSubCommand(this.cmdShop); - } + if (P.p.getConfig().getBoolean("Missions-Enabled")) { + this.addSubCommand(this.cmdMissions); + } - if (P.p.getConfig().getBoolean("f-inventory-see.Enabled")) { - this.addSubCommand(this.cmdInventorySee); - } + if (P.p.getConfig().getBoolean("F-Shop.Enabled")) { + this.addSubCommand(this.cmdShop); + } - if(P.p.getConfig().getBoolean("f-points.Enabled")){ - this.addSubCommand(this.cmdPoints); - } + if (P.p.getConfig().getBoolean("f-inventory-see.Enabled")) { + this.addSubCommand(this.cmdInventorySee); + } - if(P.p.getConfig().getBoolean("f-alts.Enabled")){ - this.addSubCommand(this.cmdAlts); - } + if (P.p.getConfig().getBoolean("f-points.Enabled")) { + this.addSubCommand(this.cmdPoints); + } - if (P.p.getConfig().getBoolean("f-grace.Enabled")) { - this.addSubCommand(this.cmdGrace); - } + if (P.p.getConfig().getBoolean("f-alts.Enabled")) { + this.addSubCommand(this.cmdAlts); + } + + if (P.p.getConfig().getBoolean("f-grace.Enabled")) { + this.addSubCommand(this.cmdGrace); + } - if (Bukkit.getServer().getPluginManager().getPlugin("CoreProtect") != null) { - P.p.log("Found CoreProtect, enabling Inspect"); - this.addSubCommand(this.cmdInspect); - } else { - P.p.log("CoreProtect not found, disabling Inspect"); - } - if (P.p.getConfig().getBoolean("ffocus.Enabled")) { - addSubCommand(this.cmdFocus); - } + if (Bukkit.getServer().getPluginManager().getPlugin("CoreProtect") != null) { + P.p.log("Found CoreProtect, enabling Inspect"); + this.addSubCommand(this.cmdInspect); + } else { + P.p.log("CoreProtect not found, disabling Inspect"); + } + if (P.p.getConfig().getBoolean("ffocus.Enabled")) { + addSubCommand(this.cmdFocus); + } - if (P.p.getConfig().getBoolean("enable-faction-flight", false)) { - this.addSubCommand(this.cmdFly); - } - if (Bukkit.getServer().getPluginManager().getPlugin("FactionsTop") != null || Bukkit.getServer().getPluginManager().getPlugin("SavageFTOP") != null) { - P.p.log(Level.INFO, "Found FactionsTop plugin. Disabling our own /f top command."); - } else { - P.p.log(Level.INFO, "Enabling FactionsTop command, this is a very basic /f top please get a dedicated /f top resource if you want land calculation etc."); - this.addSubCommand(this.cmdTop); - } - if (P.p.getConfig().getBoolean("fpaypal.Enabled")) { - this.addSubCommand(this.cmdPaypalSet); - this.addSubCommand(this.cmdPaypalSee); - } + if (P.p.getConfig().getBoolean("enable-faction-flight", false)) { + this.addSubCommand(this.cmdFly); + } + if (Bukkit.getServer().getPluginManager().getPlugin("FactionsTop") != null || Bukkit.getServer().getPluginManager().getPlugin("SavageFTOP") != null) { + P.p.log(Level.INFO, "Found FactionsTop plugin. Disabling our own /f top command."); + } else { + P.p.log(Level.INFO, "Enabling FactionsTop command, this is a very basic /f top please get a dedicated /f top resource if you want land calculation etc."); + this.addSubCommand(this.cmdTop); + } + if (P.p.getConfig().getBoolean("fpaypal.Enabled")) { + this.addSubCommand(this.cmdPaypalSet); + this.addSubCommand(this.cmdPaypalSee); + } - } + } - @Override - public void perform() { - this.commandChain.add(this); - this.cmdHelp.execute(this.sender, this.args, this.commandChain); - } + @Override + public void perform() { + this.commandChain.add(this); + this.cmdHelp.execute(this.sender, this.args, this.commandChain); + } - @Override - public TL getUsageTranslation() { - return TL.GENERIC_PLACEHOLDER; - } + @Override + public TL getUsageTranslation() { + return TL.GENERIC_PLACEHOLDER; + } } diff --git a/src/main/java/com/massivecraft/factions/cmd/FCommand.java b/src/main/java/com/massivecraft/factions/cmd/FCommand.java index 7ed31efa..ac716da8 100644 --- a/src/main/java/com/massivecraft/factions/cmd/FCommand.java +++ b/src/main/java/com/massivecraft/factions/cmd/FCommand.java @@ -15,337 +15,337 @@ import java.util.List; public abstract class FCommand extends MCommand

{ - public static final SimpleDateFormat sdf = new SimpleDateFormat(TL.DATE_FORMAT.toString()); - - public boolean disableOnLock; - public boolean disableOnSpam; - - public FPlayer fme; - public Faction myFaction; - public boolean senderMustBeMember; - public boolean senderMustBeModerator; - public boolean senderMustBeAdmin; - public boolean senderMustBeColeader; - - - public boolean isMoneyCommand; - - public FCommand() { - super(P.p); - - // Due to safety reasons it defaults to disable on lock. - disableOnLock = true; - disableOnSpam = false; - - // The money commands must be disabled if money should not be used. - isMoneyCommand = false; - - senderMustBeMember = false; - senderMustBeModerator = false; - senderMustBeColeader = false; - senderMustBeAdmin = false; - } - - @Override - 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 { - this.fme = null; - this.myFaction = null; - } - } - - @Override - public void execute(CommandSender sender, List args, List> commandChain) { - setCommandSender(sender); - super.execute(sender, args, commandChain); - } - - @Override - public boolean isEnabled() { - if (p.getLocked() && this.disableOnLock) { - msg("Factions was locked by an admin. Please try again later."); - return false; - } - - if(p.getSpam() && this.disableOnSpam){ - msg("Anti-Spam is currently enabled! Please try again later."); - return false; - } - - if (this.isMoneyCommand && !Conf.econEnabled) { - msg("Faction economy features are disabled on this server."); - return false; - } - - if (this.isMoneyCommand && !Conf.bankEnabled) { - msg("The faction bank system is disabled on this server."); - return false; - } - - return true; - } - - @Override - public boolean validSenderType(CommandSender sender, boolean informSenderIfNot) { - boolean superValid = super.validSenderType(sender, informSenderIfNot); - if (!superValid) { - return false; - } - - if (!(this.senderMustBeMember || this.senderMustBeModerator || this.senderMustBeAdmin || this.senderMustBeColeader)) { - return true; - } - - if (!(sender instanceof Player)) { - return false; - } - - if (!fme.hasFaction()) { - if (informSenderIfNot) { - sender.sendMessage(p.txt.parse(TL.ACTIONS_NOFACTION.toString())); - } - return false; - } - - - if (this.senderMustBeModerator && !fme.getRole().isAtLeast(Role.MODERATOR)) { - if (informSenderIfNot) { - sender.sendMessage(p.txt.parse(TL.ACTIONS_MUSTBE.toString().replace("{role}", "moderator").replace("{action}", this.getHelpShort()))); - } - return false; - } - - if (this.senderMustBeColeader && !fme.getRole().isAtLeast(Role.COLEADER)) { - if (informSenderIfNot) { - sender.sendMessage(p.txt.parse(TL.ACTIONS_MUSTBE.toString().replace("{role}", "coleader").replace("{action}", this.getHelpShort()))); - } - return false; - } - - if (this.senderMustBeAdmin && !fme.getRole().isAtLeast(Role.LEADER)) { - if (informSenderIfNot) { - sender.sendMessage(p.txt.parse(TL.ACTIONS_MUSTBE.toString().replace("{role}", "admin").replace("{action}", this.getHelpShort()))); - } - return false; - } - - - return true; - } - - // -------------------------------------------- // - // Assertions - // -------------------------------------------- // - - public boolean assertHasFaction() { - if (me == null) { - return true; - } - - if (!fme.hasFaction()) { - msg(TL.ACTIONS_NOFACTION); - return false; - } - return true; - } - - public boolean assertMinRole(Role role) { - if (me == null) { - return true; - } - - if (fme.getRole().value < role.value) { - msg(TL.ACTIONS_MUSTBE.toString().replace("{role}", role.nicename).replace("{action}", this.getHelpShort())); - return false; - } - return true; - } - - // -------------------------------------------- // - // Argument Readers - // -------------------------------------------- // - - // FPLAYER ====================== - public FPlayer strAsFPlayer(String name, FPlayer def, boolean msg) { - FPlayer ret = def; - - if (name != null) { - for (FPlayer fplayer : FPlayers.getInstance().getAllFPlayers()) { - if (fplayer.getName().equalsIgnoreCase(name)) { - ret = fplayer; - break; - } - } - } - - if (msg && ret == null) { - this.msg("No player \"%s\" could be found.", name); - } - - return ret; - } - - public FPlayer argAsFPlayer(int idx, FPlayer def, boolean msg) { - return this.strAsFPlayer(this.argAsString(idx), def, msg); - } - - public FPlayer argAsFPlayer(int idx, FPlayer def) { - return this.argAsFPlayer(idx, def, true); - } - - public FPlayer argAsFPlayer(int idx) { - return this.argAsFPlayer(idx, null); - } - - // BEST FPLAYER MATCH ====================== - public FPlayer strAsBestFPlayerMatch(String name, FPlayer def, boolean msg) { - return strAsFPlayer(name, def, msg); - } - - public FPlayer argAsBestFPlayerMatch(int idx, FPlayer def, boolean msg) { - return this.strAsBestFPlayerMatch(this.argAsString(idx), def, msg); - } - - public FPlayer argAsBestFPlayerMatch(int idx, FPlayer def) { - return this.argAsBestFPlayerMatch(idx, def, true); - } - - public FPlayer argAsBestFPlayerMatch(int idx) { - return this.argAsBestFPlayerMatch(idx, null); - } - - // FACTION ====================== - public Faction strAsFaction(String name, Faction def, boolean msg) { - Faction ret = def; - - if (name != null) { - // First we try an exact match - Faction faction = Factions.getInstance().getByTag(name); // Checks for faction name match. - - // Now lets try for warzone / safezone. Helpful for custom warzone / safezone names. - // Do this after we check for an exact match in case they rename the warzone / safezone - // and a player created faction took one of the names. - if (faction == null) { - if (name.equalsIgnoreCase("warzone")) { - faction = Factions.getInstance().getWarZone(); - } else if (name.equalsIgnoreCase("safezone")) { - faction = Factions.getInstance().getSafeZone(); - } - } - - // Next we match faction tags - if (faction == null) { - faction = Factions.getInstance().getBestTagMatch(name); - } - - // Next we match player names - if (faction == null) { - FPlayer fplayer = strAsFPlayer(name, null, false); - if (fplayer != null) { - faction = fplayer.getFaction(); - } - } - - if (faction != null) { - ret = faction; - } - } - - if (msg && ret == null) { - this.msg("The faction or player \"%s\" could not be found.", name); - } - - return ret; - } - - public Faction argAsFaction(int idx, Faction def, boolean msg) { - return this.strAsFaction(this.argAsString(idx), def, msg); - } - - public Faction argAsFaction(int idx, Faction def) { - return this.argAsFaction(idx, def, true); - } - - public Faction argAsFaction(int idx) { - return this.argAsFaction(idx, null); - } - - // -------------------------------------------- // - // Commonly used logic - // -------------------------------------------- // - - public boolean canIAdministerYou(FPlayer i, FPlayer you) { - if (!i.getFaction().equals(you.getFaction())) { - i.sendMessage(p.txt.parse("%s is not in the same faction as you.", you.describeTo(i, true))); - return false; - } - - if (i.getRole().value > you.getRole().value || i.getRole().equals(Role.LEADER)) { - return true; - } - - if (you.getRole().equals(Role.LEADER)) { - i.sendMessage(p.txt.parse(TL.ACTIONS_MUSTBE.toString().replace("{role}", "leader").replace("{action}", "do that"))); - - } else if ((you.getRole().equals(Role.COLEADER))) { - if (i == you) { - return true; - } else { - i.sendMessage(p.txt.parse(TL.ACTIONS_NOSAMEROLE.toString().replace("{role}", i.getRole().nicename))); - } - - } else if (i.getRole().equals(Role.MODERATOR)) { - if (i == you) { - return true; //Moderators can control themselves - } else { - i.sendMessage(p.txt.parse(TL.ACTIONS_NOSAMEROLE.toString().replace("{role}", i.getRole().nicename))); - } - } else { - i.sendMessage(p.txt.parse(TL.ACTIONS_MUSTBE.toString().replace("{role}", "moderator").replace("{action}", "do that"))); - } - - return false; - } - - // if economy is enabled and they're not on the bypass list, make 'em pay; returns true unless person can't afford the cost - public boolean payForCommand(double cost, String toDoThis, String forDoingThis) { - if (!Econ.shouldBeUsed() || this.fme == null || cost == 0.0 || fme.isAdminBypassing()) { - return true; - } - - if (Conf.bankEnabled && Conf.bankFactionPaysCosts && fme.hasFaction()) { - return Econ.modifyMoney(myFaction, -cost, toDoThis, forDoingThis); - } else { - return Econ.modifyMoney(fme, -cost, toDoThis, forDoingThis); - } - } - - public boolean payForCommand(double cost, TL toDoThis, TL forDoingThis) { - return payForCommand(cost, toDoThis.toString(), forDoingThis.toString()); - } - - // like above, but just make sure they can pay; returns true unless person can't afford the cost - public boolean canAffordCommand(double cost, String toDoThis) { - if (!Econ.shouldBeUsed() || this.fme == null || cost == 0.0 || fme.isAdminBypassing()) { - return true; - } - - if (Conf.bankEnabled && Conf.bankFactionPaysCosts && fme.hasFaction()) { - return Econ.hasAtLeast(myFaction, cost, toDoThis); - } else { - return Econ.hasAtLeast(fme, cost, toDoThis); - } - } - - public void doWarmUp(WarmUpUtil.Warmup warmup, TL translationKey, String action, Runnable runnable, long delay) { - this.doWarmUp(this.fme, warmup, translationKey, action, runnable, delay); - } - - public void doWarmUp(FPlayer player, WarmUpUtil.Warmup warmup, TL translationKey, String action, Runnable runnable, long delay) { - WarmUpUtil.process(player, warmup, translationKey, action, runnable, delay); - } + public static final SimpleDateFormat sdf = new SimpleDateFormat(TL.DATE_FORMAT.toString()); + + public boolean disableOnLock; + public boolean disableOnSpam; + + public FPlayer fme; + public Faction myFaction; + public boolean senderMustBeMember; + public boolean senderMustBeModerator; + public boolean senderMustBeAdmin; + public boolean senderMustBeColeader; + + + public boolean isMoneyCommand; + + public FCommand() { + super(P.p); + + // Due to safety reasons it defaults to disable on lock. + disableOnLock = true; + disableOnSpam = false; + + // The money commands must be disabled if money should not be used. + isMoneyCommand = false; + + senderMustBeMember = false; + senderMustBeModerator = false; + senderMustBeColeader = false; + senderMustBeAdmin = false; + } + + @Override + 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 { + this.fme = null; + this.myFaction = null; + } + } + + @Override + public void execute(CommandSender sender, List args, List> commandChain) { + setCommandSender(sender); + super.execute(sender, args, commandChain); + } + + @Override + public boolean isEnabled() { + if (p.getLocked() && this.disableOnLock) { + msg("Factions was locked by an admin. Please try again later."); + return false; + } + + if (p.getSpam() && this.disableOnSpam) { + msg("Anti-Spam is currently enabled! Please try again later."); + return false; + } + + if (this.isMoneyCommand && !Conf.econEnabled) { + msg("Faction economy features are disabled on this server."); + return false; + } + + if (this.isMoneyCommand && !Conf.bankEnabled) { + msg("The faction bank system is disabled on this server."); + return false; + } + + return true; + } + + @Override + public boolean validSenderType(CommandSender sender, boolean informSenderIfNot) { + boolean superValid = super.validSenderType(sender, informSenderIfNot); + if (!superValid) { + return false; + } + + if (!(this.senderMustBeMember || this.senderMustBeModerator || this.senderMustBeAdmin || this.senderMustBeColeader)) { + return true; + } + + if (!(sender instanceof Player)) { + return false; + } + + if (!fme.hasFaction()) { + if (informSenderIfNot) { + sender.sendMessage(p.txt.parse(TL.ACTIONS_NOFACTION.toString())); + } + return false; + } + + + if (this.senderMustBeModerator && !fme.getRole().isAtLeast(Role.MODERATOR)) { + if (informSenderIfNot) { + sender.sendMessage(p.txt.parse(TL.ACTIONS_MUSTBE.toString().replace("{role}", "moderator").replace("{action}", this.getHelpShort()))); + } + return false; + } + + if (this.senderMustBeColeader && !fme.getRole().isAtLeast(Role.COLEADER)) { + if (informSenderIfNot) { + sender.sendMessage(p.txt.parse(TL.ACTIONS_MUSTBE.toString().replace("{role}", "coleader").replace("{action}", this.getHelpShort()))); + } + return false; + } + + if (this.senderMustBeAdmin && !fme.getRole().isAtLeast(Role.LEADER)) { + if (informSenderIfNot) { + sender.sendMessage(p.txt.parse(TL.ACTIONS_MUSTBE.toString().replace("{role}", "admin").replace("{action}", this.getHelpShort()))); + } + return false; + } + + + return true; + } + + // -------------------------------------------- // + // Assertions + // -------------------------------------------- // + + public boolean assertHasFaction() { + if (me == null) { + return true; + } + + if (!fme.hasFaction()) { + msg(TL.ACTIONS_NOFACTION); + return false; + } + return true; + } + + public boolean assertMinRole(Role role) { + if (me == null) { + return true; + } + + if (fme.getRole().value < role.value) { + msg(TL.ACTIONS_MUSTBE.toString().replace("{role}", role.nicename).replace("{action}", this.getHelpShort())); + return false; + } + return true; + } + + // -------------------------------------------- // + // Argument Readers + // -------------------------------------------- // + + // FPLAYER ====================== + public FPlayer strAsFPlayer(String name, FPlayer def, boolean msg) { + FPlayer ret = def; + + if (name != null) { + for (FPlayer fplayer : FPlayers.getInstance().getAllFPlayers()) { + if (fplayer.getName().equalsIgnoreCase(name)) { + ret = fplayer; + break; + } + } + } + + if (msg && ret == null) { + this.msg("No player \"%s\" could be found.", name); + } + + return ret; + } + + public FPlayer argAsFPlayer(int idx, FPlayer def, boolean msg) { + return this.strAsFPlayer(this.argAsString(idx), def, msg); + } + + public FPlayer argAsFPlayer(int idx, FPlayer def) { + return this.argAsFPlayer(idx, def, true); + } + + public FPlayer argAsFPlayer(int idx) { + return this.argAsFPlayer(idx, null); + } + + // BEST FPLAYER MATCH ====================== + public FPlayer strAsBestFPlayerMatch(String name, FPlayer def, boolean msg) { + return strAsFPlayer(name, def, msg); + } + + public FPlayer argAsBestFPlayerMatch(int idx, FPlayer def, boolean msg) { + return this.strAsBestFPlayerMatch(this.argAsString(idx), def, msg); + } + + public FPlayer argAsBestFPlayerMatch(int idx, FPlayer def) { + return this.argAsBestFPlayerMatch(idx, def, true); + } + + public FPlayer argAsBestFPlayerMatch(int idx) { + return this.argAsBestFPlayerMatch(idx, null); + } + + // FACTION ====================== + public Faction strAsFaction(String name, Faction def, boolean msg) { + Faction ret = def; + + if (name != null) { + // First we try an exact match + Faction faction = Factions.getInstance().getByTag(name); // Checks for faction name match. + + // Now lets try for warzone / safezone. Helpful for custom warzone / safezone names. + // Do this after we check for an exact match in case they rename the warzone / safezone + // and a player created faction took one of the names. + if (faction == null) { + if (name.equalsIgnoreCase("warzone")) { + faction = Factions.getInstance().getWarZone(); + } else if (name.equalsIgnoreCase("safezone")) { + faction = Factions.getInstance().getSafeZone(); + } + } + + // Next we match faction tags + if (faction == null) { + faction = Factions.getInstance().getBestTagMatch(name); + } + + // Next we match player names + if (faction == null) { + FPlayer fplayer = strAsFPlayer(name, null, false); + if (fplayer != null) { + faction = fplayer.getFaction(); + } + } + + if (faction != null) { + ret = faction; + } + } + + if (msg && ret == null) { + this.msg("The faction or player \"%s\" could not be found.", name); + } + + return ret; + } + + public Faction argAsFaction(int idx, Faction def, boolean msg) { + return this.strAsFaction(this.argAsString(idx), def, msg); + } + + public Faction argAsFaction(int idx, Faction def) { + return this.argAsFaction(idx, def, true); + } + + public Faction argAsFaction(int idx) { + return this.argAsFaction(idx, null); + } + + // -------------------------------------------- // + // Commonly used logic + // -------------------------------------------- // + + public boolean canIAdministerYou(FPlayer i, FPlayer you) { + if (!i.getFaction().equals(you.getFaction())) { + i.sendMessage(p.txt.parse("%s is not in the same faction as you.", you.describeTo(i, true))); + return false; + } + + if (i.getRole().value > you.getRole().value || i.getRole().equals(Role.LEADER)) { + return true; + } + + if (you.getRole().equals(Role.LEADER)) { + i.sendMessage(p.txt.parse(TL.ACTIONS_MUSTBE.toString().replace("{role}", "leader").replace("{action}", "do that"))); + + } else if ((you.getRole().equals(Role.COLEADER))) { + if (i == you) { + return true; + } else { + i.sendMessage(p.txt.parse(TL.ACTIONS_NOSAMEROLE.toString().replace("{role}", i.getRole().nicename))); + } + + } else if (i.getRole().equals(Role.MODERATOR)) { + if (i == you) { + return true; //Moderators can control themselves + } else { + i.sendMessage(p.txt.parse(TL.ACTIONS_NOSAMEROLE.toString().replace("{role}", i.getRole().nicename))); + } + } else { + i.sendMessage(p.txt.parse(TL.ACTIONS_MUSTBE.toString().replace("{role}", "moderator").replace("{action}", "do that"))); + } + + return false; + } + + // if economy is enabled and they're not on the bypass list, make 'em pay; returns true unless person can't afford the cost + public boolean payForCommand(double cost, String toDoThis, String forDoingThis) { + if (!Econ.shouldBeUsed() || this.fme == null || cost == 0.0 || fme.isAdminBypassing()) { + return true; + } + + if (Conf.bankEnabled && Conf.bankFactionPaysCosts && fme.hasFaction()) { + return Econ.modifyMoney(myFaction, -cost, toDoThis, forDoingThis); + } else { + return Econ.modifyMoney(fme, -cost, toDoThis, forDoingThis); + } + } + + public boolean payForCommand(double cost, TL toDoThis, TL forDoingThis) { + return payForCommand(cost, toDoThis.toString(), forDoingThis.toString()); + } + + // like above, but just make sure they can pay; returns true unless person can't afford the cost + public boolean canAffordCommand(double cost, String toDoThis) { + if (!Econ.shouldBeUsed() || this.fme == null || cost == 0.0 || fme.isAdminBypassing()) { + return true; + } + + if (Conf.bankEnabled && Conf.bankFactionPaysCosts && fme.hasFaction()) { + return Econ.hasAtLeast(myFaction, cost, toDoThis); + } else { + return Econ.hasAtLeast(fme, cost, toDoThis); + } + } + + public void doWarmUp(WarmUpUtil.Warmup warmup, TL translationKey, String action, Runnable runnable, long delay) { + this.doWarmUp(this.fme, warmup, translationKey, action, runnable, delay); + } + + public void doWarmUp(FPlayer player, WarmUpUtil.Warmup warmup, TL translationKey, String action, Runnable runnable, long delay) { + WarmUpUtil.process(player, warmup, translationKey, action, runnable, delay); + } } diff --git a/src/main/java/com/massivecraft/factions/cmd/alts/CmdAlts.java b/src/main/java/com/massivecraft/factions/cmd/alts/CmdAlts.java index 71e7034c..537560b7 100644 --- a/src/main/java/com/massivecraft/factions/cmd/alts/CmdAlts.java +++ b/src/main/java/com/massivecraft/factions/cmd/alts/CmdAlts.java @@ -12,7 +12,7 @@ public class CmdAlts extends FCommand { public CmdAltsList cmdAltsList = new CmdAltsList(); - public CmdAlts(){ + public CmdAlts() { super(); this.aliases.add("alts"); diff --git a/src/main/java/com/massivecraft/factions/cmd/alts/CmdAltsList.java b/src/main/java/com/massivecraft/factions/cmd/alts/CmdAltsList.java index 799c9af2..a6d1a061 100644 --- a/src/main/java/com/massivecraft/factions/cmd/alts/CmdAltsList.java +++ b/src/main/java/com/massivecraft/factions/cmd/alts/CmdAltsList.java @@ -33,17 +33,17 @@ public class CmdAltsList extends FCommand { @Override public void perform() { Faction faction = myFaction; - if(argIsSet(0)){ + if (argIsSet(0)) { faction = argAsFaction(0); } - if(faction == null) + if (faction == null) return; - if(faction != myFaction && !fme.isAdminBypassing()){ + if (faction != myFaction && !fme.isAdminBypassing()) { return; } - if(faction.getAltPlayers().size() == 0){ + if (faction.getAltPlayers().size() == 0) { msg(TL.COMMAND_ALTS_LIST_NOALTS, faction.getTag()); return; } diff --git a/src/main/java/com/massivecraft/factions/cmd/alts/CmdInviteAlt.java b/src/main/java/com/massivecraft/factions/cmd/alts/CmdInviteAlt.java index d9fb739e..ff8e9492 100644 --- a/src/main/java/com/massivecraft/factions/cmd/alts/CmdInviteAlt.java +++ b/src/main/java/com/massivecraft/factions/cmd/alts/CmdInviteAlt.java @@ -33,7 +33,7 @@ public class CmdInviteAlt extends FCommand { @Override public void perform() { - if(!P.p.getConfig().getBoolean("f-alts.Enabled", false)){ + if (!P.p.getConfig().getBoolean("f-alts.Enabled", false)) { fme.msg(TL.GENERIC_DISABLED); return; } diff --git a/src/main/java/com/massivecraft/factions/cmd/chest/ChestLogsHandler.java b/src/main/java/com/massivecraft/factions/cmd/chest/ChestLogsHandler.java index 3318703c..0a8e1edd 100644 --- a/src/main/java/com/massivecraft/factions/cmd/chest/ChestLogsHandler.java +++ b/src/main/java/com/massivecraft/factions/cmd/chest/ChestLogsHandler.java @@ -94,7 +94,7 @@ public class ChestLogsHandler implements Listener { if (e.getClickedInventory() != null) { if (e.getClickedInventory().equals(topInventory)) { ItemStack current = e.getCurrentItem(); - if(current == null) return; + if (current == null) return; ItemStack cursor = e.getCursor(); if (e.getClick().isShiftClick()) return; if (cursor != null) { diff --git a/src/main/java/com/massivecraft/factions/cmd/chest/CmdChest.java b/src/main/java/com/massivecraft/factions/cmd/chest/CmdChest.java index 4f8f72d3..b952a326 100644 --- a/src/main/java/com/massivecraft/factions/cmd/chest/CmdChest.java +++ b/src/main/java/com/massivecraft/factions/cmd/chest/CmdChest.java @@ -10,44 +10,44 @@ import com.massivecraft.factions.zcore.util.TL; public class CmdChest extends FCommand { - public CmdChest() { - this.aliases.add("chest"); - this.aliases.add("pv"); + public CmdChest() { + this.aliases.add("chest"); + this.aliases.add("pv"); - //this.requiredArgs.add(""); + //this.requiredArgs.add(""); - this.permission = Permission.CHEST.node; - this.disableOnLock = false; + this.permission = Permission.CHEST.node; + this.disableOnLock = false; - senderMustBePlayer = true; - senderMustBeMember = true; - senderMustBeModerator = false; - senderMustBeAdmin = false; - } + senderMustBePlayer = true; + senderMustBeMember = true; + senderMustBeModerator = false; + senderMustBeAdmin = false; + } - @Override - public void perform() { + @Override + public void perform() { - if (!P.p.getConfig().getBoolean("fchest.Enabled")) { - fme.sendMessage("This command is disabled!"); - return; - } - // This permission check is way too explicit but it's clean - if (!fme.isAdminBypassing()) { - Access access = myFaction.getAccess(fme, PermissableAction.CHEST); - if (access != Access.ALLOW && fme.getRole() != Role.LEADER) { - fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "access chest"); - return; - } - } - me.openInventory(fme.getFaction().getChestInventory()); - } + if (!P.p.getConfig().getBoolean("fchest.Enabled")) { + fme.sendMessage("This command is disabled!"); + return; + } + // This permission check is way too explicit but it's clean + if (!fme.isAdminBypassing()) { + Access access = myFaction.getAccess(fme, PermissableAction.CHEST); + if (access != Access.ALLOW && fme.getRole() != Role.LEADER) { + fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "access chest"); + return; + } + } + me.openInventory(fme.getFaction().getChestInventory()); + } - @Override - public TL getUsageTranslation() { - return TL.COMMAND_VAULT_DESCRIPTION; - } + @Override + public TL getUsageTranslation() { + return TL.COMMAND_VAULT_DESCRIPTION; + } } diff --git a/src/main/java/com/massivecraft/factions/cmd/claim/CmdAutoClaim.java b/src/main/java/com/massivecraft/factions/cmd/claim/CmdAutoClaim.java index 101591aa..fb9296ee 100644 --- a/src/main/java/com/massivecraft/factions/cmd/claim/CmdAutoClaim.java +++ b/src/main/java/com/massivecraft/factions/cmd/claim/CmdAutoClaim.java @@ -8,51 +8,51 @@ import com.massivecraft.factions.zcore.util.TL; public class CmdAutoClaim extends FCommand { - public CmdAutoClaim() { - super(); - this.aliases.add("autoclaim"); + public CmdAutoClaim() { + super(); + this.aliases.add("autoclaim"); - //this.requiredArgs.add(""); - this.optionalArgs.put("faction", "your"); + //this.requiredArgs.add(""); + this.optionalArgs.put("faction", "your"); - this.permission = Permission.AUTOCLAIM.node; - this.disableOnLock = true; - this.disableOnSpam = false; + this.permission = Permission.AUTOCLAIM.node; + this.disableOnLock = true; + this.disableOnSpam = false; - senderMustBePlayer = true; - senderMustBeMember = false; - senderMustBeModerator = false; - senderMustBeAdmin = false; - } + senderMustBePlayer = true; + senderMustBeMember = false; + senderMustBeModerator = false; + senderMustBeAdmin = false; + } - @Override - public void perform() { - Faction forFaction = this.argAsFaction(0, myFaction); - if (forFaction == null || forFaction == fme.getAutoClaimFor()) { - fme.setAutoClaimFor(null); - msg(TL.COMMAND_AUTOCLAIM_DISABLED); - return; - } + @Override + public void perform() { + Faction forFaction = this.argAsFaction(0, myFaction); + if (forFaction == null || forFaction == fme.getAutoClaimFor()) { + fme.setAutoClaimFor(null); + msg(TL.COMMAND_AUTOCLAIM_DISABLED); + return; + } - if (!fme.canClaimForFaction(forFaction)) { - if (myFaction == forFaction) { - msg(TL.COMMAND_AUTOCLAIM_REQUIREDRANK, Role.MODERATOR.getTranslation()); - } else { - msg(TL.COMMAND_AUTOCLAIM_OTHERFACTION, forFaction.describeTo(fme)); - } + if (!fme.canClaimForFaction(forFaction)) { + if (myFaction == forFaction) { + msg(TL.COMMAND_AUTOCLAIM_REQUIREDRANK, Role.MODERATOR.getTranslation()); + } else { + msg(TL.COMMAND_AUTOCLAIM_OTHERFACTION, forFaction.describeTo(fme)); + } - return; - } + return; + } - fme.setAutoClaimFor(forFaction); + fme.setAutoClaimFor(forFaction); - msg(TL.COMMAND_AUTOCLAIM_ENABLED, forFaction.describeTo(fme)); - fme.attemptClaim(forFaction, me.getLocation(), true); - } + msg(TL.COMMAND_AUTOCLAIM_ENABLED, forFaction.describeTo(fme)); + fme.attemptClaim(forFaction, me.getLocation(), true); + } - @Override - public TL getUsageTranslation() { - return TL.COMMAND_AUTOCLAIM_DESCRIPTION; - } + @Override + public TL getUsageTranslation() { + return TL.COMMAND_AUTOCLAIM_DESCRIPTION; + } } \ No newline at end of file diff --git a/src/main/java/com/massivecraft/factions/cmd/claim/CmdClaimAt.java b/src/main/java/com/massivecraft/factions/cmd/claim/CmdClaimAt.java index 64213992..b489faa5 100644 --- a/src/main/java/com/massivecraft/factions/cmd/claim/CmdClaimAt.java +++ b/src/main/java/com/massivecraft/factions/cmd/claim/CmdClaimAt.java @@ -8,38 +8,38 @@ import com.massivecraft.factions.zcore.util.TL; public class CmdClaimAt extends FCommand { - public CmdClaimAt() { - super(); - this.aliases.add("claimat"); + public CmdClaimAt() { + super(); + this.aliases.add("claimat"); - this.requiredArgs.add("world"); - this.requiredArgs.add("x"); - this.requiredArgs.add("z"); + this.requiredArgs.add("world"); + this.requiredArgs.add("x"); + this.requiredArgs.add("z"); - this.permission = Permission.CLAIMAT.node; - this.disableOnLock = true; + this.permission = Permission.CLAIMAT.node; + this.disableOnLock = true; - senderMustBePlayer = true; - senderMustBeMember = true; - senderMustBeModerator = false; - senderMustBeColeader = false; - senderMustBeAdmin = false; - } + senderMustBePlayer = true; + senderMustBeMember = true; + senderMustBeModerator = false; + senderMustBeColeader = false; + senderMustBeAdmin = false; + } - @Override - public void perform() { - int x = argAsInt(1); - int z = argAsInt(2); - FLocation location = new FLocation(argAsString(0), x, z); - if (!((fme.getPlayer().getLocation().getX() + (x * 16)) > (fme.getPlayer().getLocation().getX() + (Conf.mapWidth * 16))) && - !((fme.getPlayer().getLocation().getZ() + (z * 16)) > (fme.getPlayer().getLocation().getZ() + (Conf.mapHeight * 16)))) { - fme.attemptClaim(myFaction, location, true); - } else fme.msg(TL.COMMAND_CLAIM_DENIED); - } + @Override + public void perform() { + int x = argAsInt(1); + int z = argAsInt(2); + FLocation location = new FLocation(argAsString(0), x, z); + if (!((fme.getPlayer().getLocation().getX() + (x * 16)) > (fme.getPlayer().getLocation().getX() + (Conf.mapWidth * 16))) && + !((fme.getPlayer().getLocation().getZ() + (z * 16)) > (fme.getPlayer().getLocation().getZ() + (Conf.mapHeight * 16)))) { + fme.attemptClaim(myFaction, location, true); + } else fme.msg(TL.COMMAND_CLAIM_DENIED); + } - @Override - public TL getUsageTranslation() { - return null; - } + @Override + public TL getUsageTranslation() { + return null; + } } diff --git a/src/main/java/com/massivecraft/factions/cmd/claim/CmdClaimLine.java b/src/main/java/com/massivecraft/factions/cmd/claim/CmdClaimLine.java index 45c89340..32b234a9 100644 --- a/src/main/java/com/massivecraft/factions/cmd/claim/CmdClaimLine.java +++ b/src/main/java/com/massivecraft/factions/cmd/claim/CmdClaimLine.java @@ -10,70 +10,70 @@ import org.bukkit.block.BlockFace; public class CmdClaimLine extends FCommand { - public static final BlockFace[] axis = {BlockFace.SOUTH, BlockFace.WEST, BlockFace.NORTH, BlockFace.EAST}; + public static final BlockFace[] axis = {BlockFace.SOUTH, BlockFace.WEST, BlockFace.NORTH, BlockFace.EAST}; - public CmdClaimLine() { + public CmdClaimLine() { - // Aliases - this.aliases.add("claimline"); - this.aliases.add("cl"); + // Aliases + this.aliases.add("claimline"); + this.aliases.add("cl"); - // Args - this.optionalArgs.put("amount", "1"); - this.optionalArgs.put("direction", "facing"); - this.optionalArgs.put("faction", "you"); + // Args + this.optionalArgs.put("amount", "1"); + this.optionalArgs.put("direction", "facing"); + this.optionalArgs.put("faction", "you"); - this.permission = Permission.CLAIM_LINE.node; - this.disableOnLock = true; + this.permission = Permission.CLAIM_LINE.node; + this.disableOnLock = true; - senderMustBePlayer = true; - senderMustBeMember = false; - senderMustBeModerator = false; - senderMustBeColeader = false; - senderMustBeAdmin = false; - } + senderMustBePlayer = true; + senderMustBeMember = false; + senderMustBeModerator = false; + senderMustBeColeader = false; + senderMustBeAdmin = false; + } - @Override - public void perform() { - // Args - Integer amount = this.argAsInt(0, 1); // Default to 1 + @Override + public void perform() { + // Args + Integer amount = this.argAsInt(0, 1); // Default to 1 - if (amount > Conf.lineClaimLimit) { - fme.msg(TL.COMMAND_CLAIMLINE_ABOVEMAX, Conf.lineClaimLimit); - return; - } + if (amount > Conf.lineClaimLimit) { + fme.msg(TL.COMMAND_CLAIMLINE_ABOVEMAX, Conf.lineClaimLimit); + return; + } - String direction = this.argAsString(1); - BlockFace blockFace; + String direction = this.argAsString(1); + BlockFace blockFace; - if (direction == null) { - blockFace = axis[Math.round(me.getLocation().getYaw() / 90f) & 0x3]; - } else if (direction.equalsIgnoreCase("north")) { - blockFace = BlockFace.NORTH; - } else if (direction.equalsIgnoreCase("east")) { - blockFace = BlockFace.EAST; - } else if (direction.equalsIgnoreCase("south")) { - blockFace = BlockFace.SOUTH; - } else if (direction.equalsIgnoreCase("west")) { - blockFace = BlockFace.WEST; - } else { - fme.msg(TL.COMMAND_CLAIMLINE_NOTVALID, direction); - return; - } + if (direction == null) { + blockFace = axis[Math.round(me.getLocation().getYaw() / 90f) & 0x3]; + } else if (direction.equalsIgnoreCase("north")) { + blockFace = BlockFace.NORTH; + } else if (direction.equalsIgnoreCase("east")) { + blockFace = BlockFace.EAST; + } else if (direction.equalsIgnoreCase("south")) { + blockFace = BlockFace.SOUTH; + } else if (direction.equalsIgnoreCase("west")) { + blockFace = BlockFace.WEST; + } else { + fme.msg(TL.COMMAND_CLAIMLINE_NOTVALID, direction); + return; + } - final Faction forFaction = this.argAsFaction(2, myFaction); - Location location = me.getLocation(); + final Faction forFaction = this.argAsFaction(2, myFaction); + Location location = me.getLocation(); - // TODO: make this a task like claiming a radius? - for (int i = 0; i < amount; i++) { - fme.attemptClaim(forFaction, location, true); - location = location.add(blockFace.getModX() * 16, 0, blockFace.getModZ() * 16); - } - } + // TODO: make this a task like claiming a radius? + for (int i = 0; i < amount; i++) { + fme.attemptClaim(forFaction, location, true); + location = location.add(blockFace.getModX() * 16, 0, blockFace.getModZ() * 16); + } + } - @Override - public TL getUsageTranslation() { - return TL.COMMAND_CLAIMLINE_DESCRIPTION; - } + @Override + public TL getUsageTranslation() { + return TL.COMMAND_CLAIMLINE_DESCRIPTION; + } } diff --git a/src/main/java/com/massivecraft/factions/cmd/claim/CmdSafeunclaimall.java b/src/main/java/com/massivecraft/factions/cmd/claim/CmdSafeunclaimall.java index 4f401c00..d19c2b73 100644 --- a/src/main/java/com/massivecraft/factions/cmd/claim/CmdSafeunclaimall.java +++ b/src/main/java/com/massivecraft/factions/cmd/claim/CmdSafeunclaimall.java @@ -12,52 +12,52 @@ import org.bukkit.World; public class CmdSafeunclaimall extends FCommand { - public CmdSafeunclaimall() { - this.aliases.add("safeunclaimall"); - this.aliases.add("safedeclaimall"); + public CmdSafeunclaimall() { + this.aliases.add("safeunclaimall"); + this.aliases.add("safedeclaimall"); - //this.requiredArgs.add(""); - this.optionalArgs.put("world", "all"); + //this.requiredArgs.add(""); + this.optionalArgs.put("world", "all"); - this.permission = Permission.MANAGE_SAFE_ZONE.node; - this.disableOnLock = true; + this.permission = Permission.MANAGE_SAFE_ZONE.node; + this.disableOnLock = true; - senderMustBePlayer = false; - senderMustBeMember = false; - senderMustBeModerator = false; - senderMustBeColeader = false; - senderMustBeAdmin = false; + senderMustBePlayer = false; + senderMustBeMember = false; + senderMustBeModerator = false; + senderMustBeColeader = false; + senderMustBeAdmin = false; - } + } - @Override - public void perform() { - String worldName = argAsString(0); - World world = null; + @Override + public void perform() { + String worldName = argAsString(0); + World world = null; - if (worldName != null) { - world = Bukkit.getWorld(worldName); - } + if (worldName != null) { + world = Bukkit.getWorld(worldName); + } - String id = Factions.getInstance().getSafeZone().getId(); + String id = Factions.getInstance().getSafeZone().getId(); - if (world == null) { - Board.getInstance().unclaimAll(id); - } else { - Board.getInstance().unclaimAllInWorld(id, world); - } + if (world == null) { + Board.getInstance().unclaimAll(id); + } else { + Board.getInstance().unclaimAllInWorld(id, world); + } - msg(TL.COMMAND_SAFEUNCLAIMALL_UNCLAIMED); + msg(TL.COMMAND_SAFEUNCLAIMALL_UNCLAIMED); - if (Conf.logLandUnclaims) { - P.p.log(TL.COMMAND_SAFEUNCLAIMALL_UNCLAIMEDLOG.format(sender.getName())); - } - } + if (Conf.logLandUnclaims) { + P.p.log(TL.COMMAND_SAFEUNCLAIMALL_UNCLAIMEDLOG.format(sender.getName())); + } + } - @Override - public TL getUsageTranslation() { - return TL.COMMAND_SAFEUNCLAIMALL_DESCRIPTION; - } + @Override + public TL getUsageTranslation() { + return TL.COMMAND_SAFEUNCLAIMALL_DESCRIPTION; + } } diff --git a/src/main/java/com/massivecraft/factions/cmd/claim/CmdUnclaim.java b/src/main/java/com/massivecraft/factions/cmd/claim/CmdUnclaim.java index 240be501..dcf45518 100644 --- a/src/main/java/com/massivecraft/factions/cmd/claim/CmdUnclaim.java +++ b/src/main/java/com/massivecraft/factions/cmd/claim/CmdUnclaim.java @@ -14,172 +14,172 @@ import org.bukkit.Bukkit; public class CmdUnclaim extends FCommand { - public CmdUnclaim() { - this.aliases.add("unclaim"); - this.aliases.add("declaim"); + public CmdUnclaim() { + this.aliases.add("unclaim"); + this.aliases.add("declaim"); - this.optionalArgs.put("radius", "1"); + this.optionalArgs.put("radius", "1"); - this.permission = Permission.UNCLAIM.node; - this.disableOnLock = true; + this.permission = Permission.UNCLAIM.node; + this.disableOnLock = true; - senderMustBePlayer = true; - senderMustBeMember = false; - senderMustBeModerator = false; - senderMustBeAdmin = false; - } + senderMustBePlayer = true; + senderMustBeMember = false; + senderMustBeModerator = false; + senderMustBeAdmin = false; + } - @Override - public void perform() { - // Read and validate input - int radius = this.argAsInt(0, 1); // Default to 1 + @Override + public void perform() { + // Read and validate input + int radius = this.argAsInt(0, 1); // Default to 1 - if (!fme.isAdminBypassing()) { - Access access = myFaction.getAccess(fme, PermissableAction.TERRITORY); - if (access != Access.ALLOW && fme.getRole() != Role.LEADER) { - fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "manage faction territory"); - return; - } - } + if (!fme.isAdminBypassing()) { + Access access = myFaction.getAccess(fme, PermissableAction.TERRITORY); + if (access != Access.ALLOW && fme.getRole() != Role.LEADER) { + fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "manage faction territory"); + return; + } + } - if (radius < 1) { - msg(TL.COMMAND_CLAIM_INVALIDRADIUS); - return; - } + if (radius < 1) { + msg(TL.COMMAND_CLAIM_INVALIDRADIUS); + return; + } - if (radius < 2) { - // single chunk - unClaim(new FLocation(me)); - } else { - // radius claim - if (!Permission.CLAIM_RADIUS.has(sender, false)) { - msg(TL.COMMAND_CLAIM_DENIED); - return; - } + if (radius < 2) { + // single chunk + unClaim(new FLocation(me)); + } else { + // radius claim + if (!Permission.CLAIM_RADIUS.has(sender, false)) { + msg(TL.COMMAND_CLAIM_DENIED); + return; + } - new SpiralTask(new FLocation(me), radius) { - private final int limit = Conf.radiusClaimFailureLimit - 1; - private int failCount = 0; + new SpiralTask(new FLocation(me), radius) { + private final int limit = Conf.radiusClaimFailureLimit - 1; + private int failCount = 0; - @Override - public boolean work() { - boolean success = unClaim(this.currentFLocation()); - if (success) { - failCount = 0; - } else if (failCount++ >= limit) { - this.stop(); - return false; - } + @Override + public boolean work() { + boolean success = unClaim(this.currentFLocation()); + if (success) { + failCount = 0; + } else if (failCount++ >= limit) { + this.stop(); + return false; + } - return true; - } - }; - } - } + return true; + } + }; + } + } - private boolean unClaim(FLocation target) { - Faction targetFaction = Board.getInstance().getFactionAt(target); - if (targetFaction.isSafeZone()) { - if (Permission.MANAGE_SAFE_ZONE.has(sender)) { - Board.getInstance().removeAt(target); - msg(TL.COMMAND_UNCLAIM_SAFEZONE_SUCCESS); + private boolean unClaim(FLocation target) { + Faction targetFaction = Board.getInstance().getFactionAt(target); + if (targetFaction.isSafeZone()) { + if (Permission.MANAGE_SAFE_ZONE.has(sender)) { + Board.getInstance().removeAt(target); + msg(TL.COMMAND_UNCLAIM_SAFEZONE_SUCCESS); - if (Conf.logLandUnclaims) { - P.p.log(TL.COMMAND_UNCLAIM_LOG.format(fme.getName(), target.getCoordString(), targetFaction.getTag())); - } - return true; - } else { - msg(TL.COMMAND_UNCLAIM_SAFEZONE_NOPERM); - return false; - } - } else if (targetFaction.isWarZone()) { - if (Permission.MANAGE_WAR_ZONE.has(sender)) { - Board.getInstance().removeAt(target); - msg(TL.COMMAND_UNCLAIM_WARZONE_SUCCESS); + if (Conf.logLandUnclaims) { + P.p.log(TL.COMMAND_UNCLAIM_LOG.format(fme.getName(), target.getCoordString(), targetFaction.getTag())); + } + return true; + } else { + msg(TL.COMMAND_UNCLAIM_SAFEZONE_NOPERM); + return false; + } + } else if (targetFaction.isWarZone()) { + if (Permission.MANAGE_WAR_ZONE.has(sender)) { + Board.getInstance().removeAt(target); + msg(TL.COMMAND_UNCLAIM_WARZONE_SUCCESS); - if (Conf.logLandUnclaims) { - P.p.log(TL.COMMAND_UNCLAIM_LOG.format(fme.getName(), target.getCoordString(), targetFaction.getTag())); - } - return true; - } else { - msg(TL.COMMAND_UNCLAIM_WARZONE_NOPERM); - return false; - } - } + if (Conf.logLandUnclaims) { + P.p.log(TL.COMMAND_UNCLAIM_LOG.format(fme.getName(), target.getCoordString(), targetFaction.getTag())); + } + return true; + } else { + msg(TL.COMMAND_UNCLAIM_WARZONE_NOPERM); + return false; + } + } - if (fme.isAdminBypassing()) { - LandUnclaimEvent unclaimEvent = new LandUnclaimEvent(target, targetFaction, fme); - Bukkit.getScheduler().runTask(P.p, () -> Bukkit.getServer().getPluginManager().callEvent(unclaimEvent)); - if (unclaimEvent.isCancelled()) { - return false; - } + if (fme.isAdminBypassing()) { + LandUnclaimEvent unclaimEvent = new LandUnclaimEvent(target, targetFaction, fme); + Bukkit.getScheduler().runTask(P.p, () -> Bukkit.getServer().getPluginManager().callEvent(unclaimEvent)); + if (unclaimEvent.isCancelled()) { + return false; + } - Board.getInstance().removeAt(target); + Board.getInstance().removeAt(target); - targetFaction.msg(TL.COMMAND_UNCLAIM_UNCLAIMED, fme.describeTo(targetFaction, true)); - msg(TL.COMMAND_UNCLAIM_UNCLAIMS); + targetFaction.msg(TL.COMMAND_UNCLAIM_UNCLAIMED, fme.describeTo(targetFaction, true)); + msg(TL.COMMAND_UNCLAIM_UNCLAIMS); - if (Conf.logLandUnclaims) { - P.p.log(TL.COMMAND_UNCLAIM_LOG.format(fme.getName(), target.getCoordString(), targetFaction.getTag())); - } + if (Conf.logLandUnclaims) { + P.p.log(TL.COMMAND_UNCLAIM_LOG.format(fme.getName(), target.getCoordString(), targetFaction.getTag())); + } - return true; - } + return true; + } - if (targetFaction.getAccess(fme, PermissableAction.TERRITORY) == Access.DENY) { - return false; - } + if (targetFaction.getAccess(fme, PermissableAction.TERRITORY) == Access.DENY) { + return false; + } - if (!assertHasFaction()) { - return false; - } + if (!assertHasFaction()) { + return false; + } - if (targetFaction.getAccess(fme, PermissableAction.TERRITORY) != Access.ALLOW && !assertMinRole(Role.MODERATOR)) { - return false; - } + if (targetFaction.getAccess(fme, PermissableAction.TERRITORY) != Access.ALLOW && !assertMinRole(Role.MODERATOR)) { + return false; + } - if (myFaction != targetFaction) { - msg(TL.COMMAND_UNCLAIM_WRONGFACTION); - return false; - } + if (myFaction != targetFaction) { + msg(TL.COMMAND_UNCLAIM_WRONGFACTION); + return false; + } - LandUnclaimEvent unclaimEvent = new LandUnclaimEvent(target, targetFaction, fme); - Bukkit.getServer().getPluginManager().callEvent(unclaimEvent); - if (unclaimEvent.isCancelled()) { - return false; - } + LandUnclaimEvent unclaimEvent = new LandUnclaimEvent(target, targetFaction, fme); + Bukkit.getServer().getPluginManager().callEvent(unclaimEvent); + if (unclaimEvent.isCancelled()) { + return false; + } - if (Econ.shouldBeUsed()) { - double refund = Econ.calculateClaimRefund(myFaction.getLandRounded()); + if (Econ.shouldBeUsed()) { + double refund = Econ.calculateClaimRefund(myFaction.getLandRounded()); - if (Conf.bankEnabled && Conf.bankFactionPaysLandCosts) { - if (!Econ.modifyMoney(myFaction, refund, TL.COMMAND_UNCLAIM_TOUNCLAIM.toString(), TL.COMMAND_UNCLAIM_FORUNCLAIM.toString())) { - return false; - } - } else { - if (!Econ.modifyMoney(fme, refund, TL.COMMAND_UNCLAIM_TOUNCLAIM.toString(), TL.COMMAND_UNCLAIM_FORUNCLAIM.toString())) { - return false; - } - } - } + if (Conf.bankEnabled && Conf.bankFactionPaysLandCosts) { + if (!Econ.modifyMoney(myFaction, refund, TL.COMMAND_UNCLAIM_TOUNCLAIM.toString(), TL.COMMAND_UNCLAIM_FORUNCLAIM.toString())) { + return false; + } + } else { + if (!Econ.modifyMoney(fme, refund, TL.COMMAND_UNCLAIM_TOUNCLAIM.toString(), TL.COMMAND_UNCLAIM_FORUNCLAIM.toString())) { + return false; + } + } + } - Board.getInstance().removeAt(target); - myFaction.msg(TL.COMMAND_UNCLAIM_FACTIONUNCLAIMED, fme.describeTo(myFaction, true)); + Board.getInstance().removeAt(target); + myFaction.msg(TL.COMMAND_UNCLAIM_FACTIONUNCLAIMED, fme.describeTo(myFaction, true)); - if (Conf.logLandUnclaims) { - P.p.log(TL.COMMAND_UNCLAIM_LOG.format(fme.getName(), target.getCoordString(), targetFaction.getTag())); - } + if (Conf.logLandUnclaims) { + P.p.log(TL.COMMAND_UNCLAIM_LOG.format(fme.getName(), target.getCoordString(), targetFaction.getTag())); + } - return true; - } + return true; + } - @Override - public TL getUsageTranslation() { - return TL.COMMAND_UNCLAIM_DESCRIPTION; - } + @Override + public TL getUsageTranslation() { + return TL.COMMAND_UNCLAIM_DESCRIPTION; + } } diff --git a/src/main/java/com/massivecraft/factions/cmd/claim/CmdUnclaimall.java b/src/main/java/com/massivecraft/factions/cmd/claim/CmdUnclaimall.java index 3b398d9f..48de06c5 100644 --- a/src/main/java/com/massivecraft/factions/cmd/claim/CmdUnclaimall.java +++ b/src/main/java/com/massivecraft/factions/cmd/claim/CmdUnclaimall.java @@ -12,55 +12,55 @@ import org.bukkit.Bukkit; public class CmdUnclaimall extends FCommand { - public CmdUnclaimall() { - this.aliases.add("unclaimall"); - this.aliases.add("declaimall"); + public CmdUnclaimall() { + this.aliases.add("unclaimall"); + this.aliases.add("declaimall"); - //this.requiredArgs.add(""); - //this.optionalArgs.put("", ""); + //this.requiredArgs.add(""); + //this.optionalArgs.put("", ""); - this.permission = Permission.UNCLAIM_ALL.node; - this.disableOnLock = true; + this.permission = Permission.UNCLAIM_ALL.node; + this.disableOnLock = true; - senderMustBePlayer = true; - senderMustBeMember = false; - senderMustBeModerator = true; - senderMustBeAdmin = false; + senderMustBePlayer = true; + senderMustBeMember = false; + senderMustBeModerator = true; + senderMustBeAdmin = false; - } + } - @Override - public void perform() { - if (Econ.shouldBeUsed()) { - double refund = Econ.calculateTotalLandRefund(myFaction.getLandRounded()); - if (Conf.bankEnabled && Conf.bankFactionPaysLandCosts) { - if (!Econ.modifyMoney(myFaction, refund, TL.COMMAND_UNCLAIMALL_TOUNCLAIM.toString(), TL.COMMAND_UNCLAIMALL_FORUNCLAIM.toString())) { - return; - } - } else { - if (!Econ.modifyMoney(fme, refund, TL.COMMAND_UNCLAIMALL_TOUNCLAIM.toString(), TL.COMMAND_UNCLAIMALL_FORUNCLAIM.toString())) { - return; - } - } - } + @Override + public void perform() { + if (Econ.shouldBeUsed()) { + double refund = Econ.calculateTotalLandRefund(myFaction.getLandRounded()); + if (Conf.bankEnabled && Conf.bankFactionPaysLandCosts) { + if (!Econ.modifyMoney(myFaction, refund, TL.COMMAND_UNCLAIMALL_TOUNCLAIM.toString(), TL.COMMAND_UNCLAIMALL_FORUNCLAIM.toString())) { + return; + } + } else { + if (!Econ.modifyMoney(fme, refund, TL.COMMAND_UNCLAIMALL_TOUNCLAIM.toString(), TL.COMMAND_UNCLAIMALL_FORUNCLAIM.toString())) { + return; + } + } + } - LandUnclaimAllEvent unclaimAllEvent = new LandUnclaimAllEvent(myFaction, fme); - Bukkit.getScheduler().runTask(P.p, () -> Bukkit.getServer().getPluginManager().callEvent(unclaimAllEvent)); - if (unclaimAllEvent.isCancelled()) { - return; - } + LandUnclaimAllEvent unclaimAllEvent = new LandUnclaimAllEvent(myFaction, fme); + Bukkit.getScheduler().runTask(P.p, () -> Bukkit.getServer().getPluginManager().callEvent(unclaimAllEvent)); + if (unclaimAllEvent.isCancelled()) { + return; + } - Board.getInstance().unclaimAll(myFaction.getId()); - myFaction.msg(TL.COMMAND_UNCLAIMALL_UNCLAIMED, fme.describeTo(myFaction, true)); + Board.getInstance().unclaimAll(myFaction.getId()); + myFaction.msg(TL.COMMAND_UNCLAIMALL_UNCLAIMED, fme.describeTo(myFaction, true)); - if (Conf.logLandUnclaims) { - P.p.log(TL.COMMAND_UNCLAIMALL_LOG.format(fme.getName(), myFaction.getTag())); - } - } + if (Conf.logLandUnclaims) { + P.p.log(TL.COMMAND_UNCLAIMALL_LOG.format(fme.getName(), myFaction.getTag())); + } + } - @Override - public TL getUsageTranslation() { - return TL.COMMAND_UNCLAIMALL_DESCRIPTION; - } + @Override + public TL getUsageTranslation() { + return TL.COMMAND_UNCLAIMALL_DESCRIPTION; + } } diff --git a/src/main/java/com/massivecraft/factions/cmd/claim/CmdWarunclaimall.java b/src/main/java/com/massivecraft/factions/cmd/claim/CmdWarunclaimall.java index 768c06ee..99d6e0ba 100644 --- a/src/main/java/com/massivecraft/factions/cmd/claim/CmdWarunclaimall.java +++ b/src/main/java/com/massivecraft/factions/cmd/claim/CmdWarunclaimall.java @@ -12,51 +12,51 @@ import org.bukkit.World; public class CmdWarunclaimall extends FCommand { - public CmdWarunclaimall() { - this.aliases.add("warunclaimall"); - this.aliases.add("wardeclaimall"); + public CmdWarunclaimall() { + this.aliases.add("warunclaimall"); + this.aliases.add("wardeclaimall"); - //this.requiredArgs.add(""); - this.optionalArgs.put("world", "all"); + //this.requiredArgs.add(""); + this.optionalArgs.put("world", "all"); - this.permission = Permission.MANAGE_WAR_ZONE.node; - this.disableOnLock = true; + this.permission = Permission.MANAGE_WAR_ZONE.node; + this.disableOnLock = true; - senderMustBePlayer = false; - senderMustBeMember = false; - senderMustBeModerator = false; - senderMustBeAdmin = false; + senderMustBePlayer = false; + senderMustBeMember = false; + senderMustBeModerator = false; + senderMustBeAdmin = false; - } + } - @Override - public void perform() { - String worldName = argAsString(0); - World world = null; + @Override + public void perform() { + String worldName = argAsString(0); + World world = null; - if (worldName != null) { - world = Bukkit.getWorld(worldName); - } + if (worldName != null) { + world = Bukkit.getWorld(worldName); + } - String id = Factions.getInstance().getWarZone().getId(); + String id = Factions.getInstance().getWarZone().getId(); - if (world == null) { - Board.getInstance().unclaimAll(id); - } else { - Board.getInstance().unclaimAllInWorld(id, world); - } + if (world == null) { + Board.getInstance().unclaimAll(id); + } else { + Board.getInstance().unclaimAllInWorld(id, world); + } - fme.msg(TL.COMMAND_WARUNCLAIMALL_SUCCESS); + fme.msg(TL.COMMAND_WARUNCLAIMALL_SUCCESS); - if (Conf.logLandUnclaims) { - P.p.log(TL.COMMAND_WARUNCLAIMALL_LOG.format(fme.getName())); - } - } + if (Conf.logLandUnclaims) { + P.p.log(TL.COMMAND_WARUNCLAIMALL_LOG.format(fme.getName())); + } + } - @Override - public TL getUsageTranslation() { - return TL.COMMAND_WARUNCLAIMALL_DESCRIPTION; - } + @Override + public TL getUsageTranslation() { + return TL.COMMAND_WARUNCLAIMALL_DESCRIPTION; + } } diff --git a/src/main/java/com/massivecraft/factions/cmd/econ/CmdMoney.java b/src/main/java/com/massivecraft/factions/cmd/econ/CmdMoney.java index 550ca648..7bec6639 100644 --- a/src/main/java/com/massivecraft/factions/cmd/econ/CmdMoney.java +++ b/src/main/java/com/massivecraft/factions/cmd/econ/CmdMoney.java @@ -6,49 +6,49 @@ import com.massivecraft.factions.zcore.util.TL; public class CmdMoney extends FCommand { - public CmdMoneyBalance cmdMoneyBalance = new CmdMoneyBalance(); - public CmdMoneyDeposit cmdMoneyDeposit = new CmdMoneyDeposit(); - public CmdMoneyWithdraw cmdMoneyWithdraw = new CmdMoneyWithdraw(); - public CmdMoneyTransferFf cmdMoneyTransferFf = new CmdMoneyTransferFf(); - public CmdMoneyTransferFp cmdMoneyTransferFp = new CmdMoneyTransferFp(); - public CmdMoneyTransferPf cmdMoneyTransferPf = new CmdMoneyTransferPf(); + public CmdMoneyBalance cmdMoneyBalance = new CmdMoneyBalance(); + public CmdMoneyDeposit cmdMoneyDeposit = new CmdMoneyDeposit(); + public CmdMoneyWithdraw cmdMoneyWithdraw = new CmdMoneyWithdraw(); + public CmdMoneyTransferFf cmdMoneyTransferFf = new CmdMoneyTransferFf(); + public CmdMoneyTransferFp cmdMoneyTransferFp = new CmdMoneyTransferFp(); + public CmdMoneyTransferPf cmdMoneyTransferPf = new CmdMoneyTransferPf(); - public CmdMoney() { - super(); - this.aliases.add("money"); - this.aliases.add("bank"); + public CmdMoney() { + super(); + this.aliases.add("money"); + this.aliases.add("bank"); - //this.requiredArgs.add(""); - //this.optionalArgs.put("","") + //this.requiredArgs.add(""); + //this.optionalArgs.put("","") - this.isMoneyCommand = true; + this.isMoneyCommand = true; - senderMustBePlayer = false; - senderMustBeMember = false; - senderMustBeModerator = false; - senderMustBeColeader = false; - senderMustBeAdmin = false; + senderMustBePlayer = false; + senderMustBeMember = false; + senderMustBeModerator = false; + senderMustBeColeader = false; + senderMustBeAdmin = false; - this.helpLong.add(p.txt.parseTags(TL.COMMAND_MONEY_LONG.toString())); + this.helpLong.add(p.txt.parseTags(TL.COMMAND_MONEY_LONG.toString())); - this.addSubCommand(this.cmdMoneyBalance); - this.addSubCommand(this.cmdMoneyDeposit); - this.addSubCommand(this.cmdMoneyWithdraw); - this.addSubCommand(this.cmdMoneyTransferFf); - this.addSubCommand(this.cmdMoneyTransferFp); - this.addSubCommand(this.cmdMoneyTransferPf); + this.addSubCommand(this.cmdMoneyBalance); + this.addSubCommand(this.cmdMoneyDeposit); + this.addSubCommand(this.cmdMoneyWithdraw); + this.addSubCommand(this.cmdMoneyTransferFf); + this.addSubCommand(this.cmdMoneyTransferFp); + this.addSubCommand(this.cmdMoneyTransferPf); - } + } - @Override - public void perform() { - this.commandChain.add(this); - P.p.cmdAutoHelp.execute(this.sender, this.args, this.commandChain); - } + @Override + public void perform() { + this.commandChain.add(this); + P.p.cmdAutoHelp.execute(this.sender, this.args, this.commandChain); + } - @Override - public TL getUsageTranslation() { - return TL.COMMAND_MONEY_DESCRIPTION; - } + @Override + public TL getUsageTranslation() { + return TL.COMMAND_MONEY_DESCRIPTION; + } } diff --git a/src/main/java/com/massivecraft/factions/cmd/econ/CmdMoneyBalance.java b/src/main/java/com/massivecraft/factions/cmd/econ/CmdMoneyBalance.java index 5c5914d0..f314026a 100644 --- a/src/main/java/com/massivecraft/factions/cmd/econ/CmdMoneyBalance.java +++ b/src/main/java/com/massivecraft/factions/cmd/econ/CmdMoneyBalance.java @@ -9,49 +9,49 @@ import org.bukkit.command.CommandSender; public class CmdMoneyBalance extends FCommand { - public CmdMoneyBalance() { - super(); - this.aliases.add("b"); - this.aliases.add("balance"); + public CmdMoneyBalance() { + super(); + this.aliases.add("b"); + this.aliases.add("balance"); - //this.requiredArgs.add(""); - this.optionalArgs.put("faction", "yours"); - this.isMoneyCommand = true; + //this.requiredArgs.add(""); + this.optionalArgs.put("faction", "yours"); + this.isMoneyCommand = true; - this.permission = Permission.MONEY_BALANCE.node; - this.setHelpShort(TL.COMMAND_MONEYBALANCE_SHORT.toString()); + this.permission = Permission.MONEY_BALANCE.node; + this.setHelpShort(TL.COMMAND_MONEYBALANCE_SHORT.toString()); - senderMustBePlayer = false; - senderMustBeMember = false; - senderMustBeModerator = false; - senderMustBeAdmin = false; - } + senderMustBePlayer = false; + senderMustBeMember = false; + senderMustBeModerator = false; + senderMustBeAdmin = false; + } - @Override - public void perform() { - Faction faction = myFaction; - if (this.argIsSet(0)) { - faction = this.argAsFaction(0); - } + @Override + public void perform() { + Faction faction = myFaction; + if (this.argIsSet(0)) { + faction = this.argAsFaction(0); + } - if (faction == null) { - return; - } - if (faction != myFaction && !Permission.MONEY_BALANCE_ANY.has(sender, true)) { - return; - } + if (faction == null) { + return; + } + if (faction != myFaction && !Permission.MONEY_BALANCE_ANY.has(sender, true)) { + return; + } - if (fme != null) { - Econ.sendBalanceInfo((CommandSender) fme, faction); - } else { - Econ.sendBalanceInfo(sender, faction); - } - } + if (fme != null) { + Econ.sendBalanceInfo((CommandSender) fme, faction); + } else { + Econ.sendBalanceInfo(sender, faction); + } + } - @Override - public TL getUsageTranslation() { - return TL.COMMAND_MONEYBALANCE_DESCRIPTION; - } + @Override + public TL getUsageTranslation() { + return TL.COMMAND_MONEYBALANCE_DESCRIPTION; + } } \ No newline at end of file diff --git a/src/main/java/com/massivecraft/factions/cmd/econ/CmdMoneyDeposit.java b/src/main/java/com/massivecraft/factions/cmd/econ/CmdMoneyDeposit.java index 6a0a8b72..f4742f1a 100644 --- a/src/main/java/com/massivecraft/factions/cmd/econ/CmdMoneyDeposit.java +++ b/src/main/java/com/massivecraft/factions/cmd/econ/CmdMoneyDeposit.java @@ -12,43 +12,43 @@ import org.bukkit.ChatColor; public class CmdMoneyDeposit extends FCommand { - public CmdMoneyDeposit() { - super(); - this.aliases.add("d"); - this.aliases.add("deposit"); + public CmdMoneyDeposit() { + super(); + this.aliases.add("d"); + this.aliases.add("deposit"); - this.requiredArgs.add("amount"); - this.optionalArgs.put("faction", "yours"); + this.requiredArgs.add("amount"); + this.optionalArgs.put("faction", "yours"); - this.isMoneyCommand = true; + this.isMoneyCommand = true; - this.permission = Permission.MONEY_DEPOSIT.node; + this.permission = Permission.MONEY_DEPOSIT.node; - senderMustBePlayer = true; - senderMustBeMember = false; - senderMustBeModerator = false; - senderMustBeColeader = false; - senderMustBeAdmin = false; - } + senderMustBePlayer = true; + senderMustBeMember = false; + senderMustBeModerator = false; + senderMustBeColeader = false; + senderMustBeAdmin = false; + } - @Override - public void perform() { - double amount = this.argAsDouble(0, 0d); - EconomyParticipator faction = this.argAsFaction(1, myFaction); - if (faction == null) { - return; - } - boolean success = Econ.transferMoney(fme, fme, faction, amount); + @Override + public void perform() { + double amount = this.argAsDouble(0, 0d); + EconomyParticipator faction = this.argAsFaction(1, myFaction); + if (faction == null) { + return; + } + boolean success = Econ.transferMoney(fme, fme, faction, amount); - if (success && Conf.logMoneyTransactions) { - P.p.log(ChatColor.stripColor(P.p.txt.parse(TL.COMMAND_MONEYDEPOSIT_DEPOSITED.toString(), fme.getName(), Econ.moneyString(amount), faction.describeTo(null)))); - } - } + if (success && Conf.logMoneyTransactions) { + P.p.log(ChatColor.stripColor(P.p.txt.parse(TL.COMMAND_MONEYDEPOSIT_DEPOSITED.toString(), fme.getName(), Econ.moneyString(amount), faction.describeTo(null)))); + } + } - @Override - public TL getUsageTranslation() { - return TL.COMMAND_MONEYDEPOSIT_DESCRIPTION; - } + @Override + public TL getUsageTranslation() { + return TL.COMMAND_MONEYDEPOSIT_DESCRIPTION; + } } diff --git a/src/main/java/com/massivecraft/factions/cmd/econ/CmdMoneyTransferFf.java b/src/main/java/com/massivecraft/factions/cmd/econ/CmdMoneyTransferFf.java index 7fe77890..169dc61e 100644 --- a/src/main/java/com/massivecraft/factions/cmd/econ/CmdMoneyTransferFf.java +++ b/src/main/java/com/massivecraft/factions/cmd/econ/CmdMoneyTransferFf.java @@ -13,52 +13,52 @@ import org.bukkit.entity.Player; public class CmdMoneyTransferFf extends FCommand { - public CmdMoneyTransferFf() { - this.aliases.add("ff"); + public CmdMoneyTransferFf() { + this.aliases.add("ff"); - this.requiredArgs.add("amount"); - this.requiredArgs.add("faction"); - this.requiredArgs.add("faction"); + this.requiredArgs.add("amount"); + this.requiredArgs.add("faction"); + this.requiredArgs.add("faction"); - //this.optionalArgs.put("", ""); + //this.optionalArgs.put("", ""); - this.permission = Permission.MONEY_F2F.node; + this.permission = Permission.MONEY_F2F.node; - this.isMoneyCommand = true; + this.isMoneyCommand = true; - senderMustBePlayer = false; - senderMustBeMember = false; - senderMustBeModerator = false; - senderMustBeColeader = false; - senderMustBeAdmin = false; - } + senderMustBePlayer = false; + senderMustBeMember = false; + senderMustBeModerator = false; + senderMustBeColeader = false; + senderMustBeAdmin = false; + } - @Override - public void perform() { - double amount = this.argAsDouble(0, 0d); - EconomyParticipator from = this.argAsFaction(1); - if (from == null) { - return; - } - EconomyParticipator to = this.argAsFaction(2); - if (to == null) { - return; - } - if (Conf.econFactionStartingBalance != 0 && (System.currentTimeMillis() - myFaction.getFoundedDate()) <= (Conf.econDenyWithdrawWhenMinutesAgeLessThan * 6000)) { - msg("Your faction is too young to transfer money like this"); - return; - } - boolean success = Econ.transferMoney(fme, from, to, amount); + @Override + public void perform() { + double amount = this.argAsDouble(0, 0d); + EconomyParticipator from = this.argAsFaction(1); + if (from == null) { + return; + } + EconomyParticipator to = this.argAsFaction(2); + if (to == null) { + return; + } + if (Conf.econFactionStartingBalance != 0 && (System.currentTimeMillis() - myFaction.getFoundedDate()) <= (Conf.econDenyWithdrawWhenMinutesAgeLessThan * 6000)) { + msg("Your faction is too young to transfer money like this"); + return; + } + boolean success = Econ.transferMoney(fme, from, to, amount); - if (success && Conf.logMoneyTransactions) { - String name = sender instanceof Player ? fme.getName() : sender.getName(); - P.p.log(ChatColor.stripColor(P.p.txt.parse(TL.COMMAND_MONEYTRANSFERFF_TRANSFER.toString(), name, Econ.moneyString(amount), from.describeTo(null), to.describeTo(null)))); - } - } + if (success && Conf.logMoneyTransactions) { + String name = sender instanceof Player ? fme.getName() : sender.getName(); + P.p.log(ChatColor.stripColor(P.p.txt.parse(TL.COMMAND_MONEYTRANSFERFF_TRANSFER.toString(), name, Econ.moneyString(amount), from.describeTo(null), to.describeTo(null)))); + } + } - @Override - public TL getUsageTranslation() { - return TL.COMMAND_MONEYTRANSFERFF_DESCRIPTION; - } + @Override + public TL getUsageTranslation() { + return TL.COMMAND_MONEYTRANSFERFF_DESCRIPTION; + } } diff --git a/src/main/java/com/massivecraft/factions/cmd/econ/CmdMoneyTransferFp.java b/src/main/java/com/massivecraft/factions/cmd/econ/CmdMoneyTransferFp.java index 94646aad..aae46aea 100644 --- a/src/main/java/com/massivecraft/factions/cmd/econ/CmdMoneyTransferFp.java +++ b/src/main/java/com/massivecraft/factions/cmd/econ/CmdMoneyTransferFp.java @@ -12,51 +12,51 @@ import org.bukkit.ChatColor; public class CmdMoneyTransferFp extends FCommand { - public CmdMoneyTransferFp() { - this.aliases.add("fp"); + public CmdMoneyTransferFp() { + this.aliases.add("fp"); - this.requiredArgs.add("amount"); - this.requiredArgs.add("faction"); - this.requiredArgs.add("player"); + this.requiredArgs.add("amount"); + this.requiredArgs.add("faction"); + this.requiredArgs.add("player"); - //this.optionalArgs.put("", ""); + //this.optionalArgs.put("", ""); - this.permission = Permission.MONEY_F2P.node; + this.permission = Permission.MONEY_F2P.node; - this.isMoneyCommand = true; + this.isMoneyCommand = true; - senderMustBePlayer = false; - senderMustBeMember = false; - senderMustBeModerator = false; - senderMustBeColeader = false; - senderMustBeAdmin = false; - } + senderMustBePlayer = false; + senderMustBeMember = false; + senderMustBeModerator = false; + senderMustBeColeader = false; + senderMustBeAdmin = false; + } - @Override - public void perform() { - double amount = this.argAsDouble(0, 0d); - EconomyParticipator from = this.argAsFaction(1); - if (from == null) { - return; - } - EconomyParticipator to = this.argAsBestFPlayerMatch(2); - if (to == null) { - return; - } + @Override + public void perform() { + double amount = this.argAsDouble(0, 0d); + EconomyParticipator from = this.argAsFaction(1); + if (from == null) { + return; + } + EconomyParticipator to = this.argAsBestFPlayerMatch(2); + if (to == null) { + return; + } - if (Conf.econFactionStartingBalance != 0 && (System.currentTimeMillis() - myFaction.getFoundedDate()) <= (Conf.econDenyWithdrawWhenMinutesAgeLessThan * 6000)) { - msg("Your faction is too young to transfer money like this"); - return; - } - boolean success = Econ.transferMoney(fme, from, to, amount); + if (Conf.econFactionStartingBalance != 0 && (System.currentTimeMillis() - myFaction.getFoundedDate()) <= (Conf.econDenyWithdrawWhenMinutesAgeLessThan * 6000)) { + msg("Your faction is too young to transfer money like this"); + return; + } + boolean success = Econ.transferMoney(fme, from, to, amount); - if (success && Conf.logMoneyTransactions) { - P.p.log(ChatColor.stripColor(P.p.txt.parse(TL.COMMAND_MONEYTRANSFERFP_TRANSFER.toString(), fme.getName(), Econ.moneyString(amount), from.describeTo(null), to.describeTo(null)))); - } - } + if (success && Conf.logMoneyTransactions) { + P.p.log(ChatColor.stripColor(P.p.txt.parse(TL.COMMAND_MONEYTRANSFERFP_TRANSFER.toString(), fme.getName(), Econ.moneyString(amount), from.describeTo(null), to.describeTo(null)))); + } + } - @Override - public TL getUsageTranslation() { - return TL.COMMAND_MONEYTRANSFERFP_DESCRIPTION; - } + @Override + public TL getUsageTranslation() { + return TL.COMMAND_MONEYTRANSFERFP_DESCRIPTION; + } } diff --git a/src/main/java/com/massivecraft/factions/cmd/econ/CmdMoneyTransferPf.java b/src/main/java/com/massivecraft/factions/cmd/econ/CmdMoneyTransferPf.java index b3688614..1efabe96 100644 --- a/src/main/java/com/massivecraft/factions/cmd/econ/CmdMoneyTransferPf.java +++ b/src/main/java/com/massivecraft/factions/cmd/econ/CmdMoneyTransferPf.java @@ -12,51 +12,51 @@ import org.bukkit.ChatColor; public class CmdMoneyTransferPf extends FCommand { - public CmdMoneyTransferPf() { - this.aliases.add("pf"); + public CmdMoneyTransferPf() { + this.aliases.add("pf"); - this.requiredArgs.add("amount"); - this.requiredArgs.add("player"); - this.requiredArgs.add("faction"); + this.requiredArgs.add("amount"); + this.requiredArgs.add("player"); + this.requiredArgs.add("faction"); - //this.optionalArgs.put("", ""); + //this.optionalArgs.put("", ""); - this.permission = Permission.MONEY_P2F.node; - this.isMoneyCommand = true; + this.permission = Permission.MONEY_P2F.node; + this.isMoneyCommand = true; - senderMustBePlayer = false; - senderMustBeMember = false; - senderMustBeModerator = false; - senderMustBeColeader = false; - senderMustBeAdmin = false; - } + senderMustBePlayer = false; + senderMustBeMember = false; + senderMustBeModerator = false; + senderMustBeColeader = false; + senderMustBeAdmin = false; + } - @Override - public void perform() { - double amount = this.argAsDouble(0, 0d); - EconomyParticipator from = this.argAsBestFPlayerMatch(1); - if (from == null) { - return; - } - EconomyParticipator to = this.argAsFaction(2); - if (to == null) { - return; - } + @Override + public void perform() { + double amount = this.argAsDouble(0, 0d); + EconomyParticipator from = this.argAsBestFPlayerMatch(1); + if (from == null) { + return; + } + EconomyParticipator to = this.argAsFaction(2); + if (to == null) { + return; + } - if (Conf.econFactionStartingBalance != 0 && (System.currentTimeMillis() - myFaction.getFoundedDate()) <= (Conf.econDenyWithdrawWhenMinutesAgeLessThan * 6000)) { - msg("Your faction is too young to transfer money like this"); - return; - } - boolean success = Econ.transferMoney(fme, from, to, amount); + if (Conf.econFactionStartingBalance != 0 && (System.currentTimeMillis() - myFaction.getFoundedDate()) <= (Conf.econDenyWithdrawWhenMinutesAgeLessThan * 6000)) { + msg("Your faction is too young to transfer money like this"); + return; + } + boolean success = Econ.transferMoney(fme, from, to, amount); - if (success && Conf.logMoneyTransactions) { - P.p.log(ChatColor.stripColor(P.p.txt.parse(TL.COMMAND_MONEYTRANSFERPF_TRANSFER.toString(), fme.getName(), Econ.moneyString(amount), from.describeTo(null), to.describeTo(null)))); - } - } + if (success && Conf.logMoneyTransactions) { + P.p.log(ChatColor.stripColor(P.p.txt.parse(TL.COMMAND_MONEYTRANSFERPF_TRANSFER.toString(), fme.getName(), Econ.moneyString(amount), from.describeTo(null), to.describeTo(null)))); + } + } - @Override - public TL getUsageTranslation() { - return TL.COMMAND_MONEYTRANSFERPF_DESCRIPTION; - } + @Override + public TL getUsageTranslation() { + return TL.COMMAND_MONEYTRANSFERPF_DESCRIPTION; + } } diff --git a/src/main/java/com/massivecraft/factions/cmd/econ/CmdMoneyWithdraw.java b/src/main/java/com/massivecraft/factions/cmd/econ/CmdMoneyWithdraw.java index 89d2df5f..97df7d48 100644 --- a/src/main/java/com/massivecraft/factions/cmd/econ/CmdMoneyWithdraw.java +++ b/src/main/java/com/massivecraft/factions/cmd/econ/CmdMoneyWithdraw.java @@ -14,53 +14,53 @@ import org.bukkit.ChatColor; public class CmdMoneyWithdraw extends FCommand { - public CmdMoneyWithdraw() { - this.aliases.add("w"); - this.aliases.add("withdraw"); + public CmdMoneyWithdraw() { + this.aliases.add("w"); + this.aliases.add("withdraw"); - this.requiredArgs.add("amount"); - this.optionalArgs.put("faction", "yours"); + this.requiredArgs.add("amount"); + this.optionalArgs.put("faction", "yours"); - this.permission = Permission.MONEY_WITHDRAW.node; - this.isMoneyCommand = true; + this.permission = Permission.MONEY_WITHDRAW.node; + this.isMoneyCommand = true; - senderMustBePlayer = true; - senderMustBeMember = false; - senderMustBeModerator = false; - senderMustBeColeader = false; - senderMustBeAdmin = false; - } + senderMustBePlayer = true; + senderMustBeMember = false; + senderMustBeModerator = false; + senderMustBeColeader = false; + senderMustBeAdmin = false; + } - @Override - public void perform() { + @Override + public void perform() { - double amount = this.argAsDouble(0, 0d); - EconomyParticipator faction = this.argAsFaction(1, myFaction); - if (faction == null) { - return; - } + double amount = this.argAsDouble(0, 0d); + EconomyParticipator faction = this.argAsFaction(1, myFaction); + if (faction == null) { + return; + } - Access access = myFaction.getAccess(fme, PermissableAction.WITHDRAW); - if (access == Access.DENY) { - fme.msg(TL.GENERIC_NOPERMISSION, "withdraw"); - return; - } + Access access = myFaction.getAccess(fme, PermissableAction.WITHDRAW); + if (access == Access.DENY) { + fme.msg(TL.GENERIC_NOPERMISSION, "withdraw"); + return; + } - if (Conf.econFactionStartingBalance != 0 && (System.currentTimeMillis() - myFaction.getFoundedDate()) <= (Conf.econDenyWithdrawWhenMinutesAgeLessThan * 6000)) { - msg("Your faction is too young to withdraw money like this"); - return; - } + if (Conf.econFactionStartingBalance != 0 && (System.currentTimeMillis() - myFaction.getFoundedDate()) <= (Conf.econDenyWithdrawWhenMinutesAgeLessThan * 6000)) { + msg("Your faction is too young to withdraw money like this"); + return; + } - boolean success = Econ.transferMoney(fme, faction, fme, amount); + boolean success = Econ.transferMoney(fme, faction, fme, amount); - if (success && Conf.logMoneyTransactions) { - P.p.log(ChatColor.stripColor(P.p.txt.parse(TL.COMMAND_MONEYWITHDRAW_WITHDRAW.toString(), fme.getName(), Econ.moneyString(amount), faction.describeTo(null)))); - } - } + if (success && Conf.logMoneyTransactions) { + P.p.log(ChatColor.stripColor(P.p.txt.parse(TL.COMMAND_MONEYWITHDRAW_WITHDRAW.toString(), fme.getName(), Econ.moneyString(amount), faction.describeTo(null)))); + } + } - @Override - public TL getUsageTranslation() { - return TL.COMMAND_MONEYWITHDRAW_DESCRIPTION; - } + @Override + public TL getUsageTranslation() { + return TL.COMMAND_MONEYWITHDRAW_DESCRIPTION; + } } diff --git a/src/main/java/com/massivecraft/factions/cmd/grace/CmdGrace.java b/src/main/java/com/massivecraft/factions/cmd/grace/CmdGrace.java index a50fb866..dc4d2911 100644 --- a/src/main/java/com/massivecraft/factions/cmd/grace/CmdGrace.java +++ b/src/main/java/com/massivecraft/factions/cmd/grace/CmdGrace.java @@ -33,10 +33,7 @@ public class CmdGrace extends FCommand { boolean gracePeriod = Conf.gracePeriod; if (args.size() == 0) { - if (gracePeriod) - Conf.gracePeriod = false; - else - Conf.gracePeriod = true; + Conf.gracePeriod = !gracePeriod; } fme.msg(TL.COMMAND_GRACE_TOGGLE, gracePeriod ? "enabled" : "disabled"); } diff --git a/src/main/java/com/massivecraft/factions/cmd/logout/CmdLogout.java b/src/main/java/com/massivecraft/factions/cmd/logout/CmdLogout.java index 2d7267e2..04362fca 100644 --- a/src/main/java/com/massivecraft/factions/cmd/logout/CmdLogout.java +++ b/src/main/java/com/massivecraft/factions/cmd/logout/CmdLogout.java @@ -7,7 +7,7 @@ import com.massivecraft.factions.zcore.util.TL; public class CmdLogout extends FCommand { - public CmdLogout(){ + public CmdLogout() { super(); this.aliases.add("logout"); @@ -25,7 +25,7 @@ public class CmdLogout extends FCommand { public void perform() { LogoutHandler handler = LogoutHandler.getByName(fme.getPlayer().getName()); - if(handler.isLogoutActive(fme.getPlayer())){ + if (handler.isLogoutActive(fme.getPlayer())) { fme.msg(TL.COMMAND_LOGOUT_ACTIVE); return; } @@ -35,5 +35,7 @@ public class CmdLogout extends FCommand { } @Override - public TL getUsageTranslation() { return TL.COMMAND_LOGOUT_DESCRIPTION; } + public TL getUsageTranslation() { + return TL.COMMAND_LOGOUT_DESCRIPTION; + } } diff --git a/src/main/java/com/massivecraft/factions/cmd/logout/LogoutHandler.java b/src/main/java/com/massivecraft/factions/cmd/logout/LogoutHandler.java index 881fcfaa..1cf724e9 100644 --- a/src/main/java/com/massivecraft/factions/cmd/logout/LogoutHandler.java +++ b/src/main/java/com/massivecraft/factions/cmd/logout/LogoutHandler.java @@ -22,30 +22,28 @@ public class LogoutHandler { factionDatas.put(name, this); } + public static LogoutHandler getByName(String name) { + LogoutHandler logoutHandler = factionDatas.get(name); + return logoutHandler == null ? new LogoutHandler(name) : factionDatas.get(name); + } + public boolean isLogoutActive(Player player) { return logoutCooldown.containsKey(player.getUniqueId()) && System.currentTimeMillis() < logoutCooldown.get(player.getUniqueId()); } public void cancelLogout(Player player) { - if(logoutCooldown.containsKey(player.getUniqueId())) { - logoutCooldown.remove(player.getUniqueId()); - } + logoutCooldown.remove(player.getUniqueId()); } public void applyLogoutCooldown(Player player) { logoutCooldown.put(player.getUniqueId(), System.currentTimeMillis() + (30 * 1000)); Bukkit.getScheduler().runTaskLater(P.p, () -> { - if(isLogoutActive(player)) { + if (isLogoutActive(player)) { player.setMetadata("Logout", new FixedMetadataValue(P.p, true)); player.kickPlayer(String.valueOf(TL.COMMAND_LOGOUT_KICK_MESSAGE)); cancelLogout(player); } }, Conf.logoutCooldown * 20L); } - - public static LogoutHandler getByName(String name) { - LogoutHandler logoutHandler = factionDatas.get(name); - return logoutHandler == null ? new LogoutHandler(name) : factionDatas.get(name); - } } diff --git a/src/main/java/com/massivecraft/factions/cmd/points/CmdPoints.java b/src/main/java/com/massivecraft/factions/cmd/points/CmdPoints.java index 47f31958..2db4ca02 100644 --- a/src/main/java/com/massivecraft/factions/cmd/points/CmdPoints.java +++ b/src/main/java/com/massivecraft/factions/cmd/points/CmdPoints.java @@ -10,7 +10,7 @@ public class CmdPoints extends FCommand { public CmdPointsSet cmdPointsSet = new CmdPointsSet(); public CmdPointsAdd cmdPointsAdd = new CmdPointsAdd(); - public CmdPoints(){ + public CmdPoints() { super(); this.aliases.add("points"); diff --git a/src/main/java/com/massivecraft/factions/cmd/points/CmdPointsAdd.java b/src/main/java/com/massivecraft/factions/cmd/points/CmdPointsAdd.java index 4512e575..e999ae99 100644 --- a/src/main/java/com/massivecraft/factions/cmd/points/CmdPointsAdd.java +++ b/src/main/java/com/massivecraft/factions/cmd/points/CmdPointsAdd.java @@ -1,7 +1,6 @@ package com.massivecraft.factions.cmd.points; import com.massivecraft.factions.FPlayer; -import com.massivecraft.factions.FPlayers; import com.massivecraft.factions.Faction; import com.massivecraft.factions.Factions; import com.massivecraft.factions.cmd.FCommand; @@ -48,14 +47,14 @@ public class CmdPointsAdd extends FCommand { msg(TL.COMMAND_POINTS_FAILURE.toString().replace("{faction}", args.get(0))); return; } - if(argAsInt(1) <= 0){ + if (argAsInt(1) <= 0) { msg(TL.COMMAND_POINTS_INSUFFICIENT); return; } faction.setPoints(faction.getPoints() + argAsInt(1)); - msg(TL.COMMAND_POINTS_SUCCESSFUL, argAsInt(1), faction.getTag(), faction.getPoints()); + msg(TL.COMMAND_POINTS_SUCCESSFUL, argAsInt(1), faction.getTag(), faction.getPoints()); } diff --git a/src/main/java/com/massivecraft/factions/cmd/points/CmdPointsRemove.java b/src/main/java/com/massivecraft/factions/cmd/points/CmdPointsRemove.java index 939fc1b5..10fe5e0c 100644 --- a/src/main/java/com/massivecraft/factions/cmd/points/CmdPointsRemove.java +++ b/src/main/java/com/massivecraft/factions/cmd/points/CmdPointsRemove.java @@ -47,7 +47,7 @@ public class CmdPointsRemove extends FCommand { return; } - if(argAsInt(1) <= 0){ + if (argAsInt(1) <= 0) { msg(TL.COMMAND_POINTS_INSUFFICIENT); return; } diff --git a/src/main/java/com/massivecraft/factions/cmd/points/CmdPointsSet.java b/src/main/java/com/massivecraft/factions/cmd/points/CmdPointsSet.java index 1e4b19e0..d8a304a2 100644 --- a/src/main/java/com/massivecraft/factions/cmd/points/CmdPointsSet.java +++ b/src/main/java/com/massivecraft/factions/cmd/points/CmdPointsSet.java @@ -46,7 +46,7 @@ public class CmdPointsSet extends FCommand { return; } - if(argAsInt(1) < 0){ + if (argAsInt(1) < 0) { msg(TL.COMMAND_POINTS_INSUFFICIENT); return; } diff --git a/src/main/java/com/massivecraft/factions/cmd/relational/CmdRelationAlly.java b/src/main/java/com/massivecraft/factions/cmd/relational/CmdRelationAlly.java index 305bff72..921c211c 100644 --- a/src/main/java/com/massivecraft/factions/cmd/relational/CmdRelationAlly.java +++ b/src/main/java/com/massivecraft/factions/cmd/relational/CmdRelationAlly.java @@ -4,8 +4,8 @@ import com.massivecraft.factions.struct.Relation; public class CmdRelationAlly extends FRelationCommand { - public CmdRelationAlly() { - aliases.add("ally"); - targetRelation = Relation.ALLY; - } + public CmdRelationAlly() { + aliases.add("ally"); + targetRelation = Relation.ALLY; + } } diff --git a/src/main/java/com/massivecraft/factions/cmd/relational/CmdRelationEnemy.java b/src/main/java/com/massivecraft/factions/cmd/relational/CmdRelationEnemy.java index 09aa71c1..7b3ab4b2 100644 --- a/src/main/java/com/massivecraft/factions/cmd/relational/CmdRelationEnemy.java +++ b/src/main/java/com/massivecraft/factions/cmd/relational/CmdRelationEnemy.java @@ -4,8 +4,8 @@ import com.massivecraft.factions.struct.Relation; public class CmdRelationEnemy extends FRelationCommand { - public CmdRelationEnemy() { - aliases.add("enemy"); - targetRelation = Relation.ENEMY; - } + public CmdRelationEnemy() { + aliases.add("enemy"); + targetRelation = Relation.ENEMY; + } } diff --git a/src/main/java/com/massivecraft/factions/cmd/relational/CmdRelationNeutral.java b/src/main/java/com/massivecraft/factions/cmd/relational/CmdRelationNeutral.java index b360d9ca..d5def765 100644 --- a/src/main/java/com/massivecraft/factions/cmd/relational/CmdRelationNeutral.java +++ b/src/main/java/com/massivecraft/factions/cmd/relational/CmdRelationNeutral.java @@ -4,8 +4,8 @@ import com.massivecraft.factions.struct.Relation; public class CmdRelationNeutral extends FRelationCommand { - public CmdRelationNeutral() { - aliases.add("neutral"); - targetRelation = Relation.NEUTRAL; - } + public CmdRelationNeutral() { + aliases.add("neutral"); + targetRelation = Relation.NEUTRAL; + } } diff --git a/src/main/java/com/massivecraft/factions/cmd/relational/CmdRelationTruce.java b/src/main/java/com/massivecraft/factions/cmd/relational/CmdRelationTruce.java index 95f0e16c..88149013 100644 --- a/src/main/java/com/massivecraft/factions/cmd/relational/CmdRelationTruce.java +++ b/src/main/java/com/massivecraft/factions/cmd/relational/CmdRelationTruce.java @@ -4,8 +4,8 @@ import com.massivecraft.factions.struct.Relation; public class CmdRelationTruce extends FRelationCommand { - public CmdRelationTruce() { - aliases.add("truce"); - targetRelation = Relation.TRUCE; - } + public CmdRelationTruce() { + aliases.add("truce"); + targetRelation = Relation.TRUCE; + } } diff --git a/src/main/java/com/massivecraft/factions/cmd/relational/FRelationCommand.java b/src/main/java/com/massivecraft/factions/cmd/relational/FRelationCommand.java index df48e160..fdc979b9 100644 --- a/src/main/java/com/massivecraft/factions/cmd/relational/FRelationCommand.java +++ b/src/main/java/com/massivecraft/factions/cmd/relational/FRelationCommand.java @@ -15,113 +15,113 @@ import org.bukkit.ChatColor; public abstract class FRelationCommand extends FCommand { - public Relation targetRelation; + public Relation targetRelation; - public FRelationCommand() { - super(); - this.requiredArgs.add("faction tag"); - //this.optionalArgs.put("player name", "you"); + public FRelationCommand() { + super(); + this.requiredArgs.add("faction tag"); + //this.optionalArgs.put("player name", "you"); - this.permission = Permission.RELATION.node; - this.disableOnLock = true; + this.permission = Permission.RELATION.node; + this.disableOnLock = true; - senderMustBePlayer = true; - senderMustBeMember = false; - senderMustBeModerator = true; - senderMustBeAdmin = false; - } + senderMustBePlayer = true; + senderMustBeMember = false; + senderMustBeModerator = true; + senderMustBeAdmin = false; + } - @Override - public void perform() { - Faction them = this.argAsFaction(0); - if (them == null) { - return; - } + @Override + public void perform() { + Faction them = this.argAsFaction(0); + if (them == null) { + return; + } - if (!them.isNormal()) { - msg(TL.COMMAND_RELATIONS_ALLTHENOPE); - return; - } + if (!them.isNormal()) { + msg(TL.COMMAND_RELATIONS_ALLTHENOPE); + return; + } - if (them == myFaction) { - msg(TL.COMMAND_RELATIONS_MORENOPE); - return; - } + if (them == myFaction) { + msg(TL.COMMAND_RELATIONS_MORENOPE); + return; + } - if (myFaction.getRelationWish(them) == targetRelation) { - msg(TL.COMMAND_RELATIONS_ALREADYINRELATIONSHIP, them.getTag()); - return; - } + if (myFaction.getRelationWish(them) == targetRelation) { + msg(TL.COMMAND_RELATIONS_ALREADYINRELATIONSHIP, them.getTag()); + return; + } - if (hasMaxRelations(them, targetRelation)) { - // We message them down there with the count. - return; - } - Relation oldRelation = myFaction.getRelationTo(them, true); - FactionRelationWishEvent wishEvent = new FactionRelationWishEvent(fme, myFaction, them, oldRelation, targetRelation); - Bukkit.getPluginManager().callEvent(wishEvent); - if (wishEvent.isCancelled()) { - return; - } + if (hasMaxRelations(them, targetRelation)) { + // We message them down there with the count. + return; + } + Relation oldRelation = myFaction.getRelationTo(them, true); + FactionRelationWishEvent wishEvent = new FactionRelationWishEvent(fme, myFaction, them, oldRelation, targetRelation); + Bukkit.getPluginManager().callEvent(wishEvent); + if (wishEvent.isCancelled()) { + return; + } - // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay - if (!payForCommand(targetRelation.getRelationCost(), TL.COMMAND_RELATIONS_TOMARRY, TL.COMMAND_RELATIONS_FORMARRY)) { - return; - } + // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay + if (!payForCommand(targetRelation.getRelationCost(), TL.COMMAND_RELATIONS_TOMARRY, TL.COMMAND_RELATIONS_FORMARRY)) { + return; + } - // try to set the new relation - myFaction.setRelationWish(them, targetRelation); - Relation currentRelation = myFaction.getRelationTo(them, true); - ChatColor currentRelationColor = currentRelation.getColor(); + // try to set the new relation + myFaction.setRelationWish(them, targetRelation); + Relation currentRelation = myFaction.getRelationTo(them, true); + ChatColor currentRelationColor = currentRelation.getColor(); - // if the relation change was successful - if (targetRelation.value == currentRelation.value) { - // trigger the faction relation event - FactionRelationEvent relationEvent = new FactionRelationEvent(myFaction, them, oldRelation, currentRelation); - Bukkit.getServer().getPluginManager().callEvent(relationEvent); + // if the relation change was successful + if (targetRelation.value == currentRelation.value) { + // trigger the faction relation event + FactionRelationEvent relationEvent = new FactionRelationEvent(myFaction, them, oldRelation, currentRelation); + Bukkit.getServer().getPluginManager().callEvent(relationEvent); - them.msg(TL.COMMAND_RELATIONS_MUTUAL, currentRelationColor + targetRelation.getTranslation(), currentRelationColor + myFaction.getTag()); - myFaction.msg(TL.COMMAND_RELATIONS_MUTUAL, currentRelationColor + targetRelation.getTranslation(), currentRelationColor + them.getTag()); - } else { - // inform the other faction of your request - them.msg(TL.COMMAND_RELATIONS_PROPOSAL_1, currentRelationColor + myFaction.getTag(), targetRelation.getColor() + targetRelation.getTranslation()); - them.msg(TL.COMMAND_RELATIONS_PROPOSAL_2, Conf.baseCommandAliases.get(0), targetRelation, myFaction.getTag()); - myFaction.msg(TL.COMMAND_RELATIONS_PROPOSAL_SENT, currentRelationColor + them.getTag(), "" + targetRelation.getColor() + targetRelation); - } + them.msg(TL.COMMAND_RELATIONS_MUTUAL, currentRelationColor + targetRelation.getTranslation(), currentRelationColor + myFaction.getTag()); + myFaction.msg(TL.COMMAND_RELATIONS_MUTUAL, currentRelationColor + targetRelation.getTranslation(), currentRelationColor + them.getTag()); + } else { + // inform the other faction of your request + them.msg(TL.COMMAND_RELATIONS_PROPOSAL_1, currentRelationColor + myFaction.getTag(), targetRelation.getColor() + targetRelation.getTranslation()); + them.msg(TL.COMMAND_RELATIONS_PROPOSAL_2, Conf.baseCommandAliases.get(0), targetRelation, myFaction.getTag()); + myFaction.msg(TL.COMMAND_RELATIONS_PROPOSAL_SENT, currentRelationColor + them.getTag(), "" + targetRelation.getColor() + targetRelation); + } - if (!targetRelation.isNeutral() && them.isPeaceful()) { - them.msg(TL.COMMAND_RELATIONS_PEACEFUL); - myFaction.msg(TL.COMMAND_RELATIONS_PEACEFULOTHER); - } + if (!targetRelation.isNeutral() && them.isPeaceful()) { + them.msg(TL.COMMAND_RELATIONS_PEACEFUL); + myFaction.msg(TL.COMMAND_RELATIONS_PEACEFULOTHER); + } - if (!targetRelation.isNeutral() && myFaction.isPeaceful()) { - them.msg(TL.COMMAND_RELATIONS_PEACEFULOTHER); - myFaction.msg(TL.COMMAND_RELATIONS_PEACEFUL); - } + if (!targetRelation.isNeutral() && myFaction.isPeaceful()) { + them.msg(TL.COMMAND_RELATIONS_PEACEFULOTHER); + myFaction.msg(TL.COMMAND_RELATIONS_PEACEFUL); + } - FTeamWrapper.updatePrefixes(myFaction); - FTeamWrapper.updatePrefixes(them); - } + FTeamWrapper.updatePrefixes(myFaction); + FTeamWrapper.updatePrefixes(them); + } - private boolean hasMaxRelations(Faction them, Relation targetRelation) { - int max = P.p.getConfig().getInt("max-relations." + targetRelation.toString(), -1); - if (P.p.getConfig().getBoolean("max-relations.enabled", false)) { - if (max != -1) { - if (myFaction.getRelationCount(targetRelation) >= max) { - msg(TL.COMMAND_RELATIONS_EXCEEDS_ME, max, targetRelation.getPluralTranslation()); - return true; - } - if (them.getRelationCount(targetRelation) >= max) { - msg(TL.COMMAND_RELATIONS_EXCEEDS_THEY, max, targetRelation.getPluralTranslation()); - return true; - } - } - } - return false; - } + private boolean hasMaxRelations(Faction them, Relation targetRelation) { + int max = P.p.getConfig().getInt("max-relations." + targetRelation.toString(), -1); + if (P.p.getConfig().getBoolean("max-relations.enabled", false)) { + if (max != -1) { + if (myFaction.getRelationCount(targetRelation) >= max) { + msg(TL.COMMAND_RELATIONS_EXCEEDS_ME, max, targetRelation.getPluralTranslation()); + return true; + } + if (them.getRelationCount(targetRelation) >= max) { + msg(TL.COMMAND_RELATIONS_EXCEEDS_THEY, max, targetRelation.getPluralTranslation()); + return true; + } + } + } + return false; + } - @Override - public TL getUsageTranslation() { - return TL.COMMAND_RELATIONS_DESCRIPTION; - } + @Override + public TL getUsageTranslation() { + return TL.COMMAND_RELATIONS_DESCRIPTION; + } } diff --git a/src/main/java/com/massivecraft/factions/cmd/roles/CmdDemote.java b/src/main/java/com/massivecraft/factions/cmd/roles/CmdDemote.java index 8a0c1f09..56efffd6 100644 --- a/src/main/java/com/massivecraft/factions/cmd/roles/CmdDemote.java +++ b/src/main/java/com/massivecraft/factions/cmd/roles/CmdDemote.java @@ -2,8 +2,8 @@ package com.massivecraft.factions.cmd.roles; public class CmdDemote extends FPromoteCommand { - public CmdDemote() { - aliases.add("demote"); - this.relative = -1; - } + public CmdDemote() { + aliases.add("demote"); + this.relative = -1; + } } diff --git a/src/main/java/com/massivecraft/factions/cmd/roles/CmdPromote.java b/src/main/java/com/massivecraft/factions/cmd/roles/CmdPromote.java index 2cd75ea6..e1a0c32d 100644 --- a/src/main/java/com/massivecraft/factions/cmd/roles/CmdPromote.java +++ b/src/main/java/com/massivecraft/factions/cmd/roles/CmdPromote.java @@ -2,9 +2,9 @@ package com.massivecraft.factions.cmd.roles; public class CmdPromote extends FPromoteCommand { - public CmdPromote() { - aliases.add("promote"); - aliases.add("promo"); - this.relative = 1; - } + public CmdPromote() { + aliases.add("promote"); + aliases.add("promo"); + this.relative = 1; + } } diff --git a/src/main/java/com/massivecraft/factions/cmd/roles/FPromoteCommand.java b/src/main/java/com/massivecraft/factions/cmd/roles/FPromoteCommand.java index 3ae19f50..7899a1a5 100644 --- a/src/main/java/com/massivecraft/factions/cmd/roles/FPromoteCommand.java +++ b/src/main/java/com/massivecraft/factions/cmd/roles/FPromoteCommand.java @@ -11,91 +11,91 @@ import org.bukkit.ChatColor; public class FPromoteCommand extends FCommand { - public int relative = 0; + public int relative = 0; - public FPromoteCommand() { - super(); + public FPromoteCommand() { + super(); - this.requiredArgs.add("player"); + this.requiredArgs.add("player"); - this.permission = Permission.PROMOTE.node; - this.disableOnLock = true; + this.permission = Permission.PROMOTE.node; + this.disableOnLock = true; - senderMustBePlayer = true; - senderMustBeMember = true; - senderMustBeModerator = false; - senderMustBeAdmin = false; - } + senderMustBePlayer = true; + senderMustBeMember = true; + senderMustBeModerator = false; + senderMustBeAdmin = false; + } - @Override - public void perform() { - FPlayer target = this.argAsBestFPlayerMatch(0); - if (target == null) { - msg(TL.GENERIC_NOPLAYERFOUND, this.argAsString(0)); - return; - } + @Override + public void perform() { + FPlayer target = this.argAsBestFPlayerMatch(0); + if (target == null) { + msg(TL.GENERIC_NOPLAYERFOUND, this.argAsString(0)); + return; + } - if (!target.getFaction().equals(myFaction)) { - msg(TL.COMMAND_PROMOTE_WRONGFACTION, target.getName()); - return; - } + if (!target.getFaction().equals(myFaction)) { + msg(TL.COMMAND_PROMOTE_WRONGFACTION, target.getName()); + return; + } - if(target.isAlt()){ - msg(ChatColor.RED + "You can not edit the rank of alt accounts."); - return; - } + if (target.isAlt()) { + msg(ChatColor.RED + "You can not edit the rank of alt accounts."); + return; + } - Role current = target.getRole(); - Role promotion = Role.getRelative(current, +relative); + Role current = target.getRole(); + Role promotion = Role.getRelative(current, +relative); - // Now it ain't that messy - if (!fme.isAdminBypassing()) { - Access access = myFaction.getAccess(fme, PermissableAction.PROMOTE); - if (access != Access.ALLOW && fme.getRole() != Role.LEADER) { - fme.msg(TL.GENERIC_NOPERMISSION, "manage ranks"); - return; - } - if (target == fme) { - fme.msg(TL.COMMAND_PROMOTE_NOTSELF); - return; - } - // Don't allow people to manage role of their same rank - if (fme.getRole() == current) { - fme.msg(TL.COMMAND_PROMOTE_NOT_SAME); - return; - } - // Don't allow people to promote people to their same or higher rank. - if (fme.getRole().value <= promotion.value) { - fme.msg(TL.COMMAND_PROMOTE_NOT_ALLOWED); - return; - } - } + // Now it ain't that messy + if (!fme.isAdminBypassing()) { + Access access = myFaction.getAccess(fme, PermissableAction.PROMOTE); + if (access != Access.ALLOW && fme.getRole() != Role.LEADER) { + fme.msg(TL.GENERIC_NOPERMISSION, "manage ranks"); + return; + } + if (target == fme) { + fme.msg(TL.COMMAND_PROMOTE_NOTSELF); + return; + } + // Don't allow people to manage role of their same rank + if (fme.getRole() == current) { + fme.msg(TL.COMMAND_PROMOTE_NOT_SAME); + return; + } + // Don't allow people to promote people to their same or higher rank. + if (fme.getRole().value <= promotion.value) { + fme.msg(TL.COMMAND_PROMOTE_NOT_ALLOWED); + return; + } + } - if (promotion == null) { - fme.msg(TL.COMMAND_PROMOTE_NOTTHATPLAYER); - return; - } + if (promotion == null) { + fme.msg(TL.COMMAND_PROMOTE_NOTTHATPLAYER); + return; + } - // Don't allow people to promote people to their same or higher rnak. - if (fme.getRole().value <= promotion.value) { - fme.msg(TL.COMMAND_PROMOTE_NOT_ALLOWED); - return; - } + // Don't allow people to promote people to their same or higher rnak. + if (fme.getRole().value <= promotion.value) { + fme.msg(TL.COMMAND_PROMOTE_NOT_ALLOWED); + return; + } - String action = relative > 0 ? TL.COMMAND_PROMOTE_PROMOTED.toString() : TL.COMMAND_PROMOTE_DEMOTED.toString(); + String action = relative > 0 ? TL.COMMAND_PROMOTE_PROMOTED.toString() : TL.COMMAND_PROMOTE_DEMOTED.toString(); - // Success! - target.setRole(promotion); - if (target.isOnline()) { - target.msg(TL.COMMAND_PROMOTE_TARGET, action, promotion.nicename); - } + // Success! + target.setRole(promotion); + if (target.isOnline()) { + target.msg(TL.COMMAND_PROMOTE_TARGET, action, promotion.nicename); + } - fme.msg(TL.COMMAND_PROMOTE_SUCCESS, action, target.getName(), promotion.nicename); - } + fme.msg(TL.COMMAND_PROMOTE_SUCCESS, action, target.getName(), promotion.nicename); + } - @Override - public TL getUsageTranslation() { - return TL.COMMAND_PROMOTE_DESCRIPTION; - } + @Override + public TL getUsageTranslation() { + return TL.COMMAND_PROMOTE_DESCRIPTION; + } } \ No newline at end of file diff --git a/src/main/java/com/massivecraft/factions/cmd/tnt/CmdTnt.java b/src/main/java/com/massivecraft/factions/cmd/tnt/CmdTnt.java index 5d9bb02d..35bad43b 100644 --- a/src/main/java/com/massivecraft/factions/cmd/tnt/CmdTnt.java +++ b/src/main/java/com/massivecraft/factions/cmd/tnt/CmdTnt.java @@ -116,8 +116,10 @@ public class CmdTnt extends FCommand { return; } - for (int i = 0; i <= fullStacks - 1; i++) me.getPlayer().getInventory().addItem(new ItemStack(XMaterial.TNT.parseMaterial(), 64)); - if (remainderAmt != 0) me.getPlayer().getInventory().addItem(new ItemStack(XMaterial.TNT.parseMaterial(), remainderAmt)); + for (int i = 0; i <= fullStacks - 1; i++) + me.getPlayer().getInventory().addItem(new ItemStack(XMaterial.TNT.parseMaterial(), 64)); + if (remainderAmt != 0) + me.getPlayer().getInventory().addItem(new ItemStack(XMaterial.TNT.parseMaterial(), remainderAmt)); fme.getFaction().takeTnt(amount); me.updateInventory(); diff --git a/src/main/java/com/massivecraft/factions/event/FPlayerEnteredFactionEvent.java b/src/main/java/com/massivecraft/factions/event/FPlayerEnteredFactionEvent.java index 9e9f8c67..d22632c1 100644 --- a/src/main/java/com/massivecraft/factions/event/FPlayerEnteredFactionEvent.java +++ b/src/main/java/com/massivecraft/factions/event/FPlayerEnteredFactionEvent.java @@ -6,37 +6,37 @@ import org.bukkit.event.HandlerList; public class FPlayerEnteredFactionEvent extends FactionPlayerEvent { - private static final HandlerList handlers = new HandlerList(); - private FPlayer fPlayer; - private Faction factionTo; - private Faction factionFrom; + private static final HandlerList handlers = new HandlerList(); + private FPlayer fPlayer; + private Faction factionTo; + private Faction factionFrom; - public FPlayerEnteredFactionEvent(Faction factionTo, Faction factionFrom, FPlayer fPlayer) { - super(fPlayer.getFaction(), fPlayer); - this.factionFrom = factionFrom; - this.factionTo = factionTo; - this.fPlayer = fPlayer; - } + public FPlayerEnteredFactionEvent(Faction factionTo, Faction factionFrom, FPlayer fPlayer) { + super(fPlayer.getFaction(), fPlayer); + this.factionFrom = factionFrom; + this.factionTo = factionTo; + this.fPlayer = fPlayer; + } - public static HandlerList getHandlerList() { - return handlers; - } + public static HandlerList getHandlerList() { + return handlers; + } - public HandlerList getHandlers() { - return handlers; - } + public HandlerList getHandlers() { + return handlers; + } - @Override - public FPlayer getfPlayer() { - return fPlayer; - } + @Override + public FPlayer getfPlayer() { + return fPlayer; + } - public Faction getFactionTo() { - return factionTo; - } + public Faction getFactionTo() { + return factionTo; + } - public Faction getFactionFrom() { - return factionFrom; - } + public Faction getFactionFrom() { + return factionFrom; + } } diff --git a/src/main/java/com/massivecraft/factions/event/FPlayerJoinEvent.java b/src/main/java/com/massivecraft/factions/event/FPlayerJoinEvent.java index 1755bdff..fd9617da 100644 --- a/src/main/java/com/massivecraft/factions/event/FPlayerJoinEvent.java +++ b/src/main/java/com/massivecraft/factions/event/FPlayerJoinEvent.java @@ -9,34 +9,34 @@ import org.bukkit.event.Cancellable; */ public class FPlayerJoinEvent extends FactionPlayerEvent implements Cancellable { - PlayerJoinReason reason; - boolean cancelled = false; + PlayerJoinReason reason; + boolean cancelled = false; - public FPlayerJoinEvent(FPlayer fp, Faction f, PlayerJoinReason r) { - super(f, fp); - reason = r; - } + public FPlayerJoinEvent(FPlayer fp, Faction f, PlayerJoinReason r) { + super(f, fp); + reason = r; + } - /** - * Get the reason the player joined the faction. - * - * @return reason player joined the faction. - */ - public PlayerJoinReason getReason() { - return reason; - } + /** + * Get the reason the player joined the faction. + * + * @return reason player joined the faction. + */ + public PlayerJoinReason getReason() { + return reason; + } - @Override - public boolean isCancelled() { - return cancelled; - } + @Override + public boolean isCancelled() { + return cancelled; + } - @Override - public void setCancelled(boolean c) { - cancelled = c; - } + @Override + public void setCancelled(boolean c) { + cancelled = c; + } - public enum PlayerJoinReason { - CREATE, LEADER, COMMAND - } + public enum PlayerJoinReason { + CREATE, LEADER, COMMAND + } } \ No newline at end of file diff --git a/src/main/java/com/massivecraft/factions/event/FPlayerLeaveEvent.java b/src/main/java/com/massivecraft/factions/event/FPlayerLeaveEvent.java index 0ecb80d1..e9b764d9 100644 --- a/src/main/java/com/massivecraft/factions/event/FPlayerLeaveEvent.java +++ b/src/main/java/com/massivecraft/factions/event/FPlayerLeaveEvent.java @@ -6,35 +6,35 @@ import org.bukkit.event.Cancellable; public class FPlayerLeaveEvent extends FactionPlayerEvent implements Cancellable { - boolean cancelled = false; - private PlayerLeaveReason reason; + boolean cancelled = false; + private PlayerLeaveReason reason; - public FPlayerLeaveEvent(FPlayer p, Faction f, PlayerLeaveReason r) { - super(f, p); - reason = r; - } + public FPlayerLeaveEvent(FPlayer p, Faction f, PlayerLeaveReason r) { + super(f, p); + reason = r; + } - /** - * Get the reason the player left the faction. - * - * @return reason player left the faction. - */ - public PlayerLeaveReason getReason() { - return reason; - } + /** + * Get the reason the player left the faction. + * + * @return reason player left the faction. + */ + public PlayerLeaveReason getReason() { + return reason; + } - @Override - public boolean isCancelled() { - return cancelled; - } + @Override + public boolean isCancelled() { + return cancelled; + } - @Override - public void setCancelled(boolean c) { - // Don't let them cancel factions disbanding. - cancelled = reason != PlayerLeaveReason.DISBAND && reason != PlayerLeaveReason.RESET && c; - } + @Override + public void setCancelled(boolean c) { + // Don't let them cancel factions disbanding. + cancelled = reason != PlayerLeaveReason.DISBAND && reason != PlayerLeaveReason.RESET && c; + } - public enum PlayerLeaveReason { - KICKED, DISBAND, RESET, JOINOTHER, LEAVE, BANNED - } + public enum PlayerLeaveReason { + KICKED, DISBAND, RESET, JOINOTHER, LEAVE, BANNED + } } \ No newline at end of file diff --git a/src/main/java/com/massivecraft/factions/event/FPlayerStoppedFlying.java b/src/main/java/com/massivecraft/factions/event/FPlayerStoppedFlying.java index 5a80a15a..f2f283c8 100644 --- a/src/main/java/com/massivecraft/factions/event/FPlayerStoppedFlying.java +++ b/src/main/java/com/massivecraft/factions/event/FPlayerStoppedFlying.java @@ -4,25 +4,25 @@ import com.massivecraft.factions.FPlayer; import org.bukkit.event.HandlerList; public class FPlayerStoppedFlying extends FactionPlayerEvent { - private static final HandlerList handlers = new HandlerList(); - private FPlayer fPlayer; + private static final HandlerList handlers = new HandlerList(); + private FPlayer fPlayer; - public FPlayerStoppedFlying(FPlayer fPlayer) { - super(fPlayer.getFaction(), fPlayer); - this.fPlayer = fPlayer; - } + public FPlayerStoppedFlying(FPlayer fPlayer) { + super(fPlayer.getFaction(), fPlayer); + this.fPlayer = fPlayer; + } - public static HandlerList getHandlerList() { - return handlers; - } + public static HandlerList getHandlerList() { + return handlers; + } - @Override - public FPlayer getfPlayer() { - return fPlayer; - } + @Override + public FPlayer getfPlayer() { + return fPlayer; + } - public HandlerList getHandlers() { - return handlers; - } + public HandlerList getHandlers() { + return handlers; + } } diff --git a/src/main/java/com/massivecraft/factions/event/FactionCreateEvent.java b/src/main/java/com/massivecraft/factions/event/FactionCreateEvent.java index 18791908..afdd1ab4 100644 --- a/src/main/java/com/massivecraft/factions/event/FactionCreateEvent.java +++ b/src/main/java/com/massivecraft/factions/event/FactionCreateEvent.java @@ -12,41 +12,41 @@ import org.bukkit.event.HandlerList; */ public class FactionCreateEvent extends Event implements Cancellable { - private static final HandlerList handlers = new HandlerList(); + private static final HandlerList handlers = new HandlerList(); - private String factionTag; - private Player sender; - private boolean cancelled; + private String factionTag; + private Player sender; + private boolean cancelled; - public FactionCreateEvent(Player sender, String tag) { - this.factionTag = tag; - this.sender = sender; - this.cancelled = false; - } + public FactionCreateEvent(Player sender, String tag) { + this.factionTag = tag; + this.sender = sender; + this.cancelled = false; + } - public static HandlerList getHandlerList() { - return handlers; - } + public static HandlerList getHandlerList() { + return handlers; + } - public FPlayer getFPlayer() { - return FPlayers.getInstance().getByPlayer(sender); - } + public FPlayer getFPlayer() { + return FPlayers.getInstance().getByPlayer(sender); + } - public String getFactionTag() { - return factionTag; - } + public String getFactionTag() { + return factionTag; + } - public HandlerList getHandlers() { - return handlers; - } + public HandlerList getHandlers() { + return handlers; + } - @Override - public boolean isCancelled() { - return cancelled; - } + @Override + public boolean isCancelled() { + return cancelled; + } - @Override - public void setCancelled(boolean c) { - this.cancelled = c; - } + @Override + public void setCancelled(boolean c) { + this.cancelled = c; + } } \ No newline at end of file diff --git a/src/main/java/com/massivecraft/factions/event/FactionDisbandEvent.java b/src/main/java/com/massivecraft/factions/event/FactionDisbandEvent.java index 0555fa2a..1d810c27 100644 --- a/src/main/java/com/massivecraft/factions/event/FactionDisbandEvent.java +++ b/src/main/java/com/massivecraft/factions/event/FactionDisbandEvent.java @@ -11,42 +11,42 @@ import org.bukkit.event.Cancellable; */ public class FactionDisbandEvent extends FactionEvent implements Cancellable { - private final Player sender; - private final PlayerDisbandReason reason; - 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)); - this.sender = sender; - this.reason = reason; - } + public FactionDisbandEvent(Player sender, String factionId, PlayerDisbandReason reason) { + super(Factions.getInstance().getFactionById(factionId)); + this.sender = sender; + this.reason = reason; + } - public FPlayer getFPlayer() { - return FPlayers.getInstance().getByPlayer(sender); - } + public FPlayer getFPlayer() { + return FPlayers.getInstance().getByPlayer(sender); + } - public Player getPlayer() { - return sender; - } + public Player getPlayer() { + return sender; + } - public PlayerDisbandReason getReason() { - return reason; - } + public PlayerDisbandReason getReason() { + return reason; + } - @Override - public boolean isCancelled() { - return cancelled; - } + @Override + public boolean isCancelled() { + return cancelled; + } - @Override - public void setCancelled(boolean c) { - cancelled = c; - } + @Override + public void setCancelled(boolean c) { + cancelled = c; + } - public enum PlayerDisbandReason { - COMMAND, - PLUGIN, - INACTIVITY, - LEAVE, - } + public enum PlayerDisbandReason { + COMMAND, + PLUGIN, + INACTIVITY, + LEAVE, + } } diff --git a/src/main/java/com/massivecraft/factions/event/FactionEvent.java b/src/main/java/com/massivecraft/factions/event/FactionEvent.java index 892f0ac0..54595475 100644 --- a/src/main/java/com/massivecraft/factions/event/FactionEvent.java +++ b/src/main/java/com/massivecraft/factions/event/FactionEvent.java @@ -9,29 +9,29 @@ import org.bukkit.event.HandlerList; */ public class FactionEvent extends Event { - private static final HandlerList handlers = new HandlerList(); - private final Faction faction; + private static final HandlerList handlers = new HandlerList(); + private final Faction faction; - public FactionEvent(Faction faction) { - this.faction = faction; - } + public FactionEvent(Faction faction) { + this.faction = faction; + } - public static HandlerList getHandlerList() { - return handlers; - } + public static HandlerList getHandlerList() { + return handlers; + } - /** - * Get the Faction involved in the event. - * - * @return faction involved in the event. - */ - public Faction getFaction() { - return this.faction; - } + /** + * Get the Faction involved in the event. + * + * @return faction involved in the event. + */ + public Faction getFaction() { + return this.faction; + } - @Override - public HandlerList getHandlers() { - return handlers; - } + @Override + public HandlerList getHandlers() { + return handlers; + } } diff --git a/src/main/java/com/massivecraft/factions/event/FactionPlayerEvent.java b/src/main/java/com/massivecraft/factions/event/FactionPlayerEvent.java index 3a76dcdd..ca0f86f4 100644 --- a/src/main/java/com/massivecraft/factions/event/FactionPlayerEvent.java +++ b/src/main/java/com/massivecraft/factions/event/FactionPlayerEvent.java @@ -8,14 +8,14 @@ import com.massivecraft.factions.Faction; */ public class FactionPlayerEvent extends FactionEvent { - protected final FPlayer fPlayer; + protected final FPlayer fPlayer; - public FactionPlayerEvent(Faction faction, FPlayer fPlayer) { - super(faction); - this.fPlayer = fPlayer; - } + public FactionPlayerEvent(Faction faction, FPlayer fPlayer) { + super(faction); + this.fPlayer = fPlayer; + } - public FPlayer getfPlayer() { - return this.fPlayer; - } + public FPlayer getfPlayer() { + return this.fPlayer; + } } diff --git a/src/main/java/com/massivecraft/factions/event/FactionRelationEvent.java b/src/main/java/com/massivecraft/factions/event/FactionRelationEvent.java index 761fd1a4..93b6cab2 100644 --- a/src/main/java/com/massivecraft/factions/event/FactionRelationEvent.java +++ b/src/main/java/com/massivecraft/factions/event/FactionRelationEvent.java @@ -10,41 +10,41 @@ import org.bukkit.event.HandlerList; */ public class FactionRelationEvent extends Event { - private static final HandlerList handlers = new HandlerList(); + private static final HandlerList handlers = new HandlerList(); - private Faction fsender; - private Faction ftarget; - private Relation foldrel; - private Relation frel; + private Faction fsender; + private Faction ftarget; + private Relation foldrel; + private Relation frel; - public FactionRelationEvent(Faction sender, Faction target, Relation oldrel, Relation rel) { - fsender = sender; - ftarget = target; - foldrel = oldrel; - frel = rel; - } + public FactionRelationEvent(Faction sender, Faction target, Relation oldrel, Relation rel) { + fsender = sender; + ftarget = target; + foldrel = oldrel; + frel = rel; + } - public static HandlerList getHandlerList() { - return handlers; - } + public static HandlerList getHandlerList() { + return handlers; + } - public HandlerList getHandlers() { - return handlers; - } + public HandlerList getHandlers() { + return handlers; + } - public Relation getOldRelation() { - return foldrel; - } + public Relation getOldRelation() { + return foldrel; + } - public Relation getRelation() { - return frel; - } + public Relation getRelation() { + return frel; + } - public Faction getFaction() { - return fsender; - } + public Faction getFaction() { + return fsender; + } - public Faction getTargetFaction() { - return ftarget; - } + public Faction getTargetFaction() { + return ftarget; + } } diff --git a/src/main/java/com/massivecraft/factions/event/FactionRelationWishEvent.java b/src/main/java/com/massivecraft/factions/event/FactionRelationWishEvent.java index dfdc6ef6..8590f7b4 100644 --- a/src/main/java/com/massivecraft/factions/event/FactionRelationWishEvent.java +++ b/src/main/java/com/massivecraft/factions/event/FactionRelationWishEvent.java @@ -6,39 +6,39 @@ import com.massivecraft.factions.struct.Relation; import org.bukkit.event.Cancellable; public class FactionRelationWishEvent extends FactionPlayerEvent implements Cancellable { - private final Faction targetFaction; - private final Relation currentRelation; - private final Relation targetRelation; + private final Faction targetFaction; + private final Relation currentRelation; + private final Relation targetRelation; - private boolean cancelled; + private boolean cancelled; - public FactionRelationWishEvent(FPlayer caller, Faction sender, Faction targetFaction, Relation currentRelation, Relation targetRelation) { - super(sender, caller); + public FactionRelationWishEvent(FPlayer caller, Faction sender, Faction targetFaction, Relation currentRelation, Relation targetRelation) { + super(sender, caller); - this.targetFaction = targetFaction; - this.currentRelation = currentRelation; - this.targetRelation = targetRelation; - } + this.targetFaction = targetFaction; + this.currentRelation = currentRelation; + this.targetRelation = targetRelation; + } - public Faction getTargetFaction() { - return targetFaction; - } + public Faction getTargetFaction() { + return targetFaction; + } - public Relation getCurrentRelation() { - return currentRelation; - } + public Relation getCurrentRelation() { + return currentRelation; + } - public Relation getTargetRelation() { - return targetRelation; - } + public Relation getTargetRelation() { + return targetRelation; + } - @Override - public boolean isCancelled() { - return cancelled; - } + @Override + public boolean isCancelled() { + return cancelled; + } - @Override - public void setCancelled(boolean cancelled) { - this.cancelled = cancelled; - } + @Override + public void setCancelled(boolean cancelled) { + this.cancelled = cancelled; + } } diff --git a/src/main/java/com/massivecraft/factions/event/FactionRenameEvent.java b/src/main/java/com/massivecraft/factions/event/FactionRenameEvent.java index cedeec77..8dc8f022 100644 --- a/src/main/java/com/massivecraft/factions/event/FactionRenameEvent.java +++ b/src/main/java/com/massivecraft/factions/event/FactionRenameEvent.java @@ -6,52 +6,52 @@ import org.bukkit.event.Cancellable; public class FactionRenameEvent extends FactionPlayerEvent implements Cancellable { - private boolean cancelled = false; - private String tag; + private boolean cancelled = false; + private String tag; - public FactionRenameEvent(FPlayer sender, String newTag) { - super(sender.getFaction(), sender); - tag = newTag; - } + public FactionRenameEvent(FPlayer sender, String newTag) { + super(sender.getFaction(), sender); + tag = newTag; + } - /** - * Get the player involved in the event. - * - * @return Player involved in the event. - * @deprecated use getfPlayer().getPlayer() instead. - */ - @Deprecated - public Player getPlayer() { - return getfPlayer().getPlayer(); - } + /** + * Get the player involved in the event. + * + * @return Player involved in the event. + * @deprecated use getfPlayer().getPlayer() instead. + */ + @Deprecated + public Player getPlayer() { + return getfPlayer().getPlayer(); + } - /** - * Get the faction tag before it was renamed. - * - * @return old faction tag. - * @deprecated use getFaction().getTag() instead. - */ - @Deprecated - public String getOldFactionTag() { - return getFaction().getTag(); - } + /** + * Get the faction tag before it was renamed. + * + * @return old faction tag. + * @deprecated use getFaction().getTag() instead. + */ + @Deprecated + public String getOldFactionTag() { + return getFaction().getTag(); + } - /** - * Get the new faction tag. - * - * @return new faction tag as String. - */ - public String getFactionTag() { - return tag; - } + /** + * Get the new faction tag. + * + * @return new faction tag as String. + */ + public String getFactionTag() { + return tag; + } - @Override - public boolean isCancelled() { - return cancelled; - } + @Override + public boolean isCancelled() { + return cancelled; + } - @Override - public void setCancelled(boolean c) { - this.cancelled = c; - } + @Override + public void setCancelled(boolean c) { + this.cancelled = c; + } } diff --git a/src/main/java/com/massivecraft/factions/event/LandClaimEvent.java b/src/main/java/com/massivecraft/factions/event/LandClaimEvent.java index 223d6852..8bef95f0 100644 --- a/src/main/java/com/massivecraft/factions/event/LandClaimEvent.java +++ b/src/main/java/com/massivecraft/factions/event/LandClaimEvent.java @@ -11,64 +11,64 @@ import org.bukkit.event.Cancellable; */ public class LandClaimEvent extends FactionPlayerEvent implements Cancellable { - private boolean cancelled; - private FLocation location; + private boolean cancelled; + private FLocation location; - public LandClaimEvent(FLocation loc, Faction f, FPlayer p) { - super(f, p); - cancelled = false; - location = loc; - } + public LandClaimEvent(FLocation loc, Faction f, FPlayer p) { + super(f, p); + cancelled = false; + location = loc; + } - /** - * Get the FLocation involved in this event. - * - * @return the FLocation (also a chunk) involved in this event. - */ - public FLocation getLocation() { - return this.location; - } + /** + * Get the FLocation involved in this event. + * + * @return the FLocation (also a chunk) involved in this event. + */ + public FLocation getLocation() { + return this.location; + } - /** - * Get the id of the faction. - * - * @return id of faction as String - * @deprecated use getFaction().getId() instead. - */ - @Deprecated - public String getFactionId() { - return getFaction().getId(); - } + /** + * Get the id of the faction. + * + * @return id of faction as String + * @deprecated use getFaction().getId() instead. + */ + @Deprecated + public String getFactionId() { + return getFaction().getId(); + } - /** - * Get the tag of the faction. - * - * @return tag of faction as String - * @deprecated use getFaction().getTag() instead. - */ - @Deprecated - public String getFactionTag() { - return getFaction().getTag(); - } + /** + * Get the tag of the faction. + * + * @return tag of faction as String + * @deprecated use getFaction().getTag() instead. + */ + @Deprecated + public String getFactionTag() { + return getFaction().getTag(); + } - /** - * Get the Player involved in this event. - * - * @return player from FPlayer. - * @deprecated use getfPlayer().getPlayer() instead. - */ - @Deprecated - public Player getPlayer() { - return getfPlayer().getPlayer(); - } + /** + * Get the Player involved in this event. + * + * @return player from FPlayer. + * @deprecated use getfPlayer().getPlayer() instead. + */ + @Deprecated + public Player getPlayer() { + return getfPlayer().getPlayer(); + } - @Override - public boolean isCancelled() { - return cancelled; - } + @Override + public boolean isCancelled() { + return cancelled; + } - @Override - public void setCancelled(boolean c) { - this.cancelled = c; - } + @Override + public void setCancelled(boolean c) { + this.cancelled = c; + } } diff --git a/src/main/java/com/massivecraft/factions/event/LandUnclaimAllEvent.java b/src/main/java/com/massivecraft/factions/event/LandUnclaimAllEvent.java index 47dfa00f..5b807bfd 100644 --- a/src/main/java/com/massivecraft/factions/event/LandUnclaimAllEvent.java +++ b/src/main/java/com/massivecraft/factions/event/LandUnclaimAllEvent.java @@ -6,52 +6,52 @@ import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; public class LandUnclaimAllEvent extends FactionPlayerEvent implements Cancellable { - private boolean cancelled; + private boolean cancelled; - public LandUnclaimAllEvent(Faction f, FPlayer p) { - super(f, p); - } + public LandUnclaimAllEvent(Faction f, FPlayer p) { + super(f, p); + } - /** - * Get the id of the faction. - * - * @return id of faction as String - * @deprecated use getFaction().getId() instead. - */ - @Deprecated - public String getFactionId() { - return getFaction().getId(); - } + /** + * Get the id of the faction. + * + * @return id of faction as String + * @deprecated use getFaction().getId() instead. + */ + @Deprecated + public String getFactionId() { + return getFaction().getId(); + } - /** - * Get the tag of the faction. - * - * @return tag of faction as String - * @deprecated use getFaction().getTag() instead. - */ - @Deprecated - public String getFactionTag() { - return getFaction().getTag(); - } + /** + * Get the tag of the faction. + * + * @return tag of faction as String + * @deprecated use getFaction().getTag() instead. + */ + @Deprecated + public String getFactionTag() { + return getFaction().getTag(); + } - /** - * Get the Player involved in the event. - * - * @return Player from FPlayer. - * @deprecated use getfPlayer().getPlayer() instead. - */ - @Deprecated - public Player getPlayer() { - return getfPlayer().getPlayer(); - } + /** + * Get the Player involved in the event. + * + * @return Player from FPlayer. + * @deprecated use getfPlayer().getPlayer() instead. + */ + @Deprecated + public Player getPlayer() { + return getfPlayer().getPlayer(); + } - @Override - public boolean isCancelled() { - return cancelled; - } + @Override + public boolean isCancelled() { + return cancelled; + } - @Override - public void setCancelled(boolean cancelled) { - this.cancelled = cancelled; - } + @Override + public void setCancelled(boolean cancelled) { + this.cancelled = cancelled; + } } diff --git a/src/main/java/com/massivecraft/factions/event/LandUnclaimEvent.java b/src/main/java/com/massivecraft/factions/event/LandUnclaimEvent.java index 72ae23c3..402f50e3 100644 --- a/src/main/java/com/massivecraft/factions/event/LandUnclaimEvent.java +++ b/src/main/java/com/massivecraft/factions/event/LandUnclaimEvent.java @@ -11,59 +11,59 @@ import org.bukkit.event.Cancellable; */ public class LandUnclaimEvent extends FactionPlayerEvent implements Cancellable { - private boolean cancelled; - private FLocation location; + private boolean cancelled; + private FLocation location; - public LandUnclaimEvent(FLocation loc, Faction f, FPlayer p) { - super(f, p); - cancelled = false; - location = loc; - } + public LandUnclaimEvent(FLocation loc, Faction f, FPlayer p) { + super(f, p); + cancelled = false; + location = loc; + } - public FLocation getLocation() { - return this.location; - } + public FLocation getLocation() { + return this.location; + } - /** - * Get the id of the faction. - * - * @return id of faction as String - * @deprecated use getFaction().getId() instead. - */ - @Deprecated - public String getFactionId() { - return getFaction().getId(); - } + /** + * Get the id of the faction. + * + * @return id of faction as String + * @deprecated use getFaction().getId() instead. + */ + @Deprecated + public String getFactionId() { + return getFaction().getId(); + } - /** - * Get the tag of the faction. - * - * @return tag of faction as String - * @deprecated use getFaction().getTag() instead. - */ - @Deprecated - public String getFactionTag() { - return getFaction().getTag(); - } + /** + * Get the tag of the faction. + * + * @return tag of faction as String + * @deprecated use getFaction().getTag() instead. + */ + @Deprecated + public String getFactionTag() { + return getFaction().getTag(); + } - /** - * Get the Player involved in the event. - * - * @return Player from FPlayer. - * @deprecated use getfPlayer().getPlayer() instead. - */ - @Deprecated - public Player getPlayer() { - return getfPlayer().getPlayer(); - } + /** + * Get the Player involved in the event. + * + * @return Player from FPlayer. + * @deprecated use getfPlayer().getPlayer() instead. + */ + @Deprecated + public Player getPlayer() { + return getfPlayer().getPlayer(); + } - @Override - public boolean isCancelled() { - return cancelled; - } + @Override + public boolean isCancelled() { + return cancelled; + } - @Override - public void setCancelled(boolean c) { - cancelled = c; - } + @Override + public void setCancelled(boolean c) { + cancelled = c; + } } diff --git a/src/main/java/com/massivecraft/factions/event/PowerLossEvent.java b/src/main/java/com/massivecraft/factions/event/PowerLossEvent.java index 6304e39c..45a5b19b 100644 --- a/src/main/java/com/massivecraft/factions/event/PowerLossEvent.java +++ b/src/main/java/com/massivecraft/factions/event/PowerLossEvent.java @@ -10,72 +10,72 @@ import org.bukkit.event.Cancellable; */ public class PowerLossEvent extends FactionPlayerEvent implements Cancellable { - private boolean cancelled = false; - private String message; + private boolean cancelled = false; + private String message; - public PowerLossEvent(Faction f, FPlayer p) { - super(f, p); - } + public PowerLossEvent(Faction f, FPlayer p) { + super(f, p); + } - /** - * Get the id of the faction. - * - * @return id of faction as String - * @deprecated use getFaction().getId() instead. - */ - @Deprecated - public String getFactionId() { - return getFaction().getId(); - } + /** + * Get the id of the faction. + * + * @return id of faction as String + * @deprecated use getFaction().getId() instead. + */ + @Deprecated + public String getFactionId() { + return getFaction().getId(); + } - /** - * Get the tag of the faction. - * - * @return tag of faction as String - * @deprecated use getFaction().getTag() instead. - */ - @Deprecated - public String getFactionTag() { - return getFaction().getTag(); - } + /** + * Get the tag of the faction. + * + * @return tag of faction as String + * @deprecated use getFaction().getTag() instead. + */ + @Deprecated + public String getFactionTag() { + return getFaction().getTag(); + } - /** - * Get the Player involved in the event. - * - * @return Player from FPlayer. - * @deprecated use getfPlayer().getPlayer() instead. - */ - @Deprecated - public Player getPlayer() { - return getfPlayer().getPlayer(); - } + /** + * Get the Player involved in the event. + * + * @return Player from FPlayer. + * @deprecated use getfPlayer().getPlayer() instead. + */ + @Deprecated + public Player getPlayer() { + return getfPlayer().getPlayer(); + } - /** - * Get the power loss message. - * - * @return power loss message as String. - */ - public String getMessage() { - return message; - } + /** + * Get the power loss message. + * + * @return power loss message as String. + */ + public String getMessage() { + return message; + } - /** - * Set the power loss message. - * - * @param message of powerloss - */ - public void setMessage(String message) { - this.message = message; - } + /** + * Set the power loss message. + * + * @param message of powerloss + */ + public void setMessage(String message) { + this.message = message; + } - @Override - public boolean isCancelled() { - return cancelled; - } + @Override + public boolean isCancelled() { + return cancelled; + } - @Override - public void setCancelled(boolean c) { - this.cancelled = c; - } + @Override + public void setCancelled(boolean c) { + this.cancelled = c; + } } diff --git a/src/main/java/com/massivecraft/factions/event/PowerRegenEvent.java b/src/main/java/com/massivecraft/factions/event/PowerRegenEvent.java index e1782b8d..b9a7ec2c 100644 --- a/src/main/java/com/massivecraft/factions/event/PowerRegenEvent.java +++ b/src/main/java/com/massivecraft/factions/event/PowerRegenEvent.java @@ -9,20 +9,20 @@ import org.bukkit.event.Cancellable; */ public class PowerRegenEvent extends FactionPlayerEvent implements Cancellable { - private boolean cancelled = false; + private boolean cancelled = false; - public PowerRegenEvent(Faction f, FPlayer p) { - super(f, p); - } + public PowerRegenEvent(Faction f, FPlayer p) { + super(f, p); + } - @Override - public boolean isCancelled() { - return cancelled; - } + @Override + public boolean isCancelled() { + return cancelled; + } - @Override - public void setCancelled(boolean c) { - this.cancelled = c; - } + @Override + public void setCancelled(boolean c) { + this.cancelled = c; + } } diff --git a/src/main/java/com/massivecraft/factions/iface/EconomyParticipator.java b/src/main/java/com/massivecraft/factions/iface/EconomyParticipator.java index 2d8f4624..9ceeb827 100644 --- a/src/main/java/com/massivecraft/factions/iface/EconomyParticipator.java +++ b/src/main/java/com/massivecraft/factions/iface/EconomyParticipator.java @@ -4,9 +4,9 @@ import com.massivecraft.factions.zcore.util.TL; public interface EconomyParticipator extends RelationParticipator { - String getAccountId(); + String getAccountId(); - void msg(String str, Object... args); + void msg(String str, Object... args); - void msg(TL translation, 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 781bed18..a536c43b 100644 --- a/src/main/java/com/massivecraft/factions/iface/RelationParticipator.java +++ b/src/main/java/com/massivecraft/factions/iface/RelationParticipator.java @@ -5,13 +5,13 @@ import org.bukkit.ChatColor; public interface RelationParticipator { - String describeTo(RelationParticipator that); + String describeTo(RelationParticipator that); - String describeTo(RelationParticipator that, boolean ucfirst); + String describeTo(RelationParticipator that, boolean ucfirst); - Relation getRelationTo(RelationParticipator that); + Relation getRelationTo(RelationParticipator that); - Relation getRelationTo(RelationParticipator that, boolean ignorePeaceful); + Relation getRelationTo(RelationParticipator that, boolean ignorePeaceful); - ChatColor getColorTo(RelationParticipator to); + 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 fe736b86..216163a3 100644 --- a/src/main/java/com/massivecraft/factions/integration/Econ.java +++ b/src/main/java/com/massivecraft/factions/integration/Econ.java @@ -24,425 +24,425 @@ import java.util.logging.Level; public class Econ { - private static final DecimalFormat format = new DecimalFormat(TL.ECON_FORMAT.toString()); - private static Economy econ = null; + private static final DecimalFormat format = new DecimalFormat(TL.ECON_FORMAT.toString()); + private static Economy econ = null; - public static void setup() { - if (isSetup()) { - return; - } + public static void setup() { + if (isSetup()) { + return; + } - String integrationFail = "Economy integration is " + (Conf.econEnabled ? "enabled, but" : "disabled, and") + " the plugin \"Vault\" "; + String integrationFail = "Economy integration is " + (Conf.econEnabled ? "enabled, but" : "disabled, and") + " the plugin \"Vault\" "; - if (Bukkit.getServer().getPluginManager().getPlugin("Vault") == null) { - P.p.log(integrationFail + "is not installed."); - return; - } + if (Bukkit.getServer().getPluginManager().getPlugin("Vault") == null) { + P.p.log(integrationFail + "is not installed."); + return; + } - RegisteredServiceProvider rsp = Bukkit.getServer().getServicesManager().getRegistration(Economy.class); - if (rsp == null) { - P.p.log(integrationFail + "is not hooked into an economy plugin."); - return; - } - econ = rsp.getProvider(); + RegisteredServiceProvider rsp = Bukkit.getServer().getServicesManager().getRegistration(Economy.class); + if (rsp == null) { + P.p.log(integrationFail + "is not hooked into an economy plugin."); + return; + } + econ = rsp.getProvider(); - P.p.log("Economy integration through Vault plugin successful."); + P.p.log("Economy integration through Vault plugin successful."); - if (!Conf.econEnabled) { - P.p.log("NOTE: Economy is disabled. You can enable it with the command: f config econEnabled true"); - } + if (!Conf.econEnabled) { + P.p.log("NOTE: Economy is disabled. You can enable it with the command: f config econEnabled true"); + } - P.p.cmdBase.cmdHelp.updateHelp(); - } + P.p.cmdBase.cmdHelp.updateHelp(); + } - public static boolean shouldBeUsed() { - return Conf.econEnabled && econ != null && econ.isEnabled(); - } + public static boolean shouldBeUsed() { + return Conf.econEnabled && econ != null && econ.isEnabled(); + } - public static boolean isSetup() { - return econ != null; - } + public static boolean isSetup() { + return econ != null; + } - public static void modifyUniverseMoney(double delta) { - if (!shouldBeUsed()) { - return; - } + public static void modifyUniverseMoney(double delta) { + if (!shouldBeUsed()) { + return; + } - if (Conf.econUniverseAccount == null) { - return; - } - if (Conf.econUniverseAccount.length() == 0) { - return; - } - if (!econ.hasAccount(Conf.econUniverseAccount)) { - return; - } + if (Conf.econUniverseAccount == null) { + return; + } + if (Conf.econUniverseAccount.length() == 0) { + return; + } + if (!econ.hasAccount(Conf.econUniverseAccount)) { + return; + } - modifyBalance(Conf.econUniverseAccount, delta); - } + modifyBalance(Conf.econUniverseAccount, delta); + } - public static void sendBalanceInfo(CommandSender to, Faction about) { - if (!shouldBeUsed()) { - P.p.log(Level.WARNING, "Vault does not appear to be hooked into an economy plugin."); - return; - } - to.sendMessage(String.format("%s's balance is %s.", about.getTag(), Econ.moneyString(econ.getBalance(about.getAccountId())))); - } + public static void sendBalanceInfo(CommandSender to, Faction about) { + if (!shouldBeUsed()) { + P.p.log(Level.WARNING, "Vault does not appear to be hooked into an economy plugin."); + return; + } + to.sendMessage(String.format("%s's balance is %s.", about.getTag(), Econ.moneyString(econ.getBalance(about.getAccountId())))); + } - public static boolean canIControllYou(EconomyParticipator i, EconomyParticipator you) { - Faction fI = RelationUtil.getFaction(i); - Faction fYou = RelationUtil.getFaction(you); + public static boolean canIControllYou(EconomyParticipator i, EconomyParticipator you) { + Faction fI = RelationUtil.getFaction(i); + Faction fYou = RelationUtil.getFaction(you); - // This is a system invoker. Accept it. - if (fI == null) { - return true; - } + // This is a system invoker. Accept it. + if (fI == null) { + return true; + } - // Bypassing players can do any kind of transaction - if (i instanceof FPlayer && ((FPlayer) i).isAdminBypassing()) { - return true; - } + // Bypassing players can do any kind of transaction + if (i instanceof FPlayer && ((FPlayer) i).isAdminBypassing()) { + return true; + } - // Players with the any withdraw can do. - if (i instanceof FPlayer && Permission.MONEY_WITHDRAW_ANY.has(((FPlayer) i).getPlayer())) { - return true; - } + // Players with the any withdraw can do. + if (i instanceof FPlayer && Permission.MONEY_WITHDRAW_ANY.has(((FPlayer) i).getPlayer())) { + return true; + } - // You can deposit to anywhere you feel like. It's your loss if you can't withdraw it again. - if (i == you) { - return true; - } + // You can deposit to anywhere you feel like. It's your loss if you can't withdraw it again. + if (i == you) { + return true; + } - // A faction can always transfer away the money of it's members and its own money... - // This will however probably never happen as a faction does not have free will. - // Ohh by the way... Yes it could. For daily rent to the faction. - if (i == fI && fI == fYou) { - return true; - } + // A faction can always transfer away the money of it's members and its own money... + // This will however probably never happen as a faction does not have free will. + // Ohh by the way... Yes it could. For daily rent to the faction. + if (i == fI && fI == fYou) { + return true; + } - // Factions can be controlled by members that are moderators... or any member if any member can withdraw. - if (you instanceof Faction && fI == fYou && (Conf.bankMembersCanWithdraw || ((FPlayer) i).getRole().value >= Role.MODERATOR.value)) { - return true; - } + // Factions can be controlled by members that are moderators... or any member if any member can withdraw. + if (you instanceof Faction && fI == fYou && (Conf.bankMembersCanWithdraw || ((FPlayer) i).getRole().value >= Role.MODERATOR.value)) { + return true; + } - // Otherwise you may not!;,,; - i.msg("%s lacks permission to control %s's money.", i.describeTo(i, true), you.describeTo(i)); - return false; - } + // Otherwise you may not!;,,; + i.msg("%s lacks permission to control %s's money.", i.describeTo(i, true), you.describeTo(i)); + return false; + } - public static boolean transferMoney(EconomyParticipator invoker, EconomyParticipator from, EconomyParticipator to, double amount) { - return transferMoney(invoker, from, to, amount, true); - } + public static boolean transferMoney(EconomyParticipator invoker, EconomyParticipator from, EconomyParticipator to, double amount) { + return transferMoney(invoker, from, to, amount, true); + } - public static boolean transferMoney(EconomyParticipator invoker, EconomyParticipator from, EconomyParticipator to, double amount, boolean notify) { - if (!shouldBeUsed()) { - invoker.msg(TL.ECON_OFF); - return false; - } + public static boolean transferMoney(EconomyParticipator invoker, EconomyParticipator from, EconomyParticipator to, double amount, boolean notify) { + if (!shouldBeUsed()) { + invoker.msg(TL.ECON_OFF); + return false; + } - // The amount must be positive. - // If the amount is negative we must flip and multiply amount with -1. - if (amount < 0) { - amount *= -1; - EconomyParticipator temp = from; - from = to; - to = temp; - } + // The amount must be positive. + // If the amount is negative we must flip and multiply amount with -1. + if (amount < 0) { + amount *= -1; + EconomyParticipator temp = from; + from = to; + to = temp; + } - // Check the rights - if (!canIControllYou(invoker, from)) { - return false; - } + // Check the rights + if (!canIControllYou(invoker, from)) { + return false; + } - OfflinePlayer fromAcc; - OfflinePlayer toAcc; + OfflinePlayer fromAcc; + OfflinePlayer toAcc; - if (isUUID(from.getAccountId())) { - fromAcc = Bukkit.getOfflinePlayer(UUID.fromString(from.getAccountId())); - if (fromAcc.getName() == null) { - return false; - } - } else { - fromAcc = Bukkit.getOfflinePlayer(from.getAccountId()); - } + if (isUUID(from.getAccountId())) { + fromAcc = Bukkit.getOfflinePlayer(UUID.fromString(from.getAccountId())); + if (fromAcc.getName() == null) { + return false; + } + } else { + fromAcc = Bukkit.getOfflinePlayer(from.getAccountId()); + } - if (isUUID(to.getAccountId())) { - toAcc = Bukkit.getOfflinePlayer(UUID.fromString(to.getAccountId())); - if (toAcc.getName() == null) { - return false; - } - } else { - toAcc = Bukkit.getOfflinePlayer(to.getAccountId()); - } + if (isUUID(to.getAccountId())) { + toAcc = Bukkit.getOfflinePlayer(UUID.fromString(to.getAccountId())); + if (toAcc.getName() == null) { + return false; + } + } else { + toAcc = Bukkit.getOfflinePlayer(to.getAccountId()); + } - // Is there enough money for the transaction to happen? - if (!econ.has(fromAcc, amount)) { - // There was not enough money to pay - if (invoker != null && notify) { - invoker.msg("%s can't afford to transfer %s to %s.", from.describeTo(invoker, true), moneyString(amount), to.describeTo(invoker)); - } + // Is there enough money for the transaction to happen? + if (!econ.has(fromAcc, amount)) { + // There was not enough money to pay + if (invoker != null && notify) { + invoker.msg("%s can't afford to transfer %s to %s.", from.describeTo(invoker, true), moneyString(amount), to.describeTo(invoker)); + } - return false; - } + return false; + } - // Check if the new balance is over Essential's money cap. - if (Essentials.isOverBalCap(to, econ.getBalance(toAcc) + amount)) { - invoker.msg(TL.ECON_OVER_BAL_CAP, amount); - return false; - } + // Check if the new balance is over Essential's money cap. + if (Essentials.isOverBalCap(to, econ.getBalance(toAcc) + amount)) { + invoker.msg(TL.ECON_OVER_BAL_CAP, amount); + return false; + } - // Transfer money - EconomyResponse erw = econ.withdrawPlayer(fromAcc, amount); + // Transfer money + EconomyResponse erw = econ.withdrawPlayer(fromAcc, amount); - if (erw.transactionSuccess()) { - EconomyResponse erd = econ.depositPlayer(toAcc, amount); - if (erd.transactionSuccess()) { - if (notify) { - sendTransferInfo(invoker, from, to, amount); - } - return true; - } else { - // transaction failed, refund account - econ.depositPlayer(fromAcc, amount); - } - } + if (erw.transactionSuccess()) { + EconomyResponse erd = econ.depositPlayer(toAcc, amount); + if (erd.transactionSuccess()) { + if (notify) { + sendTransferInfo(invoker, from, to, amount); + } + return true; + } else { + // transaction failed, refund account + econ.depositPlayer(fromAcc, amount); + } + } - // if we get here something with the transaction failed - if (notify) { - invoker.msg("Unable to transfer %s to %s from %s.", moneyString(amount), to.describeTo(invoker), from.describeTo(invoker, true)); - } + // if we get here something with the transaction failed + if (notify) { + invoker.msg("Unable to transfer %s to %s from %s.", moneyString(amount), to.describeTo(invoker), from.describeTo(invoker, true)); + } - return false; - } + return false; + } - public static Set getFplayers(EconomyParticipator ep) { - Set fplayers = new HashSet<>(); + public static Set getFplayers(EconomyParticipator ep) { + Set fplayers = new HashSet<>(); - if (ep != null) { - if (ep instanceof FPlayer) { - fplayers.add((FPlayer) ep); - } else if (ep instanceof Faction) { - fplayers.addAll(((Faction) ep).getFPlayers()); - } - } + if (ep != null) { + if (ep instanceof FPlayer) { + fplayers.add((FPlayer) ep); + } else if (ep instanceof Faction) { + fplayers.addAll(((Faction) ep).getFPlayers()); + } + } - return fplayers; - } + return fplayers; + } - public static void sendTransferInfo(EconomyParticipator invoker, EconomyParticipator from, EconomyParticipator to, double amount) { - Set recipients = new HashSet<>(); - recipients.addAll(getFplayers(invoker)); - recipients.addAll(getFplayers(from)); - recipients.addAll(getFplayers(to)); + public static void sendTransferInfo(EconomyParticipator invoker, EconomyParticipator from, EconomyParticipator to, double amount) { + Set recipients = new HashSet<>(); + recipients.addAll(getFplayers(invoker)); + recipients.addAll(getFplayers(from)); + recipients.addAll(getFplayers(to)); - if (invoker == null) { - for (FPlayer recipient : recipients) { - recipient.msg("%s was transferred from %s to %s.", moneyString(amount), from.describeTo(recipient), to.describeTo(recipient)); - } - } else if (invoker == from) { - for (FPlayer recipient : recipients) { - recipient.msg("%s gave %s to %s.", from.describeTo(recipient, true), moneyString(amount), to.describeTo(recipient)); - } - } else if (invoker == to) { - for (FPlayer recipient : recipients) { - recipient.msg("%s took %s from %s.", to.describeTo(recipient, true), moneyString(amount), from.describeTo(recipient)); - } - } else { - for (FPlayer recipient : recipients) { - recipient.msg("%s transferred %s from %s to %s.", invoker.describeTo(recipient, true), moneyString(amount), from.describeTo(recipient), to.describeTo(recipient)); - } - } - } + if (invoker == null) { + for (FPlayer recipient : recipients) { + recipient.msg("%s was transferred from %s to %s.", moneyString(amount), from.describeTo(recipient), to.describeTo(recipient)); + } + } else if (invoker == from) { + for (FPlayer recipient : recipients) { + recipient.msg("%s gave %s to %s.", from.describeTo(recipient, true), moneyString(amount), to.describeTo(recipient)); + } + } else if (invoker == to) { + for (FPlayer recipient : recipients) { + recipient.msg("%s took %s from %s.", to.describeTo(recipient, true), moneyString(amount), from.describeTo(recipient)); + } + } else { + for (FPlayer recipient : recipients) { + recipient.msg("%s transferred %s from %s to %s.", invoker.describeTo(recipient, true), moneyString(amount), from.describeTo(recipient), to.describeTo(recipient)); + } + } + } - public static boolean hasAtLeast(EconomyParticipator ep, double delta, String toDoThis) { - if (!shouldBeUsed()) { - return true; - } + public static boolean hasAtLeast(EconomyParticipator ep, double delta, String toDoThis) { + if (!shouldBeUsed()) { + return true; + } - // going the hard way round as econ.has refuses to work. - boolean affordable = false; - double currentBalance; + // going the hard way round as econ.has refuses to work. + boolean affordable = false; + double currentBalance; - if (isUUID(ep.getAccountId())) { - OfflinePlayer offline = Bukkit.getOfflinePlayer(UUID.fromString(ep.getAccountId())); - if (offline.getName() != null) { - currentBalance = econ.getBalance(Bukkit.getOfflinePlayer(UUID.fromString(ep.getAccountId()))); - } else { - currentBalance = 0; - } - } else { - currentBalance = econ.getBalance(ep.getAccountId()); - } + if (isUUID(ep.getAccountId())) { + OfflinePlayer offline = Bukkit.getOfflinePlayer(UUID.fromString(ep.getAccountId())); + if (offline.getName() != null) { + currentBalance = econ.getBalance(Bukkit.getOfflinePlayer(UUID.fromString(ep.getAccountId()))); + } else { + currentBalance = 0; + } + } else { + currentBalance = econ.getBalance(ep.getAccountId()); + } - if (currentBalance >= delta) { - affordable = true; - } + if (currentBalance >= delta) { + affordable = true; + } - if (!affordable) { - if (toDoThis != null && !toDoThis.isEmpty()) { - ep.msg("%s can't afford %s %s.", ep.describeTo(ep, true), moneyString(delta), toDoThis); - } - return false; - } - return true; - } + if (!affordable) { + if (toDoThis != null && !toDoThis.isEmpty()) { + ep.msg("%s can't afford %s %s.", ep.describeTo(ep, true), moneyString(delta), toDoThis); + } + return false; + } + return true; + } - public static boolean modifyMoney(EconomyParticipator ep, double delta, String toDoThis, String forDoingThis) { - if (!shouldBeUsed()) { - return false; - } + public static boolean modifyMoney(EconomyParticipator ep, double delta, String toDoThis, String forDoingThis) { + if (!shouldBeUsed()) { + return false; + } - OfflinePlayer acc; + OfflinePlayer acc; - if (isUUID(ep.getAccountId())) { - acc = Bukkit.getOfflinePlayer(UUID.fromString(ep.getAccountId())); - if (acc.getName() == null) { - return false; - } - } else { - acc = Bukkit.getOfflinePlayer(ep.getAccountId()); - } + if (isUUID(ep.getAccountId())) { + acc = Bukkit.getOfflinePlayer(UUID.fromString(ep.getAccountId())); + if (acc.getName() == null) { + return false; + } + } else { + acc = Bukkit.getOfflinePlayer(ep.getAccountId()); + } - String You = ep.describeTo(ep, true); + String You = ep.describeTo(ep, true); - if (delta == 0) { - // no money actually transferred? + if (delta == 0) { + // no money actually transferred? // ep.msg("%s didn't have to pay anything %s.", You, forDoingThis); // might be for gains, might be for losses - return true; - } + return true; + } - if (delta > 0) { - // The player should gain money - // The account might not have enough space - EconomyResponse er = econ.depositPlayer(acc, delta); - if (er.transactionSuccess()) { - modifyUniverseMoney(-delta); - if (forDoingThis != null && !forDoingThis.isEmpty()) { - ep.msg("%s gained %s %s.", You, moneyString(delta), forDoingThis); - } - return true; - } else { - // transfer to account failed - if (forDoingThis != null && !forDoingThis.isEmpty()) { - ep.msg("%s would have gained %s %s, but the deposit failed.", You, moneyString(delta), forDoingThis); - } - return false; - } - } else { - // The player should loose money - // The player might not have enough. + if (delta > 0) { + // The player should gain money + // The account might not have enough space + EconomyResponse er = econ.depositPlayer(acc, delta); + if (er.transactionSuccess()) { + modifyUniverseMoney(-delta); + if (forDoingThis != null && !forDoingThis.isEmpty()) { + ep.msg("%s gained %s %s.", You, moneyString(delta), forDoingThis); + } + return true; + } else { + // transfer to account failed + if (forDoingThis != null && !forDoingThis.isEmpty()) { + ep.msg("%s would have gained %s %s, but the deposit failed.", You, moneyString(delta), forDoingThis); + } + return false; + } + } else { + // The player should loose money + // The player might not have enough. - if (econ.has(acc, -delta) && econ.withdrawPlayer(acc, -delta).transactionSuccess()) { - // There is enough money to pay - modifyUniverseMoney(-delta); - if (forDoingThis != null && !forDoingThis.isEmpty()) { - 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); - } - return false; - } - } - } + if (econ.has(acc, -delta) && econ.withdrawPlayer(acc, -delta).transactionSuccess()) { + // There is enough money to pay + modifyUniverseMoney(-delta); + if (forDoingThis != null && !forDoingThis.isEmpty()) { + 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); + } + return false; + } + } + } - public static String moneyString(double amount) { - return format.format(amount); - } + public static String moneyString(double amount) { + return format.format(amount); + } - // calculate the cost for claiming land - public static double calculateClaimCost(int ownedLand, boolean takingFromAnotherFaction) { - if (!shouldBeUsed()) { - return 0d; - } + // calculate the cost for claiming land + public static double calculateClaimCost(int ownedLand, boolean takingFromAnotherFaction) { + if (!shouldBeUsed()) { + return 0d; + } - // basic claim cost, plus land inflation cost, minus the potential bonus given for claiming from another faction - return Conf.econCostClaimWilderness + (Conf.econCostClaimWilderness * Conf.econClaimAdditionalMultiplier * ownedLand) - (takingFromAnotherFaction ? Conf.econCostClaimFromFactionBonus : 0); - } + // basic claim cost, plus land inflation cost, minus the potential bonus given for claiming from another faction + return Conf.econCostClaimWilderness + (Conf.econCostClaimWilderness * Conf.econClaimAdditionalMultiplier * ownedLand) - (takingFromAnotherFaction ? Conf.econCostClaimFromFactionBonus : 0); + } - // calculate refund amount for unclaiming land - public static double calculateClaimRefund(int ownedLand) { - return calculateClaimCost(ownedLand - 1, false) * Conf.econClaimRefundMultiplier; - } + // calculate refund amount for unclaiming land + public static double calculateClaimRefund(int ownedLand) { + return calculateClaimCost(ownedLand - 1, false) * Conf.econClaimRefundMultiplier; + } - // calculate value of all owned land - public static double calculateTotalLandValue(int ownedLand) { - double amount = 0; - for (int x = 0; x < ownedLand; x++) { - amount += calculateClaimCost(x, false); - } - return amount; - } + // calculate value of all owned land + public static double calculateTotalLandValue(int ownedLand) { + double amount = 0; + for (int x = 0; x < ownedLand; x++) { + amount += calculateClaimCost(x, false); + } + return amount; + } - // -------------------------------------------- // - // Standard account management methods - // -------------------------------------------- // + // -------------------------------------------- // + // Standard account management methods + // -------------------------------------------- // - // calculate refund amount for all owned land - public static double calculateTotalLandRefund(int ownedLand) { - return calculateTotalLandValue(ownedLand) * Conf.econClaimRefundMultiplier; - } + // calculate refund amount for all owned land + public static double calculateTotalLandRefund(int ownedLand) { + return calculateTotalLandValue(ownedLand) * Conf.econClaimRefundMultiplier; + } - public static boolean hasAccount(String name) { - return econ.hasAccount(name); - } + public static boolean hasAccount(String name) { + return econ.hasAccount(name); + } - public static double getBalance(String account) { - return econ.getBalance(account); - } + public static double getBalance(String account) { + return econ.getBalance(account); + } - public static String getFriendlyBalance(UUID uuid) { - OfflinePlayer offline = Bukkit.getOfflinePlayer(uuid); - if (offline.getName() == null) { - return "0"; - } - return format.format(econ.getBalance(offline)); - } + public static String getFriendlyBalance(UUID uuid) { + OfflinePlayer offline = Bukkit.getOfflinePlayer(uuid); + if (offline.getName() == null) { + return "0"; + } + return format.format(econ.getBalance(offline)); + } - public static String getFriendlyBalance(FPlayer player) { - return getFriendlyBalance(UUID.fromString(player.getId())); - } + public static String getFriendlyBalance(FPlayer player) { + return getFriendlyBalance(UUID.fromString(player.getId())); + } - public static boolean setBalance(String account, double amount) { - double current = econ.getBalance(account); - if (current > amount) { - return econ.withdrawPlayer(account, current - amount).transactionSuccess(); - } else { - return econ.depositPlayer(account, amount - current).transactionSuccess(); - } - } + public static boolean setBalance(String account, double amount) { + double current = econ.getBalance(account); + if (current > amount) { + return econ.withdrawPlayer(account, current - amount).transactionSuccess(); + } else { + return econ.depositPlayer(account, amount - current).transactionSuccess(); + } + } - public static boolean modifyBalance(String account, double amount) { - if (amount < 0) { - return econ.withdrawPlayer(account, -amount).transactionSuccess(); - } else { - return econ.depositPlayer(account, amount).transactionSuccess(); - } - } + public static boolean modifyBalance(String account, double amount) { + if (amount < 0) { + return econ.withdrawPlayer(account, -amount).transactionSuccess(); + } else { + return econ.depositPlayer(account, amount).transactionSuccess(); + } + } - public static boolean deposit(String account, double amount) { - return econ.depositPlayer(account, amount).transactionSuccess(); - } + public static boolean deposit(String account, double amount) { + return econ.depositPlayer(account, amount).transactionSuccess(); + } - public static boolean withdraw(String account, double amount) { - return econ.withdrawPlayer(account, amount).transactionSuccess(); - } + public static boolean withdraw(String account, double amount) { + return econ.withdrawPlayer(account, amount).transactionSuccess(); + } - // --------------------------------------- - // Helpful Utilities - // --------------------------------------- + // --------------------------------------- + // Helpful Utilities + // --------------------------------------- - public static boolean isUUID(String uuid) { - try { - UUID.fromString(uuid); - } catch (IllegalArgumentException ex) { - return false; - } + public static boolean isUUID(String uuid) { + try { + UUID.fromString(uuid); + } catch (IllegalArgumentException ex) { + return false; + } - return true; - } + return true; + } } diff --git a/src/main/java/com/massivecraft/factions/integration/Essentials.java b/src/main/java/com/massivecraft/factions/integration/Essentials.java index 2c43feb4..73c44d5d 100644 --- a/src/main/java/com/massivecraft/factions/integration/Essentials.java +++ b/src/main/java/com/massivecraft/factions/integration/Essentials.java @@ -17,42 +17,42 @@ import java.math.BigDecimal; public class Essentials { - private static IEssentials essentials; + private static IEssentials essentials; - public static IEssentials setup() { - Plugin ess = Bukkit.getPluginManager().getPlugin("Essentials"); - if (ess != null) { - return Essentials.essentials = (IEssentials)ess; - } - return null; - } + public static IEssentials setup() { + Plugin ess = Bukkit.getPluginManager().getPlugin("Essentials"); + if (ess != null) { + return Essentials.essentials = (IEssentials) ess; + } + return null; + } - public static boolean isOverBalCap(EconomyParticipator participator, double amount) { - if (essentials == null) { - return false; - } - return amount > essentials.getSettings().getMaxMoney().doubleValue(); - } + public static boolean isOverBalCap(EconomyParticipator participator, double amount) { + if (essentials == null) { + return false; + } + return amount > essentials.getSettings().getMaxMoney().doubleValue(); + } - // return false if feature is disabled or Essentials isn't available - public static boolean handleTeleport(Player player, Location loc) { - if (!Conf.homesTeleportCommandEssentialsIntegration || essentials == null) { - return false; - } + // return false if feature is disabled or Essentials isn't available + public static boolean handleTeleport(Player player, Location loc) { + if (!Conf.homesTeleportCommandEssentialsIntegration || essentials == null) { + return false; + } - Teleport teleport = essentials.getUser(player).getTeleport(); - Trade trade = new Trade(new BigDecimal(Conf.econCostHome), essentials); - try { - teleport.teleport(loc, trade, TeleportCause.PLUGIN); - } catch (Exception e) { - player.sendMessage(ChatColor.RED.toString() + e.getMessage()); - } - return true; - } + Teleport teleport = essentials.getUser(player).getTeleport(); + Trade trade = new Trade(new BigDecimal(Conf.econCostHome), essentials); + try { + teleport.teleport(loc, trade, TeleportCause.PLUGIN); + } catch (Exception e) { + player.sendMessage(ChatColor.RED.toString() + e.getMessage()); + } + return true; + } - public static boolean isVanished(Player player) { - if (essentials == null) return false; - User user = essentials.getUser(player); - return user != null && user.isVanished(); - } + public static boolean isVanished(Player player) { + if (essentials == null) return false; + User user = essentials.getUser(player); + return user != null && user.isVanished(); + } } diff --git a/src/main/java/com/massivecraft/factions/integration/Worldguard.java b/src/main/java/com/massivecraft/factions/integration/Worldguard.java index b93e6e9e..2718b3c5 100644 --- a/src/main/java/com/massivecraft/factions/integration/Worldguard.java +++ b/src/main/java/com/massivecraft/factions/integration/Worldguard.java @@ -30,110 +30,110 @@ import static com.sk89q.worldguard.bukkit.BukkitUtil.toVector; public class Worldguard { - private static WorldGuardPlugin wg; - private static boolean enabled = false; + 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; - P.p.log("Could not hook to WorldGuard. WorldGuard checks are disabled."); - } else { - wg = (WorldGuardPlugin) wgplug; - enabled = true; - P.p.log("Successfully hooked to WorldGuard."); - } - } + public static void init(Plugin plugin) { + Plugin wgplug = plugin.getServer().getPluginManager().getPlugin("WorldGuard"); + if (wgplug == null || !(wgplug instanceof WorldGuardPlugin)) { + enabled = false; + wg = null; + P.p.log("Could not hook to WorldGuard. WorldGuard checks are disabled."); + } else { + wg = (WorldGuardPlugin) wgplug; + enabled = true; + P.p.log("Successfully hooked to WorldGuard."); + } + } - public static boolean isEnabled() { - return enabled; - } + 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; - } + // 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); + 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); - } + 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; - } + // 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); + World world = loc.getWorld(); + Vector pt = toVector(loc); - return wg.getRegionManager(world).getApplicableRegions(pt).size() > 0 && wg.canBuild(player, 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 + // 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()); + public static boolean checkForRegionsInChunk(FLocation floc) { + Chunk chunk = floc.getWorld().getChunkAt((int) floc.getX(), (int) floc.getZ()); - return checkForRegionsInChunk(chunk); - } + return checkForRegionsInChunk(chunk); + } - public static boolean checkForRegionsInChunk(Location loc) { - Chunk chunk = loc.getWorld().getChunkAt(loc); + public static boolean checkForRegionsInChunk(Location loc) { + Chunk chunk = loc.getWorld().getChunkAt(loc); - return checkForRegionsInChunk(chunk); - } + return checkForRegionsInChunk(chunk); + } - public static boolean checkForRegionsInChunk(Chunk chunk) { - if (!enabled) { - // No WG hooks so we'll always bypass this check. - return false; - } + 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; + 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 + int worldHeight = world.getMaxHeight(); // Allow for heights other than default - BlockVector minChunk = new BlockVector(minChunkX, 0, minChunkZ); - BlockVector maxChunk = new BlockVector(maxChunkX, worldHeight, maxChunkZ); + 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; + 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(); - } + try { + overlaps = region.getIntersectingRegions(allregionslist); + foundregions = overlaps != null && !overlaps.isEmpty(); + } catch (Exception e) { + e.printStackTrace(); + } - return foundregions; - } + return foundregions; + } } \ No newline at end of file diff --git a/src/main/java/com/massivecraft/factions/listeners/FactionsBlockListener.java b/src/main/java/com/massivecraft/factions/listeners/FactionsBlockListener.java index e93282a6..60180ba3 100644 --- a/src/main/java/com/massivecraft/factions/listeners/FactionsBlockListener.java +++ b/src/main/java/com/massivecraft/factions/listeners/FactionsBlockListener.java @@ -101,6 +101,47 @@ public class FactionsBlockListener implements Listener { return false; } + public static boolean graceisEnabled() { + return Conf.gracePeriod; + } + + private static boolean CheckPlayerAccess(Player player, FPlayer me, FLocation loc, Faction myFaction, Access access, PermissableAction action, boolean shouldHurt) { + boolean landOwned = (myFaction.doesLocationHaveOwnersSet(loc) && !myFaction.getOwnerList(loc).isEmpty()); + if ((landOwned && myFaction.getOwnerListString(loc).contains(player.getName())) || (me.getRole() == Role.LEADER && me.getFactionId().equals(myFaction.getId()))) + return true; + else if (landOwned && !myFaction.getOwnerListString(loc).contains(player.getName())) { + me.msg(TL.ACTIONS_OWNEDTERRITORYDENY.toString().replace("{owners}", myFaction.getOwnerListString(loc))); + if (shouldHurt) { + player.damage(Conf.actionDeniedPainAmount); + me.msg(TL.ACTIONS_NOPERMISSIONPAIN.toString().replace("{action}", action.toString()).replace("{faction}", Board.getInstance().getFactionAt(loc).getTag(myFaction))); + } + return false; + } else if (!landOwned && access == Access.DENY) { // If land is not owned but access is set to DENY anyway + if (shouldHurt) { + player.damage(Conf.actionDeniedPainAmount); + me.msg(TL.ACTIONS_NOPERMISSIONPAIN.toString().replace("{action}", action.toString()).replace("{faction}", Board.getInstance().getFactionAt(loc).getTag(myFaction))); + } + me.msg(TL.ACTIONS_NOPERMISSION.toString().replace("{faction}", myFaction.getTag(me.getFaction())).replace("{action}", action.toString())); + return false; + } else if (access == Access.ALLOW) return true; + me.msg(TL.ACTIONS_NOPERMISSION.toString().replace("{faction}", myFaction.getTag(me.getFaction())).replace("{action}", action.toString())); + return false; + } + + private static boolean CheckActionState(Faction target, FLocation location, FPlayer me, PermissableAction action, boolean pain) { + if (Conf.ownedAreasEnabled && target.doesLocationHaveOwnersSet(location) && !target.playerHasOwnershipRights(me, location)) { + // If pain should be applied + if (pain && Conf.ownedAreaPainBuild) + me.msg(TL.ACTIONS_OWNEDTERRITORYPAINDENY.toString().replace("{action}", action.toString()).replace("{faction}", target.getOwnerListString(location))); + if (Conf.ownedAreaDenyBuild && pain) return false; + else if (Conf.ownedAreaDenyBuild) { + me.msg(TL.ACTIONS_NOPERMISSION.toString().replace("{faction}", target.getTag(me.getFaction())).replace("{action}", action.toString())); + return false; + } + } + return CheckPlayerAccess(me.getPlayer(), me, location, target, target.getAccess(me, action), action, pain); + } + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void onBlockPlace(BlockPlaceEvent event) { if (!event.canBuild()) { @@ -400,7 +441,7 @@ public class FactionsBlockListener implements Listener { @EventHandler public void onFallingBlock(EntityChangeBlockEvent event) { - if(!P.p.getConfig().getBoolean("Falling-Block-Fix.Enabled")) + if (!P.p.getConfig().getBoolean("Falling-Block-Fix.Enabled")) return; Faction faction = Board.getInstance().getFactionAt(new FLocation(event.getBlock())); @@ -450,11 +491,6 @@ public class FactionsBlockListener implements Listener { } } - public static boolean graceisEnabled() { - return Conf.gracePeriod; - } - - private boolean canPistonMoveBlock(Faction pistonFaction, Location target) { Faction otherFaction = Board.getInstance().getFactionAt(new FLocation(target)); @@ -465,10 +501,10 @@ public class FactionsBlockListener implements Listener { if (otherFaction.isWilderness()) return !Conf.wildernessDenyBuild || Conf.worldsNoWildernessProtection.contains(target.getWorld().getName()); - else if (otherFaction.isSafeZone()) + else if (otherFaction.isSafeZone()) return !Conf.safeZoneDenyBuild; - else if (otherFaction.isWarZone()) + else if (otherFaction.isWarZone()) return !Conf.warZoneDenyBuild; Relation rel = pistonFaction.getRelationTo(otherFaction); @@ -479,7 +515,7 @@ public class FactionsBlockListener implements Listener { @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void onBlockBreak(BlockBreakEvent event) { FPlayer fme = FPlayers.getInstance().getByPlayer(event.getPlayer()); - if (!playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), "destroy", false)){ + if (!playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), "destroy", false)) { event.setCancelled(true); return; } @@ -510,41 +546,4 @@ public class FactionsBlockListener implements Listener { } } } - - private static boolean CheckPlayerAccess(Player player, FPlayer me, FLocation loc, Faction myFaction, Access access, PermissableAction action, boolean shouldHurt) { - boolean landOwned = (myFaction.doesLocationHaveOwnersSet(loc) && !myFaction.getOwnerList(loc).isEmpty()); - if ((landOwned && myFaction.getOwnerListString(loc).contains(player.getName())) || (me.getRole() == Role.LEADER && me.getFactionId().equals(myFaction.getId()))) - return true; - else if (landOwned && !myFaction.getOwnerListString(loc).contains(player.getName())) { - me.msg(TL.ACTIONS_OWNEDTERRITORYDENY.toString().replace("{owners}", myFaction.getOwnerListString(loc))); - if (shouldHurt) { - player.damage(Conf.actionDeniedPainAmount); - me.msg(TL.ACTIONS_NOPERMISSIONPAIN.toString().replace("{action}", action.toString()).replace("{faction}", Board.getInstance().getFactionAt(loc).getTag(myFaction))); - } - return false; - } else if (!landOwned && access == Access.DENY) { // If land is not owned but access is set to DENY anyway - if (shouldHurt) { - player.damage(Conf.actionDeniedPainAmount); - me.msg(TL.ACTIONS_NOPERMISSIONPAIN.toString().replace("{action}", action.toString()).replace("{faction}", Board.getInstance().getFactionAt(loc).getTag(myFaction))); - } - me.msg(TL.ACTIONS_NOPERMISSION.toString().replace("{faction}", myFaction.getTag(me.getFaction())).replace("{action}", action.toString())); - return false; - } else if (access == Access.ALLOW) return true; - me.msg(TL.ACTIONS_NOPERMISSION.toString().replace("{faction}", myFaction.getTag(me.getFaction())).replace("{action}", action.toString())); - return false; - } - - private static boolean CheckActionState(Faction target, FLocation location, FPlayer me, PermissableAction action, boolean pain) { - if (Conf.ownedAreasEnabled && target.doesLocationHaveOwnersSet(location) && !target.playerHasOwnershipRights(me, location)) { - // If pain should be applied - if (pain && Conf.ownedAreaPainBuild) - me.msg(TL.ACTIONS_OWNEDTERRITORYPAINDENY.toString().replace("{action}", action.toString()).replace("{faction}", target.getOwnerListString(location))); - if (Conf.ownedAreaDenyBuild && pain) return false; - else if (Conf.ownedAreaDenyBuild) { - me.msg(TL.ACTIONS_NOPERMISSION.toString().replace("{faction}", target.getTag(me.getFaction())).replace("{action}", action.toString())); - return false; - } - } - return CheckPlayerAccess(me.getPlayer(), me, location, target, target.getAccess(me, action), action, pain); - } } diff --git a/src/main/java/com/massivecraft/factions/listeners/FactionsChatListener.java b/src/main/java/com/massivecraft/factions/listeners/FactionsChatListener.java index 1e840646..8a25f56f 100644 --- a/src/main/java/com/massivecraft/factions/listeners/FactionsChatListener.java +++ b/src/main/java/com/massivecraft/factions/listeners/FactionsChatListener.java @@ -19,190 +19,190 @@ 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) - public void onPlayerEarlyChat(AsyncPlayerChatEvent event) { - Player talkingPlayer = event.getPlayer(); - String msg = event.getMessage(); - FPlayer me = FPlayers.getInstance().getByPlayer(talkingPlayer); - ChatMode chat = me.getChatMode(); - // Is the player entering a password for a warp? - if (me.isEnteringPassword()) { - event.setCancelled(true); - me.sendMessage(ChatColor.DARK_GRAY + event.getMessage().replaceAll("(?s).", "*")); - if (me.getFaction().isWarpPassword(me.getEnteringWarp(), event.getMessage())) { - doWarmup(me.getEnteringWarp(), me); - } else { - // Invalid Password - me.msg(TL.COMMAND_FWARP_INVALID_PASSWORD); - } - me.setEnteringPassword(false, ""); - return; - } + // 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) + public void onPlayerEarlyChat(AsyncPlayerChatEvent event) { + Player talkingPlayer = event.getPlayer(); + String msg = event.getMessage(); + FPlayer me = FPlayers.getInstance().getByPlayer(talkingPlayer); + ChatMode chat = me.getChatMode(); + // Is the player entering a password for a warp? + if (me.isEnteringPassword()) { + event.setCancelled(true); + me.sendMessage(ChatColor.DARK_GRAY + event.getMessage().replaceAll("(?s).", "*")); + if (me.getFaction().isWarpPassword(me.getEnteringWarp(), event.getMessage())) { + doWarmup(me.getEnteringWarp(), me); + } else { + // Invalid Password + me.msg(TL.COMMAND_FWARP_INVALID_PASSWORD); + } + me.setEnteringPassword(false, ""); + return; + } - //Is it a MOD chat - if (chat == ChatMode.MOD) { - Faction myFaction = me.getFaction(); + //Is it a MOD chat + if (chat == ChatMode.MOD) { + Faction myFaction = me.getFaction(); - String message = String.format(Conf.modChatFormat, ChatColor.stripColor(me.getNameAndTag()), msg); + String message = String.format(Conf.modChatFormat, ChatColor.stripColor(me.getNameAndTag()), msg); - //Send to all mods - if (me.getRole().isAtLeast(Role.MODERATOR)) { - // Iterates only through the factions' members so we enhance performance. - for (FPlayer fplayer : myFaction.getFPlayers()) { - if (fplayer.getRole().isAtLeast(Role.MODERATOR)) { - fplayer.sendMessage(message); - } else if (fplayer.isSpyingChat() && me != fplayer) { - fplayer.sendMessage("[MCspy]: " + message); - } - } - } else { - // Just in case player gets demoted while in faction chat. - me.msg(TL.COMMAND_CHAT_MOD_ONLY); - event.setCancelled(true); - me.setChatMode(ChatMode.FACTION); - return; - } + //Send to all mods + if (me.getRole().isAtLeast(Role.MODERATOR)) { + // Iterates only through the factions' members so we enhance performance. + for (FPlayer fplayer : myFaction.getFPlayers()) { + if (fplayer.getRole().isAtLeast(Role.MODERATOR)) { + fplayer.sendMessage(message); + } else if (fplayer.isSpyingChat() && me != fplayer) { + fplayer.sendMessage("[MCspy]: " + message); + } + } + } else { + // Just in case player gets demoted while in faction chat. + me.msg(TL.COMMAND_CHAT_MOD_ONLY); + event.setCancelled(true); + me.setChatMode(ChatMode.FACTION); + return; + } - Bukkit.getLogger().log(Level.INFO, ChatColor.stripColor("Mod Chat: " + message)); + Bukkit.getLogger().log(Level.INFO, ChatColor.stripColor("Mod Chat: " + message)); - event.setCancelled(true); - } else if (chat == ChatMode.FACTION) { - Faction myFaction = me.getFaction(); + event.setCancelled(true); + } else if (chat == ChatMode.FACTION) { + Faction myFaction = me.getFaction(); - String message = String.format(Conf.factionChatFormat, me.describeTo(myFaction), msg); - myFaction.sendMessage(message); + String message = String.format(Conf.factionChatFormat, me.describeTo(myFaction), msg); + myFaction.sendMessage(message); - Bukkit.getLogger().log(Level.INFO, ChatColor.stripColor("FactionChat " + myFaction.getTag() + ": " + message)); + Bukkit.getLogger().log(Level.INFO, ChatColor.stripColor("FactionChat " + myFaction.getTag() + ": " + message)); - //Send to any players who are spying chat - for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers()) { - if (fplayer.isSpyingChat() && fplayer.getFaction() != myFaction && me != fplayer) { - fplayer.sendMessage("[FCspy] " + myFaction.getTag() + ": " + message); - } - } + //Send to any players who are spying chat + for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers()) { + if (fplayer.isSpyingChat() && fplayer.getFaction() != myFaction && me != fplayer) { + fplayer.sendMessage("[FCspy] " + myFaction.getTag() + ": " + message); + } + } - event.setCancelled(true); - } else if (chat == ChatMode.ALLIANCE) { - Faction myFaction = me.getFaction(); + event.setCancelled(true); + } else if (chat == ChatMode.ALLIANCE) { + Faction myFaction = me.getFaction(); - String message = String.format(Conf.allianceChatFormat, ChatColor.stripColor(me.getNameAndTag()), msg); + String message = String.format(Conf.allianceChatFormat, ChatColor.stripColor(me.getNameAndTag()), msg); - //Send message to our own faction - myFaction.sendMessage(message); + //Send message to our own faction + myFaction.sendMessage(message); - //Send to all our allies - for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers()) { - if (myFaction.getRelationTo(fplayer) == Relation.ALLY && !fplayer.isIgnoreAllianceChat()) { - fplayer.sendMessage(message); - } else if (fplayer.isSpyingChat() && me != fplayer) { - fplayer.sendMessage("[ACspy]: " + message); - } - } + //Send to all our allies + for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers()) { + if (myFaction.getRelationTo(fplayer) == Relation.ALLY && !fplayer.isIgnoreAllianceChat()) { + fplayer.sendMessage(message); + } else if (fplayer.isSpyingChat() && me != fplayer) { + fplayer.sendMessage("[ACspy]: " + message); + } + } - Bukkit.getLogger().log(Level.INFO, ChatColor.stripColor("AllianceChat: " + message)); + Bukkit.getLogger().log(Level.INFO, ChatColor.stripColor("AllianceChat: " + message)); - event.setCancelled(true); - } else if (chat == ChatMode.TRUCE) { - Faction myFaction = me.getFaction(); + event.setCancelled(true); + } else if (chat == ChatMode.TRUCE) { + Faction myFaction = me.getFaction(); - String message = String.format(Conf.truceChatFormat, ChatColor.stripColor(me.getNameAndTag()), msg); + String message = String.format(Conf.truceChatFormat, ChatColor.stripColor(me.getNameAndTag()), msg); - //Send message to our own faction - myFaction.sendMessage(message); + //Send message to our own faction + myFaction.sendMessage(message); - //Send to all our truces - for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers()) { - if (myFaction.getRelationTo(fplayer) == Relation.TRUCE) { - fplayer.sendMessage(message); - } else if (fplayer.isSpyingChat() && fplayer != me) { - fplayer.sendMessage("[TCspy]: " + message); - } - } + //Send to all our truces + for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers()) { + if (myFaction.getRelationTo(fplayer) == Relation.TRUCE) { + fplayer.sendMessage(message); + } else if (fplayer.isSpyingChat() && fplayer != me) { + fplayer.sendMessage("[TCspy]: " + message); + } + } - Bukkit.getLogger().log(Level.INFO, ChatColor.stripColor("TruceChat: " + message)); - event.setCancelled(true); - } - } + Bukkit.getLogger().log(Level.INFO, ChatColor.stripColor("TruceChat: " + message)); + event.setCancelled(true); + } + } - // 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) - 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. - if (!Conf.chatTagEnabled || Conf.chatTagHandledByAnotherPlugin) { - return; - } + // 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) + 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. + if (!Conf.chatTagEnabled || Conf.chatTagHandledByAnotherPlugin) { + return; + } - Player talkingPlayer = event.getPlayer(); - String msg = event.getMessage(); - String eventFormat = event.getFormat(); - FPlayer me = FPlayers.getInstance().getByPlayer(talkingPlayer); - int InsertIndex; + Player talkingPlayer = event.getPlayer(); + String msg = event.getMessage(); + String eventFormat = event.getFormat(); + FPlayer me = FPlayers.getInstance().getByPlayer(talkingPlayer); + int InsertIndex; - if (!Conf.chatTagReplaceString.isEmpty() && eventFormat.contains(Conf.chatTagReplaceString)) { - // we're using the "replace" method of inserting the faction tags - if (eventFormat.contains("[FACTION_TITLE]")) { - eventFormat = eventFormat.replace("[FACTION_TITLE]", me.getTitle()); - } + if (!Conf.chatTagReplaceString.isEmpty() && eventFormat.contains(Conf.chatTagReplaceString)) { + // we're using the "replace" method of inserting the faction tags + if (eventFormat.contains("[FACTION_TITLE]")) { + eventFormat = eventFormat.replace("[FACTION_TITLE]", me.getTitle()); + } - InsertIndex = eventFormat.indexOf(Conf.chatTagReplaceString); - eventFormat = eventFormat.replace(Conf.chatTagReplaceString, ""); - Conf.chatTagPadAfter = false; - Conf.chatTagPadBefore = false; - } else if (!Conf.chatTagInsertAfterString.isEmpty() && eventFormat.contains(Conf.chatTagInsertAfterString)) { - // we're using the "insert after string" method - InsertIndex = eventFormat.indexOf(Conf.chatTagInsertAfterString) + Conf.chatTagInsertAfterString.length(); - } else if (!Conf.chatTagInsertBeforeString.isEmpty() && eventFormat.contains(Conf.chatTagInsertBeforeString)) { - // we're using the "insert before string" method - InsertIndex = eventFormat.indexOf(Conf.chatTagInsertBeforeString); - } else { - // we'll fall back to using the index place method - InsertIndex = Conf.chatTagInsertIndex; - if (InsertIndex > eventFormat.length()) { - return; - } - } + InsertIndex = eventFormat.indexOf(Conf.chatTagReplaceString); + eventFormat = eventFormat.replace(Conf.chatTagReplaceString, ""); + Conf.chatTagPadAfter = false; + Conf.chatTagPadBefore = false; + } else if (!Conf.chatTagInsertAfterString.isEmpty() && eventFormat.contains(Conf.chatTagInsertAfterString)) { + // we're using the "insert after string" method + InsertIndex = eventFormat.indexOf(Conf.chatTagInsertAfterString) + Conf.chatTagInsertAfterString.length(); + } else if (!Conf.chatTagInsertBeforeString.isEmpty() && eventFormat.contains(Conf.chatTagInsertBeforeString)) { + // we're using the "insert before string" method + InsertIndex = eventFormat.indexOf(Conf.chatTagInsertBeforeString); + } else { + // we'll fall back to using the index place method + InsertIndex = Conf.chatTagInsertIndex; + if (InsertIndex > eventFormat.length()) { + return; + } + } - String formatStart = eventFormat.substring(0, InsertIndex) + ((Conf.chatTagPadBefore && !me.getChatTag().isEmpty()) ? " " : ""); - String formatEnd = ((Conf.chatTagPadAfter && !me.getChatTag().isEmpty()) ? " " : "") + eventFormat.substring(InsertIndex); + String formatStart = eventFormat.substring(0, InsertIndex) + ((Conf.chatTagPadBefore && !me.getChatTag().isEmpty()) ? " " : ""); + String formatEnd = ((Conf.chatTagPadAfter && !me.getChatTag().isEmpty()) ? " " : "") + eventFormat.substring(InsertIndex); - String nonColoredMsgFormat = formatStart + me.getChatTag().trim() + formatEnd; + String nonColoredMsgFormat = formatStart + me.getChatTag().trim() + formatEnd; - // Relation Colored? - if (Conf.chatTagRelationColored) { - for (Player listeningPlayer : event.getRecipients()) { - FPlayer you = FPlayers.getInstance().getByPlayer(listeningPlayer); - String yourFormat = formatStart + me.getChatTag(you).trim() + formatEnd; - try { - listeningPlayer.sendMessage(String.format(yourFormat, talkingPlayer.getDisplayName(), msg)); - } catch (UnknownFormatConversionException ex) { - Conf.chatTagInsertIndex = 0; - P.p.log(Level.SEVERE, "Critical error in chat message formatting!"); - P.p.log(Level.SEVERE, "NOTE: This has been automatically fixed right now by setting chatTagInsertIndex to 0."); - P.p.log(Level.SEVERE, "For a more proper fix, please read this regarding chat configuration: http://massivecraft.com/plugins/factions/config#Chat_configuration"); - return; - } - } + // Relation Colored? + if (Conf.chatTagRelationColored) { + for (Player listeningPlayer : event.getRecipients()) { + FPlayer you = FPlayers.getInstance().getByPlayer(listeningPlayer); + String yourFormat = formatStart + me.getChatTag(you).trim() + formatEnd; + try { + listeningPlayer.sendMessage(String.format(yourFormat, talkingPlayer.getDisplayName(), msg)); + } catch (UnknownFormatConversionException ex) { + Conf.chatTagInsertIndex = 0; + P.p.log(Level.SEVERE, "Critical error in chat message formatting!"); + P.p.log(Level.SEVERE, "NOTE: This has been automatically fixed right now by setting chatTagInsertIndex to 0."); + P.p.log(Level.SEVERE, "For a more proper fix, please read this regarding chat configuration: http://massivecraft.com/plugins/factions/config#Chat_configuration"); + return; + } + } - // Messages are sent to players individually - // This still leaves a chance for other plugins to pick it up - event.getRecipients().clear(); - } - // Message with no relation color. - event.setFormat(nonColoredMsgFormat); - } + // Messages are sent to players individually + // This still leaves a chance for other plugins to pick it up + event.getRecipients().clear(); + } + // Message with no relation color. + event.setFormat(nonColoredMsgFormat); + } - private void doWarmup(final String warp, final FPlayer fme) { - WarmUpUtil.process(fme, WarmUpUtil.Warmup.WARP, TL.WARMUPS_NOTIFY_TELEPORT, warp, () -> { - Player player = Bukkit.getPlayer(fme.getPlayer().getUniqueId()); - if (player != null) { - player.teleport(fme.getFaction().getWarp(warp).getLocation()); - fme.msg(TL.COMMAND_FWARP_WARPED, warp); - } - }, P.p.getConfig().getLong("warmups.f-warp", 0)); - } + private void doWarmup(final String warp, final FPlayer fme) { + WarmUpUtil.process(fme, WarmUpUtil.Warmup.WARP, TL.WARMUPS_NOTIFY_TELEPORT, warp, () -> { + Player player = Bukkit.getPlayer(fme.getPlayer().getUniqueId()); + if (player != null) { + player.teleport(fme.getFaction().getWarp(warp).getLocation()); + fme.msg(TL.COMMAND_FWARP_WARPED, warp); + } + }, P.p.getConfig().getLong("warmups.f-warp", 0)); + } } \ No newline at end of file diff --git a/src/main/java/com/massivecraft/factions/listeners/FactionsEntityListener.java b/src/main/java/com/massivecraft/factions/listeners/FactionsEntityListener.java index c12e3de5..e1d709ed 100644 --- a/src/main/java/com/massivecraft/factions/listeners/FactionsEntityListener.java +++ b/src/main/java/com/massivecraft/factions/listeners/FactionsEntityListener.java @@ -30,490 +30,490 @@ import java.util.*; 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) - public void onEntityDeath(EntityDeathEvent event) { - Entity entity = event.getEntity(); - if (!(entity instanceof Player)) { - return; - } - - Player player = (Player) entity; - FPlayer fplayer = FPlayers.getInstance().getByPlayer(player); - Faction faction = Board.getInstance().getFactionAt(new FLocation(player.getLocation())); - - PowerLossEvent powerLossEvent = new PowerLossEvent(faction, fplayer); - // Check for no power loss conditions - if (faction.isWarZone()) { - // war zones always override worldsNoPowerLoss either way, thus this layout - if (!Conf.warZonePowerLoss) { - powerLossEvent.setMessage(TL.PLAYER_POWER_NOLOSS_WARZONE.toString()); - powerLossEvent.setCancelled(true); - } - if (Conf.worldsNoPowerLoss.contains(player.getWorld().getName())) { - powerLossEvent.setMessage(TL.PLAYER_POWER_LOSS_WARZONE.toString()); - } - } else if (faction.isWilderness() && !Conf.wildernessPowerLoss && !Conf.worldsNoWildernessProtection.contains(player.getWorld().getName())) { - powerLossEvent.setMessage(TL.PLAYER_POWER_NOLOSS_WILDERNESS.toString()); - powerLossEvent.setCancelled(true); - } else if (Conf.worldsNoPowerLoss.contains(player.getWorld().getName())) { - powerLossEvent.setMessage(TL.PLAYER_POWER_NOLOSS_WORLD.toString()); - powerLossEvent.setCancelled(true); - } else if (Conf.peacefulMembersDisablePowerLoss && fplayer.hasFaction() && fplayer.getFaction().isPeaceful()) { - powerLossEvent.setMessage(TL.PLAYER_POWER_NOLOSS_PEACEFUL.toString()); - powerLossEvent.setCancelled(true); - } else { - powerLossEvent.setMessage(TL.PLAYER_POWER_NOW.toString()); - } - - // call Event - Bukkit.getPluginManager().callEvent(powerLossEvent); - - // Call player onDeath if the event is not cancelled - if (!powerLossEvent.isCancelled()) { - fplayer.onDeath(); - } - // Send the message from the powerLossEvent - final String msg = powerLossEvent.getMessage(); - if (msg != null && !msg.isEmpty()) { - fplayer.msg(msg, fplayer.getPowerRounded(), fplayer.getPowerMaxRounded()); - } - } - - /** - * 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) - public void onEntityDamage(EntityDamageEvent event) { - if (event instanceof EntityDamageByEntityEvent) { - EntityDamageByEntityEvent sub = (EntityDamageByEntityEvent) event; - if (!this.canDamagerHurtDamagee(sub, true)) { - event.setCancelled(true); - } - // event is not cancelled by factions - - Entity damagee = sub.getEntity(); - Entity damager = sub.getDamager(); - if (damagee instanceof Player) { - if (damager instanceof Player) { - FPlayer fdamager = FPlayers.getInstance().getByPlayer((Player) damager); - FPlayer fdamagee = FPlayers.getInstance().getByPlayer((Player) damagee); - if ((fdamagee.getRelationTo(fdamager) == Relation.ALLY) || - (fdamagee.getRelationTo(fdamager) == Relation.TRUCE) || - (fdamagee.getFaction() == fdamager.getFaction())) { - return; - } - } else { - - // this triggers if damagee is a player and damager is mob ( so like if a skeleton hits u ) - if (damager instanceof Projectile) { - // this will trigger if the damager is a projectile - if (((Projectile) damager).getShooter() instanceof Player) { - Player damagerPlayer = (Player) ((Projectile) damager).getShooter(); - FPlayer fdamager = FPlayers.getInstance().getByPlayer(damagerPlayer); - FPlayer fdamagee = FPlayers.getInstance().getByPlayer((Player) damagee); - Relation relation = fdamager.getRelationTo(fdamagee); - if (relation == Relation.ALLY || relation == Relation.TRUCE || - fdamager.getFaction() == fdamagee.getFaction()) { - // this should disable the fly so - return; - } - } else { - // this should trigger if the attacker shootin the arrow is a mob - return; - } - - } - } - } else { - // Protect armor stands/item frames from being damaged in protected territories - if (damagee.getType() == EntityType.ITEM_FRAME || damagee.getType() == EntityType.ARMOR_STAND) { - // Manage projectiles launched by players - if (damager instanceof Projectile && ((Projectile) damager).getShooter() instanceof Entity) { - damager = (Entity) ((Projectile) damager).getShooter(); - } - - // Run the check for a player - if (damager instanceof Player) { - // Generate the action message. - String entityAction; - - if (damagee.getType() == EntityType.ITEM_FRAME) { - entityAction = "item frames"; - } else { - entityAction = "armor stands"; - } - - if (!FactionsBlockListener.playerCanBuildDestroyBlock((Player) damager, damagee.getLocation(), "destroy " + entityAction, false)) { - event.setCancelled(true); - } - } else { - // we don't want to let mobs/arrows destroy item frames/armor stands - // so we only have to run the check as if there had been an explosion at the damager location - if (!this.checkExplosionForBlock(damager, damagee.getLocation().getBlock())) { - event.setCancelled(true); - } - } - - // we don't need to go after - return; - } - - //this one should trigger if something other than a player takes damage - if (damager instanceof Player) { - // now itll only go here if the damage is dealt by a player - return; - // we cancel it so fly isnt removed when you hit a mob etc - } - } - if (damagee != null && damagee instanceof Player) { - cancelFStuckTeleport((Player) damagee); - cancelFFly((Player) damagee); - FPlayer fplayer = FPlayers.getInstance().getByPlayer((Player) damagee); - if (fplayer.isInspectMode()) { - fplayer.setInspectMode(false); - fplayer.msg(TL.COMMAND_INSPECT_DISABLED_MSG); - } - } - if (damager instanceof Player) { - cancelFStuckTeleport((Player) damager); - cancelFFly((Player) damager); - FPlayer fplayer = FPlayers.getInstance().getByPlayer((Player) damager); - if (fplayer.isInspectMode()) { - fplayer.setInspectMode(false); - fplayer.msg(TL.COMMAND_INSPECT_DISABLED_MSG); - } - } - } else if (Conf.safeZonePreventAllDamageToPlayers && isPlayerInSafeZone(event.getEntity())) { - // Players can not take any damage in a Safe Zone - event.setCancelled(true); - } else if (event.getCause() == EntityDamageEvent.DamageCause.FALL && event.getEntity() instanceof Player) { - Player player = (Player) event.getEntity(); - FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player); - if (fPlayer != null && !fPlayer.shouldTakeFallDamage()) { - event.setCancelled(true); // Falling after /f fly - } - } - - // entity took generic damage? - Entity entity = event.getEntity(); - if (entity instanceof Player) { - Player player = (Player) entity; - FPlayer me = FPlayers.getInstance().getByPlayer(player); - cancelFStuckTeleport(player); - if (me.isWarmingUp()) { - me.clearWarmup(); - me.msg(TL.WARMUPS_CANCELLED); - } - } - } - - private void cancelFFly(Player player) { - if (player == null) { - return; - } - - FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player); - if (fPlayer.isFlying()) { - fPlayer.setFFlying(false, true); - } - } - - public void cancelFStuckTeleport(Player player) { - if (player == null) { - return; - } - UUID uuid = player.getUniqueId(); - if (P.p.getStuckMap().containsKey(uuid)) { - FPlayers.getInstance().getByPlayer(player).msg(TL.COMMAND_STUCK_CANCELLED); - P.p.getStuckMap().remove(uuid); - } - } - - @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) - public void onEntityExplode(EntityExplodeEvent event) { - Entity boomer = event.getEntity(); - - // Before we need to check the location where the block is placed - if (!this.checkExplosionForBlock(boomer, event.getLocation().getBlock())) { - event.setCancelled(true); - return; - } - - // Loop the blocklist to run checks on each aimed block - - // The block don't have to explode - event.blockList().removeIf(block -> !this.checkExplosionForBlock(boomer, block)); - - // Cancel the event if no block will explode - if (!event.blockList().isEmpty() && (boomer instanceof TNTPrimed || boomer instanceof ExplosiveMinecart) && Conf.handleExploitTNTWaterlog) { - // TNT in water/lava doesn't normally destroy any surrounding blocks, which is usually desired behavior, but... - // this change below provides workaround for waterwalling providing perfect protection, - // and makes cheap (non-obsidian) TNT cannons require minor maintenance between shots - Block center = event.getLocation().getBlock(); - - if (center.isLiquid()) { - // 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, 1, 0)); - targets.add(center.getRelative(0, -1, 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(); - // ignore air, bedrock, water, lava, obsidian, enchanting table, etc.... too bad we can't get a blast resistance value through Bukkit yet - if (id != 0 && (id < 7 || id > 11) && id != 90 && id != 116 && id != 119 && id != 120 && id != 130) { - target.breakNaturally(); - } - } - } - } - } - - private boolean checkExplosionForBlock(Entity boomer, Block block) { - Faction faction = Board.getInstance().getFactionAt(new FLocation(block.getLocation())); - - if (faction.noExplosionsInTerritory() || (faction.isPeaceful() && Conf.peacefulTerritoryDisableBoom)) { - // faction is peaceful and has explosions set to disabled - return false; - } - - boolean online = faction.hasPlayersOnline(); - - if (boomer instanceof Creeper && ((faction.isWilderness() && Conf.wildernessBlockCreepers && !Conf.worldsNoWildernessProtection.contains(block.getWorld().getName())) || - (faction.isNormal() && (online ? Conf.territoryBlockCreepers : Conf.territoryBlockCreepersWhenOffline)) || - (faction.isWarZone() && Conf.warZoneBlockCreepers) || - faction.isSafeZone())) { - // creeper which needs prevention - return false; - } else if ( - // it's a bit crude just using fireball protection for Wither boss too, but I'd rather not add in a whole new set of xxxBlockWitherExplosion or whatever - (boomer instanceof Fireball || boomer instanceof Wither) && (faction.isWilderness() && Conf.wildernessBlockFireballs && !Conf.worldsNoWildernessProtection.contains(block.getWorld().getName()) || faction.isNormal() && (online ? Conf.territoryBlockFireballs : Conf.territoryBlockFireballsWhenOffline) || faction.isWarZone() && Conf.warZoneBlockFireballs || faction.isSafeZone())) { - // ghast fireball which needs prevention - return false; - } else - return (!(boomer instanceof TNTPrimed) && !(boomer instanceof ExplosiveMinecart)) || ((!faction.isWilderness() || !Conf.wildernessBlockTNT || Conf.worldsNoWildernessProtection.contains(block.getWorld().getName())) && - (!faction.isNormal() || (online ? !Conf.territoryBlockTNT : !Conf.territoryBlockTNTWhenOffline)) && - (!faction.isWarZone() || !Conf.warZoneBlockTNT) && - (!faction.isSafeZone() || !Conf.safeZoneBlockTNT)); - - // No condition retained, destroy the block! - } - - // 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) - public void onEntityCombustByEntity(EntityCombustByEntityEvent event) { - EntityDamageByEntityEvent sub = new EntityDamageByEntityEvent(event.getCombuster(), event.getEntity(), EntityDamageEvent.DamageCause.FIRE, 0d); - if (!this.canDamagerHurtDamagee(sub, false)) { - event.setCancelled(true); - } - } - - @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) - public void onPotionSplashEvent(PotionSplashEvent event) { - // see if the potion has a harmful effect - boolean badjuju = false; - for (PotionEffect effect : event.getPotion().getEffects()) { - if (badPotionEffects.contains(effect.getType())) { - badjuju = true; - break; - } - } - if (!badjuju) { - return; - } - - ProjectileSource thrower = event.getPotion().getShooter(); - if (!(thrower instanceof Entity)) { - return; - } - - if (thrower instanceof Player) { - Player player = (Player) thrower; - FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player); - if (badjuju && fPlayer.getFaction().isPeaceful()) { - event.setCancelled(true); - return; - } - } - - // scan through affected entities to make sure they're all valid targets - for (LivingEntity target : event.getAffectedEntities()) { - EntityDamageByEntityEvent sub = new EntityDamageByEntityEvent((Entity) thrower, target, EntityDamageEvent.DamageCause.CUSTOM, 0); - if (!this.canDamagerHurtDamagee(sub, true)) { - event.setIntensity(target, 0.0); // affected entity list doesn't accept modification (so no iter.remove()), but this works - } - } - } - - public boolean isPlayerInSafeZone(Entity damagee) { - if (!(damagee instanceof Player)) { - return false; - } - return Board.getInstance().getFactionAt(new FLocation(damagee.getLocation())).isSafeZone(); - } - - public boolean canDamagerHurtDamagee(EntityDamageByEntityEvent sub) { - return canDamagerHurtDamagee(sub, true); - } - - public boolean canDamagerHurtDamagee(EntityDamageByEntityEvent sub, boolean notify) { - Entity damager = sub.getDamager(); - Entity damagee = sub.getEntity(); - - if (!(damagee instanceof Player)) { - return true; - } - - FPlayer defender = FPlayers.getInstance().getByPlayer((Player) damagee); - - if (defender == null || defender.getPlayer() == null) { - return true; - } - - Location defenderLoc = defender.getPlayer().getLocation(); - Faction defLocFaction = Board.getInstance().getFactionAt(new FLocation(defenderLoc)); - - // for damage caused by projectiles, getDamager() returns the projectile... what we need to know is the source - if (damager instanceof Projectile) { - Projectile projectile = (Projectile) damager; - - if (!(projectile.getShooter() instanceof Entity)) { - return true; - } - - damager = (Entity) projectile.getShooter(); - } - - if (damager == damagee) // ender pearl usage and other self-inflicted damage - { - return true; - } - - // Players can not take attack damage in a SafeZone, or possibly peaceful territory - if (defLocFaction.noPvPInTerritory()) { - if (damager instanceof Player) { - if (notify) { - FPlayer attacker = FPlayers.getInstance().getByPlayer((Player) damager); - attacker.msg(TL.PLAYER_CANTHURT, (defLocFaction.isSafeZone() ? TL.REGION_SAFEZONE.toString() : TL.REGION_PEACEFUL.toString())); - } - return false; - } - return !defLocFaction.noMonstersInTerritory(); - } - - if (!(damager instanceof Player)) { - return true; - } - - FPlayer attacker = FPlayers.getInstance().getByPlayer((Player) damager); - - if (attacker == null || attacker.getPlayer() == null) { - return true; - } - - if (Conf.playersWhoBypassAllProtection.contains(attacker.getName())) { - return true; - } - - if (attacker.hasLoginPvpDisabled()) { - if (notify) { - attacker.msg(TL.PLAYER_PVP_LOGIN, Conf.noPVPDamageToOthersForXSecondsAfterLogin); - } - return false; - } - - Faction locFaction = Board.getInstance().getFactionAt(new FLocation(attacker)); - - // so we know from above that the defender isn't in a safezone... what about the attacker, sneaky dog that he might be? - if (locFaction.noPvPInTerritory()) { - if (notify) { - attacker.msg(TL.PLAYER_CANTHURT, (locFaction.isSafeZone() ? TL.REGION_SAFEZONE.toString() : TL.REGION_PEACEFUL.toString())); - } - return false; - } - - if (locFaction.isWarZone() && Conf.warZoneFriendlyFire) { - return true; - } - - if (Conf.worldsIgnorePvP.contains(defenderLoc.getWorld().getName())) { - return true; - } - - Faction defendFaction = defender.getFaction(); - Faction attackFaction = attacker.getFaction(); - - if (attackFaction.isWilderness() && Conf.disablePVPForFactionlessPlayers) { - if (notify) { - attacker.msg(TL.PLAYER_PVP_REQUIREFACTION); - } - return false; - } else if (defendFaction.isWilderness()) { - if (defLocFaction == attackFaction && Conf.enablePVPAgainstFactionlessInAttackersLand) { - // Allow PVP vs. Factionless in attacker's faction territory - return true; - } else if (Conf.disablePVPForFactionlessPlayers) { - if (notify) { - attacker.msg(TL.PLAYER_PVP_FACTIONLESS); - } - return false; - } - } - - if (defendFaction.isPeaceful()) { - if (notify) { - attacker.msg(TL.PLAYER_PVP_PEACEFUL); - } - return false; - } else if (attackFaction.isPeaceful()) { - if (notify) { - attacker.msg(TL.PLAYER_PVP_PEACEFUL); - } - return false; - } - - Relation relation = defendFaction.getRelationTo(attackFaction); - - // You can not hurt neutral factions - if (Conf.disablePVPBetweenNeutralFactions && relation.isNeutral()) { - if (notify) { - attacker.msg(TL.PLAYER_PVP_NEUTRAL); - } - return false; - } - - // Players without faction may be hurt anywhere - if (!defender.hasFaction()) { - return true; - } - - // You can never hurt faction members or allies - if (relation.isMember() || relation.isAlly() || relation.isTruce()) { - if (notify) { - attacker.msg(TL.PLAYER_PVP_CANTHURT, defender.describeTo(attacker)); - } - return false; - } - - boolean ownTerritory = defender.isInOwnTerritory(); - - // You can not hurt neutrals in their own territory. - if (ownTerritory && relation.isNeutral()) { - if (notify) { - attacker.msg(TL.PLAYER_PVP_NEUTRALFAIL, defender.describeTo(attacker)); - defender.msg(TL.PLAYER_PVP_TRIED, attacker.describeTo(defender, true)); - } - return false; - } - - // Damage will be dealt. However check if the damage should be reduced. + 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) + public void onEntityDeath(EntityDeathEvent event) { + Entity entity = event.getEntity(); + if (!(entity instanceof Player)) { + return; + } + + Player player = (Player) entity; + FPlayer fplayer = FPlayers.getInstance().getByPlayer(player); + Faction faction = Board.getInstance().getFactionAt(new FLocation(player.getLocation())); + + PowerLossEvent powerLossEvent = new PowerLossEvent(faction, fplayer); + // Check for no power loss conditions + if (faction.isWarZone()) { + // war zones always override worldsNoPowerLoss either way, thus this layout + if (!Conf.warZonePowerLoss) { + powerLossEvent.setMessage(TL.PLAYER_POWER_NOLOSS_WARZONE.toString()); + powerLossEvent.setCancelled(true); + } + if (Conf.worldsNoPowerLoss.contains(player.getWorld().getName())) { + powerLossEvent.setMessage(TL.PLAYER_POWER_LOSS_WARZONE.toString()); + } + } else if (faction.isWilderness() && !Conf.wildernessPowerLoss && !Conf.worldsNoWildernessProtection.contains(player.getWorld().getName())) { + powerLossEvent.setMessage(TL.PLAYER_POWER_NOLOSS_WILDERNESS.toString()); + powerLossEvent.setCancelled(true); + } else if (Conf.worldsNoPowerLoss.contains(player.getWorld().getName())) { + powerLossEvent.setMessage(TL.PLAYER_POWER_NOLOSS_WORLD.toString()); + powerLossEvent.setCancelled(true); + } else if (Conf.peacefulMembersDisablePowerLoss && fplayer.hasFaction() && fplayer.getFaction().isPeaceful()) { + powerLossEvent.setMessage(TL.PLAYER_POWER_NOLOSS_PEACEFUL.toString()); + powerLossEvent.setCancelled(true); + } else { + powerLossEvent.setMessage(TL.PLAYER_POWER_NOW.toString()); + } + + // call Event + Bukkit.getPluginManager().callEvent(powerLossEvent); + + // Call player onDeath if the event is not cancelled + if (!powerLossEvent.isCancelled()) { + fplayer.onDeath(); + } + // Send the message from the powerLossEvent + final String msg = powerLossEvent.getMessage(); + if (msg != null && !msg.isEmpty()) { + fplayer.msg(msg, fplayer.getPowerRounded(), fplayer.getPowerMaxRounded()); + } + } + + /** + * 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) + public void onEntityDamage(EntityDamageEvent event) { + if (event instanceof EntityDamageByEntityEvent) { + EntityDamageByEntityEvent sub = (EntityDamageByEntityEvent) event; + if (!this.canDamagerHurtDamagee(sub, true)) { + event.setCancelled(true); + } + // event is not cancelled by factions + + Entity damagee = sub.getEntity(); + Entity damager = sub.getDamager(); + if (damagee instanceof Player) { + if (damager instanceof Player) { + FPlayer fdamager = FPlayers.getInstance().getByPlayer((Player) damager); + FPlayer fdamagee = FPlayers.getInstance().getByPlayer((Player) damagee); + if ((fdamagee.getRelationTo(fdamager) == Relation.ALLY) || + (fdamagee.getRelationTo(fdamager) == Relation.TRUCE) || + (fdamagee.getFaction() == fdamager.getFaction())) { + return; + } + } else { + + // this triggers if damagee is a player and damager is mob ( so like if a skeleton hits u ) + if (damager instanceof Projectile) { + // this will trigger if the damager is a projectile + if (((Projectile) damager).getShooter() instanceof Player) { + Player damagerPlayer = (Player) ((Projectile) damager).getShooter(); + FPlayer fdamager = FPlayers.getInstance().getByPlayer(damagerPlayer); + FPlayer fdamagee = FPlayers.getInstance().getByPlayer((Player) damagee); + Relation relation = fdamager.getRelationTo(fdamagee); + if (relation == Relation.ALLY || relation == Relation.TRUCE || + fdamager.getFaction() == fdamagee.getFaction()) { + // this should disable the fly so + return; + } + } else { + // this should trigger if the attacker shootin the arrow is a mob + return; + } + + } + } + } else { + // Protect armor stands/item frames from being damaged in protected territories + if (damagee.getType() == EntityType.ITEM_FRAME || damagee.getType() == EntityType.ARMOR_STAND) { + // Manage projectiles launched by players + if (damager instanceof Projectile && ((Projectile) damager).getShooter() instanceof Entity) { + damager = (Entity) ((Projectile) damager).getShooter(); + } + + // Run the check for a player + if (damager instanceof Player) { + // Generate the action message. + String entityAction; + + if (damagee.getType() == EntityType.ITEM_FRAME) { + entityAction = "item frames"; + } else { + entityAction = "armor stands"; + } + + if (!FactionsBlockListener.playerCanBuildDestroyBlock((Player) damager, damagee.getLocation(), "destroy " + entityAction, false)) { + event.setCancelled(true); + } + } else { + // we don't want to let mobs/arrows destroy item frames/armor stands + // so we only have to run the check as if there had been an explosion at the damager location + if (!this.checkExplosionForBlock(damager, damagee.getLocation().getBlock())) { + event.setCancelled(true); + } + } + + // we don't need to go after + return; + } + + //this one should trigger if something other than a player takes damage + if (damager instanceof Player) { + // now itll only go here if the damage is dealt by a player + return; + // we cancel it so fly isnt removed when you hit a mob etc + } + } + if (damagee != null && damagee instanceof Player) { + cancelFStuckTeleport((Player) damagee); + cancelFFly((Player) damagee); + FPlayer fplayer = FPlayers.getInstance().getByPlayer((Player) damagee); + if (fplayer.isInspectMode()) { + fplayer.setInspectMode(false); + fplayer.msg(TL.COMMAND_INSPECT_DISABLED_MSG); + } + } + if (damager instanceof Player) { + cancelFStuckTeleport((Player) damager); + cancelFFly((Player) damager); + FPlayer fplayer = FPlayers.getInstance().getByPlayer((Player) damager); + if (fplayer.isInspectMode()) { + fplayer.setInspectMode(false); + fplayer.msg(TL.COMMAND_INSPECT_DISABLED_MSG); + } + } + } else if (Conf.safeZonePreventAllDamageToPlayers && isPlayerInSafeZone(event.getEntity())) { + // Players can not take any damage in a Safe Zone + event.setCancelled(true); + } else if (event.getCause() == EntityDamageEvent.DamageCause.FALL && event.getEntity() instanceof Player) { + Player player = (Player) event.getEntity(); + FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player); + if (fPlayer != null && !fPlayer.shouldTakeFallDamage()) { + event.setCancelled(true); // Falling after /f fly + } + } + + // entity took generic damage? + Entity entity = event.getEntity(); + if (entity instanceof Player) { + Player player = (Player) entity; + FPlayer me = FPlayers.getInstance().getByPlayer(player); + cancelFStuckTeleport(player); + if (me.isWarmingUp()) { + me.clearWarmup(); + me.msg(TL.WARMUPS_CANCELLED); + } + } + } + + private void cancelFFly(Player player) { + if (player == null) { + return; + } + + FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player); + if (fPlayer.isFlying()) { + fPlayer.setFFlying(false, true); + } + } + + public void cancelFStuckTeleport(Player player) { + if (player == null) { + return; + } + UUID uuid = player.getUniqueId(); + if (P.p.getStuckMap().containsKey(uuid)) { + FPlayers.getInstance().getByPlayer(player).msg(TL.COMMAND_STUCK_CANCELLED); + P.p.getStuckMap().remove(uuid); + } + } + + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void onEntityExplode(EntityExplodeEvent event) { + Entity boomer = event.getEntity(); + + // Before we need to check the location where the block is placed + if (!this.checkExplosionForBlock(boomer, event.getLocation().getBlock())) { + event.setCancelled(true); + return; + } + + // Loop the blocklist to run checks on each aimed block + + // The block don't have to explode + event.blockList().removeIf(block -> !this.checkExplosionForBlock(boomer, block)); + + // Cancel the event if no block will explode + if (!event.blockList().isEmpty() && (boomer instanceof TNTPrimed || boomer instanceof ExplosiveMinecart) && Conf.handleExploitTNTWaterlog) { + // TNT in water/lava doesn't normally destroy any surrounding blocks, which is usually desired behavior, but... + // this change below provides workaround for waterwalling providing perfect protection, + // and makes cheap (non-obsidian) TNT cannons require minor maintenance between shots + Block center = event.getLocation().getBlock(); + + if (center.isLiquid()) { + // 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, 1, 0)); + targets.add(center.getRelative(0, -1, 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(); + // ignore air, bedrock, water, lava, obsidian, enchanting table, etc.... too bad we can't get a blast resistance value through Bukkit yet + if (id != 0 && (id < 7 || id > 11) && id != 90 && id != 116 && id != 119 && id != 120 && id != 130) { + target.breakNaturally(); + } + } + } + } + } + + private boolean checkExplosionForBlock(Entity boomer, Block block) { + Faction faction = Board.getInstance().getFactionAt(new FLocation(block.getLocation())); + + if (faction.noExplosionsInTerritory() || (faction.isPeaceful() && Conf.peacefulTerritoryDisableBoom)) { + // faction is peaceful and has explosions set to disabled + return false; + } + + boolean online = faction.hasPlayersOnline(); + + if (boomer instanceof Creeper && ((faction.isWilderness() && Conf.wildernessBlockCreepers && !Conf.worldsNoWildernessProtection.contains(block.getWorld().getName())) || + (faction.isNormal() && (online ? Conf.territoryBlockCreepers : Conf.territoryBlockCreepersWhenOffline)) || + (faction.isWarZone() && Conf.warZoneBlockCreepers) || + faction.isSafeZone())) { + // creeper which needs prevention + return false; + } else if ( + // it's a bit crude just using fireball protection for Wither boss too, but I'd rather not add in a whole new set of xxxBlockWitherExplosion or whatever + (boomer instanceof Fireball || boomer instanceof Wither) && (faction.isWilderness() && Conf.wildernessBlockFireballs && !Conf.worldsNoWildernessProtection.contains(block.getWorld().getName()) || faction.isNormal() && (online ? Conf.territoryBlockFireballs : Conf.territoryBlockFireballsWhenOffline) || faction.isWarZone() && Conf.warZoneBlockFireballs || faction.isSafeZone())) { + // ghast fireball which needs prevention + return false; + } else + return (!(boomer instanceof TNTPrimed) && !(boomer instanceof ExplosiveMinecart)) || ((!faction.isWilderness() || !Conf.wildernessBlockTNT || Conf.worldsNoWildernessProtection.contains(block.getWorld().getName())) && + (!faction.isNormal() || (online ? !Conf.territoryBlockTNT : !Conf.territoryBlockTNTWhenOffline)) && + (!faction.isWarZone() || !Conf.warZoneBlockTNT) && + (!faction.isSafeZone() || !Conf.safeZoneBlockTNT)); + + // No condition retained, destroy the block! + } + + // 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) + public void onEntityCombustByEntity(EntityCombustByEntityEvent event) { + EntityDamageByEntityEvent sub = new EntityDamageByEntityEvent(event.getCombuster(), event.getEntity(), EntityDamageEvent.DamageCause.FIRE, 0d); + if (!this.canDamagerHurtDamagee(sub, false)) { + event.setCancelled(true); + } + } + + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void onPotionSplashEvent(PotionSplashEvent event) { + // see if the potion has a harmful effect + boolean badjuju = false; + for (PotionEffect effect : event.getPotion().getEffects()) { + if (badPotionEffects.contains(effect.getType())) { + badjuju = true; + break; + } + } + if (!badjuju) { + return; + } + + ProjectileSource thrower = event.getPotion().getShooter(); + if (!(thrower instanceof Entity)) { + return; + } + + if (thrower instanceof Player) { + Player player = (Player) thrower; + FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player); + if (badjuju && fPlayer.getFaction().isPeaceful()) { + event.setCancelled(true); + return; + } + } + + // scan through affected entities to make sure they're all valid targets + for (LivingEntity target : event.getAffectedEntities()) { + EntityDamageByEntityEvent sub = new EntityDamageByEntityEvent((Entity) thrower, target, EntityDamageEvent.DamageCause.CUSTOM, 0); + if (!this.canDamagerHurtDamagee(sub, true)) { + event.setIntensity(target, 0.0); // affected entity list doesn't accept modification (so no iter.remove()), but this works + } + } + } + + public boolean isPlayerInSafeZone(Entity damagee) { + if (!(damagee instanceof Player)) { + return false; + } + return Board.getInstance().getFactionAt(new FLocation(damagee.getLocation())).isSafeZone(); + } + + public boolean canDamagerHurtDamagee(EntityDamageByEntityEvent sub) { + return canDamagerHurtDamagee(sub, true); + } + + public boolean canDamagerHurtDamagee(EntityDamageByEntityEvent sub, boolean notify) { + Entity damager = sub.getDamager(); + Entity damagee = sub.getEntity(); + + if (!(damagee instanceof Player)) { + return true; + } + + FPlayer defender = FPlayers.getInstance().getByPlayer((Player) damagee); + + if (defender == null || defender.getPlayer() == null) { + return true; + } + + Location defenderLoc = defender.getPlayer().getLocation(); + Faction defLocFaction = Board.getInstance().getFactionAt(new FLocation(defenderLoc)); + + // for damage caused by projectiles, getDamager() returns the projectile... what we need to know is the source + if (damager instanceof Projectile) { + Projectile projectile = (Projectile) damager; + + if (!(projectile.getShooter() instanceof Entity)) { + return true; + } + + damager = (Entity) projectile.getShooter(); + } + + if (damager == damagee) // ender pearl usage and other self-inflicted damage + { + return true; + } + + // Players can not take attack damage in a SafeZone, or possibly peaceful territory + if (defLocFaction.noPvPInTerritory()) { + if (damager instanceof Player) { + if (notify) { + FPlayer attacker = FPlayers.getInstance().getByPlayer((Player) damager); + attacker.msg(TL.PLAYER_CANTHURT, (defLocFaction.isSafeZone() ? TL.REGION_SAFEZONE.toString() : TL.REGION_PEACEFUL.toString())); + } + return false; + } + return !defLocFaction.noMonstersInTerritory(); + } + + if (!(damager instanceof Player)) { + return true; + } + + FPlayer attacker = FPlayers.getInstance().getByPlayer((Player) damager); + + if (attacker == null || attacker.getPlayer() == null) { + return true; + } + + if (Conf.playersWhoBypassAllProtection.contains(attacker.getName())) { + return true; + } + + if (attacker.hasLoginPvpDisabled()) { + if (notify) { + attacker.msg(TL.PLAYER_PVP_LOGIN, Conf.noPVPDamageToOthersForXSecondsAfterLogin); + } + return false; + } + + Faction locFaction = Board.getInstance().getFactionAt(new FLocation(attacker)); + + // so we know from above that the defender isn't in a safezone... what about the attacker, sneaky dog that he might be? + if (locFaction.noPvPInTerritory()) { + if (notify) { + attacker.msg(TL.PLAYER_CANTHURT, (locFaction.isSafeZone() ? TL.REGION_SAFEZONE.toString() : TL.REGION_PEACEFUL.toString())); + } + return false; + } + + if (locFaction.isWarZone() && Conf.warZoneFriendlyFire) { + return true; + } + + if (Conf.worldsIgnorePvP.contains(defenderLoc.getWorld().getName())) { + return true; + } + + Faction defendFaction = defender.getFaction(); + Faction attackFaction = attacker.getFaction(); + + if (attackFaction.isWilderness() && Conf.disablePVPForFactionlessPlayers) { + if (notify) { + attacker.msg(TL.PLAYER_PVP_REQUIREFACTION); + } + return false; + } else if (defendFaction.isWilderness()) { + if (defLocFaction == attackFaction && Conf.enablePVPAgainstFactionlessInAttackersLand) { + // Allow PVP vs. Factionless in attacker's faction territory + return true; + } else if (Conf.disablePVPForFactionlessPlayers) { + if (notify) { + attacker.msg(TL.PLAYER_PVP_FACTIONLESS); + } + return false; + } + } + + if (defendFaction.isPeaceful()) { + if (notify) { + attacker.msg(TL.PLAYER_PVP_PEACEFUL); + } + return false; + } else if (attackFaction.isPeaceful()) { + if (notify) { + attacker.msg(TL.PLAYER_PVP_PEACEFUL); + } + return false; + } + + Relation relation = defendFaction.getRelationTo(attackFaction); + + // You can not hurt neutral factions + if (Conf.disablePVPBetweenNeutralFactions && relation.isNeutral()) { + if (notify) { + attacker.msg(TL.PLAYER_PVP_NEUTRAL); + } + return false; + } + + // Players without faction may be hurt anywhere + if (!defender.hasFaction()) { + return true; + } + + // You can never hurt faction members or allies + if (relation.isMember() || relation.isAlly() || relation.isTruce()) { + if (notify) { + attacker.msg(TL.PLAYER_PVP_CANTHURT, defender.describeTo(attacker)); + } + return false; + } + + boolean ownTerritory = defender.isInOwnTerritory(); + + // You can not hurt neutrals in their own territory. + if (ownTerritory && relation.isNeutral()) { + if (notify) { + attacker.msg(TL.PLAYER_PVP_NEUTRALFAIL, defender.describeTo(attacker)); + defender.msg(TL.PLAYER_PVP_TRIED, attacker.describeTo(defender, true)); + } + return false; + } + + // Damage will be dealt. However check if the damage should be reduced. /* if (damage > 0.0 && ownTerritory && Conf.territoryShieldFactor > 0) { double newDamage = Math.ceil(damage * (1D - Conf.territoryShieldFactor)); @@ -526,228 +526,228 @@ public class FactionsEntityListener implements Listener { } } */ - return true; - } + return true; + } - @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) - public void onCreatureSpawn(CreatureSpawnEvent event) { - if (event.getLocation() == null) { - return; - } + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void onCreatureSpawn(CreatureSpawnEvent event) { + if (event.getLocation() == null) { + return; + } - if (Conf.safeZoneNerfedCreatureTypes.contains(event.getEntityType()) && Board.getInstance().getFactionAt(new FLocation(event.getLocation())).noMonstersInTerritory()) { - event.setCancelled(true); - } - } + if (Conf.safeZoneNerfedCreatureTypes.contains(event.getEntityType()) && Board.getInstance().getFactionAt(new FLocation(event.getLocation())).noMonstersInTerritory()) { + event.setCancelled(true); + } + } - @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) - public void onEntityTarget(EntityTargetEvent event) { - // if there is a target - Entity target = event.getTarget(); - if (target == null) { - return; - } + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void onEntityTarget(EntityTargetEvent event) { + // if there is a target + Entity target = event.getTarget(); + if (target == null) { + return; + } - // We are interested in blocking targeting for certain mobs: - if (!Conf.safeZoneNerfedCreatureTypes.contains(MiscUtil.creatureTypeFromEntity(event.getEntity()))) { - return; - } + // We are interested in blocking targeting for certain mobs: + if (!Conf.safeZoneNerfedCreatureTypes.contains(MiscUtil.creatureTypeFromEntity(event.getEntity()))) { + return; + } - // in case the target is in a safe zone. - if (Board.getInstance().getFactionAt(new FLocation(target.getLocation())).noMonstersInTerritory()) { - event.setCancelled(true); - } - } + // in case the target is in a safe zone. + if (Board.getInstance().getFactionAt(new FLocation(target.getLocation())).noMonstersInTerritory()) { + event.setCancelled(true); + } + } - @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) - public void onPaintingBreak(HangingBreakEvent event) { - if (event.getCause() == RemoveCause.EXPLOSION) { - Location loc = event.getEntity().getLocation(); - Faction faction = Board.getInstance().getFactionAt(new FLocation(loc)); - if (faction.noExplosionsInTerritory()) { - // faction is peaceful and has explosions set to disabled - event.setCancelled(true); - return; - } + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void onPaintingBreak(HangingBreakEvent event) { + if (event.getCause() == RemoveCause.EXPLOSION) { + Location loc = event.getEntity().getLocation(); + Faction faction = Board.getInstance().getFactionAt(new FLocation(loc)); + if (faction.noExplosionsInTerritory()) { + // faction is peaceful and has explosions set to disabled + event.setCancelled(true); + return; + } - boolean online = faction.hasPlayersOnline(); + boolean online = faction.hasPlayersOnline(); - if ((faction.isWilderness() && !Conf.worldsNoWildernessProtection.contains(loc.getWorld().getName()) && (Conf.wildernessBlockCreepers || Conf.wildernessBlockFireballs || Conf.wildernessBlockTNT)) || - (faction.isNormal() && (online ? (Conf.territoryBlockCreepers || Conf.territoryBlockFireballs || Conf.territoryBlockTNT) : (Conf.territoryBlockCreepersWhenOffline || Conf.territoryBlockFireballsWhenOffline || Conf.territoryBlockTNTWhenOffline))) || - (faction.isWarZone() && (Conf.warZoneBlockCreepers || Conf.warZoneBlockFireballs || Conf.warZoneBlockTNT)) || - faction.isSafeZone()) { - // explosion which needs prevention - event.setCancelled(true); - } - } - } + if ((faction.isWilderness() && !Conf.worldsNoWildernessProtection.contains(loc.getWorld().getName()) && (Conf.wildernessBlockCreepers || Conf.wildernessBlockFireballs || Conf.wildernessBlockTNT)) || + (faction.isNormal() && (online ? (Conf.territoryBlockCreepers || Conf.territoryBlockFireballs || Conf.territoryBlockTNT) : (Conf.territoryBlockCreepersWhenOffline || Conf.territoryBlockFireballsWhenOffline || Conf.territoryBlockTNTWhenOffline))) || + (faction.isWarZone() && (Conf.warZoneBlockCreepers || Conf.warZoneBlockFireballs || Conf.warZoneBlockTNT)) || + faction.isSafeZone()) { + // explosion which needs prevention + event.setCancelled(true); + } + } + } - @EventHandler - public void onHangerBreak(HangingBreakByEntityEvent e) { - if (e.getRemover() == null) return; - if (!(e.getRemover() instanceof Player)) return; - Player p = (Player) e.getRemover(); - if (e.getEntity().getType().equals(EntityType.PAINTING)) { - if (!FactionsBlockListener.playerCanBuildDestroyBlock(p, e.getEntity().getLocation(), "destroy", false)) { - e.setCancelled(true); - } - } else if (e.getEntity().getType().equals(EntityType.ITEM_FRAME)) { - if (!FactionsBlockListener.playerCanBuildDestroyBlock(p, e.getEntity().getLocation(), "destroy", false)) { - e.setCancelled(true); - } - } - } + @EventHandler + public void onHangerBreak(HangingBreakByEntityEvent e) { + if (e.getRemover() == null) return; + if (!(e.getRemover() instanceof Player)) return; + Player p = (Player) e.getRemover(); + if (e.getEntity().getType().equals(EntityType.PAINTING)) { + if (!FactionsBlockListener.playerCanBuildDestroyBlock(p, e.getEntity().getLocation(), "destroy", false)) { + e.setCancelled(true); + } + } else if (e.getEntity().getType().equals(EntityType.ITEM_FRAME)) { + if (!FactionsBlockListener.playerCanBuildDestroyBlock(p, e.getEntity().getLocation(), "destroy", false)) { + e.setCancelled(true); + } + } + } - @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) - public void onPaintingPlace(HangingPlaceEvent event) { - if (event.getEntity().getType().equals(EntityType.PAINTING)) { - if (!FactionsBlockListener.playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), "build", false)) { - event.setCancelled(true); - // Fix: update player's inventory to avoid items glitches - event.getPlayer().updateInventory(); - } - } else if (event.getEntity().getType().equals(EntityType.ITEM_FRAME)) { - if (!FactionsBlockListener.playerCanBuildDestroyBlock(event.getPlayer(), event.getEntity().getLocation(), "build", false)) { - event.setCancelled(true); - // Fix: update player's inventory to avoid items glitches - event.getPlayer().updateInventory(); - } - } - } + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void onPaintingPlace(HangingPlaceEvent event) { + if (event.getEntity().getType().equals(EntityType.PAINTING)) { + if (!FactionsBlockListener.playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), "build", false)) { + event.setCancelled(true); + // Fix: update player's inventory to avoid items glitches + event.getPlayer().updateInventory(); + } + } else if (event.getEntity().getType().equals(EntityType.ITEM_FRAME)) { + if (!FactionsBlockListener.playerCanBuildDestroyBlock(event.getPlayer(), event.getEntity().getLocation(), "build", false)) { + event.setCancelled(true); + // Fix: update player's inventory to avoid items glitches + event.getPlayer().updateInventory(); + } + } + } - @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) - public void onEntityChangeBlock(EntityChangeBlockEvent event) { - Entity entity = event.getEntity(); + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void onEntityChangeBlock(EntityChangeBlockEvent event) { + Entity entity = event.getEntity(); - // for now, only interested in Enderman and Wither boss tomfoolery - if (!(entity instanceof Enderman) && !(entity instanceof Wither)) { - return; - } + // for now, only interested in Enderman and Wither boss tomfoolery + if (!(entity instanceof Enderman) && !(entity instanceof Wither)) { + return; + } - Location loc = event.getBlock().getLocation(); + Location loc = event.getBlock().getLocation(); - if (entity instanceof Enderman) { - if (stopEndermanBlockManipulation(loc)) { - event.setCancelled(true); - } - } else if (entity instanceof Wither) { - Faction faction = Board.getInstance().getFactionAt(new FLocation(loc)); - // it's a bit crude just using fireball protection, but I'd rather not add in a whole new set of xxxBlockWitherExplosion or whatever - if ((faction.isWilderness() && Conf.wildernessBlockFireballs && !Conf.worldsNoWildernessProtection.contains(loc.getWorld().getName())) || - (faction.isNormal() && (faction.hasPlayersOnline() ? Conf.territoryBlockFireballs : Conf.territoryBlockFireballsWhenOffline)) || - (faction.isWarZone() && Conf.warZoneBlockFireballs) || - faction.isSafeZone()) { - event.setCancelled(true); - } - } - } + if (entity instanceof Enderman) { + if (stopEndermanBlockManipulation(loc)) { + event.setCancelled(true); + } + } else if (entity instanceof Wither) { + Faction faction = Board.getInstance().getFactionAt(new FLocation(loc)); + // it's a bit crude just using fireball protection, but I'd rather not add in a whole new set of xxxBlockWitherExplosion or whatever + if ((faction.isWilderness() && Conf.wildernessBlockFireballs && !Conf.worldsNoWildernessProtection.contains(loc.getWorld().getName())) || + (faction.isNormal() && (faction.hasPlayersOnline() ? Conf.territoryBlockFireballs : Conf.territoryBlockFireballsWhenOffline)) || + (faction.isWarZone() && Conf.warZoneBlockFireballs) || + faction.isSafeZone()) { + event.setCancelled(true); + } + } + } - @EventHandler - public void onTravel(PlayerPortalEvent event) { - if (!P.p.getConfig().getBoolean("portals.limit", false)) { - return; // Don't do anything if they don't want us to. - } + @EventHandler + public void onTravel(PlayerPortalEvent event) { + if (!P.p.getConfig().getBoolean("portals.limit", false)) { + return; // Don't do anything if they don't want us to. + } - TravelAgent agent = event.getPortalTravelAgent(); + TravelAgent agent = event.getPortalTravelAgent(); - // If they aren't able to find a portal, it'll try to create one. - if (event.useTravelAgent() && agent.getCanCreatePortal() && agent.findPortal(event.getTo()) == null) { - FLocation loc = new FLocation(event.getTo()); - Faction faction = Board.getInstance().getFactionAt(loc); - if (faction.isWilderness()) { - return; // We don't care about wilderness. - } else if (!faction.isNormal() && !event.getPlayer().isOp()) { - // Don't let non ops make portals in safezone or warzone. - event.setCancelled(true); - return; - } + // If they aren't able to find a portal, it'll try to create one. + if (event.useTravelAgent() && agent.getCanCreatePortal() && agent.findPortal(event.getTo()) == null) { + FLocation loc = new FLocation(event.getTo()); + Faction faction = Board.getInstance().getFactionAt(loc); + if (faction.isWilderness()) { + return; // We don't care about wilderness. + } else if (!faction.isNormal() && !event.getPlayer().isOp()) { + // Don't let non ops make portals in safezone or warzone. + event.setCancelled(true); + return; + } - FPlayer fp = FPlayers.getInstance().getByPlayer(event.getPlayer()); - String mininumRelation = P.p.getConfig().getString("portals.minimum-relation", "MEMBER"); // Defaults to Neutral if typed wrong. - if (!fp.getFaction().getRelationTo(faction).isAtLeast(Relation.fromString(mininumRelation))) { - event.setCancelled(true); - } - } - } + FPlayer fp = FPlayers.getInstance().getByPlayer(event.getPlayer()); + String mininumRelation = P.p.getConfig().getString("portals.minimum-relation", "MEMBER"); // Defaults to Neutral if typed wrong. + if (!fp.getFaction().getRelationTo(faction).isAtLeast(Relation.fromString(mininumRelation))) { + event.setCancelled(true); + } + } + } - @EventHandler - public void onHit(EntityDamageByEntityEvent e) { - if (e.getDamager() instanceof Player) { - if (e.getEntity() instanceof Player) { - Player victim = (Player) e.getEntity(); - Player attacker = (Player) e.getDamager(); - FPlayer fvictim = FPlayers.getInstance().getByPlayer(victim); - FPlayer fattacker = FPlayers.getInstance().getByPlayer(attacker); - if (fattacker.getRelationTo(fvictim) == Relation.TRUCE) { - fattacker.msg(TL.PLAYER_PVP_CANTHURT, fvictim.describeTo(fattacker)); - e.setCancelled(true); - } - } - } - } + @EventHandler + public void onHit(EntityDamageByEntityEvent e) { + if (e.getDamager() instanceof Player) { + if (e.getEntity() instanceof Player) { + Player victim = (Player) e.getEntity(); + Player attacker = (Player) e.getDamager(); + FPlayer fvictim = FPlayers.getInstance().getByPlayer(victim); + FPlayer fattacker = FPlayers.getInstance().getByPlayer(attacker); + if (fattacker.getRelationTo(fvictim) == Relation.TRUCE) { + fattacker.msg(TL.PLAYER_PVP_CANTHURT, fvictim.describeTo(fattacker)); + e.setCancelled(true); + } + } + } + } - @EventHandler - public void onBowHit(EntityDamageByEntityEvent e) { - if (e.getDamager() instanceof Projectile) { - if (e.getEntity() instanceof Player) { - Projectile arrow = ((Projectile) e.getDamager()); - if (arrow.getShooter() instanceof Player) { - Player damager = (Player) ((Projectile) e.getDamager()).getShooter(); - Player victim = (Player) e.getEntity(); - FPlayer fdamager = FPlayers.getInstance().getByPlayer(damager); - FPlayer fvictim = FPlayers.getInstance().getByPlayer(victim); - if (fvictim.getRelationTo(fdamager) == Relation.TRUCE) { - fdamager.msg(TL.PLAYER_PVP_CANTHURT, fvictim.describeTo(fdamager)); - e.setCancelled(true); - } - if (fvictim.getRelationTo(fdamager) == Relation.ENEMY) { - if (fvictim.isFlying()) { - fvictim.setFFlying(false, true); - } - } - } - } - } - } + @EventHandler + public void onBowHit(EntityDamageByEntityEvent e) { + if (e.getDamager() instanceof Projectile) { + if (e.getEntity() instanceof Player) { + Projectile arrow = ((Projectile) e.getDamager()); + if (arrow.getShooter() instanceof Player) { + Player damager = (Player) ((Projectile) e.getDamager()).getShooter(); + Player victim = (Player) e.getEntity(); + FPlayer fdamager = FPlayers.getInstance().getByPlayer(damager); + FPlayer fvictim = FPlayers.getInstance().getByPlayer(victim); + if (fvictim.getRelationTo(fdamager) == Relation.TRUCE) { + fdamager.msg(TL.PLAYER_PVP_CANTHURT, fvictim.describeTo(fdamager)); + e.setCancelled(true); + } + if (fvictim.getRelationTo(fdamager) == Relation.ENEMY) { + if (fvictim.isFlying()) { + fvictim.setFFlying(false, true); + } + } + } + } + } + } - // For disabling interactions with item frames in another faction's territory - @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) - public void onPlayerInteractEntity(PlayerInteractEntityEvent event) { - // only need to check for item frames - if (event.getRightClicked() == null) return; - if (!event.getRightClicked().getType().equals(EntityType.ITEM_FRAME)) return; + // For disabling interactions with item frames in another faction's territory + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void onPlayerInteractEntity(PlayerInteractEntityEvent event) { + // only need to check for item frames + if (event.getRightClicked() == null) return; + if (!event.getRightClicked().getType().equals(EntityType.ITEM_FRAME)) return; - if (!FactionsBlockListener.playerCanBuildDestroyBlock(event.getPlayer(), event.getRightClicked().getLocation(), "build", false)) { - event.setCancelled(true); - } - } + if (!FactionsBlockListener.playerCanBuildDestroyBlock(event.getPlayer(), event.getRightClicked().getLocation(), "build", false)) { + event.setCancelled(true); + } + } - private boolean stopEndermanBlockManipulation(Location loc) { - if (loc == null) { - return false; - } - // quick check to see if all Enderman deny options are enabled; if so, no need to check location - if (Conf.wildernessDenyEndermanBlocks && - Conf.territoryDenyEndermanBlocks && - Conf.territoryDenyEndermanBlocksWhenOffline && - Conf.safeZoneDenyEndermanBlocks && - Conf.warZoneDenyEndermanBlocks) { - return true; - } + private boolean stopEndermanBlockManipulation(Location loc) { + if (loc == null) { + return false; + } + // quick check to see if all Enderman deny options are enabled; if so, no need to check location + if (Conf.wildernessDenyEndermanBlocks && + Conf.territoryDenyEndermanBlocks && + Conf.territoryDenyEndermanBlocksWhenOffline && + Conf.safeZoneDenyEndermanBlocks && + Conf.warZoneDenyEndermanBlocks) { + return true; + } - FLocation fLoc = new FLocation(loc); - Faction claimFaction = Board.getInstance().getFactionAt(fLoc); + FLocation fLoc = new FLocation(loc); + Faction claimFaction = Board.getInstance().getFactionAt(fLoc); - if (claimFaction.isWilderness()) { - return Conf.wildernessDenyEndermanBlocks; - } else if (claimFaction.isNormal()) { - return claimFaction.hasPlayersOnline() ? Conf.territoryDenyEndermanBlocks : Conf.territoryDenyEndermanBlocksWhenOffline; - } else if (claimFaction.isSafeZone()) { - return Conf.safeZoneDenyEndermanBlocks; - } else if (claimFaction.isWarZone()) { - return Conf.warZoneDenyEndermanBlocks; - } + if (claimFaction.isWilderness()) { + return Conf.wildernessDenyEndermanBlocks; + } else if (claimFaction.isNormal()) { + return claimFaction.hasPlayersOnline() ? Conf.territoryDenyEndermanBlocks : Conf.territoryDenyEndermanBlocksWhenOffline; + } else if (claimFaction.isSafeZone()) { + return Conf.safeZoneDenyEndermanBlocks; + } else if (claimFaction.isWarZone()) { + return Conf.warZoneDenyEndermanBlocks; + } - return false; - } + return false; + } } diff --git a/src/main/java/com/massivecraft/factions/listeners/FactionsExploitListener.java b/src/main/java/com/massivecraft/factions/listeners/FactionsExploitListener.java index 50ad9813..30081750 100644 --- a/src/main/java/com/massivecraft/factions/listeners/FactionsExploitListener.java +++ b/src/main/java/com/massivecraft/factions/listeners/FactionsExploitListener.java @@ -15,65 +15,65 @@ import org.bukkit.event.player.PlayerTeleportEvent; public class FactionsExploitListener implements Listener { - public static boolean clippingThrough(Location target, Location from, double thickness) { - return ((from.getX() > target.getX() && (from.getX() - target.getX() < thickness)) || (target.getX() > from.getX() && (target.getX() - from.getX() < thickness)) || (from.getZ() > target.getZ() && (from.getZ() - target.getZ() < thickness)) || (target.getZ() > from.getZ() && (target.getZ() - from.getZ() < thickness))); - } + public static boolean clippingThrough(Location target, Location from, double thickness) { + return ((from.getX() > target.getX() && (from.getX() - target.getX() < thickness)) || (target.getX() > from.getX() && (target.getX() - from.getX() < thickness)) || (from.getZ() > target.getZ() && (from.getZ() - target.getZ() < thickness)) || (target.getZ() > from.getZ() && (target.getZ() - from.getZ() < thickness))); + } - @SuppressWarnings("deprecation") - @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) - public void obsidianGenerator(BlockFromToEvent event) { - if (!Conf.handleExploitObsidianGenerators) { - return; - } + @SuppressWarnings("deprecation") + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void obsidianGenerator(BlockFromToEvent event) { + if (!Conf.handleExploitObsidianGenerators) { + return; + } - // thanks to ObGenBlocker and WorldGuard for this method - Block block = event.getToBlock(); + // thanks to ObGenBlocker and WorldGuard for this method + Block block = event.getToBlock(); - // Added this so it wont die on 1.14 :) - if (P.p.mc114) { - Material source = event.getBlock().getType(); - Material target = block.getType(); - if ((target == Material.REDSTONE_WIRE || target == Material.TRIPWIRE) && (source == Material.AIR || source == Material.LEGACY_STATIONARY_LAVA || source == Material.LEGACY_LAVA)) { - block.setType(Material.AIR); - } - return; - } + // Added this so it wont die on 1.14 :) + if (P.p.mc114) { + Material source = event.getBlock().getType(); + Material target = block.getType(); + if ((target == Material.REDSTONE_WIRE || target == Material.TRIPWIRE) && (source == Material.AIR || source == Material.LEGACY_STATIONARY_LAVA || source == Material.LEGACY_LAVA)) { + block.setType(Material.AIR); + } + return; + } - // run this for all versions below 1.14 - int source = event.getBlock().getType().getId(); - int target = block.getType().getId(); - if ((target == 55 || target == 132) && (source == 0 || source == 10 || source == 11)) { - block.setType(Material.AIR); - } + // run this for all versions below 1.14 + int source = event.getBlock().getType().getId(); + int target = block.getType().getId(); + if ((target == 55 || target == 132) && (source == 0 || source == 10 || source == 11)) { + block.setType(Material.AIR); + } - } + } - @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) - public void enderPearlTeleport(PlayerTeleportEvent event) { - if (!Conf.handleExploitEnderPearlClipping) { - return; - } - if (event.getCause() != PlayerTeleportEvent.TeleportCause.ENDER_PEARL) { - return; - } + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void enderPearlTeleport(PlayerTeleportEvent event) { + if (!Conf.handleExploitEnderPearlClipping) { + return; + } + if (event.getCause() != PlayerTeleportEvent.TeleportCause.ENDER_PEARL) { + return; + } - // this exploit works when the target location is within 0.31 blocks or so of a door or glass block or similar... - Location target = event.getTo(); - Location from = event.getFrom(); + // this exploit works when the target location is within 0.31 blocks or so of a door or glass block or similar... + Location target = event.getTo(); + Location from = event.getFrom(); - // blocks who occupy less than 1 block width or length wise need to be handled differently - Material mat = event.getTo().getBlock().getType(); - if (((mat == XMaterial.GLASS_PANE.parseMaterial() - || mat == XMaterial.IRON_BARS.parseMaterial()) && clippingThrough(target, from, 0.65)) - || ((mat == XMaterial.OAK_FENCE.parseMaterial() || mat == XMaterial.NETHER_BRICK_FENCE.parseMaterial()) && clippingThrough(target, from, 0.45))) { - event.setTo(from); - return; - } + // blocks who occupy less than 1 block width or length wise need to be handled differently + Material mat = event.getTo().getBlock().getType(); + if (((mat == XMaterial.GLASS_PANE.parseMaterial() + || mat == XMaterial.IRON_BARS.parseMaterial()) && clippingThrough(target, from, 0.65)) + || ((mat == XMaterial.OAK_FENCE.parseMaterial() || mat == XMaterial.NETHER_BRICK_FENCE.parseMaterial()) && clippingThrough(target, from, 0.45))) { + event.setTo(from); + return; + } - // simple fix otherwise: ender pearl target locations are standardized to be in the center (X/Z) of the target block, not at the edges - target.setX(target.getBlockX() + 0.5); - target.setZ(target.getBlockZ() + 0.5); - event.setTo(target); + // simple fix otherwise: ender pearl target locations are standardized to be in the center (X/Z) of the target block, not at the edges + target.setX(target.getBlockX() + 0.5); + target.setZ(target.getBlockZ() + 0.5); + event.setTo(target); - } + } } diff --git a/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java b/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java index 6d7fa16d..b4088697 100644 --- a/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java +++ b/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java @@ -46,9 +46,8 @@ import java.util.logging.Level; public class FactionsPlayerListener implements Listener { - private Set corners; HashMap fallMap = new HashMap<>(); - + private Set corners; // 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 @@ -287,6 +286,173 @@ public class FactionsPlayerListener implements Listener { return false; } + ///

+ /// This checks if the current player can execute an action based on it's factions access and surroundings + /// It will grant access in the following priorities: + /// - If Faction Land is Owned and the Owner is the current player, or player is faction leader. + /// - If Faction Land is not Owned and my access value is not set to DENY + /// - If none of the filters above matches, then we consider access is set to ALLOW|UNDEFINED + /// This check does not performs any kind of bypass check (i.e.: me.isAdminBypassing()) + /// + /// The player entity which the check will be made upon + /// The Faction player object related to the player + /// The World location where the action is being executed + /// The faction of the player being checked + /// The current's faction access permission for the action + private static boolean CheckPlayerAccess(Player player, FPlayer me, FLocation loc, Faction factionToCheck, Access access, PermissableAction action, boolean pain) { + boolean doPain = pain && Conf.handleExploitInteractionSpam; + if (access != null && access != Access.UNDEFINED) { + // TODO: Update this once new access values are added other than just allow / deny. + boolean landOwned = (factionToCheck.doesLocationHaveOwnersSet(loc) && !factionToCheck.getOwnerList(loc).isEmpty()); + if ((landOwned && factionToCheck.getOwnerListString(loc).contains(player.getName())) || (me.getRole() == Role.LEADER && me.getFactionId().equals(factionToCheck.getId()))) + return true; + else if (landOwned && !factionToCheck.getOwnerListString(loc).contains(player.getName())) { + me.msg("You can't do that in this territory, it is owned by: " + factionToCheck.getOwnerListString(loc)); + if (doPain) { + player.damage(Conf.actionDeniedPainAmount); + } + return false; + } else if (!landOwned && access == Access.ALLOW) return true; + else { + me.msg("You cannot " + action + " in the territory of " + factionToCheck.getTag(me.getFaction())); + return false; + } + } + // Approves any permission check if the player in question is a leader AND owns the faction. + if (me.getRole().equals(Role.LEADER) && me.getFaction().equals(factionToCheck)) return true; + me.msg("You cannot " + action + " in the territory of " + factionToCheck.getTag(me.getFaction())); + return false; + } + + /// + /// This will try to resolve a permission action based on the item material, if it's not usable, will return null + /// + private static PermissableAction GetPermissionFromUsableBlock(Block block) { + return GetPermissionFromUsableBlock(block.getType()); + } + + /// + /// This will try to resolve a permission action based on the item material, if it's not usable, will return null + /// + private static PermissableAction GetPermissionFromUsableBlock(Material material) { + // Check for doors that might have diff material name in old version. + if (material.name().contains("DOOR") || material.name().contains("FENCE_GATE")) + return PermissableAction.DOOR; + if (material.name().toUpperCase().contains("BUTTON") || material.name().toUpperCase().contains("PRESSURE")) + return PermissableAction.BUTTON; + if (P.p.mc113) { + switch (material) { + case LEVER: + return PermissableAction.LEVER; + + case ACACIA_BUTTON: + case BIRCH_BUTTON: + case DARK_OAK_BUTTON: + case JUNGLE_BUTTON: + case OAK_BUTTON: + case SPRUCE_BUTTON: + case STONE_BUTTON: + return PermissableAction.BUTTON; + + 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: + return PermissableAction.DOOR; + + 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: + return PermissableAction.CONTAINER; + default: + return null; + } + } else { + switch (material) { + case LEVER: + return PermissableAction.LEVER; + 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 OAK_FENCE_GATE: + case JUNGLE_FENCE_GATE: + case SPRUCE_FENCE_GATE: + return PermissableAction.DOOR; + 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: + return PermissableAction.CONTAINER; + default: + return null; + } + } + } + @EventHandler(priority = EventPriority.NORMAL) public void onPlayerJoin(PlayerJoinEvent event) { initPlayer(event.getPlayer()); @@ -486,13 +652,11 @@ public class FactionsPlayerListener implements Listener { } } - 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(); @@ -565,27 +729,27 @@ public class FactionsPlayerListener implements Listener { enableFly(me); } } - if (me.getAutoClaimFor() != null) { - me.attemptClaim(me.getAutoClaimFor(), event.getTo(), true); - if (Conf.disableFlightOnFactionClaimChange) CmdFly.disableFlight(me); - } 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); - } + if (me.getAutoClaimFor() != null) { + me.attemptClaim(me.getAutoClaimFor(), event.getTo(), true); + if (Conf.disableFlightOnFactionClaimChange) CmdFly.disableFlight(me); + } 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); - } + } + } 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); } + } } } @@ -804,194 +968,10 @@ public class FactionsPlayerListener implements Listener { 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; - } - } - public Set getCorners() { return this.corners; } - /// - /// This checks if the current player can execute an action based on it's factions access and surroundings - /// It will grant access in the following priorities: - /// - If Faction Land is Owned and the Owner is the current player, or player is faction leader. - /// - If Faction Land is not Owned and my access value is not set to DENY - /// - If none of the filters above matches, then we consider access is set to ALLOW|UNDEFINED - /// This check does not performs any kind of bypass check (i.e.: me.isAdminBypassing()) - /// - /// The player entity which the check will be made upon - /// The Faction player object related to the player - /// The World location where the action is being executed - /// The faction of the player being checked - /// The current's faction access permission for the action - private static boolean CheckPlayerAccess(Player player, FPlayer me, FLocation loc, Faction factionToCheck, Access access, PermissableAction action, boolean pain) { - boolean doPain = pain && Conf.handleExploitInteractionSpam; - if (access != null && access != Access.UNDEFINED) { - // TODO: Update this once new access values are added other than just allow / deny. - boolean landOwned = (factionToCheck.doesLocationHaveOwnersSet(loc) && !factionToCheck.getOwnerList(loc).isEmpty()); - if ((landOwned && factionToCheck.getOwnerListString(loc).contains(player.getName())) || (me.getRole() == Role.LEADER && me.getFactionId().equals(factionToCheck.getId()))) - return true; - else if (landOwned && !factionToCheck.getOwnerListString(loc).contains(player.getName())) { - me.msg("You can't do that in this territory, it is owned by: " + factionToCheck.getOwnerListString(loc)); - if (doPain) { - player.damage(Conf.actionDeniedPainAmount); - } - return false; - } else if (!landOwned && access == Access.ALLOW) return true; - else { - me.msg("You cannot " + action + " in the territory of " + factionToCheck.getTag(me.getFaction())); - return false; - } - } - // Approves any permission check if the player in question is a leader AND owns the faction. - if (me.getRole().equals(Role.LEADER) && me.getFaction().equals(factionToCheck)) return true; - me.msg("You cannot " + action + " in the territory of " + factionToCheck.getTag(me.getFaction())); - return false; - } - - /// - /// This will try to resolve a permission action based on the item material, if it's not usable, will return null - /// - private static PermissableAction GetPermissionFromUsableBlock(Block block) { - return GetPermissionFromUsableBlock(block.getType()); - } - - /// - /// This will try to resolve a permission action based on the item material, if it's not usable, will return null - /// - private static PermissableAction GetPermissionFromUsableBlock(Material material) { - // Check for doors that might have diff material name in old version. - if (material.name().contains("DOOR") || material.name().contains("FENCE_GATE")) - return PermissableAction.DOOR; - if (material.name().toUpperCase().contains("BUTTON") || material.name().toUpperCase().contains("PRESSURE")) - return PermissableAction.BUTTON; - if (P.p.mc113) { - switch (material) { - case LEVER: - return PermissableAction.LEVER; - - case ACACIA_BUTTON: - case BIRCH_BUTTON: - case DARK_OAK_BUTTON: - case JUNGLE_BUTTON: - case OAK_BUTTON: - case SPRUCE_BUTTON: - case STONE_BUTTON: - return PermissableAction.BUTTON; - - 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: - return PermissableAction.DOOR; - - 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: - return PermissableAction.CONTAINER; - default: - return null; - } - } else { - switch (material) { - case LEVER: - return PermissableAction.LEVER; - 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 OAK_FENCE_GATE: - case JUNGLE_FENCE_GATE: - case SPRUCE_FENCE_GATE: - return PermissableAction.DOOR; - 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: - return PermissableAction.CONTAINER; - default: - return null; - } - } - } - @EventHandler public void AsyncPlayerChatEvent(AsyncPlayerChatEvent e) { Player p = e.getPlayer(); @@ -1026,4 +1006,21 @@ public class FactionsPlayerListener implements Listener { } } } + + 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/missions/MissionHandler.java b/src/main/java/com/massivecraft/factions/missions/MissionHandler.java index 13c23775..32d55505 100644 --- a/src/main/java/com/massivecraft/factions/missions/MissionHandler.java +++ b/src/main/java/com/massivecraft/factions/missions/MissionHandler.java @@ -20,7 +20,7 @@ public class MissionHandler implements Listener { private P plugin; - public MissionHandler(P plugin){ + public MissionHandler(P plugin) { this.plugin = plugin; } diff --git a/src/main/java/com/massivecraft/factions/scoreboards/BufferedObjective.java b/src/main/java/com/massivecraft/factions/scoreboards/BufferedObjective.java index 03b6f565..d21d3898 100644 --- a/src/main/java/com/massivecraft/factions/scoreboards/BufferedObjective.java +++ b/src/main/java/com/massivecraft/factions/scoreboards/BufferedObjective.java @@ -11,152 +11,152 @@ import java.lang.reflect.Method; import java.util.*; public class BufferedObjective { - private static final Method addEntryMethod; - private static final int MAX_LINE_LENGTH; + private static final Method addEntryMethod; + private static final int MAX_LINE_LENGTH; - static { - // Check for long line support. - // We require use of Spigot's `addEntry(String)` method on - // Teams, as adding OfflinePlayers to a team is far too slow. + static { + // Check for long line support. + // We require use of Spigot's `addEntry(String)` method on + // Teams, as adding OfflinePlayers to a team is far too slow. - Method addEntryMethodLookup = null; - try { - addEntryMethodLookup = Team.class.getMethod("addEntry", String.class); - } catch (NoSuchMethodException ignored) { - } + Method addEntryMethodLookup = null; + try { + addEntryMethodLookup = Team.class.getMethod("addEntry", String.class); + } catch (NoSuchMethodException ignored) { + } - addEntryMethod = addEntryMethodLookup; + addEntryMethod = addEntryMethodLookup; - if (addEntryMethod != null) { - MAX_LINE_LENGTH = 48; - } else { - MAX_LINE_LENGTH = 16; - } - } + if (addEntryMethod != null) { + MAX_LINE_LENGTH = 48; + } else { + MAX_LINE_LENGTH = 16; + } + } - private final Scoreboard scoreboard; - private final String baseName; - private final Map contents = new HashMap<>(); - private Objective current; - private List currentTeams = new ArrayList<>(); - private String title; - private DisplaySlot displaySlot; - private int objPtr; - private int teamPtr; - private boolean requiresUpdate = false; + private final Scoreboard scoreboard; + private final String baseName; + private final Map contents = new HashMap<>(); + private Objective current; + private List currentTeams = new ArrayList<>(); + private String title; + private DisplaySlot displaySlot; + private int objPtr; + private int teamPtr; + private boolean requiresUpdate = false; - public BufferedObjective(Scoreboard scoreboard) { - this.scoreboard = scoreboard; - this.baseName = createBaseName(); + public BufferedObjective(Scoreboard scoreboard) { + this.scoreboard = scoreboard; + this.baseName = createBaseName(); - current = scoreboard.registerNewObjective(getNextObjectiveName(), "dummy"); - } + current = scoreboard.registerNewObjective(getNextObjectiveName(), "dummy"); + } - private String createBaseName() { - Random random = new Random(); - StringBuilder builder = new StringBuilder(); - while (builder.length() < 14) { - builder.append(Integer.toHexString(random.nextInt())); - } - return builder.toString().substring(0, 14); - } + private String createBaseName() { + Random random = new Random(); + StringBuilder builder = new StringBuilder(); + while (builder.length() < 14) { + builder.append(Integer.toHexString(random.nextInt())); + } + return builder.toString().substring(0, 14); + } - public void setTitle(String title) { - if (this.title == null || !this.title.equals(title)) { - this.title = title; - requiresUpdate = true; - } - } + public void setTitle(String title) { + if (this.title == null || !this.title.equals(title)) { + this.title = title; + requiresUpdate = true; + } + } - public void setDisplaySlot(DisplaySlot slot) { - this.displaySlot = slot; - current.setDisplaySlot(slot); - } + public void setDisplaySlot(DisplaySlot slot) { + this.displaySlot = slot; + current.setDisplaySlot(slot); + } - public void setAllLines(List lines) { - if (lines.size() != contents.size()) { - contents.clear(); - } - for (int i = 0; i < lines.size(); i++) { - setLine(lines.size() - i, lines.get(i)); - } - } + public void setAllLines(List lines) { + if (lines.size() != contents.size()) { + contents.clear(); + } + for (int i = 0; i < lines.size(); i++) { + setLine(lines.size() - i, lines.get(i)); + } + } - public void setLine(int lineNumber, String content) { - if (content.length() > MAX_LINE_LENGTH) { - content = content.substring(0, MAX_LINE_LENGTH); - } - content = ChatColor.translateAlternateColorCodes('&', content); + public void setLine(int lineNumber, String content) { + if (content.length() > MAX_LINE_LENGTH) { + content = content.substring(0, MAX_LINE_LENGTH); + } + content = ChatColor.translateAlternateColorCodes('&', content); - if (contents.get(lineNumber) == null || !contents.get(lineNumber).equals(content)) { - contents.put(lineNumber, content); - requiresUpdate = true; - } - } + if (contents.get(lineNumber) == null || !contents.get(lineNumber).equals(content)) { + contents.put(lineNumber, content); + requiresUpdate = true; + } + } - // Hides the objective from the display slot until flip() is called - public void hide() { - if (displaySlot != null) { - scoreboard.clearSlot(displaySlot); - } - } + // Hides the objective from the display slot until flip() is called + public void hide() { + if (displaySlot != null) { + scoreboard.clearSlot(displaySlot); + } + } - public void flip() { - if (!requiresUpdate) { - return; - } - requiresUpdate = false; + public void flip() { + if (!requiresUpdate) { + return; + } + requiresUpdate = false; - Objective buffer = scoreboard.registerNewObjective(getNextObjectiveName(), "dummy"); - buffer.setDisplayName(title); + Objective buffer = scoreboard.registerNewObjective(getNextObjectiveName(), "dummy"); + buffer.setDisplayName(title); - List bufferTeams = new ArrayList<>(); + List bufferTeams = new ArrayList<>(); - for (Map.Entry entry : contents.entrySet()) { - if (entry.getValue().length() > 16) { - Team team = scoreboard.registerNewTeam(getNextTeamName()); - bufferTeams.add(team); + for (Map.Entry entry : contents.entrySet()) { + if (entry.getValue().length() > 16) { + Team team = scoreboard.registerNewTeam(getNextTeamName()); + bufferTeams.add(team); - Iterator split = Splitter.fixedLength(16).split(entry.getValue()).iterator(); + Iterator split = Splitter.fixedLength(16).split(entry.getValue()).iterator(); - team.setPrefix(split.next()); - String name = split.next(); - if (split.hasNext()) { // We only guarantee two splits - team.setSuffix(split.next()); - } + team.setPrefix(split.next()); + String name = split.next(); + if (split.hasNext()) { // We only guarantee two splits + team.setSuffix(split.next()); + } - try { - addEntryMethod.invoke(team, name); - } catch (ReflectiveOperationException ignored) { - } - buffer.getScore(name).setScore(entry.getKey()); - } else { - buffer.getScore(entry.getValue()).setScore(entry.getKey()); - } - } + try { + addEntryMethod.invoke(team, name); + } catch (ReflectiveOperationException ignored) { + } + buffer.getScore(name).setScore(entry.getKey()); + } else { + buffer.getScore(entry.getValue()).setScore(entry.getKey()); + } + } - if (displaySlot != null) { - buffer.setDisplaySlot(displaySlot); - } + if (displaySlot != null) { + buffer.setDisplaySlot(displaySlot); + } - // Unregister _ALL_ the old things - current.unregister(); + // Unregister _ALL_ the old things + current.unregister(); - Iterator it = currentTeams.iterator(); - while (it.hasNext()) { - it.next().unregister(); - it.remove(); - } + Iterator it = currentTeams.iterator(); + while (it.hasNext()) { + it.next().unregister(); + it.remove(); + } - current = buffer; - currentTeams = bufferTeams; - } + current = buffer; + currentTeams = bufferTeams; + } - private String getNextObjectiveName() { - return baseName + "_" + ((objPtr++) % 2); - } + private String getNextObjectiveName() { + return baseName + "_" + ((objPtr++) % 2); + } - private String getNextTeamName() { - return baseName.substring(0, 10) + "_" + ((teamPtr++) % 999999); - } + private String getNextTeamName() { + return baseName.substring(0, 10) + "_" + ((teamPtr++) % 999999); + } } \ No newline at end of file diff --git a/src/main/java/com/massivecraft/factions/scoreboards/FScoreboard.java b/src/main/java/com/massivecraft/factions/scoreboards/FScoreboard.java index 9dd6304e..2225137a 100644 --- a/src/main/java/com/massivecraft/factions/scoreboards/FScoreboard.java +++ b/src/main/java/com/massivecraft/factions/scoreboards/FScoreboard.java @@ -13,137 +13,137 @@ import java.util.HashMap; import java.util.Map; public class FScoreboard { - private static final Map fscoreboards = new HashMap<>(); + private static final Map fscoreboards = new HashMap<>(); - private final Scoreboard scoreboard; - private final FPlayer fplayer; - private final BufferedObjective bufferedObjective; - private FSidebarProvider defaultProvider; - private FSidebarProvider temporaryProvider; - private boolean removed = false; + private final Scoreboard scoreboard; + private final FPlayer fplayer; + private final BufferedObjective bufferedObjective; + private FSidebarProvider defaultProvider; + private FSidebarProvider temporaryProvider; + private boolean removed = false; - private FScoreboard(FPlayer fplayer) { - this.fplayer = fplayer; + private FScoreboard(FPlayer fplayer) { + this.fplayer = fplayer; - if (isSupportedByServer()) { - this.scoreboard = Bukkit.getScoreboardManager().getNewScoreboard(); - this.bufferedObjective = new BufferedObjective(scoreboard); + if (isSupportedByServer()) { + this.scoreboard = Bukkit.getScoreboardManager().getNewScoreboard(); + this.bufferedObjective = new BufferedObjective(scoreboard); - fplayer.getPlayer().setScoreboard(scoreboard); - } else { - this.scoreboard = null; - this.bufferedObjective = null; - } - } + fplayer.getPlayer().setScoreboard(scoreboard); + } else { + this.scoreboard = null; + this.bufferedObjective = null; + } + } - // Glowstone doesn't support scoreboards. - // All references to this and related workarounds can be safely - // removed when scoreboards are supported. - public static boolean isSupportedByServer() { - return Bukkit.getScoreboardManager() != null; - } + // Glowstone doesn't support scoreboards. + // All references to this and related workarounds can be safely + // removed when scoreboards are supported. + public static boolean isSupportedByServer() { + return Bukkit.getScoreboardManager() != null; + } - public static void init(FPlayer fplayer) { - FScoreboard fboard = new FScoreboard(fplayer); - fscoreboards.put(fplayer, fboard); + public static void init(FPlayer fplayer) { + FScoreboard fboard = new FScoreboard(fplayer); + fscoreboards.put(fplayer, fboard); - if (fplayer.hasFaction()) { - FTeamWrapper.applyUpdates(fplayer.getFaction()); - } - FTeamWrapper.track(fboard); - } + if (fplayer.hasFaction()) { + FTeamWrapper.applyUpdates(fplayer.getFaction()); + } + FTeamWrapper.track(fboard); + } - public static void remove(FPlayer fplayer) { - FScoreboard fboard = fscoreboards.remove(fplayer); + public static void remove(FPlayer fplayer) { + FScoreboard fboard = fscoreboards.remove(fplayer); - if (fboard != null) { - fboard.removed = true; - FTeamWrapper.untrack(fboard); - } - } + if (fboard != null) { + fboard.removed = true; + FTeamWrapper.untrack(fboard); + } + } - public static FScoreboard get(FPlayer fplayer) { - return fscoreboards.get(fplayer); - } + public static FScoreboard get(FPlayer fplayer) { + return fscoreboards.get(fplayer); + } - public static FScoreboard get(Player player) { - return fscoreboards.get(FPlayers.getInstance().getByPlayer(player)); - } + public static FScoreboard get(Player player) { + return fscoreboards.get(FPlayers.getInstance().getByPlayer(player)); + } - protected FPlayer getFPlayer() { - return fplayer; - } + protected FPlayer getFPlayer() { + return fplayer; + } - protected Scoreboard getScoreboard() { - return scoreboard; - } + protected Scoreboard getScoreboard() { + return scoreboard; + } - public void setSidebarVisibility(boolean visible) { - if (!isSupportedByServer()) { - return; - } + public void setSidebarVisibility(boolean visible) { + if (!isSupportedByServer()) { + return; + } - bufferedObjective.setDisplaySlot(visible ? DisplaySlot.SIDEBAR : null); - } + bufferedObjective.setDisplaySlot(visible ? DisplaySlot.SIDEBAR : null); + } - public void setDefaultSidebar(final FSidebarProvider provider, int updateInterval) { - if (!isSupportedByServer()) { - return; - } + public void setDefaultSidebar(final FSidebarProvider provider, int updateInterval) { + if (!isSupportedByServer()) { + return; + } - defaultProvider = provider; - if (temporaryProvider == null) { - // We have no temporary provider; update the BufferedObjective! - updateObjective(); - } + defaultProvider = provider; + if (temporaryProvider == null) { + // We have no temporary provider; update the BufferedObjective! + updateObjective(); + } - new BukkitRunnable() { - @Override - public void run() { - if (removed || provider != defaultProvider) { - cancel(); - return; - } + new BukkitRunnable() { + @Override + public void run() { + if (removed || provider != defaultProvider) { + cancel(); + return; + } - if (temporaryProvider == null) { - updateObjective(); - } - } - }.runTaskTimer(P.p, updateInterval, updateInterval); - } + if (temporaryProvider == null) { + updateObjective(); + } + } + }.runTaskTimer(P.p, updateInterval, updateInterval); + } - public void setTemporarySidebar(final FSidebarProvider provider) { - if (!isSupportedByServer()) { - return; - } + public void setTemporarySidebar(final FSidebarProvider provider) { + if (!isSupportedByServer()) { + return; + } - temporaryProvider = provider; - updateObjective(); + temporaryProvider = provider; + updateObjective(); - new BukkitRunnable() { - @Override - public void run() { - if (removed) { - return; - } + new BukkitRunnable() { + @Override + public void run() { + if (removed) { + return; + } - if (temporaryProvider == provider) { - temporaryProvider = null; - updateObjective(); - } - } - }.runTaskLater(P.p, P.p.getConfig().getInt("scoreboard.expiration", 7) * 20); - } + if (temporaryProvider == provider) { + temporaryProvider = null; + updateObjective(); + } + } + }.runTaskLater(P.p, P.p.getConfig().getInt("scoreboard.expiration", 7) * 20); + } - private void updateObjective() { - FSidebarProvider provider = temporaryProvider != null ? temporaryProvider : defaultProvider; + private void updateObjective() { + FSidebarProvider provider = temporaryProvider != null ? temporaryProvider : defaultProvider; - if (provider == null) { - bufferedObjective.hide(); - } else { - bufferedObjective.setTitle(provider.getTitle(fplayer)); - bufferedObjective.setAllLines(provider.getLines(fplayer)); - bufferedObjective.flip(); - } - } + if (provider == null) { + bufferedObjective.hide(); + } else { + bufferedObjective.setTitle(provider.getTitle(fplayer)); + bufferedObjective.setAllLines(provider.getLines(fplayer)); + bufferedObjective.flip(); + } + } } \ No newline at end of file diff --git a/src/main/java/com/massivecraft/factions/scoreboards/FSidebarProvider.java b/src/main/java/com/massivecraft/factions/scoreboards/FSidebarProvider.java index e6d686f9..1a71af86 100644 --- a/src/main/java/com/massivecraft/factions/scoreboards/FSidebarProvider.java +++ b/src/main/java/com/massivecraft/factions/scoreboards/FSidebarProvider.java @@ -11,32 +11,32 @@ import java.util.Objects; public abstract class FSidebarProvider { - public abstract String getTitle(FPlayer fplayer); + public abstract String getTitle(FPlayer fplayer); - public abstract List getLines(FPlayer fplayer); + public abstract List getLines(FPlayer fplayer); - public String replaceTags(FPlayer fPlayer, String s) { - s = TagUtil.parsePlaceholders(fPlayer.getPlayer(), s); + public String replaceTags(FPlayer fPlayer, String s) { + s = TagUtil.parsePlaceholders(fPlayer.getPlayer(), s); - return qualityAssure(TagUtil.parsePlain(fPlayer, s)); - } + return qualityAssure(TagUtil.parsePlain(fPlayer, s)); + } - public String replaceTags(Faction faction, FPlayer fPlayer, String s) { - // Run through Placeholder API first - s = TagUtil.parsePlaceholders(fPlayer.getPlayer(), s); + public String replaceTags(Faction faction, FPlayer fPlayer, String s) { + // Run through Placeholder API first + s = TagUtil.parsePlaceholders(fPlayer.getPlayer(), s); - return qualityAssure(Objects.requireNonNull(TagUtil.parsePlain(faction, fPlayer, s))); - } + return qualityAssure(Objects.requireNonNull(TagUtil.parsePlain(faction, fPlayer, s))); + } - private String qualityAssure(String line) { - if (line.contains("{notFrozen}") || line.contains("{notPermanent}")) { - return "n/a"; // we dont support support these error variables in scoreboards - } - if (line.contains("{ig}")) { - // since you can't really fit a whole "Faction Home: world, x, y, z" on one line - // we assume it's broken up into two lines, so returning our tl will suffice. - return TL.COMMAND_SHOW_NOHOME.toString(); - } - return P.p.txt.parse(line); // finally add color :) - } + private String qualityAssure(String line) { + if (line.contains("{notFrozen}") || line.contains("{notPermanent}")) { + return "n/a"; // we dont support support these error variables in scoreboards + } + if (line.contains("{ig}")) { + // since you can't really fit a whole "Faction Home: world, x, y, z" on one line + // we assume it's broken up into two lines, so returning our tl will suffice. + return TL.COMMAND_SHOW_NOHOME.toString(); + } + return P.p.txt.parse(line); // finally add color :) + } } \ No newline at end of file diff --git a/src/main/java/com/massivecraft/factions/scoreboards/FTeamWrapper.java b/src/main/java/com/massivecraft/factions/scoreboards/FTeamWrapper.java index 90d4a3ac..8cde29fa 100644 --- a/src/main/java/com/massivecraft/factions/scoreboards/FTeamWrapper.java +++ b/src/main/java/com/massivecraft/factions/scoreboards/FTeamWrapper.java @@ -12,212 +12,212 @@ import org.bukkit.scoreboard.Team; import java.util.*; public class FTeamWrapper { - private static final Map wrappers = new HashMap<>(); - private static final List tracking = new ArrayList<>(); - private static final Set updating = new HashSet<>(); - private static int factionTeamPtr; - private final Map teams = new HashMap<>(); - private final String teamName; - private final Faction faction; - private final Set members = new HashSet<>(); + private static final Map wrappers = new HashMap<>(); + private static final List tracking = new ArrayList<>(); + private static final Set updating = new HashSet<>(); + private static int factionTeamPtr; + private final Map teams = new HashMap<>(); + private final String teamName; + private final Faction faction; + private final Set members = new HashSet<>(); - private FTeamWrapper(Faction faction) { - this.teamName = "faction_" + (factionTeamPtr++); - this.faction = faction; + private FTeamWrapper(Faction faction) { + this.teamName = "faction_" + (factionTeamPtr++); + this.faction = faction; - for (FScoreboard fboard : tracking) { - add(fboard); - } - } + for (FScoreboard fboard : tracking) { + add(fboard); + } + } - public static void applyUpdatesLater(final Faction faction) { - if (!FScoreboard.isSupportedByServer()) { - return; - } + public static void applyUpdatesLater(final Faction faction) { + if (!FScoreboard.isSupportedByServer()) { + return; + } - if (faction.isWilderness()) { - return; - } + if (faction.isWilderness()) { + return; + } - if (!P.p.getConfig().getBoolean("scoreboard.default-prefixes", false) || P.p.getConfig().getBoolean("See-Invisible-Faction-Members")) { - return; - } + if (!P.p.getConfig().getBoolean("scoreboard.default-prefixes", false) || P.p.getConfig().getBoolean("See-Invisible-Faction-Members")) { + return; + } - if (updating.add(faction)) { - Bukkit.getScheduler().runTask(P.p, () -> { - updating.remove(faction); - applyUpdates(faction); - }); - } - } + if (updating.add(faction)) { + Bukkit.getScheduler().runTask(P.p, () -> { + updating.remove(faction); + applyUpdates(faction); + }); + } + } - public static void applyUpdates(Faction faction) { - if (!FScoreboard.isSupportedByServer()) { - return; - } + public static void applyUpdates(Faction faction) { + if (!FScoreboard.isSupportedByServer()) { + return; + } - if (faction.isWilderness()) { - return; - } + if (faction.isWilderness()) { + return; + } - if (!P.p.getConfig().getBoolean("scoreboard.default-prefixes", false) || P.p.getConfig().getBoolean("See-Invisible-Faction-Members")) { - return; - } + if (!P.p.getConfig().getBoolean("scoreboard.default-prefixes", false) || P.p.getConfig().getBoolean("See-Invisible-Faction-Members")) { + return; + } - if (updating.contains(faction)) { - // Faction will be updated soon. - return; - } + if (updating.contains(faction)) { + // Faction will be updated soon. + return; + } - FTeamWrapper wrapper = wrappers.get(faction); - Set factionMembers = faction.getFPlayers(); + FTeamWrapper wrapper = wrappers.get(faction); + Set factionMembers = faction.getFPlayers(); - if (wrapper != null && Factions.getInstance().getFactionById(faction.getId()) == null) { - // Faction was disbanded - wrapper.unregister(); - wrappers.remove(faction); - return; - } + if (wrapper != null && Factions.getInstance().getFactionById(faction.getId()) == null) { + // Faction was disbanded + wrapper.unregister(); + wrappers.remove(faction); + return; + } - if (wrapper == null) { - wrapper = new FTeamWrapper(faction); - wrappers.put(faction, wrapper); - } + if (wrapper == null) { + wrapper = new FTeamWrapper(faction); + wrappers.put(faction, wrapper); + } - for (OfflinePlayer player : wrapper.getPlayers()) { - if (!player.isOnline() || !factionMembers.contains(FPlayers.getInstance().getByOfflinePlayer(player))) { - // Player is offline or no longer in faction - wrapper.removePlayer(player); - } - } + for (OfflinePlayer player : wrapper.getPlayers()) { + if (!player.isOnline() || !factionMembers.contains(FPlayers.getInstance().getByOfflinePlayer(player))) { + // Player is offline or no longer in faction + wrapper.removePlayer(player); + } + } - for (FPlayer fmember : factionMembers) { - if (!fmember.isOnline()) { - continue; - } + for (FPlayer fmember : factionMembers) { + if (!fmember.isOnline()) { + continue; + } - // Scoreboard might not have player; add him/her - wrapper.addPlayer(fmember.getPlayer()); - } + // Scoreboard might not have player; add him/her + wrapper.addPlayer(fmember.getPlayer()); + } - wrapper.updatePrefixes(); - } + wrapper.updatePrefixes(); + } - public static void updatePrefixes(Faction faction) { - if (!FScoreboard.isSupportedByServer()) { - return; - } + public static void updatePrefixes(Faction faction) { + if (!FScoreboard.isSupportedByServer()) { + return; + } - if (!wrappers.containsKey(faction)) { - applyUpdates(faction); - } else { - wrappers.get(faction).updatePrefixes(); - } - } + if (!wrappers.containsKey(faction)) { + applyUpdates(faction); + } else { + wrappers.get(faction).updatePrefixes(); + } + } - protected static void track(FScoreboard fboard) { - if (!FScoreboard.isSupportedByServer()) { - return; - } - tracking.add(fboard); - for (FTeamWrapper wrapper : wrappers.values()) { - wrapper.add(fboard); - } - } + protected static void track(FScoreboard fboard) { + if (!FScoreboard.isSupportedByServer()) { + return; + } + tracking.add(fboard); + for (FTeamWrapper wrapper : wrappers.values()) { + wrapper.add(fboard); + } + } - protected static void untrack(FScoreboard fboard) { - if (!FScoreboard.isSupportedByServer()) { - return; - } - tracking.remove(fboard); - for (FTeamWrapper wrapper : wrappers.values()) { - wrapper.remove(fboard); - } - } + protected static void untrack(FScoreboard fboard) { + if (!FScoreboard.isSupportedByServer()) { + return; + } + tracking.remove(fboard); + for (FTeamWrapper wrapper : wrappers.values()) { + wrapper.remove(fboard); + } + } - private void add(FScoreboard fboard) { - Scoreboard board = fboard.getScoreboard(); - Team team = board.registerNewTeam(teamName); - teams.put(fboard, team); + private void add(FScoreboard fboard) { + Scoreboard board = fboard.getScoreboard(); + Team team = board.registerNewTeam(teamName); + teams.put(fboard, team); - for (OfflinePlayer player : getPlayers()) { - team.addPlayer(player); - } + for (OfflinePlayer player : getPlayers()) { + team.addPlayer(player); + } - updatePrefix(fboard); - } + updatePrefix(fboard); + } - private void remove(FScoreboard fboard) { - teams.remove(fboard).unregister(); - } + private void remove(FScoreboard fboard) { + teams.remove(fboard).unregister(); + } - private void updatePrefixes() { - if (P.p.getConfig().getBoolean("scoreboard.default-prefixes", false)) { - for (FScoreboard fboard : teams.keySet()) { - updatePrefix(fboard); - } - } - } + private void updatePrefixes() { + if (P.p.getConfig().getBoolean("scoreboard.default-prefixes", false)) { + for (FScoreboard fboard : teams.keySet()) { + updatePrefix(fboard); + } + } + } - private void updatePrefix(FScoreboard fboard) { - if (P.p.getConfig().getBoolean("scoreboard.default-prefixes", false)) { - FPlayer fplayer = fboard.getFPlayer(); - Team team = teams.get(fboard); - boolean focused = false; + private void updatePrefix(FScoreboard fboard) { + if (P.p.getConfig().getBoolean("scoreboard.default-prefixes", false)) { + FPlayer fplayer = fboard.getFPlayer(); + Team team = teams.get(fboard); + boolean focused = false; - if (P.p.getConfig().getBoolean("See-Invisible-Faction-Members", false)) { - team.setCanSeeFriendlyInvisibles(true); - } + if (P.p.getConfig().getBoolean("See-Invisible-Faction-Members", false)) { + team.setCanSeeFriendlyInvisibles(true); + } - if ((P.p.getConfig().getBoolean("ffocus.Enabled")) && (fplayer.getFaction() != null) && (fplayer.getFaction().getFocused() != null)) { - for (FPlayer fp : faction.getFPlayersWhereOnline(true)) { - if (fplayer.getFaction().getFocused().equalsIgnoreCase(fp.getName())) { - team.setPrefix(ChatColor.translateAlternateColorCodes('&', P.p.getConfig().getString("ffocus.Prefix", "&7»&b"))); - focused = true; - } - } - } - if (!focused) { - String prefix = TL.DEFAULT_PREFIX.toString(); + if ((P.p.getConfig().getBoolean("ffocus.Enabled")) && (fplayer.getFaction() != null) && (fplayer.getFaction().getFocused() != null)) { + for (FPlayer fp : faction.getFPlayersWhereOnline(true)) { + if (fplayer.getFaction().getFocused().equalsIgnoreCase(fp.getName())) { + team.setPrefix(ChatColor.translateAlternateColorCodes('&', P.p.getConfig().getString("ffocus.Prefix", "&7»&b"))); + focused = true; + } + } + } + if (!focused) { + String prefix = TL.DEFAULT_PREFIX.toString(); - prefix = PlaceholderAPI.setPlaceholders(fplayer.getPlayer(), prefix); - prefix = PlaceholderAPI.setBracketPlaceholders(fplayer.getPlayer(), prefix); - prefix = prefix.replace("{relationcolor}", faction.getRelationTo(fplayer).getColor().toString()); - prefix = prefix.replace("{faction}", - faction.getTag().substring(0, Math.min("{faction}".length() + 16 - prefix.length(), faction.getTag().length()))); - if ((team.getPrefix() == null) || (!team.getPrefix().equals(prefix))) { - team.setPrefix(prefix); - } - } - } - } + prefix = PlaceholderAPI.setPlaceholders(fplayer.getPlayer(), prefix); + prefix = PlaceholderAPI.setBracketPlaceholders(fplayer.getPlayer(), prefix); + prefix = prefix.replace("{relationcolor}", faction.getRelationTo(fplayer).getColor().toString()); + prefix = prefix.replace("{faction}", + faction.getTag().substring(0, Math.min("{faction}".length() + 16 - prefix.length(), faction.getTag().length()))); + if ((team.getPrefix() == null) || (!team.getPrefix().equals(prefix))) { + team.setPrefix(prefix); + } + } + } + } - private void addPlayer(OfflinePlayer player) { - if (members.add(player)) { - for (Team team : teams.values()) { - team.addPlayer(player); - } - } - } + private void addPlayer(OfflinePlayer player) { + if (members.add(player)) { + for (Team team : teams.values()) { + team.addPlayer(player); + } + } + } - private void removePlayer(OfflinePlayer player) { - if (members.remove(player)) { - for (Team team : teams.values()) { - team.removePlayer(player); - } - } - } + private void removePlayer(OfflinePlayer player) { + if (members.remove(player)) { + for (Team team : teams.values()) { + team.removePlayer(player); + } + } + } - private Set getPlayers() { - return new HashSet<>(this.members); - } + private Set getPlayers() { + return new HashSet<>(this.members); + } - private void unregister() { - for (Team team : teams.values()) { - team.unregister(); - } - teams.clear(); - } + private void unregister() { + for (Team team : teams.values()) { + team.unregister(); + } + teams.clear(); + } } diff --git a/src/main/java/com/massivecraft/factions/shop/CmdShop.java b/src/main/java/com/massivecraft/factions/shop/CmdShop.java index b6f00842..3010502b 100644 --- a/src/main/java/com/massivecraft/factions/shop/CmdShop.java +++ b/src/main/java/com/massivecraft/factions/shop/CmdShop.java @@ -2,28 +2,26 @@ package com.massivecraft.factions.shop; import com.massivecraft.factions.P; import com.massivecraft.factions.cmd.FCommand; -import com.massivecraft.factions.cmd.logout.CmdLogout; -import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.zcore.util.TL; public class CmdShop extends FCommand { - public CmdShop(){ - super(); - this.aliases.add("shop"); - this.disableOnLock = false; + public CmdShop() { + super(); + this.aliases.add("shop"); + this.disableOnLock = false; - senderMustBePlayer = true; - senderMustBeMember = true; - senderMustBeModerator = false; - senderMustBeColeader = false; - senderMustBeAdmin = false; - } + senderMustBePlayer = true; + senderMustBeMember = true; + senderMustBeModerator = false; + senderMustBeColeader = false; + senderMustBeAdmin = false; + } @Override public void perform() { - if(!P.p.getConfig().getBoolean("F-Shop.Enabled")){ + if (!P.p.getConfig().getBoolean("F-Shop.Enabled")) { return; } ShopGUI.openShop(fme); diff --git a/src/main/java/com/massivecraft/factions/shop/ShopClickPersistence.java b/src/main/java/com/massivecraft/factions/shop/ShopClickPersistence.java index 0b58462b..9f874e22 100644 --- a/src/main/java/com/massivecraft/factions/shop/ShopClickPersistence.java +++ b/src/main/java/com/massivecraft/factions/shop/ShopClickPersistence.java @@ -18,13 +18,6 @@ import java.util.List; public class ShopClickPersistence implements Listener { - public void runCommands(List list, Player p) { - for (String cmd : list) { - cmd = cmd.replace("%player%", p.getName()); - Bukkit.dispatchCommand(Bukkit.getConsoleSender(), cmd); - } - } - public static String color(String line) { line = ChatColor.translateAlternateColorCodes('&', line); return line; @@ -37,6 +30,13 @@ public class ShopClickPersistence implements Listener { return lore; } + public void runCommands(List list, Player p) { + for (String cmd : list) { + cmd = cmd.replace("%player%", p.getName()); + Bukkit.dispatchCommand(Bukkit.getConsoleSender(), cmd); + } + } + @EventHandler public void click(InventoryClickEvent e) { Inventory i = e.getClickedInventory(); @@ -46,7 +46,7 @@ public class ShopClickPersistence implements Listener { if (e.getView().getTitle().equalsIgnoreCase(color(config.getString("F-Shop.GUI.Name")))) { ItemStack item = e.getCurrentItem(); - if(item == null) return; + if (item == null) return; String name = color(item.getItemMeta().getDisplayName()); e.setCancelled(true); int t = e.getSlot(); diff --git a/src/main/java/com/massivecraft/factions/shop/ShopConfig.java b/src/main/java/com/massivecraft/factions/shop/ShopConfig.java index b0b5fb4a..c867b0a8 100644 --- a/src/main/java/com/massivecraft/factions/shop/ShopConfig.java +++ b/src/main/java/com/massivecraft/factions/shop/ShopConfig.java @@ -13,9 +13,11 @@ public class ShopConfig { public static File shop = new File("plugins/Factions/shop.yml"); public static FileConfiguration s = YamlConfiguration.loadConfiguration(shop); + public static FileConfiguration getShop() { return s; } + public static void loadShop() { s = YamlConfiguration.loadConfiguration(shop); } diff --git a/src/main/java/com/massivecraft/factions/shop/ShopGUI.java b/src/main/java/com/massivecraft/factions/shop/ShopGUI.java index 9646bbb5..449427e7 100644 --- a/src/main/java/com/massivecraft/factions/shop/ShopGUI.java +++ b/src/main/java/com/massivecraft/factions/shop/ShopGUI.java @@ -6,7 +6,6 @@ import com.massivecraft.factions.P; import com.massivecraft.factions.util.XMaterial; import org.bukkit.Bukkit; import org.bukkit.ChatColor; -import org.bukkit.Material; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.enchantments.Enchantment; import org.bukkit.inventory.Inventory; @@ -42,7 +41,7 @@ public class ShopGUI { String s = shopitems + ""; int slot = ShopConfig.getShop().getInt("items." + s + ".slot"); ItemStack material = XMaterial.matchXMaterial(ShopConfig.getShop().getString("items." + s + ".block")).parseItem(); - // int size = ShopConfig.getShop().getInt("items." + s + ".size"); + // int size = ShopConfig.getShop().getInt("items." + s + ".size"); int cost = ShopConfig.getShop().getInt("items." + s + ".cost"); String name = ShopConfig.getShop().getString("items." + s + ".name") + " &f(" + cost + " Points)"; List lore = ShopConfig.getShop().getStringList("items." + s + ".lore"); diff --git a/src/main/java/com/massivecraft/factions/struct/BanInfo.java b/src/main/java/com/massivecraft/factions/struct/BanInfo.java index 8aacfe24..365d7a31 100644 --- a/src/main/java/com/massivecraft/factions/struct/BanInfo.java +++ b/src/main/java/com/massivecraft/factions/struct/BanInfo.java @@ -2,41 +2,41 @@ package com.massivecraft.factions.struct; public class BanInfo { - // FPlayer IDs - private final String banner; - private final String banned; - private final long time; + // FPlayer IDs + private final String banner; + private final String banned; + private final long time; - public BanInfo(String banner, String banned, long time) { - this.banner = banner; - this.banned = banned; - this.time = time; - } + public BanInfo(String banner, String banned, long time) { + this.banner = banner; + this.banned = banned; + this.time = time; + } - /** - * Get the FPlayer ID of the player who issued the ban. - * - * @return FPlayer ID. - */ - public String getBanner() { - return this.banner; - } + /** + * Get the FPlayer ID of the player who issued the ban. + * + * @return FPlayer ID. + */ + public String getBanner() { + return this.banner; + } - /** - * Get the FPlayer ID of the player who got banned. - * - * @return FPlayer ID. - */ - public String getBanned() { - return banned; - } + /** + * Get the FPlayer ID of the player who got banned. + * + * @return FPlayer ID. + */ + public String getBanned() { + return banned; + } - /** - * Get the server time when the ban was issued. - * - * @return system timestamp. - */ - public long getTime() { - return time; - } + /** + * Get the server time when the ban was issued. + * + * @return system timestamp. + */ + public long getTime() { + return time; + } } diff --git a/src/main/java/com/massivecraft/factions/struct/ChatMode.java b/src/main/java/com/massivecraft/factions/struct/ChatMode.java index 42471a1e..34536416 100644 --- a/src/main/java/com/massivecraft/factions/struct/ChatMode.java +++ b/src/main/java/com/massivecraft/factions/struct/ChatMode.java @@ -3,40 +3,40 @@ package com.massivecraft.factions.struct; import com.massivecraft.factions.zcore.util.TL; public enum ChatMode { - MOD(4, TL.CHAT_MOD), - FACTION(3, TL.CHAT_FACTION), - ALLIANCE(2, TL.CHAT_ALLIANCE), - TRUCE(1, TL.CHAT_TRUCE), - PUBLIC(0, TL.CHAT_PUBLIC); + MOD(4, TL.CHAT_MOD), + FACTION(3, TL.CHAT_FACTION), + ALLIANCE(2, TL.CHAT_ALLIANCE), + TRUCE(1, TL.CHAT_TRUCE), + PUBLIC(0, TL.CHAT_PUBLIC); - public final int value; - public final TL nicename; + public final int value; + public final TL nicename; - ChatMode(final int value, final TL nicename) { - this.value = value; - this.nicename = nicename; - } + ChatMode(final int value, final TL nicename) { + this.value = value; + this.nicename = nicename; + } - public boolean isAtLeast(ChatMode role) { - return this.value >= role.value; - } + public boolean isAtLeast(ChatMode role) { + return this.value >= role.value; + } - public boolean isAtMost(ChatMode role) { - return this.value <= role.value; - } + public boolean isAtMost(ChatMode role) { + return this.value <= role.value; + } - @Override - public String toString() { - return this.nicename.toString(); - } + @Override + public String toString() { + return this.nicename.toString(); + } - public ChatMode getNext() { - if (this == PUBLIC) { - return ALLIANCE; - } - if (this == ALLIANCE) { - return FACTION; - } - return PUBLIC; - } + public ChatMode getNext() { + if (this == PUBLIC) { + return ALLIANCE; + } + if (this == ALLIANCE) { + return FACTION; + } + return PUBLIC; + } } diff --git a/src/main/java/com/massivecraft/factions/struct/Permission.java b/src/main/java/com/massivecraft/factions/struct/Permission.java index a89fa670..b27c07ad 100644 --- a/src/main/java/com/massivecraft/factions/struct/Permission.java +++ b/src/main/java/com/massivecraft/factions/struct/Permission.java @@ -4,136 +4,137 @@ import com.massivecraft.factions.P; import org.bukkit.command.CommandSender; public enum Permission { - MANAGE_SAFE_ZONE("managesafezone"), - MANAGE_WAR_ZONE("managewarzone"), - OWNERSHIP_BYPASS("ownershipbypass"), - ADMIN("admin"), - ALTS("alts"), - ADMIN_ANY("admin.any"), - AHOME("ahome"), - ANNOUNCE("announce"), - AUTOCLAIM("autoclaim"), - AUTO_LEAVE_BYPASS("autoleavebypass"), - BAN("ban"), - BYPASS("bypass"), - CHAT("chat"), - CHATSPY("chatspy"), - CLAIM("claim"), - CLAIMAT("claimat"), - CLAIM_LINE("claim.line"), - CLAIM_RADIUS("claim.radius"), - CONFIG("config"), - CONVERT("convert"), - CREATE("create"), - CORNER("corner"), - DEFAULTRANK("defaultrank"), - DEINVITE("deinvite"), - DELHOME("delhome"), - DESCRIPTION("description"), - DISBAND("disband"), - DISBAND_ANY("disband.any"), - FLY("fly"), - FOCUS("focus"), - GRACE("grace"), - HELP("help"), - HOME("home"), - INVITE("invite"), - INVSEE("invsee"), - JOIN("join"), - JOIN_ANY("join.any"), - JOIN_OTHERS("join.others"), - KICK("kick"), - KICK_ANY("kick.any"), - LEAVE("leave"), - LIST("list"), - LOCK("lock"), - LOGOUT("logout"), - MAP("map"), - MAPHEIGHT("mapheight"), - MOD("mod"), - COLEADER("coleader"), - MOD_ANY("mod.any"), - COLEADER_ANY("coleader.any"), - MISSIONS("missions"), - MODIFY_POWER("modifypower"), - MONEY_BALANCE("money.balance"), - MONEY_BALANCE_ANY("money.balance.any"), - MONEY_DEPOSIT("money.deposit"), - MONEY_WITHDRAW("money.withdraw"), - MONEY_WITHDRAW_ANY("money.withdraw.any"), - MONEY_F2F("money.f2f"), - MONEY_F2P("money.f2p"), - MONEY_P2F("money.p2f"), - MONITOR_LOGINS("monitorlogins"), - NO_BOOM("noboom"), - OPEN("open"), - OWNER("owner"), - OWNERLIST("ownerlist"), - SET_PEACEFUL("setpeaceful"), - SET_PERMANENT("setpermanent"), - SET_PERMANENTPOWER("setpermanentpower"), - SHOW_INVITES("showinvites"), - PAYPAL("paypal"), - PAYPALSET("setpaypal"), - PERMISSIONS("permissions"), - POWERBOOST("powerboost"), - POWER("power"), - POWER_ANY("power.any"), - PROMOTE("promote"), - RELATION("relation"), - RELOAD("reload"), - SAVE("save"), - SPAM("spam"), - SETHOME("sethome"), - SETHOME_ANY("sethome.any"), - SETSTRIKES("setstrikes"), - SHOW("show"), - STATUS("status"), - STEALTH("stealth"), - STUCK("stuck"), - TAG("tag"), - TNT("tnt"), - TITLE("title"), - TITLE_COLOR("title.color"), - TOGGLE_ALLIANCE_CHAT("togglealliancechat"), - UNCLAIM("unclaim"), - UNCLAIM_ALL("unclaimall"), - VERSION("version"), - SCOREBOARD("scoreboard"), - SEECHUNK("seechunk"), - SETWARP("setwarp"), - TOP("top"), - VIEWCHEST("viewchest"), - ADDPOINTS("addpoints"), - REMOVEPOINTS("removepoints"), - SETPOINTS("setpoints"), - VAULT("vault"), - GETVAULT("getvault"), - SETMAXVAULTS("setmaxvaults"), - RULES("rules"), - CHECKPOINT("checkpoint"), - UPGRADES("upgrades"), - BANNER("banner"), - TPBANNER("tpbanner"), - KILLHOLOS("killholos"), - INSPECT("inspect"), - TNTFILL("tntfill"), - COORD("coords"), - SHOWCLAIMS("showclaims"), - WARP("warp"), - CHEST("chest"); + MANAGE_SAFE_ZONE("managesafezone"), + MANAGE_WAR_ZONE("managewarzone"), + OWNERSHIP_BYPASS("ownershipbypass"), + ADMIN("admin"), + ALTS("alts"), + ADMIN_ANY("admin.any"), + AHOME("ahome"), + ANNOUNCE("announce"), + AUTOCLAIM("autoclaim"), + AUTO_LEAVE_BYPASS("autoleavebypass"), + BAN("ban"), + BYPASS("bypass"), + CHAT("chat"), + CHATSPY("chatspy"), + CHECK("check"), + CLAIM("claim"), + CLAIMAT("claimat"), + CLAIM_LINE("claim.line"), + CLAIM_RADIUS("claim.radius"), + CONFIG("config"), + CONVERT("convert"), + CREATE("create"), + CORNER("corner"), + DEFAULTRANK("defaultrank"), + DEINVITE("deinvite"), + DELHOME("delhome"), + DESCRIPTION("description"), + DISBAND("disband"), + DISBAND_ANY("disband.any"), + FLY("fly"), + FOCUS("focus"), + GRACE("grace"), + HELP("help"), + HOME("home"), + INVITE("invite"), + INVSEE("invsee"), + JOIN("join"), + JOIN_ANY("join.any"), + JOIN_OTHERS("join.others"), + KICK("kick"), + KICK_ANY("kick.any"), + LEAVE("leave"), + LIST("list"), + LOCK("lock"), + LOGOUT("logout"), + MAP("map"), + MAPHEIGHT("mapheight"), + MOD("mod"), + COLEADER("coleader"), + MOD_ANY("mod.any"), + COLEADER_ANY("coleader.any"), + MISSIONS("missions"), + MODIFY_POWER("modifypower"), + MONEY_BALANCE("money.balance"), + MONEY_BALANCE_ANY("money.balance.any"), + MONEY_DEPOSIT("money.deposit"), + MONEY_WITHDRAW("money.withdraw"), + MONEY_WITHDRAW_ANY("money.withdraw.any"), + MONEY_F2F("money.f2f"), + MONEY_F2P("money.f2p"), + MONEY_P2F("money.p2f"), + MONITOR_LOGINS("monitorlogins"), + NO_BOOM("noboom"), + OPEN("open"), + OWNER("owner"), + OWNERLIST("ownerlist"), + SET_PEACEFUL("setpeaceful"), + SET_PERMANENT("setpermanent"), + SET_PERMANENTPOWER("setpermanentpower"), + SHOW_INVITES("showinvites"), + PAYPAL("paypal"), + PAYPALSET("setpaypal"), + PERMISSIONS("permissions"), + POWERBOOST("powerboost"), + POWER("power"), + POWER_ANY("power.any"), + PROMOTE("promote"), + RELATION("relation"), + RELOAD("reload"), + SAVE("save"), + SPAM("spam"), + SETHOME("sethome"), + SETHOME_ANY("sethome.any"), + SETSTRIKES("setstrikes"), + SHOW("show"), + STATUS("status"), + STEALTH("stealth"), + STUCK("stuck"), + TAG("tag"), + TNT("tnt"), + TITLE("title"), + TITLE_COLOR("title.color"), + TOGGLE_ALLIANCE_CHAT("togglealliancechat"), + UNCLAIM("unclaim"), + UNCLAIM_ALL("unclaimall"), + VERSION("version"), + SCOREBOARD("scoreboard"), + SEECHUNK("seechunk"), + SETWARP("setwarp"), + TOP("top"), + VIEWCHEST("viewchest"), + ADDPOINTS("addpoints"), + REMOVEPOINTS("removepoints"), + SETPOINTS("setpoints"), + VAULT("vault"), + GETVAULT("getvault"), + SETMAXVAULTS("setmaxvaults"), + RULES("rules"), + CHECKPOINT("checkpoint"), + UPGRADES("upgrades"), + BANNER("banner"), + TPBANNER("tpbanner"), + KILLHOLOS("killholos"), + INSPECT("inspect"), + TNTFILL("tntfill"), + COORD("coords"), + SHOWCLAIMS("showclaims"), + WARP("warp"), + CHEST("chest"); - public final String node; + public final String node; - Permission(final String node) { - this.node = "factions." + node; - } + Permission(final String node) { + this.node = "factions." + node; + } - public boolean has(CommandSender sender, boolean informSenderIfNot) { - return P.p.perm.has(sender, this.node, informSenderIfNot); - } + public boolean has(CommandSender sender, boolean informSenderIfNot) { + return P.p.perm.has(sender, this.node, informSenderIfNot); + } - public boolean has(CommandSender sender) { - return has(sender, false); - } + public boolean has(CommandSender sender) { + return has(sender, false); + } } diff --git a/src/main/java/com/massivecraft/factions/struct/Relation.java b/src/main/java/com/massivecraft/factions/struct/Relation.java index 9682706c..10d81048 100644 --- a/src/main/java/com/massivecraft/factions/struct/Relation.java +++ b/src/main/java/com/massivecraft/factions/struct/Relation.java @@ -16,221 +16,221 @@ import java.util.List; public enum Relation implements Permissable { - MEMBER(4, TL.RELATION_MEMBER_SINGULAR.toString()), - ALLY(3, TL.RELATION_ALLY_SINGULAR.toString()), - TRUCE(2, TL.RELATION_TRUCE_SINGULAR.toString()), - NEUTRAL(1, TL.RELATION_NEUTRAL_SINGULAR.toString()), - ENEMY(0, TL.RELATION_ENEMY_SINGULAR.toString()); + MEMBER(4, TL.RELATION_MEMBER_SINGULAR.toString()), + ALLY(3, TL.RELATION_ALLY_SINGULAR.toString()), + TRUCE(2, TL.RELATION_TRUCE_SINGULAR.toString()), + NEUTRAL(1, TL.RELATION_NEUTRAL_SINGULAR.toString()), + ENEMY(0, TL.RELATION_ENEMY_SINGULAR.toString()); - public final int value; - public final String nicename; + public final int value; + public final String nicename; - Relation(final int value, final String nicename) { - this.value = value; - this.nicename = nicename; - } + Relation(final int value, final String nicename) { + this.value = value; + this.nicename = nicename; + } - public static Relation fromString(String s) { - // Because Java 6 doesn't allow String switches :( - if (s.equalsIgnoreCase(MEMBER.nicename)) { - return MEMBER; - } else if (s.equalsIgnoreCase(ALLY.nicename)) { - return ALLY; - } else if (s.equalsIgnoreCase(TRUCE.nicename)) { - return TRUCE; - } else if (s.equalsIgnoreCase(ENEMY.nicename)) { - return ENEMY; - } else { - return NEUTRAL; // If they somehow mess things up, go back to default behavior. - } - } + public static Relation fromString(String s) { + // Because Java 6 doesn't allow String switches :( + if (s.equalsIgnoreCase(MEMBER.nicename)) { + return MEMBER; + } else if (s.equalsIgnoreCase(ALLY.nicename)) { + return ALLY; + } else if (s.equalsIgnoreCase(TRUCE.nicename)) { + return TRUCE; + } else if (s.equalsIgnoreCase(ENEMY.nicename)) { + return ENEMY; + } else { + return NEUTRAL; // If they somehow mess things up, go back to default behavior. + } + } - @Override - public String toString() { - return this.nicename; - } + @Override + public String toString() { + return this.nicename; + } - public String getTranslation() { - try { - return TL.valueOf("RELATION_" + name() + "_SINGULAR").toString(); - } catch (IllegalArgumentException e) { - return toString(); - } - } + public String getTranslation() { + try { + return TL.valueOf("RELATION_" + name() + "_SINGULAR").toString(); + } catch (IllegalArgumentException e) { + return toString(); + } + } - public String getPluralTranslation() { - for (TL t : TL.values()) { - if (t.name().equalsIgnoreCase("RELATION_" + name() + "_PLURAL")) { - return t.toString(); - } - } - return toString(); - } + public String getPluralTranslation() { + for (TL t : TL.values()) { + if (t.name().equalsIgnoreCase("RELATION_" + name() + "_PLURAL")) { + return t.toString(); + } + } + return toString(); + } - public boolean isMember() { - return this == MEMBER; - } + public boolean isMember() { + return this == MEMBER; + } - public boolean isAlly() { - return this == ALLY; - } + public boolean isAlly() { + return this == ALLY; + } - public boolean isTruce() { - return this == TRUCE; - } + public boolean isTruce() { + return this == TRUCE; + } - public boolean isNeutral() { - return this == NEUTRAL; - } + public boolean isNeutral() { + return this == NEUTRAL; + } - public boolean isEnemy() { - return this == ENEMY; - } + public boolean isEnemy() { + return this == ENEMY; + } - public boolean isAtLeast(Relation relation) { - return this.value >= relation.value; - } + public boolean isAtLeast(Relation relation) { + return this.value >= relation.value; + } - public boolean isAtMost(Relation relation) { - return this.value <= relation.value; - } + public boolean isAtMost(Relation relation) { + return this.value <= relation.value; + } - public ChatColor getColor() { + 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 - public boolean confDenyBuild(boolean online) { - if (isMember()) { - return false; - } + // return appropriate Conf setting for DenyBuild based on this relation and their online status + public boolean confDenyBuild(boolean online) { + if (isMember()) { + return false; + } - if (online) { - if (isEnemy()) { - return Conf.territoryEnemyDenyBuild; - } else if (isAlly()) { - return Conf.territoryAllyDenyBuild; - } else if (isTruce()) { - return Conf.territoryTruceDenyBuild; - } else { - return Conf.territoryDenyBuild; - } - } else { - if (isEnemy()) { - return Conf.territoryEnemyDenyBuildWhenOffline; - } else if (isAlly()) { - return Conf.territoryAllyDenyBuildWhenOffline; - } else if (isTruce()) { - return Conf.territoryTruceDenyBuildWhenOffline; - } else { - return Conf.territoryDenyBuildWhenOffline; - } - } - } + if (online) { + if (isEnemy()) { + return Conf.territoryEnemyDenyBuild; + } else if (isAlly()) { + return Conf.territoryAllyDenyBuild; + } else if (isTruce()) { + return Conf.territoryTruceDenyBuild; + } else { + return Conf.territoryDenyBuild; + } + } else { + if (isEnemy()) { + return Conf.territoryEnemyDenyBuildWhenOffline; + } else if (isAlly()) { + return Conf.territoryAllyDenyBuildWhenOffline; + } else if (isTruce()) { + return Conf.territoryTruceDenyBuildWhenOffline; + } else { + return Conf.territoryDenyBuildWhenOffline; + } + } + } - // return appropriate Conf setting for PainBuild based on this relation and their online status - public boolean confPainBuild(boolean online) { - if (isMember()) { - return false; - } + // return appropriate Conf setting for PainBuild based on this relation and their online status + public boolean confPainBuild(boolean online) { + if (isMember()) { + return false; + } - if (online) { - if (isEnemy()) { - return Conf.territoryEnemyPainBuild; - } else if (isAlly()) { - return Conf.territoryAllyPainBuild; - } else if (isTruce()) { - return Conf.territoryTrucePainBuild; - } else { - return Conf.territoryPainBuild; - } - } else { - if (isEnemy()) { - return Conf.territoryEnemyPainBuildWhenOffline; - } else if (isAlly()) { - return Conf.territoryAllyPainBuildWhenOffline; - } else if (isTruce()) { - return Conf.territoryTrucePainBuildWhenOffline; - } else { - return Conf.territoryPainBuildWhenOffline; - } - } - } + if (online) { + if (isEnemy()) { + return Conf.territoryEnemyPainBuild; + } else if (isAlly()) { + return Conf.territoryAllyPainBuild; + } else if (isTruce()) { + return Conf.territoryTrucePainBuild; + } else { + return Conf.territoryPainBuild; + } + } else { + if (isEnemy()) { + return Conf.territoryEnemyPainBuildWhenOffline; + } else if (isAlly()) { + return Conf.territoryAllyPainBuildWhenOffline; + } else if (isTruce()) { + return Conf.territoryTrucePainBuildWhenOffline; + } else { + return Conf.territoryPainBuildWhenOffline; + } + } + } - // return appropriate Conf setting for DenyUseage based on this relation - public boolean confDenyUseage() { - if (isMember()) { - return false; - } else if (isEnemy()) { - return Conf.territoryEnemyDenyUseage; - } else if (isAlly()) { - return Conf.territoryAllyDenyUseage; - } else if (isTruce()) { - return Conf.territoryTruceDenyUseage; - } else { - return Conf.territoryDenyUseage; - } - } + // return appropriate Conf setting for DenyUseage based on this relation + public boolean confDenyUseage() { + if (isMember()) { + return false; + } else if (isEnemy()) { + return Conf.territoryEnemyDenyUseage; + } else if (isAlly()) { + return Conf.territoryAllyDenyUseage; + } else if (isTruce()) { + return Conf.territoryTruceDenyUseage; + } else { + return Conf.territoryDenyUseage; + } + } - public double getRelationCost() { - if (isEnemy()) { - return Conf.econCostEnemy; - } else if (isAlly()) { - return Conf.econCostAlly; - } else if (isTruce()) { - return Conf.econCostTruce; - } else { - return Conf.econCostNeutral; - } - } + public double getRelationCost() { + if (isEnemy()) { + return Conf.econCostEnemy; + } else if (isAlly()) { + return Conf.econCostAlly; + } else if (isTruce()) { + return Conf.econCostTruce; + } else { + return Conf.econCostNeutral; + } + } - // Utility method to build items for F Perm GUI - @Override - public ItemStack buildItem() { - final ConfigurationSection RELATION_CONFIG = P.p.getConfig().getConfigurationSection("fperm-gui.relation"); + // Utility method to build items for F Perm GUI + @Override + public ItemStack buildItem() { + final ConfigurationSection RELATION_CONFIG = P.p.getConfig().getConfigurationSection("fperm-gui.relation"); - String displayName = replacePlaceholders(RELATION_CONFIG.getString("placeholder-item.name", "")); - List lore = new ArrayList<>(); + String displayName = replacePlaceholders(RELATION_CONFIG.getString("placeholder-item.name", "")); + List lore = new ArrayList<>(); - Material material = XMaterial.matchXMaterial(RELATION_CONFIG.getString("materials." + name().toLowerCase())).parseMaterial(); - if (material == null) { - return null; - } + Material material = XMaterial.matchXMaterial(RELATION_CONFIG.getString("materials." + name().toLowerCase())).parseMaterial(); + if (material == null) { + return null; + } - ItemStack item = new ItemStack(material); - ItemMeta itemMeta = item.getItemMeta(); + ItemStack item = new ItemStack(material); + ItemMeta itemMeta = item.getItemMeta(); - for (String loreLine : RELATION_CONFIG.getStringList("placeholder-item.lore")) { - lore.add(replacePlaceholders(loreLine)); - } + for (String loreLine : RELATION_CONFIG.getStringList("placeholder-item.lore")) { + lore.add(replacePlaceholders(loreLine)); + } - itemMeta.setDisplayName(displayName); - itemMeta.setLore(lore); - item.setItemMeta(itemMeta); + itemMeta.setDisplayName(displayName); + itemMeta.setLore(lore); + item.setItemMeta(itemMeta); - return item; - } + return item; + } - public String replacePlaceholders(String string) { - string = ChatColor.translateAlternateColorCodes('&', string); + public String replacePlaceholders(String string) { + string = ChatColor.translateAlternateColorCodes('&', string); - String permissableName = nicename.substring(0, 1).toUpperCase() + nicename.substring(1); + String permissableName = nicename.substring(0, 1).toUpperCase() + nicename.substring(1); - string = string.replace("{relation-color}", getColor().toString()); - string = string.replace("{relation}", permissableName); + string = string.replace("{relation-color}", getColor().toString()); + string = string.replace("{relation}", permissableName); - return string; - } + return string; + } } diff --git a/src/main/java/com/massivecraft/factions/struct/Role.java b/src/main/java/com/massivecraft/factions/struct/Role.java index b157d61a..45048fc3 100644 --- a/src/main/java/com/massivecraft/factions/struct/Role.java +++ b/src/main/java/com/massivecraft/factions/struct/Role.java @@ -16,140 +16,140 @@ import java.util.ArrayList; import java.util.List; public enum Role implements Permissable { - LEADER(4, TL.ROLE_LEADER), - COLEADER(3, TL.ROLE_COLEADER), - MODERATOR(2, TL.ROLE_MODERATOR), - NORMAL(1, TL.ROLE_NORMAL), - RECRUIT(0, TL.ROLE_RECRUIT); + LEADER(4, TL.ROLE_LEADER), + COLEADER(3, TL.ROLE_COLEADER), + MODERATOR(2, TL.ROLE_MODERATOR), + NORMAL(1, TL.ROLE_NORMAL), + RECRUIT(0, TL.ROLE_RECRUIT); - public final int value; - public final String nicename; - public final TL translation; + public final int value; + public final String nicename; + public final TL translation; - Role(final int value, final TL translation) { - this.value = value; - this.nicename = translation.toString(); - this.translation = translation; - } + Role(final int value, final TL translation) { + this.value = value; + this.nicename = translation.toString(); + this.translation = translation; + } - public static Role getRelative(Role role, int relative) { - return Role.getByValue(role.value + relative); - } + public static Role getRelative(Role role, int relative) { + return Role.getByValue(role.value + relative); + } - public static Role getByValue(int value) { - switch (value) { - case 0: - return RECRUIT; - case 1: - return NORMAL; - case 2: - return MODERATOR; - case 3: - return COLEADER; - case 4: - return LEADER; - } + public static Role getByValue(int value) { + switch (value) { + case 0: + return RECRUIT; + case 1: + return NORMAL; + case 2: + return MODERATOR; + case 3: + return COLEADER; + case 4: + return LEADER; + } - return null; - } + return null; + } - public static Role fromString(String check) { - switch (check.toLowerCase()) { - case "leader": - case "admin": - return LEADER; - case "coleader": - return COLEADER; - case "mod": - case "moderator": - return MODERATOR; - case "normal": - case "member": - return NORMAL; - case "recruit": - case "rec": - return RECRUIT; - } + public static Role fromString(String check) { + switch (check.toLowerCase()) { + case "leader": + case "admin": + return LEADER; + case "coleader": + return COLEADER; + case "mod": + case "moderator": + return MODERATOR; + case "normal": + case "member": + return NORMAL; + case "recruit": + case "rec": + return RECRUIT; + } - return null; - } + return null; + } - public boolean isAtLeast(Role role) { - return this.value >= role.value; - } + public boolean isAtLeast(Role role) { + return this.value >= role.value; + } - public boolean isAtMost(Role role) { - return this.value <= role.value; - } + public boolean isAtMost(Role role) { + return this.value <= role.value; + } - @Override - public String toString() { - return this.nicename; - } + @Override + public String toString() { + return this.nicename; + } - public TL getTranslation() { - return translation; - } + public TL getTranslation() { + return translation; + } - public String getPrefix() { + 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 ""; - } + return ""; + } - // Utility method to build items for F Perm GUI - @Override - public ItemStack buildItem() { - final ConfigurationSection RELATION_CONFIG = P.p.getConfig().getConfigurationSection("fperm-gui.relation"); + // Utility method to build items for F Perm GUI + @Override + public ItemStack buildItem() { + final ConfigurationSection RELATION_CONFIG = P.p.getConfig().getConfigurationSection("fperm-gui.relation"); - String displayName = replacePlaceholders(RELATION_CONFIG.getString("placeholder-item.name", "")); - List lore = new ArrayList<>(); + String displayName = replacePlaceholders(RELATION_CONFIG.getString("placeholder-item.name", "")); + List lore = new ArrayList<>(); - Material material = XMaterial.matchXMaterial(RELATION_CONFIG.getString("materials." + name().toLowerCase(), "STAINED_CLAY")).parseMaterial(); - if (material == null) { - return null; - } + Material material = XMaterial.matchXMaterial(RELATION_CONFIG.getString("materials." + name().toLowerCase(), "STAINED_CLAY")).parseMaterial(); + if (material == null) { + return null; + } - ItemStack item = new ItemStack(material); - ItemMeta itemMeta = item.getItemMeta(); + ItemStack item = new ItemStack(material); + ItemMeta itemMeta = item.getItemMeta(); - for (String loreLine : RELATION_CONFIG.getStringList("placeholder-item.lore")) { - lore.add(replacePlaceholders(loreLine)); - } + for (String loreLine : RELATION_CONFIG.getStringList("placeholder-item.lore")) { + lore.add(replacePlaceholders(loreLine)); + } - itemMeta.setDisplayName(displayName); - itemMeta.setLore(lore); - if (!P.p.mc17) { - itemMeta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES); - } + itemMeta.setDisplayName(displayName); + itemMeta.setLore(lore); + if (!P.p.mc17) { + itemMeta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES); + } - item.setItemMeta(itemMeta); + item.setItemMeta(itemMeta); - return item; - } + return item; + } - public String replacePlaceholders(String string) { - string = ChatColor.translateAlternateColorCodes('&', string); + public String replacePlaceholders(String string) { + string = ChatColor.translateAlternateColorCodes('&', string); - String permissableName = nicename.substring(0, 1).toUpperCase() + nicename.substring(1); + String permissableName = nicename.substring(0, 1).toUpperCase() + nicename.substring(1); - string = string.replace("{relation-color}", ChatColor.GREEN.toString()); - string = string.replace("{relation}", permissableName); + string = string.replace("{relation-color}", ChatColor.GREEN.toString()); + string = string.replace("{relation}", permissableName); - return string; - } + return string; + } } \ No newline at end of file diff --git a/src/main/java/com/massivecraft/factions/util/AsciiCompass.java b/src/main/java/com/massivecraft/factions/util/AsciiCompass.java index f2096851..a4149c94 100644 --- a/src/main/java/com/massivecraft/factions/util/AsciiCompass.java +++ b/src/main/java/com/massivecraft/factions/util/AsciiCompass.java @@ -7,104 +7,104 @@ import java.util.ArrayList; public class AsciiCompass { - public static Point getCompassPointForDirection(double inDegrees) { - double degrees = (inDegrees - 180) % 360; - if (degrees < 0) { - degrees += 360; - } + public static Point getCompassPointForDirection(double inDegrees) { + double degrees = (inDegrees - 180) % 360; + if (degrees < 0) { + degrees += 360; + } - if (0 <= degrees && degrees < 22.5) { - return Point.N; - } else if (22.5 <= degrees && degrees < 67.5) { - return Point.NE; - } else if (67.5 <= degrees && degrees < 112.5) { - return Point.E; - } else if (112.5 <= degrees && degrees < 157.5) { - return Point.SE; - } else if (157.5 <= degrees && degrees < 202.5) { - return Point.S; - } else if (202.5 <= degrees && degrees < 247.5) { - return Point.SW; - } else if (247.5 <= degrees && degrees < 292.5) { - return Point.W; - } else if (292.5 <= degrees && degrees < 337.5) { - return Point.NW; - } else if (337.5 <= degrees && degrees < 360.0) { - return Point.N; - } else { - return null; - } - } + if (0 <= degrees && degrees < 22.5) { + return Point.N; + } else if (22.5 <= degrees && degrees < 67.5) { + return Point.NE; + } else if (67.5 <= degrees && degrees < 112.5) { + return Point.E; + } else if (112.5 <= degrees && degrees < 157.5) { + return Point.SE; + } else if (157.5 <= degrees && degrees < 202.5) { + return Point.S; + } else if (202.5 <= degrees && degrees < 247.5) { + return Point.SW; + } else if (247.5 <= degrees && degrees < 292.5) { + return Point.W; + } else if (292.5 <= degrees && degrees < 337.5) { + return Point.NW; + } else if (337.5 <= degrees && degrees < 360.0) { + return Point.N; + } else { + return null; + } + } - public static ArrayList getAsciiCompass(Point point, ChatColor colorActive, String colorDefault) { - ArrayList ret = new ArrayList<>(); - String row; + public static ArrayList getAsciiCompass(Point point, ChatColor colorActive, String colorDefault) { + ArrayList ret = new ArrayList<>(); + String row; - row = ""; - row += Point.NW.toString(Point.NW == point, colorActive, colorDefault); - row += Point.N.toString(Point.N == point, colorActive, colorDefault); - row += Point.NE.toString(Point.NE == point, colorActive, colorDefault); - ret.add(row); + row = ""; + row += Point.NW.toString(Point.NW == point, colorActive, colorDefault); + row += Point.N.toString(Point.N == point, colorActive, colorDefault); + row += Point.NE.toString(Point.NE == point, colorActive, colorDefault); + ret.add(row); - row = ""; - row += Point.W.toString(Point.W == point, colorActive, colorDefault); - row += colorDefault + "+"; - row += Point.E.toString(Point.E == point, colorActive, colorDefault); - ret.add(row); + row = ""; + row += Point.W.toString(Point.W == point, colorActive, colorDefault); + row += colorDefault + "+"; + row += Point.E.toString(Point.E == point, colorActive, colorDefault); + ret.add(row); - row = ""; - row += Point.SW.toString(Point.SW == point, colorActive, colorDefault); - row += Point.S.toString(Point.S == point, colorActive, colorDefault); - row += Point.SE.toString(Point.SE == point, colorActive, colorDefault); - ret.add(row); + row = ""; + row += Point.SW.toString(Point.SW == point, colorActive, colorDefault); + row += Point.S.toString(Point.S == point, colorActive, colorDefault); + row += Point.SE.toString(Point.SE == point, colorActive, colorDefault); + ret.add(row); - return ret; - } + return ret; + } - public static ArrayList getAsciiCompass(double inDegrees, ChatColor colorActive, String colorDefault) { - return getAsciiCompass(getCompassPointForDirection(inDegrees), colorActive, colorDefault); - } + public static ArrayList getAsciiCompass(double inDegrees, ChatColor colorActive, String colorDefault) { + return getAsciiCompass(getCompassPointForDirection(inDegrees), colorActive, colorDefault); + } - public enum Point { + public enum Point { - N('N'), - NE('/'), - E('E'), - SE('\\'), - S('S'), - SW('/'), - W('W'), - NW('\\'); + N('N'), + NE('/'), + E('E'), + SE('\\'), + S('S'), + SW('/'), + W('W'), + NW('\\'); - public final char asciiChar; + public final char asciiChar; - Point(final char asciiChar) { - this.asciiChar = asciiChar; - } + Point(final char asciiChar) { + this.asciiChar = asciiChar; + } - @Override - public String toString() { - return String.valueOf(this.asciiChar); - } + @Override + public String toString() { + return String.valueOf(this.asciiChar); + } - public String getTranslation() { - if (this == N) { - return TL.COMPASS_SHORT_NORTH.toString(); - } - if (this == E) { - return TL.COMPASS_SHORT_EAST.toString(); - } - if (this == S) { - return TL.COMPASS_SHORT_SOUTH.toString(); - } - if (this == W) { - return TL.COMPASS_SHORT_WEST.toString(); - } - return toString(); - } + public String getTranslation() { + if (this == N) { + return TL.COMPASS_SHORT_NORTH.toString(); + } + if (this == E) { + return TL.COMPASS_SHORT_EAST.toString(); + } + if (this == S) { + return TL.COMPASS_SHORT_SOUTH.toString(); + } + if (this == W) { + return TL.COMPASS_SHORT_WEST.toString(); + } + return toString(); + } - public String toString(boolean isActive, ChatColor colorActive, String colorDefault) { - return (isActive ? colorActive : colorDefault) + getTranslation(); - } - } + public String toString(boolean isActive, ChatColor colorActive, String colorDefault) { + return (isActive ? colorActive : colorDefault) + getTranslation(); + } + } } diff --git a/src/main/java/com/massivecraft/factions/util/AutoLeaveProcessTask.java b/src/main/java/com/massivecraft/factions/util/AutoLeaveProcessTask.java index 75c8dd98..e9946a1e 100644 --- a/src/main/java/com/massivecraft/factions/util/AutoLeaveProcessTask.java +++ b/src/main/java/com/massivecraft/factions/util/AutoLeaveProcessTask.java @@ -10,84 +10,84 @@ import java.util.logging.Level; public class AutoLeaveProcessTask extends BukkitRunnable { - private transient boolean readyToGo = false; - private transient boolean finished = false; - private transient ListIterator iterator; - private transient double toleranceMillis; + private transient boolean readyToGo = false; + private transient boolean finished = false; + private transient ListIterator iterator; + private transient double toleranceMillis; - public AutoLeaveProcessTask() { - ArrayList fplayers = (ArrayList) FPlayers.getInstance().getAllFPlayers(); - this.iterator = fplayers.listIterator(); - this.toleranceMillis = Conf.autoLeaveAfterDaysOfInactivity * 24 * 60 * 60 * 1000; - this.readyToGo = true; - this.finished = false; - } + public AutoLeaveProcessTask() { + ArrayList fplayers = (ArrayList) FPlayers.getInstance().getAllFPlayers(); + this.iterator = fplayers.listIterator(); + this.toleranceMillis = Conf.autoLeaveAfterDaysOfInactivity * 24 * 60 * 60 * 1000; + this.readyToGo = true; + this.finished = false; + } - public void run() { - if (Conf.autoLeaveAfterDaysOfInactivity <= 0.0 || Conf.autoLeaveRoutineMaxMillisecondsPerTick <= 0.0) { - this.stop(); - return; - } + public void run() { + if (Conf.autoLeaveAfterDaysOfInactivity <= 0.0 || Conf.autoLeaveRoutineMaxMillisecondsPerTick <= 0.0) { + this.stop(); + return; + } - if (!readyToGo) { - return; - } - // this is set so it only does one iteration at a time, no matter how frequently the timer fires - readyToGo = false; - // and this is tracked to keep one iteration from dragging on too long and possibly choking the system if there are a very large number of players to go through - long loopStartTime = System.currentTimeMillis(); + if (!readyToGo) { + return; + } + // this is set so it only does one iteration at a time, no matter how frequently the timer fires + readyToGo = false; + // and this is tracked to keep one iteration from dragging on too long and possibly choking the system if there are a very large number of players to go through + long loopStartTime = System.currentTimeMillis(); - while (iterator.hasNext()) { - long now = System.currentTimeMillis(); + while (iterator.hasNext()) { + long now = System.currentTimeMillis(); - // if this iteration has been running for maximum time, stop to take a breather until next tick - if (now > loopStartTime + Conf.autoLeaveRoutineMaxMillisecondsPerTick) { - readyToGo = true; - return; - } + // if this iteration has been running for maximum time, stop to take a breather until next tick + if (now > loopStartTime + Conf.autoLeaveRoutineMaxMillisecondsPerTick) { + readyToGo = true; + return; + } - FPlayer fplayer = iterator.next(); + FPlayer fplayer = iterator.next(); - // Check if they should be exempt from this. - if (!fplayer.willAutoLeave()) { - P.p.debug(Level.INFO, fplayer.getName() + " was going to be auto-removed but was set not to."); - continue; - } + // Check if they should be exempt from this. + if (!fplayer.willAutoLeave()) { + P.p.debug(Level.INFO, fplayer.getName() + " was going to be auto-removed but was set not to."); + continue; + } - if (fplayer.isOffline() && now - fplayer.getLastLoginTime() > toleranceMillis) { - if (Conf.logFactionLeave || Conf.logFactionKick) { - P.p.log("Player " + fplayer.getName() + " was auto-removed due to inactivity."); - } + if (fplayer.isOffline() && now - fplayer.getLastLoginTime() > toleranceMillis) { + if (Conf.logFactionLeave || Conf.logFactionKick) { + P.p.log("Player " + fplayer.getName() + " was auto-removed due to inactivity."); + } - // if player is faction admin, sort out the faction since he's going away - if (fplayer.getRole() == Role.LEADER) { - Faction faction = fplayer.getFaction(); - if (faction != null) { - fplayer.getFaction().promoteNewLeader(true); - } - } + // if player is faction admin, sort out the faction since he's going away + if (fplayer.getRole() == Role.LEADER) { + Faction faction = fplayer.getFaction(); + if (faction != null) { + fplayer.getFaction().promoteNewLeader(true); + } + } - fplayer.leave(false); - iterator.remove(); // go ahead and remove this list's link to the FPlayer object - if (Conf.autoLeaveDeleteFPlayerData) { - fplayer.remove(); - } - } - } + fplayer.leave(false); + iterator.remove(); // go ahead and remove this list's link to the FPlayer object + if (Conf.autoLeaveDeleteFPlayerData) { + fplayer.remove(); + } + } + } - // looks like we've finished - this.stop(); - } + // looks like we've finished + this.stop(); + } - // we're done, shut down - public void stop() { - readyToGo = false; - finished = true; + // we're done, shut down + public void stop() { + readyToGo = false; + finished = true; - this.cancel(); - } + this.cancel(); + } - public boolean isFinished() { - return finished; - } + public boolean isFinished() { + return finished; + } } diff --git a/src/main/java/com/massivecraft/factions/util/AutoLeaveTask.java b/src/main/java/com/massivecraft/factions/util/AutoLeaveTask.java index 1dfbeeeb..6a1bda45 100644 --- a/src/main/java/com/massivecraft/factions/util/AutoLeaveTask.java +++ b/src/main/java/com/massivecraft/factions/util/AutoLeaveTask.java @@ -5,24 +5,24 @@ import com.massivecraft.factions.P; public class AutoLeaveTask implements Runnable { - private static AutoLeaveProcessTask task; - double rate; + private static AutoLeaveProcessTask task; + double rate; - public AutoLeaveTask() { - this.rate = Conf.autoLeaveRoutineRunsEveryXMinutes; - } + public AutoLeaveTask() { + this.rate = Conf.autoLeaveRoutineRunsEveryXMinutes; + } - public synchronized void run() { - if (task != null && !task.isFinished()) { - return; - } + public synchronized void run() { + if (task != null && !task.isFinished()) { + return; + } - task = new AutoLeaveProcessTask(); - task.runTaskTimer(P.p, 1, 1); + task = new AutoLeaveProcessTask(); + task.runTaskTimer(P.p, 1, 1); - // maybe setting has been changed? if so, restart this task at new rate - if (this.rate != Conf.autoLeaveRoutineRunsEveryXMinutes) { - P.p.startAutoLeaveTask(true); - } - } + // maybe setting has been changed? if so, restart this task at new rate + if (this.rate != Conf.autoLeaveRoutineRunsEveryXMinutes) { + P.p.startAutoLeaveTask(true); + } + } } diff --git a/src/main/java/com/massivecraft/factions/util/CheckWallTask.java b/src/main/java/com/massivecraft/factions/util/CheckWallTask.java new file mode 100644 index 00000000..c49fefbb --- /dev/null +++ b/src/main/java/com/massivecraft/factions/util/CheckWallTask.java @@ -0,0 +1,23 @@ +package com.massivecraft.factions.util; + +import com.massivecraft.factions.Faction; +import com.massivecraft.factions.Factions; +import org.bukkit.scheduler.BukkitRunnable; + +public class CheckWallTask extends BukkitRunnable { + + private int overtime; + + public CheckWallTask() { + overtime = 0; + } + + public void run() { + ++overtime; + for (Faction faction : Factions.getInstance().getAllFactions()) { + if (faction.getCheckNotifier() != 0L && overtime % faction.getCheckNotifier() == 0L) { + faction.sendCheckNotify(); + } + } + } +} diff --git a/src/main/java/com/massivecraft/factions/util/ClipPlaceholderAPIManager.java b/src/main/java/com/massivecraft/factions/util/ClipPlaceholderAPIManager.java index 26f9e272..77e7588d 100644 --- a/src/main/java/com/massivecraft/factions/util/ClipPlaceholderAPIManager.java +++ b/src/main/java/com/massivecraft/factions/util/ClipPlaceholderAPIManager.java @@ -15,161 +15,161 @@ import java.util.UUID; public class ClipPlaceholderAPIManager extends PlaceholderExpansion implements Relational { - // Identifier for this expansion - @Override - public String getIdentifier() { - return "factionsuuid"; - } + // Identifier for this expansion + @Override + public String getIdentifier() { + return "factionsuuid"; + } - @Override - public String getAuthor() { - return "drtshock"; - } + @Override + public String getAuthor() { + return "drtshock"; + } - // Since we are registering this expansion from the dependency, this can be null - @Override - public String getPlugin() { - return null; - } + // Since we are registering this expansion from the dependency, this can be null + @Override + public String getPlugin() { + return null; + } - // Return the plugin version since this expansion is bundled with the dependency - @Override - public String getVersion() { - return P.p.getDescription().getVersion(); - } + // Return the plugin version since this expansion is bundled with the dependency + @Override + public String getVersion() { + return P.p.getDescription().getVersion(); + } - @Override - public boolean persist() { - return true; - } + @Override + public boolean persist() { + return true; + } - // Relational placeholders - @Override - public String onPlaceholderRequest(Player p1, Player p2, String placeholder) { - if (p1 == null || p2 == null || placeholder == null) { - return ""; - } + // Relational placeholders + @Override + public String onPlaceholderRequest(Player p1, Player p2, String placeholder) { + if (p1 == null || p2 == null || placeholder == null) { + return ""; + } - FPlayer fp1 = FPlayers.getInstance().getByPlayer(p1); - FPlayer fp2 = FPlayers.getInstance().getByPlayer(p2); - if (fp1 == null || fp2 == null) { - return ""; - } + FPlayer fp1 = FPlayers.getInstance().getByPlayer(p1); + FPlayer fp2 = FPlayers.getInstance().getByPlayer(p2); + if (fp1 == null || fp2 == null) { + return ""; + } - switch (placeholder) { - case "relation": - String relationName = fp1.getRelationTo(fp2).nicename; - return relationName != null ? relationName : ""; - case "relation_color": - ChatColor color = fp1.getColorTo(fp2); - return color != null ? color.toString() : ""; - } + switch (placeholder) { + case "relation": + String relationName = fp1.getRelationTo(fp2).nicename; + return relationName != null ? relationName : ""; + case "relation_color": + ChatColor color = fp1.getColorTo(fp2); + return color != null ? color.toString() : ""; + } - return null; - } + return null; + } - @Override - public String onPlaceholderRequest(Player player, String placeholder) { - if (player == null || placeholder == null) { - return ""; - } + @Override + public String onPlaceholderRequest(Player player, String placeholder) { + if (player == null || placeholder == null) { + return ""; + } - FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player); - Faction faction = fPlayer.getFaction(); - switch (placeholder) { - // First list player stuff - case "player_name": - return fPlayer.getName(); - case "player_lastseen": - String humanized = DurationFormatUtils.formatDurationWords(System.currentTimeMillis() - fPlayer.getLastLoginTime(), true, true) + TL.COMMAND_STATUS_AGOSUFFIX; - return fPlayer.isOnline() ? ChatColor.GREEN + TL.COMMAND_STATUS_ONLINE.toString() : (System.currentTimeMillis() - fPlayer.getLastLoginTime() < 432000000 ? ChatColor.YELLOW + humanized : ChatColor.RED + humanized); - case "player_group": - return P.p.getPrimaryGroup(Bukkit.getOfflinePlayer(UUID.fromString(fPlayer.getId()))); - case "player_balance": - return Econ.isSetup() ? Econ.getFriendlyBalance(fPlayer) : TL.ECON_OFF.format("balance"); - case "player_power": - return String.valueOf(fPlayer.getPowerRounded()); - case "player_maxpower": - return String.valueOf(fPlayer.getPowerMaxRounded()); - case "player_kills": - return String.valueOf(fPlayer.getKills()); - case "player_deaths": - return String.valueOf(fPlayer.getDeaths()); - case "player_role_prefix": - return String.valueOf(fPlayer.getRolePrefix()); - case "player_role": - return fPlayer.hasFaction() ? fPlayer.getRole().getPrefix() : ""; - case "player_role_name": - return fPlayer.hasFaction() ? fPlayer.getRole().getTranslation().toString() : TL.PLACEHOLDER_ROLE_NAME.toString(); - // Then Faction stuff - case "faction_name": - return fPlayer.hasFaction() ? faction.getTag() : TL.NOFACTION_PREFIX.toString(); - case "faction_power": - return String.valueOf(faction.getPowerRounded()); - case "faction_powermax": - return String.valueOf(faction.getPowerMaxRounded()); - case "faction_description": - return faction.getDescription(); - case "faction_claims": - return String.valueOf(faction.getAllClaims().size()); - case "faction_founded": - 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": - return faction.isPeaceful() ? Conf.colorNeutral + TL.COMMAND_SHOW_PEACEFUL.toString() : ""; - case "faction_tntbank_balance": - return String.valueOf(faction.getTnt()); - case "faction_powerboost": - double powerBoost = faction.getPowerBoost(); - return (powerBoost == 0.0) ? "" : (powerBoost > 0.0 ? TL.COMMAND_SHOW_BONUS.toString() : TL.COMMAND_SHOW_PENALTY.toString()) + powerBoost + ")"; - case "faction_leader": - FPlayer fAdmin = faction.getFPlayerAdmin(); - return fAdmin == null ? "Server" : fAdmin.getName().substring(0, fAdmin.getName().length() > 14 ? 13 : fAdmin.getName().length()); - case "faction_warps": - return String.valueOf(faction.getWarps().size()); - case "faction_raidable": - boolean raid = P.p.getConfig().getBoolean("hcf.raidable", false) && faction.getLandRounded() >= faction.getPowerRounded(); - return raid ? TL.RAIDABLE_TRUE.toString() : TL.RAIDABLE_FALSE.toString(); - case "faction_home_world": - return faction.hasHome() ? faction.getHome().getWorld().getName() : ""; - case "faction_home_x": - return faction.hasHome() ? String.valueOf(faction.getHome().getBlockX()) : ""; - case "faction_home_y": - return faction.hasHome() ? String.valueOf(faction.getHome().getBlockY()) : ""; - case "faction_home_z": - return faction.hasHome() ? String.valueOf(faction.getHome().getBlockZ()) : ""; - case "facion_land_value": - return Econ.shouldBeUsed() ? Econ.moneyString(Econ.calculateTotalLandValue(faction.getLandRounded())) : TL.ECON_OFF.format("value"); - case "faction_land_refund": - return Econ.shouldBeUsed() ? Econ.moneyString(Econ.calculateTotalLandRefund(faction.getLandRounded())) : TL.ECON_OFF.format("refund"); - case "faction_bank_balance": - return Econ.shouldBeUsed() ? Econ.moneyString(Econ.getBalance(faction.getAccountId())) : TL.ECON_OFF.format("balance"); - case "faction_allies": - return String.valueOf(faction.getRelationCount(Relation.ALLY)); - case "faction_enemies": - return String.valueOf(faction.getRelationCount(Relation.ENEMY)); - case "faction_truces": - return String.valueOf(faction.getRelationCount(Relation.TRUCE)); - case "faction_online": - return String.valueOf(faction.getOnlinePlayers().size()); - case "faction_offline": - return String.valueOf(faction.getFPlayers().size() - faction.getOnlinePlayers().size()); - case "faction_size": - return String.valueOf(faction.getFPlayers().size()); - case "faction_kills": - return String.valueOf(faction.getKills()); - case "faction_deaths": - return String.valueOf(faction.getDeaths()); - case "faction_maxvaults": - return String.valueOf(faction.getMaxVaults()); - case "faction_grace": - return String.valueOf(Conf.gracePeriod); - case "faction_name_at_location": - Faction factionAtLocation = Board.getInstance().getFactionAt(new FLocation(player.getLocation())); - return factionAtLocation != null ? factionAtLocation.getTag() : Factions.getInstance().getWilderness().getTag(); - } + FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player); + Faction faction = fPlayer.getFaction(); + switch (placeholder) { + // First list player stuff + case "player_name": + return fPlayer.getName(); + case "player_lastseen": + String humanized = DurationFormatUtils.formatDurationWords(System.currentTimeMillis() - fPlayer.getLastLoginTime(), true, true) + TL.COMMAND_STATUS_AGOSUFFIX; + return fPlayer.isOnline() ? ChatColor.GREEN + TL.COMMAND_STATUS_ONLINE.toString() : (System.currentTimeMillis() - fPlayer.getLastLoginTime() < 432000000 ? ChatColor.YELLOW + humanized : ChatColor.RED + humanized); + case "player_group": + return P.p.getPrimaryGroup(Bukkit.getOfflinePlayer(UUID.fromString(fPlayer.getId()))); + case "player_balance": + return Econ.isSetup() ? Econ.getFriendlyBalance(fPlayer) : TL.ECON_OFF.format("balance"); + case "player_power": + return String.valueOf(fPlayer.getPowerRounded()); + case "player_maxpower": + return String.valueOf(fPlayer.getPowerMaxRounded()); + case "player_kills": + return String.valueOf(fPlayer.getKills()); + case "player_deaths": + return String.valueOf(fPlayer.getDeaths()); + case "player_role_prefix": + return String.valueOf(fPlayer.getRolePrefix()); + case "player_role": + return fPlayer.hasFaction() ? fPlayer.getRole().getPrefix() : ""; + case "player_role_name": + return fPlayer.hasFaction() ? fPlayer.getRole().getTranslation().toString() : TL.PLACEHOLDER_ROLE_NAME.toString(); + // Then Faction stuff + case "faction_name": + return fPlayer.hasFaction() ? faction.getTag() : TL.NOFACTION_PREFIX.toString(); + case "faction_power": + return String.valueOf(faction.getPowerRounded()); + case "faction_powermax": + return String.valueOf(faction.getPowerMaxRounded()); + case "faction_description": + return faction.getDescription(); + case "faction_claims": + return String.valueOf(faction.getAllClaims().size()); + case "faction_founded": + 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": + return faction.isPeaceful() ? Conf.colorNeutral + TL.COMMAND_SHOW_PEACEFUL.toString() : ""; + case "faction_tntbank_balance": + return String.valueOf(faction.getTnt()); + case "faction_powerboost": + double powerBoost = faction.getPowerBoost(); + return (powerBoost == 0.0) ? "" : (powerBoost > 0.0 ? TL.COMMAND_SHOW_BONUS.toString() : TL.COMMAND_SHOW_PENALTY.toString()) + powerBoost + ")"; + case "faction_leader": + FPlayer fAdmin = faction.getFPlayerAdmin(); + return fAdmin == null ? "Server" : fAdmin.getName().substring(0, fAdmin.getName().length() > 14 ? 13 : fAdmin.getName().length()); + case "faction_warps": + return String.valueOf(faction.getWarps().size()); + case "faction_raidable": + boolean raid = P.p.getConfig().getBoolean("hcf.raidable", false) && faction.getLandRounded() >= faction.getPowerRounded(); + return raid ? TL.RAIDABLE_TRUE.toString() : TL.RAIDABLE_FALSE.toString(); + case "faction_home_world": + return faction.hasHome() ? faction.getHome().getWorld().getName() : ""; + case "faction_home_x": + return faction.hasHome() ? String.valueOf(faction.getHome().getBlockX()) : ""; + case "faction_home_y": + return faction.hasHome() ? String.valueOf(faction.getHome().getBlockY()) : ""; + case "faction_home_z": + return faction.hasHome() ? String.valueOf(faction.getHome().getBlockZ()) : ""; + case "facion_land_value": + return Econ.shouldBeUsed() ? Econ.moneyString(Econ.calculateTotalLandValue(faction.getLandRounded())) : TL.ECON_OFF.format("value"); + case "faction_land_refund": + return Econ.shouldBeUsed() ? Econ.moneyString(Econ.calculateTotalLandRefund(faction.getLandRounded())) : TL.ECON_OFF.format("refund"); + case "faction_bank_balance": + return Econ.shouldBeUsed() ? Econ.moneyString(Econ.getBalance(faction.getAccountId())) : TL.ECON_OFF.format("balance"); + case "faction_allies": + return String.valueOf(faction.getRelationCount(Relation.ALLY)); + case "faction_enemies": + return String.valueOf(faction.getRelationCount(Relation.ENEMY)); + case "faction_truces": + return String.valueOf(faction.getRelationCount(Relation.TRUCE)); + case "faction_online": + return String.valueOf(faction.getOnlinePlayers().size()); + case "faction_offline": + return String.valueOf(faction.getFPlayers().size() - faction.getOnlinePlayers().size()); + case "faction_size": + return String.valueOf(faction.getFPlayers().size()); + case "faction_kills": + return String.valueOf(faction.getKills()); + case "faction_deaths": + return String.valueOf(faction.getDeaths()); + case "faction_maxvaults": + return String.valueOf(faction.getMaxVaults()); + case "faction_grace": + return String.valueOf(Conf.gracePeriod); + case "faction_name_at_location": + Faction factionAtLocation = Board.getInstance().getFactionAt(new FLocation(player.getLocation())); + return factionAtLocation != null ? factionAtLocation.getTag() : Factions.getInstance().getWilderness().getTag(); + } - return null; - } + return null; + } } \ No newline at end of file diff --git a/src/main/java/com/massivecraft/factions/util/EnumTypeAdapter.java b/src/main/java/com/massivecraft/factions/util/EnumTypeAdapter.java index 2f0ed3e9..f5b2b975 100644 --- a/src/main/java/com/massivecraft/factions/util/EnumTypeAdapter.java +++ b/src/main/java/com/massivecraft/factions/util/EnumTypeAdapter.java @@ -15,52 +15,52 @@ 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 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 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 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 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)); - } + 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 d389bf90..c9d964ee 100644 --- a/src/main/java/com/massivecraft/factions/util/FactionGUI.java +++ b/src/main/java/com/massivecraft/factions/util/FactionGUI.java @@ -5,8 +5,8 @@ import org.bukkit.inventory.InventoryHolder; public interface FactionGUI extends InventoryHolder { - void onClick(int slot, ClickType action); + void onClick(int slot, ClickType action); - void build(); + void build(); } diff --git a/src/main/java/com/massivecraft/factions/util/FactionWarpsFrame.java b/src/main/java/com/massivecraft/factions/util/FactionWarpsFrame.java index c70cae51..e4790637 100644 --- a/src/main/java/com/massivecraft/factions/util/FactionWarpsFrame.java +++ b/src/main/java/com/massivecraft/factions/util/FactionWarpsFrame.java @@ -4,21 +4,20 @@ import com.github.stefvanschie.inventoryframework.Gui; import com.github.stefvanschie.inventoryframework.GuiItem; import com.github.stefvanschie.inventoryframework.pane.PaginatedPane; import com.massivecraft.factions.Conf; +import com.massivecraft.factions.FPlayer; +import com.massivecraft.factions.Faction; import com.massivecraft.factions.P; import com.massivecraft.factions.integration.Econ; +import com.massivecraft.factions.zcore.util.TL; +import org.bukkit.Bukkit; +import org.bukkit.configuration.ConfigurationSection; import org.bukkit.entity.Player; -import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; import java.util.ArrayList; import java.util.List; -import org.bukkit.Bukkit; -import com.massivecraft.factions.zcore.util.TL; import java.util.Map; -import com.massivecraft.factions.FPlayer; - -import com.massivecraft.factions.Faction; -import org.bukkit.configuration.ConfigurationSection; public class FactionWarpsFrame { @@ -27,7 +26,7 @@ public class FactionWarpsFrame { public FactionWarpsFrame(final Faction f) { this.section = P.p.getConfig().getConfigurationSection("fwarp-gui"); - this.gui = new Gui(P.p, section.getInt("rows", 3), P.p.color(this.section.getString("name").replace("{faction}",f.getTag()))); + this.gui = new Gui(P.p, section.getInt("rows", 3), P.p.color(this.section.getString("name").replace("{faction}", f.getTag()))); } public void buildGUI(final FPlayer fplayer) { @@ -35,7 +34,8 @@ public class FactionWarpsFrame { final List GUIItems = new ArrayList<>(); final List slots = section.getIntegerList("warp-slots"); int count = 0; - for (int x = 0; x <= gui.getRows() * 9 - 1; ++x) GUIItems.add(new GuiItem(buildDummyItem(), e -> e.setCancelled(true))); + for (int x = 0; x <= gui.getRows() * 9 - 1; ++x) + GUIItems.add(new GuiItem(buildDummyItem(), e -> e.setCancelled(true))); slots.forEach(slot -> GUIItems.set(slot, new GuiItem(XMaterial.AIR.parseItem()))); for (final Map.Entry warp : fplayer.getFaction().getWarps().entrySet()) { if (count > slots.size()) continue; diff --git a/src/main/java/com/massivecraft/factions/util/InventoryTypeAdapter.java b/src/main/java/com/massivecraft/factions/util/InventoryTypeAdapter.java index 518d2b3c..0b941b1d 100644 --- a/src/main/java/com/massivecraft/factions/util/InventoryTypeAdapter.java +++ b/src/main/java/com/massivecraft/factions/util/InventoryTypeAdapter.java @@ -8,20 +8,20 @@ import java.lang.reflect.Type; public class InventoryTypeAdapter implements JsonSerializer, JsonDeserializer { - @Override - public JsonElement serialize(Inventory inventory, Type type, JsonSerializationContext jsonSerializationContext) { + @Override + public JsonElement serialize(Inventory inventory, Type type, JsonSerializationContext jsonSerializationContext) { - JsonObject object = new JsonObject(); - object.add("contents", new JsonPrimitive(InventoryUtil.toBase64(inventory))); - return object; - } + JsonObject object = new JsonObject(); + object.add("contents", new JsonPrimitive(InventoryUtil.toBase64(inventory))); + return object; + } - @Override - public Inventory deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) { - JsonObject object = jsonElement.getAsJsonObject(); - return InventoryUtil.fromBase64(object.get("contents").getAsString()); - } + @Override + public Inventory deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) { + JsonObject object = jsonElement.getAsJsonObject(); + return InventoryUtil.fromBase64(object.get("contents").getAsString()); + } } diff --git a/src/main/java/com/massivecraft/factions/util/InventoryUtil.java b/src/main/java/com/massivecraft/factions/util/InventoryUtil.java index a64ad690..98f31df6 100644 --- a/src/main/java/com/massivecraft/factions/util/InventoryUtil.java +++ b/src/main/java/com/massivecraft/factions/util/InventoryUtil.java @@ -14,78 +14,78 @@ import java.io.IOException; public class InventoryUtil { - public static String InventoryToString(ItemStack[] items) throws IllegalStateException { - try { - ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); - BukkitObjectOutputStream dataOutput = new BukkitObjectOutputStream(outputStream); - dataOutput.writeInt(items.length); - for (ItemStack item : items) { - dataOutput.writeObject(item); - } - dataOutput.close(); - return Base64Coder.encodeLines(outputStream.toByteArray()); - } catch (Exception e) { - throw new IllegalStateException("Unable to save item stacks.", e); - } - } + public static String InventoryToString(ItemStack[] items) throws IllegalStateException { + try { + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + BukkitObjectOutputStream dataOutput = new BukkitObjectOutputStream(outputStream); + dataOutput.writeInt(items.length); + for (ItemStack item : items) { + dataOutput.writeObject(item); + } + dataOutput.close(); + return Base64Coder.encodeLines(outputStream.toByteArray()); + } catch (Exception e) { + throw new IllegalStateException("Unable to save item stacks.", e); + } + } - public static ItemStack[] StringToInventory(String data) throws IOException { - try { - ByteArrayInputStream inputStream = new ByteArrayInputStream(Base64Coder.decodeLines(data)); - BukkitObjectInputStream dataInput = new BukkitObjectInputStream(inputStream); - ItemStack[] items = new ItemStack[dataInput.readInt()]; - for (int i = 0; i < items.length; i++) { - items[i] = (ItemStack) dataInput.readObject(); - } - dataInput.close(); - return items; - } catch (ClassNotFoundException e) { - throw new IOException("Unable to decode class type.", e); - } - } + public static ItemStack[] StringToInventory(String data) throws IOException { + try { + ByteArrayInputStream inputStream = new ByteArrayInputStream(Base64Coder.decodeLines(data)); + BukkitObjectInputStream dataInput = new BukkitObjectInputStream(inputStream); + ItemStack[] items = new ItemStack[dataInput.readInt()]; + for (int i = 0; i < items.length; i++) { + items[i] = (ItemStack) dataInput.readObject(); + } + dataInput.close(); + return items; + } catch (ClassNotFoundException e) { + throw new IOException("Unable to decode class type.", e); + } + } - public static String toBase64(Inventory inventory) { - try { - ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); - BukkitObjectOutputStream dataOutput = new BukkitObjectOutputStream(outputStream); + public static String toBase64(Inventory inventory) { + try { + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + BukkitObjectOutputStream dataOutput = new BukkitObjectOutputStream(outputStream); - // Write the size of the inventory - dataOutput.writeInt(inventory.getSize()); + // Write the size of the inventory + dataOutput.writeInt(inventory.getSize()); - // Save every element in the list - for (int i = 0; i < inventory.getSize(); i++) { - dataOutput.writeObject(inventory.getItem(i)); - } + // Save every element in the list + for (int i = 0; i < inventory.getSize(); i++) { + dataOutput.writeObject(inventory.getItem(i)); + } - // Serialize that array - dataOutput.close(); - return Base64Coder.encodeLines(outputStream.toByteArray()); - } catch (Exception e) { - throw new IllegalStateException("Cannot into itemstacksz!", e); - } - } + // Serialize that array + dataOutput.close(); + return Base64Coder.encodeLines(outputStream.toByteArray()); + } catch (Exception e) { + throw new IllegalStateException("Cannot into itemstacksz!", e); + } + } - public static String toBase64(ItemStack[] is, int size) { - Inventory inventory = Bukkit.createInventory(null, size); - inventory.setContents(is); - return toBase64(inventory); - } + public static String toBase64(ItemStack[] is, int size) { + Inventory inventory = Bukkit.createInventory(null, size); + inventory.setContents(is); + return toBase64(inventory); + } - public static Inventory fromBase64(String data) { - try { - ByteArrayInputStream inputStream = new ByteArrayInputStream(Base64Coder.decodeLines(data)); - BukkitObjectInputStream dataInput = new BukkitObjectInputStream(inputStream); - Inventory inventory = Bukkit.getServer().createInventory(null, dataInput.readInt()); + public static Inventory fromBase64(String data) { + try { + ByteArrayInputStream inputStream = new ByteArrayInputStream(Base64Coder.decodeLines(data)); + BukkitObjectInputStream dataInput = new BukkitObjectInputStream(inputStream); + Inventory inventory = Bukkit.getServer().createInventory(null, dataInput.readInt()); - // Read the serialized inventory - for (int i = 0; i < inventory.getSize(); i++) { - inventory.setItem(i, (ItemStack) dataInput.readObject()); - } - dataInput.close(); - return inventory; - } catch (Exception e) { - } - return null; - } + // Read the serialized inventory + for (int i = 0; i < inventory.getSize(); i++) { + inventory.setItem(i, (ItemStack) dataInput.readObject()); + } + dataInput.close(); + return inventory; + } catch (Exception e) { + } + return null; + } } diff --git a/src/main/java/com/massivecraft/factions/util/LazyLocation.java b/src/main/java/com/massivecraft/factions/util/LazyLocation.java index 1682d8d3..a141bbc7 100644 --- a/src/main/java/com/massivecraft/factions/util/LazyLocation.java +++ b/src/main/java/com/massivecraft/factions/util/LazyLocation.java @@ -12,90 +12,90 @@ import java.io.Serializable; */ public class LazyLocation implements Serializable { - private static final long serialVersionUID = -6049901271320963314L; - private transient Location location = null; - private String worldName; - private double x; - private double y; - private double z; - private float pitch; - private float yaw; + private static final long serialVersionUID = -6049901271320963314L; + private transient Location location = null; + private String worldName; + private double x; + private double y; + private double z; + private float pitch; + private float yaw; - public LazyLocation(Location loc) { - setLocation(loc); - } + public LazyLocation(Location loc) { + setLocation(loc); + } - public LazyLocation(final String worldName, final double x, final double y, final double z) { - this(worldName, x, y, z, 0, 0); - } + public LazyLocation(final String worldName, final double x, final double y, final double z) { + this(worldName, x, y, z, 0, 0); + } - public LazyLocation(final String worldName, final double x, final double y, final double z, final float yaw, final float pitch) { - this.worldName = worldName; - this.x = x; - this.y = y; - this.z = z; - this.yaw = yaw; - this.pitch = pitch; - } + public LazyLocation(final String worldName, final double x, final double y, final double z, final float yaw, final float pitch) { + this.worldName = worldName; + this.x = x; + this.y = y; + this.z = z; + this.yaw = yaw; + this.pitch = pitch; + } - // This returns the actual Location - public final Location getLocation() { - // make sure Location is initialized before returning it - initLocation(); - return location; - } + // This returns the actual Location + public final Location getLocation() { + // make sure Location is initialized before returning it + initLocation(); + return location; + } - // change the Location - public final void setLocation(Location loc) { - this.location = loc; - this.worldName = loc.getWorld().getName(); - this.x = loc.getX(); - this.y = loc.getY(); - this.z = loc.getZ(); - this.yaw = loc.getYaw(); - this.pitch = loc.getPitch(); - } + // change the Location + public final void setLocation(Location loc) { + this.location = loc; + this.worldName = loc.getWorld().getName(); + this.x = loc.getX(); + this.y = loc.getY(); + this.z = loc.getZ(); + this.yaw = loc.getYaw(); + this.pitch = loc.getPitch(); + } - // This initializes the Location - private void initLocation() { - // if location is already initialized, simply return - if (location != null) { - return; - } + // This initializes the Location + private void initLocation() { + // if location is already initialized, simply return + if (location != null) { + return; + } - // get World; hopefully it's initialized at this point - World world = Bukkit.getWorld(worldName); - if (world == null) { - return; - } + // get World; hopefully it's initialized at this point + World world = Bukkit.getWorld(worldName); + if (world == null) { + return; + } - // store the Location for future calls, and pass it on - location = new Location(world, x, y, z, yaw, pitch); - } + // store the Location for future calls, and pass it on + location = new Location(world, x, y, z, yaw, pitch); + } - public final String getWorldName() { - return worldName; - } + public final String getWorldName() { + return worldName; + } - public final double getX() { - return x; - } + public final double getX() { + return x; + } - public final double getY() { - return y; - } + public final double getY() { + return y; + } - public final double getZ() { - return z; - } + public final double getZ() { + return z; + } - public final double getPitch() { - return pitch; - } + public final double getPitch() { + return pitch; + } - public final double getYaw() { - return yaw; - } + public final double getYaw() { + return yaw; + } } diff --git a/src/main/java/com/massivecraft/factions/util/LocationTypeAdapter.java b/src/main/java/com/massivecraft/factions/util/LocationTypeAdapter.java index 4017fc24..a5862681 100644 --- a/src/main/java/com/massivecraft/factions/util/LocationTypeAdapter.java +++ b/src/main/java/com/massivecraft/factions/util/LocationTypeAdapter.java @@ -10,41 +10,41 @@ import java.util.logging.Level; public class LocationTypeAdapter implements JsonSerializer, JsonDeserializer { - @Override - public JsonElement serialize(Location location, Type type, JsonSerializationContext jsonSerializationContext) { - JsonObject object = new JsonObject(); - try { - object.add("x", new JsonPrimitive(location.getX())); - object.add("y", new JsonPrimitive(location.getY())); - object.add("z", new JsonPrimitive(location.getZ())); - object.add("world", new JsonPrimitive(location.getWorld().getName())); - return object; - } catch (Exception ex) { - ex.printStackTrace(); - P.p.log(Level.WARNING, "Error encountered while serializing a Location."); - return object; - } - } + @Override + public JsonElement serialize(Location location, Type type, JsonSerializationContext jsonSerializationContext) { + JsonObject object = new JsonObject(); + try { + object.add("x", new JsonPrimitive(location.getX())); + object.add("y", new JsonPrimitive(location.getY())); + object.add("z", new JsonPrimitive(location.getZ())); + object.add("world", new JsonPrimitive(location.getWorld().getName())); + return object; + } catch (Exception ex) { + ex.printStackTrace(); + P.p.log(Level.WARNING, "Error encountered while serializing a Location."); + return object; + } + } - @Override - public Location deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) { - JsonObject object = jsonElement.getAsJsonObject(); - try { + @Override + public Location deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) { + JsonObject object = jsonElement.getAsJsonObject(); + try { - return new Location(Bukkit.getWorld(object.get("world").getAsString()), - object.get("x").getAsDouble(), - object.get("y").getAsDouble(), - object.get("z").getAsDouble()); - } catch (Exception ex) { - ex.printStackTrace(); - P.p.log(Level.WARNING, "Error encountered while" + - " deserializing a Location."); - return null; - } + return new Location(Bukkit.getWorld(object.get("world").getAsString()), + object.get("x").getAsDouble(), + object.get("y").getAsDouble(), + object.get("z").getAsDouble()); + } catch (Exception ex) { + ex.printStackTrace(); + P.p.log(Level.WARNING, "Error encountered while" + + " deserializing a Location."); + return null; + } - } + } } diff --git a/src/main/java/com/massivecraft/factions/util/MapFLocToStringSetTypeAdapter.java b/src/main/java/com/massivecraft/factions/util/MapFLocToStringSetTypeAdapter.java index 88cda92b..d70d2cba 100644 --- a/src/main/java/com/massivecraft/factions/util/MapFLocToStringSetTypeAdapter.java +++ b/src/main/java/com/massivecraft/factions/util/MapFLocToStringSetTypeAdapter.java @@ -16,87 +16,87 @@ import java.util.logging.Level; public class MapFLocToStringSetTypeAdapter implements JsonDeserializer>>, JsonSerializer>> { - @Override - public Map> deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { - try { - JsonObject obj = json.getAsJsonObject(); - if (obj == null) { - return null; - } + @Override + public Map> deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { + try { + JsonObject obj = json.getAsJsonObject(); + if (obj == null) { + return null; + } - Map> locationMap = new ConcurrentHashMap<>(); - Set nameSet; - Iterator iter; - String worldName; - String[] coords; - int x, z; + Map> locationMap = new ConcurrentHashMap<>(); + Set nameSet; + Iterator iter; + String worldName; + String[] coords; + int x, z; - for (Entry entry : obj.entrySet()) { - worldName = entry.getKey(); - for (Entry entry2 : entry.getValue().getAsJsonObject().entrySet()) { - coords = entry2.getKey().trim().split("[,\\s]+"); - x = Integer.parseInt(coords[0]); - z = Integer.parseInt(coords[1]); + for (Entry entry : obj.entrySet()) { + worldName = entry.getKey(); + for (Entry entry2 : entry.getValue().getAsJsonObject().entrySet()) { + coords = entry2.getKey().trim().split("[,\\s]+"); + x = Integer.parseInt(coords[0]); + z = Integer.parseInt(coords[1]); - nameSet = new HashSet<>(); - iter = entry2.getValue().getAsJsonArray().iterator(); - while (iter.hasNext()) nameSet.add(iter.next().getAsString()); + nameSet = new HashSet<>(); + iter = entry2.getValue().getAsJsonArray().iterator(); + while (iter.hasNext()) nameSet.add(iter.next().getAsString()); - locationMap.put(new FLocation(worldName, x, z), nameSet); - } - } + locationMap.put(new FLocation(worldName, x, z), nameSet); + } + } - return locationMap; + return locationMap; - } catch (Exception ex) { - ex.printStackTrace(); - P.p.log(Level.WARNING, "Error encountered while deserializing a Map of FLocations to String Sets."); - return null; - } - } + } catch (Exception ex) { + ex.printStackTrace(); + P.p.log(Level.WARNING, "Error encountered while deserializing a Map of FLocations to String Sets."); + return null; + } + } - @Override - public JsonElement serialize(Map> src, Type typeOfSrc, JsonSerializationContext context) { - JsonObject obj = new JsonObject(); + @Override + public JsonElement serialize(Map> src, Type typeOfSrc, JsonSerializationContext context) { + JsonObject obj = new JsonObject(); - try { - if (src != null) { - FLocation loc; - String locWorld; - Set nameSet; - Iterator iter; - JsonArray nameArray; - JsonPrimitive nameElement; + try { + if (src != null) { + FLocation loc; + String locWorld; + Set nameSet; + Iterator iter; + JsonArray nameArray; + JsonPrimitive nameElement; - for (Entry> entry : src.entrySet()) { - loc = entry.getKey(); - locWorld = loc.getWorldName(); - nameSet = entry.getValue(); + for (Entry> entry : src.entrySet()) { + loc = entry.getKey(); + locWorld = loc.getWorldName(); + nameSet = entry.getValue(); - if (nameSet == null || nameSet.isEmpty()) { - continue; - } + if (nameSet == null || nameSet.isEmpty()) { + continue; + } - nameArray = new JsonArray(); - iter = nameSet.iterator(); - while (iter.hasNext()) { - nameElement = new JsonPrimitive(iter.next()); - nameArray.add(nameElement); - } + nameArray = new JsonArray(); + iter = nameSet.iterator(); + while (iter.hasNext()) { + nameElement = new JsonPrimitive(iter.next()); + nameArray.add(nameElement); + } - if (!obj.has(locWorld)) { - obj.add(locWorld, new JsonObject()); - } + if (!obj.has(locWorld)) { + obj.add(locWorld, new JsonObject()); + } - obj.get(locWorld).getAsJsonObject().add(loc.getCoordString(), nameArray); - } - } - return obj; + obj.get(locWorld).getAsJsonObject().add(loc.getCoordString(), nameArray); + } + } + return obj; - } catch (Exception ex) { - ex.printStackTrace(); - P.p.log(Level.WARNING, "Error encountered while serializing a Map of FLocations to String Sets."); - return obj; - } - } + } catch (Exception ex) { + ex.printStackTrace(); + P.p.log(Level.WARNING, "Error encountered while serializing a Map of FLocations to String Sets."); + return obj; + } + } } diff --git a/src/main/java/com/massivecraft/factions/util/MiscUtil.java b/src/main/java/com/massivecraft/factions/util/MiscUtil.java index 3735477f..5c1ffcb0 100644 --- a/src/main/java/com/massivecraft/factions/util/MiscUtil.java +++ b/src/main/java/com/massivecraft/factions/util/MiscUtil.java @@ -18,113 +18,113 @@ import java.util.logging.Level; public class MiscUtil { - /// TODO create tag whitelist!! - public static HashSet substanceChars = - new HashSet<>(Arrays.asList("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""))); + /// TODO create tag whitelist!! + public static HashSet substanceChars = + new HashSet<>(Arrays.asList("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""))); - public static EntityType creatureTypeFromEntity(Entity entity) { - if (!(entity instanceof Creature)) { - return null; - } + public static EntityType creatureTypeFromEntity(Entity entity) { + if (!(entity instanceof Creature)) { + return null; + } - String name = entity.getClass().getSimpleName(); - name = name.substring(5); // Remove "Craft" + String name = entity.getClass().getSimpleName(); + name = name.substring(5); // Remove "Craft" - return EntityType.fromName(name); - } + return EntityType.fromName(name); + } - // Inclusive range - public static long[] range(long start, long end) { - long[] values = new long[(int) Math.abs(end - start) + 1]; + // Inclusive range + public static long[] range(long start, long end) { + long[] values = new long[(int) Math.abs(end - start) + 1]; - if (end < start) { - long oldstart = start; - start = end; - end = oldstart; - } + if (end < start) { + long oldstart = start; + start = end; + end = oldstart; + } - for (long i = start; i <= end; i++) { - values[(int) (i - start)] = i; - } + for (long i = start; i <= end; i++) { + values[(int) (i - start)] = i; + } - return values; - } + return values; + } - public static String getComparisonString(String str) { - StringBuilder ret = new StringBuilder(); + public static String getComparisonString(String str) { + StringBuilder ret = new StringBuilder(); - str = ChatColor.stripColor(str); - str = str.toLowerCase(); + str = ChatColor.stripColor(str); + str = str.toLowerCase(); - for (char c : str.toCharArray()) { - if (substanceChars.contains(String.valueOf(c))) { - ret.append(c); - } - } - return ret.toString().toLowerCase(); - } + for (char c : str.toCharArray()) { + if (substanceChars.contains(String.valueOf(c))) { + ret.append(c); + } + } + return ret.toString().toLowerCase(); + } - public static ArrayList validateTag(String str) { - ArrayList errors = new ArrayList<>(); + public static ArrayList validateTag(String str) { + ArrayList errors = new ArrayList<>(); - if (getComparisonString(str).length() < Conf.factionTagLengthMin) { - errors.add(P.p.txt.parse(TL.GENERIC_FACTIONTAG_TOOSHORT.toString(), Conf.factionTagLengthMin)); - } + if (getComparisonString(str).length() < Conf.factionTagLengthMin) { + errors.add(P.p.txt.parse(TL.GENERIC_FACTIONTAG_TOOSHORT.toString(), Conf.factionTagLengthMin)); + } - if (str.length() > Conf.factionTagLengthMax) { - errors.add(P.p.txt.parse(TL.GENERIC_FACTIONTAG_TOOLONG.toString(), Conf.factionTagLengthMax)); - } + if (str.length() > Conf.factionTagLengthMax) { + errors.add(P.p.txt.parse(TL.GENERIC_FACTIONTAG_TOOLONG.toString(), Conf.factionTagLengthMax)); + } - for (char c : str.toCharArray()) { - if (!substanceChars.contains(String.valueOf(c))) { - errors.add(P.p.txt.parse(TL.GENERIC_FACTIONTAG_ALPHANUMERIC.toString(), c)); - } - } + for (char c : str.toCharArray()) { + if (!substanceChars.contains(String.valueOf(c))) { + errors.add(P.p.txt.parse(TL.GENERIC_FACTIONTAG_ALPHANUMERIC.toString(), c)); + } + } - return errors; - } + return errors; + } - public static Iterable rankOrder(Iterable players) { - List admins = new ArrayList<>(); - List coleaders = new ArrayList<>(); - List moderators = new ArrayList<>(); - List normal = new ArrayList<>(); - List recruit = new ArrayList<>(); + public static Iterable rankOrder(Iterable players) { + List admins = new ArrayList<>(); + List coleaders = new ArrayList<>(); + List moderators = new ArrayList<>(); + List normal = new ArrayList<>(); + List recruit = new ArrayList<>(); - for (FPlayer player : players) { + for (FPlayer player : players) { - // Fix for some data being broken when we added the recruit rank. - if (player.getRole() == null) { - player.setRole(Role.NORMAL); - P.p.log(Level.WARNING, String.format("Player %s had null role. Setting them to normal. This isn't good D:", player.getName())); - } + // Fix for some data being broken when we added the recruit rank. + if (player.getRole() == null) { + player.setRole(Role.NORMAL); + P.p.log(Level.WARNING, String.format("Player %s had null role. Setting them to normal. This isn't good D:", player.getName())); + } - 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; - } - } + 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; + } + } - List ret = new ArrayList<>(); - ret.addAll(admins); - ret.addAll(coleaders); - ret.addAll(moderators); - ret.addAll(normal); - ret.addAll(recruit); - return ret; - } + List ret = new ArrayList<>(); + ret.addAll(admins); + ret.addAll(coleaders); + ret.addAll(moderators); + ret.addAll(normal); + ret.addAll(recruit); + return ret; + } } diff --git a/src/main/java/com/massivecraft/factions/util/MyLocationTypeAdapter.java b/src/main/java/com/massivecraft/factions/util/MyLocationTypeAdapter.java index 49746b2f..c68fca6b 100644 --- a/src/main/java/com/massivecraft/factions/util/MyLocationTypeAdapter.java +++ b/src/main/java/com/massivecraft/factions/util/MyLocationTypeAdapter.java @@ -9,51 +9,51 @@ import java.util.logging.Level; public class MyLocationTypeAdapter implements JsonDeserializer, JsonSerializer { - private static final String WORLD = "world"; - private static final String X = "x"; - private static final String Y = "y"; - private static final String Z = "z"; - private static final String YAW = "yaw"; - private static final String PITCH = "pitch"; + private static final String WORLD = "world"; + private static final String X = "x"; + private static final String Y = "y"; + private static final String Z = "z"; + private static final String YAW = "yaw"; + private static final String PITCH = "pitch"; - @Override - public LazyLocation deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { - try { - JsonObject obj = json.getAsJsonObject(); + @Override + public LazyLocation deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { + try { + JsonObject obj = json.getAsJsonObject(); - String worldName = obj.get(WORLD).getAsString(); - double x = obj.get(X).getAsDouble(); - double y = obj.get(Y).getAsDouble(); - double z = obj.get(Z).getAsDouble(); - float yaw = obj.get(YAW).getAsFloat(); - float pitch = obj.get(PITCH).getAsFloat(); + String worldName = obj.get(WORLD).getAsString(); + double x = obj.get(X).getAsDouble(); + double y = obj.get(Y).getAsDouble(); + double z = obj.get(Z).getAsDouble(); + float yaw = obj.get(YAW).getAsFloat(); + float pitch = obj.get(PITCH).getAsFloat(); - return new LazyLocation(worldName, x, y, z, yaw, pitch); + return new LazyLocation(worldName, x, y, z, yaw, pitch); - } catch (Exception ex) { - ex.printStackTrace(); - P.p.log(Level.WARNING, "Error encountered while deserializing a LazyLocation."); - return null; - } - } + } catch (Exception ex) { + ex.printStackTrace(); + P.p.log(Level.WARNING, "Error encountered while deserializing a LazyLocation."); + return null; + } + } - @Override - public JsonElement serialize(LazyLocation src, Type typeOfSrc, JsonSerializationContext context) { - JsonObject obj = new JsonObject(); + @Override + public JsonElement serialize(LazyLocation src, Type typeOfSrc, JsonSerializationContext context) { + JsonObject obj = new JsonObject(); - try { - obj.addProperty(WORLD, src.getWorldName()); - obj.addProperty(X, src.getX()); - obj.addProperty(Y, src.getY()); - obj.addProperty(Z, src.getZ()); - obj.addProperty(YAW, src.getYaw()); - obj.addProperty(PITCH, src.getPitch()); + try { + obj.addProperty(WORLD, src.getWorldName()); + obj.addProperty(X, src.getX()); + obj.addProperty(Y, src.getY()); + obj.addProperty(Z, src.getZ()); + obj.addProperty(YAW, src.getYaw()); + obj.addProperty(PITCH, src.getPitch()); - return obj; - } catch (Exception ex) { - ex.printStackTrace(); - P.p.log(Level.WARNING, "Error encountered while serializing a LazyLocation."); - return obj; - } - } + return obj; + } catch (Exception ex) { + ex.printStackTrace(); + P.p.log(Level.WARNING, "Error encountered while serializing a LazyLocation."); + return obj; + } + } } 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 f22c9d06..4b58026a 100644 --- a/src/main/java/com/massivecraft/factions/util/Particles/ParticleEffect.java +++ b/src/main/java/com/massivecraft/factions/util/Particles/ParticleEffect.java @@ -40,1559 +40,1559 @@ import java.util.Map.Entry; * @version 1.7 */ public enum ParticleEffect { - /** - * A particle effect which is displayed by exploding tnt and creepers: - *
    - *
  • It looks like a white cloud - *
  • The speed value influences the velocity at which the particle flies off - *
- */ - EXPLOSION_NORMAL("explode", 0, -1, ParticleProperty.DIRECTIONAL), - /** - * A particle effect which is displayed by exploding ghast fireballs and wither skulls: - *
    - *
  • It looks like a gray ball which is fading away - *
  • The speed value slightly influences the size of this particle effect - *
- */ - EXPLOSION_LARGE("largeexplode", 1, -1), - /** - * A particle effect which is displayed by exploding tnt and creepers: - *
    - *
  • It looks like a crowd of gray balls which are fading away - *
  • The speed value has no influence on this particle effect - *
- */ - EXPLOSION_HUGE("hugeexplosion", 2, -1), - /** - * A particle effect which is displayed by launching fireworks: - *
    - *
  • It looks like a white star which is sparkling - *
  • The speed value influences the velocity at which the particle flies off - *
- */ - FIREWORKS_SPARK("fireworksSpark", 3, -1, ParticleProperty.DIRECTIONAL), - /** - * A particle effect which is displayed by swimming entities and arrows in water: - *
    - *
  • It looks like a bubble - *
  • The speed value influences the velocity at which the particle flies off - *
- */ - WATER_BUBBLE("bubble", 4, -1, ParticleProperty.DIRECTIONAL, ParticleProperty.REQUIRES_WATER), - /** - * A particle effect which is displayed by swimming entities and shaking wolves: - *
    - *
  • It looks like a blue drop - *
  • The speed value has no influence on this particle effect - *
- */ - WATER_SPLASH("splash", 5, -1, ParticleProperty.DIRECTIONAL), - /** - * A particle effect which is displayed on water when fishing: - *
    - *
  • It looks like a blue droplet - *
  • The speed value influences the velocity at which the particle flies off - *
- */ - WATER_WAKE("wake", 6, 7, ParticleProperty.DIRECTIONAL), - /** - * A particle effect which is displayed by water: - *
    - *
  • It looks like a tiny blue square - *
  • The speed value has no influence on this particle effect - *
- */ - SUSPENDED("suspended", 7, -1, ParticleProperty.REQUIRES_WATER), - /** - * A particle effect which is displayed by air when close to bedrock and the in the void: - *
    - *
  • It looks like a tiny gray square - *
  • The speed value has no influence on this particle effect - *
- */ - SUSPENDED_DEPTH("depthSuspend", 8, -1, ParticleProperty.DIRECTIONAL), - /** - * A particle effect which is displayed when landing a critical hit and by arrows: - *
    - *
  • It looks like a light brown cross - *
  • The speed value influences the velocity at which the particle flies off - *
- */ - CRIT("crit", 9, -1, ParticleProperty.DIRECTIONAL), - /** - * A particle effect which is displayed when landing a hit with an enchanted weapon: - *
    - *
  • It looks like a cyan star - *
  • The speed value influences the velocity at which the particle flies off - *
- */ - 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: - *
    - *
  • It looks like a little gray cloud - *
  • The speed value influences the velocity at which the particle flies off - *
- */ - SMOKE_NORMAL("smoke", 11, -1, ParticleProperty.DIRECTIONAL), - /** - * A particle effect which is displayed by fire, minecarts with furnace and blazes: - *
    - *
  • It looks like a large gray cloud - *
  • The speed value influences the velocity at which the particle flies off - *
- */ - SMOKE_LARGE("largesmoke", 12, -1, ParticleProperty.DIRECTIONAL), - /** - * A particle effect which is displayed when splash potions or bottles o' enchanting hit something: - *
    - *
  • It looks like a white swirl - *
  • The speed value causes the particle to only move upwards when set to 0 - *
  • 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), - /** - * A particle effect which is displayed when instant splash potions hit something: - *
    - *
  • It looks like a white cross - *
  • The speed value causes the particle to only move upwards when set to 0 - *
  • 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), - /** - * A particle effect which is displayed by entities with active potion effects: - *
    - *
  • It looks like a colored swirl - *
  • The speed value causes the particle to be colored black when set to 0 - *
  • The particle color gets lighter when increasing the speed and darker when decreasing the speed - *
- */ - SPELL_MOB("mobSpell", 15, -1, ParticleProperty.COLORABLE), - /** - * A particle effect which is displayed by entities with active potion effects applied through a beacon: - *
    - *
  • It looks like a transparent colored swirl - *
  • The speed value causes the particle to be always colored black when set to 0 - *
  • The particle color gets lighter when increasing the speed and darker when decreasing the speed - *
- */ - SPELL_MOB_AMBIENT("mobSpellAmbient", 16, -1, ParticleProperty.COLORABLE), - /** - * A particle effect which is displayed by witches: - *
    - *
  • It looks like a purple cross - *
  • The speed value causes the particle to only move upwards when set to 0 - *
  • 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), - /** - * A particle effect which is displayed by blocks beneath a water source: - *
    - *
  • It looks like a blue drip - *
  • The speed value has no influence on this particle effect - *
- */ - DRIP_WATER("dripWater", 18, -1), - /** - * A particle effect which is displayed by blocks beneath a lava source: - *
    - *
  • It looks like an orange drip - *
  • The speed value has no influence on this particle effect - *
- */ - DRIP_LAVA("dripLava", 19, -1), - /** - * A particle effect which is displayed when attacking a villager in a village: - *
    - *
  • It looks like a cracked gray heart - *
  • The speed value has no influence on this particle effect - *
- */ - VILLAGER_ANGRY("angryVillager", 20, -1), - /** - * A particle effect which is displayed when using bone meal and trading with a villager in a village: - *
    - *
  • It looks like a green star - *
  • The speed value has no influence on this particle effect - *
- */ - VILLAGER_HAPPY("happyVillager", 21, -1, ParticleProperty.DIRECTIONAL), - /** - * A particle effect which is displayed by mycelium: - *
    - *
  • It looks like a tiny gray square - *
  • The speed value has no influence on this particle effect - *
- */ - TOWN_AURA("townaura", 22, -1, ParticleProperty.DIRECTIONAL), - /** - * A particle effect which is displayed by note blocks: - *
    - *
  • It looks like a colored note - *
  • The speed value causes the particle to be colored green when set to 0 - *
- */ - 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: - *
    - *
  • It looks like a purple cloud - *
  • The speed value influences the spread of this particle effect - *
- */ - PORTAL("portal", 24, -1, ParticleProperty.DIRECTIONAL), - /** - * A particle effect which is displayed by enchantment tables which are nearby bookshelves: - *
    - *
  • It looks like a cryptic white letter - *
  • The speed value influences the spread of this particle effect - *
- */ - ENCHANTMENT_TABLE("enchantmenttable", 25, -1, ParticleProperty.DIRECTIONAL), - /** - * A particle effect which is displayed by torches, active furnaces, magma cubes and monster spawners: - *
    - *
  • It looks like a tiny flame - *
  • The speed value influences the velocity at which the particle flies off - *
- */ - FLAME("flame", 26, -1, ParticleProperty.DIRECTIONAL), - /** - * A particle effect which is displayed by lava: - *
    - *
  • It looks like a spark - *
  • The speed value has no influence on this particle effect - *
- */ - LAVA("lava", 27, -1), - /** - * A particle effect which is currently unused: - *
    - *
  • It looks like a transparent gray square - *
  • The speed value has no influence on this particle effect - *
- */ - FOOTSTEP("footstep", 28, -1), - /** - * A particle effect which is displayed when a mob dies: - *
    - *
  • It looks like a large white cloud - *
  • The speed value influences the velocity at which the particle flies off - *
- */ - CLOUD("cloud", 29, -1, ParticleProperty.DIRECTIONAL), - /** - * A particle effect which is displayed by redstone ore, powered redstone, redstone torches and redstone repeaters: - *
    - *
  • It looks like a tiny colored cloud - *
  • The speed value causes the particle to be colored red when set to 0 - *
- */ - REDSTONE("reddust", 30, -1, ParticleProperty.COLORABLE), - /** - * A particle effect which is displayed when snowballs hit a block: - *
    - *
  • It looks like a little piece with the snowball texture - *
  • The speed value has no influence on this particle effect - *
- */ - SNOWBALL("snowballpoof", 31, -1), - /** - * A particle effect which is currently unused: - *
    - *
  • It looks like a tiny white cloud - *
  • The speed value influences the velocity at which the particle flies off - *
- */ - SNOW_SHOVEL("snowshovel", 32, -1, ParticleProperty.DIRECTIONAL), - /** - * A particle effect which is displayed by slimes: - *
    - *
  • It looks like a tiny part of the slimeball icon - *
  • The speed value has no influence on this particle effect - *
- */ - SLIME("slime", 33, -1), - /** - * A particle effect which is displayed when breeding and taming animals: - *
    - *
  • It looks like a red heart - *
  • The speed value has no influence on this particle effect - *
- */ - HEART("heart", 34, -1), - /** - * A particle effect which is displayed by barriers: - *
    - *
  • It looks like a red box with a slash through it - *
  • The speed value has no influence on this particle effect - *
- */ - BARRIER("barrier", 35, 8), - /** - * A particle effect which is displayed when breaking a tool or eggs hit a block: - *
    - *
  • It looks like a little piece with an item texture - *
- */ - ITEM_CRACK("iconcrack", 36, -1, ParticleProperty.DIRECTIONAL, ParticleProperty.REQUIRES_DATA), - /** - * A particle effect which is displayed when breaking blocks or sprinting: - *
    - *
  • It looks like a little piece with a block texture - *
  • The speed value has no influence on this particle effect - *
- */ - BLOCK_CRACK("blockcrack", 37, -1, ParticleProperty.REQUIRES_DATA), - /** - * A particle effect which is displayed when falling: - *
    - *
  • It looks like a little piece with a block texture - *
- */ - BLOCK_DUST("blockdust", 38, 7, ParticleProperty.DIRECTIONAL, ParticleProperty.REQUIRES_DATA), - /** - * A particle effect which is displayed when rain hits the ground: - *
    - *
  • It looks like a blue droplet - *
  • The speed value has no influence on this particle effect - *
- */ - WATER_DROP("droplet", 39, 8), - /** - * A particle effect which is currently unused: - *
    - *
  • It has no visual effect - *
- */ - ITEM_TAKE("take", 40, 8), - /** - * A particle effect which is displayed by elder guardians: - *
    - *
  • It looks like the shape of the elder guardian - *
  • The speed value has no influence on this particle effect - *
  • The offset values have no influence on this particle effect - *
- */ - MOB_APPEARANCE("mobappearance", 41, 8); - - private static final Map NAME_MAP = new HashMap(); - private static final Map ID_MAP = new HashMap(); - - // Initialize map for quick name and id lookup - static { - for (ParticleEffect effect : values()) { - NAME_MAP.put(effect.name, effect); - ID_MAP.put(effect.id, effect); - } - } - - private final String name; - private final int id; - private final int requiredVersion; - private final List properties; - - /** - * Construct a new particle effect - * - * @param name Name of this particle effect - * @param id Id of this particle effect - * @param requiredVersion Version which is required (1.x) - * @param properties Properties of this particle effect - */ - ParticleEffect(String name, int id, int requiredVersion, ParticleProperty... properties) { - this.name = name; - this.id = id; - this.requiredVersion = requiredVersion; - this.properties = Arrays.asList(properties); - } - - /** - * Returns the particle effect with the given name - * - * @param name Name of the particle effect - * @return The particle effect - */ - public static ParticleEffect fromName(String name) { - for (Entry entry : NAME_MAP.entrySet()) { - if (!entry.getKey().equalsIgnoreCase(name)) { - continue; - } - return entry.getValue(); - } - return null; - } - - /** - * Returns the particle effect with the given id - * - * @param id Id of the particle effect - * @return The particle effect - */ - public static ParticleEffect fromId(int id) { - for (Entry entry : ID_MAP.entrySet()) { - if (entry.getKey() != id) { - continue; - } - return entry.getValue(); - } - return null; - } - - /** - * Determine if water is at a certain location - * - * @param location Location to check - * @return Whether water is at this location or not - */ - private static boolean isWater(Location location) { - Material material = location.getBlock().getType(); - return material == Material.WATER || material == XMaterial.WATER.parseMaterial(); - } - - /** - * Determine if the distance between @param location and one of the players exceeds 256 - * - * @param location Location to check - * @return Whether the distance exceeds 256 or not - */ - private static boolean isLongDistance(Location location, List players) { - String world = location.getWorld().getName(); - for (Player player : players) { - Location playerLocation = player.getLocation(); - if (!world.equals(playerLocation.getWorld().getName()) || playerLocation.distanceSquared(location) < 65536) { - continue; - } - return true; - } - return false; - } - - /** - * Determine if the data type for a particle effect is correct - * - * @param effect Particle effect - * @param data Particle data - * @return Whether the data type is correct or not - */ - private static boolean isDataCorrect(ParticleEffect effect, ParticleData data) { - return ((effect == BLOCK_CRACK || effect == BLOCK_DUST) && data instanceof BlockData) || (effect == ITEM_CRACK && data instanceof ItemData); - } - - /** - * Determine if the color type for a particle effect is correct - * - * @param effect Particle effect - * @param color Particle color - * @return Whether the color type is correct or not - */ - private static boolean isColorCorrect(ParticleEffect effect, ParticleColor color) { - return ((effect == SPELL_MOB || effect == SPELL_MOB_AMBIENT || effect == REDSTONE) && color instanceof OrdinaryColor) || (effect == NOTE && color instanceof NoteColor); - } - - /** - * Returns the name of this particle effect - * - * @return The name - */ - public String getName() { - return name; - } - - /** - * Returns the id of this particle effect - * - * @return The id - */ - public int getId() { - return id; - } - - /** - * Returns the required version for this particle effect (1.x) - * - * @return The required version - */ - public int getRequiredVersion() { - return requiredVersion; - } - - /** - * Determine if this particle effect has a specific property - * - * @param property - property to check. - * @return Whether it has the property or not - */ - public boolean hasProperty(ParticleProperty property) { - return properties.contains(property); - } - - /** - * Determine if this particle effect is supported by your current server version - * - * @return Whether the particle effect is supported or not - */ - public boolean isSupported() { - if (requiredVersion == -1) { - return true; - } - return ParticlePacket.getVersion() >= requiredVersion; - } - - /** - * Displays a particle effect which is only visible for all players within a certain range in the world of @param center - * - * @param offsetX Maximum distance particles can fly away from the center on the x-axis - * @param offsetY Maximum distance particles can fly away from the center on the y-axis - * @param offsetZ Maximum distance particles can fly away from the center on the z-axis - * @param speed Display speed of the particles - * @param amount Amount of particles - * @param center Center location of the effect - * @param range Range of the visibility - * @throws ParticleVersionException If the particle effect is not supported by the server version - * @throws ParticleDataException If the particle effect requires additional data - * @throws IllegalArgumentException If the particle effect requires water and none is at the center location - * @see ParticlePacket - * @see ParticlePacket#sendTo(Location, double) - */ - public void display(float offsetX, float offsetY, float offsetZ, float speed, int amount, Location center, double range) throws ParticleVersionException, ParticleDataException, IllegalArgumentException { - if (!isSupported()) { - throw new ParticleVersionException("This particle effect is not supported by your server version"); - } - if (hasProperty(ParticleProperty.REQUIRES_DATA)) { - throw new ParticleDataException("This particle effect requires additional data"); - } - if (hasProperty(ParticleProperty.REQUIRES_WATER) && !isWater(center)) { - throw new IllegalArgumentException("There is no water at the center location"); - } - new ParticlePacket(this, offsetX, offsetY, offsetZ, speed, amount, range > 256, null).sendTo(center, range); - } - - /** - * Displays a particle effect which is only visible for the specified players - * - * @param offsetX Maximum distance particles can fly away from the center on the x-axis - * @param offsetY Maximum distance particles can fly away from the center on the y-axis - * @param offsetZ Maximum distance particles can fly away from the center on the z-axis - * @param speed Display speed of the particles - * @param amount Amount of particles - * @param center Center location of the effect - * @param players Receivers of the effect - * @throws ParticleVersionException If the particle effect is not supported by the server version - * @throws ParticleDataException If the particle effect requires additional data - * @throws IllegalArgumentException If the particle effect requires water and none is at the center location - * @see ParticlePacket - * @see ParticlePacket#sendTo(Location, List) - */ - public void display(float offsetX, float offsetY, float offsetZ, float speed, int amount, Location center, List players) throws ParticleVersionException, ParticleDataException, IllegalArgumentException { - if (!isSupported()) { - throw new ParticleVersionException("This particle effect is not supported by your server version"); - } - if (hasProperty(ParticleProperty.REQUIRES_DATA)) { - throw new ParticleDataException("This particle effect requires additional data"); - } - if (hasProperty(ParticleProperty.REQUIRES_WATER) && !isWater(center)) { - throw new IllegalArgumentException("There is no water at the center location"); - } - new ParticlePacket(this, offsetX, offsetY, offsetZ, speed, amount, isLongDistance(center, players), null).sendTo(center, players); - } - - /** - * Displays a particle effect which is only visible for the specified players - * - * @param offsetX Maximum distance particles can fly away from the center on the x-axis - * @param offsetY Maximum distance particles can fly away from the center on the y-axis - * @param offsetZ Maximum distance particles can fly away from the center on the z-axis - * @param speed Display speed of the particles - * @param amount Amount of particles - * @param center Center location of the effect - * @param players Receivers of the effect - * @throws ParticleVersionException If the particle effect is not supported by the server version - * @throws ParticleDataException If the particle effect requires additional data - * @throws IllegalArgumentException If the particle effect requires water and none is at the center location - * @see #display(float, float, float, float, int, Location, List) - */ - public void display(float offsetX, float offsetY, float offsetZ, float speed, int amount, Location center, Player... players) throws ParticleVersionException, ParticleDataException, IllegalArgumentException { - display(offsetX, offsetY, offsetZ, speed, amount, center, Arrays.asList(players)); - } - - /** - * Displays a single particle which flies into a determined direction and is only visible for all players within a certain range in the world of @param center - * - * @param direction Direction of the particle - * @param speed Display speed of the particle - * @param center Center location of the effect - * @param range Range of the visibility - * @throws ParticleVersionException If the particle effect is not supported by the server version - * @throws ParticleDataException If the particle effect requires additional data - * @throws IllegalArgumentException If the particle effect is not directional or if it requires water and none is at the center location - * @see ParticlePacket#ParticlePacket(ParticleEffect, Vector, float, boolean, ParticleData) - * @see ParticlePacket#sendTo(Location, double) - */ - public void display(Vector direction, float speed, Location center, double range) throws ParticleVersionException, ParticleDataException, IllegalArgumentException { - if (!isSupported()) { - throw new ParticleVersionException("This particle effect is not supported by your server version"); - } - if (hasProperty(ParticleProperty.REQUIRES_DATA)) { - throw new ParticleDataException("This particle effect requires additional data"); - } - if (!hasProperty(ParticleProperty.DIRECTIONAL)) { - throw new IllegalArgumentException("This particle effect is not directional"); - } - if (hasProperty(ParticleProperty.REQUIRES_WATER) && !isWater(center)) { - throw new IllegalArgumentException("There is no water at the center location"); - } - new ParticlePacket(this, direction, speed, range > 256, null).sendTo(center, range); - } - - /** - * Displays a single particle which flies into a determined direction and is only visible for the specified players - * - * @param direction Direction of the particle - * @param speed Display speed of the particle - * @param center Center location of the effect - * @param players Receivers of the effect - * @throws ParticleVersionException If the particle effect is not supported by the server version - * @throws ParticleDataException If the particle effect requires additional data - * @throws IllegalArgumentException If the particle effect is not directional or if it requires water and none is at the center location - * @see ParticlePacket#ParticlePacket(ParticleEffect, Vector, float, boolean, ParticleData) - * @see ParticlePacket#sendTo(Location, List) - */ - public void display(Vector direction, float speed, Location center, List players) throws ParticleVersionException, ParticleDataException, IllegalArgumentException { - if (!isSupported()) { - throw new ParticleVersionException("This particle effect is not supported by your server version"); - } - if (hasProperty(ParticleProperty.REQUIRES_DATA)) { - throw new ParticleDataException("This particle effect requires additional data"); - } - if (!hasProperty(ParticleProperty.DIRECTIONAL)) { - throw new IllegalArgumentException("This particle effect is not directional"); - } - if (hasProperty(ParticleProperty.REQUIRES_WATER) && !isWater(center)) { - throw new IllegalArgumentException("There is no water at the center location"); - } - new ParticlePacket(this, direction, speed, isLongDistance(center, players), null).sendTo(center, players); - } - - /** - * Displays a single particle which flies into a determined direction and is only visible for the specified players - * - * @param direction Direction of the particle - * @param speed Display speed of the particle - * @param center Center location of the effect - * @param players Receivers of the effect - * @throws ParticleVersionException If the particle effect is not supported by the server version - * @throws ParticleDataException If the particle effect requires additional data - * @throws IllegalArgumentException If the particle effect is not directional or if it requires water and none is at the center location - * @see #display(Vector, float, Location, List) - */ - public void display(Vector direction, float speed, Location center, Player... players) throws ParticleVersionException, ParticleDataException, IllegalArgumentException { - display(direction, speed, center, Arrays.asList(players)); - } - - /** - * Displays a single particle which is colored and only visible for all players within a certain range in the world of @param center - * - * @param color Color of the particle - * @param center Center location of the effect - * @param range Range of the visibility - * @throws ParticleVersionException If the particle effect is not supported by the server version - * @throws ParticleColorException If the particle effect is not colorable or the color type is incorrect - * @see ParticlePacket#ParticlePacket(ParticleEffect, ParticleColor, boolean) - * @see ParticlePacket#sendTo(Location, double) - */ - public void display(ParticleColor color, Location center, double range) throws ParticleVersionException, ParticleColorException { - if (!isSupported()) { - throw new ParticleVersionException("This particle effect is not supported by your server version"); - } - if (!hasProperty(ParticleProperty.COLORABLE)) { - throw new ParticleColorException("This particle effect is not colorable"); - } - if (!isColorCorrect(this, color)) { - throw new ParticleColorException("The particle color type is incorrect"); - } - new ParticlePacket(this, color, range > 256).sendTo(center, range); - } - - /** - * Displays a single particle which is colored and only visible for the specified players - * - * @param color Color of the particle - * @param center Center location of the effect - * @param players Receivers of the effect - * @throws ParticleVersionException If the particle effect is not supported by the server version - * @throws ParticleColorException If the particle effect is not colorable or the color type is incorrect - * @see ParticlePacket#ParticlePacket(ParticleEffect, ParticleColor, boolean) - * @see ParticlePacket#sendTo(Location, List) - */ - public void display(ParticleColor color, Location center, List players) throws ParticleVersionException, ParticleColorException { - if (!isSupported()) { - throw new ParticleVersionException("This particle effect is not supported by your server version"); - } - if (!hasProperty(ParticleProperty.COLORABLE)) { - throw new ParticleColorException("This particle effect is not colorable"); - } - if (!isColorCorrect(this, color)) { - throw new ParticleColorException("The particle color type is incorrect"); - } - new ParticlePacket(this, color, isLongDistance(center, players)).sendTo(center, players); - } - - /** - * Displays a single particle which is colored and only visible for the specified players - * - * @param color Color of the particle - * @param center Center location of the effect - * @param players Receivers of the effect - * @throws ParticleVersionException If the particle effect is not supported by the server version - * @throws ParticleColorException If the particle effect is not colorable or the color type is incorrect - * @see #display(ParticleColor, Location, List) - */ - public void display(ParticleColor color, Location center, Player... players) throws ParticleVersionException, ParticleColorException { - display(color, center, Arrays.asList(players)); - } - - /** - * Displays a particle effect which requires additional data and is only visible for all players within a certain range in the world of @param center - * - * @param data Data of the effect - * @param offsetX Maximum distance particles can fly away from the center on the x-axis - * @param offsetY Maximum distance particles can fly away from the center on the y-axis - * @param offsetZ Maximum distance particles can fly away from the center on the z-axis - * @param speed Display speed of the particles - * @param amount Amount of particles - * @param center Center location of the effect - * @param range Range of the visibility - * @throws ParticleVersionException If the particle effect is not supported by the server version - * @throws ParticleDataException If the particle effect does not require additional data or if the data type is incorrect - * @see ParticlePacket - * @see ParticlePacket#sendTo(Location, double) - */ - public void display(ParticleData data, float offsetX, float offsetY, float offsetZ, float speed, int amount, Location center, double range) throws ParticleVersionException, ParticleDataException { - if (!isSupported()) { - throw new ParticleVersionException("This particle effect is not supported by your server version"); - } - if (!hasProperty(ParticleProperty.REQUIRES_DATA)) { - throw new ParticleDataException("This particle effect does not require additional data"); - } - if (!isDataCorrect(this, data)) { - throw new ParticleDataException("The particle data type is incorrect"); - } - new ParticlePacket(this, offsetX, offsetY, offsetZ, speed, amount, range > 256, data).sendTo(center, range); - } - - /** - * Displays a particle effect which requires additional data and is only visible for the specified players - * - * @param data Data of the effect - * @param offsetX Maximum distance particles can fly away from the center on the x-axis - * @param offsetY Maximum distance particles can fly away from the center on the y-axis - * @param offsetZ Maximum distance particles can fly away from the center on the z-axis - * @param speed Display speed of the particles - * @param amount Amount of particles - * @param center Center location of the effect - * @param players Receivers of the effect - * @throws ParticleVersionException If the particle effect is not supported by the server version - * @throws ParticleDataException If the particle effect does not require additional data or if the data type is incorrect - * @see ParticlePacket - * @see ParticlePacket#sendTo(Location, List) - */ - public void display(ParticleData data, float offsetX, float offsetY, float offsetZ, float speed, int amount, Location center, List players) throws ParticleVersionException, ParticleDataException { - if (!isSupported()) { - throw new ParticleVersionException("This particle effect is not supported by your server version"); - } - if (!hasProperty(ParticleProperty.REQUIRES_DATA)) { - throw new ParticleDataException("This particle effect does not require additional data"); - } - if (!isDataCorrect(this, data)) { - throw new ParticleDataException("The particle data type is incorrect"); - } - new ParticlePacket(this, offsetX, offsetY, offsetZ, speed, amount, isLongDistance(center, players), data).sendTo(center, players); - } - - /** - * Displays a particle effect which requires additional data and is only visible for the specified players - * - * @param data Data of the effect - * @param offsetX Maximum distance particles can fly away from the center on the x-axis - * @param offsetY Maximum distance particles can fly away from the center on the y-axis - * @param offsetZ Maximum distance particles can fly away from the center on the z-axis - * @param speed Display speed of the particles - * @param amount Amount of particles - * @param center Center location of the effect - * @param players Receivers of the effect - * @throws ParticleVersionException If the particle effect is not supported by the server version - * @throws ParticleDataException If the particle effect does not require additional data or if the data type is incorrect - * @see #display(ParticleData, float, float, float, float, int, Location, List) - */ - public void display(ParticleData data, float offsetX, float offsetY, float offsetZ, float speed, int amount, Location center, Player... players) throws ParticleVersionException, ParticleDataException { - display(data, offsetX, offsetY, offsetZ, speed, amount, center, Arrays.asList(players)); - } - - /** - * Displays a single particle which requires additional data that flies into a determined direction and is only visible for all players within a certain range in the world of @param center - * - * @param data Data of the effect - * @param direction Direction of the particle - * @param speed Display speed of the particles - * @param center Center location of the effect - * @param range Range of the visibility - * @throws ParticleVersionException If the particle effect is not supported by the server version - * @throws ParticleDataException If the particle effect does not require additional data or if the data type is incorrect - * @see ParticlePacket - * @see ParticlePacket#sendTo(Location, double) - */ - public void display(ParticleData data, Vector direction, float speed, Location center, double range) throws ParticleVersionException, ParticleDataException { - if (!isSupported()) { - throw new ParticleVersionException("This particle effect is not supported by your server version"); - } - if (!hasProperty(ParticleProperty.REQUIRES_DATA)) { - throw new ParticleDataException("This particle effect does not require additional data"); - } - if (!isDataCorrect(this, data)) { - throw new ParticleDataException("The particle data type is incorrect"); - } - new ParticlePacket(this, direction, speed, range > 256, data).sendTo(center, range); - } - - /** - * Displays a single particle which requires additional data that flies into a determined direction and is only visible for the specified players - * - * @param data Data of the effect - * @param direction Direction of the particle - * @param speed Display speed of the particles - * @param center Center location of the effect - * @param players Receivers of the effect - * @throws ParticleVersionException If the particle effect is not supported by the server version - * @throws ParticleDataException If the particle effect does not require additional data or if the data type is incorrect - * @see ParticlePacket - * @see ParticlePacket#sendTo(Location, List) - */ - public void display(ParticleData data, Vector direction, float speed, Location center, List players) throws ParticleVersionException, ParticleDataException { - if (!isSupported()) { - throw new ParticleVersionException("This particle effect is not supported by your server version"); - } - if (!hasProperty(ParticleProperty.REQUIRES_DATA)) { - throw new ParticleDataException("This particle effect does not require additional data"); - } - if (!isDataCorrect(this, data)) { - throw new ParticleDataException("The particle data type is incorrect"); - } - new ParticlePacket(this, direction, speed, isLongDistance(center, players), data).sendTo(center, players); - } - - /** - * Displays a single particle which requires additional data that flies into a determined direction and is only visible for the specified players - * - * @param data Data of the effect - * @param direction Direction of the particle - * @param speed Display speed of the particles - * @param center Center location of the effect - * @param players Receivers of the effect - * @throws ParticleVersionException If the particle effect is not supported by the server version - * @throws ParticleDataException If the particle effect does not require additional data or if the data type is incorrect - * @see #display(ParticleData, Vector, float, Location, List) - */ - public void display(ParticleData data, Vector direction, float speed, Location center, Player... players) throws ParticleVersionException, ParticleDataException { - display(data, direction, speed, center, Arrays.asList(players)); - } - - /** - * Represents the property of a particle effect - * This class is part of the ParticleEffect Library and follows the same usage conditions - * - * @author DarkBlade12 - * @since 1.7 - */ - public enum ParticleProperty { - /** - * The particle effect requires water to be displayed - */ - REQUIRES_WATER, - /** - * The particle effect requires block or item data to be displayed - */ - REQUIRES_DATA, - /** - * The particle effect uses the offsets as direction values - */ - DIRECTIONAL, - /** - * The particle effect uses the offsets as color values - */ - COLORABLE - } - - /** - * Represents the particle data for effects like {@link ParticleEffect#ITEM_CRACK}, {@link ParticleEffect#BLOCK_CRACK} and {@link ParticleEffect#BLOCK_DUST} - * This class is part of the ParticleEffect Library and follows the same usage conditions - * - * @author DarkBlade12 - * @since 1.6 - */ - public static abstract class ParticleData { - private final Material material; - private final byte data; - private final int[] packetData; - - /** - * Construct a new particle data - * - * @param material Material of the item/block - * @param data Data value of the item/block - */ - @SuppressWarnings("deprecation") - public ParticleData(Material material, byte data) { - this.material = material; - this.data = data; - this.packetData = new int[]{material.getId(), data}; - } - - /** - * Returns the material of this data - * - * @return The material - */ - public Material getMaterial() { - return material; - } - - /** - * Returns the data value of this data - * - * @return The data value - */ - public byte getData() { - return data; - } - - /** - * Returns the data as an int array for packet construction - * - * @return The data for the packet - */ - public int[] getPacketData() { - return packetData; - } - - /** - * Returns the data as a string for pre 1.8 versions - * - * @return The data string for the packet - */ - public String getPacketDataString() { - return "_" + packetData[0] + "_" + packetData[1]; - } - } - - /** - * Represents the item data for the {@link ParticleEffect#ITEM_CRACK} effect - * This class is part of the ParticleEffect Library and follows the same usage conditions - * - * @author DarkBlade12 - * @since 1.6 - */ - public static final class ItemData extends ParticleData { - /** - * Construct a new item data - * - * @param material Material of the item - * @param data Data value of the item - * @see ParticleData#ParticleData(Material, byte) - */ - public ItemData(Material material, byte data) { - super(material, data); - } - } - - /** - * Represents the block data for the {@link ParticleEffect#BLOCK_CRACK} and {@link ParticleEffect#BLOCK_DUST} effects - * This class is part of the ParticleEffect Library and follows the same usage conditions - * - * @author DarkBlade12 - * @since 1.6 - */ - public static final class BlockData extends ParticleData { - /** - * Construct a new block data - * - * @param material Material of the block - * @param data Data value of the block - * @throws IllegalArgumentException If the material is not a block - * @see ParticleData#ParticleData(Material, byte) - */ - public BlockData(Material material, byte data) throws IllegalArgumentException { - super(material, data); - if (!material.isBlock()) { - throw new IllegalArgumentException("The material is not a block"); - } - } - } - - /** - * Represents the color for effects like {@link ParticleEffect#SPELL_MOB}, {@link ParticleEffect#SPELL_MOB_AMBIENT}, {@link ParticleEffect#REDSTONE} and {@link ParticleEffect#NOTE} - * This class is part of the ParticleEffect Library and follows the same usage conditions - * - * @author DarkBlade12 - * @since 1.7 - */ - public static abstract class ParticleColor { - /** - * Returns the value for the offsetX field - * - * @return The offsetX value - */ - public abstract float getValueX(); - - /** - * Returns the value for the offsetY field - * - * @return The offsetY value - */ - public abstract float getValueY(); - - /** - * Returns the value for the offsetZ field - * - * @return The offsetZ value - */ - public abstract float getValueZ(); - } - - /** - * Represents the color for effects like {@link ParticleEffect#SPELL_MOB}, {@link ParticleEffect#SPELL_MOB_AMBIENT} and {@link ParticleEffect#NOTE} - * This class is part of the ParticleEffect Library and follows the same usage conditions - * - * @author DarkBlade12 - * @since 1.7 - */ - public static final class OrdinaryColor extends ParticleColor { - private final int red; - private final int green; - private final int blue; - - /** - * Construct a new ordinary color - * - * @param red Red value of the RGB format - * @param green Green value of the RGB format - * @param blue Blue value of the RGB format - * @throws IllegalArgumentException If one of the values is lower than 0 or higher than 255 - */ - public OrdinaryColor(int red, int green, int blue) throws IllegalArgumentException { - if (red < 0) { - throw new IllegalArgumentException("The red value is lower than 0"); - } - if (red > 255) { - throw new IllegalArgumentException("The red value is higher than 255"); - } - this.red = red; - if (green < 0) { - throw new IllegalArgumentException("The green value is lower than 0"); - } - if (green > 255) { - throw new IllegalArgumentException("The green value is higher than 255"); - } - this.green = green; - if (blue < 0) { - throw new IllegalArgumentException("The blue value is lower than 0"); - } - if (blue > 255) { - throw new IllegalArgumentException("The blue value is higher than 255"); - } - this.blue = blue; - } - - /** - * Construct a new ordinary color - * - * @param color Bukkit color - */ - public OrdinaryColor(Color color) { - this(color.getRed(), color.getGreen(), color.getBlue()); - } - - /** - * Returns the red value of the RGB format - * - * @return The red value - */ - public int getRed() { - return red; - } - - /** - * Returns the green value of the RGB format - * - * @return The green value - */ - public int getGreen() { - return green; - } - - /** - * Returns the blue value of the RGB format - * - * @return The blue value - */ - public int getBlue() { - return blue; - } - - /** - * Returns the red value divided by 255 - * - * @return The offsetX value - */ - @Override - public float getValueX() { - return (float) red / 255F; - } - - /** - * Returns the green value divided by 255 - * - * @return The offsetY value - */ - @Override - public float getValueY() { - return (float) green / 255F; - } - - /** - * Returns the blue value divided by 255 - * - * @return The offsetZ value - */ - @Override - public float getValueZ() { - return (float) blue / 255F; - } - } - - /** - * 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 - * @since 1.7 - */ - public static final class NoteColor extends ParticleColor { - private final int note; - - /** - * Construct a new note color - * - * @param note Note id which determines color - * @throws IllegalArgumentException If the note value is lower than 0 or higher than 24 - */ - public NoteColor(int note) throws IllegalArgumentException { - if (note < 0) { - throw new IllegalArgumentException("The note value is lower than 0"); - } - if (note > 24) { - throw new IllegalArgumentException("The note value is higher than 24"); - } - this.note = note; - } - - /** - * Returns the note value divided by 24 - * - * @return The offsetX value - */ - @Override - public float getValueX() { - return (float) note / 24F; - } - - /** - * Returns zero because the offsetY value is unused - * - * @return zero - */ - @Override - public float getValueY() { - return 0; - } - - /** - * Returns zero because the offsetZ value is unused - * - * @return zero - */ - @Override - public float getValueZ() { - return 0; - } - - } - - /** - * 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 - * @since 1.6 - */ - private static final class ParticleDataException extends RuntimeException { - private static final long serialVersionUID = 3203085387160737484L; - - /** - * Construct a new particle data exception - * - * @param message Message that will be logged - */ - public ParticleDataException(String message) { - super(message); - } - } - - /** - * 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 - * @since 1.7 - */ - private static final class ParticleColorException extends RuntimeException { - private static final long serialVersionUID = 3203085387160737484L; - - /** - * Construct a new particle color exception - * - * @param message Message that will be logged - */ - public ParticleColorException(String message) { - super(message); - } - } - - /** - * 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 - * @since 1.6 - */ - private static final class ParticleVersionException extends RuntimeException { - private static final long serialVersionUID = 3203085387160737484L; - - /** - * Construct a new particle version exception - * - * @param message Message that will be logged - */ - public ParticleVersionException(String message) { - super(message); - } - } - - /** - * 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 - * @since 1.5 - */ - public static final class ParticlePacket { - private static int version; - private static Class enumParticle; - private static Constructor packetConstructor; - private static Method getHandle; - private static Field playerConnection; - private static Method sendPacket; - private static boolean initialized; - private final ParticleEffect effect; - private final float offsetY; - private final float offsetZ; - private final float speed; - private final int amount; - private final boolean longDistance; - private final ParticleData data; - private float offsetX; - private Object packet; - - /** - * Construct a new particle packet - * - * @param effect Particle effect - * @param offsetX Maximum distance particles can fly away from the center on the x-axis - * @param offsetY Maximum distance particles can fly away from the center on the y-axis - * @param offsetZ Maximum distance particles can fly away from the center on the z-axis - * @param speed Display speed of the particles - * @param amount Amount of particles - * @param longDistance Indicates whether the maximum distance is increased from 256 to 65536 - * @param data Data of the effect - * @throws IllegalArgumentException If the speed or amount is lower than 0 - * @see #initialize() - */ - public ParticlePacket(ParticleEffect effect, float offsetX, float offsetY, float offsetZ, float speed, int amount, boolean longDistance, ParticleData data) throws IllegalArgumentException { - initialize(); - if (speed < 0) { - throw new IllegalArgumentException("The speed is lower than 0"); - } - if (amount < 0) { - throw new IllegalArgumentException("The amount is lower than 0"); - } - this.effect = effect; - this.offsetX = offsetX; - this.offsetY = offsetY; - this.offsetZ = offsetZ; - this.speed = speed; - this.amount = amount; - this.longDistance = longDistance; - this.data = data; - } - - /** - * Construct a new particle packet of a single particle flying into a determined direction - * - * @param effect Particle effect - * @param direction Direction of the particle - * @param speed Display speed of the particle - * @param longDistance Indicates whether the maximum distance is increased from 256 to 65536 - * @param data Data of the effect - * @throws IllegalArgumentException If the speed is lower than 0 - */ - public ParticlePacket(ParticleEffect effect, Vector direction, float speed, boolean longDistance, ParticleData data) throws IllegalArgumentException { - this(effect, (float) direction.getX(), (float) direction.getY(), (float) direction.getZ(), speed, 0, longDistance, data); - } - - /** - * Construct a new particle packet of a single colored particle - * - * @param effect Particle effect - * @param color Color of the particle - * @param longDistance Indicates whether the maximum distance is increased from 256 to 65536 - */ - public ParticlePacket(ParticleEffect effect, ParticleColor color, boolean longDistance) { - this(effect, color.getValueX(), color.getValueY(), color.getValueZ(), 1, 0, longDistance, null); - if (effect == ParticleEffect.REDSTONE && color instanceof OrdinaryColor && ((OrdinaryColor) color).getRed() == 0) { - offsetX = Float.MIN_NORMAL; - } - } - - /** - * 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 - */ - public static void initialize() throws VersionIncompatibleException { - if (initialized) { - return; - } - try { - version = Integer.parseInt(ReflectionUtils.PackageType.getServerVersion().split("_")[1]); - if (version > 7) { - enumParticle = ReflectionUtils.PackageType.MINECRAFT_SERVER.getClass("EnumParticle"); - } - - Class packetClass = ReflectionUtils.PackageType.MINECRAFT_SERVER.getClass(version < 7 ? "Packet63WorldParticles" : "PacketPlayOutWorldParticles"); - - packetConstructor = ReflectionUtils.getConstructor(packetClass); - getHandle = ReflectionUtils.getMethod("CraftPlayer", ReflectionUtils.PackageType.CRAFTBUKKIT_ENTITY, "getHandle"); - playerConnection = ReflectionUtils.getField("EntityPlayer", ReflectionUtils.PackageType.MINECRAFT_SERVER, false, "playerConnection"); - sendPacket = ReflectionUtils.getMethod(playerConnection.getType(), "sendPacket", ReflectionUtils.PackageType.MINECRAFT_SERVER.getClass("Packet")); - } catch (Exception exception) { - throw new VersionIncompatibleException("Your current bukkit version seems to be incompatible with this library", exception); - } - initialized = true; - } - - /** - * Returns the version of your server (1.x) - * - * @return The version number - */ - public static int getVersion() { - if (!initialized) { - initialize(); - } - return version; - } - - /** - * Determine if {@link #packetConstructor}, {@link #getHandle}, {@link #playerConnection} and {@link #sendPacket} are initialized - * - * @return Whether these fields are initialized or not - * @see #initialize() - */ - public static boolean isInitialized() { - return initialized; - } - - /** - * Initializes {@link #packet} with all set values - * - * @param center Center location of the effect - * @throws PacketInstantiationException If instantion fails due to an unknown error - */ - private void initializePacket(Location center) throws PacketInstantiationException { - if (packet != null) { - return; - } - try { - packet = packetConstructor.newInstance(); - if (version < 8) { - String name = effect.getName(); - if (data != null) { - name += data.getPacketDataString(); - } - ReflectionUtils.setValue(packet, true, "a", name); - } else { - ReflectionUtils.setValue(packet, true, "a", enumParticle.getEnumConstants()[effect.getId()]); - ReflectionUtils.setValue(packet, true, "j", longDistance); - if (data != null) { - int[] packetData = data.getPacketData(); - ReflectionUtils.setValue(packet, true, "k", effect == ParticleEffect.ITEM_CRACK ? packetData : new int[]{packetData[0] | (packetData[1] << 12)}); - } - } - ReflectionUtils.setValue(packet, true, "b", (float) center.getX()); - ReflectionUtils.setValue(packet, true, "c", (float) center.getY()); - ReflectionUtils.setValue(packet, true, "d", (float) center.getZ()); - ReflectionUtils.setValue(packet, true, "e", offsetX); - ReflectionUtils.setValue(packet, true, "f", offsetY); - ReflectionUtils.setValue(packet, true, "g", offsetZ); - ReflectionUtils.setValue(packet, true, "h", speed); - ReflectionUtils.setValue(packet, true, "i", amount); - } catch (Exception exception) { - throw new PacketInstantiationException("Packet instantiation failed", exception); - } - } - - /** - * Sends the packet to a single player and caches it - * - * @param center Center location of the effect - * @param player Receiver of the packet - * @throws PacketInstantiationException If instantion fails due to an unknown error - * @throws PacketSendingException If sending fails due to an unknown error - * @see #initializePacket(Location) - */ - public void sendTo(Location center, Player player) throws PacketInstantiationException, PacketSendingException { - initializePacket(center); - try { - sendPacket.invoke(playerConnection.get(getHandle.invoke(player)), packet); - } catch (Exception exception) { - throw new PacketSendingException("Failed to send the packet to player '" + player.getName() + "'", exception); - } - } - - /** - * Sends the packet to all players in the list - * - * @param center Center location of the effect - * @param players Receivers of the packet - * @throws IllegalArgumentException If the player list is empty - * @see #sendTo(Location center, Player player) - */ - public void sendTo(Location center, List players) throws IllegalArgumentException { - if (players.isEmpty()) { - throw new IllegalArgumentException("The player list is empty"); - } - for (Player player : players) { - sendTo(center, player); - } - } - - /** - * Sends the packet to all players in a certain range - * - * @param center Center location of the effect - * @param range Range in which players will receive the packet (Maximum range for particles is usually 16, but it can differ for some types) - * @throws IllegalArgumentException If the range is lower than 1 - * @see #sendTo(Location center, Player player) - */ - public void sendTo(Location center, double range) throws IllegalArgumentException { - if (range < 1) { - throw new IllegalArgumentException("The range is lower than 1"); - } - String worldName = center.getWorld().getName(); - double squared = range * range; - for (Player player : Bukkit.getOnlinePlayers()) { - if (!player.getWorld().getName().equals(worldName) || player.getLocation().distanceSquared(center) > squared) { - continue; - } - sendTo(center, player); - } - } - - /** - * 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 - * @since 1.5 - */ - private static final class VersionIncompatibleException extends RuntimeException { - private static final long serialVersionUID = 3203085387160737484L; - - /** - * Construct a new version incompatible exception - * - * @param message Message that will be logged - * @param cause Cause of the exception - */ - public VersionIncompatibleException(String message, Throwable cause) { - super(message, cause); - } - } - - /** - * 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 - * @since 1.4 - */ - private static final class PacketInstantiationException extends RuntimeException { - private static final long serialVersionUID = 3203085387160737484L; - - /** - * Construct a new packet instantiation exception - * - * @param message Message that will be logged - * @param cause Cause of the exception - */ - public PacketInstantiationException(String message, Throwable cause) { - super(message, cause); - } - } - - /** - * 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 - * @since 1.4 - */ - private static final class PacketSendingException extends RuntimeException { - private static final long serialVersionUID = 3203085387160737484L; - - /** - * Construct a new packet sending exception - * - * @param message Message that will be logged - * @param cause Cause of the exception - */ - public PacketSendingException(String message, Throwable cause) { - super(message, cause); - } - } - } + /** + * A particle effect which is displayed by exploding tnt and creepers: + *

    + *
  • It looks like a white cloud + *
  • The speed value influences the velocity at which the particle flies off + *
+ */ + EXPLOSION_NORMAL("explode", 0, -1, ParticleProperty.DIRECTIONAL), + /** + * A particle effect which is displayed by exploding ghast fireballs and wither skulls: + *
    + *
  • It looks like a gray ball which is fading away + *
  • The speed value slightly influences the size of this particle effect + *
+ */ + EXPLOSION_LARGE("largeexplode", 1, -1), + /** + * A particle effect which is displayed by exploding tnt and creepers: + *
    + *
  • It looks like a crowd of gray balls which are fading away + *
  • The speed value has no influence on this particle effect + *
+ */ + EXPLOSION_HUGE("hugeexplosion", 2, -1), + /** + * A particle effect which is displayed by launching fireworks: + *
    + *
  • It looks like a white star which is sparkling + *
  • The speed value influences the velocity at which the particle flies off + *
+ */ + FIREWORKS_SPARK("fireworksSpark", 3, -1, ParticleProperty.DIRECTIONAL), + /** + * A particle effect which is displayed by swimming entities and arrows in water: + *
    + *
  • It looks like a bubble + *
  • The speed value influences the velocity at which the particle flies off + *
+ */ + WATER_BUBBLE("bubble", 4, -1, ParticleProperty.DIRECTIONAL, ParticleProperty.REQUIRES_WATER), + /** + * A particle effect which is displayed by swimming entities and shaking wolves: + *
    + *
  • It looks like a blue drop + *
  • The speed value has no influence on this particle effect + *
+ */ + WATER_SPLASH("splash", 5, -1, ParticleProperty.DIRECTIONAL), + /** + * A particle effect which is displayed on water when fishing: + *
    + *
  • It looks like a blue droplet + *
  • The speed value influences the velocity at which the particle flies off + *
+ */ + WATER_WAKE("wake", 6, 7, ParticleProperty.DIRECTIONAL), + /** + * A particle effect which is displayed by water: + *
    + *
  • It looks like a tiny blue square + *
  • The speed value has no influence on this particle effect + *
+ */ + SUSPENDED("suspended", 7, -1, ParticleProperty.REQUIRES_WATER), + /** + * A particle effect which is displayed by air when close to bedrock and the in the void: + *
    + *
  • It looks like a tiny gray square + *
  • The speed value has no influence on this particle effect + *
+ */ + SUSPENDED_DEPTH("depthSuspend", 8, -1, ParticleProperty.DIRECTIONAL), + /** + * A particle effect which is displayed when landing a critical hit and by arrows: + *
    + *
  • It looks like a light brown cross + *
  • The speed value influences the velocity at which the particle flies off + *
+ */ + CRIT("crit", 9, -1, ParticleProperty.DIRECTIONAL), + /** + * A particle effect which is displayed when landing a hit with an enchanted weapon: + *
    + *
  • It looks like a cyan star + *
  • The speed value influences the velocity at which the particle flies off + *
+ */ + 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: + *
    + *
  • It looks like a little gray cloud + *
  • The speed value influences the velocity at which the particle flies off + *
+ */ + SMOKE_NORMAL("smoke", 11, -1, ParticleProperty.DIRECTIONAL), + /** + * A particle effect which is displayed by fire, minecarts with furnace and blazes: + *
    + *
  • It looks like a large gray cloud + *
  • The speed value influences the velocity at which the particle flies off + *
+ */ + SMOKE_LARGE("largesmoke", 12, -1, ParticleProperty.DIRECTIONAL), + /** + * A particle effect which is displayed when splash potions or bottles o' enchanting hit something: + *
    + *
  • It looks like a white swirl + *
  • The speed value causes the particle to only move upwards when set to 0 + *
  • 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), + /** + * A particle effect which is displayed when instant splash potions hit something: + *
    + *
  • It looks like a white cross + *
  • The speed value causes the particle to only move upwards when set to 0 + *
  • 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), + /** + * A particle effect which is displayed by entities with active potion effects: + *
    + *
  • It looks like a colored swirl + *
  • The speed value causes the particle to be colored black when set to 0 + *
  • The particle color gets lighter when increasing the speed and darker when decreasing the speed + *
+ */ + SPELL_MOB("mobSpell", 15, -1, ParticleProperty.COLORABLE), + /** + * A particle effect which is displayed by entities with active potion effects applied through a beacon: + *
    + *
  • It looks like a transparent colored swirl + *
  • The speed value causes the particle to be always colored black when set to 0 + *
  • The particle color gets lighter when increasing the speed and darker when decreasing the speed + *
+ */ + SPELL_MOB_AMBIENT("mobSpellAmbient", 16, -1, ParticleProperty.COLORABLE), + /** + * A particle effect which is displayed by witches: + *
    + *
  • It looks like a purple cross + *
  • The speed value causes the particle to only move upwards when set to 0 + *
  • 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), + /** + * A particle effect which is displayed by blocks beneath a water source: + *
    + *
  • It looks like a blue drip + *
  • The speed value has no influence on this particle effect + *
+ */ + DRIP_WATER("dripWater", 18, -1), + /** + * A particle effect which is displayed by blocks beneath a lava source: + *
    + *
  • It looks like an orange drip + *
  • The speed value has no influence on this particle effect + *
+ */ + DRIP_LAVA("dripLava", 19, -1), + /** + * A particle effect which is displayed when attacking a villager in a village: + *
    + *
  • It looks like a cracked gray heart + *
  • The speed value has no influence on this particle effect + *
+ */ + VILLAGER_ANGRY("angryVillager", 20, -1), + /** + * A particle effect which is displayed when using bone meal and trading with a villager in a village: + *
    + *
  • It looks like a green star + *
  • The speed value has no influence on this particle effect + *
+ */ + VILLAGER_HAPPY("happyVillager", 21, -1, ParticleProperty.DIRECTIONAL), + /** + * A particle effect which is displayed by mycelium: + *
    + *
  • It looks like a tiny gray square + *
  • The speed value has no influence on this particle effect + *
+ */ + TOWN_AURA("townaura", 22, -1, ParticleProperty.DIRECTIONAL), + /** + * A particle effect which is displayed by note blocks: + *
    + *
  • It looks like a colored note + *
  • The speed value causes the particle to be colored green when set to 0 + *
+ */ + 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: + *
    + *
  • It looks like a purple cloud + *
  • The speed value influences the spread of this particle effect + *
+ */ + PORTAL("portal", 24, -1, ParticleProperty.DIRECTIONAL), + /** + * A particle effect which is displayed by enchantment tables which are nearby bookshelves: + *
    + *
  • It looks like a cryptic white letter + *
  • The speed value influences the spread of this particle effect + *
+ */ + ENCHANTMENT_TABLE("enchantmenttable", 25, -1, ParticleProperty.DIRECTIONAL), + /** + * A particle effect which is displayed by torches, active furnaces, magma cubes and monster spawners: + *
    + *
  • It looks like a tiny flame + *
  • The speed value influences the velocity at which the particle flies off + *
+ */ + FLAME("flame", 26, -1, ParticleProperty.DIRECTIONAL), + /** + * A particle effect which is displayed by lava: + *
    + *
  • It looks like a spark + *
  • The speed value has no influence on this particle effect + *
+ */ + LAVA("lava", 27, -1), + /** + * A particle effect which is currently unused: + *
    + *
  • It looks like a transparent gray square + *
  • The speed value has no influence on this particle effect + *
+ */ + FOOTSTEP("footstep", 28, -1), + /** + * A particle effect which is displayed when a mob dies: + *
    + *
  • It looks like a large white cloud + *
  • The speed value influences the velocity at which the particle flies off + *
+ */ + CLOUD("cloud", 29, -1, ParticleProperty.DIRECTIONAL), + /** + * A particle effect which is displayed by redstone ore, powered redstone, redstone torches and redstone repeaters: + *
    + *
  • It looks like a tiny colored cloud + *
  • The speed value causes the particle to be colored red when set to 0 + *
+ */ + REDSTONE("reddust", 30, -1, ParticleProperty.COLORABLE), + /** + * A particle effect which is displayed when snowballs hit a block: + *
    + *
  • It looks like a little piece with the snowball texture + *
  • The speed value has no influence on this particle effect + *
+ */ + SNOWBALL("snowballpoof", 31, -1), + /** + * A particle effect which is currently unused: + *
    + *
  • It looks like a tiny white cloud + *
  • The speed value influences the velocity at which the particle flies off + *
+ */ + SNOW_SHOVEL("snowshovel", 32, -1, ParticleProperty.DIRECTIONAL), + /** + * A particle effect which is displayed by slimes: + *
    + *
  • It looks like a tiny part of the slimeball icon + *
  • The speed value has no influence on this particle effect + *
+ */ + SLIME("slime", 33, -1), + /** + * A particle effect which is displayed when breeding and taming animals: + *
    + *
  • It looks like a red heart + *
  • The speed value has no influence on this particle effect + *
+ */ + HEART("heart", 34, -1), + /** + * A particle effect which is displayed by barriers: + *
    + *
  • It looks like a red box with a slash through it + *
  • The speed value has no influence on this particle effect + *
+ */ + BARRIER("barrier", 35, 8), + /** + * A particle effect which is displayed when breaking a tool or eggs hit a block: + *
    + *
  • It looks like a little piece with an item texture + *
+ */ + ITEM_CRACK("iconcrack", 36, -1, ParticleProperty.DIRECTIONAL, ParticleProperty.REQUIRES_DATA), + /** + * A particle effect which is displayed when breaking blocks or sprinting: + *
    + *
  • It looks like a little piece with a block texture + *
  • The speed value has no influence on this particle effect + *
+ */ + BLOCK_CRACK("blockcrack", 37, -1, ParticleProperty.REQUIRES_DATA), + /** + * A particle effect which is displayed when falling: + *
    + *
  • It looks like a little piece with a block texture + *
+ */ + BLOCK_DUST("blockdust", 38, 7, ParticleProperty.DIRECTIONAL, ParticleProperty.REQUIRES_DATA), + /** + * A particle effect which is displayed when rain hits the ground: + *
    + *
  • It looks like a blue droplet + *
  • The speed value has no influence on this particle effect + *
+ */ + WATER_DROP("droplet", 39, 8), + /** + * A particle effect which is currently unused: + *
    + *
  • It has no visual effect + *
+ */ + ITEM_TAKE("take", 40, 8), + /** + * A particle effect which is displayed by elder guardians: + *
    + *
  • It looks like the shape of the elder guardian + *
  • The speed value has no influence on this particle effect + *
  • The offset values have no influence on this particle effect + *
+ */ + MOB_APPEARANCE("mobappearance", 41, 8); + + private static final Map NAME_MAP = new HashMap(); + private static final Map ID_MAP = new HashMap(); + + // Initialize map for quick name and id lookup + static { + for (ParticleEffect effect : values()) { + NAME_MAP.put(effect.name, effect); + ID_MAP.put(effect.id, effect); + } + } + + private final String name; + private final int id; + private final int requiredVersion; + private final List properties; + + /** + * Construct a new particle effect + * + * @param name Name of this particle effect + * @param id Id of this particle effect + * @param requiredVersion Version which is required (1.x) + * @param properties Properties of this particle effect + */ + ParticleEffect(String name, int id, int requiredVersion, ParticleProperty... properties) { + this.name = name; + this.id = id; + this.requiredVersion = requiredVersion; + this.properties = Arrays.asList(properties); + } + + /** + * Returns the particle effect with the given name + * + * @param name Name of the particle effect + * @return The particle effect + */ + public static ParticleEffect fromName(String name) { + for (Entry entry : NAME_MAP.entrySet()) { + if (!entry.getKey().equalsIgnoreCase(name)) { + continue; + } + return entry.getValue(); + } + return null; + } + + /** + * Returns the particle effect with the given id + * + * @param id Id of the particle effect + * @return The particle effect + */ + public static ParticleEffect fromId(int id) { + for (Entry entry : ID_MAP.entrySet()) { + if (entry.getKey() != id) { + continue; + } + return entry.getValue(); + } + return null; + } + + /** + * Determine if water is at a certain location + * + * @param location Location to check + * @return Whether water is at this location or not + */ + private static boolean isWater(Location location) { + Material material = location.getBlock().getType(); + return material == Material.WATER || material == XMaterial.WATER.parseMaterial(); + } + + /** + * Determine if the distance between @param location and one of the players exceeds 256 + * + * @param location Location to check + * @return Whether the distance exceeds 256 or not + */ + private static boolean isLongDistance(Location location, List players) { + String world = location.getWorld().getName(); + for (Player player : players) { + Location playerLocation = player.getLocation(); + if (!world.equals(playerLocation.getWorld().getName()) || playerLocation.distanceSquared(location) < 65536) { + continue; + } + return true; + } + return false; + } + + /** + * Determine if the data type for a particle effect is correct + * + * @param effect Particle effect + * @param data Particle data + * @return Whether the data type is correct or not + */ + private static boolean isDataCorrect(ParticleEffect effect, ParticleData data) { + return ((effect == BLOCK_CRACK || effect == BLOCK_DUST) && data instanceof BlockData) || (effect == ITEM_CRACK && data instanceof ItemData); + } + + /** + * Determine if the color type for a particle effect is correct + * + * @param effect Particle effect + * @param color Particle color + * @return Whether the color type is correct or not + */ + private static boolean isColorCorrect(ParticleEffect effect, ParticleColor color) { + return ((effect == SPELL_MOB || effect == SPELL_MOB_AMBIENT || effect == REDSTONE) && color instanceof OrdinaryColor) || (effect == NOTE && color instanceof NoteColor); + } + + /** + * Returns the name of this particle effect + * + * @return The name + */ + public String getName() { + return name; + } + + /** + * Returns the id of this particle effect + * + * @return The id + */ + public int getId() { + return id; + } + + /** + * Returns the required version for this particle effect (1.x) + * + * @return The required version + */ + public int getRequiredVersion() { + return requiredVersion; + } + + /** + * Determine if this particle effect has a specific property + * + * @param property - property to check. + * @return Whether it has the property or not + */ + public boolean hasProperty(ParticleProperty property) { + return properties.contains(property); + } + + /** + * Determine if this particle effect is supported by your current server version + * + * @return Whether the particle effect is supported or not + */ + public boolean isSupported() { + if (requiredVersion == -1) { + return true; + } + return ParticlePacket.getVersion() >= requiredVersion; + } + + /** + * Displays a particle effect which is only visible for all players within a certain range in the world of @param center + * + * @param offsetX Maximum distance particles can fly away from the center on the x-axis + * @param offsetY Maximum distance particles can fly away from the center on the y-axis + * @param offsetZ Maximum distance particles can fly away from the center on the z-axis + * @param speed Display speed of the particles + * @param amount Amount of particles + * @param center Center location of the effect + * @param range Range of the visibility + * @throws ParticleVersionException If the particle effect is not supported by the server version + * @throws ParticleDataException If the particle effect requires additional data + * @throws IllegalArgumentException If the particle effect requires water and none is at the center location + * @see ParticlePacket + * @see ParticlePacket#sendTo(Location, double) + */ + public void display(float offsetX, float offsetY, float offsetZ, float speed, int amount, Location center, double range) throws ParticleVersionException, ParticleDataException, IllegalArgumentException { + if (!isSupported()) { + throw new ParticleVersionException("This particle effect is not supported by your server version"); + } + if (hasProperty(ParticleProperty.REQUIRES_DATA)) { + throw new ParticleDataException("This particle effect requires additional data"); + } + if (hasProperty(ParticleProperty.REQUIRES_WATER) && !isWater(center)) { + throw new IllegalArgumentException("There is no water at the center location"); + } + new ParticlePacket(this, offsetX, offsetY, offsetZ, speed, amount, range > 256, null).sendTo(center, range); + } + + /** + * Displays a particle effect which is only visible for the specified players + * + * @param offsetX Maximum distance particles can fly away from the center on the x-axis + * @param offsetY Maximum distance particles can fly away from the center on the y-axis + * @param offsetZ Maximum distance particles can fly away from the center on the z-axis + * @param speed Display speed of the particles + * @param amount Amount of particles + * @param center Center location of the effect + * @param players Receivers of the effect + * @throws ParticleVersionException If the particle effect is not supported by the server version + * @throws ParticleDataException If the particle effect requires additional data + * @throws IllegalArgumentException If the particle effect requires water and none is at the center location + * @see ParticlePacket + * @see ParticlePacket#sendTo(Location, List) + */ + public void display(float offsetX, float offsetY, float offsetZ, float speed, int amount, Location center, List players) throws ParticleVersionException, ParticleDataException, IllegalArgumentException { + if (!isSupported()) { + throw new ParticleVersionException("This particle effect is not supported by your server version"); + } + if (hasProperty(ParticleProperty.REQUIRES_DATA)) { + throw new ParticleDataException("This particle effect requires additional data"); + } + if (hasProperty(ParticleProperty.REQUIRES_WATER) && !isWater(center)) { + throw new IllegalArgumentException("There is no water at the center location"); + } + new ParticlePacket(this, offsetX, offsetY, offsetZ, speed, amount, isLongDistance(center, players), null).sendTo(center, players); + } + + /** + * Displays a particle effect which is only visible for the specified players + * + * @param offsetX Maximum distance particles can fly away from the center on the x-axis + * @param offsetY Maximum distance particles can fly away from the center on the y-axis + * @param offsetZ Maximum distance particles can fly away from the center on the z-axis + * @param speed Display speed of the particles + * @param amount Amount of particles + * @param center Center location of the effect + * @param players Receivers of the effect + * @throws ParticleVersionException If the particle effect is not supported by the server version + * @throws ParticleDataException If the particle effect requires additional data + * @throws IllegalArgumentException If the particle effect requires water and none is at the center location + * @see #display(float, float, float, float, int, Location, List) + */ + public void display(float offsetX, float offsetY, float offsetZ, float speed, int amount, Location center, Player... players) throws ParticleVersionException, ParticleDataException, IllegalArgumentException { + display(offsetX, offsetY, offsetZ, speed, amount, center, Arrays.asList(players)); + } + + /** + * Displays a single particle which flies into a determined direction and is only visible for all players within a certain range in the world of @param center + * + * @param direction Direction of the particle + * @param speed Display speed of the particle + * @param center Center location of the effect + * @param range Range of the visibility + * @throws ParticleVersionException If the particle effect is not supported by the server version + * @throws ParticleDataException If the particle effect requires additional data + * @throws IllegalArgumentException If the particle effect is not directional or if it requires water and none is at the center location + * @see ParticlePacket#ParticlePacket(ParticleEffect, Vector, float, boolean, ParticleData) + * @see ParticlePacket#sendTo(Location, double) + */ + public void display(Vector direction, float speed, Location center, double range) throws ParticleVersionException, ParticleDataException, IllegalArgumentException { + if (!isSupported()) { + throw new ParticleVersionException("This particle effect is not supported by your server version"); + } + if (hasProperty(ParticleProperty.REQUIRES_DATA)) { + throw new ParticleDataException("This particle effect requires additional data"); + } + if (!hasProperty(ParticleProperty.DIRECTIONAL)) { + throw new IllegalArgumentException("This particle effect is not directional"); + } + if (hasProperty(ParticleProperty.REQUIRES_WATER) && !isWater(center)) { + throw new IllegalArgumentException("There is no water at the center location"); + } + new ParticlePacket(this, direction, speed, range > 256, null).sendTo(center, range); + } + + /** + * Displays a single particle which flies into a determined direction and is only visible for the specified players + * + * @param direction Direction of the particle + * @param speed Display speed of the particle + * @param center Center location of the effect + * @param players Receivers of the effect + * @throws ParticleVersionException If the particle effect is not supported by the server version + * @throws ParticleDataException If the particle effect requires additional data + * @throws IllegalArgumentException If the particle effect is not directional or if it requires water and none is at the center location + * @see ParticlePacket#ParticlePacket(ParticleEffect, Vector, float, boolean, ParticleData) + * @see ParticlePacket#sendTo(Location, List) + */ + public void display(Vector direction, float speed, Location center, List players) throws ParticleVersionException, ParticleDataException, IllegalArgumentException { + if (!isSupported()) { + throw new ParticleVersionException("This particle effect is not supported by your server version"); + } + if (hasProperty(ParticleProperty.REQUIRES_DATA)) { + throw new ParticleDataException("This particle effect requires additional data"); + } + if (!hasProperty(ParticleProperty.DIRECTIONAL)) { + throw new IllegalArgumentException("This particle effect is not directional"); + } + if (hasProperty(ParticleProperty.REQUIRES_WATER) && !isWater(center)) { + throw new IllegalArgumentException("There is no water at the center location"); + } + new ParticlePacket(this, direction, speed, isLongDistance(center, players), null).sendTo(center, players); + } + + /** + * Displays a single particle which flies into a determined direction and is only visible for the specified players + * + * @param direction Direction of the particle + * @param speed Display speed of the particle + * @param center Center location of the effect + * @param players Receivers of the effect + * @throws ParticleVersionException If the particle effect is not supported by the server version + * @throws ParticleDataException If the particle effect requires additional data + * @throws IllegalArgumentException If the particle effect is not directional or if it requires water and none is at the center location + * @see #display(Vector, float, Location, List) + */ + public void display(Vector direction, float speed, Location center, Player... players) throws ParticleVersionException, ParticleDataException, IllegalArgumentException { + display(direction, speed, center, Arrays.asList(players)); + } + + /** + * Displays a single particle which is colored and only visible for all players within a certain range in the world of @param center + * + * @param color Color of the particle + * @param center Center location of the effect + * @param range Range of the visibility + * @throws ParticleVersionException If the particle effect is not supported by the server version + * @throws ParticleColorException If the particle effect is not colorable or the color type is incorrect + * @see ParticlePacket#ParticlePacket(ParticleEffect, ParticleColor, boolean) + * @see ParticlePacket#sendTo(Location, double) + */ + public void display(ParticleColor color, Location center, double range) throws ParticleVersionException, ParticleColorException { + if (!isSupported()) { + throw new ParticleVersionException("This particle effect is not supported by your server version"); + } + if (!hasProperty(ParticleProperty.COLORABLE)) { + throw new ParticleColorException("This particle effect is not colorable"); + } + if (!isColorCorrect(this, color)) { + throw new ParticleColorException("The particle color type is incorrect"); + } + new ParticlePacket(this, color, range > 256).sendTo(center, range); + } + + /** + * Displays a single particle which is colored and only visible for the specified players + * + * @param color Color of the particle + * @param center Center location of the effect + * @param players Receivers of the effect + * @throws ParticleVersionException If the particle effect is not supported by the server version + * @throws ParticleColorException If the particle effect is not colorable or the color type is incorrect + * @see ParticlePacket#ParticlePacket(ParticleEffect, ParticleColor, boolean) + * @see ParticlePacket#sendTo(Location, List) + */ + public void display(ParticleColor color, Location center, List players) throws ParticleVersionException, ParticleColorException { + if (!isSupported()) { + throw new ParticleVersionException("This particle effect is not supported by your server version"); + } + if (!hasProperty(ParticleProperty.COLORABLE)) { + throw new ParticleColorException("This particle effect is not colorable"); + } + if (!isColorCorrect(this, color)) { + throw new ParticleColorException("The particle color type is incorrect"); + } + new ParticlePacket(this, color, isLongDistance(center, players)).sendTo(center, players); + } + + /** + * Displays a single particle which is colored and only visible for the specified players + * + * @param color Color of the particle + * @param center Center location of the effect + * @param players Receivers of the effect + * @throws ParticleVersionException If the particle effect is not supported by the server version + * @throws ParticleColorException If the particle effect is not colorable or the color type is incorrect + * @see #display(ParticleColor, Location, List) + */ + public void display(ParticleColor color, Location center, Player... players) throws ParticleVersionException, ParticleColorException { + display(color, center, Arrays.asList(players)); + } + + /** + * Displays a particle effect which requires additional data and is only visible for all players within a certain range in the world of @param center + * + * @param data Data of the effect + * @param offsetX Maximum distance particles can fly away from the center on the x-axis + * @param offsetY Maximum distance particles can fly away from the center on the y-axis + * @param offsetZ Maximum distance particles can fly away from the center on the z-axis + * @param speed Display speed of the particles + * @param amount Amount of particles + * @param center Center location of the effect + * @param range Range of the visibility + * @throws ParticleVersionException If the particle effect is not supported by the server version + * @throws ParticleDataException If the particle effect does not require additional data or if the data type is incorrect + * @see ParticlePacket + * @see ParticlePacket#sendTo(Location, double) + */ + public void display(ParticleData data, float offsetX, float offsetY, float offsetZ, float speed, int amount, Location center, double range) throws ParticleVersionException, ParticleDataException { + if (!isSupported()) { + throw new ParticleVersionException("This particle effect is not supported by your server version"); + } + if (!hasProperty(ParticleProperty.REQUIRES_DATA)) { + throw new ParticleDataException("This particle effect does not require additional data"); + } + if (!isDataCorrect(this, data)) { + throw new ParticleDataException("The particle data type is incorrect"); + } + new ParticlePacket(this, offsetX, offsetY, offsetZ, speed, amount, range > 256, data).sendTo(center, range); + } + + /** + * Displays a particle effect which requires additional data and is only visible for the specified players + * + * @param data Data of the effect + * @param offsetX Maximum distance particles can fly away from the center on the x-axis + * @param offsetY Maximum distance particles can fly away from the center on the y-axis + * @param offsetZ Maximum distance particles can fly away from the center on the z-axis + * @param speed Display speed of the particles + * @param amount Amount of particles + * @param center Center location of the effect + * @param players Receivers of the effect + * @throws ParticleVersionException If the particle effect is not supported by the server version + * @throws ParticleDataException If the particle effect does not require additional data or if the data type is incorrect + * @see ParticlePacket + * @see ParticlePacket#sendTo(Location, List) + */ + public void display(ParticleData data, float offsetX, float offsetY, float offsetZ, float speed, int amount, Location center, List players) throws ParticleVersionException, ParticleDataException { + if (!isSupported()) { + throw new ParticleVersionException("This particle effect is not supported by your server version"); + } + if (!hasProperty(ParticleProperty.REQUIRES_DATA)) { + throw new ParticleDataException("This particle effect does not require additional data"); + } + if (!isDataCorrect(this, data)) { + throw new ParticleDataException("The particle data type is incorrect"); + } + new ParticlePacket(this, offsetX, offsetY, offsetZ, speed, amount, isLongDistance(center, players), data).sendTo(center, players); + } + + /** + * Displays a particle effect which requires additional data and is only visible for the specified players + * + * @param data Data of the effect + * @param offsetX Maximum distance particles can fly away from the center on the x-axis + * @param offsetY Maximum distance particles can fly away from the center on the y-axis + * @param offsetZ Maximum distance particles can fly away from the center on the z-axis + * @param speed Display speed of the particles + * @param amount Amount of particles + * @param center Center location of the effect + * @param players Receivers of the effect + * @throws ParticleVersionException If the particle effect is not supported by the server version + * @throws ParticleDataException If the particle effect does not require additional data or if the data type is incorrect + * @see #display(ParticleData, float, float, float, float, int, Location, List) + */ + public void display(ParticleData data, float offsetX, float offsetY, float offsetZ, float speed, int amount, Location center, Player... players) throws ParticleVersionException, ParticleDataException { + display(data, offsetX, offsetY, offsetZ, speed, amount, center, Arrays.asList(players)); + } + + /** + * Displays a single particle which requires additional data that flies into a determined direction and is only visible for all players within a certain range in the world of @param center + * + * @param data Data of the effect + * @param direction Direction of the particle + * @param speed Display speed of the particles + * @param center Center location of the effect + * @param range Range of the visibility + * @throws ParticleVersionException If the particle effect is not supported by the server version + * @throws ParticleDataException If the particle effect does not require additional data or if the data type is incorrect + * @see ParticlePacket + * @see ParticlePacket#sendTo(Location, double) + */ + public void display(ParticleData data, Vector direction, float speed, Location center, double range) throws ParticleVersionException, ParticleDataException { + if (!isSupported()) { + throw new ParticleVersionException("This particle effect is not supported by your server version"); + } + if (!hasProperty(ParticleProperty.REQUIRES_DATA)) { + throw new ParticleDataException("This particle effect does not require additional data"); + } + if (!isDataCorrect(this, data)) { + throw new ParticleDataException("The particle data type is incorrect"); + } + new ParticlePacket(this, direction, speed, range > 256, data).sendTo(center, range); + } + + /** + * Displays a single particle which requires additional data that flies into a determined direction and is only visible for the specified players + * + * @param data Data of the effect + * @param direction Direction of the particle + * @param speed Display speed of the particles + * @param center Center location of the effect + * @param players Receivers of the effect + * @throws ParticleVersionException If the particle effect is not supported by the server version + * @throws ParticleDataException If the particle effect does not require additional data or if the data type is incorrect + * @see ParticlePacket + * @see ParticlePacket#sendTo(Location, List) + */ + public void display(ParticleData data, Vector direction, float speed, Location center, List players) throws ParticleVersionException, ParticleDataException { + if (!isSupported()) { + throw new ParticleVersionException("This particle effect is not supported by your server version"); + } + if (!hasProperty(ParticleProperty.REQUIRES_DATA)) { + throw new ParticleDataException("This particle effect does not require additional data"); + } + if (!isDataCorrect(this, data)) { + throw new ParticleDataException("The particle data type is incorrect"); + } + new ParticlePacket(this, direction, speed, isLongDistance(center, players), data).sendTo(center, players); + } + + /** + * Displays a single particle which requires additional data that flies into a determined direction and is only visible for the specified players + * + * @param data Data of the effect + * @param direction Direction of the particle + * @param speed Display speed of the particles + * @param center Center location of the effect + * @param players Receivers of the effect + * @throws ParticleVersionException If the particle effect is not supported by the server version + * @throws ParticleDataException If the particle effect does not require additional data or if the data type is incorrect + * @see #display(ParticleData, Vector, float, Location, List) + */ + public void display(ParticleData data, Vector direction, float speed, Location center, Player... players) throws ParticleVersionException, ParticleDataException { + display(data, direction, speed, center, Arrays.asList(players)); + } + + /** + * Represents the property of a particle effect + * This class is part of the ParticleEffect Library and follows the same usage conditions + * + * @author DarkBlade12 + * @since 1.7 + */ + public enum ParticleProperty { + /** + * The particle effect requires water to be displayed + */ + REQUIRES_WATER, + /** + * The particle effect requires block or item data to be displayed + */ + REQUIRES_DATA, + /** + * The particle effect uses the offsets as direction values + */ + DIRECTIONAL, + /** + * The particle effect uses the offsets as color values + */ + COLORABLE + } + + /** + * Represents the particle data for effects like {@link ParticleEffect#ITEM_CRACK}, {@link ParticleEffect#BLOCK_CRACK} and {@link ParticleEffect#BLOCK_DUST} + * This class is part of the ParticleEffect Library and follows the same usage conditions + * + * @author DarkBlade12 + * @since 1.6 + */ + public static abstract class ParticleData { + private final Material material; + private final byte data; + private final int[] packetData; + + /** + * Construct a new particle data + * + * @param material Material of the item/block + * @param data Data value of the item/block + */ + @SuppressWarnings("deprecation") + public ParticleData(Material material, byte data) { + this.material = material; + this.data = data; + this.packetData = new int[]{material.getId(), data}; + } + + /** + * Returns the material of this data + * + * @return The material + */ + public Material getMaterial() { + return material; + } + + /** + * Returns the data value of this data + * + * @return The data value + */ + public byte getData() { + return data; + } + + /** + * Returns the data as an int array for packet construction + * + * @return The data for the packet + */ + public int[] getPacketData() { + return packetData; + } + + /** + * Returns the data as a string for pre 1.8 versions + * + * @return The data string for the packet + */ + public String getPacketDataString() { + return "_" + packetData[0] + "_" + packetData[1]; + } + } + + /** + * Represents the item data for the {@link ParticleEffect#ITEM_CRACK} effect + * This class is part of the ParticleEffect Library and follows the same usage conditions + * + * @author DarkBlade12 + * @since 1.6 + */ + public static final class ItemData extends ParticleData { + /** + * Construct a new item data + * + * @param material Material of the item + * @param data Data value of the item + * @see ParticleData#ParticleData(Material, byte) + */ + public ItemData(Material material, byte data) { + super(material, data); + } + } + + /** + * Represents the block data for the {@link ParticleEffect#BLOCK_CRACK} and {@link ParticleEffect#BLOCK_DUST} effects + * This class is part of the ParticleEffect Library and follows the same usage conditions + * + * @author DarkBlade12 + * @since 1.6 + */ + public static final class BlockData extends ParticleData { + /** + * Construct a new block data + * + * @param material Material of the block + * @param data Data value of the block + * @throws IllegalArgumentException If the material is not a block + * @see ParticleData#ParticleData(Material, byte) + */ + public BlockData(Material material, byte data) throws IllegalArgumentException { + super(material, data); + if (!material.isBlock()) { + throw new IllegalArgumentException("The material is not a block"); + } + } + } + + /** + * Represents the color for effects like {@link ParticleEffect#SPELL_MOB}, {@link ParticleEffect#SPELL_MOB_AMBIENT}, {@link ParticleEffect#REDSTONE} and {@link ParticleEffect#NOTE} + * This class is part of the ParticleEffect Library and follows the same usage conditions + * + * @author DarkBlade12 + * @since 1.7 + */ + public static abstract class ParticleColor { + /** + * Returns the value for the offsetX field + * + * @return The offsetX value + */ + public abstract float getValueX(); + + /** + * Returns the value for the offsetY field + * + * @return The offsetY value + */ + public abstract float getValueY(); + + /** + * Returns the value for the offsetZ field + * + * @return The offsetZ value + */ + public abstract float getValueZ(); + } + + /** + * Represents the color for effects like {@link ParticleEffect#SPELL_MOB}, {@link ParticleEffect#SPELL_MOB_AMBIENT} and {@link ParticleEffect#NOTE} + * This class is part of the ParticleEffect Library and follows the same usage conditions + * + * @author DarkBlade12 + * @since 1.7 + */ + public static final class OrdinaryColor extends ParticleColor { + private final int red; + private final int green; + private final int blue; + + /** + * Construct a new ordinary color + * + * @param red Red value of the RGB format + * @param green Green value of the RGB format + * @param blue Blue value of the RGB format + * @throws IllegalArgumentException If one of the values is lower than 0 or higher than 255 + */ + public OrdinaryColor(int red, int green, int blue) throws IllegalArgumentException { + if (red < 0) { + throw new IllegalArgumentException("The red value is lower than 0"); + } + if (red > 255) { + throw new IllegalArgumentException("The red value is higher than 255"); + } + this.red = red; + if (green < 0) { + throw new IllegalArgumentException("The green value is lower than 0"); + } + if (green > 255) { + throw new IllegalArgumentException("The green value is higher than 255"); + } + this.green = green; + if (blue < 0) { + throw new IllegalArgumentException("The blue value is lower than 0"); + } + if (blue > 255) { + throw new IllegalArgumentException("The blue value is higher than 255"); + } + this.blue = blue; + } + + /** + * Construct a new ordinary color + * + * @param color Bukkit color + */ + public OrdinaryColor(Color color) { + this(color.getRed(), color.getGreen(), color.getBlue()); + } + + /** + * Returns the red value of the RGB format + * + * @return The red value + */ + public int getRed() { + return red; + } + + /** + * Returns the green value of the RGB format + * + * @return The green value + */ + public int getGreen() { + return green; + } + + /** + * Returns the blue value of the RGB format + * + * @return The blue value + */ + public int getBlue() { + return blue; + } + + /** + * Returns the red value divided by 255 + * + * @return The offsetX value + */ + @Override + public float getValueX() { + return (float) red / 255F; + } + + /** + * Returns the green value divided by 255 + * + * @return The offsetY value + */ + @Override + public float getValueY() { + return (float) green / 255F; + } + + /** + * Returns the blue value divided by 255 + * + * @return The offsetZ value + */ + @Override + public float getValueZ() { + return (float) blue / 255F; + } + } + + /** + * 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 + * @since 1.7 + */ + public static final class NoteColor extends ParticleColor { + private final int note; + + /** + * Construct a new note color + * + * @param note Note id which determines color + * @throws IllegalArgumentException If the note value is lower than 0 or higher than 24 + */ + public NoteColor(int note) throws IllegalArgumentException { + if (note < 0) { + throw new IllegalArgumentException("The note value is lower than 0"); + } + if (note > 24) { + throw new IllegalArgumentException("The note value is higher than 24"); + } + this.note = note; + } + + /** + * Returns the note value divided by 24 + * + * @return The offsetX value + */ + @Override + public float getValueX() { + return (float) note / 24F; + } + + /** + * Returns zero because the offsetY value is unused + * + * @return zero + */ + @Override + public float getValueY() { + return 0; + } + + /** + * Returns zero because the offsetZ value is unused + * + * @return zero + */ + @Override + public float getValueZ() { + return 0; + } + + } + + /** + * 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 + * @since 1.6 + */ + private static final class ParticleDataException extends RuntimeException { + private static final long serialVersionUID = 3203085387160737484L; + + /** + * Construct a new particle data exception + * + * @param message Message that will be logged + */ + public ParticleDataException(String message) { + super(message); + } + } + + /** + * 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 + * @since 1.7 + */ + private static final class ParticleColorException extends RuntimeException { + private static final long serialVersionUID = 3203085387160737484L; + + /** + * Construct a new particle color exception + * + * @param message Message that will be logged + */ + public ParticleColorException(String message) { + super(message); + } + } + + /** + * 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 + * @since 1.6 + */ + private static final class ParticleVersionException extends RuntimeException { + private static final long serialVersionUID = 3203085387160737484L; + + /** + * Construct a new particle version exception + * + * @param message Message that will be logged + */ + public ParticleVersionException(String message) { + super(message); + } + } + + /** + * 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 + * @since 1.5 + */ + public static final class ParticlePacket { + private static int version; + private static Class enumParticle; + private static Constructor packetConstructor; + private static Method getHandle; + private static Field playerConnection; + private static Method sendPacket; + private static boolean initialized; + private final ParticleEffect effect; + private final float offsetY; + private final float offsetZ; + private final float speed; + private final int amount; + private final boolean longDistance; + private final ParticleData data; + private float offsetX; + private Object packet; + + /** + * Construct a new particle packet + * + * @param effect Particle effect + * @param offsetX Maximum distance particles can fly away from the center on the x-axis + * @param offsetY Maximum distance particles can fly away from the center on the y-axis + * @param offsetZ Maximum distance particles can fly away from the center on the z-axis + * @param speed Display speed of the particles + * @param amount Amount of particles + * @param longDistance Indicates whether the maximum distance is increased from 256 to 65536 + * @param data Data of the effect + * @throws IllegalArgumentException If the speed or amount is lower than 0 + * @see #initialize() + */ + public ParticlePacket(ParticleEffect effect, float offsetX, float offsetY, float offsetZ, float speed, int amount, boolean longDistance, ParticleData data) throws IllegalArgumentException { + initialize(); + if (speed < 0) { + throw new IllegalArgumentException("The speed is lower than 0"); + } + if (amount < 0) { + throw new IllegalArgumentException("The amount is lower than 0"); + } + this.effect = effect; + this.offsetX = offsetX; + this.offsetY = offsetY; + this.offsetZ = offsetZ; + this.speed = speed; + this.amount = amount; + this.longDistance = longDistance; + this.data = data; + } + + /** + * Construct a new particle packet of a single particle flying into a determined direction + * + * @param effect Particle effect + * @param direction Direction of the particle + * @param speed Display speed of the particle + * @param longDistance Indicates whether the maximum distance is increased from 256 to 65536 + * @param data Data of the effect + * @throws IllegalArgumentException If the speed is lower than 0 + */ + public ParticlePacket(ParticleEffect effect, Vector direction, float speed, boolean longDistance, ParticleData data) throws IllegalArgumentException { + this(effect, (float) direction.getX(), (float) direction.getY(), (float) direction.getZ(), speed, 0, longDistance, data); + } + + /** + * Construct a new particle packet of a single colored particle + * + * @param effect Particle effect + * @param color Color of the particle + * @param longDistance Indicates whether the maximum distance is increased from 256 to 65536 + */ + public ParticlePacket(ParticleEffect effect, ParticleColor color, boolean longDistance) { + this(effect, color.getValueX(), color.getValueY(), color.getValueZ(), 1, 0, longDistance, null); + if (effect == ParticleEffect.REDSTONE && color instanceof OrdinaryColor && ((OrdinaryColor) color).getRed() == 0) { + offsetX = Float.MIN_NORMAL; + } + } + + /** + * 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 + */ + public static void initialize() throws VersionIncompatibleException { + if (initialized) { + return; + } + try { + version = Integer.parseInt(ReflectionUtils.PackageType.getServerVersion().split("_")[1]); + if (version > 7) { + enumParticle = ReflectionUtils.PackageType.MINECRAFT_SERVER.getClass("EnumParticle"); + } + + Class packetClass = ReflectionUtils.PackageType.MINECRAFT_SERVER.getClass(version < 7 ? "Packet63WorldParticles" : "PacketPlayOutWorldParticles"); + + packetConstructor = ReflectionUtils.getConstructor(packetClass); + getHandle = ReflectionUtils.getMethod("CraftPlayer", ReflectionUtils.PackageType.CRAFTBUKKIT_ENTITY, "getHandle"); + playerConnection = ReflectionUtils.getField("EntityPlayer", ReflectionUtils.PackageType.MINECRAFT_SERVER, false, "playerConnection"); + sendPacket = ReflectionUtils.getMethod(playerConnection.getType(), "sendPacket", ReflectionUtils.PackageType.MINECRAFT_SERVER.getClass("Packet")); + } catch (Exception exception) { + throw new VersionIncompatibleException("Your current bukkit version seems to be incompatible with this library", exception); + } + initialized = true; + } + + /** + * Returns the version of your server (1.x) + * + * @return The version number + */ + public static int getVersion() { + if (!initialized) { + initialize(); + } + return version; + } + + /** + * Determine if {@link #packetConstructor}, {@link #getHandle}, {@link #playerConnection} and {@link #sendPacket} are initialized + * + * @return Whether these fields are initialized or not + * @see #initialize() + */ + public static boolean isInitialized() { + return initialized; + } + + /** + * Initializes {@link #packet} with all set values + * + * @param center Center location of the effect + * @throws PacketInstantiationException If instantion fails due to an unknown error + */ + private void initializePacket(Location center) throws PacketInstantiationException { + if (packet != null) { + return; + } + try { + packet = packetConstructor.newInstance(); + if (version < 8) { + String name = effect.getName(); + if (data != null) { + name += data.getPacketDataString(); + } + ReflectionUtils.setValue(packet, true, "a", name); + } else { + ReflectionUtils.setValue(packet, true, "a", enumParticle.getEnumConstants()[effect.getId()]); + ReflectionUtils.setValue(packet, true, "j", longDistance); + if (data != null) { + int[] packetData = data.getPacketData(); + ReflectionUtils.setValue(packet, true, "k", effect == ParticleEffect.ITEM_CRACK ? packetData : new int[]{packetData[0] | (packetData[1] << 12)}); + } + } + ReflectionUtils.setValue(packet, true, "b", (float) center.getX()); + ReflectionUtils.setValue(packet, true, "c", (float) center.getY()); + ReflectionUtils.setValue(packet, true, "d", (float) center.getZ()); + ReflectionUtils.setValue(packet, true, "e", offsetX); + ReflectionUtils.setValue(packet, true, "f", offsetY); + ReflectionUtils.setValue(packet, true, "g", offsetZ); + ReflectionUtils.setValue(packet, true, "h", speed); + ReflectionUtils.setValue(packet, true, "i", amount); + } catch (Exception exception) { + throw new PacketInstantiationException("Packet instantiation failed", exception); + } + } + + /** + * Sends the packet to a single player and caches it + * + * @param center Center location of the effect + * @param player Receiver of the packet + * @throws PacketInstantiationException If instantion fails due to an unknown error + * @throws PacketSendingException If sending fails due to an unknown error + * @see #initializePacket(Location) + */ + public void sendTo(Location center, Player player) throws PacketInstantiationException, PacketSendingException { + initializePacket(center); + try { + sendPacket.invoke(playerConnection.get(getHandle.invoke(player)), packet); + } catch (Exception exception) { + throw new PacketSendingException("Failed to send the packet to player '" + player.getName() + "'", exception); + } + } + + /** + * Sends the packet to all players in the list + * + * @param center Center location of the effect + * @param players Receivers of the packet + * @throws IllegalArgumentException If the player list is empty + * @see #sendTo(Location center, Player player) + */ + public void sendTo(Location center, List players) throws IllegalArgumentException { + if (players.isEmpty()) { + throw new IllegalArgumentException("The player list is empty"); + } + for (Player player : players) { + sendTo(center, player); + } + } + + /** + * Sends the packet to all players in a certain range + * + * @param center Center location of the effect + * @param range Range in which players will receive the packet (Maximum range for particles is usually 16, but it can differ for some types) + * @throws IllegalArgumentException If the range is lower than 1 + * @see #sendTo(Location center, Player player) + */ + public void sendTo(Location center, double range) throws IllegalArgumentException { + if (range < 1) { + throw new IllegalArgumentException("The range is lower than 1"); + } + String worldName = center.getWorld().getName(); + double squared = range * range; + for (Player player : Bukkit.getOnlinePlayers()) { + if (!player.getWorld().getName().equals(worldName) || player.getLocation().distanceSquared(center) > squared) { + continue; + } + sendTo(center, player); + } + } + + /** + * 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 + * @since 1.5 + */ + private static final class VersionIncompatibleException extends RuntimeException { + private static final long serialVersionUID = 3203085387160737484L; + + /** + * Construct a new version incompatible exception + * + * @param message Message that will be logged + * @param cause Cause of the exception + */ + public VersionIncompatibleException(String message, Throwable cause) { + super(message, cause); + } + } + + /** + * 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 + * @since 1.4 + */ + private static final class PacketInstantiationException extends RuntimeException { + private static final long serialVersionUID = 3203085387160737484L; + + /** + * Construct a new packet instantiation exception + * + * @param message Message that will be logged + * @param cause Cause of the exception + */ + public PacketInstantiationException(String message, Throwable cause) { + super(message, cause); + } + } + + /** + * 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 + * @since 1.4 + */ + private static final class PacketSendingException extends RuntimeException { + private static final long serialVersionUID = 3203085387160737484L; + + /** + * Construct a new packet sending exception + * + * @param message Message that will be logged + * @param cause Cause of the exception + */ + public PacketSendingException(String message, Throwable cause) { + super(message, cause); + } + } + } } \ No newline at end of file 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 4184eb08..e3923367 100644 --- a/src/main/java/com/massivecraft/factions/util/Particles/ReflectionUtils.java +++ b/src/main/java/com/massivecraft/factions/util/Particles/ReflectionUtils.java @@ -26,583 +26,583 @@ import java.util.Map; * @version 1.1 */ public final class ReflectionUtils { - // Prevent accidental construction - private ReflectionUtils() { - } + // Prevent accidental construction + private ReflectionUtils() { + } - /** - * Returns the constructor of a given class with the given parameter types - * - * @param clazz Target class - * @param parameterTypes Parameter types of the desired constructor - * @return The constructor of the target class with the specified parameter types - * @throws NoSuchMethodException If the desired constructor with the specified parameter types cannot be found - * @see DataType - * @see DataType#getPrimitive(Class[]) - * @see DataType#compare(Class[], Class[]) - */ - public static Constructor getConstructor(Class clazz, Class... parameterTypes) throws NoSuchMethodException { - Class[] primitiveTypes = DataType.getPrimitive(parameterTypes); - for (Constructor constructor : clazz.getConstructors()) { - if (!DataType.compare(DataType.getPrimitive(constructor.getParameterTypes()), primitiveTypes)) { - continue; - } - return constructor; - } - throw new NoSuchMethodException("There is no such constructor in this class with the specified parameter types"); - } + /** + * Returns the constructor of a given class with the given parameter types + * + * @param clazz Target class + * @param parameterTypes Parameter types of the desired constructor + * @return The constructor of the target class with the specified parameter types + * @throws NoSuchMethodException If the desired constructor with the specified parameter types cannot be found + * @see DataType + * @see DataType#getPrimitive(Class[]) + * @see DataType#compare(Class[], Class[]) + */ + public static Constructor getConstructor(Class clazz, Class... parameterTypes) throws NoSuchMethodException { + Class[] primitiveTypes = DataType.getPrimitive(parameterTypes); + for (Constructor constructor : clazz.getConstructors()) { + if (!DataType.compare(DataType.getPrimitive(constructor.getParameterTypes()), primitiveTypes)) { + continue; + } + return constructor; + } + throw new NoSuchMethodException("There is no such constructor in this class with the specified parameter types"); + } - /** - * Returns the constructor of a desired class with the given parameter types - * - * @param className Name of the desired target class - * @param packageType Package where the desired target class is located - * @param parameterTypes Parameter types of the desired constructor - * @return The constructor of the desired target class with the specified parameter types - * @throws NoSuchMethodException If the desired constructor with the specified parameter types cannot be found - * @throws ClassNotFoundException ClassNotFoundException If the desired target class with the specified name and package cannot be found - * @see #getClass() (String, PackageType) - * @see #getConstructor(Class, Class...) - */ - public static Constructor getConstructor(String className, PackageType packageType, Class... parameterTypes) throws NoSuchMethodException, ClassNotFoundException { - return getConstructor(packageType.getClass(className), parameterTypes); - } + /** + * Returns the constructor of a desired class with the given parameter types + * + * @param className Name of the desired target class + * @param packageType Package where the desired target class is located + * @param parameterTypes Parameter types of the desired constructor + * @return The constructor of the desired target class with the specified parameter types + * @throws NoSuchMethodException If the desired constructor with the specified parameter types cannot be found + * @throws ClassNotFoundException ClassNotFoundException If the desired target class with the specified name and package cannot be found + * @see #getClass() (String, PackageType) + * @see #getConstructor(Class, Class...) + */ + public static Constructor getConstructor(String className, PackageType packageType, Class... parameterTypes) throws NoSuchMethodException, ClassNotFoundException { + return getConstructor(packageType.getClass(className), parameterTypes); + } - /** - * Returns an instance of a class with the given arguments - * - * @param clazz Target class - * @param arguments Arguments which are used to construct an object of the target class - * @return The instance of the target class with the specified arguments - * @throws InstantiationException If you cannot create an instance of the target class due to certain circumstances - * @throws IllegalAccessException If the desired constructor cannot be accessed due to certain circumstances - * @throws IllegalArgumentException If the types of the arguments do not match the parameter types of the constructor (this should not occur since it searches for a constructor with the types of the arguments) - * @throws InvocationTargetException If the desired constructor cannot be invoked - * @throws NoSuchMethodException If the desired constructor with the specified arguments cannot be found - */ - public static Object instantiateObject(Class clazz, Object... arguments) throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException { - return getConstructor(clazz, DataType.getPrimitive(arguments)).newInstance(arguments); - } + /** + * Returns an instance of a class with the given arguments + * + * @param clazz Target class + * @param arguments Arguments which are used to construct an object of the target class + * @return The instance of the target class with the specified arguments + * @throws InstantiationException If you cannot create an instance of the target class due to certain circumstances + * @throws IllegalAccessException If the desired constructor cannot be accessed due to certain circumstances + * @throws IllegalArgumentException If the types of the arguments do not match the parameter types of the constructor (this should not occur since it searches for a constructor with the types of the arguments) + * @throws InvocationTargetException If the desired constructor cannot be invoked + * @throws NoSuchMethodException If the desired constructor with the specified arguments cannot be found + */ + public static Object instantiateObject(Class clazz, Object... arguments) throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException { + return getConstructor(clazz, DataType.getPrimitive(arguments)).newInstance(arguments); + } - /** - * Returns an instance of a desired class with the given arguments - * - * @param className Name of the desired target class - * @param packageType Package where the desired target class is located - * @param arguments Arguments which are used to construct an object of the desired target class - * @return The instance of the desired target class with the specified arguments - * @throws InstantiationException If you cannot create an instance of the desired target class due to certain circumstances - * @throws IllegalAccessException If the desired constructor cannot be accessed due to certain circumstances - * @throws IllegalArgumentException If the types of the arguments do not match the parameter types of the constructor (this should not occur since it searches for a constructor with the types of the arguments) - * @throws InvocationTargetException If the desired constructor cannot be invoked - * @throws NoSuchMethodException If the desired constructor with the specified arguments cannot be found - * @throws ClassNotFoundException If the desired target class with the specified name and package cannot be found - * @see #getClass() (String, PackageType) - * @see #instantiateObject(Class, Object...) - */ - public static Object instantiateObject(String className, PackageType packageType, Object... arguments) throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, ClassNotFoundException { - return instantiateObject(packageType.getClass(className), arguments); - } + /** + * Returns an instance of a desired class with the given arguments + * + * @param className Name of the desired target class + * @param packageType Package where the desired target class is located + * @param arguments Arguments which are used to construct an object of the desired target class + * @return The instance of the desired target class with the specified arguments + * @throws InstantiationException If you cannot create an instance of the desired target class due to certain circumstances + * @throws IllegalAccessException If the desired constructor cannot be accessed due to certain circumstances + * @throws IllegalArgumentException If the types of the arguments do not match the parameter types of the constructor (this should not occur since it searches for a constructor with the types of the arguments) + * @throws InvocationTargetException If the desired constructor cannot be invoked + * @throws NoSuchMethodException If the desired constructor with the specified arguments cannot be found + * @throws ClassNotFoundException If the desired target class with the specified name and package cannot be found + * @see #getClass() (String, PackageType) + * @see #instantiateObject(Class, Object...) + */ + public static Object instantiateObject(String className, PackageType packageType, Object... arguments) throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, ClassNotFoundException { + return instantiateObject(packageType.getClass(className), arguments); + } - /** - * Returns a method of a class with the given parameter types - * - * @param clazz Target class - * @param methodName Name of the desired method - * @param parameterTypes Parameter types of the desired method - * @return The method of the target class with the specified name and parameter types - * @throws NoSuchMethodException If the desired method of the target class with the specified name and parameter types cannot be found - * @see DataType#getPrimitive(Class[]) - * @see DataType#compare(Class[], Class[]) - */ - public static Method getMethod(Class clazz, String methodName, Class... parameterTypes) throws NoSuchMethodException { - Class[] primitiveTypes = DataType.getPrimitive(parameterTypes); - for (Method method : clazz.getMethods()) { - if (!method.getName().equals(methodName) || !DataType.compare(DataType.getPrimitive(method.getParameterTypes()), primitiveTypes)) { - continue; - } - return method; - } - throw new NoSuchMethodException("There is no such method in this class with the specified name and parameter types"); - } + /** + * Returns a method of a class with the given parameter types + * + * @param clazz Target class + * @param methodName Name of the desired method + * @param parameterTypes Parameter types of the desired method + * @return The method of the target class with the specified name and parameter types + * @throws NoSuchMethodException If the desired method of the target class with the specified name and parameter types cannot be found + * @see DataType#getPrimitive(Class[]) + * @see DataType#compare(Class[], Class[]) + */ + public static Method getMethod(Class clazz, String methodName, Class... parameterTypes) throws NoSuchMethodException { + Class[] primitiveTypes = DataType.getPrimitive(parameterTypes); + for (Method method : clazz.getMethods()) { + if (!method.getName().equals(methodName) || !DataType.compare(DataType.getPrimitive(method.getParameterTypes()), primitiveTypes)) { + continue; + } + return method; + } + throw new NoSuchMethodException("There is no such method in this class with the specified name and parameter types"); + } - /** - * Returns a method of a desired class with the given parameter types - * - * @param className Name of the desired target class - * @param packageType Package where the desired target class is located - * @param methodName Name of the desired method - * @param parameterTypes Parameter types of the desired method - * @return The method of the desired target class with the specified name and parameter types - * @throws NoSuchMethodException If the desired method of the desired target class with the specified name and parameter types cannot be found - * @throws ClassNotFoundException If the desired target class with the specified name and package cannot be found - * @see #getClass() (String, PackageType) - * @see #getMethod(Class, String, Class...) - */ - public static Method getMethod(String className, PackageType packageType, String methodName, Class... parameterTypes) throws NoSuchMethodException, ClassNotFoundException { - return getMethod(packageType.getClass(className), methodName, parameterTypes); - } + /** + * Returns a method of a desired class with the given parameter types + * + * @param className Name of the desired target class + * @param packageType Package where the desired target class is located + * @param methodName Name of the desired method + * @param parameterTypes Parameter types of the desired method + * @return The method of the desired target class with the specified name and parameter types + * @throws NoSuchMethodException If the desired method of the desired target class with the specified name and parameter types cannot be found + * @throws ClassNotFoundException If the desired target class with the specified name and package cannot be found + * @see #getClass() (String, PackageType) + * @see #getMethod(Class, String, Class...) + */ + public static Method getMethod(String className, PackageType packageType, String methodName, Class... parameterTypes) throws NoSuchMethodException, ClassNotFoundException { + return getMethod(packageType.getClass(className), methodName, parameterTypes); + } - /** - * Invokes a method on an object with the given arguments - * - * @param instance Target object - * @param methodName Name of the desired method - * @param arguments Arguments which are used to invoke the desired method - * @return The result of invoking the desired method on the target object - * @throws IllegalAccessException If the desired method cannot be accessed due to certain circumstances - * @throws IllegalArgumentException If the types of the arguments do not match the parameter types of the method (this should not occur since it searches for a method with the types of the arguments) - * @throws InvocationTargetException If the desired method cannot be invoked on the target object - * @throws NoSuchMethodException If the desired method of the class of the target object with the specified name and arguments cannot be found - * @see #getMethod(Class, String, Class...) - * @see DataType#getPrimitive(Object[]) - */ - public static Object invokeMethod(Object instance, String methodName, Object... arguments) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException { - return getMethod(instance.getClass(), methodName, DataType.getPrimitive(arguments)).invoke(instance, arguments); - } + /** + * Invokes a method on an object with the given arguments + * + * @param instance Target object + * @param methodName Name of the desired method + * @param arguments Arguments which are used to invoke the desired method + * @return The result of invoking the desired method on the target object + * @throws IllegalAccessException If the desired method cannot be accessed due to certain circumstances + * @throws IllegalArgumentException If the types of the arguments do not match the parameter types of the method (this should not occur since it searches for a method with the types of the arguments) + * @throws InvocationTargetException If the desired method cannot be invoked on the target object + * @throws NoSuchMethodException If the desired method of the class of the target object with the specified name and arguments cannot be found + * @see #getMethod(Class, String, Class...) + * @see DataType#getPrimitive(Object[]) + */ + public static Object invokeMethod(Object instance, String methodName, Object... arguments) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException { + return getMethod(instance.getClass(), methodName, DataType.getPrimitive(arguments)).invoke(instance, arguments); + } - /** - * Invokes a method of the target class on an object with the given arguments - * - * @param instance Target object - * @param clazz Target class - * @param methodName Name of the desired method - * @param arguments Arguments which are used to invoke the desired method - * @return The result of invoking the desired method on the target object - * @throws IllegalAccessException If the desired method cannot be accessed due to certain circumstances - * @throws IllegalArgumentException If the types of the arguments do not match the parameter types of the method (this should not occur since it searches for a method with the types of the arguments) - * @throws InvocationTargetException If the desired method cannot be invoked on the target object - * @throws NoSuchMethodException If the desired method of the target class with the specified name and arguments cannot be found - * @see #getMethod(Class, String, Class...) - * @see DataType#getPrimitive(Object[]) - */ - public static Object invokeMethod(Object instance, Class clazz, String methodName, Object... arguments) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException { - return getMethod(clazz, methodName, DataType.getPrimitive(arguments)).invoke(instance, arguments); - } + /** + * Invokes a method of the target class on an object with the given arguments + * + * @param instance Target object + * @param clazz Target class + * @param methodName Name of the desired method + * @param arguments Arguments which are used to invoke the desired method + * @return The result of invoking the desired method on the target object + * @throws IllegalAccessException If the desired method cannot be accessed due to certain circumstances + * @throws IllegalArgumentException If the types of the arguments do not match the parameter types of the method (this should not occur since it searches for a method with the types of the arguments) + * @throws InvocationTargetException If the desired method cannot be invoked on the target object + * @throws NoSuchMethodException If the desired method of the target class with the specified name and arguments cannot be found + * @see #getMethod(Class, String, Class...) + * @see DataType#getPrimitive(Object[]) + */ + public static Object invokeMethod(Object instance, Class clazz, String methodName, Object... arguments) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException { + return getMethod(clazz, methodName, DataType.getPrimitive(arguments)).invoke(instance, arguments); + } - /** - * Invokes a method of a desired class on an object with the given arguments - * - * @param instance Target object - * @param className Name of the desired target class - * @param packageType Package where the desired target class is located - * @param methodName Name of the desired method - * @param arguments Arguments which are used to invoke the desired method - * @return The result of invoking the desired method on the target object - * @throws IllegalAccessException If the desired method cannot be accessed due to certain circumstances - * @throws IllegalArgumentException If the types of the arguments do not match the parameter types of the method (this should not occur since it searches for a method with the types of the arguments) - * @throws InvocationTargetException If the desired method cannot be invoked on the target object - * @throws NoSuchMethodException If the desired method of the desired target class with the specified name and arguments cannot be found - * @throws ClassNotFoundException If the desired target class with the specified name and package cannot be found - * @see #getClass() (String, PackageType) - * @see #invokeMethod(Object, Class, String, Object...) - */ - public static Object invokeMethod(Object instance, String className, PackageType packageType, String methodName, Object... arguments) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, ClassNotFoundException { - return invokeMethod(instance, packageType.getClass(className), methodName, arguments); - } + /** + * Invokes a method of a desired class on an object with the given arguments + * + * @param instance Target object + * @param className Name of the desired target class + * @param packageType Package where the desired target class is located + * @param methodName Name of the desired method + * @param arguments Arguments which are used to invoke the desired method + * @return The result of invoking the desired method on the target object + * @throws IllegalAccessException If the desired method cannot be accessed due to certain circumstances + * @throws IllegalArgumentException If the types of the arguments do not match the parameter types of the method (this should not occur since it searches for a method with the types of the arguments) + * @throws InvocationTargetException If the desired method cannot be invoked on the target object + * @throws NoSuchMethodException If the desired method of the desired target class with the specified name and arguments cannot be found + * @throws ClassNotFoundException If the desired target class with the specified name and package cannot be found + * @see #getClass() (String, PackageType) + * @see #invokeMethod(Object, Class, String, Object...) + */ + public static Object invokeMethod(Object instance, String className, PackageType packageType, String methodName, Object... arguments) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, ClassNotFoundException { + return invokeMethod(instance, packageType.getClass(className), methodName, arguments); + } - /** - * Returns a field of the target class with the given name - * - * @param clazz Target class - * @param declared Whether the desired field is declared or not - * @param fieldName Name of the desired field - * @return The field of the target class with the specified name - * @throws NoSuchFieldException If the desired field of the given class cannot be found - * @throws SecurityException If the desired field cannot be made accessible - */ - public static Field getField(Class clazz, boolean declared, String fieldName) throws NoSuchFieldException, SecurityException { - Field field = declared ? clazz.getDeclaredField(fieldName) : clazz.getField(fieldName); - field.setAccessible(true); - return field; - } + /** + * Returns a field of the target class with the given name + * + * @param clazz Target class + * @param declared Whether the desired field is declared or not + * @param fieldName Name of the desired field + * @return The field of the target class with the specified name + * @throws NoSuchFieldException If the desired field of the given class cannot be found + * @throws SecurityException If the desired field cannot be made accessible + */ + public static Field getField(Class clazz, boolean declared, String fieldName) throws NoSuchFieldException, SecurityException { + Field field = declared ? clazz.getDeclaredField(fieldName) : clazz.getField(fieldName); + field.setAccessible(true); + return field; + } - /** - * Returns a field of a desired class with the given name - * - * @param className Name of the desired target class - * @param packageType Package where the desired target class is located - * @param declared Whether the desired field is declared or not - * @param fieldName Name of the desired field - * @return The field of the desired target class with the specified name - * @throws NoSuchFieldException If the desired field of the desired class cannot be found - * @throws SecurityException If the desired field cannot be made accessible - * @throws ClassNotFoundException If the desired target class with the specified name and package cannot be found - * @see #getField(Class, boolean, String) - */ - public static Field getField(String className, PackageType packageType, boolean declared, String fieldName) throws NoSuchFieldException, SecurityException, ClassNotFoundException { - return getField(packageType.getClass(className), declared, fieldName); - } + /** + * Returns a field of a desired class with the given name + * + * @param className Name of the desired target class + * @param packageType Package where the desired target class is located + * @param declared Whether the desired field is declared or not + * @param fieldName Name of the desired field + * @return The field of the desired target class with the specified name + * @throws NoSuchFieldException If the desired field of the desired class cannot be found + * @throws SecurityException If the desired field cannot be made accessible + * @throws ClassNotFoundException If the desired target class with the specified name and package cannot be found + * @see #getField(Class, boolean, String) + */ + public static Field getField(String className, PackageType packageType, boolean declared, String fieldName) throws NoSuchFieldException, SecurityException, ClassNotFoundException { + return getField(packageType.getClass(className), declared, fieldName); + } - /** - * Returns the value of a field of the given class of an object - * - * @param instance Target object - * @param clazz Target class - * @param declared Whether the desired field is declared or not - * @param fieldName Name of the desired field - * @return The value of field of the target object - * @throws IllegalArgumentException If the target object does not feature the desired field - * @throws IllegalAccessException If the desired field cannot be accessed - * @throws NoSuchFieldException If the desired field of the target class cannot be found - * @throws SecurityException If the desired field cannot be made accessible - * @see #getField(Class, boolean, String) - */ - public static Object getValue(Object instance, Class clazz, boolean declared, String fieldName) throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException { - return getField(clazz, declared, fieldName).get(instance); - } + /** + * Returns the value of a field of the given class of an object + * + * @param instance Target object + * @param clazz Target class + * @param declared Whether the desired field is declared or not + * @param fieldName Name of the desired field + * @return The value of field of the target object + * @throws IllegalArgumentException If the target object does not feature the desired field + * @throws IllegalAccessException If the desired field cannot be accessed + * @throws NoSuchFieldException If the desired field of the target class cannot be found + * @throws SecurityException If the desired field cannot be made accessible + * @see #getField(Class, boolean, String) + */ + public static Object getValue(Object instance, Class clazz, boolean declared, String fieldName) throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException { + return getField(clazz, declared, fieldName).get(instance); + } - /** - * Returns the value of a field of a desired class of an object - * - * @param instance Target object - * @param className Name of the desired target class - * @param packageType Package where the desired target class is located - * @param declared Whether the desired field is declared or not - * @param fieldName Name of the desired field - * @return The value of field of the target object - * @throws IllegalArgumentException If the target object does not feature the desired field - * @throws IllegalAccessException If the desired field cannot be accessed - * @throws NoSuchFieldException If the desired field of the desired class cannot be found - * @throws SecurityException If the desired field cannot be made accessible - * @throws ClassNotFoundException If the desired target class with the specified name and package cannot be found - * @see #getValue(Object, Class, boolean, String) - */ - public static Object getValue(Object instance, String className, PackageType packageType, boolean declared, String fieldName) throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException, ClassNotFoundException { - return getValue(instance, packageType.getClass(className), declared, fieldName); - } + /** + * Returns the value of a field of a desired class of an object + * + * @param instance Target object + * @param className Name of the desired target class + * @param packageType Package where the desired target class is located + * @param declared Whether the desired field is declared or not + * @param fieldName Name of the desired field + * @return The value of field of the target object + * @throws IllegalArgumentException If the target object does not feature the desired field + * @throws IllegalAccessException If the desired field cannot be accessed + * @throws NoSuchFieldException If the desired field of the desired class cannot be found + * @throws SecurityException If the desired field cannot be made accessible + * @throws ClassNotFoundException If the desired target class with the specified name and package cannot be found + * @see #getValue(Object, Class, boolean, String) + */ + public static Object getValue(Object instance, String className, PackageType packageType, boolean declared, String fieldName) throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException, ClassNotFoundException { + return getValue(instance, packageType.getClass(className), declared, fieldName); + } - /** - * Returns the value of a field with the given name of an object - * - * @param instance Target object - * @param declared Whether the desired field is declared or not - * @param fieldName Name of the desired field - * @return The value of field of the target object - * @throws IllegalArgumentException If the target object does not feature the desired field (should not occur since it searches for a field with the given name in the class of the object) - * @throws IllegalAccessException If the desired field cannot be accessed - * @throws NoSuchFieldException If the desired field of the target object cannot be found - * @throws SecurityException If the desired field cannot be made accessible - * @see #getValue(Object, Class, boolean, String) - */ - public static Object getValue(Object instance, boolean declared, String fieldName) throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException { - return getValue(instance, instance.getClass(), declared, fieldName); - } + /** + * Returns the value of a field with the given name of an object + * + * @param instance Target object + * @param declared Whether the desired field is declared or not + * @param fieldName Name of the desired field + * @return The value of field of the target object + * @throws IllegalArgumentException If the target object does not feature the desired field (should not occur since it searches for a field with the given name in the class of the object) + * @throws IllegalAccessException If the desired field cannot be accessed + * @throws NoSuchFieldException If the desired field of the target object cannot be found + * @throws SecurityException If the desired field cannot be made accessible + * @see #getValue(Object, Class, boolean, String) + */ + public static Object getValue(Object instance, boolean declared, String fieldName) throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException { + return getValue(instance, instance.getClass(), declared, fieldName); + } - /** - * Sets the value of a field of the given class of an object - * - * @param instance Target object - * @param clazz Target class - * @param declared Whether the desired field is declared or not - * @param fieldName Name of the desired field - * @param value New value - * @throws IllegalArgumentException If the type of the value does not match the type of the desired field - * @throws IllegalAccessException If the desired field cannot be accessed - * @throws NoSuchFieldException If the desired field of the target class cannot be found - * @throws SecurityException If the desired field cannot be made accessible - * @see #getField(Class, boolean, String) - */ - public static void setValue(Object instance, Class clazz, boolean declared, String fieldName, Object value) throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException { - getField(clazz, declared, fieldName).set(instance, value); - } + /** + * Sets the value of a field of the given class of an object + * + * @param instance Target object + * @param clazz Target class + * @param declared Whether the desired field is declared or not + * @param fieldName Name of the desired field + * @param value New value + * @throws IllegalArgumentException If the type of the value does not match the type of the desired field + * @throws IllegalAccessException If the desired field cannot be accessed + * @throws NoSuchFieldException If the desired field of the target class cannot be found + * @throws SecurityException If the desired field cannot be made accessible + * @see #getField(Class, boolean, String) + */ + public static void setValue(Object instance, Class clazz, boolean declared, String fieldName, Object value) throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException { + getField(clazz, declared, fieldName).set(instance, value); + } - /** - * Sets the value of a field of a desired class of an object - * - * @param instance Target object - * @param className Name of the desired target class - * @param packageType Package where the desired target class is located - * @param declared Whether the desired field is declared or not - * @param fieldName Name of the desired field - * @param value New value - * @throws IllegalArgumentException If the type of the value does not match the type of the desired field - * @throws IllegalAccessException If the desired field cannot be accessed - * @throws NoSuchFieldException If the desired field of the desired class cannot be found - * @throws SecurityException If the desired field cannot be made accessible - * @throws ClassNotFoundException If the desired target class with the specified name and package cannot be found - * @see #setValue(Object, Class, boolean, String, Object) - */ - public static void setValue(Object instance, String className, PackageType packageType, boolean declared, String fieldName, Object value) throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException, ClassNotFoundException { - setValue(instance, packageType.getClass(className), declared, fieldName, value); - } + /** + * Sets the value of a field of a desired class of an object + * + * @param instance Target object + * @param className Name of the desired target class + * @param packageType Package where the desired target class is located + * @param declared Whether the desired field is declared or not + * @param fieldName Name of the desired field + * @param value New value + * @throws IllegalArgumentException If the type of the value does not match the type of the desired field + * @throws IllegalAccessException If the desired field cannot be accessed + * @throws NoSuchFieldException If the desired field of the desired class cannot be found + * @throws SecurityException If the desired field cannot be made accessible + * @throws ClassNotFoundException If the desired target class with the specified name and package cannot be found + * @see #setValue(Object, Class, boolean, String, Object) + */ + public static void setValue(Object instance, String className, PackageType packageType, boolean declared, String fieldName, Object value) throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException, ClassNotFoundException { + setValue(instance, packageType.getClass(className), declared, fieldName, value); + } - /** - * Sets the value of a field with the given name of an object - * - * @param instance Target object - * @param declared Whether the desired field is declared or not - * @param fieldName Name of the desired field - * @param value New value - * @throws IllegalArgumentException If the type of the value does not match the type of the desired field - * @throws IllegalAccessException If the desired field cannot be accessed - * @throws NoSuchFieldException If the desired field of the target object cannot be found - * @throws SecurityException If the desired field cannot be made accessible - * @see #setValue(Object, Class, boolean, String, Object) - */ - public static void setValue(Object instance, boolean declared, String fieldName, Object value) throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException { - setValue(instance, instance.getClass(), declared, fieldName, value); - } + /** + * Sets the value of a field with the given name of an object + * + * @param instance Target object + * @param declared Whether the desired field is declared or not + * @param fieldName Name of the desired field + * @param value New value + * @throws IllegalArgumentException If the type of the value does not match the type of the desired field + * @throws IllegalAccessException If the desired field cannot be accessed + * @throws NoSuchFieldException If the desired field of the target object cannot be found + * @throws SecurityException If the desired field cannot be made accessible + * @see #setValue(Object, Class, boolean, String, Object) + */ + public static void setValue(Object instance, boolean declared, String fieldName, Object value) throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException { + setValue(instance, instance.getClass(), declared, fieldName, value); + } - /** - * 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 - * @since 1.0 - */ - public enum PackageType { - MINECRAFT_SERVER("net.minecraft.server." + getServerVersion()), - CRAFTBUKKIT("org.bukkit.craftbukkit." + getServerVersion()), - CRAFTBUKKIT_BLOCK(CRAFTBUKKIT, "block"), - CRAFTBUKKIT_CHUNKIO(CRAFTBUKKIT, "chunkio"), - CRAFTBUKKIT_COMMAND(CRAFTBUKKIT, "command"), - CRAFTBUKKIT_CONVERSATIONS(CRAFTBUKKIT, "conversations"), - CRAFTBUKKIT_ENCHANTMENS(CRAFTBUKKIT, "enchantments"), - CRAFTBUKKIT_ENTITY(CRAFTBUKKIT, "entity"), - CRAFTBUKKIT_EVENT(CRAFTBUKKIT, "event"), - CRAFTBUKKIT_GENERATOR(CRAFTBUKKIT, "generator"), - CRAFTBUKKIT_HELP(CRAFTBUKKIT, "help"), - CRAFTBUKKIT_INVENTORY(CRAFTBUKKIT, "inventory"), - CRAFTBUKKIT_MAP(CRAFTBUKKIT, "map"), - CRAFTBUKKIT_METADATA(CRAFTBUKKIT, "metadata"), - CRAFTBUKKIT_POTION(CRAFTBUKKIT, "potion"), - CRAFTBUKKIT_PROJECTILES(CRAFTBUKKIT, "projectiles"), - CRAFTBUKKIT_SCHEDULER(CRAFTBUKKIT, "scheduler"), - CRAFTBUKKIT_SCOREBOARD(CRAFTBUKKIT, "scoreboard"), - CRAFTBUKKIT_UPDATER(CRAFTBUKKIT, "updater"), - CRAFTBUKKIT_UTIL(CRAFTBUKKIT, "util"); + /** + * 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 + * @since 1.0 + */ + public enum PackageType { + MINECRAFT_SERVER("net.minecraft.server." + getServerVersion()), + CRAFTBUKKIT("org.bukkit.craftbukkit." + getServerVersion()), + CRAFTBUKKIT_BLOCK(CRAFTBUKKIT, "block"), + CRAFTBUKKIT_CHUNKIO(CRAFTBUKKIT, "chunkio"), + CRAFTBUKKIT_COMMAND(CRAFTBUKKIT, "command"), + CRAFTBUKKIT_CONVERSATIONS(CRAFTBUKKIT, "conversations"), + CRAFTBUKKIT_ENCHANTMENS(CRAFTBUKKIT, "enchantments"), + CRAFTBUKKIT_ENTITY(CRAFTBUKKIT, "entity"), + CRAFTBUKKIT_EVENT(CRAFTBUKKIT, "event"), + CRAFTBUKKIT_GENERATOR(CRAFTBUKKIT, "generator"), + CRAFTBUKKIT_HELP(CRAFTBUKKIT, "help"), + CRAFTBUKKIT_INVENTORY(CRAFTBUKKIT, "inventory"), + CRAFTBUKKIT_MAP(CRAFTBUKKIT, "map"), + CRAFTBUKKIT_METADATA(CRAFTBUKKIT, "metadata"), + CRAFTBUKKIT_POTION(CRAFTBUKKIT, "potion"), + CRAFTBUKKIT_PROJECTILES(CRAFTBUKKIT, "projectiles"), + CRAFTBUKKIT_SCHEDULER(CRAFTBUKKIT, "scheduler"), + CRAFTBUKKIT_SCOREBOARD(CRAFTBUKKIT, "scoreboard"), + CRAFTBUKKIT_UPDATER(CRAFTBUKKIT, "updater"), + CRAFTBUKKIT_UTIL(CRAFTBUKKIT, "util"); - private final String path; + private final String path; - /** - * Construct a new package type - * - * @param path Path of the package - */ - PackageType(String path) { - this.path = path; - } + /** + * Construct a new package type + * + * @param path Path of the package + */ + PackageType(String path) { + this.path = path; + } - /** - * Construct a new package type - * - * @param parent Parent package of the package - * @param path Path of the package - */ - PackageType(PackageType parent, String path) { - this(parent + "." + path); - } + /** + * Construct a new package type + * + * @param parent Parent package of the package + * @param path Path of the package + */ + PackageType(PackageType parent, String path) { + this(parent + "." + path); + } - /** - * Returns the version of your server - * - * @return The server version - */ - public static String getServerVersion() { - return Bukkit.getServer().getClass().getName().split("\\.")[3]; - } + /** + * Returns the version of your server + * + * @return The server version + */ + public static String getServerVersion() { + return Bukkit.getServer().getClass().getName().split("\\.")[3]; + } - /** - * Returns the path of this package type - * - * @return The path - */ - public String getPath() { - return path; - } + /** + * Returns the path of this package type + * + * @return The path + */ + public String getPath() { + return path; + } - /** - * Returns the class with the given name - * - * @param className Name of the desired class - * @return The class with the specified name - * @throws ClassNotFoundException If the desired class with the specified name and package cannot be found - */ - public Class getClass(String className) throws ClassNotFoundException { - return Class.forName(this + "." + className); - } + /** + * Returns the class with the given name + * + * @param className Name of the desired class + * @return The class with the specified name + * @throws ClassNotFoundException If the desired class with the specified name and package cannot be found + */ + public Class getClass(String className) throws ClassNotFoundException { + return Class.forName(this + "." + className); + } - // Override for convenience - @Override - public String toString() { - return path; - } - } + // Override for convenience + @Override + public String toString() { + return path; + } + } - /** - * 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 - * @since 1.0 - */ - public enum DataType { - BYTE(byte.class, Byte.class), - SHORT(short.class, Short.class), - INTEGER(int.class, Integer.class), - LONG(long.class, Long.class), - CHARACTER(char.class, Character.class), - FLOAT(float.class, Float.class), - DOUBLE(double.class, Double.class), - BOOLEAN(boolean.class, Boolean.class); + /** + * 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 + * @since 1.0 + */ + public enum DataType { + BYTE(byte.class, Byte.class), + SHORT(short.class, Short.class), + INTEGER(int.class, Integer.class), + LONG(long.class, Long.class), + CHARACTER(char.class, Character.class), + FLOAT(float.class, Float.class), + DOUBLE(double.class, Double.class), + BOOLEAN(boolean.class, Boolean.class); - private static final Map, DataType> CLASS_MAP = new HashMap, DataType>(); + private static final Map, DataType> CLASS_MAP = new HashMap, DataType>(); - // Initialize map for quick class lookup - static { - for (DataType type : values()) { - CLASS_MAP.put(type.primitive, type); - CLASS_MAP.put(type.reference, type); - } - } + // Initialize map for quick class lookup + static { + for (DataType type : values()) { + CLASS_MAP.put(type.primitive, type); + CLASS_MAP.put(type.reference, type); + } + } - private final Class primitive; - private final Class reference; + private final Class primitive; + private final Class reference; - /** - * Construct a new data type - * - * @param primitive Primitive class of this data type - * @param reference Reference class of this data type - */ - DataType(Class primitive, Class reference) { - this.primitive = primitive; - this.reference = reference; - } + /** + * Construct a new data type + * + * @param primitive Primitive class of this data type + * @param reference Reference class of this data type + */ + DataType(Class primitive, Class reference) { + this.primitive = primitive; + this.reference = reference; + } - /** - * Returns the data type with the given primitive/reference class - * - * @param clazz Primitive/Reference class of the data type - * @return The data type - */ - public static DataType fromClass(Class clazz) { - return CLASS_MAP.get(clazz); - } + /** + * Returns the data type with the given primitive/reference class + * + * @param clazz Primitive/Reference class of the data type + * @return The data type + */ + public static DataType fromClass(Class clazz) { + return CLASS_MAP.get(clazz); + } - /** - * Returns the primitive class of the data type with the given reference class - * - * @param clazz Reference class of the data type - * @return The primitive class - */ - public static Class getPrimitive(Class clazz) { - DataType type = fromClass(clazz); - return type == null ? clazz : type.getPrimitive(); - } + /** + * Returns the primitive class of the data type with the given reference class + * + * @param clazz Reference class of the data type + * @return The primitive class + */ + public static Class getPrimitive(Class clazz) { + DataType type = fromClass(clazz); + return type == null ? clazz : type.getPrimitive(); + } - /** - * Returns the reference class of the data type with the given primitive class - * - * @param clazz Primitive class of the data type - * @return The reference class - */ - public static Class getReference(Class clazz) { - DataType type = fromClass(clazz); - return type == null ? clazz : type.getReference(); - } + /** + * Returns the reference class of the data type with the given primitive class + * + * @param clazz Primitive class of the data type + * @return The reference class + */ + public static Class getReference(Class clazz) { + DataType type = fromClass(clazz); + return type == null ? clazz : type.getReference(); + } - /** - * Returns the primitive class array of the given class array - * - * @param classes Given class array - * @return The primitive class array - */ - public static Class[] getPrimitive(Class[] classes) { - int length = classes == null ? 0 : classes.length; - Class[] types = new Class[length]; - for (int index = 0; index < length; index++) { - types[index] = getPrimitive(classes[index]); - } - return types; - } + /** + * Returns the primitive class array of the given class array + * + * @param classes Given class array + * @return The primitive class array + */ + public static Class[] getPrimitive(Class[] classes) { + int length = classes == null ? 0 : classes.length; + Class[] types = new Class[length]; + for (int index = 0; index < length; index++) { + types[index] = getPrimitive(classes[index]); + } + return types; + } - /** - * Returns the reference class array of the given class array - * - * @param classes Given class array - * @return The reference class array - */ - public static Class[] getReference(Class[] classes) { - int length = classes == null ? 0 : classes.length; - Class[] types = new Class[length]; - for (int index = 0; index < length; index++) { - types[index] = getReference(classes[index]); - } - return types; - } + /** + * Returns the reference class array of the given class array + * + * @param classes Given class array + * @return The reference class array + */ + public static Class[] getReference(Class[] classes) { + int length = classes == null ? 0 : classes.length; + Class[] types = new Class[length]; + for (int index = 0; index < length; index++) { + types[index] = getReference(classes[index]); + } + return types; + } - /** - * Returns the primitive class array of the given object array - * - * @param objects Given object array - * @return The primitive class array - */ - public static Class[] getPrimitive(Object[] objects) { - int length = objects == null ? 0 : objects.length; - Class[] types = new Class[length]; - for (int index = 0; index < length; index++) { - types[index] = getPrimitive(objects[index].getClass()); - } - return types; - } + /** + * Returns the primitive class array of the given object array + * + * @param objects Given object array + * @return The primitive class array + */ + public static Class[] getPrimitive(Object[] objects) { + int length = objects == null ? 0 : objects.length; + Class[] types = new Class[length]; + for (int index = 0; index < length; index++) { + types[index] = getPrimitive(objects[index].getClass()); + } + return types; + } - /** - * Returns the reference class array of the given object array - * - * @param objects Given object array - * @return The reference class array - */ - public static Class[] getReference(Object[] objects) { - int length = objects == null ? 0 : objects.length; - Class[] types = new Class[length]; - for (int index = 0; index < length; index++) { - types[index] = getReference(objects[index].getClass()); - } - return types; - } + /** + * Returns the reference class array of the given object array + * + * @param objects Given object array + * @return The reference class array + */ + public static Class[] getReference(Object[] objects) { + int length = objects == null ? 0 : objects.length; + Class[] types = new Class[length]; + for (int index = 0; index < length; index++) { + types[index] = getReference(objects[index].getClass()); + } + return types; + } - /** - * Compares two class arrays on equivalence - * - * @param primary Primary class array - * @param secondary Class array which is compared to the primary array - * @return Whether these arrays are equal or not - */ - public static boolean compare(Class[] primary, Class[] secondary) { - if (primary == null || secondary == null || primary.length != secondary.length) { - return false; - } - for (int index = 0; index < primary.length; index++) { - Class primaryClass = primary[index]; - Class secondaryClass = secondary[index]; - if (primaryClass.equals(secondaryClass) || primaryClass.isAssignableFrom(secondaryClass)) { - continue; - } - return false; - } - return true; - } + /** + * Compares two class arrays on equivalence + * + * @param primary Primary class array + * @param secondary Class array which is compared to the primary array + * @return Whether these arrays are equal or not + */ + public static boolean compare(Class[] primary, Class[] secondary) { + if (primary == null || secondary == null || primary.length != secondary.length) { + return false; + } + for (int index = 0; index < primary.length; index++) { + Class primaryClass = primary[index]; + Class secondaryClass = secondary[index]; + if (primaryClass.equals(secondaryClass) || primaryClass.isAssignableFrom(secondaryClass)) { + continue; + } + return false; + } + return true; + } - /** - * Returns the primitive class of this data type - * - * @return The primitive class - */ - public Class getPrimitive() { - return primitive; - } + /** + * Returns the primitive class of this data type + * + * @return The primitive class + */ + public Class getPrimitive() { + return primitive; + } - /** - * Returns the reference class of this data type - * - * @return The reference class - */ - public Class getReference() { - return reference; - } - } + /** + * Returns the reference class of this data type + * + * @return The reference class + */ + public Class getReference() { + return reference; + } + } } \ No newline at end of file diff --git a/src/main/java/com/massivecraft/factions/util/PermissionsMapTypeAdapter.java b/src/main/java/com/massivecraft/factions/util/PermissionsMapTypeAdapter.java index c69f370c..fe5e160d 100644 --- a/src/main/java/com/massivecraft/factions/util/PermissionsMapTypeAdapter.java +++ b/src/main/java/com/massivecraft/factions/util/PermissionsMapTypeAdapter.java @@ -17,82 +17,82 @@ import java.util.logging.Level; public class PermissionsMapTypeAdapter implements JsonDeserializer>> { - @Override - public Map> deserialize(JsonElement json, Type type, JsonDeserializationContext context) throws JsonParseException { + @Override + public Map> deserialize(JsonElement json, Type type, JsonDeserializationContext context) throws JsonParseException { - try { - JsonObject obj = json.getAsJsonObject(); - if (obj == null) { - return null; - } + try { + JsonObject obj = json.getAsJsonObject(); + if (obj == null) { + return null; + } - Map> permissionsMap = new ConcurrentHashMap<>(); + Map> permissionsMap = new ConcurrentHashMap<>(); - // Top level is Relation - for (Map.Entry entry : obj.entrySet()) { - Permissable permissable = getPermissable(entry.getKey()); + // Top level is Relation + for (Map.Entry entry : obj.entrySet()) { + Permissable permissable = getPermissable(entry.getKey()); - if (permissable == null) { - continue; - } + if (permissable == null) { + continue; + } - // Second level is the map between action -> access - Map accessMap = new HashMap<>(); - for (Map.Entry entry2 : entry.getValue().getAsJsonObject().entrySet()) { - PermissableAction permissableAction = PermissableAction.fromString(entry2.getKey()); - if (permissableAction == null) { - switch (entry2.getKey()) { - case "frostwalk": - permissableAction = PermissableAction.FROST_WALK; - break; - case "painbuild": - permissableAction = PermissableAction.PAIN_BUILD; - break; - case "items": - permissableAction = PermissableAction.ITEM; - break; - } - } - Access access = Access.fromString(entry2.getValue().getAsString()); - accessMap.put(permissableAction, access); - } - permissionsMap.put(permissable, accessMap); - } + // Second level is the map between action -> access + Map accessMap = new HashMap<>(); + for (Map.Entry entry2 : entry.getValue().getAsJsonObject().entrySet()) { + PermissableAction permissableAction = PermissableAction.fromString(entry2.getKey()); + if (permissableAction == null) { + switch (entry2.getKey()) { + case "frostwalk": + permissableAction = PermissableAction.FROST_WALK; + break; + case "painbuild": + permissableAction = PermissableAction.PAIN_BUILD; + break; + case "items": + permissableAction = PermissableAction.ITEM; + break; + } + } + Access access = Access.fromString(entry2.getValue().getAsString()); + accessMap.put(permissableAction, access); + } + permissionsMap.put(permissable, accessMap); + } - return permissionsMap; + return permissionsMap; - } catch (Exception ex) { - P.p.log(Level.WARNING, "Error encountered while deserializing a PermissionsMap."); - ex.printStackTrace(); - return null; - } - } + } catch (Exception ex) { + P.p.log(Level.WARNING, "Error encountered while deserializing a PermissionsMap."); + ex.printStackTrace(); + return null; + } + } - private Permissable getPermissable(String name) { - // If name is uppercase then it is (probably, no way to completely know) valid if not begin conversion - if (name.equals(name.toUpperCase())) { - if (Role.fromString(name.toUpperCase()) != null) { - return Role.fromString(name.toUpperCase()); - } else if (Relation.fromString(name.toUpperCase()) != null) { - return Relation.fromString(name.toUpperCase()); - } else { - return null; - } - } else { - if (name.equals(TL.ROLE_RECRUIT.toString())) { - return Role.RECRUIT; - } else if (name.equals(TL.ROLE_NORMAL.toString())) { - return Role.NORMAL; - } else if (name.equals(TL.ROLE_MODERATOR.toString())) { - return Role.MODERATOR; - } else { - // If it is explicitly member and its old data then it refers to relation member not role, skip it - if (name.equals("member")) { - return null; - } - return Relation.fromString(name); - } - } - } + private Permissable getPermissable(String name) { + // If name is uppercase then it is (probably, no way to completely know) valid if not begin conversion + if (name.equals(name.toUpperCase())) { + if (Role.fromString(name.toUpperCase()) != null) { + return Role.fromString(name.toUpperCase()); + } else if (Relation.fromString(name.toUpperCase()) != null) { + return Relation.fromString(name.toUpperCase()); + } else { + return null; + } + } else { + if (name.equals(TL.ROLE_RECRUIT.toString())) { + return Role.RECRUIT; + } else if (name.equals(TL.ROLE_NORMAL.toString())) { + return Role.NORMAL; + } else if (name.equals(TL.ROLE_MODERATOR.toString())) { + return Role.MODERATOR; + } else { + // If it is explicitly member and its old data then it refers to relation member not role, skip it + if (name.equals("member")) { + return null; + } + return Relation.fromString(name); + } + } + } } diff --git a/src/main/java/com/massivecraft/factions/util/RelationUtil.java b/src/main/java/com/massivecraft/factions/util/RelationUtil.java index 0912b81c..4c656f84 100644 --- a/src/main/java/com/massivecraft/factions/util/RelationUtil.java +++ b/src/main/java/com/massivecraft/factions/util/RelationUtil.java @@ -11,101 +11,101 @@ import org.bukkit.ChatColor; public class RelationUtil { - public static String describeThatToMe(RelationParticipator that, RelationParticipator me, boolean ucfirst) { - String ret = ""; + public static String describeThatToMe(RelationParticipator that, RelationParticipator me, boolean ucfirst) { + String ret = ""; - Faction thatFaction = getFaction(that); - if (thatFaction == null) { - return "ERROR"; // ERROR - } + Faction thatFaction = getFaction(that); + if (thatFaction == null) { + return "ERROR"; // ERROR + } - Faction myFaction = getFaction(me); + 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 (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); - } + if (ucfirst) { + ret = TextUtil.upperCaseFirst(ret); + } - return "" + getColorOfThatToMe(that, me) + ret; - } + return "" + getColorOfThatToMe(that, me) + ret; + } - public static String describeThatToMe(RelationParticipator that, RelationParticipator me) { - return describeThatToMe(that, me, false); - } + 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) { + return getRelationTo(that, me, false); + } - public static Relation getRelationTo(RelationParticipator me, RelationParticipator that, boolean ignorePeaceful) { - Faction fthat = getFaction(that); - Faction fme = getFaction(me); + 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 == null || fme == null) { + return Relation.NEUTRAL; // ERROR + } - if (!fthat.isNormal() || !fme.isNormal()) { - return Relation.NEUTRAL; - } + if (!fthat.isNormal() || !fme.isNormal()) { + return Relation.NEUTRAL; + } - if (fthat.equals(fme)) { - return Relation.MEMBER; - } + if (fthat.equals(fme)) { + return Relation.MEMBER; + } - if (!ignorePeaceful && (fme.isPeaceful() || fthat.isPeaceful())) { - return Relation.NEUTRAL; - } + if (!ignorePeaceful && (fme.isPeaceful() || fthat.isPeaceful())) { + return Relation.NEUTRAL; + } - if (fme.getRelationWish(fthat).value >= fthat.getRelationWish(fme).value) { - return fthat.getRelationWish(fme); - } + if (fme.getRelationWish(fthat).value >= fthat.getRelationWish(fme).value) { + return fthat.getRelationWish(fme); + } - return fme.getRelationWish(fthat); - } + return fme.getRelationWish(fthat); + } - public static Faction getFaction(RelationParticipator rp) { - if (rp instanceof Faction) { - return (Faction) rp; - } + public static Faction getFaction(RelationParticipator rp) { + if (rp instanceof Faction) { + return (Faction) rp; + } - if (rp instanceof FPlayer) { - return ((FPlayer) rp).getFaction(); - } + if (rp instanceof FPlayer) { + return ((FPlayer) rp).getFaction(); + } - // ERROR - return null; - } + // ERROR + return null; + } - public static ChatColor getColorOfThatToMe(RelationParticipator that, RelationParticipator me) { - Faction thatFaction = getFaction(that); + 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; - } + 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(); - } + 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 f19537d6..6cde74f2 100644 --- a/src/main/java/com/massivecraft/factions/util/SpiralTask.java +++ b/src/main/java/com/massivecraft/factions/util/SpiralTask.java @@ -24,186 +24,186 @@ import java.util.logging.Level; 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 limit = 0; + // general task-related reference data + private transient World world = null; + private transient boolean readyToGo = false; + private transient int taskID = -1; + private transient int limit = 0; - // values for the spiral pattern routine - private transient int x = 0; - private transient int z = 0; - private transient boolean isZLeg = false; - private transient boolean isNeg = false; - private transient int length = -1; - private transient int current = 0; + // values for the spiral pattern routine + private transient int x = 0; + private transient int z = 0; + private transient boolean isZLeg = false; + private transient boolean isNeg = false; + private transient int length = -1; + private transient int current = 0; - @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; + @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; - this.world = Bukkit.getWorld(fLocation.getWorldName()); - if (this.world == null) { - P.p.log(Level.WARNING, "[SpiralTask] A valid world must be specified!"); - this.stop(); - return; - } + this.world = Bukkit.getWorld(fLocation.getWorldName()); + if (this.world == null) { + P.p.log(Level.WARNING, "[SpiralTask] A valid world must be specified!"); + this.stop(); + return; + } - this.x = (int) fLocation.getX(); - this.z = (int) fLocation.getZ(); + this.x = (int) fLocation.getX(); + this.z = (int) fLocation.getZ(); - this.readyToGo = true; + this.readyToGo = true; - // get this party started - this.setTaskID(Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(P.p, this, 2, 2)); - } + // get this party started + this.setTaskID(Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(P.p, this, 2, 2)); + } - private static long now() { - return System.currentTimeMillis(); - } + private static long now() { + return System.currentTimeMillis(); + } - /* - * This is where the necessary work is done; you'll need to override this method with whatever you want - * done at each chunk in the spiral pattern. - * Return false if the entire task needs to be aborted, otherwise return true to continue. - */ - public abstract boolean work(); + /* + * This is where the necessary work is done; you'll need to override this method with whatever you want + * done at each chunk in the spiral pattern. + * Return false if the entire task needs to be aborted, otherwise return true to continue. + */ + public abstract boolean work(); - /* - * Returns an FLocation pointing at the current chunk X and Z values. - */ - public final FLocation currentFLocation() { - return new FLocation(world.getName(), x, z); - } + /* + * Returns an FLocation pointing at the current chunk X and Z values. + */ + public final FLocation currentFLocation() { + return new FLocation(world.getName(), x, z); + } - /* - * Returns a Location pointing at the current chunk X and Z values. - * note that the Location is at the corner of the chunk, not the center. - */ - public final Location currentLocation() { - return new Location(world, FLocation.chunkToBlock(x), 65.0, FLocation.chunkToBlock(z)); - } + /* + * Returns a Location pointing at the current chunk X and Z values. + * note that the Location is at the corner of the chunk, not the center. + */ + public final Location currentLocation() { + return new Location(world, FLocation.chunkToBlock(x), 65.0, FLocation.chunkToBlock(z)); + } - /* - * Returns current chunk X and Z values. - */ - public final int getX() { - return x; - } + /* + * Returns current chunk X and Z values. + */ + public final int getX() { + return x; + } - /* - * Below are the guts of the class, which you normally wouldn't need to mess with. - */ + /* + * Below are the guts of the class, which you normally wouldn't need to mess with. + */ - public final int getZ() { - return z; - } + public final int getZ() { + return z; + } - public final void setTaskID(int ID) { - if (ID == -1) { - this.stop(); - } - taskID = ID; - } + public final void setTaskID(int ID) { + if (ID == -1) { + this.stop(); + } + taskID = ID; + } - public final void run() { - if (!this.valid() || !readyToGo) { - return; - } + public final void run() { + if (!this.valid() || !readyToGo) { + return; + } - // this is set so it only does one iteration at a time, no matter how frequently the timer fires - readyToGo = false; + // this is set so it only does one iteration at a time, no matter how frequently the timer fires + readyToGo = false; - // make sure we're still inside the specified radius - if (!this.insideRadius()) { - return; - } + // make sure we're still inside the specified radius + if (!this.insideRadius()) { + return; + } - // track this to keep one iteration from dragging on too long and possibly choking the system - long loopStartTime = now(); + // track this to keep one iteration from dragging on too long and possibly choking the system + long loopStartTime = now(); - // keep going until the task has been running for 20ms or more, then stop to take a breather - while (now() < loopStartTime + 20) { - // run the primary task on the current X/Z coordinates - if (!this.work()) { - this.finish(); - return; - } + // keep going until the task has been running for 20ms or more, then stop to take a breather + while (now() < loopStartTime + 20) { + // run the primary task on the current X/Z coordinates + if (!this.work()) { + this.finish(); + return; + } - // move on to next chunk in spiral - if (!this.moveToNext()) { - return; - } - } + // move on to next chunk in spiral + if (!this.moveToNext()) { + return; + } + } - // ready for the next iteration to run - readyToGo = true; - } + // ready for the next iteration to run + readyToGo = true; + } - // step through chunks in spiral pattern from center; returns false if we're done, otherwise returns true - public final boolean moveToNext() { - if (!this.valid()) { - return false; - } + // step through chunks in spiral pattern from center; returns false if we're done, otherwise returns true + public final boolean moveToNext() { + if (!this.valid()) { + return false; + } - // make sure we don't need to turn down the next leg of the spiral - if (current < length) { - current++; + // make sure we don't need to turn down the next leg of the spiral + if (current < length) { + current++; - // if we're outside the radius, we're done - if (!this.insideRadius()) { - return false; - } - } else { // one leg/side of the spiral down... - current = 0; - isZLeg ^= true; - // every second leg (between X and Z legs, negative or positive), length increases - if (isZLeg) { - isNeg ^= true; - length++; - } - } + // if we're outside the radius, we're done + if (!this.insideRadius()) { + return false; + } + } else { // one leg/side of the spiral down... + current = 0; + isZLeg ^= true; + // every second leg (between X and Z legs, negative or positive), length increases + if (isZLeg) { + isNeg ^= true; + length++; + } + } - // move one chunk further in the appropriate direction - if (isZLeg) { - z += (isNeg) ? -1 : 1; - } else { - x += (isNeg) ? -1 : 1; - } + // move one chunk further in the appropriate direction + if (isZLeg) { + z += (isNeg) ? -1 : 1; + } else { + x += (isNeg) ? -1 : 1; + } - return true; - } + return true; + } - public final boolean insideRadius() { - boolean inside = current < limit; - if (!inside) { - this.finish(); - } - return inside; - } + public final boolean insideRadius() { + boolean inside = current < limit; + if (!inside) { + this.finish(); + } + return inside; + } - // for successful completion - public void finish() { + // for successful completion + public void finish() { // P.p.log("SpiralTask successfully completed!"); - this.stop(); - } + this.stop(); + } - // we're done, whether finished or cancelled - public final void stop() { - if (!this.valid()) { - return; - } + // we're done, whether finished or cancelled + public final void stop() { + if (!this.valid()) { + return; + } - readyToGo = false; - Bukkit.getServer().getScheduler().cancelTask(taskID); - taskID = -1; - } + readyToGo = false; + Bukkit.getServer().getScheduler().cancelTask(taskID); + taskID = -1; + } - // is this task still valid/workable? - public final boolean valid() { - return taskID != -1; - } + // is this task still valid/workable? + public final boolean valid() { + 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 index 3dd1da5e..e579eb92 100644 --- a/src/main/java/com/massivecraft/factions/util/UtilFly.java +++ b/src/main/java/com/massivecraft/factions/util/UtilFly.java @@ -11,86 +11,86 @@ import org.bukkit.Bukkit; public class UtilFly { - public static void run() { - if (!P.p.getConfig().getBoolean("enable-faction-flight")) - return; + public static void run() { + if (!P.p.getConfig().getBoolean("enable-faction-flight")) + return; - Bukkit.getScheduler().scheduleSyncRepeatingTask(P.p, () -> { - for (FPlayer fp : FPlayers.getInstance().getOnlinePlayers()) { - if (fp.isFlying()) fp.checkIfNearbyEnemies(); - } - }, 0, P.p.getConfig().getInt("fly-task-interval", 10)); - } + Bukkit.getScheduler().scheduleSyncRepeatingTask(P.p, () -> { + for (FPlayer fp : FPlayers.getInstance().getOnlinePlayers()) { + if (fp.isFlying()) fp.checkIfNearbyEnemies(); + } + }, 0, P.p.getConfig().getInt("fly-task-interval", 10)); + } - public static void setFly(FPlayer fp, boolean fly, boolean silent, boolean damage) { - if (!P.p.getConfig().getBoolean("enable-faction-flight")) - return; + public static void setFly(FPlayer fp, boolean fly, boolean silent, boolean damage) { + if (!P.p.getConfig().getBoolean("enable-faction-flight")) + return; - fp.getPlayer().setAllowFlight(fly); - fp.getPlayer().setFlying(fly); - fp.setFlying(fly); + fp.getPlayer().setAllowFlight(fly); + fp.getPlayer().setFlying(fly); + fp.setFlying(fly); - if (!silent) { - if (!damage) { - fp.msg(TL.COMMAND_FLY_CHANGE, fly ? "enabled" : "disabled"); - } else { - fp.msg(TL.COMMAND_FLY_DAMAGE); - } - } + if (!silent) { + if (!damage) { + fp.msg(TL.COMMAND_FLY_CHANGE, fly ? "enabled" : "disabled"); + } else { + fp.msg(TL.COMMAND_FLY_DAMAGE); + } + } - setFallDamage(fp, fly, damage); - } + setFallDamage(fp, fly, damage); + } - public static void checkFly(FPlayer me, Faction factionTo) { - if (!P.p.getConfig().getBoolean("enable-faction-flight")) - return; + public static void checkFly(FPlayer me, Faction factionTo) { + if (!P.p.getConfig().getBoolean("enable-faction-flight")) + return; - if (me.isAdminBypassing() && me.isFlying()) - return; + if (me.isAdminBypassing() && me.isFlying()) + return; - if (!me.isFlying()) { - if (me.isAdminBypassing()) { - UtilFly.setFly(me, true, false, false); - return; - } + if (!me.isFlying()) { + if (me.isAdminBypassing()) { + UtilFly.setFly(me, true, false, false); + return; + } - if (factionTo == me.getFaction() && me.getPlayer().hasPermission("factions.fly")) { - UtilFly.setFly(me, true, false, false); - } else { - 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())) { - UtilFly.setFly(me, true, false, false); - } - } - } else { - Relation 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())) { - UtilFly.setFly(me, false, false, false); - } - } - } + if (factionTo == me.getFaction() && me.getPlayer().hasPermission("factions.fly")) { + UtilFly.setFly(me, true, false, false); + } else { + 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())) { + UtilFly.setFly(me, true, false, false); + } + } + } else { + Relation 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())) { + UtilFly.setFly(me, false, false, false); + } + } + } - public static void setFallDamage(FPlayer fp, boolean fly, boolean damage) { - if (!fly) { - if (!damage) { - fp.sendMessage(TL.COMMAND_FLY_COOLDOWN.toString().replace("{amount}", P.p.getConfig().getInt("fly-falldamage-cooldown", 3) + "")); - } + public static void setFallDamage(FPlayer fp, boolean fly, boolean damage) { + if (!fly) { + if (!damage) { + fp.sendMessage(TL.COMMAND_FLY_COOLDOWN.toString().replace("{amount}", P.p.getConfig().getInt("fly-falldamage-cooldown", 3) + "")); + } - int cooldown = P.p.getConfig().getInt("fly-falldamage-cooldown", 3); - if (cooldown > 0) { - fp.setTakeFallDamage(false); - Bukkit.getScheduler().runTaskLater(P.p, () -> fp.setTakeFallDamage(true), 20L * cooldown); - } - } - } + int cooldown = P.p.getConfig().getInt("fly-falldamage-cooldown", 3); + if (cooldown > 0) { + fp.setTakeFallDamage(false); + Bukkit.getScheduler().runTaskLater(P.p, () -> fp.setTakeFallDamage(true), 20L * cooldown); + } + } + } } diff --git a/src/main/java/com/massivecraft/factions/util/VisualizeUtil.java b/src/main/java/com/massivecraft/factions/util/VisualizeUtil.java index 06388637..54825151 100644 --- a/src/main/java/com/massivecraft/factions/util/VisualizeUtil.java +++ b/src/main/java/com/massivecraft/factions/util/VisualizeUtil.java @@ -9,60 +9,60 @@ import java.util.*; public class VisualizeUtil { - protected static Map> playerLocations = new HashMap<>(); + protected static Map> playerLocations = new HashMap<>(); - public static Set getPlayerLocations(Player player) { - return getPlayerLocations(player.getUniqueId()); - } + public static Set getPlayerLocations(Player player) { + return getPlayerLocations(player.getUniqueId()); + } - public static Set getPlayerLocations(UUID uuid) { - Set ret = playerLocations.computeIfAbsent(uuid, k -> new HashSet<>()); - return ret; - } + public static Set getPlayerLocations(UUID uuid) { + Set ret = playerLocations.computeIfAbsent(uuid, k -> new HashSet<>()); + 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 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 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 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 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(); - } + @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 2a16cb2b..965e7095 100644 --- a/src/main/java/com/massivecraft/factions/util/WarmUpUtil.java +++ b/src/main/java/com/massivecraft/factions/util/WarmUpUtil.java @@ -6,34 +6,34 @@ import com.massivecraft.factions.zcore.util.TL; public class WarmUpUtil { - /** - * @param player The player to notify. - * @param translationKey The translation key used for notifying. - * @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) { - if (delay > 0) { - if (player.isWarmingUp()) { - player.msg(TL.WARMUPS_ALREADY); - } else { - player.msg(translationKey.format(action, delay)); - int id = P.p.getServer().getScheduler().runTaskLater(P.p, () -> { - player.stopWarmup(); - runnable.run(); - }, delay * 20).getTaskId(); - player.addWarmup(warmup, id); - } - } else { - runnable.run(); - } - } + /** + * @param player The player to notify. + * @param translationKey The translation key used for notifying. + * @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) { + if (delay > 0) { + if (player.isWarmingUp()) { + player.msg(TL.WARMUPS_ALREADY); + } else { + player.msg(translationKey.format(action, delay)); + int id = P.p.getServer().getScheduler().runTaskLater(P.p, () -> { + player.stopWarmup(); + runnable.run(); + }, delay * 20).getTaskId(); + player.addWarmup(warmup, id); + } + } else { + runnable.run(); + } + } - public enum Warmup { - HOME, WARP, FLIGHT, BANNER, CHECKPOINT - } + public enum Warmup { + HOME, WARP, FLIGHT, BANNER, CHECKPOINT + } } diff --git a/src/main/java/com/massivecraft/factions/util/XMaterial.java b/src/main/java/com/massivecraft/factions/util/XMaterial.java index 4d6f8fb5..a238aa61 100644 --- a/src/main/java/com/massivecraft/factions/util/XMaterial.java +++ b/src/main/java/com/massivecraft/factions/util/XMaterial.java @@ -1318,7 +1318,8 @@ public enum XMaterial { */ public static String getExactMajorVersion(String version) { // getBukkitVersion() - if (version.contains("SNAPSHOT") || version.contains("-R")) version = version.substring(0, version.indexOf("-")); + if (version.contains("SNAPSHOT") || version.contains("-R")) + version = version.substring(0, version.indexOf("-")); // getVersion() if (version.contains("git")) version = version.substring(version.indexOf("MC:") + 4).replace(")", ""); if (version.split(Pattern.quote(".")).length > 2) version = version.substring(0, version.lastIndexOf(".")); @@ -1334,7 +1335,8 @@ public enum XMaterial { */ private static MinecraftVersion valueOfVersion(String version) { version = getExactMajorVersion(version); - if (version.equals("1.10") || version.equals("1.11") || version.equals("1.12")) return MinecraftVersion.VERSION_1_9; + if (version.equals("1.10") || version.equals("1.11") || version.equals("1.12")) + return MinecraftVersion.VERSION_1_9; version = version.replace(".", "_"); if (!version.startsWith("VERSION_")) version = "VERSION_" + version; String check = version; diff --git a/src/main/java/com/massivecraft/factions/zcore/CommandVisibility.java b/src/main/java/com/massivecraft/factions/zcore/CommandVisibility.java index 2bc4a19d..66ea11eb 100644 --- a/src/main/java/com/massivecraft/factions/zcore/CommandVisibility.java +++ b/src/main/java/com/massivecraft/factions/zcore/CommandVisibility.java @@ -1,7 +1,7 @@ package com.massivecraft.factions.zcore; public enum CommandVisibility { - VISIBLE, // Visible commands are visible to anyone. Even those who don't have permission to use it or is of invalid sender type. - SECRET, // Secret commands are visible only to those who can use the command. These commands are usually some kind of admin commands. - INVISIBLE // Invisible commands are invisible to everyone, even those who can use the command. + VISIBLE, // Visible commands are visible to anyone. Even those who don't have permission to use it or is of invalid sender type. + SECRET, // Secret commands are visible only to those who can use the command. These commands are usually some kind of admin commands. + INVISIBLE // Invisible commands are invisible to everyone, even those who can use the command. } diff --git a/src/main/java/com/massivecraft/factions/zcore/MCommand.java b/src/main/java/com/massivecraft/factions/zcore/MCommand.java index a2a705d8..5a3012a9 100644 --- a/src/main/java/com/massivecraft/factions/zcore/MCommand.java +++ b/src/main/java/com/massivecraft/factions/zcore/MCommand.java @@ -23,463 +23,463 @@ import java.util.UUID; public abstract class MCommand { - public T p; - - // The sub-commands to this command - public List> subCommands; - // The different names this commands will react to - public List aliases; - public boolean allowNoSlashAccess; - // Information on the args - public List requiredArgs; - public LinkedHashMap optionalArgs; - public boolean errorOnToManyArgs = true; - public List helpLong; - public CommandVisibility visibility; - // Some information on permissions - public boolean senderMustBePlayer; - public boolean senderMustHaveFaction; - public String permission; - // Information available on execution of the command - public CommandSender sender; // Will always be set - public Player me; // Will only be set when the sender is a player - public boolean senderIsConsole; - public List args; // Will contain the arguments, or and empty list if there are none. - public List> commandChain = new ArrayList<>(); // The command chain used to execute this command - // FIELD: Help Short - // This field may be left blank and will in such case be loaded from the permissions node instead. - // Thus make sure the permissions node description is an action description like "eat hamburgers" or "do admin stuff". - private String helpShort; - - public MCommand(T p) { - this.p = p; - - this.permission = null; - - this.allowNoSlashAccess = false; - - this.subCommands = new ArrayList<>(); - this.aliases = new ArrayList<>(); - - this.requiredArgs = new ArrayList<>(); - this.optionalArgs = new LinkedHashMap<>(); - - this.helpShort = null; - this.helpLong = new ArrayList<>(); - this.visibility = CommandVisibility.VISIBLE; - } - - public void addSubCommand(MCommand subCommand) { - subCommand.commandChain.addAll(this.commandChain); - subCommand.commandChain.add(this); - this.subCommands.add(subCommand); - } - - public String getHelpShort() { - return this.helpShort != null ? this.helpShort : getUsageTranslation().toString(); - } - - public void setHelpShort(String val) { - this.helpShort = val; - } - - public abstract TL getUsageTranslation(); - - public void setCommandSender(CommandSender sender) { - this.sender = sender; - if (sender instanceof Player) { - this.me = (Player) sender; - this.senderIsConsole = false; - } else { - this.me = null; - 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 - setCommandSender(sender); - this.args = args; - this.commandChain = commandChain; - - // Is there a matching sub command? - if (args.size() > 0) { - for (MCommand subCommand : this.subCommands) { - if (subCommand.aliases.contains(args.get(0).toLowerCase())) { - args.remove(0); - commandChain.add(this); - subCommand.execute(sender, args, commandChain); - return; - } - } - } - - if (!validCall(this.sender, this.args)) { - return; - } - - if (!this.isEnabled()) { - return; - } - - perform(); - } - - public void execute(CommandSender sender, List args) { - execute(sender, args, new ArrayList<>()); - } - - // This is where the command action is performed. - public abstract void perform(); - - - // -------------------------------------------- // - // Call Validation - // -------------------------------------------- // - - /** - * In this method we validate that all prerequisites to perform this command has been met. - * - * @param sender of the command - * @param args of the command - * @return true if valid, false if not. - */ - // TODO: There should be a boolean for silence - public boolean validCall(CommandSender sender, List args) { - return validSenderType(sender, true) && validSenderPermissions(sender, true) && validArgs(args, sender); - } - - public boolean isEnabled() { - return true; - } - - - public boolean validSenderType(CommandSender sender, boolean informSenderIfNot) { - if (this.senderMustBePlayer && !(sender instanceof Player)) { - if (informSenderIfNot) { - msg(TL.GENERIC_PLAYERONLY); - } - return false; - - } - return !this.senderMustHaveFaction || !FPlayers.getInstance().getByPlayer((Player) sender).hasFaction(); - } - - public boolean validSenderPermissions(CommandSender sender, boolean informSenderIfNot) { - return this.permission == null || p.perm.has(sender, this.permission, informSenderIfNot); - } - - public boolean validArgs(List args, CommandSender sender) { - if (args.size() < this.requiredArgs.size()) { - if (sender != null) { - msg(TL.GENERIC_ARGS_TOOFEW); - sender.sendMessage(this.getUseageTemplate()); - } - return false; - } - - if (args.size() > this.requiredArgs.size() + this.optionalArgs.size() && this.errorOnToManyArgs) { - if (sender != null) { - // Get the to many string slice - List theToMany = args.subList(this.requiredArgs.size() + this.optionalArgs.size(), args.size()); - msg(TL.GENERIC_ARGS_TOOMANY, TextUtil.implode(theToMany, " ")); - sender.sendMessage(this.getUseageTemplate()); - } - return false; - } - return true; - } - - public boolean validArgs(List args) { - return this.validArgs(args, null); - } - - // -------------------------------------------- // - // Help and Usage information - // -------------------------------------------- // - - public String getUseageTemplate(List> commandChain, boolean addShortHelp) { - StringBuilder ret = new StringBuilder(); - ret.append(p.txt.parseTags("")); - ret.append('/'); - - for (MCommand mc : commandChain) { - ret.append(TextUtil.implode(mc.aliases, ",")); - ret.append(' '); - } - - ret.append(TextUtil.implode(this.aliases, ",")); - - List args = new ArrayList<>(); - - for (String requiredArg : this.requiredArgs) { - args.add("<" + requiredArg + ">"); - } - - for (Entry optionalArg : this.optionalArgs.entrySet()) { - String val = optionalArg.getValue(); - if (val == null) { - val = ""; - } else { - val = "=" + val; - } - args.add("[" + optionalArg.getKey() + val + "]"); - } - - if (args.size() > 0) { - ret.append(p.txt.parseTags(" ")); - ret.append(TextUtil.implode(args, " ")); - } - - if (addShortHelp) { - ret.append(p.txt.parseTags(" ")); - ret.append(this.getHelpShort()); - } - - return ret.toString(); - } - - public String getUseageTemplate(boolean addShortHelp) { - return getUseageTemplate(this.commandChain, addShortHelp); - } - - public String getUseageTemplate() { - return getUseageTemplate(false); - } - - // -------------------------------------------- // - // Message Sending Helpers - // -------------------------------------------- // - - public void msg(String str, Object... args) { - sender.sendMessage(p.txt.parse(str, args)); - } - - public void msg(TL translation, Object... args) { - sender.sendMessage(p.txt.parse(translation.toString(), args)); - } - - public void sendMessage(String msg) { - sender.sendMessage(msg); - } - - public void sendMessage(List msgs) { - for (String msg : msgs) { - this.sendMessage(msg); - } - } - - public void sendFancyMessage(FancyMessage message) { - message.send(sender); - } - - public void sendFancyMessage(List messages) { - for (FancyMessage m : messages) { - sendFancyMessage(m); - } - } - - public List getToolTips(FPlayer player) { - List lines = new ArrayList<>(); - for (String s : p.getConfig().getStringList("tooltips.show")) { - lines.add(ChatColor.translateAlternateColorCodes('&', replaceFPlayerTags(s, player))); - } - return lines; - } - - public List getToolTips(Faction faction) { - List lines = new ArrayList<>(); - for (String s : p.getConfig().getStringList("tooltips.list")) { - lines.add(ChatColor.translateAlternateColorCodes('&', replaceFactionTags(s, faction))); - } - return lines; - } - - public String replaceFPlayerTags(String s, FPlayer player) { - if (s.contains("{balance}")) { - String balance = Econ.isSetup() ? Econ.getFriendlyBalance(player) : "no balance"; - s = s.replace("{balance}", balance); - } - if (s.contains("{lastSeen}")) { - String humanized = DurationFormatUtils.formatDurationWords(System.currentTimeMillis() - player.getLastLoginTime(), true, true) + " ago"; - String lastSeen = player.isOnline() ? ChatColor.GREEN + "Online" : (System.currentTimeMillis() - player.getLastLoginTime() < 432000000 ? ChatColor.YELLOW + humanized : ChatColor.RED + humanized); - s = s.replace("{lastSeen}", lastSeen); - } - if (s.contains("{power}")) { - String power = player.getPowerRounded() + "/" + player.getPowerMaxRounded(); - s = s.replace("{power}", power); - } - if (s.contains("{group}")) { - String group = P.p.getPrimaryGroup(Bukkit.getOfflinePlayer(UUID.fromString(player.getId()))); - s = s.replace("{group}", group); - } - return s; - } - - public String replaceFactionTags(String s, Faction faction) { - if (s.contains("{power}")) { - s = s.replace("{power}", String.valueOf(faction.getPowerRounded())); - } - if (s.contains("{maxPower}")) { - s = s.replace("{maxPower}", String.valueOf(faction.getPowerMaxRounded())); - } - if (s.contains("{leader}")) { - FPlayer fLeader = faction.getFPlayerAdmin(); - String leader = fLeader == null ? "Server" : fLeader.getName().substring(0, fLeader.getName().length() > 14 ? 13 : fLeader.getName().length()); - s = s.replace("{leader}", leader); - } - if (s.contains("{chunks}")) { - s = s.replace("{chunks}", String.valueOf(faction.getLandRounded())); - } - if (s.contains("{members}")) { - s = s.replace("{members}", String.valueOf(faction.getSize())); - - } - if (s.contains("{online}")) { - s = s.replace("{online}", String.valueOf(faction.getOnlinePlayers().size())); - } - return s; - } - - // -------------------------------------------- // - // Argument Readers - // -------------------------------------------- // - - // Is set? ====================== - public boolean argIsSet(int idx) { - return this.args.size() >= idx + 1; - } - - // STRING ====================== - public String argAsString(int idx, String def) { - if (this.args.size() < idx + 1) { - return def; - } - return this.args.get(idx); - } - - public String argAsString(int idx) { - return this.argAsString(idx, null); - } - - // INT ====================== - public Integer strAsInt(String str, Integer def) { - if (str == null) { - return def; - } - try { - return Integer.parseInt(str); - } catch (Exception e) { - return def; - } - } - - public Integer argAsInt(int idx, Integer def) { - return strAsInt(this.argAsString(idx), def); - } - - public Integer argAsInt(int idx) { - return this.argAsInt(idx, null); - } - - // Double ====================== - public Double strAsDouble(String str, Double def) { - if (str == null) { - return def; - } - try { - return Double.parseDouble(str); - } catch (Exception e) { - return def; - } - } - - public Double argAsDouble(int idx, Double def) { - return strAsDouble(this.argAsString(idx), def); - } - - public Double argAsDouble(int idx) { - return this.argAsDouble(idx, null); - } - - // TODO: Go through the str conversion for the other arg-readers as well. - // Boolean ====================== - public Boolean strAsBool(String str) { - str = str.toLowerCase(); - return str.startsWith("y") || str.startsWith("t") || str.startsWith("on") || str.startsWith("+") || str.startsWith("1"); - } - - public Boolean argAsBool(int idx, boolean def) { - String str = this.argAsString(idx); - if (str == null) { - return def; - } - - return strAsBool(str); - } - - public Boolean argAsBool(int idx) { - return this.argAsBool(idx, false); - } - - // PLAYER ====================== - public Player strAsPlayer(String name, Player def, boolean msg) { - Player ret = def; - - if (name != null) { - Player player = Bukkit.getServer().getPlayer(name); - if (player != null) { - ret = player; - } - } - - if (msg && ret == null) { - this.msg(TL.GENERIC_NOPLAYERFOUND, name); - } - - return ret; - } - - public Player argAsPlayer(int idx, Player def, boolean msg) { - return this.strAsPlayer(this.argAsString(idx), def, msg); - } - - public Player argAsPlayer(int idx, Player def) { - return this.argAsPlayer(idx, def, true); - } - - public Player argAsPlayer(int idx) { - return this.argAsPlayer(idx, null); - } - - // BEST PLAYER MATCH ====================== - public Player strAsBestPlayerMatch(String name, Player def, boolean msg) { - Player ret = def; - - if (name != null) { - List players = Bukkit.getServer().matchPlayer(name); - if (players.size() > 0) { - ret = players.get(0); - } - } - - if (msg && ret == null) { - this.msg(TL.GENERIC_NOPLAYERMATCH, name); - } - - return ret; - } - - public Player argAsBestPlayerMatch(int idx, Player def, boolean msg) { - return this.strAsBestPlayerMatch(this.argAsString(idx), def, msg); - } - - public Player argAsBestPlayerMatch(int idx, Player def) { - return this.argAsBestPlayerMatch(idx, def, true); - } - - public Player argAsBestPlayerMatch(int idx) { - return this.argAsPlayer(idx, null); - } + public T p; + + // The sub-commands to this command + public List> subCommands; + // The different names this commands will react to + public List aliases; + public boolean allowNoSlashAccess; + // Information on the args + public List requiredArgs; + public LinkedHashMap optionalArgs; + public boolean errorOnToManyArgs = true; + public List helpLong; + public CommandVisibility visibility; + // Some information on permissions + public boolean senderMustBePlayer; + public boolean senderMustHaveFaction; + public String permission; + // Information available on execution of the command + public CommandSender sender; // Will always be set + public Player me; // Will only be set when the sender is a player + public boolean senderIsConsole; + public List args; // Will contain the arguments, or and empty list if there are none. + public List> commandChain = new ArrayList<>(); // The command chain used to execute this command + // FIELD: Help Short + // This field may be left blank and will in such case be loaded from the permissions node instead. + // Thus make sure the permissions node description is an action description like "eat hamburgers" or "do admin stuff". + private String helpShort; + + public MCommand(T p) { + this.p = p; + + this.permission = null; + + this.allowNoSlashAccess = false; + + this.subCommands = new ArrayList<>(); + this.aliases = new ArrayList<>(); + + this.requiredArgs = new ArrayList<>(); + this.optionalArgs = new LinkedHashMap<>(); + + this.helpShort = null; + this.helpLong = new ArrayList<>(); + this.visibility = CommandVisibility.VISIBLE; + } + + public void addSubCommand(MCommand subCommand) { + subCommand.commandChain.addAll(this.commandChain); + subCommand.commandChain.add(this); + this.subCommands.add(subCommand); + } + + public String getHelpShort() { + return this.helpShort != null ? this.helpShort : getUsageTranslation().toString(); + } + + public void setHelpShort(String val) { + this.helpShort = val; + } + + public abstract TL getUsageTranslation(); + + public void setCommandSender(CommandSender sender) { + this.sender = sender; + if (sender instanceof Player) { + this.me = (Player) sender; + this.senderIsConsole = false; + } else { + this.me = null; + 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 + setCommandSender(sender); + this.args = args; + this.commandChain = commandChain; + + // Is there a matching sub command? + if (args.size() > 0) { + for (MCommand subCommand : this.subCommands) { + if (subCommand.aliases.contains(args.get(0).toLowerCase())) { + args.remove(0); + commandChain.add(this); + subCommand.execute(sender, args, commandChain); + return; + } + } + } + + if (!validCall(this.sender, this.args)) { + return; + } + + if (!this.isEnabled()) { + return; + } + + perform(); + } + + public void execute(CommandSender sender, List args) { + execute(sender, args, new ArrayList<>()); + } + + // This is where the command action is performed. + public abstract void perform(); + + + // -------------------------------------------- // + // Call Validation + // -------------------------------------------- // + + /** + * In this method we validate that all prerequisites to perform this command has been met. + * + * @param sender of the command + * @param args of the command + * @return true if valid, false if not. + */ + // TODO: There should be a boolean for silence + public boolean validCall(CommandSender sender, List args) { + return validSenderType(sender, true) && validSenderPermissions(sender, true) && validArgs(args, sender); + } + + public boolean isEnabled() { + return true; + } + + + public boolean validSenderType(CommandSender sender, boolean informSenderIfNot) { + if (this.senderMustBePlayer && !(sender instanceof Player)) { + if (informSenderIfNot) { + msg(TL.GENERIC_PLAYERONLY); + } + return false; + + } + return !this.senderMustHaveFaction || !FPlayers.getInstance().getByPlayer((Player) sender).hasFaction(); + } + + public boolean validSenderPermissions(CommandSender sender, boolean informSenderIfNot) { + return this.permission == null || p.perm.has(sender, this.permission, informSenderIfNot); + } + + public boolean validArgs(List args, CommandSender sender) { + if (args.size() < this.requiredArgs.size()) { + if (sender != null) { + msg(TL.GENERIC_ARGS_TOOFEW); + sender.sendMessage(this.getUseageTemplate()); + } + return false; + } + + if (args.size() > this.requiredArgs.size() + this.optionalArgs.size() && this.errorOnToManyArgs) { + if (sender != null) { + // Get the to many string slice + List theToMany = args.subList(this.requiredArgs.size() + this.optionalArgs.size(), args.size()); + msg(TL.GENERIC_ARGS_TOOMANY, TextUtil.implode(theToMany, " ")); + sender.sendMessage(this.getUseageTemplate()); + } + return false; + } + return true; + } + + public boolean validArgs(List args) { + return this.validArgs(args, null); + } + + // -------------------------------------------- // + // Help and Usage information + // -------------------------------------------- // + + public String getUseageTemplate(List> commandChain, boolean addShortHelp) { + StringBuilder ret = new StringBuilder(); + ret.append(p.txt.parseTags("")); + ret.append('/'); + + for (MCommand mc : commandChain) { + ret.append(TextUtil.implode(mc.aliases, ",")); + ret.append(' '); + } + + ret.append(TextUtil.implode(this.aliases, ",")); + + List args = new ArrayList<>(); + + for (String requiredArg : this.requiredArgs) { + args.add("<" + requiredArg + ">"); + } + + for (Entry optionalArg : this.optionalArgs.entrySet()) { + String val = optionalArg.getValue(); + if (val == null) { + val = ""; + } else { + val = "=" + val; + } + args.add("[" + optionalArg.getKey() + val + "]"); + } + + if (args.size() > 0) { + ret.append(p.txt.parseTags(" ")); + ret.append(TextUtil.implode(args, " ")); + } + + if (addShortHelp) { + ret.append(p.txt.parseTags(" ")); + ret.append(this.getHelpShort()); + } + + return ret.toString(); + } + + public String getUseageTemplate(boolean addShortHelp) { + return getUseageTemplate(this.commandChain, addShortHelp); + } + + public String getUseageTemplate() { + return getUseageTemplate(false); + } + + // -------------------------------------------- // + // Message Sending Helpers + // -------------------------------------------- // + + public void msg(String str, Object... args) { + sender.sendMessage(p.txt.parse(str, args)); + } + + public void msg(TL translation, Object... args) { + sender.sendMessage(p.txt.parse(translation.toString(), args)); + } + + public void sendMessage(String msg) { + sender.sendMessage(msg); + } + + public void sendMessage(List msgs) { + for (String msg : msgs) { + this.sendMessage(msg); + } + } + + public void sendFancyMessage(FancyMessage message) { + message.send(sender); + } + + public void sendFancyMessage(List messages) { + for (FancyMessage m : messages) { + sendFancyMessage(m); + } + } + + public List getToolTips(FPlayer player) { + List lines = new ArrayList<>(); + for (String s : p.getConfig().getStringList("tooltips.show")) { + lines.add(ChatColor.translateAlternateColorCodes('&', replaceFPlayerTags(s, player))); + } + return lines; + } + + public List getToolTips(Faction faction) { + List lines = new ArrayList<>(); + for (String s : p.getConfig().getStringList("tooltips.list")) { + lines.add(ChatColor.translateAlternateColorCodes('&', replaceFactionTags(s, faction))); + } + return lines; + } + + public String replaceFPlayerTags(String s, FPlayer player) { + if (s.contains("{balance}")) { + String balance = Econ.isSetup() ? Econ.getFriendlyBalance(player) : "no balance"; + s = s.replace("{balance}", balance); + } + if (s.contains("{lastSeen}")) { + String humanized = DurationFormatUtils.formatDurationWords(System.currentTimeMillis() - player.getLastLoginTime(), true, true) + " ago"; + String lastSeen = player.isOnline() ? ChatColor.GREEN + "Online" : (System.currentTimeMillis() - player.getLastLoginTime() < 432000000 ? ChatColor.YELLOW + humanized : ChatColor.RED + humanized); + s = s.replace("{lastSeen}", lastSeen); + } + if (s.contains("{power}")) { + String power = player.getPowerRounded() + "/" + player.getPowerMaxRounded(); + s = s.replace("{power}", power); + } + if (s.contains("{group}")) { + String group = P.p.getPrimaryGroup(Bukkit.getOfflinePlayer(UUID.fromString(player.getId()))); + s = s.replace("{group}", group); + } + return s; + } + + public String replaceFactionTags(String s, Faction faction) { + if (s.contains("{power}")) { + s = s.replace("{power}", String.valueOf(faction.getPowerRounded())); + } + if (s.contains("{maxPower}")) { + s = s.replace("{maxPower}", String.valueOf(faction.getPowerMaxRounded())); + } + if (s.contains("{leader}")) { + FPlayer fLeader = faction.getFPlayerAdmin(); + String leader = fLeader == null ? "Server" : fLeader.getName().substring(0, fLeader.getName().length() > 14 ? 13 : fLeader.getName().length()); + s = s.replace("{leader}", leader); + } + if (s.contains("{chunks}")) { + s = s.replace("{chunks}", String.valueOf(faction.getLandRounded())); + } + if (s.contains("{members}")) { + s = s.replace("{members}", String.valueOf(faction.getSize())); + + } + if (s.contains("{online}")) { + s = s.replace("{online}", String.valueOf(faction.getOnlinePlayers().size())); + } + return s; + } + + // -------------------------------------------- // + // Argument Readers + // -------------------------------------------- // + + // Is set? ====================== + public boolean argIsSet(int idx) { + return this.args.size() >= idx + 1; + } + + // STRING ====================== + public String argAsString(int idx, String def) { + if (this.args.size() < idx + 1) { + return def; + } + return this.args.get(idx); + } + + public String argAsString(int idx) { + return this.argAsString(idx, null); + } + + // INT ====================== + public Integer strAsInt(String str, Integer def) { + if (str == null) { + return def; + } + try { + return Integer.parseInt(str); + } catch (Exception e) { + return def; + } + } + + public Integer argAsInt(int idx, Integer def) { + return strAsInt(this.argAsString(idx), def); + } + + public Integer argAsInt(int idx) { + return this.argAsInt(idx, null); + } + + // Double ====================== + public Double strAsDouble(String str, Double def) { + if (str == null) { + return def; + } + try { + return Double.parseDouble(str); + } catch (Exception e) { + return def; + } + } + + public Double argAsDouble(int idx, Double def) { + return strAsDouble(this.argAsString(idx), def); + } + + public Double argAsDouble(int idx) { + return this.argAsDouble(idx, null); + } + + // TODO: Go through the str conversion for the other arg-readers as well. + // Boolean ====================== + public Boolean strAsBool(String str) { + str = str.toLowerCase(); + return str.startsWith("y") || str.startsWith("t") || str.startsWith("on") || str.startsWith("+") || str.startsWith("1"); + } + + public Boolean argAsBool(int idx, boolean def) { + String str = this.argAsString(idx); + if (str == null) { + return def; + } + + return strAsBool(str); + } + + public Boolean argAsBool(int idx) { + return this.argAsBool(idx, false); + } + + // PLAYER ====================== + public Player strAsPlayer(String name, Player def, boolean msg) { + Player ret = def; + + if (name != null) { + Player player = Bukkit.getServer().getPlayer(name); + if (player != null) { + ret = player; + } + } + + if (msg && ret == null) { + this.msg(TL.GENERIC_NOPLAYERFOUND, name); + } + + return ret; + } + + public Player argAsPlayer(int idx, Player def, boolean msg) { + return this.strAsPlayer(this.argAsString(idx), def, msg); + } + + public Player argAsPlayer(int idx, Player def) { + return this.argAsPlayer(idx, def, true); + } + + public Player argAsPlayer(int idx) { + return this.argAsPlayer(idx, null); + } + + // BEST PLAYER MATCH ====================== + public Player strAsBestPlayerMatch(String name, Player def, boolean msg) { + Player ret = def; + + if (name != null) { + List players = Bukkit.getServer().matchPlayer(name); + if (players.size() > 0) { + ret = players.get(0); + } + } + + if (msg && ret == null) { + this.msg(TL.GENERIC_NOPLAYERMATCH, name); + } + + return ret; + } + + public Player argAsBestPlayerMatch(int idx, Player def, boolean msg) { + return this.strAsBestPlayerMatch(this.argAsString(idx), def, msg); + } + + public Player argAsBestPlayerMatch(int idx, Player def) { + return this.argAsBestPlayerMatch(idx, def, true); + } + + public Player argAsBestPlayerMatch(int idx) { + return this.argAsPlayer(idx, null); + } } \ No newline at end of file diff --git a/src/main/java/com/massivecraft/factions/zcore/MPlugin.java b/src/main/java/com/massivecraft/factions/zcore/MPlugin.java index 94a4955f..faa241c2 100644 --- a/src/main/java/com/massivecraft/factions/zcore/MPlugin.java +++ b/src/main/java/com/massivecraft/factions/zcore/MPlugin.java @@ -27,308 +27,308 @@ 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; + // 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; + // 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 boolean getAutoSave() { + return this.autoSave; + } - public void setAutoSave(boolean val) { - this.autoSave = val; - } + public void setAutoSave(boolean val) { + this.autoSave = val; + } - public List> getBaseCommands() { - return this.baseCommands; - } + public List> getBaseCommands() { + return this.baseCommands; + } - public boolean preEnable() { - log("=== ENABLE START ==="); - timeEnableStart = System.currentTimeMillis(); + public boolean preEnable() { + log("=== ENABLE START ==="); + timeEnableStart = System.currentTimeMillis(); - // Ensure basefolder exists! - this.getDataFolder().mkdirs(); + // Ensure basefolder exists! + this.getDataFolder().mkdirs(); - // Create Utility Instances - this.perm = new PermUtil(this); - this.persist = new Persist(this); + // Create Utility Instances + this.perm = new PermUtil(this); + this.persist = new Persist(this); - this.txt = new TextUtil(); - initTXT(); + 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) { - } + // 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); + // 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); - } + // 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(); + loadLang(); - loadSuccessful = true; - return true; - } + loadSuccessful = true; + return true; + } - public void postEnable() { - log("=== ENABLE DONE (Took " + (System.currentTimeMillis() - timeEnableStart) + "ms) ==="); - } + 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]; + 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(); - } + 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()); - } - } + 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."); - } + // 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 Driftay."); - e.printStackTrace(); - } - } + 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 Driftay."); + 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"); - } + 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. - // -------------------------------------------- // + // -------------------------------------------- // + // 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); - } + public void suicide() { + log("Now I suicide!"); + this.getServer().getPluginManager().disablePlugin(this); + } - // -------------------------------------------- // - // LANG AND TAGS - // -------------------------------------------- // + // -------------------------------------------- // + // LANG AND TAGS + // -------------------------------------------- // - public GsonBuilder getGsonBuilder() { - return new GsonBuilder().setPrettyPrinting().disableHtmlEscaping().serializeNulls().excludeFieldsWithModifiers(Modifier.TRANSIENT, Modifier.VOLATILE); - } + 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 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(); + public void initTXT() { + this.addRawTags(); - Type type = new TypeToken>() { - }.getType(); + 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"); + 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())); - } - } + for (Entry rawTag : this.rawTags.entrySet()) { + this.txt.tags.put(rawTag.getKey(), TextUtil.parseColor(rawTag.getValue())); + } + } - // -------------------------------------------- // - // COMMAND HANDLING - // -------------------------------------------- // + // -------------------------------------------- // + // COMMAND HANDLING + // -------------------------------------------- // - // can be overridden by P method, to provide option - public boolean logPlayerCommands() { - return true; - } + // can be overridden by P 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(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); - } + 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 (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; - } + 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 (commandString.startsWith(alias + " ") || commandString.equals(alias)) { + final List args = new ArrayList<>(Arrays.asList(commandString.split("\\s+"))); + args.remove(0); - if (testOnly) { - return true; - } + if (testOnly) { + return true; + } - if (async) { - Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this, () -> command.execute(sender, args)); - } else { - command.execute(sender, args); - } + if (async) { + Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this, () -> command.execute(sender, args)); + } else { + command.execute(sender, args); + } - return true; - } - } - } - return false; - } + return true; + } + } + } + return false; + } - public boolean handleCommand(CommandSender sender, String commandString) { - return this.handleCommand(sender, commandString, false); - } + public boolean handleCommand(CommandSender sender, String commandString) { + return this.handleCommand(sender, commandString, false); + } - // -------------------------------------------- // - // HOOKS - // -------------------------------------------- // - public void preAutoSave() { + // -------------------------------------------- // + // HOOKS + // -------------------------------------------- // + public void preAutoSave() { - } + } - public void postAutoSave() { + public void postAutoSave() { - } + } - public Map getStuckMap() { - return this.stuckMap; - } + public Map getStuckMap() { + return this.stuckMap; + } - public Map getTimers() { - return this.timers; - } + public Map getTimers() { + return this.timers; + } - // -------------------------------------------- // - // LOGGING - // -------------------------------------------- // - public void log(Object msg) { - log(Level.INFO, msg); - } + // -------------------------------------------- // + // 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(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, 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); - } + 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 e8f91a7b..7df5d34c 100644 --- a/src/main/java/com/massivecraft/factions/zcore/MPluginSecretPlayerListener.java +++ b/src/main/java/com/massivecraft/factions/zcore/MPluginSecretPlayerListener.java @@ -12,30 +12,30 @@ import org.bukkit.event.player.PlayerLoginEvent; public class MPluginSecretPlayerListener implements Listener { - private MPlugin p; + private MPlugin p; - public MPluginSecretPlayerListener(MPlugin p) { - this.p = 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 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); - } + @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(); @@ -43,10 +43,10 @@ public class MPluginSecretPlayerListener implements Listener { format = format.replace(Conf.chatTagReplaceString, P.p.getPlayerFactionTag(speaker)).replace("[FACTION_TITLE]", P.p.getPlayerTitle(speaker)); event.setFormat(format); */ - } + } - @EventHandler(priority = EventPriority.LOWEST) - public void onPlayerPreLogin(PlayerLoginEvent event) { - FPlayers.getInstance().getByPlayer(event.getPlayer()); - } + @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/DefaultPermissions.java b/src/main/java/com/massivecraft/factions/zcore/fperms/DefaultPermissions.java index 52a43874..c405d786 100644 --- a/src/main/java/com/massivecraft/factions/zcore/fperms/DefaultPermissions.java +++ b/src/main/java/com/massivecraft/factions/zcore/fperms/DefaultPermissions.java @@ -1,5 +1,8 @@ package com.massivecraft.factions.zcore.fperms; +import com.massivecraft.factions.util.XMaterial; +import javafx.scene.paint.Material; + public class DefaultPermissions { public boolean ban; public boolean build; @@ -27,6 +30,7 @@ public class DefaultPermissions { public boolean tntfill; public boolean withdraw; public boolean chest; + public boolean check; public boolean spawner; public DefaultPermissions() { @@ -59,6 +63,7 @@ public class DefaultPermissions { this.tntfill = def; this.withdraw = def; this.chest = def; + this.check = def; this.spawner = def; } @@ -88,6 +93,7 @@ public class DefaultPermissions { boolean canTntfill, boolean canWithdraw, boolean canChest, + boolean canCheck, boolean canSpawners) { this.ban = canBan; this.build = canBuild; @@ -115,6 +121,7 @@ public class DefaultPermissions { this.tntfill = canTntfill; this.withdraw = canWithdraw; this.chest = canChest; + this.check = canCheck; this.spawner = canSpawners; } @@ -146,6 +153,7 @@ public class DefaultPermissions { else if (name == "tntfill") return this.tntfill; else if (name == "withdraw") return this.withdraw; else if (name == "chest") return this.chest; + else if(name == "check") return this.check; else if (name == "spawner") return this.spawner; else return false; } 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 a725264a..dfd3dd78 100644 --- a/src/main/java/com/massivecraft/factions/zcore/fperms/PermissableAction.java +++ b/src/main/java/com/massivecraft/factions/zcore/fperms/PermissableAction.java @@ -39,6 +39,7 @@ public enum PermissableAction { TNTFILL("tntfill"), WITHDRAW("withdraw"), CHEST("chest"), + CHECK("check"), SPAWNER("spawner"); private String name; 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 3f8c2f9b..df0a9ebb 100644 --- a/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFaction.java +++ b/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFaction.java @@ -67,6 +67,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator { protected Role defaultRole; protected Map> permissions = new HashMap<>(); protected Set bans = new HashSet<>(); + protected long checkNotifier = 0; protected String player; Inventory chest; Map bannerSerialized; @@ -97,6 +98,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator { this.foundedDate = System.currentTimeMillis(); this.maxVaults = Conf.defaultMaxVaults; this.defaultRole = Role.RECRUIT; + this.checkNotifier = 0; resetPerms(); // Reset on new Faction so it has default values. } @@ -122,6 +124,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator { invites = old.invites; announcements = old.announcements; this.defaultRole = Role.NORMAL; + this.checkNotifier = 0; resetPerms(); // Reset on new Faction so it has default values. } @@ -342,6 +345,21 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator { return false; } + @Override + public long getCheckNotifier() { + return this.checkNotifier; + } + + @Override + public void setCheckNotifier(final long minutes) { + this.checkNotifier = minutes; + } + + @Override + public void sendCheckNotify() { + this.sendMessage(TL.CHECK_NOTIFY_MESSAGE.toString()); + } + public Set getBannedPlayers() { return this.bans; } 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 3adfe129..1f623f4f 100644 --- a/src/main/java/com/massivecraft/factions/zcore/util/TL.java +++ b/src/main/java/com/massivecraft/factions/zcore/util/TL.java @@ -26,1137 +26,1142 @@ import java.text.SimpleDateFormat; * changes. */ public enum TL { - /** - * Translation meta - */ - _AUTHOR("misc"), - _RESPONSIBLE("misc"), - _LANGUAGE("English"), - _ENCODING("UTF-8"), - _LOCALE("en_US"), - _REQUIRESUNICODE("false"), - _DEFAULT("true"), - _STATE("complete"), //incomplete, limited, partial, majority, complete - - /** - * Localised translation meta - */ - _LOCAL_AUTHOR("misc"), - _LOCAL_RESPONSIBLE("misc"), - _LOCAL_LANGUAGE("English"), - _LOCAL_REGION("US"), - _LOCAL_STATE("complete"), //And this is the English version. It's not ever going to be not complete. - /** - * Actions translations - */ - ACTIONS_NOPERMISSION("{faction} does not allow you to {action}"), - ACTIONS_NOPERMISSIONPAIN("It is painful to try to {action} in the territory of {faction}"), - ACTIONS_OWNEDTERRITORYDENY("You cant do that in this territory, it is owned by {owners}"), - ACTIONS_OWNEDTERRITORYPAINDENY("It is painful to try to {action} in this territory, it is owned by {owners}"), - ACTIONS_MUSTBE("Youmust be {role} to {action}."), - ACTIONS_NOSAMEROLE("{role} can't control each other..."), - ACTIONS_NOFACTION("You are not member of any faction."), - /** - * Command translations - */ - - /** - * Messsges for /f help - */ - COMMAND_HELP_NEXTCREATE("Learn how to create a faction on the next page."), - COMMAND_HELP_INVITATIONS("command.help.invitations", "You might want to close it and use invitations:"), - COMMAND_HELP_HOME("And don't forget to set your home:"), - COMMAND_HELP_404("&c&l» &7This page does &cnot &7exist"), - COMMAND_HELP_BANK_1("Your faction has a bank which is used to pay for certain"), //Move to last /f help page - COMMAND_HELP_BANK_2("things, so it will need to have money deposited into it."), //Move to last /f help page - COMMAND_HELP_BANK_3("To learn more, use the money command."), //Move to last /f help page - COMMAND_HELP_PLAYERTITLES("Player titles are just for fun. No rules connected to them."), //Move to last /f help page - COMMAND_HELP_OWNERSHIP_1("Claimed land with ownership set is further protected so"), //Move to last /f help page - COMMAND_HELP_OWNERSHIP_2("that only the owner(s), faction admin, and possibly the"), //Move to last /f help page - COMMAND_HELP_OWNERSHIP_3("faction moderators have full access."), //Move to last /f help page - COMMAND_HELP_RELATIONS_1("Set the relation you WISH to have with another faction."), //Move to last /f help page - COMMAND_HELP_RELATIONS_2("Your default relation with other factions will be neutral."), //Move to last /f help page - COMMAND_HELP_RELATIONS_3("If BOTH factions choose \"ally\" you will be allies."), //Move to last /f help page - COMMAND_HELP_RELATIONS_4("If ONE faction chooses \"enemy\" you will be enemies."), //Move to last /f help page - COMMAND_HELP_RELATIONS_5("You can never hurt members or allies."), //Move to last /f help page - COMMAND_HELP_RELATIONS_6("You can not hurt neutrals in their own territory."), //Move to last /f help page - COMMAND_HELP_RELATIONS_7("You can always hurt enemies and players without faction."), //Move to last /f help page - COMMAND_HELP_RELATIONS_8(""), - COMMAND_HELP_RELATIONS_9("Damage from enemies is reduced in your own territory."), //Move to last /f help page - COMMAND_HELP_RELATIONS_10("When you die you lose power. It is restored over time."), //Move to last /f help page - COMMAND_HELP_RELATIONS_11("The power of a faction is the sum of all member power."), //Move to last /f help page - COMMAND_HELP_RELATIONS_12("The power of a faction determines how much land it can hold."), //Move to last /f help page - COMMAND_HELP_RELATIONS_13("You can claim land from factions with too little power."), //Move to last /f help page - COMMAND_HELP_PERMISSIONS_1("Only faction members can build and destroy in their own"), //Move to last /f help page - COMMAND_HELP_PERMISSIONS_2("territory. Usage of the following items is also restricted:"), //Move to last /f help page - COMMAND_HELP_PERMISSIONS_3("Door, Chest, Furnace, Dispenser, Diode."), //Move to last /f help page - COMMAND_HELP_PERMISSIONS_4(""), - COMMAND_HELP_PERMISSIONS_5("Make sure to put pressure plates in front of doors for your"), //Move to last /f help page - COMMAND_HELP_PERMISSIONS_6("guest visitors. Otherwise they can't get through. You can"), //Move to last /f help page - COMMAND_HELP_PERMISSIONS_7("also use this to create member only areas."), //Move to last /f help page - COMMAND_HELP_PERMISSIONS_8("As dispensers are protected, you can create traps without"), //Move to last /f help page - COMMAND_HELP_PERMISSIONS_9("worrying about those arrows getting stolen."), //Move to last /f help page - COMMAND_HELP_ADMIN_1("&a&l» &a/f claim safezone \n &7claim land for the Safe Zone"), - COMMAND_HELP_ADMIN_2("&a&l» &a/f claim warzone \n &7claim land for the War Zone"), - COMMAND_HELP_ADMIN_3("&a&l» &a/f autoclaim [safezone|warzone] \n &7take a guess"), - COMMAND_HELP_MOAR_1("Finally some commands for the server admins:"), - COMMAND_HELP_MOAR_2("More commands for server admins:"), - COMMAND_HELP_MOAR_3("Even more commands for server admins:"), - COMMAND_HELP_DESCRIPTION("\n &a&l» &7Display a &ahelp &7page"), - - COMMAND_NEAR_DESCRIPTION("Get nearby faction players in a radius."), - COMMAND_NEAR_DISABLED_MSG("&cThis command is disabled!"), - COMMAND_NEAR_FORMAT("{playername} &c({distance}m)"), - COMMAND_NEAR_USE_MSG("&cFaction members nearby"), - - /** - * Messsges for Faction Admins/Mods - */ - - COMMAND_UPGRADES_DESCRIPTION("&cOpen the Upgrades Menu"), - COMMAND_CORNER_CANT_CLAIM("&c&l[!] &cYou may not claim this corner!"), - COMMAND_CORNER_CLAIMED("\n&2&l[!] &aYou have claimed the corner successfully, totalling in &b%1$d &achunks!\n"), - COMMAND_CORNER_ATTEMPTING_CLAIM("&c&l[!] &7Attempting to claim corner..."), - COMMAND_CORNER_NOT_CORNER("&c&l[!] &7You must be in a corner to use this command!"), - COMMAND_CORNER_DESCRIPTION("claim a corner at world border"), - COMMAND_CORNERLIST_DESCRIPTION("list of all corners"), - - COMMAND_ADMIN_NOTMEMBER("&c&l[!] &7%1$s &cis not a member in your faction."), - COMMAND_ADMIN_NOTADMIN("&c&l[!] &cYou are not the faction admin."), - COMMAND_ADMIN_TARGETSELF("'&c&l[!] &cThe target player musn''t be yourself."), - COMMAND_ADMIN_DEMOTES("&c&l[!] &cYou have demoted &7%1$s &cfrom the position of faction admin."), - COMMAND_ADMIN_DEMOTED("&c&l[!] &cYou have been demoted from the position of faction admin by &7%1$s&c"), - COMMAND_ADMIN_PROMOTES("&e&l[!] &eYou have promoted &6%1$s &eto the position of faction admin."), - COMMAND_ADMIN_PROMOTED("&e&l[!] &6%1$s &egave &6%2$s ðe leadership of &6%3$s&e."), - COMMAND_ADMIN_DESCRIPTION("Hand over your admin rights"), - COMMAND_ADMIN_NOMEMBERS("&e&l[!] &cNo one else to promote, please disband faction."), - - COMMAND_AHOME_DESCRIPTION("Send a player to their f home no matter what."), - COMMAND_AHOME_NOHOME("%1$s doesn't have an f home."), - COMMAND_AHOME_SUCCESS("$1%s was sent to their f home."), - COMMAND_AHOME_OFFLINE("%1$s is offline."), - COMMAND_AHOME_TARGET("You were sent to your f home."), - - COMMAND_ANNOUNCE_DESCRIPTION("Announce a message to players in faction."), - COMMAND_ALTS_DESCRIPTION("Faction Alts Commands"), - COMMAND_STRIKE_DESCRIPTION("Faction Strike Commands"), - - COMMAND_ALTS_LIST_DESCRIPTION("List all alts in your faction"), - - COMMAND_FREECAM_ENEMYINRADIUS("Freecam disabled, An enemy is closeby!"), - COMMAND_FREECAM_OUTSIDEFLIGHT("Please dont leave the flight radius!"), - COMMAND_FREECAM_ENABLED("Freecam is now enabled!"), - COMMAND_FREECAM_DISABLED("Freecam is now disabled"), - COMMAND_FREECAM_DESCRIPTION("Go into spectator mode"), - - - COMMAND_AUTOCLAIM_ENABLED("&c&l[!] &7Now &cauto-claiming&7 land for %1$s."), - COMMAND_AUTOCLAIM_DISABLED("&c&l[!] Auto-claiming&7 of land is now &cdisabled."), - COMMAND_AUTOCLAIM_REQUIREDRANK("&c&l[!] &7You must be &c%1$s&7 to claim land."), - COMMAND_AUTOCLAIM_OTHERFACTION("&c&l[!]&7 You &ccan't &7claim land for &c%1$s&7."), - COMMAND_AUTOCLAIM_DESCRIPTION("Auto-claim land as you walk around"), - - - COMMAND_ALTINVITE_DESCRIPTION("Invite Alts to your faction."), - COMMAND_ALTKICK_DESCRIPTION("Kick alts from your faction"), - COMMAND_ALTKICK_NOTALT("&c&l[!] &7Player is not an alt."), - COMMAND_ALTKICK_NOTMEMBER("&c&l[!] &7This player is not a member of your faction."), - - COMMAND_ALTS_LIST_NOALTS("&c&l[!] &7%s does not have any alts in their faction!"), - COMMAND_AUTOHELP_HELPFOR("Help for command \""), - COMMAND_HOME_OTHER_NOTSET("&c&l[!] &7%s does not have their faction home set!"), - COMMAND_HOME_TELEPORT_OTHER("&c&l[!] &7You have teleported to %s's faction home!"), - COMMAND_SHOP_DESCRIPTION("opens shop gui"), - - COMMAND_BAN_DESCRIPTION("Ban players from joining your Faction."), - COMMAND_BAN_TARGET("&c&l[!] &7You were &cbanned &7from &c%1$s"), // banned player perspective - COMMAND_BAN_BANNED("&c&l[!] &7%1$s &cbanned &7%2$s"), - COMMAND_BAN_SELF("&c&l[!] &7You may &cnot &7ban &cyourself&7."), - COMMAND_BAN_INSUFFICIENTRANK("&c&l[!] &7Your &crank &7is too low to&c ban &7%1$s"), - COMMAND_BAN_ALREADYBANNED("&c&l[!] &7This player is &calready banned&7!"), - - COMMAND_BANLIST_DESCRIPTION("View a Faction's ban list"), - COMMAND_BANLIST_HEADER("&c&l[!] &7There are &c%d&7 bans for &c%s"), - COMMAND_BANLIST_ENTRY("&7%d. &c%s &r&7// &c%s &r&7// &c%s"), - COMMAND_BANLIST_NOFACTION("&c&l[!] &7You are &cnot &7in a Faction."), - COMMAND_BANLIST_INVALID("&c&l[!] &7The faction &c%s &7does not exist"), - - COMMAND_BOOM_PEACEFULONLY("&c&l[!] &7This command is &conly &7usable by factions which are &cspecifically &7designated as &cpeaceful&7."), - COMMAND_BOOM_TOTOGGLE("to toggle explosions"), - COMMAND_BOOM_FORTOGGLE("for toggling explosions"), - COMMAND_BOOM_ENABLED("&c&l[!] &c%1$s&7 has&c %2$s&7 explosions in your faction's territory."), - COMMAND_BOOM_DESCRIPTION("Toggle explosions (peaceful factions only)"), - - - COMMAND_BYPASS_ENABLE("&e&l[!] &eYou have enabled admin bypass mode. You will be able to build or destroy anywhere."), - COMMAND_BYPASS_ENABLELOG(" has ENABLED admin bypass mode."), - COMMAND_BYPASS_DISABLE("&c&l[!] &cYou have disabled admin bypass mode."), - COMMAND_BYPASS_DISABLELOG(" has DISABLED admin bypass mode."), - COMMAND_BYPASS_DESCRIPTION("Enable admin bypass mode"), - - COMMAND_BANNER_DESCRIPTION("Turn a held banner into a war banner"), - COMMAND_BANNER_NOTENOUGHMONEY("&c&l[!] &7You do&c not&7 have enough money"), - COMMAND_BANNER_MONEYTAKE("&c&l[!] $&c{amount} &7has been taken from your account."), - COMMAND_BANNER_SUCCESS("&c&l[!] &7You have created a &c&lWarBanner!"), - COMMAND_BANNER_DISABLED("&c&l[!] &7Buying&c warbanners&7 is &cdisabled!"), - - COMMAND_TPBANNER_NOTSET("&c&l[!] &7Your faction &cdoes not &7have a &c&lWarBanner &7placed!"), - COMMAND_TPBANNER_SUCCESS("&c&l[!] &cTeleporting &7to your factions's &c&lWarBanner"), - COMMAND_TPBANNER_DESCRIPTION("Teleport to your faction banner"), - - - COMMAND_CHAT_DISABLED("&c&l[!] &7The built in chat channels are &cdisabled &7on this server."), - COMMAND_CHAT_INVALIDMODE("&c&l[!] &cUnrecognised &7chat mode. Please enter either '&da&7','&af&7','&6m&7' or '&fp&7'"), - COMMAND_CHAT_DESCRIPTION("Change chat mode"), - - COMMAND_CHAT_MODE_PUBLIC("&c&l[!] &fPublic &7chat mode."), - COMMAND_CHAT_MODE_ALLIANCE("&c&l[!] &dAlliance &7only chat mode."), - COMMAND_CHAT_MODE_TRUCE("&c&l[!] &5Truce &7only chat mode."), - COMMAND_CHAT_MODE_FACTION("&c&l[!] &aFaction&7 only chat mode."), - COMMAND_CHAT_MODE_MOD("&c&l[!] &dMod &7only chat mode."), - COMMAND_CHAT_MOD_ONLY("&c&l[!] &7Only Mods can talk through this chat mode."), - - COMMAND_CHATSPY_ENABLE("&c&l[!] &7You have &cenabled &7chat spying mode."), - COMMAND_CHATSPY_ENABLELOG(" has ENABLED chat spying mode."), - COMMAND_CHATSPY_DISABLE("&c&l[!] &7You have &cdisabled &7chat spying mode."), - COMMAND_CHATSPY_DISABLELOG(" has DISABLED chat spying mode."), - COMMAND_CHATSPY_DESCRIPTION("Enable admin chat spy mode"), - - COMMAND_CLAIM_INVALIDRADIUS("&c&l[!]&7 If you specify a &cradius&7, it must be at least &c1&7."), - COMMAND_CLAIM_DENIED("&c&l[!]&7 You &cdo not &7have &cpermission&7 to &cclaim&7 in a radius."), - COMMAND_CLAIM_DESCRIPTION("Claim land from where you are standing"), - - COMMAND_CLAIMLINE_INVALIDRADIUS("&c&l[!]&7 If you &cspecify&7 a distance, it must be at least &c1&7."), - COMMAND_CLAIMLINE_DENIED("&c&l[!]&7 You &cdo not &7have&c permission&7 to claim in a line."), - COMMAND_CLAIMLINE_DESCRIPTION("Claim land in a straight line."), - COMMAND_CLAIMLINE_ABOVEMAX("&c&l[!]&7 The &cmaximum&7 limit for claim line is &c%s&7."), - COMMAND_CLAIMLINE_NOTVALID("&c&l[!]&7 &c%s&7 is not a &ccardinal &7direction. You may use &cnorth&7, &ceast&7, &csouth &7or &cwest&7."), - - COMMAND_CONFIG_NOEXIST("&c&l[!]&7 No configuration setting \"&c%1$s&7\" exists."), - COMMAND_CONFIG_SET_TRUE("\" option set to true (enabled)."), - COMMAND_CONFIG_SET_FALSE("\" option set to false (disabled)."), - COMMAND_CONFIG_OPTIONSET("\" option set to "), - COMMAND_CONFIG_COLOURSET("\" color option set to \""), - COMMAND_CONFIG_INTREQUIRED("Cannot set \"%1$s\": An integer (whole number) value required."), - COMMAND_CONFIG_LONGREQUIRED("Cannot set \"%1$s\": A long integer (whole number) value required."), - COMMAND_CONFIG_DOUBLEREQUIRED("Cannot set \"%1$s\": A double (numeric) value required."), - COMMAND_CONFIG_FLOATREQUIRED("Cannot set \"%1$s\": A float (numeric) value required."), - COMMAND_CONFIG_INVALID_COLOUR("Cannot set \"%1$s\": \"%2$s\" is not a valid color."), - COMMAND_CONFIG_INVALID_COLLECTION("\"%1$s\" is not a data collection type which can be modified with this command."), - COMMAND_CONFIG_INVALID_MATERIAL("Cannot change \"%1$s\" set: \"%2$s\" is not a valid material."), - COMMAND_CONFIG_INVALID_TYPESET("\"%1$s\" is not a data type set which can be modified with this command."), - COMMAND_CONFIG_MATERIAL_ADDED("\"%1$s\" set: Material \"%2$s\" added."), - COMMAND_CONFIG_MATERIAL_REMOVED("\"%1$s\" set: Material \"%2$s\" removed."), - COMMAND_CONFIG_SET_ADDED("\"%1$s\" set: \"%2$s\" added."), - COMMAND_CONFIG_SET_REMOVED("\"%1$s\" set: \"%2$s\" removed."), - COMMAND_CONFIG_LOG(" (Command was run by %1$s.)"), - COMMAND_CONFIG_ERROR_SETTING("Error setting configuration setting \"%1$s\" to \"%2$s\"."), - COMMAND_CONFIG_ERROR_MATCHING("Configuration setting \"%1$s\" couldn't be matched, though it should be... please report this error."), - COMMAND_CONFIG_ERROR_TYPE("'%1$s' is of type '%2$s', which cannot be modified with this command."), - COMMAND_CONFIG_DESCRIPTION("Change a conf.json setting"), - - COMMAND_CONVERT_BACKEND_RUNNING("&c&l[!]&7 Already running that backend."), - COMMAND_CONVERT_BACKEND_INVALID("&c&l[!]&7 Invalid backend"), - COMMAND_CONVERT_DESCRIPTION("Convert the plugin backend"), - - COMMAND_COORDS_MESSAGE("&c&l[!] &7{player}&7's coords are &c{x}&7,&c{y}&7,&c{z}&7 in &c{world}"), - COMMAND_COORDS_DESCRIPTION("broadcast your coords to your faction"), - - COMMAND_CHECKPOINT_DISABLED("&c&l[!]&7 You &ccannot&7 use checkpoint while its&c disabled&7!"), - COMMAND_CHECKPOINT_SET("&c&l[!]&7 You have &cset&7 the &cfaction checkpoint&7 at your &cLocation&7."), - COMMAND_CHECKPOINT_GO("&c&l[!]&7 &cTeleporting&7 to &cfaction checkpoint"), - COMMAND_CHECKPOINT_INVALIDLOCATION("&c&l[!]&7 &cInvalid Location!&7 You can &cset&7 checkpoints in &cyour claims&7 or &2wilderness&7."), - COMMAND_CHECKPOINT_NOT_SET("&c&l[!]&7 You have to &cset &7the &cfaction checkpoint&7 first."), - COMMAND_CHECKPOINT_CLAIMED("&c&l[!]&7 Your current &cfaction checkpoint&7 is claimed, set a &cnew &7one!"), - COMMAND_CHECKPOINT_DESCRIPTION("Set or go to your faction checkpoint!"), - - COMMAND_CREATE_MUSTLEAVE("&c&l[!]&7 You must &cleave &7your &ccurrent faction &7first."), - COMMAND_CREATE_INUSE("&c&l[!]&7 That tag is &calready &7in use."), - COMMAND_CREATE_TOCREATE("to create a new faction"), - COMMAND_CREATE_FORCREATE("for creating a new faction"), - COMMAND_CREATE_ERROR("&c&l[!]&7 There was an &cinternal error&7 while trying to create your faction. &cPlease try again&7."), - COMMAND_CREATE_CREATED("&c&l[!]&7 &c%1$s &7created a new faction &c&l%2$s"), - COMMAND_CREATE_YOUSHOULD("&c&l[!]&7 You should now: &c%1$s"), - COMMAND_CREATE_CREATEDLOG(" created a new faction: "), - COMMAND_CREATE_DESCRIPTION("Create a new faction"), - - COMMAND_DEINVITE_CANDEINVITE("&c&l[!]&7 Players you can &cdeinvite: "), - COMMAND_DEINVITE_CLICKTODEINVITE("&c&l[!]&7 Click to &crevoke&7 invite for &c%1$s"), - COMMAND_DEINVITE_ALREADYMEMBER("&c&l[!]&7 &c%1$s&7 is already a member of &c%2$s"), - COMMAND_DEINVITE_MIGHTWANT("&c&l[!]&7 You might want to: &c%1$s"), - COMMAND_DEINVITE_REVOKED("&c&l[!]&7 &7%1$s &crevoked&7 your invitation to &c%2$s&7."), - COMMAND_DEINVITE_REVOKES("&c&l[!]&7 %1$s&c revoked &7%2$s's&c invitation."), - COMMAND_DEINVITE_DESCRIPTION("Remove a pending invitation"), - - COMMAND_DELFWARP_DELETED("&c&l[!]&7 Deleted warp &c%1$s"), - COMMAND_DELFWARP_INVALID("&c&l[!]&7 Couldn't &cfind&7 warp &c%1$s"), - COMMAND_DELFWARP_TODELETE("to delete warp"), - COMMAND_DELFWARP_FORDELETE("for deleting warp"), - COMMAND_DELFWARP_DESCRIPTION("Delete a faction warp"), - - COMMAND_DESCRIPTION_CHANGES("&c&l[!]&7 You have &cchanged&7 the &cdescription&7 for &c%1$s&7 to:"), - COMMAND_DESCRIPTION_CHANGED("&c&l[!]&7 The faction&c %1$s&7 changed their &cdescription &7to:"), - COMMAND_DESCRIPTION_TOCHANGE("to change faction description"), - COMMAND_DESCRIPTION_FORCHANGE("for changing faction description"), - COMMAND_DESCRIPTION_DESCRIPTION("Change the faction description"), - - COMMAND_DISBAND_IMMUTABLE("&c&l[!]&7 &7You &ccannot&7 disband &2Wilderness&7,&e SafeZone&7, or &4WarZone."), - COMMAND_DISBAND_MARKEDPERMANENT("&c&l[!]&7 This faction is designated as&c permanent&7, so you cannot disband it."), - COMMAND_DISBAND_BROADCAST_YOURS("&c&l[!]&7 &c%1$s&7 disbanded your &cfaction."), - COMMAND_DISBAND_BROADCAST_NOTYOURS("&c&l[!]&7 &c%1$s &7disbanded the faction &c%2$s."), - COMMAND_DISBAND_HOLDINGS("&c&l[!]&7 &7You have been given the disbanded &cfaction's bank&7, totaling &c%1$s."), - COMMAND_DISBAND_PLAYER("&c&l[!] &7You have disbanded your &cfaction"), - COMMAND_DISBAND_CONFIRM("&c&l[!]&7 Your Faction has&c {tnt} &7tnt left in the bank, it will be &clost&7 if the faction is &cdisbanded&7. Type&c /f disband &7again within &c10&7 seconds to&c disband&7."), - COMMAND_DISBAND_DESCRIPTION("Disband a faction"), - - COMMAND_FLY_DISABLED("&c&l[!]&7 Sorry, Faction flight is &cdisabled &7on this server"), - COMMAND_FLY_DESCRIPTION("Enter or leave Faction flight mode"), - COMMAND_FLY_CHANGE("&c&l[!]&7 Faction flight &c%1$s"), - COMMAND_FLY_COOLDOWN("&c&l[!]&7 You will &cnot&7 take fall damage for &c{amount}&7 seconds"), - COMMAND_FLY_DAMAGE("&c&l[!]&7 Faction flight &cdisabled&7 due to entering combat"), - COMMAND_FLY_NO_ACCESS("&c&l[!]&7 &cCannot fly &7in territory of %1$s"), - COMMAND_FLY_ENEMY_NEAR("&c&l[!]&7 Flight has been&c disabled&7 an enemy is nearby"), - COMMAND_FLY_CHECK_ENEMY("&c&l[!]&7 Cannot fly here, an enemy is &cnearby"), - COMMAND_FLY_NO_EPEARL("&c&l[!] &7You &ccannot&7 throw enderpearls while flying!"), - - COMMAND_FOCUS_SAMEFACTION("&c[!] You may not focus players in your faction!"), - COMMAND_FOCUS_FOCUSING("&c&l[!] &7Your faction is now focusing &c%s"), - COMMAND_FOCUS_NO_LONGER("&c&l[!] &7Your faction is no longer focusing &c%s"), - COMMAND_FOCUS_DESCRIPTION("Focus a Specific Player"), - - - COMMAND_FWARP_CLICKTOWARP("&c&l[!]&7 Click to &cwarp!"), - COMMAND_FWARP_COMMANDFORMAT("&c&l[!]&7 /f warp &c[password]"), - COMMAND_FWARP_WARPED("&c&l[!]&7 Warped to &c%1$s"), - COMMAND_FWARP_INVALID_WARP("&c&l[!]&7 Couldn't find warp &c%1$s"), - COMMAND_FWARP_TOWARP("to warp"), - COMMAND_FWARP_FORWARPING("for warping"), - COMMAND_FWARP_WARPS("Warps: "), - COMMAND_FWARP_DESCRIPTION("Teleport to a faction warp"), - COMMAND_FWARP_INVALID_PASSWORD("&c&l[!]&7 &cInvalid password!"), - COMMAND_FWARP_PASSWORD_REQUIRED("&c&l[!]&c Warp Password:"), - COMMAND_FWARP_PASSWORD_TIMEOUT("&c&l[!]&7 Warp password &ccanceled"), - - COMMAND_GRACE_DESCRIPTION("Toggles Grace Period on/off"), - COMMAND_GRACE_ENABLED("&cYou cannot place &e%s &cwhile grace period is active!"), - COMMAND_GRACE_TOGGLE("&8» &7Grace period is now &c%1$s"), - - COMMAND_HINT_PERMISSION("&aYou can manage your factions permissions using &7/f perms"), - - COMMAND_HOME_DISABLED("&c&l[!]&7 Sorry, Faction homes are &cdisabled on this server."), - COMMAND_HOME_TELEPORTDISABLED("&c&l[!]&7 Sorry, the ability to &cteleport &7to Faction homes is &cdisabled &7on this server."), - COMMAND_HOME_NOHOME("&c&l[!]&7 Your faction does &cnot &7have a home. "), - COMMAND_HOME_INENEMY("&c&l[!]&7 You &ccannot teleport &7to your &cfaction home&7 while in the territory of an &cenemy faction&7."), - COMMAND_HOME_WRONGWORLD("&c&l[!]&7 You &ccannot &7teleport to your &cfaction home&7 while in a different world."), - COMMAND_HOME_ENEMYNEAR("&c&l[!]&7 You &ccannot teleport&7 to your faction home while an enemy is within &c%s&7 blocks of you."), - 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_INVENTORYSEE_DESCRIPTION("View a faction members inventory"), - - 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!"), - COMMAND_INSPECT_ENABLED("&c&l[!]&7 Inspect mode is now &aEnabled."), - COMMAND_INSPECT_HEADER("&c&m---&7Inspect Data&c&m---&c//&7x:{x},y:{y},z:{z}"), - COMMAND_INSPECT_ROW("&c{time} &7// &c{action} &7// &c{player} &7// &c{block-type}"), - COMMAND_INSPECT_NODATA("&c&l[!]&7 &7No Data was found!"), - COMMAND_INSPECT_NOTINCLAIM("&c&l[!]&7 &7You can &conly&7 inspect in &cyour &7claims!"), - COMMAND_INSPECT_BYPASS("&c&l[!]&7 Inspecting in &cbypass&7 mode"), - COMMAND_INSPECT_DESCRIPTION("Inspect blocks!"), - - COMMAND_INVITE_TOINVITE("to invite someone"), - COMMAND_INVITE_FORINVITE("for inviting someone"), - COMMAND_INVITE_CLICKTOJOIN("Click to join!"), - COMMAND_INVITE_INVITEDYOU(" &chas invited you to join "), - COMMAND_INVITE_INVITED("&c&l[!]&7 &c%1$s&7 invited &c%2$s&7 to your faction."), - COMMAND_ALTINVITE_INVITED_ALT("&c&l[!]&7 &c%1$s&7 invited &c%2$s&7 to your faction as an alt."), - - COMMAND_INVITE_ALREADYMEMBER("&c&l[!]&7 &c%1$s&7 is already a member of&c %2$s"), - COMMAND_INVITE_ALREADYINVITED("&c&l[!]&7 &c%1$s&7 has already been invited"), - COMMAND_INVITE_DESCRIPTION("Invite a player to your faction"), - COMMAND_INVITE_BANNED("&c&l[!]&7 &7%1$s &cis banned &7from your Faction. &cNot &7sending an invite."), - - BANKNOTE_WITHDRAW_NOT_ENOUGH("&c&l[!] &7You do not have enough money!"), - BANKNOTE_WITHDRAW_NO_ARGS("&c&l[!] &7Try /withdraw "), - XPBOTTLE_NOT_ENOUGH("&c&l[!] &7You do not have enough experience!"), - XPBOTTLE_WITHDRAW_NO_ARGS("&c&l[!] &7Try /bottle "), - - COMMAND_JOIN_CANNOTFORCE("&c&l[!]&7 You&c do not&7 have permission to &cmove other players&7 into a faction."), - COMMAND_JOIN_SYSTEMFACTION("&c&l[!]&7 Players may only join &cnormal factions&7. This is a &c&lsystem faction&7."), - COMMAND_JOIN_ALREADYMEMBER("&c&l[!]&7 &c%1$s %2$s already a member of&c %3$s"), - COMMAND_JOIN_ATLIMIT(" &c&l[!]&7 The faction &c%1$s &7is at the limit of&c %2$d&7 members, so&c %3$s&7 cannot currently join."), - COMMAND_JOIN_INOTHERFACTION("&c&l[!]&7 &c%1$s &7must leave&c %2$s &7current faction first."), - COMMAND_JOIN_NEGATIVEPOWER("&c&l[!]&7 &c%1$s &7cannot join a faction with a &cnegative power&7 level."), - COMMAND_JOIN_REQUIRESINVITATION("&c&l[!]&7 This faction &crequires&7 an invitation."), - COMMAND_JOIN_ATTEMPTEDJOIN("&c&l[!]&7 &c%1$s&7 tried to join your faction."), - COMMAND_JOIN_TOJOIN("to join a faction"), - COMMAND_JOIN_FORJOIN("for joining a faction"), - COMMAND_JOIN_SUCCESS("&c&l[!]&7 &c%1$s &7successfully joined &c%2$s."), - COMMAND_JOIN_MOVED("&c&l[!]&7 &c%1$s &7moved you into the faction&c %2$s."), - COMMAND_JOIN_JOINED("&c&l[!]&7 &c%1$s &7joined your faction."), - COMMAND_JOIN_JOINEDLOG("&c&l[!]&7 &c%1$s&7 joined the faction&c %2$s."), - COMMAND_JOIN_MOVEDLOG("&c&l[!]&7 &c%1$s &7moved the player&c %2$s &7into the faction&c %3$s&7."), - COMMAND_JOIN_DESCRIPTION("&a&l» &7Join a faction"), - COMMAND_JOIN_BANNED("&c&l[!]&7 You are &cbanned &7from &c%1$s."), - - COMMAND_KICK_CANDIDATES("&c&l[!]&7 Players you can kick: "), - COMMAND_KICK_CLICKTOKICK("Click to kick "), - COMMAND_KICK_SELF("&c&l[!]&7 You &ccannot &7kick&c yourself&7."), - COMMAND_KICK_NONE("&c&l[!]&7 That player&c is not&7 in a faction."), - COMMAND_KICK_NOTMEMBER("&c&l[!]&7 &c%1$s is not a member of %2$s"), - COMMAND_KICK_INSUFFICIENTRANK("&c&l[!]&7 Your rank is &ctoo low &7to kick this player."), - COMMAND_KICK_NEGATIVEPOWER("&c&l[!]&7 You &ccannot &7kick that member until their power is &apositive&7."), - COMMAND_KICK_TOKICK("to kick someone from the faction"), - COMMAND_KICK_FORKICK("for kicking someone from the faction"), - COMMAND_KICK_FACTION("&c&l[!]&7 %1$s&7 kicked %2$s&c from the faction!"), //message given to faction members - COMMAND_KICK_KICKS("&c&l[!]&7 You kicked &c%1$s&7 from the faction&c %2$s&7!"), //kicker perspective - COMMAND_KICK_KICKED("&c&l[!]&7 &c%1$s &7kicked you from&c %2$s&7!"), //kicked player perspective - COMMAND_KICK_DESCRIPTION("Kick a player from the faction"), - - COMMAND_LIST_FACTIONLIST("&c&l[!]&7 Faction List "), - COMMAND_LIST_TOLIST("to list the factions"), - COMMAND_LIST_FORLIST("for listing the factions"), - COMMAND_LIST_ONLINEFACTIONLESS("Online factionless: "), - COMMAND_LIST_DESCRIPTION("&a&l» &7See a list of the factions"), - - - COMMAND_SPAM_ENABLED("&c&l[!]&7 Factions Anti-Spam is now&a enabled"), - COMMAND_SPAM_DISABLED("&c&l[!]&7 Factions Anti-Spam in now&c disabled"), - COMMAND_SPAM_DESCRIPTION("enable antispam system"), - - COMMAND_LOCK_LOCKED("&c&l[!]&7 Factions is now&c locked"), - COMMAND_LOCK_UNLOCKED("&c&l[!]&7 Factions in now&a unlocked"), - COMMAND_LOCK_DESCRIPTION("Lock all write stuff. Apparently."), - - COMMAND_LOGINS_TOGGLE("&c&l[!]&7 Set login / logout notifications for Faction members to: &c%s"), - COMMAND_LOGINS_DESCRIPTION("Toggle(?) login / logout notifications for Faction members"), - - COMMAND_LOWPOWER_HEADER("&8&m--------&8&8&m---------"), - COMMAND_LOWPOWER_FORMAT("&c{player} &8(&c{player_power}&8/&c{maxpower}&8)"), - COMMAND_LOWPOWER_DESCRIPTION("Shows a list of players in your faction with lower power levels"), - - COMMAND_MAP_TOSHOW("to show the map"), - COMMAND_MAP_FORSHOW("for showing the map"), - COMMAND_MAP_UPDATE_ENABLED("&c&l[!]&7 Map auto update &aENABLED."), - COMMAND_MAP_UPDATE_DISABLED("&c&l[!]&7 Map auto update &cDISABLED."), - COMMAND_MAP_DESCRIPTION("Show the territory map, and set optional auto update"), - - COMMAND_MAPHEIGHT_DESCRIPTION("&eUpdate the lines that /f map sends"), - COMMAND_MAPHEIGHT_SET("&c&l[!]&7 Set /f map lines to &c&a%1$d"), - COMMAND_MAPHEIGHT_CURRENT("&c&l[!]&7 Current &cmapheight: &a%1$d"), - - COMMAND_MOD_CANDIDATES("&c&l[!]&7 Players you can promote: "), - COMMAND_MOD_CLICKTOPROMOTE("Click to promote "), - COMMAND_MOD_NOTMEMBER("&c&l[!]&7 &c%1$s7 is not a member in your faction."), - COMMAND_MOD_NOTADMIN("&c&l[!]&7 You &care not&7 the faction admin."), - COMMAND_MOD_SELF("&c&l[!]&7 The target player&c musn't&7 be yourself."), - COMMAND_MOD_TARGETISADMIN("&c&l[!]&7 The target player is a &cfaction admin.&7 Demote them first."), - COMMAND_MOD_REVOKES("&c&l[!]&7 &7You have &cremoved&7 moderator status from &c%1$s."), - COMMAND_MOD_REVOKED("&c&l[!]&7 &c%1$s&7 is &cno longer&7 moderator in your faction."), - COMMAND_MOD_PROMOTES("&c&l[!]&7 &c%1$s&7 was &cpromoted&7 to moderator in your faction."), - COMMAND_MOD_PROMOTED("&c&l[!]&7 You have promoted&c %1$s&7 to moderator."), - COMMAND_MOD_DESCRIPTION("Give or revoke moderator rights"), - - COMMAND_COLEADER_CANDIDATES("&c&l[!]&7 Players you can promote: "), - COMMAND_COLEADER_CLICKTOPROMOTE("Click to promote "), - COMMAND_COLEADER_NOTMEMBER("&c&l[!]&7 &c%1$s&7 is &cnot a member&7 in your faction."), - COMMAND_COLEADER_NOTADMIN("&c&l[!]&7 You are&c not&7 the faction admin."), - COMMAND_COLEADER_SELF("&c&l[!]&7 The target player&c musn't&7 be yourself."), - COMMAND_COLEADER_TARGETISADMIN("&c&l[!]&7 The target player is a &cfaction admin&7. Demote them first."), - COMMAND_COLEADER_REVOKES("&c&l[!]&7 You have removed &ccoleader &7status from&c %1$s&7."), - COMMAND_COLEADER_REVOKED("&c&l[!]&7 &c%1$s&7 is no longer&c coleader &7in your faction."), - COMMAND_COLEADER_PROMOTES("&c&l[!]&7 &c%1$s&7 was promoted to &ccoleader &7in your faction."), - COMMAND_COLEADER_PROMOTED("&c&l[!]&7 You have &cpromoted &7%1$s to &ccoleader."), - COMMAND_COLEADER_DESCRIPTION("Give or revoke coleader rights"), - - COMMAND_MODIFYPOWER_ADDED("&c&l[!]&7 Added &c%1$f &7power to &c%2$s. &7New total rounded power: &c%3$d"), - COMMAND_MODIFYPOWER_DESCRIPTION("Modify the power of a faction/player"), - - COMMAND_MONEY_LONG("&c&l[!]&7 The faction money commands."), - COMMAND_MONEY_DESCRIPTION("Faction money commands"), - - COMMAND_MONEYBALANCE_SHORT("show faction balance"), - COMMAND_MONEYBALANCE_DESCRIPTION("Show your factions current money balance"), - - COMMAND_MONEYDEPOSIT_DESCRIPTION("Deposit money"), - COMMAND_MONEYDEPOSIT_DEPOSITED("&c&l[!]&7 &c%1$s &7deposited&c %2$s&7 in the faction bank:&c %3$s"), - - COMMAND_MONEYTRANSFERFF_DESCRIPTION("Transfer f -> f"), - COMMAND_MONEYTRANSFERFF_TRANSFER("&c&l[!]&7 &c%1$s&7 transferred&c %2$s &7from the faction &c\"%3$s\"&7 to the faction&c \"%4$s\"&7"), - - COMMAND_MONEYTRANSFERFP_DESCRIPTION("Transfer f -> plugin"), - COMMAND_MONEYTRANSFERFP_TRANSFER("&c&l[!]&7 &c%1$s &7transferred&c %2$s &7from the faction&c \"%3$s\" &7to the player &c\"%4$s\""), - - COMMAND_MONEYTRANSFERPF_DESCRIPTION("Transfer plugin -> f"), - COMMAND_MONEYTRANSFERPF_TRANSFER("&c&l[!]&7 &c%1$s&7 transferred &c%2$s&7 from the player &c\"%3$s\" &7to the faction&c \"%4$s\""), - - COMMAND_MONEYWITHDRAW_DESCRIPTION("Withdraw money"), - COMMAND_MONEYWITHDRAW_WITHDRAW("&c&l[!]&7 &c%1$s&7 withdrew&c %2$s &7from the faction bank:&c %3$s"), - - COMMAND_OPEN_TOOPEN("to open or close the faction"), - COMMAND_OPEN_FOROPEN("for opening or closing the faction"), - COMMAND_OPEN_OPEN("open"), - COMMAND_OPEN_CLOSED("closed"), - COMMAND_OPEN_CHANGES("&c&l[!]&7 &c%1$s&7 changed the faction to &c%2$s&7."), - COMMAND_OPEN_CHANGED("&c&l[!]&7 The faction &c%1$s&7 is now &c%2$s"), - COMMAND_OPEN_DESCRIPTION("Switch if invitation is required to join"), - - COMMAND_OWNER_DISABLED("&c&l[!]&7 Sorry, but &cowned areas &7are &cdisabled &7on this server."), - COMMAND_OWNER_LIMIT("&c&l[!]&7 Sorry, but you have reached the server's &climit&7 of &c%1$d&7 owned areas per faction."), - COMMAND_OWNER_WRONGFACTION("&c&l[!]&7 &7This land is &cnot claimed &7by your faction, so you &ccan't set&7 ownership of it."), - COMMAND_OWNER_NOTCLAIMED("&c&l[!]&7 This land&c is not &7claimed by a faction. Ownership &cis not &7possible."), - COMMAND_OWNER_NOTMEMBER("&c&l[!]&7 &c%1$s&7 is &cnot a member &7of this faction."), - COMMAND_OWNER_CLEARED("&c&l[!]&7 You have &ccleared &7ownership for this claimed area."), - COMMAND_OWNER_REMOVED("&c&l[!]&7 You have&c removed ownership &7of this &cclaimed land&7 from &c%1$s&7."), - COMMAND_OWNER_TOSET("to set ownership of claimed land"), - COMMAND_OWNER_FORSET("for setting ownership of claimed land"), - COMMAND_OWNER_ADDED("&c&l[!]&7 You have added &c%1$s&7 to the &cowner list&7 for this claimed land."), - COMMAND_OWNER_DESCRIPTION("Set ownership of claimed land"), - - COMMAND_KILLHOLOGRAMS_DESCRIPTION("Kill holograms in a radius, admin command"), - - COMMAND_OWNERLIST_DISABLED("&c&l[!]&7 &cSorry, &7but owned areas are &cdisabled&7 on this server."),//dup-> - COMMAND_OWNERLIST_WRONGFACTION("&c&l[!]&7 This land &cis not&7 claimed by your faction."),//eq - COMMAND_OWNERLIST_NOTCLAIMED("&c&l[!]&7 This land is not claimed by any faction, thus no owners."),//eq - COMMAND_OWNERLIST_NONE("&c&l[!]&7 No owners are set here; everyone in the faction has access."), - COMMAND_OWNERLIST_OWNERS("&c&l[!]&7 Current owner(s) of this land: %1$s"), - COMMAND_OWNERLIST_DESCRIPTION("List owner(s) of this claimed land"), - - PAYPALSEE_PLAYER_PAYPAL("&c&l[!] &7You're factions paypal is: &b%1$s&7."), - COMMAND_PAYPAL_NOTSET("&c&l[!] &7Your faction does not have their paypal set!"), - COMMAND_PAYPALSET_ADMIN_SUCCESSFUL("&c&l[!] &7You have set &b%1$s's &7paypal to &b%2$s&7."), - COMMAND_PAYPALSET_ADMIN_FAILED("&c&l[!] &b%1$s &7is not an email!"), - COMMAND_PAYPALSET_NOTEMAIL("&c&l[!] &b%1$s &7is not an email!"), - COMMAND_PAYPALSET_DESCRIPTION("&c&l[!] &7Set the email of your faction to claim rewards."), - COMMAND_PAYPALSEE_DESCRIPTION("&c&l[!] &7View a specific factions paypal email with &b/f &b."), - COMMAND_PAYPALSET_CREATED("&c&l[!] &7Make sure to type &b/f &7!"), - COMMAND_PAYPALSET_SUCCESSFUL("&c&l[!] &7Successfully set your factions email - &b%1$s&7."), - COMMAND_PAYPALSEE_FACTION_PAYPAL("&c&l[!] &b%1$s's &7faction has their paypal set to &b%2$s&7."), - COMMAND_PAYPALSEE_FACTION_NOTSET("&c&l[!] &b%1$s's &7paypal has not yet been set!"), - COMMAND_PAYPALSEE_FACTION_NOFACTION("&c&l[!] &b%1$s &7does not have a faction!"), - - COMMAND_PEACEFUL_DESCRIPTION("&c&l[!]&7Set a faction to peaceful"), - COMMAND_PEACEFUL_YOURS("&c&l[!]&7%1$s has %2$s your faction"), - COMMAND_PEACEFUL_OTHER("&c&l[!]&7%s has %s the faction '%s'."), - COMMAND_PEACEFUL_GRANT("&c&l[!]&7 granted peaceful status to"), - COMMAND_PEACEFUL_REVOKE("removed peaceful status from"), - - COMMAND_PERM_DESCRIPTION("&c&l[!]&7&6Edit or list your Faction's permissions."), - COMMAND_PERM_INVALID_RELATION("&c&l[!]&7Invalid relation defined. Try something like&c 'ally'"), - COMMAND_PERM_INVALID_ACCESS("&c&l[!]&7 Invalid access defined. Try something like &c'allow'"), - COMMAND_PERM_INVALID_ACTION("&c&l[!]&7 Invalid action defined. Try something like &c'build'"), - COMMAND_PERM_SET("&c&l[!]&7 Set permission&c %1$s &7to &c%2$s &7for relation&c %3$s"), - COMMAND_PERM_TOP("RCT MEM OFF ALLY TRUCE NEUT ENEMY"), - COMMAND_PERM_LOCKED("&cThis permission has been locked by the server"), - - COMMAND_POINTS_FAILURE("&c&l[!] &c{faction} does not exist."), - COMMAND_POINTS_SUCCESSFUL("&c&l[!] &7You have added &e%1$s &7points to &b%2$s&7. &b%2$s's &7New Point Balance: &e%3$s"), - COMMAND_POINTS_INSUFFICIENT("&c&l[!] &7You may not add/set/remove a negative number of points to a faction!"), - COMMAND_POINTS_DESCRIPTION("General Command For Faction Points"), - - COMMAND_ADDPOINTS_DESCRIPTION("Add Points to Faction"), - - - COMMAND_REMOVEPOINTS_SUCCESSFUL("&c&l[!] &7You have taken &e%1$s &7points from &b%2$s&7. &b%2$s's &7New Point Balance: &e%3$s"), - COMMAND_REMOVEPOINTS_DESCRIPTION("Remove Points from a Faction"), - - COMMAND_SETPOINTS_SUCCESSFUL("&c&l[!] &7You have set &e%1$s &7points to &b%2$s&7. &b%2$s's &7New Point Balance: &e%3$s"), - COMMAND_SETPOINTS_DESCRIPTION("Set Points of a Faction"), - - COMMAND_PERMANENT_DESCRIPTION("Toggles a permanent faction option"), - COMMAND_PERMANENT_GRANT("&c&l[!]&7 added permanent status to"), - COMMAND_PERMANENT_REVOKE("&c&l[!]&7 removed permanent status from"), - COMMAND_PERMANENT_YOURS("&c&l[!]&7 &c%1$s&7 has &c%2$s&7 your faction"), - COMMAND_PERMANENT_OTHER("&c&l[!]&7 &c%s &7has &c%s &7the faction &c'%s'."), - COMMAND_PROMOTE_TARGET("&c&l[!]&7 You've been &c%1$s&7 to &c%2$s"), - COMMAND_PROMOTE_SUCCESS("&c&l[!]&7 You successfully&c %1$s %2$s &cto&7 %3$s"), - COMMAND_PROMOTE_PROMOTED("promoted"), - COMMAND_PROMOTE_DEMOTED("demoted"), - COMMAND_PROMOTE_COLEADER_ADMIN("&c&l[!]&7 &cColeaders cant promote players to Admin!"), - - COMMAND_PERMANENTPOWER_DESCRIPTION("Toggle permanent faction power option"), - COMMAND_PERMANENTPOWER_GRANT("added permanentpower status to"), - COMMAND_PERMANENTPOWER_REVOKE("removed permanentpower status from"), - COMMAND_PERMANENTPOWER_SUCCESS("&c&l[!]&7 You&c %s &7%s."), - COMMAND_PERMANENTPOWER_FACTION("&c&l[!]&7 &c%s %s &7your faction"), - - COMMAND_PROMOTE_DESCRIPTION("/f promote "), - COMMAND_PROMOTE_WRONGFACTION("&c&l[!]&7 &c%1$s&7 is &cnot&7 part of your faction."), - COMMAND_NOACCESS("&c&l[!]&7 You don't have access to that."), - COMMAND_PROMOTE_NOTTHATPLAYER("&c&l[!]&7 That player &ccannot&7 be promoted."), - COMMAND_PROMOTE_NOT_ALLOWED("&c&l[!]&7 You cannot promote to the same rank as yourself!"), - COMMAND_PROMOTE_NOTSELF("&c&l[!]&7 You cannot manage your own rank."), - COMMAND_PROMOTE_NOT_SAME("&c&l[!]&7 You cannot promote to the same rank as yourself!"), - - - COMMAND_POWER_TOSHOW("to show player power info"), - COMMAND_POWER_FORSHOW("for showing player power info"), - COMMAND_POWER_POWER("&c&l[!]&7 &c%1$s » &cPower &7/ &cMaxpower&a » &c%2$d &7/&c%3$d %4$s"), - COMMAND_POWER_BONUS(" (bonus: "), - COMMAND_POWER_PENALTY(" (penalty: "), - COMMAND_POWER_DESCRIPTION("&a&l» &7Show player &apower &7info"), - - COMMAND_POWERBOOST_HELP_1("&c&l[!]&7 You must specify \"plugin\" or \"player\" to target a player or \"f\" or \"faction\" to target a faction."), - COMMAND_POWERBOOST_HELP_2("&c&l[!]&7 ex. /f powerboost plugin SomePlayer 0.5 -or- /f powerboost f SomeFaction -5"), - COMMAND_POWERBOOST_INVALIDNUM("You must specify a valid numeric value for the power bonus/penalty amount."), - COMMAND_POWERBOOST_PLAYER("Player \"%1$s\""), - COMMAND_POWERBOOST_FACTION("Faction \"%1$s\""), - COMMAND_POWERBOOST_BOOST("%1$s now has a power bonus/penalty of %2$d to min and max power levels."), - COMMAND_POWERBOOST_BOOSTLOG("%1$s has set the power bonus/penalty for %2$s to %3$d."), - COMMAND_POWERBOOST_DESCRIPTION("Apply permanent power bonus/penalty to specified player or faction"), - - COMMAND_RELATIONS_ALLTHENOPE("&c&l[!]&7 &cNope!You can't."), - COMMAND_RELATIONS_MORENOPE("&c&l[!]&7 &cNope!&7You can't declare a relation to &cyourself"), - COMMAND_RELATIONS_ALREADYINRELATIONSHIP("&c&l[!]&7 You &calready&7 have that relation wish set with&c %1$s."), - COMMAND_RELATIONS_TOMARRY("to change a relation wish"), - COMMAND_RELATIONS_FORMARRY("for changing a relation wish"), - COMMAND_RELATIONS_MUTUAL("&c&l[!]&7 Your faction is now %1$s to %2$s"), - COMMAND_RELATIONS_PEACEFUL("&c&l[!]&7 This will have no effect while your faction is peaceful."), - COMMAND_RELATIONS_PEACEFULOTHER("&c&l[!]&7 This will have &cno effect&7 while their faction is peaceful."), - COMMAND_RELATIONS_DESCRIPTION("Set relation wish to another faction"), - COMMAND_RELATIONS_EXCEEDS_ME("&c&l[!]&7 Failed to set relation wish. You can only have %1$s %2$s."), - COMMAND_RELATIONS_EXCEEDS_THEY("&c&l[!]&7 Failed to set relation wish. They can only have %1$s %2$s."), - - COMMAND_RELATIONS_PROPOSAL_1("&c&l[!]&7&c %1$s &7wishes to be your&c %2$s"), - COMMAND_RELATIONS_PROPOSAL_2("&c&l[!]&7 Type &c/%1$s %2$s %3$s&7 to accept."), - COMMAND_RELATIONS_PROPOSAL_SENT("&c&l[!]&7 &c%1$s&7 were informed that you wish to be &c%2$s"), - - COMMAND_RELOAD_TIME("&c&l[!]&7 Reloaded &call &7configuration files from disk, took &c%1$d ms."), - COMMAND_RELOAD_DESCRIPTION("Reload data file(s) from disk"), - - COMMAND_SAFEUNCLAIMALL_DESCRIPTION("Unclaim all safezone land"), - COMMAND_SAFEUNCLAIMALL_UNCLAIMED("&c&l[!]&7 You unclaimed&c ALL&7 safe zone land."), - COMMAND_SAFEUNCLAIMALL_UNCLAIMEDLOG("&c&l[!]&7 &c%1$s&7 unclaimed all safe zones."), - - COMMAND_SAVEALL_SUCCESS("&c&l[!]&7 &cFactions saved to disk!"), - COMMAND_SAVEALL_DESCRIPTION("Save all data to disk"), - - COMMAND_SCOREBOARD_DESCRIPTION("Scoreboardy things"), - - COMMAND_SETBANNER_SUCCESS("&c&l[!] &7Banner Pattern Set!"), - COMMAND_SETBANNER_NOTBANNER("&c&l[!] &7The item is &cnot&7 a banner!"), - COMMAND_SETBANNER_DESCRIPTION("set banner pattern for your faction"), - - - COMMAND_SETDEFAULTROLE_DESCRIPTION("/f defaultrole - set your Faction's default role."), - COMMAND_SETDEFAULTROLE_NOTTHATROLE("&c&l[!]&7 You cannot set the default to admin."), - COMMAND_SETDEFAULTROLE_SUCCESS("Set default role of your faction to %1$s"), - COMMAND_SETDEFAULTROLE_INVALIDROLE("Couldn't find matching role for %1$s"), - - COMMAND_SETFWARP_NOTCLAIMED("&c&l[!]&7 You can &conly&7 set warps in your faction territory."), - COMMAND_SETFWARP_LIMIT("&c&l[!]&7 Your Faction already has the &cmax amount&7 of warps set &c(%1$d)."), - COMMAND_SETFWARP_SET("&c&l[!]&7 Set warp &c%1$s&7 and password &c'%2$s' &7to your location."), - COMMAND_SETFWARP_TOSET("to set warp"), - COMMAND_SETFWARP_FORSET("for setting warp"), - COMMAND_SETFWARP_DESCRIPTION("Set a faction warp"), - - COMMAND_SETHOME_DISABLED("&c&l[!]&7 &cSorry&7, Faction homes are disabled on this server."), - COMMAND_SETHOME_NOTCLAIMED("&c&l[!]&c Sorry&7, your faction home can only be set inside your &cown &7claimed territory."), - COMMAND_SETHOME_TOSET("to set the faction home"), - COMMAND_SETHOME_FORSET("for setting the faction home"), - COMMAND_SETHOME_SET("&c&l[!]&c %1$s&7 set the home for your faction. You can now use:"), - COMMAND_SETHOME_SETOTHER("&c&l[!]&7 You have set the home for the &c%1$s&7 faction."), - COMMAND_SETHOME_DESCRIPTION("Set the faction home"), - COMMAND_STRIKE_FACTION("View Factions Strikes"), - - COMMAND_SETMAXVAULTS_DESCRIPTION("Set max vaults for a Faction."), - COMMAND_SETMAXVAULTS_SUCCESS("&aSet max vaults for &e%s &ato &b%d"), - COMMAND_ONCOOOLDOWN("&c&l[!] &7You cannot use this command for another &b%1$s &7seconds."), - - COMMAND_SETSTRIKES_FAILURE("&c&l[!]&7 &c{faction} does not exist."), - COMMAND_SETSTRIKES_BROADCAST("&c&l[!]&7 &c{faction} has received a strike for {reason}"), - COMMAND_SETSTRIKES_SUCCESS("&c&l[!]&7 &c{faction}'s&7 new strikes are &c{strikes}"), - COMMAND_SETSTRIKES_DESCRIPTION("Set a faction's strikes"), - COMMAND_STRIKEREMOVE_DESCRIPTION("Remove a faction's strikes"), - COMMAND_STRIKE_MESSAGE("&c&l[!] &7{faction} has {strikes} strikes."), - COMMAND_STRIKE_NOTFOUND("&c&l[!] &7{faction} does not exist."), - COMMAND_STRIKE_NEEDFACTION("&c&l[!] &7&cYou need to join a faction to view your own!"), - - SHOP_NOT_ENOUGH_POINTS("&c&l[!] &7Your faction does not have enough points to purchase this!"), - SHOP_BOUGHT_BROADCAST_FACTION("\n&c&l[!] &e&lFactionShop » &b{player} &7bought &b{item}&7!\n"), - - COMMAND_STRIKEGIVE_DESCRIPTION("Give a faction strikes"), - - COMMAND_VIEWCHEST_DESCRIPTION("view a factions chest/pv"), - - COMMAND_VAULT_DESCRIPTION("Open your placed faction vault!"), - COMMAND_VAULT_INVALID("&c&l[!]&7 Your vault was either&c claimed&7, &cbroken&7, or has&c not been&7 placed yet."), - COMMAND_VAULT_OPENING("&c&l[!]&7 Opening faction vault."), - COMMAND_VAULT_NO_HOPPER("&c&l[!] &7You cannot place a hopper near a vault!"), - - COMMAND_GETVAULT_ALREADYSET("&c&l[!]&7 Vault has already been set!"), - COMMAND_GETVAULT_ALREADYHAVE("&c&l[!]&7 You already have a vault in your inventory!"), - COMMAND_GETVAULT_CHESTNEAR("&c&l[!]&7 &7There is a chest or hopper &cnearby"), - COMMAND_GETVAULT_SUCCESS("&cSucessfully set vault."), - COMMAND_GETVAULT_INVALIDLOCATION("&cVault can only be placed in faction land!"), - COMMAND_GETVAULT_DESCRIPTION("Get the faction vault item!"), - COMMAND_GETVAULT_RECEIVE("&cYou have recieved a faction vault!"), - COMMAND_GETVAULT_NOMONEY("&cYou do not have enough money"), - COMMAND_GETVAULT_MONEYTAKE("&c{amount} has been taken from your account"), - - COMMAND_LOGOUT_KICK_MESSAGE("&2You have safely logged out!"), - COMMAND_LOGOUT_ACTIVE("&c&l[!] &7You are already logging out!"), - COMMAND_LOGOUT_LOGGING("&c&l[!] &7You are logging out. Please wait &b%1$s &7seconds."), - COMMAND_LOGOUT_DESCRIPTION("logout safely from the server"), - COMMAND_LOGOUT_MOVED("&c&l[!] &7Your logout was cancelled because you moved!"), - COMMAND_LOGOUT_DAMAGE_TAKEN("&c&l[!] &7Your logout was cancelled because you were damaged!"), - COMMAND_LOGOUT_TELEPORTED("&c&l[!] &7Your logout was cancelled because you teleported!"), - - COMMAND_NOTIFICATIONS_TOGGLED_ON("&c&l[!] &7You will now see claimed land notifications!"), - COMMAND_NOTIFICATIONS_TOGGLED_OFF("&c&l[!] &7You will no longer see claimed land notifications!"), - COMMAND_NOTIFICATIONS_DESCRIPTION("Toggle notifications for land claiming"), - - COMMAND_SHOW_NOFACTION_SELF("You are not in a faction"), - COMMAND_SHOW_NOFACTION_OTHER("That's not a faction"), - COMMAND_SHOW_TOSHOW("to show faction information"), - COMMAND_SHOW_FORSHOW("for showing faction information"), - COMMAND_SHOW_DESCRIPTION("Description: %1$s"), - COMMAND_SHOW_PEACEFUL("This faction is Peaceful"), - COMMAND_SHOW_PERMANENT("This faction is permanent, remaining even with no members."), - COMMAND_SHOW_JOINING("Joining: %1$s "), - COMMAND_SHOW_INVITATION("invitation is required"), - COMMAND_SHOW_UNINVITED("no invitation is needed"), - COMMAND_SHOW_NOHOME("n/a"), - COMMAND_SHOW_POWER("Land / Power / Maxpower: %1$d/%2$d/%3$d %4$s."), - COMMAND_SHOW_BONUS(" (bonus: "), - COMMAND_SHOW_PENALTY(" (penalty: "), - COMMAND_SHOW_DEPRECIATED("(%1$s depreciated)"), //This is spelled correctly. - COMMAND_SHOW_LANDVALUE("Total land value: %1$s %2$s"), - COMMAND_SHOW_BANKCONTAINS("Bank contains: %1$s"), - COMMAND_SHOW_ALLIES("Allies: "), - COMMAND_SHOW_ENEMIES("Enemies: "), - COMMAND_SHOW_MEMBERSONLINE("Members online: "), - COMMAND_SHOW_MEMBERSOFFLINE("Members offline: "), - COMMAND_SHOW_COMMANDDESCRIPTION("Show faction information"), - COMMAND_SHOW_DEATHS_TIL_RAIDABLE("DTR: %1$d"), - COMMAND_SHOW_EXEMPT("This faction is exempt and cannot be seen."), - COMMAND_SHOW_NEEDFACTION("&cYou need to join a faction to view your own!"), - - COMMAND_SHOWCLAIMS_HEADER("&8&m-------------&8<{faction}'s claims&8>&8&m-------------"), - COMMAND_SHOWCLAIMS_FORMAT("&8[{world}]:"), - COMMAND_SHOWCLAIMS_CHUNKSFORMAT("&8(&c{x}&8,&c{z}&8)"), - COMMAND_SHOWCLAIMS_DESCRIPTION("show your factions claims!"), - - COMMAND_SHOWINVITES_PENDING("Players with pending invites: "), - COMMAND_SHOWINVITES_CLICKTOREVOKE("Click to revoke invite for %1$s"), - COMMAND_SHOWINVITES_DESCRIPTION("Show pending faction invites"), - - COMMAND_ALTS_LIST_FORMAT("%1$s Power: %2$s Last Seen: %3$s"), - COMMAND_ALTS_DEINVITE_DESCRIPTION("Base command for revoking alt invitations"), - - COMMAND_STATUS_FORMAT("%1$s Power: %2$s Last Seen: %3$s"), - COMMAND_STATUS_ONLINE("Online"), - COMMAND_STATUS_AGOSUFFIX(" ago."), - COMMAND_STATUS_DESCRIPTION("Show the status of a player"), - - COMMAND_STEALTH_DESCRIPTION("Enable and Disable Stealth Mode"), - COMMAND_STEALTH_ENABLE("&cStealth &7» &7You will no longer disable nearby players in /f fly."), - COMMAND_STEALTH_DISABLE("&cStealth &8» &7You will now disable other nearby players in /f fly."), - COMMAND_STEALTH_MUSTBEMEMBER("&cStealth &8» &4You must be in a faction to use this command"), - - COMMAND_STUCK_TIMEFORMAT("m 'minutes', s 'seconds.'"), - COMMAND_STUCK_CANCELLED("Teleport cancelled because you were damaged"), - COMMAND_STUCK_OUTSIDE("Teleport cancelled because you left %1$d block radius"), - COMMAND_STUCK_EXISTS("You are already teleporting, you must wait %1$s"), - COMMAND_STUCK_START("Teleport will commence in %s. Don't take or deal damage. "), - COMMAND_STUCK_TELEPORT("Teleported safely to %1$d, %2$d, %3$d."), - COMMAND_STUCK_TOSTUCK("to safely teleport %1$s out"), - COMMAND_STUCK_FORSTUCK("for %1$s initiating a safe teleport out"), - COMMAND_STUCK_DESCRIPTION("Safely teleports you out of enemy faction"), - - COMMAND_SEECHUNK_ENABLED("&cSeechunk enabled!"), - COMMAND_SEECHUNK_DISABLED("&cSeechunk disabled!"), - - - COMMAND_TAG_TAKEN("That tag is already taken"), - COMMAND_TAG_TOCHANGE("to change the faction tag"), - COMMAND_TAG_FORCHANGE("for changing the faction tag"), - COMMAND_TAG_FACTION("%1$s changed your faction tag to %2$s"), - COMMAND_TAG_CHANGED("The faction %1$s changed their name to %2$s."), - COMMAND_TAG_DESCRIPTION("Change the faction tag"), - - COMMAND_TITLE_TOCHANGE("to change a players title"), - COMMAND_TITLE_FORCHANGE("for changing a players title"), - COMMAND_TITLE_CHANGED("%1$s changed a title: %2$s"), - COMMAND_TITLE_DESCRIPTION("Set or remove a players title"), - - COMMAND_TOGGLEALLIANCECHAT_DESCRIPTION("Toggles whether or not you will see alliance chat"), - COMMAND_TOGGLEALLIANCECHAT_IGNORE("Alliance chat is now ignored"), - COMMAND_TOGGLEALLIANCECHAT_UNIGNORE("Alliance chat is no longer ignored"), - - COMMAND_TOGGLESB_DISABLED("You can't toggle scoreboards while they are disabled."), - - - COMMAND_TOP_DESCRIPTION("Sort Factions to see the top of some criteria."), - COMMAND_TOP_TOP("Top Factions by %s. Page %d/%d"), - COMMAND_TOP_LINE("%d. &6%s: &c%s"), // Rank. Faction: Value - COMMAND_TOP_INVALID("Could not sort by %s. Try balance, online, members, power or land."), - - COMMAND_TNT_DISABLED_MSG("&cThis command is disabled!"), - COMMAND_TNT_INVALID_NUM("The amount needs to be a number!"), - COMMAND_TNT_DEPOSIT_SUCCESS("&cSuccessfully deposited tnt."), - COMMAND_TNT_EXCEEDLIMIT("&cThis exceeds the bank limit!"), - COMMAND_TNT_WIDTHDRAW_SUCCESS("&cSuccessfully withdrew tnt."), - COMMAND_TNT_WIDTHDRAW_NOTENOUGH("&cNot enough tnt in bank."), - COMMAND_TNT_DEPOSIT_NOTENOUGH("&cNot enough tnt in tnt inventory."), - COMMAND_TNT_AMOUNT("&cYour faction has {amount} tnt in the tnt bank."), - COMMAND_TNT_POSITIVE("&cPlease use positive numbers!"), - COMMAND_TNT_DESCRIPTION("add/widthraw from faction's tnt bank"), - COMMAND_TNT_WIDTHDRAW_NOTENOUGH_SPACE("&cNot enough space in your inventory."), - COMMAND_TNT_ADD_DESCRIPTION("&b/f tnt add&3 "), - COMMAND_TNT_TAKE_DESCRIPTION("&b/f tnt take&3 "), - - COMMAND_TNTFILL_HEADER("&c&l[!] &7Filling tnt in dispensers..."), - COMMAND_TNTFILL_SUCCESS("&c&l[!] &7Filled &c{amount}&7 Tnt in &c{dispensers} &7dispensers"), - COMMAND_TNTFILL_NOTENOUGH("&c&l[!] &7Not enough tnt in inventory."), - COMMAND_TNTFILL_RADIUSMAX("&c&l[!] &7The max radius is {max}"), - COMMAND_TNTFILL_AMOUNTMAX("&c&l[!] &7The max amount is {max}"), - COMMAND_TNTFILL_MOD("&c&l[!] &7Tnt will be used from the faction bank because you dont have the specified amount in your inventory and you are a {role}"), - COMMAND_TNTFILL_DESCRIPTION("Fill tnt into dispensers around you"), - - COMMAND_UNBAN_DESCRIPTION("Unban someone from your Faction"), - COMMAND_UNBAN_NOTBANNED("&7%s &cisn't banned. Not doing anything."), - COMMAND_UNBAN_UNBANNED("&e%1$s &cunbanned &7%2$s"), - COMMAND_UNBAN_TARGET("&aYou were unbanned from &r%s"), - - COMMAND_UNCLAIM_SAFEZONE_SUCCESS("Safe zone was unclaimed."), - COMMAND_UNCLAIM_SAFEZONE_NOPERM("This is a safe zone. You lack permissions to unclaim."), - COMMAND_UNCLAIM_WARZONE_SUCCESS("War zone was unclaimed."), - COMMAND_UNCLAIM_WARZONE_NOPERM("This is a war zone. You lack permissions to unclaim."), - COMMAND_UNCLAIM_UNCLAIMED("%1$s unclaimed some of your land."), - COMMAND_UNCLAIM_UNCLAIMS("You unclaimed this land."), - COMMAND_UNCLAIM_LOG("%1$s unclaimed land at (%2$s) from the faction: %3$s"), - COMMAND_UNCLAIM_WRONGFACTION("You don't own this land."), - COMMAND_UNCLAIM_TOUNCLAIM("to unclaim this land"), - COMMAND_UNCLAIM_FORUNCLAIM("for unclaiming this land"), - COMMAND_UNCLAIM_FACTIONUNCLAIMED("%1$s unclaimed some land."), - COMMAND_UNCLAIM_DESCRIPTION("Unclaim the land where you are standing"), - - COMMAND_UNCLAIMALL_TOUNCLAIM("to unclaim all faction land"), - COMMAND_UNCLAIMALL_FORUNCLAIM("for unclaiming all faction land"), - COMMAND_UNCLAIMALL_UNCLAIMED("%1$s unclaimed ALL of your faction's land."), - COMMAND_UNCLAIMALL_LOG("%1$s unclaimed everything for the faction: %2$s"), - COMMAND_UNCLAIMALL_DESCRIPTION("Unclaim all of your factions land"), - COMMAND_UNCLAIM_CLICKTOUNCLAIM("Click to unclaim &2(%1$d, %2$d)"), - - COMMAND_VERSION_NAME("&c&l[!]&7 &c&k||| &r&4SaberFactions&7 &c&k|||&r &c» &7By Driftay"), - COMMAND_VERSION_VERSION("&7Version &c» &7%1$s"), - COMMAND_VERSION_DESCRIPTION("Show plugin and translation version information"), - - COMMAND_WARUNCLAIMALL_DESCRIPTION("Unclaim all warzone land"), - COMMAND_WARUNCLAIMALL_SUCCESS("You unclaimed ALL war zone land."), - COMMAND_WARUNCLAIMALL_LOG("%1$s unclaimed all war zones."), - - COMMAND_RULES_DISABLED_MSG("&cThis command is disabled!"), - COMMAND_RULES_DESCRIPTION("set/remove/add rules!"), - COMMAND_RULES_ADD_INVALIDARGS("Please include a rule!"), - COMMAND_RULES_SET_INVALIDARGS("Please include a line number & rule!"), - COMMAND_RULES_REMOVE_INVALIDARGS("Please include a line number!"), - COMMAND_RULES_ADD_SUCCESS("&cRule added successfully!"), - COMMAND_RULES_REMOVE_SUCCESS("&cRule removed successfully!"), - COMMAND_RULES_SET_SUCCESS("&cRule set successfully!"), - COMMAND_RULES_CLEAR_SUCCESS("&cRule cleared successfully!"), - - // F Global \\ - COMMAND_F_GLOBAL_TOGGLE("&c&l[!] &7You have &b%1$s &7Global Chat"), - COMMAND_F_GLOBAL_DESCRIPTION("Toggle global chat and only allow factions based chats"), - - /** - * Leaving - This is accessed through a command, and so it MAY need a COMMAND_* slug :s - */ - LEAVE_PASSADMIN("You must give the admin role to someone else first."), - LEAVE_NEGATIVEPOWER("You cannot leave until your power is positive."), - LEAVE_TOLEAVE("to leave your faction."), - LEAVE_FORLEAVE("for leaving your faction."), - LEAVE_LEFT("%s left faction %s."), - LEAVE_DISBANDED("%s was disbanded."), - LEAVE_DISBANDEDLOG("The faction %s (%s) was disbanded due to the last player (%s) leaving."), - LEAVE_DESCRIPTION("\\n &a&l» &7Leave your faction"), - - /** - * Claiming - Same as above basically. No COMMAND_* because it's not in a command class, but... - */ - CLAIM_PROTECTED("This land is protected"), - CLAIM_DISABLED("Sorry, this world has land claiming disabled."), - CLAIM_CANTCLAIM("You can't claim land for %s."), - CLAIM_ALREADYOWN("%s already own this land."), - CLAIM_MUSTBE("You must be %s to claim land."), - CLAIM_MEMBERS("Factions must have at least %s members to claim land."), - CLAIM_SAFEZONE("You can not claim a Safe Zone."), - CLAIM_WARZONE("You can not claim a War Zone."), - CLAIM_POWER("You can't claim more land!You need more power!"), - CLAIM_LIMIT("Limit reached. You can't claim more land!"), - CLAIM_ALLY("You can't claim the land of your allies."), - CLAIM_CONTIGIOUS("You can only claim additional land which is connected to your first claim or controlled by another faction!"), - CLAIM_FACTIONCONTIGUOUS("You can only claim additional land which is connected to your first claim!"), - CLAIM_PEACEFUL("%s owns this land. Your faction is peaceful, so you cannot claim land from other factions."), - CLAIM_PEACEFULTARGET("%s owns this land, and is a peaceful faction. You cannot claim land from them."), - CLAIM_THISISSPARTA("%s owns this land and is strong enough to keep it."), - CLAIM_BORDER("You must start claiming land at the border of the territory."), - CLAIM_TOCLAIM("to claim this land"), - CLAIM_FORCLAIM("for claiming this land"), - CLAIM_TOOVERCLAIM("to overclaim this land"), - CLAIM_FOROVERCLAIM("for over claiming this land"), - CLAIM_CLAIMED("%s claimed land for %s from %s."), - CLAIM_CLAIMEDLOG("%s claimed land at (%s) for the faction: %s"), - CLAIM_OVERCLAIM_DISABLED("Over claiming is disabled on this server."), - CLAIM_TOOCLOSETOOTHERFACTION("Your claim is too close to another Faction. Buffer required is %d"), - CLAIM_OUTSIDEWORLDBORDER("Your claim is outside the border."), - CLAIM_OUTSIDEBORDERBUFFER("Your claim is outside the border. %d chunks away world edge required."), - CLAIM_CLICK_TO_CLAIM("Click to try to claim &2(%1$d, %2$d)"), - CLAIM_MAP_OUTSIDEBORDER("&cThis claim is outside the worldborder!"), - CLAIM_YOUAREHERE("You are here"), - CLAIM_NO_TERRITORY_PERM("You do not have permission from your faction leader to do this!"), - - /** - * More generic, or less easily categorisable translations, which may apply to more than one class - */ - GENERIC_YOU("you"), - GENERIC_YOURFACTION("your faction"), - GENERIC_NOPERMISSION("You don't have permission to %1$s."), - GENERIC_FPERM_NOPERMISSION("&7The faction leader does not allow you to &c%1$s."), - GENERIC_DOTHAT("do that"), //Ugh nuke this from high orbit - GENERIC_NOPLAYERMATCH("No player match found for \"%1$s\"."), - GENERIC_NOPLAYERFOUND("No player \"%1$s\" could not be found."), - GENERIC_ARGS_TOOFEW("Too few arguments. Use like this:"), - GENERIC_ARGS_TOOMANY("Strange argument \"%1$s\". Use the command like this:"), - GENERIC_DEFAULTDESCRIPTION("Default faction description :("), - GENERIC_OWNERS("Owner(s): %1$s"), - GENERIC_PUBLICLAND("Public faction land."), - GENERIC_FACTIONLESS("factionless"), - GENERIC_SERVERADMIN("A server admin"), - GENERIC_DISABLED("disabled"), - GENERIC_ENABLED("enabled"), - GENERIC_INFINITY("∞"), - GENERIC_CONSOLEONLY("This command cannot be run as a player."), - GENERIC_PLAYERONLY("This command can only be used by ingame players."), - GENERIC_ASKYOURLEADER(" Ask your leader to:"), - GENERIC_YOUSHOULD("You should:"), - GENERIC_YOUMAYWANT("You may want to: "), - GENERIC_TRANSLATION_VERSION("Translation: %1$s(%2$s,%3$s) State: %4$s"), - GENERIC_TRANSLATION_CONTRIBUTORS("Translation contributors: %1$s"), - GENERIC_TRANSLATION_RESPONSIBLE("Responsible for translation: %1$s"), - GENERIC_FACTIONTAG_TOOSHORT("The faction tag can't be shorter than %1$s chars."), - GENERIC_FACTIONTAG_TOOLONG("The faction tag can't be longer than %s chars."), - GENERIC_FACTIONTAG_ALPHANUMERIC("Faction tag must be alphanumeric. \"%s\" is not allowed."), - GENERIC_PLACEHOLDER(""), - GENERIC_NOTENOUGHMONEY("&cYou dont have enough money!"), - GENERIC_MONEYTAKE("&c{amount} has been taken from your account."), - - - MISSION_MISSION_STARTED("&f%1$s &dstarted the %2$s &fmission"), - MISSION_MISSION_ACTIVE("&c&l[!] &7This mission is currently active!"), - MISSION_MISSION_MAX_ALLOWED("&c&l[!] &7You may not have more then &b%1$s &7missions active at once."), - MISSION_MISSION_FINISHED("&c&l[!] &7Your faction has successfully completed %1$s mission!"), - COMMAND_MISSION_DESCRIPTION("Opens missions gui"), - // F Global \\ - - - PLAYER_NOT_FOUND("&c&l[!] &b%1$s &7is either not online or not in your faction!"), - PLACEHOLDER_ROLE_NAME("None"), - - - 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) - */ - COMPASS_SHORT_NORTH("N"), - COMPASS_SHORT_EAST("E"), - COMPASS_SHORT_SOUTH("S"), - COMPASS_SHORT_WEST("W"), - - /** - * Chat modes - */ - CHAT_MOD("mod chat"), - CHAT_FACTION("faction chat"), - CHAT_ALLIANCE("alliance chat"), - CHAT_TRUCE("truce chat"), - CHAT_PUBLIC("public chat"), - - /** - * Economy stuff - */ - - ECON_OFF("no %s"), // no balance, no value, no refund, etc - ECON_FORMAT("###,###.###"), - ECON_DISABLED("Factions econ is disabled."), - ECON_OVER_BAL_CAP("&4The amount &e%s &4is over Essentials' balance cap."), - - /** - * Relations - */ - RELATION_MEMBER_SINGULAR("member"), - RELATION_MEMBER_PLURAL("members"), - RELATION_ALLY_SINGULAR("ally"), - RELATION_ALLY_PLURAL("allies"), - RELATION_TRUCE_SINGULAR("truce"), - RELATION_TRUCE_PLURAL("truces"), - RELATION_NEUTRAL_SINGULAR("neutral"), - RELATION_NEUTRAL_PLURAL("neutrals"), - RELATION_ENEMY_SINGULAR("enemy"), - RELATION_ENEMY_PLURAL("enemies"), - - /** - * Roles - */ - ROLE_LEADER("leader"), - ROLE_COLEADER("coleader"), - ROLE_MODERATOR("moderator"), - ROLE_NORMAL("normal member"), - ROLE_RECRUIT("recruit"), - - /** - * Region types. - */ - REGION_SAFEZONE("safezone"), - REGION_WARZONE("warzone"), - REGION_WILDERNESS("wilderness"), - - REGION_PEACEFUL("peaceful territory"), - /** - * In the player and entity listeners - */ - PLAYER_CANTHURT("You may not harm other players in %s"), - PLAYER_SAFEAUTO("This land is now a safe zone."), - PLAYER_WARAUTO("This land is now a war zone."), - PLAYER_OUCH("Ouch, that is starting to hurt. You should give it a rest."), - PLAYER_USE_WILDERNESS("You can't use %s in the wilderness."), - PLAYER_USE_SAFEZONE("You can't use %s in a safe zone."), - PLAYER_USE_WARZONE("You can't use %s in a war zone."), - PLAYER_USE_TERRITORY("You can't %s in the territory of %s."), - PLAYER_USE_OWNED("You can't use %s in this territory, it is owned by: %s."), - PLAYER_COMMAND_WARZONE("You can't use the command '%s' in warzone."), - PLAYER_COMMAND_NEUTRAL("You can't use the command '%s' in neutral territory."), - PLAYER_COMMAND_ENEMY("You can't use the command '%s' in enemy territory."), - PLAYER_COMMAND_PERMANENT("You can't use the command '%s' because you are in a permanent faction."), - PLAYER_COMMAND_ALLY("You can't use the command '%s' in ally territory."), - PLAYER_COMMAND_WILDERNESS("You can't use the command '%s' in the wilderness."), - - PLAYER_POWER_NOLOSS_PEACEFUL("You didn't lose any power since you are in a peaceful faction."), - PLAYER_POWER_NOLOSS_WORLD("You didn't lose any power due to the world you died in."), - PLAYER_POWER_NOLOSS_WILDERNESS("You didn't lose any power since you were in the wilderness."), - PLAYER_POWER_NOLOSS_WARZONE("You didn't lose any power since you were in a war zone."), - PLAYER_POWER_LOSS_WARZONE("The world you are in has power loss normally disabled, but you still lost power since you were in a war zone.\nYour power is now %d / %d"), - PLAYER_POWER_NOW("Your power is now %d / %d"), - - PLAYER_PVP_LOGIN("You can't hurt other players for %d seconds after logging in."), - PLAYER_PVP_REQUIREFACTION("You can't hurt other players until you join a faction."), - PLAYER_PVP_FACTIONLESS("You can't hurt players who are not currently in a faction."), - PLAYER_PVP_PEACEFUL("Peaceful players cannot participate in combat."), - PLAYER_PVP_NEUTRAL("You can't hurt neutral factions. Declare them as an enemy."), - PLAYER_PVP_CANTHURT("You can't hurt %s."), - - PLAYER_PVP_NEUTRALFAIL("You can't hurt %s in their own territory unless you declare them as an enemy."), - PLAYER_PVP_TRIED("%s tried to hurt you."), - - /** - * Strings lying around in other bits of the plugins - */ - NOPAGES("Sorry. No Pages available."), - INVALIDPAGE("Invalid page. Must be between 1 and %1$d"), - - /** - * The ones here before I started messing around with this - */ - TITLE("title", "&bFactions &0|&r"), - WILDERNESS("wilderness", "&2Wilderness"), - WILDERNESS_DESCRIPTION("wilderness-description", ""), - WARZONE("warzone", "&4Warzone"), - WARZONE_DESCRIPTION("warzone-description", "Not the safest place to be."), - SAFEZONE("safezone", "&6Safezone"), - SAFEZONE_DESCRIPTION("safezone-description", "Free from pvp and monsters."), - TOGGLE_SB("toggle-sb", "You now have scoreboards set to {value}"), - FACTION_LEAVE("faction-leave", "Leaving %1$s, Entering %2$s"), - FACTIONS_ANNOUNCEMENT_TOP("faction-announcement-top", "&d--Unread Faction Announcements--"), - FACTIONS_ANNOUNCEMENT_BOTTOM("faction-announcement-bottom", "&d--Unread Faction Announcements--"), - DEFAULT_PREFIX("default-prefix", "{relationcolor}[{faction}]"), - FACTION_LOGIN("faction-login", "&e%1$s &9logged in."), - FACTION_LOGOUT("faction-logout", "&e%1$s &9logged out.."), - NOFACTION_PREFIX("nofactions-prefix", "&6[&ano-faction&6]&r"), - DATE_FORMAT("date-format", "MM/d/yy h:ma"), // 3/31/15 07:49AM - - /** - * Raidable is used in multiple places. Allow more than just true/false. - */ - RAIDABLE_TRUE("raidable-true", "true"), - RAIDABLE_FALSE("raidable-false", "false"), - /** - * Warmups - */ - WARMUPS_NOTIFY_FLIGHT("&eFlight will enable in &d%2$d &eseconds."), - WARMUPS_NOTIFY_TELEPORT("&eYou will teleport to &d%1$s &ein &d%2$d &eseconds."), - WARMUPS_ALREADY("&cYou are already warming up."), - WARMUPS_CANCELLED("&cYou have cancelled your warmup."); - - public static SimpleDateFormat sdf; - private static YamlConfiguration LANG; - private String path; - private String def; - - /** - * Lang enum constructor. - * - * @param path The string path. - * @param start The default string. - */ - TL(String path, String start) { - this.path = path; - this.def = start; - } - - /** - * Lang enum constructor. Use this when your desired path simply exchanges '_' for '.' - * - * @param start The default string. - */ - TL(String start) { - this.path = this.name().replace('_', '.'); - if (this.path.startsWith(".")) { - path = "root" + path; - } - this.def = start; - } - - /** - * Set the {@code YamlConfiguration} to use. - * - * @param config The config to set. - */ - public static void setFile(YamlConfiguration config) { - LANG = config; - sdf = new SimpleDateFormat(DATE_FORMAT.toString()); - } - - @Override - public String toString() { - return ChatColor.translateAlternateColorCodes('&', LANG.getString(this.path, def)) + (this == TITLE ? " " : ""); - } - - public String format(Object... args) { - return String.format(toString(), args); - } - - /** - * Get the default value of the path. - * - * @return The default value of the path. - */ - public String getDefault() { - return this.def; - } - - /** - * Get the path to the string. - * - * @return The path to the string. - */ - public String getPath() { - return this.path; - } + /** + * Translation meta + */ + _AUTHOR("misc"), + _RESPONSIBLE("misc"), + _LANGUAGE("English"), + _ENCODING("UTF-8"), + _LOCALE("en_US"), + _REQUIRESUNICODE("false"), + _DEFAULT("true"), + _STATE("complete"), //incomplete, limited, partial, majority, complete + + /** + * Localised translation meta + */ + _LOCAL_AUTHOR("misc"), + _LOCAL_RESPONSIBLE("misc"), + _LOCAL_LANGUAGE("English"), + _LOCAL_REGION("US"), + _LOCAL_STATE("complete"), //And this is the English version. It's not ever going to be not complete. + /** + * Actions translations + */ + ACTIONS_NOPERMISSION("{faction} does not allow you to {action}"), + ACTIONS_NOPERMISSIONPAIN("It is painful to try to {action} in the territory of {faction}"), + ACTIONS_OWNEDTERRITORYDENY("You cant do that in this territory, it is owned by {owners}"), + ACTIONS_OWNEDTERRITORYPAINDENY("It is painful to try to {action} in this territory, it is owned by {owners}"), + ACTIONS_MUSTBE("Youmust be {role} to {action}."), + ACTIONS_NOSAMEROLE("{role} can't control each other..."), + ACTIONS_NOFACTION("You are not member of any faction."), + /** + * Command translations + */ + + /** + * Messsges for /f help + */ + COMMAND_HELP_NEXTCREATE("Learn how to create a faction on the next page."), + COMMAND_HELP_INVITATIONS("command.help.invitations", "You might want to close it and use invitations:"), + COMMAND_HELP_HOME("And don't forget to set your home:"), + COMMAND_HELP_404("&c&l» &7This page does &cnot &7exist"), + COMMAND_HELP_BANK_1("Your faction has a bank which is used to pay for certain"), //Move to last /f help page + COMMAND_HELP_BANK_2("things, so it will need to have money deposited into it."), //Move to last /f help page + COMMAND_HELP_BANK_3("To learn more, use the money command."), //Move to last /f help page + COMMAND_HELP_PLAYERTITLES("Player titles are just for fun. No rules connected to them."), //Move to last /f help page + COMMAND_HELP_OWNERSHIP_1("Claimed land with ownership set is further protected so"), //Move to last /f help page + COMMAND_HELP_OWNERSHIP_2("that only the owner(s), faction admin, and possibly the"), //Move to last /f help page + COMMAND_HELP_OWNERSHIP_3("faction moderators have full access."), //Move to last /f help page + COMMAND_HELP_RELATIONS_1("Set the relation you WISH to have with another faction."), //Move to last /f help page + COMMAND_HELP_RELATIONS_2("Your default relation with other factions will be neutral."), //Move to last /f help page + COMMAND_HELP_RELATIONS_3("If BOTH factions choose \"ally\" you will be allies."), //Move to last /f help page + COMMAND_HELP_RELATIONS_4("If ONE faction chooses \"enemy\" you will be enemies."), //Move to last /f help page + COMMAND_HELP_RELATIONS_5("You can never hurt members or allies."), //Move to last /f help page + COMMAND_HELP_RELATIONS_6("You can not hurt neutrals in their own territory."), //Move to last /f help page + COMMAND_HELP_RELATIONS_7("You can always hurt enemies and players without faction."), //Move to last /f help page + COMMAND_HELP_RELATIONS_8(""), + COMMAND_HELP_RELATIONS_9("Damage from enemies is reduced in your own territory."), //Move to last /f help page + COMMAND_HELP_RELATIONS_10("When you die you lose power. It is restored over time."), //Move to last /f help page + COMMAND_HELP_RELATIONS_11("The power of a faction is the sum of all member power."), //Move to last /f help page + COMMAND_HELP_RELATIONS_12("The power of a faction determines how much land it can hold."), //Move to last /f help page + COMMAND_HELP_RELATIONS_13("You can claim land from factions with too little power."), //Move to last /f help page + COMMAND_HELP_PERMISSIONS_1("Only faction members can build and destroy in their own"), //Move to last /f help page + COMMAND_HELP_PERMISSIONS_2("territory. Usage of the following items is also restricted:"), //Move to last /f help page + COMMAND_HELP_PERMISSIONS_3("Door, Chest, Furnace, Dispenser, Diode."), //Move to last /f help page + COMMAND_HELP_PERMISSIONS_4(""), + COMMAND_HELP_PERMISSIONS_5("Make sure to put pressure plates in front of doors for your"), //Move to last /f help page + COMMAND_HELP_PERMISSIONS_6("guest visitors. Otherwise they can't get through. You can"), //Move to last /f help page + COMMAND_HELP_PERMISSIONS_7("also use this to create member only areas."), //Move to last /f help page + COMMAND_HELP_PERMISSIONS_8("As dispensers are protected, you can create traps without"), //Move to last /f help page + COMMAND_HELP_PERMISSIONS_9("worrying about those arrows getting stolen."), //Move to last /f help page + COMMAND_HELP_ADMIN_1("&a&l» &a/f claim safezone \n &7claim land for the Safe Zone"), + COMMAND_HELP_ADMIN_2("&a&l» &a/f claim warzone \n &7claim land for the War Zone"), + COMMAND_HELP_ADMIN_3("&a&l» &a/f autoclaim [safezone|warzone] \n &7take a guess"), + COMMAND_HELP_MOAR_1("Finally some commands for the server admins:"), + COMMAND_HELP_MOAR_2("More commands for server admins:"), + COMMAND_HELP_MOAR_3("Even more commands for server admins:"), + COMMAND_HELP_DESCRIPTION("\n &a&l» &7Display a &ahelp &7page"), + + COMMAND_NEAR_DESCRIPTION("Get nearby faction players in a radius."), + COMMAND_NEAR_DISABLED_MSG("&cThis command is disabled!"), + COMMAND_NEAR_FORMAT("{playername} &c({distance}m)"), + COMMAND_NEAR_USE_MSG("&cFaction members nearby"), + + /** + * Messsges for Faction Admins/Mods + */ + + COMMAND_UPGRADES_DESCRIPTION("&cOpen the Upgrades Menu"), + COMMAND_CORNER_CANT_CLAIM("&c&l[!] &cYou may not claim this corner!"), + COMMAND_CORNER_CLAIMED("\n&2&l[!] &aYou have claimed the corner successfully, totalling in &b%1$d &achunks!\n"), + COMMAND_CORNER_ATTEMPTING_CLAIM("&c&l[!] &7Attempting to claim corner..."), + COMMAND_CORNER_NOT_CORNER("&c&l[!] &7You must be in a corner to use this command!"), + COMMAND_CORNER_DESCRIPTION("claim a corner at world border"), + COMMAND_CORNERLIST_DESCRIPTION("list of all corners"), + + COMMAND_ADMIN_NOTMEMBER("&c&l[!] &7%1$s &cis not a member in your faction."), + COMMAND_ADMIN_NOTADMIN("&c&l[!] &cYou are not the faction admin."), + COMMAND_ADMIN_TARGETSELF("'&c&l[!] &cThe target player musn''t be yourself."), + COMMAND_ADMIN_DEMOTES("&c&l[!] &cYou have demoted &7%1$s &cfrom the position of faction admin."), + COMMAND_ADMIN_DEMOTED("&c&l[!] &cYou have been demoted from the position of faction admin by &7%1$s&c"), + COMMAND_ADMIN_PROMOTES("&e&l[!] &eYou have promoted &6%1$s &eto the position of faction admin."), + COMMAND_ADMIN_PROMOTED("&e&l[!] &6%1$s &egave &6%2$s ðe leadership of &6%3$s&e."), + COMMAND_ADMIN_DESCRIPTION("Hand over your admin rights"), + COMMAND_ADMIN_NOMEMBERS("&e&l[!] &cNo one else to promote, please disband faction."), + + COMMAND_AHOME_DESCRIPTION("Send a player to their f home no matter what."), + COMMAND_AHOME_NOHOME("%1$s doesn't have an f home."), + COMMAND_AHOME_SUCCESS("$1%s was sent to their f home."), + COMMAND_AHOME_OFFLINE("%1$s is offline."), + COMMAND_AHOME_TARGET("You were sent to your f home."), + + COMMAND_ANNOUNCE_DESCRIPTION("Announce a message to players in faction."), + COMMAND_ALTS_DESCRIPTION("Faction Alts Commands"), + COMMAND_STRIKE_DESCRIPTION("Faction Strike Commands"), + + COMMAND_ALTS_LIST_DESCRIPTION("List all alts in your faction"), + + COMMAND_FREECAM_ENEMYINRADIUS("Freecam disabled, An enemy is closeby!"), + COMMAND_FREECAM_OUTSIDEFLIGHT("Please dont leave the flight radius!"), + COMMAND_FREECAM_ENABLED("Freecam is now enabled!"), + COMMAND_FREECAM_DISABLED("Freecam is now disabled"), + COMMAND_FREECAM_DESCRIPTION("Go into spectator mode"), + + + COMMAND_AUTOCLAIM_ENABLED("&c&l[!] &7Now &cauto-claiming&7 land for %1$s."), + COMMAND_AUTOCLAIM_DISABLED("&c&l[!] Auto-claiming&7 of land is now &cdisabled."), + COMMAND_AUTOCLAIM_REQUIREDRANK("&c&l[!] &7You must be &c%1$s&7 to claim land."), + COMMAND_AUTOCLAIM_OTHERFACTION("&c&l[!]&7 You &ccan't &7claim land for &c%1$s&7."), + COMMAND_AUTOCLAIM_DESCRIPTION("Auto-claim land as you walk around"), + + + COMMAND_ALTINVITE_DESCRIPTION("Invite Alts to your faction."), + COMMAND_ALTKICK_DESCRIPTION("Kick alts from your faction"), + COMMAND_ALTKICK_NOTALT("&c&l[!] &7Player is not an alt."), + COMMAND_ALTKICK_NOTMEMBER("&c&l[!] &7This player is not a member of your faction."), + + COMMAND_ALTS_LIST_NOALTS("&c&l[!] &7%s does not have any alts in their faction!"), + COMMAND_AUTOHELP_HELPFOR("Help for command \""), + COMMAND_HOME_OTHER_NOTSET("&c&l[!] &7%s does not have their faction home set!"), + COMMAND_HOME_TELEPORT_OTHER("&c&l[!] &7You have teleported to %s's faction home!"), + COMMAND_SHOP_DESCRIPTION("opens shop gui"), + + COMMAND_BAN_DESCRIPTION("Ban players from joining your Faction."), + COMMAND_BAN_TARGET("&c&l[!] &7You were &cbanned &7from &c%1$s"), // banned player perspective + COMMAND_BAN_BANNED("&c&l[!] &7%1$s &cbanned &7%2$s"), + COMMAND_BAN_SELF("&c&l[!] &7You may &cnot &7ban &cyourself&7."), + COMMAND_BAN_INSUFFICIENTRANK("&c&l[!] &7Your &crank &7is too low to&c ban &7%1$s"), + COMMAND_BAN_ALREADYBANNED("&c&l[!] &7This player is &calready banned&7!"), + + COMMAND_BANLIST_DESCRIPTION("View a Faction's ban list"), + COMMAND_BANLIST_HEADER("&c&l[!] &7There are &c%d&7 bans for &c%s"), + COMMAND_BANLIST_ENTRY("&7%d. &c%s &r&7// &c%s &r&7// &c%s"), + COMMAND_BANLIST_NOFACTION("&c&l[!] &7You are &cnot &7in a Faction."), + COMMAND_BANLIST_INVALID("&c&l[!] &7The faction &c%s &7does not exist"), + + COMMAND_BOOM_PEACEFULONLY("&c&l[!] &7This command is &conly &7usable by factions which are &cspecifically &7designated as &cpeaceful&7."), + COMMAND_BOOM_TOTOGGLE("to toggle explosions"), + COMMAND_BOOM_FORTOGGLE("for toggling explosions"), + COMMAND_BOOM_ENABLED("&c&l[!] &c%1$s&7 has&c %2$s&7 explosions in your faction's territory."), + COMMAND_BOOM_DESCRIPTION("Toggle explosions (peaceful factions only)"), + + + COMMAND_BYPASS_ENABLE("&e&l[!] &eYou have enabled admin bypass mode. You will be able to build or destroy anywhere."), + COMMAND_BYPASS_ENABLELOG(" has ENABLED admin bypass mode."), + COMMAND_BYPASS_DISABLE("&c&l[!] &cYou have disabled admin bypass mode."), + COMMAND_BYPASS_DISABLELOG(" has DISABLED admin bypass mode."), + COMMAND_BYPASS_DESCRIPTION("Enable admin bypass mode"), + + COMMAND_BANNER_DESCRIPTION("Turn a held banner into a war banner"), + COMMAND_BANNER_NOTENOUGHMONEY("&c&l[!] &7You do&c not&7 have enough money"), + COMMAND_BANNER_MONEYTAKE("&c&l[!] $&c{amount} &7has been taken from your account."), + COMMAND_BANNER_SUCCESS("&c&l[!] &7You have created a &c&lWarBanner!"), + COMMAND_BANNER_DISABLED("&c&l[!] &7Buying&c warbanners&7 is &cdisabled!"), + + COMMAND_TPBANNER_NOTSET("&c&l[!] &7Your faction &cdoes not &7have a &c&lWarBanner &7placed!"), + COMMAND_TPBANNER_SUCCESS("&c&l[!] &cTeleporting &7to your factions's &c&lWarBanner"), + COMMAND_TPBANNER_DESCRIPTION("Teleport to your faction banner"), + + + COMMAND_CHAT_DISABLED("&c&l[!] &7The built in chat channels are &cdisabled &7on this server."), + COMMAND_CHAT_INVALIDMODE("&c&l[!] &cUnrecognised &7chat mode. Please enter either '&da&7','&af&7','&6m&7' or '&fp&7'"), + COMMAND_CHAT_DESCRIPTION("Change chat mode"), + + COMMAND_CHAT_MODE_PUBLIC("&c&l[!] &fPublic &7chat mode."), + COMMAND_CHAT_MODE_ALLIANCE("&c&l[!] &dAlliance &7only chat mode."), + COMMAND_CHAT_MODE_TRUCE("&c&l[!] &5Truce &7only chat mode."), + COMMAND_CHAT_MODE_FACTION("&c&l[!] &aFaction&7 only chat mode."), + COMMAND_CHAT_MODE_MOD("&c&l[!] &dMod &7only chat mode."), + COMMAND_CHAT_MOD_ONLY("&c&l[!] &7Only Mods can talk through this chat mode."), + + COMMAND_CHATSPY_ENABLE("&c&l[!] &7You have &cenabled &7chat spying mode."), + COMMAND_CHATSPY_ENABLELOG(" has ENABLED chat spying mode."), + COMMAND_CHATSPY_DISABLE("&c&l[!] &7You have &cdisabled &7chat spying mode."), + COMMAND_CHATSPY_DISABLELOG(" has DISABLED chat spying mode."), + COMMAND_CHATSPY_DESCRIPTION("Enable admin chat spy mode"), + + COMMAND_CLAIM_INVALIDRADIUS("&c&l[!]&7 If you specify a &cradius&7, it must be at least &c1&7."), + COMMAND_CLAIM_DENIED("&c&l[!]&7 You &cdo not &7have &cpermission&7 to &cclaim&7 in a radius."), + COMMAND_CLAIM_DESCRIPTION("Claim land from where you are standing"), + + COMMAND_CLAIMLINE_INVALIDRADIUS("&c&l[!]&7 If you &cspecify&7 a distance, it must be at least &c1&7."), + COMMAND_CLAIMLINE_DENIED("&c&l[!]&7 You &cdo not &7have&c permission&7 to claim in a line."), + COMMAND_CLAIMLINE_DESCRIPTION("Claim land in a straight line."), + COMMAND_CLAIMLINE_ABOVEMAX("&c&l[!]&7 The &cmaximum&7 limit for claim line is &c%s&7."), + COMMAND_CLAIMLINE_NOTVALID("&c&l[!]&7 &c%s&7 is not a &ccardinal &7direction. You may use &cnorth&7, &ceast&7, &csouth &7or &cwest&7."), + + COMMAND_CONFIG_NOEXIST("&c&l[!]&7 No configuration setting \"&c%1$s&7\" exists."), + COMMAND_CONFIG_SET_TRUE("\" option set to true (enabled)."), + COMMAND_CONFIG_SET_FALSE("\" option set to false (disabled)."), + COMMAND_CONFIG_OPTIONSET("\" option set to "), + COMMAND_CONFIG_COLOURSET("\" color option set to \""), + COMMAND_CONFIG_INTREQUIRED("Cannot set \"%1$s\": An integer (whole number) value required."), + COMMAND_CONFIG_LONGREQUIRED("Cannot set \"%1$s\": A long integer (whole number) value required."), + COMMAND_CONFIG_DOUBLEREQUIRED("Cannot set \"%1$s\": A double (numeric) value required."), + COMMAND_CONFIG_FLOATREQUIRED("Cannot set \"%1$s\": A float (numeric) value required."), + COMMAND_CONFIG_INVALID_COLOUR("Cannot set \"%1$s\": \"%2$s\" is not a valid color."), + COMMAND_CONFIG_INVALID_COLLECTION("\"%1$s\" is not a data collection type which can be modified with this command."), + COMMAND_CONFIG_INVALID_MATERIAL("Cannot change \"%1$s\" set: \"%2$s\" is not a valid material."), + COMMAND_CONFIG_INVALID_TYPESET("\"%1$s\" is not a data type set which can be modified with this command."), + COMMAND_CONFIG_MATERIAL_ADDED("\"%1$s\" set: Material \"%2$s\" added."), + COMMAND_CONFIG_MATERIAL_REMOVED("\"%1$s\" set: Material \"%2$s\" removed."), + COMMAND_CONFIG_SET_ADDED("\"%1$s\" set: \"%2$s\" added."), + COMMAND_CONFIG_SET_REMOVED("\"%1$s\" set: \"%2$s\" removed."), + COMMAND_CONFIG_LOG(" (Command was run by %1$s.)"), + COMMAND_CONFIG_ERROR_SETTING("Error setting configuration setting \"%1$s\" to \"%2$s\"."), + COMMAND_CONFIG_ERROR_MATCHING("Configuration setting \"%1$s\" couldn't be matched, though it should be... please report this error."), + COMMAND_CONFIG_ERROR_TYPE("'%1$s' is of type '%2$s', which cannot be modified with this command."), + COMMAND_CONFIG_DESCRIPTION("Change a conf.json setting"), + + COMMAND_CONVERT_BACKEND_RUNNING("&c&l[!]&7 Already running that backend."), + COMMAND_CONVERT_BACKEND_INVALID("&c&l[!]&7 Invalid backend"), + COMMAND_CONVERT_DESCRIPTION("Convert the plugin backend"), + + COMMAND_COORDS_MESSAGE("&c&l[!] &7{player}&7's coords are &c{x}&7,&c{y}&7,&c{z}&7 in &c{world}"), + COMMAND_COORDS_DESCRIPTION("broadcast your coords to your faction"), + + COMMAND_CHECKPOINT_DISABLED("&c&l[!]&7 You &ccannot&7 use checkpoint while its&c disabled&7!"), + COMMAND_CHECKPOINT_SET("&c&l[!]&7 You have &cset&7 the &cfaction checkpoint&7 at your &cLocation&7."), + COMMAND_CHECKPOINT_GO("&c&l[!]&7 &cTeleporting&7 to &cfaction checkpoint"), + COMMAND_CHECKPOINT_INVALIDLOCATION("&c&l[!]&7 &cInvalid Location!&7 You can &cset&7 checkpoints in &cyour claims&7 or &2wilderness&7."), + COMMAND_CHECKPOINT_NOT_SET("&c&l[!]&7 You have to &cset &7the &cfaction checkpoint&7 first."), + COMMAND_CHECKPOINT_CLAIMED("&c&l[!]&7 Your current &cfaction checkpoint&7 is claimed, set a &cnew &7one!"), + COMMAND_CHECKPOINT_DESCRIPTION("Set or go to your faction checkpoint!"), + + COMMAND_CREATE_MUSTLEAVE("&c&l[!]&7 You must &cleave &7your &ccurrent faction &7first."), + COMMAND_CREATE_INUSE("&c&l[!]&7 That tag is &calready &7in use."), + COMMAND_CREATE_TOCREATE("to create a new faction"), + COMMAND_CREATE_FORCREATE("for creating a new faction"), + COMMAND_CREATE_ERROR("&c&l[!]&7 There was an &cinternal error&7 while trying to create your faction. &cPlease try again&7."), + COMMAND_CREATE_CREATED("&c&l[!]&7 &c%1$s &7created a new faction &c&l%2$s"), + COMMAND_CREATE_YOUSHOULD("&c&l[!]&7 You should now: &c%1$s"), + COMMAND_CREATE_CREATEDLOG(" created a new faction: "), + COMMAND_CREATE_DESCRIPTION("Create a new faction"), + + COMMAND_CHECK_INVALID_NUMBER("&c&l[!] &7You may not set your factions wall check timer to that number!"), + COMMAND_CHECK_SUCCESSFUL("&c&l[!] &7You have set your factions wall check timer to &b%1$d &7minutes!"), + COMMAND_CHECK_DESCRIPTION("Check your factions walls!"), + CHECK_NOTIFY_MESSAGE("\n &c&lFaction Walls&7» &bCheck Your Walls! \n"), + + COMMAND_DEINVITE_CANDEINVITE("&c&l[!]&7 Players you can &cdeinvite: "), + COMMAND_DEINVITE_CLICKTODEINVITE("&c&l[!]&7 Click to &crevoke&7 invite for &c%1$s"), + COMMAND_DEINVITE_ALREADYMEMBER("&c&l[!]&7 &c%1$s&7 is already a member of &c%2$s"), + COMMAND_DEINVITE_MIGHTWANT("&c&l[!]&7 You might want to: &c%1$s"), + COMMAND_DEINVITE_REVOKED("&c&l[!]&7 &7%1$s &crevoked&7 your invitation to &c%2$s&7."), + COMMAND_DEINVITE_REVOKES("&c&l[!]&7 %1$s&c revoked &7%2$s's&c invitation."), + COMMAND_DEINVITE_DESCRIPTION("Remove a pending invitation"), + + COMMAND_DELFWARP_DELETED("&c&l[!]&7 Deleted warp &c%1$s"), + COMMAND_DELFWARP_INVALID("&c&l[!]&7 Couldn't &cfind&7 warp &c%1$s"), + COMMAND_DELFWARP_TODELETE("to delete warp"), + COMMAND_DELFWARP_FORDELETE("for deleting warp"), + COMMAND_DELFWARP_DESCRIPTION("Delete a faction warp"), + + COMMAND_DESCRIPTION_CHANGES("&c&l[!]&7 You have &cchanged&7 the &cdescription&7 for &c%1$s&7 to:"), + COMMAND_DESCRIPTION_CHANGED("&c&l[!]&7 The faction&c %1$s&7 changed their &cdescription &7to:"), + COMMAND_DESCRIPTION_TOCHANGE("to change faction description"), + COMMAND_DESCRIPTION_FORCHANGE("for changing faction description"), + COMMAND_DESCRIPTION_DESCRIPTION("Change the faction description"), + + COMMAND_DISBAND_IMMUTABLE("&c&l[!]&7 &7You &ccannot&7 disband &2Wilderness&7,&e SafeZone&7, or &4WarZone."), + COMMAND_DISBAND_MARKEDPERMANENT("&c&l[!]&7 This faction is designated as&c permanent&7, so you cannot disband it."), + COMMAND_DISBAND_BROADCAST_YOURS("&c&l[!]&7 &c%1$s&7 disbanded your &cfaction."), + COMMAND_DISBAND_BROADCAST_NOTYOURS("&c&l[!]&7 &c%1$s &7disbanded the faction &c%2$s."), + COMMAND_DISBAND_HOLDINGS("&c&l[!]&7 &7You have been given the disbanded &cfaction's bank&7, totaling &c%1$s."), + COMMAND_DISBAND_PLAYER("&c&l[!] &7You have disbanded your &cfaction"), + COMMAND_DISBAND_CONFIRM("&c&l[!]&7 Your Faction has&c {tnt} &7tnt left in the bank, it will be &clost&7 if the faction is &cdisbanded&7. Type&c /f disband &7again within &c10&7 seconds to&c disband&7."), + COMMAND_DISBAND_DESCRIPTION("Disband a faction"), + + COMMAND_FLY_DISABLED("&c&l[!]&7 Sorry, Faction flight is &cdisabled &7on this server"), + COMMAND_FLY_DESCRIPTION("Enter or leave Faction flight mode"), + COMMAND_FLY_CHANGE("&c&l[!]&7 Faction flight &c%1$s"), + COMMAND_FLY_COOLDOWN("&c&l[!]&7 You will &cnot&7 take fall damage for &c{amount}&7 seconds"), + COMMAND_FLY_DAMAGE("&c&l[!]&7 Faction flight &cdisabled&7 due to entering combat"), + COMMAND_FLY_NO_ACCESS("&c&l[!]&7 &cCannot fly &7in territory of %1$s"), + COMMAND_FLY_ENEMY_NEAR("&c&l[!]&7 Flight has been&c disabled&7 an enemy is nearby"), + COMMAND_FLY_CHECK_ENEMY("&c&l[!]&7 Cannot fly here, an enemy is &cnearby"), + COMMAND_FLY_NO_EPEARL("&c&l[!] &7You &ccannot&7 throw enderpearls while flying!"), + + COMMAND_FOCUS_SAMEFACTION("&c[!] You may not focus players in your faction!"), + COMMAND_FOCUS_FOCUSING("&c&l[!] &7Your faction is now focusing &c%s"), + COMMAND_FOCUS_NO_LONGER("&c&l[!] &7Your faction is no longer focusing &c%s"), + COMMAND_FOCUS_DESCRIPTION("Focus a Specific Player"), + + + COMMAND_FWARP_CLICKTOWARP("&c&l[!]&7 Click to &cwarp!"), + COMMAND_FWARP_COMMANDFORMAT("&c&l[!]&7 /f warp &c[password]"), + COMMAND_FWARP_WARPED("&c&l[!]&7 Warped to &c%1$s"), + COMMAND_FWARP_INVALID_WARP("&c&l[!]&7 Couldn't find warp &c%1$s"), + COMMAND_FWARP_TOWARP("to warp"), + COMMAND_FWARP_FORWARPING("for warping"), + COMMAND_FWARP_WARPS("Warps: "), + COMMAND_FWARP_DESCRIPTION("Teleport to a faction warp"), + COMMAND_FWARP_INVALID_PASSWORD("&c&l[!]&7 &cInvalid password!"), + COMMAND_FWARP_PASSWORD_REQUIRED("&c&l[!]&c Warp Password:"), + COMMAND_FWARP_PASSWORD_TIMEOUT("&c&l[!]&7 Warp password &ccanceled"), + + COMMAND_GRACE_DESCRIPTION("Toggles Grace Period on/off"), + COMMAND_GRACE_ENABLED("&cYou cannot place &e%s &cwhile grace period is active!"), + COMMAND_GRACE_TOGGLE("&8» &7Grace period is now &c%1$s"), + + COMMAND_HINT_PERMISSION("&aYou can manage your factions permissions using &7/f perms"), + + COMMAND_HOME_DISABLED("&c&l[!]&7 Sorry, Faction homes are &cdisabled on this server."), + COMMAND_HOME_TELEPORTDISABLED("&c&l[!]&7 Sorry, the ability to &cteleport &7to Faction homes is &cdisabled &7on this server."), + COMMAND_HOME_NOHOME("&c&l[!]&7 Your faction does &cnot &7have a home. "), + COMMAND_HOME_INENEMY("&c&l[!]&7 You &ccannot teleport &7to your &cfaction home&7 while in the territory of an &cenemy faction&7."), + COMMAND_HOME_WRONGWORLD("&c&l[!]&7 You &ccannot &7teleport to your &cfaction home&7 while in a different world."), + COMMAND_HOME_ENEMYNEAR("&c&l[!]&7 You &ccannot teleport&7 to your faction home while an enemy is within &c%s&7 blocks of you."), + 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_INVENTORYSEE_DESCRIPTION("View a faction members inventory"), + + 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!"), + COMMAND_INSPECT_ENABLED("&c&l[!]&7 Inspect mode is now &aEnabled."), + COMMAND_INSPECT_HEADER("&c&m---&7Inspect Data&c&m---&c//&7x:{x},y:{y},z:{z}"), + COMMAND_INSPECT_ROW("&c{time} &7// &c{action} &7// &c{player} &7// &c{block-type}"), + COMMAND_INSPECT_NODATA("&c&l[!]&7 &7No Data was found!"), + COMMAND_INSPECT_NOTINCLAIM("&c&l[!]&7 &7You can &conly&7 inspect in &cyour &7claims!"), + COMMAND_INSPECT_BYPASS("&c&l[!]&7 Inspecting in &cbypass&7 mode"), + COMMAND_INSPECT_DESCRIPTION("Inspect blocks!"), + + COMMAND_INVITE_TOINVITE("to invite someone"), + COMMAND_INVITE_FORINVITE("for inviting someone"), + COMMAND_INVITE_CLICKTOJOIN("Click to join!"), + COMMAND_INVITE_INVITEDYOU(" &chas invited you to join "), + COMMAND_INVITE_INVITED("&c&l[!]&7 &c%1$s&7 invited &c%2$s&7 to your faction."), + COMMAND_ALTINVITE_INVITED_ALT("&c&l[!]&7 &c%1$s&7 invited &c%2$s&7 to your faction as an alt."), + + COMMAND_INVITE_ALREADYMEMBER("&c&l[!]&7 &c%1$s&7 is already a member of&c %2$s"), + COMMAND_INVITE_ALREADYINVITED("&c&l[!]&7 &c%1$s&7 has already been invited"), + COMMAND_INVITE_DESCRIPTION("Invite a player to your faction"), + COMMAND_INVITE_BANNED("&c&l[!]&7 &7%1$s &cis banned &7from your Faction. &cNot &7sending an invite."), + + BANKNOTE_WITHDRAW_NOT_ENOUGH("&c&l[!] &7You do not have enough money!"), + BANKNOTE_WITHDRAW_NO_ARGS("&c&l[!] &7Try /withdraw "), + XPBOTTLE_NOT_ENOUGH("&c&l[!] &7You do not have enough experience!"), + XPBOTTLE_WITHDRAW_NO_ARGS("&c&l[!] &7Try /bottle "), + + COMMAND_JOIN_CANNOTFORCE("&c&l[!]&7 You&c do not&7 have permission to &cmove other players&7 into a faction."), + COMMAND_JOIN_SYSTEMFACTION("&c&l[!]&7 Players may only join &cnormal factions&7. This is a &c&lsystem faction&7."), + COMMAND_JOIN_ALREADYMEMBER("&c&l[!]&7 &c%1$s %2$s already a member of&c %3$s"), + COMMAND_JOIN_ATLIMIT(" &c&l[!]&7 The faction &c%1$s &7is at the limit of&c %2$d&7 members, so&c %3$s&7 cannot currently join."), + COMMAND_JOIN_INOTHERFACTION("&c&l[!]&7 &c%1$s &7must leave&c %2$s &7current faction first."), + COMMAND_JOIN_NEGATIVEPOWER("&c&l[!]&7 &c%1$s &7cannot join a faction with a &cnegative power&7 level."), + COMMAND_JOIN_REQUIRESINVITATION("&c&l[!]&7 This faction &crequires&7 an invitation."), + COMMAND_JOIN_ATTEMPTEDJOIN("&c&l[!]&7 &c%1$s&7 tried to join your faction."), + COMMAND_JOIN_TOJOIN("to join a faction"), + COMMAND_JOIN_FORJOIN("for joining a faction"), + COMMAND_JOIN_SUCCESS("&c&l[!]&7 &c%1$s &7successfully joined &c%2$s."), + COMMAND_JOIN_MOVED("&c&l[!]&7 &c%1$s &7moved you into the faction&c %2$s."), + COMMAND_JOIN_JOINED("&c&l[!]&7 &c%1$s &7joined your faction."), + COMMAND_JOIN_JOINEDLOG("&c&l[!]&7 &c%1$s&7 joined the faction&c %2$s."), + COMMAND_JOIN_MOVEDLOG("&c&l[!]&7 &c%1$s &7moved the player&c %2$s &7into the faction&c %3$s&7."), + COMMAND_JOIN_DESCRIPTION("&a&l» &7Join a faction"), + COMMAND_JOIN_BANNED("&c&l[!]&7 You are &cbanned &7from &c%1$s."), + + COMMAND_KICK_CANDIDATES("&c&l[!]&7 Players you can kick: "), + COMMAND_KICK_CLICKTOKICK("Click to kick "), + COMMAND_KICK_SELF("&c&l[!]&7 You &ccannot &7kick&c yourself&7."), + COMMAND_KICK_NONE("&c&l[!]&7 That player&c is not&7 in a faction."), + COMMAND_KICK_NOTMEMBER("&c&l[!]&7 &c%1$s is not a member of %2$s"), + COMMAND_KICK_INSUFFICIENTRANK("&c&l[!]&7 Your rank is &ctoo low &7to kick this player."), + COMMAND_KICK_NEGATIVEPOWER("&c&l[!]&7 You &ccannot &7kick that member until their power is &apositive&7."), + COMMAND_KICK_TOKICK("to kick someone from the faction"), + COMMAND_KICK_FORKICK("for kicking someone from the faction"), + COMMAND_KICK_FACTION("&c&l[!]&7 %1$s&7 kicked %2$s&c from the faction!"), //message given to faction members + COMMAND_KICK_KICKS("&c&l[!]&7 You kicked &c%1$s&7 from the faction&c %2$s&7!"), //kicker perspective + COMMAND_KICK_KICKED("&c&l[!]&7 &c%1$s &7kicked you from&c %2$s&7!"), //kicked player perspective + COMMAND_KICK_DESCRIPTION("Kick a player from the faction"), + + COMMAND_LIST_FACTIONLIST("&c&l[!]&7 Faction List "), + COMMAND_LIST_TOLIST("to list the factions"), + COMMAND_LIST_FORLIST("for listing the factions"), + COMMAND_LIST_ONLINEFACTIONLESS("Online factionless: "), + COMMAND_LIST_DESCRIPTION("&a&l» &7See a list of the factions"), + + + COMMAND_SPAM_ENABLED("&c&l[!]&7 Factions Anti-Spam is now&a enabled"), + COMMAND_SPAM_DISABLED("&c&l[!]&7 Factions Anti-Spam in now&c disabled"), + COMMAND_SPAM_DESCRIPTION("enable antispam system"), + + COMMAND_LOCK_LOCKED("&c&l[!]&7 Factions is now&c locked"), + COMMAND_LOCK_UNLOCKED("&c&l[!]&7 Factions in now&a unlocked"), + COMMAND_LOCK_DESCRIPTION("Lock all write stuff. Apparently."), + + COMMAND_LOGINS_TOGGLE("&c&l[!]&7 Set login / logout notifications for Faction members to: &c%s"), + COMMAND_LOGINS_DESCRIPTION("Toggle(?) login / logout notifications for Faction members"), + + COMMAND_LOWPOWER_HEADER("&8&m--------&8&8&m---------"), + COMMAND_LOWPOWER_FORMAT("&c{player} &8(&c{player_power}&8/&c{maxpower}&8)"), + COMMAND_LOWPOWER_DESCRIPTION("Shows a list of players in your faction with lower power levels"), + + COMMAND_MAP_TOSHOW("to show the map"), + COMMAND_MAP_FORSHOW("for showing the map"), + COMMAND_MAP_UPDATE_ENABLED("&c&l[!]&7 Map auto update &aENABLED."), + COMMAND_MAP_UPDATE_DISABLED("&c&l[!]&7 Map auto update &cDISABLED."), + COMMAND_MAP_DESCRIPTION("Show the territory map, and set optional auto update"), + + COMMAND_MAPHEIGHT_DESCRIPTION("&eUpdate the lines that /f map sends"), + COMMAND_MAPHEIGHT_SET("&c&l[!]&7 Set /f map lines to &c&a%1$d"), + COMMAND_MAPHEIGHT_CURRENT("&c&l[!]&7 Current &cmapheight: &a%1$d"), + + COMMAND_MOD_CANDIDATES("&c&l[!]&7 Players you can promote: "), + COMMAND_MOD_CLICKTOPROMOTE("Click to promote "), + COMMAND_MOD_NOTMEMBER("&c&l[!]&7 &c%1$s7 is not a member in your faction."), + COMMAND_MOD_NOTADMIN("&c&l[!]&7 You &care not&7 the faction admin."), + COMMAND_MOD_SELF("&c&l[!]&7 The target player&c musn't&7 be yourself."), + COMMAND_MOD_TARGETISADMIN("&c&l[!]&7 The target player is a &cfaction admin.&7 Demote them first."), + COMMAND_MOD_REVOKES("&c&l[!]&7 &7You have &cremoved&7 moderator status from &c%1$s."), + COMMAND_MOD_REVOKED("&c&l[!]&7 &c%1$s&7 is &cno longer&7 moderator in your faction."), + COMMAND_MOD_PROMOTES("&c&l[!]&7 &c%1$s&7 was &cpromoted&7 to moderator in your faction."), + COMMAND_MOD_PROMOTED("&c&l[!]&7 You have promoted&c %1$s&7 to moderator."), + COMMAND_MOD_DESCRIPTION("Give or revoke moderator rights"), + + COMMAND_COLEADER_CANDIDATES("&c&l[!]&7 Players you can promote: "), + COMMAND_COLEADER_CLICKTOPROMOTE("Click to promote "), + COMMAND_COLEADER_NOTMEMBER("&c&l[!]&7 &c%1$s&7 is &cnot a member&7 in your faction."), + COMMAND_COLEADER_NOTADMIN("&c&l[!]&7 You are&c not&7 the faction admin."), + COMMAND_COLEADER_SELF("&c&l[!]&7 The target player&c musn't&7 be yourself."), + COMMAND_COLEADER_TARGETISADMIN("&c&l[!]&7 The target player is a &cfaction admin&7. Demote them first."), + COMMAND_COLEADER_REVOKES("&c&l[!]&7 You have removed &ccoleader &7status from&c %1$s&7."), + COMMAND_COLEADER_REVOKED("&c&l[!]&7 &c%1$s&7 is no longer&c coleader &7in your faction."), + COMMAND_COLEADER_PROMOTES("&c&l[!]&7 &c%1$s&7 was promoted to &ccoleader &7in your faction."), + COMMAND_COLEADER_PROMOTED("&c&l[!]&7 You have &cpromoted &7%1$s to &ccoleader."), + COMMAND_COLEADER_DESCRIPTION("Give or revoke coleader rights"), + + COMMAND_MODIFYPOWER_ADDED("&c&l[!]&7 Added &c%1$f &7power to &c%2$s. &7New total rounded power: &c%3$d"), + COMMAND_MODIFYPOWER_DESCRIPTION("Modify the power of a faction/player"), + + COMMAND_MONEY_LONG("&c&l[!]&7 The faction money commands."), + COMMAND_MONEY_DESCRIPTION("Faction money commands"), + + COMMAND_MONEYBALANCE_SHORT("show faction balance"), + COMMAND_MONEYBALANCE_DESCRIPTION("Show your factions current money balance"), + + COMMAND_MONEYDEPOSIT_DESCRIPTION("Deposit money"), + COMMAND_MONEYDEPOSIT_DEPOSITED("&c&l[!]&7 &c%1$s &7deposited&c %2$s&7 in the faction bank:&c %3$s"), + + COMMAND_MONEYTRANSFERFF_DESCRIPTION("Transfer f -> f"), + COMMAND_MONEYTRANSFERFF_TRANSFER("&c&l[!]&7 &c%1$s&7 transferred&c %2$s &7from the faction &c\"%3$s\"&7 to the faction&c \"%4$s\"&7"), + + COMMAND_MONEYTRANSFERFP_DESCRIPTION("Transfer f -> plugin"), + COMMAND_MONEYTRANSFERFP_TRANSFER("&c&l[!]&7 &c%1$s &7transferred&c %2$s &7from the faction&c \"%3$s\" &7to the player &c\"%4$s\""), + + COMMAND_MONEYTRANSFERPF_DESCRIPTION("Transfer plugin -> f"), + COMMAND_MONEYTRANSFERPF_TRANSFER("&c&l[!]&7 &c%1$s&7 transferred &c%2$s&7 from the player &c\"%3$s\" &7to the faction&c \"%4$s\""), + + COMMAND_MONEYWITHDRAW_DESCRIPTION("Withdraw money"), + COMMAND_MONEYWITHDRAW_WITHDRAW("&c&l[!]&7 &c%1$s&7 withdrew&c %2$s &7from the faction bank:&c %3$s"), + + COMMAND_OPEN_TOOPEN("to open or close the faction"), + COMMAND_OPEN_FOROPEN("for opening or closing the faction"), + COMMAND_OPEN_OPEN("open"), + COMMAND_OPEN_CLOSED("closed"), + COMMAND_OPEN_CHANGES("&c&l[!]&7 &c%1$s&7 changed the faction to &c%2$s&7."), + COMMAND_OPEN_CHANGED("&c&l[!]&7 The faction &c%1$s&7 is now &c%2$s"), + COMMAND_OPEN_DESCRIPTION("Switch if invitation is required to join"), + + COMMAND_OWNER_DISABLED("&c&l[!]&7 Sorry, but &cowned areas &7are &cdisabled &7on this server."), + COMMAND_OWNER_LIMIT("&c&l[!]&7 Sorry, but you have reached the server's &climit&7 of &c%1$d&7 owned areas per faction."), + COMMAND_OWNER_WRONGFACTION("&c&l[!]&7 &7This land is &cnot claimed &7by your faction, so you &ccan't set&7 ownership of it."), + COMMAND_OWNER_NOTCLAIMED("&c&l[!]&7 This land&c is not &7claimed by a faction. Ownership &cis not &7possible."), + COMMAND_OWNER_NOTMEMBER("&c&l[!]&7 &c%1$s&7 is &cnot a member &7of this faction."), + COMMAND_OWNER_CLEARED("&c&l[!]&7 You have &ccleared &7ownership for this claimed area."), + COMMAND_OWNER_REMOVED("&c&l[!]&7 You have&c removed ownership &7of this &cclaimed land&7 from &c%1$s&7."), + COMMAND_OWNER_TOSET("to set ownership of claimed land"), + COMMAND_OWNER_FORSET("for setting ownership of claimed land"), + COMMAND_OWNER_ADDED("&c&l[!]&7 You have added &c%1$s&7 to the &cowner list&7 for this claimed land."), + COMMAND_OWNER_DESCRIPTION("Set ownership of claimed land"), + + COMMAND_KILLHOLOGRAMS_DESCRIPTION("Kill holograms in a radius, admin command"), + + COMMAND_OWNERLIST_DISABLED("&c&l[!]&7 &cSorry, &7but owned areas are &cdisabled&7 on this server."),//dup-> + COMMAND_OWNERLIST_WRONGFACTION("&c&l[!]&7 This land &cis not&7 claimed by your faction."),//eq + COMMAND_OWNERLIST_NOTCLAIMED("&c&l[!]&7 This land is not claimed by any faction, thus no owners."),//eq + COMMAND_OWNERLIST_NONE("&c&l[!]&7 No owners are set here; everyone in the faction has access."), + COMMAND_OWNERLIST_OWNERS("&c&l[!]&7 Current owner(s) of this land: %1$s"), + COMMAND_OWNERLIST_DESCRIPTION("List owner(s) of this claimed land"), + + PAYPALSEE_PLAYER_PAYPAL("&c&l[!] &7You're factions paypal is: &b%1$s&7."), + COMMAND_PAYPAL_NOTSET("&c&l[!] &7Your faction does not have their paypal set!"), + COMMAND_PAYPALSET_ADMIN_SUCCESSFUL("&c&l[!] &7You have set &b%1$s's &7paypal to &b%2$s&7."), + COMMAND_PAYPALSET_ADMIN_FAILED("&c&l[!] &b%1$s &7is not an email!"), + COMMAND_PAYPALSET_NOTEMAIL("&c&l[!] &b%1$s &7is not an email!"), + COMMAND_PAYPALSET_DESCRIPTION("&c&l[!] &7Set the email of your faction to claim rewards."), + COMMAND_PAYPALSEE_DESCRIPTION("&c&l[!] &7View a specific factions paypal email with &b/f &b."), + COMMAND_PAYPALSET_CREATED("&c&l[!] &7Make sure to type &b/f &7!"), + COMMAND_PAYPALSET_SUCCESSFUL("&c&l[!] &7Successfully set your factions email - &b%1$s&7."), + COMMAND_PAYPALSEE_FACTION_PAYPAL("&c&l[!] &b%1$s's &7faction has their paypal set to &b%2$s&7."), + COMMAND_PAYPALSEE_FACTION_NOTSET("&c&l[!] &b%1$s's &7paypal has not yet been set!"), + COMMAND_PAYPALSEE_FACTION_NOFACTION("&c&l[!] &b%1$s &7does not have a faction!"), + + COMMAND_PEACEFUL_DESCRIPTION("&c&l[!]&7Set a faction to peaceful"), + COMMAND_PEACEFUL_YOURS("&c&l[!]&7%1$s has %2$s your faction"), + COMMAND_PEACEFUL_OTHER("&c&l[!]&7%s has %s the faction '%s'."), + COMMAND_PEACEFUL_GRANT("&c&l[!]&7 granted peaceful status to"), + COMMAND_PEACEFUL_REVOKE("removed peaceful status from"), + + COMMAND_PERM_DESCRIPTION("&c&l[!]&7&6Edit or list your Faction's permissions."), + COMMAND_PERM_INVALID_RELATION("&c&l[!]&7Invalid relation defined. Try something like&c 'ally'"), + COMMAND_PERM_INVALID_ACCESS("&c&l[!]&7 Invalid access defined. Try something like &c'allow'"), + COMMAND_PERM_INVALID_ACTION("&c&l[!]&7 Invalid action defined. Try something like &c'build'"), + COMMAND_PERM_SET("&c&l[!]&7 Set permission&c %1$s &7to &c%2$s &7for relation&c %3$s"), + COMMAND_PERM_TOP("RCT MEM OFF ALLY TRUCE NEUT ENEMY"), + COMMAND_PERM_LOCKED("&cThis permission has been locked by the server"), + + COMMAND_POINTS_FAILURE("&c&l[!] &c{faction} does not exist."), + COMMAND_POINTS_SUCCESSFUL("&c&l[!] &7You have added &e%1$s &7points to &b%2$s&7. &b%2$s's &7New Point Balance: &e%3$s"), + COMMAND_POINTS_INSUFFICIENT("&c&l[!] &7You may not add/set/remove a negative number of points to a faction!"), + COMMAND_POINTS_DESCRIPTION("General Command For Faction Points"), + + COMMAND_ADDPOINTS_DESCRIPTION("Add Points to Faction"), + + + COMMAND_REMOVEPOINTS_SUCCESSFUL("&c&l[!] &7You have taken &e%1$s &7points from &b%2$s&7. &b%2$s's &7New Point Balance: &e%3$s"), + COMMAND_REMOVEPOINTS_DESCRIPTION("Remove Points from a Faction"), + + COMMAND_SETPOINTS_SUCCESSFUL("&c&l[!] &7You have set &e%1$s &7points to &b%2$s&7. &b%2$s's &7New Point Balance: &e%3$s"), + COMMAND_SETPOINTS_DESCRIPTION("Set Points of a Faction"), + + COMMAND_PERMANENT_DESCRIPTION("Toggles a permanent faction option"), + COMMAND_PERMANENT_GRANT("&c&l[!]&7 added permanent status to"), + COMMAND_PERMANENT_REVOKE("&c&l[!]&7 removed permanent status from"), + COMMAND_PERMANENT_YOURS("&c&l[!]&7 &c%1$s&7 has &c%2$s&7 your faction"), + COMMAND_PERMANENT_OTHER("&c&l[!]&7 &c%s &7has &c%s &7the faction &c'%s'."), + COMMAND_PROMOTE_TARGET("&c&l[!]&7 You've been &c%1$s&7 to &c%2$s"), + COMMAND_PROMOTE_SUCCESS("&c&l[!]&7 You successfully&c %1$s %2$s &cto&7 %3$s"), + COMMAND_PROMOTE_PROMOTED("promoted"), + COMMAND_PROMOTE_DEMOTED("demoted"), + COMMAND_PROMOTE_COLEADER_ADMIN("&c&l[!]&7 &cColeaders cant promote players to Admin!"), + + COMMAND_PERMANENTPOWER_DESCRIPTION("Toggle permanent faction power option"), + COMMAND_PERMANENTPOWER_GRANT("added permanentpower status to"), + COMMAND_PERMANENTPOWER_REVOKE("removed permanentpower status from"), + COMMAND_PERMANENTPOWER_SUCCESS("&c&l[!]&7 You&c %s &7%s."), + COMMAND_PERMANENTPOWER_FACTION("&c&l[!]&7 &c%s %s &7your faction"), + + COMMAND_PROMOTE_DESCRIPTION("/f promote "), + COMMAND_PROMOTE_WRONGFACTION("&c&l[!]&7 &c%1$s&7 is &cnot&7 part of your faction."), + COMMAND_NOACCESS("&c&l[!]&7 You don't have access to that."), + COMMAND_PROMOTE_NOTTHATPLAYER("&c&l[!]&7 That player &ccannot&7 be promoted."), + COMMAND_PROMOTE_NOT_ALLOWED("&c&l[!]&7 You cannot promote to the same rank as yourself!"), + COMMAND_PROMOTE_NOTSELF("&c&l[!]&7 You cannot manage your own rank."), + COMMAND_PROMOTE_NOT_SAME("&c&l[!]&7 You cannot promote to the same rank as yourself!"), + + + COMMAND_POWER_TOSHOW("to show player power info"), + COMMAND_POWER_FORSHOW("for showing player power info"), + COMMAND_POWER_POWER("&c&l[!]&7 &c%1$s » &cPower &7/ &cMaxpower&a » &c%2$d &7/&c%3$d %4$s"), + COMMAND_POWER_BONUS(" (bonus: "), + COMMAND_POWER_PENALTY(" (penalty: "), + COMMAND_POWER_DESCRIPTION("&a&l» &7Show player &apower &7info"), + + COMMAND_POWERBOOST_HELP_1("&c&l[!]&7 You must specify \"plugin\" or \"player\" to target a player or \"f\" or \"faction\" to target a faction."), + COMMAND_POWERBOOST_HELP_2("&c&l[!]&7 ex. /f powerboost plugin SomePlayer 0.5 -or- /f powerboost f SomeFaction -5"), + COMMAND_POWERBOOST_INVALIDNUM("You must specify a valid numeric value for the power bonus/penalty amount."), + COMMAND_POWERBOOST_PLAYER("Player \"%1$s\""), + COMMAND_POWERBOOST_FACTION("Faction \"%1$s\""), + COMMAND_POWERBOOST_BOOST("%1$s now has a power bonus/penalty of %2$d to min and max power levels."), + COMMAND_POWERBOOST_BOOSTLOG("%1$s has set the power bonus/penalty for %2$s to %3$d."), + COMMAND_POWERBOOST_DESCRIPTION("Apply permanent power bonus/penalty to specified player or faction"), + + COMMAND_RELATIONS_ALLTHENOPE("&c&l[!]&7 &cNope!You can't."), + COMMAND_RELATIONS_MORENOPE("&c&l[!]&7 &cNope!&7You can't declare a relation to &cyourself"), + COMMAND_RELATIONS_ALREADYINRELATIONSHIP("&c&l[!]&7 You &calready&7 have that relation wish set with&c %1$s."), + COMMAND_RELATIONS_TOMARRY("to change a relation wish"), + COMMAND_RELATIONS_FORMARRY("for changing a relation wish"), + COMMAND_RELATIONS_MUTUAL("&c&l[!]&7 Your faction is now %1$s to %2$s"), + COMMAND_RELATIONS_PEACEFUL("&c&l[!]&7 This will have no effect while your faction is peaceful."), + COMMAND_RELATIONS_PEACEFULOTHER("&c&l[!]&7 This will have &cno effect&7 while their faction is peaceful."), + COMMAND_RELATIONS_DESCRIPTION("Set relation wish to another faction"), + COMMAND_RELATIONS_EXCEEDS_ME("&c&l[!]&7 Failed to set relation wish. You can only have %1$s %2$s."), + COMMAND_RELATIONS_EXCEEDS_THEY("&c&l[!]&7 Failed to set relation wish. They can only have %1$s %2$s."), + + COMMAND_RELATIONS_PROPOSAL_1("&c&l[!]&7&c %1$s &7wishes to be your&c %2$s"), + COMMAND_RELATIONS_PROPOSAL_2("&c&l[!]&7 Type &c/%1$s %2$s %3$s&7 to accept."), + COMMAND_RELATIONS_PROPOSAL_SENT("&c&l[!]&7 &c%1$s&7 were informed that you wish to be &c%2$s"), + + COMMAND_RELOAD_TIME("&c&l[!]&7 Reloaded &call &7configuration files from disk, took &c%1$d ms."), + COMMAND_RELOAD_DESCRIPTION("Reload data file(s) from disk"), + + COMMAND_SAFEUNCLAIMALL_DESCRIPTION("Unclaim all safezone land"), + COMMAND_SAFEUNCLAIMALL_UNCLAIMED("&c&l[!]&7 You unclaimed&c ALL&7 safe zone land."), + COMMAND_SAFEUNCLAIMALL_UNCLAIMEDLOG("&c&l[!]&7 &c%1$s&7 unclaimed all safe zones."), + + COMMAND_SAVEALL_SUCCESS("&c&l[!]&7 &cFactions saved to disk!"), + COMMAND_SAVEALL_DESCRIPTION("Save all data to disk"), + + COMMAND_SCOREBOARD_DESCRIPTION("Scoreboardy things"), + + COMMAND_SETBANNER_SUCCESS("&c&l[!] &7Banner Pattern Set!"), + COMMAND_SETBANNER_NOTBANNER("&c&l[!] &7The item is &cnot&7 a banner!"), + COMMAND_SETBANNER_DESCRIPTION("set banner pattern for your faction"), + + + COMMAND_SETDEFAULTROLE_DESCRIPTION("/f defaultrole - set your Faction's default role."), + COMMAND_SETDEFAULTROLE_NOTTHATROLE("&c&l[!]&7 You cannot set the default to admin."), + COMMAND_SETDEFAULTROLE_SUCCESS("Set default role of your faction to %1$s"), + COMMAND_SETDEFAULTROLE_INVALIDROLE("Couldn't find matching role for %1$s"), + + COMMAND_SETFWARP_NOTCLAIMED("&c&l[!]&7 You can &conly&7 set warps in your faction territory."), + COMMAND_SETFWARP_LIMIT("&c&l[!]&7 Your Faction already has the &cmax amount&7 of warps set &c(%1$d)."), + COMMAND_SETFWARP_SET("&c&l[!]&7 Set warp &c%1$s&7 and password &c'%2$s' &7to your location."), + COMMAND_SETFWARP_TOSET("to set warp"), + COMMAND_SETFWARP_FORSET("for setting warp"), + COMMAND_SETFWARP_DESCRIPTION("Set a faction warp"), + + COMMAND_SETHOME_DISABLED("&c&l[!]&7 &cSorry&7, Faction homes are disabled on this server."), + COMMAND_SETHOME_NOTCLAIMED("&c&l[!]&c Sorry&7, your faction home can only be set inside your &cown &7claimed territory."), + COMMAND_SETHOME_TOSET("to set the faction home"), + COMMAND_SETHOME_FORSET("for setting the faction home"), + COMMAND_SETHOME_SET("&c&l[!]&c %1$s&7 set the home for your faction. You can now use:"), + COMMAND_SETHOME_SETOTHER("&c&l[!]&7 You have set the home for the &c%1$s&7 faction."), + COMMAND_SETHOME_DESCRIPTION("Set the faction home"), + COMMAND_STRIKE_FACTION("View Factions Strikes"), + + COMMAND_SETMAXVAULTS_DESCRIPTION("Set max vaults for a Faction."), + COMMAND_SETMAXVAULTS_SUCCESS("&aSet max vaults for &e%s &ato &b%d"), + COMMAND_ONCOOOLDOWN("&c&l[!] &7You cannot use this command for another &b%1$s &7seconds."), + + COMMAND_SETSTRIKES_FAILURE("&c&l[!]&7 &c{faction} does not exist."), + COMMAND_SETSTRIKES_BROADCAST("&c&l[!]&7 &c{faction} has received a strike for {reason}"), + COMMAND_SETSTRIKES_SUCCESS("&c&l[!]&7 &c{faction}'s&7 new strikes are &c{strikes}"), + COMMAND_SETSTRIKES_DESCRIPTION("Set a faction's strikes"), + COMMAND_STRIKEREMOVE_DESCRIPTION("Remove a faction's strikes"), + COMMAND_STRIKE_MESSAGE("&c&l[!] &7{faction} has {strikes} strikes."), + COMMAND_STRIKE_NOTFOUND("&c&l[!] &7{faction} does not exist."), + COMMAND_STRIKE_NEEDFACTION("&c&l[!] &7&cYou need to join a faction to view your own!"), + + SHOP_NOT_ENOUGH_POINTS("&c&l[!] &7Your faction does not have enough points to purchase this!"), + SHOP_BOUGHT_BROADCAST_FACTION("\n&c&l[!] &e&lFactionShop » &b{player} &7bought &b{item}&7!\n"), + + COMMAND_STRIKEGIVE_DESCRIPTION("Give a faction strikes"), + + COMMAND_VIEWCHEST_DESCRIPTION("view a factions chest/pv"), + + COMMAND_VAULT_DESCRIPTION("Open your placed faction vault!"), + COMMAND_VAULT_INVALID("&c&l[!]&7 Your vault was either&c claimed&7, &cbroken&7, or has&c not been&7 placed yet."), + COMMAND_VAULT_OPENING("&c&l[!]&7 Opening faction vault."), + COMMAND_VAULT_NO_HOPPER("&c&l[!] &7You cannot place a hopper near a vault!"), + + COMMAND_GETVAULT_ALREADYSET("&c&l[!]&7 Vault has already been set!"), + COMMAND_GETVAULT_ALREADYHAVE("&c&l[!]&7 You already have a vault in your inventory!"), + COMMAND_GETVAULT_CHESTNEAR("&c&l[!]&7 &7There is a chest or hopper &cnearby"), + COMMAND_GETVAULT_SUCCESS("&cSucessfully set vault."), + COMMAND_GETVAULT_INVALIDLOCATION("&cVault can only be placed in faction land!"), + COMMAND_GETVAULT_DESCRIPTION("Get the faction vault item!"), + COMMAND_GETVAULT_RECEIVE("&cYou have recieved a faction vault!"), + COMMAND_GETVAULT_NOMONEY("&cYou do not have enough money"), + COMMAND_GETVAULT_MONEYTAKE("&c{amount} has been taken from your account"), + + COMMAND_LOGOUT_KICK_MESSAGE("&2You have safely logged out!"), + COMMAND_LOGOUT_ACTIVE("&c&l[!] &7You are already logging out!"), + COMMAND_LOGOUT_LOGGING("&c&l[!] &7You are logging out. Please wait &b%1$s &7seconds."), + COMMAND_LOGOUT_DESCRIPTION("logout safely from the server"), + COMMAND_LOGOUT_MOVED("&c&l[!] &7Your logout was cancelled because you moved!"), + COMMAND_LOGOUT_DAMAGE_TAKEN("&c&l[!] &7Your logout was cancelled because you were damaged!"), + COMMAND_LOGOUT_TELEPORTED("&c&l[!] &7Your logout was cancelled because you teleported!"), + + COMMAND_NOTIFICATIONS_TOGGLED_ON("&c&l[!] &7You will now see claimed land notifications!"), + COMMAND_NOTIFICATIONS_TOGGLED_OFF("&c&l[!] &7You will no longer see claimed land notifications!"), + COMMAND_NOTIFICATIONS_DESCRIPTION("Toggle notifications for land claiming"), + + COMMAND_SHOW_NOFACTION_SELF("You are not in a faction"), + COMMAND_SHOW_NOFACTION_OTHER("That's not a faction"), + COMMAND_SHOW_TOSHOW("to show faction information"), + COMMAND_SHOW_FORSHOW("for showing faction information"), + COMMAND_SHOW_DESCRIPTION("Description: %1$s"), + COMMAND_SHOW_PEACEFUL("This faction is Peaceful"), + COMMAND_SHOW_PERMANENT("This faction is permanent, remaining even with no members."), + COMMAND_SHOW_JOINING("Joining: %1$s "), + COMMAND_SHOW_INVITATION("invitation is required"), + COMMAND_SHOW_UNINVITED("no invitation is needed"), + COMMAND_SHOW_NOHOME("n/a"), + COMMAND_SHOW_POWER("Land / Power / Maxpower: %1$d/%2$d/%3$d %4$s."), + COMMAND_SHOW_BONUS(" (bonus: "), + COMMAND_SHOW_PENALTY(" (penalty: "), + COMMAND_SHOW_DEPRECIATED("(%1$s depreciated)"), //This is spelled correctly. + COMMAND_SHOW_LANDVALUE("Total land value: %1$s %2$s"), + COMMAND_SHOW_BANKCONTAINS("Bank contains: %1$s"), + COMMAND_SHOW_ALLIES("Allies: "), + COMMAND_SHOW_ENEMIES("Enemies: "), + COMMAND_SHOW_MEMBERSONLINE("Members online: "), + COMMAND_SHOW_MEMBERSOFFLINE("Members offline: "), + COMMAND_SHOW_COMMANDDESCRIPTION("Show faction information"), + COMMAND_SHOW_DEATHS_TIL_RAIDABLE("DTR: %1$d"), + COMMAND_SHOW_EXEMPT("This faction is exempt and cannot be seen."), + COMMAND_SHOW_NEEDFACTION("&cYou need to join a faction to view your own!"), + + COMMAND_SHOWCLAIMS_HEADER("&8&m-------------&8<{faction}'s claims&8>&8&m-------------"), + COMMAND_SHOWCLAIMS_FORMAT("&8[{world}]:"), + COMMAND_SHOWCLAIMS_CHUNKSFORMAT("&8(&c{x}&8,&c{z}&8)"), + COMMAND_SHOWCLAIMS_DESCRIPTION("show your factions claims!"), + + COMMAND_SHOWINVITES_PENDING("Players with pending invites: "), + COMMAND_SHOWINVITES_CLICKTOREVOKE("Click to revoke invite for %1$s"), + COMMAND_SHOWINVITES_DESCRIPTION("Show pending faction invites"), + + COMMAND_ALTS_LIST_FORMAT("%1$s Power: %2$s Last Seen: %3$s"), + COMMAND_ALTS_DEINVITE_DESCRIPTION("Base command for revoking alt invitations"), + + COMMAND_STATUS_FORMAT("%1$s Power: %2$s Last Seen: %3$s"), + COMMAND_STATUS_ONLINE("Online"), + COMMAND_STATUS_AGOSUFFIX(" ago."), + COMMAND_STATUS_DESCRIPTION("Show the status of a player"), + + COMMAND_STEALTH_DESCRIPTION("Enable and Disable Stealth Mode"), + COMMAND_STEALTH_ENABLE("&cStealth &7» &7You will no longer disable nearby players in /f fly."), + COMMAND_STEALTH_DISABLE("&cStealth &8» &7You will now disable other nearby players in /f fly."), + COMMAND_STEALTH_MUSTBEMEMBER("&cStealth &8» &4You must be in a faction to use this command"), + + COMMAND_STUCK_TIMEFORMAT("m 'minutes', s 'seconds.'"), + COMMAND_STUCK_CANCELLED("Teleport cancelled because you were damaged"), + COMMAND_STUCK_OUTSIDE("Teleport cancelled because you left %1$d block radius"), + COMMAND_STUCK_EXISTS("You are already teleporting, you must wait %1$s"), + COMMAND_STUCK_START("Teleport will commence in %s. Don't take or deal damage. "), + COMMAND_STUCK_TELEPORT("Teleported safely to %1$d, %2$d, %3$d."), + COMMAND_STUCK_TOSTUCK("to safely teleport %1$s out"), + COMMAND_STUCK_FORSTUCK("for %1$s initiating a safe teleport out"), + COMMAND_STUCK_DESCRIPTION("Safely teleports you out of enemy faction"), + + COMMAND_SEECHUNK_ENABLED("&cSeechunk enabled!"), + COMMAND_SEECHUNK_DISABLED("&cSeechunk disabled!"), + + + COMMAND_TAG_TAKEN("That tag is already taken"), + COMMAND_TAG_TOCHANGE("to change the faction tag"), + COMMAND_TAG_FORCHANGE("for changing the faction tag"), + COMMAND_TAG_FACTION("%1$s changed your faction tag to %2$s"), + COMMAND_TAG_CHANGED("The faction %1$s changed their name to %2$s."), + COMMAND_TAG_DESCRIPTION("Change the faction tag"), + + COMMAND_TITLE_TOCHANGE("to change a players title"), + COMMAND_TITLE_FORCHANGE("for changing a players title"), + COMMAND_TITLE_CHANGED("%1$s changed a title: %2$s"), + COMMAND_TITLE_DESCRIPTION("Set or remove a players title"), + + COMMAND_TOGGLEALLIANCECHAT_DESCRIPTION("Toggles whether or not you will see alliance chat"), + COMMAND_TOGGLEALLIANCECHAT_IGNORE("Alliance chat is now ignored"), + COMMAND_TOGGLEALLIANCECHAT_UNIGNORE("Alliance chat is no longer ignored"), + + COMMAND_TOGGLESB_DISABLED("You can't toggle scoreboards while they are disabled."), + + + COMMAND_TOP_DESCRIPTION("Sort Factions to see the top of some criteria."), + COMMAND_TOP_TOP("Top Factions by %s. Page %d/%d"), + COMMAND_TOP_LINE("%d. &6%s: &c%s"), // Rank. Faction: Value + COMMAND_TOP_INVALID("Could not sort by %s. Try balance, online, members, power or land."), + + COMMAND_TNT_DISABLED_MSG("&cThis command is disabled!"), + COMMAND_TNT_INVALID_NUM("The amount needs to be a number!"), + COMMAND_TNT_DEPOSIT_SUCCESS("&cSuccessfully deposited tnt."), + COMMAND_TNT_EXCEEDLIMIT("&cThis exceeds the bank limit!"), + COMMAND_TNT_WIDTHDRAW_SUCCESS("&cSuccessfully withdrew tnt."), + COMMAND_TNT_WIDTHDRAW_NOTENOUGH("&cNot enough tnt in bank."), + COMMAND_TNT_DEPOSIT_NOTENOUGH("&cNot enough tnt in tnt inventory."), + COMMAND_TNT_AMOUNT("&cYour faction has {amount} tnt in the tnt bank."), + COMMAND_TNT_POSITIVE("&cPlease use positive numbers!"), + COMMAND_TNT_DESCRIPTION("add/widthraw from faction's tnt bank"), + COMMAND_TNT_WIDTHDRAW_NOTENOUGH_SPACE("&cNot enough space in your inventory."), + COMMAND_TNT_ADD_DESCRIPTION("&b/f tnt add&3 "), + COMMAND_TNT_TAKE_DESCRIPTION("&b/f tnt take&3 "), + + COMMAND_TNTFILL_HEADER("&c&l[!] &7Filling tnt in dispensers..."), + COMMAND_TNTFILL_SUCCESS("&c&l[!] &7Filled &c{amount}&7 Tnt in &c{dispensers} &7dispensers"), + COMMAND_TNTFILL_NOTENOUGH("&c&l[!] &7Not enough tnt in inventory."), + COMMAND_TNTFILL_RADIUSMAX("&c&l[!] &7The max radius is {max}"), + COMMAND_TNTFILL_AMOUNTMAX("&c&l[!] &7The max amount is {max}"), + COMMAND_TNTFILL_MOD("&c&l[!] &7Tnt will be used from the faction bank because you dont have the specified amount in your inventory and you are a {role}"), + COMMAND_TNTFILL_DESCRIPTION("Fill tnt into dispensers around you"), + + COMMAND_UNBAN_DESCRIPTION("Unban someone from your Faction"), + COMMAND_UNBAN_NOTBANNED("&7%s &cisn't banned. Not doing anything."), + COMMAND_UNBAN_UNBANNED("&e%1$s &cunbanned &7%2$s"), + COMMAND_UNBAN_TARGET("&aYou were unbanned from &r%s"), + + COMMAND_UNCLAIM_SAFEZONE_SUCCESS("Safe zone was unclaimed."), + COMMAND_UNCLAIM_SAFEZONE_NOPERM("This is a safe zone. You lack permissions to unclaim."), + COMMAND_UNCLAIM_WARZONE_SUCCESS("War zone was unclaimed."), + COMMAND_UNCLAIM_WARZONE_NOPERM("This is a war zone. You lack permissions to unclaim."), + COMMAND_UNCLAIM_UNCLAIMED("%1$s unclaimed some of your land."), + COMMAND_UNCLAIM_UNCLAIMS("You unclaimed this land."), + COMMAND_UNCLAIM_LOG("%1$s unclaimed land at (%2$s) from the faction: %3$s"), + COMMAND_UNCLAIM_WRONGFACTION("You don't own this land."), + COMMAND_UNCLAIM_TOUNCLAIM("to unclaim this land"), + COMMAND_UNCLAIM_FORUNCLAIM("for unclaiming this land"), + COMMAND_UNCLAIM_FACTIONUNCLAIMED("%1$s unclaimed some land."), + COMMAND_UNCLAIM_DESCRIPTION("Unclaim the land where you are standing"), + + COMMAND_UNCLAIMALL_TOUNCLAIM("to unclaim all faction land"), + COMMAND_UNCLAIMALL_FORUNCLAIM("for unclaiming all faction land"), + COMMAND_UNCLAIMALL_UNCLAIMED("%1$s unclaimed ALL of your faction's land."), + COMMAND_UNCLAIMALL_LOG("%1$s unclaimed everything for the faction: %2$s"), + COMMAND_UNCLAIMALL_DESCRIPTION("Unclaim all of your factions land"), + COMMAND_UNCLAIM_CLICKTOUNCLAIM("Click to unclaim &2(%1$d, %2$d)"), + + COMMAND_VERSION_NAME("&c&l[!]&7 &c&k||| &r&4SaberFactions&7 &c&k|||&r &c» &7By Driftay"), + COMMAND_VERSION_VERSION("&7Version &c» &7%1$s"), + COMMAND_VERSION_DESCRIPTION("Show plugin and translation version information"), + + COMMAND_WARUNCLAIMALL_DESCRIPTION("Unclaim all warzone land"), + COMMAND_WARUNCLAIMALL_SUCCESS("You unclaimed ALL war zone land."), + COMMAND_WARUNCLAIMALL_LOG("%1$s unclaimed all war zones."), + + COMMAND_RULES_DISABLED_MSG("&cThis command is disabled!"), + COMMAND_RULES_DESCRIPTION("set/remove/add rules!"), + COMMAND_RULES_ADD_INVALIDARGS("Please include a rule!"), + COMMAND_RULES_SET_INVALIDARGS("Please include a line number & rule!"), + COMMAND_RULES_REMOVE_INVALIDARGS("Please include a line number!"), + COMMAND_RULES_ADD_SUCCESS("&cRule added successfully!"), + COMMAND_RULES_REMOVE_SUCCESS("&cRule removed successfully!"), + COMMAND_RULES_SET_SUCCESS("&cRule set successfully!"), + COMMAND_RULES_CLEAR_SUCCESS("&cRule cleared successfully!"), + + // F Global \\ + COMMAND_F_GLOBAL_TOGGLE("&c&l[!] &7You have &b%1$s &7Global Chat"), + COMMAND_F_GLOBAL_DESCRIPTION("Toggle global chat and only allow factions based chats"), + + /** + * Leaving - This is accessed through a command, and so it MAY need a COMMAND_* slug :s + */ + LEAVE_PASSADMIN("You must give the admin role to someone else first."), + LEAVE_NEGATIVEPOWER("You cannot leave until your power is positive."), + LEAVE_TOLEAVE("to leave your faction."), + LEAVE_FORLEAVE("for leaving your faction."), + LEAVE_LEFT("%s left faction %s."), + LEAVE_DISBANDED("%s was disbanded."), + LEAVE_DISBANDEDLOG("The faction %s (%s) was disbanded due to the last player (%s) leaving."), + LEAVE_DESCRIPTION("\\n &a&l» &7Leave your faction"), + + /** + * Claiming - Same as above basically. No COMMAND_* because it's not in a command class, but... + */ + CLAIM_PROTECTED("This land is protected"), + CLAIM_DISABLED("Sorry, this world has land claiming disabled."), + CLAIM_CANTCLAIM("You can't claim land for %s."), + CLAIM_ALREADYOWN("%s already own this land."), + CLAIM_MUSTBE("You must be %s to claim land."), + CLAIM_MEMBERS("Factions must have at least %s members to claim land."), + CLAIM_SAFEZONE("You can not claim a Safe Zone."), + CLAIM_WARZONE("You can not claim a War Zone."), + CLAIM_POWER("You can't claim more land!You need more power!"), + CLAIM_LIMIT("Limit reached. You can't claim more land!"), + CLAIM_ALLY("You can't claim the land of your allies."), + CLAIM_CONTIGIOUS("You can only claim additional land which is connected to your first claim or controlled by another faction!"), + CLAIM_FACTIONCONTIGUOUS("You can only claim additional land which is connected to your first claim!"), + CLAIM_PEACEFUL("%s owns this land. Your faction is peaceful, so you cannot claim land from other factions."), + CLAIM_PEACEFULTARGET("%s owns this land, and is a peaceful faction. You cannot claim land from them."), + CLAIM_THISISSPARTA("%s owns this land and is strong enough to keep it."), + CLAIM_BORDER("You must start claiming land at the border of the territory."), + CLAIM_TOCLAIM("to claim this land"), + CLAIM_FORCLAIM("for claiming this land"), + CLAIM_TOOVERCLAIM("to overclaim this land"), + CLAIM_FOROVERCLAIM("for over claiming this land"), + CLAIM_CLAIMED("%s claimed land for %s from %s."), + CLAIM_CLAIMEDLOG("%s claimed land at (%s) for the faction: %s"), + CLAIM_OVERCLAIM_DISABLED("Over claiming is disabled on this server."), + CLAIM_TOOCLOSETOOTHERFACTION("Your claim is too close to another Faction. Buffer required is %d"), + CLAIM_OUTSIDEWORLDBORDER("Your claim is outside the border."), + CLAIM_OUTSIDEBORDERBUFFER("Your claim is outside the border. %d chunks away world edge required."), + CLAIM_CLICK_TO_CLAIM("Click to try to claim &2(%1$d, %2$d)"), + CLAIM_MAP_OUTSIDEBORDER("&cThis claim is outside the worldborder!"), + CLAIM_YOUAREHERE("You are here"), + CLAIM_NO_TERRITORY_PERM("You do not have permission from your faction leader to do this!"), + + /** + * More generic, or less easily categorisable translations, which may apply to more than one class + */ + GENERIC_YOU("you"), + GENERIC_YOURFACTION("your faction"), + GENERIC_NOPERMISSION("You don't have permission to %1$s."), + GENERIC_FPERM_NOPERMISSION("&7The faction leader does not allow you to &c%1$s."), + GENERIC_DOTHAT("do that"), //Ugh nuke this from high orbit + GENERIC_NOPLAYERMATCH("No player match found for \"%1$s\"."), + GENERIC_NOPLAYERFOUND("No player \"%1$s\" could not be found."), + GENERIC_ARGS_TOOFEW("Too few arguments. Use like this:"), + GENERIC_ARGS_TOOMANY("Strange argument \"%1$s\". Use the command like this:"), + GENERIC_DEFAULTDESCRIPTION("Default faction description :("), + GENERIC_OWNERS("Owner(s): %1$s"), + GENERIC_PUBLICLAND("Public faction land."), + GENERIC_FACTIONLESS("factionless"), + GENERIC_SERVERADMIN("A server admin"), + GENERIC_DISABLED("disabled"), + GENERIC_ENABLED("enabled"), + GENERIC_INFINITY("∞"), + GENERIC_CONSOLEONLY("This command cannot be run as a player."), + GENERIC_PLAYERONLY("This command can only be used by ingame players."), + GENERIC_ASKYOURLEADER(" Ask your leader to:"), + GENERIC_YOUSHOULD("You should:"), + GENERIC_YOUMAYWANT("You may want to: "), + GENERIC_TRANSLATION_VERSION("Translation: %1$s(%2$s,%3$s) State: %4$s"), + GENERIC_TRANSLATION_CONTRIBUTORS("Translation contributors: %1$s"), + GENERIC_TRANSLATION_RESPONSIBLE("Responsible for translation: %1$s"), + GENERIC_FACTIONTAG_TOOSHORT("The faction tag can't be shorter than %1$s chars."), + GENERIC_FACTIONTAG_TOOLONG("The faction tag can't be longer than %s chars."), + GENERIC_FACTIONTAG_ALPHANUMERIC("Faction tag must be alphanumeric. \"%s\" is not allowed."), + GENERIC_PLACEHOLDER(""), + GENERIC_NOTENOUGHMONEY("&cYou dont have enough money!"), + GENERIC_MONEYTAKE("&c{amount} has been taken from your account."), + + + MISSION_MISSION_STARTED("&f%1$s &dstarted the %2$s &fmission"), + MISSION_MISSION_ACTIVE("&c&l[!] &7This mission is currently active!"), + MISSION_MISSION_MAX_ALLOWED("&c&l[!] &7You may not have more then &b%1$s &7missions active at once."), + MISSION_MISSION_FINISHED("&c&l[!] &7Your faction has successfully completed %1$s mission!"), + COMMAND_MISSION_DESCRIPTION("Opens missions gui"), + // F Global \\ + + + PLAYER_NOT_FOUND("&c&l[!] &b%1$s &7is either not online or not in your faction!"), + PLACEHOLDER_ROLE_NAME("None"), + + + 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) + */ + COMPASS_SHORT_NORTH("N"), + COMPASS_SHORT_EAST("E"), + COMPASS_SHORT_SOUTH("S"), + COMPASS_SHORT_WEST("W"), + + /** + * Chat modes + */ + CHAT_MOD("mod chat"), + CHAT_FACTION("faction chat"), + CHAT_ALLIANCE("alliance chat"), + CHAT_TRUCE("truce chat"), + CHAT_PUBLIC("public chat"), + + /** + * Economy stuff + */ + + ECON_OFF("no %s"), // no balance, no value, no refund, etc + ECON_FORMAT("###,###.###"), + ECON_DISABLED("Factions econ is disabled."), + ECON_OVER_BAL_CAP("&4The amount &e%s &4is over Essentials' balance cap."), + + /** + * Relations + */ + RELATION_MEMBER_SINGULAR("member"), + RELATION_MEMBER_PLURAL("members"), + RELATION_ALLY_SINGULAR("ally"), + RELATION_ALLY_PLURAL("allies"), + RELATION_TRUCE_SINGULAR("truce"), + RELATION_TRUCE_PLURAL("truces"), + RELATION_NEUTRAL_SINGULAR("neutral"), + RELATION_NEUTRAL_PLURAL("neutrals"), + RELATION_ENEMY_SINGULAR("enemy"), + RELATION_ENEMY_PLURAL("enemies"), + + /** + * Roles + */ + ROLE_LEADER("leader"), + ROLE_COLEADER("coleader"), + ROLE_MODERATOR("moderator"), + ROLE_NORMAL("normal member"), + ROLE_RECRUIT("recruit"), + + /** + * Region types. + */ + REGION_SAFEZONE("safezone"), + REGION_WARZONE("warzone"), + REGION_WILDERNESS("wilderness"), + + REGION_PEACEFUL("peaceful territory"), + /** + * In the player and entity listeners + */ + PLAYER_CANTHURT("You may not harm other players in %s"), + PLAYER_SAFEAUTO("This land is now a safe zone."), + PLAYER_WARAUTO("This land is now a war zone."), + PLAYER_OUCH("Ouch, that is starting to hurt. You should give it a rest."), + PLAYER_USE_WILDERNESS("You can't use %s in the wilderness."), + PLAYER_USE_SAFEZONE("You can't use %s in a safe zone."), + PLAYER_USE_WARZONE("You can't use %s in a war zone."), + PLAYER_USE_TERRITORY("You can't %s in the territory of %s."), + PLAYER_USE_OWNED("You can't use %s in this territory, it is owned by: %s."), + PLAYER_COMMAND_WARZONE("You can't use the command '%s' in warzone."), + PLAYER_COMMAND_NEUTRAL("You can't use the command '%s' in neutral territory."), + PLAYER_COMMAND_ENEMY("You can't use the command '%s' in enemy territory."), + PLAYER_COMMAND_PERMANENT("You can't use the command '%s' because you are in a permanent faction."), + PLAYER_COMMAND_ALLY("You can't use the command '%s' in ally territory."), + PLAYER_COMMAND_WILDERNESS("You can't use the command '%s' in the wilderness."), + + PLAYER_POWER_NOLOSS_PEACEFUL("You didn't lose any power since you are in a peaceful faction."), + PLAYER_POWER_NOLOSS_WORLD("You didn't lose any power due to the world you died in."), + PLAYER_POWER_NOLOSS_WILDERNESS("You didn't lose any power since you were in the wilderness."), + PLAYER_POWER_NOLOSS_WARZONE("You didn't lose any power since you were in a war zone."), + PLAYER_POWER_LOSS_WARZONE("The world you are in has power loss normally disabled, but you still lost power since you were in a war zone.\nYour power is now %d / %d"), + PLAYER_POWER_NOW("Your power is now %d / %d"), + + PLAYER_PVP_LOGIN("You can't hurt other players for %d seconds after logging in."), + PLAYER_PVP_REQUIREFACTION("You can't hurt other players until you join a faction."), + PLAYER_PVP_FACTIONLESS("You can't hurt players who are not currently in a faction."), + PLAYER_PVP_PEACEFUL("Peaceful players cannot participate in combat."), + PLAYER_PVP_NEUTRAL("You can't hurt neutral factions. Declare them as an enemy."), + PLAYER_PVP_CANTHURT("You can't hurt %s."), + + PLAYER_PVP_NEUTRALFAIL("You can't hurt %s in their own territory unless you declare them as an enemy."), + PLAYER_PVP_TRIED("%s tried to hurt you."), + + /** + * Strings lying around in other bits of the plugins + */ + NOPAGES("Sorry. No Pages available."), + INVALIDPAGE("Invalid page. Must be between 1 and %1$d"), + + /** + * The ones here before I started messing around with this + */ + TITLE("title", "&bFactions &0|&r"), + WILDERNESS("wilderness", "&2Wilderness"), + WILDERNESS_DESCRIPTION("wilderness-description", ""), + WARZONE("warzone", "&4Warzone"), + WARZONE_DESCRIPTION("warzone-description", "Not the safest place to be."), + SAFEZONE("safezone", "&6Safezone"), + SAFEZONE_DESCRIPTION("safezone-description", "Free from pvp and monsters."), + TOGGLE_SB("toggle-sb", "You now have scoreboards set to {value}"), + FACTION_LEAVE("faction-leave", "Leaving %1$s, Entering %2$s"), + FACTIONS_ANNOUNCEMENT_TOP("faction-announcement-top", "&d--Unread Faction Announcements--"), + FACTIONS_ANNOUNCEMENT_BOTTOM("faction-announcement-bottom", "&d--Unread Faction Announcements--"), + DEFAULT_PREFIX("default-prefix", "{relationcolor}[{faction}]"), + FACTION_LOGIN("faction-login", "&e%1$s &9logged in."), + FACTION_LOGOUT("faction-logout", "&e%1$s &9logged out.."), + NOFACTION_PREFIX("nofactions-prefix", "&6[&ano-faction&6]&r"), + DATE_FORMAT("date-format", "MM/d/yy h:ma"), // 3/31/15 07:49AM + + /** + * Raidable is used in multiple places. Allow more than just true/false. + */ + RAIDABLE_TRUE("raidable-true", "true"), + RAIDABLE_FALSE("raidable-false", "false"), + /** + * Warmups + */ + WARMUPS_NOTIFY_FLIGHT("&eFlight will enable in &d%2$d &eseconds."), + WARMUPS_NOTIFY_TELEPORT("&eYou will teleport to &d%1$s &ein &d%2$d &eseconds."), + WARMUPS_ALREADY("&cYou are already warming up."), + WARMUPS_CANCELLED("&cYou have cancelled your warmup."); + + public static SimpleDateFormat sdf; + private static YamlConfiguration LANG; + private String path; + private String def; + + /** + * Lang enum constructor. + * + * @param path The string path. + * @param start The default string. + */ + TL(String path, String start) { + this.path = path; + this.def = start; + } + + /** + * Lang enum constructor. Use this when your desired path simply exchanges '_' for '.' + * + * @param start The default string. + */ + TL(String start) { + this.path = this.name().replace('_', '.'); + if (this.path.startsWith(".")) { + path = "root" + path; + } + this.def = start; + } + + /** + * Set the {@code YamlConfiguration} to use. + * + * @param config The config to set. + */ + public static void setFile(YamlConfiguration config) { + LANG = config; + sdf = new SimpleDateFormat(DATE_FORMAT.toString()); + } + + @Override + public String toString() { + return ChatColor.translateAlternateColorCodes('&', LANG.getString(this.path, def)) + (this == TITLE ? " " : ""); + } + + public String format(Object... args) { + return String.format(toString(), args); + } + + /** + * Get the default value of the path. + * + * @return The default value of the path. + */ + public String getDefault() { + return this.def; + } + + /** + * Get the path to the string. + * + * @return The path to the string. + */ + public String getPath() { + return this.path; + } } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 9ecedb0b..890d0dbb 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -472,6 +472,7 @@ fperm-gui: tntbank: BEACON tntfill: TNT chest: ENDER_CHEST + check: WATCH spawner: MOB_SPAWNER home: ENDER_EYE slots: @@ -505,8 +506,9 @@ fperm-gui: tntbank: 39 tntfill: 41 chest: 42 + check: 50 spawner: 38 - home: 49 + home: 48 # {action} Action name eg: Setwarp, Kick # {action-access} Access name eg: Allow, Deny # {action-access-color} Access color eg: Allow;GREEN diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 0a3ae6f8..1062f419 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -114,6 +114,8 @@ permissions: factions.banner: true factions.vault: true factions.getvault: true + factions.check: + description: give players access to use check commands factions.admin: description: hand over your admin rights factions.admin.any: