# Conflicts:
#	src/main/java/com/massivecraft/factions/SavageFactions.java
This commit is contained in:
ProSavage 2019-03-04 15:46:39 -06:00
commit 5a63e71054
235 changed files with 26923 additions and 26699 deletions

View File

@ -12,6 +12,8 @@
* Ensure the PR description clearly describes the problem and solution. Include the relevant issue number if applicable. * Ensure the PR description clearly describes the problem and solution. Include the relevant issue number if applicable.
* Please use tabs as ident with a size of 3 spaces.
#### **Did you fix whitespace, format code, or make a purely cosmetic patch?** #### **Did you fix whitespace, format code, or make a purely cosmetic patch?**
Please specify what changes you made to the formatting etc., as it allows us to get an idea of how this will change our files overall. Please specify what changes you made to the formatting etc., as it allows us to get an idea of how this will change our files overall.

Binary file not shown.

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 ArrayList<FancyMessage> getMap(FPlayer fPlayer, FLocation flocation, double inDegrees); public abstract ArrayList<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

@ -3,6 +3,7 @@ package com.massivecraft.factions;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.massivecraft.factions.integration.dynmap.DynmapStyle; import com.massivecraft.factions.integration.dynmap.DynmapStyle;
import com.massivecraft.factions.util.MultiversionMaterials; import com.massivecraft.factions.util.MultiversionMaterials;
import com.massivecraft.factions.zcore.fperms.DefaultPermissions;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
@ -11,439 +12,454 @@ 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;
public static Set<String> allowedStealthFactions = new LinkedHashSet<>(); public static Set<String> allowedStealthFactions = new LinkedHashSet<>();
// 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;
// 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 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 territoryEnemyProtectMaterials = true; public static boolean territoryEnemyProtectMaterials = 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 territoryAllyProtectMaterials = true; public static boolean territoryAllyProtectMaterials = 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 territoryTruceProtectMaterials = true; public static boolean territoryTruceProtectMaterials = 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 ownedAreaProtectMaterials = true; public static boolean ownedAreaProtectMaterials = true;
public static boolean ownedAreaDenyUseage = true; public static boolean ownedAreaDenyUseage = true;
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);
// 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;
// -------------------------------------------- // // -------------------------------------------- //
// 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 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 String vaultPrefix = "faction-%s"; public static String vaultPrefix = "faction-%s";
public static int defaultMaxVaults = 0; public static int defaultMaxVaults = 0;
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();
// -------------------------------------------- //
// Persistance
// -------------------------------------------- //
private static transient Conf i = new Conf();
static {
baseCommandAliases.add("f");
territoryEnemyDenyCommands.add("home");
territoryEnemyDenyCommands.add("sethome");
territoryEnemyDenyCommands.add("spawn");
territoryEnemyDenyCommands.add("tpahere");
territoryEnemyDenyCommands.add("tpaccept");
territoryEnemyDenyCommands.add("tpa");
territoryProtectedMaterials.add(SavageFactions.plugin.WOODEN_DOOR);
territoryProtectedMaterials.add(SavageFactions.plugin.TRAP_DOOR);
territoryProtectedMaterials.add(SavageFactions.plugin.FENCE_GATE);
territoryProtectedMaterials.add(Material.DISPENSER);
territoryProtectedMaterials.add(Material.CHEST);
territoryProtectedMaterials.add(Material.FURNACE);
territoryProtectedMaterials.add(SavageFactions.plugin.BURNING_FURNACE);
territoryProtectedMaterials.add(SavageFactions.plugin.DIODE_BLOCK_OFF);
territoryProtectedMaterials.add(SavageFactions.plugin.DIODE_BLOCK_ON);
territoryProtectedMaterials.add(Material.JUKEBOX);
territoryProtectedMaterials.add(Material.BREWING_STAND);
territoryProtectedMaterials.add(SavageFactions.plugin.ENCHANTMENT_TABLE);
territoryProtectedMaterials.add(Material.CAULDRON);
territoryProtectedMaterials.add(SavageFactions.plugin.ENCHANTMENT_TABLE);
territoryProtectedMaterials.add(Material.BEACON);
territoryProtectedMaterials.add(Material.ANVIL);
territoryProtectedMaterials.add(Material.TRAPPED_CHEST);
territoryProtectedMaterials.add(Material.DROPPER);
territoryProtectedMaterials.add(Material.HOPPER);
territoryDenyUseageMaterials.add(SavageFactions.plugin.FIREBALL);
territoryDenyUseageMaterials.add(Material.FLINT_AND_STEEL);
territoryDenyUseageMaterials.add(Material.BUCKET);
territoryDenyUseageMaterials.add(Material.WATER_BUCKET);
territoryDenyUseageMaterials.add(Material.LAVA_BUCKET);
territoryDenyUseageMaterials.add(MultiversionMaterials.ACACIA_BUTTON.parseMaterial());
territoryDenyUseageMaterials.add(MultiversionMaterials.BIRCH_BUTTON.parseMaterial());
territoryDenyUseageMaterials.add(MultiversionMaterials.DARK_OAK_BUTTON.parseMaterial());
territoryDenyUseageMaterials.add(MultiversionMaterials.JUNGLE_BUTTON.parseMaterial());
territoryDenyUseageMaterials.add(MultiversionMaterials.OAK_BUTTON.parseMaterial());
territoryDenyUseageMaterials.add(MultiversionMaterials.STONE_BUTTON.parseMaterial());
if (!SavageFactions.plugin.mc17) {
territoryDenyUseageMaterials.add(Material.ARMOR_STAND);
}
territoryProtectedMaterialsWhenOffline.add(SavageFactions.plugin.WOODEN_DOOR); // Default Options
territoryProtectedMaterialsWhenOffline.add(SavageFactions.plugin.TRAP_DOOR); public static boolean useCustomDefaultPermissions = false;
territoryProtectedMaterialsWhenOffline.add(SavageFactions.plugin.FENCE_GATE); public static boolean usePermissionHints = false;
territoryProtectedMaterialsWhenOffline.add(Material.DISPENSER); public static HashMap<String, DefaultPermissions> defaultFactionPermissions;
territoryProtectedMaterialsWhenOffline.add(Material.CHEST); // Custom Ranks
territoryProtectedMaterialsWhenOffline.add(Material.FURNACE); //public static boolean enableCustomRanks = false; // We will disable it by default to avoid any migration error
territoryProtectedMaterialsWhenOffline.add(SavageFactions.plugin.BURNING_FURNACE); //public static int maxCustomRanks = 2; // Setting this to -1 will allow unlimited custom ranks
territoryProtectedMaterialsWhenOffline.add(SavageFactions.plugin.DIODE_BLOCK_OFF); // -------------------------------------------- //
territoryProtectedMaterialsWhenOffline.add(SavageFactions.plugin.DIODE_BLOCK_OFF); // Persistance
territoryProtectedMaterialsWhenOffline.add(Material.JUKEBOX); // -------------------------------------------- //
territoryProtectedMaterialsWhenOffline.add(Material.BREWING_STAND); private static transient Conf i = new Conf();
territoryProtectedMaterialsWhenOffline.add(SavageFactions.plugin.ENCHANTMENT_TABLE);
territoryProtectedMaterialsWhenOffline.add(Material.CAULDRON);
territoryProtectedMaterialsWhenOffline.add(SavageFactions.plugin.SOIL);
territoryProtectedMaterialsWhenOffline.add(Material.BEACON);
territoryProtectedMaterialsWhenOffline.add(Material.ANVIL);
territoryProtectedMaterialsWhenOffline.add(Material.TRAPPED_CHEST);
territoryProtectedMaterialsWhenOffline.add(Material.DROPPER);
territoryProtectedMaterialsWhenOffline.add(Material.HOPPER);
territoryDenyUseageMaterialsWhenOffline.add(SavageFactions.plugin.FIREBALL); static {
territoryDenyUseageMaterialsWhenOffline.add(Material.FLINT_AND_STEEL); baseCommandAliases.add("f");
territoryDenyUseageMaterialsWhenOffline.add(Material.BUCKET);
territoryDenyUseageMaterialsWhenOffline.add(Material.WATER_BUCKET);
territoryDenyUseageMaterialsWhenOffline.add(Material.LAVA_BUCKET);
territoryDenyUseageMaterialsWhenOffline.add(MultiversionMaterials.ACACIA_BUTTON.parseMaterial());
territoryDenyUseageMaterialsWhenOffline.add(MultiversionMaterials.BIRCH_BUTTON.parseMaterial());
territoryDenyUseageMaterialsWhenOffline.add(MultiversionMaterials.DARK_OAK_BUTTON.parseMaterial());
territoryDenyUseageMaterialsWhenOffline.add(MultiversionMaterials.JUNGLE_BUTTON.parseMaterial());
territoryDenyUseageMaterialsWhenOffline.add(MultiversionMaterials.OAK_BUTTON.parseMaterial());
territoryDenyUseageMaterialsWhenOffline.add(MultiversionMaterials.STONE_BUTTON.parseMaterial());
if (!SavageFactions.plugin.mc17) {
territoryDenyUseageMaterialsWhenOffline.add(Material.ARMOR_STAND);
}
safeZoneNerfedCreatureTypes.add(EntityType.BLAZE);
safeZoneNerfedCreatureTypes.add(EntityType.CAVE_SPIDER);
safeZoneNerfedCreatureTypes.add(EntityType.CREEPER);
safeZoneNerfedCreatureTypes.add(EntityType.ENDER_DRAGON);
safeZoneNerfedCreatureTypes.add(EntityType.ENDERMAN);
safeZoneNerfedCreatureTypes.add(EntityType.GHAST);
safeZoneNerfedCreatureTypes.add(EntityType.MAGMA_CUBE);
safeZoneNerfedCreatureTypes.add(EntityType.PIG_ZOMBIE);
safeZoneNerfedCreatureTypes.add(EntityType.SILVERFISH);
safeZoneNerfedCreatureTypes.add(EntityType.SKELETON);
safeZoneNerfedCreatureTypes.add(EntityType.SPIDER);
safeZoneNerfedCreatureTypes.add(EntityType.SLIME);
safeZoneNerfedCreatureTypes.add(EntityType.WITCH);
safeZoneNerfedCreatureTypes.add(EntityType.WITHER);
safeZoneNerfedCreatureTypes.add(EntityType.ZOMBIE);
}
public static void load() { territoryEnemyDenyCommands.add("home");
SavageFactions.plugin.persist.loadOrSaveDefault(i, Conf.class, "conf"); territoryEnemyDenyCommands.add("sethome");
} territoryEnemyDenyCommands.add("spawn");
territoryEnemyDenyCommands.add("tpahere");
territoryEnemyDenyCommands.add("tpaccept");
territoryEnemyDenyCommands.add("tpa");
public static void save() { territoryProtectedMaterials.add(SavageFactions.plugin.WOODEN_DOOR);
SavageFactions.plugin.persist.save(i); territoryProtectedMaterials.add(SavageFactions.plugin.TRAP_DOOR);
} territoryProtectedMaterials.add(SavageFactions.plugin.FENCE_GATE);
territoryProtectedMaterials.add(Material.DISPENSER);
territoryProtectedMaterials.add(Material.CHEST);
territoryProtectedMaterials.add(Material.FURNACE);
territoryProtectedMaterials.add(SavageFactions.plugin.BURNING_FURNACE);
territoryProtectedMaterials.add(SavageFactions.plugin.DIODE_BLOCK_OFF);
territoryProtectedMaterials.add(SavageFactions.plugin.DIODE_BLOCK_ON);
territoryProtectedMaterials.add(Material.JUKEBOX);
territoryProtectedMaterials.add(Material.BREWING_STAND);
territoryProtectedMaterials.add(SavageFactions.plugin.ENCHANTMENT_TABLE);
territoryProtectedMaterials.add(Material.CAULDRON);
territoryProtectedMaterials.add(SavageFactions.plugin.ENCHANTMENT_TABLE);
territoryProtectedMaterials.add(Material.BEACON);
territoryProtectedMaterials.add(Material.ANVIL);
territoryProtectedMaterials.add(Material.TRAPPED_CHEST);
territoryProtectedMaterials.add(Material.DROPPER);
territoryProtectedMaterials.add(Material.HOPPER);
public enum Backend { territoryDenyUseageMaterials.add(SavageFactions.plugin.FIREBALL);
JSON, territoryDenyUseageMaterials.add(Material.FLINT_AND_STEEL);
//MYSQL, TODO add MySQL storage territoryDenyUseageMaterials.add(Material.BUCKET);
; territoryDenyUseageMaterials.add(Material.WATER_BUCKET);
} territoryDenyUseageMaterials.add(Material.LAVA_BUCKET);
territoryDenyUseageMaterials.add(MultiversionMaterials.ACACIA_BUTTON.parseMaterial());
territoryDenyUseageMaterials.add(MultiversionMaterials.BIRCH_BUTTON.parseMaterial());
territoryDenyUseageMaterials.add(MultiversionMaterials.DARK_OAK_BUTTON.parseMaterial());
territoryDenyUseageMaterials.add(MultiversionMaterials.JUNGLE_BUTTON.parseMaterial());
territoryDenyUseageMaterials.add(MultiversionMaterials.OAK_BUTTON.parseMaterial());
territoryDenyUseageMaterials.add(MultiversionMaterials.STONE_BUTTON.parseMaterial());
if (!SavageFactions.plugin.mc17) {
territoryDenyUseageMaterials.add(Material.ARMOR_STAND);
}
territoryProtectedMaterialsWhenOffline.add(SavageFactions.plugin.WOODEN_DOOR);
territoryProtectedMaterialsWhenOffline.add(SavageFactions.plugin.TRAP_DOOR);
territoryProtectedMaterialsWhenOffline.add(SavageFactions.plugin.FENCE_GATE);
territoryProtectedMaterialsWhenOffline.add(Material.DISPENSER);
territoryProtectedMaterialsWhenOffline.add(Material.CHEST);
territoryProtectedMaterialsWhenOffline.add(Material.FURNACE);
territoryProtectedMaterialsWhenOffline.add(SavageFactions.plugin.BURNING_FURNACE);
territoryProtectedMaterialsWhenOffline.add(SavageFactions.plugin.DIODE_BLOCK_OFF);
territoryProtectedMaterialsWhenOffline.add(SavageFactions.plugin.DIODE_BLOCK_OFF);
territoryProtectedMaterialsWhenOffline.add(Material.JUKEBOX);
territoryProtectedMaterialsWhenOffline.add(Material.BREWING_STAND);
territoryProtectedMaterialsWhenOffline.add(SavageFactions.plugin.ENCHANTMENT_TABLE);
territoryProtectedMaterialsWhenOffline.add(Material.CAULDRON);
territoryProtectedMaterialsWhenOffline.add(SavageFactions.plugin.SOIL);
territoryProtectedMaterialsWhenOffline.add(Material.BEACON);
territoryProtectedMaterialsWhenOffline.add(Material.ANVIL);
territoryProtectedMaterialsWhenOffline.add(Material.TRAPPED_CHEST);
territoryProtectedMaterialsWhenOffline.add(Material.DROPPER);
territoryProtectedMaterialsWhenOffline.add(Material.HOPPER);
territoryDenyUseageMaterialsWhenOffline.add(SavageFactions.plugin.FIREBALL);
territoryDenyUseageMaterialsWhenOffline.add(Material.FLINT_AND_STEEL);
territoryDenyUseageMaterialsWhenOffline.add(Material.BUCKET);
territoryDenyUseageMaterialsWhenOffline.add(Material.WATER_BUCKET);
territoryDenyUseageMaterialsWhenOffline.add(Material.LAVA_BUCKET);
territoryDenyUseageMaterialsWhenOffline.add(MultiversionMaterials.ACACIA_BUTTON.parseMaterial());
territoryDenyUseageMaterialsWhenOffline.add(MultiversionMaterials.BIRCH_BUTTON.parseMaterial());
territoryDenyUseageMaterialsWhenOffline.add(MultiversionMaterials.DARK_OAK_BUTTON.parseMaterial());
territoryDenyUseageMaterialsWhenOffline.add(MultiversionMaterials.JUNGLE_BUTTON.parseMaterial());
territoryDenyUseageMaterialsWhenOffline.add(MultiversionMaterials.OAK_BUTTON.parseMaterial());
territoryDenyUseageMaterialsWhenOffline.add(MultiversionMaterials.STONE_BUTTON.parseMaterial());
if (!SavageFactions.plugin.mc17) {
territoryDenyUseageMaterialsWhenOffline.add(Material.ARMOR_STAND);
}
safeZoneNerfedCreatureTypes.add(EntityType.BLAZE);
safeZoneNerfedCreatureTypes.add(EntityType.CAVE_SPIDER);
safeZoneNerfedCreatureTypes.add(EntityType.CREEPER);
safeZoneNerfedCreatureTypes.add(EntityType.ENDER_DRAGON);
safeZoneNerfedCreatureTypes.add(EntityType.ENDERMAN);
safeZoneNerfedCreatureTypes.add(EntityType.GHAST);
safeZoneNerfedCreatureTypes.add(EntityType.MAGMA_CUBE);
safeZoneNerfedCreatureTypes.add(EntityType.PIG_ZOMBIE);
safeZoneNerfedCreatureTypes.add(EntityType.SILVERFISH);
safeZoneNerfedCreatureTypes.add(EntityType.SKELETON);
safeZoneNerfedCreatureTypes.add(EntityType.SPIDER);
safeZoneNerfedCreatureTypes.add(EntityType.SLIME);
safeZoneNerfedCreatureTypes.add(EntityType.WITCH);
safeZoneNerfedCreatureTypes.add(EntityType.WITHER);
safeZoneNerfedCreatureTypes.add(EntityType.ZOMBIE);
// Is this called lazy load?
defaultFactionPermissions.put("LEADER", new DefaultPermissions(true));
defaultFactionPermissions.put("COLEADER", new DefaultPermissions(true));
defaultFactionPermissions.put("MODERATOR", new DefaultPermissions(true));
defaultFactionPermissions.put("MEMBER", new DefaultPermissions(false));
defaultFactionPermissions.put("RECRUIT", new DefaultPermissions(false));
}
public static void load() {
SavageFactions.plugin.persist.loadOrSaveDefault(i, Conf.class, "conf");
}
public static void save() {
SavageFactions.plugin.persist.save(i);
}
public enum Backend {
JSON,
//MYSQL, TODO add MySQL storage
;
}
} }

View File

@ -11,247 +11,247 @@ import java.util.LinkedHashSet;
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 - 1 || -diffZ > lim - 1; return diffX > lim || diffZ > lim || -diffX > lim - 1 || -diffZ > lim - 1;
} }
//----------------------------------------------// //----------------------------------------------//
// 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 && (this.worldName == null ? that.worldName == null : this.worldName.equals(that.worldName)); return this.x == that.x && this.z == that.z && (this.worldName == null ? that.worldName == null : this.worldName.equals(that.worldName));
} }
} }

View File

