Showing Dropping Anvil Something (Ignore)

This commit is contained in:
Driftay 2019-09-15 05:14:14 -04:00
parent 2a1a8db554
commit e7db7170d1
285 changed files with 28757 additions and 28757 deletions

View File

@ -9,82 +9,82 @@ import java.util.Set;
public abstract class Board { public abstract class Board {
protected static Board instance = getBoardImpl(); protected static Board instance = getBoardImpl();
private static Board getBoardImpl() { private static Board getBoardImpl() {
switch (Conf.backEnd) { switch (Conf.backEnd) {
case JSON: case JSON:
return new JSONBoard(); return new JSONBoard();
} }
return null; return null;
} }
public static Board getInstance() { public static Board getInstance() {
return instance; return instance;
} }
//----------------------------------------------// //----------------------------------------------//
// Get and Set // Get and Set
//----------------------------------------------// //----------------------------------------------//
public abstract String getIdAt(FLocation flocation); 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<FLocation> getAllClaims(String factionId); public abstract Set<FLocation> getAllClaims(String factionId);
public abstract Set<FLocation> getAllClaims(Faction faction); public abstract Set<FLocation> getAllClaims(Faction faction);
// not to be confused with claims, ownership referring to further member-specific ownership of a claim // 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 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? // 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? // Simpler: Is there any nearby coord with a faction other than the faction here?
public abstract boolean isBorderLocation(FLocation flocation); public abstract boolean isBorderLocation(FLocation flocation);
// Is this coord connected to any coord claimed by the specified faction? // Is this coord connected to any coord claimed by the specified faction?
public abstract boolean isConnectedLocation(FLocation flocation, Faction 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 * 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 * of decreasing z
*/ */
public abstract List<FancyMessage> getMap(FPlayer fPlayer, FLocation flocation, double inDegrees); public abstract List<FancyMessage> 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();
} }

View File

@ -13,430 +13,430 @@ import java.util.*;
public class Conf { public class Conf {
// Region Style // Region Style
public static final transient String DYNMAP_STYLE_LINE_COLOR = "#00FF00"; 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 double DYNMAP_STYLE_LINE_OPACITY = 0.8D;
public static final transient int DYNMAP_STYLE_LINE_WEIGHT = 3; public static final transient int DYNMAP_STYLE_LINE_WEIGHT = 3;
public static final transient String DYNMAP_STYLE_FILL_COLOR = "#00FF00"; 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 double DYNMAP_STYLE_FILL_OPACITY = 0.35D;
public static final transient String DYNMAP_STYLE_HOME_MARKER = "greenflag"; public static final transient String DYNMAP_STYLE_HOME_MARKER = "greenflag";
public static final transient boolean DYNMAP_STYLE_BOOST = false; public static final transient boolean DYNMAP_STYLE_BOOST = false;
public static List<String> baseCommandAliases = new ArrayList<>(); public static List<String> baseCommandAliases = new ArrayList<>();
public static boolean allowNoSlashCommand = true; public static boolean allowNoSlashCommand = true;
// Colors // Colors
public static ChatColor colorMember = ChatColor.GREEN; public static ChatColor colorMember = ChatColor.GREEN;
public static ChatColor colorAlly = ChatColor.LIGHT_PURPLE; public static ChatColor colorAlly = ChatColor.LIGHT_PURPLE;
public static ChatColor colorTruce = ChatColor.DARK_PURPLE; public static ChatColor colorTruce = ChatColor.DARK_PURPLE;
public static ChatColor colorNeutral = ChatColor.WHITE; public static ChatColor colorNeutral = ChatColor.WHITE;
public static ChatColor colorEnemy = ChatColor.RED; public static ChatColor colorEnemy = ChatColor.RED;
public static ChatColor colorPeaceful = ChatColor.GOLD; public static ChatColor colorPeaceful = ChatColor.GOLD;
public static ChatColor colorWilderness = ChatColor.GRAY; public static ChatColor colorWilderness = ChatColor.GRAY;
public static ChatColor colorSafezone = ChatColor.GOLD; public static ChatColor colorSafezone = ChatColor.GOLD;
public static ChatColor colorWar = ChatColor.DARK_RED; public static ChatColor colorWar = ChatColor.DARK_RED;
// Power // Power
public static double powerPlayerMax = 10.0; public static double powerPlayerMax = 10.0;
public static double powerPlayerMin = -10.0; public static double powerPlayerMin = -10.0;
public static double powerPlayerStarting = 0.0; public static double powerPlayerStarting = 0.0;
public static double powerPerMinute = 0.2; // Default health rate... it takes 5 min to heal one power 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 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 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 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 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 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 prefixLeader = "***";
public static String prefixCoLeader = "**"; public static String prefixCoLeader = "**";
public static String prefixMod = "*"; public static String prefixMod = "*";
public static String prefixRecruit = "-"; public static String prefixRecruit = "-";
public static String prefixNormal = "+"; public static String prefixNormal = "+";
public static int factionTagLengthMin = 3; public static int factionTagLengthMin = 3;
public static int factionTagLengthMax = 10; public static int factionTagLengthMax = 10;
public static boolean factionTagForceUpperCase = false; public static boolean factionTagForceUpperCase = false;
public static boolean newFactionsDefaultOpen = 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 // 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 factionMemberLimit = 0;
public static int factionAltMemberLimit = 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" // 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 String newPlayerStartingFactionID = "0";
public static boolean showMapFactionKey = true; public static boolean showMapFactionKey = true;
public static boolean showNeutralFactionsOnMap = true; public static boolean showNeutralFactionsOnMap = true;
public static boolean showEnemyFactionsOnMap = true; public static boolean showEnemyFactionsOnMap = true;
public static boolean showTrucesFactionsOnMap = true; public static boolean showTrucesFactionsOnMap = true;
// Disallow joining/leaving/kicking while power is negative // Disallow joining/leaving/kicking while power is negative
public static boolean canLeaveWithNegativePower = true; public static boolean canLeaveWithNegativePower = true;
// Configuration for faction-only chat // Configuration for faction-only chat
public static boolean factionOnlyChat = true; public static boolean factionOnlyChat = true;
// Configuration on the Faction tag in chat messages. // Configuration on the Faction tag in chat messages.
public static boolean chatTagEnabled = true; public static boolean chatTagEnabled = true;
public static transient boolean chatTagHandledByAnotherPlugin = false; public static transient boolean chatTagHandledByAnotherPlugin = false;
public static boolean chatTagRelationColored = true; public static boolean chatTagRelationColored = true;
public static String chatTagReplaceString = "[FACTION]"; public static String chatTagReplaceString = "[FACTION]";
public static String chatTagInsertAfterString = ""; public static String chatTagInsertAfterString = "";
public static String chatTagInsertBeforeString = ""; public static String chatTagInsertBeforeString = "";
public static int chatTagInsertIndex = 0; public static int chatTagInsertIndex = 0;
public static boolean chatTagPadBefore = false; public static boolean chatTagPadBefore = false;
public static boolean chatTagPadAfter = true; public static boolean chatTagPadAfter = true;
public static String chatTagFormat = "%s" + ChatColor.WHITE; public static String chatTagFormat = "%s" + ChatColor.WHITE;
public static String factionChatFormat = "%s:" + ChatColor.WHITE + " %s"; public static String factionChatFormat = "%s:" + ChatColor.WHITE + " %s";
public static String allianceChatFormat = ChatColor.LIGHT_PURPLE + "%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 truceChatFormat = ChatColor.DARK_PURPLE + "%s:" + ChatColor.WHITE + " %s";
public static String modChatFormat = ChatColor.RED + "%s:" + ChatColor.WHITE + " %s"; public static String modChatFormat = ChatColor.RED + "%s:" + ChatColor.WHITE + " %s";
public static int stealthFlyCheckRadius = 32; public static int stealthFlyCheckRadius = 32;
public static int factionBufferSize = 20; public static int factionBufferSize = 20;
public static boolean useCheckSystem = true; public static boolean useCheckSystem = true;
public static boolean gracePeriod = false; public static boolean gracePeriod = false;
public static boolean noEnderpearlsInFly = false; public static boolean noEnderpearlsInFly = false;
public static boolean broadcastDescriptionChanges = false; public static boolean broadcastDescriptionChanges = false;
public static boolean broadcastTagChanges = false; public static boolean broadcastTagChanges = false;
public static double saveToFileEveryXMinutes = 30.0; public static double saveToFileEveryXMinutes = 30.0;
public static double autoLeaveAfterDaysOfInactivity = 10.0; public static double autoLeaveAfterDaysOfInactivity = 10.0;
public static double autoLeaveRoutineRunsEveryXMinutes = 5.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 int autoLeaveRoutineMaxMillisecondsPerTick = 5; // 1 server tick is roughly 50ms, so default max 10% of a tick
public static boolean removePlayerDataWhenBanned = true; public static boolean removePlayerDataWhenBanned = true;
public static boolean autoLeaveDeleteFPlayerData = true; // Let them just remove player from Faction. public static boolean autoLeaveDeleteFPlayerData = true; // Let them just remove player from Faction.
public static boolean worldGuardChecking = false; public static boolean worldGuardChecking = false;
public static boolean worldGuardBuildPriority = false; public static boolean worldGuardBuildPriority = false;
// server logging options // server logging options
public static boolean logFactionCreate = true; public static boolean logFactionCreate = true;
public static boolean logFactionDisband = true; public static boolean logFactionDisband = true;
public static boolean logFactionJoin = true; public static boolean logFactionJoin = true;
public static boolean logFactionKick = true; public static boolean logFactionKick = true;
public static boolean logFactionLeave = true; public static boolean logFactionLeave = true;
public static boolean logLandClaims = true; public static boolean logLandClaims = true;
public static boolean logLandUnclaims = true; public static boolean logLandUnclaims = true;
public static boolean logMoneyTransactions = true; public static boolean logMoneyTransactions = true;
public static boolean logPlayerCommands = true; public static boolean logPlayerCommands = true;
// prevent some potential exploits // prevent some potential exploits
public static boolean handleExploitObsidianGenerators = true; public static boolean handleExploitObsidianGenerators = true;
public static boolean handleExploitEnderPearlClipping = true; public static boolean handleExploitEnderPearlClipping = true;
public static boolean handleExploitInteractionSpam = true; public static boolean handleExploitInteractionSpam = true;
public static boolean handleExploitTNTWaterlog = false; public static boolean handleExploitTNTWaterlog = false;
public static boolean handleExploitLiquidFlow = false; public static boolean handleExploitLiquidFlow = false;
public static boolean homesEnabled = true; public static boolean homesEnabled = true;
public static boolean homesMustBeInClaimedTerritory = true; public static boolean homesMustBeInClaimedTerritory = true;
public static boolean homesTeleportToOnDeath = true; public static boolean homesTeleportToOnDeath = true;
public static boolean homesRespawnFromNoPowerLossWorlds = true; public static boolean homesRespawnFromNoPowerLossWorlds = true;
public static boolean homesTeleportCommandEnabled = true; public static boolean homesTeleportCommandEnabled = true;
public static boolean homesTeleportCommandEssentialsIntegration = true; public static boolean homesTeleportCommandEssentialsIntegration = true;
public static boolean homesTeleportCommandSmokeEffectEnabled = true; public static boolean homesTeleportCommandSmokeEffectEnabled = true;
public static float homesTeleportCommandSmokeEffectThickness = 3f; public static float homesTeleportCommandSmokeEffectThickness = 3f;
public static boolean homesTeleportAllowedFromEnemyTerritory = true; public static boolean homesTeleportAllowedFromEnemyTerritory = true;
public static boolean homesTeleportAllowedFromDifferentWorld = true; public static boolean homesTeleportAllowedFromDifferentWorld = true;
public static double homesTeleportAllowedEnemyDistance = 32.0; public static double homesTeleportAllowedEnemyDistance = 32.0;
public static boolean homesTeleportIgnoreEnemiesIfInOwnTerritory = true; public static boolean homesTeleportIgnoreEnemiesIfInOwnTerritory = true;
public static boolean disablePVPBetweenNeutralFactions = false; public static boolean disablePVPBetweenNeutralFactions = false;
public static boolean disablePVPForFactionlessPlayers = false; public static boolean disablePVPForFactionlessPlayers = false;
public static boolean enablePVPAgainstFactionlessInAttackersLand = false; public static boolean enablePVPAgainstFactionlessInAttackersLand = false;
public static int noPVPDamageToOthersForXSecondsAfterLogin = 3; public static int noPVPDamageToOthersForXSecondsAfterLogin = 3;
public static boolean peacefulTerritoryDisablePVP = true; public static boolean peacefulTerritoryDisablePVP = true;
public static boolean peacefulTerritoryDisableMonsters = false; public static boolean peacefulTerritoryDisableMonsters = false;
public static boolean peacefulTerritoryDisableBoom = false; public static boolean peacefulTerritoryDisableBoom = false;
public static boolean peacefulMembersDisablePowerLoss = true; public static boolean peacefulMembersDisablePowerLoss = true;
public static boolean permanentFactionsDisableLeaderPromotion = false; public static boolean permanentFactionsDisableLeaderPromotion = false;
public static boolean claimsMustBeConnected = false; public static boolean claimsMustBeConnected = false;
public static boolean claimsCanBeUnconnectedIfOwnedByOtherFaction = true; public static boolean claimsCanBeUnconnectedIfOwnedByOtherFaction = true;
public static int claimsRequireMinFactionMembers = 1; public static int claimsRequireMinFactionMembers = 1;
public static int claimedLandsMax = 0; public static int claimedLandsMax = 0;
public static int lineClaimLimit = 5; 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 // 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 int radiusClaimFailureLimit = 9;
public static double considerFactionsReallyOfflineAfterXMinutes = 0.0; public static double considerFactionsReallyOfflineAfterXMinutes = 0.0;
public static int actionDeniedPainAmount = 1; public static int actionDeniedPainAmount = 1;
// commands which will be prevented if the player is a member of a permanent faction // commands which will be prevented if the player is a member of a permanent faction
public static Set<String> permanentFactionMemberDenyCommands = new LinkedHashSet<>(); public static Set<String> permanentFactionMemberDenyCommands = new LinkedHashSet<>();
// commands which will be prevented when in claimed territory of another faction // commands which will be prevented when in claimed territory of another faction
public static Set<String> territoryNeutralDenyCommands = new LinkedHashSet<>(); public static Set<String> territoryNeutralDenyCommands = new LinkedHashSet<>();
public static Set<String> territoryEnemyDenyCommands = new LinkedHashSet<>(); public static Set<String> territoryEnemyDenyCommands = new LinkedHashSet<>();
public static Set<String> territoryAllyDenyCommands = new LinkedHashSet<>(); public static Set<String> territoryAllyDenyCommands = new LinkedHashSet<>();
public static Set<String> warzoneDenyCommands = new LinkedHashSet<>(); public static Set<String> warzoneDenyCommands = new LinkedHashSet<>();
public static Set<String> wildernessDenyCommands = new LinkedHashSet<>(); public static Set<String> wildernessDenyCommands = new LinkedHashSet<>();
public static boolean territoryDenyBuild = true; public static boolean territoryDenyBuild = true;
public static boolean territoryDenyBuildWhenOffline = true; public static boolean territoryDenyBuildWhenOffline = true;
public static boolean territoryPainBuild = false; public static boolean territoryPainBuild = false;
public static boolean territoryPainBuildWhenOffline = false; public static boolean territoryPainBuildWhenOffline = false;
public static boolean territoryDenyUseage = true; public static boolean territoryDenyUseage = true;
public static boolean territoryEnemyDenyBuild = true; public static boolean territoryEnemyDenyBuild = true;
public static boolean territoryEnemyDenyBuildWhenOffline = true; public static boolean territoryEnemyDenyBuildWhenOffline = true;
public static boolean territoryEnemyPainBuild = false; public static boolean territoryEnemyPainBuild = false;
public static boolean territoryEnemyPainBuildWhenOffline = false; public static boolean territoryEnemyPainBuildWhenOffline = false;
public static boolean territoryEnemyDenyUseage = true; public static boolean territoryEnemyDenyUseage = true;
public static boolean territoryAllyDenyBuild = true; public static boolean territoryAllyDenyBuild = true;
public static boolean territoryAllyDenyBuildWhenOffline = true; public static boolean territoryAllyDenyBuildWhenOffline = true;
public static boolean territoryAllyPainBuild = false; public static boolean territoryAllyPainBuild = false;
public static boolean territoryAllyPainBuildWhenOffline = false; public static boolean territoryAllyPainBuildWhenOffline = false;
public static boolean territoryAllyDenyUseage = true; public static boolean territoryAllyDenyUseage = true;
public static boolean territoryTruceDenyBuild = true; public static boolean territoryTruceDenyBuild = true;
public static boolean territoryTruceDenyBuildWhenOffline = true; public static boolean territoryTruceDenyBuildWhenOffline = true;
public static boolean territoryTrucePainBuild = false; public static boolean territoryTrucePainBuild = false;
public static boolean territoryTrucePainBuildWhenOffline = false; public static boolean territoryTrucePainBuildWhenOffline = false;
public static boolean territoryTruceDenyUseage = true; public static boolean territoryTruceDenyUseage = true;
public static boolean territoryBlockCreepers = false; public static boolean territoryBlockCreepers = false;
public static boolean territoryBlockCreepersWhenOffline = false; public static boolean territoryBlockCreepersWhenOffline = false;
public static boolean territoryBlockFireballs = false; public static boolean territoryBlockFireballs = false;
public static boolean territoryBlockFireballsWhenOffline = false; public static boolean territoryBlockFireballsWhenOffline = false;
public static boolean territoryBlockTNT = false; public static boolean territoryBlockTNT = false;
public static boolean territoryBlockTNTWhenOffline = false; public static boolean territoryBlockTNTWhenOffline = false;
public static boolean territoryDenyEndermanBlocks = true; public static boolean territoryDenyEndermanBlocks = true;
public static boolean territoryDenyEndermanBlocksWhenOffline = true; public static boolean territoryDenyEndermanBlocksWhenOffline = true;
public static boolean safeZoneDenyBuild = true; public static boolean safeZoneDenyBuild = true;
public static boolean safeZoneDenyUseage = true; public static boolean safeZoneDenyUseage = true;
public static boolean safeZoneBlockTNT = true; public static boolean safeZoneBlockTNT = true;
public static boolean safeZonePreventAllDamageToPlayers = false; public static boolean safeZonePreventAllDamageToPlayers = false;
public static boolean safeZoneDenyEndermanBlocks = true; public static boolean safeZoneDenyEndermanBlocks = true;
public static boolean warZoneDenyBuild = true; public static boolean warZoneDenyBuild = true;
public static boolean warZoneDenyUseage = true; public static boolean warZoneDenyUseage = true;
public static boolean warZoneBlockCreepers = false; public static boolean warZoneBlockCreepers = false;
public static boolean warZoneBlockFireballs = false; public static boolean warZoneBlockFireballs = false;
public static boolean warZoneBlockTNT = true; public static boolean warZoneBlockTNT = true;
public static boolean warZonePowerLoss = true; public static boolean warZonePowerLoss = true;
public static boolean warZoneFriendlyFire = false; public static boolean warZoneFriendlyFire = false;
public static boolean warZoneDenyEndermanBlocks = true; public static boolean warZoneDenyEndermanBlocks = true;
public static boolean wildernessDenyBuild = false; public static boolean wildernessDenyBuild = false;
public static boolean wildernessDenyUseage = false; public static boolean wildernessDenyUseage = false;
public static boolean wildernessBlockCreepers = false; public static boolean wildernessBlockCreepers = false;
public static boolean wildernessBlockFireballs = false; public static boolean wildernessBlockFireballs = false;
public static boolean wildernessBlockTNT = false; public static boolean wildernessBlockTNT = false;
public static boolean wildernessPowerLoss = true; public static boolean wildernessPowerLoss = true;
public static boolean wildernessDenyEndermanBlocks = false; public static boolean wildernessDenyEndermanBlocks = false;
// for claimed areas where further faction-member ownership can be defined // for claimed areas where further faction-member ownership can be defined
public static boolean ownedAreasEnabled = true; public static boolean ownedAreasEnabled = true;
public static int ownedAreasLimitPerFaction = 0; public static int ownedAreasLimitPerFaction = 0;
public static boolean ownedAreasModeratorsCanSet = false; public static boolean ownedAreasModeratorsCanSet = false;
public static boolean ownedAreaModeratorsBypass = true; public static boolean ownedAreaModeratorsBypass = true;
public static boolean ownedAreaDenyBuild = true; public static boolean ownedAreaDenyBuild = true;
public static boolean ownedAreaPainBuild = false; public static boolean ownedAreaPainBuild = false;
public static boolean ownedMessageOnBorder = true; public static boolean ownedMessageOnBorder = true;
public static boolean ownedMessageInsideTerritory = true; public static boolean ownedMessageInsideTerritory = true;
public static boolean ownedMessageByChunk = false; public static boolean ownedMessageByChunk = false;
public static boolean pistonProtectionThroughDenyBuild = true; public static boolean pistonProtectionThroughDenyBuild = true;
public static Set<Material> territoryProtectedMaterials = EnumSet.noneOf(Material.class); public static Set<Material> territoryProtectedMaterials = EnumSet.noneOf(Material.class);
public static Set<Material> territoryDenyUseageMaterials = EnumSet.noneOf(Material.class); public static Set<Material> territoryDenyUseageMaterials = EnumSet.noneOf(Material.class);
public static Set<Material> territoryProtectedMaterialsWhenOffline = EnumSet.noneOf(Material.class); public static Set<Material> territoryProtectedMaterialsWhenOffline = EnumSet.noneOf(Material.class);
public static Set<Material> territoryDenyUseageMaterialsWhenOffline = EnumSet.noneOf(Material.class); public static Set<Material> territoryDenyUseageMaterialsWhenOffline = EnumSet.noneOf(Material.class);
public static transient Set<EntityType> safeZoneNerfedCreatureTypes = EnumSet.noneOf(EntityType.class); public static transient Set<EntityType> safeZoneNerfedCreatureTypes = EnumSet.noneOf(EntityType.class);
/// <summary> /// <summary>
/// This defines a set of materials which should always be allowed to use, regardless of factions permissions. /// This defines a set of materials which should always be allowed to use, regardless of factions permissions.
/// Useful for HCF features. /// Useful for HCF features.
/// </summary> /// </summary>
public static Set<Material> territoryBypassProtectedMaterials = EnumSet.noneOf(Material.class); public static Set<Material> territoryBypassProtectedMaterials = EnumSet.noneOf(Material.class);
// Economy settings // Economy settings
public static boolean econEnabled = false; public static boolean econEnabled = false;
public static String econUniverseAccount = ""; public static String econUniverseAccount = "";
public static double econCostClaimWilderness = 30.0; public static double econCostClaimWilderness = 30.0;
public static double econCostClaimFromFactionBonus = 30.0; public static double econCostClaimFromFactionBonus = 30.0;
public static double econOverclaimRewardMultiplier = 0.0; public static double econOverclaimRewardMultiplier = 0.0;
public static double econClaimAdditionalMultiplier = 0.5; public static double econClaimAdditionalMultiplier = 0.5;
public static double econClaimRefundMultiplier = 0.7; public static double econClaimRefundMultiplier = 0.7;
public static double econClaimUnconnectedFee = 0.0; public static double econClaimUnconnectedFee = 0.0;
public static double econCostCreate = 100.0; public static double econCostCreate = 100.0;
public static double econCostOwner = 15.0; public static double econCostOwner = 15.0;
public static double econCostSethome = 30.0; public static double econCostSethome = 30.0;
public static double econCostJoin = 0.0; public static double econCostJoin = 0.0;
public static double econCostLeave = 0.0; public static double econCostLeave = 0.0;
public static double econCostKick = 0.0; public static double econCostKick = 0.0;
public static double econCostInvite = 0.0; public static double econCostInvite = 0.0;
public static double econCostHome = 0.0; public static double econCostHome = 0.0;
public static double econCostTag = 0.0; public static double econCostTag = 0.0;
public static double econCostDesc = 0.0; public static double econCostDesc = 0.0;
public static double econCostTitle = 0.0; public static double econCostTitle = 0.0;
public static double econCostList = 0.0; public static double econCostList = 0.0;
public static double econCostMap = 0.0; public static double econCostMap = 0.0;
public static double econCostPower = 0.0; public static double econCostPower = 0.0;
public static double econCostShow = 0.0; public static double econCostShow = 0.0;
public static double econFactionStartingBalance = 0.0; public static double econFactionStartingBalance = 0.0;
public static double econDenyWithdrawWhenMinutesAgeLessThan = 2880; // 2 days public static double econDenyWithdrawWhenMinutesAgeLessThan = 2880; // 2 days
public static String dateFormat = "HH:mm dd/MM/yyyy"; public static String dateFormat = "HH:mm dd/MM/yyyy";
// -------------------------------------------- // // -------------------------------------------- //
// INTEGRATION: DYNMAP // INTEGRATION: DYNMAP
// -------------------------------------------- // // -------------------------------------------- //
public static double econCostStuck = 0.0; public static double econCostStuck = 0.0;
public static double econCostOpen = 0.0; public static double econCostOpen = 0.0;
public static double econCostAlly = 0.0; public static double econCostAlly = 0.0;
public static double econCostTruce = 0.0; public static double econCostTruce = 0.0;
public static double econCostEnemy = 0.0; public static double econCostEnemy = 0.0;
public static double econCostNeutral = 0.0; public static double econCostNeutral = 0.0;
public static double econCostNoBoom = 0.0; public static double econCostNoBoom = 0.0;
// Should the dynmap intagration be used? // Should the dynmap intagration be used?
public static boolean dynmapUse = false; public static boolean dynmapUse = false;
// Name of the Factions layer // Name of the Factions layer
public static String dynmapLayerName = "Factions"; public static String dynmapLayerName = "Factions";
// Should the layer be visible per default // Should the layer be visible per default
public static boolean dynmapLayerVisible = true; public static boolean dynmapLayerVisible = true;
// Ordering priority in layer menu (low goes before high - default is 0) // Ordering priority in layer menu (low goes before high - default is 0)
public static int dynmapLayerPriority = 2; public static int dynmapLayerPriority = 2;
// (optional) set minimum zoom level before layer is visible (0 = default, always visible) // (optional) set minimum zoom level before layer is visible (0 = default, always visible)
public static int dynmapLayerMinimumZoom = 0; public static int dynmapLayerMinimumZoom = 0;
// Format for popup - substitute values for macros // Format for popup - substitute values for macros
public static String dynmapDescription = public static String dynmapDescription =
"<div class=\"infowindow\">\n" "<div class=\"infowindow\">\n"
+ "<span style=\"font-weight: bold; font-size: 150%;\">%name%</span><br>\n" + "<span style=\"font-weight: bold; font-size: 150%;\">%name%</span><br>\n"
+ "<span style=\"font-style: italic; font-size: 110%;\">%description%</span><br>" + "<span style=\"font-style: italic; font-size: 110%;\">%description%</span><br>"
+ "<br>\n" + "<br>\n"
+ "<span style=\"font-weight: bold;\">Leader:</span> %players.leader%<br>\n" + "<span style=\"font-weight: bold;\">Leader:</span> %players.leader%<br>\n"
+ "<span style=\"font-weight: bold;\">Admins:</span> %players.admins.count%<br>\n" + "<span style=\"font-weight: bold;\">Admins:</span> %players.admins.count%<br>\n"
+ "<span style=\"font-weight: bold;\">Moderators:</span> %players.moderators.count%<br>\n" + "<span style=\"font-weight: bold;\">Moderators:</span> %players.moderators.count%<br>\n"
+ "<span style=\"font-weight: bold;\">Members:</span> %players.normals.count%<br>\n" + "<span style=\"font-weight: bold;\">Members:</span> %players.normals.count%<br>\n"
+ "<span style=\"font-weight: bold;\">TOTAL:</span> %players.count%<br>\n" + "<span style=\"font-weight: bold;\">TOTAL:</span> %players.count%<br>\n"
+ "</br>\n" + "</br>\n"
+ "<span style=\"font-weight: bold;\">Bank:</span> %money%<br>\n" + "<span style=\"font-weight: bold;\">Bank:</span> %money%<br>\n"
+ "<br>\n" + "<br>\n"
+ "</div>"; + "</div>";
// Enable the %money% macro. Only do this if you know your economy manager is thread-safe. // Enable the %money% macro. Only do this if you know your economy manager is thread-safe.
public static boolean dynmapDescriptionMoney = false; public static boolean dynmapDescriptionMoney = false;
// Allow players in faction to see one another on Dynmap (only relevant if Dynmap has 'player-info-protected' enabled) // Allow players in faction to see one another on Dynmap (only relevant if Dynmap has 'player-info-protected' enabled)
public static boolean dynmapVisibilityByFaction = true; public static boolean dynmapVisibilityByFaction = true;
// Optional setting to limit which regions to show. // Optional setting to limit which regions to show.
// If empty all regions are shown. // If empty all regions are shown.
// Specify Faction either by name or UUID. // Specify Faction either by name or UUID.
// To show all regions on a given world, add 'world:<worldname>' to the list. // To show all regions on a given world, add 'world:<worldname>' to the list.
public static Set<String> dynmapVisibleFactions = new HashSet<>(); public static Set<String> dynmapVisibleFactions = new HashSet<>();
// Optional setting to hide specific Factions. // Optional setting to hide specific Factions.
// Specify Faction either by name or UUID. // Specify Faction either by name or UUID.
// To hide all regions on a given world, add 'world:<worldname>' to the list. // To hide all regions on a given world, add 'world:<worldname>' to the list.
public static Set<String> dynmapHiddenFactions = new HashSet<>(); public static Set<String> dynmapHiddenFactions = new HashSet<>();
public static DynmapStyle dynmapDefaultStyle = new DynmapStyle() public static DynmapStyle dynmapDefaultStyle = new DynmapStyle()
.setStrokeColor(DYNMAP_STYLE_LINE_COLOR) .setStrokeColor(DYNMAP_STYLE_LINE_COLOR)
.setLineOpacity(DYNMAP_STYLE_LINE_OPACITY) .setLineOpacity(DYNMAP_STYLE_LINE_OPACITY)
.setLineWeight(DYNMAP_STYLE_LINE_WEIGHT) .setLineWeight(DYNMAP_STYLE_LINE_WEIGHT)
.setFillColor(DYNMAP_STYLE_FILL_COLOR) .setFillColor(DYNMAP_STYLE_FILL_COLOR)
.setFillOpacity(DYNMAP_STYLE_FILL_OPACITY) .setFillOpacity(DYNMAP_STYLE_FILL_OPACITY)
.setHomeMarker(DYNMAP_STYLE_HOME_MARKER) .setHomeMarker(DYNMAP_STYLE_HOME_MARKER)
.setBoost(DYNMAP_STYLE_BOOST); .setBoost(DYNMAP_STYLE_BOOST);
// Optional per Faction style overrides. Any defined replace those in dynmapDefaultStyle. // Optional per Faction style overrides. Any defined replace those in dynmapDefaultStyle.
// Specify Faction either by name or UUID. // Specify Faction either by name or UUID.
public static Map<String, DynmapStyle> dynmapFactionStyles = ImmutableMap.of( public static Map<String, DynmapStyle> dynmapFactionStyles = ImmutableMap.of(
"SafeZone", new DynmapStyle().setStrokeColor("#FF00FF").setFillColor("#FF00FF").setBoost(false), "SafeZone", new DynmapStyle().setStrokeColor("#FF00FF").setFillColor("#FF00FF").setBoost(false),
"WarZone", new DynmapStyle().setStrokeColor("#FF0000").setFillColor("#FF0000").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 //Faction banks, to pay for land claiming and other costs instead of individuals paying for them
public static boolean bankEnabled = true; 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 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 bankFactionPaysCosts = true; //The faction pays for faction command costs, such as sethome
public static boolean bankFactionPaysLandCosts = true; //The faction pays for land claiming costs. 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 // mainly for other plugins/mods that use a fake player to take actions, which shouldn't be subject to our protections
public static Set<String> playersWhoBypassAllProtection = new LinkedHashSet<>(); public static Set<String> playersWhoBypassAllProtection = new LinkedHashSet<>();
public static boolean useWorldConfigurationsAsWhitelist = false; public static boolean useWorldConfigurationsAsWhitelist = false;
public static Set<String> worldsNoClaiming = new LinkedHashSet<>(); public static Set<String> worldsNoClaiming = new LinkedHashSet<>();
public static Set<String> worldsNoPowerLoss = new LinkedHashSet<>(); public static Set<String> worldsNoPowerLoss = new LinkedHashSet<>();
public static Set<String> worldsIgnorePvP = new LinkedHashSet<>(); public static Set<String> worldsIgnorePvP = new LinkedHashSet<>();
public static Set<String> worldsNoWildernessProtection = new LinkedHashSet<>(); public static Set<String> worldsNoWildernessProtection = new LinkedHashSet<>();
// faction-<factionId> // faction-<factionId>
public static int defaultMaxVaults = 0; public static int defaultMaxVaults = 0;
public static boolean disableFlightOnFactionClaimChange = true; public static boolean disableFlightOnFactionClaimChange = true;
public static Backend backEnd = Backend.JSON; public static Backend backEnd = Backend.JSON;
// Taller and wider for "bigger f map" // Taller and wider for "bigger f map"
public static int mapHeight = 17; public static int mapHeight = 17;
public static int mapWidth = 49; public static int mapWidth = 49;
public static transient char[] mapKeyChrs = "\\/#$%=&^ABCDEFGHJKLMNOPQRSTUVWXYZ1234567890abcdeghjmnopqrsuvwxyz?".toCharArray(); public static transient char[] mapKeyChrs = "\\/#$%=&^ABCDEFGHJKLMNOPQRSTUVWXYZ1234567890abcdeghjmnopqrsuvwxyz?".toCharArray();
//Cooldown for /f logout in seconds //Cooldown for /f logout in seconds
public static long logoutCooldown = 30; public static long logoutCooldown = 30;
// Custom Ranks - Oof I forgot I was doing this _SvenjaReissaus_ // 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 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 //public static int maxCustomRanks = 2; // Setting this to -1 will allow unlimited custom ranks
// -------------------------------------------- // // -------------------------------------------- //
// Persistance // Persistance
// ----------------------------------------- // // ----------------------------------------- //
// Default Faction Permission Settings. // Default Faction Permission Settings.
public static boolean useLockedPermissions = false; public static boolean useLockedPermissions = false;
public static boolean useCustomDefaultPermissions = true; public static boolean useCustomDefaultPermissions = true;
public static boolean usePermissionHints = false; public static boolean usePermissionHints = false;
public static HashMap<String, DefaultPermissions> defaultFactionPermissions = new HashMap<>(); public static HashMap<String, DefaultPermissions> defaultFactionPermissions = new HashMap<>();
public static HashSet<PermissableAction> lockedPermissions = new HashSet<>(); public static HashSet<PermissableAction> lockedPermissions = new HashSet<>();
private static transient Conf i = new Conf(); private static transient Conf i = new Conf();
static { static {
lockedPermissions.add(PermissableAction.CHEST); lockedPermissions.add(PermissableAction.CHEST);
} }
static { static {
baseCommandAliases.add("f"); baseCommandAliases.add("f");
territoryEnemyDenyCommands.add("home"); territoryEnemyDenyCommands.add("home");
territoryEnemyDenyCommands.add("sethome"); territoryEnemyDenyCommands.add("sethome");
territoryEnemyDenyCommands.add("spawn"); territoryEnemyDenyCommands.add("spawn");
territoryEnemyDenyCommands.add("tpahere"); territoryEnemyDenyCommands.add("tpahere");
territoryEnemyDenyCommands.add("tpaccept"); territoryEnemyDenyCommands.add("tpaccept");
territoryEnemyDenyCommands.add("tpa"); territoryEnemyDenyCommands.add("tpa");
/// TODO: Consider removing this in a future release, as permissions works just fine now /// TODO: Consider removing this in a future release, as permissions works just fine now
territoryProtectedMaterials.add(Material.BEACON); territoryProtectedMaterials.add(Material.BEACON);
// Config is not loading if value is empty ??? // Config is not loading if value is empty ???
territoryBypassProtectedMaterials.add(Material.COOKIE); territoryBypassProtectedMaterials.add(Material.COOKIE);
territoryDenyUseageMaterials.add(XMaterial.FIRE_CHARGE.parseMaterial()); territoryDenyUseageMaterials.add(XMaterial.FIRE_CHARGE.parseMaterial());
territoryDenyUseageMaterials.add(Material.FLINT_AND_STEEL); territoryDenyUseageMaterials.add(Material.FLINT_AND_STEEL);
territoryDenyUseageMaterials.add(Material.BUCKET); territoryDenyUseageMaterials.add(Material.BUCKET);
territoryDenyUseageMaterials.add(Material.WATER_BUCKET); territoryDenyUseageMaterials.add(Material.WATER_BUCKET);
territoryDenyUseageMaterials.add(Material.LAVA_BUCKET); territoryDenyUseageMaterials.add(Material.LAVA_BUCKET);
if (!FactionsPlugin.getInstance().mc17) { if (!FactionsPlugin.getInstance().mc17) {
territoryDenyUseageMaterials.add(Material.ARMOR_STAND); territoryDenyUseageMaterials.add(Material.ARMOR_STAND);
} }
territoryProtectedMaterialsWhenOffline.add(Material.BEACON); territoryProtectedMaterialsWhenOffline.add(Material.BEACON);
territoryDenyUseageMaterialsWhenOffline.add(XMaterial.FIRE_CHARGE.parseMaterial()); territoryDenyUseageMaterialsWhenOffline.add(XMaterial.FIRE_CHARGE.parseMaterial());
territoryDenyUseageMaterialsWhenOffline.add(Material.FLINT_AND_STEEL); territoryDenyUseageMaterialsWhenOffline.add(Material.FLINT_AND_STEEL);
territoryDenyUseageMaterialsWhenOffline.add(Material.BUCKET); territoryDenyUseageMaterialsWhenOffline.add(Material.BUCKET);
territoryDenyUseageMaterialsWhenOffline.add(Material.WATER_BUCKET); territoryDenyUseageMaterialsWhenOffline.add(Material.WATER_BUCKET);
territoryDenyUseageMaterialsWhenOffline.add(Material.LAVA_BUCKET); territoryDenyUseageMaterialsWhenOffline.add(Material.LAVA_BUCKET);
if (!FactionsPlugin.getInstance().mc17) { if (!FactionsPlugin.getInstance().mc17) {
territoryDenyUseageMaterialsWhenOffline.add(Material.ARMOR_STAND); territoryDenyUseageMaterialsWhenOffline.add(Material.ARMOR_STAND);
} }
safeZoneNerfedCreatureTypes.add(EntityType.BLAZE); safeZoneNerfedCreatureTypes.add(EntityType.BLAZE);
safeZoneNerfedCreatureTypes.add(EntityType.CAVE_SPIDER); safeZoneNerfedCreatureTypes.add(EntityType.CAVE_SPIDER);
safeZoneNerfedCreatureTypes.add(EntityType.CREEPER); safeZoneNerfedCreatureTypes.add(EntityType.CREEPER);
safeZoneNerfedCreatureTypes.add(EntityType.ENDER_DRAGON); safeZoneNerfedCreatureTypes.add(EntityType.ENDER_DRAGON);
safeZoneNerfedCreatureTypes.add(EntityType.ENDERMAN); safeZoneNerfedCreatureTypes.add(EntityType.ENDERMAN);
safeZoneNerfedCreatureTypes.add(EntityType.GHAST); safeZoneNerfedCreatureTypes.add(EntityType.GHAST);
safeZoneNerfedCreatureTypes.add(EntityType.MAGMA_CUBE); safeZoneNerfedCreatureTypes.add(EntityType.MAGMA_CUBE);
safeZoneNerfedCreatureTypes.add(EntityType.PIG_ZOMBIE); safeZoneNerfedCreatureTypes.add(EntityType.PIG_ZOMBIE);
safeZoneNerfedCreatureTypes.add(EntityType.SILVERFISH); safeZoneNerfedCreatureTypes.add(EntityType.SILVERFISH);
safeZoneNerfedCreatureTypes.add(EntityType.SKELETON); safeZoneNerfedCreatureTypes.add(EntityType.SKELETON);
safeZoneNerfedCreatureTypes.add(EntityType.SPIDER); safeZoneNerfedCreatureTypes.add(EntityType.SPIDER);
safeZoneNerfedCreatureTypes.add(EntityType.SLIME); safeZoneNerfedCreatureTypes.add(EntityType.SLIME);
safeZoneNerfedCreatureTypes.add(EntityType.WITCH); safeZoneNerfedCreatureTypes.add(EntityType.WITCH);
safeZoneNerfedCreatureTypes.add(EntityType.WITHER); safeZoneNerfedCreatureTypes.add(EntityType.WITHER);
safeZoneNerfedCreatureTypes.add(EntityType.ZOMBIE); safeZoneNerfedCreatureTypes.add(EntityType.ZOMBIE);
// Is this called lazy load? // Is this called lazy load?
defaultFactionPermissions.put("LEADER", new DefaultPermissions(true)); defaultFactionPermissions.put("LEADER", new DefaultPermissions(true));
defaultFactionPermissions.put("COLEADER", new DefaultPermissions(true)); defaultFactionPermissions.put("COLEADER", new DefaultPermissions(true));
defaultFactionPermissions.put("MODERATOR", new DefaultPermissions(true)); defaultFactionPermissions.put("MODERATOR", new DefaultPermissions(true));
defaultFactionPermissions.put("NORMAL MEMBER", new DefaultPermissions(false)); defaultFactionPermissions.put("NORMAL MEMBER", new DefaultPermissions(false));
defaultFactionPermissions.put("RECRUIT", new DefaultPermissions(false)); defaultFactionPermissions.put("RECRUIT", new DefaultPermissions(false));
} }
public static void load() { public static void load() {
FactionsPlugin.getInstance().persist.loadOrSaveDefault(i, Conf.class, "conf"); FactionsPlugin.getInstance().persist.loadOrSaveDefault(i, Conf.class, "conf");
} }
public static void save() { public static void save() {
FactionsPlugin.getInstance().persist.save(i); FactionsPlugin.getInstance().persist.save(i);
} }
public enum Backend { public enum Backend {
JSON, JSON,
//MYSQL, TODO add MySQL storage //MYSQL, TODO add MySQL storage
; ;
} }
} }

View File

@ -12,248 +12,248 @@ import java.util.Objects;
import java.util.Set; import java.util.Set;
public class FLocation implements Serializable { public class FLocation implements Serializable {
private static final long serialVersionUID = -8292915234027387983L; private static final long serialVersionUID = -8292915234027387983L;
private static final boolean worldBorderSupport; private static final boolean worldBorderSupport;
static { static {
boolean worldBorderClassPresent = false; boolean worldBorderClassPresent = false;
try { try {
Class.forName("org.bukkit.WorldBorder"); Class.forName("org.bukkit.WorldBorder");
worldBorderClassPresent = true; worldBorderClassPresent = true;
} catch (ClassNotFoundException ignored) { } catch (ClassNotFoundException ignored) {
} }
worldBorderSupport = worldBorderClassPresent; worldBorderSupport = worldBorderClassPresent;
} }
private String worldName = "world"; private String worldName = "world";
private int x = 0; private int x = 0;
private int z = 0; private int z = 0;
//----------------------------------------------// //----------------------------------------------//
// Constructors // Constructors
//----------------------------------------------// //----------------------------------------------//
public FLocation() { public FLocation() {
} }
public FLocation(String worldName, int x, int z) { public FLocation(String worldName, int x, int z) {
this.worldName = worldName; this.worldName = worldName;
this.x = x; this.x = x;
this.z = z; this.z = z;
} }
public FLocation(Location location) { public FLocation(Location location) {
this(location.getWorld().getName(), blockToChunk(location.getBlockX()), blockToChunk(location.getBlockZ())); this(location.getWorld().getName(), blockToChunk(location.getBlockX()), blockToChunk(location.getBlockZ()));
} }
public FLocation(Player player) { public FLocation(Player player) {
this(player.getLocation()); this(player.getLocation());
} }
public FLocation(FPlayer fplayer) { public FLocation(FPlayer fplayer) {
this(fplayer.getPlayer()); this(fplayer.getPlayer());
} }
public FLocation(Block block) { public FLocation(Block block) {
this(block.getLocation()); this(block.getLocation());
} }
//----------------------------------------------// //----------------------------------------------//
// Getters and Setters // Getters and Setters
//----------------------------------------------// //----------------------------------------------//
public static FLocation fromString(String string) { public static FLocation fromString(String string) {
int index = string.indexOf(","); int index = string.indexOf(",");
int start = 1; int start = 1;
String worldName = string.substring(start, index); String worldName = string.substring(start, index);
start = index + 1; start = index + 1;
index = string.indexOf(",", start); index = string.indexOf(",", start);
int x = Integer.valueOf(string.substring(start, index)); int x = Integer.valueOf(string.substring(start, index));
int y = Integer.valueOf(string.substring(index + 1, string.length() - 1)); int y = Integer.valueOf(string.substring(index + 1, string.length() - 1));
return new FLocation(worldName, x, y); return new FLocation(worldName, x, y);
} }
// bit-shifting is used because it's much faster than standard division and multiplication // 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 public static int blockToChunk(int blockVal) { // 1 chunk is 16x16 blocks
return blockVal >> 4; // ">> 4" == "/ 16" return blockVal >> 4; // ">> 4" == "/ 16"
} }
public static int blockToRegion(int blockVal) { // 1 region is 512x512 blocks public static int blockToRegion(int blockVal) { // 1 region is 512x512 blocks
return blockVal >> 9; // ">> 9" == "/ 512" return blockVal >> 9; // ">> 9" == "/ 512"
} }
public static int chunkToRegion(int chunkVal) { // 1 region is 32x32 chunks public static int chunkToRegion(int chunkVal) { // 1 region is 32x32 chunks
return chunkVal >> 5; // ">> 5" == "/ 32" return chunkVal >> 5; // ">> 5" == "/ 32"
} }
public static int chunkToBlock(int chunkVal) { public static int chunkToBlock(int chunkVal) {
return chunkVal << 4; // "<< 4" == "* 16" return chunkVal << 4; // "<< 4" == "* 16"
} }
public static int regionToBlock(int regionVal) { public static int regionToBlock(int regionVal) {
return regionVal << 9; // "<< 9" == "* 512" return regionVal << 9; // "<< 9" == "* 512"
} }
public static int regionToChunk(int regionVal) { public static int regionToChunk(int regionVal) {
return regionVal << 5; // "<< 5" == "* 32" return regionVal << 5; // "<< 5" == "* 32"
} }
public static HashSet<FLocation> getArea(FLocation from, FLocation to) { public static HashSet<FLocation> getArea(FLocation from, FLocation to) {
HashSet<FLocation> ret = new HashSet<>(); HashSet<FLocation> ret = new HashSet<>();
for (long x : MiscUtil.range(from.getX(), to.getX())) { for (long x : MiscUtil.range(from.getX(), to.getX())) {
for (long z : MiscUtil.range(from.getZ(), to.getZ())) { for (long z : MiscUtil.range(from.getZ(), to.getZ())) {
ret.add(new FLocation(from.getWorldName(), (int) x, (int) z)); ret.add(new FLocation(from.getWorldName(), (int) x, (int) z));
} }
} }
return ret; return ret;
} }
public Chunk getChunk() { public Chunk getChunk() {
return Bukkit.getWorld(worldName).getChunkAt(x, z); return Bukkit.getWorld(worldName).getChunkAt(x, z);
} }
public String getWorldName() { public String getWorldName() {
return worldName; return worldName;
} }
public void setWorldName(String worldName) { public void setWorldName(String worldName) {
this.worldName = worldName; this.worldName = worldName;
} }
//----------------------------------------------// //----------------------------------------------//
// Block/Chunk/Region Value Transformation // Block/Chunk/Region Value Transformation
//----------------------------------------------// //----------------------------------------------//
public World getWorld() { public World getWorld() {
return Bukkit.getWorld(worldName); return Bukkit.getWorld(worldName);
} }
public long getX() { public long getX() {
return x; return x;
} }
public void setX(int x) { public void setX(int x) {
this.x = x; this.x = x;
} }
public long getZ() { public long getZ() {
return z; return z;
} }
public void setZ(int z) { public void setZ(int z) {
this.z = z; this.z = z;
} }
public String getCoordString() { public String getCoordString() {
return "" + x + "," + z; return "" + x + "," + z;
} }
//----------------------------------------------// //----------------------------------------------//
// Misc Geometry // Misc Geometry
//----------------------------------------------// //----------------------------------------------//
@Override @Override
public String toString() { public String toString() {
return "[" + this.getWorldName() + "," + this.getCoordString() + "]"; return "[" + this.getWorldName() + "," + this.getCoordString() + "]";
} }
public FLocation getRelative(int dx, int dz) { public FLocation getRelative(int dx, int dz) {
return new FLocation(this.worldName, this.x + dx, this.z + dz); return new FLocation(this.worldName, this.x + dx, this.z + dz);
} }
public double getDistanceTo(FLocation that) { public double getDistanceTo(FLocation that) {
double dx = that.x - this.x; double dx = that.x - this.x;
double dz = that.z - this.z; double dz = that.z - this.z;
return Math.sqrt(dx * dx + dz * dz); return Math.sqrt(dx * dx + dz * dz);
} }
public double getDistanceSquaredTo(FLocation that) { public double getDistanceSquaredTo(FLocation that) {
double dx = that.x - this.x; double dx = that.x - this.x;
double dz = that.z - this.z; double dz = that.z - this.z;
return dx * dx + dz * dz; return dx * dx + dz * dz;
} }
public boolean isInChunk(Location loc) { public boolean isInChunk(Location loc) {
if (loc == null) { if (loc == null) {
return false; return false;
} }
Chunk chunk = loc.getChunk(); Chunk chunk = loc.getChunk();
return loc.getWorld().getName().equalsIgnoreCase(getWorldName()) && chunk.getX() == x && chunk.getZ() == z; return loc.getWorld().getName().equalsIgnoreCase(getWorldName()) && chunk.getX() == x && chunk.getZ() == z;
} }
/** /**
* Checks if the chunk represented by this FLocation is outside the world border * 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" * @param buffer the number of chunks from the border that will be treated as "outside"
* @return whether this location is outside of the border * @return whether this location is outside of the border
*/ */
public boolean isOutsideWorldBorder(int buffer) { public boolean isOutsideWorldBorder(int buffer) {
if (!worldBorderSupport) { if (!worldBorderSupport) {
return false; return false;
} }
WorldBorder border = getWorld().getWorldBorder(); WorldBorder border = getWorld().getWorldBorder();
Chunk chunk = border.getCenter().getChunk(); Chunk chunk = border.getCenter().getChunk();
int lim = FLocation.chunkToRegion((int) border.getSize()) - buffer; int lim = FLocation.chunkToRegion((int) border.getSize()) - buffer;
int diffX = chunk.getX() - x; int diffX = chunk.getX() - x;
int diffZ = chunk.getZ() - z; int diffZ = chunk.getZ() - z;
return (diffX > lim || diffZ > lim) || (-diffX >= lim || -diffZ >= lim); return (diffX > lim || diffZ > lim) || (-diffX >= lim || -diffZ >= lim);
} }
//----------------------------------------------// //----------------------------------------------//
// Some Geometry // Some Geometry
//----------------------------------------------// //----------------------------------------------//
public Set<FLocation> getCircle(double radius) { public Set<FLocation> getCircle(double radius) {
double radiusSquared = radius * radius; double radiusSquared = radius * radius;
Set<FLocation> ret = new LinkedHashSet<>(); Set<FLocation> ret = new LinkedHashSet<>();
if (radius <= 0) { if (radius <= 0) {
return ret; return ret;
} }
int xfrom = (int) Math.floor(this.x - radius); int xfrom = (int) Math.floor(this.x - radius);
int xto = (int) Math.ceil(this.x + radius); int xto = (int) Math.ceil(this.x + radius);
int zfrom = (int) Math.floor(this.z - radius); int zfrom = (int) Math.floor(this.z - radius);
int zto = (int) Math.ceil(this.z + radius); int zto = (int) Math.ceil(this.z + radius);
for (int x = xfrom; x <= xto; x++) { for (int x = xfrom; x <= xto; x++) {
for (int z = zfrom; z <= zto; z++) { for (int z = zfrom; z <= zto; z++) {
FLocation potential = new FLocation(this.worldName, x, z); FLocation potential = new FLocation(this.worldName, x, z);
if (this.getDistanceSquaredTo(potential) <= radiusSquared) { if (this.getDistanceSquaredTo(potential) <= radiusSquared) {
ret.add(potential); ret.add(potential);
} }
} }
} }
return ret; return ret;
} }
//----------------------------------------------// //----------------------------------------------//
// Comparison // Comparison
//----------------------------------------------// //----------------------------------------------//
@Override @Override
public int hashCode() { public int hashCode() {
// should be fast, with good range and few hash collisions: (x * 512) + z + worldName.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); return (this.x << 9) + this.z + (this.worldName != null ? this.worldName.hashCode() : 0);
} }
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (obj == this) { if (obj == this) {
return true; return true;
} }
if (!(obj instanceof FLocation)) { if (!(obj instanceof FLocation)) {
return false; return false;
} }
FLocation that = (FLocation) obj; FLocation that = (FLocation) obj;
return this.x == that.x && this.z == that.z && (Objects.equals(this.worldName, that.worldName)); return this.x == that.x && this.z == that.z && (Objects.equals(this.worldName, that.worldName));
} }
} }

View File

@ -26,368 +26,368 @@ import java.util.List;
public interface FPlayer extends EconomyParticipator { public interface FPlayer extends EconomyParticipator {
void setNotificationsEnabled(boolean notifications); void setNotificationsEnabled(boolean notifications);
boolean hasNotificationsEnabled(); boolean hasNotificationsEnabled();
boolean isAlt(); boolean isAlt();
void setAlt(boolean alt); void setAlt(boolean alt);
/** /**
* Used to know if stealth is toggled on or off * Used to know if stealth is toggled on or off
* *
* @return if stealth mode is on or not. * @return if stealth mode is on or not.
*/ */
boolean isStealthEnabled(); boolean isStealthEnabled();
/** /**
* Toggles the stealth of the FPlayer depending on the parameter * Toggles the stealth of the FPlayer depending on the parameter
* *
* @param stealthToggle - toggles stealth * @param stealthToggle - toggles stealth
*/ */
void setStealth(boolean stealthToggle); void setStealth(boolean stealthToggle);
/** /**
* Sets the kills and deaths of a player. * Sets the kills and deaths of a player.
*/ */
void login(); void login();
/** /**
* Caches the kills and deaths of a player. * Caches the kills and deaths of a player.
*/ */
void logout(); void logout();
/** /**
* gets the faction of a FPlayer. * gets the faction of a FPlayer.
* *
* @return Faction of the FPlayer. * @return Faction of the FPlayer.
*/ */
Faction getFaction(); Faction getFaction();
/** /**
* Sets the faction of the FPlayer * Sets the faction of the FPlayer
* *
* @param faction faction to set. * @param faction faction to set.
*/ */
void setFaction(Faction faction, boolean alt); void setFaction(Faction faction, boolean alt);
/** /**
* Gets the faction ID of the player. * Gets the faction ID of the player.
* *
* @return FactionsID string * @return FactionsID string
*/ */
String getFactionId(); String getFactionId();
/** /**
* Check if a player has a faction * Check if a player has a faction
* *
* @return boolean * @return boolean
*/ */
boolean hasFaction(); boolean hasFaction();
/** /**
* Gets autoleave status * Gets autoleave status
* *
* @return boolean of the autoleave * @return boolean of the autoleave
*/ */
boolean willAutoLeave(); 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 // FIELD: account
String getAccountId(); 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: // Colored concatenations:
// These are used in information messages // These are used in information messages
String getNameAndTitle(Faction faction); String getNameAndTitle(Faction faction);
String getNameAndTitle(FPlayer fplayer); String getNameAndTitle(FPlayer fplayer);
// Chat Tag: // Chat Tag:
// These are injected into the format of global chat messages. // These are injected into the format of global chat messages.
String getChatTag(); String getChatTag();
// Colored Chat Tag // Colored Chat Tag
String getChatTag(Faction faction); 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 @Override
String describeTo(RelationParticipator that, boolean ucfirst); String describeTo(RelationParticipator that, boolean ucfirst);
@Override @Override
String describeTo(RelationParticipator that); String describeTo(RelationParticipator that);
@Override @Override
Relation getRelationTo(RelationParticipator rp); Relation getRelationTo(RelationParticipator rp);
@Override @Override
Relation getRelationTo(RelationParticipator rp, boolean ignorePeaceful); Relation getRelationTo(RelationParticipator rp, boolean ignorePeaceful);
Relation getRelationToLocation(); Relation getRelationToLocation();
@Override @Override
ChatColor getColorTo(RelationParticipator rp); ChatColor getColorTo(RelationParticipator rp);
String getRolePrefix(); String getRolePrefix();
//----------------------------------------------// //----------------------------------------------//
// Health // Health
//----------------------------------------------// //----------------------------------------------//
void heal(int amnt); void heal(int amnt);
//----------------------------------------------// //----------------------------------------------//
// Power // Power
//----------------------------------------------// //----------------------------------------------//
double getPower(); 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 // Territory
//----------------------------------------------// //----------------------------------------------//
boolean isInOwnTerritory(); 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<String> messages); void sendMessage(List<String> messages);
void sendFancyMessage(FancyMessage message); void sendFancyMessage(FancyMessage message);
void sendFancyMessage(List<FancyMessage> message); void sendFancyMessage(List<FancyMessage> 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();
} }

View File

@ -7,34 +7,34 @@ import org.bukkit.entity.Player;
import java.util.Collection; import java.util.Collection;
public abstract class FPlayers { public abstract class FPlayers {
protected static FPlayers instance = getFPlayersImpl(); protected static FPlayers instance = getFPlayersImpl();
public static FPlayers getInstance() { public static FPlayers getInstance() {
return instance; return instance;
} }
private static FPlayers getFPlayersImpl() { private static FPlayers getFPlayersImpl() {
if (Conf.backEnd == Conf.Backend.JSON) { if (Conf.backEnd == Conf.Backend.JSON) {
return new JSONFPlayers(); return new JSONFPlayers();
} }
return null; return null;
} }
public abstract void clean(); public abstract void clean();
public abstract Collection<FPlayer> getOnlinePlayers(); public abstract Collection<FPlayer> getOnlinePlayers();
public abstract FPlayer getByPlayer(Player player); public abstract FPlayer getByPlayer(Player player);
public abstract Collection<FPlayer> getAllFPlayers(); public abstract Collection<FPlayer> 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();
} }

View File

@ -24,370 +24,370 @@ import java.util.concurrent.ConcurrentHashMap;
public interface Faction extends EconomyParticipator { public interface Faction extends EconomyParticipator {
int getWallCheckMinutes(); int getWallCheckMinutes();
void setWallCheckMinutes(int minutes); void setWallCheckMinutes(int minutes);
int getBufferCheckMinutes(); int getBufferCheckMinutes();
void setBufferCheckMinutes(int minutes); void setBufferCheckMinutes(int minutes);
Map<Long, String> getChecks(); Map<Long, String> getChecks();
Map<UUID, Integer> getPlayerBufferCheckCount(); Map<UUID, Integer> getPlayerBufferCheckCount();
Map<UUID, Integer> getPlayerWallCheckCount(); Map<UUID, Integer> getPlayerWallCheckCount();
boolean isWeeWoo(); boolean isWeeWoo();
void setWeeWoo(boolean weeWoo); void setWeeWoo(boolean weeWoo);
boolean altInvited(FPlayer fplayer); boolean altInvited(FPlayer fplayer);
Map<String, Mission> getMissions(); Map<String, Mission> getMissions();
void deinviteAlt(FPlayer alt); void deinviteAlt(FPlayer alt);
void deinviteAllAlts(); void deinviteAllAlts();
void altInvite(FPlayer fplayer); void altInvite(FPlayer fplayer);
boolean addAltPlayer(FPlayer fplayer); boolean addAltPlayer(FPlayer fplayer);
boolean removeAltPlayer(FPlayer fplayer); boolean removeAltPlayer(FPlayer fplayer);
Set<FPlayer> getAltPlayers(); Set<FPlayer> getAltPlayers();
HashMap<String, List<String>> getAnnouncements(); HashMap<String, List<String>> getAnnouncements();
ConcurrentHashMap<String, LazyLocation> getWarps(); ConcurrentHashMap<String, LazyLocation> getWarps();
LazyLocation getWarp(String name); LazyLocation getWarp(String name);
void setWarp(String name, LazyLocation loc); void setWarp(String name, LazyLocation loc);
boolean isWarp(String name); boolean isWarp(String name);
boolean hasWarpPassword(String warp); boolean hasWarpPassword(String warp);
boolean isWarpPassword(String warp, String password); boolean isWarpPassword(String warp, String password);
void setWarpPassword(String warp, String password); void setWarpPassword(String warp, String password);
boolean removeWarp(String name); boolean removeWarp(String name);
void clearWarps(); void clearWarps();
int getMaxVaults(); int getMaxVaults();
void setMaxVaults(int value); void setMaxVaults(int value);
void addAnnouncement(FPlayer fPlayer, String msg); void addAnnouncement(FPlayer fPlayer, String msg);
void sendUnreadAnnouncements(FPlayer fPlayer); void sendUnreadAnnouncements(FPlayer fPlayer);
void removeAnnouncements(FPlayer fPlayer); void removeAnnouncements(FPlayer fPlayer);
Set<String> getInvites(); Set<String> getInvites();
String getFocused(); String getFocused();
void setFocused(String setFocused); void setFocused(String setFocused);
String getId(); String getId();
void setId(String id); void setId(String id);
void invite(FPlayer fplayer); void invite(FPlayer fplayer);
void deinvite(FPlayer fplayer); void deinvite(FPlayer fplayer);
void setUpgrade(UpgradeType upgrade, int level); void setUpgrade(UpgradeType upgrade, int level);
int getUpgrade(UpgradeType upgrade); int getUpgrade(UpgradeType upgrade);
boolean isInvited(FPlayer fplayer); boolean isInvited(FPlayer fplayer);
void ban(FPlayer target, FPlayer banner); void ban(FPlayer target, FPlayer banner);
int getPoints(); int getPoints();
void setPoints(int points); void setPoints(int points);
int getStrikes(); int getStrikes();
void setStrikes(int strikes); void setStrikes(int strikes);
void unban(FPlayer player); void unban(FPlayer player);
boolean isBanned(FPlayer player); boolean isBanned(FPlayer player);
Set<BanInfo> getBannedPlayers(); Set<BanInfo> getBannedPlayers();
HashMap<Integer, String> getRulesMap(); HashMap<Integer, String> getRulesMap();
void addRule(String rule); void addRule(String rule);
void removeRule(int index); void removeRule(int index);
void clearRules(); void clearRules();
Location getCheckpoint(); Location getCheckpoint();
void setCheckpoint(Location location); void setCheckpoint(Location location);
void addTnt(int amt); void addTnt(int amt);
void takeTnt(int amt); void takeTnt(int amt);
Location getVault(); Location getVault();
void setVault(Location vaultLocation); void setVault(Location vaultLocation);
Inventory getChestInventory(); Inventory getChestInventory();
void setChestSize(int chestSize); void setChestSize(int chestSize);
void setBannerPattern(ItemStack banner); void setBannerPattern(ItemStack banner);
ItemStack getBanner(); ItemStack getBanner();
int getTnt(); int getTnt();
String getRule(int index); String getRule(int index);
boolean getOpen(); boolean getOpen();
void setOpen(boolean isOpen); void setOpen(boolean isOpen);
boolean isPeaceful(); boolean isPeaceful();
void setPeaceful(boolean isPeaceful); void setPeaceful(boolean isPeaceful);
boolean getPeacefulExplosionsEnabled(); boolean getPeacefulExplosionsEnabled();
void setPeacefulExplosionsEnabled(boolean val); void setPeacefulExplosionsEnabled(boolean val);
boolean noExplosionsInTerritory(); boolean noExplosionsInTerritory();
boolean isPermanent(); boolean isPermanent();
void setPermanent(boolean isPermanent); void setPermanent(boolean isPermanent);
String getTag(); String getTag();
void setTag(String str); void setTag(String str);
String getTag(String prefix); String getTag(String prefix);
String getTag(Faction otherFaction); String getTag(Faction otherFaction);
String getTag(FPlayer otherFplayer); String getTag(FPlayer otherFplayer);
String getComparisonTag(); String getComparisonTag();
String getDescription(); String getDescription();
void setDescription(String value); void setDescription(String value);
boolean hasHome(); boolean hasHome();
Location getHome(); Location getHome();
void setHome(Location home); void setHome(Location home);
long getFoundedDate(); long getFoundedDate();
void setFoundedDate(long newDate); void setFoundedDate(long newDate);
void confirmValidHome(); void confirmValidHome();
String getAccountId(); String getAccountId();
Integer getPermanentPower(); Integer getPermanentPower();
void setPermanentPower(Integer permanentPower); void setPermanentPower(Integer permanentPower);
boolean hasPermanentPower(); boolean hasPermanentPower();
double getPowerBoost(); double getPowerBoost();
void setPowerBoost(double powerBoost); void setPowerBoost(double powerBoost);
boolean noPvPInTerritory(); boolean noPvPInTerritory();
boolean noMonstersInTerritory(); boolean noMonstersInTerritory();
boolean isNormal(); boolean isNormal();
boolean isSystemFaction(); boolean isSystemFaction();
@Deprecated @Deprecated
boolean isNone(); boolean isNone();
boolean isWilderness(); boolean isWilderness();
boolean isSafeZone(); boolean isSafeZone();
boolean isWarZone(); boolean isWarZone();
boolean isPlayerFreeType(); boolean isPlayerFreeType();
boolean isPowerFrozen(); boolean isPowerFrozen();
void setLastDeath(long time); void setLastDeath(long time);
int getKills(); int getKills();
int getDeaths(); int getDeaths();
Access getAccess(Permissable permissable, PermissableAction permissableAction); Access getAccess(Permissable permissable, PermissableAction permissableAction);
Access getAccess(FPlayer player, PermissableAction permissableAction); Access getAccess(FPlayer player, PermissableAction permissableAction);
boolean setPermission(Permissable permissable, PermissableAction permissableAction, Access access); boolean setPermission(Permissable permissable, PermissableAction permissableAction, Access access);
void resetPerms(); void resetPerms();
void setDefaultPerms(); void setDefaultPerms();
void disband(Player disbander); void disband(Player disbander);
void disband(Player disbander, PlayerDisbandReason reason); void disband(Player disbander, PlayerDisbandReason reason);
// ------------------------------- // -------------------------------
// Relation and relation colors // Relation and relation colors
// ------------------------------- // -------------------------------
Map<Permissable, Map<PermissableAction, Access>> getPermissions(); Map<Permissable, Map<PermissableAction, Access>> getPermissions();
@Override @Override
String describeTo(RelationParticipator that, boolean ucfirst); String describeTo(RelationParticipator that, boolean ucfirst);
@Override @Override
String describeTo(RelationParticipator that); String describeTo(RelationParticipator that);
@Override @Override
Relation getRelationTo(RelationParticipator rp); Relation getRelationTo(RelationParticipator rp);
@Override @Override
Relation getRelationTo(RelationParticipator rp, boolean ignorePeaceful); Relation getRelationTo(RelationParticipator rp, boolean ignorePeaceful);
@Override @Override
ChatColor getColorTo(RelationParticipator rp); ChatColor getColorTo(RelationParticipator rp);
Relation getRelationWish(Faction otherFaction); Relation getRelationWish(Faction otherFaction);
void setRelationWish(Faction otherFaction, Relation relation); void setRelationWish(Faction otherFaction, Relation relation);
int getRelationCount(Relation relation); int getRelationCount(Relation relation);
// ----------------------------------------------// // ----------------------------------------------//
// Power // Power
// ----------------------------------------------// // ----------------------------------------------//
double getPower(); double getPower();
double getPowerMax(); double getPowerMax();
int getPowerRounded(); int getPowerRounded();
int getPowerMaxRounded(); int getPowerMaxRounded();
int getLandRounded(); int getLandRounded();
int getLandRoundedInWorld(String worldName); int getLandRoundedInWorld(String worldName);
// ------------------------------- // -------------------------------
// FPlayers // FPlayers
// ------------------------------- // -------------------------------
boolean hasLandInflation(); boolean hasLandInflation();
// maintain the reference list of FPlayers in this faction // maintain the reference list of FPlayers in this faction
void refreshFPlayers(); void refreshFPlayers();
boolean addFPlayer(FPlayer fplayer); boolean addFPlayer(FPlayer fplayer);
boolean removeFPlayer(FPlayer fplayer); boolean removeFPlayer(FPlayer fplayer);
int getSize(); int getSize();
Set<FPlayer> getFPlayers(); Set<FPlayer> getFPlayers();
Set<FPlayer> getFPlayersWhereOnline(boolean online); Set<FPlayer> getFPlayersWhereOnline(boolean online);
Set<FPlayer> getFPlayersWhereOnline(boolean online, FPlayer viewer); Set<FPlayer> getFPlayersWhereOnline(boolean online, FPlayer viewer);
FPlayer getFPlayerAdmin(); FPlayer getFPlayerAdmin();
FPlayer getFPlayerLeader(); FPlayer getFPlayerLeader();
ArrayList<FPlayer> getFPlayersWhereRole(Role role); ArrayList<FPlayer> getFPlayersWhereRole(Role role);
ArrayList<Player> getOnlinePlayers(); ArrayList<Player> getOnlinePlayers();
// slightly faster check than getOnlinePlayers() if you just want to see if // slightly faster check than getOnlinePlayers() if you just want to see if
// there are any players online // there are any players online
boolean hasPlayersOnline(); boolean hasPlayersOnline();
void memberLoggedOff(); void memberLoggedOff();
// used when current leader is about to be removed from the faction; // used when current leader is about to be removed from the faction;
// promotes new leader, or disbands faction if no other members left // promotes new leader, or disbands faction if no other members left
void promoteNewLeader(); void promoteNewLeader();
void promoteNewLeader(boolean autoLeave); void promoteNewLeader(boolean autoLeave);
Role getDefaultRole(); Role getDefaultRole();
void setDefaultRole(Role role); void setDefaultRole(Role role);
// ----------------------------------------------// // ----------------------------------------------//
// Messages // Messages
// ----------------------------------------------// // ----------------------------------------------//
void msg(String message, Object... args); void msg(String message, Object... args);
void sendMessage(String message); void sendMessage(String message);
// ----------------------------------------------// // ----------------------------------------------//
// Ownership of specific claims // Ownership of specific claims
// ----------------------------------------------// // ----------------------------------------------//
void sendMessage(List<String> messages); void sendMessage(List<String> messages);
Map<FLocation, Set<String>> getClaimOwnership(); Map<FLocation, Set<String>> getClaimOwnership();
void clearAllClaimOwnership(); void clearAllClaimOwnership();
void clearClaimOwnership(FLocation loc); void clearClaimOwnership(FLocation loc);
void clearClaimOwnership(FPlayer player); void clearClaimOwnership(FPlayer player);
int getCountOfClaimsWithOwners(); int getCountOfClaimsWithOwners();
boolean doesLocationHaveOwnersSet(FLocation loc); boolean doesLocationHaveOwnersSet(FLocation loc);
boolean isPlayerInOwnerList(FPlayer player, FLocation loc); boolean isPlayerInOwnerList(FPlayer player, FLocation loc);
void setPlayerAsOwner(FPlayer player, FLocation loc); void setPlayerAsOwner(FPlayer player, FLocation loc);
void removePlayerAsOwner(FPlayer player, FLocation loc); void removePlayerAsOwner(FPlayer player, FLocation loc);
Set<String> getOwnerList(FLocation loc); Set<String> getOwnerList(FLocation loc);
String getOwnerListString(FLocation loc); String getOwnerListString(FLocation loc);
boolean playerHasOwnershipRights(FPlayer fplayer, FLocation loc); boolean playerHasOwnershipRights(FPlayer fplayer, FLocation loc);
// ----------------------------------------------// // ----------------------------------------------//
// Persistance and entity management // Persistance and entity management
// ----------------------------------------------// // ----------------------------------------------//
void remove(); void remove();
Set<FLocation> getAllClaims(); Set<FLocation> getAllClaims();
String getPaypal(); String getPaypal();
void paypalSet(String paypal); void paypalSet(String paypal);
} }

View File

@ -6,50 +6,50 @@ import java.util.ArrayList;
import java.util.Set; import java.util.Set;
public abstract class Factions { public abstract class Factions {
protected static Factions instance = getFactionsImpl(); protected static Factions instance = getFactionsImpl();
public static Factions getInstance() { public static Factions getInstance() {
return instance; return instance;
} }
private static Factions getFactionsImpl() { private static Factions getFactionsImpl() {
switch (Conf.backEnd) { switch (Conf.backEnd) {
case JSON: case JSON:
return new JSONFactions(); return new JSONFactions();
} }
return null; 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<String> getFactionTags(); public abstract Set<String> getFactionTags();
public abstract ArrayList<Faction> getAllFactions(); public abstract ArrayList<Faction> getAllFactions();
@Deprecated @Deprecated
public abstract Faction getNone(); 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();
} }

File diff suppressed because it is too large Load Diff

View File

@ -15,78 +15,78 @@ import java.util.Map;
public class BrigadierManager { public class BrigadierManager {
public Commodore commodore; public Commodore commodore;
public LiteralArgumentBuilder<Object> brigadier = LiteralArgumentBuilder.literal("factions"); public LiteralArgumentBuilder<Object> brigadier = LiteralArgumentBuilder.literal("factions");
public BrigadierManager() { public BrigadierManager() {
commodore = CommodoreProvider.getCommodore(FactionsPlugin.getInstance()); commodore = CommodoreProvider.getCommodore(FactionsPlugin.getInstance());
} }
public void build() { public void build() {
commodore.register(brigadier.build()); commodore.register(brigadier.build());
// Add factions children to f alias // Add factions children to f alias
LiteralArgumentBuilder<Object> fLiteral = LiteralArgumentBuilder.literal("f"); LiteralArgumentBuilder<Object> fLiteral = LiteralArgumentBuilder.literal("f");
for (CommandNode<Object> node : brigadier.getArguments()) fLiteral.then(node); for (CommandNode<Object> node : brigadier.getArguments()) fLiteral.then(node);
commodore.register(fLiteral.build()); commodore.register(fLiteral.build());
} }
public void addSubCommand(FCommand subCommand) { public void addSubCommand(FCommand subCommand) {
// Register brigadier to all command aliases // Register brigadier to all command aliases
for (String alias : subCommand.aliases) { for (String alias : subCommand.aliases) {
LiteralArgumentBuilder<Object> literal = LiteralArgumentBuilder.literal(alias); LiteralArgumentBuilder<Object> literal = LiteralArgumentBuilder.literal(alias);
if (subCommand.requirements.brigadier != null) { if (subCommand.requirements.brigadier != null) {
// If the requirements explicitly provide a BrigadierProvider then use it // If the requirements explicitly provide a BrigadierProvider then use it
Class<? extends BrigadierProvider> brigadierProvider = subCommand.requirements.brigadier; Class<? extends BrigadierProvider> brigadierProvider = subCommand.requirements.brigadier;
try { try {
Constructor<? extends BrigadierProvider> constructor = brigadierProvider.getDeclaredConstructor(subCommand.getClass()); Constructor<? extends BrigadierProvider> constructor = brigadierProvider.getDeclaredConstructor(subCommand.getClass());
brigadier.then(constructor.newInstance(subCommand).get(literal)); brigadier.then(constructor.newInstance(subCommand).get(literal));
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
} else { } else {
// Generate our own based on args - quite ugly // Generate our own based on args - quite ugly
// We create an orderly stack of all args, required and optional, format them differently // We create an orderly stack of all args, required and optional, format them differently
List<RequiredArgumentBuilder<Object, ?>> stack = new ArrayList<>(); List<RequiredArgumentBuilder<Object, ?>> stack = new ArrayList<>();
for (String required : subCommand.requiredArgs) { for (String required : subCommand.requiredArgs) {
// Simply add the arg name as required // Simply add the arg name as required
stack.add(RequiredArgumentBuilder.argument(required, StringArgumentType.word())); stack.add(RequiredArgumentBuilder.argument(required, StringArgumentType.word()));
} }
for (Map.Entry<String, String> optionalEntry : subCommand.optionalArgs.entrySet()) { for (Map.Entry<String, String> optionalEntry : subCommand.optionalArgs.entrySet()) {
RequiredArgumentBuilder<Object, ?> optional; RequiredArgumentBuilder<Object, ?> optional;
// Optional without default // Optional without default
if (optionalEntry.getKey().equalsIgnoreCase(optionalEntry.getValue())) { if (optionalEntry.getKey().equalsIgnoreCase(optionalEntry.getValue())) {
optional = RequiredArgumentBuilder.argument(":" + optionalEntry.getKey(), StringArgumentType.word()); optional = RequiredArgumentBuilder.argument(":" + optionalEntry.getKey(), StringArgumentType.word());
// Optional with default, explain // Optional with default, explain
} else {
optional = RequiredArgumentBuilder.argument(optionalEntry.getKey() + "|" + optionalEntry.getValue(), StringArgumentType.word());
}
stack.add(optional);
}
// Reverse the stack and apply .then()
RequiredArgumentBuilder<Object, ?> previous = null;
for (int i = stack.size() - 1; i >= 0; i--) {
if (previous == null) {
previous = stack.get(i);
} else {
previous = stack.get(i).then(previous);
}
}
if (previous == null) {
brigadier.then(literal);
} else { } else {
brigadier.then(literal.then(previous)); optional = RequiredArgumentBuilder.argument(optionalEntry.getKey() + "|" + optionalEntry.getValue(), StringArgumentType.word());
} }
}
} stack.add(optional);
} }
// Reverse the stack and apply .then()
RequiredArgumentBuilder<Object, ?> previous = null;
for (int i = stack.size() - 1; i >= 0; i--) {
if (previous == null) {
previous = stack.get(i);
} else {
previous = stack.get(i).then(previous);
}
}
if (previous == null) {
brigadier.then(literal);
} else {
brigadier.then(literal.then(previous));
}
}
}
}
} }

View File

@ -4,6 +4,6 @@ import com.mojang.brigadier.builder.ArgumentBuilder;
public interface BrigadierProvider { public interface BrigadierProvider {
ArgumentBuilder<Object, ?> get(ArgumentBuilder<Object, ?> parent); ArgumentBuilder<Object, ?> get(ArgumentBuilder<Object, ?> parent);
} }

View File

@ -8,40 +8,40 @@ import org.bukkit.event.player.PlayerTeleportEvent;
public class CmdAHome extends FCommand { public class CmdAHome extends FCommand {
public CmdAHome() { public CmdAHome() {
super(); super();
this.aliases.add("ahome"); this.aliases.add("ahome");
this.requiredArgs.add("player"); this.requiredArgs.add("player");
this.requirements = new CommandRequirements.Builder(Permission.AHOME).noDisableOnLock().build(); this.requirements = new CommandRequirements.Builder(Permission.AHOME).noDisableOnLock().build();
} }
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
FPlayer target = context.argAsBestFPlayerMatch(0); FPlayer target = context.argAsBestFPlayerMatch(0);
if (target == null) { if (target == null) {
context.msg(TL.GENERIC_NOPLAYERMATCH, context.argAsString(0)); context.msg(TL.GENERIC_NOPLAYERMATCH, context.argAsString(0));
return; return;
} }
if (target.isOnline()) { if (target.isOnline()) {
Faction faction = target.getFaction(); Faction faction = target.getFaction();
if (faction.hasHome()) { if (faction.hasHome()) {
target.getPlayer().teleport(faction.getHome(), PlayerTeleportEvent.TeleportCause.PLUGIN); target.getPlayer().teleport(faction.getHome(), PlayerTeleportEvent.TeleportCause.PLUGIN);
context.msg(TL.COMMAND_AHOME_SUCCESS, target.getName()); context.msg(TL.COMMAND_AHOME_SUCCESS, target.getName());
target.msg(TL.COMMAND_AHOME_TARGET); target.msg(TL.COMMAND_AHOME_TARGET);
} else { } else {
context.msg(TL.COMMAND_AHOME_NOHOME, target.getName()); context.msg(TL.COMMAND_AHOME_NOHOME, target.getName());
} }
} else { } else {
context.msg(TL.COMMAND_AHOME_OFFLINE, target.getName()); context.msg(TL.COMMAND_AHOME_OFFLINE, target.getName());
} }
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_AHOME_DESCRIPTION; return TL.COMMAND_AHOME_DESCRIPTION;
} }
} }

View File

@ -11,77 +11,77 @@ import org.bukkit.Bukkit;
public class CmdAdmin extends FCommand { public class CmdAdmin extends FCommand {
public CmdAdmin() { public CmdAdmin() {
super(); super();
this.aliases.add("admin"); this.aliases.add("admin");
this.aliases.add("setadmin"); this.aliases.add("setadmin");
this.aliases.add("leader"); this.aliases.add("leader");
this.aliases.add("setleader"); this.aliases.add("setleader");
this.requiredArgs.add("player"); this.requiredArgs.add("player");
this.requirements = new CommandRequirements.Builder(Permission.ADMIN).build(); this.requirements = new CommandRequirements.Builder(Permission.ADMIN).build();
} }
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
// Allows admins bypass this. // Allows admins bypass this.
if (!context.fPlayer.isAdminBypassing() && !context.fPlayer.getRole().equals(Role.LEADER)) { if (!context.fPlayer.isAdminBypassing() && !context.fPlayer.getRole().equals(Role.LEADER)) {
context.msg(TL.COMMAND_ADMIN_NOTADMIN); context.msg(TL.COMMAND_ADMIN_NOTADMIN);
return; return;
} }
FPlayer fyou = context.argAsBestFPlayerMatch(0); FPlayer fyou = context.argAsBestFPlayerMatch(0);
if (fyou == null) { if (fyou == null) {
return; return;
} }
boolean permAny = Permission.ADMIN_ANY.has(context.sender, false); boolean permAny = Permission.ADMIN_ANY.has(context.sender, false);
Faction targetFaction = fyou.getFaction(); Faction targetFaction = fyou.getFaction();
if (targetFaction != context.faction && !permAny) { if (targetFaction != context.faction && !permAny) {
context.msg(TL.COMMAND_ADMIN_NOTMEMBER, fyou.describeTo(context.fPlayer, true)); context.msg(TL.COMMAND_ADMIN_NOTMEMBER, fyou.describeTo(context.fPlayer, true));
return; return;
} }
if (fyou == context.fPlayer && !permAny) { if (fyou == context.fPlayer && !permAny) {
context.msg(TL.COMMAND_ADMIN_TARGETSELF); context.msg(TL.COMMAND_ADMIN_TARGETSELF);
return; return;
} }
// only perform a FPlayerJoinEvent when newLeader isn't actually in the faction // only perform a FPlayerJoinEvent when newLeader isn't actually in the faction
if (fyou.getFaction() != targetFaction) { if (fyou.getFaction() != targetFaction) {
FPlayerJoinEvent event = new FPlayerJoinEvent(FPlayers.getInstance().getByPlayer(context.player), targetFaction, FPlayerJoinEvent.PlayerJoinReason.LEADER); FPlayerJoinEvent event = new FPlayerJoinEvent(FPlayers.getInstance().getByPlayer(context.player), targetFaction, FPlayerJoinEvent.PlayerJoinReason.LEADER);
Bukkit.getServer().getPluginManager().callEvent(event); Bukkit.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) { if (event.isCancelled()) {
return; return;
} }
} }
FPlayer admin = targetFaction.getFPlayerAdmin(); FPlayer admin = targetFaction.getFPlayerAdmin();
// if target player is currently admin, demote and replace him // if target player is currently admin, demote and replace him
if (fyou == admin) { if (fyou == admin) {
targetFaction.promoteNewLeader(); targetFaction.promoteNewLeader();
context.msg(TL.COMMAND_ADMIN_DEMOTES, fyou.describeTo(context.fPlayer, true)); context.msg(TL.COMMAND_ADMIN_DEMOTES, fyou.describeTo(context.fPlayer, true));
fyou.msg(TL.COMMAND_ADMIN_DEMOTED, context.player == null ? TL.GENERIC_SERVERADMIN.toString() : context.fPlayer.describeTo(fyou, true)); fyou.msg(TL.COMMAND_ADMIN_DEMOTED, context.player == null ? TL.GENERIC_SERVERADMIN.toString() : context.fPlayer.describeTo(fyou, true));
return; return;
} }
// promote target player, and demote existing admin if one exists // promote target player, and demote existing admin if one exists
if (admin != null) { if (admin != null) {
admin.setRole(Role.COLEADER); admin.setRole(Role.COLEADER);
} }
fyou.setRole(Role.LEADER); fyou.setRole(Role.LEADER);
context.msg(TL.COMMAND_ADMIN_PROMOTES, fyou.describeTo(context.fPlayer, true)); context.msg(TL.COMMAND_ADMIN_PROMOTES, fyou.describeTo(context.fPlayer, true));
// Inform all players // Inform all players
for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers()) { for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers()) {
fplayer.msg(TL.COMMAND_ADMIN_PROMOTED, context.player == null ? TL.GENERIC_SERVERADMIN.toString() : context.fPlayer.describeTo(fplayer, true), fyou.describeTo(fplayer), targetFaction.describeTo(fplayer)); fplayer.msg(TL.COMMAND_ADMIN_PROMOTED, context.player == null ? TL.GENERIC_SERVERADMIN.toString() : context.fPlayer.describeTo(fplayer, true), fyou.describeTo(fplayer), targetFaction.describeTo(fplayer));
} }
} }
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_ADMIN_DESCRIPTION; return TL.COMMAND_ADMIN_DESCRIPTION;
} }
} }

View File

@ -12,46 +12,46 @@ import org.bukkit.entity.Player;
public class CmdAnnounce extends FCommand { public class CmdAnnounce extends FCommand {
public CmdAnnounce() { public CmdAnnounce() {
super(); super();
this.aliases.add("ann"); this.aliases.add("ann");
this.aliases.add("announce"); this.aliases.add("announce");
this.requiredArgs.add("message"); this.requiredArgs.add("message");
this.requirements = new CommandRequirements.Builder(Permission.ANNOUNCE) this.requirements = new CommandRequirements.Builder(Permission.ANNOUNCE)
.playerOnly() .playerOnly()
.memberOnly() .memberOnly()
.brigadier(AnnounceBrigadier.class) .brigadier(AnnounceBrigadier.class)
.noErrorOnManyArgs() .noErrorOnManyArgs()
.build(); .build();
} }
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
String prefix = ChatColor.GREEN + context.faction.getTag() + ChatColor.YELLOW + " [" + ChatColor.GRAY + context.player.getName() + ChatColor.YELLOW + "] " + ChatColor.RESET; String prefix = ChatColor.GREEN + context.faction.getTag() + ChatColor.YELLOW + " [" + ChatColor.GRAY + context.player.getName() + ChatColor.YELLOW + "] " + ChatColor.RESET;
String message = StringUtils.join(context.args, " "); String message = StringUtils.join(context.args, " ");
for (Player player : context.faction.getOnlinePlayers()) { for (Player player : context.faction.getOnlinePlayers()) {
player.sendMessage(prefix + message); player.sendMessage(prefix + message);
} }
// Add for offline players. // Add for offline players.
for (FPlayer fp : context.faction.getFPlayersWhereOnline(false)) { for (FPlayer fp : context.faction.getFPlayersWhereOnline(false)) {
context.faction.addAnnouncement(fp, prefix + message); context.faction.addAnnouncement(fp, prefix + message);
} }
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_ANNOUNCE_DESCRIPTION; return TL.COMMAND_ANNOUNCE_DESCRIPTION;
} }
protected class AnnounceBrigadier implements BrigadierProvider { protected class AnnounceBrigadier implements BrigadierProvider {
@Override @Override
public ArgumentBuilder<Object, ?> get(ArgumentBuilder<Object, ?> parent) { public ArgumentBuilder<Object, ?> get(ArgumentBuilder<Object, ?> parent) {
return parent.then(RequiredArgumentBuilder.argument("message", StringArgumentType.greedyString())); return parent.then(RequiredArgumentBuilder.argument("message", StringArgumentType.greedyString()));
} }
} }
} }

View File

@ -8,37 +8,37 @@ import java.util.ArrayList;
public class CmdAutoHelp extends FCommand { public class CmdAutoHelp extends FCommand {
public CmdAutoHelp() { public CmdAutoHelp() {
this.aliases.add("?"); this.aliases.add("?");
this.aliases.add("h"); this.aliases.add("h");
this.aliases.add("help"); this.aliases.add("help");
this.setHelpShort(""); this.setHelpShort("");
this.optionalArgs.put("page", "1"); this.optionalArgs.put("page", "1");
} }
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
if (context.commandChain.size() == 0) { if (context.commandChain.size() == 0) {
return; return;
} }
FCommand pcmd = context.commandChain.get(context.commandChain.size() - 1); FCommand pcmd = context.commandChain.get(context.commandChain.size() - 1);
ArrayList<String> lines = new ArrayList<>(pcmd.helpLong); ArrayList<String> lines = new ArrayList<>(pcmd.helpLong);
for (FCommand scmd : pcmd.subCommands) { for (FCommand scmd : pcmd.subCommands) {
if (scmd.visibility == CommandVisibility.VISIBLE) { if (scmd.visibility == CommandVisibility.VISIBLE) {
lines.add(scmd.getUseageTemplate(context, true)); lines.add(scmd.getUseageTemplate(context, true));
} }
// TODO deal with other visibilities // TODO deal with other visibilities
} }
context.sendMessage(FactionsPlugin.getInstance().txt.getPage(lines, context.argAsInt(0, 1), TL.COMMAND_AUTOHELP_HELPFOR.toString() + pcmd.aliases.get(0) + "\"")); context.sendMessage(FactionsPlugin.getInstance().txt.getPage(lines, context.argAsInt(0, 1), TL.COMMAND_AUTOHELP_HELPFOR.toString() + pcmd.aliases.get(0) + "\""));
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_HELP_DESCRIPTION; return TL.COMMAND_HELP_DESCRIPTION;
} }
} }

View File

@ -13,73 +13,73 @@ import java.util.logging.Level;
public class CmdBan extends FCommand { public class CmdBan extends FCommand {
public CmdBan() { public CmdBan() {
super(); super();
this.aliases.add("ban"); this.aliases.add("ban");
this.requiredArgs.add("target"); this.requiredArgs.add("target");
this.requirements = new CommandRequirements.Builder(Permission.BAN) this.requirements = new CommandRequirements.Builder(Permission.BAN)
.playerOnly() .playerOnly()
.withAction(PermissableAction.BAN) .withAction(PermissableAction.BAN)
.build(); .build();
} }
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
// Good on permission checks. Now lets just ban the player. // Good on permission checks. Now lets just ban the player.
FPlayer target = context.argAsFPlayer(0); FPlayer target = context.argAsFPlayer(0);
if (target == null) { if (target == null) {
return; // the above method sends a message if fails to find someone. return; // the above method sends a message if fails to find someone.
} }
if (context.fPlayer == target) { if (context.fPlayer == target) {
// You may not ban yourself // You may not ban yourself
context.msg(TL.COMMAND_BAN_SELF); context.msg(TL.COMMAND_BAN_SELF);
return; return;
} else if (target.getFaction() == context.faction && target.getRole().value >= context.fPlayer.getRole().value) { } else if (target.getFaction() == context.faction && target.getRole().value >= context.fPlayer.getRole().value) {
// You may not ban someone that has same or higher faction rank // You may not ban someone that has same or higher faction rank
context.msg(TL.COMMAND_BAN_INSUFFICIENTRANK, target.getName()); context.msg(TL.COMMAND_BAN_INSUFFICIENTRANK, target.getName());
return; return;
} }
for (BanInfo banInfo : context.faction.getBannedPlayers()) { for (BanInfo banInfo : context.faction.getBannedPlayers()) {
if (banInfo.getBanned().equals(target.getId())) { if (banInfo.getBanned().equals(target.getId())) {
context.msg(TL.COMMAND_BAN_ALREADYBANNED); context.msg(TL.COMMAND_BAN_ALREADYBANNED);
return; return;
} }
} }
// Ban the user. // Ban the user.
context.faction.ban(target, context.fPlayer); context.faction.ban(target, context.fPlayer);
context.faction.deinvite(target); // can't hurt context.faction.deinvite(target); // can't hurt
// If in same Faction, lets make sure to kick them and throw an event. // If in same Faction, lets make sure to kick them and throw an event.
if (target.getFaction() == context.faction) { if (target.getFaction() == context.faction) {
FPlayerLeaveEvent event = new FPlayerLeaveEvent(target, context.faction, FPlayerLeaveEvent.PlayerLeaveReason.BANNED); FPlayerLeaveEvent event = new FPlayerLeaveEvent(target, context.faction, FPlayerLeaveEvent.PlayerLeaveReason.BANNED);
Bukkit.getServer().getPluginManager().callEvent(event); Bukkit.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) { if (event.isCancelled()) {
// if someone cancels a ban, we'll get people complaining here. So lets log it. // if someone cancels a ban, we'll get people complaining here. So lets log it.
FactionsPlugin.getInstance().log(Level.WARNING, "Attempted to ban {0} but someone cancelled the kick event. This isn't good.", target.getName()); FactionsPlugin.getInstance().log(Level.WARNING, "Attempted to ban {0} but someone cancelled the kick event. This isn't good.", target.getName());
return; return;
} }
// Didn't get cancelled so remove them and reset their invite. // Didn't get cancelled so remove them and reset their invite.
context.faction.removeFPlayer(target); context.faction.removeFPlayer(target);
target.resetFactionData(); target.resetFactionData();
} }
// Lets inform the people! // Lets inform the people!
target.msg(TL.COMMAND_BAN_TARGET, context.faction.getTag(target.getFaction())); target.msg(TL.COMMAND_BAN_TARGET, context.faction.getTag(target.getFaction()));
context.faction.msg(TL.COMMAND_BAN_BANNED, context.fPlayer.getName(), target.getName()); context.faction.msg(TL.COMMAND_BAN_BANNED, context.fPlayer.getName(), target.getName());
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_BAN_DESCRIPTION; return TL.COMMAND_BAN_DESCRIPTION;
} }
} }

View File

@ -13,57 +13,57 @@ import java.util.List;
public class CmdBanlist extends FCommand { public class CmdBanlist extends FCommand {
public CmdBanlist() { public CmdBanlist() {
super(); super();
this.aliases.add("banlist"); this.aliases.add("banlist");
this.aliases.add("bans"); this.aliases.add("bans");
this.aliases.add("banl"); this.aliases.add("banl");
this.optionalArgs.put("faction", "faction"); this.optionalArgs.put("faction", "faction");
this.requirements = new CommandRequirements.Builder(Permission.BAN) this.requirements = new CommandRequirements.Builder(Permission.BAN)
.playerOnly() .playerOnly()
.memberOnly() .memberOnly()
.build(); .build();
} }
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
Faction target = context.faction; Faction target = context.faction;
if (!context.args.isEmpty()) { if (!context.args.isEmpty()) {
target = context.argAsFaction(0); target = context.argAsFaction(0);
} }
if (target == Factions.getInstance().getWilderness()) { if (target == Factions.getInstance().getWilderness()) {
context.sender.sendMessage(TL.COMMAND_BANLIST_NOFACTION.toString()); context.sender.sendMessage(TL.COMMAND_BANLIST_NOFACTION.toString());
return; return;
} }
if (target == null) { if (target == null) {
context.sender.sendMessage(TL.COMMAND_BANLIST_INVALID.format(context.argAsString(0))); context.sender.sendMessage(TL.COMMAND_BANLIST_INVALID.format(context.argAsString(0)));
return; return;
} }
List<String> lines = new ArrayList<>(); List<String> lines = new ArrayList<>();
lines.add(TL.COMMAND_BANLIST_HEADER.format(target.getBannedPlayers().size(), target.getTag(context.faction))); lines.add(TL.COMMAND_BANLIST_HEADER.format(target.getBannedPlayers().size(), target.getTag(context.faction)));
int i = 1; int i = 1;
for (BanInfo info : target.getBannedPlayers()) { for (BanInfo info : target.getBannedPlayers()) {
FPlayer banned = FPlayers.getInstance().getById(info.getBanned()); FPlayer banned = FPlayers.getInstance().getById(info.getBanned());
FPlayer banner = FPlayers.getInstance().getById(info.getBanner()); FPlayer banner = FPlayers.getInstance().getById(info.getBanner());
String timestamp = TL.sdf.format(info.getTime()); String timestamp = TL.sdf.format(info.getTime());
lines.add(TL.COMMAND_BANLIST_ENTRY.format(i, banned.getName(), banner.getName(), timestamp)); lines.add(TL.COMMAND_BANLIST_ENTRY.format(i, banned.getName(), banner.getName(), timestamp));
i++; i++;
} }
for (String s : lines) { for (String s : lines) {
context.fPlayer.getPlayer().sendMessage(s); context.fPlayer.getPlayer().sendMessage(s);
} }
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_BANLIST_DESCRIPTION; return TL.COMMAND_BANLIST_DESCRIPTION;
} }
} }

View File

@ -13,103 +13,103 @@ import org.bukkit.inventory.PlayerInventory;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;
public class CmdBanner extends FCommand { public class CmdBanner extends FCommand {
public CmdBanner() { public CmdBanner() {
this.aliases.add("banner"); this.aliases.add("banner");
this.aliases.add("warbanner"); this.aliases.add("warbanner");
this.requirements = new CommandRequirements.Builder(Permission.BANNER).playerOnly().memberOnly().build(); this.requirements = new CommandRequirements.Builder(Permission.BANNER).playerOnly().memberOnly().build();
} }
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
if (!FactionsPlugin.getInstance().getConfig().getBoolean("fbanners.Enabled")) { if (!FactionsPlugin.getInstance().getConfig().getBoolean("fbanners.Enabled")) {
context.msg(TL.COMMAND_BANNER_DISABLED); context.msg(TL.COMMAND_BANNER_DISABLED);
return; return;
} }
if (context.faction.getBanner() == null) { if (context.faction.getBanner() == null) {
context.msg(TL.COMMAND_BANNER_NOBANNER); context.msg(TL.COMMAND_BANNER_NOBANNER);
return; return;
} }
if (!context.fPlayer.hasMoney(FactionsPlugin.getInstance().getConfig().getInt("fbanners.Banner-Cost", 5000))) { if (!context.fPlayer.hasMoney(FactionsPlugin.getInstance().getConfig().getInt("fbanners.Banner-Cost", 5000))) {
context.msg(TL.COMMAND_BANNER_NOTENOUGHMONEY); context.msg(TL.COMMAND_BANNER_NOTENOUGHMONEY);
return; return;
} }
this.takeMoney(context.fPlayer, FactionsPlugin.getInstance().getConfig().getInt("fbanners.Banner-Cost", 5000)); this.takeMoney(context.fPlayer, FactionsPlugin.getInstance().getConfig().getInt("fbanners.Banner-Cost", 5000));
this.takeMoney(context.fPlayer, FactionsPlugin.getInstance().getConfig().getInt("fbanners.Banner-Cost", 5000)); this.takeMoney(context.fPlayer, FactionsPlugin.getInstance().getConfig().getInt("fbanners.Banner-Cost", 5000));
ItemStack warBanner = context.fPlayer.getFaction().getBanner(); ItemStack warBanner = context.fPlayer.getFaction().getBanner();
ItemMeta warmeta = warBanner.getItemMeta(); ItemMeta warmeta = warBanner.getItemMeta();
warmeta.setDisplayName(FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fbanners.Item.Name"))); warmeta.setDisplayName(FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fbanners.Item.Name")));
warmeta.setLore(FactionsPlugin.getInstance().colorList(FactionsPlugin.getInstance().getConfig().getStringList("fbanners.Item.Lore"))); warmeta.setLore(FactionsPlugin.getInstance().colorList(FactionsPlugin.getInstance().getConfig().getStringList("fbanners.Item.Lore")));
warBanner.setItemMeta(warmeta); warBanner.setItemMeta(warmeta);
context.msg(TL.COMMAND_BANNER_SUCCESS); context.msg(TL.COMMAND_BANNER_SUCCESS);
warBanner.setAmount(1); warBanner.setAmount(1);
context.player.getInventory().addItem(warBanner); context.player.getInventory().addItem(warBanner);
} }
public boolean hasMoney(FPlayer fme, int amt) { public boolean hasMoney(FPlayer fme, int amt) {
Economy econ = FactionsPlugin.getInstance().getEcon(); Economy econ = FactionsPlugin.getInstance().getEcon();
if (econ.getBalance(fme.getPlayer()) >= amt) { if (econ.getBalance(fme.getPlayer()) >= amt) {
return true; return true;
} }
fme.msg(TL.COMMAND_BANNER_NOTENOUGHMONEY); fme.msg(TL.COMMAND_BANNER_NOTENOUGHMONEY);
return false; return false;
} }
public void takeMoney(FPlayer fme, int amt) { public void takeMoney(FPlayer fme, int amt) {
if (this.hasMoney(fme, amt)) { if (this.hasMoney(fme, amt)) {
Economy econ = FactionsPlugin.getInstance().getEcon(); Economy econ = FactionsPlugin.getInstance().getEcon();
econ.withdrawPlayer(fme.getPlayer(), (double) amt); econ.withdrawPlayer(fme.getPlayer(), (double) amt);
fme.sendMessage(TL.COMMAND_BANNER_MONEYTAKE.toString().replace("{amount}", amt + "")); fme.sendMessage(TL.COMMAND_BANNER_MONEYTAKE.toString().replace("{amount}", amt + ""));
} }
} }
public boolean inventoryContains(Inventory inventory, ItemStack item) { public boolean inventoryContains(Inventory inventory, ItemStack item) {
int count = 0; int count = 0;
ItemStack[] items = inventory.getContents(); ItemStack[] items = inventory.getContents();
for (ItemStack item1 : items) { for (ItemStack item1 : items) {
if (item1 != null && item1.getType() == item.getType() && item1.getDurability() == item.getDurability()) { if (item1 != null && item1.getType() == item.getType() && item1.getDurability() == item.getDurability()) {
count += item1.getAmount(); count += item1.getAmount();
} }
if (count >= item.getAmount()) { if (count >= item.getAmount()) {
return true; return true;
} }
} }
return false; return false;
} }
public void removeFromInventory(Inventory inventory, ItemStack item) { public void removeFromInventory(Inventory inventory, ItemStack item) {
int amt = item.getAmount(); int amt = item.getAmount();
ItemStack[] items = inventory.getContents(); ItemStack[] items = inventory.getContents();
for (int i = 0; i < items.length; ++i) { for (int i = 0; i < items.length; ++i) {
if (items[i] != null && items[i].getType() == item.getType() && items[i].getDurability() == item.getDurability()) { if (items[i] != null && items[i].getType() == item.getType() && items[i].getDurability() == item.getDurability()) {
if (items[i].getAmount() > amt) { if (items[i].getAmount() > amt) {
items[i].setAmount(items[i].getAmount() - amt); items[i].setAmount(items[i].getAmount() - amt);
break; break;
} }
if (items[i].getAmount() == amt) { if (items[i].getAmount() == amt) {
items[i] = null;
break;
}
amt -= items[i].getAmount();
items[i] = null; items[i] = null;
} break;
} }
inventory.setContents(items); amt -= items[i].getAmount();
} items[i] = null;
}
}
inventory.setContents(items);
}
public int getEmptySlots(Player p) { public int getEmptySlots(Player p) {
PlayerInventory inventory = p.getInventory(); PlayerInventory inventory = p.getInventory();
ItemStack[] cont = inventory.getContents(); ItemStack[] cont = inventory.getContents();
int i = 0; int i = 0;
for (ItemStack item : cont) { for (ItemStack item : cont) {
if (item != null && item.getType() != Material.AIR) { if (item != null && item.getType() != Material.AIR) {
++i; ++i;
} }
} }
return 36 - i; return 36 - i;
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_BANNER_DESCRIPTION; return TL.COMMAND_BANNER_DESCRIPTION;
} }
} }

View File

@ -6,42 +6,42 @@ import com.massivecraft.factions.zcore.util.TL;
public class CmdBoom extends FCommand { public class CmdBoom extends FCommand {
public CmdBoom() { public CmdBoom() {
super(); super();
this.aliases.add("noboom"); this.aliases.add("noboom");
this.aliases.add("explosions"); this.aliases.add("explosions");
this.aliases.add("toggleexplosions"); this.aliases.add("toggleexplosions");
//this.requiredArgs.add(""); //this.requiredArgs.add("");
this.optionalArgs.put("on/off", "flip"); this.optionalArgs.put("on/off", "flip");
this.requirements = new CommandRequirements.Builder(Permission.NO_BOOM) this.requirements = new CommandRequirements.Builder(Permission.NO_BOOM)
.playerOnly() .playerOnly()
.build(); .build();
} }
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
if (!context.faction.isPeaceful()) { if (!context.faction.isPeaceful()) {
context.msg(TL.COMMAND_BOOM_PEACEFULONLY); context.msg(TL.COMMAND_BOOM_PEACEFULONLY);
return; return;
} }
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
if (!context.payForCommand(Conf.econCostNoBoom, TL.COMMAND_BOOM_TOTOGGLE, TL.COMMAND_BOOM_FORTOGGLE)) { if (!context.payForCommand(Conf.econCostNoBoom, TL.COMMAND_BOOM_TOTOGGLE, TL.COMMAND_BOOM_FORTOGGLE)) {
return; return;
} }
context.faction.setPeacefulExplosionsEnabled(context.argAsBool(0, !context.faction.getPeacefulExplosionsEnabled())); context.faction.setPeacefulExplosionsEnabled(context.argAsBool(0, !context.faction.getPeacefulExplosionsEnabled()));
String enabled = context.faction.noExplosionsInTerritory() ? TL.GENERIC_DISABLED.toString() : TL.GENERIC_ENABLED.toString(); String enabled = context.faction.noExplosionsInTerritory() ? TL.GENERIC_DISABLED.toString() : TL.GENERIC_ENABLED.toString();
// Inform // Inform
context.faction.msg(TL.COMMAND_BOOM_ENABLED, context.fPlayer.describeTo(context.faction), enabled); context.faction.msg(TL.COMMAND_BOOM_ENABLED, context.fPlayer.describeTo(context.faction), enabled);
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_BOOM_DESCRIPTION; return TL.COMMAND_BOOM_DESCRIPTION;
} }
} }

View File

@ -6,34 +6,34 @@ import com.massivecraft.factions.zcore.util.TL;
public class CmdBypass extends FCommand { public class CmdBypass extends FCommand {
public CmdBypass() { public CmdBypass() {
super(); super();
this.aliases.add("bypass"); this.aliases.add("bypass");
//this.requiredArgs.add(""); //this.requiredArgs.add("");
this.optionalArgs.put("on/off", "flip"); this.optionalArgs.put("on/off", "flip");
this.requirements = new CommandRequirements.Builder(Permission.BYPASS) this.requirements = new CommandRequirements.Builder(Permission.BYPASS)
.playerOnly() .playerOnly()
.build(); .build();
} }
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
context.fPlayer.setIsAdminBypassing(context.argAsBool(0, !context.fPlayer.isAdminBypassing())); context.fPlayer.setIsAdminBypassing(context.argAsBool(0, !context.fPlayer.isAdminBypassing()));
// TODO: Move this to a transient field in the model?? // TODO: Move this to a transient field in the model??
if (context.fPlayer.isAdminBypassing()) { if (context.fPlayer.isAdminBypassing()) {
context.fPlayer.msg(TL.COMMAND_BYPASS_ENABLE.toString()); context.fPlayer.msg(TL.COMMAND_BYPASS_ENABLE.toString());
FactionsPlugin.getInstance().log(context.fPlayer.getName() + TL.COMMAND_BYPASS_ENABLELOG.toString()); FactionsPlugin.getInstance().log(context.fPlayer.getName() + TL.COMMAND_BYPASS_ENABLELOG.toString());
} else { } else {
context.fPlayer.msg(TL.COMMAND_BYPASS_DISABLE.toString()); context.fPlayer.msg(TL.COMMAND_BYPASS_DISABLE.toString());
FactionsPlugin.getInstance().log(context.fPlayer.getName() + TL.COMMAND_BYPASS_DISABLELOG.toString()); FactionsPlugin.getInstance().log(context.fPlayer.getName() + TL.COMMAND_BYPASS_DISABLELOG.toString());
} }
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_BYPASS_DESCRIPTION; return TL.COMMAND_BYPASS_DESCRIPTION;
} }
} }

View File

@ -10,88 +10,88 @@ import com.mojang.brigadier.builder.LiteralArgumentBuilder;
public class CmdChat extends FCommand { public class CmdChat extends FCommand {
public CmdChat() { public CmdChat() {
super(); super();
this.aliases.add("c"); this.aliases.add("c");
this.aliases.add("chat"); this.aliases.add("chat");
//this.requiredArgs.add(""); //this.requiredArgs.add("");
this.optionalArgs.put("mode", "next"); this.optionalArgs.put("mode", "next");
this.requirements = new CommandRequirements.Builder(Permission.CHAT) this.requirements = new CommandRequirements.Builder(Permission.CHAT)
.playerOnly() .playerOnly()
.memberOnly() .memberOnly()
.brigadier(ChatBrigadier.class) .brigadier(ChatBrigadier.class)
.build(); .build();
} }
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
if (!Conf.factionOnlyChat) { if (!Conf.factionOnlyChat) {
context.msg(TL.COMMAND_CHAT_DISABLED.toString()); context.msg(TL.COMMAND_CHAT_DISABLED.toString());
return; return;
} }
String modeString = context.argAsString(0); String modeString = context.argAsString(0);
ChatMode modeTarget = context.fPlayer.getChatMode().getNext(); ChatMode modeTarget = context.fPlayer.getChatMode().getNext();
if (modeString != null) { if (modeString != null) {
modeString = modeString.toLowerCase(); modeString = modeString.toLowerCase();
// Only allow Mods and higher rank to switch to this channel. // Only allow Mods and higher rank to switch to this channel.
if (modeString.startsWith("m")) { if (modeString.startsWith("m")) {
if (!context.fPlayer.getRole().isAtLeast(Role.MODERATOR)) { if (!context.fPlayer.getRole().isAtLeast(Role.MODERATOR)) {
context.msg(TL.COMMAND_CHAT_MOD_ONLY); context.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 {
context.msg(TL.COMMAND_CHAT_INVALIDMODE);
return; 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 {
context.msg(TL.COMMAND_CHAT_INVALIDMODE);
return;
}
}
context.fPlayer.setChatMode(modeTarget); context.fPlayer.setChatMode(modeTarget);
switch (context.fPlayer.getChatMode()) { switch (context.fPlayer.getChatMode()) {
case MOD: case MOD:
context.msg(TL.COMMAND_CHAT_MODE_MOD); context.msg(TL.COMMAND_CHAT_MODE_MOD);
break; break;
case PUBLIC: case PUBLIC:
context.msg(TL.COMMAND_CHAT_MODE_PUBLIC); context.msg(TL.COMMAND_CHAT_MODE_PUBLIC);
break; break;
case ALLIANCE: case ALLIANCE:
context.msg(TL.COMMAND_CHAT_MODE_ALLIANCE); context.msg(TL.COMMAND_CHAT_MODE_ALLIANCE);
break; break;
case TRUCE: case TRUCE:
context.msg(TL.COMMAND_CHAT_MODE_TRUCE); context.msg(TL.COMMAND_CHAT_MODE_TRUCE);
break; break;
default: default:
context.msg(TL.COMMAND_CHAT_MODE_FACTION); context.msg(TL.COMMAND_CHAT_MODE_FACTION);
break; break;
} }
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_CHAT_DESCRIPTION; return TL.COMMAND_CHAT_DESCRIPTION;
} }
protected class ChatBrigadier implements BrigadierProvider { protected class ChatBrigadier implements BrigadierProvider {
@Override @Override
public ArgumentBuilder<Object, ?> get(ArgumentBuilder<Object, ?> parent) { public ArgumentBuilder<Object, ?> get(ArgumentBuilder<Object, ?> parent) {
return parent.then(LiteralArgumentBuilder.literal("public")) return parent.then(LiteralArgumentBuilder.literal("public"))
.then(LiteralArgumentBuilder.literal("mod")) .then(LiteralArgumentBuilder.literal("mod"))
.then(LiteralArgumentBuilder.literal("alliance")) .then(LiteralArgumentBuilder.literal("alliance"))
.then(LiteralArgumentBuilder.literal("faction")) .then(LiteralArgumentBuilder.literal("faction"))
.then(LiteralArgumentBuilder.literal("truce")); .then(LiteralArgumentBuilder.literal("truce"));
} }
} }
} }

View File

@ -6,32 +6,32 @@ import com.massivecraft.factions.zcore.util.TL;
public class CmdChatSpy extends FCommand { public class CmdChatSpy extends FCommand {
public CmdChatSpy() { public CmdChatSpy() {
super(); super();
this.aliases.add("chatspy"); this.aliases.add("chatspy");
this.optionalArgs.put("on/off", "flip"); this.optionalArgs.put("on/off", "flip");
this.requirements = new CommandRequirements.Builder(Permission.CHATSPY) this.requirements = new CommandRequirements.Builder(Permission.CHATSPY)
.playerOnly() .playerOnly()
.build(); .build();
} }
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
context.fPlayer.setSpyingChat(context.argAsBool(0, !context.fPlayer.isSpyingChat())); context.fPlayer.setSpyingChat(context.argAsBool(0, !context.fPlayer.isSpyingChat()));
if (context.fPlayer.isSpyingChat()) { if (context.fPlayer.isSpyingChat()) {
context.msg(TL.COMMAND_CHATSPY_ENABLE); context.msg(TL.COMMAND_CHATSPY_ENABLE);
FactionsPlugin.getInstance().log(context.fPlayer.getName() + TL.COMMAND_CHATSPY_ENABLELOG.toString()); FactionsPlugin.getInstance().log(context.fPlayer.getName() + TL.COMMAND_CHATSPY_ENABLELOG.toString());
} else { } else {
context.msg(TL.COMMAND_CHATSPY_DISABLE); context.msg(TL.COMMAND_CHATSPY_DISABLE);
FactionsPlugin.getInstance().log(context.fPlayer.getName() + TL.COMMAND_CHATSPY_DISABLELOG.toString()); FactionsPlugin.getInstance().log(context.fPlayer.getName() + TL.COMMAND_CHATSPY_DISABLELOG.toString());
} }
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_CHATSPY_DESCRIPTION; return TL.COMMAND_CHATSPY_DESCRIPTION;
} }
} }

View File

@ -6,60 +6,60 @@ import com.massivecraft.factions.util.WarmUpUtil;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
public class CmdCheckpoint extends FCommand { public class CmdCheckpoint extends FCommand {
public CmdCheckpoint() { public CmdCheckpoint() {
super(); super();
this.aliases.add("checkp"); this.aliases.add("checkp");
this.aliases.add("checkpoint"); this.aliases.add("checkpoint");
this.aliases.add("cpoint"); this.aliases.add("cpoint");
this.optionalArgs.put("set", ""); this.optionalArgs.put("set", "");
this.requirements = new CommandRequirements.Builder(Permission.CHECKPOINT) this.requirements = new CommandRequirements.Builder(Permission.CHECKPOINT)
.playerOnly() .playerOnly()
.memberOnly() .memberOnly()
.build(); .build();
} }
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
if (!FactionsPlugin.getInstance().getConfig().getBoolean("checkpoints.Enabled")) { if (!FactionsPlugin.getInstance().getConfig().getBoolean("checkpoints.Enabled")) {
context.msg(TL.COMMAND_CHECKPOINT_DISABLED); context.msg(TL.COMMAND_CHECKPOINT_DISABLED);
return; return;
} }
if (context.args.size() == 1) { if (context.args.size() == 1) {
FLocation myLocation = new FLocation(context.player.getLocation()); FLocation myLocation = new FLocation(context.player.getLocation());
Faction myLocFaction = Board.getInstance().getFactionAt(myLocation); Faction myLocFaction = Board.getInstance().getFactionAt(myLocation);
if (myLocFaction == Factions.getInstance().getWilderness() || myLocFaction == context.faction) { if (myLocFaction == Factions.getInstance().getWilderness() || myLocFaction == context.faction) {
context.faction.setCheckpoint(context.player.getLocation()); context.faction.setCheckpoint(context.player.getLocation());
context.msg(TL.COMMAND_CHECKPOINT_SET); context.msg(TL.COMMAND_CHECKPOINT_SET);
return; return;
} else { } else {
context.msg(TL.COMMAND_CHECKPOINT_INVALIDLOCATION); context.msg(TL.COMMAND_CHECKPOINT_INVALIDLOCATION);
return; return;
} }
} }
if (context.faction.getCheckpoint() == null) { if (context.faction.getCheckpoint() == null) {
context.msg(TL.COMMAND_CHECKPOINT_NOT_SET); context.msg(TL.COMMAND_CHECKPOINT_NOT_SET);
return; return;
} }
FLocation checkLocation = new FLocation(context.faction.getCheckpoint()); FLocation checkLocation = new FLocation(context.faction.getCheckpoint());
Faction checkfaction = Board.getInstance().getFactionAt(checkLocation); Faction checkfaction = Board.getInstance().getFactionAt(checkLocation);
if (checkfaction.getId().equals(Factions.getInstance().getWilderness().getId()) || checkfaction.getId().equals(context.faction.getId())) { if (checkfaction.getId().equals(Factions.getInstance().getWilderness().getId()) || checkfaction.getId().equals(context.faction.getId())) {
context.msg(TL.COMMAND_CHECKPOINT_GO); context.msg(TL.COMMAND_CHECKPOINT_GO);
context.doWarmUp(WarmUpUtil.Warmup.CHECKPOINT, TL.WARMUPS_NOTIFY_TELEPORT, "Checkpoint", () -> { context.doWarmUp(WarmUpUtil.Warmup.CHECKPOINT, TL.WARMUPS_NOTIFY_TELEPORT, "Checkpoint", () -> {
context.player.teleport(context.faction.getCheckpoint()); context.player.teleport(context.faction.getCheckpoint());
}, FactionsPlugin.getInstance().getConfig().getLong("warmups.f-checkpoint", 0)); }, FactionsPlugin.getInstance().getConfig().getLong("warmups.f-checkpoint", 0));
} else { } else {
context.msg(TL.COMMAND_CHECKPOINT_CLAIMED); context.msg(TL.COMMAND_CHECKPOINT_CLAIMED);
} }
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_CHECKPOINT_DESCRIPTION; return TL.COMMAND_CHECKPOINT_DESCRIPTION;
} }
} }

View File

@ -10,78 +10,78 @@ import mkremins.fanciful.FancyMessage;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
public class CmdColeader extends FCommand { public class CmdColeader extends FCommand {
public CmdColeader() { public CmdColeader() {
super(); super();
this.aliases.add("co"); this.aliases.add("co");
this.aliases.add("setcoleader"); this.aliases.add("setcoleader");
this.aliases.add("coleader"); this.aliases.add("coleader");
this.aliases.add("setco"); this.aliases.add("setco");
this.optionalArgs.put("player name", "name"); this.optionalArgs.put("player name", "name");
this.requirements = new CommandRequirements.Builder(Permission.COLEADER) this.requirements = new CommandRequirements.Builder(Permission.COLEADER)
.memberOnly() .memberOnly()
.withRole(Role.LEADER) .withRole(Role.LEADER)
.build(); .build();
} }
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
FPlayer you = context.argAsBestFPlayerMatch(0); FPlayer you = context.argAsBestFPlayerMatch(0);
if (you == null) { if (you == null) {
FancyMessage msg = new FancyMessage(TL.COMMAND_COLEADER_CANDIDATES.toString()).color(ChatColor.GOLD); FancyMessage msg = new FancyMessage(TL.COMMAND_COLEADER_CANDIDATES.toString()).color(ChatColor.GOLD);
for (FPlayer player : context.faction.getFPlayersWhereRole(Role.NORMAL)) { for (FPlayer player : context.faction.getFPlayersWhereRole(Role.NORMAL)) {
String s = player.getName(); String s = player.getName();
msg.then(s + " ").color(ChatColor.WHITE).tooltip(TL.COMMAND_MOD_CLICKTOPROMOTE.toString() + s).command("/" + Conf.baseCommandAliases.get(0) + " coleader " + s); msg.then(s + " ").color(ChatColor.WHITE).tooltip(TL.COMMAND_MOD_CLICKTOPROMOTE.toString() + s).command("/" + Conf.baseCommandAliases.get(0) + " coleader " + s);
} }
for (FPlayer player : context.faction.getFPlayersWhereRole(Role.MODERATOR)) { for (FPlayer player : context.faction.getFPlayersWhereRole(Role.MODERATOR)) {
String s = player.getName(); String s = player.getName();
msg.then(s + " ").color(ChatColor.WHITE).tooltip(TL.COMMAND_MOD_CLICKTOPROMOTE.toString() + s).command("/" + Conf.baseCommandAliases.get(0) + " coleader " + s); msg.then(s + " ").color(ChatColor.WHITE).tooltip(TL.COMMAND_MOD_CLICKTOPROMOTE.toString() + s).command("/" + Conf.baseCommandAliases.get(0) + " coleader " + s);
} }
context.sendFancyMessage(msg); context.sendFancyMessage(msg);
return; return;
} }
boolean permAny = Permission.COLEADER_ANY.has(context.sender, false); boolean permAny = Permission.COLEADER_ANY.has(context.sender, false);
Faction targetFaction = you.getFaction(); Faction targetFaction = you.getFaction();
if (targetFaction != context.faction && !permAny) { if (targetFaction != context.faction && !permAny) {
context.msg(TL.COMMAND_MOD_NOTMEMBER, you.describeTo(context.fPlayer, true)); context.msg(TL.COMMAND_MOD_NOTMEMBER, you.describeTo(context.fPlayer, true));
return; return;
} }
if (context.fPlayer != null && context.fPlayer.getRole() != Role.LEADER && !permAny) { if (context.fPlayer != null && context.fPlayer.getRole() != Role.LEADER && !permAny) {
context.msg(TL.COMMAND_COLEADER_NOTADMIN); context.msg(TL.COMMAND_COLEADER_NOTADMIN);
return; return;
} }
if (you == context.fPlayer && !permAny) { if (you == context.fPlayer && !permAny) {
context.msg(TL.COMMAND_COLEADER_SELF); context.msg(TL.COMMAND_COLEADER_SELF);
return; return;
} }
if (you.getRole() == Role.LEADER) { if (you.getRole() == Role.LEADER) {
context.msg(TL.COMMAND_COLEADER_TARGETISADMIN); context.msg(TL.COMMAND_COLEADER_TARGETISADMIN);
return; return;
} }
if (you.getRole() == Role.COLEADER) { if (you.getRole() == Role.COLEADER) {
// Revoke // Revoke
you.setRole(Role.MODERATOR); you.setRole(Role.MODERATOR);
targetFaction.msg(TL.COMMAND_COLEADER_REVOKED, you.describeTo(targetFaction, true)); targetFaction.msg(TL.COMMAND_COLEADER_REVOKED, you.describeTo(targetFaction, true));
context.msg(TL.COMMAND_COLEADER_REVOKES, you.describeTo(context.fPlayer, true)); context.msg(TL.COMMAND_COLEADER_REVOKES, you.describeTo(context.fPlayer, true));
} else { } else {
// Give // Give
you.setRole(Role.COLEADER); you.setRole(Role.COLEADER);
targetFaction.msg(TL.COMMAND_COLEADER_PROMOTED, you.describeTo(targetFaction, true)); targetFaction.msg(TL.COMMAND_COLEADER_PROMOTED, you.describeTo(targetFaction, true));
context.msg(TL.COMMAND_COLEADER_PROMOTES, you.describeTo(context.fPlayer, true)); context.msg(TL.COMMAND_COLEADER_PROMOTES, you.describeTo(context.fPlayer, true));
} }
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_COLEADER_DESCRIPTION; return TL.COMMAND_COLEADER_DESCRIPTION;
} }
} }

View File

@ -16,228 +16,228 @@ import java.util.Set;
public class CmdConfig extends FCommand { public class CmdConfig extends FCommand {
private static HashMap<String, String> properFieldNames = new HashMap<>(); private static HashMap<String, String> properFieldNames = new HashMap<>();
public CmdConfig() { public CmdConfig() {
super(); super();
this.aliases.add("config"); this.aliases.add("config");
this.requiredArgs.add("setting"); this.requiredArgs.add("setting");
this.requiredArgs.add("value"); this.requiredArgs.add("value");
this.requirements = new CommandRequirements.Builder(Permission.CONFIG) this.requirements = new CommandRequirements.Builder(Permission.CONFIG)
.noErrorOnManyArgs() .noErrorOnManyArgs()
.build(); .build();
} }
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
// store a lookup map of lowercase field names paired with proper capitalization field names // 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 // that way, if the person using this command messes up the capitalization, we can fix that
if (properFieldNames.isEmpty()) { if (properFieldNames.isEmpty()) {
Field[] fields = Conf.class.getDeclaredFields(); Field[] fields = Conf.class.getDeclaredFields();
for (Field field : fields) { for (Field field : fields) {
properFieldNames.put(field.getName().toLowerCase(), field.getName()); properFieldNames.put(field.getName().toLowerCase(), field.getName());
} }
} }
String field = context.argAsString(0).toLowerCase(); String field = context.argAsString(0).toLowerCase();
if (field.startsWith("\"") && field.endsWith("\"")) { if (field.startsWith("\"") && field.endsWith("\"")) {
field = field.substring(1, field.length() - 1); field = field.substring(1, field.length() - 1);
} }
String fieldName = properFieldNames.get(field); String fieldName = properFieldNames.get(field);
if (fieldName == null || fieldName.isEmpty()) { if (fieldName == null || fieldName.isEmpty()) {
context.msg(TL.COMMAND_CONFIG_NOEXIST, field); context.msg(TL.COMMAND_CONFIG_NOEXIST, field);
return; return;
} }
String success; String success;
StringBuilder value = new StringBuilder(context.args.get(1)); StringBuilder value = new StringBuilder(context.args.get(1));
for (int i = 2; i < context.args.size(); i++) { for (int i = 2; i < context.args.size(); i++) {
value.append(' ').append(context.args.get(i)); value.append(' ').append(context.args.get(i));
} }
try { try {
Field target = Conf.class.getField(fieldName); Field target = Conf.class.getField(fieldName);
// boolean // boolean
if (target.getType() == boolean.class) { if (target.getType() == boolean.class) {
boolean targetValue = context.strAsBool(value.toString()); boolean targetValue = context.strAsBool(value.toString());
target.setBoolean(null, targetValue); target.setBoolean(null, targetValue);
if (targetValue) { if (targetValue) {
success = "\"" + fieldName + TL.COMMAND_CONFIG_SET_TRUE.toString(); success = "\"" + fieldName + TL.COMMAND_CONFIG_SET_TRUE.toString();
} else { } else {
success = "\"" + fieldName + TL.COMMAND_CONFIG_SET_FALSE.toString(); success = "\"" + fieldName + TL.COMMAND_CONFIG_SET_FALSE.toString();
} }
} }
// int // int
else if (target.getType() == int.class) { 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) {
context.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) {
context.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) {
context.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) {
context.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 + "\".";
}
// ChatColor
else if (target.getType() == ChatColor.class) {
ChatColor newColor = null;
try {
newColor = ChatColor.valueOf(value.toString().toUpperCase());
} catch (IllegalArgumentException ex) {
}
if (newColor == null) {
context.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];
// not a Set, somehow, and that should be the only collection we're using in Conf.java
if (targSet.getRawType() != Set.class) {
context.sendMessage(TL.COMMAND_CONFIG_INVALID_COLLECTION.format(fieldName));
return;
}
// Set<Material>
else if (innerType == Material.class) {
Material newMat = null;
try { try {
int intVal = Integer.parseInt(value.toString()); newMat = Material.valueOf(value.toString().toUpperCase());
target.setInt(null, intVal);
success = "\"" + fieldName + TL.COMMAND_CONFIG_OPTIONSET.toString() + intVal + ".";
} catch (NumberFormatException ex) {
context.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) {
context.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) {
context.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) {
context.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 + "\".";
}
// ChatColor
else if (target.getType() == ChatColor.class) {
ChatColor newColor = null;
try {
newColor = ChatColor.valueOf(value.toString().toUpperCase());
} catch (IllegalArgumentException ex) { } catch (IllegalArgumentException ex) {
} }
if (newColor == null) { if (newMat == null) {
context.sendMessage(TL.COMMAND_CONFIG_INVALID_COLOUR.format(fieldName, value.toString().toUpperCase())); context.sendMessage(TL.COMMAND_CONFIG_INVALID_MATERIAL.format(fieldName, value.toString().toUpperCase()));
return; 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];
// not a Set, somehow, and that should be the only collection we're using in Conf.java
if (targSet.getRawType() != Set.class) {
context.sendMessage(TL.COMMAND_CONFIG_INVALID_COLLECTION.format(fieldName));
return;
} }
// Set<Material> @SuppressWarnings("unchecked") Set<Material> matSet = (Set<Material>) target.get(null);
else if (innerType == Material.class) {
Material newMat = null;
try {
newMat = Material.valueOf(value.toString().toUpperCase());
} catch (IllegalArgumentException ex) {
} // Material already present, so remove it
if (newMat == null) { if (matSet.contains(newMat)) {
context.sendMessage(TL.COMMAND_CONFIG_INVALID_MATERIAL.format(fieldName, value.toString().toUpperCase())); matSet.remove(newMat);
return; target.set(null, matSet);
} success = TL.COMMAND_CONFIG_MATERIAL_REMOVED.format(fieldName, value.toString().toUpperCase());
@SuppressWarnings("unchecked") Set<Material> matSet = (Set<Material>) 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 not present yet, add it
// Set<String>
else if (innerType == String.class) {
@SuppressWarnings("unchecked") Set<String> stringSet = (Set<String>) 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());
}
}
// Set of unknown type
else { else {
context.sendMessage(TL.COMMAND_CONFIG_INVALID_TYPESET.format(fieldName)); matSet.add(newMat);
return; target.set(null, matSet);
success = TL.COMMAND_CONFIG_MATERIAL_ADDED.format(fieldName, value.toString().toUpperCase());
} }
} }
// unknown type // Set<String>
else { else if (innerType == String.class) {
context.sendMessage(TL.COMMAND_CONFIG_ERROR_TYPE.format(fieldName, target.getClass().getName())); @SuppressWarnings("unchecked") Set<String> stringSet = (Set<String>) 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());
}
}
// Set of unknown type
else {
context.sendMessage(TL.COMMAND_CONFIG_INVALID_TYPESET.format(fieldName));
return; return;
} }
} catch (NoSuchFieldException ex) { }
context.sendMessage(TL.COMMAND_CONFIG_ERROR_MATCHING.format(fieldName));
return;
} catch (IllegalAccessException ex) {
context.sendMessage(TL.COMMAND_CONFIG_ERROR_SETTING.format(fieldName, value.toString()));
return;
}
if (!success.isEmpty()) { // unknown type
if (context.sender instanceof Player) { else {
context.sendMessage(success); context.sendMessage(TL.COMMAND_CONFIG_ERROR_TYPE.format(fieldName, target.getClass().getName()));
FactionsPlugin.getInstance().log(success + TL.COMMAND_CONFIG_LOG.format((Player) context.sender)); return;
} else // using FactionsPlugin.getInstance().log() instead of sendMessage if run from server console so that "[Factions v#.#.#]" is prepended in server log }
{ } catch (NoSuchFieldException ex) {
FactionsPlugin.getInstance().log(success); context.sendMessage(TL.COMMAND_CONFIG_ERROR_MATCHING.format(fieldName));
} return;
} } catch (IllegalAccessException ex) {
// save change to disk context.sendMessage(TL.COMMAND_CONFIG_ERROR_SETTING.format(fieldName, value.toString()));
Conf.save(); return;
} }
@Override if (!success.isEmpty()) {
public TL getUsageTranslation() { if (context.sender instanceof Player) {
return TL.COMMAND_CONFIG_DESCRIPTION; context.sendMessage(success);
} FactionsPlugin.getInstance().log(success + TL.COMMAND_CONFIG_LOG.format((Player) context.sender));
} else // using FactionsPlugin.getInstance().log() instead of sendMessage if run from server console so that "[Factions v#.#.#]" is prepended in server log
{
FactionsPlugin.getInstance().log(success);
}
}
// save change to disk
Conf.save();
}
@Override
public TL getUsageTranslation() {
return TL.COMMAND_CONFIG_DESCRIPTION;
}
} }

View File

@ -9,36 +9,36 @@ import org.bukkit.command.ConsoleCommandSender;
public class CmdConvert extends FCommand { public class CmdConvert extends FCommand {
public CmdConvert() { public CmdConvert() {
this.aliases.add("convert"); this.aliases.add("convert");
this.requiredArgs.add("[MYSQL|JSON]"); this.requiredArgs.add("[MYSQL|JSON]");
this.requirements = new CommandRequirements.Builder(Permission.CONVERT) this.requirements = new CommandRequirements.Builder(Permission.CONVERT)
.build(); .build();
} }
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
if (!(context.sender instanceof ConsoleCommandSender)) { if (!(context.sender instanceof ConsoleCommandSender)) {
context.sender.sendMessage(TL.GENERIC_CONSOLEONLY.toString()); context.sender.sendMessage(TL.GENERIC_CONSOLEONLY.toString());
} }
Backend nb = Backend.valueOf(context.argAsString(0).toUpperCase()); Backend nb = Backend.valueOf(context.argAsString(0).toUpperCase());
if (nb == Conf.backEnd) { if (nb == Conf.backEnd) {
context.sender.sendMessage(TL.COMMAND_CONVERT_BACKEND_RUNNING.toString()); context.sender.sendMessage(TL.COMMAND_CONVERT_BACKEND_RUNNING.toString());
return; return;
} }
if (nb == Backend.JSON) { if (nb == Backend.JSON) {
FactionsJSON.convertTo(); FactionsJSON.convertTo();
} else { } else {
context.sender.sendMessage(TL.COMMAND_CONVERT_BACKEND_INVALID.toString()); context.sender.sendMessage(TL.COMMAND_CONVERT_BACKEND_INVALID.toString());
return; return;
} }
Conf.backEnd = nb; Conf.backEnd = nb;
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_CONVERT_DESCRIPTION; return TL.COMMAND_CONVERT_DESCRIPTION;
} }
} }

View File

@ -7,31 +7,31 @@ import org.bukkit.Location;
public class CmdCoords extends FCommand { public class CmdCoords extends FCommand {
public CmdCoords() { public CmdCoords() {
super(); super();
this.aliases.add("coords"); this.aliases.add("coords");
this.aliases.add("coord"); this.aliases.add("coord");
this.requirements = new CommandRequirements.Builder(Permission.COORD) this.requirements = new CommandRequirements.Builder(Permission.COORD)
.playerOnly() .playerOnly()
.memberOnly() .memberOnly()
.build(); .build();
} }
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
Location location = context.player.getLocation(); Location location = context.player.getLocation();
String message = TL.COMMAND_COORDS_MESSAGE.toString().replace("{player}", context.player.getDisplayName()).replace("{x}", (int) location.getX() + "") String message = TL.COMMAND_COORDS_MESSAGE.toString().replace("{player}", context.player.getDisplayName()).replace("{x}", (int) location.getX() + "")
.replace("{y}", (int) location.getY() + "").replace("{z}", (int) location.getZ() + "").replace("{world}", location.getWorld().getName()); .replace("{y}", (int) location.getY() + "").replace("{z}", (int) location.getZ() + "").replace("{world}", location.getWorld().getName());
for (FPlayer fPlayer : context.faction.getFPlayers()) { for (FPlayer fPlayer : context.faction.getFPlayers()) {
fPlayer.sendMessage(message); fPlayer.sendMessage(message);
} }
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_COORDS_DESCRIPTION; return TL.COMMAND_COORDS_DESCRIPTION;
} }
} }

View File

@ -15,94 +15,94 @@ import java.util.ArrayList;
public class CmdCreate extends FCommand { public class CmdCreate extends FCommand {
public CmdCreate() { public CmdCreate() {
super(); super();
this.aliases.add("create"); this.aliases.add("create");
this.requiredArgs.add("faction tag"); this.requiredArgs.add("faction tag");
this.requirements = new CommandRequirements.Builder(Permission.CREATE) this.requirements = new CommandRequirements.Builder(Permission.CREATE)
.playerOnly() .playerOnly()
.build(); .build();
} }
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
String tag = context.argAsString(0); String tag = context.argAsString(0);
if (context.fPlayer.hasFaction()) { if (context.fPlayer.hasFaction()) {
context.msg(TL.COMMAND_CREATE_MUSTLEAVE); context.msg(TL.COMMAND_CREATE_MUSTLEAVE);
return; return;
} }
if (Factions.getInstance().isTagTaken(tag)) { if (Factions.getInstance().isTagTaken(tag)) {
context.msg(TL.COMMAND_CREATE_INUSE); context.msg(TL.COMMAND_CREATE_INUSE);
return; return;
} }
ArrayList<String> tagValidationErrors = MiscUtil.validateTag(tag); ArrayList<String> tagValidationErrors = MiscUtil.validateTag(tag);
if (tagValidationErrors.size() > 0) { if (tagValidationErrors.size() > 0) {
context.sendMessage(tagValidationErrors); context.sendMessage(tagValidationErrors);
return; 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 economy is enabled, they're not on the bypass list, and this command has a cost set, make sure they can pay
if (!context.canAffordCommand(Conf.econCostCreate, TL.COMMAND_CREATE_TOCREATE.toString())) { if (!context.canAffordCommand(Conf.econCostCreate, TL.COMMAND_CREATE_TOCREATE.toString())) {
return; return;
} }
// trigger the faction creation event (cancellable) // trigger the faction creation event (cancellable)
FactionCreateEvent createEvent = new FactionCreateEvent(context.player, tag); FactionCreateEvent createEvent = new FactionCreateEvent(context.player, tag);
Bukkit.getServer().getPluginManager().callEvent(createEvent); Bukkit.getServer().getPluginManager().callEvent(createEvent);
if (createEvent.isCancelled()) { if (createEvent.isCancelled()) {
return; return;
} }
// then make 'em pay (if applicable) // then make 'em pay (if applicable)
if (!context.payForCommand(Conf.econCostCreate, TL.COMMAND_CREATE_TOCREATE, TL.COMMAND_CREATE_FORCREATE)) { if (!context.payForCommand(Conf.econCostCreate, TL.COMMAND_CREATE_TOCREATE, TL.COMMAND_CREATE_FORCREATE)) {
return; return;
} }
Faction faction = Factions.getInstance().createFaction(); Faction faction = Factions.getInstance().createFaction();
// TODO: Why would this even happen??? Auto increment clash?? // TODO: Why would this even happen??? Auto increment clash??
if (faction == null) { if (faction == null) {
context.msg(TL.COMMAND_CREATE_ERROR); context.msg(TL.COMMAND_CREATE_ERROR);
return; return;
} }
// finish setting up the Faction // finish setting up the Faction
faction.setTag(tag); faction.setTag(tag);
// trigger the faction join event for the creator // trigger the faction join event for the creator
FPlayerJoinEvent joinEvent = new FPlayerJoinEvent(FPlayers.getInstance().getByPlayer(context.player), faction, FPlayerJoinEvent.PlayerJoinReason.CREATE); FPlayerJoinEvent joinEvent = new FPlayerJoinEvent(FPlayers.getInstance().getByPlayer(context.player), faction, FPlayerJoinEvent.PlayerJoinReason.CREATE);
Bukkit.getServer().getPluginManager().callEvent(joinEvent); Bukkit.getServer().getPluginManager().callEvent(joinEvent);
// join event cannot be cancelled or you'll have an empty faction // join event cannot be cancelled or you'll have an empty faction
// finish setting up the FPlayer // finish setting up the FPlayer
context.fPlayer.setFaction(faction, false); context.fPlayer.setFaction(faction, false);
// We should consider adding the role just AFTER joining the faction. // We should consider adding the role just AFTER joining the faction.
// That way we don't have to mess up deleting more stuff. // 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. // And prevent the user from being returned to NORMAL after deleting his old faction.
context.fPlayer.setRole(Role.LEADER); context.fPlayer.setRole(Role.LEADER);
if (FactionsPlugin.getInstance().getConfig().getBoolean("faction-creation-broadcast", true)) { if (FactionsPlugin.getInstance().getConfig().getBoolean("faction-creation-broadcast", true)) {
for (FPlayer follower : FPlayers.getInstance().getOnlinePlayers()) { for (FPlayer follower : FPlayers.getInstance().getOnlinePlayers()) {
follower.msg(TL.COMMAND_CREATE_CREATED, context.fPlayer.getName(), faction.getTag(follower)); follower.msg(TL.COMMAND_CREATE_CREATED, context.fPlayer.getName(), faction.getTag(follower));
} }
} }
context.msg(TL.COMMAND_CREATE_YOUSHOULD, FactionsPlugin.getInstance().cmdBase.cmdDescription.getUseageTemplate(context)); context.msg(TL.COMMAND_CREATE_YOUSHOULD, FactionsPlugin.getInstance().cmdBase.cmdDescription.getUseageTemplate(context));
if (Conf.econEnabled) Econ.setBalance(faction.getAccountId(), Conf.econFactionStartingBalance); if (Conf.econEnabled) Econ.setBalance(faction.getAccountId(), Conf.econFactionStartingBalance);
if (Conf.logFactionCreate) if (Conf.logFactionCreate)
FactionsPlugin.getInstance().log(context.fPlayer.getName() + TL.COMMAND_CREATE_CREATEDLOG.toString() + tag); FactionsPlugin.getInstance().log(context.fPlayer.getName() + TL.COMMAND_CREATE_CREATEDLOG.toString() + tag);
if (FactionsPlugin.getInstance().getConfig().getBoolean("fpaypal.Enabled")) if (FactionsPlugin.getInstance().getConfig().getBoolean("fpaypal.Enabled"))
context.msg(TL.COMMAND_PAYPALSET_CREATED); context.msg(TL.COMMAND_PAYPALSET_CREATED);
if (Conf.useCustomDefaultPermissions) faction.setDefaultPerms(); if (Conf.useCustomDefaultPermissions) faction.setDefaultPerms();
if (Conf.usePermissionHints) context.msg(TL.COMMAND_HINT_PERMISSION); if (Conf.usePermissionHints) context.msg(TL.COMMAND_HINT_PERMISSION);
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_CREATE_DESCRIPTION; return TL.COMMAND_CREATE_DESCRIPTION;
} }
} }

View File

@ -14,71 +14,71 @@ import org.bukkit.ChatColor;
public class CmdDeinvite extends FCommand { public class CmdDeinvite extends FCommand {
public CmdDeinvite() { public CmdDeinvite() {
super(); super();
this.aliases.add("deinvite"); this.aliases.add("deinvite");
this.aliases.add("deinv"); this.aliases.add("deinv");
this.optionalArgs.put("player name", "name"); this.optionalArgs.put("player name", "name");
this.requirements = new CommandRequirements.Builder(Permission.DEINVITE) this.requirements = new CommandRequirements.Builder(Permission.DEINVITE)
.memberOnly() .memberOnly()
.build(); .build();
} }
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
// Check if arg 0 == null do you don't have // Check if arg 0 == null do you don't have
// `No player "null" could be found.` message. // `No player "null" could be found.` message.
if (context.args.get(0) == null) { if (context.args.get(0) == null) {
FancyMessage msg = new FancyMessage(TL.COMMAND_DEINVITE_CANDEINVITE.toString()).color(ChatColor.GOLD); FancyMessage msg = new FancyMessage(TL.COMMAND_DEINVITE_CANDEINVITE.toString()).color(ChatColor.GOLD);
for (String id : context.faction.getInvites()) { for (String id : context.faction.getInvites()) {
FPlayer fp = FPlayers.getInstance().getById(id); FPlayer fp = FPlayers.getInstance().getById(id);
String name = fp != null ? fp.getName() : 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); msg.then(name + " ").color(ChatColor.WHITE).tooltip(TL.COMMAND_DEINVITE_CLICKTODEINVITE.format(name)).command("/" + Conf.baseCommandAliases.get(0) + " deinvite " + name);
} }
context.sendFancyMessage(msg); context.sendFancyMessage(msg);
return; return;
} }
FPlayer you = context.argAsBestFPlayerMatch(0); FPlayer you = context.argAsBestFPlayerMatch(0);
if (!context.fPlayer.isAdminBypassing()) { if (!context.fPlayer.isAdminBypassing()) {
Access access = context.faction.getAccess(context.fPlayer, PermissableAction.INVITE); Access access = context.faction.getAccess(context.fPlayer, PermissableAction.INVITE);
if (access != Access.ALLOW && context.fPlayer.getRole() != Role.LEADER) { if (access != Access.ALLOW && context.fPlayer.getRole() != Role.LEADER) {
context.msg(TL.GENERIC_FPERM_NOPERMISSION, "manage invites"); context.msg(TL.GENERIC_FPERM_NOPERMISSION, "manage invites");
return; return;
} }
} }
if (you == null) { if (you == null) {
FancyMessage msg = new FancyMessage(TL.COMMAND_DEINVITE_CANDEINVITE.toString()).color(ChatColor.GOLD); FancyMessage msg = new FancyMessage(TL.COMMAND_DEINVITE_CANDEINVITE.toString()).color(ChatColor.GOLD);
for (String id : context.faction.getInvites()) { for (String id : context.faction.getInvites()) {
FPlayer fp = FPlayers.getInstance().getById(id); FPlayer fp = FPlayers.getInstance().getById(id);
String name = fp != null ? fp.getName() : 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); msg.then(name + " ").color(ChatColor.WHITE).tooltip(TL.COMMAND_DEINVITE_CLICKTODEINVITE.format(name)).command("/" + Conf.baseCommandAliases.get(0) + " deinvite " + name);
} }
context.sendFancyMessage(msg); context.sendFancyMessage(msg);
return; return;
} }
if (you.getFaction() == context.faction) { if (you.getFaction() == context.faction) {
context.msg(TL.COMMAND_DEINVITE_ALREADYMEMBER, you.getName(), context.faction.getTag()); context.msg(TL.COMMAND_DEINVITE_ALREADYMEMBER, you.getName(), context.faction.getTag());
context.msg(TL.COMMAND_DEINVITE_MIGHTWANT, FactionsPlugin.getInstance().cmdBase.cmdKick.getUseageTemplate(context)); context.msg(TL.COMMAND_DEINVITE_MIGHTWANT, FactionsPlugin.getInstance().cmdBase.cmdKick.getUseageTemplate(context));
return; return;
} }
context.faction.deinvite(you); context.faction.deinvite(you);
you.msg(TL.COMMAND_DEINVITE_REVOKED, context.fPlayer.describeTo(you), context.faction.describeTo(you)); you.msg(TL.COMMAND_DEINVITE_REVOKED, context.fPlayer.describeTo(you), context.faction.describeTo(you));
context.faction.msg(TL.COMMAND_DEINVITE_REVOKES, context.fPlayer.describeTo(context.faction), you.describeTo(context.faction)); context.faction.msg(TL.COMMAND_DEINVITE_REVOKES, context.fPlayer.describeTo(context.faction), you.describeTo(context.faction));
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_DEINVITE_DESCRIPTION; return TL.COMMAND_DEINVITE_DESCRIPTION;
} }
} }

View File

@ -7,40 +7,40 @@ import com.massivecraft.factions.zcore.util.TL;
public class CmdDelFWarp extends FCommand { public class CmdDelFWarp extends FCommand {
public CmdDelFWarp() { public CmdDelFWarp() {
super(); super();
this.aliases.add("delwarp"); this.aliases.add("delwarp");
this.aliases.add("dw"); this.aliases.add("dw");
this.aliases.add("deletewarp"); this.aliases.add("deletewarp");
this.requiredArgs.add("warp name"); this.requiredArgs.add("warp name");
this.requirements = new CommandRequirements.Builder(Permission.SETWARP) this.requirements = new CommandRequirements.Builder(Permission.SETWARP)
.playerOnly() .playerOnly()
.memberOnly() .memberOnly()
.build(); .build();
} }
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
String warp = context.argAsString(0); String warp = context.argAsString(0);
if (context.faction.isWarp(warp)) { if (context.faction.isWarp(warp)) {
if (!transact(context.fPlayer, context)) { if (!transact(context.fPlayer, context)) {
return; return;
} }
context.faction.removeWarp(warp); context.faction.removeWarp(warp);
context.msg(TL.COMMAND_DELFWARP_DELETED, warp); context.msg(TL.COMMAND_DELFWARP_DELETED, warp);
} else { } else {
context.msg(TL.COMMAND_DELFWARP_INVALID, warp); context.msg(TL.COMMAND_DELFWARP_INVALID, warp);
} }
} }
private boolean transact(FPlayer player, CommandContext context) { private boolean transact(FPlayer player, CommandContext context) {
return !FactionsPlugin.getInstance().getConfig().getBoolean("warp-cost.enabled", false) || player.isAdminBypassing() || context.payForCommand(FactionsPlugin.getInstance().getConfig().getDouble("warp-cost.delwarp", 5), TL.COMMAND_DELFWARP_TODELETE.toString(), TL.COMMAND_DELFWARP_FORDELETE.toString()); return !FactionsPlugin.getInstance().getConfig().getBoolean("warp-cost.enabled", false) || player.isAdminBypassing() || context.payForCommand(FactionsPlugin.getInstance().getConfig().getDouble("warp-cost.delwarp", 5), TL.COMMAND_DELFWARP_TODELETE.toString(), TL.COMMAND_DELFWARP_FORDELETE.toString());
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_DELFWARP_DESCRIPTION; return TL.COMMAND_DELFWARP_DESCRIPTION;
} }
} }

View File

@ -9,47 +9,47 @@ import com.massivecraft.factions.zcore.util.TextUtil;
public class CmdDescription extends FCommand { public class CmdDescription extends FCommand {
public CmdDescription() { public CmdDescription() {
super(); super();
this.aliases.add("desc"); this.aliases.add("desc");
this.aliases.add("description"); this.aliases.add("description");
this.requiredArgs.add("desc"); this.requiredArgs.add("desc");
this.requirements = new CommandRequirements.Builder(Permission.DESCRIPTION) this.requirements = new CommandRequirements.Builder(Permission.DESCRIPTION)
.playerOnly() .playerOnly()
.memberOnly() .memberOnly()
.noErrorOnManyArgs() .noErrorOnManyArgs()
.build(); .build();
} }
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
if (!context.payForCommand(Conf.econCostDesc, TL.COMMAND_DESCRIPTION_TOCHANGE, TL.COMMAND_DESCRIPTION_FORCHANGE)) { if (!context.payForCommand(Conf.econCostDesc, TL.COMMAND_DESCRIPTION_TOCHANGE, TL.COMMAND_DESCRIPTION_FORCHANGE)) {
return; return;
} }
// since "&" color tags seem to work even through plain old FPlayer.sendMessage() for some reason, we need to break those up // 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. // And replace all the % because it messes with string formatting and this is easy way around that.
context.faction.setDescription(TextUtil.implode(context.args, " ").replaceAll("%", "").replaceAll("(&([a-f0-9klmnor]))", "& $2")); context.faction.setDescription(TextUtil.implode(context.args, " ").replaceAll("%", "").replaceAll("(&([a-f0-9klmnor]))", "& $2"));
if (!Conf.broadcastDescriptionChanges) { if (!Conf.broadcastDescriptionChanges) {
context.msg(TL.COMMAND_DESCRIPTION_CHANGED, context.faction.describeTo(context.fPlayer)); context.msg(TL.COMMAND_DESCRIPTION_CHANGED, context.faction.describeTo(context.fPlayer));
context.sendMessage(context.faction.getDescription()); context.sendMessage(context.faction.getDescription());
return; return;
} }
// Broadcast the description to everyone // Broadcast the description to everyone
for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers()) { for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers()) {
fplayer.msg(TL.COMMAND_DESCRIPTION_CHANGES, context.faction.describeTo(fplayer)); fplayer.msg(TL.COMMAND_DESCRIPTION_CHANGES, context.faction.describeTo(fplayer));
fplayer.sendMessage(context.faction.getDescription()); // players can inject "&" or "`" or "<i>" or whatever in their description; &k is particularly interesting looking fplayer.sendMessage(context.faction.getDescription()); // players can inject "&" or "`" or "<i>" or whatever in their description; &k is particularly interesting looking
} }
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_DESCRIPTION_DESCRIPTION; return TL.COMMAND_DESCRIPTION_DESCRIPTION;
} }
} }

View File

@ -17,85 +17,85 @@ import java.util.HashMap;
public class CmdDisband extends FCommand { public class CmdDisband extends FCommand {
private static HashMap<String, String> disbandMap = new HashMap<>(); private static HashMap<String, String> disbandMap = new HashMap<>();
public CmdDisband() { public CmdDisband() {
super(); super();
this.aliases.add("disband"); this.aliases.add("disband");
this.optionalArgs.put("faction tag", "yours"); this.optionalArgs.put("faction tag", "yours");
this.requirements = new CommandRequirements.Builder(Permission.DISBAND) this.requirements = new CommandRequirements.Builder(Permission.DISBAND)
.build(); .build();
} }
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
// The faction, default to your own.. but null if console sender. // The faction, default to your own.. but null if console sender.
Faction faction = context.argAsFaction(0, context.fPlayer == null ? null : context.faction); Faction faction = context.argAsFaction(0, context.fPlayer == null ? null : context.faction);
if (faction == null) return; if (faction == null) return;
boolean isMyFaction = context.fPlayer != null && faction == context.faction; boolean isMyFaction = context.fPlayer != null && faction == context.faction;
if (!isMyFaction) { if (!isMyFaction) {
if (!Permission.DISBAND_ANY.has(context.sender, true)) { if (!Permission.DISBAND_ANY.has(context.sender, true)) {
return; return;
} }
} }
if (context.fPlayer != null && !context.fPlayer.isAdminBypassing()) { if (context.fPlayer != null && !context.fPlayer.isAdminBypassing()) {
Access access = faction.getAccess(context.fPlayer, PermissableAction.DISBAND); Access access = faction.getAccess(context.fPlayer, PermissableAction.DISBAND);
if (context.fPlayer.getRole() != Role.LEADER && faction.getFPlayerLeader() != context.fPlayer && access != Access.ALLOW) { if (context.fPlayer.getRole() != Role.LEADER && faction.getFPlayerLeader() != context.fPlayer && access != Access.ALLOW) {
context.msg(TL.GENERIC_FPERM_NOPERMISSION, "disband " + faction.getTag()); context.msg(TL.GENERIC_FPERM_NOPERMISSION, "disband " + faction.getTag());
return; return;
} }
} }
if (!faction.isNormal()) { if (!faction.isNormal()) {
context.msg(TL.COMMAND_DISBAND_IMMUTABLE.toString()); context.msg(TL.COMMAND_DISBAND_IMMUTABLE.toString());
return; return;
} }
if (faction.isPermanent()) { if (faction.isPermanent()) {
context.msg(TL.COMMAND_DISBAND_MARKEDPERMANENT.toString()); context.msg(TL.COMMAND_DISBAND_MARKEDPERMANENT.toString());
return; return;
} }
// THis means they are a console command sender. // THis means they are a console command sender.
if (context.player == null) { if (context.player == null) {
faction.disband(null, PlayerDisbandReason.PLUGIN); faction.disband(null, PlayerDisbandReason.PLUGIN);
return; return;
} }
// check for tnt before disbanding. // check for tnt before disbanding.
if (!disbandMap.containsKey(context.player.getUniqueId().toString()) && faction.getTnt() > 0) { if (!disbandMap.containsKey(context.player.getUniqueId().toString()) && faction.getTnt() > 0) {
context.msg(TL.COMMAND_DISBAND_CONFIRM.toString().replace("{tnt}", faction.getTnt() + "")); context.msg(TL.COMMAND_DISBAND_CONFIRM.toString().replace("{tnt}", faction.getTnt() + ""));
disbandMap.put(context.player.getUniqueId().toString(), faction.getId()); disbandMap.put(context.player.getUniqueId().toString(), faction.getId());
Bukkit.getScheduler().scheduleSyncDelayedTask(FactionsPlugin.getInstance(), () -> disbandMap.remove(context.player.getUniqueId().toString()), 200L); Bukkit.getScheduler().scheduleSyncDelayedTask(FactionsPlugin.getInstance(), () -> disbandMap.remove(context.player.getUniqueId().toString()), 200L);
} else if (faction.getId().equals(disbandMap.get(context.player.getUniqueId().toString())) || faction.getTnt() == 0) { } else if (faction.getId().equals(disbandMap.get(context.player.getUniqueId().toString())) || faction.getTnt() == 0) {
if (FactionsPlugin.getInstance().getConfig().getBoolean("faction-disband-broadcast", true)) { if (FactionsPlugin.getInstance().getConfig().getBoolean("faction-disband-broadcast", true)) {
for (FPlayer follower : FPlayers.getInstance().getOnlinePlayers()) { for (FPlayer follower : FPlayers.getInstance().getOnlinePlayers()) {
String amountString = context.sender instanceof ConsoleCommandSender ? TL.GENERIC_SERVERADMIN.toString() : context.fPlayer.describeTo(follower); String amountString = context.sender instanceof ConsoleCommandSender ? TL.GENERIC_SERVERADMIN.toString() : context.fPlayer.describeTo(follower);
UtilFly.checkFly(context.fPlayer, Board.getInstance().getFactionAt(new FLocation(follower))); UtilFly.checkFly(context.fPlayer, Board.getInstance().getFactionAt(new FLocation(follower)));
if (follower.getFaction() == faction) { if (follower.getFaction() == faction) {
follower.msg(TL.COMMAND_DISBAND_BROADCAST_YOURS, amountString); follower.msg(TL.COMMAND_DISBAND_BROADCAST_YOURS, amountString);
} else { } else {
follower.msg(TL.COMMAND_DISBAND_BROADCAST_NOTYOURS, amountString, faction.getTag(follower)); follower.msg(TL.COMMAND_DISBAND_BROADCAST_NOTYOURS, amountString, faction.getTag(follower));
}
} }
faction.disband(context.player, PlayerDisbandReason.COMMAND); }
} else { faction.disband(context.player, PlayerDisbandReason.COMMAND);
faction.disband(context.player, PlayerDisbandReason.COMMAND); } else {
context.player.sendMessage(String.valueOf(TL.COMMAND_DISBAND_PLAYER)); faction.disband(context.player, PlayerDisbandReason.COMMAND);
} context.player.sendMessage(String.valueOf(TL.COMMAND_DISBAND_PLAYER));
} }
} }
}
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_DISBAND_DESCRIPTION; return TL.COMMAND_DISBAND_DESCRIPTION;
} }
} }

View File

@ -9,36 +9,36 @@ import java.util.UUID;
public class CmdFGlobal extends FCommand { public class CmdFGlobal extends FCommand {
public static List<UUID> toggled = new ArrayList<>(); public static List<UUID> toggled = new ArrayList<>();
public CmdFGlobal() { public CmdFGlobal() {
super(); super();
this.aliases.add("gchat"); this.aliases.add("gchat");
this.aliases.add("global"); this.aliases.add("global");
this.aliases.add("globalchat"); this.aliases.add("globalchat");
this.requirements = new CommandRequirements.Builder(Permission.GLOBALCHAT) this.requirements = new CommandRequirements.Builder(Permission.GLOBALCHAT)
.playerOnly() .playerOnly()
.memberOnly() .memberOnly()
.build(); .build();
} }
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
// /f global // /f global
if (toggled.contains(context.player.getUniqueId())) { if (toggled.contains(context.player.getUniqueId())) {
toggled.remove(context.player.getUniqueId()); toggled.remove(context.player.getUniqueId());
} else { } else {
toggled.add(context.player.getUniqueId()); toggled.add(context.player.getUniqueId());
} }
context.msg(TL.COMMAND_F_GLOBAL_TOGGLE, toggled.contains(context.player.getUniqueId()) ? "disabled" : "enabled"); context.msg(TL.COMMAND_F_GLOBAL_TOGGLE, toggled.contains(context.player.getUniqueId()) ? "disabled" : "enabled");
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_F_GLOBAL_DESCRIPTION; return TL.COMMAND_F_GLOBAL_DESCRIPTION;
} }
} }

View File

@ -14,63 +14,63 @@ import java.util.UUID;
public class CmdFWarp extends FCommand { public class CmdFWarp extends FCommand {
public CmdFWarp() { public CmdFWarp() {
super(); super();
this.aliases.add("warp"); this.aliases.add("warp");
this.aliases.add("warps"); this.aliases.add("warps");
this.optionalArgs.put("warpname", "warpname"); this.optionalArgs.put("warpname", "warpname");
this.optionalArgs.put("password", "password"); this.optionalArgs.put("password", "password");
this.requirements = new CommandRequirements.Builder(Permission.WARP) this.requirements = new CommandRequirements.Builder(Permission.WARP)
.playerOnly() .playerOnly()
.memberOnly() .memberOnly()
.withAction(PermissableAction.WARP) .withAction(PermissableAction.WARP)
.build(); .build();
} }
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
if (context.args.size() == 0) { if (context.args.size() == 0) {
new FactionWarpsFrame(context.faction).buildGUI(context.fPlayer); new FactionWarpsFrame(context.faction).buildGUI(context.fPlayer);
} else if (context.args.size() > 2) { } else if (context.args.size() > 2) {
context.msg(TL.COMMAND_FWARP_COMMANDFORMAT); context.msg(TL.COMMAND_FWARP_COMMANDFORMAT);
} else { } else {
final String warpName = context.argAsString(0); final String warpName = context.argAsString(0);
final String passwordAttempt = context.argAsString(1); final String passwordAttempt = context.argAsString(1);
if (context.faction.isWarp(context.argAsString(0))) { if (context.faction.isWarp(context.argAsString(0))) {
// Check if requires password and if so, check if valid. CASE SENSITIVE // Check if requires password and if so, check if valid. CASE SENSITIVE
if (context.faction.hasWarpPassword(warpName) && !context.faction.isWarpPassword(warpName, passwordAttempt)) { if (context.faction.hasWarpPassword(warpName) && !context.faction.isWarpPassword(warpName, passwordAttempt)) {
context.faction.msg(TL.COMMAND_FWARP_INVALID_PASSWORD); context.faction.msg(TL.COMMAND_FWARP_INVALID_PASSWORD);
return; return;
}
// Check transaction AFTER password check.
if (!transact(context.fPlayer, context)) return;
final FPlayer fPlayer = context.fPlayer;
final UUID uuid = context.player.getUniqueId();
context.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);
} }
}, FactionsPlugin.getInstance().getConfig().getLong("warmups.f-warp", 0));
} else {
context.msg(TL.COMMAND_FWARP_INVALID_WARP, warpName);
}
}
}
// Check transaction AFTER password check. private boolean transact(FPlayer player, CommandContext context) {
if (!transact(context.fPlayer, context)) return; return !FactionsPlugin.getInstance().getConfig().getBoolean("warp-cost.enabled", false) || player.isAdminBypassing() || context.payForCommand(FactionsPlugin.getInstance().getConfig().getDouble("warp-cost.warp", 5), TL.COMMAND_FWARP_TOWARP.toString(), TL.COMMAND_FWARP_FORWARPING.toString());
}
final FPlayer fPlayer = context.fPlayer; @Override
final UUID uuid = context.player.getUniqueId(); public TL getUsageTranslation() {
context.doWarmUp(WarmUpUtil.Warmup.WARP, TL.WARMUPS_NOTIFY_TELEPORT, warpName, () -> { return TL.COMMAND_FWARP_DESCRIPTION;
Player player = Bukkit.getPlayer(uuid); }
if (player != null) {
player.teleport(fPlayer.getFaction().getWarp(warpName).getLocation());
fPlayer.msg(TL.COMMAND_FWARP_WARPED, warpName);
}
}, FactionsPlugin.getInstance().getConfig().getLong("warmups.f-warp", 0));
} else {
context.msg(TL.COMMAND_FWARP_INVALID_WARP, warpName);
}
}
}
private boolean transact(FPlayer player, CommandContext context) {
return !FactionsPlugin.getInstance().getConfig().getBoolean("warp-cost.enabled", false) || player.isAdminBypassing() || context.payForCommand(FactionsPlugin.getInstance().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;
}
} }

View File

@ -19,186 +19,186 @@ import java.util.concurrent.ConcurrentHashMap;
public class CmdFly extends FCommand { public class CmdFly extends FCommand {
public static ConcurrentHashMap<String, Boolean> flyMap = new ConcurrentHashMap<String, Boolean>(); public static ConcurrentHashMap<String, Boolean> flyMap = new ConcurrentHashMap<String, Boolean>();
public static int id = -1; public static int id = -1;
public static int flyid = -1; public static int flyid = -1;
public CmdFly() { public CmdFly() {
super(); super();
this.aliases.add("fly"); this.aliases.add("fly");
this.optionalArgs.put("on/off", "flip"); this.optionalArgs.put("on/off", "flip");
this.requirements = new CommandRequirements.Builder(Permission.FLY) this.requirements = new CommandRequirements.Builder(Permission.FLY)
.playerOnly() .playerOnly()
.memberOnly() .memberOnly()
.build(); .build();
} }
public static void startParticles() { public static void startParticles() {
id = Bukkit.getScheduler().scheduleSyncRepeatingTask(FactionsPlugin.getInstance(), () -> { id = Bukkit.getScheduler().scheduleSyncRepeatingTask(FactionsPlugin.getInstance(), () -> {
for (String name : flyMap.keySet()) { for (String name : flyMap.keySet()) {
Player player = Bukkit.getPlayer(name);
if (player == null) continue;
if (!player.isFlying()) continue;
if (!FactionsPlugin.getInstance().mc17) {
if (player.getGameMode() == GameMode.SPECTATOR) continue;
}
FPlayer fplayer = FPlayers.getInstance().getByPlayer(player);
fplayer.isVanished();
}
if (flyMap.keySet().size() == 0) {
Bukkit.getScheduler().cancelTask(id);
id = -1;
}
}, 10L, 3L);
}
public static void startFlyCheck() {
flyid = Bukkit.getScheduler().scheduleSyncRepeatingTask(FactionsPlugin.getInstance(), () -> { //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); Player player = Bukkit.getPlayer(name);
if (player == null) continue; if (player == null
if (!player.isFlying()) continue; || !player.isFlying()
if (!FactionsPlugin.getInstance().mc17) { || player.getGameMode() == GameMode.CREATIVE
if (player.getGameMode() == GameMode.SPECTATOR) continue; || !FactionsPlugin.getInstance().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 (player.hasPermission("factions.fly.bypassnearbyenemycheck") || 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);
}
} }
FPlayer fplayer = FPlayers.getInstance().getByPlayer(player); }
fplayer.isVanished(); }
} }, 20L, 20L);
if (flyMap.keySet().size() == 0) { }
Bukkit.getScheduler().cancelTask(id);
id = -1;
}
}, 10L, 3L);
}
public static void startFlyCheck() { private static boolean checkBypassPerms(FPlayer fme, Player me, Faction toFac) {
flyid = Bukkit.getScheduler().scheduleSyncRepeatingTask(FactionsPlugin.getInstance(), () -> { //threw the exception for now, until I recode fly :( Cringe. if (toFac != fme.getFaction()) {
checkTaskState(); if (!me.hasPermission("factions.fly.wilderness") && toFac.isWilderness() || !me.hasPermission("factions.fly.safezone") && toFac.isSafeZone() || !me.hasPermission("factions.fly.warzone") && toFac.isWarZone()) {
if (flyMap.keySet().size() != 0) { fme.msg(TL.COMMAND_FLY_NO_ACCESS, toFac.getTag(fme));
for (String name : flyMap.keySet()) { return false;
if (name == null) { }
continue; Access access = toFac.getAccess(fme, PermissableAction.FLY);
} if ((!(me.hasPermission("factions.fly.enemy") || access == Access.ALLOW)) && toFac.getRelationTo(fme.getFaction()) == Relation.ENEMY) {
Player player = Bukkit.getPlayer(name); fme.msg(TL.COMMAND_FLY_NO_ACCESS, toFac.getTag(fme));
if (player == null return false;
|| !player.isFlying() }
|| player.getGameMode() == GameMode.CREATIVE if (!(me.hasPermission("factions.fly.ally") || access == Access.ALLOW) && toFac.getRelationTo(fme.getFaction()) == Relation.ALLY) {
|| !FactionsPlugin.getInstance().mc17 && player.getGameMode() == GameMode.SPECTATOR) { fme.msg(TL.COMMAND_FLY_NO_ACCESS, toFac.getTag(fme));
continue; return false;
} }
FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player); if (!(me.hasPermission("factions.fly.truce") || access == Access.ALLOW) && toFac.getRelationTo(fme.getFaction()) == Relation.TRUCE) {
Faction myFaction = fPlayer.getFaction(); fme.msg(TL.COMMAND_FLY_NO_ACCESS, toFac.getTag(fme));
if (myFaction.isWilderness()) { return false;
fPlayer.setFlying(false); }
flyMap.remove(name);
continue;
}
if (player.hasPermission("factions.fly.bypassnearbyenemycheck") || 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);
}
}
} 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;
}
}, 20L, 20L); public static Boolean isSystemFaction(Faction faction) {
} return faction.isSafeZone() ||
faction.isWarZone() ||
faction.isWilderness();
}
private static boolean checkBypassPerms(FPlayer fme, Player me, Faction toFac) { public static void checkTaskState() {
if (toFac != fme.getFaction()) { if (flyMap.keySet().size() == 0) {
if (!me.hasPermission("factions.fly.wilderness") && toFac.isWilderness() || !me.hasPermission("factions.fly.safezone") && toFac.isSafeZone() || !me.hasPermission("factions.fly.warzone") && toFac.isWarZone()) { Bukkit.getScheduler().cancelTask(flyid);
fme.msg(TL.COMMAND_FLY_NO_ACCESS, toFac.getTag(fme)); flyid = -1;
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)) { public static void disableFlight(final FPlayer fme) {
fme.msg(TL.COMMAND_FLY_NO_ACCESS, toFac.getTag(fme)); fme.setFlying(false);
return false; flyMap.remove(fme.getPlayer().getName());
} }
return me.hasPermission("factions.fly") && access != Access.DENY;
}
return true;
}
public static Boolean isSystemFaction(Faction faction) { public boolean isInFlightChecker(Player player) {
return faction.isSafeZone() || return flyMap.containsKey(player.getName());
faction.isWarZone() || }
faction.isWilderness();
}
public static void checkTaskState() { @Override
if (flyMap.keySet().size() == 0) { public void perform(CommandContext context) {
Bukkit.getScheduler().cancelTask(flyid); // Disabled by default.
flyid = -1; if (!FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight", false)) {
} context.fPlayer.msg(TL.COMMAND_FLY_DISABLED);
} return;
}
public static void disableFlight(final FPlayer fme) { FLocation myfloc = new FLocation(context.player.getLocation());
fme.setFlying(false); Faction toFac = Board.getInstance().getFactionAt(myfloc);
flyMap.remove(fme.getPlayer().getName()); if (!checkBypassPerms(context.fPlayer, context.player, toFac)) return;
} List<Entity> entities = context.player.getNearbyEntities(16.0D, 256.0D, 16.0D);
public boolean isInFlightChecker(Player player) { for (int i = 0; i <= entities.size() - 1; ++i) {
return flyMap.containsKey(player.getName()); if (entities.get(i) instanceof Player) {
} Player eplayer = (Player) entities.get(i);
FPlayer efplayer = FPlayers.getInstance().getByPlayer(eplayer);
@Override if (efplayer.getRelationTo(context.fPlayer) == Relation.ENEMY && !efplayer.isStealthEnabled()) {
public void perform(CommandContext context) { context.msg(TL.COMMAND_FLY_CHECK_ENEMY);
// Disabled by default. return;
if (!FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight", false)) { }
context.fPlayer.msg(TL.COMMAND_FLY_DISABLED); }
return; }
}
FLocation myfloc = new FLocation(context.player.getLocation());
Faction toFac = Board.getInstance().getFactionAt(myfloc);
if (!checkBypassPerms(context.fPlayer, context.player, toFac)) return;
List<Entity> entities = context.player.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(context.fPlayer) == Relation.ENEMY && !efplayer.isStealthEnabled()) {
context.msg(TL.COMMAND_FLY_CHECK_ENEMY);
return;
}
}
}
if (context.args.size() == 0) { if (context.args.size() == 0) {
toggleFlight(context.fPlayer.isFlying(), context.fPlayer, context); toggleFlight(context.fPlayer.isFlying(), context.fPlayer, context);
} else if (context.args.size() == 1) { } else if (context.args.size() == 1) {
toggleFlight(context.argAsBool(0), context.fPlayer, context); toggleFlight(context.argAsBool(0), context.fPlayer, context);
} }
} }
private void toggleFlight(final boolean toggle, final FPlayer fme, CommandContext context) { private void toggleFlight(final boolean toggle, final FPlayer fme, CommandContext context) {
if (toggle) { if (toggle) {
fme.setFlying(false); fme.setFlying(false);
flyMap.remove(fme.getPlayer().getName()); flyMap.remove(fme.getPlayer().getName());
return; return;
} }
if (fme.canFlyAtLocation()) if (fme.canFlyAtLocation())
context.doWarmUp(WarmUpUtil.Warmup.FLIGHT, TL.WARMUPS_NOTIFY_FLIGHT, "Fly", () -> { context.doWarmUp(WarmUpUtil.Warmup.FLIGHT, TL.WARMUPS_NOTIFY_FLIGHT, "Fly", () -> {
fme.setFlying(true); fme.setFlying(true);
flyMap.put(fme.getPlayer().getName(), true); flyMap.put(fme.getPlayer().getName(), true);
if (flyid == -1) { if (flyid == -1) {
startFlyCheck(); startFlyCheck();
} }
}, FactionsPlugin.getInstance().getConfig().getLong("warmups.f-fly", 0)); }, FactionsPlugin.getInstance().getConfig().getLong("warmups.f-fly", 0));
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_FLY_DESCRIPTION; return TL.COMMAND_FLY_DESCRIPTION;
} }
} }

View File

@ -7,43 +7,43 @@ import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
public class CmdFocus extends FCommand { public class CmdFocus extends FCommand {
public CmdFocus() { public CmdFocus() {
aliases.add("focus"); aliases.add("focus");
requiredArgs.add("player"); requiredArgs.add("player");
this.requirements = new CommandRequirements.Builder(Permission.FOCUS) this.requirements = new CommandRequirements.Builder(Permission.FOCUS)
.playerOnly() .playerOnly()
.memberOnly() .memberOnly()
.build(); .build();
} }
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
if (!FactionsPlugin.getInstance().getConfig().getBoolean("ffocus.Enabled")) { if (!FactionsPlugin.getInstance().getConfig().getBoolean("ffocus.Enabled")) {
context.msg(TL.GENERIC_DISABLED); context.msg(TL.GENERIC_DISABLED);
return; return;
} }
FPlayer target = context.argAsFPlayer(0); FPlayer target = context.argAsFPlayer(0);
if (target == null) { if (target == null) {
return; return;
} }
if (target.getFaction().getId().equalsIgnoreCase(context.faction.getId())) { if (target.getFaction().getId().equalsIgnoreCase(context.faction.getId())) {
context.msg(TL.COMMAND_FOCUS_SAMEFACTION); context.msg(TL.COMMAND_FOCUS_SAMEFACTION);
return; return;
} }
if ((context.faction.getFocused() != null) && (context.faction.getFocused().equalsIgnoreCase(target.getName()))) { if ((context.faction.getFocused() != null) && (context.faction.getFocused().equalsIgnoreCase(target.getName()))) {
context.faction.setFocused(null); context.faction.setFocused(null);
context.faction.msg(TL.COMMAND_FOCUS_NO_LONGER, target.getName()); context.faction.msg(TL.COMMAND_FOCUS_NO_LONGER, target.getName());
FTeamWrapper.updatePrefixes(target.getFaction()); FTeamWrapper.updatePrefixes(target.getFaction());
return; return;
} }
context.faction.msg(TL.COMMAND_FOCUS_FOCUSING, target.getName()); context.faction.msg(TL.COMMAND_FOCUS_FOCUSING, target.getName());
context.faction.setFocused(target.getName()); context.faction.setFocused(target.getName());
FTeamWrapper.updatePrefixes(target.getFaction()); FTeamWrapper.updatePrefixes(target.getFaction());
} }
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_FOCUS_DESCRIPTION; return TL.COMMAND_FOCUS_DESCRIPTION;
} }
} }

View File

@ -9,64 +9,64 @@ import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
public class CmdGetVault extends FCommand { public class CmdGetVault extends FCommand {
public CmdGetVault() { public CmdGetVault() {
super(); super();
this.aliases.add("getvault"); this.aliases.add("getvault");
this.requirements = new CommandRequirements.Builder(Permission.GETVAULT) this.requirements = new CommandRequirements.Builder(Permission.GETVAULT)
.playerOnly() .playerOnly()
.memberOnly() .memberOnly()
.build(); .build();
} }
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
if (!FactionsPlugin.getInstance().getConfig().getBoolean("fvault.Enabled")) { if (!FactionsPlugin.getInstance().getConfig().getBoolean("fvault.Enabled")) {
context.fPlayer.sendMessage("This command is disabled!"); context.fPlayer.sendMessage("This command is disabled!");
return; return;
} }
Location vaultLocation = context.faction.getVault(); Location vaultLocation = context.faction.getVault();
ItemStack vault = FactionsPlugin.getInstance().createItem(Material.CHEST, 1, (short) 0, FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fvault.Item.Name")), FactionsPlugin.getInstance().colorList(FactionsPlugin.getInstance().getConfig().getStringList("fvault.Item.Lore"))); ItemStack vault = FactionsPlugin.getInstance().createItem(Material.CHEST, 1, (short) 0, FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fvault.Item.Name")), FactionsPlugin.getInstance().colorList(FactionsPlugin.getInstance().getConfig().getStringList("fvault.Item.Lore")));
//check if vault is set //check if vault is set
if (vaultLocation != null) { if (vaultLocation != null) {
context.msg(TL.COMMAND_GETVAULT_ALREADYSET); context.msg(TL.COMMAND_GETVAULT_ALREADYSET);
return; return;
} }
//has enough money? //has enough money?
int amount = FactionsPlugin.getInstance().getConfig().getInt("fvault.Price"); int amount = FactionsPlugin.getInstance().getConfig().getInt("fvault.Price");
if (!context.fPlayer.hasMoney(amount)) { if (!context.fPlayer.hasMoney(amount)) {
return; return;
} }
//success :) //success :)
context.fPlayer.takeMoney(amount); context.fPlayer.takeMoney(amount);
context.player.getInventory().addItem(vault); context.player.getInventory().addItem(vault);
context.fPlayer.msg(TL.COMMAND_GETVAULT_RECEIVE); context.fPlayer.msg(TL.COMMAND_GETVAULT_RECEIVE);
} }
public boolean inventoryContains(Inventory inventory, ItemStack item) { public boolean inventoryContains(Inventory inventory, ItemStack item) {
int count = 0; int count = 0;
ItemStack[] items = inventory.getContents(); ItemStack[] items = inventory.getContents();
for (int i = 0; i < items.length; i++) { for (int i = 0; i < items.length; i++) {
if (items[i] != null && items[i].getType() == item.getType() && items[i].getDurability() == item.getDurability()) { if (items[i] != null && items[i].getType() == item.getType() && items[i].getDurability() == item.getDurability()) {
count += items[i].getAmount(); count += items[i].getAmount();
} }
if (count >= item.getAmount()) { if (count >= item.getAmount()) {
return true; return true;
} }
} }
return false; return false;
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_GETVAULT_DESCRIPTION; return TL.COMMAND_GETVAULT_DESCRIPTION;
} }
} }

View File

@ -13,201 +13,201 @@ import java.util.List;
public class CmdHelp extends FCommand { public class CmdHelp extends FCommand {
public ArrayList<ArrayList<String>> helpPages; public ArrayList<ArrayList<String>> helpPages;
public CmdHelp() { public CmdHelp() {
super(); super();
this.aliases.add("help"); this.aliases.add("help");
this.aliases.add("h"); this.aliases.add("h");
this.aliases.add("?"); this.aliases.add("?");
//this.requiredArgs.add(""); //this.requiredArgs.add("");
this.optionalArgs.put("page", "1"); this.optionalArgs.put("page", "1");
this.requirements = new CommandRequirements.Builder(Permission.HELP) this.requirements = new CommandRequirements.Builder(Permission.HELP)
.build(); .build();
} }
//----------------------------------------------// //----------------------------------------------//
// Build the help pages // Build the help pages
//----------------------------------------------// //----------------------------------------------//
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
if (FactionsPlugin.getInstance().getConfig().getBoolean("use-old-help", true)) { if (FactionsPlugin.getInstance().getConfig().getBoolean("use-old-help", true)) {
if (helpPages == null) { if (helpPages == null) {
updateHelp(context); updateHelp(context);
} }
int page = context.argAsInt(0, 1); int page = context.argAsInt(0, 1);
context.sendMessage(FactionsPlugin.getInstance().txt.titleize("Factions Help (" + page + "/" + helpPages.size() + ")")); context.sendMessage(FactionsPlugin.getInstance().txt.titleize("Factions Help (" + page + "/" + helpPages.size() + ")"));
page -= 1; page -= 1;
if (page < 0 || page >= helpPages.size()) { if (page < 0 || page >= helpPages.size()) {
context.msg(TL.COMMAND_HELP_404.format(String.valueOf(page))); context.msg(TL.COMMAND_HELP_404.format(String.valueOf(page)));
return; return;
} }
context.sendMessage(helpPages.get(page)); context.sendMessage(helpPages.get(page));
return; return;
} }
ConfigurationSection help = FactionsPlugin.getInstance().getConfig().getConfigurationSection("help"); ConfigurationSection help = FactionsPlugin.getInstance().getConfig().getConfigurationSection("help");
if (help == null) { if (help == null) {
help = FactionsPlugin.getInstance().getConfig().createSection("help"); // create new help section help = FactionsPlugin.getInstance().getConfig().createSection("help"); // create new help section
List<String> error = new ArrayList<>(); List<String> error = new ArrayList<>();
error.add("&cUpdate help messages in config.yml!"); error.add("&cUpdate help messages in config.yml!");
error.add("&cSet use-old-help for legacy help messages"); error.add("&cSet use-old-help for legacy help messages");
help.set("'1'", error); // add default error messages help.set("'1'", error); // add default error messages
} }
String pageArg = context.argAsString(0, "1"); String pageArg = context.argAsString(0, "1");
List<String> page = help.getStringList(pageArg); List<String> page = help.getStringList(pageArg);
if (page == null || page.isEmpty()) { if (page == null || page.isEmpty()) {
context.msg(TL.COMMAND_HELP_404.format(pageArg)); context.msg(TL.COMMAND_HELP_404.format(pageArg));
return; return;
} }
for (String helpLine : page) { for (String helpLine : page) {
context.sendMessage(FactionsPlugin.getInstance().txt.parse(helpLine)); context.sendMessage(FactionsPlugin.getInstance().txt.parse(helpLine));
} }
} }
public void updateHelp(CommandContext context) { public void updateHelp(CommandContext context) {
helpPages = new ArrayList<>(); helpPages = new ArrayList<>();
ArrayList<String> pageLines; ArrayList<String> pageLines;
pageLines = new ArrayList<>(); pageLines = new ArrayList<>();
pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdHelp.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdHelp.getUseageTemplate(context));
pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdList.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdList.getUseageTemplate(context));
pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdShow.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdShow.getUseageTemplate(context));
pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdPower.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdPower.getUseageTemplate(context));
pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdJoin.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdJoin.getUseageTemplate(context));
pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdLeave.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdLeave.getUseageTemplate(context));
pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdChat.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdChat.getUseageTemplate(context));
pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdToggleAllianceChat.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdToggleAllianceChat.getUseageTemplate(context));
pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdHome.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdHome.getUseageTemplate(context));
pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_NEXTCREATE.toString())); pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_NEXTCREATE.toString()));
helpPages.add(pageLines); helpPages.add(pageLines);
pageLines = new ArrayList<>(); pageLines = new ArrayList<>();
pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdCreate.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdCreate.getUseageTemplate(context));
pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdDescription.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdDescription.getUseageTemplate(context));
pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdTag.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdTag.getUseageTemplate(context));
pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_INVITATIONS.toString())); pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_INVITATIONS.toString()));
pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdOpen.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdOpen.getUseageTemplate(context));
pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdInvite.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdInvite.getUseageTemplate(context));
pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdDeinvite.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdDeinvite.getUseageTemplate(context));
pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_HOME.toString())); pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_HOME.toString()));
pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdSethome.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdSethome.getUseageTemplate(context));
helpPages.add(pageLines); helpPages.add(pageLines);
if (Econ.isSetup() && Conf.econEnabled && Conf.bankEnabled) { if (Econ.isSetup() && Conf.econEnabled && Conf.bankEnabled) {
pageLines = new ArrayList<>(); pageLines = new ArrayList<>();
pageLines.add(""); pageLines.add("");
pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_BANK_1.toString())); pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_BANK_1.toString()));
pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_BANK_2.toString())); pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_BANK_2.toString()));
pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_BANK_3.toString())); pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_BANK_3.toString()));
pageLines.add(""); pageLines.add("");
pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdMoney.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdMoney.getUseageTemplate(context));
pageLines.add(""); pageLines.add("");
pageLines.add(""); pageLines.add("");
pageLines.add(""); pageLines.add("");
helpPages.add(pageLines); helpPages.add(pageLines);
} }
pageLines = new ArrayList<>(); pageLines = new ArrayList<>();
pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdClaim.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdClaim.getUseageTemplate(context));
pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdAutoClaim.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdAutoClaim.getUseageTemplate(context));
pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdUnclaim.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdUnclaim.getUseageTemplate(context));
pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdUnclaimall.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdUnclaimall.getUseageTemplate(context));
pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdKick.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdKick.getUseageTemplate(context));
pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdMod.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdMod.getUseageTemplate(context));
pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdAdmin.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdAdmin.getUseageTemplate(context));
pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdTitle.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdTitle.getUseageTemplate(context));
pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdSB.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdSB.getUseageTemplate(context));
pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdSeeChunk.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdSeeChunk.getUseageTemplate(context));
pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdStatus.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdStatus.getUseageTemplate(context));
pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_PLAYERTITLES.toString())); pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_PLAYERTITLES.toString()));
helpPages.add(pageLines); helpPages.add(pageLines);
pageLines = new ArrayList<>(); pageLines = new ArrayList<>();
pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdMap.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdMap.getUseageTemplate(context));
pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdBoom.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdBoom.getUseageTemplate(context));
pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdOwner.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdOwner.getUseageTemplate(context));
pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdOwnerList.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdOwnerList.getUseageTemplate(context));
pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_OWNERSHIP_1.toString())); pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_OWNERSHIP_1.toString()));
pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_OWNERSHIP_2.toString())); pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_OWNERSHIP_2.toString()));
pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_OWNERSHIP_3.toString())); pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_OWNERSHIP_3.toString()));
helpPages.add(pageLines); helpPages.add(pageLines);
pageLines = new ArrayList<>(); pageLines = new ArrayList<>();
pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdDisband.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdDisband.getUseageTemplate(context));
pageLines.add(""); pageLines.add("");
pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdRelationAlly.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdRelationAlly.getUseageTemplate(context));
pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdRelationNeutral.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdRelationNeutral.getUseageTemplate(context));
pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdRelationEnemy.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdRelationEnemy.getUseageTemplate(context));
pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_RELATIONS_1.toString())); pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_RELATIONS_1.toString()));
pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_RELATIONS_2.toString())); pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_RELATIONS_2.toString()));
pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_RELATIONS_3.toString())); pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_RELATIONS_3.toString()));
pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_RELATIONS_4.toString())); pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_RELATIONS_4.toString()));
helpPages.add(pageLines); helpPages.add(pageLines);
pageLines = new ArrayList<>(); pageLines = new ArrayList<>();
pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_RELATIONS_5.toString())); pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_RELATIONS_5.toString()));
pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_RELATIONS_6.toString())); pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_RELATIONS_6.toString()));
pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_RELATIONS_7.toString())); pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_RELATIONS_7.toString()));
pageLines.add(TL.COMMAND_HELP_RELATIONS_8.toString()); pageLines.add(TL.COMMAND_HELP_RELATIONS_8.toString());
pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_RELATIONS_9.toString())); pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_RELATIONS_9.toString()));
pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_RELATIONS_10.toString())); pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_RELATIONS_10.toString()));
pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_RELATIONS_11.toString())); pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_RELATIONS_11.toString()));
pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_RELATIONS_12.toString())); pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_RELATIONS_12.toString()));
pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_RELATIONS_13.toString())); pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_RELATIONS_13.toString()));
helpPages.add(pageLines); helpPages.add(pageLines);
pageLines = new ArrayList<>(); pageLines = new ArrayList<>();
pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_PERMISSIONS_1.toString())); pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_PERMISSIONS_1.toString()));
pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_PERMISSIONS_2.toString())); pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_PERMISSIONS_2.toString()));
pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_PERMISSIONS_3.toString())); pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_PERMISSIONS_3.toString()));
pageLines.add(TL.COMMAND_HELP_PERMISSIONS_4.toString()); pageLines.add(TL.COMMAND_HELP_PERMISSIONS_4.toString());
pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_PERMISSIONS_5.toString())); pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_PERMISSIONS_5.toString()));
pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_PERMISSIONS_6.toString())); pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_PERMISSIONS_6.toString()));
pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_PERMISSIONS_7.toString())); pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_PERMISSIONS_7.toString()));
pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_PERMISSIONS_8.toString())); pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_PERMISSIONS_8.toString()));
pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_PERMISSIONS_9.toString())); pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_PERMISSIONS_9.toString()));
helpPages.add(pageLines); helpPages.add(pageLines);
pageLines = new ArrayList<>(); pageLines = new ArrayList<>();
pageLines.add(TL.COMMAND_HELP_MOAR_1.toString()); pageLines.add(TL.COMMAND_HELP_MOAR_1.toString());
pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdBypass.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdBypass.getUseageTemplate(context));
pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_ADMIN_1.toString())); pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_ADMIN_1.toString()));
pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_ADMIN_2.toString())); pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_ADMIN_2.toString()));
pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_ADMIN_3.toString())); pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_ADMIN_3.toString()));
pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdSafeunclaimall.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdSafeunclaimall.getUseageTemplate(context));
pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdWarunclaimall.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdWarunclaimall.getUseageTemplate(context));
//TODO:TL //TODO:TL
pageLines.add(FactionsPlugin.getInstance().txt.parse("<i>Note: " + FactionsPlugin.getInstance().cmdBase.cmdUnclaim.getUseageTemplate(context) + FactionsPlugin.getInstance().txt.parse("<i>") + " works on safe/war zones as well.")); pageLines.add(FactionsPlugin.getInstance().txt.parse("<i>Note: " + FactionsPlugin.getInstance().cmdBase.cmdUnclaim.getUseageTemplate(context) + FactionsPlugin.getInstance().txt.parse("<i>") + " works on safe/war zones as well."));
pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdPeaceful.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdPeaceful.getUseageTemplate(context));
helpPages.add(pageLines); helpPages.add(pageLines);
pageLines = new ArrayList<>(); pageLines = new ArrayList<>();
pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_MOAR_2.toString())); pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_MOAR_2.toString()));
pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdChatSpy.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdChatSpy.getUseageTemplate(context));
pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdPermanent.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdPermanent.getUseageTemplate(context));
pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdPermanentPower.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdPermanentPower.getUseageTemplate(context));
pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdPowerBoost.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdPowerBoost.getUseageTemplate(context));
pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdConfig.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdConfig.getUseageTemplate(context));
helpPages.add(pageLines); helpPages.add(pageLines);
pageLines = new ArrayList<>(); pageLines = new ArrayList<>();
pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_MOAR_3.toString())); pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_MOAR_3.toString()));
pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdLock.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdLock.getUseageTemplate(context));
pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdReload.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdReload.getUseageTemplate(context));
pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdSaveAll.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdSaveAll.getUseageTemplate(context));
pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdVersion.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdVersion.getUseageTemplate(context));
helpPages.add(pageLines); helpPages.add(pageLines);
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_HELP_DESCRIPTION; return TL.COMMAND_HELP_DESCRIPTION;
} }
} }

View File

@ -20,118 +20,118 @@ import java.util.List;
public class CmdHome extends FCommand { public class CmdHome extends FCommand {
public CmdHome() { public CmdHome() {
super(); super();
this.aliases.add("home"); this.aliases.add("home");
this.requirements = new CommandRequirements.Builder(Permission.HOME) this.requirements = new CommandRequirements.Builder(Permission.HOME)
.playerOnly() .playerOnly()
.memberOnly() .memberOnly()
.withAction(PermissableAction.HOME) .withAction(PermissableAction.HOME)
.build(); .build();
} }
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
// TODO: Hide this command on help also. // TODO: Hide this command on help also.
if (!Conf.homesEnabled) { if (!Conf.homesEnabled) {
context.msg(TL.COMMAND_HOME_DISABLED); context.msg(TL.COMMAND_HOME_DISABLED);
return; return;
} }
if (!Conf.homesTeleportCommandEnabled) { if (!Conf.homesTeleportCommandEnabled) {
context.msg(TL.COMMAND_HOME_TELEPORTDISABLED); context.msg(TL.COMMAND_HOME_TELEPORTDISABLED);
return; return;
} }
if (!context.faction.hasHome()) { if (!context.faction.hasHome()) {
context.msg(TL.COMMAND_HOME_NOHOME.toString() + (context.fPlayer.getRole().value < Role.MODERATOR.value ? TL.GENERIC_ASKYOURLEADER.toString() : TL.GENERIC_YOUSHOULD.toString())); context.msg(TL.COMMAND_HOME_NOHOME.toString() + (context.fPlayer.getRole().value < Role.MODERATOR.value ? TL.GENERIC_ASKYOURLEADER.toString() : TL.GENERIC_YOUSHOULD.toString()));
context.sendMessage(FactionsPlugin.getInstance().cmdBase.cmdSethome.getUseageTemplate(context)); context.sendMessage(FactionsPlugin.getInstance().cmdBase.cmdSethome.getUseageTemplate(context));
return; return;
} }
if (!Conf.homesTeleportAllowedFromEnemyTerritory && context.fPlayer.isInEnemyTerritory()) { if (!Conf.homesTeleportAllowedFromEnemyTerritory && context.fPlayer.isInEnemyTerritory()) {
context.msg(TL.COMMAND_HOME_INENEMY); context.msg(TL.COMMAND_HOME_INENEMY);
return; return;
} }
if (!Conf.homesTeleportAllowedFromDifferentWorld && context.player.getWorld().getUID() != context.faction.getHome().getWorld().getUID()) { if (!Conf.homesTeleportAllowedFromDifferentWorld && context.player.getWorld().getUID() != context.faction.getHome().getWorld().getUID()) {
context.msg(TL.COMMAND_HOME_WRONGWORLD); context.msg(TL.COMMAND_HOME_WRONGWORLD);
return; return;
} }
if (!context.fPlayer.isAdminBypassing()) { if (!context.fPlayer.isAdminBypassing()) {
Access access = context.faction.getAccess(context.fPlayer, PermissableAction.HOME); Access access = context.faction.getAccess(context.fPlayer, PermissableAction.HOME);
if (access != Access.ALLOW && context.fPlayer.getRole() != Role.LEADER) { if (access != Access.ALLOW && context.fPlayer.getRole() != Role.LEADER) {
context.fPlayer.msg(TL.GENERIC_FPERM_NOPERMISSION, "teleport home"); context.fPlayer.msg(TL.GENERIC_FPERM_NOPERMISSION, "teleport home");
return; return;
} }
} }
Faction faction = Board.getInstance().getFactionAt(new FLocation(context.player.getLocation())); Faction faction = Board.getInstance().getFactionAt(new FLocation(context.player.getLocation()));
final Location loc = context.player.getLocation().clone(); final Location loc = context.player.getLocation().clone();
// if player is not in a safe zone or their own faction territory, only allow teleport if no enemies are nearby // 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() && (!context.fPlayer.isInOwnTerritory() || !Conf.homesTeleportIgnoreEnemiesIfInOwnTerritory)) { if (Conf.homesTeleportAllowedEnemyDistance > 0 && !faction.isSafeZone() && (!context.fPlayer.isInOwnTerritory() || !Conf.homesTeleportIgnoreEnemiesIfInOwnTerritory)) {
World w = loc.getWorld(); World w = loc.getWorld();
double x = loc.getX(); double x = loc.getX();
double y = loc.getY(); double y = loc.getY();
double z = loc.getZ(); double z = loc.getZ();
for (Player p : context.player.getServer().getOnlinePlayers()) { for (Player p : context.player.getServer().getOnlinePlayers()) {
if (p == null || !p.isOnline() || p.isDead() || p == context.player || p.getWorld() != w) { if (p == null || !p.isOnline() || p.isDead() || p == context.player || p.getWorld() != w) {
continue; continue;
} }
FPlayer fp = FPlayers.getInstance().getByPlayer(p); FPlayer fp = FPlayers.getInstance().getByPlayer(p);
if (context.fPlayer.getRelationTo(fp) != Relation.ENEMY || fp.isVanished()) { if (context.fPlayer.getRelationTo(fp) != Relation.ENEMY || fp.isVanished()) {
continue; continue;
} }
Location l = p.getLocation(); Location l = p.getLocation();
double dx = Math.abs(x - l.getX()); double dx = Math.abs(x - l.getX());
double dy = Math.abs(y - l.getY()); double dy = Math.abs(y - l.getY());
double dz = Math.abs(z - l.getZ()); double dz = Math.abs(z - l.getZ());
double max = Conf.homesTeleportAllowedEnemyDistance; double max = Conf.homesTeleportAllowedEnemyDistance;
// box-shaped distance check // box-shaped distance check
if (dx > max || dy > max || dz > max) { if (dx > max || dy > max || dz > max) {
continue; continue;
} }
context.msg(TL.COMMAND_HOME_ENEMYNEAR, String.valueOf(Conf.homesTeleportAllowedEnemyDistance)); context.msg(TL.COMMAND_HOME_ENEMYNEAR, String.valueOf(Conf.homesTeleportAllowedEnemyDistance));
return; return;
} }
} }
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
if (!context.payForCommand(Conf.econCostHome, TL.COMMAND_HOME_TOTELEPORT.toString(), TL.COMMAND_HOME_FORTELEPORT.toString())) { if (!context.payForCommand(Conf.econCostHome, TL.COMMAND_HOME_TOTELEPORT.toString(), TL.COMMAND_HOME_FORTELEPORT.toString())) {
return; return;
} }
// if Essentials teleport handling is enabled and available, pass the teleport off to it (for delay and cooldown) // if Essentials teleport handling is enabled and available, pass the teleport off to it (for delay and cooldown)
if (Essentials.handleTeleport(context.player, context.faction.getHome())) { if (Essentials.handleTeleport(context.player, context.faction.getHome())) {
return; return;
} }
context.doWarmUp(WarmUpUtil.Warmup.HOME, TL.WARMUPS_NOTIFY_TELEPORT, "Home", () -> { context.doWarmUp(WarmUpUtil.Warmup.HOME, TL.WARMUPS_NOTIFY_TELEPORT, "Home", () -> {
// Create a smoke effect // Create a smoke effect
if (Conf.homesTeleportCommandSmokeEffectEnabled) { if (Conf.homesTeleportCommandSmokeEffectEnabled) {
List<Location> smokeLocations = new ArrayList<>(); List<Location> smokeLocations = new ArrayList<>();
smokeLocations.add(loc); smokeLocations.add(loc);
smokeLocations.add(loc.add(0, 1, 0)); smokeLocations.add(loc.add(0, 1, 0));
smokeLocations.add(context.faction.getHome()); smokeLocations.add(context.faction.getHome());
smokeLocations.add(context.faction.getHome().clone().add(0, 1, 0)); smokeLocations.add(context.faction.getHome().clone().add(0, 1, 0));
SmokeUtil.spawnCloudRandom(smokeLocations, Conf.homesTeleportCommandSmokeEffectThickness); SmokeUtil.spawnCloudRandom(smokeLocations, Conf.homesTeleportCommandSmokeEffectThickness);
} }
context.player.teleport(context.faction.getHome()); context.player.teleport(context.faction.getHome());
}, FactionsPlugin.getInstance().getConfig().getLong("warmups.f-home", 0)); }, FactionsPlugin.getInstance().getConfig().getLong("warmups.f-home", 0));
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_HOME_DESCRIPTION; return TL.COMMAND_HOME_DESCRIPTION;
} }
} }

View File

@ -4,33 +4,33 @@ import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
public class CmdInspect extends FCommand { public class CmdInspect extends FCommand {
public CmdInspect() { public CmdInspect() {
super(); super();
this.aliases.add("inspect"); this.aliases.add("inspect");
this.aliases.add("ins"); this.aliases.add("ins");
this.requirements = new CommandRequirements.Builder(Permission.INSPECT) this.requirements = new CommandRequirements.Builder(Permission.INSPECT)
.playerOnly() .playerOnly()
.memberOnly() .memberOnly()
.build(); .build();
} }
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
if (context.fPlayer.isInspectMode()) { if (context.fPlayer.isInspectMode()) {
context.fPlayer.setInspectMode(false); context.fPlayer.setInspectMode(false);
context.msg(TL.COMMAND_INSPECT_DISABLED_MSG); context.msg(TL.COMMAND_INSPECT_DISABLED_MSG);
} else { } else {
context.fPlayer.setInspectMode(true); context.fPlayer.setInspectMode(true);
context.msg(TL.COMMAND_INSPECT_ENABLED); context.msg(TL.COMMAND_INSPECT_ENABLED);
} }
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_INSPECT_DESCRIPTION; return TL.COMMAND_INSPECT_DESCRIPTION;
} }
} }

View File

@ -16,50 +16,50 @@ import java.util.Objects;
public class CmdInventorySee extends FCommand { public class CmdInventorySee extends FCommand {
public CmdInventorySee() { public CmdInventorySee() {
super(); super();
this.aliases.add("invsee"); this.aliases.add("invsee");
this.aliases.add("inventorysee"); this.aliases.add("inventorysee");
this.requiredArgs.add("member name"); this.requiredArgs.add("member name");
this.requirements = new CommandRequirements.Builder(Permission.INVSEE) this.requirements = new CommandRequirements.Builder(Permission.INVSEE)
.playerOnly() .playerOnly()
.build(); .build();
} }
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
if (!FactionsPlugin.getInstance().getConfig().getBoolean("f-inventory-see.Enabled")) { if (!FactionsPlugin.getInstance().getConfig().getBoolean("f-inventory-see.Enabled")) {
context.msg(TL.GENERIC_DISABLED); context.msg(TL.GENERIC_DISABLED);
return; return;
} }
Access use = context.fPlayer.getFaction().getAccess(context.fPlayer, PermissableAction.TERRITORY); Access use = context.fPlayer.getFaction().getAccess(context.fPlayer, PermissableAction.TERRITORY);
if (use == Access.DENY || (use == Access.UNDEFINED && !context.assertMinRole(Role.MODERATOR))) { if (use == Access.DENY || (use == Access.UNDEFINED && !context.assertMinRole(Role.MODERATOR))) {
context.msg(TL.GENERIC_NOPERMISSION, "territory"); context.msg(TL.GENERIC_NOPERMISSION, "territory");
return; return;
} }
ArrayList<Player> fplayers = context.fPlayer.getFaction().getOnlinePlayers(); ArrayList<Player> fplayers = context.fPlayer.getFaction().getOnlinePlayers();
FPlayer targetInv = context.argAsFPlayer(0); FPlayer targetInv = context.argAsFPlayer(0);
if (targetInv == null || !fplayers.contains(targetInv.getPlayer())) { if (targetInv == null || !fplayers.contains(targetInv.getPlayer())) {
context.msg(TL.PLAYER_NOT_FOUND, Objects.requireNonNull(targetInv).toString()); context.msg(TL.PLAYER_NOT_FOUND, Objects.requireNonNull(targetInv).toString());
return; return;
} }
Inventory inventory = Bukkit.createInventory(context.player, 36, targetInv.getName() + "'s Inventory"); Inventory inventory = Bukkit.createInventory(context.player, 36, targetInv.getName() + "'s Inventory");
for (int i = 0; i < 36; i++) for (int i = 0; i < 36; i++)
if (targetInv.getPlayer().getInventory().getItem(i) != null) if (targetInv.getPlayer().getInventory().getItem(i) != null)
inventory.setItem(i, targetInv.getPlayer().getInventory().getItem(i)); inventory.setItem(i, targetInv.getPlayer().getInventory().getItem(i));
context.player.openInventory(inventory); context.player.openInventory(inventory);
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_INVENTORYSEE_DESCRIPTION; return TL.COMMAND_INVENTORYSEE_DESCRIPTION;
} }
} }

View File

@ -11,69 +11,69 @@ import org.bukkit.ChatColor;
public class CmdInvite extends FCommand { public class CmdInvite extends FCommand {
public CmdInvite() { public CmdInvite() {
super(); super();
this.aliases.add("invite"); this.aliases.add("invite");
this.aliases.add("inv"); this.aliases.add("inv");
this.requiredArgs.add("player name"); this.requiredArgs.add("player name");
this.requirements = new CommandRequirements.Builder(Permission.INVITE) this.requirements = new CommandRequirements.Builder(Permission.INVITE)
.playerOnly() .playerOnly()
.withAction(PermissableAction.INVITE) .withAction(PermissableAction.INVITE)
.build(); .build();
} }
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
FPlayer target = context.argAsBestFPlayerMatch(0); FPlayer target = context.argAsBestFPlayerMatch(0);
if (target == null) { if (target == null) {
return; return;
} }
if (target.getFaction() == context.faction) { if (target.getFaction() == context.faction) {
context.msg(TL.COMMAND_INVITE_ALREADYMEMBER, target.getName(), context.faction.getTag()); context.msg(TL.COMMAND_INVITE_ALREADYMEMBER, target.getName(), context.faction.getTag());
context.msg(TL.GENERIC_YOUMAYWANT.toString() + FactionsPlugin.getInstance().cmdBase.cmdKick.getUseageTemplate(context)); context.msg(TL.GENERIC_YOUMAYWANT.toString() + FactionsPlugin.getInstance().cmdBase.cmdKick.getUseageTemplate(context));
return; return;
} }
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
if (!context.payForCommand(Conf.econCostInvite, TL.COMMAND_INVITE_TOINVITE.toString(), TL.COMMAND_INVITE_FORINVITE.toString())) { if (!context.payForCommand(Conf.econCostInvite, TL.COMMAND_INVITE_TOINVITE.toString(), TL.COMMAND_INVITE_FORINVITE.toString())) {
return; return;
} }
if (context.faction.isInvited(target)) { if (context.faction.isInvited(target)) {
context.msg(TL.COMMAND_INVITE_ALREADYINVITED, target.getName()); context.msg(TL.COMMAND_INVITE_ALREADYINVITED, target.getName());
return; return;
} }
if (context.faction.isBanned(target)) { if (context.faction.isBanned(target)) {
context.msg(TL.COMMAND_INVITE_BANNED, target.getName()); context.msg(TL.COMMAND_INVITE_BANNED, target.getName());
return; return;
} }
context.faction.invite(target); context.faction.invite(target);
// Send the invitation to the target player when online, otherwise just ignore // Send the invitation to the target player when online, otherwise just ignore
if (target.isOnline()) { if (target.isOnline()) {
// Tooltips, colors, and commands only apply to the string immediately before it. // Tooltips, colors, and commands only apply to the string immediately before it.
FancyMessage message = new FancyMessage(context.fPlayer.describeTo(target, true)) FancyMessage message = new FancyMessage(context.fPlayer.describeTo(target, true))
.tooltip(TL.COMMAND_INVITE_CLICKTOJOIN.toString()) .tooltip(TL.COMMAND_INVITE_CLICKTOJOIN.toString())
.command("/" + Conf.baseCommandAliases.get(0) + " join " + context.faction.getTag()) .command("/" + Conf.baseCommandAliases.get(0) + " join " + context.faction.getTag())
.then(TL.COMMAND_INVITE_INVITEDYOU.toString()) .then(TL.COMMAND_INVITE_INVITEDYOU.toString())
.color(ChatColor.YELLOW) .color(ChatColor.YELLOW)
.tooltip(TL.COMMAND_INVITE_CLICKTOJOIN.toString()) .tooltip(TL.COMMAND_INVITE_CLICKTOJOIN.toString())
.command("/" + Conf.baseCommandAliases.get(0) + " join " + context.faction.getTag()) .command("/" + Conf.baseCommandAliases.get(0) + " join " + context.faction.getTag())
.then(context.faction.describeTo(target)).tooltip(TL.COMMAND_INVITE_CLICKTOJOIN.toString()) .then(context.faction.describeTo(target)).tooltip(TL.COMMAND_INVITE_CLICKTOJOIN.toString())
.command("/" + Conf.baseCommandAliases.get(0) + " join " + context.faction.getTag()); .command("/" + Conf.baseCommandAliases.get(0) + " join " + context.faction.getTag());
message.send(target.getPlayer()); message.send(target.getPlayer());
} }
context.faction.msg(TL.COMMAND_INVITE_INVITED, context.fPlayer.describeTo(context.faction, true), target.describeTo(context.faction)); context.faction.msg(TL.COMMAND_INVITE_INVITED, context.fPlayer.describeTo(context.faction, true), target.describeTo(context.faction));
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_INVITE_DESCRIPTION; return TL.COMMAND_INVITE_DESCRIPTION;
} }
} }

View File

@ -9,132 +9,132 @@ import org.bukkit.Bukkit;
public class CmdJoin extends FCommand { public class CmdJoin extends FCommand {
public CmdJoin() { public CmdJoin() {
super(); super();
this.aliases.add("join"); this.aliases.add("join");
this.requiredArgs.add("faction name"); this.requiredArgs.add("faction name");
this.optionalArgs.put("player", "you"); this.optionalArgs.put("player", "you");
this.requirements = new CommandRequirements.Builder(Permission.JOIN) this.requirements = new CommandRequirements.Builder(Permission.JOIN)
.playerOnly() .playerOnly()
.build(); .build();
} }
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
Faction faction = context.argAsFaction(0); Faction faction = context.argAsFaction(0);
if (faction == null) { if (faction == null) {
return; return;
} }
FPlayer fplayer = context.argAsBestFPlayerMatch(1, context.fPlayer, false); FPlayer fplayer = context.argAsBestFPlayerMatch(1, context.fPlayer, false);
boolean samePlayer = fplayer == context.fPlayer; boolean samePlayer = fplayer == context.fPlayer;
if (!samePlayer && !Permission.JOIN_OTHERS.has(context.sender, false)) { if (!samePlayer && !Permission.JOIN_OTHERS.has(context.sender, false)) {
context.msg(TL.COMMAND_JOIN_CANNOTFORCE); context.msg(TL.COMMAND_JOIN_CANNOTFORCE);
return; return;
} }
if (!faction.isNormal()) { if (!faction.isNormal()) {
context.msg(TL.COMMAND_JOIN_SYSTEMFACTION); context.msg(TL.COMMAND_JOIN_SYSTEMFACTION);
return; return;
} }
if (faction == fplayer.getFaction()) { if (faction == fplayer.getFaction()) {
context.msg(TL.COMMAND_JOIN_ALREADYMEMBER, fplayer.describeTo(context.fPlayer, true), (samePlayer ? "are" : "is"), faction.getTag(context.fPlayer)); context.msg(TL.COMMAND_JOIN_ALREADYMEMBER, fplayer.describeTo(context.fPlayer, true), (samePlayer ? "are" : "is"), faction.getTag(context.fPlayer));
return; return;
} }
if (Conf.factionMemberLimit > 0 && faction.getFPlayers().size() >= getFactionMemberLimit(faction)) { if (Conf.factionMemberLimit > 0 && faction.getFPlayers().size() >= getFactionMemberLimit(faction)) {
context.msg(TL.COMMAND_JOIN_ATLIMIT, faction.getTag(context.fPlayer), getFactionMemberLimit(faction), fplayer.describeTo(context.fPlayer, false)); context.msg(TL.COMMAND_JOIN_ATLIMIT, faction.getTag(context.fPlayer), getFactionMemberLimit(faction), fplayer.describeTo(context.fPlayer, false));
return; return;
} }
if (fplayer.hasFaction()) { if (fplayer.hasFaction()) {
context.msg(TL.COMMAND_JOIN_INOTHERFACTION, fplayer.describeTo(context.fPlayer, true), (samePlayer ? "your" : "their")); context.msg(TL.COMMAND_JOIN_INOTHERFACTION, fplayer.describeTo(context.fPlayer, true), (samePlayer ? "your" : "their"));
return; return;
} }
if (!Conf.canLeaveWithNegativePower && fplayer.getPower() < 0) { if (!Conf.canLeaveWithNegativePower && fplayer.getPower() < 0) {
context.msg(TL.COMMAND_JOIN_NEGATIVEPOWER, fplayer.describeTo(context.fPlayer, true)); context.msg(TL.COMMAND_JOIN_NEGATIVEPOWER, fplayer.describeTo(context.fPlayer, true));
return; return;
} }
if (!(faction.getOpen() || faction.isInvited(fplayer) || context.fPlayer.isAdminBypassing() || Permission.JOIN_ANY.has(context.sender, false))) { if (!(faction.getOpen() || faction.isInvited(fplayer) || context.fPlayer.isAdminBypassing() || Permission.JOIN_ANY.has(context.sender, false))) {
context.msg(TL.COMMAND_JOIN_REQUIRESINVITATION); context.msg(TL.COMMAND_JOIN_REQUIRESINVITATION);
if (samePlayer) { if (samePlayer) {
faction.msg(TL.COMMAND_JOIN_ATTEMPTEDJOIN, fplayer.describeTo(faction, true)); faction.msg(TL.COMMAND_JOIN_ATTEMPTEDJOIN, fplayer.describeTo(faction, true));
} }
return; return;
} }
int altLimit = Conf.factionAltMemberLimit; int altLimit = Conf.factionAltMemberLimit;
if (altLimit > 0 && faction.getAltPlayers().size() >= altLimit && !faction.altInvited(context.fPlayer)) { if (altLimit > 0 && faction.getAltPlayers().size() >= altLimit && !faction.altInvited(context.fPlayer)) {
context.msg(TL.COMMAND_JOIN_ATLIMIT, faction.getTag(context.fPlayer), altLimit, fplayer.describeTo(context.fPlayer, false)); context.msg(TL.COMMAND_JOIN_ATLIMIT, faction.getTag(context.fPlayer), altLimit, fplayer.describeTo(context.fPlayer, false));
return; 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 economy is enabled, they're not on the bypass list, and this command has a cost set, make sure they can pay
if (samePlayer && !context.canAffordCommand(Conf.econCostJoin, TL.COMMAND_JOIN_TOJOIN.toString())) { if (samePlayer && !context.canAffordCommand(Conf.econCostJoin, TL.COMMAND_JOIN_TOJOIN.toString())) {
return; return;
} }
// Check for ban // Check for ban
if (!context.fPlayer.isAdminBypassing() && faction.isBanned(context.fPlayer)) { if (!context.fPlayer.isAdminBypassing() && faction.isBanned(context.fPlayer)) {
context.msg(TL.COMMAND_JOIN_BANNED, faction.getTag(context.fPlayer)); context.msg(TL.COMMAND_JOIN_BANNED, faction.getTag(context.fPlayer));
return; return;
} }
// trigger the join event (cancellable) // trigger the join event (cancellable)
FPlayerJoinEvent joinEvent = new FPlayerJoinEvent(FPlayers.getInstance().getByPlayer(context.player), faction, FPlayerJoinEvent.PlayerJoinReason.COMMAND); FPlayerJoinEvent joinEvent = new FPlayerJoinEvent(FPlayers.getInstance().getByPlayer(context.player), faction, FPlayerJoinEvent.PlayerJoinReason.COMMAND);
Bukkit.getServer().getPluginManager().callEvent(joinEvent); Bukkit.getServer().getPluginManager().callEvent(joinEvent);
if (joinEvent.isCancelled()) { if (joinEvent.isCancelled()) {
return; return;
} }
// then make 'em pay (if applicable) // then make 'em pay (if applicable)
if (samePlayer && !context.payForCommand(Conf.econCostJoin, TL.COMMAND_JOIN_TOJOIN.toString(), TL.COMMAND_JOIN_FORJOIN.toString())) { if (samePlayer && !context.payForCommand(Conf.econCostJoin, TL.COMMAND_JOIN_TOJOIN.toString(), TL.COMMAND_JOIN_FORJOIN.toString())) {
return; return;
} }
context.msg(TL.COMMAND_JOIN_SUCCESS, fplayer.describeTo(context.fPlayer, true), faction.getTag(context.fPlayer)); context.msg(TL.COMMAND_JOIN_SUCCESS, fplayer.describeTo(context.fPlayer, true), faction.getTag(context.fPlayer));
if (!samePlayer) { if (!samePlayer) {
fplayer.msg(TL.COMMAND_JOIN_MOVED, context.fPlayer.describeTo(fplayer, true), faction.getTag(fplayer)); fplayer.msg(TL.COMMAND_JOIN_MOVED, context.fPlayer.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)) { if (faction.altInvited(fplayer)) {
fplayer.setAlt(true); fplayer.setAlt(true);
fplayer.setFaction(faction, true); fplayer.setFaction(faction, true);
} else { } else {
fplayer.setFaction(faction, false); fplayer.setFaction(faction, false);
} }
faction.deinvite(fplayer); faction.deinvite(fplayer);
context.fPlayer.setRole(faction.getDefaultRole()); context.fPlayer.setRole(faction.getDefaultRole());
if (Conf.logFactionJoin) { if (Conf.logFactionJoin) {
if (samePlayer) { if (samePlayer) {
FactionsPlugin.getInstance().log(TL.COMMAND_JOIN_JOINEDLOG.toString(), fplayer.getName(), faction.getTag()); FactionsPlugin.getInstance().log(TL.COMMAND_JOIN_JOINEDLOG.toString(), fplayer.getName(), faction.getTag());
} else { } else {
FactionsPlugin.getInstance().log(TL.COMMAND_JOIN_MOVEDLOG.toString(), context.fPlayer.getName(), fplayer.getName(), faction.getTag()); FactionsPlugin.getInstance().log(TL.COMMAND_JOIN_MOVEDLOG.toString(), context.fPlayer.getName(), fplayer.getName(), faction.getTag());
} }
} }
} }
private int getFactionMemberLimit(Faction f) { private int getFactionMemberLimit(Faction f) {
if (f.getUpgrade(UpgradeType.MEMBERS) == 0) return Conf.factionMemberLimit; if (f.getUpgrade(UpgradeType.MEMBERS) == 0) return Conf.factionMemberLimit;
return Conf.factionMemberLimit + FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Members.Member-Boost.level-" + f.getUpgrade(UpgradeType.MEMBERS)); return Conf.factionMemberLimit + FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Members.Member-Boost.level-" + f.getUpgrade(UpgradeType.MEMBERS));
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_JOIN_DESCRIPTION; return TL.COMMAND_JOIN_DESCRIPTION;
} }
} }

View File

@ -16,115 +16,115 @@ import org.bukkit.command.ConsoleCommandSender;
public class CmdKick extends FCommand { public class CmdKick extends FCommand {
public CmdKick() { public CmdKick() {
super(); super();
this.aliases.add("kick"); this.aliases.add("kick");
this.optionalArgs.put("player name", "player name"); this.optionalArgs.put("player name", "player name");
this.requirements = new CommandRequirements.Builder(Permission.KICK) this.requirements = new CommandRequirements.Builder(Permission.KICK)
.playerOnly() .playerOnly()
.withAction(PermissableAction.KICK) .withAction(PermissableAction.KICK)
.memberOnly() .memberOnly()
.build(); .build();
} }
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
FPlayer toKick = context.argIsSet(0) ? context.argAsBestFPlayerMatch(0) : null; FPlayer toKick = context.argIsSet(0) ? context.argAsBestFPlayerMatch(0) : null;
if (toKick == null) { if (toKick == null) {
FancyMessage msg = new FancyMessage(TL.COMMAND_KICK_CANDIDATES.toString()).color(ChatColor.GOLD); FancyMessage msg = new FancyMessage(TL.COMMAND_KICK_CANDIDATES.toString()).color(ChatColor.GOLD);
for (FPlayer player : context.faction.getFPlayersWhereRole(Role.NORMAL)) { for (FPlayer player : context.faction.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 (context.fPlayer.getRole().isAtLeast(Role.COLEADER)) {
// For both coleader and admin, add mods.
for (FPlayer player : context.faction.getFPlayersWhereRole(Role.MODERATOR)) {
String s = player.getName(); String s = player.getName();
msg.then(s + " ").color(ChatColor.WHITE).tooltip(TL.COMMAND_KICK_CLICKTOKICK.toString() + s).command("/" + Conf.baseCommandAliases.get(0) + " kick " + s); msg.then(s + " ").color(ChatColor.GRAY).tooltip(TL.COMMAND_KICK_CLICKTOKICK.toString() + s).command("/" + Conf.baseCommandAliases.get(0) + " kick " + s);
} }
if (context.fPlayer.getRole().isAtLeast(Role.COLEADER)) { if (context.fPlayer.getRole() == Role.LEADER) {
// For both coleader and admin, add mods. // Only add coleader to this for the leader.
for (FPlayer player : context.faction.getFPlayersWhereRole(Role.MODERATOR)) { for (FPlayer player : context.faction.getFPlayersWhereRole(Role.COLEADER)) {
String s = player.getName(); String s = player.getName();
msg.then(s + " ").color(ChatColor.GRAY).tooltip(TL.COMMAND_KICK_CLICKTOKICK.toString() + s).command("/" + Conf.baseCommandAliases.get(0) + " kick " + s); msg.then(s + " ").color(ChatColor.RED).tooltip(TL.COMMAND_KICK_CLICKTOKICK.toString() + s).command("/" + Conf.baseCommandAliases.get(0) + " kick " + s);
} }
if (context.fPlayer.getRole() == Role.LEADER) { }
// Only add coleader to this for the leader. }
for (FPlayer player : context.faction.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);
}
}
}
context.sendFancyMessage(msg); context.sendFancyMessage(msg);
return; return;
} }
if (context.fPlayer == toKick) { if (context.fPlayer == toKick) {
context.msg(TL.COMMAND_KICK_SELF); context.msg(TL.COMMAND_KICK_SELF);
context.msg(TL.GENERIC_YOUMAYWANT.toString() + FactionsPlugin.getInstance().cmdBase.cmdLeave.getUseageTemplate(context)); context.msg(TL.GENERIC_YOUMAYWANT.toString() + FactionsPlugin.getInstance().cmdBase.cmdLeave.getUseageTemplate(context));
return; return;
} }
Faction toKickFaction = toKick.getFaction(); Faction toKickFaction = toKick.getFaction();
if (toKickFaction.isWilderness()) { if (toKickFaction.isWilderness()) {
context.sender.sendMessage(TL.COMMAND_KICK_NONE.toString()); context.sender.sendMessage(TL.COMMAND_KICK_NONE.toString());
return; return;
} }
// This permission check has been cleaned to be more understandable and logical // This permission check has been cleaned to be more understandable and logical
// Unless is admin, // Unless is admin,
// - Check for the kick permission. // - Check for the kick permission.
// - Make sure the player is in the faction. // - Make sure the player is in the faction.
// - Make sure the kicked player has lower rank than the kicker. // - Make sure the kicked player has lower rank than the kicker.
if (!context.fPlayer.isAdminBypassing()) { if (!context.fPlayer.isAdminBypassing()) {
if (toKickFaction != context.faction) { if (toKickFaction != context.faction) {
context.msg(TL.COMMAND_KICK_NOTMEMBER, toKick.describeTo(context.fPlayer, true), context.faction.describeTo(context.fPlayer)); context.msg(TL.COMMAND_KICK_NOTMEMBER, toKick.describeTo(context.fPlayer, true), context.faction.describeTo(context.fPlayer));
return; return;
} }
if (toKick.getRole().value >= context.fPlayer.getRole().value) { if (toKick.getRole().value >= context.fPlayer.getRole().value) {
context.msg(TL.COMMAND_KICK_INSUFFICIENTRANK); context.msg(TL.COMMAND_KICK_INSUFFICIENTRANK);
return; return;
} }
if (!Conf.canLeaveWithNegativePower && toKick.getPower() < 0) { if (!Conf.canLeaveWithNegativePower && toKick.getPower() < 0) {
context.msg(TL.COMMAND_KICK_NEGATIVEPOWER); context.msg(TL.COMMAND_KICK_NEGATIVEPOWER);
return; 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 economy is enabled, they're not on the bypass list, and this command has a cost set, make sure they can pay
if (!context.canAffordCommand(Conf.econCostKick, TL.COMMAND_KICK_TOKICK.toString())) { if (!context.canAffordCommand(Conf.econCostKick, TL.COMMAND_KICK_TOKICK.toString())) {
return; return;
} }
// trigger the leave event (cancellable) [reason:kicked] // trigger the leave event (cancellable) [reason:kicked]
FPlayerLeaveEvent event = new FPlayerLeaveEvent(toKick, toKick.getFaction(), FPlayerLeaveEvent.PlayerLeaveReason.KICKED); FPlayerLeaveEvent event = new FPlayerLeaveEvent(toKick, toKick.getFaction(), FPlayerLeaveEvent.PlayerLeaveReason.KICKED);
Bukkit.getServer().getPluginManager().callEvent(event); Bukkit.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) { if (event.isCancelled()) {
return; return;
} }
// then make 'em pay (if applicable) // then make 'em pay (if applicable)
if (!context.payForCommand(Conf.econCostKick, TL.COMMAND_KICK_TOKICK.toString(), TL.COMMAND_KICK_FORKICK.toString())) { if (!context.payForCommand(Conf.econCostKick, TL.COMMAND_KICK_TOKICK.toString(), TL.COMMAND_KICK_FORKICK.toString())) {
return; return;
} }
toKickFaction.msg(TL.COMMAND_KICK_FACTION, context.fPlayer.describeTo(toKickFaction, true), toKick.describeTo(toKickFaction, true)); toKickFaction.msg(TL.COMMAND_KICK_FACTION, context.fPlayer.describeTo(toKickFaction, true), toKick.describeTo(toKickFaction, true));
toKick.msg(TL.COMMAND_KICK_KICKED, context.fPlayer.describeTo(toKick, true), toKickFaction.describeTo(toKick)); toKick.msg(TL.COMMAND_KICK_KICKED, context.fPlayer.describeTo(toKick, true), toKickFaction.describeTo(toKick));
if (toKickFaction != context.faction) { if (toKickFaction != context.faction) {
context.fPlayer.msg(TL.COMMAND_KICK_KICKS, toKick.describeTo(context.fPlayer), toKickFaction.describeTo(context.fPlayer)); context.fPlayer.msg(TL.COMMAND_KICK_KICKS, toKick.describeTo(context.fPlayer), toKickFaction.describeTo(context.fPlayer));
} }
if (Conf.logFactionKick) { if (Conf.logFactionKick) {
FactionsPlugin.getInstance().log((context.sender instanceof ConsoleCommandSender ? "A console command" : context.fPlayer.getName()) + " kicked " + toKick.getName() + " from the faction: " + toKickFaction.getTag()); FactionsPlugin.getInstance().log((context.sender instanceof ConsoleCommandSender ? "A console command" : context.fPlayer.getName()) + " kicked " + toKick.getName() + " from the faction: " + toKickFaction.getTag());
} }
if (toKick.getRole() == Role.LEADER) { if (toKick.getRole() == Role.LEADER) {
toKickFaction.promoteNewLeader(); toKickFaction.promoteNewLeader();
} }
toKickFaction.deinvite(toKick); toKickFaction.deinvite(toKick);
toKick.resetFactionData(); toKick.resetFactionData();
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_KICK_DESCRIPTION; return TL.COMMAND_KICK_DESCRIPTION;
} }
} }

View File

@ -4,26 +4,26 @@ import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
public class CmdKillHolograms extends FCommand { public class CmdKillHolograms extends FCommand {
public CmdKillHolograms() { public CmdKillHolograms() {
super(); super();
this.aliases.add("killholos"); this.aliases.add("killholos");
this.requiredArgs.add("radius"); this.requiredArgs.add("radius");
this.requirements = new CommandRequirements.Builder(Permission.KILLHOLOS) this.requirements = new CommandRequirements.Builder(Permission.KILLHOLOS)
.playerOnly() .playerOnly()
.build(); .build();
} }
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
context.player.sendMessage("Killing Invisible Armor Stands.."); context.player.sendMessage("Killing Invisible Armor Stands..");
context.player.chat("/minecraft:kill @e[type=ArmorStand,r=" + context.argAsInt(0) + "]"); context.player.chat("/minecraft:kill @e[type=ArmorStand,r=" + context.argAsInt(0) + "]");
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_KILLHOLOGRAMS_DESCRIPTION; return TL.COMMAND_KILLHOLOGRAMS_DESCRIPTION;
} }
} }

View File

@ -5,24 +5,24 @@ import com.massivecraft.factions.zcore.util.TL;
public class CmdLeave extends FCommand { public class CmdLeave extends FCommand {
public CmdLeave() { public CmdLeave() {
super(); super();
this.aliases.add("leave"); this.aliases.add("leave");
this.requirements = new CommandRequirements.Builder(Permission.LEAVE) this.requirements = new CommandRequirements.Builder(Permission.LEAVE)
.playerOnly() .playerOnly()
.memberOnly() .memberOnly()
.build(); .build();
} }
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
context.fPlayer.leave(true); context.fPlayer.leave(true);
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.LEAVE_DESCRIPTION; return TL.LEAVE_DESCRIPTION;
} }
} }

View File

@ -14,103 +14,103 @@ import java.util.List;
public class CmdList extends FCommand { public class CmdList extends FCommand {
private String[] defaults = new String[3]; private String[] defaults = new String[3];
public CmdList() { public CmdList() {
super(); super();
this.aliases.add("list"); this.aliases.add("list");
this.aliases.add("ls"); this.aliases.add("ls");
// default values in case user has old config // default values in case user has old config
defaults[0] = "&e&m----------&r&e[ &2Faction List &9{pagenumber}&e/&9{pagecount} &e]&m----------"; defaults[0] = "&e&m----------&r&e[ &2Faction List &9{pagenumber}&e/&9{pagecount} &e]&m----------";
defaults[1] = "<i>Factionless<i> {factionless} online"; defaults[1] = "<i>Factionless<i> {factionless} online";
defaults[2] = "<a>{faction} <i>{online} / {members} online, <a>Land / Power / Maxpower: <i>{chunks}/{power}/{maxPower}"; defaults[2] = "<a>{faction} <i>{online} / {members} online, <a>Land / Power / Maxpower: <i>{chunks}/{power}/{maxPower}";
//this.requiredArgs.add(""); //this.requiredArgs.add("");
this.optionalArgs.put("page", "1"); this.optionalArgs.put("page", "1");
this.requirements = new CommandRequirements.Builder(Permission.LIST) this.requirements = new CommandRequirements.Builder(Permission.LIST)
.playerOnly() .playerOnly()
.build(); .build();
} }
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
if (!context.payForCommand(Conf.econCostList, "to list the factions", "for listing the factions")) if (!context.payForCommand(Conf.econCostList, "to list the factions", "for listing the factions"))
return; return;
ArrayList<Faction> factionList = Factions.getInstance().getAllFactions(); ArrayList<Faction> factionList = Factions.getInstance().getAllFactions();
factionList.remove(Factions.getInstance().getWilderness()); factionList.remove(Factions.getInstance().getWilderness());
factionList.remove(Factions.getInstance().getSafeZone()); factionList.remove(Factions.getInstance().getSafeZone());
factionList.remove(Factions.getInstance().getWarZone()); factionList.remove(Factions.getInstance().getWarZone());
// remove exempt factions // remove exempt factions
if (context.fPlayer != null && context.fPlayer.getPlayer() != null && !context.fPlayer.getPlayer().hasPermission("factions.show.bypassexempt")) { if (context.fPlayer != null && context.fPlayer.getPlayer() != null && !context.fPlayer.getPlayer().hasPermission("factions.show.bypassexempt")) {
List<String> exemptFactions = FactionsPlugin.getInstance().getConfig().getStringList("show-exempt"); List<String> exemptFactions = FactionsPlugin.getInstance().getConfig().getStringList("show-exempt");
factionList.removeIf(next -> exemptFactions.contains(next.getTag())); factionList.removeIf(next -> exemptFactions.contains(next.getTag()));
} }
// Sort by total followers first // Sort by total followers first
factionList.sort((f1, f2) -> { factionList.sort((f1, f2) -> {
int f1Size = f1.getFPlayers().size(); int f1Size = f1.getFPlayers().size();
int f2Size = f2.getFPlayers().size(); int f2Size = f2.getFPlayers().size();
if (f1Size < f2Size) { if (f1Size < f2Size) {
return 1; return 1;
} else if (f1Size > f2Size) { } else if (f1Size > f2Size) {
return -1; return -1;
} }
return 0; return 0;
}); });
// Then sort by how many members are online now // Then sort by how many members are online now
factionList.sort((f1, f2) -> { factionList.sort((f1, f2) -> {
int f1Size = f1.getFPlayersWhereOnline(true).size(); int f1Size = f1.getFPlayersWhereOnline(true).size();
int f2Size = f2.getFPlayersWhereOnline(true).size(); int f2Size = f2.getFPlayersWhereOnline(true).size();
if (f1Size < f2Size) { if (f1Size < f2Size) {
return 1; return 1;
} else if (f1Size > f2Size) { } else if (f1Size > f2Size) {
return -1; return -1;
} }
return 0; return 0;
}); });
ArrayList<String> lines = new ArrayList<>(); ArrayList<String> lines = new ArrayList<>();
factionList.add(0, Factions.getInstance().getWilderness()); factionList.add(0, Factions.getInstance().getWilderness());
final int pageheight = 9; final int pageheight = 9;
int pagenumber = context.argAsInt(0, 1); int pagenumber = context.argAsInt(0, 1);
int pagecount = (factionList.size() / pageheight) + 1; int pagecount = (factionList.size() / pageheight) + 1;
if (pagenumber > pagecount) { if (pagenumber > pagecount) {
pagenumber = pagecount; pagenumber = pagecount;
} else if (pagenumber < 1) { } else if (pagenumber < 1) {
pagenumber = 1; pagenumber = 1;
} }
int start = (pagenumber - 1) * pageheight; int start = (pagenumber - 1) * pageheight;
int end = start + pageheight; int end = start + pageheight;
if (end > factionList.size()) { if (end > factionList.size()) {
end = factionList.size(); end = factionList.size();
} }
String header = FactionsPlugin.getInstance().getConfig().getString("list.header", defaults[0]); String header = FactionsPlugin.getInstance().getConfig().getString("list.header", defaults[0]);
header = header.replace("{pagenumber}", String.valueOf(pagenumber)).replace("{pagecount}", String.valueOf(pagecount)); header = header.replace("{pagenumber}", String.valueOf(pagenumber)).replace("{pagecount}", String.valueOf(pagecount));
lines.add(FactionsPlugin.getInstance().txt.parse(header)); lines.add(FactionsPlugin.getInstance().txt.parse(header));
for (Faction faction : factionList.subList(start, end)) { for (Faction faction : factionList.subList(start, end)) {
if (faction.isWilderness()) { if (faction.isWilderness()) {
lines.add(FactionsPlugin.getInstance().txt.parse(TagUtil.parsePlain(faction, FactionsPlugin.getInstance().getConfig().getString("list.factionless", defaults[1])))); lines.add(FactionsPlugin.getInstance().txt.parse(TagUtil.parsePlain(faction, FactionsPlugin.getInstance().getConfig().getString("list.factionless", defaults[1]))));
continue; continue;
} }
lines.add(FactionsPlugin.getInstance().txt.parse(TagUtil.parsePlain(faction, context.fPlayer, FactionsPlugin.getInstance().getConfig().getString("list.entry", defaults[2])))); lines.add(FactionsPlugin.getInstance().txt.parse(TagUtil.parsePlain(faction, context.fPlayer, FactionsPlugin.getInstance().getConfig().getString("list.entry", defaults[2]))));
} }
context.sendMessage(lines); context.sendMessage(lines);
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_LIST_DESCRIPTION; return TL.COMMAND_LIST_DESCRIPTION;
} }
} }

View File

@ -6,33 +6,33 @@ import com.massivecraft.factions.zcore.util.TL;
public class CmdLock extends FCommand { public class CmdLock extends FCommand {
// TODO: This solution needs refactoring. // TODO: This solution needs refactoring.
/* /*
factions.lock: factions.lock:
description: use the /f lock [on/off] command to temporarily lock the data files from being overwritten description: use the /f lock [on/off] command to temporarily lock the data files from being overwritten
default: op default: op
*/ */
public CmdLock() { public CmdLock() {
super(); super();
this.aliases.add("lock"); this.aliases.add("lock");
this.optionalArgs.put("on/off", "flip"); this.optionalArgs.put("on/off", "flip");
this.requirements = new CommandRequirements.Builder(Permission.LOCK) this.requirements = new CommandRequirements.Builder(Permission.LOCK)
.playerOnly() .playerOnly()
.build(); .build();
} }
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
FactionsPlugin.getInstance().setLocked(context.argAsBool(0, !FactionsPlugin.getInstance().getLocked())); FactionsPlugin.getInstance().setLocked(context.argAsBool(0, !FactionsPlugin.getInstance().getLocked()));
context.msg(FactionsPlugin.getInstance().getLocked() ? TL.COMMAND_LOCK_LOCKED : TL.COMMAND_LOCK_UNLOCKED); context.msg(FactionsPlugin.getInstance().getLocked() ? TL.COMMAND_LOCK_LOCKED : TL.COMMAND_LOCK_UNLOCKED);
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_LOCK_DESCRIPTION; return TL.COMMAND_LOCK_DESCRIPTION;
} }
} }

View File

@ -5,28 +5,28 @@ import com.massivecraft.factions.zcore.util.TL;
public class CmdLogins extends FCommand { public class CmdLogins extends FCommand {
public CmdLogins() { public CmdLogins() {
super(); super();
this.aliases.add("login"); this.aliases.add("login");
this.aliases.add("logins"); this.aliases.add("logins");
this.aliases.add("logout"); this.aliases.add("logout");
this.aliases.add("logouts"); this.aliases.add("logouts");
this.requirements = new CommandRequirements.Builder(Permission.MONITOR_LOGINS) this.requirements = new CommandRequirements.Builder(Permission.MONITOR_LOGINS)
.playerOnly() .playerOnly()
.memberOnly() .memberOnly()
.build(); .build();
} }
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
boolean monitor = context.fPlayer.isMonitoringJoins(); boolean monitor = context.fPlayer.isMonitoringJoins();
context.msg(TL.COMMAND_LOGINS_TOGGLE, String.valueOf(!monitor)); context.msg(TL.COMMAND_LOGINS_TOGGLE, String.valueOf(!monitor));
context.fPlayer.setMonitorJoins(!monitor); context.fPlayer.setMonitorJoins(!monitor);
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_LOGINS_DESCRIPTION; return TL.COMMAND_LOGINS_DESCRIPTION;
} }
} }

View File

@ -7,33 +7,33 @@ import com.massivecraft.factions.zcore.util.TL;
public class CmdLowPower extends FCommand { public class CmdLowPower extends FCommand {
public CmdLowPower() { public CmdLowPower() {
super(); super();
this.aliases.add("lowpower"); this.aliases.add("lowpower");
this.requirements = new CommandRequirements.Builder(Permission.POWER_ANY) this.requirements = new CommandRequirements.Builder(Permission.POWER_ANY)
.playerOnly() .playerOnly()
.memberOnly() .memberOnly()
.build(); .build();
} }
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
double maxPower = Conf.powerPlayerMax; double maxPower = Conf.powerPlayerMax;
String format = TL.COMMAND_LOWPOWER_FORMAT.toString(); String format = TL.COMMAND_LOWPOWER_FORMAT.toString();
context.msg(TL.COMMAND_LOWPOWER_HEADER.toString().replace("{maxpower}", (int) maxPower + "")); context.msg(TL.COMMAND_LOWPOWER_HEADER.toString().replace("{maxpower}", (int) maxPower + ""));
for (FPlayer fPlayer : context.faction.getFPlayers()) { for (FPlayer fPlayer : context.faction.getFPlayers()) {
if (fPlayer.getPower() < maxPower) { if (fPlayer.getPower() < maxPower) {
context.sendMessage(format.replace("{player}", fPlayer.getName()).replace("{player_power}", (int) fPlayer.getPower() + "").replace("{maxpower}", (int) maxPower + "")); context.sendMessage(format.replace("{player}", fPlayer.getName()).replace("{player_power}", (int) fPlayer.getPower() + "").replace("{maxpower}", (int) maxPower + ""));
} }
} }
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_LOWPOWER_DESCRIPTION; return TL.COMMAND_LOWPOWER_DESCRIPTION;
} }
} }

View File

@ -9,55 +9,55 @@ import com.massivecraft.factions.zcore.util.TL;
public class CmdMap extends FCommand { public class CmdMap extends FCommand {
public CmdMap() { public CmdMap() {
super(); super();
this.aliases.add("map"); this.aliases.add("map");
this.optionalArgs.put("on/off", "once"); this.optionalArgs.put("on/off", "once");
this.requirements = new CommandRequirements.Builder(Permission.MAP) this.requirements = new CommandRequirements.Builder(Permission.MAP)
.playerOnly() .playerOnly()
.build(); .build();
} }
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
if (context.argIsSet(0)) { if (context.argIsSet(0)) {
if (context.argAsBool(0, !context.fPlayer.isMapAutoUpdating())) { if (context.argAsBool(0, !context.fPlayer.isMapAutoUpdating())) {
// Turn on // Turn on
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
if (!context.payForCommand(Conf.econCostMap, "to show the map", "for showing the map")) { if (!context.payForCommand(Conf.econCostMap, "to show the map", "for showing the map")) {
return;
}
context.fPlayer.setMapAutoUpdating(true);
context.msg(TL.COMMAND_MAP_UPDATE_ENABLED);
// And show the map once
showMap(context);
} else {
// Turn off
context.fPlayer.setMapAutoUpdating(false);
context.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 (!context.payForCommand(Conf.econCostMap, TL.COMMAND_MAP_TOSHOW, TL.COMMAND_MAP_FORSHOW)) {
return; return;
} }
showMap(context); context.fPlayer.setMapAutoUpdating(true);
} context.msg(TL.COMMAND_MAP_UPDATE_ENABLED);
}
public void showMap(CommandContext context) { // And show the map once
context.sendFancyMessage(Board.getInstance().getMap(context.fPlayer, new FLocation(context.fPlayer), context.player.getLocation().getYaw())); showMap(context);
} } else {
// Turn off
context.fPlayer.setMapAutoUpdating(false);
context.msg(TL.COMMAND_MAP_UPDATE_DISABLED);
@Override }
public TL getUsageTranslation() { } else {
return TL.COMMAND_MAP_DESCRIPTION; // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
} if (!context.payForCommand(Conf.econCostMap, TL.COMMAND_MAP_TOSHOW, TL.COMMAND_MAP_FORSHOW)) {
return;
}
showMap(context);
}
}
public void showMap(CommandContext context) {
context.sendFancyMessage(Board.getInstance().getMap(context.fPlayer, new FLocation(context.fPlayer), context.player.getLocation().getYaw()));
}
@Override
public TL getUsageTranslation() {
return TL.COMMAND_MAP_DESCRIPTION;
}
} }

View File

@ -5,34 +5,34 @@ import com.massivecraft.factions.zcore.util.TL;
public class CmdMapHeight extends FCommand { public class CmdMapHeight extends FCommand {
public CmdMapHeight() { public CmdMapHeight() {
super(); super();
this.aliases.add("mapheight"); this.aliases.add("mapheight");
this.aliases.add("mh"); this.aliases.add("mh");
this.optionalArgs.put("height", "height"); this.optionalArgs.put("height", "height");
this.requirements = new CommandRequirements.Builder(Permission.MAPHEIGHT) this.requirements = new CommandRequirements.Builder(Permission.MAPHEIGHT)
.playerOnly() .playerOnly()
.build(); .build();
} }
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
if (context.args.size() == 0) { if (context.args.size() == 0) {
context.fPlayer.sendMessage(TL.COMMAND_MAPHEIGHT_CURRENT.format(context.fPlayer.getMapHeight())); context.fPlayer.sendMessage(TL.COMMAND_MAPHEIGHT_CURRENT.format(context.fPlayer.getMapHeight()));
return; return;
} }
int height = context.argAsInt(0); int height = context.argAsInt(0);
context.fPlayer.setMapHeight(height); context.fPlayer.setMapHeight(height);
context.msg(TL.COMMAND_MAPHEIGHT_SET.format(context.fPlayer.getMapHeight())); context.msg(TL.COMMAND_MAPHEIGHT_SET.format(context.fPlayer.getMapHeight()));
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_MAPHEIGHT_DESCRIPTION; return TL.COMMAND_MAPHEIGHT_DESCRIPTION;
} }
} }

View File

@ -11,73 +11,73 @@ import org.bukkit.ChatColor;
public class CmdMod extends FCommand { public class CmdMod extends FCommand {
public CmdMod() { public CmdMod() {
super(); super();
this.aliases.add("mod"); this.aliases.add("mod");
this.aliases.add("setmod"); this.aliases.add("setmod");
this.aliases.add("officer"); this.aliases.add("officer");
this.aliases.add("setofficer"); this.aliases.add("setofficer");
this.optionalArgs.put("player name", "name"); this.optionalArgs.put("player name", "name");
this.requirements = new CommandRequirements.Builder(Permission.MOD) this.requirements = new CommandRequirements.Builder(Permission.MOD)
.playerOnly() .playerOnly()
.memberOnly() .memberOnly()
.build(); .build();
} }
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
FPlayer you = context.argAsBestFPlayerMatch(0); FPlayer you = context.argAsBestFPlayerMatch(0);
if (you == null) { if (you == null) {
FancyMessage msg = new FancyMessage(TL.COMMAND_MOD_CANDIDATES.toString()).color(ChatColor.GOLD); FancyMessage msg = new FancyMessage(TL.COMMAND_MOD_CANDIDATES.toString()).color(ChatColor.GOLD);
for (FPlayer player : context.faction.getFPlayersWhereRole(Role.NORMAL)) { for (FPlayer player : context.faction.getFPlayersWhereRole(Role.NORMAL)) {
String s = player.getName(); String s = player.getName();
msg.then(s + " ").color(ChatColor.WHITE).tooltip(TL.COMMAND_MOD_CLICKTOPROMOTE.toString() + s).command("/" + Conf.baseCommandAliases.get(0) + " mod " + s); msg.then(s + " ").color(ChatColor.WHITE).tooltip(TL.COMMAND_MOD_CLICKTOPROMOTE.toString() + s).command("/" + Conf.baseCommandAliases.get(0) + " mod " + s);
} }
context.sendFancyMessage(msg); context.sendFancyMessage(msg);
return; return;
} }
boolean permAny = Permission.MOD_ANY.has(context.sender, false); boolean permAny = Permission.MOD_ANY.has(context.sender, false);
Faction targetFaction = you.getFaction(); Faction targetFaction = you.getFaction();
if (targetFaction != context.faction && !permAny) { if (targetFaction != context.faction && !permAny) {
context.msg(TL.COMMAND_MOD_NOTMEMBER, you.describeTo(context.fPlayer, true)); context.msg(TL.COMMAND_MOD_NOTMEMBER, you.describeTo(context.fPlayer, true));
return; return;
} }
if (context.fPlayer != null && context.fPlayer.getRole() != Role.LEADER && !permAny) { if (context.fPlayer != null && context.fPlayer.getRole() != Role.LEADER && !permAny) {
context.msg(TL.COMMAND_MOD_NOTADMIN); context.msg(TL.COMMAND_MOD_NOTADMIN);
return; return;
} }
if (you == context.fPlayer && !permAny) { if (you == context.fPlayer && !permAny) {
context.msg(TL.COMMAND_MOD_SELF); context.msg(TL.COMMAND_MOD_SELF);
return; return;
} }
if (you.getRole() == Role.LEADER) { if (you.getRole() == Role.LEADER) {
context.msg(TL.COMMAND_MOD_TARGETISADMIN); context.msg(TL.COMMAND_MOD_TARGETISADMIN);
return; return;
} }
if (you.getRole() == Role.MODERATOR) { if (you.getRole() == Role.MODERATOR) {
// Revoke // Revoke
you.setRole(Role.NORMAL); you.setRole(Role.NORMAL);
targetFaction.msg(TL.COMMAND_MOD_REVOKED, you.describeTo(targetFaction, true)); targetFaction.msg(TL.COMMAND_MOD_REVOKED, you.describeTo(targetFaction, true));
context.msg(TL.COMMAND_MOD_REVOKES, you.describeTo(context.fPlayer, true)); context.msg(TL.COMMAND_MOD_REVOKES, you.describeTo(context.fPlayer, true));
} else { } else {
// Give // Give
you.setRole(Role.MODERATOR); you.setRole(Role.MODERATOR);
targetFaction.msg(TL.COMMAND_MOD_PROMOTED, you.describeTo(targetFaction, true)); targetFaction.msg(TL.COMMAND_MOD_PROMOTED, you.describeTo(targetFaction, true));
context.msg(TL.COMMAND_MOD_PROMOTES, you.describeTo(context.fPlayer, true)); context.msg(TL.COMMAND_MOD_PROMOTES, you.describeTo(context.fPlayer, true));
} }
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_MOD_DESCRIPTION; return TL.COMMAND_MOD_DESCRIPTION;
} }
} }

View File

@ -6,39 +6,39 @@ import com.massivecraft.factions.zcore.util.TL;
public class CmdModifyPower extends FCommand { public class CmdModifyPower extends FCommand {
public CmdModifyPower() { public CmdModifyPower() {
super(); super();
this.aliases.add("pm"); this.aliases.add("pm");
this.aliases.add("mp"); this.aliases.add("mp");
this.aliases.add("modifypower"); this.aliases.add("modifypower");
this.aliases.add("modpower"); this.aliases.add("modpower");
this.requiredArgs.add("name"); this.requiredArgs.add("name");
this.requiredArgs.add("power"); this.requiredArgs.add("power");
this.requirements = new CommandRequirements.Builder(Permission.MODIFY_POWER) this.requirements = new CommandRequirements.Builder(Permission.MODIFY_POWER)
.build(); .build();
} }
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
// /f modify <name> # // /f modify <name> #
FPlayer player = context.argAsBestFPlayerMatch(0); FPlayer player = context.argAsBestFPlayerMatch(0);
Double number = context.argAsDouble(1); // returns null if not a Double. Double number = context.argAsDouble(1); // returns null if not a Double.
if (player == null || number == null) { if (player == null || number == null) {
context.sender.sendMessage(getHelpShort()); context.sender.sendMessage(getHelpShort());
return; return;
} }
player.alterPower(number); player.alterPower(number);
int newPower = player.getPowerRounded(); // int so we don't have super long doubles. int newPower = player.getPowerRounded(); // int so we don't have super long doubles.
context.msg(TL.COMMAND_MODIFYPOWER_ADDED, number, player.getName(), newPower); context.msg(TL.COMMAND_MODIFYPOWER_ADDED, number, player.getName(), newPower);
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_MODIFYPOWER_DESCRIPTION; return TL.COMMAND_MODIFYPOWER_DESCRIPTION;
} }
} }

View File

@ -9,42 +9,42 @@ import org.bukkit.entity.Entity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
public class CmdNear extends FCommand { public class CmdNear extends FCommand {
public CmdNear() { public CmdNear() {
super(); super();
this.aliases.add("near"); this.aliases.add("near");
this.aliases.add("nearby"); this.aliases.add("nearby");
this.requirements = new CommandRequirements.Builder(Permission.NEAR) this.requirements = new CommandRequirements.Builder(Permission.NEAR)
.playerOnly() .playerOnly()
.memberOnly() .memberOnly()
.build(); .build();
} }
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
if (!FactionsPlugin.getInstance().getConfig().getBoolean("fnear.Enabled")) { if (!FactionsPlugin.getInstance().getConfig().getBoolean("fnear.Enabled")) {
context.msg(TL.COMMAND_NEAR_DISABLED_MSG); context.msg(TL.COMMAND_NEAR_DISABLED_MSG);
return; return;
} }
double range = FactionsPlugin.getInstance().getConfig().getInt("fnear.Radius"); double range = FactionsPlugin.getInstance().getConfig().getInt("fnear.Radius");
String format = TL.COMMAND_NEAR_FORMAT.toString(); String format = TL.COMMAND_NEAR_FORMAT.toString();
context.msg(TL.COMMAND_NEAR_USE_MSG); context.msg(TL.COMMAND_NEAR_USE_MSG);
for (Entity e : context.player.getNearbyEntities(range, 255, range)) { for (Entity e : context.player.getNearbyEntities(range, 255, range)) {
if (e instanceof Player) { if (e instanceof Player) {
Player player = (((Player) e).getPlayer()); Player player = (((Player) e).getPlayer());
FPlayer fplayer = FPlayers.getInstance().getByPlayer(player); FPlayer fplayer = FPlayers.getInstance().getByPlayer(player);
if (context.faction == fplayer.getFaction()) { if (context.faction == fplayer.getFaction()) {
double distance = context.player.getLocation().distance(player.getLocation()); double distance = context.player.getLocation().distance(player.getLocation());
context.sendMessage(format.replace("{playername}", player.getDisplayName()).replace("{distance}", (int) distance + "")); context.sendMessage(format.replace("{playername}", player.getDisplayName()).replace("{distance}", (int) distance + ""));
} }
} }
} }
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_NEAR_DESCRIPTION; return TL.COMMAND_NEAR_DESCRIPTION;
} }
} }

View File

@ -9,42 +9,42 @@ import com.massivecraft.factions.zcore.util.TL;
public class CmdOpen extends FCommand { public class CmdOpen extends FCommand {
public CmdOpen() { public CmdOpen() {
super(); super();
this.aliases.add("open"); this.aliases.add("open");
this.optionalArgs.put("yes/no", "flip"); this.optionalArgs.put("yes/no", "flip");
this.requirements = new CommandRequirements.Builder(Permission.OPEN) this.requirements = new CommandRequirements.Builder(Permission.OPEN)
.withRole(Role.COLEADER) .withRole(Role.COLEADER)
.playerOnly() .playerOnly()
.memberOnly() .memberOnly()
.build(); .build();
} }
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
if (!context.payForCommand(Conf.econCostOpen, TL.COMMAND_OPEN_TOOPEN, TL.COMMAND_OPEN_FOROPEN)) { if (!context.payForCommand(Conf.econCostOpen, TL.COMMAND_OPEN_TOOPEN, TL.COMMAND_OPEN_FOROPEN)) {
return; return;
} }
context.faction.setOpen(context.argAsBool(0, !context.faction.getOpen())); context.faction.setOpen(context.argAsBool(0, !context.faction.getOpen()));
String open = context.faction.getOpen() ? TL.COMMAND_OPEN_OPEN.toString() : TL.COMMAND_OPEN_CLOSED.toString(); String open = context.faction.getOpen() ? TL.COMMAND_OPEN_OPEN.toString() : TL.COMMAND_OPEN_CLOSED.toString();
// Inform // Inform
for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers()) { for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers()) {
if (fplayer.getFactionId().equals(context.faction.getId())) { if (fplayer.getFactionId().equals(context.faction.getId())) {
fplayer.msg(TL.COMMAND_OPEN_CHANGES, context.fPlayer.getName(), open); fplayer.msg(TL.COMMAND_OPEN_CHANGES, context.fPlayer.getName(), open);
continue; continue;
} }
fplayer.msg(TL.COMMAND_OPEN_CHANGED, context.faction.getTag(fplayer.getFaction()), open); fplayer.msg(TL.COMMAND_OPEN_CHANGED, context.faction.getTag(fplayer.getFaction()), open);
} }
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_OPEN_DESCRIPTION; return TL.COMMAND_OPEN_DESCRIPTION;
} }
} }

View File

@ -8,94 +8,94 @@ import com.massivecraft.factions.zcore.util.TL;
public class CmdOwner extends FCommand { public class CmdOwner extends FCommand {
public CmdOwner() { public CmdOwner() {
super(); super();
this.aliases.add("owner"); this.aliases.add("owner");
this.optionalArgs.put("player name", "you"); this.optionalArgs.put("player name", "you");
this.requirements = new CommandRequirements.Builder(Permission.OWNER) this.requirements = new CommandRequirements.Builder(Permission.OWNER)
.withRole(Role.LEADER) .withRole(Role.LEADER)
.playerOnly() .playerOnly()
.memberOnly() .memberOnly()
.build(); .build();
} }
// TODO: Fix colors! // TODO: Fix colors!
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
boolean hasBypass = context.fPlayer.isAdminBypassing(); boolean hasBypass = context.fPlayer.isAdminBypassing();
if (!hasBypass && !context.assertHasFaction()) { if (!hasBypass && !context.assertHasFaction()) {
return; return;
} }
if (!Conf.ownedAreasEnabled) { if (!Conf.ownedAreasEnabled) {
context.msg(TL.COMMAND_OWNER_DISABLED); context.msg(TL.COMMAND_OWNER_DISABLED);
return; return;
} }
if (!hasBypass && Conf.ownedAreasLimitPerFaction > 0 && context.faction.getCountOfClaimsWithOwners() >= Conf.ownedAreasLimitPerFaction) { if (!hasBypass && Conf.ownedAreasLimitPerFaction > 0 && context.faction.getCountOfClaimsWithOwners() >= Conf.ownedAreasLimitPerFaction) {
context.msg(TL.COMMAND_OWNER_LIMIT, Conf.ownedAreasLimitPerFaction); context.msg(TL.COMMAND_OWNER_LIMIT, Conf.ownedAreasLimitPerFaction);
return; return;
} }
if (!hasBypass && !context.assertMinRole(Conf.ownedAreasModeratorsCanSet ? Role.MODERATOR : Role.LEADER)) { if (!hasBypass && !context.assertMinRole(Conf.ownedAreasModeratorsCanSet ? Role.MODERATOR : Role.LEADER)) {
return; return;
} }
FLocation flocation = new FLocation(context.fPlayer); FLocation flocation = new FLocation(context.fPlayer);
Faction factionHere = Board.getInstance().getFactionAt(flocation); Faction factionHere = Board.getInstance().getFactionAt(flocation);
if (factionHere != context.faction) { if (factionHere != context.faction) {
if (!factionHere.isNormal()) { if (!factionHere.isNormal()) {
context.msg(TL.COMMAND_OWNER_NOTCLAIMED); context.msg(TL.COMMAND_OWNER_NOTCLAIMED);
return; return;
} }
if (!hasBypass) { if (!hasBypass) {
context.msg(TL.COMMAND_OWNER_WRONGFACTION); context.msg(TL.COMMAND_OWNER_WRONGFACTION);
return; return;
} }
} }
FPlayer target = context.argAsBestFPlayerMatch(0, context.fPlayer); FPlayer target = context.argAsBestFPlayerMatch(0, context.fPlayer);
if (target == null) { if (target == null) {
return; return;
} }
String playerName = target.getName(); String playerName = target.getName();
if (target.getFaction() != context.faction) { if (target.getFaction() != context.faction) {
context.msg(TL.COMMAND_OWNER_NOTMEMBER, playerName); context.msg(TL.COMMAND_OWNER_NOTMEMBER, playerName);
return; return;
} }
// if no player name was passed, and this claim does already have owners set, clear them // if no player name was passed, and this claim does already have owners set, clear them
if (context.args.isEmpty() && context.faction.doesLocationHaveOwnersSet(flocation)) { if (context.args.isEmpty() && context.faction.doesLocationHaveOwnersSet(flocation)) {
context.faction.clearClaimOwnership(flocation); context.faction.clearClaimOwnership(flocation);
context.msg(TL.COMMAND_OWNER_CLEARED); context.msg(TL.COMMAND_OWNER_CLEARED);
return; return;
} }
if (context.faction.isPlayerInOwnerList(target, flocation)) { if (context.faction.isPlayerInOwnerList(target, flocation)) {
context.faction.removePlayerAsOwner(target, flocation); context.faction.removePlayerAsOwner(target, flocation);
context.msg(TL.COMMAND_OWNER_REMOVED, playerName); context.msg(TL.COMMAND_OWNER_REMOVED, playerName);
return; return;
} }
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
if (!context.payForCommand(Conf.econCostOwner, TL.COMMAND_OWNER_TOSET, TL.COMMAND_OWNER_FORSET)) { if (!context.payForCommand(Conf.econCostOwner, TL.COMMAND_OWNER_TOSET, TL.COMMAND_OWNER_FORSET)) {
return; return;
} }
context.faction.setPlayerAsOwner(target, flocation); context.faction.setPlayerAsOwner(target, flocation);
context.msg(TL.COMMAND_OWNER_ADDED, playerName); context.msg(TL.COMMAND_OWNER_ADDED, playerName);
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_OWNER_DESCRIPTION; return TL.COMMAND_OWNER_DESCRIPTION;
} }
} }

View File

@ -9,56 +9,56 @@ import com.massivecraft.factions.zcore.util.TL;
public class CmdOwnerList extends FCommand { public class CmdOwnerList extends FCommand {
public CmdOwnerList() { public CmdOwnerList() {
super(); super();
this.aliases.add("ownerlist"); this.aliases.add("ownerlist");
this.requirements = new CommandRequirements.Builder(Permission.OWNERLIST) this.requirements = new CommandRequirements.Builder(Permission.OWNERLIST)
.playerOnly() .playerOnly()
.memberOnly() .memberOnly()
.build(); .build();
} }
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
boolean hasBypass = context.fPlayer.isAdminBypassing(); boolean hasBypass = context.fPlayer.isAdminBypassing();
if (!hasBypass && !context.assertHasFaction()) { if (!hasBypass && !context.assertHasFaction()) {
return; return;
} }
if (!Conf.ownedAreasEnabled) { if (!Conf.ownedAreasEnabled) {
context.msg(TL.COMMAND_OWNERLIST_DISABLED); context.msg(TL.COMMAND_OWNERLIST_DISABLED);
return; return;
} }
FLocation flocation = new FLocation(context.fPlayer); FLocation flocation = new FLocation(context.fPlayer);
if (Board.getInstance().getFactionAt(flocation) != context.faction) { if (Board.getInstance().getFactionAt(flocation) != context.faction) {
if (!hasBypass) { if (!hasBypass) {
context.msg(TL.COMMAND_OWNERLIST_WRONGFACTION); context.msg(TL.COMMAND_OWNERLIST_WRONGFACTION);
return; return;
} }
//TODO: This code won't ever be called. //TODO: This code won't ever be called.
context.faction = Board.getInstance().getFactionAt(flocation); context.faction = Board.getInstance().getFactionAt(flocation);
if (!context.faction.isNormal()) { if (!context.faction.isNormal()) {
context.msg(TL.COMMAND_OWNERLIST_NOTCLAIMED); context.msg(TL.COMMAND_OWNERLIST_NOTCLAIMED);
return; return;
} }
} }
String owners = context.faction.getOwnerListString(flocation); String owners = context.faction.getOwnerListString(flocation);
if (owners == null || owners.isEmpty()) { if (owners == null || owners.isEmpty()) {
context.msg(TL.COMMAND_OWNERLIST_NONE); context.msg(TL.COMMAND_OWNERLIST_NONE);
return; return;
} }
context.msg(TL.COMMAND_OWNERLIST_OWNERS, owners); context.msg(TL.COMMAND_OWNERLIST_OWNERS, owners);
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_OWNERLIST_DESCRIPTION; return TL.COMMAND_OWNERLIST_DESCRIPTION;
} }
} }

View File

@ -6,52 +6,52 @@ import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
public class CmdPaypalSee extends FCommand { public class CmdPaypalSee extends FCommand {
public CmdPaypalSee() { public CmdPaypalSee() {
this.aliases.add("seepaypal"); this.aliases.add("seepaypal");
this.aliases.add("paypal"); this.aliases.add("paypal");
this.optionalArgs.put("faction", "yours"); this.optionalArgs.put("faction", "yours");
this.requirements = new CommandRequirements.Builder(Permission.PAYPAL) this.requirements = new CommandRequirements.Builder(Permission.PAYPAL)
.memberOnly() .memberOnly()
.build(); .build();
} }
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
if (!FactionsPlugin.getInstance().getConfig().getBoolean("fpaypal.Enabled")) { if (!FactionsPlugin.getInstance().getConfig().getBoolean("fpaypal.Enabled")) {
context.msg(TL.GENERIC_DISABLED); context.msg(TL.GENERIC_DISABLED);
return; return;
} }
if (context.args.size() == 0) { if (context.args.size() == 0) {
if (context.fPlayer.getFaction().getPaypal().isEmpty()) { if (context.fPlayer.getFaction().getPaypal().isEmpty()) {
context.msg(TL.COMMAND_PAYPAL_NOTSET); context.msg(TL.COMMAND_PAYPAL_NOTSET);
} else { } else {
context.msg(TL.PAYPALSEE_PLAYER_PAYPAL, context.fPlayer.getFaction().getPaypal()); context.msg(TL.PAYPALSEE_PLAYER_PAYPAL, context.fPlayer.getFaction().getPaypal());
} }
} else if (context.args.size() == 1) { } else if (context.args.size() == 1) {
if (context.fPlayer.isAdminBypassing()) { if (context.fPlayer.isAdminBypassing()) {
Faction faction = context.argAsFaction(0); Faction faction = context.argAsFaction(0);
if (faction != null) { if (faction != null) {
if (faction.getPaypal().isEmpty()) { if (faction.getPaypal().isEmpty()) {
context.msg(TL.COMMAND_PAYPALSEE_FACTION_NOTSET, faction.getTag()); context.msg(TL.COMMAND_PAYPALSEE_FACTION_NOTSET, faction.getTag());
} else { } else {
context.msg(TL.COMMAND_PAYPALSEE_FACTION_PAYPAL.toString(), faction.getTag(), faction.getPaypal()); context.msg(TL.COMMAND_PAYPALSEE_FACTION_PAYPAL.toString(), faction.getTag(), faction.getPaypal());
}
} }
} else { }
context.msg(TL.GENERIC_NOPERMISSION, "see another factions paypal."); } else {
} context.msg(TL.GENERIC_NOPERMISSION, "see another factions paypal.");
} else { }
context.msg(FactionsPlugin.getInstance().cmdBase.cmdPaypalSee.getUseageTemplate(context)); } else {
} context.msg(FactionsPlugin.getInstance().cmdBase.cmdPaypalSee.getUseageTemplate(context));
} }
}
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_PAYPALSEE_DESCRIPTION; return TL.COMMAND_PAYPALSEE_DESCRIPTION;
} }
} }

View File

@ -7,60 +7,60 @@ import com.massivecraft.factions.zcore.util.TL;
public class CmdPaypalSet extends FCommand { public class CmdPaypalSet extends FCommand {
public CmdPaypalSet() { public CmdPaypalSet() {
this.aliases.add("setpaypal"); this.aliases.add("setpaypal");
this.optionalArgs.put("faction", "yours"); this.optionalArgs.put("faction", "yours");
this.requiredArgs.add("email"); this.requiredArgs.add("email");
this.requirements = new CommandRequirements.Builder(Permission.PAYPALSET) this.requirements = new CommandRequirements.Builder(Permission.PAYPALSET)
.playerOnly() .playerOnly()
.memberOnly() .memberOnly()
.build(); .build();
} }
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
if (!FactionsPlugin.getInstance().getConfig().getBoolean("fpaypal.Enabled")) { if (!FactionsPlugin.getInstance().getConfig().getBoolean("fpaypal.Enabled")) {
context.fPlayer.msg(TL.GENERIC_DISABLED); context.fPlayer.msg(TL.GENERIC_DISABLED);
return; return;
} }
if (context.args.size() == 1) { if (context.args.size() == 1) {
if (isEmail(context.argAsString(0))) { if (isEmail(context.argAsString(0))) {
context.fPlayer.getFaction().paypalSet(context.argAsString(0)); context.fPlayer.getFaction().paypalSet(context.argAsString(0));
context.msg(TL.COMMAND_PAYPALSET_SUCCESSFUL, context.argAsString(0)); context.msg(TL.COMMAND_PAYPALSET_SUCCESSFUL, context.argAsString(0));
} else { } else {
context.msg(TL.COMMAND_PAYPALSET_NOTEMAIL, context.argAsString(0)); context.msg(TL.COMMAND_PAYPALSET_NOTEMAIL, context.argAsString(0));
} }
} else if (context.args.size() == 2) { } else if (context.args.size() == 2) {
if (context.fPlayer.isAdminBypassing()) { if (context.fPlayer.isAdminBypassing()) {
Faction faction = context.argAsFaction(1); Faction faction = context.argAsFaction(1);
if (faction != null) { if (faction != null) {
if (isEmail(context.argAsString(0))) { if (isEmail(context.argAsString(0))) {
context.fPlayer.getFaction().paypalSet(context.argAsString(0)); context.fPlayer.getFaction().paypalSet(context.argAsString(0));
context.msg(TL.COMMAND_PAYPALSET_ADMIN_SUCCESSFUL, faction.getTag(), context.argAsString(0)); context.msg(TL.COMMAND_PAYPALSET_ADMIN_SUCCESSFUL, faction.getTag(), context.argAsString(0));
} else { } else {
context.msg(TL.COMMAND_PAYPALSET_ADMIN_FAILED, context.argAsString(0)); context.msg(TL.COMMAND_PAYPALSET_ADMIN_FAILED, context.argAsString(0));
}
} }
} else { }
context.msg(TL.GENERIC_NOPERMISSION, "set another factions paypal!"); } else {
} context.msg(TL.GENERIC_NOPERMISSION, "set another factions paypal!");
} else { }
context.msg(FactionsPlugin.getInstance().cmdBase.cmdPaypalSet.getUseageTemplate(context)); } else {
} context.msg(FactionsPlugin.getInstance().cmdBase.cmdPaypalSet.getUseageTemplate(context));
} }
}
private boolean isEmail(String email) { private boolean isEmail(String email) {
return email.contains("@") && email.contains("."); return email.contains("@") && email.contains(".");
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_PAYPALSET_DESCRIPTION; return TL.COMMAND_PAYPALSET_DESCRIPTION;
} }
} }

View File

@ -8,47 +8,47 @@ import com.massivecraft.factions.zcore.util.TL;
public class CmdPeaceful extends FCommand { public class CmdPeaceful extends FCommand {
public CmdPeaceful() { public CmdPeaceful() {
super(); super();
this.aliases.add("peaceful"); this.aliases.add("peaceful");
this.requiredArgs.add("faction tag"); this.requiredArgs.add("faction tag");
this.requirements = new CommandRequirements.Builder(Permission.SET_PEACEFUL) this.requirements = new CommandRequirements.Builder(Permission.SET_PEACEFUL)
.build(); .build();
} }
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
Faction faction = context.argAsFaction(0); Faction faction = context.argAsFaction(0);
if (faction == null) { if (faction == null) {
return; return;
} }
String change; String change;
if (faction.isPeaceful()) { if (faction.isPeaceful()) {
change = TL.COMMAND_PEACEFUL_REVOKE.toString(); change = TL.COMMAND_PEACEFUL_REVOKE.toString();
faction.setPeaceful(false); faction.setPeaceful(false);
} else { } else {
change = TL.COMMAND_PEACEFUL_GRANT.toString(); change = TL.COMMAND_PEACEFUL_GRANT.toString();
faction.setPeaceful(true); faction.setPeaceful(true);
} }
// Inform all players // Inform all players
for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers()) { for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers()) {
String blame = (context.fPlayer == null ? TL.GENERIC_SERVERADMIN.toString() : context.fPlayer.describeTo(fplayer, true)); String blame = (context.fPlayer == null ? TL.GENERIC_SERVERADMIN.toString() : context.fPlayer.describeTo(fplayer, true));
if (fplayer.getFaction() == faction) { if (fplayer.getFaction() == faction) {
fplayer.msg(TL.COMMAND_PEACEFUL_YOURS, blame, change); fplayer.msg(TL.COMMAND_PEACEFUL_YOURS, blame, change);
} else { } else {
fplayer.msg(TL.COMMAND_PEACEFUL_OTHER, blame, change, faction.getTag(fplayer)); fplayer.msg(TL.COMMAND_PEACEFUL_OTHER, blame, change, faction.getTag(fplayer));
} }
} }
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_PEACEFUL_DESCRIPTION; return TL.COMMAND_PEACEFUL_DESCRIPTION;
} }
} }

View File

@ -17,102 +17,102 @@ import java.util.Set;
public class CmdPerm extends FCommand { public class CmdPerm extends FCommand {
public CmdPerm() { public CmdPerm() {
super(); super();
this.aliases.add("perm"); this.aliases.add("perm");
this.aliases.add("perms"); this.aliases.add("perms");
this.aliases.add("permission"); this.aliases.add("permission");
this.aliases.add("permissions"); this.aliases.add("permissions");
this.optionalArgs.put("relation", "relation"); this.optionalArgs.put("relation", "relation");
this.optionalArgs.put("action", "action"); this.optionalArgs.put("action", "action");
this.optionalArgs.put("access", "access"); this.optionalArgs.put("access", "access");
this.requirements = new CommandRequirements.Builder(Permission.PERMISSIONS) this.requirements = new CommandRequirements.Builder(Permission.PERMISSIONS)
.playerOnly() .playerOnly()
.memberOnly() .memberOnly()
.withRole(Role.LEADER) .withRole(Role.LEADER)
.build(); .build();
} }
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
if (context.args.size() == 0) { if (context.args.size() == 0) {
new PermissableRelationFrame(context.faction).buildGUI(context.fPlayer); new PermissableRelationFrame(context.faction).buildGUI(context.fPlayer);
return; return;
} else if (context.args.size() == 1 && getPermissable(context.argAsString(0)) != null) { } else if (context.args.size() == 1 && getPermissable(context.argAsString(0)) != null) {
new PermissableActionFrame(context.faction).buildGUI(context.fPlayer, getPermissable(context.argAsString(0))); new PermissableActionFrame(context.faction).buildGUI(context.fPlayer, getPermissable(context.argAsString(0)));
return; return;
} }
// If not opening GUI, then setting the permission manually. // If not opening GUI, then setting the permission manually.
if (context.args.size() != 3) { if (context.args.size() != 3) {
context.msg(TL.COMMAND_PERM_DESCRIPTION); context.msg(TL.COMMAND_PERM_DESCRIPTION);
return; return;
} }
Set<Permissable> permissables = new HashSet<>(); Set<Permissable> permissables = new HashSet<>();
Set<PermissableAction> permissableActions = new HashSet<>(); Set<PermissableAction> permissableActions = new HashSet<>();
boolean allRelations = context.argAsString(0).equalsIgnoreCase("all"); boolean allRelations = context.argAsString(0).equalsIgnoreCase("all");
boolean allActions = context.argAsString(1).equalsIgnoreCase("all"); boolean allActions = context.argAsString(1).equalsIgnoreCase("all");
if (allRelations) { if (allRelations) {
permissables.addAll(context.faction.getPermissions().keySet()); permissables.addAll(context.faction.getPermissions().keySet());
} else { } else {
Permissable permissable = getPermissable(context.argAsString(0)); Permissable permissable = getPermissable(context.argAsString(0));
if (permissable == null) { if (permissable == null) {
context.msg(TL.COMMAND_PERM_INVALID_RELATION); context.msg(TL.COMMAND_PERM_INVALID_RELATION);
return; return;
} }
permissables.add(permissable); permissables.add(permissable);
} }
if (allActions) { if (allActions) {
permissableActions.addAll(Arrays.asList(PermissableAction.values())); permissableActions.addAll(Arrays.asList(PermissableAction.values()));
} else { } else {
PermissableAction permissableAction = PermissableAction.fromString(context.argAsString(1)); PermissableAction permissableAction = PermissableAction.fromString(context.argAsString(1));
if (permissableAction == null) { if (permissableAction == null) {
context.msg(TL.COMMAND_PERM_INVALID_ACTION); context.msg(TL.COMMAND_PERM_INVALID_ACTION);
return; return;
} }
permissableActions.add(permissableAction); permissableActions.add(permissableAction);
} }
Access access = Access.fromString(context.argAsString(2)); Access access = Access.fromString(context.argAsString(2));
if (access == null) { if (access == null) {
context.msg(TL.COMMAND_PERM_INVALID_ACCESS); context.msg(TL.COMMAND_PERM_INVALID_ACCESS);
return; return;
} }
for (Permissable permissable : permissables) { for (Permissable permissable : permissables) {
for (PermissableAction permissableAction : permissableActions) { for (PermissableAction permissableAction : permissableActions) {
context.faction.setPermission(permissable, permissableAction, access); context.faction.setPermission(permissable, permissableAction, access);
} }
} }
context.msg(TL.COMMAND_PERM_SET, context.argAsString(1), access.name(), context.argAsString(0)); context.msg(TL.COMMAND_PERM_SET, context.argAsString(1), access.name(), context.argAsString(0));
FactionsPlugin.getInstance().log(String.format(TL.COMMAND_PERM_SET.toString(), context.argAsString(1), access.name(), context.argAsString(0)) + " for faction " + context.fPlayer.getTag()); FactionsPlugin.getInstance().log(String.format(TL.COMMAND_PERM_SET.toString(), context.argAsString(1), access.name(), context.argAsString(0)) + " for faction " + context.fPlayer.getTag());
} }
private Permissable getPermissable(String name) { private Permissable getPermissable(String name) {
if (Role.fromString(name.toUpperCase()) != null) { if (Role.fromString(name.toUpperCase()) != null) {
return Role.fromString(name.toUpperCase()); return Role.fromString(name.toUpperCase());
} else if (Relation.fromString(name.toUpperCase()) != null) { } else if (Relation.fromString(name.toUpperCase()) != null) {
return Relation.fromString(name.toUpperCase()); return Relation.fromString(name.toUpperCase());
} else { } else {
return null; return null;
} }
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_PERM_DESCRIPTION; return TL.COMMAND_PERM_DESCRIPTION;
} }
} }

View File

@ -10,47 +10,47 @@ import com.massivecraft.factions.zcore.util.TL;
public class CmdPermanent extends FCommand { public class CmdPermanent extends FCommand {
public CmdPermanent() { public CmdPermanent() {
super(); super();
this.aliases.add("permanent"); this.aliases.add("permanent");
this.requiredArgs.add("faction tag"); this.requiredArgs.add("faction tag");
this.requirements = new CommandRequirements.Builder(Permission.SET_PERMANENT) this.requirements = new CommandRequirements.Builder(Permission.SET_PERMANENT)
.build(); .build();
} }
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
Faction faction = context.argAsFaction(0); Faction faction = context.argAsFaction(0);
if (faction == null) { if (faction == null) {
return; return;
} }
String change; String change;
if (faction.isPermanent()) { if (faction.isPermanent()) {
change = TL.COMMAND_PERMANENT_REVOKE.toString(); change = TL.COMMAND_PERMANENT_REVOKE.toString();
faction.setPermanent(false); faction.setPermanent(false);
} else { } else {
change = TL.COMMAND_PERMANENT_GRANT.toString(); change = TL.COMMAND_PERMANENT_GRANT.toString();
faction.setPermanent(true); faction.setPermanent(true);
} }
FactionsPlugin.getInstance().log((context.fPlayer == null ? "A server admin" : context.fPlayer.getName()) + " " + change + " the faction \"" + faction.getTag() + "\"."); FactionsPlugin.getInstance().log((context.fPlayer == null ? "A server admin" : context.fPlayer.getName()) + " " + change + " the faction \"" + faction.getTag() + "\".");
// Inform all players // Inform all players
for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers()) { for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers()) {
String blame = (context.fPlayer == null ? TL.GENERIC_SERVERADMIN.toString() : context.fPlayer.describeTo(fplayer, true)); String blame = (context.fPlayer == null ? TL.GENERIC_SERVERADMIN.toString() : context.fPlayer.describeTo(fplayer, true));
if (fplayer.getFaction() == faction) { if (fplayer.getFaction() == faction) {
fplayer.msg(TL.COMMAND_PERMANENT_YOURS, blame, change); fplayer.msg(TL.COMMAND_PERMANENT_YOURS, blame, change);
} else { } else {
fplayer.msg(TL.COMMAND_PERMANENT_OTHER, blame, change, faction.getTag(fplayer)); fplayer.msg(TL.COMMAND_PERMANENT_OTHER, blame, change, faction.getTag(fplayer));
} }
} }
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_PERMANENT_DESCRIPTION; return TL.COMMAND_PERMANENT_DESCRIPTION;
} }
} }

View File

@ -6,47 +6,47 @@ import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
public class CmdPermanentPower extends FCommand { public class CmdPermanentPower extends FCommand {
public CmdPermanentPower() { public CmdPermanentPower() {
super(); super();
this.aliases.add("permanentpower"); this.aliases.add("permanentpower");
this.requiredArgs.add("faction"); this.requiredArgs.add("faction");
this.requiredArgs.add("power"); this.requiredArgs.add("power");
this.requirements = new CommandRequirements.Builder(Permission.SET_PERMANENTPOWER) this.requirements = new CommandRequirements.Builder(Permission.SET_PERMANENTPOWER)
.build(); .build();
} }
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
Faction targetFaction = context.argAsFaction(0); Faction targetFaction = context.argAsFaction(0);
if (targetFaction == null) { if (targetFaction == null) {
return; return;
} }
Integer targetPower = context.argAsInt(1); Integer targetPower = context.argAsInt(1);
targetFaction.setPermanentPower(targetPower); targetFaction.setPermanentPower(targetPower);
String change = TL.COMMAND_PERMANENTPOWER_REVOKE.toString(); String change = TL.COMMAND_PERMANENTPOWER_REVOKE.toString();
if (targetFaction.hasPermanentPower()) { if (targetFaction.hasPermanentPower()) {
change = TL.COMMAND_PERMANENTPOWER_GRANT.toString(); change = TL.COMMAND_PERMANENTPOWER_GRANT.toString();
} }
// Inform sender // Inform sender
context.msg(TL.COMMAND_PERMANENTPOWER_SUCCESS, change, targetFaction.describeTo(context.fPlayer)); context.msg(TL.COMMAND_PERMANENTPOWER_SUCCESS, change, targetFaction.describeTo(context.fPlayer));
// Inform all other players // Inform all other players
for (FPlayer fplayer : targetFaction.getFPlayersWhereOnline(true)) { for (FPlayer fplayer : targetFaction.getFPlayersWhereOnline(true)) {
if (fplayer == context.fPlayer) { if (fplayer == context.fPlayer) {
continue; continue;
} }
String blame = (context.fPlayer == null ? TL.GENERIC_SERVERADMIN.toString() : context.fPlayer.describeTo(fplayer, true)); String blame = (context.fPlayer == null ? TL.GENERIC_SERVERADMIN.toString() : context.fPlayer.describeTo(fplayer, true));
fplayer.msg(TL.COMMAND_PERMANENTPOWER_FACTION, blame, change); fplayer.msg(TL.COMMAND_PERMANENTPOWER_FACTION, blame, change);
} }
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_PERMANENTPOWER_DESCRIPTION; return TL.COMMAND_PERMANENTPOWER_DESCRIPTION;
} }
} }

View File

@ -7,42 +7,42 @@ import com.massivecraft.factions.zcore.util.TL;
public class CmdPower extends FCommand { public class CmdPower extends FCommand {
public CmdPower() { public CmdPower() {
super(); super();
this.aliases.add("power"); this.aliases.add("power");
this.aliases.add("pow"); this.aliases.add("pow");
this.optionalArgs.put("player name", "you"); this.optionalArgs.put("player name", "you");
this.requirements = new CommandRequirements.Builder(Permission.POWER) this.requirements = new CommandRequirements.Builder(Permission.POWER)
.build(); .build();
} }
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
FPlayer target = context.argAsBestFPlayerMatch(0, context.fPlayer); FPlayer target = context.argAsBestFPlayerMatch(0, context.fPlayer);
if (target == null) { if (target == null) {
return; return;
} }
if (target != context.fPlayer && !Permission.POWER_ANY.has(context.sender, true)) { if (target != context.fPlayer && !Permission.POWER_ANY.has(context.sender, true)) {
return; return;
} }
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
if (!context.payForCommand(Conf.econCostPower, TL.COMMAND_POWER_TOSHOW, TL.COMMAND_POWER_FORSHOW)) { if (!context.payForCommand(Conf.econCostPower, TL.COMMAND_POWER_TOSHOW, TL.COMMAND_POWER_FORSHOW)) {
return; return;
} }
double powerBoost = target.getPowerBoost(); double powerBoost = target.getPowerBoost();
String boost = (powerBoost == 0.0) ? "" : (powerBoost > 0.0 ? TL.COMMAND_POWER_BONUS.toString() : TL.COMMAND_POWER_PENALTY.toString()) + powerBoost + ")"; String boost = (powerBoost == 0.0) ? "" : (powerBoost > 0.0 ? TL.COMMAND_POWER_BONUS.toString() : TL.COMMAND_POWER_PENALTY.toString()) + powerBoost + ")";
context.msg(TL.COMMAND_POWER_POWER, target.describeTo(context.fPlayer, true), target.getPowerRounded(), target.getPowerMaxRounded(), boost); context.msg(TL.COMMAND_POWER_POWER, target.describeTo(context.fPlayer, true), target.getPowerRounded(), target.getPowerMaxRounded(), boost);
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_POWER_DESCRIPTION; return TL.COMMAND_POWER_DESCRIPTION;
} }
} }

View File

@ -9,74 +9,74 @@ import org.bukkit.command.ConsoleCommandSender;
public class CmdPowerBoost extends FCommand { public class CmdPowerBoost extends FCommand {
public CmdPowerBoost() { public CmdPowerBoost() {
super(); super();
this.aliases.add("powerboost"); this.aliases.add("powerboost");
this.requiredArgs.add("plugin|f|player|faction"); this.requiredArgs.add("plugin|f|player|faction");
this.requiredArgs.add("name"); this.requiredArgs.add("name");
this.requiredArgs.add("# or reset"); this.requiredArgs.add("# or reset");
this.requirements = new CommandRequirements.Builder(Permission.POWERBOOST) this.requirements = new CommandRequirements.Builder(Permission.POWERBOOST)
.build(); .build();
} }
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
String type = context.argAsString(0).toLowerCase(); String type = context.argAsString(0).toLowerCase();
boolean doPlayer = true; boolean doPlayer = true;
if (type.equals("f") || type.equals("faction")) { if (type.equals("f") || type.equals("faction")) {
doPlayer = false; doPlayer = false;
} else if (!type.equals("plugin") && !type.equals("player")) { } else if (!type.equals("plugin") && !type.equals("player")) {
context.msg(TL.COMMAND_POWERBOOST_HELP_1); context.msg(TL.COMMAND_POWERBOOST_HELP_1);
context.msg(TL.COMMAND_POWERBOOST_HELP_2); context.msg(TL.COMMAND_POWERBOOST_HELP_2);
return; return;
} }
Double targetPower = context.argAsDouble(2); Double targetPower = context.argAsDouble(2);
if (targetPower == null) { if (targetPower == null) {
if (context.argAsString(2).equalsIgnoreCase("reset")) { if (context.argAsString(2).equalsIgnoreCase("reset")) {
targetPower = 0D; targetPower = 0D;
} else { } else {
context.msg(TL.COMMAND_POWERBOOST_INVALIDNUM); context.msg(TL.COMMAND_POWERBOOST_INVALIDNUM);
return; return;
} }
} }
String target; String target;
if (doPlayer) { if (doPlayer) {
FPlayer targetPlayer = context.argAsBestFPlayerMatch(1); FPlayer targetPlayer = context.argAsBestFPlayerMatch(1);
if (targetPlayer == null) { if (targetPlayer == null) {
return; return;
} }
if (targetPower != 0) { if (targetPower != 0) {
targetPower += targetPlayer.getPowerBoost(); targetPower += targetPlayer.getPowerBoost();
} }
targetPlayer.setPowerBoost(targetPower); targetPlayer.setPowerBoost(targetPower);
target = TL.COMMAND_POWERBOOST_PLAYER.format(targetPlayer.getName()); target = TL.COMMAND_POWERBOOST_PLAYER.format(targetPlayer.getName());
} else { } else {
Faction targetFaction = context.argAsFaction(1); Faction targetFaction = context.argAsFaction(1);
if (targetFaction == null) { if (targetFaction == null) {
return; return;
} }
if (targetPower != 0) { if (targetPower != 0) {
targetPower += targetFaction.getPowerBoost(); targetPower += targetFaction.getPowerBoost();
} }
targetFaction.setPowerBoost(targetPower); targetFaction.setPowerBoost(targetPower);
target = TL.COMMAND_POWERBOOST_FACTION.format(targetFaction.getTag()); target = TL.COMMAND_POWERBOOST_FACTION.format(targetFaction.getTag());
} }
int roundedPower = (int) Math.round(targetPower); int roundedPower = (int) Math.round(targetPower);
context.msg(TL.COMMAND_POWERBOOST_BOOST, target, roundedPower); context.msg(TL.COMMAND_POWERBOOST_BOOST, target, roundedPower);
if (!(context.sender instanceof ConsoleCommandSender)) { if (!(context.sender instanceof ConsoleCommandSender)) {
FactionsPlugin.getInstance().log(TL.COMMAND_POWERBOOST_BOOSTLOG.toString(), context.fPlayer.getName(), target, roundedPower); FactionsPlugin.getInstance().log(TL.COMMAND_POWERBOOST_BOOSTLOG.toString(), context.fPlayer.getName(), target, roundedPower);
} }
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_POWERBOOST_DESCRIPTION; return TL.COMMAND_POWERBOOST_DESCRIPTION;
} }
} }

View File

@ -7,32 +7,32 @@ import com.massivecraft.factions.zcore.util.TL;
public class CmdReload extends FCommand { public class CmdReload extends FCommand {
public CmdReload() { public CmdReload() {
super(); super();
this.aliases.add("reload"); this.aliases.add("reload");
this.requirements = new CommandRequirements.Builder(Permission.RELOAD).build(); this.requirements = new CommandRequirements.Builder(Permission.RELOAD).build();
} }
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
long timeInitStart = System.currentTimeMillis(); long timeInitStart = System.currentTimeMillis();
Conf.load(); Conf.load();
Conf.save(); Conf.save();
FactionsPlugin.getInstance().reloadConfig(); FactionsPlugin.getInstance().reloadConfig();
FactionsPlugin.getInstance().loadLang(); FactionsPlugin.getInstance().loadLang();
if (FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight")) { if (FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight")) {
FactionsPlugin.getInstance().factionsFlight = true; FactionsPlugin.getInstance().factionsFlight = true;
} }
long timeReload = (System.currentTimeMillis() - timeInitStart); long timeReload = (System.currentTimeMillis() - timeInitStart);
context.msg(TL.COMMAND_RELOAD_TIME, timeReload); context.msg(TL.COMMAND_RELOAD_TIME, timeReload);
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_RELOAD_DESCRIPTION; return TL.COMMAND_RELOAD_DESCRIPTION;
} }
} }

View File

@ -8,80 +8,80 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
public class CmdRules extends FCommand { public class CmdRules extends FCommand {
public CmdRules() { public CmdRules() {
super(); super();
aliases.add("r"); aliases.add("r");
aliases.add("rule"); aliases.add("rule");
aliases.add("rules"); aliases.add("rules");
this.optionalArgs.put("add/remove/set/clear", ""); this.optionalArgs.put("add/remove/set/clear", "");
this.requirements = new CommandRequirements.Builder(Permission.RULES) this.requirements = new CommandRequirements.Builder(Permission.RULES)
.playerOnly() .playerOnly()
.memberOnly() .memberOnly()
.noErrorOnManyArgs() .noErrorOnManyArgs()
.build(); .build();
} }
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
if (!FactionsPlugin.getInstance().getConfig().getBoolean("frules.Enabled")) { if (!FactionsPlugin.getInstance().getConfig().getBoolean("frules.Enabled")) {
context.msg(TL.COMMAND_RULES_DISABLED_MSG); context.msg(TL.COMMAND_RULES_DISABLED_MSG);
return; return;
} }
if (context.args.size() == 0) { if (context.args.size() == 0) {
HashMap<Integer, String> rules = context.faction.getRulesMap(); HashMap<Integer, String> rules = context.faction.getRulesMap();
if (rules.size() == 0) { if (rules.size() == 0) {
List<String> ruleList = FactionsPlugin.getInstance().getConfig().getStringList("frules.default-rules"); List<String> ruleList = FactionsPlugin.getInstance().getConfig().getStringList("frules.default-rules");
context.sendMessage(FactionsPlugin.getInstance().colorList(ruleList)); context.sendMessage(FactionsPlugin.getInstance().colorList(ruleList));
} else { } else {
for (int i = 0; i <= rules.size() - 1; i++) { for (int i = 0; i <= rules.size() - 1; i++) {
context.sendMessage(FactionsPlugin.getInstance().color(rules.get(i))); context.sendMessage(FactionsPlugin.getInstance().color(rules.get(i)));
} }
} }
} }
if (context.args.size() == 1) { if (context.args.size() == 1) {
if (context.args.get(0).equalsIgnoreCase("add")) { if (context.args.get(0).equalsIgnoreCase("add")) {
context.msg(TL.COMMAND_RULES_ADD_INVALIDARGS); context.msg(TL.COMMAND_RULES_ADD_INVALIDARGS);
} }
if (context.args.get(0).equalsIgnoreCase("set")) { if (context.args.get(0).equalsIgnoreCase("set")) {
context.msg(TL.COMMAND_RULES_SET_INVALIDARGS); context.msg(TL.COMMAND_RULES_SET_INVALIDARGS);
} }
if (context.args.get(0).equalsIgnoreCase("remove")) { if (context.args.get(0).equalsIgnoreCase("remove")) {
context.msg(TL.COMMAND_RULES_REMOVE_INVALIDARGS); context.msg(TL.COMMAND_RULES_REMOVE_INVALIDARGS);
} }
if (context.args.get(0).equalsIgnoreCase("clear")) { if (context.args.get(0).equalsIgnoreCase("clear")) {
context.faction.clearRules(); context.faction.clearRules();
context.msg(TL.COMMAND_RULES_CLEAR_SUCCESS); context.msg(TL.COMMAND_RULES_CLEAR_SUCCESS);
} }
} }
if (context.args.size() >= 2) { if (context.args.size() >= 2) {
if (context.args.get(0).equalsIgnoreCase("add")) { if (context.args.get(0).equalsIgnoreCase("add")) {
String message = ""; String message = "";
StringBuilder string = new StringBuilder(message); StringBuilder string = new StringBuilder(message);
for (int i = 1; i <= context.args.size() - 1; i++) { for (int i = 1; i <= context.args.size() - 1; i++) {
string.append(" " + context.args.get(i)); string.append(" " + context.args.get(i));
} }
context.faction.addRule(string.toString()); context.faction.addRule(string.toString());
context.msg(TL.COMMAND_RULES_ADD_SUCCESS); context.msg(TL.COMMAND_RULES_ADD_SUCCESS);
} }
if (context.args.size() == 2) { if (context.args.size() == 2) {
if (context.args.get(0).equalsIgnoreCase("remove")) { if (context.args.get(0).equalsIgnoreCase("remove")) {
int index = context.argAsInt(1); int index = context.argAsInt(1);
context.faction.removeRule(index - 1); context.faction.removeRule(index - 1);
context.msg(TL.COMMAND_RULES_REMOVE_SUCCESS); context.msg(TL.COMMAND_RULES_REMOVE_SUCCESS);
} }
} }
} }
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_RULES_DESCRIPTION; return TL.COMMAND_RULES_DESCRIPTION;
} }
} }

View File

@ -6,30 +6,30 @@ import com.massivecraft.factions.zcore.util.TL;
public class CmdSB extends FCommand { public class CmdSB extends FCommand {
public CmdSB() { public CmdSB() {
this.aliases.add("sb"); this.aliases.add("sb");
this.aliases.add("scoreboard"); this.aliases.add("scoreboard");
this.requirements = new CommandRequirements.Builder(Permission.SCOREBOARD) this.requirements = new CommandRequirements.Builder(Permission.SCOREBOARD)
.playerOnly() .playerOnly()
.build(); .build();
} }
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
boolean toggleTo = !context.fPlayer.showScoreboard(); boolean toggleTo = !context.fPlayer.showScoreboard();
FScoreboard board = FScoreboard.get(context.fPlayer); FScoreboard board = FScoreboard.get(context.fPlayer);
if (board == null) { if (board == null) {
context.msg(TL.COMMAND_TOGGLESB_DISABLED.toString()); context.msg(TL.COMMAND_TOGGLESB_DISABLED.toString());
} else { } else {
context.msg(TL.TOGGLE_SB.toString().replace("{value}", String.valueOf(toggleTo))); context.msg(TL.TOGGLE_SB.toString().replace("{value}", String.valueOf(toggleTo)));
board.setSidebarVisibility(toggleTo); board.setSidebarVisibility(toggleTo);
} }
context.fPlayer.setShowScoreboard(toggleTo); context.fPlayer.setShowScoreboard(toggleTo);
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_SCOREBOARD_DESCRIPTION; return TL.COMMAND_SCOREBOARD_DESCRIPTION;
} }
} }

View File

@ -10,28 +10,28 @@ import com.massivecraft.factions.zcore.util.TL;
public class CmdSaveAll extends FCommand { public class CmdSaveAll extends FCommand {
public CmdSaveAll() { public CmdSaveAll() {
super(); super();
this.aliases.add("saveall"); this.aliases.add("saveall");
this.aliases.add("save"); this.aliases.add("save");
this.requirements = new CommandRequirements.Builder(Permission.SAVE) this.requirements = new CommandRequirements.Builder(Permission.SAVE)
.build(); .build();
} }
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
FPlayers.getInstance().forceSave(false); FPlayers.getInstance().forceSave(false);
Factions.getInstance().forceSave(false); Factions.getInstance().forceSave(false);
Board.getInstance().forceSave(false); Board.getInstance().forceSave(false);
Conf.save(); Conf.save();
ShopConfig.saveShop(); ShopConfig.saveShop();
context.msg(TL.COMMAND_SAVEALL_SUCCESS); context.msg(TL.COMMAND_SAVEALL_SUCCESS);
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_SAVEALL_DESCRIPTION; return TL.COMMAND_SAVEALL_DESCRIPTION;
} }
} }

View File

@ -15,127 +15,127 @@ import java.util.HashMap;
public class CmdSeeChunk extends FCommand { public class CmdSeeChunk extends FCommand {
//Used a hashmap cuz imma make a particle selection gui later, will store it where the boolean is rn. //Used a hashmap cuz imma make a particle selection gui later, will store it where the boolean is rn.
public static HashMap<String, Boolean> seeChunkMap = new HashMap<>(); public static HashMap<String, Boolean> seeChunkMap = new HashMap<>();
private long interval; private long interval;
private boolean useParticles; private boolean useParticles;
private ParticleEffect effect; private ParticleEffect effect;
private int taskID = -1; private int taskID = -1;
//I remade it cause of people getting mad that I had the same seechunk as drtshock //I remade it cause of people getting mad that I had the same seechunk as drtshock
public CmdSeeChunk() { public CmdSeeChunk() {
super(); super();
aliases.add("seechunk"); aliases.add("seechunk");
aliases.add("sc"); aliases.add("sc");
this.useParticles = FactionsPlugin.getInstance().getConfig().getBoolean("see-chunk.particles", true); this.useParticles = FactionsPlugin.getInstance().getConfig().getBoolean("see-chunk.particles", true);
interval = FactionsPlugin.getInstance().getConfig().getLong("see-chunk.interval", 10L); interval = FactionsPlugin.getInstance().getConfig().getLong("see-chunk.interval", 10L);
if (effect == null) { if (effect == null) {
effect = ParticleEffect.REDSTONE; effect = ParticleEffect.REDSTONE;
} }
this.requirements = new CommandRequirements.Builder(Permission.SEECHUNK) this.requirements = new CommandRequirements.Builder(Permission.SEECHUNK)
.playerOnly() .playerOnly()
.build(); .build();
} }
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
if (seeChunkMap.containsKey(context.player.getName())) { if (seeChunkMap.containsKey(context.player.getName())) {
seeChunkMap.remove(context.player.getName()); seeChunkMap.remove(context.player.getName());
context.msg(TL.COMMAND_SEECHUNK_DISABLED); context.msg(TL.COMMAND_SEECHUNK_DISABLED);
} else { } else {
seeChunkMap.put(context.player.getName(), true); seeChunkMap.put(context.player.getName(), true);
context.msg(TL.COMMAND_SEECHUNK_ENABLED); context.msg(TL.COMMAND_SEECHUNK_ENABLED);
manageTask(); manageTask();
} }
} }
private void manageTask() { private void manageTask() {
if (taskID != -1) { if (taskID != -1) {
if (seeChunkMap.keySet().size() == 0) { if (seeChunkMap.keySet().size() == 0) {
Bukkit.getScheduler().cancelTask(taskID); Bukkit.getScheduler().cancelTask(taskID);
taskID = -1; taskID = -1;
} }
} else { } else {
startTask(); startTask();
} }
} }
private void startTask() { private void startTask() {
taskID = Bukkit.getScheduler().scheduleSyncRepeatingTask(FactionsPlugin.getInstance(), () -> { taskID = Bukkit.getScheduler().scheduleSyncRepeatingTask(FactionsPlugin.getInstance(), () -> {
for (Object nameObject : seeChunkMap.keySet()) { for (Object nameObject : seeChunkMap.keySet()) {
String name = nameObject + ""; String name = nameObject + "";
Player player = Bukkit.getPlayer(name); Player player = Bukkit.getPlayer(name);
showBorders(player); showBorders(player);
} }
manageTask(); manageTask();
}, 0, interval); }, 0, interval);
} }
private void showBorders(Player me) { private void showBorders(Player me) {
World world = me.getWorld(); World world = me.getWorld();
FLocation flocation = new FLocation(me); FLocation flocation = new FLocation(me);
int chunkX = (int) flocation.getX(); int chunkX = (int) flocation.getX();
int chunkZ = (int) flocation.getZ(); int chunkZ = (int) flocation.getZ();
int blockX; int blockX;
int blockZ; int blockZ;
blockX = chunkX * 16; blockX = chunkX * 16;
blockZ = chunkZ * 16; blockZ = chunkZ * 16;
showPillar(me, world, blockX, blockZ); showPillar(me, world, blockX, blockZ);
blockX = chunkX * 16 + 15; blockX = chunkX * 16 + 15;
blockZ = chunkZ * 16; blockZ = chunkZ * 16;
showPillar(me, world, blockX, blockZ); showPillar(me, world, blockX, blockZ);
blockX = chunkX * 16; blockX = chunkX * 16;
blockZ = chunkZ * 16 + 15; blockZ = chunkZ * 16 + 15;
showPillar(me, world, blockX, blockZ); showPillar(me, world, blockX, blockZ);
blockX = chunkX * 16 + 15; blockX = chunkX * 16 + 15;
blockZ = chunkZ * 16 + 15; blockZ = chunkZ * 16 + 15;
showPillar(me, world, blockX, blockZ); 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 (FactionsPlugin.getInstance().useNonPacketParticles) {
// Dust options only exists in the 1.13 API, so we use an
// alternative method to achieve this in lower versions.
if (FactionsPlugin.getInstance().mc113 || FactionsPlugin.getInstance().mc114) {
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 (FactionsPlugin.getInstance().useNonPacketParticles) {
// Dust options only exists in the 1.13 API, so we use an
// alternative method to achieve this in lower versions.
if (FactionsPlugin.getInstance().mc113 || FactionsPlugin.getInstance().mc114) {
player.spawnParticle(Particle.REDSTONE, loc, 0, new Particle.DustOptions(Color.RED, 1));
} else { } else {
this.effect.display(0, 0, 0, 0, 1, loc, player); player.getWorld().spawnParticle(Particle.REDSTONE, loc, 0, 255, 0, 0, 1);
} }
} else {
} else { this.effect.display(0, 0, 0, 0, 1, loc, player);
Material type = blockY % 5 == 0 ? XMaterial.REDSTONE_LAMP.parseMaterial() : XMaterial.BLACK_STAINED_GLASS.parseMaterial(); }
VisualizeUtil.addLocation(player, loc, type);
}
}
}
@Override } else {
public TL getUsageTranslation() { Material type = blockY % 5 == 0 ? XMaterial.REDSTONE_LAMP.parseMaterial() : XMaterial.BLACK_STAINED_GLASS.parseMaterial();
return TL.GENERIC_PLACEHOLDER; VisualizeUtil.addLocation(player, loc, type);
} }
}
}
@Override
public TL getUsageTranslation() {
return TL.GENERIC_PLACEHOLDER;
}
} }

View File

@ -5,31 +5,31 @@ import com.massivecraft.factions.zcore.util.TL;
public class CmdSetBanner extends FCommand { public class CmdSetBanner extends FCommand {
public CmdSetBanner() { public CmdSetBanner() {
super(); super();
aliases.add("setbanner"); aliases.add("setbanner");
this.requirements = new CommandRequirements.Builder(Permission.BANNER) this.requirements = new CommandRequirements.Builder(Permission.BANNER)
.playerOnly() .playerOnly()
.build(); .build();
} }
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
if (!context.player.getItemInHand().getType().toString().contains("BANNER")) { if (!context.player.getItemInHand().getType().toString().contains("BANNER")) {
context.msg(TL.COMMAND_SETBANNER_NOTBANNER); context.msg(TL.COMMAND_SETBANNER_NOTBANNER);
return; return;
} }
context.faction.setBannerPattern(context.player.getItemInHand()); context.faction.setBannerPattern(context.player.getItemInHand());
context.msg(TL.COMMAND_SETBANNER_SUCCESS); context.msg(TL.COMMAND_SETBANNER_SUCCESS);
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_SETBANNER_DESCRIPTION; return TL.COMMAND_SETBANNER_DESCRIPTION;
} }
} }

View File

@ -6,41 +6,41 @@ import com.massivecraft.factions.zcore.util.TL;
public class CmdSetDefaultRole extends FCommand { public class CmdSetDefaultRole extends FCommand {
public CmdSetDefaultRole() { public CmdSetDefaultRole() {
super(); super();
this.aliases.add("defaultrole"); this.aliases.add("defaultrole");
this.aliases.add("defaultrank"); this.aliases.add("defaultrank");
this.aliases.add("default"); this.aliases.add("default");
this.aliases.add("def"); this.aliases.add("def");
this.requiredArgs.add("role"); this.requiredArgs.add("role");
this.requirements = new CommandRequirements.Builder(Permission.DEFAULTRANK) this.requirements = new CommandRequirements.Builder(Permission.DEFAULTRANK)
.playerOnly() .playerOnly()
.memberOnly() .memberOnly()
.build(); .build();
} }
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
Role target = Role.fromString(context.argAsString(0).toUpperCase()); Role target = Role.fromString(context.argAsString(0).toUpperCase());
if (target == null) { if (target == null) {
context.msg(TL.COMMAND_SETDEFAULTROLE_INVALIDROLE, context.argAsString(0)); context.msg(TL.COMMAND_SETDEFAULTROLE_INVALIDROLE, context.argAsString(0));
return; return;
} }
if (target == Role.LEADER) { if (target == Role.LEADER) {
context.msg(TL.COMMAND_SETDEFAULTROLE_NOTTHATROLE, context.argAsString(0)); context.msg(TL.COMMAND_SETDEFAULTROLE_NOTTHATROLE, context.argAsString(0));
return; return;
} }
context.faction.setDefaultRole(target); context.faction.setDefaultRole(target);
context.msg(TL.COMMAND_SETDEFAULTROLE_SUCCESS, target.nicename); context.msg(TL.COMMAND_SETDEFAULTROLE_SUCCESS, target.nicename);
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_SETDEFAULTROLE_DESCRIPTION; return TL.COMMAND_SETDEFAULTROLE_DESCRIPTION;
} }
} }

View File

@ -10,61 +10,61 @@ import com.massivecraft.factions.zcore.util.TL;
public class CmdSetFWarp extends FCommand { public class CmdSetFWarp extends FCommand {
public CmdSetFWarp() { public CmdSetFWarp() {
super(); super();
this.aliases.add("setwarp"); this.aliases.add("setwarp");
this.aliases.add("sw"); this.aliases.add("sw");
this.requiredArgs.add("warp name"); this.requiredArgs.add("warp name");
this.optionalArgs.put("password", "password"); this.optionalArgs.put("password", "password");
this.requirements = new CommandRequirements.Builder(Permission.SETWARP) this.requirements = new CommandRequirements.Builder(Permission.SETWARP)
.playerOnly() .playerOnly()
.memberOnly() .memberOnly()
.withAction(PermissableAction.SETWARP) .withAction(PermissableAction.SETWARP)
.build(); .build();
} }
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
if (!(context.fPlayer.getRelationToLocation() == Relation.MEMBER)) { if (!(context.fPlayer.getRelationToLocation() == Relation.MEMBER)) {
context.msg(TL.COMMAND_SETFWARP_NOTCLAIMED); context.msg(TL.COMMAND_SETFWARP_NOTCLAIMED);
return; return;
} }
String warp = context.argAsString(0); String warp = context.argAsString(0);
// Checks if warp with same name already exists and ignores maxWarp check if it does. // Checks if warp with same name already exists and ignores maxWarp check if it does.
boolean warpExists = context.faction.isWarp(warp); boolean warpExists = context.faction.isWarp(warp);
int maxWarps = FactionsPlugin.getInstance().getConfig().getInt("max-warps", 5); int maxWarps = FactionsPlugin.getInstance().getConfig().getInt("max-warps", 5);
boolean tooManyWarps = maxWarps <= context.faction.getWarps().size(); boolean tooManyWarps = maxWarps <= context.faction.getWarps().size();
if (tooManyWarps && !warpExists) { if (tooManyWarps && !warpExists) {
context.msg(TL.COMMAND_SETFWARP_LIMIT, maxWarps); context.msg(TL.COMMAND_SETFWARP_LIMIT, maxWarps);
return; return;
} }
if (!transact(context.fPlayer, context)) { if (!transact(context.fPlayer, context)) {
return; return;
} }
String password = context.argAsString(1); String password = context.argAsString(1);
LazyLocation loc = new LazyLocation(context.player.getLocation()); LazyLocation loc = new LazyLocation(context.player.getLocation());
context.faction.setWarp(warp, loc); context.faction.setWarp(warp, loc);
if (password != null) { if (password != null) {
context.faction.setWarpPassword(warp, password); context.faction.setWarpPassword(warp, password);
} }
context.msg(TL.COMMAND_SETFWARP_SET, warp, password != null ? password : ""); context.msg(TL.COMMAND_SETFWARP_SET, warp, password != null ? password : "");
} }
private boolean transact(FPlayer player, CommandContext context) { private boolean transact(FPlayer player, CommandContext context) {
return !FactionsPlugin.getInstance().getConfig().getBoolean("warp-cost.enabled", false) || player.isAdminBypassing() || context.payForCommand(FactionsPlugin.getInstance().getConfig().getDouble("warp-cost.setwarp", 5), TL.COMMAND_SETFWARP_TOSET.toString(), TL.COMMAND_SETFWARP_FORSET.toString()); return !FactionsPlugin.getInstance().getConfig().getBoolean("warp-cost.enabled", false) || player.isAdminBypassing() || context.payForCommand(FactionsPlugin.getInstance().getConfig().getDouble("warp-cost.setwarp", 5), TL.COMMAND_SETFWARP_TOSET.toString(), TL.COMMAND_SETFWARP_FORSET.toString());
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_SETFWARP_DESCRIPTION; return TL.COMMAND_SETFWARP_DESCRIPTION;
} }
} }

View File

@ -7,36 +7,36 @@ import org.bukkit.ChatColor;
public class CmdSetMaxVaults extends FCommand { public class CmdSetMaxVaults extends FCommand {
public CmdSetMaxVaults() { public CmdSetMaxVaults() {
this.aliases.add("setmaxvaults"); this.aliases.add("setmaxvaults");
this.aliases.add("smv"); this.aliases.add("smv");
this.requiredArgs.add("faction"); this.requiredArgs.add("faction");
this.requiredArgs.add("number"); this.requiredArgs.add("number");
this.requirements = new CommandRequirements.Builder(Permission.SETMAXVAULTS) this.requirements = new CommandRequirements.Builder(Permission.SETMAXVAULTS)
.build(); .build();
} }
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
Faction targetFaction = context.argAsFaction(0); Faction targetFaction = context.argAsFaction(0);
int value = context.argAsInt(1, -1); int value = context.argAsInt(1, -1);
if (value < 0) { if (value < 0) {
context.sender.sendMessage(ChatColor.RED + "Number must be greater than 0."); context.sender.sendMessage(ChatColor.RED + "Number must be greater than 0.");
return; return;
} }
if (targetFaction == null) { if (targetFaction == null) {
context.sender.sendMessage(ChatColor.RED + "Couldn't find Faction: " + ChatColor.YELLOW + context.argAsString(0)); context.sender.sendMessage(ChatColor.RED + "Couldn't find Faction: " + ChatColor.YELLOW + context.argAsString(0));
return; return;
} }
targetFaction.setMaxVaults(value); targetFaction.setMaxVaults(value);
context.sender.sendMessage(TL.COMMAND_SETMAXVAULTS_SUCCESS.format(targetFaction.getTag(), value)); context.sender.sendMessage(TL.COMMAND_SETMAXVAULTS_SUCCESS.format(targetFaction.getTag(), value));
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_SETMAXVAULTS_DESCRIPTION; return TL.COMMAND_SETMAXVAULTS_DESCRIPTION;
} }
} }

View File

@ -7,54 +7,54 @@ import com.massivecraft.factions.zcore.util.TL;
public class CmdSethome extends FCommand { public class CmdSethome extends FCommand {
public CmdSethome() { public CmdSethome() {
this.aliases.add("sethome"); this.aliases.add("sethome");
this.optionalArgs.put("faction tag", "mine"); this.optionalArgs.put("faction tag", "mine");
this.requirements = new CommandRequirements.Builder(Permission.SETHOME) this.requirements = new CommandRequirements.Builder(Permission.SETHOME)
.playerOnly() .playerOnly()
.memberOnly() .memberOnly()
.withAction(PermissableAction.SETHOME) .withAction(PermissableAction.SETHOME)
.build(); .build();
} }
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
if (!Conf.homesEnabled) { if (!Conf.homesEnabled) {
context.msg(TL.COMMAND_SETHOME_DISABLED); context.msg(TL.COMMAND_SETHOME_DISABLED);
return; return;
} }
Faction faction = context.argAsFaction(0, context.faction); Faction faction = context.argAsFaction(0, context.faction);
if (faction == null) { if (faction == null) {
return; return;
} }
// Can the player set the faction home HERE? // Can the player set the faction home HERE?
if (!Permission.BYPASS.has(context.player) && if (!Permission.BYPASS.has(context.player) &&
Conf.homesMustBeInClaimedTerritory && Conf.homesMustBeInClaimedTerritory &&
Board.getInstance().getFactionAt(new FLocation(context.player)) != faction) { Board.getInstance().getFactionAt(new FLocation(context.player)) != faction) {
context.msg(TL.COMMAND_SETHOME_NOTCLAIMED); context.msg(TL.COMMAND_SETHOME_NOTCLAIMED);
return; return;
} }
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
if (!context.payForCommand(Conf.econCostSethome, TL.COMMAND_SETHOME_TOSET, TL.COMMAND_SETHOME_FORSET)) { if (!context.payForCommand(Conf.econCostSethome, TL.COMMAND_SETHOME_TOSET, TL.COMMAND_SETHOME_FORSET)) {
return; return;
} }
faction.setHome(context.player.getLocation()); faction.setHome(context.player.getLocation());
faction.msg(TL.COMMAND_SETHOME_SET, context.fPlayer.describeTo(context.faction, true)); faction.msg(TL.COMMAND_SETHOME_SET, context.fPlayer.describeTo(context.faction, true));
faction.sendMessage(FactionsPlugin.getInstance().cmdBase.cmdHome.getUseageTemplate(context)); faction.sendMessage(FactionsPlugin.getInstance().cmdBase.cmdHome.getUseageTemplate(context));
if (faction != context.faction) { if (faction != context.faction) {
context.msg(TL.COMMAND_SETHOME_SETOTHER, faction.getTag(context.fPlayer)); context.msg(TL.COMMAND_SETHOME_SETOTHER, faction.getTag(context.fPlayer));
} }
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_SETHOME_DESCRIPTION; return TL.COMMAND_SETHOME_DESCRIPTION;
} }
} }

View File

@ -14,100 +14,100 @@ import java.util.List;
public class CmdShow extends FCommand { public class CmdShow extends FCommand {
List<String> defaults = new ArrayList<>(); List<String> defaults = new ArrayList<>();
public CmdShow() { public CmdShow() {
this.aliases.add("show"); this.aliases.add("show");
this.aliases.add("who"); this.aliases.add("who");
// add defaults to /f show in case config doesnt have it // add defaults to /f show in case config doesnt have it
defaults.add("{header}"); defaults.add("{header}");
defaults.add("<a>Description: <i>{description}"); defaults.add("<a>Description: <i>{description}");
defaults.add("<a>Joining: <i>{joining} {peaceful}"); defaults.add("<a>Joining: <i>{joining} {peaceful}");
defaults.add("<a>Land / Power / Maxpower: <i> {chunks} / {power} / {maxPower}"); defaults.add("<a>Land / Power / Maxpower: <i> {chunks} / {power} / {maxPower}");
defaults.add("<a>Founded: <i>{create-date}"); defaults.add("<a>Founded: <i>{create-date}");
defaults.add("<a>This faction is permanent, remaining even with no members."); defaults.add("<a>This faction is permanent, remaining even with no members.");
defaults.add("<a>Land value: <i>{land-value} {land-refund}"); defaults.add("<a>Land value: <i>{land-value} {land-refund}");
defaults.add("<a>Balance: <i>{faction-balance}"); defaults.add("<a>Balance: <i>{faction-balance}");
defaults.add("<a>Allies(<i>{allies}<a>/<i>{max-allies}<a>): {allies-list}"); defaults.add("<a>Allies(<i>{allies}<a>/<i>{max-allies}<a>): {allies-list}");
defaults.add("<a>Online: (<i>{online}<a>/<i>{members}<a>): {online-list}"); defaults.add("<a>Online: (<i>{online}<a>/<i>{members}<a>): {online-list}");
defaults.add("<a>Offline: (<i>{offline}<a>/<i>{members}<a>): {offline-list}"); defaults.add("<a>Offline: (<i>{offline}<a>/<i>{members}<a>): {offline-list}");
// this.requiredArgs.add(""); // this.requiredArgs.add("");
this.optionalArgs.put("faction tag", "yours"); this.optionalArgs.put("faction tag", "yours");
this.requirements = new CommandRequirements.Builder(Permission.SHOW).build(); this.requirements = new CommandRequirements.Builder(Permission.SHOW).build();
} }
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
Faction faction = context.faction; Faction faction = context.faction;
if (context.argIsSet(0)) if (context.argIsSet(0))
faction = context.argAsFaction(0); faction = context.argAsFaction(0);
if (faction == null) if (faction == null)
return; return;
if (context.fPlayer != null && !context.player.getPlayer().hasPermission("factions.show.bypassexempt") if (context.fPlayer != null && !context.player.getPlayer().hasPermission("factions.show.bypassexempt")
&& FactionsPlugin.getInstance().getConfig().getStringList("show-exempt").contains(faction.getTag())) { && FactionsPlugin.getInstance().getConfig().getStringList("show-exempt").contains(faction.getTag())) {
context.msg(TL.COMMAND_SHOW_EXEMPT); context.msg(TL.COMMAND_SHOW_EXEMPT);
return; return;
} }
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
if (!context.payForCommand(Conf.econCostShow, TL.COMMAND_SHOW_TOSHOW, TL.COMMAND_SHOW_FORSHOW)) { if (!context.payForCommand(Conf.econCostShow, TL.COMMAND_SHOW_TOSHOW, TL.COMMAND_SHOW_FORSHOW)) {
return; return;
} }
List<String> show = FactionsPlugin.getInstance().getConfig().getStringList("show"); List<String> show = FactionsPlugin.getInstance().getConfig().getStringList("show");
if (show == null || show.isEmpty()) if (show == null || show.isEmpty())
show = defaults; show = defaults;
if (!faction.isNormal()) { if (!faction.isNormal()) {
String tag = faction.getTag(context.fPlayer); String tag = faction.getTag(context.fPlayer);
// send header and that's all // send header and that's all
String header = show.get(0); String header = show.get(0);
if (TagReplacer.HEADER.contains(header)) { if (TagReplacer.HEADER.contains(header)) {
context.msg(FactionsPlugin.getInstance().txt.titleize(tag)); context.msg(FactionsPlugin.getInstance().txt.titleize(tag));
} else { } else {
context.msg(FactionsPlugin.getInstance().txt.parse(TagReplacer.FACTION.replace(header, tag))); context.msg(FactionsPlugin.getInstance().txt.parse(TagReplacer.FACTION.replace(header, tag)));
} }
return; // we only show header for non-normal factions return; // we only show header for non-normal factions
} }
for (String raw : show) { for (String raw : show) {
String parsed = TagUtil.parsePlain(faction, context.fPlayer, raw); // use relations String parsed = TagUtil.parsePlain(faction, context.fPlayer, raw); // use relations
if (parsed == null) { if (parsed == null) {
continue; // Due to minimal f show. continue; // Due to minimal f show.
} }
if (context.fPlayer != null) { if (context.fPlayer != null) {
parsed = TagUtil.parsePlaceholders(context.fPlayer.getPlayer(), parsed); parsed = TagUtil.parsePlaceholders(context.fPlayer.getPlayer(), parsed);
} }
if (TagUtil.hasFancy(parsed)) { if (TagUtil.hasFancy(parsed)) {
List<FancyMessage> fancy = TagUtil.parseFancy(faction, context.fPlayer, parsed); List<FancyMessage> fancy = TagUtil.parseFancy(faction, context.fPlayer, parsed);
if (fancy != null) if (fancy != null)
context.sendFancyMessage(fancy); context.sendFancyMessage(fancy);
continue; continue;
} }
if (!parsed.contains("{notFrozen}") && !parsed.contains("{notPermanent}")) { if (!parsed.contains("{notFrozen}") && !parsed.contains("{notPermanent}")) {
if (parsed.contains("{ig}")) { if (parsed.contains("{ig}")) {
// replaces all variables with no home TL // replaces all variables with no home TL
parsed = parsed.substring(0, parsed.indexOf("{ig}")) + TL.COMMAND_SHOW_NOHOME.toString(); parsed = parsed.substring(0, parsed.indexOf("{ig}")) + TL.COMMAND_SHOW_NOHOME.toString();
} }
if (parsed.contains("%")) { if (parsed.contains("%")) {
parsed = parsed.replaceAll("%", ""); // Just in case it got in there before we disallowed it. parsed = parsed.replaceAll("%", ""); // Just in case it got in there before we disallowed it.
} }
context.msg(FactionsPlugin.getInstance().txt.parse(parsed)); context.msg(FactionsPlugin.getInstance().txt.parse(parsed));
} }
} }
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_SHOW_COMMANDDESCRIPTION; return TL.COMMAND_SHOW_COMMANDDESCRIPTION;
} }
} }

View File

@ -8,47 +8,47 @@ import com.massivecraft.factions.zcore.util.TL;
public class CmdShowClaims extends FCommand { public class CmdShowClaims extends FCommand {
public CmdShowClaims() { public CmdShowClaims() {
this.aliases.add("showclaims"); this.aliases.add("showclaims");
this.aliases.add("showclaim"); this.aliases.add("showclaim");
this.requirements = new CommandRequirements.Builder(Permission.SHOWCLAIMS) this.requirements = new CommandRequirements.Builder(Permission.SHOWCLAIMS)
.playerOnly() .playerOnly()
.memberOnly() .memberOnly()
.build(); .build();
} }
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
context.sendMessage(TL.COMMAND_SHOWCLAIMS_HEADER.toString().replace("{faction}", context.faction.describeTo(context.fPlayer))); context.sendMessage(TL.COMMAND_SHOWCLAIMS_HEADER.toString().replace("{faction}", context.faction.describeTo(context.fPlayer)));
ListMultimap<String, String> chunkMap = ArrayListMultimap.create(); ListMultimap<String, String> chunkMap = ArrayListMultimap.create();
String format = TL.COMMAND_SHOWCLAIMS_CHUNKSFORMAT.toString(); String format = TL.COMMAND_SHOWCLAIMS_CHUNKSFORMAT.toString();
for (FLocation fLocation : context.faction.getAllClaims()) { for (FLocation fLocation : context.faction.getAllClaims()) {
chunkMap.put(fLocation.getWorldName(), format.replace("{x}", fLocation.getX() + "").replace("{z}", fLocation.getZ() + "")); chunkMap.put(fLocation.getWorldName(), format.replace("{x}", fLocation.getX() + "").replace("{z}", fLocation.getZ() + ""));
} }
for (String world : chunkMap.keySet()) { for (String world : chunkMap.keySet()) {
String message = TL.COMMAND_SHOWCLAIMS_FORMAT.toString().replace("{world}", world); 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: // made {chunks} blank as I removed the placeholder and people wont update their config :shrug:
context.sendMessage(message.replace("{chunks}", "")); context.sendMessage(message.replace("{chunks}", ""));
StringBuilder chunks = new StringBuilder(); StringBuilder chunks = new StringBuilder();
for (String chunkString : chunkMap.get(world)) { for (String chunkString : chunkMap.get(world)) {
chunks.append(chunkString).append(", "); chunks.append(chunkString).append(", ");
if (chunks.toString().length() >= 2000) { if (chunks.toString().length() >= 2000) {
context.sendMessage(chunks.toString()); context.sendMessage(chunks.toString());
chunks.setLength(0); chunks.setLength(0);
} }
} }
if (chunks.length() != 0) context.sendMessage(chunks.toString()); if (chunks.length() != 0) context.sendMessage(chunks.toString());
context.sendMessage(""); context.sendMessage("");
} }
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_SHOWCLAIMS_DESCRIPTION; return TL.COMMAND_SHOWCLAIMS_DESCRIPTION;
} }
} }

View File

@ -10,33 +10,33 @@ import org.bukkit.ChatColor;
public class CmdShowInvites extends FCommand { public class CmdShowInvites extends FCommand {
public CmdShowInvites() { public CmdShowInvites() {
super(); super();
aliases.add("showinvites"); aliases.add("showinvites");
this.requirements = new CommandRequirements.Builder(Permission.SHOW_INVITES) this.requirements = new CommandRequirements.Builder(Permission.SHOW_INVITES)
.playerOnly() .playerOnly()
.memberOnly() .memberOnly()
.build(); .build();
} }
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
FancyMessage msg = new FancyMessage(TL.COMMAND_SHOWINVITES_PENDING.toString()).color(ChatColor.GOLD); FancyMessage msg = new FancyMessage(TL.COMMAND_SHOWINVITES_PENDING.toString()).color(ChatColor.GOLD);
for (String id : context.faction.getInvites()) { for (String id : context.faction.getInvites()) {
FPlayer fp = FPlayers.getInstance().getById(id); FPlayer fp = FPlayers.getInstance().getById(id);
String name = fp != null ? fp.getName() : 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); msg.then(name + " ").color(ChatColor.WHITE).tooltip(TL.COMMAND_SHOWINVITES_CLICKTOREVOKE.format(name)).command("/" + Conf.baseCommandAliases.get(0) + " deinvite " + name);
} }
context.sendFancyMessage(msg); context.sendFancyMessage(msg);
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_SHOWINVITES_DESCRIPTION; return TL.COMMAND_SHOWINVITES_DESCRIPTION;
} }
} }

View File

@ -10,32 +10,32 @@ import java.util.ArrayList;
public class CmdStatus extends FCommand { public class CmdStatus extends FCommand {
public CmdStatus() { public CmdStatus() {
super(); super();
this.aliases.add("status"); this.aliases.add("status");
this.aliases.add("s"); this.aliases.add("s");
this.requirements = new CommandRequirements.Builder(Permission.STATUS) this.requirements = new CommandRequirements.Builder(Permission.STATUS)
.playerOnly() .playerOnly()
.memberOnly() .memberOnly()
.build(); .build();
} }
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
ArrayList<String> ret = new ArrayList<>(); ArrayList<String> ret = new ArrayList<>();
for (FPlayer fp : context.faction.getFPlayers()) { for (FPlayer fp : context.faction.getFPlayers()) {
String humanized = DurationFormatUtils.formatDurationWords(System.currentTimeMillis() - fp.getLastLoginTime(), true, true) + TL.COMMAND_STATUS_AGOSUFFIX; 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 last = fp.isOnline() ? ChatColor.GREEN + TL.COMMAND_STATUS_ONLINE.toString() : (System.currentTimeMillis() - fp.getLastLoginTime() < 432000000 ? ChatColor.YELLOW + humanized : ChatColor.RED + humanized);
String power = ChatColor.YELLOW + String.valueOf(fp.getPowerRounded()) + " / " + fp.getPowerMaxRounded() + ChatColor.RESET; String power = ChatColor.YELLOW + String.valueOf(fp.getPowerRounded()) + " / " + fp.getPowerMaxRounded() + ChatColor.RESET;
ret.add(String.format(TL.COMMAND_STATUS_FORMAT.toString(), ChatColor.GOLD + fp.getRole().getPrefix() + fp.getName() + ChatColor.RESET, power, last).trim()); ret.add(String.format(TL.COMMAND_STATUS_FORMAT.toString(), ChatColor.GOLD + fp.getRole().getPrefix() + fp.getName() + ChatColor.RESET, power, last).trim());
} }
context.fPlayer.sendMessage(ret); context.fPlayer.sendMessage(ret);
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_STATUS_DESCRIPTION; return TL.COMMAND_STATUS_DESCRIPTION;
} }
} }

View File

@ -4,26 +4,26 @@ import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
public class CmdStealth extends FCommand { public class CmdStealth extends FCommand {
public CmdStealth() { public CmdStealth() {
this.aliases.add("ninja"); this.aliases.add("ninja");
this.aliases.add("stealth"); this.aliases.add("stealth");
this.requirements = new CommandRequirements.Builder(Permission.STEALTH) this.requirements = new CommandRequirements.Builder(Permission.STEALTH)
.playerOnly() .playerOnly()
.build(); .build();
} }
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
if (context.faction != null && !context.faction.getId().equalsIgnoreCase("0") && !context.faction.getId().equalsIgnoreCase("none") && !context.faction.getId().equalsIgnoreCase("safezone") && !context.faction.getId().equalsIgnoreCase("warzone")) { if (context.faction != null && !context.faction.getId().equalsIgnoreCase("0") && !context.faction.getId().equalsIgnoreCase("none") && !context.faction.getId().equalsIgnoreCase("safezone") && !context.faction.getId().equalsIgnoreCase("warzone")) {
context.fPlayer.setStealth(!context.fPlayer.isStealthEnabled()); context.fPlayer.setStealth(!context.fPlayer.isStealthEnabled());
context.msg(context.fPlayer.isStealthEnabled() ? TL.COMMAND_STEALTH_ENABLE : TL.COMMAND_STEALTH_DISABLE); context.msg(context.fPlayer.isStealthEnabled() ? TL.COMMAND_STEALTH_ENABLE : TL.COMMAND_STEALTH_DISABLE);
} else { } else {
context.msg(TL.COMMAND_STEALTH_MUSTBEMEMBER); context.msg(TL.COMMAND_STEALTH_MUSTBEMEMBER);
} }
} }
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_STEALTH_DESCRIPTION; return TL.COMMAND_STEALTH_DESCRIPTION;
} }
} }

View File

@ -7,35 +7,35 @@ import com.massivecraft.factions.zcore.util.TL;
public class CmdStrikes extends FCommand { public class CmdStrikes extends FCommand {
public CmdStrikesGive cmdStrikesGive = new CmdStrikesGive(); public CmdStrikesGive cmdStrikesGive = new CmdStrikesGive();
public CmdStrikesInfo cmdStrikesInfo = new CmdStrikesInfo(); public CmdStrikesInfo cmdStrikesInfo = new CmdStrikesInfo();
public CmdStrikesSet cmdStrikesSet = new CmdStrikesSet(); public CmdStrikesSet cmdStrikesSet = new CmdStrikesSet();
public CmdStrikesTake cmdStrikesTake = new CmdStrikesTake(); public CmdStrikesTake cmdStrikesTake = new CmdStrikesTake();
public CmdStrikes() { public CmdStrikes() {
super(); super();
this.aliases.add("strikes"); this.aliases.add("strikes");
this.addSubCommand(cmdStrikesGive); this.addSubCommand(cmdStrikesGive);
this.addSubCommand(cmdStrikesInfo); this.addSubCommand(cmdStrikesInfo);
this.addSubCommand(cmdStrikesSet); this.addSubCommand(cmdStrikesSet);
this.addSubCommand(cmdStrikesTake); this.addSubCommand(cmdStrikesTake);
this.requirements = new CommandRequirements.Builder(Permission.SETSTRIKES) this.requirements = new CommandRequirements.Builder(Permission.SETSTRIKES)
.playerOnly() .playerOnly()
.build(); .build();
} }
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
context.commandChain.add(this); context.commandChain.add(this);
FactionsPlugin.getInstance().cmdAutoHelp.execute(context); FactionsPlugin.getInstance().cmdAutoHelp.execute(context);
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_STRIKES_DESCRIPTION; return TL.COMMAND_STRIKES_DESCRIPTION;
} }
} }

View File

@ -7,31 +7,31 @@ import com.massivecraft.factions.zcore.util.TL;
public class CmdStrikesGive extends FCommand { public class CmdStrikesGive extends FCommand {
public CmdStrikesGive() { public CmdStrikesGive() {
super(); super();
this.aliases.add("give"); this.aliases.add("give");
this.requiredArgs.add(0, "faction"); this.requiredArgs.add(0, "faction");
this.requirements = new CommandRequirements.Builder(Permission.SETSTRIKES) this.requirements = new CommandRequirements.Builder(Permission.SETSTRIKES)
.playerOnly() .playerOnly()
.build(); .build();
} }
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
Faction target = context.argAsFaction(0); Faction target = context.argAsFaction(0);
if (target == null || target.isSystemFaction()) { if (target == null || target.isSystemFaction()) {
context.msg(TL.COMMAND_STRIKES_TARGET_INVALID, context.argAsString(0)); context.msg(TL.COMMAND_STRIKES_TARGET_INVALID, context.argAsString(0));
return; return;
} }
target.setStrikes(target.getStrikes() + 1); target.setStrikes(target.getStrikes() + 1);
context.msg(TL.COMMAND_STRIKES_CHANGED, target.getTag(), target.getStrikes()); context.msg(TL.COMMAND_STRIKES_CHANGED, target.getTag(), target.getStrikes());
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_STRIKESGIVE_DESCRIPTION; return TL.COMMAND_STRIKESGIVE_DESCRIPTION;
} }
} }

View File

@ -6,32 +6,32 @@ import com.massivecraft.factions.zcore.util.TL;
public class CmdStrikesInfo extends FCommand { public class CmdStrikesInfo extends FCommand {
public CmdStrikesInfo() { public CmdStrikesInfo() {
super(); super();
this.aliases.add("info"); this.aliases.add("info");
this.optionalArgs.put("target", "faction"); this.optionalArgs.put("target", "faction");
this.requirements = new CommandRequirements.Builder(Permission.SETSTRIKES) this.requirements = new CommandRequirements.Builder(Permission.SETSTRIKES)
.playerOnly() .playerOnly()
.build(); .build();
} }
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
Faction target = context.argAsFaction(0); Faction target = context.argAsFaction(0);
if (target == null) target = context.faction; if (target == null) target = context.faction;
if (target.isSystemFaction()) { if (target.isSystemFaction()) {
context.msg(TL.COMMAND_STRIKES_TARGET_INVALID, context.argAsString(0)); context.msg(TL.COMMAND_STRIKES_TARGET_INVALID, context.argAsString(0));
return; return;
} }
context.msg(TL.COMMAND_STRIKES_INFO, target.getTag(), target.getStrikes()); context.msg(TL.COMMAND_STRIKES_INFO, target.getTag(), target.getStrikes());
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_STRIKESINFO_DESCRIPTION; return TL.COMMAND_STRIKESINFO_DESCRIPTION;
} }
} }

View File

@ -6,32 +6,32 @@ import com.massivecraft.factions.zcore.util.TL;
public class CmdStrikesSet extends FCommand { public class CmdStrikesSet extends FCommand {
public CmdStrikesSet() { public CmdStrikesSet() {
super(); super();
this.aliases.add("set"); this.aliases.add("set");
this.requiredArgs.add(0, "faction"); this.requiredArgs.add(0, "faction");
this.requiredArgs.add(1, "amount"); this.requiredArgs.add(1, "amount");
this.requirements = new CommandRequirements.Builder(Permission.SETSTRIKES) this.requirements = new CommandRequirements.Builder(Permission.SETSTRIKES)
.playerOnly() .playerOnly()
.build(); .build();
} }
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
Faction target = context.argAsFaction(0); Faction target = context.argAsFaction(0);
if (target == null || target.isSystemFaction()) { if (target == null || target.isSystemFaction()) {
context.msg(TL.COMMAND_STRIKES_TARGET_INVALID, context.argAsString(0)); context.msg(TL.COMMAND_STRIKES_TARGET_INVALID, context.argAsString(0));
return; return;
} }
target.setStrikes(context.argAsInt(1)); target.setStrikes(context.argAsInt(1));
context.msg(TL.COMMAND_STRIKES_CHANGED, target.getTag(), target.getStrikes()); context.msg(TL.COMMAND_STRIKES_CHANGED, target.getTag(), target.getStrikes());
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_STRIKESET_DESCRIPTION; return TL.COMMAND_STRIKESET_DESCRIPTION;
} }
} }

View File

@ -7,32 +7,32 @@ import com.massivecraft.factions.zcore.util.TL;
public class CmdStrikesTake extends FCommand { public class CmdStrikesTake extends FCommand {
public CmdStrikesTake() { public CmdStrikesTake() {
super(); super();
this.aliases.add("take"); this.aliases.add("take");
this.requiredArgs.add(0, "faction"); this.requiredArgs.add(0, "faction");
this.requiredArgs.add(1, "number of strikes"); this.requiredArgs.add(1, "number of strikes");
this.requirements = new CommandRequirements.Builder(Permission.SETSTRIKES) this.requirements = new CommandRequirements.Builder(Permission.SETSTRIKES)
.playerOnly() .playerOnly()
.build(); .build();
} }
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
Faction target = context.argAsFaction(0); Faction target = context.argAsFaction(0);
if (target == null || target.isSystemFaction()) { if (target == null || target.isSystemFaction()) {
context.msg(TL.COMMAND_STRIKES_TARGET_INVALID, context.argAsString(0)); context.msg(TL.COMMAND_STRIKES_TARGET_INVALID, context.argAsString(0));
return; return;
} }
target.setStrikes(target.getStrikes() - context.argAsInt(1)); target.setStrikes(target.getStrikes() - context.argAsInt(1));
context.msg(TL.COMMAND_STRIKES_CHANGED, target.getTag(), target.getStrikes()); context.msg(TL.COMMAND_STRIKES_CHANGED, target.getTag(), target.getStrikes());
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_STRIKETAKE_DESCRIPTION; return TL.COMMAND_STRIKETAKE_DESCRIPTION;
} }
} }

View File

@ -13,93 +13,93 @@ import org.bukkit.entity.Player;
public class CmdStuck extends FCommand { public class CmdStuck extends FCommand {
public CmdStuck() { public CmdStuck() {
super(); super();
this.aliases.add("stuck"); this.aliases.add("stuck");
this.aliases.add("halp!"); // halp!c: this.aliases.add("halp!"); // halp!c:
this.requirements = new CommandRequirements.Builder(Permission.STUCK) this.requirements = new CommandRequirements.Builder(Permission.STUCK)
.playerOnly() .playerOnly()
.build(); .build();
} }
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
final Player player = context.player; final Player player = context.player;
final Location sentAt = player.getLocation(); final Location sentAt = player.getLocation();
final FLocation chunk = context.fPlayer.getLastStoodAt(); final FLocation chunk = context.fPlayer.getLastStoodAt();
final long delay = FactionsPlugin.getInstance().getConfig().getLong("hcf.stuck.delay", 30); final long delay = FactionsPlugin.getInstance().getConfig().getLong("hcf.stuck.delay", 30);
final int radius = FactionsPlugin.getInstance().getConfig().getInt("hcf.stuck.radius", 10); final int radius = FactionsPlugin.getInstance().getConfig().getInt("hcf.stuck.radius", 10);
if (FactionsPlugin.getInstance().getStuckMap().containsKey(player.getUniqueId())) { if (FactionsPlugin.getInstance().getStuckMap().containsKey(player.getUniqueId())) {
long wait = FactionsPlugin.getInstance().getTimers().get(player.getUniqueId()) - System.currentTimeMillis(); long wait = FactionsPlugin.getInstance().getTimers().get(player.getUniqueId()) - System.currentTimeMillis();
String time = DurationFormatUtils.formatDuration(wait, TL.COMMAND_STUCK_TIMEFORMAT.toString(), true); String time = DurationFormatUtils.formatDuration(wait, TL.COMMAND_STUCK_TIMEFORMAT.toString(), true);
context.msg(TL.COMMAND_STUCK_EXISTS, time); context.msg(TL.COMMAND_STUCK_EXISTS, time);
} else { } else {
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
if (!context.payForCommand(Conf.econCostStuck, TL.COMMAND_STUCK_TOSTUCK.format(context.fPlayer.getName()), TL.COMMAND_STUCK_FORSTUCK.format(context.fPlayer.getName()))) { if (!context.payForCommand(Conf.econCostStuck, TL.COMMAND_STUCK_TOSTUCK.format(context.fPlayer.getName()), TL.COMMAND_STUCK_FORSTUCK.format(context.fPlayer.getName()))) {
return; return;
} }
final int id = Bukkit.getScheduler().runTaskLater(FactionsPlugin.getInstance(), new Runnable() { final int id = Bukkit.getScheduler().runTaskLater(FactionsPlugin.getInstance(), new Runnable() {
@Override @Override
public void run() { public void run() {
if (!FactionsPlugin.getInstance().getStuckMap().containsKey(player.getUniqueId())) { if (!FactionsPlugin.getInstance().getStuckMap().containsKey(player.getUniqueId())) {
return; return;
}
// check for world difference or radius exceeding
final World world = chunk.getWorld();
if (world.getUID() != player.getWorld().getUID() || sentAt.distance(player.getLocation()) > radius) {
context.msg(TL.COMMAND_STUCK_OUTSIDE.format(radius));
FactionsPlugin.getInstance().getTimers().remove(player.getUniqueId());
FactionsPlugin.getInstance().getStuckMap().remove(player.getUniqueId());
return;
}
final Board board = Board.getInstance();
// spiral task to find nearest wilderness chunk
new SpiralTask(new FLocation(context.player), radius * 2) {
@Override
public boolean work() {
FLocation chunk = currentFLocation();
Faction faction = board.getFactionAt(chunk);
int buffer = FactionsPlugin.getInstance().getConfig().getInt("world-border.buffer", 0) - 1;
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);
context.msg(TL.COMMAND_STUCK_TELEPORT, tp.getBlockX(), tp.getBlockY(), tp.getBlockZ());
FactionsPlugin.getInstance().getTimers().remove(player.getUniqueId());
FactionsPlugin.getInstance().getStuckMap().remove(player.getUniqueId());
if (!Essentials.handleTeleport(player, tp)) {
player.teleport(tp);
FactionsPlugin.getInstance().debug("/f stuck used regular teleport, not essentials!");
}
this.stop();
return false;
}
return true;
}
};
} }
}, delay * 20).getTaskId();
FactionsPlugin.getInstance().getTimers().put(player.getUniqueId(), System.currentTimeMillis() + (delay * 1000)); // check for world difference or radius exceeding
long wait = FactionsPlugin.getInstance().getTimers().get(player.getUniqueId()) - System.currentTimeMillis(); final World world = chunk.getWorld();
String time = DurationFormatUtils.formatDuration(wait, TL.COMMAND_STUCK_TIMEFORMAT.toString(), true); if (world.getUID() != player.getWorld().getUID() || sentAt.distance(player.getLocation()) > radius) {
context.msg(TL.COMMAND_STUCK_START, time); context.msg(TL.COMMAND_STUCK_OUTSIDE.format(radius));
FactionsPlugin.getInstance().getStuckMap().put(player.getUniqueId(), id); FactionsPlugin.getInstance().getTimers().remove(player.getUniqueId());
} FactionsPlugin.getInstance().getStuckMap().remove(player.getUniqueId());
} return;
}
@Override final Board board = Board.getInstance();
public TL getUsageTranslation() { // spiral task to find nearest wilderness chunk
return TL.COMMAND_STUCK_DESCRIPTION; new SpiralTask(new FLocation(context.player), radius * 2) {
} @Override
public boolean work() {
FLocation chunk = currentFLocation();
Faction faction = board.getFactionAt(chunk);
int buffer = FactionsPlugin.getInstance().getConfig().getInt("world-border.buffer", 0) - 1;
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);
context.msg(TL.COMMAND_STUCK_TELEPORT, tp.getBlockX(), tp.getBlockY(), tp.getBlockZ());
FactionsPlugin.getInstance().getTimers().remove(player.getUniqueId());
FactionsPlugin.getInstance().getStuckMap().remove(player.getUniqueId());
if (!Essentials.handleTeleport(player, tp)) {
player.teleport(tp);
FactionsPlugin.getInstance().debug("/f stuck used regular teleport, not essentials!");
}
this.stop();
return false;
}
return true;
}
};
}
}, delay * 20).getTaskId();
FactionsPlugin.getInstance().getTimers().put(player.getUniqueId(), System.currentTimeMillis() + (delay * 1000));
long wait = FactionsPlugin.getInstance().getTimers().get(player.getUniqueId()) - System.currentTimeMillis();
String time = DurationFormatUtils.formatDuration(wait, TL.COMMAND_STUCK_TIMEFORMAT.toString(), true);
context.msg(TL.COMMAND_STUCK_START, time);
FactionsPlugin.getInstance().getStuckMap().put(player.getUniqueId(), id);
}
}
@Override
public TL getUsageTranslation() {
return TL.COMMAND_STUCK_DESCRIPTION;
}
} }

View File

@ -13,75 +13,75 @@ import java.util.ArrayList;
public class CmdTag extends FCommand { public class CmdTag extends FCommand {
public CmdTag() { public CmdTag() {
this.aliases.add("tag"); this.aliases.add("tag");
this.aliases.add("rename"); this.aliases.add("rename");
this.requiredArgs.add("faction tag"); this.requiredArgs.add("faction tag");
this.requirements = new CommandRequirements.Builder(Permission.TAG) this.requirements = new CommandRequirements.Builder(Permission.TAG)
.withRole(Role.COLEADER) .withRole(Role.COLEADER)
.playerOnly() .playerOnly()
.memberOnly() .memberOnly()
.build(); .build();
} }
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
String tag = context.argAsString(0); String tag = context.argAsString(0);
// TODO does not first test cover selfcase? // TODO does not first test cover selfcase?
if (Factions.getInstance().isTagTaken(tag) && !MiscUtil.getComparisonString(tag).equals(context.faction.getComparisonTag())) { if (Factions.getInstance().isTagTaken(tag) && !MiscUtil.getComparisonString(tag).equals(context.faction.getComparisonTag())) {
context.msg(TL.COMMAND_TAG_TAKEN); context.msg(TL.COMMAND_TAG_TAKEN);
return; return;
} }
ArrayList<String> errors = MiscUtil.validateTag(tag); ArrayList<String> errors = MiscUtil.validateTag(tag);
if (errors.size() > 0) { if (errors.size() > 0) {
context.sendMessage(errors); context.sendMessage(errors);
return; 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 economy is enabled, they're not on the bypass list, and this command has a cost set, make sure they can pay
if (!context.canAffordCommand(Conf.econCostTag, TL.COMMAND_TAG_TOCHANGE.toString())) { if (!context.canAffordCommand(Conf.econCostTag, TL.COMMAND_TAG_TOCHANGE.toString())) {
return; return;
} }
// trigger the faction rename event (cancellable) // trigger the faction rename event (cancellable)
FactionRenameEvent renameEvent = new FactionRenameEvent(context.fPlayer, tag); FactionRenameEvent renameEvent = new FactionRenameEvent(context.fPlayer, tag);
Bukkit.getServer().getPluginManager().callEvent(renameEvent); Bukkit.getServer().getPluginManager().callEvent(renameEvent);
if (renameEvent.isCancelled()) { if (renameEvent.isCancelled()) {
return; return;
} }
// then make 'em pay (if applicable) // then make 'em pay (if applicable)
if (!context.payForCommand(Conf.econCostTag, TL.COMMAND_TAG_TOCHANGE, TL.COMMAND_TAG_FORCHANGE)) { if (!context.payForCommand(Conf.econCostTag, TL.COMMAND_TAG_TOCHANGE, TL.COMMAND_TAG_FORCHANGE)) {
return; return;
} }
String oldtag = context.faction.getTag(); String oldtag = context.faction.getTag();
context.faction.setTag(tag); context.faction.setTag(tag);
// Inform // Inform
for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers()) { for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers()) {
if (fplayer.getFactionId().equals(context.faction.getId())) { if (fplayer.getFactionId().equals(context.faction.getId())) {
fplayer.msg(TL.COMMAND_TAG_FACTION, context.fPlayer.describeTo(context.faction, true), context.faction.getTag(context.faction)); fplayer.msg(TL.COMMAND_TAG_FACTION, context.fPlayer.describeTo(context.faction, true), context.faction.getTag(context.faction));
continue; continue;
} }
// Broadcast the tag change (if applicable) // Broadcast the tag change (if applicable)
if (Conf.broadcastTagChanges) { if (Conf.broadcastTagChanges) {
Faction faction = fplayer.getFaction(); Faction faction = fplayer.getFaction();
fplayer.msg(TL.COMMAND_TAG_CHANGED, context.fPlayer.getColorTo(faction) + oldtag, context.faction.getTag(faction)); fplayer.msg(TL.COMMAND_TAG_CHANGED, context.fPlayer.getColorTo(faction) + oldtag, context.faction.getTag(faction));
} }
} }
FTeamWrapper.updatePrefixes(context.faction); FTeamWrapper.updatePrefixes(context.faction);
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_TAG_DESCRIPTION; return TL.COMMAND_TAG_DESCRIPTION;
} }
} }

View File

@ -8,33 +8,33 @@ import com.massivecraft.factions.zcore.util.TextUtil;
public class CmdTitle extends FCommand { public class CmdTitle extends FCommand {
public CmdTitle() { public CmdTitle() {
this.aliases.add("title"); this.aliases.add("title");
this.requiredArgs.add("player name"); this.requiredArgs.add("player name");
this.optionalArgs.put("title", ""); this.optionalArgs.put("title", "");
this.requirements = new CommandRequirements.Builder(Permission.TITLE) this.requirements = new CommandRequirements.Builder(Permission.TITLE)
.playerOnly() .playerOnly()
.build(); .build();
} }
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
FPlayer you = context.argAsBestFPlayerMatch(0); FPlayer you = context.argAsBestFPlayerMatch(0);
if (you == null) return; if (you == null) return;
context.args.remove(0); context.args.remove(0);
String title = TextUtil.implode(context.args, " "); String title = TextUtil.implode(context.args, " ");
if (!context.canIAdministerYou(context.fPlayer, you)) return; if (!context.canIAdministerYou(context.fPlayer, you)) return;
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
if (!context.payForCommand(Conf.econCostTitle, TL.COMMAND_TITLE_TOCHANGE, TL.COMMAND_TITLE_FORCHANGE)) return; if (!context.payForCommand(Conf.econCostTitle, TL.COMMAND_TITLE_TOCHANGE, TL.COMMAND_TITLE_FORCHANGE)) return;
you.setTitle(context.sender, title); you.setTitle(context.sender, title);
// Inform // Inform
context.faction.msg(TL.COMMAND_TITLE_CHANGED, context.fPlayer.describeTo(context.faction, true), you.describeTo(context.faction, true)); context.faction.msg(TL.COMMAND_TITLE_CHANGED, context.fPlayer.describeTo(context.faction, true), you.describeTo(context.faction, true));
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_TITLE_DESCRIPTION; return TL.COMMAND_TITLE_DESCRIPTION;
} }
} }

View File

@ -6,34 +6,34 @@ import com.massivecraft.factions.zcore.util.TL;
public class CmdToggleAllianceChat extends FCommand { public class CmdToggleAllianceChat extends FCommand {
public CmdToggleAllianceChat() { public CmdToggleAllianceChat() {
super(); super();
this.aliases.add("tac"); this.aliases.add("tac");
this.aliases.add("togglealliancechat"); this.aliases.add("togglealliancechat");
this.aliases.add("ac"); this.aliases.add("ac");
this.requirements = new CommandRequirements.Builder(Permission.TOGGLE_ALLIANCE_CHAT) this.requirements = new CommandRequirements.Builder(Permission.TOGGLE_ALLIANCE_CHAT)
.playerOnly() .playerOnly()
.memberOnly() .memberOnly()
.build(); .build();
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_TOGGLEALLIANCECHAT_DESCRIPTION; return TL.COMMAND_TOGGLEALLIANCECHAT_DESCRIPTION;
} }
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
if (!Conf.factionOnlyChat) { if (!Conf.factionOnlyChat) {
context.msg(TL.COMMAND_CHAT_DISABLED.toString()); context.msg(TL.COMMAND_CHAT_DISABLED.toString());
return; return;
} }
boolean ignoring = context.fPlayer.isIgnoreAllianceChat(); boolean ignoring = context.fPlayer.isIgnoreAllianceChat();
context.msg(ignoring ? TL.COMMAND_TOGGLEALLIANCECHAT_UNIGNORE : TL.COMMAND_TOGGLEALLIANCECHAT_IGNORE); context.msg(ignoring ? TL.COMMAND_TOGGLEALLIANCECHAT_UNIGNORE : TL.COMMAND_TOGGLEALLIANCECHAT_IGNORE);
context.fPlayer.setIgnoreAllianceChat(!ignoring); context.fPlayer.setIgnoreAllianceChat(!ignoring);
} }
} }

View File

@ -12,159 +12,159 @@ import java.util.ArrayList;
public class CmdTop extends FCommand { public class CmdTop extends FCommand {
public CmdTop() { public CmdTop() {
super(); super();
this.aliases.add("top"); this.aliases.add("top");
this.aliases.add("t"); this.aliases.add("t");
this.requiredArgs.add("criteria"); this.requiredArgs.add("criteria");
this.optionalArgs.put("page", "1"); this.optionalArgs.put("page", "1");
this.requirements = new CommandRequirements.Builder(Permission.TOP) this.requirements = new CommandRequirements.Builder(Permission.TOP)
.build(); .build();
} }
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
// Can sort by: money, members, online, allies, enemies, power, land. // Can sort by: money, members, online, allies, enemies, power, land.
// Get all Factions and remove non player ones. // Get all Factions and remove non player ones.
ArrayList<Faction> factionList = Factions.getInstance().getAllFactions(); ArrayList<Faction> factionList = Factions.getInstance().getAllFactions();
factionList.remove(Factions.getInstance().getWilderness()); factionList.remove(Factions.getInstance().getWilderness());
factionList.remove(Factions.getInstance().getSafeZone()); factionList.remove(Factions.getInstance().getSafeZone());
factionList.remove(Factions.getInstance().getWarZone()); factionList.remove(Factions.getInstance().getWarZone());
String criteria = context.argAsString(0); String criteria = context.argAsString(0);
// TODO: Better way to sort? // TODO: Better way to sort?
if (criteria.equalsIgnoreCase("members")) { if (criteria.equalsIgnoreCase("members")) {
factionList.sort((f1, f2) -> { factionList.sort((f1, f2) -> {
int f1Size = f1.getFPlayers().size(); int f1Size = f1.getFPlayers().size();
int f2Size = f2.getFPlayers().size(); int f2Size = f2.getFPlayers().size();
if (f1Size < f2Size) { if (f1Size < f2Size) {
return 1; return 1;
} else if (f1Size > f2Size) { } else if (f1Size > f2Size) {
return -1; return -1;
} }
return 0; return 0;
}); });
} else if (criteria.equalsIgnoreCase("start")) { } else if (criteria.equalsIgnoreCase("start")) {
factionList.sort((f1, f2) -> { factionList.sort((f1, f2) -> {
long f1start = f1.getFoundedDate(); long f1start = f1.getFoundedDate();
long f2start = f2.getFoundedDate(); long f2start = f2.getFoundedDate();
// flip signs because a smaller date is farther in the past // flip signs because a smaller date is farther in the past
if (f1start > f2start) { if (f1start > f2start) {
return 1; return 1;
} else if (f1start < f2start) { } else if (f1start < f2start) {
return -1; return -1;
} }
return 0; return 0;
}); });
} else if (criteria.equalsIgnoreCase("power")) { } else if (criteria.equalsIgnoreCase("power")) {
factionList.sort((f1, f2) -> { factionList.sort((f1, f2) -> {
int f1Size = f1.getPowerRounded(); int f1Size = f1.getPowerRounded();
int f2Size = f2.getPowerRounded(); int f2Size = f2.getPowerRounded();
if (f1Size < f2Size) { if (f1Size < f2Size) {
return 1; return 1;
} else if (f1Size > f2Size) { } else if (f1Size > f2Size) {
return -1; return -1;
} }
return 0; return 0;
}); });
} else if (criteria.equalsIgnoreCase("land")) { } else if (criteria.equalsIgnoreCase("land")) {
factionList.sort((f1, f2) -> { factionList.sort((f1, f2) -> {
int f1Size = f1.getLandRounded(); int f1Size = f1.getLandRounded();
int f2Size = f2.getLandRounded(); int f2Size = f2.getLandRounded();
if (f1Size < f2Size) { if (f1Size < f2Size) {
return 1; return 1;
} else if (f1Size > f2Size) { } else if (f1Size > f2Size) {
return -1; return -1;
} }
return 0; return 0;
}); });
} else if (criteria.equalsIgnoreCase("online")) { } else if (criteria.equalsIgnoreCase("online")) {
factionList.sort((f1, f2) -> { factionList.sort((f1, f2) -> {
int f1Size = f1.getFPlayersWhereOnline(true).size(); int f1Size = f1.getFPlayersWhereOnline(true).size();
int f2Size = f2.getFPlayersWhereOnline(true).size(); int f2Size = f2.getFPlayersWhereOnline(true).size();
if (f1Size < f2Size) { if (f1Size < f2Size) {
return 1; return 1;
} else if (f1Size > f2Size) { } else if (f1Size > f2Size) {
return -1; return -1;
} }
return 0; return 0;
}); });
} else if (criteria.equalsIgnoreCase("money") || criteria.equalsIgnoreCase("balance") || criteria.equalsIgnoreCase("bal")) { } else if (criteria.equalsIgnoreCase("money") || criteria.equalsIgnoreCase("balance") || criteria.equalsIgnoreCase("bal")) {
factionList.sort((f1, f2) -> { factionList.sort((f1, f2) -> {
double f1Size = Econ.getBalance(f1.getAccountId()); double f1Size = Econ.getBalance(f1.getAccountId());
// Lets get the balance of /all/ the players in the Faction. // Lets get the balance of /all/ the players in the Faction.
for (FPlayer fp : f1.getFPlayers()) { for (FPlayer fp : f1.getFPlayers()) {
f1Size = f1Size + Econ.getBalance(fp.getAccountId()); f1Size = f1Size + Econ.getBalance(fp.getAccountId());
} }
double f2Size = Econ.getBalance(f2.getAccountId()); double f2Size = Econ.getBalance(f2.getAccountId());
for (FPlayer fp : f2.getFPlayers()) { for (FPlayer fp : f2.getFPlayers()) {
f2Size = f2Size + Econ.getBalance(fp.getAccountId()); f2Size = f2Size + Econ.getBalance(fp.getAccountId());
} }
if (f1Size < f2Size) { if (f1Size < f2Size) {
return 1; return 1;
} else if (f1Size > f2Size) { } else if (f1Size > f2Size) {
return -1; return -1;
} }
return 0; return 0;
}); });
} else { } else {
context.msg(TL.COMMAND_TOP_INVALID, criteria); context.msg(TL.COMMAND_TOP_INVALID, criteria);
} }
ArrayList<String> lines = new ArrayList<>(); ArrayList<String> lines = new ArrayList<>();
final int pageheight = 9; final int pageheight = 9;
int pagenumber = context.argAsInt(1, 1); int pagenumber = context.argAsInt(1, 1);
int pagecount = (factionList.size() / pageheight) + 1; int pagecount = (factionList.size() / pageheight) + 1;
if (pagenumber > pagecount) { if (pagenumber > pagecount) {
pagenumber = pagecount; pagenumber = pagecount;
} else if (pagenumber < 1) { } else if (pagenumber < 1) {
pagenumber = 1; pagenumber = 1;
} }
int start = (pagenumber - 1) * pageheight; int start = (pagenumber - 1) * pageheight;
int end = start + pageheight; int end = start + pageheight;
if (end > factionList.size()) { if (end > factionList.size()) {
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; int rank = 1;
for (Faction faction : factionList.subList(start, end)) { for (Faction faction : factionList.subList(start, end)) {
// Get the relation color if player is executing this. // Get the relation color if player is executing this.
String fac = context.sender instanceof Player ? faction.getRelationTo(context.fPlayer).getColor() + faction.getTag() : faction.getTag(); String fac = context.sender instanceof Player ? faction.getRelationTo(context.fPlayer).getColor() + faction.getTag() : faction.getTag();
lines.add(TL.COMMAND_TOP_LINE.format(rank, fac, getValue(faction, criteria))); lines.add(TL.COMMAND_TOP_LINE.format(rank, fac, getValue(faction, criteria)));
rank++; rank++;
} }
context.sendMessage(lines); context.sendMessage(lines);
} }
private String getValue(Faction faction, String criteria) { private String getValue(Faction faction, String criteria) {
if (criteria.equalsIgnoreCase("online")) { if (criteria.equalsIgnoreCase("online")) {
return String.valueOf(faction.getFPlayersWhereOnline(true).size()); return String.valueOf(faction.getFPlayersWhereOnline(true).size());
} else if (criteria.equalsIgnoreCase("start")) { } else if (criteria.equalsIgnoreCase("start")) {
return TL.sdf.format(faction.getFoundedDate()); return TL.sdf.format(faction.getFoundedDate());
} else if (criteria.equalsIgnoreCase("members")) { } else if (criteria.equalsIgnoreCase("members")) {
return String.valueOf(faction.getFPlayers().size()); return String.valueOf(faction.getFPlayers().size());
} else if (criteria.equalsIgnoreCase("land")) { } else if (criteria.equalsIgnoreCase("land")) {
return String.valueOf(faction.getLandRounded()); return String.valueOf(faction.getLandRounded());
} else if (criteria.equalsIgnoreCase("power")) { } else if (criteria.equalsIgnoreCase("power")) {
return String.valueOf(faction.getPowerRounded()); return String.valueOf(faction.getPowerRounded());
} else { // Last one is balance, and it has 3 different things it could be. } else { // Last one is balance, and it has 3 different things it could be.
double balance = Econ.getBalance(faction.getAccountId()); double balance = Econ.getBalance(faction.getAccountId());
for (FPlayer fp : faction.getFPlayers()) { for (FPlayer fp : faction.getFPlayers()) {
balance = Math.round(balance + Econ.getBalance(fp.getAccountId())); balance = Math.round(balance + Econ.getBalance(fp.getAccountId()));
} }
return String.valueOf(balance); return String.valueOf(balance);
} }
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_TOP_DESCRIPTION; return TL.COMMAND_TOP_DESCRIPTION;
} }
} }

View File

@ -9,37 +9,37 @@ import com.massivecraft.factions.zcore.util.TL;
public class CmdTpBanner extends FCommand { public class CmdTpBanner extends FCommand {
public CmdTpBanner() { public CmdTpBanner() {
super(); super();
this.aliases.add("tpbanner"); this.aliases.add("tpbanner");
this.requirements = new CommandRequirements.Builder(Permission.TPBANNER) this.requirements = new CommandRequirements.Builder(Permission.TPBANNER)
.playerOnly() .playerOnly()
.memberOnly() .memberOnly()
.build(); .build();
} }
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
if (!FactionsPlugin.getInstance().getConfig().getBoolean("fbanners.Enabled")) { if (!FactionsPlugin.getInstance().getConfig().getBoolean("fbanners.Enabled")) {
return; return;
} }
final FactionsPlayerListener fpl = new FactionsPlayerListener(); final FactionsPlayerListener fpl = new FactionsPlayerListener();
if (FactionsBlockListener.bannerLocations.containsKey(context.fPlayer.getTag())) { if (FactionsBlockListener.bannerLocations.containsKey(context.fPlayer.getTag())) {
context.msg(TL.COMMAND_TPBANNER_SUCCESS); context.msg(TL.COMMAND_TPBANNER_SUCCESS);
context.doWarmUp(WarmUpUtil.Warmup.BANNER, TL.WARMUPS_NOTIFY_TELEPORT, "Banner", () -> { context.doWarmUp(WarmUpUtil.Warmup.BANNER, TL.WARMUPS_NOTIFY_TELEPORT, "Banner", () -> {
context.player.teleport(FactionsBlockListener.bannerLocations.get(context.fPlayer.getTag())); context.player.teleport(FactionsBlockListener.bannerLocations.get(context.fPlayer.getTag()));
}, FactionsPlugin.getInstance().getConfig().getLong("warmups.f-banner", 0)); }, FactionsPlugin.getInstance().getConfig().getLong("warmups.f-banner", 0));
} else { } else {
context.msg(TL.COMMAND_TPBANNER_NOTSET); context.msg(TL.COMMAND_TPBANNER_NOTSET);
} }
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_TPBANNER_DESCRIPTION; return TL.COMMAND_TPBANNER_DESCRIPTION;
} }
} }

View File

@ -8,47 +8,47 @@ import com.massivecraft.factions.zcore.util.TL;
public class CmdUnban extends FCommand { public class CmdUnban extends FCommand {
public CmdUnban() { public CmdUnban() {
super(); super();
this.aliases.add("unban"); this.aliases.add("unban");
this.requiredArgs.add("target"); this.requiredArgs.add("target");
this.requirements = new CommandRequirements.Builder(Permission.BAN) this.requirements = new CommandRequirements.Builder(Permission.BAN)
.playerOnly() .playerOnly()
.memberOnly() .memberOnly()
.withAction(PermissableAction.BAN) .withAction(PermissableAction.BAN)
.build(); .build();
} }
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
// Good on permission checks. Now lets just ban the player. // Good on permission checks. Now lets just ban the player.
FPlayer target = context.argAsFPlayer(0); FPlayer target = context.argAsFPlayer(0);
if (target == null) { if (target == null) {
return; // the above method sends a message if fails to find someone. return; // the above method sends a message if fails to find someone.
} }
if (target.getFaction() != context.fPlayer.getFaction()) { if (target.getFaction() != context.fPlayer.getFaction()) {
if (target.getFaction().getAccess(context.fPlayer, PermissableAction.BAN) != Access.ALLOW) { if (target.getFaction().getAccess(context.fPlayer, PermissableAction.BAN) != Access.ALLOW) {
if (!context.fPlayer.isAdminBypassing()) { if (!context.fPlayer.isAdminBypassing()) {
context.fPlayer.msg(TL.COMMAND_UNBAN_TARGET_IN_OTHER_FACTION); context.fPlayer.msg(TL.COMMAND_UNBAN_TARGET_IN_OTHER_FACTION);
} }
} }
} }
if (!context.faction.isBanned(target)) { if (!context.faction.isBanned(target)) {
context.msg(TL.COMMAND_UNBAN_NOTBANNED, target.getName()); context.msg(TL.COMMAND_UNBAN_NOTBANNED, target.getName());
return; return;
} }
context.faction.unban(target); context.faction.unban(target);
context.msg(TL.COMMAND_UNBAN_UNBANNED, context.fPlayer.getName(), target.getName()); context.msg(TL.COMMAND_UNBAN_UNBANNED, context.fPlayer.getName(), target.getName());
target.msg(TL.COMMAND_UNBAN_TARGET, context.faction.getTag(target)); target.msg(TL.COMMAND_UNBAN_TARGET, context.faction.getTag(target));
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_UNBAN_DESCRIPTION; return TL.COMMAND_UNBAN_DESCRIPTION;
} }
} }

View File

@ -6,30 +6,30 @@ import com.massivecraft.factions.zcore.fupgrades.FUpgradesGUI;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
public class CmdUpgrades extends FCommand { public class CmdUpgrades extends FCommand {
public CmdUpgrades() { public CmdUpgrades() {
super(); super();
this.aliases.add("upgrades"); this.aliases.add("upgrades");
this.aliases.add("upgrade"); this.aliases.add("upgrade");
this.requirements = new CommandRequirements.Builder(Permission.UPGRADES) this.requirements = new CommandRequirements.Builder(Permission.UPGRADES)
.playerOnly() .playerOnly()
.memberOnly() .memberOnly()
.build(); .build();
} }
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
if (!FactionsPlugin.getInstance().getConfig().getBoolean("fupgrades.Enabled")) { if (!FactionsPlugin.getInstance().getConfig().getBoolean("fupgrades.Enabled")) {
context.fPlayer.sendMessage("This command is disabled!"); context.fPlayer.sendMessage("This command is disabled!");
return; return;
} }
new FUpgradesGUI().openMainMenu(context.fPlayer); new FUpgradesGUI().openMainMenu(context.fPlayer);
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_UPGRADES_DESCRIPTION; return TL.COMMAND_UPGRADES_DESCRIPTION;
} }
} }

View File

@ -13,58 +13,58 @@ import org.bukkit.inventory.Inventory;
public class CmdVault extends FCommand { public class CmdVault extends FCommand {
public CmdVault() { public CmdVault() {
this.aliases.add("vault"); this.aliases.add("vault");
this.requirements = new CommandRequirements.Builder(Permission.VAULT) this.requirements = new CommandRequirements.Builder(Permission.VAULT)
.playerOnly() .playerOnly()
.memberOnly() .memberOnly()
.withAction(PermissableAction.VAULT) .withAction(PermissableAction.VAULT)
.build(); .build();
} }
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
if (!FactionsPlugin.getInstance().getConfig().getBoolean("fvault.Enabled")) { if (!FactionsPlugin.getInstance().getConfig().getBoolean("fvault.Enabled")) {
context.fPlayer.sendMessage("This command is disabled!"); context.fPlayer.sendMessage("This command is disabled!");
return; return;
} }
if (context.fPlayer.isInVault()) { if (context.fPlayer.isInVault()) {
context.player.closeInventory(); context.player.closeInventory();
return; return;
} }
context.fPlayer.setInVault(true); context.fPlayer.setInVault(true);
Location vaultLocation = context.faction.getVault(); Location vaultLocation = context.faction.getVault();
if (vaultLocation == null) { if (vaultLocation == null) {
context.msg(TL.COMMAND_VAULT_INVALID); context.msg(TL.COMMAND_VAULT_INVALID);
return; return;
} }
FLocation vaultFLocation = new FLocation(vaultLocation); FLocation vaultFLocation = new FLocation(vaultLocation);
if (Board.getInstance().getFactionAt(vaultFLocation) != context.faction) { if (Board.getInstance().getFactionAt(vaultFLocation) != context.faction) {
context.faction.setVault(null); context.faction.setVault(null);
context.msg(TL.COMMAND_VAULT_INVALID); context.msg(TL.COMMAND_VAULT_INVALID);
return; return;
} }
if (vaultLocation.getBlock().getType() != Material.CHEST) { if (vaultLocation.getBlock().getType() != Material.CHEST) {
context.faction.setVault(null); context.faction.setVault(null);
context.msg(TL.COMMAND_VAULT_INVALID); context.msg(TL.COMMAND_VAULT_INVALID);
return; return;
} }
Chest chest = (Chest) vaultLocation.getBlock().getState(); Chest chest = (Chest) vaultLocation.getBlock().getState();
Inventory chestInv = chest.getBlockInventory(); Inventory chestInv = chest.getBlockInventory();
context.msg(TL.COMMAND_VAULT_OPENING); context.msg(TL.COMMAND_VAULT_OPENING);
context.player.openInventory(chestInv); context.player.openInventory(chestInv);
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_VAULT_DESCRIPTION; return TL.COMMAND_VAULT_DESCRIPTION;
} }
} }

View File

@ -7,22 +7,22 @@ import com.massivecraft.factions.zcore.util.TL;
public class CmdVersion extends FCommand { public class CmdVersion extends FCommand {
public CmdVersion() { public CmdVersion() {
this.aliases.add("version"); this.aliases.add("version");
this.aliases.add("ver"); this.aliases.add("ver");
this.requirements = new CommandRequirements.Builder(Permission.VERSION) this.requirements = new CommandRequirements.Builder(Permission.VERSION)
.build(); .build();
} }
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
context.msg(TL.COMMAND_VERSION_NAME); // Did this so people can differentiate between SavageFactions and FactionsUUID (( Requested Feature )) context.msg(TL.COMMAND_VERSION_NAME); // Did this so people can differentiate between SavageFactions and FactionsUUID (( Requested Feature ))
context.msg(TL.COMMAND_VERSION_VERSION, FactionsPlugin.getInstance().getDescription().getFullName()); context.msg(TL.COMMAND_VERSION_VERSION, FactionsPlugin.getInstance().getDescription().getFullName());
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_VERSION_DESCRIPTION; return TL.COMMAND_VERSION_DESCRIPTION;
} }
} }

View File

@ -7,37 +7,37 @@ import com.massivecraft.factions.zcore.util.TL;
public class CmdViewChest extends FCommand { public class CmdViewChest extends FCommand {
public CmdViewChest() { public CmdViewChest() {
super(); super();
this.aliases.add("viewchest"); this.aliases.add("viewchest");
this.aliases.add("viewpv"); this.aliases.add("viewpv");
this.requiredArgs.add("faction name"); this.requiredArgs.add("faction name");
this.requirements = new CommandRequirements.Builder(Permission.VIEWCHEST) this.requirements = new CommandRequirements.Builder(Permission.VIEWCHEST)
.playerOnly() .playerOnly()
.build(); .build();
} }
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
if (!FactionsPlugin.getInstance().getConfig().getBoolean("fchest.Enabled")) { if (!FactionsPlugin.getInstance().getConfig().getBoolean("fchest.Enabled")) {
context.msg(TL.GENERIC_DISABLED); context.msg(TL.GENERIC_DISABLED);
return; return;
} }
Faction myFaction = context.fPlayer.getFaction(); Faction myFaction = context.fPlayer.getFaction();
Faction faction = context.argAsFaction(0, context.fPlayer == null ? null : myFaction); Faction faction = context.argAsFaction(0, context.fPlayer == null ? null : myFaction);
if (faction == null) { if (faction == null) {
return; return;
} }
context.player.openInventory(context.faction.getChestInventory()); context.player.openInventory(context.faction.getChestInventory());
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_VIEWCHEST_DESCRIPTION; return TL.COMMAND_VIEWCHEST_DESCRIPTION;
} }
} }

View File

@ -19,400 +19,400 @@ import java.util.List;
*/ */
public class CommandContext { public class CommandContext {
public CommandSender sender; public CommandSender sender;
public Player player; public Player player;
public FPlayer fPlayer; public FPlayer fPlayer;
public Faction faction; public Faction faction;
public List<String> args; public List<String> args;
public String alias; public String alias;
public List<FCommand> commandChain = new ArrayList<>(); // The command chain used to execute this command public List<FCommand> commandChain = new ArrayList<>(); // The command chain used to execute this command
public CommandContext(CommandSender sender, List<String> args, String alias) { public CommandContext(CommandSender sender, List<String> args, String alias) {
this.sender = sender; this.sender = sender;
this.args = args; this.args = args;
this.alias = alias; this.alias = alias;
if (sender instanceof Player) { if (sender instanceof Player) {
this.player = (Player) sender; this.player = (Player) sender;
this.fPlayer = FPlayers.getInstance().getByPlayer(player); this.fPlayer = FPlayers.getInstance().getByPlayer(player);
this.faction = fPlayer.getFaction(); this.faction = fPlayer.getFaction();
} }
} }
// -------------------------------------------- // // -------------------------------------------- //
// Message Sending Helpers // Message Sending Helpers
// -------------------------------------------- // // -------------------------------------------- //
public void msg(String str, Object... args) { public void msg(String str, Object... args) {
sender.sendMessage(FactionsPlugin.getInstance().txt.parse(str, args)); sender.sendMessage(FactionsPlugin.getInstance().txt.parse(str, args));
} }
public void msg(TL translation, Object... args) { public void msg(TL translation, Object... args) {
sender.sendMessage(FactionsPlugin.getInstance().txt.parse(translation.toString(), args)); sender.sendMessage(FactionsPlugin.getInstance().txt.parse(translation.toString(), args));
} }
public void sendMessage(String msg) { public void sendMessage(String msg) {
sender.sendMessage(msg); sender.sendMessage(msg);
} }
public void sendMessage(List<String> msgs) { public void sendMessage(List<String> msgs) {
for (String msg : msgs) { for (String msg : msgs) {
this.sendMessage(msg); this.sendMessage(msg);
} }
} }
public void sendFancyMessage(FancyMessage message) { public void sendFancyMessage(FancyMessage message) {
message.send(sender); message.send(sender);
} }
public void sendFancyMessage(List<FancyMessage> messages) { public void sendFancyMessage(List<FancyMessage> messages) {
for (FancyMessage m : messages) { for (FancyMessage m : messages) {
sendFancyMessage(m); sendFancyMessage(m);
} }
} }
// TODO: Clean this UP // TODO: Clean this UP
// -------------------------------------------- // // -------------------------------------------- //
// Argument Readers // Argument Readers
// -------------------------------------------- // // -------------------------------------------- //
// Is set? ====================== // Is set? ======================
public boolean argIsSet(int idx) { public boolean argIsSet(int idx) {
return args.size() >= idx + 1; return args.size() >= idx + 1;
} }
// STRING ====================== // STRING ======================
public String argAsString(int idx, String def) { public String argAsString(int idx, String def) {
if (args.size() < idx + 1) { if (args.size() < idx + 1) {
return def; return def;
} }
return args.get(idx); return args.get(idx);
} }
public String argAsString(int idx) { public String argAsString(int idx) {
return argAsString(idx, null); return argAsString(idx, null);
} }
// INT ====================== // INT ======================
public Integer strAsInt(String str, Integer def) { public Integer strAsInt(String str, Integer def) {
if (str == null) { if (str == null) {
return def; return def;
} }
try { try {
return Integer.parseInt(str); return Integer.parseInt(str);
} catch (Exception e) { } catch (Exception e) {
return def; return def;
} }
} }
public Integer argAsInt(int idx, Integer def) { public Integer argAsInt(int idx, Integer def) {
return strAsInt(argAsString(idx), def); return strAsInt(argAsString(idx), def);
} }
public Integer argAsInt(int idx) { public Integer argAsInt(int idx) {
return argAsInt(idx, null); return argAsInt(idx, null);
} }
// Double ====================== // Double ======================
public Double strAsDouble(String str, Double def) { public Double strAsDouble(String str, Double def) {
if (str == null) { if (str == null) {
return def; return def;
} }
try { try {
return Double.parseDouble(str); return Double.parseDouble(str);
} catch (Exception e) { } catch (Exception e) {
return def; return def;
} }
} }
public Double argAsDouble(int idx, Double def) { public Double argAsDouble(int idx, Double def) {
return strAsDouble(argAsString(idx), def); return strAsDouble(argAsString(idx), def);
} }
public Double argAsDouble(int idx) { public Double argAsDouble(int idx) {
return argAsDouble(idx, null); return argAsDouble(idx, null);
} }
// TODO: Go through the str conversion for the other arg-readers as well. // TODO: Go through the str conversion for the other arg-readers as well.
// Boolean ====================== // Boolean ======================
public Boolean strAsBool(String str) { public Boolean strAsBool(String str) {
str = str.toLowerCase(); str = str.toLowerCase();
return str.startsWith("y") || str.startsWith("t") || str.startsWith("on") || str.startsWith("+") || str.startsWith("1"); return str.startsWith("y") || str.startsWith("t") || str.startsWith("on") || str.startsWith("+") || str.startsWith("1");
} }
public Boolean argAsBool(int idx, boolean def) { public Boolean argAsBool(int idx, boolean def) {
String str = argAsString(idx); String str = argAsString(idx);
if (str == null) { if (str == null) {
return def; return def;
} }
return strAsBool(str); return strAsBool(str);
} }
public Boolean argAsBool(int idx) { public Boolean argAsBool(int idx) {
return argAsBool(idx, false); return argAsBool(idx, false);
} }
// PLAYER ====================== // PLAYER ======================
public Player strAsPlayer(String name, Player def, boolean msg) { public Player strAsPlayer(String name, Player def, boolean msg) {
Player ret = def; Player ret = def;
if (name != null) { if (name != null) {
Player player = Bukkit.getServer().getPlayer(name); Player player = Bukkit.getServer().getPlayer(name);
if (player != null) { if (player != null) {
ret = player; ret = player;
} }
} }
if (msg && ret == null) { if (msg && ret == null) {
sender.sendMessage(TL.GENERIC_NOPLAYERFOUND.format(name)); sender.sendMessage(TL.GENERIC_NOPLAYERFOUND.format(name));
} }
return ret; return ret;
} }
public Player argAsPlayer(int idx, Player def, boolean msg) { public Player argAsPlayer(int idx, Player def, boolean msg) {
return this.strAsPlayer(argAsString(idx), def, msg); return this.strAsPlayer(argAsString(idx), def, msg);
} }
public Player argAsPlayer(int idx, Player def) { public Player argAsPlayer(int idx, Player def) {
return argAsPlayer(idx, def, true); return argAsPlayer(idx, def, true);
} }
public Player argAsPlayer(int idx) { public Player argAsPlayer(int idx) {
return argAsPlayer(idx, null); return argAsPlayer(idx, null);
} }
// BEST PLAYER MATCH ====================== // BEST PLAYER MATCH ======================
public Player strAsBestPlayerMatch(String name, Player def, boolean msg) { public Player strAsBestPlayerMatch(String name, Player def, boolean msg) {
Player ret = def; Player ret = def;
if (name != null) { if (name != null) {
List<Player> players = Bukkit.getServer().matchPlayer(name); List<Player> players = Bukkit.getServer().matchPlayer(name);
if (players.size() > 0) { if (players.size() > 0) {
ret = players.get(0); ret = players.get(0);
} }
} }
if (msg && ret == null) { if (msg && ret == null) {
sender.sendMessage(TL.GENERIC_NOPLAYERMATCH.format(name)); sender.sendMessage(TL.GENERIC_NOPLAYERMATCH.format(name));
} }
return ret; return ret;
} }
public Player argAsBestPlayerMatch(int idx, Player def, boolean msg) { public Player argAsBestPlayerMatch(int idx, Player def, boolean msg) {
return this.strAsBestPlayerMatch(argAsString(idx), def, msg); return this.strAsBestPlayerMatch(argAsString(idx), def, msg);
} }
public Player argAsBestPlayerMatch(int idx, Player def) { public Player argAsBestPlayerMatch(int idx, Player def) {
return argAsBestPlayerMatch(idx, def, true); return argAsBestPlayerMatch(idx, def, true);
} }
public Player argAsBestPlayerMatch(int idx) { public Player argAsBestPlayerMatch(int idx) {
return argAsPlayer(idx, null); return argAsPlayer(idx, null);
} }
// -------------------------------------------- // // -------------------------------------------- //
// Faction Argument Readers // Faction Argument Readers
// -------------------------------------------- // // -------------------------------------------- //
// FPLAYER ====================== // FPLAYER ======================
public FPlayer strAsFPlayer(String name, FPlayer def, boolean msg) { public FPlayer strAsFPlayer(String name, FPlayer def, boolean msg) {
FPlayer ret = def; FPlayer ret = def;
if (name != null) { if (name != null) {
for (FPlayer fplayer : FPlayers.getInstance().getAllFPlayers()) { for (FPlayer fplayer : FPlayers.getInstance().getAllFPlayers()) {
if (fplayer.getName().equalsIgnoreCase(name)) { if (fplayer.getName().equalsIgnoreCase(name)) {
ret = fplayer; ret = fplayer;
break; break;
} }
} }
} }
if (msg && ret == null) { if (msg && ret == null) {
msg(TL.GENERIC_NOPLAYERFOUND, name); msg(TL.GENERIC_NOPLAYERFOUND, name);
} }
return ret; return ret;
} }
public FPlayer argAsFPlayer(int idx, FPlayer def, boolean msg) { public FPlayer argAsFPlayer(int idx, FPlayer def, boolean msg) {
return this.strAsFPlayer(argAsString(idx), def, msg); return this.strAsFPlayer(argAsString(idx), def, msg);
} }
public FPlayer argAsFPlayer(int idx, FPlayer def) { public FPlayer argAsFPlayer(int idx, FPlayer def) {
return argAsFPlayer(idx, def, true); return argAsFPlayer(idx, def, true);
} }
public FPlayer argAsFPlayer(int idx) { public FPlayer argAsFPlayer(int idx) {
return argAsFPlayer(idx, null); return argAsFPlayer(idx, null);
} }
// BEST FPLAYER MATCH ====================== // BEST FPLAYER MATCH ======================
public FPlayer strAsBestFPlayerMatch(String name, FPlayer def, boolean msg) { public FPlayer strAsBestFPlayerMatch(String name, FPlayer def, boolean msg) {
return strAsFPlayer(name, def, msg); return strAsFPlayer(name, def, msg);
} }
public FPlayer argAsBestFPlayerMatch(int idx, FPlayer def, boolean msg) { public FPlayer argAsBestFPlayerMatch(int idx, FPlayer def, boolean msg) {
return this.strAsBestFPlayerMatch(argAsString(idx), def, msg); return this.strAsBestFPlayerMatch(argAsString(idx), def, msg);
} }
public FPlayer argAsBestFPlayerMatch(int idx, FPlayer def) { public FPlayer argAsBestFPlayerMatch(int idx, FPlayer def) {
return argAsBestFPlayerMatch(idx, def, true); return argAsBestFPlayerMatch(idx, def, true);
} }
public FPlayer argAsBestFPlayerMatch(int idx) { public FPlayer argAsBestFPlayerMatch(int idx) {
return argAsBestFPlayerMatch(idx, null); return argAsBestFPlayerMatch(idx, null);
} }
// FACTION ====================== // FACTION ======================
public Faction strAsFaction(String name, Faction def, boolean msg) { public Faction strAsFaction(String name, Faction def, boolean msg) {
Faction ret = def; Faction ret = def;
if (name != null) { if (name != null) {
// First we try an exact match // First we try an exact match
Faction faction = Factions.getInstance().getByTag(name); // Checks for faction name match. Faction faction = Factions.getInstance().getByTag(name); // Checks for faction name match.
// Now lets try for warzone / safezone. Helpful for custom warzone / safezone names. // 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 // 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. // and a player created faction took one of the names.
if (faction == null) { if (faction == null) {
if (name.equalsIgnoreCase("warzone")) { if (name.equalsIgnoreCase("warzone")) {
faction = Factions.getInstance().getWarZone(); faction = Factions.getInstance().getWarZone();
} else if (name.equalsIgnoreCase("safezone")) { } else if (name.equalsIgnoreCase("safezone")) {
faction = Factions.getInstance().getSafeZone(); faction = Factions.getInstance().getSafeZone();
} }
} }
// Next we match faction tags // Next we match faction tags
if (faction == null) { if (faction == null) {
faction = Factions.getInstance().getBestTagMatch(name); faction = Factions.getInstance().getBestTagMatch(name);
} }
// Next we match player names // Next we match player names
if (faction == null) { if (faction == null) {
FPlayer fplayer = strAsFPlayer(name, null, false); FPlayer fplayer = strAsFPlayer(name, null, false);
if (fplayer != null) { if (fplayer != null) {
faction = fplayer.getFaction(); faction = fplayer.getFaction();
} }
} }
if (faction != null) { if (faction != null) {
ret = faction; ret = faction;
} }
} }
if (msg && ret == null) { if (msg && ret == null) {
sender.sendMessage(TL.GENERIC_NOFACTION_FOUND.format(name)); sender.sendMessage(TL.GENERIC_NOFACTION_FOUND.format(name));
} }
return ret; return ret;
} }
public Faction argAsFaction(int idx, Faction def, boolean msg) { public Faction argAsFaction(int idx, Faction def, boolean msg) {
return this.strAsFaction(argAsString(idx), def, msg); return this.strAsFaction(argAsString(idx), def, msg);
} }
public Faction argAsFaction(int idx, Faction def) { public Faction argAsFaction(int idx, Faction def) {
return argAsFaction(idx, def, true); return argAsFaction(idx, def, true);
} }
public Faction argAsFaction(int idx) { public Faction argAsFaction(int idx) {
return argAsFaction(idx, null); return argAsFaction(idx, null);
} }
/* /*
Assertions Assertions
*/ */
public boolean assertHasFaction() { public boolean assertHasFaction() {
if (player == null) { if (player == null) {
return true; return true;
} }
if (!fPlayer.hasFaction()) { if (!fPlayer.hasFaction()) {
sendMessage("You are not member of any faction."); sendMessage("You are not member of any faction.");
return false; return false;
} }
return true; return true;
} }
public boolean assertMinRole(Role role) { public boolean assertMinRole(Role role) {
if (player == null) { if (player == null) {
return true; return true;
} }
if (fPlayer.getRole().value < role.value) { if (fPlayer.getRole().value < role.value) {
msg("<b>You <h>must be " + role); msg("<b>You <h>must be " + role);
return false; return false;
} }
return true; return true;
} }
/* /*
Common Methods Common Methods
*/ */
public boolean canIAdministerYou(FPlayer i, FPlayer you) { public boolean canIAdministerYou(FPlayer i, FPlayer you) {
if (!i.getFaction().equals(you.getFaction())) { if (!i.getFaction().equals(you.getFaction())) {
i.msg(TL.COMMAND_CONTEXT_ADMINISTER_DIF_FACTION, you.describeTo(i, true)); i.msg(TL.COMMAND_CONTEXT_ADMINISTER_DIF_FACTION, you.describeTo(i, true));
return false; return false;
} }
if (i.getRole().value > you.getRole().value || i.getRole().equals(Role.LEADER)) return true; if (i.getRole().value > you.getRole().value || i.getRole().equals(Role.LEADER)) return true;
if (you.getRole().equals(Role.LEADER)) i.msg(TL.COMMAND_CONTEXT_ADMINISTER_ADMIN_REQUIRED); if (you.getRole().equals(Role.LEADER)) i.msg(TL.COMMAND_CONTEXT_ADMINISTER_ADMIN_REQUIRED);
else if (i.getRole().equals(Role.MODERATOR)) { else if (i.getRole().equals(Role.MODERATOR)) {
if (i == you) return true; //Moderators can control themselves if (i == you) return true; //Moderators can control themselves
else i.msg(TL.COMMAND_CONTEXT_ADMINISTER_SAME_RANK_CONTROL); else i.msg(TL.COMMAND_CONTEXT_ADMINISTER_SAME_RANK_CONTROL);
} else i.msg(TL.COMMAND_CONTEXT_ADMINISTER_MOD_REQUIRED); } else i.msg(TL.COMMAND_CONTEXT_ADMINISTER_MOD_REQUIRED);
return false; 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 // 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) { public boolean payForCommand(double cost, String toDoThis, String forDoingThis) {
if (!Econ.shouldBeUsed() || this.fPlayer == null || cost == 0.0 || fPlayer.isAdminBypassing()) { if (!Econ.shouldBeUsed() || this.fPlayer == null || cost == 0.0 || fPlayer.isAdminBypassing()) {
return true; return true;
} }
if (Conf.bankEnabled && Conf.bankFactionPaysCosts && fPlayer.hasFaction()) { if (Conf.bankEnabled && Conf.bankFactionPaysCosts && fPlayer.hasFaction()) {
return Econ.modifyMoney(faction, -cost, toDoThis, forDoingThis); return Econ.modifyMoney(faction, -cost, toDoThis, forDoingThis);
} else { } else {
return Econ.modifyMoney(fPlayer, -cost, toDoThis, forDoingThis); return Econ.modifyMoney(fPlayer, -cost, toDoThis, forDoingThis);
} }
} }
public boolean payForCommand(double cost, TL toDoThis, TL forDoingThis) { public boolean payForCommand(double cost, TL toDoThis, TL forDoingThis) {
return payForCommand(cost, toDoThis.toString(), forDoingThis.toString()); 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 // 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) { public boolean canAffordCommand(double cost, String toDoThis) {
if (!Econ.shouldBeUsed() || fPlayer == null || cost == 0.0 || fPlayer.isAdminBypassing()) { if (!Econ.shouldBeUsed() || fPlayer == null || cost == 0.0 || fPlayer.isAdminBypassing()) {
return true; return true;
} }
if (Conf.bankEnabled && Conf.bankFactionPaysCosts && fPlayer.hasFaction()) { if (Conf.bankEnabled && Conf.bankFactionPaysCosts && fPlayer.hasFaction()) {
return Econ.hasAtLeast(faction, cost, toDoThis); return Econ.hasAtLeast(faction, cost, toDoThis);
} else { } else {
return Econ.hasAtLeast(fPlayer, cost, toDoThis); return Econ.hasAtLeast(fPlayer, cost, toDoThis);
} }
} }
public void doWarmUp(WarmUpUtil.Warmup warmup, TL translationKey, String action, Runnable runnable, long delay) { public void doWarmUp(WarmUpUtil.Warmup warmup, TL translationKey, String action, Runnable runnable, long delay) {
this.doWarmUp(fPlayer, warmup, translationKey, action, runnable, delay); this.doWarmUp(fPlayer, warmup, translationKey, action, runnable, delay);
} }
public void doWarmUp(FPlayer player, WarmUpUtil.Warmup warmup, TL translationKey, String action, Runnable runnable, long 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); WarmUpUtil.process(player, warmup, translationKey, action, runnable, delay);
} }
} }

View File

@ -9,147 +9,147 @@ import com.massivecraft.factions.zcore.util.TL;
public class CommandRequirements { public class CommandRequirements {
// Permission required to execute command // Permission required to execute command
public Permission permission; public Permission permission;
// Must be player // Must be player
public boolean playerOnly; public boolean playerOnly;
// Must be member of faction // Must be member of faction
public boolean memberOnly; public boolean memberOnly;
// Must be atleast this role // Must be atleast this role
public Role role; public Role role;
// PermissableAction check if the player has allow for this before checking the role // PermissableAction check if the player has allow for this before checking the role
public PermissableAction action; public PermissableAction action;
// Commodore stuffs // Commodore stuffs
public Class<? extends BrigadierProvider> brigadier; public Class<? extends BrigadierProvider> brigadier;
// Edge case handling // Edge case handling
public boolean errorOnManyArgs; public boolean errorOnManyArgs;
public boolean disableOnLock; public boolean disableOnLock;
private CommandRequirements(Permission permission, boolean playerOnly, boolean memberOnly, Role role, PermissableAction action, Class<? extends BrigadierProvider> brigadier) { private CommandRequirements(Permission permission, boolean playerOnly, boolean memberOnly, Role role, PermissableAction action, Class<? extends BrigadierProvider> brigadier) {
this.permission = permission; this.permission = permission;
this.playerOnly = playerOnly; this.playerOnly = playerOnly;
this.memberOnly = memberOnly; this.memberOnly = memberOnly;
this.role = role; this.role = role;
this.action = action; this.action = action;
this.brigadier = brigadier; this.brigadier = brigadier;
} }
public boolean computeRequirements(CommandContext context, boolean informIfNot) { public boolean computeRequirements(CommandContext context, boolean informIfNot) {
// Did not modify CommandRequirements return true // Did not modify CommandRequirements return true
if (permission == null) { if (permission == null) {
return true; return true;
} }
if (context.player != null) { if (context.player != null) {
// Is Player // Is Player
if (!context.fPlayer.hasFaction() && memberOnly) { if (!context.fPlayer.hasFaction() && memberOnly) {
if (informIfNot) context.msg(TL.GENERIC_MEMBERONLY); if (informIfNot) context.msg(TL.GENERIC_MEMBERONLY);
return false;
}
if (!FactionsPlugin.getInstance().perm.has(context.sender, permission.node, informIfNot)) return false;
// Permissable Action provided compute that before role
if (action != null) {
if (context.fPlayer.getRole() == Role.LEADER) return true;
Access access = context.faction.getAccess(context.fPlayer, action);
if (access == Access.DENY) {
if (informIfNot) context.msg(TL.GENERIC_FPERM_NOPERMISSION, action.getName());
return false; return false;
} }
if (!FactionsPlugin.getInstance().perm.has(context.sender, permission.node, informIfNot)) return false; if (access != Access.ALLOW) {
// They have undefined assert their role
// Permissable Action provided compute that before role if (role != null && !context.fPlayer.getRole().isAtLeast(role)) {
if (action != null) { // They do not fullfill the role
if (context.fPlayer.getRole() == Role.LEADER) return true; if (informIfNot) context.msg(TL.GENERIC_YOUMUSTBE, role.translation);
Access access = context.faction.getAccess(context.fPlayer, action); return false;
if (access == Access.DENY) {
if (informIfNot) context.msg(TL.GENERIC_FPERM_NOPERMISSION, action.getName());
return false;
} }
}
// They have been explicitly allowed
return true;
} else {
if ((role != null && !context.fPlayer.getRole().isAtLeast(role)) && informIfNot) {
context.msg(TL.GENERIC_YOUMUSTBE, role.translation);
}
return role == null || context.fPlayer.getRole().isAtLeast(role);
}
} else {
if (playerOnly) {
if (informIfNot) context.sender.sendMessage(TL.GENERIC_PLAYERONLY.toString());
return false;
}
return context.sender.hasPermission(permission.node);
}
}
if (access != Access.ALLOW) { public static class Builder {
// They have undefined assert their role
if (role != null && !context.fPlayer.getRole().isAtLeast(role)) {
// They do not fullfill the role
if (informIfNot) context.msg(TL.GENERIC_YOUMUSTBE, role.translation);
return false;
}
}
// They have been explicitly allowed
return true;
} else {
if ((role != null && !context.fPlayer.getRole().isAtLeast(role)) && informIfNot) {
context.msg(TL.GENERIC_YOUMUSTBE, role.translation);
}
return role == null || context.fPlayer.getRole().isAtLeast(role);
}
} else {
if (playerOnly) {
if (informIfNot) context.sender.sendMessage(TL.GENERIC_PLAYERONLY.toString());
return false;
}
return context.sender.hasPermission(permission.node);
}
}
public static class Builder { private Permission permission;
private Permission permission; private boolean playerOnly = false;
private boolean memberOnly = false;
private boolean playerOnly = false; private Role role = null;
private boolean memberOnly = false; private PermissableAction action;
private Role role = null; private Class<? extends BrigadierProvider> brigadier;
private PermissableAction action;
private Class<? extends BrigadierProvider> brigadier; private boolean errorOnManyArgs = true;
private boolean disableOnLock = true;
private boolean errorOnManyArgs = true; public Builder(Permission permission) {
private boolean disableOnLock = true; this.permission = permission;
}
public Builder(Permission permission) { public Builder playerOnly() {
this.permission = permission; playerOnly = true;
} return this;
}
public Builder playerOnly() { public Builder memberOnly() {
playerOnly = true; playerOnly = true;
return this; memberOnly = true;
} return this;
}
public Builder memberOnly() { public Builder withRole(Role role) {
playerOnly = true; this.role = role;
memberOnly = true; return this;
return this; }
}
public Builder withRole(Role role) { public Builder withAction(PermissableAction action) {
this.role = role; this.action = action;
return this; return this;
} }
public Builder withAction(PermissableAction action) { public Builder brigadier(Class<? extends BrigadierProvider> brigadier) {
this.action = action; this.brigadier = brigadier;
return this; return this;
} }
public Builder brigadier(Class<? extends BrigadierProvider> brigadier) { public CommandRequirements build() {
this.brigadier = brigadier; CommandRequirements requirements = new CommandRequirements(permission, playerOnly, memberOnly, role, action, brigadier);
return this; requirements.errorOnManyArgs = errorOnManyArgs;
} requirements.disableOnLock = disableOnLock;
return requirements;
}
public CommandRequirements build() { public Builder noErrorOnManyArgs() {
CommandRequirements requirements = new CommandRequirements(permission, playerOnly, memberOnly, role, action, brigadier); errorOnManyArgs = false;
requirements.errorOnManyArgs = errorOnManyArgs; return this;
requirements.disableOnLock = disableOnLock; }
return requirements;
}
public Builder noErrorOnManyArgs() { public Builder noDisableOnLock() {
errorOnManyArgs = false; disableOnLock = false;
return this; return this;
} }
public Builder noDisableOnLock() { }
disableOnLock = false;
return this;
}
}
} }

View File

@ -36,307 +36,307 @@ import java.util.logging.Level;
public class FCmdRoot extends FCommand implements CommandExecutor { public class FCmdRoot extends FCommand implements CommandExecutor {
public BrigadierManager brigadierManager; public BrigadierManager brigadierManager;
public CmdAdmin cmdAdmin = new CmdAdmin(); public CmdAdmin cmdAdmin = new CmdAdmin();
public CmdAutoClaim cmdAutoClaim = new CmdAutoClaim(); public CmdAutoClaim cmdAutoClaim = new CmdAutoClaim();
public CmdBoom cmdBoom = new CmdBoom(); public CmdBoom cmdBoom = new CmdBoom();
public CmdBypass cmdBypass = new CmdBypass(); public CmdBypass cmdBypass = new CmdBypass();
public CmdChat cmdChat = new CmdChat(); public CmdChat cmdChat = new CmdChat();
public CmdChatSpy cmdChatSpy = new CmdChatSpy(); public CmdChatSpy cmdChatSpy = new CmdChatSpy();
public CmdClaim cmdClaim = new CmdClaim(); public CmdClaim cmdClaim = new CmdClaim();
public CmdConfig cmdConfig = new CmdConfig(); public CmdConfig cmdConfig = new CmdConfig();
public CmdCreate cmdCreate = new CmdCreate(); public CmdCreate cmdCreate = new CmdCreate();
public CmdDeinvite cmdDeinvite = new CmdDeinvite(); public CmdDeinvite cmdDeinvite = new CmdDeinvite();
public CmdDescription cmdDescription = new CmdDescription(); public CmdDescription cmdDescription = new CmdDescription();
public CmdDisband cmdDisband = new CmdDisband(); public CmdDisband cmdDisband = new CmdDisband();
public CmdFocus cmdFocus = new CmdFocus(); public CmdFocus cmdFocus = new CmdFocus();
public CmdGrace cmdGrace = new CmdGrace(); public CmdGrace cmdGrace = new CmdGrace();
public CmdHelp cmdHelp = new CmdHelp(); public CmdHelp cmdHelp = new CmdHelp();
public CmdHome cmdHome = new CmdHome(); public CmdHome cmdHome = new CmdHome();
public CmdInvite cmdInvite = new CmdInvite(); public CmdInvite cmdInvite = new CmdInvite();
public CmdJoin cmdJoin = new CmdJoin(); public CmdJoin cmdJoin = new CmdJoin();
public CmdKick cmdKick = new CmdKick(); public CmdKick cmdKick = new CmdKick();
public CmdLeave cmdLeave = new CmdLeave(); public CmdLeave cmdLeave = new CmdLeave();
public CmdList cmdList = new CmdList(); public CmdList cmdList = new CmdList();
public CmdLock cmdLock = new CmdLock(); public CmdLock cmdLock = new CmdLock();
public CmdMap cmdMap = new CmdMap(); public CmdMap cmdMap = new CmdMap();
public CmdMod cmdMod = new CmdMod(); public CmdMod cmdMod = new CmdMod();
public CmdMoney cmdMoney = new CmdMoney(); public CmdMoney cmdMoney = new CmdMoney();
public CmdOpen cmdOpen = new CmdOpen(); public CmdOpen cmdOpen = new CmdOpen();
public CmdOwner cmdOwner = new CmdOwner(); public CmdOwner cmdOwner = new CmdOwner();
public CmdOwnerList cmdOwnerList = new CmdOwnerList(); public CmdOwnerList cmdOwnerList = new CmdOwnerList();
public CmdPeaceful cmdPeaceful = new CmdPeaceful(); public CmdPeaceful cmdPeaceful = new CmdPeaceful();
public CmdPermanent cmdPermanent = new CmdPermanent(); public CmdPermanent cmdPermanent = new CmdPermanent();
public CmdPermanentPower cmdPermanentPower = new CmdPermanentPower(); public CmdPermanentPower cmdPermanentPower = new CmdPermanentPower();
public CmdPowerBoost cmdPowerBoost = new CmdPowerBoost(); public CmdPowerBoost cmdPowerBoost = new CmdPowerBoost();
public CmdPower cmdPower = new CmdPower(); public CmdPower cmdPower = new CmdPower();
public CmdRelationAlly cmdRelationAlly = new CmdRelationAlly(); public CmdRelationAlly cmdRelationAlly = new CmdRelationAlly();
public CmdRelationEnemy cmdRelationEnemy = new CmdRelationEnemy(); public CmdRelationEnemy cmdRelationEnemy = new CmdRelationEnemy();
public CmdRelationNeutral cmdRelationNeutral = new CmdRelationNeutral(); public CmdRelationNeutral cmdRelationNeutral = new CmdRelationNeutral();
public CmdRelationTruce cmdRelationTruce = new CmdRelationTruce(); public CmdRelationTruce cmdRelationTruce = new CmdRelationTruce();
public CmdReload cmdReload = new CmdReload(); public CmdReload cmdReload = new CmdReload();
public CmdSafeunclaimall cmdSafeunclaimall = new CmdSafeunclaimall(); public CmdSafeunclaimall cmdSafeunclaimall = new CmdSafeunclaimall();
public CmdSaveAll cmdSaveAll = new CmdSaveAll(); public CmdSaveAll cmdSaveAll = new CmdSaveAll();
public CmdSethome cmdSethome = new CmdSethome(); public CmdSethome cmdSethome = new CmdSethome();
public CmdShow cmdShow = new CmdShow(); public CmdShow cmdShow = new CmdShow();
public CmdStatus cmdStatus = new CmdStatus(); public CmdStatus cmdStatus = new CmdStatus();
public CmdStealth cmdStealth = new CmdStealth(); public CmdStealth cmdStealth = new CmdStealth();
public CmdStuck cmdStuck = new CmdStuck(); public CmdStuck cmdStuck = new CmdStuck();
public CmdTag cmdTag = new CmdTag(); public CmdTag cmdTag = new CmdTag();
public CmdTitle cmdTitle = new CmdTitle(); public CmdTitle cmdTitle = new CmdTitle();
public CmdToggleAllianceChat cmdToggleAllianceChat = new CmdToggleAllianceChat(); public CmdToggleAllianceChat cmdToggleAllianceChat = new CmdToggleAllianceChat();
public CmdUnclaim cmdUnclaim = new CmdUnclaim(); public CmdUnclaim cmdUnclaim = new CmdUnclaim();
public CmdUnclaimall cmdUnclaimall = new CmdUnclaimall(); public CmdUnclaimall cmdUnclaimall = new CmdUnclaimall();
public CmdVersion cmdVersion = new CmdVersion(); public CmdVersion cmdVersion = new CmdVersion();
public CmdWarunclaimall cmdWarunclaimall = new CmdWarunclaimall(); public CmdWarunclaimall cmdWarunclaimall = new CmdWarunclaimall();
public CmdSB cmdSB = new CmdSB(); public CmdSB cmdSB = new CmdSB();
public CmdShowInvites cmdShowInvites = new CmdShowInvites(); public CmdShowInvites cmdShowInvites = new CmdShowInvites();
public CmdAnnounce cmdAnnounce = new CmdAnnounce(); public CmdAnnounce cmdAnnounce = new CmdAnnounce();
public CmdPaypalSet cmdPaypalSet = new CmdPaypalSet(); public CmdPaypalSet cmdPaypalSet = new CmdPaypalSet();
public CmdPaypalSee cmdPaypalSee = new CmdPaypalSee(); public CmdPaypalSee cmdPaypalSee = new CmdPaypalSee();
public CmdSeeChunk cmdSeeChunk = new CmdSeeChunk(); public CmdSeeChunk cmdSeeChunk = new CmdSeeChunk();
public CmdConvert cmdConvert = new CmdConvert(); public CmdConvert cmdConvert = new CmdConvert();
public CmdFWarp cmdFWarp = new CmdFWarp(); public CmdFWarp cmdFWarp = new CmdFWarp();
public CmdSetFWarp cmdSetFWarp = new CmdSetFWarp(); public CmdSetFWarp cmdSetFWarp = new CmdSetFWarp();
public CmdDelFWarp cmdDelFWarp = new CmdDelFWarp(); public CmdDelFWarp cmdDelFWarp = new CmdDelFWarp();
public CmdModifyPower cmdModifyPower = new CmdModifyPower(); public CmdModifyPower cmdModifyPower = new CmdModifyPower();
public CmdLogins cmdLogins = new CmdLogins(); public CmdLogins cmdLogins = new CmdLogins();
public CmdClaimLine cmdClaimLine = new CmdClaimLine(); public CmdClaimLine cmdClaimLine = new CmdClaimLine();
public CmdTop cmdTop = new CmdTop(); public CmdTop cmdTop = new CmdTop();
public CmdAHome cmdAHome = new CmdAHome(); public CmdAHome cmdAHome = new CmdAHome();
public CmdPerm cmdPerm = new CmdPerm(); public CmdPerm cmdPerm = new CmdPerm();
public CmdPromote cmdPromote = new CmdPromote(); public CmdPromote cmdPromote = new CmdPromote();
public CmdDemote cmdDemote = new CmdDemote(); public CmdDemote cmdDemote = new CmdDemote();
public CmdSetDefaultRole cmdSetDefaultRole = new CmdSetDefaultRole(); public CmdSetDefaultRole cmdSetDefaultRole = new CmdSetDefaultRole();
public CmdMapHeight cmdMapHeight = new CmdMapHeight(); public CmdMapHeight cmdMapHeight = new CmdMapHeight();
public CmdClaimAt cmdClaimAt = new CmdClaimAt(); public CmdClaimAt cmdClaimAt = new CmdClaimAt();
public CmdBan cmdban = new CmdBan(); public CmdBan cmdban = new CmdBan();
public CmdUnban cmdUnban = new CmdUnban(); public CmdUnban cmdUnban = new CmdUnban();
public CmdBanlist cmdbanlist = new CmdBanlist(); public CmdBanlist cmdbanlist = new CmdBanlist();
public CmdRules cmdRules = new CmdRules(); public CmdRules cmdRules = new CmdRules();
public CmdCheckpoint cmdCheckpoint = new CmdCheckpoint(); public CmdCheckpoint cmdCheckpoint = new CmdCheckpoint();
public CmdTnt cmdTnt = new CmdTnt(); public CmdTnt cmdTnt = new CmdTnt();
public CmdNear cmdNear = new CmdNear(); public CmdNear cmdNear = new CmdNear();
public CmdUpgrades cmdUpgrades = new CmdUpgrades(); public CmdUpgrades cmdUpgrades = new CmdUpgrades();
public CmdVault cmdVault = new CmdVault(); public CmdVault cmdVault = new CmdVault();
public CmdGetVault cmdGetVault = new CmdGetVault(); public CmdGetVault cmdGetVault = new CmdGetVault();
public CmdFly cmdFly = new CmdFly(); public CmdFly cmdFly = new CmdFly();
public CmdColeader cmdColeader = new CmdColeader(); public CmdColeader cmdColeader = new CmdColeader();
public CmdBanner cmdBanner = new CmdBanner(); public CmdBanner cmdBanner = new CmdBanner();
public CmdTpBanner cmdTpBanner = new CmdTpBanner(); public CmdTpBanner cmdTpBanner = new CmdTpBanner();
public CmdKillHolograms cmdKillHolograms = new CmdKillHolograms(); public CmdKillHolograms cmdKillHolograms = new CmdKillHolograms();
public CmdInspect cmdInspect = new CmdInspect(); public CmdInspect cmdInspect = new CmdInspect();
public CmdCoords cmdCoords = new CmdCoords(); public CmdCoords cmdCoords = new CmdCoords();
public CmdShowClaims cmdShowClaims = new CmdShowClaims(); public CmdShowClaims cmdShowClaims = new CmdShowClaims();
public CmdLowPower cmdLowPower = new CmdLowPower(); public CmdLowPower cmdLowPower = new CmdLowPower();
public CmdTntFill cmdTntFill = new CmdTntFill(); public CmdTntFill cmdTntFill = new CmdTntFill();
public CmdChest cmdChest = new CmdChest(); public CmdChest cmdChest = new CmdChest();
public CmdSetBanner cmdSetBanner = new CmdSetBanner(); public CmdSetBanner cmdSetBanner = new CmdSetBanner();
public CmdAlts cmdAlts = new CmdAlts(); public CmdAlts cmdAlts = new CmdAlts();
public CmdCorner cmdCorner = new CmdCorner(); public CmdCorner cmdCorner = new CmdCorner();
public CmdInventorySee cmdInventorySee = new CmdInventorySee(); public CmdInventorySee cmdInventorySee = new CmdInventorySee();
public CmdFGlobal cmdFGlobal = new CmdFGlobal(); public CmdFGlobal cmdFGlobal = new CmdFGlobal();
public CmdViewChest cmdViewChest = new CmdViewChest(); public CmdViewChest cmdViewChest = new CmdViewChest();
public CmdPoints cmdPoints = new CmdPoints(); public CmdPoints cmdPoints = new CmdPoints();
public CmdLogout cmdLogout = new CmdLogout(); public CmdLogout cmdLogout = new CmdLogout();
public CmdShop cmdShop = new CmdShop(); public CmdShop cmdShop = new CmdShop();
public CmdMissions cmdMissions = new CmdMissions(); public CmdMissions cmdMissions = new CmdMissions();
public CmdStrikes cmdStrikes = new CmdStrikes(); public CmdStrikes cmdStrikes = new CmdStrikes();
public CmdCheck cmdCheck = new CmdCheck(); public CmdCheck cmdCheck = new CmdCheck();
public CmdWeeWoo cmdWeeWoo = new CmdWeeWoo(); public CmdWeeWoo cmdWeeWoo = new CmdWeeWoo();
public CmdConvertConfig cmdConvertConfig = new CmdConvertConfig(); public CmdConvertConfig cmdConvertConfig = new CmdConvertConfig();
public FCmdRoot() { public FCmdRoot() {
super(); super();
if (CommodoreProvider.isSupported()) brigadierManager = new BrigadierManager(); if (CommodoreProvider.isSupported()) brigadierManager = new BrigadierManager();
this.aliases.addAll(Conf.baseCommandAliases); this.aliases.addAll(Conf.baseCommandAliases);
this.aliases.removeAll(Collections.<String>singletonList(null)); this.aliases.removeAll(Collections.<String>singletonList(null));
this.setHelpShort("The faction base command"); this.setHelpShort("The faction base command");
this.helpLong.add(FactionsPlugin.getInstance().txt.parseTags("<i>This command contains all faction stuff.")); this.helpLong.add(FactionsPlugin.getInstance().txt.parseTags("<i>This command contains all faction stuff."));
if (CommodoreProvider.isSupported()) brigadierManager = new BrigadierManager(); if (CommodoreProvider.isSupported()) brigadierManager = new BrigadierManager();
this.addSubCommand(this.cmdAdmin); this.addSubCommand(this.cmdAdmin);
this.addSubCommand(this.cmdAutoClaim); this.addSubCommand(this.cmdAutoClaim);
this.addSubCommand(this.cmdBoom); this.addSubCommand(this.cmdBoom);
this.addSubCommand(this.cmdBypass); this.addSubCommand(this.cmdBypass);
this.addSubCommand(this.cmdChat); this.addSubCommand(this.cmdChat);
this.addSubCommand(this.cmdToggleAllianceChat); this.addSubCommand(this.cmdToggleAllianceChat);
this.addSubCommand(this.cmdChatSpy); this.addSubCommand(this.cmdChatSpy);
this.addSubCommand(this.cmdClaim); this.addSubCommand(this.cmdClaim);
this.addSubCommand(this.cmdConfig); this.addSubCommand(this.cmdConfig);
this.addSubCommand(this.cmdCreate); this.addSubCommand(this.cmdCreate);
this.addSubCommand(this.cmdDeinvite); this.addSubCommand(this.cmdDeinvite);
this.addSubCommand(this.cmdDescription); this.addSubCommand(this.cmdDescription);
this.addSubCommand(this.cmdDisband); this.addSubCommand(this.cmdDisband);
this.addSubCommand(this.cmdHelp); this.addSubCommand(this.cmdHelp);
this.addSubCommand(this.cmdHome); this.addSubCommand(this.cmdHome);
this.addSubCommand(this.cmdInvite); this.addSubCommand(this.cmdInvite);
this.addSubCommand(this.cmdJoin); this.addSubCommand(this.cmdJoin);
this.addSubCommand(this.cmdKick); this.addSubCommand(this.cmdKick);
this.addSubCommand(this.cmdLeave); this.addSubCommand(this.cmdLeave);
this.addSubCommand(this.cmdList); this.addSubCommand(this.cmdList);
this.addSubCommand(this.cmdLock); this.addSubCommand(this.cmdLock);
this.addSubCommand(this.cmdMap); this.addSubCommand(this.cmdMap);
this.addSubCommand(this.cmdMod); this.addSubCommand(this.cmdMod);
this.addSubCommand(this.cmdMoney); this.addSubCommand(this.cmdMoney);
this.addSubCommand(this.cmdOpen); this.addSubCommand(this.cmdOpen);
this.addSubCommand(this.cmdOwner); this.addSubCommand(this.cmdOwner);
this.addSubCommand(this.cmdOwnerList); this.addSubCommand(this.cmdOwnerList);
this.addSubCommand(this.cmdPeaceful); this.addSubCommand(this.cmdPeaceful);
this.addSubCommand(this.cmdPermanent); this.addSubCommand(this.cmdPermanent);
this.addSubCommand(this.cmdPermanentPower); this.addSubCommand(this.cmdPermanentPower);
this.addSubCommand(this.cmdPower); this.addSubCommand(this.cmdPower);
this.addSubCommand(this.cmdPowerBoost); this.addSubCommand(this.cmdPowerBoost);
this.addSubCommand(this.cmdRelationAlly); this.addSubCommand(this.cmdRelationAlly);
this.addSubCommand(this.cmdRelationEnemy); this.addSubCommand(this.cmdRelationEnemy);
this.addSubCommand(this.cmdRelationNeutral); this.addSubCommand(this.cmdRelationNeutral);
this.addSubCommand(this.cmdRelationTruce); this.addSubCommand(this.cmdRelationTruce);
this.addSubCommand(this.cmdReload); this.addSubCommand(this.cmdReload);
this.addSubCommand(this.cmdSafeunclaimall); this.addSubCommand(this.cmdSafeunclaimall);
this.addSubCommand(this.cmdSaveAll); this.addSubCommand(this.cmdSaveAll);
this.addSubCommand(this.cmdSethome); this.addSubCommand(this.cmdSethome);
this.addSubCommand(this.cmdShow); this.addSubCommand(this.cmdShow);
this.addSubCommand(this.cmdStatus); this.addSubCommand(this.cmdStatus);
this.addSubCommand(this.cmdStealth); this.addSubCommand(this.cmdStealth);
this.addSubCommand(this.cmdStuck); this.addSubCommand(this.cmdStuck);
this.addSubCommand(this.cmdLogout); this.addSubCommand(this.cmdLogout);
this.addSubCommand(this.cmdTag); this.addSubCommand(this.cmdTag);
this.addSubCommand(this.cmdTitle); this.addSubCommand(this.cmdTitle);
this.addSubCommand(this.cmdUnclaim); this.addSubCommand(this.cmdUnclaim);
this.addSubCommand(this.cmdUnclaimall); this.addSubCommand(this.cmdUnclaimall);
this.addSubCommand(this.cmdVersion); this.addSubCommand(this.cmdVersion);
this.addSubCommand(this.cmdWarunclaimall); this.addSubCommand(this.cmdWarunclaimall);
this.addSubCommand(this.cmdSB); this.addSubCommand(this.cmdSB);
this.addSubCommand(this.cmdShowInvites); this.addSubCommand(this.cmdShowInvites);
this.addSubCommand(this.cmdAnnounce); this.addSubCommand(this.cmdAnnounce);
this.addSubCommand(this.cmdSeeChunk); this.addSubCommand(this.cmdSeeChunk);
this.addSubCommand(this.cmdConvert); this.addSubCommand(this.cmdConvert);
this.addSubCommand(this.cmdFWarp); this.addSubCommand(this.cmdFWarp);
this.addSubCommand(this.cmdSetFWarp); this.addSubCommand(this.cmdSetFWarp);
this.addSubCommand(this.cmdDelFWarp); this.addSubCommand(this.cmdDelFWarp);
this.addSubCommand(this.cmdModifyPower); this.addSubCommand(this.cmdModifyPower);
this.addSubCommand(this.cmdLogins); this.addSubCommand(this.cmdLogins);
this.addSubCommand(this.cmdClaimLine); this.addSubCommand(this.cmdClaimLine);
this.addSubCommand(this.cmdAHome); this.addSubCommand(this.cmdAHome);
this.addSubCommand(this.cmdPerm); this.addSubCommand(this.cmdPerm);
this.addSubCommand(this.cmdPromote); this.addSubCommand(this.cmdPromote);
this.addSubCommand(this.cmdDemote); this.addSubCommand(this.cmdDemote);
this.addSubCommand(this.cmdSetDefaultRole); this.addSubCommand(this.cmdSetDefaultRole);
this.addSubCommand(this.cmdMapHeight); this.addSubCommand(this.cmdMapHeight);
this.addSubCommand(this.cmdClaimAt); this.addSubCommand(this.cmdClaimAt);
this.addSubCommand(this.cmdban); this.addSubCommand(this.cmdban);
this.addSubCommand(this.cmdUnban); this.addSubCommand(this.cmdUnban);
this.addSubCommand(this.cmdbanlist); this.addSubCommand(this.cmdbanlist);
this.addSubCommand(this.cmdRules); this.addSubCommand(this.cmdRules);
this.addSubCommand(this.cmdCheckpoint); this.addSubCommand(this.cmdCheckpoint);
this.addSubCommand(this.cmdTnt); this.addSubCommand(this.cmdTnt);
this.addSubCommand(this.cmdNear); this.addSubCommand(this.cmdNear);
this.addSubCommand(this.cmdUpgrades); this.addSubCommand(this.cmdUpgrades);
this.addSubCommand(this.cmdVault); this.addSubCommand(this.cmdVault);
this.addSubCommand(this.cmdGetVault); this.addSubCommand(this.cmdGetVault);
this.addSubCommand(this.cmdColeader); this.addSubCommand(this.cmdColeader);
this.addSubCommand(this.cmdBanner); this.addSubCommand(this.cmdBanner);
this.addSubCommand(this.cmdTpBanner); this.addSubCommand(this.cmdTpBanner);
this.addSubCommand(this.cmdKillHolograms); this.addSubCommand(this.cmdKillHolograms);
this.addSubCommand(this.cmdCoords); this.addSubCommand(this.cmdCoords);
this.addSubCommand(this.cmdShowClaims); this.addSubCommand(this.cmdShowClaims);
this.addSubCommand(this.cmdLowPower); this.addSubCommand(this.cmdLowPower);
this.addSubCommand(this.cmdTntFill); this.addSubCommand(this.cmdTntFill);
this.addSubCommand(this.cmdChest); this.addSubCommand(this.cmdChest);
this.addSubCommand(this.cmdSetBanner); this.addSubCommand(this.cmdSetBanner);
this.addSubCommand(this.cmdCorner); this.addSubCommand(this.cmdCorner);
this.addSubCommand(this.cmdStrikes); this.addSubCommand(this.cmdStrikes);
this.addSubCommand(this.cmdFGlobal); this.addSubCommand(this.cmdFGlobal);
this.addSubCommand(this.cmdViewChest); this.addSubCommand(this.cmdViewChest);
this.addSubCommand(this.cmdConvertConfig); this.addSubCommand(this.cmdConvertConfig);
if (Conf.useCheckSystem) { if (Conf.useCheckSystem) {
this.addSubCommand(this.cmdCheck); this.addSubCommand(this.cmdCheck);
this.addSubCommand(this.cmdWeeWoo); this.addSubCommand(this.cmdWeeWoo);
} }
if (FactionsPlugin.getInstance().getConfig().getBoolean("Missions-Enabled")) { if (FactionsPlugin.getInstance().getConfig().getBoolean("Missions-Enabled")) {
this.addSubCommand(this.cmdMissions); this.addSubCommand(this.cmdMissions);
} }
if (FactionsPlugin.getInstance().getConfig().getBoolean("F-Shop.Enabled")) { if (FactionsPlugin.getInstance().getConfig().getBoolean("F-Shop.Enabled")) {
this.addSubCommand(this.cmdShop); this.addSubCommand(this.cmdShop);
} }
if (FactionsPlugin.getInstance().getConfig().getBoolean("f-inventory-see.Enabled")) { if (FactionsPlugin.getInstance().getConfig().getBoolean("f-inventory-see.Enabled")) {
this.addSubCommand(this.cmdInventorySee); this.addSubCommand(this.cmdInventorySee);
} }
if (FactionsPlugin.getInstance().getConfig().getBoolean("f-points.Enabled")) { if (FactionsPlugin.getInstance().getConfig().getBoolean("f-points.Enabled")) {
this.addSubCommand(this.cmdPoints); this.addSubCommand(this.cmdPoints);
} }
if (FactionsPlugin.getInstance().getConfig().getBoolean("f-alts.Enabled")) { if (FactionsPlugin.getInstance().getConfig().getBoolean("f-alts.Enabled")) {
this.addSubCommand(this.cmdAlts); this.addSubCommand(this.cmdAlts);
} }
if (FactionsPlugin.getInstance().getConfig().getBoolean("f-grace.Enabled")) { if (FactionsPlugin.getInstance().getConfig().getBoolean("f-grace.Enabled")) {
this.addSubCommand(this.cmdGrace); this.addSubCommand(this.cmdGrace);
} }
if (Bukkit.getServer().getPluginManager().getPlugin("CoreProtect") != null) { if (Bukkit.getServer().getPluginManager().getPlugin("CoreProtect") != null) {
FactionsPlugin.getInstance().log("Found CoreProtect, enabling Inspect"); FactionsPlugin.getInstance().log("Found CoreProtect, enabling Inspect");
this.addSubCommand(this.cmdInspect); this.addSubCommand(this.cmdInspect);
} else { } else {
FactionsPlugin.getInstance().log("CoreProtect not found, disabling Inspect"); FactionsPlugin.getInstance().log("CoreProtect not found, disabling Inspect");
} }
if (FactionsPlugin.getInstance().getConfig().getBoolean("ffocus.Enabled")) { if (FactionsPlugin.getInstance().getConfig().getBoolean("ffocus.Enabled")) {
addSubCommand(this.cmdFocus); addSubCommand(this.cmdFocus);
} }
if (FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight", false)) { if (FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight", false)) {
this.addSubCommand(this.cmdFly); this.addSubCommand(this.cmdFly);
} }
if (Bukkit.getServer().getPluginManager().getPlugin("FactionsTop") != null || Bukkit.getServer().getPluginManager().getPlugin("SavageFTOP") != null || Bukkit.getServer().getPluginManager().getPlugin("SaberFTOP") != null) { if (Bukkit.getServer().getPluginManager().getPlugin("FactionsTop") != null || Bukkit.getServer().getPluginManager().getPlugin("SavageFTOP") != null || Bukkit.getServer().getPluginManager().getPlugin("SaberFTOP") != null) {
FactionsPlugin.getInstance().log(Level.INFO, "Found FactionsTop plugin. Disabling our own /f top command."); FactionsPlugin.getInstance().log(Level.INFO, "Found FactionsTop plugin. Disabling our own /f top command.");
} else { } else {
FactionsPlugin.getInstance().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."); FactionsPlugin.getInstance().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); this.addSubCommand(this.cmdTop);
} }
if (FactionsPlugin.getInstance().getConfig().getBoolean("fpaypal.Enabled")) { if (FactionsPlugin.getInstance().getConfig().getBoolean("fpaypal.Enabled")) {
this.addSubCommand(this.cmdPaypalSet); this.addSubCommand(this.cmdPaypalSet);
this.addSubCommand(this.cmdPaypalSee); this.addSubCommand(this.cmdPaypalSee);
} }
if (CommodoreProvider.isSupported()) brigadierManager.build(); if (CommodoreProvider.isSupported()) brigadierManager.build();
} }
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
context.commandChain.add(this); context.commandChain.add(this);
this.cmdHelp.execute(context); this.cmdHelp.execute(context);
} }
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
this.execute(new CommandContext(sender, new ArrayList<>(Arrays.asList(args)), label)); this.execute(new CommandContext(sender, new ArrayList<>(Arrays.asList(args)), label));
return true; return true;
} }
@Override @Override
public void addSubCommand(FCommand subCommand) { public void addSubCommand(FCommand subCommand) {
super.addSubCommand(subCommand); super.addSubCommand(subCommand);
// People were getting NPE's as somehow CommodoreProvider#isSupported returned true on legacy versions. // People were getting NPE's as somehow CommodoreProvider#isSupported returned true on legacy versions.
if (CommodoreProvider.isSupported()) { if (CommodoreProvider.isSupported()) {
brigadierManager.addSubCommand(subCommand); brigadierManager.addSubCommand(subCommand);
} }
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.GENERIC_PLACEHOLDER; return TL.GENERIC_PLACEHOLDER;
} }
} }

View File

@ -17,232 +17,232 @@ import java.util.*;
public abstract class FCommand { public abstract class FCommand {
public SimpleDateFormat sdf = new SimpleDateFormat(TL.DATE_FORMAT.toString()); public SimpleDateFormat sdf = new SimpleDateFormat(TL.DATE_FORMAT.toString());
// Command Aliases // Command Aliases
public List<String> aliases; public List<String> aliases;
// Information on the args // Information on the args
public List<String> requiredArgs; public List<String> requiredArgs;
public LinkedHashMap<String, String> optionalArgs; public LinkedHashMap<String, String> optionalArgs;
// Requirements to execute this command // Requirements to execute this command
public CommandRequirements requirements; public CommandRequirements requirements;
/* /*
Subcommands Subcommands
*/ */
public List<FCommand> subCommands; public List<FCommand> subCommands;
/* /*
Help Help
*/ */
public List<String> helpLong; public List<String> helpLong;
public CommandVisibility visibility; public CommandVisibility visibility;
private String helpShort; private String helpShort;
public FCommand() { public FCommand() {
requirements = new CommandRequirements.Builder(null).build(); requirements = new CommandRequirements.Builder(null).build();
this.subCommands = new ArrayList<>(); this.subCommands = new ArrayList<>();
this.aliases = new ArrayList<>(); this.aliases = new ArrayList<>();
this.requiredArgs = new ArrayList<>(); this.requiredArgs = new ArrayList<>();
this.optionalArgs = new LinkedHashMap<>(); this.optionalArgs = new LinkedHashMap<>();
this.helpShort = null; this.helpShort = null;
this.helpLong = new ArrayList<>(); this.helpLong = new ArrayList<>();
this.visibility = CommandVisibility.VISIBLE; this.visibility = CommandVisibility.VISIBLE;
} }
public abstract void perform(CommandContext context); public abstract void perform(CommandContext context);
public void execute(CommandContext context) { public void execute(CommandContext context) {
// Is there a matching sub command? // Is there a matching sub command?
if (context.args.size() > 0) { if (context.args.size() > 0) {
for (FCommand subCommand : this.subCommands) { for (FCommand subCommand : this.subCommands) {
if (subCommand.aliases.contains(context.args.get(0).toLowerCase())) { if (subCommand.aliases.contains(context.args.get(0).toLowerCase())) {
context.args.remove(0); context.args.remove(0);
context.commandChain.add(this); context.commandChain.add(this);
subCommand.execute(context); subCommand.execute(context);
return; return;
} }
} }
} }
if (!validCall(context)) { if (!validCall(context)) {
return; return;
} }
if (!this.isEnabled(context)) { if (!this.isEnabled(context)) {
return; return;
} }
perform(context); perform(context);
} }
public boolean validCall(CommandContext context) { public boolean validCall(CommandContext context) {
return requirements.computeRequirements(context, true) && validArgs(context); return requirements.computeRequirements(context, true) && validArgs(context);
} }
public boolean isEnabled(CommandContext context) { public boolean isEnabled(CommandContext context) {
if (FactionsPlugin.getInstance().getLocked() && requirements.disableOnLock) { if (FactionsPlugin.getInstance().getLocked() && requirements.disableOnLock) {
context.msg("<b>Factions was locked by an admin. Please try again later."); context.msg("<b>Factions was locked by an admin. Please try again later.");
return false; return false;
} }
return true; return true;
} }
public boolean validArgs(CommandContext context) { public boolean validArgs(CommandContext context) {
if (context.args.size() < this.requiredArgs.size()) { if (context.args.size() < this.requiredArgs.size()) {
if (context.sender != null) { if (context.sender != null) {
context.msg(TL.GENERIC_ARGS_TOOFEW); context.msg(TL.GENERIC_ARGS_TOOFEW);
context.sender.sendMessage(this.getUseageTemplate(context)); context.sender.sendMessage(this.getUseageTemplate(context));
} }
return false; return false;
} }
if (context.args.size() > this.requiredArgs.size() + this.optionalArgs.size() && this.requirements.errorOnManyArgs) { if (context.args.size() > this.requiredArgs.size() + this.optionalArgs.size() && this.requirements.errorOnManyArgs) {
if (context.sender != null) { if (context.sender != null) {
// Get the to many string slice // Get the to many string slice
List<String> theToMany = context.args.subList(this.requiredArgs.size() + this.optionalArgs.size(), context.args.size()); List<String> theToMany = context.args.subList(this.requiredArgs.size() + this.optionalArgs.size(), context.args.size());
context.msg(TL.GENERIC_ARGS_TOOMANY, TextUtil.implode(theToMany, " ")); context.msg(TL.GENERIC_ARGS_TOOMANY, TextUtil.implode(theToMany, " "));
context.sender.sendMessage(this.getUseageTemplate(context)); context.sender.sendMessage(this.getUseageTemplate(context));
} }
return false; return false;
} }
return true; return true;
} }
public void addSubCommand(FCommand subCommand) { public void addSubCommand(FCommand subCommand) {
this.subCommands.add(subCommand); this.subCommands.add(subCommand);
} }
public String getHelpShort() { public String getHelpShort() {
if (this.helpShort == null) { if (this.helpShort == null) {
return getUsageTranslation().toString(); return getUsageTranslation().toString();
} }
return this.helpShort; return this.helpShort;
} }
public void setHelpShort(String val) { public void setHelpShort(String val) {
this.helpShort = val; this.helpShort = val;
} }
public abstract TL getUsageTranslation(); public abstract TL getUsageTranslation();
/* /*
Common Logic Common Logic
*/ */
public List<String> getToolTips(FPlayer player) { public List<String> getToolTips(FPlayer player) {
List<String> lines = new ArrayList<>(); List<String> lines = new ArrayList<>();
for (String s : FactionsPlugin.getInstance().getConfig().getStringList("tooltips.show")) { for (String s : FactionsPlugin.getInstance().getConfig().getStringList("tooltips.show")) {
lines.add(ChatColor.translateAlternateColorCodes('&', replaceFPlayerTags(s, player))); lines.add(ChatColor.translateAlternateColorCodes('&', replaceFPlayerTags(s, player)));
} }
return lines; return lines;
} }
public List<String> getToolTips(Faction faction) { public List<String> getToolTips(Faction faction) {
List<String> lines = new ArrayList<>(); List<String> lines = new ArrayList<>();
for (String s : FactionsPlugin.getInstance().getConfig().getStringList("tooltips.list")) { for (String s : FactionsPlugin.getInstance().getConfig().getStringList("tooltips.list")) {
lines.add(ChatColor.translateAlternateColorCodes('&', replaceFactionTags(s, faction))); lines.add(ChatColor.translateAlternateColorCodes('&', replaceFactionTags(s, faction)));
} }
return lines; return lines;
} }
public String replaceFPlayerTags(String s, FPlayer player) { public String replaceFPlayerTags(String s, FPlayer player) {
if (s.contains("{balance}")) { if (s.contains("{balance}")) {
String balance = Econ.isSetup() ? Econ.getFriendlyBalance(player) : "no balance"; String balance = Econ.isSetup() ? Econ.getFriendlyBalance(player) : "no balance";
s = s.replace("{balance}", balance); s = s.replace("{balance}", balance);
} }
if (s.contains("{lastSeen}")) { if (s.contains("{lastSeen}")) {
String humanized = DurationFormatUtils.formatDurationWords(System.currentTimeMillis() - player.getLastLoginTime(), true, true) + " ago"; 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); String lastSeen = player.isOnline() ? ChatColor.GREEN + "Online" : (System.currentTimeMillis() - player.getLastLoginTime() < 432000000 ? ChatColor.YELLOW + humanized : ChatColor.RED + humanized);
s = s.replace("{lastSeen}", lastSeen); s = s.replace("{lastSeen}", lastSeen);
} }
if (s.contains("{power}")) { if (s.contains("{power}")) {
String power = player.getPowerRounded() + "/" + player.getPowerMaxRounded(); String power = player.getPowerRounded() + "/" + player.getPowerMaxRounded();
s = s.replace("{power}", power); s = s.replace("{power}", power);
} }
if (s.contains("{group}")) { if (s.contains("{group}")) {
String group = FactionsPlugin.getInstance().getPrimaryGroup(Bukkit.getOfflinePlayer(UUID.fromString(player.getId()))); String group = FactionsPlugin.getInstance().getPrimaryGroup(Bukkit.getOfflinePlayer(UUID.fromString(player.getId())));
s = s.replace("{group}", group); s = s.replace("{group}", group);
} }
return s; return s;
} }
public String replaceFactionTags(String s, Faction faction) { public String replaceFactionTags(String s, Faction faction) {
if (s.contains("{power}")) { if (s.contains("{power}")) {
s = s.replace("{power}", String.valueOf(faction.getPowerRounded())); s = s.replace("{power}", String.valueOf(faction.getPowerRounded()));
} }
if (s.contains("{maxPower}")) { if (s.contains("{maxPower}")) {
s = s.replace("{maxPower}", String.valueOf(faction.getPowerMaxRounded())); s = s.replace("{maxPower}", String.valueOf(faction.getPowerMaxRounded()));
} }
if (s.contains("{leader}")) { if (s.contains("{leader}")) {
FPlayer fLeader = faction.getFPlayerAdmin(); FPlayer fLeader = faction.getFPlayerAdmin();
String leader = fLeader == null ? "Server" : fLeader.getName().substring(0, fLeader.getName().length() > 14 ? 13 : fLeader.getName().length()); String leader = fLeader == null ? "Server" : fLeader.getName().substring(0, fLeader.getName().length() > 14 ? 13 : fLeader.getName().length());
s = s.replace("{leader}", leader); s = s.replace("{leader}", leader);
} }
if (s.contains("{chunks}")) { if (s.contains("{chunks}")) {
s = s.replace("{chunks}", String.valueOf(faction.getLandRounded())); s = s.replace("{chunks}", String.valueOf(faction.getLandRounded()));
} }
if (s.contains("{members}")) { if (s.contains("{members}")) {
s = s.replace("{members}", String.valueOf(faction.getSize())); s = s.replace("{members}", String.valueOf(faction.getSize()));
} }
if (s.contains("{online}")) { if (s.contains("{online}")) {
s = s.replace("{online}", String.valueOf(faction.getOnlinePlayers().size())); s = s.replace("{online}", String.valueOf(faction.getOnlinePlayers().size()));
} }
return s; return s;
} }
/* /*
Help and Usage information Help and Usage information
*/ */
public String getUseageTemplate(CommandContext context, boolean addShortHelp) { public String getUseageTemplate(CommandContext context, boolean addShortHelp) {
StringBuilder ret = new StringBuilder(); StringBuilder ret = new StringBuilder();
ret.append(FactionsPlugin.getInstance().color(TL.COMMAND_USEAGE_TEMPLATE_COLOR.toString())); ret.append(FactionsPlugin.getInstance().color(TL.COMMAND_USEAGE_TEMPLATE_COLOR.toString()));
ret.append('/'); ret.append('/');
for (FCommand fc : context.commandChain) { for (FCommand fc : context.commandChain) {
ret.append(TextUtil.implode(fc.aliases, ",")); ret.append(TextUtil.implode(fc.aliases, ","));
ret.append(' '); ret.append(' ');
} }
ret.append(TextUtil.implode(this.aliases, ",")); ret.append(TextUtil.implode(this.aliases, ","));
List<String> args = new ArrayList<>(); List<String> args = new ArrayList<>();
for (String requiredArg : this.requiredArgs) { for (String requiredArg : this.requiredArgs) {
args.add("<" + requiredArg + ">"); args.add("<" + requiredArg + ">");
} }
for (Map.Entry<String, String> optionalArg : this.optionalArgs.entrySet()) { for (Map.Entry<String, String> optionalArg : this.optionalArgs.entrySet()) {
String val = optionalArg.getValue(); String val = optionalArg.getValue();
if (val == null) { if (val == null) {
val = ""; val = "";
} else { } else {
val = "=" + val; val = "=" + val;
} }
args.add("[" + optionalArg.getKey() + val + "]"); args.add("[" + optionalArg.getKey() + val + "]");
} }
if (args.size() > 0) { if (args.size() > 0) {
ret.append(FactionsPlugin.getInstance().txt.parseTags(" ")); ret.append(FactionsPlugin.getInstance().txt.parseTags(" "));
ret.append(TextUtil.implode(args, " ")); ret.append(TextUtil.implode(args, " "));
} }
if (addShortHelp) { if (addShortHelp) {
ret.append(FactionsPlugin.getInstance().txt.parseTags(" ")); ret.append(FactionsPlugin.getInstance().txt.parseTags(" "));
ret.append(this.getHelpShort()); ret.append(this.getHelpShort());
} }
return ret.toString(); return ret.toString();
} }
public String getUseageTemplate(CommandContext context) { public String getUseageTemplate(CommandContext context) {
return getUseageTemplate(context, false); return getUseageTemplate(context, false);
} }
} }

Some files were not shown because too many files have changed in this diff Show More