@ -26,354 +26,354 @@ import java.util.List;
public interface FPlayer extends EconomyParticipator { public interface FPlayer extends EconomyParticipator {
/** /**
* 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); void setFaction(Faction faction);
/** /**
* 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();
// ------------------------------- // -------------------------------
// 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

@ -1,41 +1,41 @@
package com.massivecraft.factions; package com.massivecraft.factions;
import com.massivecraft.factions.zcore.persist.json.JSONFPlayers; import com.massivecraft.factions.zcore.persist.json.JSONFPlayers;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player; 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() {
switch (Conf.backEnd) { switch (Conf.backEnd) {
case JSON: case 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

@ -21,326 +21,328 @@ import java.util.*;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
public interface Faction extends EconomyParticipator { public interface Faction extends EconomyParticipator {
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(Upgrade upgrade, int level); void setUpgrade(Upgrade upgrade, int level);
int getUpgrade(Upgrade upgrade); int getUpgrade(Upgrade upgrade);
boolean isInvited(FPlayer fplayer); boolean isInvited(FPlayer fplayer);
void ban(FPlayer target, FPlayer banner); void ban(FPlayer target, FPlayer banner);
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 setRule(int index, String rule); void setRule(int index, String rule);
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();
@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);
void setPermission(Permissable permissable, PermissableAction permissableAction, Access access); void setPermission(Permissable permissable, PermissableAction permissableAction, Access access);
void resetPerms(); void resetPerms();
void disband(Player disbander); void setDefaultPerms();
void disband(Player disbander, PlayerDisbandReason reason); void disband(Player disbander);
// ------------------------------- void disband(Player disbander, PlayerDisbandReason reason);
// Relation and relation colors
// -------------------------------
Map<Permissable, Map<PermissableAction, Access>> getPermissions(); // -------------------------------
// Relation and relation colors
// -------------------------------
@Override Map<Permissable, Map<PermissableAction, Access>> getPermissions();
String describeTo(RelationParticipator that, boolean ucfirst);
@Override @Override
String describeTo(RelationParticipator that); String describeTo(RelationParticipator that, boolean ucfirst);
@Override @Override
Relation getRelationTo(RelationParticipator rp); String describeTo(RelationParticipator that);
@Override @Override
Relation getRelationTo(RelationParticipator rp, boolean ignorePeaceful); Relation getRelationTo(RelationParticipator rp);
@Override @Override
ChatColor getColorTo(RelationParticipator rp); Relation getRelationTo(RelationParticipator rp, boolean ignorePeaceful);
Relation getRelationWish(Faction otherFaction); @Override
ChatColor getColorTo(RelationParticipator rp);
void setRelationWish(Faction otherFaction, Relation relation); Relation getRelationWish(Faction otherFaction);
int getRelationCount(Relation relation); void setRelationWish(Faction otherFaction, Relation relation);
// ----------------------------------------------// int getRelationCount(Relation relation);
// Power
// ----------------------------------------------//
double getPower();
double getPowerMax(); // ----------------------------------------------//
// Power
// ----------------------------------------------//
double getPower();
int getPowerRounded(); double getPowerMax();
int getPowerMaxRounded(); int getPowerRounded();
int getLandRounded(); int getPowerMaxRounded();
int getLandRoundedInWorld(String worldName); int getLandRounded();
// ------------------------------- int getLandRoundedInWorld(String worldName);
// FPlayers
// -------------------------------
boolean hasLandInflation(); // -------------------------------
// FPlayers
// -------------------------------
// maintain the reference list of FPlayers in this faction boolean hasLandInflation();
void refreshFPlayers();
boolean addFPlayer(FPlayer fplayer); // maintain the reference list of FPlayers in this faction
void refreshFPlayers();
boolean removeFPlayer(FPlayer fplayer); boolean addFPlayer(FPlayer fplayer);
int getSize(); boolean removeFPlayer(FPlayer fplayer);
Set<FPlayer> getFPlayers(); int getSize();
Set<FPlayer> getFPlayersWhereOnline(boolean online); Set<FPlayer> getFPlayers();
Set<FPlayer> getFPlayersWhereOnline(boolean online, FPlayer viewer); Set<FPlayer> getFPlayersWhereOnline(boolean online);
FPlayer getFPlayerAdmin(); Set<FPlayer> getFPlayersWhereOnline(boolean online, FPlayer viewer);
FPlayer getFPlayerLeader(); FPlayer getFPlayerAdmin();
ArrayList<FPlayer> getFPlayersWhereRole(Role role); FPlayer getFPlayerLeader();
ArrayList<Player> getOnlinePlayers(); ArrayList<FPlayer> getFPlayersWhereRole(Role role);
// slightly faster check than getOnlinePlayers() if you just want to see if ArrayList<Player> getOnlinePlayers();
// there are any players online
boolean hasPlayersOnline();
void memberLoggedOff(); // slightly faster check than getOnlinePlayers() if you just want to see if
// there are any players online
boolean hasPlayersOnline();
// used when current leader is about to be removed from the faction; void memberLoggedOff();
// promotes new leader, or disbands faction if no other members left
void promoteNewLeader();
void promoteNewLeader(boolean autoLeave); // used when current leader is about to be removed from the faction;
// promotes new leader, or disbands faction if no other members left
void promoteNewLeader();
Role getDefaultRole(); void promoteNewLeader(boolean autoLeave);
void setDefaultRole(Role role); Role getDefaultRole();
// ----------------------------------------------// void setDefaultRole(Role role);
// Messages
// ----------------------------------------------//
void msg(String message, Object... args);
void sendMessage(String message); // ----------------------------------------------//
// Messages
// ----------------------------------------------//
void msg(String message, Object... args);
// ----------------------------------------------// void sendMessage(String message);
// Ownership of specific claims
// ----------------------------------------------//
void sendMessage(List<String> messages); // ----------------------------------------------//
// Ownership of specific claims
// ----------------------------------------------//
Map<FLocation, Set<String>> getClaimOwnership(); void sendMessage(List<String> messages);
void clearAllClaimOwnership(); Map<FLocation, Set<String>> getClaimOwnership();
void clearClaimOwnership(FLocation loc); void clearAllClaimOwnership();
void clearClaimOwnership(FPlayer player); void clearClaimOwnership(FLocation loc);
int getCountOfClaimsWithOwners(); void clearClaimOwnership(FPlayer player);
boolean doesLocationHaveOwnersSet(FLocation loc); int getCountOfClaimsWithOwners();
boolean isPlayerInOwnerList(FPlayer player, FLocation loc); boolean doesLocationHaveOwnersSet(FLocation loc);
void setPlayerAsOwner(FPlayer player, FLocation loc); boolean isPlayerInOwnerList(FPlayer player, FLocation loc);
void removePlayerAsOwner(FPlayer player, FLocation loc); void setPlayerAsOwner(FPlayer player, FLocation loc);
Set<String> getOwnerList(FLocation loc); void removePlayerAsOwner(FPlayer player, FLocation loc);
String getOwnerListString(FLocation loc); Set<String> getOwnerList(FLocation loc);
boolean playerHasOwnershipRights(FPlayer fplayer, FLocation loc); String getOwnerListString(FLocation loc);
// ----------------------------------------------// boolean playerHasOwnershipRights(FPlayer fplayer, FLocation loc);
// Persistance and entity management
// ----------------------------------------------//
void remove();
Set<FLocation> getAllClaims(); // ----------------------------------------------//
// Persistance and entity management
// ----------------------------------------------//
void remove();
String getPaypal(); Set<FLocation> getAllClaims();
void paypalSet(String paypal); String getPaypal();
void paypalSet(String paypal);
} }

View File

@ -1,55 +1,55 @@
package com.massivecraft.factions; package com.massivecraft.factions;
import com.massivecraft.factions.zcore.persist.json.JSONFactions; import com.massivecraft.factions.zcore.persist.json.JSONFactions;
import java.util.ArrayList; 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();
} }

View File

@ -34,464 +34,464 @@ import java.net.URL;
@SuppressWarnings("all") @SuppressWarnings("all")
public class MassiveStats implements Listener { public class MassiveStats implements Listener {
/* START: MASSIVESTATS SETTINGS */ /* START: MASSIVESTATS SETTINGS */
public static final int CLIENT_VERSION = 0; // v3.0 public static final int CLIENT_VERSION = 0; // v3.0
public static final String API_URL = "https://report.massivestats.com/v2/"; public static final String API_URL = "https://report.massivestats.com/v2/";
public static final String MASSIVE_UPDATE_PERMISSION = "massivestats.update"; public static final String MASSIVE_UPDATE_PERMISSION = "massivestats.update";
/* END: MASSIVESTATS SETTINGS */ /* END: MASSIVESTATS SETTINGS */
private final JavaPlugin plugin; private final JavaPlugin plugin;
private MassiveStatsUpdateTask task = null; private MassiveStatsUpdateTask task = null;
private int pingInterval; private int pingInterval;
private MassiveStatsDataResponse lastResponse; private MassiveStatsDataResponse lastResponse;
private boolean listenerDisabled; private boolean listenerDisabled;
private Class jsonElement; private Class jsonElement;
private Class jsonParser; private Class jsonParser;
private Class jsonObject; private Class jsonObject;
private Class jsonPrimitive; private Class jsonPrimitive;
/** /**
* @param plugin The plugin you wish to collect data for. * @param plugin The plugin you wish to collect data for.
* @author Sam Jakob Harker * @author Sam Jakob Harker
*/ */
public MassiveStats(JavaPlugin plugin) { public MassiveStats(JavaPlugin plugin) {
this(plugin, 900); // default value: 900 seconds (= 15 minutes) this(plugin, 900); // default value: 900 seconds (= 15 minutes)
} }
/** /**
* @param plugin The plugin you wish to collect data for. * @param plugin The plugin you wish to collect data for.
* @param pingInterval Duration between requests. * @param pingInterval Duration between requests.
* @author Sam Jakob Harker * @author Sam Jakob Harker
*/ */
public MassiveStats(JavaPlugin plugin, int pingInterval) { public MassiveStats(JavaPlugin plugin, int pingInterval) {
try { try {
jsonElement = Class.forName("com.google.gson.JsonElement"); jsonElement = Class.forName("com.google.gson.JsonElement");
jsonParser = Class.forName("com.google.gson.JsonParser"); jsonParser = Class.forName("com.google.gson.JsonParser");
jsonObject = Class.forName("com.google.gson.JsonObject"); jsonObject = Class.forName("com.google.gson.JsonObject");
jsonPrimitive = Class.forName("com.google.gson.JsonPrimitive"); jsonPrimitive = Class.forName("com.google.gson.JsonPrimitive");
} catch (ClassNotFoundException ex) { } catch (ClassNotFoundException ex) {
// Gson not included in classpath (so use NMS version) // Gson not included in classpath (so use NMS version)
try { try {
jsonElement = Class.forName("net.minecraft.util.com.google.gson.JsonElement"); jsonElement = Class.forName("net.minecraft.util.com.google.gson.JsonElement");
jsonParser = Class.forName("net.minecraft.util.com.google.gson.JsonParser"); jsonParser = Class.forName("net.minecraft.util.com.google.gson.JsonParser");
jsonObject = Class.forName("net.minecraft.util.com.google.gson.JsonObject"); jsonObject = Class.forName("net.minecraft.util.com.google.gson.JsonObject");
jsonPrimitive = Class.forName("net.minecraft.util.com.google.gson.JsonPrimitive"); jsonPrimitive = Class.forName("net.minecraft.util.com.google.gson.JsonPrimitive");
} catch (ClassNotFoundException ignored) { } catch (ClassNotFoundException ignored) {
Bukkit.getLogger().severe("MassiveStats could not find an instance/version of Gson to use."); Bukkit.getLogger().severe("MassiveStats could not find an instance/version of Gson to use.");
this.plugin = null; this.plugin = null;
return; return;
} }
} }
// Ensure the pingInterval that is set is reasonable. // Ensure the pingInterval that is set is reasonable.
if (pingInterval < 10 || pingInterval > 86400) { if (pingInterval < 10 || pingInterval > 86400) {
pingInterval = 900; pingInterval = 900;
} }
// Ensure that a plugin instance has been provided. // Ensure that a plugin instance has been provided.
if (plugin == null) { if (plugin == null) {
throw new IllegalArgumentException("You must provide a plugin for MassiveStats to collect data for!"); throw new IllegalArgumentException("You must provide a plugin for MassiveStats to collect data for!");
} }
// Set the ping interval. // Set the ping interval.
this.pingInterval = pingInterval; this.pingInterval = pingInterval;
// Set the plugin reference. // Set the plugin reference.
this.plugin = plugin; this.plugin = plugin;
// and start sending data to the MassiveStats server immediately. // and start sending data to the MassiveStats server immediately.
start(); start();
// Register join/leave events for the plugin // Register join/leave events for the plugin
Bukkit.getServer().getPluginManager().registerEvents(this, plugin); Bukkit.getServer().getPluginManager().registerEvents(this, plugin);
} }
/** /**
* Gets whether or not the built-in MassiveStats {@link org.bukkit.event.player.PlayerJoinEvent} listener is enabled. * Gets whether or not the built-in MassiveStats {@link org.bukkit.event.player.PlayerJoinEvent} listener is enabled.
* *
* @return Whether or not the MassiveStats listener is enabled. * @return Whether or not the MassiveStats listener is enabled.
*/ */
public boolean isListenerDisabled() { public boolean isListenerDisabled() {
return listenerDisabled; return listenerDisabled;
} }
/** /**
* Sets whether or not the built-in MassiveStats {@link org.bukkit.event.player.PlayerJoinEvent} listener is enabled. * Sets whether or not the built-in MassiveStats {@link org.bukkit.event.player.PlayerJoinEvent} listener is enabled.
* *
* @param listenerDisabled Whether or not the MassiveStats listener is enabled. * @param listenerDisabled Whether or not the MassiveStats listener is enabled.
*/ */
public void setListenerDisabled(boolean listenerDisabled) { public void setListenerDisabled(boolean listenerDisabled) {
this.listenerDisabled = listenerDisabled; this.listenerDisabled = listenerDisabled;
} }
/** /**
* Start the MassiveStats reporting timer. * Start the MassiveStats reporting timer.
* If the timer is already running, this method will do nothing. * If the timer is already running, this method will do nothing.
* *
* @author Sam Jakob Harker * @author Sam Jakob Harker
*/ */
public void start() { public void start() {
if (this.plugin == null) { if (this.plugin == null) {
Bukkit.getLogger().severe("MassiveStats could not find an instance/version of Gson to use and thus cannot start."); Bukkit.getLogger().severe("MassiveStats could not find an instance/version of Gson to use and thus cannot start.");
return; return;
} }
if (task == null) { if (task == null) {
// If the API endpoint URL is invalid, don't start a new task to prevent the user from being spammed. // If the API endpoint URL is invalid, don't start a new task to prevent the user from being spammed.
try { try {
new URL(MassiveStats.API_URL); new URL(MassiveStats.API_URL);
} catch (MalformedURLException ex) { } catch (MalformedURLException ex) {
getPlugin() getPlugin()
.getLogger().warning("You have specified an invalid API endpoint for MassiveStats."); .getLogger().warning("You have specified an invalid API endpoint for MassiveStats.");
return; return;
} }
task = new MassiveStatsUpdateTask(this); task = new MassiveStatsUpdateTask(this);
task.runTaskTimerAsynchronously(plugin, 0L, pingInterval * 20L); task.runTaskTimerAsynchronously(plugin, 0L, pingInterval * 20L);
} }
} }
/** /**
* Stop the MassiveStats reporting timer. * Stop the MassiveStats reporting timer.
* Requests will no longer be sent to the server - or until {@link #start()} is invoked. * Requests will no longer be sent to the server - or until {@link #start()} is invoked.
* *
* @author Sam Jakob Harker * @author Sam Jakob Harker
*/ */
public void stop() { public void stop() {
if (task == null) { if (task == null) {
return; return;
} }
task.cancel(); task.cancel();
task = null; task = null;
} }
/** /**
* Returns the duration, in seconds, that MassiveStats will wait before sending another request to the server. * Returns the duration, in seconds, that MassiveStats will wait before sending another request to the server.
* *
* @return Duration between requests. * @return Duration between requests.
* @author Sam Jakob Harker * @author Sam Jakob Harker
*/ */
public int getPingInterval() { public int getPingInterval() {
return pingInterval; return pingInterval;
} }
/** /**
* Sets the duration, in seconds, that MassiveStats should wait before sending another request to the server. * Sets the duration, in seconds, that MassiveStats should wait before sending another request to the server.
* *
* @param pingInterval Duration between requests. * @param pingInterval Duration between requests.
* @author Sam Jakob Harker * @author Sam Jakob Harker
*/ */
public void setPingInterval(int pingInterval) { public void setPingInterval(int pingInterval) {
this.pingInterval = pingInterval; this.pingInterval = pingInterval;
stop(); stop();
start(); start();
} }
/** /**
* Returns the plugin that this MassiveStats instance is collecting data for. * Returns the plugin that this MassiveStats instance is collecting data for.
* *
* @return MassiveStats instance plugin. * @return MassiveStats instance plugin.
* @author Sam Jakob Harker * @author Sam Jakob Harker
*/ */
public JavaPlugin getPlugin() { public JavaPlugin getPlugin() {
return plugin; return plugin;
} }
/** /**
* Returns the contents of the last response from the MassiveStats server. * Returns the contents of the last response from the MassiveStats server.
* *
* @return MassiveStats server response. * @return MassiveStats server response.
* @author Sam Jakob Harker * @author Sam Jakob Harker
*/ */
public MassiveStatsDataResponse getLastResponse() { public MassiveStatsDataResponse getLastResponse() {
return lastResponse; return lastResponse;
} }
void setLastResponse(MassiveStatsDataResponse lastResponse) { void setLastResponse(MassiveStatsDataResponse lastResponse) {
this.lastResponse = lastResponse; this.lastResponse = lastResponse;
} }
@EventHandler @EventHandler
public void onPlayerJoin(PlayerJoinEvent event) { public void onPlayerJoin(PlayerJoinEvent event) {
// Ensure the listener should be active // Ensure the listener should be active
if (lastResponse == null || listenerDisabled) { if (lastResponse == null || listenerDisabled) {
return; return;
} }
// Of course, only notify the user if the plugin is not up to date. // Of course, only notify the user if the plugin is not up to date.
if (lastResponse.isUpToDate()) { if (lastResponse.isUpToDate()) {
return; return;
} }
// and only notify operators - or players with the correct permission. // and only notify operators - or players with the correct permission.
if (!event.getPlayer().isOp() && !event.getPlayer().hasPermission(MassiveStats.MASSIVE_UPDATE_PERMISSION)) { if (!event.getPlayer().isOp() && !event.getPlayer().hasPermission(MassiveStats.MASSIVE_UPDATE_PERMISSION)) {
return; return;
} }
event.getPlayer().sendMessage(lastResponse.getUpdateMessage()); event.getPlayer().sendMessage(lastResponse.getUpdateMessage());
} }
Class getJsonElement() { Class getJsonElement() {
return jsonElement; return jsonElement;
} }
Class getJsonParser() { Class getJsonParser() {
return jsonParser; return jsonParser;
} }
Class getJsonObject() { Class getJsonObject() {
return jsonObject; return jsonObject;
} }
Class getJsonPrimitive() { Class getJsonPrimitive() {
return jsonPrimitive; return jsonPrimitive;
} }
} }
class MassiveStatsUpdateTask extends BukkitRunnable { class MassiveStatsUpdateTask extends BukkitRunnable {
private final MassiveStats instance; private final MassiveStats instance;
MassiveStatsUpdateTask(MassiveStats requester) { MassiveStatsUpdateTask(MassiveStats requester) {
instance = requester; instance = requester;
} }
@Override @Override
@SuppressWarnings("all") @SuppressWarnings("all")
public void run() { public void run() {
try { try {
// Generate the request payload and serialize it as JSON. // Generate the request payload and serialize it as JSON.
String payload = new MassiveStatsDataRequest(instance).serialize(); String payload = new MassiveStatsDataRequest(instance).serialize();
// Then create a new HttpsUrlConnection to the API server and open it. // Then create a new HttpsUrlConnection to the API server and open it.
HttpsURLConnection connection = (HttpsURLConnection) new URL(MassiveStats.API_URL).openConnection(); HttpsURLConnection connection = (HttpsURLConnection) new URL(MassiveStats.API_URL).openConnection();
// Ensure that we don't hang the server with our 'dang shenanigans'. // Ensure that we don't hang the server with our 'dang shenanigans'.
connection.setConnectTimeout(2500); connection.setConnectTimeout(2500);
connection.setReadTimeout(3500); connection.setReadTimeout(3500);
// Set the all-important request headers before we begin POSTing... // Set the all-important request headers before we begin POSTing...
connection.setRequestMethod("POST"); connection.setRequestMethod("POST");
connection.setRequestProperty("Accept", "application/json"); connection.setRequestProperty("Accept", "application/json");
connection.setRequestProperty("Content-Type", "application/json; charset=utf-8"); connection.setRequestProperty("Content-Type", "application/json; charset=utf-8");
connection.setRequestProperty("User-Agent", "Massive/" + MassiveStats.CLIENT_VERSION); connection.setRequestProperty("User-Agent", "Massive/" + MassiveStats.CLIENT_VERSION);
// Open the output stream, write the payload, and then close the stream. // Open the output stream, write the payload, and then close the stream.
connection.setDoOutput(true); connection.setDoOutput(true);
DataOutputStream output = new DataOutputStream(connection.getOutputStream()); DataOutputStream output = new DataOutputStream(connection.getOutputStream());
output.writeBytes(payload); output.writeBytes(payload);
output.flush(); output.flush();
output.close(); output.close();
// Ensure that the server was happy with our data. // Ensure that the server was happy with our data.
int responseCode = connection.getResponseCode(); int responseCode = connection.getResponseCode();
if (responseCode != 200) { if (responseCode != 200) {
throw new IOException(); throw new IOException();
} }
// Now, read the server's response to our payload... // Now, read the server's response to our payload...
BufferedReader input = new BufferedReader(new InputStreamReader(connection.getInputStream())); BufferedReader input = new BufferedReader(new InputStreamReader(connection.getInputStream()));
StringBuilder response = new StringBuilder(); StringBuilder response = new StringBuilder();
// ...line by line. // ...line by line.
String line; String line;
while ((line = input.readLine()) != null) { while ((line = input.readLine()) != null) {
response.append(line); response.append(line);
} }
input.close(); input.close();
// Now, we parse the JSON object. // Now, we parse the JSON object.
try { try {
if (response.toString().contains("ERR_DATA_MISSING")) { if (response.toString().contains("ERR_DATA_MISSING")) {
Bukkit.getLogger().severe("MassiveStats has encountered an error for the following plugin: " Bukkit.getLogger().severe("MassiveStats has encountered an error for the following plugin: "
+ instance.getPlugin().getName()); + instance.getPlugin().getName());
instance.stop(); instance.stop();
return; return;
} }
Object parser = instance.getJsonParser().newInstance(); Object parser = instance.getJsonParser().newInstance();
// JsonElement // JsonElement
Object serverResponseRaw = Object serverResponseRaw =
parser.getClass().getMethod("parse", String.class).invoke(parser, response.toString()); parser.getClass().getMethod("parse", String.class).invoke(parser, response.toString());
// JsonObject // JsonObject
Object serverResponse = serverResponseRaw.getClass().getMethod("getAsJsonObject", null) Object serverResponse = serverResponseRaw.getClass().getMethod("getAsJsonObject", null)
.invoke(serverResponseRaw, null); .invoke(serverResponseRaw, null);
Method serverResponseGet = instance.getJsonObject().getMethod("get", String.class); Method serverResponseGet = instance.getJsonObject().getMethod("get", String.class);
Method getAsBoolean = Method getAsBoolean =
instance.getJsonPrimitive().getMethod("getAsBoolean", null); instance.getJsonPrimitive().getMethod("getAsBoolean", null);
Method getAsString = Method getAsString =
instance.getJsonPrimitive().getMethod("getAsString", null); instance.getJsonPrimitive().getMethod("getAsString", null);
if (serverResponseGet.invoke(serverResponse, "upToDate") == null) { if (serverResponseGet.invoke(serverResponse, "upToDate") == null) {
Bukkit.getLogger().severe("MassiveStats has encountered an error for the following plugin: " Bukkit.getLogger().severe("MassiveStats has encountered an error for the following plugin: "
+ instance.getPlugin().getName()); + instance.getPlugin().getName());
instance.stop(); instance.stop();
return; return;
} }
if (serverResponseGet.invoke(serverResponse, "notice") != null) { if (serverResponseGet.invoke(serverResponse, "notice") != null) {
Bukkit.getLogger().severe( Bukkit.getLogger().severe(
(String) getAsString.invoke(serverResponseGet.invoke(serverResponse, "notice")) (String) getAsString.invoke(serverResponseGet.invoke(serverResponse, "notice"))
); );
instance.stop(); instance.stop();
return; return;
} }
boolean upToDate = (boolean) getAsBoolean.invoke(serverResponseGet.invoke(serverResponse, "upToDate"), null); boolean upToDate = (boolean) getAsBoolean.invoke(serverResponseGet.invoke(serverResponse, "upToDate"), null);
String latestVersion = (String) getAsString.invoke(serverResponseGet.invoke(serverResponse, "latestVersion"), null); String latestVersion = (String) getAsString.invoke(serverResponseGet.invoke(serverResponse, "latestVersion"), null);
String updateMessage = ChatColor.translateAlternateColorCodes( String updateMessage = ChatColor.translateAlternateColorCodes(
'&', (String) getAsString.invoke(serverResponseGet.invoke(serverResponse, "updateMessage"), null) '&', (String) getAsString.invoke(serverResponseGet.invoke(serverResponse, "updateMessage"), null)
); );
instance.setLastResponse(new MassiveStatsDataResponse( instance.setLastResponse(new MassiveStatsDataResponse(
upToDate, latestVersion, updateMessage upToDate, latestVersion, updateMessage
)); ));
} catch (IllegalAccessException | InstantiationException | NoSuchMethodException | InvocationTargetException e) { } catch (IllegalAccessException | InstantiationException | NoSuchMethodException | InvocationTargetException e) {
instance.getPlugin() instance.getPlugin()
.getLogger().warning("MassiveStats returned an invalid response for this plugin."); .getLogger().warning("MassiveStats returned an invalid response for this plugin.");
} }
// Finally, call an event to mark the update. // Finally, call an event to mark the update.
} catch (MalformedURLException ex) { } catch (MalformedURLException ex) {
instance.getPlugin() instance.getPlugin()
.getLogger().warning("You have specified an invalid API endpoint for MassiveStats."); .getLogger().warning("You have specified an invalid API endpoint for MassiveStats.");
} catch (IOException ex) { } catch (IOException ex) {
instance.getPlugin() instance.getPlugin()
.getLogger().warning("MassiveStats was unable to communicate with its API endpoint."); .getLogger().warning("MassiveStats was unable to communicate with its API endpoint.");
} }
} }
} }
class MassiveStatsDataRequest { class MassiveStatsDataRequest {
private Object jsonObject; private Object jsonObject;
MassiveStatsDataRequest(MassiveStats requester) { MassiveStatsDataRequest(MassiveStats requester) {
try { try {
jsonObject = requester.getJsonObject().newInstance(); jsonObject = requester.getJsonObject().newInstance();
Method add = Method add =
requester.getJsonObject().newInstance().getClass().getMethod("add", String.class, requester.getJsonElement()); requester.getJsonObject().newInstance().getClass().getMethod("add", String.class, requester.getJsonElement());
Method addPropertyString = Method addPropertyString =
requester.getJsonObject().newInstance().getClass().getMethod("addProperty", String.class, String.class); requester.getJsonObject().newInstance().getClass().getMethod("addProperty", String.class, String.class);
Method addPropertyNumber = Method addPropertyNumber =
requester.getJsonObject().newInstance().getClass().getMethod("addProperty", String.class, Number.class); requester.getJsonObject().newInstance().getClass().getMethod("addProperty", String.class, Number.class);
Method addPropertyBoolean = Method addPropertyBoolean =
requester.getJsonObject().newInstance().getClass().getMethod("addProperty", String.class, Boolean.class); requester.getJsonObject().newInstance().getClass().getMethod("addProperty", String.class, Boolean.class);
addPropertyNumber.invoke(jsonObject, "now", System.currentTimeMillis()); addPropertyNumber.invoke(jsonObject, "now", System.currentTimeMillis());
/* PLUGIN DATA */ /* PLUGIN DATA */
Object pluginObject = jsonObject.getClass().newInstance(); Object pluginObject = jsonObject.getClass().newInstance();
addPropertyString.invoke(pluginObject, "name", requester.getPlugin().getDescription().getName()); addPropertyString.invoke(pluginObject, "name", requester.getPlugin().getDescription().getName());
addPropertyString.invoke(pluginObject, "version", requester.getPlugin().getDescription().getVersion()); addPropertyString.invoke(pluginObject, "version", requester.getPlugin().getDescription().getVersion());
add.invoke(jsonObject, "plugin", pluginObject); add.invoke(jsonObject, "plugin", pluginObject);
/* SERVER DATA */ /* SERVER DATA */
Object minecraftServerObject = jsonObject.getClass().newInstance(); Object minecraftServerObject = jsonObject.getClass().newInstance();
addPropertyNumber.invoke(minecraftServerObject, "players", Bukkit.getServer().getOnlinePlayers().size()); addPropertyNumber.invoke(minecraftServerObject, "players", Bukkit.getServer().getOnlinePlayers().size());
addPropertyBoolean.invoke(minecraftServerObject, "onlineMode", Bukkit.getServer().getOnlineMode()); addPropertyBoolean.invoke(minecraftServerObject, "onlineMode", Bukkit.getServer().getOnlineMode());
addPropertyString.invoke(minecraftServerObject, "version", Bukkit.getServer().getVersion()); addPropertyString.invoke(minecraftServerObject, "version", Bukkit.getServer().getVersion());
Object javaServerObject = jsonObject.getClass().newInstance(); Object javaServerObject = jsonObject.getClass().newInstance();
addPropertyString.invoke(javaServerObject, "version", System.getProperty("java.version")); addPropertyString.invoke(javaServerObject, "version", System.getProperty("java.version"));
Object osServerObject = jsonObject.getClass().newInstance(); Object osServerObject = jsonObject.getClass().newInstance();
addPropertyString.invoke(osServerObject, "name", System.getProperty("os.name")); addPropertyString.invoke(osServerObject, "name", System.getProperty("os.name"));
addPropertyString.invoke(osServerObject, "arch", System.getProperty("os.arch")); addPropertyString.invoke(osServerObject, "arch", System.getProperty("os.arch"));
addPropertyString.invoke(osServerObject, "version", System.getProperty("os.version")); addPropertyString.invoke(osServerObject, "version", System.getProperty("os.version"));
Object hardwareServerObject = jsonObject.getClass().newInstance(); Object hardwareServerObject = jsonObject.getClass().newInstance();
addPropertyNumber.invoke(hardwareServerObject, "cores", Runtime.getRuntime().availableProcessors()); addPropertyNumber.invoke(hardwareServerObject, "cores", Runtime.getRuntime().availableProcessors());
Object serverObject = jsonObject.getClass().newInstance(); Object serverObject = jsonObject.getClass().newInstance();
add.invoke(serverObject, "minecraft", minecraftServerObject); add.invoke(serverObject, "minecraft", minecraftServerObject);
add.invoke(serverObject, "java", javaServerObject); add.invoke(serverObject, "java", javaServerObject);
add.invoke(serverObject, "os", osServerObject); add.invoke(serverObject, "os", osServerObject);
add.invoke(serverObject, "hardware", hardwareServerObject); add.invoke(serverObject, "hardware", hardwareServerObject);
add.invoke(jsonObject, "server", serverObject); add.invoke(jsonObject, "server", serverObject);
/* MASSIVE DATA */ /* MASSIVE DATA */
Object massiveObject = jsonObject.getClass().newInstance(); Object massiveObject = jsonObject.getClass().newInstance();
addPropertyNumber.invoke(massiveObject, "version", MassiveStats.CLIENT_VERSION); addPropertyNumber.invoke(massiveObject, "version", MassiveStats.CLIENT_VERSION);
addPropertyNumber.invoke(massiveObject, "pingInterval", requester.getPingInterval()); addPropertyNumber.invoke(massiveObject, "pingInterval", requester.getPingInterval());
//object.add("Massive", massiveObject); //object.add("Massive", massiveObject);
add.invoke(jsonObject, "Massive", massiveObject); add.invoke(jsonObject, "Massive", massiveObject);
} catch (IllegalAccessException | InstantiationException | NoSuchMethodException | InvocationTargetException e) { } catch (IllegalAccessException | InstantiationException | NoSuchMethodException | InvocationTargetException e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
@SuppressWarnings("all") @SuppressWarnings("all")
public String serialize() { public String serialize() {
//return object.toString(); //return object.toString();
try { try {
Method toString = jsonObject.getClass().getMethod("toString", null); Method toString = jsonObject.getClass().getMethod("toString", null);
return (String) toString.invoke(jsonObject); return (String) toString.invoke(jsonObject);
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
e.printStackTrace(); e.printStackTrace();
} }
return null; return null;
} }
} }
final class MassiveStatsDataResponse { final class MassiveStatsDataResponse {
private final boolean isUpToDate; private final boolean isUpToDate;
private final String newVersion; private final String newVersion;
private final String updateMessage; private final String updateMessage;
MassiveStatsDataResponse(boolean isUpToDate, String newVersion, String updateMessage) { MassiveStatsDataResponse(boolean isUpToDate, String newVersion, String updateMessage) {
this.isUpToDate = isUpToDate; this.isUpToDate = isUpToDate;
if (!isUpToDate) { if (!isUpToDate) {
this.newVersion = newVersion; this.newVersion = newVersion;
this.updateMessage = updateMessage; this.updateMessage = updateMessage;
return; return;
} }
this.newVersion = null; this.newVersion = null;
this.updateMessage = null; this.updateMessage = null;
} }
/** /**
* Indicates whether or not this version of the plugin is the latest. * Indicates whether or not this version of the plugin is the latest.
* True = This is the latest version of the plugin. * True = This is the latest version of the plugin.
* False = There is an update available. * False = There is an update available.
* *
* @return Whether or not there is an update available. * @return Whether or not there is an update available.
*/ */
public boolean isUpToDate() { public boolean isUpToDate() {
return isUpToDate; return isUpToDate;
} }
/** /**
* Gets the name of the latest version. If this is the latest version, it returns null. * Gets the name of the latest version. If this is the latest version, it returns null.
* *
* @return The name of the latest version. * @return The name of the latest version.
*/ */
public String getLatestVersion() { public String getLatestVersion() {
return newVersion; return newVersion;
} }
/** /**
* Gets the message to display, convincing the user to update to the new version of the plugin. * Gets the message to display, convincing the user to update to the new version of the plugin.
* *
* @return The update message to display. * @return The update message to display.
*/ */
public String getUpdateMessage() { public String getUpdateMessage() {
return updateMessage; return updateMessage;
} }
} }

File diff suppressed because it is too large Load Diff

View File

@ -8,45 +8,45 @@ 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 name"); this.requiredArgs.add("player name");
this.permission = Permission.AHOME.node; this.permission = Permission.AHOME.node;
this.disableOnLock = false; this.disableOnLock = false;
senderMustBePlayer = false; senderMustBePlayer = false;
senderMustBeMember = false; senderMustBeMember = false;
senderMustBeModerator = false; senderMustBeModerator = false;
senderMustBeAdmin = false; senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform() {
FPlayer target = argAsBestFPlayerMatch(0); FPlayer target = argAsBestFPlayerMatch(0);
if (target == null) { if (target == null) {
msg(TL.GENERIC_NOPLAYERMATCH, argAsString(0)); msg(TL.GENERIC_NOPLAYERMATCH, 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);
msg(TL.COMMAND_AHOME_SUCCESS, target.getName()); msg(TL.COMMAND_AHOME_SUCCESS, target.getName());
target.msg(TL.COMMAND_AHOME_TARGET); target.msg(TL.COMMAND_AHOME_TARGET);
} else { } else {
msg(TL.COMMAND_AHOME_NOHOME, target.getName()); msg(TL.COMMAND_AHOME_NOHOME, target.getName());
} }
} else { } else {
msg(TL.COMMAND_AHOME_OFFLINE, target.getName()); 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,90 +11,90 @@ 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 name"); this.requiredArgs.add("player name");
//this.optionalArgs.put("", ""); //this.optionalArgs.put("", "");
this.permission = Permission.ADMIN.node; this.permission = Permission.ADMIN.node;
this.disableOnLock = true; this.disableOnLock = true;
senderMustBePlayer = false; senderMustBePlayer = false;
senderMustBeMember = false; senderMustBeMember = false;
senderMustBeModerator = false; senderMustBeModerator = false;
senderMustBeAdmin = false; senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform() {
FPlayer fyou = this.argAsBestFPlayerMatch(0); FPlayer fyou = this.argAsBestFPlayerMatch(0);
if (fyou == null) { if (fyou == null) {
return; return;
} }
boolean permAny = Permission.ADMIN_ANY.has(sender, false); boolean permAny = Permission.ADMIN_ANY.has(sender, false);
Faction targetFaction = fyou.getFaction(); Faction targetFaction = fyou.getFaction();
if (targetFaction != myFaction && !permAny) { if (targetFaction != myFaction && !permAny) {
msg(TL.COMMAND_ADMIN_NOTMEMBER, fyou.describeTo(fme, true)); msg(TL.COMMAND_ADMIN_NOTMEMBER, fyou.describeTo(fme, true));
return; return;
} }
if (fme != null && fme.getRole() != Role.LEADER && !permAny) { if (fme != null && fme.getRole() != Role.LEADER && !permAny) {
msg(TL.COMMAND_ADMIN_NOTADMIN); msg(TL.COMMAND_ADMIN_NOTADMIN);
return; return;
} }
if (fyou == fme && !permAny) { if (fyou == fme && !permAny) {
msg(TL.COMMAND_ADMIN_TARGETSELF); 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(me), targetFaction, FPlayerJoinEvent.PlayerJoinReason.LEADER); FPlayerJoinEvent event = new FPlayerJoinEvent(FPlayers.getInstance().getByPlayer(me), 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 (fyou == admin && fyou.getFaction().getSize() == 1) { if (fyou == admin && fyou.getFaction().getSize() == 1) {
msg(TL.COMMAND_ADMIN_NOMEMBERS); msg(TL.COMMAND_ADMIN_NOMEMBERS);
return; return;
} }
// 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();
msg(TL.COMMAND_ADMIN_DEMOTES, fyou.describeTo(fme, true)); msg(TL.COMMAND_ADMIN_DEMOTES, fyou.describeTo(fme, true));
fyou.msg(TL.COMMAND_ADMIN_DEMOTED, senderIsConsole ? TL.GENERIC_SERVERADMIN.toString() : fme.describeTo(fyou, true)); fyou.msg(TL.COMMAND_ADMIN_DEMOTED, senderIsConsole ? TL.GENERIC_SERVERADMIN.toString() : fme.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);
msg(TL.COMMAND_ADMIN_PROMOTES, fyou.describeTo(fme, true)); msg(TL.COMMAND_ADMIN_PROMOTES, fyou.describeTo(fme, 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, senderIsConsole ? TL.GENERIC_SERVERADMIN.toString() : fme.describeTo(fplayer, true), fyou.describeTo(fplayer), targetFaction.describeTo(fplayer)); fplayer.msg(TL.COMMAND_ADMIN_PROMOTED, senderIsConsole ? TL.GENERIC_SERVERADMIN.toString() : fme.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

@ -9,41 +9,41 @@ 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.errorOnToManyArgs = false; this.errorOnToManyArgs = false;
this.permission = Permission.ANNOUNCE.node; this.permission = Permission.ANNOUNCE.node;
this.disableOnLock = false; this.disableOnLock = false;
senderMustBePlayer = true; senderMustBePlayer = true;
senderMustBeMember = true; senderMustBeMember = true;
senderMustBeModerator = false; senderMustBeModerator = false;
senderMustBeColeader = false; senderMustBeColeader = false;
} }
@Override @Override
public void perform() { public void perform() {
String prefix = ChatColor.GREEN + myFaction.getTag() + ChatColor.YELLOW + " [" + ChatColor.GRAY + me.getName() + ChatColor.YELLOW + "] " + ChatColor.RESET; String prefix = ChatColor.GREEN + myFaction.getTag() + ChatColor.YELLOW + " [" + ChatColor.GRAY + me.getName() + ChatColor.YELLOW + "] " + ChatColor.RESET;
String message = StringUtils.join(args, " "); String message = StringUtils.join(args, " ");
for (Player player : myFaction.getOnlinePlayers()) { for (Player player : myFaction.getOnlinePlayers()) {
player.sendMessage(prefix + message); player.sendMessage(prefix + message);
} }
// Add for offline players. // Add for offline players.
for (FPlayer fp : myFaction.getFPlayersWhereOnline(false)) { for (FPlayer fp : myFaction.getFPlayersWhereOnline(false)) {
myFaction.addAnnouncement(fp, prefix + message); myFaction.addAnnouncement(fp, prefix + message);
} }
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_ANNOUNCE_DESCRIPTION; return TL.COMMAND_ANNOUNCE_DESCRIPTION;
} }
} }

View File

@ -7,50 +7,50 @@ import com.massivecraft.factions.zcore.util.TL;
public class CmdAutoClaim extends FCommand { public class CmdAutoClaim extends FCommand {
public CmdAutoClaim() { public CmdAutoClaim() {
super(); super();
this.aliases.add("autoclaim"); this.aliases.add("autoclaim");
//this.requiredArgs.add(""); //this.requiredArgs.add("");
this.optionalArgs.put("faction", "your"); this.optionalArgs.put("faction", "your");
this.permission = Permission.AUTOCLAIM.node; this.permission = Permission.AUTOCLAIM.node;
this.disableOnLock = true; this.disableOnLock = true;
senderMustBePlayer = true; senderMustBePlayer = true;
senderMustBeMember = false; senderMustBeMember = false;
senderMustBeModerator = false; senderMustBeModerator = false;
senderMustBeAdmin = false; senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform() {
Faction forFaction = this.argAsFaction(0, myFaction); Faction forFaction = this.argAsFaction(0, myFaction);
if (forFaction == null || forFaction == fme.getAutoClaimFor()) { if (forFaction == null || forFaction == fme.getAutoClaimFor()) {
fme.setAutoClaimFor(null); fme.setAutoClaimFor(null);
msg(TL.COMMAND_AUTOCLAIM_DISABLED); msg(TL.COMMAND_AUTOCLAIM_DISABLED);
return; return;
} }
if (!fme.canClaimForFaction(forFaction)) { if (!fme.canClaimForFaction(forFaction)) {
if (myFaction == forFaction) { if (myFaction == forFaction) {
msg(TL.COMMAND_AUTOCLAIM_REQUIREDRANK, Role.MODERATOR.getTranslation()); msg(TL.COMMAND_AUTOCLAIM_REQUIREDRANK, Role.MODERATOR.getTranslation());
} else { } else {
msg(TL.COMMAND_AUTOCLAIM_OTHERFACTION, forFaction.describeTo(fme)); msg(TL.COMMAND_AUTOCLAIM_OTHERFACTION, forFaction.describeTo(fme));
} }
return; return;
} }
fme.setAutoClaimFor(forFaction); fme.setAutoClaimFor(forFaction);
msg(TL.COMMAND_AUTOCLAIM_ENABLED, forFaction.describeTo(fme)); msg(TL.COMMAND_AUTOCLAIM_ENABLED, forFaction.describeTo(fme));
fme.attemptClaim(forFaction, me.getLocation(), true); fme.attemptClaim(forFaction, me.getLocation(), true);
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_AUTOCLAIM_DESCRIPTION; return TL.COMMAND_AUTOCLAIM_DESCRIPTION;
} }
} }

View File

@ -1,48 +1,48 @@
package com.massivecraft.factions.cmd; package com.massivecraft.factions.cmd;
import com.massivecraft.factions.SavageFactions; import com.massivecraft.factions.SavageFactions;
import com.massivecraft.factions.zcore.CommandVisibility; import com.massivecraft.factions.zcore.CommandVisibility;
import com.massivecraft.factions.zcore.MCommand; import com.massivecraft.factions.zcore.MCommand;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
import java.util.ArrayList; import java.util.ArrayList;
public class CmdAutoHelp extends MCommand<SavageFactions> { public class CmdAutoHelp extends MCommand<SavageFactions> {
public CmdAutoHelp() { public CmdAutoHelp() {
super(SavageFactions.plugin); super(SavageFactions.plugin);
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() { public void perform() {
if (this.commandChain.size() == 0) { if (this.commandChain.size() == 0) {
return; return;
} }
MCommand<?> pcmd = this.commandChain.get(this.commandChain.size() - 1); MCommand<?> pcmd = this.commandChain.get(this.commandChain.size() - 1);
ArrayList<String> lines = new ArrayList<>(); ArrayList<String> lines = new ArrayList<>();
lines.addAll(pcmd.helpLong); lines.addAll(pcmd.helpLong);
for (MCommand<?> scmd : pcmd.subCommands) { for (MCommand<?> scmd : pcmd.subCommands) {
if (scmd.visibility == CommandVisibility.VISIBLE || (scmd.visibility == CommandVisibility.SECRET && scmd.validSenderPermissions(sender, false))) { if (scmd.visibility == CommandVisibility.VISIBLE || (scmd.visibility == CommandVisibility.SECRET && scmd.validSenderPermissions(sender, false))) {
lines.add(scmd.getUseageTemplate(this.commandChain, true)); lines.add(scmd.getUseageTemplate(this.commandChain, true));
} }
} }
sendMessage(p.txt.getPage(lines, this.argAsInt(0, 1), TL.COMMAND_AUTOHELP_HELPFOR.toString() + pcmd.aliases.get(0) + "\"")); sendMessage(p.txt.getPage(lines, this.argAsInt(0, 1), TL.COMMAND_AUTOHELP_HELPFOR.toString() + pcmd.aliases.get(0) + "\""));
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_HELP_DESCRIPTION; return TL.COMMAND_HELP_DESCRIPTION;
} }
} }

View File

@ -15,87 +15,87 @@ 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.permission = Permission.BAN.node; this.permission = Permission.BAN.node;
this.disableOnLock = true; this.disableOnLock = true;
senderMustBePlayer = true; senderMustBePlayer = true;
senderMustBeMember = false; senderMustBeMember = false;
senderMustBeModerator = false; senderMustBeModerator = false;
senderMustBeColeader = false; senderMustBeColeader = false;
senderMustBeAdmin = false; senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform() {
// Adds bypass to admins and clean permission check // Adds bypass to admins and clean permission check
if (!fme.isAdminBypassing()) { if (!fme.isAdminBypassing()) {
Access access = myFaction.getAccess(fme, PermissableAction.BAN); Access access = myFaction.getAccess(fme, PermissableAction.BAN);
if (access != Access.ALLOW && fme.getRole() != Role.LEADER) { if (access != Access.ALLOW && fme.getRole() != Role.LEADER) {
fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "ban"); fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "ban");
return; return;
} }
} }
// Good on permission checks. Now lets just ban the player. // Good on permission checks. Now lets just ban the player.
FPlayer target = argAsFPlayer(0); FPlayer target = 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 (fme == target) { if (fme == target) {
// You may not ban yourself // You may not ban yourself
fme.msg(TL.COMMAND_BAN_SELF); fme.msg(TL.COMMAND_BAN_SELF);
return; return;
} else if (target.getFaction() == myFaction && target.getRole().value >= fme.getRole().value) { } else if (target.getFaction() == myFaction && target.getRole().value >= fme.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
fme.msg(TL.COMMAND_BAN_INSUFFICIENTRANK, target.getName()); fme.msg(TL.COMMAND_BAN_INSUFFICIENTRANK, target.getName());
return; return;
} }
for (BanInfo banInfo : myFaction.getBannedPlayers()) { for (BanInfo banInfo : myFaction.getBannedPlayers()) {
if (banInfo.getBanned().equals(target.getId())) { if (banInfo.getBanned().equals(target.getId())) {
msg(TL.COMMAND_BAN_ALREADYBANNED); msg(TL.COMMAND_BAN_ALREADYBANNED);
return; return;
} }
} }
// Ban the user. // Ban the user.
myFaction.ban(target, fme); myFaction.ban(target, fme);
myFaction.deinvite(target); // can't hurt myFaction.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() == myFaction) { if (target.getFaction() == myFaction) {
FPlayerLeaveEvent event = new FPlayerLeaveEvent(target, myFaction, FPlayerLeaveEvent.PlayerLeaveReason.BANNED); FPlayerLeaveEvent event = new FPlayerLeaveEvent(target, myFaction, 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.
SavageFactions.plugin.log(Level.WARNING, "Attempted to ban {0} but someone cancelled the kick event. This isn't good.", target.getName()); SavageFactions.plugin.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.
myFaction.removeFPlayer(target); myFaction.removeFPlayer(target);
target.resetFactionData(); target.resetFactionData();
} }
// Lets inform the people! // Lets inform the people!
target.msg(TL.COMMAND_BAN_TARGET, myFaction.getTag(target.getFaction())); target.msg(TL.COMMAND_BAN_TARGET, myFaction.getTag(target.getFaction()));
myFaction.msg(TL.COMMAND_BAN_BANNED, fme.getName(), target.getName()); myFaction.msg(TL.COMMAND_BAN_BANNED, fme.getName(), target.getName());
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_BAN_DESCRIPTION; return TL.COMMAND_BAN_DESCRIPTION;
} }
} }

View File

@ -13,60 +13,60 @@ 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.permission = Permission.BAN.node; this.permission = Permission.BAN.node;
this.disableOnLock = true; this.disableOnLock = true;
senderMustBePlayer = true; senderMustBePlayer = true;
senderMustBeMember = false; senderMustBeMember = false;
senderMustBeModerator = false; senderMustBeModerator = false;
senderMustBeAdmin = false; senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform() {
Faction target = myFaction; Faction target = myFaction;
if (!args.isEmpty()) { if (!args.isEmpty()) {
target = argAsFaction(0); target = argAsFaction(0);
} }
if (target == Factions.getInstance().getWilderness()) { if (target == Factions.getInstance().getWilderness()) {
sender.sendMessage(TL.COMMAND_BANLIST_NOFACTION.toString()); sender.sendMessage(TL.COMMAND_BANLIST_NOFACTION.toString());
return; return;
} }
if (target == null) { if (target == null) {
sender.sendMessage(TL.COMMAND_BANLIST_INVALID.format(argAsString(0))); sender.sendMessage(TL.COMMAND_BANLIST_INVALID.format(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(myFaction))); lines.add(TL.COMMAND_BANLIST_HEADER.format(target.getBannedPlayers().size(), target.getTag(myFaction)));
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) {
fme.sendMessage(s); fme.sendMessage(s);
} }
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_BANLIST_DESCRIPTION; return TL.COMMAND_BANLIST_DESCRIPTION;
} }
} }

View File

@ -13,123 +13,123 @@ 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() {
super(); super();
this.aliases.add("banner"); this.aliases.add("banner");
this.aliases.add("warbanner"); this.aliases.add("warbanner");
this.permission = Permission.BANNER.node; this.permission = Permission.BANNER.node;
this.disableOnLock = false; this.disableOnLock = false;
senderMustBePlayer = true; senderMustBePlayer = true;
senderMustBeMember = false; senderMustBeMember = false;
senderMustBeModerator = false; senderMustBeModerator = false;
senderMustBeColeader = true; senderMustBeColeader = true;
senderMustBeAdmin = false; senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform() {
if (!SavageFactions.plugin.getConfig().getBoolean("fbanners.Enabled")) { if (!SavageFactions.plugin.getConfig().getBoolean("fbanners.Enabled")) {
msg(TL.COMMAND_BANNER_DISABLED); msg(TL.COMMAND_BANNER_DISABLED);
return; return;
} }
if (!fme.hasMoney(SavageFactions.plugin.getConfig().getInt("fbanners.Banner-Cost", 5000))) { if (!fme.hasMoney(SavageFactions.plugin.getConfig().getInt("fbanners.Banner-Cost", 5000))) {
msg(TL.COMMAND_BANNER_NOTENOUGHMONEY); msg(TL.COMMAND_BANNER_NOTENOUGHMONEY);
return; return;
} }
takeMoney(fme, SavageFactions.plugin.getConfig().getInt("fbanners.Banner-Cost", 5000)); takeMoney(fme, SavageFactions.plugin.getConfig().getInt("fbanners.Banner-Cost", 5000));
//ItemStack warBanner = SavageFactions.plugin.createItem(Material.BANNER, 1, (short) 1, SavageFactions.plugin.getConfig().getString("fbanners.Item.Name"), SavageFactions.plugin.getConfig().getStringList("fbanners.Item.Lore")); //ItemStack warBanner = SavageFactions.plugin.createItem(Material.BANNER, 1, (short) 1, SavageFactions.plugin.getConfig().getString("fbanners.Item.Name"), SavageFactions.plugin.getConfig().getStringList("fbanners.Item.Lore"));
//BannerMeta bannerMeta = (BannerMeta) warBanner.getItemMeta(); //BannerMeta bannerMeta = (BannerMeta) warBanner.getItemMeta();
ItemStack warBanner = fme.getFaction().getBanner(); ItemStack warBanner = fme.getFaction().getBanner();
if (warBanner != null) { if (warBanner != null) {
ItemMeta warmeta = warBanner.getItemMeta(); ItemMeta warmeta = warBanner.getItemMeta();
warmeta.setDisplayName(SavageFactions.plugin.color(SavageFactions.plugin.getConfig().getString("fbanners.Item.Name"))); warmeta.setDisplayName(SavageFactions.plugin.color(SavageFactions.plugin.getConfig().getString("fbanners.Item.Name")));
warmeta.setLore(SavageFactions.plugin.colorList(SavageFactions.plugin.getConfig().getStringList("fbanners.Item.Lore"))); warmeta.setLore(SavageFactions.plugin.colorList(SavageFactions.plugin.getConfig().getStringList("fbanners.Item.Lore")));
warBanner.setItemMeta(warmeta); warBanner.setItemMeta(warmeta);
} else { } else {
warBanner = SavageFactions.plugin.createItem(SavageFactions.plugin.BANNER, 1, (short) 1, SavageFactions.plugin.getConfig().getString("fbanners.Item.Name"), SavageFactions.plugin.getConfig().getStringList("fbanners.Item.Lore")); warBanner = SavageFactions.plugin.createItem(SavageFactions.plugin.BANNER, 1, (short) 1, SavageFactions.plugin.getConfig().getString("fbanners.Item.Name"), SavageFactions.plugin.getConfig().getStringList("fbanners.Item.Lore"));
} }
fme.msg(TL.COMMAND_BANNER_SUCCESS); fme.msg(TL.COMMAND_BANNER_SUCCESS);
warBanner.setAmount(1); warBanner.setAmount(1);
me.getInventory().addItem(warBanner); me.getInventory().addItem(warBanner);
} }
public boolean hasMoney(FPlayer fme, int amt) { public boolean hasMoney(FPlayer fme, int amt) {
Economy econ = SavageFactions.plugin.getEcon(); Economy econ = SavageFactions.plugin.getEcon();
if (econ.getBalance(fme.getPlayer()) >= amt) { if (econ.getBalance(fme.getPlayer()) >= amt) {
return true; return true;
} else { } else {
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 (hasMoney(fme, amt)) { if (hasMoney(fme, amt)) {
Economy econ = SavageFactions.plugin.getEcon(); Economy econ = SavageFactions.plugin.getEcon();
econ.withdrawPlayer(fme.getPlayer(), amt); econ.withdrawPlayer(fme.getPlayer(), 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 (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;
} }
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;
} else if (items[i].getAmount() == amt) { } else if (items[i].getAmount() == amt) {
items[i] = null; items[i] = null;
break; break;
} else { } else {
amt -= items[i].getAmount(); amt -= items[i].getAmount();
items[i] = null; items[i] = null;
} }
} }
} }
inventory.setContents(items); 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,47 +6,47 @@ 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.permission = Permission.NO_BOOM.node; this.permission = Permission.NO_BOOM.node;
this.disableOnLock = true; this.disableOnLock = true;
senderMustBePlayer = true; senderMustBePlayer = true;
senderMustBeMember = false; senderMustBeMember = false;
senderMustBeModerator = false; senderMustBeModerator = false;
senderMustBeColeader = true; senderMustBeColeader = true;
senderMustBeAdmin = false; senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform() {
if (!myFaction.isPeaceful()) { if (!myFaction.isPeaceful()) {
fme.msg(TL.COMMAND_BOOM_PEACEFULONLY); fme.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 (!payForCommand(Conf.econCostNoBoom, TL.COMMAND_BOOM_TOTOGGLE, TL.COMMAND_BOOM_FORTOGGLE)) { if (!payForCommand(Conf.econCostNoBoom, TL.COMMAND_BOOM_TOTOGGLE, TL.COMMAND_BOOM_FORTOGGLE)) {
return; return;
} }
myFaction.setPeacefulExplosionsEnabled(this.argAsBool(0, !myFaction.getPeacefulExplosionsEnabled())); myFaction.setPeacefulExplosionsEnabled(this.argAsBool(0, !myFaction.getPeacefulExplosionsEnabled()));
String enabled = myFaction.noExplosionsInTerritory() ? TL.GENERIC_DISABLED.toString() : TL.GENERIC_ENABLED.toString(); String enabled = myFaction.noExplosionsInTerritory() ? TL.GENERIC_DISABLED.toString() : TL.GENERIC_ENABLED.toString();
// Inform // Inform
myFaction.msg(TL.COMMAND_BOOM_ENABLED, fme.describeTo(myFaction), enabled); myFaction.msg(TL.COMMAND_BOOM_ENABLED, fme.describeTo(myFaction), enabled);
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_BOOM_DESCRIPTION; return TL.COMMAND_BOOM_DESCRIPTION;
} }
} }

View File

@ -6,39 +6,39 @@ 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.permission = Permission.BYPASS.node; this.permission = Permission.BYPASS.node;
this.disableOnLock = false; this.disableOnLock = false;
senderMustBePlayer = true; senderMustBePlayer = true;
senderMustBeMember = false; senderMustBeMember = false;
senderMustBeModerator = false; senderMustBeModerator = false;
senderMustBeColeader = false; senderMustBeColeader = false;
senderMustBeAdmin = false; senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform() {
fme.setIsAdminBypassing(this.argAsBool(0, !fme.isAdminBypassing())); fme.setIsAdminBypassing(this.argAsBool(0, !fme.isAdminBypassing()));
// TODO: Move this to a transient field in the model?? // TODO: Move this to a transient field in the model??
if (fme.isAdminBypassing()) { if (fme.isAdminBypassing()) {
fme.msg(TL.COMMAND_BYPASS_ENABLE.toString()); fme.msg(TL.COMMAND_BYPASS_ENABLE.toString());
SavageFactions.plugin.log(fme.getName() + TL.COMMAND_BYPASS_ENABLELOG.toString()); SavageFactions.plugin.log(fme.getName() + TL.COMMAND_BYPASS_ENABLELOG.toString());
} else { } else {
fme.msg(TL.COMMAND_BYPASS_DISABLE.toString()); fme.msg(TL.COMMAND_BYPASS_DISABLE.toString());
SavageFactions.plugin.log(fme.getName() + TL.COMMAND_BYPASS_DISABLELOG.toString()); SavageFactions.plugin.log(fme.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

@ -8,80 +8,80 @@ import com.massivecraft.factions.zcore.util.TL;
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.permission = Permission.CHAT.node; this.permission = Permission.CHAT.node;
this.disableOnLock = false; this.disableOnLock = false;
senderMustBePlayer = true; senderMustBePlayer = true;
senderMustBeMember = true; senderMustBeMember = true;
senderMustBeModerator = false; senderMustBeModerator = false;
senderMustBeColeader = false; senderMustBeColeader = false;
senderMustBeAdmin = false; senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform() {
if (!Conf.factionOnlyChat) { if (!Conf.factionOnlyChat) {
msg(TL.COMMAND_CHAT_DISABLED.toString()); msg(TL.COMMAND_CHAT_DISABLED.toString());
return; return;
} }
String modeString = this.argAsString(0); String modeString = this.argAsString(0);
ChatMode modeTarget = fme.getChatMode().getNext(); ChatMode modeTarget = fme.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 (!fme.getRole().isAtLeast(Role.MODERATOR)) { if (!fme.getRole().isAtLeast(Role.MODERATOR)) {
msg(TL.COMMAND_CHAT_MOD_ONLY); msg(TL.COMMAND_CHAT_MOD_ONLY);
return; return;
} else modeTarget = ChatMode.MOD; } else modeTarget = ChatMode.MOD;
} else if (modeString.startsWith("p")) { } else if (modeString.startsWith("p")) {
modeTarget = ChatMode.PUBLIC; modeTarget = ChatMode.PUBLIC;
} else if (modeString.startsWith("a")) { } else if (modeString.startsWith("a")) {
modeTarget = ChatMode.ALLIANCE; modeTarget = ChatMode.ALLIANCE;
} else if (modeString.startsWith("f")) { } else if (modeString.startsWith("f")) {
modeTarget = ChatMode.FACTION; modeTarget = ChatMode.FACTION;
} else if (modeString.startsWith("t")) { } else if (modeString.startsWith("t")) {
modeTarget = ChatMode.TRUCE; modeTarget = ChatMode.TRUCE;
} else { } else {
msg(TL.COMMAND_CHAT_INVALIDMODE); msg(TL.COMMAND_CHAT_INVALIDMODE);
return; return;
} }
} }
fme.setChatMode(modeTarget); fme.setChatMode(modeTarget);
switch (fme.getChatMode()) { switch (fme.getChatMode()) {
case MOD: case MOD:
msg(TL.COMMAND_CHAT_MODE_MOD); msg(TL.COMMAND_CHAT_MODE_MOD);
break; break;
case PUBLIC: case PUBLIC:
msg(TL.COMMAND_CHAT_MODE_PUBLIC); msg(TL.COMMAND_CHAT_MODE_PUBLIC);
break; break;
case ALLIANCE: case ALLIANCE:
msg(TL.COMMAND_CHAT_MODE_ALLIANCE); msg(TL.COMMAND_CHAT_MODE_ALLIANCE);
break; break;
case TRUCE: case TRUCE:
msg(TL.COMMAND_CHAT_MODE_TRUCE); msg(TL.COMMAND_CHAT_MODE_TRUCE);
break; break;
default: default:
msg(TL.COMMAND_CHAT_MODE_FACTION); 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;
} }
} }

View File

@ -6,37 +6,37 @@ 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.permission = Permission.CHATSPY.node; this.permission = Permission.CHATSPY.node;
this.disableOnLock = false; this.disableOnLock = false;
senderMustBePlayer = true; senderMustBePlayer = true;
senderMustBeMember = false; senderMustBeMember = false;
senderMustBeModerator = false; senderMustBeModerator = false;
senderMustBeColeader = false; senderMustBeColeader = false;
senderMustBeAdmin = false; senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform() {
fme.setSpyingChat(this.argAsBool(0, !fme.isSpyingChat())); fme.setSpyingChat(this.argAsBool(0, !fme.isSpyingChat()));
if (fme.isSpyingChat()) { if (fme.isSpyingChat()) {
fme.msg(TL.COMMAND_CHATSPY_ENABLE); fme.msg(TL.COMMAND_CHATSPY_ENABLE);
SavageFactions.plugin.log(fme.getName() + TL.COMMAND_CHATSPY_ENABLELOG.toString()); SavageFactions.plugin.log(fme.getName() + TL.COMMAND_CHATSPY_ENABLELOG.toString());
} else { } else {
fme.msg(TL.COMMAND_CHATSPY_DISABLE); fme.msg(TL.COMMAND_CHATSPY_DISABLE);
SavageFactions.plugin.log(fme.getName() + TL.COMMAND_CHATSPY_DISABLELOG.toString()); SavageFactions.plugin.log(fme.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,66 +6,66 @@ 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.permission = Permission.CHECKPOINT.node; this.permission = Permission.CHECKPOINT.node;
this.disableOnLock = false; this.disableOnLock = false;
senderMustBePlayer = true; senderMustBePlayer = true;
senderMustBeMember = true; senderMustBeMember = true;
senderMustBeModerator = false; senderMustBeModerator = false;
senderMustBeColeader = false; senderMustBeColeader = false;
senderMustBeAdmin = false; senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform() {
if (!SavageFactions.plugin.getConfig().getBoolean("checkpoints.Enabled")) { if (!SavageFactions.plugin.getConfig().getBoolean("checkpoints.Enabled")) {
fme.msg(TL.COMMAND_CHECKPOINT_DISABLED); fme.msg(TL.COMMAND_CHECKPOINT_DISABLED);
return; return;
} }
if (args.size() == 1) { if (args.size() == 1) {
FLocation myLocation = new FLocation(fme.getPlayer().getLocation()); FLocation myLocation = new FLocation(fme.getPlayer().getLocation());
Faction myLocFaction = Board.getInstance().getFactionAt(myLocation); Faction myLocFaction = Board.getInstance().getFactionAt(myLocation);
if (myLocFaction == Factions.getInstance().getWilderness() || myLocFaction == fme.getFaction()) { if (myLocFaction == Factions.getInstance().getWilderness() || myLocFaction == fme.getFaction()) {
fme.getFaction().setCheckpoint(fme.getPlayer().getLocation()); fme.getFaction().setCheckpoint(fme.getPlayer().getLocation());
fme.msg(TL.COMMAND_CHECKPOINT_SET); fme.msg(TL.COMMAND_CHECKPOINT_SET);
return; return;
} else { } else {
fme.msg(TL.COMMAND_CHECKPOINT_INVALIDLOCATION); fme.msg(TL.COMMAND_CHECKPOINT_INVALIDLOCATION);
return; return;
} }
} }
if (fme.getFaction().getCheckpoint() == null) { if (fme.getFaction().getCheckpoint() == null) {
fme.msg(TL.COMMAND_CHECKPOINT_NOT_SET); fme.msg(TL.COMMAND_CHECKPOINT_NOT_SET);
return; return;
} }
FLocation checkLocation = new FLocation(fme.getFaction().getCheckpoint()); FLocation checkLocation = new FLocation(fme.getFaction().getCheckpoint());
Faction checkfaction = Board.getInstance().getFactionAt(checkLocation); Faction checkfaction = Board.getInstance().getFactionAt(checkLocation);
if (checkfaction.getId().equals(Factions.getInstance().getWilderness().getId()) || checkfaction.getId().equals(fme.getFaction().getId())) { if (checkfaction.getId().equals(Factions.getInstance().getWilderness().getId()) || checkfaction.getId().equals(fme.getFaction().getId())) {
fme.msg(TL.COMMAND_CHECKPOINT_GO); fme.msg(TL.COMMAND_CHECKPOINT_GO);
this.doWarmUp(WarmUpUtil.Warmup.CHECKPOINT, TL.WARMUPS_NOTIFY_TELEPORT, "Checkpoint", new Runnable() { this.doWarmUp(WarmUpUtil.Warmup.CHECKPOINT, TL.WARMUPS_NOTIFY_TELEPORT, "Checkpoint", new Runnable() {
@Override @Override
public void run() { public void run() {
fme.getPlayer().teleport(fme.getFaction().getCheckpoint()); fme.getPlayer().teleport(fme.getFaction().getCheckpoint());
} }
}, this.p.getConfig().getLong("warmups.f-checkpoint", 0)); }, this.p.getConfig().getLong("warmups.f-checkpoint", 0));
} else { } else {
fme.msg(TL.COMMAND_CHECKPOINT_CLAIMED); fme.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

@ -9,47 +9,47 @@ import com.massivecraft.factions.zcore.util.TL;
public class CmdChest extends FCommand { public class CmdChest extends FCommand {
public CmdChest() { public CmdChest() {
this.aliases.add("chest"); this.aliases.add("chest");
this.aliases.add("pv"); this.aliases.add("pv");
//this.requiredArgs.add(""); //this.requiredArgs.add("");
this.permission = Permission.CHEST.node; this.permission = Permission.CHEST.node;
this.disableOnLock = false; this.disableOnLock = false;
senderMustBePlayer = true; senderMustBePlayer = true;
senderMustBeMember = true; senderMustBeMember = true;
senderMustBeModerator = false; senderMustBeModerator = false;
senderMustBeAdmin = false; senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform() {
if (!SavageFactions.plugin.getConfig().getBoolean("fchest.Enabled")) { if (!SavageFactions.plugin.getConfig().getBoolean("fchest.Enabled")) {
fme.sendMessage("This command is disabled!"); fme.sendMessage("This command is disabled!");
return; return;
} }
// This permission check is way too explicit but it's clean // This permission check is way too explicit but it's clean
if (!fme.isAdminBypassing()) { if (!fme.isAdminBypassing()) {
Access access = myFaction.getAccess(fme, PermissableAction.CHEST); Access access = myFaction.getAccess(fme, PermissableAction.CHEST);
if (access != Access.ALLOW && fme.getRole() != Role.LEADER) { if (access != Access.ALLOW && fme.getRole() != Role.LEADER) {
fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "access chest"); fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "access chest");
return; return;
} }
} }
me.openInventory(fme.getFaction().getChestInventory()); me.openInventory(fme.getFaction().getChestInventory());
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_VAULT_DESCRIPTION; return TL.COMMAND_VAULT_DESCRIPTION;
} }
} }

View File

@ -14,82 +14,82 @@ import com.massivecraft.factions.zcore.util.TL;
public class CmdClaim extends FCommand { public class CmdClaim extends FCommand {
public CmdClaim() { public CmdClaim() {
super(); super();
this.aliases.add("claim"); this.aliases.add("claim");
//this.requiredArgs.add(""); //this.requiredArgs.add("");
this.optionalArgs.put("radius", "1"); this.optionalArgs.put("radius", "1");
this.optionalArgs.put("faction", "your"); this.optionalArgs.put("faction", "your");
this.permission = Permission.CLAIM.node; this.permission = Permission.CLAIM.node;
this.disableOnLock = true; this.disableOnLock = true;
senderMustBePlayer = true; senderMustBePlayer = true;
senderMustBeMember = false; senderMustBeMember = false;
senderMustBeModerator = false; senderMustBeModerator = false;
senderMustBeColeader = false; senderMustBeColeader = false;
senderMustBeAdmin = false; senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform() {
// Read and validate input // Read and validate input
int radius = this.argAsInt(0, 1); // Default to 1 int radius = this.argAsInt(0, 1); // Default to 1
final Faction forFaction = this.argAsFaction(1, myFaction); // Default to own final Faction forFaction = this.argAsFaction(1, myFaction); // Default to own
if (!fme.isAdminBypassing()) { if (!fme.isAdminBypassing()) {
Access access = myFaction.getAccess(fme, PermissableAction.TERRITORY); Access access = myFaction.getAccess(fme, PermissableAction.TERRITORY);
if (access != Access.ALLOW && fme.getRole() != Role.LEADER) { if (access != Access.ALLOW && fme.getRole() != Role.LEADER) {
fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "change faction territory"); fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "change faction territory");
return; return;
} }
} }
if (forFaction.isWilderness()) { if (forFaction.isWilderness()) {
CmdUnclaim cmdUnclaim = SavageFactions.plugin.cmdBase.cmdUnclaim; CmdUnclaim cmdUnclaim = SavageFactions.plugin.cmdBase.cmdUnclaim;
cmdUnclaim.execute(sender, args.size() > 1 ? args.subList(0, 1) : args); cmdUnclaim.execute(sender, args.size() > 1 ? args.subList(0, 1) : args);
return; return;
} }
if (radius < 1) { if (radius < 1) {
msg(TL.COMMAND_CLAIM_INVALIDRADIUS); msg(TL.COMMAND_CLAIM_INVALIDRADIUS);
return; return;
} }
if (radius < 2) { if (radius < 2) {
// single chunk // single chunk
fme.attemptClaim(forFaction, me.getLocation(), true); fme.attemptClaim(forFaction, me.getLocation(), true);
} else { } else {
// radius claim // radius claim
if (!Permission.CLAIM_RADIUS.has(sender, false)) { if (!Permission.CLAIM_RADIUS.has(sender, false)) {
msg(TL.COMMAND_CLAIM_DENIED); msg(TL.COMMAND_CLAIM_DENIED);
return; return;
} }
new SpiralTask(new FLocation(me), radius) { new SpiralTask(new FLocation(me), radius) {
private final int limit = Conf.radiusClaimFailureLimit - 1; private final int limit = Conf.radiusClaimFailureLimit - 1;
private int failCount = 0; private int failCount = 0;
@Override @Override
public boolean work() { public boolean work() {
boolean success = fme.attemptClaim(forFaction, this.currentLocation(), true); boolean success = fme.attemptClaim(forFaction, this.currentLocation(), true);
if (success) { if (success) {
failCount = 0; failCount = 0;
} else if (failCount++ >= limit) { } else if (failCount++ >= limit) {
this.stop(); this.stop();
return false; return false;
} }
return true; return true;
} }
}; };
} }
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_CLAIM_DESCRIPTION; return TL.COMMAND_CLAIM_DESCRIPTION;
} }
} }

View File

@ -6,35 +6,35 @@ import com.massivecraft.factions.zcore.util.TL;
public class CmdClaimAt extends FCommand { public class CmdClaimAt extends FCommand {
public CmdClaimAt() { public CmdClaimAt() {
super(); super();
this.aliases.add("claimat"); this.aliases.add("claimat");
this.requiredArgs.add("world"); this.requiredArgs.add("world");
this.requiredArgs.add("x"); this.requiredArgs.add("x");
this.requiredArgs.add("z"); this.requiredArgs.add("z");
this.permission = Permission.CLAIMAT.node; this.permission = Permission.CLAIMAT.node;
this.disableOnLock = true; this.disableOnLock = true;
senderMustBePlayer = true; senderMustBePlayer = true;
senderMustBeMember = true; senderMustBeMember = true;
senderMustBeModerator = false; senderMustBeModerator = false;
senderMustBeColeader = false; senderMustBeColeader = false;
senderMustBeAdmin = false; senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform() {
int x = argAsInt(1); int x = argAsInt(1);
int z = argAsInt(2); int z = argAsInt(2);
FLocation location = new FLocation(argAsString(0), x, z); FLocation location = new FLocation(argAsString(0), x, z);
fme.attemptClaim(myFaction, location, true); fme.attemptClaim(myFaction, location, true);
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return null; return null;
} }
} }

View File

@ -9,70 +9,70 @@ import org.bukkit.block.BlockFace;
public class CmdClaimLine extends FCommand { public class CmdClaimLine extends FCommand {
public static final BlockFace[] axis = {BlockFace.SOUTH, BlockFace.WEST, BlockFace.NORTH, BlockFace.EAST}; public static final BlockFace[] axis = {BlockFace.SOUTH, BlockFace.WEST, BlockFace.NORTH, BlockFace.EAST};
public CmdClaimLine() { public CmdClaimLine() {
// Aliases // Aliases
this.aliases.add("claimline"); this.aliases.add("claimline");
this.aliases.add("cl"); this.aliases.add("cl");
// Args // Args
this.optionalArgs.put("amount", "1"); this.optionalArgs.put("amount", "1");
this.optionalArgs.put("direction", "facing"); this.optionalArgs.put("direction", "facing");
this.optionalArgs.put("faction", "you"); this.optionalArgs.put("faction", "you");
this.permission = Permission.CLAIM_LINE.node; this.permission = Permission.CLAIM_LINE.node;
this.disableOnLock = true; this.disableOnLock = true;
senderMustBePlayer = true; senderMustBePlayer = true;
senderMustBeMember = false; senderMustBeMember = false;
senderMustBeModerator = false; senderMustBeModerator = false;
senderMustBeColeader = false; senderMustBeColeader = false;
senderMustBeAdmin = false; senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform() {
// Args // Args
Integer amount = this.argAsInt(0, 1); // Default to 1 Integer amount = this.argAsInt(0, 1); // Default to 1
if (amount > Conf.lineClaimLimit) { if (amount > Conf.lineClaimLimit) {
fme.msg(TL.COMMAND_CLAIMLINE_ABOVEMAX, Conf.lineClaimLimit); fme.msg(TL.COMMAND_CLAIMLINE_ABOVEMAX, Conf.lineClaimLimit);
return; return;
} }
String direction = this.argAsString(1); String direction = this.argAsString(1);
BlockFace blockFace; BlockFace blockFace;
if (direction == null) { if (direction == null) {
blockFace = axis[Math.round(me.getLocation().getYaw() / 90f) & 0x3]; blockFace = axis[Math.round(me.getLocation().getYaw() / 90f) & 0x3];
} else if (direction.equalsIgnoreCase("north")) { } else if (direction.equalsIgnoreCase("north")) {
blockFace = BlockFace.NORTH; blockFace = BlockFace.NORTH;
} else if (direction.equalsIgnoreCase("east")) { } else if (direction.equalsIgnoreCase("east")) {
blockFace = BlockFace.EAST; blockFace = BlockFace.EAST;
} else if (direction.equalsIgnoreCase("south")) { } else if (direction.equalsIgnoreCase("south")) {
blockFace = BlockFace.SOUTH; blockFace = BlockFace.SOUTH;
} else if (direction.equalsIgnoreCase("west")) { } else if (direction.equalsIgnoreCase("west")) {
blockFace = BlockFace.WEST; blockFace = BlockFace.WEST;
} else { } else {
fme.msg(TL.COMMAND_CLAIMLINE_NOTVALID, direction); fme.msg(TL.COMMAND_CLAIMLINE_NOTVALID, direction);
return; return;
} }
final Faction forFaction = this.argAsFaction(2, myFaction); final Faction forFaction = this.argAsFaction(2, myFaction);
Location location = me.getLocation(); Location location = me.getLocation();
// TODO: make this a task like claiming a radius? // TODO: make this a task like claiming a radius?
for (int i = 0; i < amount; i++) { for (int i = 0; i < amount; i++) {
fme.attemptClaim(forFaction, location, true); fme.attemptClaim(forFaction, location, true);
location = location.add(blockFace.getModX() * 16, 0, blockFace.getModZ() * 16); location = location.add(blockFace.getModX() * 16, 0, blockFace.getModZ() * 16);
} }
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_CLAIMLINE_DESCRIPTION; return TL.COMMAND_CLAIMLINE_DESCRIPTION;
} }
} }

View File

@ -10,82 +10,82 @@ 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.optionalArgs.put("", ""); //this.optionalArgs.put("", "");
this.permission = Permission.COLEADER.node; this.permission = Permission.COLEADER.node;
this.disableOnLock = true; this.disableOnLock = true;
senderMustBePlayer = false; senderMustBePlayer = false;
senderMustBeMember = true; senderMustBeMember = true;
senderMustBeModerator = false; senderMustBeModerator = false;
senderMustBeAdmin = true; senderMustBeAdmin = true;
} }
@Override @Override
public void perform() { public void perform() {
FPlayer you = this.argAsBestFPlayerMatch(0); FPlayer you = this.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 : myFaction.getFPlayersWhereRole(Role.NORMAL)) { for (FPlayer player : myFaction.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 : myFaction.getFPlayersWhereRole(Role.MODERATOR)) { for (FPlayer player : myFaction.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);
} }
sendFancyMessage(msg); sendFancyMessage(msg);
return; return;
} }
boolean permAny = Permission.COLEADER_ANY.has(sender, false); boolean permAny = Permission.COLEADER_ANY.has(sender, false);
Faction targetFaction = you.getFaction(); Faction targetFaction = you.getFaction();
if (targetFaction != myFaction && !permAny) { if (targetFaction != myFaction && !permAny) {
msg(TL.COMMAND_MOD_NOTMEMBER, you.describeTo(fme, true)); msg(TL.COMMAND_MOD_NOTMEMBER, you.describeTo(fme, true));
return; return;
} }
if (fme != null && fme.getRole() != Role.LEADER && !permAny) { if (fme != null && fme.getRole() != Role.LEADER && !permAny) {
msg(TL.COMMAND_COLEADER_NOTADMIN); msg(TL.COMMAND_COLEADER_NOTADMIN);
return; return;
} }
if (you == fme && !permAny) { if (you == fme && !permAny) {
msg(TL.COMMAND_COLEADER_SELF); msg(TL.COMMAND_COLEADER_SELF);
return; return;
} }
if (you.getRole() == Role.LEADER) { if (you.getRole() == Role.LEADER) {
msg(TL.COMMAND_COLEADER_TARGETISADMIN); 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));
msg(TL.COMMAND_COLEADER_REVOKES, you.describeTo(fme, true)); msg(TL.COMMAND_COLEADER_REVOKES, you.describeTo(fme, 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));
msg(TL.COMMAND_COLEADER_PROMOTES, you.describeTo(fme, true)); msg(TL.COMMAND_COLEADER_PROMOTES, you.describeTo(fme, true));
} }
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_COLEADER_DESCRIPTION; return TL.COMMAND_COLEADER_DESCRIPTION;
} }
} }

View File

@ -16,234 +16,234 @@ 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.errorOnToManyArgs = false; this.errorOnToManyArgs = false;
this.permission = Permission.CONFIG.node; this.permission = Permission.CONFIG.node;
this.disableOnLock = true; this.disableOnLock = true;
senderMustBePlayer = false; senderMustBePlayer = false;
senderMustBeMember = false; senderMustBeMember = false;
senderMustBeModerator = false; senderMustBeModerator = false;
senderMustBeColeader = false; senderMustBeColeader = false;
senderMustBeAdmin = false; senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform() {
// 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 = this.argAsString(0).toLowerCase(); String field = this.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()) {
msg(TL.COMMAND_CONFIG_NOEXIST, field); msg(TL.COMMAND_CONFIG_NOEXIST, field);
return; return;
} }
String success; String success;
StringBuilder value = new StringBuilder(args.get(1)); StringBuilder value = new StringBuilder(args.get(1));
for (int i = 2; i < args.size(); i++) { for (int i = 2; i < args.size(); i++) {
value.append(' ').append(args.get(i)); value.append(' ').append(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 = this.strAsBool(value.toString()); boolean targetValue = this.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 { try {
int intVal = Integer.parseInt(value.toString()); int intVal = Integer.parseInt(value.toString());
target.setInt(null, intVal); target.setInt(null, intVal);
success = "\"" + fieldName + TL.COMMAND_CONFIG_OPTIONSET.toString() + intVal + "."; success = "\"" + fieldName + TL.COMMAND_CONFIG_OPTIONSET.toString() + intVal + ".";
} catch (NumberFormatException ex) { } catch (NumberFormatException ex) {
sendMessage(TL.COMMAND_CONFIG_INTREQUIRED.format(fieldName)); sendMessage(TL.COMMAND_CONFIG_INTREQUIRED.format(fieldName));
return; return;
} }
} }
// long // long
else if (target.getType() == long.class) { else if (target.getType() == long.class) {
try { try {
long longVal = Long.parseLong(value.toString()); long longVal = Long.parseLong(value.toString());
target.setLong(null, longVal); target.setLong(null, longVal);
success = "\"" + fieldName + TL.COMMAND_CONFIG_OPTIONSET.toString() + longVal + "."; success = "\"" + fieldName + TL.COMMAND_CONFIG_OPTIONSET.toString() + longVal + ".";
} catch (NumberFormatException ex) { } catch (NumberFormatException ex) {
sendMessage(TL.COMMAND_CONFIG_LONGREQUIRED.format(fieldName)); sendMessage(TL.COMMAND_CONFIG_LONGREQUIRED.format(fieldName));
return; return;
} }
} }
// double // double
else if (target.getType() == double.class) { else if (target.getType() == double.class) {
try { try {
double doubleVal = Double.parseDouble(value.toString()); double doubleVal = Double.parseDouble(value.toString());
target.setDouble(null, doubleVal); target.setDouble(null, doubleVal);
success = "\"" + fieldName + TL.COMMAND_CONFIG_OPTIONSET.toString() + doubleVal + "."; success = "\"" + fieldName + TL.COMMAND_CONFIG_OPTIONSET.toString() + doubleVal + ".";
} catch (NumberFormatException ex) { } catch (NumberFormatException ex) {
sendMessage(TL.COMMAND_CONFIG_DOUBLEREQUIRED.format(fieldName)); sendMessage(TL.COMMAND_CONFIG_DOUBLEREQUIRED.format(fieldName));
return; return;
} }
} }
// float // float
else if (target.getType() == float.class) { else if (target.getType() == float.class) {
try { try {
float floatVal = Float.parseFloat(value.toString()); float floatVal = Float.parseFloat(value.toString());
target.setFloat(null, floatVal); target.setFloat(null, floatVal);
success = "\"" + fieldName + TL.COMMAND_CONFIG_OPTIONSET.toString() + floatVal + "."; success = "\"" + fieldName + TL.COMMAND_CONFIG_OPTIONSET.toString() + floatVal + ".";
} catch (NumberFormatException ex) { } catch (NumberFormatException ex) {
sendMessage(TL.COMMAND_CONFIG_FLOATREQUIRED.format(fieldName)); sendMessage(TL.COMMAND_CONFIG_FLOATREQUIRED.format(fieldName));
return; return;
} }
} }
// String // String
else if (target.getType() == String.class) { else if (target.getType() == String.class) {
target.set(null, value.toString()); target.set(null, value.toString());
success = "\"" + fieldName + TL.COMMAND_CONFIG_OPTIONSET.toString() + value + "\"."; success = "\"" + fieldName + TL.COMMAND_CONFIG_OPTIONSET.toString() + value + "\".";
} }
// ChatColor // ChatColor
else if (target.getType() == ChatColor.class) { else if (target.getType() == ChatColor.class) {
ChatColor newColor = null; ChatColor newColor = null;
try { try {
newColor = ChatColor.valueOf(value.toString().toUpperCase()); newColor = ChatColor.valueOf(value.toString().toUpperCase());
} catch (IllegalArgumentException ex) { } catch (IllegalArgumentException ex) {
} }
if (newColor == null) { if (newColor == null) {
sendMessage(TL.COMMAND_CONFIG_INVALID_COLOUR.format(fieldName, value.toString().toUpperCase())); sendMessage(TL.COMMAND_CONFIG_INVALID_COLOUR.format(fieldName, value.toString().toUpperCase()));
return; return;
} }
target.set(null, newColor); target.set(null, newColor);
success = "\"" + fieldName + TL.COMMAND_CONFIG_COLOURSET.toString() + value.toString().toUpperCase() + "\"."; success = "\"" + fieldName + TL.COMMAND_CONFIG_COLOURSET.toString() + value.toString().toUpperCase() + "\".";
} }
// Set<?> or other parameterized collection // Set<?> or other parameterized collection
else if (target.getGenericType() instanceof ParameterizedType) { else if (target.getGenericType() instanceof ParameterizedType) {
ParameterizedType targSet = (ParameterizedType) target.getGenericType(); ParameterizedType targSet = (ParameterizedType) target.getGenericType();
Type innerType = targSet.getActualTypeArguments()[0]; Type innerType = targSet.getActualTypeArguments()[0];
// not a Set, somehow, and that should be the only collection we're using in Conf.java // not a Set, somehow, and that should be the only collection we're using in Conf.java
if (targSet.getRawType() != Set.class) { if (targSet.getRawType() != Set.class) {
sendMessage(TL.COMMAND_CONFIG_INVALID_COLLECTION.format(fieldName)); sendMessage(TL.COMMAND_CONFIG_INVALID_COLLECTION.format(fieldName));
return; return;
} }
// Set<Material> // Set<Material>
else if (innerType == Material.class) { else if (innerType == Material.class) {
Material newMat = null; Material newMat = null;
try { try {
newMat = Material.valueOf(value.toString().toUpperCase()); newMat = Material.valueOf(value.toString().toUpperCase());
} catch (IllegalArgumentException ex) { } catch (IllegalArgumentException ex) {
} }
if (newMat == null) { if (newMat == null) {
sendMessage(TL.COMMAND_CONFIG_INVALID_MATERIAL.format(fieldName, value.toString().toUpperCase())); sendMessage(TL.COMMAND_CONFIG_INVALID_MATERIAL.format(fieldName, value.toString().toUpperCase()));
return; return;
} }
@SuppressWarnings("unchecked") Set<Material> matSet = (Set<Material>) target.get(null); @SuppressWarnings("unchecked") Set<Material> matSet = (Set<Material>) target.get(null);
// Material already present, so remove it // Material already present, so remove it
if (matSet.contains(newMat)) { if (matSet.contains(newMat)) {
matSet.remove(newMat); matSet.remove(newMat);
target.set(null, matSet); target.set(null, matSet);
success = TL.COMMAND_CONFIG_MATERIAL_REMOVED.format(fieldName, value.toString().toUpperCase()); success = TL.COMMAND_CONFIG_MATERIAL_REMOVED.format(fieldName, value.toString().toUpperCase());
} }
// Material not present yet, add it // Material not present yet, add it
else { else {
matSet.add(newMat); matSet.add(newMat);
target.set(null, matSet); target.set(null, matSet);
success = TL.COMMAND_CONFIG_MATERIAL_ADDED.format(fieldName, value.toString().toUpperCase()); success = TL.COMMAND_CONFIG_MATERIAL_ADDED.format(fieldName, value.toString().toUpperCase());
} }
} }
// Set<String> // Set<String>
else if (innerType == String.class) { else if (innerType == String.class) {
@SuppressWarnings("unchecked") Set<String> stringSet = (Set<String>) target.get(null); @SuppressWarnings("unchecked") Set<String> stringSet = (Set<String>) target.get(null);
// String already present, so remove it // String already present, so remove it
if (stringSet.contains(value.toString())) { if (stringSet.contains(value.toString())) {
stringSet.remove(value.toString()); stringSet.remove(value.toString());
target.set(null, stringSet); target.set(null, stringSet);
success = TL.COMMAND_CONFIG_SET_REMOVED.format(fieldName, value.toString()); success = TL.COMMAND_CONFIG_SET_REMOVED.format(fieldName, value.toString());
} }
// String not present yet, add it // String not present yet, add it
else { else {
stringSet.add(value.toString()); stringSet.add(value.toString());
target.set(null, stringSet); target.set(null, stringSet);
success = TL.COMMAND_CONFIG_SET_ADDED.format(fieldName, value.toString()); success = TL.COMMAND_CONFIG_SET_ADDED.format(fieldName, value.toString());
} }
} }
// Set of unknown type // Set of unknown type
else { else {
sendMessage(TL.COMMAND_CONFIG_INVALID_TYPESET.format(fieldName)); sendMessage(TL.COMMAND_CONFIG_INVALID_TYPESET.format(fieldName));
return; return;
} }
} }
// unknown type // unknown type
else { else {
sendMessage(TL.COMMAND_CONFIG_ERROR_TYPE.format(fieldName, target.getClass().getName())); sendMessage(TL.COMMAND_CONFIG_ERROR_TYPE.format(fieldName, target.getClass().getName()));
return; return;
} }
} catch (NoSuchFieldException ex) { } catch (NoSuchFieldException ex) {
sendMessage(TL.COMMAND_CONFIG_ERROR_MATCHING.format(fieldName)); sendMessage(TL.COMMAND_CONFIG_ERROR_MATCHING.format(fieldName));
return; return;
} catch (IllegalAccessException ex) { } catch (IllegalAccessException ex) {
sendMessage(TL.COMMAND_CONFIG_ERROR_SETTING.format(fieldName, value.toString())); sendMessage(TL.COMMAND_CONFIG_ERROR_SETTING.format(fieldName, value.toString()));
return; return;
} }
if (!success.isEmpty()) { if (!success.isEmpty()) {
if (sender instanceof Player) { if (sender instanceof Player) {
sendMessage(success); sendMessage(success);
SavageFactions.plugin.log(success + TL.COMMAND_CONFIG_LOG.format((Player) sender)); SavageFactions.plugin.log(success + TL.COMMAND_CONFIG_LOG.format((Player) sender));
} else // using SavageFactions.plugin.log() instead of sendMessage if run from server console so that "[Factions v#.#.#]" is prepended in server log } else // using SavageFactions.plugin.log() instead of sendMessage if run from server console so that "[Factions v#.#.#]" is prepended in server log
{ {
SavageFactions.plugin.log(success); SavageFactions.plugin.log(success);
} }
} }
// save change to disk // save change to disk
Conf.save(); Conf.save();
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_CONFIG_DESCRIPTION; return TL.COMMAND_CONFIG_DESCRIPTION;
} }
} }

View File

@ -9,39 +9,39 @@ 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.permission = Permission.CONVERT.node; this.permission = Permission.CONVERT.node;
this.requiredArgs.add("[MYSQL|JSON]"); this.requiredArgs.add("[MYSQL|JSON]");
} }
@Override @Override
public void perform() { public void perform() {
if (!(this.sender instanceof ConsoleCommandSender)) { if (!(this.sender instanceof ConsoleCommandSender)) {
this.sender.sendMessage(TL.GENERIC_CONSOLEONLY.toString()); this.sender.sendMessage(TL.GENERIC_CONSOLEONLY.toString());
} }
Backend nb = Backend.valueOf(this.argAsString(0).toUpperCase()); Backend nb = Backend.valueOf(this.argAsString(0).toUpperCase());
if (nb == Conf.backEnd) { if (nb == Conf.backEnd) {
this.sender.sendMessage(TL.COMMAND_CONVERT_BACKEND_RUNNING.toString()); this.sender.sendMessage(TL.COMMAND_CONVERT_BACKEND_RUNNING.toString());
return; return;
} }
switch (nb) { switch (nb) {
case JSON: case JSON:
FactionsJSON.convertTo(); FactionsJSON.convertTo();
break; break;
default: default:
this.sender.sendMessage(TL.COMMAND_CONVERT_BACKEND_INVALID.toString()); this.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,36 +7,36 @@ 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.permission = Permission.COORD.node; this.permission = Permission.COORD.node;
this.disableOnLock = true; this.disableOnLock = true;
senderMustBePlayer = true; senderMustBePlayer = true;
senderMustBeMember = true; senderMustBeMember = true;
senderMustBeModerator = false; senderMustBeModerator = false;
senderMustBeColeader = false; senderMustBeColeader = false;
senderMustBeAdmin = false; senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform() {
Location location = fme.getPlayer().getLocation(); Location location = fme.getPlayer().getLocation();
String message = TL.COMMAND_COORDS_MESSAGE.toString().replace("{player}", fme.getPlayer().getDisplayName()).replace("{x}", (int) location.getX() + "") String message = TL.COMMAND_COORDS_MESSAGE.toString().replace("{player}", fme.getPlayer().getDisplayName()).replace("{x}", (int) location.getX() + "")
.replace("{y}", (int) location.getY() + "").replace("{z}", (int) location.getZ() + "").replace("{world}", location.getWorld().getName()); .replace("{y}", (int) location.getY() + "").replace("{z}", (int) location.getZ() + "").replace("{world}", location.getWorld().getName());
for (FPlayer fPlayer : fme.getFaction().getFPlayers()) { for (FPlayer fPlayer : fme.getFaction().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

@ -14,100 +14,105 @@ 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.optionalArgs.put("", ""); //this.optionalArgs.put("", "");
this.permission = Permission.CREATE.node; this.permission = Permission.CREATE.node;
this.disableOnLock = true; this.disableOnLock = true;
senderMustBePlayer = true; senderMustBePlayer = true;
senderMustBeMember = false; senderMustBeMember = false;
senderMustBeModerator = false; senderMustBeModerator = false;
senderMustBeColeader = false; senderMustBeColeader = false;
senderMustBeAdmin = false; senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform() {
String tag = this.argAsString(0); String tag = this.argAsString(0);
if (fme.hasFaction()) { if (fme.hasFaction()) {
msg(TL.COMMAND_CREATE_MUSTLEAVE); msg(TL.COMMAND_CREATE_MUSTLEAVE);
return; return;
} }
if (Factions.getInstance().isTagTaken(tag)) { if (Factions.getInstance().isTagTaken(tag)) {
msg(TL.COMMAND_CREATE_INUSE); 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) {
sendMessage(tagValidationErrors); 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 (!canAffordCommand(Conf.econCostCreate, TL.COMMAND_CREATE_TOCREATE.toString())) { if (!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(me, tag); FactionCreateEvent createEvent = new FactionCreateEvent(me, 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 (!payForCommand(Conf.econCostCreate, TL.COMMAND_CREATE_TOCREATE, TL.COMMAND_CREATE_FORCREATE)) { if (!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) {
msg(TL.COMMAND_CREATE_ERROR); 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(me), faction, FPlayerJoinEvent.PlayerJoinReason.CREATE); FPlayerJoinEvent joinEvent = new FPlayerJoinEvent(FPlayers.getInstance().getByPlayer(me), 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
fme.setFaction(faction); fme.setFaction(faction);
// 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.
fme.setRole(Role.LEADER); fme.setRole(Role.LEADER);
if (SavageFactions.plugin.getConfig().getBoolean("faction-creation-broadcast", true)) { if (SavageFactions.plugin.getConfig().getBoolean("faction-creation-broadcast", true)) {
for (FPlayer follower : FPlayers.getInstance().getOnlinePlayers()) { for (FPlayer follower : FPlayers.getInstance().getOnlinePlayers()) {
follower.msg(TL.COMMAND_CREATE_CREATED, fme.describeTo(follower, true), faction.getTag(follower)); follower.msg(TL.COMMAND_CREATE_CREATED, fme.describeTo(follower, true), faction.getTag(follower));
} }
} }
msg(TL.COMMAND_CREATE_YOUSHOULD, p.cmdBase.cmdDescription.getUseageTemplate()); msg(TL.COMMAND_CREATE_YOUSHOULD, p.cmdBase.cmdDescription.getUseageTemplate());
if (Conf.logFactionCreate) { if (Conf.logFactionCreate) {
SavageFactions.plugin.log(fme.getName() + TL.COMMAND_CREATE_CREATEDLOG.toString() + tag); SavageFactions.plugin.log(fme.getName() + TL.COMMAND_CREATE_CREATEDLOG.toString() + tag);
} }
if (SavageFactions.plugin.getConfig().getBoolean("fpaypal.Enabled")) { if (SavageFactions.plugin.getConfig().getBoolean("fpaypal.Enabled")) {
this.fme.msg(TL.COMMAND_PAYPALSET_CREATED); this.fme.msg(TL.COMMAND_PAYPALSET_CREATED);
} }
} if (Conf.useCustomDefaultPermissions) {
faction.setDefaultPerms();
if (Conf.usePermissionHints)
this.fme.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

@ -13,62 +13,62 @@ 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.optionalArgs.put("", ""); //this.optionalArgs.put("", "");
this.permission = Permission.DEINVITE.node; this.permission = Permission.DEINVITE.node;
this.disableOnLock = true; this.disableOnLock = true;
senderMustBePlayer = true; senderMustBePlayer = true;
senderMustBeMember = false; senderMustBeMember = false;
senderMustBeModerator = true; senderMustBeModerator = true;
senderMustBeColeader = false; senderMustBeColeader = false;
senderMustBeAdmin = false; senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform() {
FPlayer you = this.argAsBestFPlayerMatch(0); FPlayer you = this.argAsBestFPlayerMatch(0);
if (!fme.isAdminBypassing()) { if (!fme.isAdminBypassing()) {
Access access = myFaction.getAccess(fme, PermissableAction.INVITE); Access access = myFaction.getAccess(fme, PermissableAction.INVITE);
if (access != Access.ALLOW && fme.getRole() != Role.LEADER) { if (access != Access.ALLOW && fme.getRole() != Role.LEADER) {
fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "manage invites"); fme.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 : myFaction.getInvites()) { for (String id : myFaction.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);
} }
sendFancyMessage(msg); sendFancyMessage(msg);
return; return;
} }
if (you.getFaction() == myFaction) { if (you.getFaction() == myFaction) {
msg(TL.COMMAND_DEINVITE_ALREADYMEMBER, you.getName(), myFaction.getTag()); msg(TL.COMMAND_DEINVITE_ALREADYMEMBER, you.getName(), myFaction.getTag());
msg(TL.COMMAND_DEINVITE_MIGHTWANT, p.cmdBase.cmdKick.getUseageTemplate(false)); msg(TL.COMMAND_DEINVITE_MIGHTWANT, p.cmdBase.cmdKick.getUseageTemplate(false));
return; return;
} }
myFaction.deinvite(you); myFaction.deinvite(you);
you.msg(TL.COMMAND_DEINVITE_REVOKED, fme.describeTo(you), myFaction.describeTo(you)); you.msg(TL.COMMAND_DEINVITE_REVOKED, fme.describeTo(you), myFaction.describeTo(you));
myFaction.msg(TL.COMMAND_DEINVITE_REVOKES, fme.describeTo(myFaction), you.describeTo(myFaction)); myFaction.msg(TL.COMMAND_DEINVITE_REVOKES, fme.describeTo(myFaction), you.describeTo(myFaction));
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_DEINVITE_DESCRIPTION; return TL.COMMAND_DEINVITE_DESCRIPTION;
} }
} }

View File

@ -7,39 +7,39 @@ 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.senderMustBeMember = true; this.senderMustBeMember = true;
this.senderMustBeModerator = true; this.senderMustBeModerator = true;
this.senderMustBePlayer = true; this.senderMustBePlayer = true;
this.permission = Permission.SETWARP.node; this.permission = Permission.SETWARP.node;
} }
@Override @Override
public void perform() { public void perform() {
String warp = argAsString(0); String warp = argAsString(0);
if (myFaction.isWarp(warp)) { if (myFaction.isWarp(warp)) {
if (!transact(fme)) { if (!transact(fme)) {
return; return;
} }
myFaction.removeWarp(warp); myFaction.removeWarp(warp);
fme.msg(TL.COMMAND_DELFWARP_DELETED, warp); fme.msg(TL.COMMAND_DELFWARP_DELETED, warp);
} else { } else {
fme.msg(TL.COMMAND_DELFWARP_INVALID, warp); fme.msg(TL.COMMAND_DELFWARP_INVALID, warp);
} }
} }
private boolean transact(FPlayer player) { private boolean transact(FPlayer player) {
return !SavageFactions.plugin.getConfig().getBoolean("warp-cost.enabled", false) || player.isAdminBypassing() || payForCommand(SavageFactions.plugin.getConfig().getDouble("warp-cost.delwarp", 5), TL.COMMAND_DELFWARP_TODELETE.toString(), TL.COMMAND_DELFWARP_FORDELETE.toString()); return !SavageFactions.plugin.getConfig().getBoolean("warp-cost.enabled", false) || player.isAdminBypassing() || payForCommand(SavageFactions.plugin.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

@ -2,8 +2,8 @@ package com.massivecraft.factions.cmd;
public class CmdDemote extends FPromoteCommand { public class CmdDemote extends FPromoteCommand {
public CmdDemote() { public CmdDemote() {
aliases.add("demote"); aliases.add("demote");
this.relative = -1; this.relative = -1;
} }
} }

View File

@ -9,53 +9,53 @@ 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.errorOnToManyArgs = false; this.errorOnToManyArgs = false;
//this.optionalArgs //this.optionalArgs
this.permission = Permission.DESCRIPTION.node; this.permission = Permission.DESCRIPTION.node;
this.disableOnLock = true; this.disableOnLock = true;
senderMustBePlayer = true; senderMustBePlayer = true;
senderMustBeMember = false; senderMustBeMember = false;
senderMustBeModerator = false; senderMustBeModerator = false;
senderMustBeColeader = true; senderMustBeColeader = true;
senderMustBeAdmin = false; senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform() {
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
if (!payForCommand(Conf.econCostDesc, TL.COMMAND_DESCRIPTION_TOCHANGE, TL.COMMAND_DESCRIPTION_FORCHANGE)) { if (!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.
myFaction.setDescription(TextUtil.implode(args, " ").replaceAll("%", "").replaceAll("(&([a-f0-9klmnor]))", "& $2")); myFaction.setDescription(TextUtil.implode(args, " ").replaceAll("%", "").replaceAll("(&([a-f0-9klmnor]))", "& $2"));
if (!Conf.broadcastDescriptionChanges) { if (!Conf.broadcastDescriptionChanges) {
fme.msg(TL.COMMAND_DESCRIPTION_CHANGED, myFaction.describeTo(fme)); fme.msg(TL.COMMAND_DESCRIPTION_CHANGED, myFaction.describeTo(fme));
fme.sendMessage(myFaction.getDescription()); fme.sendMessage(myFaction.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, myFaction.describeTo(fplayer)); fplayer.msg(TL.COMMAND_DESCRIPTION_CHANGES, myFaction.describeTo(fplayer));
fplayer.sendMessage(myFaction.getDescription()); // players can inject "&" or "`" or "<i>" or whatever in their description; &k is particularly interesting looking fplayer.sendMessage(myFaction.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

@ -16,99 +16,99 @@ 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.requiredArgs.add(""); //this.requiredArgs.add("");
this.optionalArgs.put("faction tag", "yours"); this.optionalArgs.put("faction tag", "yours");
this.permission = Permission.DISBAND.node; this.permission = Permission.DISBAND.node;
this.disableOnLock = true; this.disableOnLock = true;
senderMustBePlayer = false; senderMustBePlayer = false;
senderMustBeMember = false; senderMustBeMember = false;
senderMustBeModerator = false; senderMustBeModerator = false;
senderMustBeColeader = false; senderMustBeColeader = false;
senderMustBeAdmin = false; senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform() {
// The faction, default to your own.. but null if console sender. // The faction, default to your own.. but null if console sender.
Faction faction = this.argAsFaction(0, fme == null ? null : myFaction); Faction faction = this.argAsFaction(0, fme == null ? null : myFaction);
if (faction == null) { if (faction == null) {
return; return;
} }
boolean isMyFaction = fme != null && faction == myFaction; boolean isMyFaction = fme != null && faction == myFaction;
if (isMyFaction) { if (isMyFaction) {
if (!assertMinRole(Role.LEADER)) { if (!assertMinRole(Role.LEADER)) {
return; return;
} }
} else { } else {
if (!Permission.DISBAND_ANY.has(sender, true)) { if (!Permission.DISBAND_ANY.has(sender, true)) {
return; return;
} }
} }
if (!fme.isAdminBypassing()) { if (!fme.isAdminBypassing()) {
Access access = faction.getAccess(fme, PermissableAction.DISBAND); Access access = faction.getAccess(fme, PermissableAction.DISBAND);
if (fme.getRole() != Role.LEADER && faction.getFPlayerLeader() != fme && access != Access.ALLOW) { if (fme.getRole() != Role.LEADER && faction.getFPlayerLeader() != fme && access != Access.ALLOW) {
fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "disband " + faction.getTag()); fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "disband " + faction.getTag());
return; return;
} }
} }
if (!faction.isNormal()) { if (!faction.isNormal()) {
msg(TL.COMMAND_DISBAND_IMMUTABLE.toString()); msg(TL.COMMAND_DISBAND_IMMUTABLE.toString());
return; return;
} }
if (faction.isPermanent()) { if (faction.isPermanent()) {
msg(TL.COMMAND_DISBAND_MARKEDPERMANENT.toString()); msg(TL.COMMAND_DISBAND_MARKEDPERMANENT.toString());
return; return;
} }
// check for tnt before disbanding. // check for tnt before disbanding.
if (!disbandMap.containsKey(me.getUniqueId().toString()) && faction.getTnt() > 0) { if (!disbandMap.containsKey(me.getUniqueId().toString()) && faction.getTnt() > 0) {
msg(TL.COMMAND_DISBAND_CONFIRM.toString().replace("{tnt}", faction.getTnt() + "")); msg(TL.COMMAND_DISBAND_CONFIRM.toString().replace("{tnt}", faction.getTnt() + ""));
disbandMap.put(me.getUniqueId().toString(), faction.getId()); disbandMap.put(me.getUniqueId().toString(), faction.getId());
Bukkit.getScheduler().scheduleSyncDelayedTask(SavageFactions.plugin, new Runnable() { Bukkit.getScheduler().scheduleSyncDelayedTask(SavageFactions.plugin, new Runnable() {
@Override @Override
public void run() { public void run() {
disbandMap.remove(me.getUniqueId().toString()); disbandMap.remove(me.getUniqueId().toString());
} }
}, 200L); }, 200L);
} else if (faction.getId().equals(disbandMap.get(me.getUniqueId().toString())) || faction.getTnt() == 0) { } else if (faction.getId().equals(disbandMap.get(me.getUniqueId().toString())) || faction.getTnt() == 0) {
if (SavageFactions.plugin.getConfig().getBoolean("faction-disband-broadcast", true)) { if (SavageFactions.plugin.getConfig().getBoolean("faction-disband-broadcast", true)) {
for (FPlayer follower : FPlayers.getInstance().getOnlinePlayers()) { for (FPlayer follower : FPlayers.getInstance().getOnlinePlayers()) {
String amountString = senderIsConsole ? TL.GENERIC_SERVERADMIN.toString() : fme.describeTo(follower); String amountString = senderIsConsole ? TL.GENERIC_SERVERADMIN.toString() : fme.describeTo(follower);
UtilFly.checkFly(this.fme, Board.getInstance().getFactionAt(new FLocation(follower))); UtilFly.checkFly(this.fme, 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(me, PlayerDisbandReason.COMMAND); faction.disband(me, PlayerDisbandReason.COMMAND);
} else { } else {
faction.disband(me, PlayerDisbandReason.COMMAND); faction.disband(me, PlayerDisbandReason.COMMAND);
me.sendMessage(String.valueOf(TL.COMMAND_DISBAND_PLAYER)); me.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

@ -16,78 +16,78 @@ 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.permission = Permission.WARP.node; this.permission = Permission.WARP.node;
this.senderMustBeMember = true; this.senderMustBeMember = true;
this.senderMustBeModerator = false; this.senderMustBeModerator = false;
} }
@Override @Override
public void perform() { public void perform() {
//TODO: check if in combat. //TODO: check if in combat.
if (!fme.isAdminBypassing()) { if (!fme.isAdminBypassing()) {
Access access = myFaction.getAccess(fme, PermissableAction.WARP); Access access = myFaction.getAccess(fme, PermissableAction.WARP);
if (access != Access.ALLOW && fme.getRole() != Role.LEADER) { if (access != Access.ALLOW && fme.getRole() != Role.LEADER) {
fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "use warps"); fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "use warps");
return; return;
} }
} }
if (args.size() == 0) { if (args.size() == 0) {
WarpGUI warpGUI = new WarpGUI(fme); WarpGUI warpGUI = new WarpGUI(fme);
warpGUI.build(); warpGUI.build();
me.openInventory(warpGUI.getInventory()); me.openInventory(warpGUI.getInventory());
} else if (args.size() > 2) { } else if (args.size() > 2) {
fme.msg(TL.COMMAND_FWARP_COMMANDFORMAT); fme.msg(TL.COMMAND_FWARP_COMMANDFORMAT);
} else { } else {
final String warpName = argAsString(0); final String warpName = argAsString(0);
final String passwordAttempt = argAsString(1); final String passwordAttempt = argAsString(1);
if (myFaction.isWarp(argAsString(0))) { if (myFaction.isWarp(argAsString(0))) {
// Check if requires password and if so, check if valid. CASE SENSITIVE // Check if requires password and if so, check if valid. CASE SENSITIVE
if (myFaction.hasWarpPassword(warpName) && !myFaction.isWarpPassword(warpName, passwordAttempt)) { if (myFaction.hasWarpPassword(warpName) && !myFaction.isWarpPassword(warpName, passwordAttempt)) {
fme.msg(TL.COMMAND_FWARP_INVALID_PASSWORD); fme.msg(TL.COMMAND_FWARP_INVALID_PASSWORD);
return; return;
} }
// Check transaction AFTER password check. // Check transaction AFTER password check.
if (!transact(fme)) { if (!transact(fme)) {
return; return;
} }
final FPlayer fPlayer = fme; final FPlayer fPlayer = fme;
final UUID uuid = fme.getPlayer().getUniqueId(); final UUID uuid = fme.getPlayer().getUniqueId();
this.doWarmUp(WarmUpUtil.Warmup.WARP, TL.WARMUPS_NOTIFY_TELEPORT, warpName, new Runnable() { this.doWarmUp(WarmUpUtil.Warmup.WARP, TL.WARMUPS_NOTIFY_TELEPORT, warpName, new Runnable() {
@Override @Override
public void run() { public void run() {
Player player = Bukkit.getPlayer(uuid); Player player = Bukkit.getPlayer(uuid);
if (player != null) { if (player != null) {
player.teleport(fPlayer.getFaction().getWarp(warpName).getLocation()); player.teleport(fPlayer.getFaction().getWarp(warpName).getLocation());
fPlayer.msg(TL.COMMAND_FWARP_WARPED, warpName); fPlayer.msg(TL.COMMAND_FWARP_WARPED, warpName);
} }
} }
}, this.p.getConfig().getLong("warmups.f-warp", 0)); }, this.p.getConfig().getLong("warmups.f-warp", 0));
} else { } else {
fme.msg(TL.COMMAND_FWARP_INVALID_WARP, warpName); fme.msg(TL.COMMAND_FWARP_INVALID_WARP, warpName);
} }
} }
} }
private boolean transact(FPlayer player) { private boolean transact(FPlayer player) {
return !SavageFactions.plugin.getConfig().getBoolean("warp-cost.enabled", false) || player.isAdminBypassing() || payForCommand(SavageFactions.plugin.getConfig().getDouble("warp-cost.warp", 5), TL.COMMAND_FWARP_TOWARP.toString(), TL.COMMAND_FWARP_FORWARPING.toString()); return !SavageFactions.plugin.getConfig().getBoolean("warp-cost.enabled", false) || player.isAdminBypassing() || payForCommand(SavageFactions.plugin.getConfig().getDouble("warp-cost.warp", 5), TL.COMMAND_FWARP_TOWARP.toString(), TL.COMMAND_FWARP_FORWARPING.toString());
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_FWARP_DESCRIPTION; return TL.COMMAND_FWARP_DESCRIPTION;
} }
} }

View File

@ -22,230 +22,230 @@ 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.permission = Permission.FLY.node; this.permission = Permission.FLY.node;
this.senderMustBeMember = true; this.senderMustBeMember = true;
this.senderMustBeModerator = false; this.senderMustBeModerator = false;
} }
public static void startParticles() { public static void startParticles() {
// Just a secondary check. // Just a secondary check.
if (!SavageFactions.plugin.getConfig().getBoolean("ffly.Particles.Enabled")) { if (!SavageFactions.plugin.getConfig().getBoolean("ffly.Particles.Enabled")) {
return; return;
} }
id = Bukkit.getScheduler().scheduleSyncRepeatingTask(SavageFactions.plugin, new Runnable() { id = Bukkit.getScheduler().scheduleSyncRepeatingTask(SavageFactions.plugin, new Runnable() {
@Override @Override
public void run() { public void run() {
for (String name : flyMap.keySet()) { for (String name : flyMap.keySet()) {
Player player = Bukkit.getPlayer(name); Player player = Bukkit.getPlayer(name);
if (player == null) { if (player == null) {
continue; continue;
} }
if (!player.isFlying()) { if (!player.isFlying()) {
continue; continue;
} }
if (!SavageFactions.plugin.mc17) { if (!SavageFactions.plugin.mc17) {
if (player.getGameMode() == GameMode.SPECTATOR) { if (player.getGameMode() == GameMode.SPECTATOR) {
continue; continue;
} }
} }
if (FPlayers.getInstance().getByPlayer(player).isVanished()) { if (FPlayers.getInstance().getByPlayer(player).isVanished()) {
// Actually, vanished players (such as admins) should not display particles to prevent others from knowing their vanished assistance for moderation. // Actually, vanished players (such as admins) should not display particles to prevent others from knowing their vanished assistance for moderation.
// But we can keep it as a config. // But we can keep it as a config.
if (SavageFactions.plugin.getConfig().getBoolean("ffly.Particles.Enable-While-Vanished")) { if (SavageFactions.plugin.getConfig().getBoolean("ffly.Particles.Enable-While-Vanished")) {
return; return;
} }
continue; continue;
} }
if (SavageFactions.plugin.useNonPacketParticles) { if (SavageFactions.plugin.useNonPacketParticles) {
// 1.9+ based servers will use the built in particleAPI instead of packet based. // 1.9+ based servers will use the built in particleAPI instead of packet based.
// any particle amount higher than 0 made them go everywhere, and the offset at 0 was not working. // any particle amount higher than 0 made them go everywhere, and the offset at 0 was not working.
// So setting the amount to 0 spawns 1 in the precise location // So setting the amount to 0 spawns 1 in the precise location
player.getWorld().spawnParticle(Particle.CLOUD, player.getLocation().add(0, -0.35, 0), 0); player.getWorld().spawnParticle(Particle.CLOUD, player.getLocation().add(0, -0.35, 0), 0);
} else { } else {
ParticleEffect.CLOUD.display((float) 0, (float) 0, (float) 0, (float) 0, 3, player.getLocation().add(0, -0.35, 0), 16); ParticleEffect.CLOUD.display((float) 0, (float) 0, (float) 0, (float) 0, 3, player.getLocation().add(0, -0.35, 0), 16);
} }
} }
if (flyMap.keySet().size() == 0) { if (flyMap.keySet().size() == 0) {
Bukkit.getScheduler().cancelTask(id); Bukkit.getScheduler().cancelTask(id);
id = -1; id = -1;
} }
} }
}, 10L, 3L); }, 10L, 3L);
} }
public static void startFlyCheck() { public static void startFlyCheck() {
flyid = Bukkit.getScheduler().scheduleSyncRepeatingTask(SavageFactions.plugin, new Runnable() { flyid = Bukkit.getScheduler().scheduleSyncRepeatingTask(SavageFactions.plugin, new Runnable() {
@Override @Override
public void run() throws ConcurrentModificationException { //threw the exception for now, until I recode fly :( Cringe. public void run() throws ConcurrentModificationException { //threw the exception for now, until I recode fly :( Cringe.
checkTaskState(); checkTaskState();
if (flyMap.keySet().size() != 0) { if (flyMap.keySet().size() != 0) {
for (String name : flyMap.keySet()) { for (String name : flyMap.keySet()) {
if (name == null) { if (name == null) {
continue; continue;
} }
Player player = Bukkit.getPlayer(name); Player player = Bukkit.getPlayer(name);
if (player == null) { if (player == null) {
continue; continue;
} }
if (!player.isFlying()) { if (!player.isFlying()) {
continue; continue;
} }
FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player); FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player);
if (fPlayer == null) { if (fPlayer == null) {
continue; continue;
} }
if (player.getGameMode() == GameMode.CREATIVE) { if (player.getGameMode() == GameMode.CREATIVE) {
continue; continue;
} }
if (!SavageFactions.plugin.mc17 && player.getGameMode() == GameMode.SPECTATOR) { if (!SavageFactions.plugin.mc17 && player.getGameMode() == GameMode.SPECTATOR) {
continue; continue;
} }
Faction myFaction = fPlayer.getFaction(); Faction myFaction = fPlayer.getFaction();
if (myFaction.isWilderness()) { if (myFaction.isWilderness()) {
fPlayer.setFlying(false); fPlayer.setFlying(false);
flyMap.remove(name); flyMap.remove(name);
continue; continue;
} }
if (fPlayer.checkIfNearbyEnemies()) { if (fPlayer.checkIfNearbyEnemies()) {
continue; continue;
} }
FLocation myFloc = new FLocation(player.getLocation()); FLocation myFloc = new FLocation(player.getLocation());
Faction toFac = Board.getInstance().getFactionAt(myFloc); Faction toFac = Board.getInstance().getFactionAt(myFloc);
if (Board.getInstance().getFactionAt(myFloc) != myFaction) { if (Board.getInstance().getFactionAt(myFloc) != myFaction) {
if (!checkBypassPerms(fPlayer, player, toFac)) { if (!checkBypassPerms(fPlayer, player, toFac)) {
fPlayer.setFlying(false); fPlayer.setFlying(false);
flyMap.remove(name); flyMap.remove(name);
continue; continue;
} }
} }
} }
} }
} }
}, 20L, 20L); }, 20L, 20L);
} }
private static boolean checkBypassPerms(FPlayer fme, Player me, Faction toFac) { private static boolean checkBypassPerms(FPlayer fme, Player me, Faction toFac) {
if (toFac != fme.getFaction()) { if (toFac != fme.getFaction()) {
if (!me.hasPermission("factions.fly.wilderness") && toFac.isWilderness() || !me.hasPermission("factions.fly.safezone") && toFac.isSafeZone() || !me.hasPermission("factions.fly.warzone") && toFac.isWarZone()) { if (!me.hasPermission("factions.fly.wilderness") && toFac.isWilderness() || !me.hasPermission("factions.fly.safezone") && toFac.isSafeZone() || !me.hasPermission("factions.fly.warzone") && toFac.isWarZone()) {
fme.msg(TL.COMMAND_FLY_NO_ACCESS, toFac.getTag(fme)); fme.msg(TL.COMMAND_FLY_NO_ACCESS, toFac.getTag(fme));
return false; return false;
} }
Access access = toFac.getAccess(fme, PermissableAction.FLY); Access access = toFac.getAccess(fme, PermissableAction.FLY);
if ((!(me.hasPermission("factions.fly.enemy") || access == Access.ALLOW)) && toFac.getRelationTo(fme.getFaction()) == Relation.ENEMY) { 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)); fme.msg(TL.COMMAND_FLY_NO_ACCESS, toFac.getTag(fme));
return false; return false;
} }
if (!(me.hasPermission("factions.fly.ally") || access == Access.ALLOW) && toFac.getRelationTo(fme.getFaction()) == Relation.ALLY) { 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)); fme.msg(TL.COMMAND_FLY_NO_ACCESS, toFac.getTag(fme));
return false; return false;
} }
if (!(me.hasPermission("factions.fly.truce") || access == Access.ALLOW) && toFac.getRelationTo(fme.getFaction()) == Relation.TRUCE) { 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)); fme.msg(TL.COMMAND_FLY_NO_ACCESS, toFac.getTag(fme));
return false; return false;
} }
if (!(me.hasPermission("factions.fly.neutral") || access == Access.ALLOW) && toFac.getRelationTo(fme.getFaction()) == Relation.NEUTRAL && !isSystemFaction(toFac)) { 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)); fme.msg(TL.COMMAND_FLY_NO_ACCESS, toFac.getTag(fme));
return false; return false;
} }
return me.hasPermission("factions.fly") && access != Access.DENY; return me.hasPermission("factions.fly") && access != Access.DENY;
} }
return true; return true;
} }
public static Boolean isSystemFaction(Faction faction) { public static Boolean isSystemFaction(Faction faction) {
return faction.isSafeZone() || return faction.isSafeZone() ||
faction.isWarZone() || faction.isWarZone() ||
faction.isWilderness(); faction.isWilderness();
} }
public static void checkTaskState() { public static void checkTaskState() {
if (flyMap.keySet().size() == 0) { if (flyMap.keySet().size() == 0) {
Bukkit.getScheduler().cancelTask(flyid); Bukkit.getScheduler().cancelTask(flyid);
flyid = -1; flyid = -1;
} }
} }
public boolean isInFlightChecker(Player player) { public boolean isInFlightChecker(Player player) {
return flyMap.containsKey(player.getName()); return flyMap.containsKey(player.getName());
} }
@Override @Override
public void perform() { public void perform() {
// Disabled by default. // Disabled by default.
if (!SavageFactions.plugin.getConfig().getBoolean("enable-faction-flight", false)) { if (!SavageFactions.plugin.getConfig().getBoolean("enable-faction-flight", false)) {
fme.msg(TL.COMMAND_FLY_DISABLED); fme.msg(TL.COMMAND_FLY_DISABLED);
return; return;
} }
FLocation myfloc = new FLocation(me.getLocation()); FLocation myfloc = new FLocation(me.getLocation());
Faction toFac = Board.getInstance().getFactionAt(myfloc); Faction toFac = Board.getInstance().getFactionAt(myfloc);
if (!checkBypassPerms(fme, me, toFac)) return; if (!checkBypassPerms(fme, me, toFac)) return;
List<Entity> entities = this.me.getNearbyEntities(16.0D, 256.0D, 16.0D); List<Entity> entities = this.me.getNearbyEntities(16.0D, 256.0D, 16.0D);
for (int i = 0; i <= entities.size() - 1; ++i) { for (int i = 0; i <= entities.size() - 1; ++i) {
if (entities.get(i) instanceof Player) { if (entities.get(i) instanceof Player) {
Player eplayer = (Player) entities.get(i); Player eplayer = (Player) entities.get(i);
FPlayer efplayer = FPlayers.getInstance().getByPlayer(eplayer); FPlayer efplayer = FPlayers.getInstance().getByPlayer(eplayer);
if (efplayer.getRelationTo(this.fme) == Relation.ENEMY && !efplayer.isStealthEnabled()) { if (efplayer.getRelationTo(this.fme) == Relation.ENEMY && !efplayer.isStealthEnabled()) {
this.fme.msg(TL.COMMAND_FLY_CHECK_ENEMY); this.fme.msg(TL.COMMAND_FLY_CHECK_ENEMY);
return; return;
} }
} }
} }
if (args.size() == 0) { if (args.size() == 0) {
toggleFlight(!fme.isFlying(), me); toggleFlight(!fme.isFlying(), me);
} else if (args.size() == 1) { } else if (args.size() == 1) {
toggleFlight(argAsBool(0), me); toggleFlight(argAsBool(0), me);
} }
} }
private void toggleFlight(final boolean toggle, final Player player) { private void toggleFlight(final boolean toggle, final Player player) {
if (!toggle) { if (!toggle) {
fme.setFlying(false); fme.setFlying(false);
flyMap.remove(player.getName()); flyMap.remove(player.getName());
return; return;
} }
if (fme.canFlyAtLocation()) if (fme.canFlyAtLocation())
this.doWarmUp(WarmUpUtil.Warmup.FLIGHT, TL.WARMUPS_NOTIFY_FLIGHT, "Fly", new Runnable() { this.doWarmUp(WarmUpUtil.Warmup.FLIGHT, TL.WARMUPS_NOTIFY_FLIGHT, "Fly", new Runnable() {
@Override @Override
public void run() { public void run() {
fme.setFlying(true); fme.setFlying(true);
flyMap.put(player.getName(), true); flyMap.put(player.getName(), true);
if (id == -1) { if (id == -1) {
if (SavageFactions.plugin.getConfig().getBoolean("ffly.Particles.Enabled")) { if (SavageFactions.plugin.getConfig().getBoolean("ffly.Particles.Enabled")) {
startParticles(); startParticles();
} }
} }
if (flyid == -1) { if (flyid == -1) {
startFlyCheck(); startFlyCheck();
} }
} }
}, this.p.getConfig().getLong("warmups.f-fly", 0)); }, this.p.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,48 +7,48 @@ import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
public class CmdFocus public class CmdFocus
extends FCommand { extends FCommand {
public CmdFocus() { public CmdFocus() {
aliases.add("focus"); aliases.add("focus");
requiredArgs.add("player"); requiredArgs.add("player");
permission = Permission.FOCUS.node; permission = Permission.FOCUS.node;
senderMustBePlayer = true; senderMustBePlayer = true;
senderMustBeMember = false; senderMustBeMember = false;
senderMustBeModerator = true; senderMustBeModerator = true;
senderMustBeColeader = false; senderMustBeColeader = false;
senderMustBeAdmin = false; senderMustBeAdmin = false;
} }
public void perform() { public void perform() {
if (!SavageFactions.plugin.getConfig().getBoolean("ffocus.Enabled")) { if (!SavageFactions.plugin.getConfig().getBoolean("ffocus.Enabled")) {
fme.msg(TL.GENERIC_DISABLED); fme.msg(TL.GENERIC_DISABLED);
return; return;
} }
FPlayer target = argAsFPlayer(0); FPlayer target = argAsFPlayer(0);
if (target == null) { if (target == null) {
return; return;
} }
if (target.getFaction().getId().equalsIgnoreCase(myFaction.getId())) { if (target.getFaction().getId().equalsIgnoreCase(myFaction.getId())) {
fme.msg(TL.COMMAND_FOCUS_SAMEFACTION); fme.msg(TL.COMMAND_FOCUS_SAMEFACTION);
return; return;
} }
if ((myFaction.getFocused() != null) && (myFaction.getFocused().equalsIgnoreCase(target.getName()))) { if ((myFaction.getFocused() != null) && (myFaction.getFocused().equalsIgnoreCase(target.getName()))) {
myFaction.setFocused(null); myFaction.setFocused(null);
myFaction.msg(TL.COMMAND_FOCUS_NO_LONGER, target.getName()); myFaction.msg(TL.COMMAND_FOCUS_NO_LONGER, target.getName());
FTeamWrapper.updatePrefixes(target.getFaction()); FTeamWrapper.updatePrefixes(target.getFaction());
return; return;
} }
myFaction.msg(TL.COMMAND_FOCUS_FOCUSING, target.getName()); myFaction.msg(TL.COMMAND_FOCUS_FOCUSING, target.getName());
myFaction.setFocused(target.getName()); myFaction.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,70 +9,70 @@ 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.permission = Permission.GETVAULT.node; this.permission = Permission.GETVAULT.node;
this.disableOnLock = true; this.disableOnLock = true;
senderMustBePlayer = true; senderMustBePlayer = true;
senderMustBeMember = true; senderMustBeMember = true;
senderMustBeModerator = false; senderMustBeModerator = false;
senderMustBeColeader = false; senderMustBeColeader = false;
senderMustBeAdmin = false; senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform() {
if (!SavageFactions.plugin.getConfig().getBoolean("fvault.Enabled")) { if (!SavageFactions.plugin.getConfig().getBoolean("fvault.Enabled")) {
fme.sendMessage("This command is disabled!"); fme.sendMessage("This command is disabled!");
return; return;
} }
Location vaultLocation = fme.getFaction().getVault(); Location vaultLocation = fme.getFaction().getVault();
ItemStack vault = SavageFactions.plugin.createItem(Material.CHEST, 1, (short) 0, SavageFactions.plugin.color(SavageFactions.plugin.getConfig().getString("fvault.Item.Name")), SavageFactions.plugin.colorList(SavageFactions.plugin.getConfig().getStringList("fvault.Item.Lore"))); ItemStack vault = SavageFactions.plugin.createItem(Material.CHEST, 1, (short) 0, SavageFactions.plugin.color(SavageFactions.plugin.getConfig().getString("fvault.Item.Name")), SavageFactions.plugin.colorList(SavageFactions.plugin.getConfig().getStringList("fvault.Item.Lore")));
//check if vault is set //check if vault is set
if (vaultLocation != null) { if (vaultLocation != null) {
fme.msg(TL.COMMAND_GETVAULT_ALREADYSET); fme.msg(TL.COMMAND_GETVAULT_ALREADYSET);
return; return;
} }
//has enough money? //has enough money?
int amount = SavageFactions.plugin.getConfig().getInt("fvault.Price"); int amount = SavageFactions.plugin.getConfig().getInt("fvault.Price");
if (!fme.hasMoney(amount)) { if (!fme.hasMoney(amount)) {
return; return;
} }
//success :) //success :)
fme.takeMoney(amount); fme.takeMoney(amount);
me.getInventory().addItem(vault); me.getInventory().addItem(vault);
fme.msg(TL.COMMAND_GETVAULT_RECEIVE); fme.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,207 +13,207 @@ 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.permission = Permission.HELP.node; this.permission = Permission.HELP.node;
this.disableOnLock = false; this.disableOnLock = false;
senderMustBePlayer = false; senderMustBePlayer = false;
senderMustBeMember = false; senderMustBeMember = false;
senderMustBeModerator = false; senderMustBeModerator = false;
senderMustBeColeader = false; senderMustBeColeader = false;
senderMustBeAdmin = false; senderMustBeAdmin = false;
} }
//----------------------------------------------// //----------------------------------------------//
// Build the help pages // Build the help pages
//----------------------------------------------// //----------------------------------------------//
@Override @Override
public void perform() { public void perform() {
if (SavageFactions.plugin.getConfig().getBoolean("use-old-help", true)) { if (SavageFactions.plugin.getConfig().getBoolean("use-old-help", true)) {
if (helpPages == null) { if (helpPages == null) {
updateHelp(); updateHelp();
} }
int page = this.argAsInt(0, 1); int page = this.argAsInt(0, 1);
sendMessage(p.txt.titleize("Factions Help (" + page + "/" + helpPages.size() + ")")); sendMessage(p.txt.titleize("Factions Help (" + page + "/" + helpPages.size() + ")"));
page -= 1; page -= 1;
if (page < 0 || page >= helpPages.size()) { if (page < 0 || page >= helpPages.size()) {
msg(TL.COMMAND_HELP_404.format(String.valueOf(page))); msg(TL.COMMAND_HELP_404.format(String.valueOf(page)));
return; return;
} }
sendMessage(helpPages.get(page)); sendMessage(helpPages.get(page));
return; return;
} }
ConfigurationSection help = SavageFactions.plugin.getConfig().getConfigurationSection("help"); ConfigurationSection help = SavageFactions.plugin.getConfig().getConfigurationSection("help");
if (help == null) { if (help == null) {
help = SavageFactions.plugin.getConfig().createSection("help"); // create new help section help = SavageFactions.plugin.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 = this.argAsString(0, "1"); String pageArg = this.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()) {
msg(TL.COMMAND_HELP_404.format(pageArg)); msg(TL.COMMAND_HELP_404.format(pageArg));
return; return;
} }
for (String helpLine : page) { for (String helpLine : page) {
sendMessage(SavageFactions.plugin.txt.parse(helpLine)); sendMessage(SavageFactions.plugin.txt.parse(helpLine));
} }
} }
public void updateHelp() { public void updateHelp() {
helpPages = new ArrayList<>(); helpPages = new ArrayList<>();
ArrayList<String> pageLines; ArrayList<String> pageLines;
pageLines = new ArrayList<>(); pageLines = new ArrayList<>();
pageLines.add(p.cmdBase.cmdHelp.getUseageTemplate(true)); pageLines.add(p.cmdBase.cmdHelp.getUseageTemplate(true));
pageLines.add(p.cmdBase.cmdList.getUseageTemplate(true)); pageLines.add(p.cmdBase.cmdList.getUseageTemplate(true));
pageLines.add(p.cmdBase.cmdShow.getUseageTemplate(true)); pageLines.add(p.cmdBase.cmdShow.getUseageTemplate(true));
pageLines.add(p.cmdBase.cmdPower.getUseageTemplate(true)); pageLines.add(p.cmdBase.cmdPower.getUseageTemplate(true));
pageLines.add(p.cmdBase.cmdJoin.getUseageTemplate(true)); pageLines.add(p.cmdBase.cmdJoin.getUseageTemplate(true));
pageLines.add(p.cmdBase.cmdLeave.getUseageTemplate(true)); pageLines.add(p.cmdBase.cmdLeave.getUseageTemplate(true));
pageLines.add(p.cmdBase.cmdChat.getUseageTemplate(true)); pageLines.add(p.cmdBase.cmdChat.getUseageTemplate(true));
pageLines.add(p.cmdBase.cmdToggleAllianceChat.getUseageTemplate(true)); pageLines.add(p.cmdBase.cmdToggleAllianceChat.getUseageTemplate(true));
pageLines.add(p.cmdBase.cmdHome.getUseageTemplate(true)); pageLines.add(p.cmdBase.cmdHome.getUseageTemplate(true));
pageLines.add(p.txt.parse(TL.COMMAND_HELP_NEXTCREATE.toString())); pageLines.add(p.txt.parse(TL.COMMAND_HELP_NEXTCREATE.toString()));
helpPages.add(pageLines); helpPages.add(pageLines);
pageLines = new ArrayList<>(); pageLines = new ArrayList<>();
pageLines.add(p.cmdBase.cmdCreate.getUseageTemplate(true)); pageLines.add(p.cmdBase.cmdCreate.getUseageTemplate(true));
pageLines.add(p.cmdBase.cmdDescription.getUseageTemplate(true)); pageLines.add(p.cmdBase.cmdDescription.getUseageTemplate(true));
pageLines.add(p.cmdBase.cmdTag.getUseageTemplate(true)); pageLines.add(p.cmdBase.cmdTag.getUseageTemplate(true));
pageLines.add(p.txt.parse(TL.COMMAND_HELP_INVITATIONS.toString())); pageLines.add(p.txt.parse(TL.COMMAND_HELP_INVITATIONS.toString()));
pageLines.add(p.cmdBase.cmdOpen.getUseageTemplate(true)); pageLines.add(p.cmdBase.cmdOpen.getUseageTemplate(true));
pageLines.add(p.cmdBase.cmdInvite.getUseageTemplate(true)); pageLines.add(p.cmdBase.cmdInvite.getUseageTemplate(true));
pageLines.add(p.cmdBase.cmdDeinvite.getUseageTemplate(true)); pageLines.add(p.cmdBase.cmdDeinvite.getUseageTemplate(true));
pageLines.add(p.txt.parse(TL.COMMAND_HELP_HOME.toString())); pageLines.add(p.txt.parse(TL.COMMAND_HELP_HOME.toString()));
pageLines.add(p.cmdBase.cmdSethome.getUseageTemplate(true)); pageLines.add(p.cmdBase.cmdSethome.getUseageTemplate(true));
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(p.txt.parse(TL.COMMAND_HELP_BANK_1.toString())); pageLines.add(p.txt.parse(TL.COMMAND_HELP_BANK_1.toString()));
pageLines.add(p.txt.parse(TL.COMMAND_HELP_BANK_2.toString())); pageLines.add(p.txt.parse(TL.COMMAND_HELP_BANK_2.toString()));
pageLines.add(p.txt.parse(TL.COMMAND_HELP_BANK_3.toString())); pageLines.add(p.txt.parse(TL.COMMAND_HELP_BANK_3.toString()));
pageLines.add(""); pageLines.add("");
pageLines.add(p.cmdBase.cmdMoney.getUseageTemplate(true)); pageLines.add(p.cmdBase.cmdMoney.getUseageTemplate(true));
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(p.cmdBase.cmdClaim.getUseageTemplate(true)); pageLines.add(p.cmdBase.cmdClaim.getUseageTemplate(true));
pageLines.add(p.cmdBase.cmdAutoClaim.getUseageTemplate(true)); pageLines.add(p.cmdBase.cmdAutoClaim.getUseageTemplate(true));
pageLines.add(p.cmdBase.cmdUnclaim.getUseageTemplate(true)); pageLines.add(p.cmdBase.cmdUnclaim.getUseageTemplate(true));
pageLines.add(p.cmdBase.cmdUnclaimall.getUseageTemplate(true)); pageLines.add(p.cmdBase.cmdUnclaimall.getUseageTemplate(true));
pageLines.add(p.cmdBase.cmdKick.getUseageTemplate(true)); pageLines.add(p.cmdBase.cmdKick.getUseageTemplate(true));
pageLines.add(p.cmdBase.cmdMod.getUseageTemplate(true)); pageLines.add(p.cmdBase.cmdMod.getUseageTemplate(true));
pageLines.add(p.cmdBase.cmdAdmin.getUseageTemplate(true)); pageLines.add(p.cmdBase.cmdAdmin.getUseageTemplate(true));
pageLines.add(p.cmdBase.cmdTitle.getUseageTemplate(true)); pageLines.add(p.cmdBase.cmdTitle.getUseageTemplate(true));
pageLines.add(p.cmdBase.cmdSB.getUseageTemplate(true)); pageLines.add(p.cmdBase.cmdSB.getUseageTemplate(true));
pageLines.add(p.cmdBase.cmdSeeChunk.getUseageTemplate(true)); pageLines.add(p.cmdBase.cmdSeeChunk.getUseageTemplate(true));
pageLines.add(p.cmdBase.cmdStatus.getUseageTemplate(true)); pageLines.add(p.cmdBase.cmdStatus.getUseageTemplate(true));
pageLines.add(p.txt.parse(TL.COMMAND_HELP_PLAYERTITLES.toString())); pageLines.add(p.txt.parse(TL.COMMAND_HELP_PLAYERTITLES.toString()));
helpPages.add(pageLines); helpPages.add(pageLines);
pageLines = new ArrayList<>(); pageLines = new ArrayList<>();
pageLines.add(p.cmdBase.cmdMap.getUseageTemplate(true)); pageLines.add(p.cmdBase.cmdMap.getUseageTemplate(true));
pageLines.add(p.cmdBase.cmdBoom.getUseageTemplate(true)); pageLines.add(p.cmdBase.cmdBoom.getUseageTemplate(true));
pageLines.add(p.cmdBase.cmdOwner.getUseageTemplate(true)); pageLines.add(p.cmdBase.cmdOwner.getUseageTemplate(true));
pageLines.add(p.cmdBase.cmdOwnerList.getUseageTemplate(true)); pageLines.add(p.cmdBase.cmdOwnerList.getUseageTemplate(true));
pageLines.add(p.txt.parse(TL.COMMAND_HELP_OWNERSHIP_1.toString())); pageLines.add(p.txt.parse(TL.COMMAND_HELP_OWNERSHIP_1.toString()));
pageLines.add(p.txt.parse(TL.COMMAND_HELP_OWNERSHIP_2.toString())); pageLines.add(p.txt.parse(TL.COMMAND_HELP_OWNERSHIP_2.toString()));
pageLines.add(p.txt.parse(TL.COMMAND_HELP_OWNERSHIP_3.toString())); pageLines.add(p.txt.parse(TL.COMMAND_HELP_OWNERSHIP_3.toString()));
helpPages.add(pageLines); helpPages.add(pageLines);
pageLines = new ArrayList<>(); pageLines = new ArrayList<>();
pageLines.add(p.cmdBase.cmdDisband.getUseageTemplate(true)); pageLines.add(p.cmdBase.cmdDisband.getUseageTemplate(true));
pageLines.add(""); pageLines.add("");
pageLines.add(p.cmdBase.cmdRelationAlly.getUseageTemplate(true)); pageLines.add(p.cmdBase.cmdRelationAlly.getUseageTemplate(true));
pageLines.add(p.cmdBase.cmdRelationNeutral.getUseageTemplate(true)); pageLines.add(p.cmdBase.cmdRelationNeutral.getUseageTemplate(true));
pageLines.add(p.cmdBase.cmdRelationEnemy.getUseageTemplate(true)); pageLines.add(p.cmdBase.cmdRelationEnemy.getUseageTemplate(true));
pageLines.add(p.txt.parse(TL.COMMAND_HELP_RELATIONS_1.toString())); pageLines.add(p.txt.parse(TL.COMMAND_HELP_RELATIONS_1.toString()));
pageLines.add(p.txt.parse(TL.COMMAND_HELP_RELATIONS_2.toString())); pageLines.add(p.txt.parse(TL.COMMAND_HELP_RELATIONS_2.toString()));
pageLines.add(p.txt.parse(TL.COMMAND_HELP_RELATIONS_3.toString())); pageLines.add(p.txt.parse(TL.COMMAND_HELP_RELATIONS_3.toString()));
pageLines.add(p.txt.parse(TL.COMMAND_HELP_RELATIONS_4.toString())); pageLines.add(p.txt.parse(TL.COMMAND_HELP_RELATIONS_4.toString()));
helpPages.add(pageLines); helpPages.add(pageLines);
pageLines = new ArrayList<>(); pageLines = new ArrayList<>();
pageLines.add(p.txt.parse(TL.COMMAND_HELP_RELATIONS_5.toString())); pageLines.add(p.txt.parse(TL.COMMAND_HELP_RELATIONS_5.toString()));
pageLines.add(p.txt.parse(TL.COMMAND_HELP_RELATIONS_6.toString())); pageLines.add(p.txt.parse(TL.COMMAND_HELP_RELATIONS_6.toString()));
pageLines.add(p.txt.parse(TL.COMMAND_HELP_RELATIONS_7.toString())); pageLines.add(p.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(p.txt.parse(TL.COMMAND_HELP_RELATIONS_9.toString())); pageLines.add(p.txt.parse(TL.COMMAND_HELP_RELATIONS_9.toString()));
pageLines.add(p.txt.parse(TL.COMMAND_HELP_RELATIONS_10.toString())); pageLines.add(p.txt.parse(TL.COMMAND_HELP_RELATIONS_10.toString()));
pageLines.add(p.txt.parse(TL.COMMAND_HELP_RELATIONS_11.toString())); pageLines.add(p.txt.parse(TL.COMMAND_HELP_RELATIONS_11.toString()));
pageLines.add(p.txt.parse(TL.COMMAND_HELP_RELATIONS_12.toString())); pageLines.add(p.txt.parse(TL.COMMAND_HELP_RELATIONS_12.toString()));
pageLines.add(p.txt.parse(TL.COMMAND_HELP_RELATIONS_13.toString())); pageLines.add(p.txt.parse(TL.COMMAND_HELP_RELATIONS_13.toString()));
helpPages.add(pageLines); helpPages.add(pageLines);
pageLines = new ArrayList<>(); pageLines = new ArrayList<>();
pageLines.add(p.txt.parse(TL.COMMAND_HELP_PERMISSIONS_1.toString())); pageLines.add(p.txt.parse(TL.COMMAND_HELP_PERMISSIONS_1.toString()));
pageLines.add(p.txt.parse(TL.COMMAND_HELP_PERMISSIONS_2.toString())); pageLines.add(p.txt.parse(TL.COMMAND_HELP_PERMISSIONS_2.toString()));
pageLines.add(p.txt.parse(TL.COMMAND_HELP_PERMISSIONS_3.toString())); pageLines.add(p.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(p.txt.parse(TL.COMMAND_HELP_PERMISSIONS_5.toString())); pageLines.add(p.txt.parse(TL.COMMAND_HELP_PERMISSIONS_5.toString()));
pageLines.add(p.txt.parse(TL.COMMAND_HELP_PERMISSIONS_6.toString())); pageLines.add(p.txt.parse(TL.COMMAND_HELP_PERMISSIONS_6.toString()));
pageLines.add(p.txt.parse(TL.COMMAND_HELP_PERMISSIONS_7.toString())); pageLines.add(p.txt.parse(TL.COMMAND_HELP_PERMISSIONS_7.toString()));
pageLines.add(p.txt.parse(TL.COMMAND_HELP_PERMISSIONS_8.toString())); pageLines.add(p.txt.parse(TL.COMMAND_HELP_PERMISSIONS_8.toString()));
pageLines.add(p.txt.parse(TL.COMMAND_HELP_PERMISSIONS_9.toString())); pageLines.add(p.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(p.cmdBase.cmdBypass.getUseageTemplate(true)); pageLines.add(p.cmdBase.cmdBypass.getUseageTemplate(true));
pageLines.add(p.txt.parse(TL.COMMAND_HELP_ADMIN_1.toString())); pageLines.add(p.txt.parse(TL.COMMAND_HELP_ADMIN_1.toString()));
pageLines.add(p.txt.parse(TL.COMMAND_HELP_ADMIN_2.toString())); pageLines.add(p.txt.parse(TL.COMMAND_HELP_ADMIN_2.toString()));
pageLines.add(p.txt.parse(TL.COMMAND_HELP_ADMIN_3.toString())); pageLines.add(p.txt.parse(TL.COMMAND_HELP_ADMIN_3.toString()));
pageLines.add(p.cmdBase.cmdSafeunclaimall.getUseageTemplate(true)); pageLines.add(p.cmdBase.cmdSafeunclaimall.getUseageTemplate(true));
pageLines.add(p.cmdBase.cmdWarunclaimall.getUseageTemplate(true)); pageLines.add(p.cmdBase.cmdWarunclaimall.getUseageTemplate(true));
//TODO:TL //TODO:TL
pageLines.add(p.txt.parse("<i>Note: " + p.cmdBase.cmdUnclaim.getUseageTemplate(false) + SavageFactions.plugin.txt.parse("<i>") + " works on safe/war zones as well.")); pageLines.add(p.txt.parse("<i>Note: " + p.cmdBase.cmdUnclaim.getUseageTemplate(false) + SavageFactions.plugin.txt.parse("<i>") + " works on safe/war zones as well."));
pageLines.add(p.cmdBase.cmdPeaceful.getUseageTemplate(true)); pageLines.add(p.cmdBase.cmdPeaceful.getUseageTemplate(true));
helpPages.add(pageLines); helpPages.add(pageLines);
pageLines = new ArrayList<>(); pageLines = new ArrayList<>();
pageLines.add(p.txt.parse(TL.COMMAND_HELP_MOAR_2.toString())); pageLines.add(p.txt.parse(TL.COMMAND_HELP_MOAR_2.toString()));
pageLines.add(p.cmdBase.cmdChatSpy.getUseageTemplate(true)); pageLines.add(p.cmdBase.cmdChatSpy.getUseageTemplate(true));
pageLines.add(p.cmdBase.cmdPermanent.getUseageTemplate(true)); pageLines.add(p.cmdBase.cmdPermanent.getUseageTemplate(true));
pageLines.add(p.cmdBase.cmdPermanentPower.getUseageTemplate(true)); pageLines.add(p.cmdBase.cmdPermanentPower.getUseageTemplate(true));
pageLines.add(p.cmdBase.cmdPowerBoost.getUseageTemplate(true)); pageLines.add(p.cmdBase.cmdPowerBoost.getUseageTemplate(true));
pageLines.add(p.cmdBase.cmdConfig.getUseageTemplate(true)); pageLines.add(p.cmdBase.cmdConfig.getUseageTemplate(true));
helpPages.add(pageLines); helpPages.add(pageLines);
pageLines = new ArrayList<>(); pageLines = new ArrayList<>();
pageLines.add(p.txt.parse(TL.COMMAND_HELP_MOAR_3.toString())); pageLines.add(p.txt.parse(TL.COMMAND_HELP_MOAR_3.toString()));
pageLines.add(p.cmdBase.cmdLock.getUseageTemplate(true)); pageLines.add(p.cmdBase.cmdLock.getUseageTemplate(true));
pageLines.add(p.cmdBase.cmdReload.getUseageTemplate(true)); pageLines.add(p.cmdBase.cmdReload.getUseageTemplate(true));
pageLines.add(p.cmdBase.cmdSaveAll.getUseageTemplate(true)); pageLines.add(p.cmdBase.cmdSaveAll.getUseageTemplate(true));
pageLines.add(p.cmdBase.cmdVersion.getUseageTemplate(true)); pageLines.add(p.cmdBase.cmdVersion.getUseageTemplate(true));
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,130 +20,130 @@ 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.requiredArgs.add(""); //this.requiredArgs.add("");
//this.optionalArgs.put("", ""); //this.optionalArgs.put("", "");
this.permission = Permission.HOME.node; this.permission = Permission.HOME.node;
this.disableOnLock = false; this.disableOnLock = false;
senderMustBePlayer = true; senderMustBePlayer = true;
senderMustBeMember = true; senderMustBeMember = true;
senderMustBeModerator = false; senderMustBeModerator = false;
senderMustBeColeader = false; senderMustBeColeader = false;
senderMustBeAdmin = false; senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform() {
// TODO: Hide this command on help also. // TODO: Hide this command on help also.
if (!Conf.homesEnabled) { if (!Conf.homesEnabled) {
fme.msg(TL.COMMAND_HOME_DISABLED); fme.msg(TL.COMMAND_HOME_DISABLED);
return; return;
} }
if (!Conf.homesTeleportCommandEnabled) { if (!Conf.homesTeleportCommandEnabled) {
fme.msg(TL.COMMAND_HOME_TELEPORTDISABLED); fme.msg(TL.COMMAND_HOME_TELEPORTDISABLED);
return; return;
} }
if (!fme.isAdminBypassing()) { if (!fme.isAdminBypassing()) {
Access access = myFaction.getAccess(fme, PermissableAction.HOME); Access access = myFaction.getAccess(fme, PermissableAction.HOME);
if (access != Access.ALLOW && fme.getRole() != Role.LEADER) { if (access != Access.ALLOW && fme.getRole() != Role.LEADER) {
fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "teleport home"); fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "teleport home");
return; return;
} }
} }
if (!myFaction.hasHome()) { if (!myFaction.hasHome()) {
fme.msg(TL.COMMAND_HOME_NOHOME.toString() + (fme.getRole().value < Role.MODERATOR.value ? TL.GENERIC_ASKYOURLEADER.toString() : TL.GENERIC_YOUSHOULD.toString())); fme.msg(TL.COMMAND_HOME_NOHOME.toString() + (fme.getRole().value < Role.MODERATOR.value ? TL.GENERIC_ASKYOURLEADER.toString() : TL.GENERIC_YOUSHOULD.toString()));
fme.sendMessage(p.cmdBase.cmdSethome.getUseageTemplate()); fme.sendMessage(p.cmdBase.cmdSethome.getUseageTemplate());
return; return;
} }
if (!Conf.homesTeleportAllowedFromEnemyTerritory && fme.isInEnemyTerritory()) { if (!Conf.homesTeleportAllowedFromEnemyTerritory && fme.isInEnemyTerritory()) {
fme.msg(TL.COMMAND_HOME_INENEMY); fme.msg(TL.COMMAND_HOME_INENEMY);
return; return;
} }
if (!Conf.homesTeleportAllowedFromDifferentWorld && me.getWorld().getUID() != myFaction.getHome().getWorld().getUID()) { if (!Conf.homesTeleportAllowedFromDifferentWorld && me.getWorld().getUID() != myFaction.getHome().getWorld().getUID()) {
fme.msg(TL.COMMAND_HOME_WRONGWORLD); fme.msg(TL.COMMAND_HOME_WRONGWORLD);
return; return;
} }
Faction faction = Board.getInstance().getFactionAt(new FLocation(me.getLocation())); Faction faction = Board.getInstance().getFactionAt(new FLocation(me.getLocation()));
final Location loc = me.getLocation().clone(); final Location loc = me.getLocation().clone();
// if player is not in a safe zone or their own faction territory, only allow teleport if no enemies are nearby // if player is not in a safe zone or their own faction territory, only allow teleport if no enemies are nearby
if (Conf.homesTeleportAllowedEnemyDistance > 0 && if (Conf.homesTeleportAllowedEnemyDistance > 0 &&
!faction.isSafeZone() && !faction.isSafeZone() &&
(!fme.isInOwnTerritory() || (fme.isInOwnTerritory() && !Conf.homesTeleportIgnoreEnemiesIfInOwnTerritory))) { (!fme.isInOwnTerritory() || (fme.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 : me.getServer().getOnlinePlayers()) { for (Player p : me.getServer().getOnlinePlayers()) {
if (p == null || !p.isOnline() || p.isDead() || p == me || p.getWorld() != w) { if (p == null || !p.isOnline() || p.isDead() || p == me || p.getWorld() != w) {
continue; continue;
} }
FPlayer fp = FPlayers.getInstance().getByPlayer(p); FPlayer fp = FPlayers.getInstance().getByPlayer(p);
if (fme.getRelationTo(fp) != Relation.ENEMY || fp.isVanished()) { if (fme.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;
} }
fme.msg(TL.COMMAND_HOME_ENEMYNEAR, String.valueOf(Conf.homesTeleportAllowedEnemyDistance)); fme.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 (!payForCommand(Conf.econCostHome, TL.COMMAND_HOME_TOTELEPORT.toString(), TL.COMMAND_HOME_FORTELEPORT.toString())) { if (!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(me, myFaction.getHome())) { if (Essentials.handleTeleport(me, myFaction.getHome())) {
return; return;
} }
this.doWarmUp(WarmUpUtil.Warmup.HOME, TL.WARMUPS_NOTIFY_TELEPORT, "Home", new Runnable() { this.doWarmUp(WarmUpUtil.Warmup.HOME, TL.WARMUPS_NOTIFY_TELEPORT, "Home", new Runnable() {
@Override @Override
public void run() { public void run() {
// 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(CmdHome.this.myFaction.getHome()); smokeLocations.add(CmdHome.this.myFaction.getHome());
smokeLocations.add(CmdHome.this.myFaction.getHome().clone().add(0, 1, 0)); smokeLocations.add(CmdHome.this.myFaction.getHome().clone().add(0, 1, 0));
SmokeUtil.spawnCloudRandom(smokeLocations, Conf.homesTeleportCommandSmokeEffectThickness); SmokeUtil.spawnCloudRandom(smokeLocations, Conf.homesTeleportCommandSmokeEffectThickness);
} }
CmdHome.this.me.teleport(CmdHome.this.myFaction.getHome()); CmdHome.this.me.teleport(CmdHome.this.myFaction.getHome());
} }
}, this.p.getConfig().getLong("warmups.f-home", 0)); }, this.p.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,37 +4,37 @@ 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.permission = Permission.INSPECT.node; this.permission = Permission.INSPECT.node;
this.disableOnLock = true; this.disableOnLock = true;
senderMustBePlayer = true; senderMustBePlayer = true;
senderMustBeMember = true; senderMustBeMember = true;
senderMustBeModerator = false; senderMustBeModerator = false;
senderMustBeColeader = false; senderMustBeColeader = false;
senderMustBeAdmin = false; senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform() {
if (fme.isInspectMode()) { if (fme.isInspectMode()) {
fme.setInspectMode(false); fme.setInspectMode(false);
msg(TL.COMMAND_INSPECT_DISABLED_MSG); msg(TL.COMMAND_INSPECT_DISABLED_MSG);
} else { } else {
fme.setInspectMode(true); fme.setInspectMode(true);
msg(TL.COMMAND_INSPECT_ENABLED); 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

@ -12,83 +12,83 @@ 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.optionalArgs.put("", ""); //this.optionalArgs.put("", "");
this.permission = Permission.INVITE.node; this.permission = Permission.INVITE.node;
this.disableOnLock = true; this.disableOnLock = true;
senderMustBePlayer = true; senderMustBePlayer = true;
senderMustBeMember = false; senderMustBeMember = false;
senderMustBeModerator = false; senderMustBeModerator = false;
senderMustBeColeader = false; senderMustBeColeader = false;
senderMustBeAdmin = false; senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform() {
FPlayer target = this.argAsBestFPlayerMatch(0); FPlayer target = this.argAsBestFPlayerMatch(0);
if (target == null) { if (target == null) {
return; return;
} }
if (target.getFaction() == myFaction) { if (target.getFaction() == myFaction) {
msg(TL.COMMAND_INVITE_ALREADYMEMBER, target.getName(), myFaction.getTag()); msg(TL.COMMAND_INVITE_ALREADYMEMBER, target.getName(), myFaction.getTag());
msg(TL.GENERIC_YOUMAYWANT.toString() + p.cmdBase.cmdKick.getUseageTemplate(false)); msg(TL.GENERIC_YOUMAYWANT.toString() + p.cmdBase.cmdKick.getUseageTemplate(false));
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 (!payForCommand(Conf.econCostInvite, TL.COMMAND_INVITE_TOINVITE.toString(), TL.COMMAND_INVITE_FORINVITE.toString())) { if (!payForCommand(Conf.econCostInvite, TL.COMMAND_INVITE_TOINVITE.toString(), TL.COMMAND_INVITE_FORINVITE.toString())) {
return; return;
} }
if (!fme.isAdminBypassing()) { if (!fme.isAdminBypassing()) {
Access access = myFaction.getAccess(fme, PermissableAction.INVITE); Access access = myFaction.getAccess(fme, PermissableAction.INVITE);
if (access != Access.ALLOW && fme.getRole() != Role.LEADER) { if (access != Access.ALLOW && fme.getRole() != Role.LEADER) {
fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "manage invites"); fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "manage invites");
return; return;
} }
} }
if (myFaction.isInvited(target)) { if (myFaction.isInvited(target)) {
fme.msg(TL.COMMAND_INVITE_ALREADYINVITED, target.getName()); fme.msg(TL.COMMAND_INVITE_ALREADYINVITED, target.getName());
return; return;
} }
if (myFaction.isBanned(target)) { if (myFaction.isBanned(target)) {
fme.msg(TL.COMMAND_INVITE_BANNED, target.getName()); fme.msg(TL.COMMAND_INVITE_BANNED, target.getName());
return; return;
} }
myFaction.invite(target); myFaction.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(fme.describeTo(target, true)) FancyMessage message = new FancyMessage(fme.describeTo(target, true))
.tooltip(TL.COMMAND_INVITE_CLICKTOJOIN.toString()) .tooltip(TL.COMMAND_INVITE_CLICKTOJOIN.toString())
.command("/" + Conf.baseCommandAliases.get(0) + " join " + myFaction.getTag()) .command("/" + Conf.baseCommandAliases.get(0) + " join " + myFaction.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 " + myFaction.getTag()) .command("/" + Conf.baseCommandAliases.get(0) + " join " + myFaction.getTag())
.then(myFaction.describeTo(target)).tooltip(TL.COMMAND_INVITE_CLICKTOJOIN.toString()) .then(myFaction.describeTo(target)).tooltip(TL.COMMAND_INVITE_CLICKTOJOIN.toString())
.command("/" + Conf.baseCommandAliases.get(0) + " join " + myFaction.getTag()); .command("/" + Conf.baseCommandAliases.get(0) + " join " + myFaction.getTag());
message.send(target.getPlayer()); message.send(target.getPlayer());
} }
myFaction.msg(TL.COMMAND_INVITE_INVITED, fme.describeTo(myFaction, true), target.describeTo(myFaction)); myFaction.msg(TL.COMMAND_INVITE_INVITED, fme.describeTo(myFaction, true), target.describeTo(myFaction));
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_INVITE_DESCRIPTION; return TL.COMMAND_INVITE_DESCRIPTION;
} }
} }

View File

@ -8,120 +8,120 @@ 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.permission = Permission.JOIN.node; this.permission = Permission.JOIN.node;
this.disableOnLock = true; this.disableOnLock = true;
senderMustBePlayer = true; senderMustBePlayer = true;
senderMustBeMember = false; senderMustBeMember = false;
senderMustBeModerator = false; senderMustBeModerator = false;
senderMustBeColeader = false; senderMustBeColeader = false;
senderMustBeAdmin = false; senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform() {
Faction faction = this.argAsFaction(0); Faction faction = this.argAsFaction(0);
if (faction == null) { if (faction == null) {
return; return;
} }
FPlayer fplayer = this.argAsBestFPlayerMatch(1, fme, false); FPlayer fplayer = this.argAsBestFPlayerMatch(1, fme, false);
boolean samePlayer = fplayer == fme; boolean samePlayer = fplayer == fme;
if (!samePlayer && !Permission.JOIN_OTHERS.has(sender, false)) { if (!samePlayer && !Permission.JOIN_OTHERS.has(sender, false)) {
msg(TL.COMMAND_JOIN_CANNOTFORCE); msg(TL.COMMAND_JOIN_CANNOTFORCE);
return; return;
} }
if (!faction.isNormal()) { if (!faction.isNormal()) {
msg(TL.COMMAND_JOIN_SYSTEMFACTION); msg(TL.COMMAND_JOIN_SYSTEMFACTION);
return; return;
} }
if (faction == fplayer.getFaction()) { if (faction == fplayer.getFaction()) {
//TODO:TL //TODO:TL
msg(TL.COMMAND_JOIN_ALREADYMEMBER, fplayer.describeTo(fme, true), (samePlayer ? "are" : "is"), faction.getTag(fme)); msg(TL.COMMAND_JOIN_ALREADYMEMBER, fplayer.describeTo(fme, true), (samePlayer ? "are" : "is"), faction.getTag(fme));
return; return;
} }
if (Conf.factionMemberLimit > 0 && faction.getFPlayers().size() >= Conf.factionMemberLimit) { if (Conf.factionMemberLimit > 0 && faction.getFPlayers().size() >= Conf.factionMemberLimit) {
msg(TL.COMMAND_JOIN_ATLIMIT, faction.getTag(fme), Conf.factionMemberLimit, fplayer.describeTo(fme, false)); msg(TL.COMMAND_JOIN_ATLIMIT, faction.getTag(fme), Conf.factionMemberLimit, fplayer.describeTo(fme, false));
return; return;
} }
if (fplayer.hasFaction()) { if (fplayer.hasFaction()) {
//TODO:TL //TODO:TL
msg(TL.COMMAND_JOIN_INOTHERFACTION, fplayer.describeTo(fme, true), (samePlayer ? "your" : "their")); msg(TL.COMMAND_JOIN_INOTHERFACTION, fplayer.describeTo(fme, true), (samePlayer ? "your" : "their"));
return; return;
} }
if (!Conf.canLeaveWithNegativePower && fplayer.getPower() < 0) { if (!Conf.canLeaveWithNegativePower && fplayer.getPower() < 0) {
msg(TL.COMMAND_JOIN_NEGATIVEPOWER, fplayer.describeTo(fme, true)); msg(TL.COMMAND_JOIN_NEGATIVEPOWER, fplayer.describeTo(fme, true));
return; return;
} }
if (!(faction.getOpen() || faction.isInvited(fplayer) || fme.isAdminBypassing() || Permission.JOIN_ANY.has(sender, false))) { if (!(faction.getOpen() || faction.isInvited(fplayer) || fme.isAdminBypassing() || Permission.JOIN_ANY.has(sender, false))) {
msg(TL.COMMAND_JOIN_REQUIRESINVITATION); 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;
} }
// 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 && !canAffordCommand(Conf.econCostJoin, TL.COMMAND_JOIN_TOJOIN.toString())) { if (samePlayer && !canAffordCommand(Conf.econCostJoin, TL.COMMAND_JOIN_TOJOIN.toString())) {
return; return;
} }
// Check for ban // Check for ban
if (!fme.isAdminBypassing() && faction.isBanned(fme)) { if (!fme.isAdminBypassing() && faction.isBanned(fme)) {
fme.msg(TL.COMMAND_JOIN_BANNED, faction.getTag(fme)); fme.msg(TL.COMMAND_JOIN_BANNED, faction.getTag(fme));
return; return;
} }
// trigger the join event (cancellable) // trigger the join event (cancellable)
FPlayerJoinEvent joinEvent = new FPlayerJoinEvent(FPlayers.getInstance().getByPlayer(me), faction, FPlayerJoinEvent.PlayerJoinReason.COMMAND); FPlayerJoinEvent joinEvent = new FPlayerJoinEvent(FPlayers.getInstance().getByPlayer(me), 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 && !payForCommand(Conf.econCostJoin, TL.COMMAND_JOIN_TOJOIN.toString(), TL.COMMAND_JOIN_FORJOIN.toString())) { if (samePlayer && !payForCommand(Conf.econCostJoin, TL.COMMAND_JOIN_TOJOIN.toString(), TL.COMMAND_JOIN_FORJOIN.toString())) {
return; return;
} }
fme.msg(TL.COMMAND_JOIN_SUCCESS, fplayer.describeTo(fme, true), faction.getTag(fme)); fme.msg(TL.COMMAND_JOIN_SUCCESS, fplayer.describeTo(fme, true), faction.getTag(fme));
if (!samePlayer) { if (!samePlayer) {
fplayer.msg(TL.COMMAND_JOIN_MOVED, fme.describeTo(fplayer, true), faction.getTag(fplayer)); fplayer.msg(TL.COMMAND_JOIN_MOVED, fme.describeTo(fplayer, true), faction.getTag(fplayer));
} }
faction.msg(TL.COMMAND_JOIN_JOINED, fplayer.describeTo(faction, true)); faction.msg(TL.COMMAND_JOIN_JOINED, fplayer.describeTo(faction, true));
fplayer.resetFactionData(); fplayer.resetFactionData();
fplayer.setFaction(faction); fplayer.setFaction(faction);
faction.deinvite(fplayer); faction.deinvite(fplayer);
fme.setRole(faction.getDefaultRole()); fme.setRole(faction.getDefaultRole());
if (Conf.logFactionJoin) { if (Conf.logFactionJoin) {
if (samePlayer) { if (samePlayer) {
SavageFactions.plugin.log(TL.COMMAND_JOIN_JOINEDLOG.toString(), fplayer.getName(), faction.getTag()); SavageFactions.plugin.log(TL.COMMAND_JOIN_JOINEDLOG.toString(), fplayer.getName(), faction.getTag());
} else { } else {
SavageFactions.plugin.log(TL.COMMAND_JOIN_MOVEDLOG.toString(), fme.getName(), fplayer.getName(), faction.getTag()); SavageFactions.plugin.log(TL.COMMAND_JOIN_MOVEDLOG.toString(), fme.getName(), fplayer.getName(), faction.getTag());
} }
} }
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_JOIN_DESCRIPTION; return TL.COMMAND_JOIN_DESCRIPTION;
} }
} }

View File

@ -16,125 +16,125 @@ import org.bukkit.ChatColor;
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.optionalArgs.put("", ""); //this.optionalArgs.put("", "");
this.permission = Permission.KICK.node; this.permission = Permission.KICK.node;
this.disableOnLock = false; this.disableOnLock = false;
senderMustBePlayer = true; senderMustBePlayer = true;
senderMustBeMember = false; senderMustBeMember = false;
senderMustBeModerator = false; senderMustBeModerator = false;
senderMustBeAdmin = false; senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform() {
FPlayer toKick = this.argIsSet(0) ? this.argAsBestFPlayerMatch(0) : null; FPlayer toKick = this.argIsSet(0) ? this.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 : myFaction.getFPlayersWhereRole(Role.NORMAL)) { for (FPlayer player : myFaction.getFPlayersWhereRole(Role.NORMAL)) {
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.WHITE).tooltip(TL.COMMAND_KICK_CLICKTOKICK.toString() + s).command("/" + Conf.baseCommandAliases.get(0) + " kick " + s);
} }
if (fme.getRole().isAtLeast(Role.COLEADER)) { if (fme.getRole().isAtLeast(Role.COLEADER)) {
// For both coleader and admin, add mods. // For both coleader and admin, add mods.
for (FPlayer player : myFaction.getFPlayersWhereRole(Role.MODERATOR)) { for (FPlayer player : myFaction.getFPlayersWhereRole(Role.MODERATOR)) {
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.GRAY).tooltip(TL.COMMAND_KICK_CLICKTOKICK.toString() + s).command("/" + Conf.baseCommandAliases.get(0) + " kick " + s);
} }
if (fme.getRole() == Role.LEADER) { if (fme.getRole() == Role.LEADER) {
// Only add coleader to this for the leader. // Only add coleader to this for the leader.
for (FPlayer player : myFaction.getFPlayersWhereRole(Role.COLEADER)) { for (FPlayer player : myFaction.getFPlayersWhereRole(Role.COLEADER)) {
String s = player.getName(); String s = player.getName();
msg.then(s + " ").color(ChatColor.RED).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);
} }
} }
} }
sendFancyMessage(msg); sendFancyMessage(msg);
return; return;
} }
if (fme == toKick) { if (fme == toKick) {
msg(TL.COMMAND_KICK_SELF); msg(TL.COMMAND_KICK_SELF);
msg(TL.GENERIC_YOUMAYWANT.toString() + p.cmdBase.cmdLeave.getUseageTemplate(false)); msg(TL.GENERIC_YOUMAYWANT.toString() + p.cmdBase.cmdLeave.getUseageTemplate(false));
return; return;
} }
Faction toKickFaction = toKick.getFaction(); Faction toKickFaction = toKick.getFaction();
if (toKickFaction.isWilderness()) { if (toKickFaction.isWilderness()) {
sender.sendMessage(TL.COMMAND_KICK_NONE.toString()); 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 (!fme.isAdminBypassing()) { if (!fme.isAdminBypassing()) {
Access access = myFaction.getAccess(fme, PermissableAction.KICK); Access access = myFaction.getAccess(fme, PermissableAction.KICK);
if (access != Access.ALLOW && fme.getRole() != Role.LEADER) { if (access != Access.ALLOW && fme.getRole() != Role.LEADER) {
fme.msg(TL.GENERIC_NOPERMISSION, "kick"); fme.msg(TL.GENERIC_NOPERMISSION, "kick");
return; return;
} }
if (toKickFaction != myFaction) { if (toKickFaction != myFaction) {
msg(TL.COMMAND_KICK_NOTMEMBER, toKick.describeTo(fme, true), myFaction.describeTo(fme)); msg(TL.COMMAND_KICK_NOTMEMBER, toKick.describeTo(fme, true), myFaction.describeTo(fme));
return; return;
} }
if (toKick.getRole().value >= fme.getRole().value) { if (toKick.getRole().value >= fme.getRole().value) {
msg(TL.COMMAND_KICK_INSUFFICIENTRANK); msg(TL.COMMAND_KICK_INSUFFICIENTRANK);
return; return;
} }
if (!Conf.canLeaveWithNegativePower && toKick.getPower() < 0) { if (!Conf.canLeaveWithNegativePower && toKick.getPower() < 0) {
msg(TL.COMMAND_KICK_NEGATIVEPOWER); 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 (!canAffordCommand(Conf.econCostKick, TL.COMMAND_KICK_TOKICK.toString())) { if (!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 (!payForCommand(Conf.econCostKick, TL.COMMAND_KICK_TOKICK.toString(), TL.COMMAND_KICK_FORKICK.toString())) { if (!payForCommand(Conf.econCostKick, TL.COMMAND_KICK_TOKICK.toString(), TL.COMMAND_KICK_FORKICK.toString())) {
return; return;
} }
toKickFaction.msg(TL.COMMAND_KICK_FACTION, fme.describeTo(toKickFaction, true), toKick.describeTo(toKickFaction, true)); toKickFaction.msg(TL.COMMAND_KICK_FACTION, fme.describeTo(toKickFaction, true), toKick.describeTo(toKickFaction, true));
toKick.msg(TL.COMMAND_KICK_KICKED, fme.describeTo(toKick, true), toKickFaction.describeTo(toKick)); toKick.msg(TL.COMMAND_KICK_KICKED, fme.describeTo(toKick, true), toKickFaction.describeTo(toKick));
if (toKickFaction != myFaction) { if (toKickFaction != myFaction) {
fme.msg(TL.COMMAND_KICK_KICKS, toKick.describeTo(fme), toKickFaction.describeTo(fme)); fme.msg(TL.COMMAND_KICK_KICKS, toKick.describeTo(fme), toKickFaction.describeTo(fme));
} }
if (Conf.logFactionKick) { if (Conf.logFactionKick) {
SavageFactions.plugin.log((senderIsConsole ? "A console command" : fme.getName()) + " kicked " + toKick.getName() + " from the faction: " + toKickFaction.getTag()); SavageFactions.plugin.log((senderIsConsole ? "A console command" : fme.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,32 +4,32 @@ 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.permission = Permission.KILLHOLOS.node; this.permission = Permission.KILLHOLOS.node;
this.disableOnLock = true; this.disableOnLock = true;
senderMustBePlayer = true; senderMustBePlayer = true;
senderMustBeMember = false; senderMustBeMember = false;
senderMustBeModerator = false; senderMustBeModerator = false;
senderMustBeColeader = false; senderMustBeColeader = false;
senderMustBeAdmin = false; senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform() {
me.sendMessage("Killing Invisible Armor Stands.."); me.sendMessage("Killing Invisible Armor Stands..");
me.chat("/minecraft:kill @e[type=ArmorStand,r=" + argAsInt(0) + "]"); me.chat("/minecraft:kill @e[type=ArmorStand,r=" + argAsInt(0) + "]");
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_KILLHOLOGRAMS_DESCRIPTION; return TL.COMMAND_KILLHOLOGRAMS_DESCRIPTION;
} }
} }

View File

@ -5,32 +5,32 @@ 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.requiredArgs.add(""); //this.requiredArgs.add("");
//this.optionalArgs.put("", ""); //this.optionalArgs.put("", "");
this.permission = Permission.LEAVE.node; this.permission = Permission.LEAVE.node;
this.disableOnLock = true; this.disableOnLock = true;
senderMustBePlayer = true; senderMustBePlayer = true;
senderMustBeMember = true; senderMustBeMember = true;
senderMustBeModerator = false; senderMustBeModerator = false;
senderMustBeColeader = false; senderMustBeColeader = false;
senderMustBeAdmin = false; senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform() {
fme.leave(true); fme.leave(true);
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.LEAVE_DESCRIPTION; return TL.LEAVE_DESCRIPTION;
} }
} }

View File

@ -13,119 +13,119 @@ import java.util.*;
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.permission = Permission.LIST.node; this.permission = Permission.LIST.node;
this.disableOnLock = false; this.disableOnLock = false;
senderMustBePlayer = false; senderMustBePlayer = false;
senderMustBeMember = false; senderMustBeMember = false;
senderMustBeModerator = false; senderMustBeModerator = false;
senderMustBeColeader = false; senderMustBeColeader = false;
senderMustBeAdmin = false; senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform() {
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
if (!payForCommand(Conf.econCostList, "to list the factions", "for listing the factions")) if (!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 (fme != null && fme.getPlayer() != null && !fme.getPlayer().hasPermission("factions.show.bypassexempt")) { if (fme != null && fme.getPlayer() != null && !fme.getPlayer().hasPermission("factions.show.bypassexempt")) {
List<String> exemptFactions = SavageFactions.plugin.getConfig().getStringList("show-exempt"); List<String> exemptFactions = SavageFactions.plugin.getConfig().getStringList("show-exempt");
Iterator<Faction> factionIterator = factionList.iterator(); Iterator<Faction> factionIterator = factionList.iterator();
while (factionIterator.hasNext()) { while (factionIterator.hasNext()) {
Faction next = factionIterator.next(); Faction next = factionIterator.next();
if (exemptFactions.contains(next.getTag())) if (exemptFactions.contains(next.getTag()))
factionIterator.remove(); factionIterator.remove();
} }
} }
// Sort by total followers first // Sort by total followers first
Collections.sort(factionList, new Comparator<Faction>() { Collections.sort(factionList, new Comparator<Faction>() {
@Override @Override
public int compare(Faction f1, Faction f2) { public int compare(Faction f1, Faction 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
Collections.sort(factionList, new Comparator<Faction>() { Collections.sort(factionList, new Comparator<Faction>() {
@Override @Override
public int compare(Faction f1, Faction f2) { public int compare(Faction f1, Faction 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 = this.argAsInt(0, 1); int pagenumber = this.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 = p.getConfig().getString("list.header", defaults[0]); String header = p.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(p.txt.parse(header)); lines.add(p.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(p.txt.parse(TagUtil.parsePlain(faction, p.getConfig().getString("list.factionless", defaults[1])))); lines.add(p.txt.parse(TagUtil.parsePlain(faction, p.getConfig().getString("list.factionless", defaults[1]))));
continue; continue;
} }
lines.add(p.txt.parse(TagUtil.parsePlain(faction, fme, p.getConfig().getString("list.entry", defaults[2])))); lines.add(p.txt.parse(TagUtil.parsePlain(faction, fme, p.getConfig().getString("list.entry", defaults[2]))));
} }
sendMessage(lines); sendMessage(lines);
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_LIST_DESCRIPTION; return TL.COMMAND_LIST_DESCRIPTION;
} }
} }

View File

@ -5,40 +5,40 @@ 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.requiredArgs.add(""); //this.requiredArgs.add("");
this.optionalArgs.put("on/off", "flip"); this.optionalArgs.put("on/off", "flip");
this.permission = Permission.LOCK.node; this.permission = Permission.LOCK.node;
this.disableOnLock = false; this.disableOnLock = false;
senderMustBePlayer = false; senderMustBePlayer = false;
senderMustBeMember = false; senderMustBeMember = false;
senderMustBeModerator = false; senderMustBeModerator = false;
senderMustBeColeader = false; senderMustBeColeader = false;
senderMustBeAdmin = false; senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform() {
p.setLocked(this.argAsBool(0, !p.getLocked())); p.setLocked(this.argAsBool(0, !p.getLocked()));
msg(p.getLocked() ? TL.COMMAND_LOCK_LOCKED : TL.COMMAND_LOCK_UNLOCKED); msg(p.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,27 +5,27 @@ 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.senderMustBePlayer = true; this.senderMustBePlayer = true;
this.senderMustBeMember = true; this.senderMustBeMember = true;
this.permission = Permission.MONITOR_LOGINS.node; this.permission = Permission.MONITOR_LOGINS.node;
} }
@Override @Override
public void perform() { public void perform() {
boolean monitor = fme.isMonitoringJoins(); boolean monitor = fme.isMonitoringJoins();
fme.msg(TL.COMMAND_LOGINS_TOGGLE, String.valueOf(!monitor)); fme.msg(TL.COMMAND_LOGINS_TOGGLE, String.valueOf(!monitor));
fme.setMonitorJoins(!monitor); fme.setMonitorJoins(!monitor);
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_LOGINS_DESCRIPTION; return TL.COMMAND_LOGINS_DESCRIPTION;
} }
} }

View File

@ -6,38 +6,38 @@ 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.disableOnLock = false; this.disableOnLock = false;
senderMustBePlayer = true; senderMustBePlayer = true;
senderMustBeMember = true; senderMustBeMember = true;
senderMustBeModerator = false; senderMustBeModerator = false;
senderMustBeColeader = true; senderMustBeColeader = true;
senderMustBeAdmin = false; senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform() {
double maxPower = Conf.powerPlayerMax; double maxPower = Conf.powerPlayerMax;
String format = TL.COMMAND_LOWPOWER_FORMAT.toString(); String format = TL.COMMAND_LOWPOWER_FORMAT.toString();
msg(TL.COMMAND_LOWPOWER_HEADER.toString().replace("{maxpower}", (int) maxPower + "")); msg(TL.COMMAND_LOWPOWER_HEADER.toString().replace("{maxpower}", (int) maxPower + ""));
for (FPlayer fPlayer : fme.getFaction().getFPlayers()) { for (FPlayer fPlayer : fme.getFaction().getFPlayers()) {
if (fPlayer.getPower() < maxPower) { if (fPlayer.getPower() < maxPower) {
sendMessage(format.replace("{player}", fPlayer.getName()).replace("{player_power}", (int) fPlayer.getPower() + "").replace("{maxpower}", (int) maxPower + "")); 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,62 +9,62 @@ 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.requiredArgs.add(""); //this.requiredArgs.add("");
this.optionalArgs.put("on/off", "once"); this.optionalArgs.put("on/off", "once");
this.permission = Permission.MAP.node; this.permission = Permission.MAP.node;
this.disableOnLock = false; this.disableOnLock = false;
senderMustBePlayer = true; senderMustBePlayer = true;
senderMustBeMember = false; senderMustBeMember = false;
senderMustBeModerator = false; senderMustBeModerator = false;
senderMustBeColeader = false; senderMustBeColeader = false;
senderMustBeAdmin = false; senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform() {
if (this.argIsSet(0)) { if (this.argIsSet(0)) {
if (this.argAsBool(0, !fme.isMapAutoUpdating())) { if (this.argAsBool(0, !fme.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 (!payForCommand(Conf.econCostMap, "to show the map", "for showing the map")) { if (!payForCommand(Conf.econCostMap, "to show the map", "for showing the map")) {
return; return;
} }
fme.setMapAutoUpdating(true); fme.setMapAutoUpdating(true);
msg(TL.COMMAND_MAP_UPDATE_ENABLED); msg(TL.COMMAND_MAP_UPDATE_ENABLED);
// And show the map once // And show the map once
showMap(); showMap();
} else { } else {
// Turn off // Turn off
fme.setMapAutoUpdating(false); fme.setMapAutoUpdating(false);
msg(TL.COMMAND_MAP_UPDATE_DISABLED); msg(TL.COMMAND_MAP_UPDATE_DISABLED);
} }
} 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 (!payForCommand(Conf.econCostMap, TL.COMMAND_MAP_TOSHOW, TL.COMMAND_MAP_FORSHOW)) { if (!payForCommand(Conf.econCostMap, TL.COMMAND_MAP_TOSHOW, TL.COMMAND_MAP_FORSHOW)) {
return; return;
} }
showMap(); showMap();
} }
} }
public void showMap() { public void showMap() {
sendFancyMessage(Board.getInstance().getMap(fme, new FLocation(fme), fme.getPlayer().getLocation().getYaw())); sendFancyMessage(Board.getInstance().getMap(fme, new FLocation(fme), fme.getPlayer().getLocation().getYaw()));
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_MAP_DESCRIPTION; return TL.COMMAND_MAP_DESCRIPTION;
} }
} }

View File

@ -5,36 +5,36 @@ 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.permission = Permission.MAPHEIGHT.node; this.permission = Permission.MAPHEIGHT.node;
this.senderMustBePlayer = true; this.senderMustBePlayer = true;
} }
@Override @Override
public void perform() { public void perform() {
if (args.size() == 0) { if (args.size() == 0) {
fme.sendMessage(TL.COMMAND_MAPHEIGHT_CURRENT.format(fme.getMapHeight())); fme.sendMessage(TL.COMMAND_MAPHEIGHT_CURRENT.format(fme.getMapHeight()));
return; return;
} }
int height = argAsInt(0); int height = argAsInt(0);
fme.setMapHeight(height); fme.setMapHeight(height);
fme.sendMessage(TL.COMMAND_MAPHEIGHT_SET.format(fme.getMapHeight())); fme.sendMessage(TL.COMMAND_MAPHEIGHT_SET.format(fme.getMapHeight()));
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_MAPHEIGHT_DESCRIPTION; return TL.COMMAND_MAPHEIGHT_DESCRIPTION;
} }
} }

View File

@ -11,79 +11,79 @@ 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.optionalArgs.put("", ""); //this.optionalArgs.put("", "");
this.permission = Permission.MOD.node; this.permission = Permission.MOD.node;
this.disableOnLock = true; this.disableOnLock = true;
senderMustBePlayer = false; senderMustBePlayer = false;
senderMustBeMember = true; senderMustBeMember = true;
senderMustBeModerator = false; senderMustBeModerator = false;
senderMustBeColeader = true; senderMustBeColeader = true;
senderMustBeAdmin = false; senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform() {
FPlayer you = this.argAsBestFPlayerMatch(0); FPlayer you = this.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 : myFaction.getFPlayersWhereRole(Role.NORMAL)) { for (FPlayer player : myFaction.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);
} }
sendFancyMessage(msg); sendFancyMessage(msg);
return; return;
} }
boolean permAny = Permission.MOD_ANY.has(sender, false); boolean permAny = Permission.MOD_ANY.has(sender, false);
Faction targetFaction = you.getFaction(); Faction targetFaction = you.getFaction();
if (targetFaction != myFaction && !permAny) { if (targetFaction != myFaction && !permAny) {
msg(TL.COMMAND_MOD_NOTMEMBER, you.describeTo(fme, true)); msg(TL.COMMAND_MOD_NOTMEMBER, you.describeTo(fme, true));
return; return;
} }
if (fme != null && fme.getRole() != Role.LEADER && !permAny) { if (fme != null && fme.getRole() != Role.LEADER && !permAny) {
msg(TL.COMMAND_MOD_NOTADMIN); msg(TL.COMMAND_MOD_NOTADMIN);
return; return;
} }
if (you == fme && !permAny) { if (you == fme && !permAny) {
msg(TL.COMMAND_MOD_SELF); msg(TL.COMMAND_MOD_SELF);
return; return;
} }
if (you.getRole() == Role.LEADER) { if (you.getRole() == Role.LEADER) {
msg(TL.COMMAND_MOD_TARGETISADMIN); 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));
msg(TL.COMMAND_MOD_REVOKES, you.describeTo(fme, true)); msg(TL.COMMAND_MOD_REVOKES, you.describeTo(fme, 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));
msg(TL.COMMAND_MOD_PROMOTES, you.describeTo(fme, true)); msg(TL.COMMAND_MOD_PROMOTES, you.describeTo(fme, true));
} }
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_MOD_DESCRIPTION; return TL.COMMAND_MOD_DESCRIPTION;
} }
} }

View File

@ -6,45 +6,45 @@ 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.permission = Permission.MODIFY_POWER.node; // admin only perm. this.permission = Permission.MODIFY_POWER.node; // admin only perm.
// Let's not require anything and let console modify this as well. // Let's not require anything and let console modify this as well.
this.senderMustBeAdmin = false; this.senderMustBeAdmin = false;
this.senderMustBePlayer = false; this.senderMustBePlayer = false;
this.senderMustBeMember = false; this.senderMustBeMember = false;
senderMustBeColeader = false; senderMustBeColeader = false;
this.senderMustBeModerator = false; this.senderMustBeModerator = false;
} }
@Override @Override
public void perform() { public void perform() {
// /f modify <name> # // /f modify <name> #
FPlayer player = argAsBestFPlayerMatch(0); FPlayer player = argAsBestFPlayerMatch(0);
Double number = argAsDouble(1); // returns null if not a Double. Double number = argAsDouble(1); // returns null if not a Double.
if (player == null || number == null) { if (player == null || number == null) {
sender.sendMessage(getHelpShort()); 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.
msg(TL.COMMAND_MODIFYPOWER_ADDED, number, player.getName(), newPower); 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

@ -5,48 +5,48 @@ import com.massivecraft.factions.zcore.util.TL;
public class CmdMoney extends FCommand { public class CmdMoney extends FCommand {
public CmdMoneyBalance cmdMoneyBalance = new CmdMoneyBalance(); public CmdMoneyBalance cmdMoneyBalance = new CmdMoneyBalance();
public CmdMoneyDeposit cmdMoneyDeposit = new CmdMoneyDeposit(); public CmdMoneyDeposit cmdMoneyDeposit = new CmdMoneyDeposit();
public CmdMoneyWithdraw cmdMoneyWithdraw = new CmdMoneyWithdraw(); public CmdMoneyWithdraw cmdMoneyWithdraw = new CmdMoneyWithdraw();
public CmdMoneyTransferFf cmdMoneyTransferFf = new CmdMoneyTransferFf(); public CmdMoneyTransferFf cmdMoneyTransferFf = new CmdMoneyTransferFf();
public CmdMoneyTransferFp cmdMoneyTransferFp = new CmdMoneyTransferFp(); public CmdMoneyTransferFp cmdMoneyTransferFp = new CmdMoneyTransferFp();
public CmdMoneyTransferPf cmdMoneyTransferPf = new CmdMoneyTransferPf(); public CmdMoneyTransferPf cmdMoneyTransferPf = new CmdMoneyTransferPf();
public CmdMoney() { public CmdMoney() {
super(); super();
this.aliases.add("money"); this.aliases.add("money");
//this.requiredArgs.add(""); //this.requiredArgs.add("");
//this.optionalArgs.put("","") //this.optionalArgs.put("","")
this.isMoneyCommand = true; this.isMoneyCommand = true;
senderMustBePlayer = false; senderMustBePlayer = false;
senderMustBeMember = false; senderMustBeMember = false;
senderMustBeModerator = false; senderMustBeModerator = false;
senderMustBeColeader = false; senderMustBeColeader = false;
senderMustBeAdmin = false; senderMustBeAdmin = false;
this.helpLong.add(p.txt.parseTags(TL.COMMAND_MONEY_LONG.toString())); this.helpLong.add(p.txt.parseTags(TL.COMMAND_MONEY_LONG.toString()));
this.addSubCommand(this.cmdMoneyBalance); this.addSubCommand(this.cmdMoneyBalance);
this.addSubCommand(this.cmdMoneyDeposit); this.addSubCommand(this.cmdMoneyDeposit);
this.addSubCommand(this.cmdMoneyWithdraw); this.addSubCommand(this.cmdMoneyWithdraw);
this.addSubCommand(this.cmdMoneyTransferFf); this.addSubCommand(this.cmdMoneyTransferFf);
this.addSubCommand(this.cmdMoneyTransferFp); this.addSubCommand(this.cmdMoneyTransferFp);
this.addSubCommand(this.cmdMoneyTransferPf); this.addSubCommand(this.cmdMoneyTransferPf);
} }
@Override @Override
public void perform() { public void perform() {
this.commandChain.add(this); this.commandChain.add(this);
SavageFactions.plugin.cmdAutoHelp.execute(this.sender, this.args, this.commandChain); SavageFactions.plugin.cmdAutoHelp.execute(this.sender, this.args, this.commandChain);
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_MONEY_DESCRIPTION; return TL.COMMAND_MONEY_DESCRIPTION;
} }
} }

View File

@ -7,46 +7,46 @@ import com.massivecraft.factions.zcore.util.TL;
public class CmdMoneyBalance extends FCommand { public class CmdMoneyBalance extends FCommand {
public CmdMoneyBalance() { public CmdMoneyBalance() {
super(); super();
this.aliases.add("b"); this.aliases.add("b");
this.aliases.add("balance"); this.aliases.add("balance");
//this.requiredArgs.add(""); //this.requiredArgs.add("");
this.optionalArgs.put("faction", "yours"); this.optionalArgs.put("faction", "yours");
this.permission = Permission.MONEY_BALANCE.node; this.permission = Permission.MONEY_BALANCE.node;
this.setHelpShort(TL.COMMAND_MONEYBALANCE_SHORT.toString()); this.setHelpShort(TL.COMMAND_MONEYBALANCE_SHORT.toString());
senderMustBePlayer = false; senderMustBePlayer = false;
senderMustBeMember = false; senderMustBeMember = false;
senderMustBeModerator = false; senderMustBeModerator = false;
senderMustBeAdmin = false; senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform() {
Faction faction = myFaction; Faction faction = myFaction;
if (this.argIsSet(0)) { if (this.argIsSet(0)) {
faction = this.argAsFaction(0); faction = this.argAsFaction(0);
} }
if (faction == null) { if (faction == null) {
return; return;
} }
if (faction != myFaction && !Permission.MONEY_BALANCE_ANY.has(sender, true)) { if (faction != myFaction && !Permission.MONEY_BALANCE_ANY.has(sender, true)) {
return; return;
} }
if (fme != null) { if (fme != null) {
Econ.sendBalanceInfo(fme, faction); Econ.sendBalanceInfo(fme, faction);
} }
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_MONEYBALANCE_DESCRIPTION; return TL.COMMAND_MONEYBALANCE_DESCRIPTION;
} }
} }

View File

@ -11,41 +11,41 @@ import org.bukkit.ChatColor;
public class CmdMoneyDeposit extends FCommand { public class CmdMoneyDeposit extends FCommand {
public CmdMoneyDeposit() { public CmdMoneyDeposit() {
super(); super();
this.aliases.add("d"); this.aliases.add("d");
this.aliases.add("deposit"); this.aliases.add("deposit");
this.requiredArgs.add("amount"); this.requiredArgs.add("amount");
this.optionalArgs.put("faction", "yours"); this.optionalArgs.put("faction", "yours");
this.permission = Permission.MONEY_DEPOSIT.node; this.permission = Permission.MONEY_DEPOSIT.node;
senderMustBePlayer = true; senderMustBePlayer = true;
senderMustBeMember = false; senderMustBeMember = false;
senderMustBeModerator = false; senderMustBeModerator = false;
senderMustBeColeader = false; senderMustBeColeader = false;
senderMustBeAdmin = false; senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform() {
double amount = this.argAsDouble(0, 0d); double amount = this.argAsDouble(0, 0d);
EconomyParticipator faction = this.argAsFaction(1, myFaction); EconomyParticipator faction = this.argAsFaction(1, myFaction);
if (faction == null) { if (faction == null) {
return; return;
} }
boolean success = Econ.transferMoney(fme, fme, faction, amount); boolean success = Econ.transferMoney(fme, fme, faction, amount);
if (success && Conf.logMoneyTransactions) { if (success && Conf.logMoneyTransactions) {
SavageFactions.plugin.log(ChatColor.stripColor(SavageFactions.plugin.txt.parse(TL.COMMAND_MONEYDEPOSIT_DEPOSITED.toString(), fme.getName(), Econ.moneyString(amount), faction.describeTo(null)))); SavageFactions.plugin.log(ChatColor.stripColor(SavageFactions.plugin.txt.parse(TL.COMMAND_MONEYDEPOSIT_DEPOSITED.toString(), fme.getName(), Econ.moneyString(amount), faction.describeTo(null))));
} }
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_MONEYDEPOSIT_DESCRIPTION; return TL.COMMAND_MONEYDEPOSIT_DESCRIPTION;
} }
} }

View File

@ -12,47 +12,47 @@ import org.bukkit.entity.Player;
public class CmdMoneyTransferFf extends FCommand { public class CmdMoneyTransferFf extends FCommand {
public CmdMoneyTransferFf() { public CmdMoneyTransferFf() {
this.aliases.add("ff"); this.aliases.add("ff");
this.requiredArgs.add("amount"); this.requiredArgs.add("amount");
this.requiredArgs.add("faction"); this.requiredArgs.add("faction");
this.requiredArgs.add("faction"); this.requiredArgs.add("faction");
//this.optionalArgs.put("", ""); //this.optionalArgs.put("", "");
this.permission = Permission.MONEY_F2F.node; this.permission = Permission.MONEY_F2F.node;
senderMustBePlayer = false; senderMustBePlayer = false;
senderMustBeMember = false; senderMustBeMember = false;
senderMustBeModerator = false; senderMustBeModerator = false;
senderMustBeColeader = false; senderMustBeColeader = false;
senderMustBeAdmin = false; senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform() {
double amount = this.argAsDouble(0, 0d); double amount = this.argAsDouble(0, 0d);
EconomyParticipator from = this.argAsFaction(1); EconomyParticipator from = this.argAsFaction(1);
if (from == null) { if (from == null) {
return; return;
} }
EconomyParticipator to = this.argAsFaction(2); EconomyParticipator to = this.argAsFaction(2);
if (to == null) { if (to == null) {
return; return;
} }
boolean success = Econ.transferMoney(fme, from, to, amount); boolean success = Econ.transferMoney(fme, from, to, amount);
if (success && Conf.logMoneyTransactions) { if (success && Conf.logMoneyTransactions) {
String name = sender instanceof Player ? fme.getName() : sender.getName(); String name = sender instanceof Player ? fme.getName() : sender.getName();
SavageFactions.plugin.log(ChatColor.stripColor(SavageFactions.plugin.txt.parse(TL.COMMAND_MONEYTRANSFERFF_TRANSFER.toString(), name, Econ.moneyString(amount), from.describeTo(null), to.describeTo(null)))); SavageFactions.plugin.log(ChatColor.stripColor(SavageFactions.plugin.txt.parse(TL.COMMAND_MONEYTRANSFERFF_TRANSFER.toString(), name, Econ.moneyString(amount), from.describeTo(null), to.describeTo(null))));
} }
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_MONEYTRANSFERFF_DESCRIPTION; return TL.COMMAND_MONEYTRANSFERFF_DESCRIPTION;
} }
} }

View File

@ -11,46 +11,46 @@ import org.bukkit.ChatColor;
public class CmdMoneyTransferFp extends FCommand { public class CmdMoneyTransferFp extends FCommand {
public CmdMoneyTransferFp() { public CmdMoneyTransferFp() {
this.aliases.add("fp"); this.aliases.add("fp");
this.requiredArgs.add("amount"); this.requiredArgs.add("amount");
this.requiredArgs.add("faction"); this.requiredArgs.add("faction");
this.requiredArgs.add("player"); this.requiredArgs.add("player");
//this.optionalArgs.put("", ""); //this.optionalArgs.put("", "");
this.permission = Permission.MONEY_F2P.node; this.permission = Permission.MONEY_F2P.node;
senderMustBePlayer = false; senderMustBePlayer = false;
senderMustBeMember = false; senderMustBeMember = false;
senderMustBeModerator = false; senderMustBeModerator = false;
senderMustBeColeader = false; senderMustBeColeader = false;
senderMustBeAdmin = false; senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform() {
double amount = this.argAsDouble(0, 0d); double amount = this.argAsDouble(0, 0d);
EconomyParticipator from = this.argAsFaction(1); EconomyParticipator from = this.argAsFaction(1);
if (from == null) { if (from == null) {
return; return;
} }
EconomyParticipator to = this.argAsBestFPlayerMatch(2); EconomyParticipator to = this.argAsBestFPlayerMatch(2);
if (to == null) { if (to == null) {
return; return;
} }
boolean success = Econ.transferMoney(fme, from, to, amount); boolean success = Econ.transferMoney(fme, from, to, amount);
if (success && Conf.logMoneyTransactions) { if (success && Conf.logMoneyTransactions) {
SavageFactions.plugin.log(ChatColor.stripColor(SavageFactions.plugin.txt.parse(TL.COMMAND_MONEYTRANSFERFP_TRANSFER.toString(), fme.getName(), Econ.moneyString(amount), from.describeTo(null), to.describeTo(null)))); SavageFactions.plugin.log(ChatColor.stripColor(SavageFactions.plugin.txt.parse(TL.COMMAND_MONEYTRANSFERFP_TRANSFER.toString(), fme.getName(), Econ.moneyString(amount), from.describeTo(null), to.describeTo(null))));
} }
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_MONEYTRANSFERFP_DESCRIPTION; return TL.COMMAND_MONEYTRANSFERFP_DESCRIPTION;
} }
} }

View File

@ -11,46 +11,46 @@ import org.bukkit.ChatColor;
public class CmdMoneyTransferPf extends FCommand { public class CmdMoneyTransferPf extends FCommand {
public CmdMoneyTransferPf() { public CmdMoneyTransferPf() {
this.aliases.add("pf"); this.aliases.add("pf");
this.requiredArgs.add("amount"); this.requiredArgs.add("amount");
this.requiredArgs.add("player"); this.requiredArgs.add("player");
this.requiredArgs.add("faction"); this.requiredArgs.add("faction");
//this.optionalArgs.put("", ""); //this.optionalArgs.put("", "");
this.permission = Permission.MONEY_P2F.node; this.permission = Permission.MONEY_P2F.node;
senderMustBePlayer = false; senderMustBePlayer = false;
senderMustBeMember = false; senderMustBeMember = false;
senderMustBeModerator = false; senderMustBeModerator = false;
senderMustBeColeader = false; senderMustBeColeader = false;
senderMustBeAdmin = false; senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform() {
double amount = this.argAsDouble(0, 0d); double amount = this.argAsDouble(0, 0d);
EconomyParticipator from = this.argAsBestFPlayerMatch(1); EconomyParticipator from = this.argAsBestFPlayerMatch(1);
if (from == null) { if (from == null) {
return; return;
} }
EconomyParticipator to = this.argAsFaction(2); EconomyParticipator to = this.argAsFaction(2);
if (to == null) { if (to == null) {
return; return;
} }
boolean success = Econ.transferMoney(fme, from, to, amount); boolean success = Econ.transferMoney(fme, from, to, amount);
if (success && Conf.logMoneyTransactions) { if (success && Conf.logMoneyTransactions) {
SavageFactions.plugin.log(ChatColor.stripColor(SavageFactions.plugin.txt.parse(TL.COMMAND_MONEYTRANSFERPF_TRANSFER.toString(), fme.getName(), Econ.moneyString(amount), from.describeTo(null), to.describeTo(null)))); SavageFactions.plugin.log(ChatColor.stripColor(SavageFactions.plugin.txt.parse(TL.COMMAND_MONEYTRANSFERPF_TRANSFER.toString(), fme.getName(), Econ.moneyString(amount), from.describeTo(null), to.describeTo(null))));
} }
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_MONEYTRANSFERPF_DESCRIPTION; return TL.COMMAND_MONEYTRANSFERPF_DESCRIPTION;
} }
} }

View File

@ -13,47 +13,47 @@ import org.bukkit.ChatColor;
public class CmdMoneyWithdraw extends FCommand { public class CmdMoneyWithdraw extends FCommand {
public CmdMoneyWithdraw() { public CmdMoneyWithdraw() {
this.aliases.add("w"); this.aliases.add("w");
this.aliases.add("withdraw"); this.aliases.add("withdraw");
this.requiredArgs.add("amount"); this.requiredArgs.add("amount");
this.optionalArgs.put("faction", "yours"); this.optionalArgs.put("faction", "yours");
this.permission = Permission.MONEY_WITHDRAW.node; this.permission = Permission.MONEY_WITHDRAW.node;
senderMustBePlayer = true; senderMustBePlayer = true;
senderMustBeMember = false; senderMustBeMember = false;
senderMustBeModerator = false; senderMustBeModerator = false;
senderMustBeColeader = false; senderMustBeColeader = false;
senderMustBeAdmin = false; senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform() {
double amount = this.argAsDouble(0, 0d); double amount = this.argAsDouble(0, 0d);
EconomyParticipator faction = this.argAsFaction(1, myFaction); EconomyParticipator faction = this.argAsFaction(1, myFaction);
if (faction == null) { if (faction == null) {
return; return;
} }
Access access = myFaction.getAccess(fme, PermissableAction.WITHDRAW); Access access = myFaction.getAccess(fme, PermissableAction.WITHDRAW);
if (access == Access.DENY) { if (access == Access.DENY) {
fme.msg(TL.GENERIC_NOPERMISSION, "withdraw"); fme.msg(TL.GENERIC_NOPERMISSION, "withdraw");
return; return;
} }
boolean success = Econ.transferMoney(fme, faction, fme, amount); boolean success = Econ.transferMoney(fme, faction, fme, amount);
if (success && Conf.logMoneyTransactions) { if (success && Conf.logMoneyTransactions) {
SavageFactions.plugin.log(ChatColor.stripColor(SavageFactions.plugin.txt.parse(TL.COMMAND_MONEYWITHDRAW_WITHDRAW.toString(), fme.getName(), Econ.moneyString(amount), faction.describeTo(null)))); SavageFactions.plugin.log(ChatColor.stripColor(SavageFactions.plugin.txt.parse(TL.COMMAND_MONEYWITHDRAW_WITHDRAW.toString(), fme.getName(), Econ.moneyString(amount), faction.describeTo(null))));
} }
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_MONEYWITHDRAW_DESCRIPTION; return TL.COMMAND_MONEYWITHDRAW_DESCRIPTION;
} }
} }

View File

@ -8,47 +8,47 @@ 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.disableOnLock = true; this.disableOnLock = true;
senderMustBePlayer = true; senderMustBePlayer = true;
senderMustBeMember = true; senderMustBeMember = true;
senderMustBeModerator = false; senderMustBeModerator = false;
senderMustBeColeader = false; senderMustBeColeader = false;
senderMustBeAdmin = false; senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform() {
if (!SavageFactions.plugin.getConfig().getBoolean("fnear.Enabled")) { if (!SavageFactions.plugin.getConfig().getBoolean("fnear.Enabled")) {
fme.msg(TL.COMMAND_NEAR_DISABLED_MSG); fme.msg(TL.COMMAND_NEAR_DISABLED_MSG);
return; return;
} }
double range = SavageFactions.plugin.getConfig().getInt("fnear.Radius"); double range = SavageFactions.plugin.getConfig().getInt("fnear.Radius");
String format = TL.COMMAND_NEAR_FORMAT.toString(); String format = TL.COMMAND_NEAR_FORMAT.toString();
fme.msg(TL.COMMAND_NEAR_USE_MSG); fme.msg(TL.COMMAND_NEAR_USE_MSG);
for (Entity e : me.getNearbyEntities(range, 255, range)) { for (Entity e : me.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 (fme.getFaction() == fplayer.getFaction()) { if (fme.getFaction() == fplayer.getFaction()) {
double distance = me.getLocation().distance(player.getLocation()); double distance = me.getLocation().distance(player.getLocation());
fme.sendMessage(format.replace("{playername}", player.getDisplayName()).replace("{distance}", (int) distance + "")); fme.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

@ -8,48 +8,48 @@ 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.requiredArgs.add(""); //this.requiredArgs.add("");
this.optionalArgs.put("yes/no", "flip"); this.optionalArgs.put("yes/no", "flip");
this.permission = Permission.OPEN.node; this.permission = Permission.OPEN.node;
this.disableOnLock = false; this.disableOnLock = false;
senderMustBePlayer = true; senderMustBePlayer = true;
senderMustBeMember = false; senderMustBeMember = false;
senderMustBeModerator = false; senderMustBeModerator = false;
senderMustBeColeader = true; senderMustBeColeader = true;
senderMustBeAdmin = false; senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform() {
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
if (!payForCommand(Conf.econCostOpen, TL.COMMAND_OPEN_TOOPEN, TL.COMMAND_OPEN_FOROPEN)) { if (!payForCommand(Conf.econCostOpen, TL.COMMAND_OPEN_TOOPEN, TL.COMMAND_OPEN_FOROPEN)) {
return; return;
} }
myFaction.setOpen(this.argAsBool(0, !myFaction.getOpen())); myFaction.setOpen(this.argAsBool(0, !myFaction.getOpen()));
String open = myFaction.getOpen() ? TL.COMMAND_OPEN_OPEN.toString() : TL.COMMAND_OPEN_CLOSED.toString(); String open = myFaction.getOpen() ? TL.COMMAND_OPEN_OPEN.toString() : TL.COMMAND_OPEN_CLOSED.toString();
// Inform // Inform
for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers()) { for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers()) {
if (fplayer.getFactionId().equals(myFaction.getId())) { if (fplayer.getFactionId().equals(myFaction.getId())) {
fplayer.msg(TL.COMMAND_OPEN_CHANGES, fme.getName(), open); fplayer.msg(TL.COMMAND_OPEN_CHANGES, fme.getName(), open);
continue; continue;
} }
fplayer.msg(TL.COMMAND_OPEN_CHANGED, myFaction.getTag(fplayer.getFaction()), open); fplayer.msg(TL.COMMAND_OPEN_CHANGED, myFaction.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,100 +8,100 @@ 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.requiredArgs.add(""); //this.requiredArgs.add("");
this.optionalArgs.put("player name", "you"); this.optionalArgs.put("player name", "you");
this.permission = Permission.OWNER.node; this.permission = Permission.OWNER.node;
this.disableOnLock = true; this.disableOnLock = true;
senderMustBePlayer = true; senderMustBePlayer = true;
senderMustBeMember = false; senderMustBeMember = false;
senderMustBeModerator = false; senderMustBeModerator = false;
senderMustBeColeader = false; senderMustBeColeader = false;
senderMustBeAdmin = false; senderMustBeAdmin = false;
} }
// TODO: Fix colors! // TODO: Fix colors!
@Override @Override
public void perform() { public void perform() {
boolean hasBypass = fme.isAdminBypassing(); boolean hasBypass = fme.isAdminBypassing();
if (!hasBypass && !assertHasFaction()) { if (!hasBypass && !assertHasFaction()) {
return; return;
} }
if (!Conf.ownedAreasEnabled) { if (!Conf.ownedAreasEnabled) {
fme.msg(TL.COMMAND_OWNER_DISABLED); fme.msg(TL.COMMAND_OWNER_DISABLED);
return; return;
} }
if (!hasBypass && Conf.ownedAreasLimitPerFaction > 0 && myFaction.getCountOfClaimsWithOwners() >= Conf.ownedAreasLimitPerFaction) { if (!hasBypass && Conf.ownedAreasLimitPerFaction > 0 && myFaction.getCountOfClaimsWithOwners() >= Conf.ownedAreasLimitPerFaction) {
fme.msg(TL.COMMAND_OWNER_LIMIT, Conf.ownedAreasLimitPerFaction); fme.msg(TL.COMMAND_OWNER_LIMIT, Conf.ownedAreasLimitPerFaction);
return; return;
} }
if (!hasBypass && !assertMinRole(Conf.ownedAreasModeratorsCanSet ? Role.MODERATOR : Role.LEADER)) { if (!hasBypass && !assertMinRole(Conf.ownedAreasModeratorsCanSet ? Role.MODERATOR : Role.LEADER)) {
return; return;
} }
FLocation flocation = new FLocation(fme); FLocation flocation = new FLocation(fme);
Faction factionHere = Board.getInstance().getFactionAt(flocation); Faction factionHere = Board.getInstance().getFactionAt(flocation);
if (factionHere != myFaction) { if (factionHere != myFaction) {
if (!factionHere.isNormal()) { if (!factionHere.isNormal()) {
fme.msg(TL.COMMAND_OWNER_NOTCLAIMED); fme.msg(TL.COMMAND_OWNER_NOTCLAIMED);
return; return;
} }
if (!hasBypass) { if (!hasBypass) {
fme.msg(TL.COMMAND_OWNER_WRONGFACTION); fme.msg(TL.COMMAND_OWNER_WRONGFACTION);
return; return;
} }
} }
FPlayer target = this.argAsBestFPlayerMatch(0, fme); FPlayer target = this.argAsBestFPlayerMatch(0, fme);
if (target == null) { if (target == null) {
return; return;
} }
String playerName = target.getName(); String playerName = target.getName();
if (target.getFaction() != myFaction) { if (target.getFaction() != myFaction) {
fme.msg(TL.COMMAND_OWNER_NOTMEMBER, playerName); fme.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 (args.isEmpty() && myFaction.doesLocationHaveOwnersSet(flocation)) { if (args.isEmpty() && myFaction.doesLocationHaveOwnersSet(flocation)) {
myFaction.clearClaimOwnership(flocation); myFaction.clearClaimOwnership(flocation);
fme.msg(TL.COMMAND_OWNER_CLEARED); fme.msg(TL.COMMAND_OWNER_CLEARED);
return; return;
} }
if (myFaction.isPlayerInOwnerList(target, flocation)) { if (myFaction.isPlayerInOwnerList(target, flocation)) {
myFaction.removePlayerAsOwner(target, flocation); myFaction.removePlayerAsOwner(target, flocation);
fme.msg(TL.COMMAND_OWNER_REMOVED, playerName); fme.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 (!payForCommand(Conf.econCostOwner, TL.COMMAND_OWNER_TOSET, TL.COMMAND_OWNER_FORSET)) { if (!payForCommand(Conf.econCostOwner, TL.COMMAND_OWNER_TOSET, TL.COMMAND_OWNER_FORSET)) {
return; return;
} }
myFaction.setPlayerAsOwner(target, flocation); myFaction.setPlayerAsOwner(target, flocation);
fme.msg(TL.COMMAND_OWNER_ADDED, playerName); fme.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,64 +9,64 @@ 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.requiredArgs.add(""); //this.requiredArgs.add("");
//this.optionalArgs.put("", ""); //this.optionalArgs.put("", "");
this.permission = Permission.OWNERLIST.node; this.permission = Permission.OWNERLIST.node;
this.disableOnLock = false; this.disableOnLock = false;
senderMustBePlayer = true; senderMustBePlayer = true;
senderMustBeMember = false; senderMustBeMember = false;
senderMustBeModerator = false; senderMustBeModerator = false;
senderMustBeColeader = false; senderMustBeColeader = false;
senderMustBeAdmin = false; senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform() {
boolean hasBypass = fme.isAdminBypassing(); boolean hasBypass = fme.isAdminBypassing();
if (!hasBypass && !assertHasFaction()) { if (!hasBypass && !assertHasFaction()) {
return; return;
} }
if (!Conf.ownedAreasEnabled) { if (!Conf.ownedAreasEnabled) {
fme.msg(TL.COMMAND_OWNERLIST_DISABLED); fme.msg(TL.COMMAND_OWNERLIST_DISABLED);
return; return;
} }
FLocation flocation = new FLocation(fme); FLocation flocation = new FLocation(fme);
if (Board.getInstance().getFactionAt(flocation) != myFaction) { if (Board.getInstance().getFactionAt(flocation) != myFaction) {
if (!hasBypass) { if (!hasBypass) {
fme.msg(TL.COMMAND_OWNERLIST_WRONGFACTION); fme.msg(TL.COMMAND_OWNERLIST_WRONGFACTION);
return; return;
} }
//TODO: This code won't ever be called. //TODO: This code won't ever be called.
myFaction = Board.getInstance().getFactionAt(flocation); myFaction = Board.getInstance().getFactionAt(flocation);
if (!myFaction.isNormal()) { if (!myFaction.isNormal()) {
fme.msg(TL.COMMAND_OWNERLIST_NOTCLAIMED); fme.msg(TL.COMMAND_OWNERLIST_NOTCLAIMED);
return; return;
} }
} }
String owners = myFaction.getOwnerListString(flocation); String owners = myFaction.getOwnerListString(flocation);
if (owners == null || owners.isEmpty()) { if (owners == null || owners.isEmpty()) {
fme.msg(TL.COMMAND_OWNERLIST_NONE); fme.msg(TL.COMMAND_OWNERLIST_NONE);
return; return;
} }
fme.msg(TL.COMMAND_OWNERLIST_OWNERS, owners); fme.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,44 +6,44 @@ 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() {
aliases.add("seepaypal"); aliases.add("seepaypal");
aliases.add("getpaypal"); aliases.add("getpaypal");
requiredArgs.add("faction"); requiredArgs.add("faction");
permission = Permission.ADMIN.node; permission = Permission.ADMIN.node;
disableOnLock = false; disableOnLock = false;
senderMustBePlayer = false; senderMustBePlayer = false;
senderMustBeMember = false; senderMustBeMember = false;
senderMustBeModerator = false; senderMustBeModerator = false;
senderMustBeColeader = false; senderMustBeColeader = false;
senderMustBeAdmin = false; senderMustBeAdmin = false;
} }
public void perform() { public void perform() {
if (!SavageFactions.plugin.getConfig().getBoolean("fpaypal.Enabled")) { if (!SavageFactions.plugin.getConfig().getBoolean("fpaypal.Enabled")) {
fme.msg(TL.GENERIC_DISABLED); fme.msg(TL.GENERIC_DISABLED);
} else { } else {
Faction faction = argAsFaction(0); Faction faction = argAsFaction(0);
if (faction != null) { if (faction != null) {
if (!faction.isWilderness() && !faction.isSafeZone() && !faction.isWarZone()) { if (!faction.isWilderness() && !faction.isSafeZone() && !faction.isWarZone()) {
if (faction.getPaypal() != null) { if (faction.getPaypal() != null) {
fme.msg(TL.COMMAND_PAYPALSEE_FACTION_PAYPAL.toString(), faction.getTag(), faction.getPaypal()); fme.msg(TL.COMMAND_PAYPALSEE_FACTION_PAYPAL.toString(), faction.getTag(), faction.getPaypal());
} else { } else {
fme.msg(TL.COMMAND_PAYPALSEE_FACTION_NOTSET.toString(), faction.getTag(), faction.getPaypal()); fme.msg(TL.COMMAND_PAYPALSEE_FACTION_NOTSET.toString(), faction.getTag(), faction.getPaypal());
} }
} else { } else {
fme.msg(TL.COMMAND_PAYPALSEE_FACTION_NOFACTION.toString(), me.getName()); fme.msg(TL.COMMAND_PAYPALSEE_FACTION_NOFACTION.toString(), me.getName());
} }
} }
} }
} }
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_PAYPALSEE_DESCRIPTION; return TL.COMMAND_PAYPALSEE_DESCRIPTION;
} }
} }

View File

@ -6,34 +6,34 @@ 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.aliases.add("paypal"); this.aliases.add("paypal");
this.requiredArgs.add("email"); this.requiredArgs.add("email");
this.permission = Permission.PAYPALSET.node; this.permission = Permission.PAYPALSET.node;
this.disableOnLock = false; this.disableOnLock = false;
this.senderMustBePlayer = true; this.senderMustBePlayer = true;
this.senderMustBeMember = false; this.senderMustBeMember = false;
this.senderMustBeModerator = false; this.senderMustBeModerator = false;
this.senderMustBeColeader = true; this.senderMustBeColeader = true;
this.senderMustBeAdmin = false; this.senderMustBeAdmin = false;
} }
public void perform() { public void perform() {
if (!SavageFactions.plugin.getConfig().getBoolean("fpaypal.Enabled")) { if (!SavageFactions.plugin.getConfig().getBoolean("fpaypal.Enabled")) {
fme.msg(TL.GENERIC_DISABLED); fme.msg(TL.GENERIC_DISABLED);
} else { } else {
String paypal = argAsString(0); String paypal = argAsString(0);
if (paypal != null) { if (paypal != null) {
myFaction.paypalSet(paypal); myFaction.paypalSet(paypal);
fme.msg(TL.COMMAND_PAYPALSET_SUCCESSFUL, paypal); fme.msg(TL.COMMAND_PAYPALSET_SUCCESSFUL, paypal);
} }
} }
} }
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_PAYPALSET_DESCRIPTION; return TL.COMMAND_PAYPALSET_DESCRIPTION;
} }
} }

View File

@ -8,55 +8,55 @@ 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.optionalArgs.put("", ""); //this.optionalArgs.put("", "");
this.permission = Permission.SET_PEACEFUL.node; this.permission = Permission.SET_PEACEFUL.node;
this.disableOnLock = true; this.disableOnLock = true;
senderMustBePlayer = false; senderMustBePlayer = false;
senderMustBeMember = false; senderMustBeMember = false;
senderMustBeModerator = false; senderMustBeModerator = false;
senderMustBeColeader = false; senderMustBeColeader = false;
senderMustBeAdmin = false; senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform() {
Faction faction = this.argAsFaction(0); Faction faction = this.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 = (fme == null ? TL.GENERIC_SERVERADMIN.toString() : fme.describeTo(fplayer, true)); String blame = (fme == null ? TL.GENERIC_SERVERADMIN.toString() : fme.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

@ -16,111 +16,111 @@ 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.disableOnLock = true; this.disableOnLock = true;
senderMustBePlayer = true; senderMustBePlayer = true;
senderMustBeMember = true; senderMustBeMember = true;
senderMustBeModerator = false; senderMustBeModerator = false;
senderMustBeColeader = false; senderMustBeColeader = false;
senderMustBeAdmin = true; senderMustBeAdmin = true;
} }
@Override @Override
public void perform() { public void perform() {
if (args.size() == 0) { if (args.size() == 0) {
PermissableRelationGUI gui = new PermissableRelationGUI(fme); PermissableRelationGUI gui = new PermissableRelationGUI(fme);
gui.build(); gui.build();
me.openInventory(gui.getInventory()); me.openInventory(gui.getInventory());
return; return;
} else if (args.size() == 1 && getPermissable(argAsString(0)) != null) { } else if (args.size() == 1 && getPermissable(argAsString(0)) != null) {
PermissableActionGUI gui = new PermissableActionGUI(fme, getPermissable(argAsString(0))); PermissableActionGUI gui = new PermissableActionGUI(fme, getPermissable(argAsString(0)));
gui.build(); gui.build();
me.openInventory(gui.getInventory()); me.openInventory(gui.getInventory());
return; return;
} }
// If not opening GUI, then setting the permission manually. // If not opening GUI, then setting the permission manually.
if (args.size() != 3) { if (args.size() != 3) {
fme.msg(TL.COMMAND_PERM_DESCRIPTION); fme.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 = argAsString(0).equalsIgnoreCase("all"); boolean allRelations = argAsString(0).equalsIgnoreCase("all");
boolean allActions = argAsString(1).equalsIgnoreCase("all"); boolean allActions = argAsString(1).equalsIgnoreCase("all");
if (allRelations) { if (allRelations) {
permissables.addAll(myFaction.getPermissions().keySet()); permissables.addAll(myFaction.getPermissions().keySet());
} else { } else {
Permissable permissable = getPermissable(argAsString(0)); Permissable permissable = getPermissable(argAsString(0));
if (permissable == null) { if (permissable == null) {
fme.msg(TL.COMMAND_PERM_INVALID_RELATION); fme.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(argAsString(1)); PermissableAction permissableAction = PermissableAction.fromString(argAsString(1));
if (permissableAction == null) { if (permissableAction == null) {
fme.msg(TL.COMMAND_PERM_INVALID_ACTION); fme.msg(TL.COMMAND_PERM_INVALID_ACTION);
return; return;
} }
permissableActions.add(permissableAction); permissableActions.add(permissableAction);
} }
Access access = Access.fromString(argAsString(2)); Access access = Access.fromString(argAsString(2));
if (access == null) { if (access == null) {
fme.msg(TL.COMMAND_PERM_INVALID_ACCESS); fme.msg(TL.COMMAND_PERM_INVALID_ACCESS);
return; return;
} }
for (Permissable permissable : permissables) { for (Permissable permissable : permissables) {
for (PermissableAction permissableAction : permissableActions) { for (PermissableAction permissableAction : permissableActions) {
fme.getFaction().setPermission(permissable, permissableAction, access); fme.getFaction().setPermission(permissable, permissableAction, access);
} }
} }
fme.msg(TL.COMMAND_PERM_SET, argAsString(1), access.name(), argAsString(0)); fme.msg(TL.COMMAND_PERM_SET, argAsString(1), access.name(), argAsString(0));
SavageFactions.plugin.log(String.format(TL.COMMAND_PERM_SET.toString(), argAsString(1), access.name(), argAsString(0)) + " for faction " + fme.getTag()); SavageFactions.plugin.log(String.format(TL.COMMAND_PERM_SET.toString(), argAsString(1), access.name(), argAsString(0)) + " for faction " + fme.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

@ -1,63 +1,63 @@
package com.massivecraft.factions.cmd; package com.massivecraft.factions.cmd;
import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.FPlayers; import com.massivecraft.factions.FPlayers;
import com.massivecraft.factions.Faction; import com.massivecraft.factions.Faction;
import com.massivecraft.factions.SavageFactions; import com.massivecraft.factions.SavageFactions;
import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.zcore.util.TL; 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.optionalArgs.put("", ""); //this.optionalArgs.put("", "");
this.permission = Permission.SET_PERMANENT.node; this.permission = Permission.SET_PERMANENT.node;
this.disableOnLock = true; this.disableOnLock = true;
senderMustBePlayer = false; senderMustBePlayer = false;
senderMustBeMember = false; senderMustBeMember = false;
senderMustBeModerator = false; senderMustBeModerator = false;
senderMustBeColeader = false; senderMustBeColeader = false;
senderMustBeAdmin = false; senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform() {
Faction faction = this.argAsFaction(0); Faction faction = this.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);
} }
SavageFactions.plugin.log((fme == null ? "A server admin" : fme.getName()) + " " + change + " the faction \"" + faction.getTag() + "\"."); SavageFactions.plugin.log((fme == null ? "A server admin" : fme.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 = (fme == null ? TL.GENERIC_SERVERADMIN.toString() : fme.describeTo(fplayer, true)); String blame = (fme == null ? TL.GENERIC_SERVERADMIN.toString() : fme.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

@ -1,59 +1,59 @@
package com.massivecraft.factions.cmd; package com.massivecraft.factions.cmd;
import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.Faction; import com.massivecraft.factions.Faction;
import com.massivecraft.factions.struct.Permission; 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.permission = Permission.SET_PERMANENTPOWER.node; this.permission = Permission.SET_PERMANENTPOWER.node;
this.disableOnLock = true; this.disableOnLock = true;
senderMustBePlayer = false; senderMustBePlayer = false;
senderMustBeMember = false; senderMustBeMember = false;
senderMustBeModerator = false; senderMustBeModerator = false;
senderMustBeColeader = false; senderMustBeColeader = false;
senderMustBeAdmin = false; senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform() {
Faction targetFaction = this.argAsFaction(0); Faction targetFaction = this.argAsFaction(0);
if (targetFaction == null) { if (targetFaction == null) {
return; return;
} }
Integer targetPower = this.argAsInt(1); Integer targetPower = this.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
msg(TL.COMMAND_PERMANENTPOWER_SUCCESS, change, targetFaction.describeTo(fme)); msg(TL.COMMAND_PERMANENTPOWER_SUCCESS, change, targetFaction.describeTo(fme));
// Inform all other players // Inform all other players
for (FPlayer fplayer : targetFaction.getFPlayersWhereOnline(true)) { for (FPlayer fplayer : targetFaction.getFPlayersWhereOnline(true)) {
if (fplayer == fme) { if (fplayer == fme) {
continue; continue;
} }
String blame = (fme == null ? TL.GENERIC_SERVERADMIN.toString() : fme.describeTo(fplayer, true)); String blame = (fme == null ? TL.GENERIC_SERVERADMIN.toString() : fme.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,50 +7,50 @@ 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.requiredArgs.add("faction tag"); //this.requiredArgs.add("faction tag");
this.optionalArgs.put("player name", "you"); this.optionalArgs.put("player name", "you");
this.permission = Permission.POWER.node; this.permission = Permission.POWER.node;
this.disableOnLock = false; this.disableOnLock = false;
senderMustBePlayer = false; senderMustBePlayer = false;
senderMustBeMember = false; senderMustBeMember = false;
senderMustBeModerator = false; senderMustBeModerator = false;
senderMustBeColeader = false; senderMustBeColeader = false;
senderMustBeAdmin = false; senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform() {
FPlayer target = this.argAsBestFPlayerMatch(0, fme); FPlayer target = this.argAsBestFPlayerMatch(0, fme);
if (target == null) { if (target == null) {
return; return;
} }
if (target != fme && !Permission.POWER_ANY.has(sender, true)) { if (target != fme && !Permission.POWER_ANY.has(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 (!payForCommand(Conf.econCostPower, TL.COMMAND_POWER_TOSHOW, TL.COMMAND_POWER_FORSHOW)) { if (!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 + ")";
msg(TL.COMMAND_POWER_POWER, target.describeTo(fme, true), target.getPowerRounded(), target.getPowerMaxRounded(), boost); msg(TL.COMMAND_POWER_POWER, target.describeTo(fme, 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

@ -1,88 +1,88 @@
package com.massivecraft.factions.cmd; package com.massivecraft.factions.cmd;
import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.Faction; import com.massivecraft.factions.Faction;
import com.massivecraft.factions.SavageFactions; import com.massivecraft.factions.SavageFactions;
import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
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.permission = Permission.POWERBOOST.node; this.permission = Permission.POWERBOOST.node;
this.disableOnLock = true; this.disableOnLock = true;
senderMustBePlayer = false; senderMustBePlayer = false;
senderMustBeMember = false; senderMustBeMember = false;
senderMustBeModerator = false; senderMustBeModerator = false;
senderMustBeColeader = false; senderMustBeColeader = false;
senderMustBeAdmin = false; senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform() {
String type = this.argAsString(0).toLowerCase(); String type = this.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")) {
msg(TL.COMMAND_POWERBOOST_HELP_1); msg(TL.COMMAND_POWERBOOST_HELP_1);
msg(TL.COMMAND_POWERBOOST_HELP_2); msg(TL.COMMAND_POWERBOOST_HELP_2);
return; return;
} }
Double targetPower = this.argAsDouble(2); Double targetPower = this.argAsDouble(2);
if (targetPower == null) { if (targetPower == null) {
if (this.argAsString(2).equalsIgnoreCase("reset")) { if (this.argAsString(2).equalsIgnoreCase("reset")) {
targetPower = 0D; targetPower = 0D;
} else { } else {
msg(TL.COMMAND_POWERBOOST_INVALIDNUM); msg(TL.COMMAND_POWERBOOST_INVALIDNUM);
return; return;
} }
} }
String target; String target;
if (doPlayer) { if (doPlayer) {
FPlayer targetPlayer = this.argAsBestFPlayerMatch(1); FPlayer targetPlayer = this.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 = this.argAsFaction(1); Faction targetFaction = this.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);
msg(TL.COMMAND_POWERBOOST_BOOST, target, roundedPower); msg(TL.COMMAND_POWERBOOST_BOOST, target, roundedPower);
if (!senderIsConsole) { if (!senderIsConsole) {
SavageFactions.plugin.log(TL.COMMAND_POWERBOOST_BOOSTLOG.toString(), fme.getName(), target, roundedPower); SavageFactions.plugin.log(TL.COMMAND_POWERBOOST_BOOSTLOG.toString(), fme.getName(), target, roundedPower);
} }
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_POWERBOOST_DESCRIPTION; return TL.COMMAND_POWERBOOST_DESCRIPTION;
} }
} }

View File

@ -2,9 +2,9 @@ package com.massivecraft.factions.cmd;
public class CmdPromote extends FPromoteCommand { public class CmdPromote extends FPromoteCommand {
public CmdPromote() { public CmdPromote() {
aliases.add("promote"); aliases.add("promote");
aliases.add("promo"); aliases.add("promo");
this.relative = 1; this.relative = 1;
} }
} }

View File

@ -4,8 +4,8 @@ import com.massivecraft.factions.struct.Relation;
public class CmdRelationAlly extends FRelationCommand { public class CmdRelationAlly extends FRelationCommand {
public CmdRelationAlly() { public CmdRelationAlly() {
aliases.add("ally"); aliases.add("ally");
targetRelation = Relation.ALLY; targetRelation = Relation.ALLY;
} }
} }

View File

@ -4,8 +4,8 @@ import com.massivecraft.factions.struct.Relation;
public class CmdRelationEnemy extends FRelationCommand { public class CmdRelationEnemy extends FRelationCommand {
public CmdRelationEnemy() { public CmdRelationEnemy() {
aliases.add("enemy"); aliases.add("enemy");
targetRelation = Relation.ENEMY; targetRelation = Relation.ENEMY;
} }
} }

View File

@ -4,8 +4,8 @@ import com.massivecraft.factions.struct.Relation;
public class CmdRelationNeutral extends FRelationCommand { public class CmdRelationNeutral extends FRelationCommand {
public CmdRelationNeutral() { public CmdRelationNeutral() {
aliases.add("neutral"); aliases.add("neutral");
targetRelation = Relation.NEUTRAL; targetRelation = Relation.NEUTRAL;
} }
} }

View File

@ -4,8 +4,8 @@ import com.massivecraft.factions.struct.Relation;
public class CmdRelationTruce extends FRelationCommand { public class CmdRelationTruce extends FRelationCommand {
public CmdRelationTruce() { public CmdRelationTruce() {
aliases.add("truce"); aliases.add("truce");
targetRelation = Relation.TRUCE; targetRelation = Relation.TRUCE;
} }
} }

View File

@ -8,41 +8,41 @@ 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.permission = Permission.RELOAD.node; this.permission = Permission.RELOAD.node;
this.disableOnLock = false; this.disableOnLock = false;
senderMustBePlayer = false; senderMustBePlayer = false;
senderMustBeMember = false; senderMustBeMember = false;
senderMustBeModerator = false; senderMustBeModerator = false;
senderMustBeColeader = false; senderMustBeColeader = false;
senderMustBeAdmin = false; senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform() {
long timeInitStart = System.currentTimeMillis(); long timeInitStart = System.currentTimeMillis();
Conf.load(); Conf.load();
Conf.save(); Conf.save();
SavageFactions.plugin.reloadConfig(); SavageFactions.plugin.reloadConfig();
SavageFactions.plugin.changeItemIDSInConfig(); SavageFactions.plugin.changeItemIDSInConfig();
SavageFactions.plugin.loadLang(); SavageFactions.plugin.loadLang();
int version = Integer.parseInt(ReflectionUtils.PackageType.getServerVersion().split("_")[1]); int version = Integer.parseInt(ReflectionUtils.PackageType.getServerVersion().split("_")[1]);
if (SavageFactions.plugin.getConfig().getBoolean("enable-faction-flight")) { if (SavageFactions.plugin.getConfig().getBoolean("enable-faction-flight")) {
SavageFactions.plugin.factionsFlight = true; SavageFactions.plugin.factionsFlight = true;
} }
long timeReload = (System.currentTimeMillis() - timeInitStart); long timeReload = (System.currentTimeMillis() - timeInitStart);
msg(TL.COMMAND_RELOAD_TIME, timeReload); 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,84 +8,84 @@ 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.errorOnToManyArgs = false; this.errorOnToManyArgs = false;
permission = Permission.RULES.node; permission = Permission.RULES.node;
senderMustBePlayer = true; senderMustBePlayer = true;
senderMustBeMember = true; senderMustBeMember = true;
senderMustBeModerator = false; senderMustBeModerator = false;
senderMustBeColeader = true; senderMustBeColeader = true;
senderMustBeAdmin = false; senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform() {
if (!SavageFactions.plugin.getConfig().getBoolean("frules.Enabled")) { if (!SavageFactions.plugin.getConfig().getBoolean("frules.Enabled")) {
fme.msg(TL.COMMAND_RULES_DISABLED_MSG); fme.msg(TL.COMMAND_RULES_DISABLED_MSG);
return; return;
} }
if (this.args.size() == 0) { if (this.args.size() == 0) {
HashMap<Integer, String> rules = fme.getFaction().getRulesMap(); HashMap<Integer, String> rules = fme.getFaction().getRulesMap();
if (rules.size() == 0) { if (rules.size() == 0) {
List<String> ruleList = SavageFactions.plugin.getConfig().getStringList("frules.default-rules"); List<String> ruleList = SavageFactions.plugin.getConfig().getStringList("frules.default-rules");
fme.sendMessage(SavageFactions.plugin.colorList(ruleList)); fme.sendMessage(SavageFactions.plugin.colorList(ruleList));
} else { } else {
for (int i = 0; i <= rules.size() - 1; i++) { for (int i = 0; i <= rules.size() - 1; i++) {
fme.sendMessage(SavageFactions.plugin.color(rules.get(i))); fme.sendMessage(SavageFactions.plugin.color(rules.get(i)));
} }
} }
} }
if (this.args.size() == 1) { if (this.args.size() == 1) {
if (args.get(0).equalsIgnoreCase("add")) { if (args.get(0).equalsIgnoreCase("add")) {
fme.msg(TL.COMMAND_RULES_ADD_INVALIDARGS); fme.msg(TL.COMMAND_RULES_ADD_INVALIDARGS);
} }
if (args.get(0).equalsIgnoreCase("set")) { if (args.get(0).equalsIgnoreCase("set")) {
fme.msg(TL.COMMAND_RULES_SET_INVALIDARGS); fme.msg(TL.COMMAND_RULES_SET_INVALIDARGS);
} }
if (args.get(0).equalsIgnoreCase("remove")) { if (args.get(0).equalsIgnoreCase("remove")) {
fme.msg(TL.COMMAND_RULES_REMOVE_INVALIDARGS); fme.msg(TL.COMMAND_RULES_REMOVE_INVALIDARGS);
} }
if (args.get(0).equalsIgnoreCase("clear")) { if (args.get(0).equalsIgnoreCase("clear")) {
fme.getFaction().clearRules(); fme.getFaction().clearRules();
fme.msg(TL.COMMAND_RULES_CLEAR_SUCCESS); fme.msg(TL.COMMAND_RULES_CLEAR_SUCCESS);
} }
} }
if (this.args.size() >= 2) { if (this.args.size() >= 2) {
if (args.get(0).equalsIgnoreCase("add")) { if (args.get(0).equalsIgnoreCase("add")) {
String message = ""; String message = "";
StringBuilder string = new StringBuilder(message); StringBuilder string = new StringBuilder(message);
for (int i = 1; i <= args.size() - 1; i++) { for (int i = 1; i <= args.size() - 1; i++) {
string.append(" " + args.get(i)); string.append(" " + args.get(i));
} }
fme.getFaction().addRule(string.toString()); fme.getFaction().addRule(string.toString());
fme.msg(TL.COMMAND_RULES_ADD_SUCCESS); fme.msg(TL.COMMAND_RULES_ADD_SUCCESS);
} }
if (this.args.size() == 2) { if (this.args.size() == 2) {
if (args.get(0).equalsIgnoreCase("remove")) { if (args.get(0).equalsIgnoreCase("remove")) {
int index = argAsInt(1); int index = argAsInt(1);
fme.getFaction().removeRule(index - 1); fme.getFaction().removeRule(index - 1);
fme.msg(TL.COMMAND_RULES_REMOVE_SUCCESS); fme.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,28 +6,28 @@ 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.permission = Permission.SCOREBOARD.node; this.permission = Permission.SCOREBOARD.node;
this.senderMustBePlayer = true; this.senderMustBePlayer = true;
} }
@Override @Override
public void perform() { public void perform() {
boolean toggleTo = !fme.showScoreboard(); boolean toggleTo = !fme.showScoreboard();
FScoreboard board = FScoreboard.get(fme); FScoreboard board = FScoreboard.get(fme);
if (board == null) { if (board == null) {
me.sendMessage(TL.COMMAND_TOGGLESB_DISABLED.toString()); me.sendMessage(TL.COMMAND_TOGGLESB_DISABLED.toString());
} else { } else {
me.sendMessage(TL.TOGGLE_SB.toString().replace("{value}", String.valueOf(toggleTo))); me.sendMessage(TL.TOGGLE_SB.toString().replace("{value}", String.valueOf(toggleTo)));
board.setSidebarVisibility(toggleTo); board.setSidebarVisibility(toggleTo);
} }
fme.setShowScoreboard(toggleTo); fme.setShowScoreboard(toggleTo);
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_SCOREBOARD_DESCRIPTION; return TL.COMMAND_SCOREBOARD_DESCRIPTION;
} }
} }

View File

@ -11,52 +11,52 @@ import org.bukkit.World;
public class CmdSafeunclaimall extends FCommand { public class CmdSafeunclaimall extends FCommand {
public CmdSafeunclaimall() { public CmdSafeunclaimall() {
this.aliases.add("safeunclaimall"); this.aliases.add("safeunclaimall");
this.aliases.add("safedeclaimall"); this.aliases.add("safedeclaimall");
//this.requiredArgs.add(""); //this.requiredArgs.add("");
this.optionalArgs.put("world", "all"); this.optionalArgs.put("world", "all");
this.permission = Permission.MANAGE_SAFE_ZONE.node; this.permission = Permission.MANAGE_SAFE_ZONE.node;
this.disableOnLock = true; this.disableOnLock = true;
senderMustBePlayer = false; senderMustBePlayer = false;
senderMustBeMember = false; senderMustBeMember = false;
senderMustBeModerator = false; senderMustBeModerator = false;
senderMustBeColeader = false; senderMustBeColeader = false;
senderMustBeAdmin = false; senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform() {
String worldName = argAsString(0); String worldName = argAsString(0);
World world = null; World world = null;
if (worldName != null) { if (worldName != null) {
world = Bukkit.getWorld(worldName); world = Bukkit.getWorld(worldName);
} }
String id = Factions.getInstance().getSafeZone().getId(); String id = Factions.getInstance().getSafeZone().getId();
if (world == null) { if (world == null) {
Board.getInstance().unclaimAll(id); Board.getInstance().unclaimAll(id);
} else { } else {
Board.getInstance().unclaimAllInWorld(id, world); Board.getInstance().unclaimAllInWorld(id, world);
} }
msg(TL.COMMAND_SAFEUNCLAIMALL_UNCLAIMED); msg(TL.COMMAND_SAFEUNCLAIMALL_UNCLAIMED);
if (Conf.logLandUnclaims) { if (Conf.logLandUnclaims) {
SavageFactions.plugin.log(TL.COMMAND_SAFEUNCLAIMALL_UNCLAIMEDLOG.format(sender.getName())); SavageFactions.plugin.log(TL.COMMAND_SAFEUNCLAIMALL_UNCLAIMEDLOG.format(sender.getName()));
} }
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_SAFEUNCLAIMALL_DESCRIPTION; return TL.COMMAND_SAFEUNCLAIMALL_DESCRIPTION;
} }
} }

View File

@ -1,44 +1,44 @@
package com.massivecraft.factions.cmd; package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Board; import com.massivecraft.factions.Board;
import com.massivecraft.factions.Conf; import com.massivecraft.factions.Conf;
import com.massivecraft.factions.FPlayers; import com.massivecraft.factions.FPlayers;
import com.massivecraft.factions.Factions; import com.massivecraft.factions.Factions;
import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.zcore.util.TL; 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.requiredArgs.add(""); //this.requiredArgs.add("");
//this.optionalArgs.put("", ""); //this.optionalArgs.put("", "");
this.permission = Permission.SAVE.node; this.permission = Permission.SAVE.node;
this.disableOnLock = false; this.disableOnLock = false;
senderMustBePlayer = false; senderMustBePlayer = false;
senderMustBeMember = false; senderMustBeMember = false;
senderMustBeModerator = false; senderMustBeModerator = false;
senderMustBeColeader = false; senderMustBeColeader = false;
senderMustBeAdmin = false; senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform() {
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();
msg(TL.COMMAND_SAVEALL_SUCCESS); 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,137 +15,137 @@ import java.util.Iterator;
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<>();
Long interval = 10L; Long interval = 10L;
private boolean useParticles; private boolean useParticles;
private int length; private int length;
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");
permission = Permission.SEECHUNK.node; permission = Permission.SEECHUNK.node;
senderMustBePlayer = true; senderMustBePlayer = true;
senderMustBeMember = false; senderMustBeMember = false;
senderMustBeModerator = false; senderMustBeModerator = false;
senderMustBeAdmin = false; senderMustBeAdmin = false;
this.useParticles = p.getConfig().getBoolean("see-chunk.particles", true); this.useParticles = p.getConfig().getBoolean("see-chunk.particles", true);
interval = SavageFactions.plugin.getConfig().getLong("see-chunk.interval", 10L); interval = SavageFactions.plugin.getConfig().getLong("see-chunk.interval", 10L);
if (effect == null) { if (effect == null) {
effect = ParticleEffect.REDSTONE; effect = ParticleEffect.REDSTONE;
} }
} }
@Override @Override
public void perform() { public void perform() {
if (seeChunkMap.containsKey(me.getName())) { if (seeChunkMap.containsKey(me.getName())) {
seeChunkMap.remove(me.getName()); seeChunkMap.remove(me.getName());
msg(TL.COMMAND_SEECHUNK_DISABLED); msg(TL.COMMAND_SEECHUNK_DISABLED);
} else { } else {
seeChunkMap.put(me.getName(), true); seeChunkMap.put(me.getName(), true);
msg(TL.COMMAND_SEECHUNK_ENABLED); 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(SavageFactions.plugin, new Runnable() { taskID = Bukkit.getScheduler().scheduleSyncRepeatingTask(SavageFactions.plugin, new Runnable() {
@Override @Override
public void run() { public void run() {
Iterator<String> itr = seeChunkMap.keySet().iterator(); Iterator<String> itr = seeChunkMap.keySet().iterator();
while (itr.hasNext()) { while (itr.hasNext()) {
Object nameObject = itr.next(); Object nameObject = itr.next();
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) { private void showPillar(Player player, World world, int blockX, int blockZ) {
for (int blockY = 0; blockY < player.getLocation().getBlockY() + 30; blockY++) { for (int blockY = 0; blockY < player.getLocation().getBlockY() + 30; blockY++) {
Location loc = new Location(world, blockX, blockY, blockZ).add(0.5, 0, 0.5); Location loc = new Location(world, blockX, blockY, blockZ).add(0.5, 0, 0.5);
if (loc.getBlock().getType() != Material.AIR) { if (loc.getBlock().getType() != Material.AIR) {
continue; continue;
} }
if (useParticles) { if (useParticles) {
if (SavageFactions.plugin.useNonPacketParticles) { if (SavageFactions.plugin.useNonPacketParticles) {
// Dust options only exists in the 1.13 API, so we use an // Dust options only exists in the 1.13 API, so we use an
// alternative method to achieve this in lower versions. // alternative method to achieve this in lower versions.
if (SavageFactions.plugin.mc113) { if (SavageFactions.plugin.mc113) {
player.spawnParticle(Particle.REDSTONE, loc, 0, new Particle.DustOptions(Color.RED, 1)); player.spawnParticle(Particle.REDSTONE, loc, 0, new Particle.DustOptions(Color.RED, 1));
} else { } else {
player.getWorld().spawnParticle(Particle.REDSTONE, loc, 0, 255, 0, 0, 1); player.getWorld().spawnParticle(Particle.REDSTONE, loc, 0, 255, 0, 0, 1);
} }
} else { } else {
this.effect.display(0, 0, 0, 0, 1, loc, player); this.effect.display(0, 0, 0, 0, 1, loc, player);
} }
} else { } else {
Material type = blockY % 5 == 0 ? SavageFactions.plugin.REDSTONE_LAMP_ON : SavageFactions.plugin.STAINED_GLASS; Material type = blockY % 5 == 0 ? SavageFactions.plugin.REDSTONE_LAMP_ON : SavageFactions.plugin.STAINED_GLASS;
VisualizeUtil.addLocation(player, loc, type); VisualizeUtil.addLocation(player, loc, type);
} }
} }
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.GENERIC_PLACEHOLDER; return TL.GENERIC_PLACEHOLDER;
} }
} }

View File

@ -5,35 +5,35 @@ 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");
permission = Permission.BANNER.node; permission = Permission.BANNER.node;
senderMustBePlayer = true; senderMustBePlayer = true;
senderMustBeMember = false; senderMustBeMember = false;
senderMustBeModerator = false; senderMustBeModerator = false;
senderMustBeAdmin = true; senderMustBeAdmin = true;
} }
public void perform() { public void perform() {
if (!me.getItemInHand().getType().toString().contains("BANNER")) { if (!me.getItemInHand().getType().toString().contains("BANNER")) {
fme.msg(TL.COMMAND_SETBANNER_NOTBANNER); fme.msg(TL.COMMAND_SETBANNER_NOTBANNER);
return; return;
} }
fme.getFaction().setBannerPattern(me.getItemInHand()); fme.getFaction().setBannerPattern(me.getItemInHand());
fme.msg(TL.COMMAND_SETBANNER_SUCCESS); fme.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,43 +6,43 @@ 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.senderMustBeAdmin = true; this.senderMustBeAdmin = true;
this.senderMustBePlayer = true; this.senderMustBePlayer = true;
senderMustBeColeader = false; senderMustBeColeader = false;
this.permission = Permission.DEFAULTRANK.node; this.permission = Permission.DEFAULTRANK.node;
} }
@Override @Override
public void perform() { public void perform() {
Role target = Role.fromString(argAsString(0).toUpperCase()); Role target = Role.fromString(argAsString(0).toUpperCase());
if (target == null) { if (target == null) {
msg(TL.COMMAND_SETDEFAULTROLE_INVALIDROLE, argAsString(0)); msg(TL.COMMAND_SETDEFAULTROLE_INVALIDROLE, argAsString(0));
return; return;
} }
if (target == Role.LEADER) { if (target == Role.LEADER) {
msg(TL.COMMAND_SETDEFAULTROLE_NOTTHATROLE, argAsString(0)); msg(TL.COMMAND_SETDEFAULTROLE_NOTTHATROLE, argAsString(0));
return; return;
} }
myFaction.setDefaultRole(target); myFaction.setDefaultRole(target);
msg(TL.COMMAND_SETDEFAULTROLE_SUCCESS, target.nicename); 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

@ -12,72 +12,72 @@ 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.senderMustBeMember = true; this.senderMustBeMember = true;
this.senderMustBeModerator = false; this.senderMustBeModerator = false;
this.senderMustBePlayer = true; this.senderMustBePlayer = true;
this.permission = Permission.SETWARP.node; this.permission = Permission.SETWARP.node;
} }
@Override @Override
public void perform() { public void perform() {
if (!(fme.getRelationToLocation() == Relation.MEMBER)) { if (!(fme.getRelationToLocation() == Relation.MEMBER)) {
fme.msg(TL.COMMAND_SETFWARP_NOTCLAIMED); fme.msg(TL.COMMAND_SETFWARP_NOTCLAIMED);
return; return;
} }
// This statement allows us to check if they've specifically denied it, or default to // This statement allows us to check if they've specifically denied it, or default to
// the old setting of allowing moderators to set warps. // the old setting of allowing moderators to set warps.
if (!fme.isAdminBypassing()) { if (!fme.isAdminBypassing()) {
Access access = myFaction.getAccess(fme, PermissableAction.SETWARP); Access access = myFaction.getAccess(fme, PermissableAction.SETWARP);
if (access != Access.ALLOW && fme.getRole() != Role.LEADER) { if (access != Access.ALLOW && fme.getRole() != Role.LEADER) {
fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "set warps"); fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "set warps");
return; return;
} }
} }
String warp = argAsString(0); String warp = 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 = myFaction.isWarp(warp); boolean warpExists = myFaction.isWarp(warp);
int maxWarps = SavageFactions.plugin.getConfig().getInt("max-warps", 5); int maxWarps = SavageFactions.plugin.getConfig().getInt("max-warps", 5);
boolean tooManyWarps = maxWarps <= myFaction.getWarps().size(); boolean tooManyWarps = maxWarps <= myFaction.getWarps().size();
if (tooManyWarps && !warpExists) { if (tooManyWarps && !warpExists) {
fme.msg(TL.COMMAND_SETFWARP_LIMIT, maxWarps); fme.msg(TL.COMMAND_SETFWARP_LIMIT, maxWarps);
return; return;
} }
if (!transact(fme)) { if (!transact(fme)) {
return; return;
} }
String password = argAsString(1); String password = argAsString(1);
LazyLocation loc = new LazyLocation(fme.getPlayer().getLocation()); LazyLocation loc = new LazyLocation(fme.getPlayer().getLocation());
myFaction.setWarp(warp, loc); myFaction.setWarp(warp, loc);
if (password != null) { if (password != null) {
myFaction.setWarpPassword(warp, password); myFaction.setWarpPassword(warp, password);
} }
fme.msg(TL.COMMAND_SETFWARP_SET, warp, password != null ? password : ""); fme.msg(TL.COMMAND_SETFWARP_SET, warp, password != null ? password : "");
} }
private boolean transact(FPlayer player) { private boolean transact(FPlayer player) {
return !SavageFactions.plugin.getConfig().getBoolean("warp-cost.enabled", false) || player.isAdminBypassing() || payForCommand(SavageFactions.plugin.getConfig().getDouble("warp-cost.setwarp", 5), TL.COMMAND_SETFWARP_TOSET.toString(), TL.COMMAND_SETFWARP_FORSET.toString()); return !SavageFactions.plugin.getConfig().getBoolean("warp-cost.enabled", false) || player.isAdminBypassing() || payForCommand(SavageFactions.plugin.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,44 +7,44 @@ 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.permission = Permission.SETMAXVAULTS.node; this.permission = Permission.SETMAXVAULTS.node;
this.disableOnLock = false; this.disableOnLock = false;
senderMustBePlayer = false; senderMustBePlayer = false;
senderMustBeMember = false; senderMustBeMember = false;
senderMustBeModerator = false; senderMustBeModerator = false;
senderMustBeColeader = false; senderMustBeColeader = false;
senderMustBeAdmin = false; senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform() {
Faction targetFaction = argAsFaction(0); Faction targetFaction = argAsFaction(0);
int value = argAsInt(1, -1); int value = argAsInt(1, -1);
if (value < 0) { if (value < 0) {
sender.sendMessage(ChatColor.RED + "Number must be greater than 0."); sender.sendMessage(ChatColor.RED + "Number must be greater than 0.");
return; return;
} }
if (targetFaction == null) { if (targetFaction == null) {
sender.sendMessage(ChatColor.RED + "Couldn't find Faction: " + ChatColor.YELLOW + argAsString(0)); sender.sendMessage(ChatColor.RED + "Couldn't find Faction: " + ChatColor.YELLOW + argAsString(0));
return; return;
} }
targetFaction.setMaxVaults(value); targetFaction.setMaxVaults(value);
sender.sendMessage(TL.COMMAND_SETMAXVAULTS_SUCCESS.format(targetFaction.getTag(), value)); 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

@ -12,68 +12,68 @@ 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.requiredArgs.add(""); //this.requiredArgs.add("");
this.optionalArgs.put("faction tag", "mine"); this.optionalArgs.put("faction tag", "mine");
this.permission = Permission.SETHOME.node; this.permission = Permission.SETHOME.node;
this.disableOnLock = true; this.disableOnLock = true;
senderMustBePlayer = true; senderMustBePlayer = true;
senderMustBeMember = false; senderMustBeMember = false;
senderMustBeModerator = false; senderMustBeModerator = false;
senderMustBeColeader = false; senderMustBeColeader = false;
senderMustBeAdmin = false; senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform() {
if (!Conf.homesEnabled) { if (!Conf.homesEnabled) {
fme.msg(TL.COMMAND_SETHOME_DISABLED); fme.msg(TL.COMMAND_SETHOME_DISABLED);
return; return;
} }
Faction faction = this.argAsFaction(0, myFaction); Faction faction = this.argAsFaction(0, myFaction);
if (faction == null) { if (faction == null) {
return; return;
} }
if (!fme.isAdminBypassing()) { if (!fme.isAdminBypassing()) {
Access access = myFaction.getAccess(fme, PermissableAction.SETHOME); Access access = myFaction.getAccess(fme, PermissableAction.SETHOME);
if (access != Access.ALLOW && fme.getRole() != Role.LEADER && !Permission.SETHOME_ANY.has(sender, true)) { if (access != Access.ALLOW && fme.getRole() != Role.LEADER && !Permission.SETHOME_ANY.has(sender, true)) {
fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "set home"); fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "set home");
return; return;
} }
} }
// Can the player set the faction home HERE? // Can the player set the faction home HERE?
if (!Permission.BYPASS.has(me) && if (!Permission.BYPASS.has(me) &&
Conf.homesMustBeInClaimedTerritory && Conf.homesMustBeInClaimedTerritory &&
Board.getInstance().getFactionAt(new FLocation(me)) != faction) { Board.getInstance().getFactionAt(new FLocation(me)) != faction) {
fme.msg(TL.COMMAND_SETHOME_NOTCLAIMED); fme.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 (!payForCommand(Conf.econCostSethome, TL.COMMAND_SETHOME_TOSET, TL.COMMAND_SETHOME_FORSET)) { if (!payForCommand(Conf.econCostSethome, TL.COMMAND_SETHOME_TOSET, TL.COMMAND_SETHOME_FORSET)) {
return; return;
} }
faction.setHome(me.getLocation()); faction.setHome(me.getLocation());
faction.msg(TL.COMMAND_SETHOME_SET, fme.describeTo(myFaction, true)); faction.msg(TL.COMMAND_SETHOME_SET, fme.describeTo(myFaction, true));
faction.sendMessage(p.cmdBase.cmdHome.getUseageTemplate()); faction.sendMessage(p.cmdBase.cmdHome.getUseageTemplate());
if (faction != myFaction) { if (faction != myFaction) {
fme.msg(TL.COMMAND_SETHOME_SETOTHER, faction.getTag(fme)); fme.msg(TL.COMMAND_SETHOME_SETOTHER, faction.getTag(fme));
} }
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_SETHOME_DESCRIPTION; return TL.COMMAND_SETHOME_DESCRIPTION;
} }
} }

View File

@ -14,105 +14,105 @@ 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.permission = Permission.SHOW.node; this.permission = Permission.SHOW.node;
this.disableOnLock = false; this.disableOnLock = false;
senderMustBeMember = false; senderMustBeMember = false;
senderMustBeModerator = false; senderMustBeModerator = false;
senderMustBeAdmin = false; senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform() {
Faction faction = myFaction; Faction faction = myFaction;
if (this.argIsSet(0)) if (this.argIsSet(0))
faction = this.argAsFaction(0); faction = this.argAsFaction(0);
if (faction == null) if (faction == null)
return; return;
if (fme != null && !fme.getPlayer().hasPermission("factions.show.bypassexempt") if (fme != null && !fme.getPlayer().hasPermission("factions.show.bypassexempt")
&& SavageFactions.plugin.getConfig().getStringList("show-exempt").contains(faction.getTag())) { && SavageFactions.plugin.getConfig().getStringList("show-exempt").contains(faction.getTag())) {
msg(TL.COMMAND_SHOW_EXEMPT); 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 (!payForCommand(Conf.econCostShow, TL.COMMAND_SHOW_TOSHOW, TL.COMMAND_SHOW_FORSHOW)) { if (!payForCommand(Conf.econCostShow, TL.COMMAND_SHOW_TOSHOW, TL.COMMAND_SHOW_FORSHOW)) {
return; return;
} }
List<String> show = SavageFactions.plugin.getConfig().getStringList("show"); List<String> show = SavageFactions.plugin.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(fme); String tag = faction.getTag(fme);
// 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)) {
msg(p.txt.titleize(tag)); msg(p.txt.titleize(tag));
} else { } else {
msg(p.txt.parse(TagReplacer.FACTION.replace(header, tag))); msg(p.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, fme, raw); // use relations String parsed = TagUtil.parsePlain(faction, fme, raw); // use relations
if (parsed == null) { if (parsed == null) {
continue; // Due to minimal f show. continue; // Due to minimal f show.
} }
if (fme != null) { if (fme != null) {
parsed = TagUtil.parsePlaceholders(fme.getPlayer(), parsed); parsed = TagUtil.parsePlaceholders(fme.getPlayer(), parsed);
} }
if (TagUtil.hasFancy(parsed)) { if (TagUtil.hasFancy(parsed)) {
List<FancyMessage> fancy = TagUtil.parseFancy(faction, fme, parsed); List<FancyMessage> fancy = TagUtil.parseFancy(faction, fme, parsed);
if (fancy != null) if (fancy != null)
sendFancyMessage(fancy); 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.
} }
msg(p.txt.parse(parsed)); msg(p.txt.parse(parsed));
} }
} }
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_SHOW_COMMANDDESCRIPTION; return TL.COMMAND_SHOW_COMMANDDESCRIPTION;
} }
} }

View File

@ -8,51 +8,51 @@ 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");
permission = Permission.SHOWCLAIMS.node; permission = Permission.SHOWCLAIMS.node;
this.senderMustBePlayer = true; this.senderMustBePlayer = true;
this.senderMustBeMember = true; this.senderMustBeMember = true;
this.senderMustBeModerator = false; this.senderMustBeModerator = false;
this.senderMustBePlayer = true; this.senderMustBePlayer = true;
} }
@Override @Override
public void perform() { public void perform() {
sendMessage(TL.COMMAND_SHOWCLAIMS_HEADER.toString().replace("{faction}", fme.getFaction().describeTo(fme))); sendMessage(TL.COMMAND_SHOWCLAIMS_HEADER.toString().replace("{faction}", fme.getFaction().describeTo(fme)));
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 : fme.getFaction().getAllClaims()) { for (FLocation fLocation : fme.getFaction().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);
sendMessage(message.replace("{chunks}", "")); // made {chunks} blank as I removed the placeholder and people wont update their config :shrug: sendMessage(message.replace("{chunks}", "")); // made {chunks} blank as I removed the placeholder and people wont update their config :shrug:
StringBuilder chunks = new StringBuilder(); StringBuilder chunks = new StringBuilder();
for (String chunkString : chunkMap.get(world)) { for (String chunkString : chunkMap.get(world)) {
chunks.append(chunkString + ", "); chunks.append(chunkString + ", ");
if (chunks.toString().length() >= 2000) { if (chunks.toString().length() >= 2000) {
sendMessage(chunks.toString()); sendMessage(chunks.toString());
chunks.setLength(0); chunks.setLength(0);
} }
} }
sendMessage(""); sendMessage("");
} }
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_SHOWCLAIMS_DESCRIPTION; return TL.COMMAND_SHOWCLAIMS_DESCRIPTION;
} }
} }

View File

@ -10,32 +10,32 @@ 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");
permission = Permission.SHOW_INVITES.node; permission = Permission.SHOW_INVITES.node;
senderMustBePlayer = true; senderMustBePlayer = true;
senderMustBeMember = true; senderMustBeMember = true;
} }
@Override @Override
public void perform() { public void perform() {
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 : myFaction.getInvites()) { for (String id : myFaction.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);
} }
sendFancyMessage(msg); sendFancyMessage(msg);
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_SHOWINVITES_DESCRIPTION; return TL.COMMAND_SHOWINVITES_DESCRIPTION;
} }
} }

View File

@ -10,35 +10,35 @@ 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.permission = Permission.STATUS.node; this.permission = Permission.STATUS.node;
senderMustBePlayer = true; senderMustBePlayer = true;
senderMustBeMember = true; senderMustBeMember = true;
senderMustBeModerator = false; senderMustBeModerator = false;
senderMustBeAdmin = false; senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform() {
ArrayList<String> ret = new ArrayList<>(); ArrayList<String> ret = new ArrayList<>();
for (FPlayer fp : myFaction.getFPlayers()) { for (FPlayer fp : myFaction.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());
} }
fme.sendMessage(ret); fme.sendMessage(ret);
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_STATUS_DESCRIPTION; return TL.COMMAND_STATUS_DESCRIPTION;
} }
} }

View File

@ -5,32 +5,32 @@ 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.permission = Permission.STEALTH.node; this.permission = Permission.STEALTH.node;
this.disableOnLock = true; this.disableOnLock = true;
this.senderMustBePlayer = true; this.senderMustBePlayer = true;
this.senderMustBeMember = false; this.senderMustBeMember = false;
this.senderMustBeModerator = false; this.senderMustBeModerator = false;
this.senderMustBeColeader = false; this.senderMustBeColeader = false;
this.senderMustBeAdmin = false; this.senderMustBeAdmin = false;
} }
public void perform() { public void perform() {
Faction faction = fme.getFaction(); Faction faction = fme.getFaction();
if (faction != null && !faction.getId().equalsIgnoreCase("0") && !faction.getId().equalsIgnoreCase("none") && !faction.getId().equalsIgnoreCase("safezone") && !faction.getId().equalsIgnoreCase("warzone")) { if (faction != null && !faction.getId().equalsIgnoreCase("0") && !faction.getId().equalsIgnoreCase("none") && !faction.getId().equalsIgnoreCase("safezone") && !faction.getId().equalsIgnoreCase("warzone")) {
fme.setStealth(!fme.isStealthEnabled()); fme.setStealth(!fme.isStealthEnabled());
fme.msg(fme.isStealthEnabled() ? TL.COMMAND_STEALTH_ENABLE : TL.COMMAND_STEALTH_DISABLE); fme.msg(fme.isStealthEnabled() ? TL.COMMAND_STEALTH_ENABLE : TL.COMMAND_STEALTH_DISABLE);
} else { } else {
fme.msg(TL.COMMAND_STEALTH_MUSTBEMEMBER); fme.msg(TL.COMMAND_STEALTH_MUSTBEMEMBER);
} }
} }
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_STEALTH_DESCRIPTION; return TL.COMMAND_STEALTH_DESCRIPTION;
} }
} }

View File

@ -14,98 +14,98 @@ import org.bukkit.scheduler.BukkitRunnable;
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.permission = Permission.STUCK.node; this.permission = Permission.STUCK.node;
this.disableOnLock = true; this.disableOnLock = true;
senderMustBePlayer = false; senderMustBePlayer = false;
senderMustBeMember = false; senderMustBeMember = false;
senderMustBeModerator = false; senderMustBeModerator = false;
senderMustBeAdmin = false; senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform() {
final Player player = fme.getPlayer(); final Player player = fme.getPlayer();
final Location sentAt = player.getLocation(); final Location sentAt = player.getLocation();
final FLocation chunk = fme.getLastStoodAt(); final FLocation chunk = fme.getLastStoodAt();
final long delay = SavageFactions.plugin.getConfig().getLong("hcf.stuck.delay", 30); final long delay = SavageFactions.plugin.getConfig().getLong("hcf.stuck.delay", 30);
final int radius = SavageFactions.plugin.getConfig().getInt("hcf.stuck.radius", 10); final int radius = SavageFactions.plugin.getConfig().getInt("hcf.stuck.radius", 10);
if (SavageFactions.plugin.getStuckMap().containsKey(player.getUniqueId())) { if (SavageFactions.plugin.getStuckMap().containsKey(player.getUniqueId())) {
long wait = SavageFactions.plugin.getTimers().get(player.getUniqueId()) - System.currentTimeMillis(); long wait = SavageFactions.plugin.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);
msg(TL.COMMAND_STUCK_EXISTS, time); 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 (!payForCommand(Conf.econCostStuck, TL.COMMAND_STUCK_TOSTUCK.format(fme.getName()), TL.COMMAND_STUCK_FORSTUCK.format(fme.getName()))) { if (!payForCommand(Conf.econCostStuck, TL.COMMAND_STUCK_TOSTUCK.format(fme.getName()), TL.COMMAND_STUCK_FORSTUCK.format(fme.getName()))) {
return; return;
} }
final int id = Bukkit.getScheduler().runTaskLater(SavageFactions.plugin, new BukkitRunnable() { final int id = Bukkit.getScheduler().runTaskLater(SavageFactions.plugin, new BukkitRunnable() {
@Override @Override
public void run() { public void run() {
if (!SavageFactions.plugin.getStuckMap().containsKey(player.getUniqueId())) { if (!SavageFactions.plugin.getStuckMap().containsKey(player.getUniqueId())) {
return; return;
} }
// check for world difference or radius exceeding // check for world difference or radius exceeding
final World world = chunk.getWorld(); final World world = chunk.getWorld();
if (world.getUID() != player.getWorld().getUID() || sentAt.distance(player.getLocation()) > radius) { if (world.getUID() != player.getWorld().getUID() || sentAt.distance(player.getLocation()) > radius) {
msg(TL.COMMAND_STUCK_OUTSIDE.format(radius)); msg(TL.COMMAND_STUCK_OUTSIDE.format(radius));
SavageFactions.plugin.getTimers().remove(player.getUniqueId()); SavageFactions.plugin.getTimers().remove(player.getUniqueId());
SavageFactions.plugin.getStuckMap().remove(player.getUniqueId()); SavageFactions.plugin.getStuckMap().remove(player.getUniqueId());
return; return;
} }
final Board board = Board.getInstance(); final Board board = Board.getInstance();
// spiral task to find nearest wilderness chunk // spiral task to find nearest wilderness chunk
new SpiralTask(new FLocation(me), radius * 2) { new SpiralTask(new FLocation(me), radius * 2) {
@Override @Override
public boolean work() { public boolean work() {
FLocation chunk = currentFLocation(); FLocation chunk = currentFLocation();
Faction faction = board.getFactionAt(chunk); Faction faction = board.getFactionAt(chunk);
int buffer = SavageFactions.plugin.getConfig().getInt("world-border.buffer", 0); int buffer = SavageFactions.plugin.getConfig().getInt("world-border.buffer", 0);
if (faction.isWilderness() && !chunk.isOutsideWorldBorder(buffer)) { if (faction.isWilderness() && !chunk.isOutsideWorldBorder(buffer)) {
int cx = FLocation.chunkToBlock((int) chunk.getX()); int cx = FLocation.chunkToBlock((int) chunk.getX());
int cz = FLocation.chunkToBlock((int) chunk.getZ()); int cz = FLocation.chunkToBlock((int) chunk.getZ());
int y = world.getHighestBlockYAt(cx, cz); int y = world.getHighestBlockYAt(cx, cz);
Location tp = new Location(world, cx, y, cz); Location tp = new Location(world, cx, y, cz);
msg(TL.COMMAND_STUCK_TELEPORT, tp.getBlockX(), tp.getBlockY(), tp.getBlockZ()); msg(TL.COMMAND_STUCK_TELEPORT, tp.getBlockX(), tp.getBlockY(), tp.getBlockZ());
SavageFactions.plugin.getTimers().remove(player.getUniqueId()); SavageFactions.plugin.getTimers().remove(player.getUniqueId());
SavageFactions.plugin.getStuckMap().remove(player.getUniqueId()); SavageFactions.plugin.getStuckMap().remove(player.getUniqueId());
if (!Essentials.handleTeleport(player, tp)) { if (!Essentials.handleTeleport(player, tp)) {
player.teleport(tp); player.teleport(tp);
SavageFactions.plugin.debug("/f stuck used regular teleport, not essentials!"); SavageFactions.plugin.debug("/f stuck used regular teleport, not essentials!");
} }
this.stop(); this.stop();
return false; return false;
} }
return true; return true;
} }
}; };
} }
}, delay * 20).getTaskId(); }, delay * 20).getTaskId();
SavageFactions.plugin.getTimers().put(player.getUniqueId(), System.currentTimeMillis() + (delay * 1000)); SavageFactions.plugin.getTimers().put(player.getUniqueId(), System.currentTimeMillis() + (delay * 1000));
long wait = SavageFactions.plugin.getTimers().get(player.getUniqueId()) - System.currentTimeMillis(); long wait = SavageFactions.plugin.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);
msg(TL.COMMAND_STUCK_START, time); msg(TL.COMMAND_STUCK_START, time);
SavageFactions.plugin.getStuckMap().put(player.getUniqueId(), id); SavageFactions.plugin.getStuckMap().put(player.getUniqueId(), id);
} }
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_STUCK_DESCRIPTION; return TL.COMMAND_STUCK_DESCRIPTION;
} }
} }

View File

@ -12,79 +12,79 @@ 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.optionalArgs.put("", ""); //this.optionalArgs.put("", "");
this.permission = Permission.TAG.node; this.permission = Permission.TAG.node;
this.disableOnLock = true; this.disableOnLock = true;
senderMustBePlayer = true; senderMustBePlayer = true;
senderMustBeMember = false; senderMustBeMember = false;
senderMustBeModerator = true; senderMustBeModerator = true;
senderMustBeAdmin = false; senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform() {
String tag = this.argAsString(0); String tag = this.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(myFaction.getComparisonTag())) { if (Factions.getInstance().isTagTaken(tag) && !MiscUtil.getComparisonString(tag).equals(myFaction.getComparisonTag())) {
msg(TL.COMMAND_TAG_TAKEN); 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) {
sendMessage(errors); 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 (!canAffordCommand(Conf.econCostTag, TL.COMMAND_TAG_TOCHANGE.toString())) { if (!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(fme, tag); FactionRenameEvent renameEvent = new FactionRenameEvent(fme, 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 (!payForCommand(Conf.econCostTag, TL.COMMAND_TAG_TOCHANGE, TL.COMMAND_TAG_FORCHANGE)) { if (!payForCommand(Conf.econCostTag, TL.COMMAND_TAG_TOCHANGE, TL.COMMAND_TAG_FORCHANGE)) {
return; return;
} }
String oldtag = myFaction.getTag(); String oldtag = myFaction.getTag();
myFaction.setTag(tag); myFaction.setTag(tag);
// Inform // Inform
for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers()) { for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers()) {
if (fplayer.getFactionId().equals(myFaction.getId())) { if (fplayer.getFactionId().equals(myFaction.getId())) {
fplayer.msg(TL.COMMAND_TAG_FACTION, fme.describeTo(myFaction, true), myFaction.getTag(myFaction)); fplayer.msg(TL.COMMAND_TAG_FACTION, fme.describeTo(myFaction, true), myFaction.getTag(myFaction));
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, fme.getColorTo(faction) + oldtag, myFaction.getTag(faction)); fplayer.msg(TL.COMMAND_TAG_CHANGED, fme.getColorTo(faction) + oldtag, myFaction.getTag(faction));
} }
} }
FTeamWrapper.updatePrefixes(myFaction); FTeamWrapper.updatePrefixes(myFaction);
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_TAG_DESCRIPTION; return TL.COMMAND_TAG_DESCRIPTION;
} }
} }

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