diff --git a/.gitignore b/.gitignore index 99412a2a..6fa8deb6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,20 +1,31 @@ -# Eclipse stuff +# Eclipse /.classpath /.project /.settings +/*.jardesc + +# IntelliJ +*.iml +*.ipr +*.iws +.idea/ # NetBeans /nbproject -/build.xml # vim .*.sw[a-p] +# Maven +/build.xml +/target +/dependency-reduced-pom.xml + # various other potential build files /build /bin /dist -/*.jardesc +/manifest.mf # Mac filesystem dust -.DS_Store \ No newline at end of file +.DS_Store diff --git a/README.md b/README.md index 50a369e4..0521d9ee 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,3 @@ - + ![Factions Logotype](https://raw.github.com/MassiveCraft/Factions/master/media/logo300.png)
-http://massivecraft.com/plugins/factions
\ No newline at end of file +http://massivecraft.com/factions diff --git a/lib/Herochat.jar b/lib/HeroChat-5.6.7.jar similarity index 78% rename from lib/Herochat.jar rename to lib/HeroChat-5.6.7.jar index c7720326..eaf0abd1 100644 Binary files a/lib/Herochat.jar and b/lib/HeroChat-5.6.7.jar differ diff --git a/lib/LWC-4.4.0.jar b/lib/LWC-4.4.0.jar new file mode 100644 index 00000000..ada1677f Binary files /dev/null and b/lib/LWC-4.4.0.jar differ diff --git a/lib/LWC.jar b/lib/LWC.jar deleted file mode 100644 index 2cfd17c8..00000000 Binary files a/lib/LWC.jar and /dev/null differ diff --git a/lib/Vault.jar b/lib/Vault.jar deleted file mode 100644 index 4a452b0f..00000000 Binary files a/lib/Vault.jar and /dev/null differ diff --git a/media/Thumbs.db b/media/Thumbs.db new file mode 100644 index 00000000..7d9e784d Binary files /dev/null and b/media/Thumbs.db differ diff --git a/pom.xml b/pom.xml new file mode 100644 index 00000000..86d7c5ed --- /dev/null +++ b/pom.xml @@ -0,0 +1,82 @@ + + 4.0.0 + + Factions + http://www.massivecraft.com/factions + + com.massivecraft + Factions + 2.6.1 + + + UTF-8 + + + + clean install + Factions + ${basedir}/src/main/java/ + + + . + ${basedir}/src/main/resources/ + true + + *.yml + *.md + *.txt + + + + + + maven-compiler-plugin + 3.1 + + 1.7 + 1.7 + + + + + + + + com.massivecraft + MassiveCore + LATEST + + + us.dynmap + dynmap-api + 2.0.0-SNAPSHOT + + + us.dynmap + DynmapCore + 2.0.0-SNAPSHOT + + + org.dthielke + HeroChat + 5.6.7 + system + ${project.basedir}/lib/HeroChat-5.6.7.jar + + + com.griefcraft + LWC + 4.4.0 + system + ${project.basedir}/lib/LWC-4.4.0.jar + + + + + + dynmap-repo + http://repo.mikeprimm.com/ + + + + diff --git a/src/com/massivecraft/factions/ConfServer.java b/src/com/massivecraft/factions/ConfServer.java deleted file mode 100644 index aaa10d3a..00000000 --- a/src/com/massivecraft/factions/ConfServer.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.massivecraft.factions; - -import java.util.*; - -import com.massivecraft.mcore.SimpleConfig; -import com.massivecraft.mcore.util.MUtil; - -public class ConfServer extends SimpleConfig -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static transient ConfServer i = new ConfServer(); - public static ConfServer get() { return i; } - public ConfServer() { super(Factions.get()); } - - // -------------------------------------------- // - // FIELDS - // -------------------------------------------- // - - public static List baseCommandAliases = MUtil.list("f"); - public static String dburi = "default"; - -} diff --git a/src/com/massivecraft/factions/Const.java b/src/com/massivecraft/factions/Const.java deleted file mode 100644 index 66c19867..00000000 --- a/src/com/massivecraft/factions/Const.java +++ /dev/null @@ -1,87 +0,0 @@ -package com.massivecraft.factions; - -import java.util.Set; - -import org.bukkit.Material; -import org.bukkit.entity.EntityType; - -import com.massivecraft.mcore.util.MUtil; - -public class Const -{ - // MStore Collection Names - public static final String COLLECTION_BASENAME = "factions"; - public static final String COLLECTION_BASENAME_ = COLLECTION_BASENAME+"_"; - public static final String COLLECTION_BASENAME_BOARD = COLLECTION_BASENAME_+"board"; - public static final String COLLECTION_BASENAME_FACTION = COLLECTION_BASENAME_+"faction"; - public static final String COLLECTION_BASENAME_UPLAYER = COLLECTION_BASENAME_+"uplayer"; - public static final String COLLECTION_BASENAME_MPLAYER = COLLECTION_BASENAME_+"mplayer"; - public static final String COLLECTION_BASENAME_UCONF = COLLECTION_BASENAME_+"uconf"; - public static final String COLLECTION_BASENAME_MCONF = COLLECTION_BASENAME_+"mconf"; - - // Aspect Ids - public static final String ASPECT_ID = "factions"; - - // ASCII Map - public static final int MAP_HEIGHT = 8; - public static final int MAP_WIDTH = 39; - public static final char[] MAP_KEY_CHARS = "\\/#?$%=&^ABCDEFGHJKLMNOPQRSTUVWXYZ1234567890abcdeghjmnopqrsuvwxyz".toCharArray(); - - // Enumerations - - public static final Set MATERIALS_EDIT_ON_INTERACT = MUtil.set( - Material.DIODE_BLOCK_OFF, - Material.DIODE_BLOCK_ON, - Material.NOTE_BLOCK, - Material.CAULDRON, - Material.SOIL - ); - - public static final Set MATERIALS_EDIT_TOOLS = MUtil.set( - Material.FIREBALL, - Material.FLINT_AND_STEEL, - Material.BUCKET, - Material.WATER_BUCKET, - Material.LAVA_BUCKET - ); - - public static final Set MATERIALS_DOOR = MUtil.set( - Material.WOODEN_DOOR, - Material.TRAP_DOOR, - Material.FENCE_GATE - ); - - public static final Set MATERIALS_CONTAINER = MUtil.set( - Material.DISPENSER, - Material.CHEST, - Material.FURNACE, - Material.BURNING_FURNACE, - Material.JUKEBOX, - Material.BREWING_STAND, - Material.ENCHANTMENT_TABLE, - Material.ANVIL, - Material.BEACON, - Material.TRAPPED_CHEST, - Material.HOPPER, - Material.DROPPER - ); - - public static final Set ENTITY_TYPES_MONSTERS = MUtil.set( - EntityType.BLAZE, - EntityType.CAVE_SPIDER, - EntityType.CREEPER, - EntityType.ENDERMAN, - EntityType.ENDER_DRAGON, - EntityType.GHAST, - EntityType.GIANT, - EntityType.MAGMA_CUBE, - EntityType.PIG_ZOMBIE, - EntityType.SILVERFISH, - EntityType.SKELETON, - EntityType.SLIME, - EntityType.SPIDER, - EntityType.WITCH, - EntityType.WITHER, - EntityType.ZOMBIE - ); -} diff --git a/src/com/massivecraft/factions/cmd/arg/ARUPlayer.java b/src/com/massivecraft/factions/cmd/arg/ARUPlayer.java deleted file mode 100644 index 662da45b..00000000 --- a/src/com/massivecraft/factions/cmd/arg/ARUPlayer.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.massivecraft.factions.cmd.arg; - -import com.massivecraft.factions.entity.UPlayer; -import com.massivecraft.factions.entity.UPlayerColls; -import com.massivecraft.mcore.cmd.arg.ARSenderEntity; -import com.massivecraft.mcore.cmd.arg.ArgReader; - -public class ARUPlayer -{ - // -------------------------------------------- // - // INSTANCE - // -------------------------------------------- // - - public static ArgReader getFullAny(Object o) { return ARSenderEntity.getFullAny(UPlayerColls.get().get(o)); } - - public static ArgReader getStartAny(Object o) { return ARSenderEntity.getStartAny(UPlayerColls.get().get(o)); } - - public static ArgReader getFullOnline(Object o) { return ARSenderEntity.getFullOnline(UPlayerColls.get().get(o)); } - - public static ArgReader getStartOnline(Object o) { return ARSenderEntity.getStartOnline(UPlayerColls.get().get(o)); } - -} diff --git a/src/com/massivecraft/factions/entity/MConf.java b/src/com/massivecraft/factions/entity/MConf.java deleted file mode 100644 index 9a1060dd..00000000 --- a/src/com/massivecraft/factions/entity/MConf.java +++ /dev/null @@ -1,159 +0,0 @@ -package com.massivecraft.factions.entity; - -import java.util.HashSet; -import java.util.LinkedHashSet; -import java.util.Set; - -import org.bukkit.ChatColor; -import org.bukkit.event.EventPriority; - -import com.massivecraft.factions.Factions; -import com.massivecraft.factions.listeners.FactionsListenerChat; -import com.massivecraft.mcore.store.Entity; - -public class MConf extends Entity -{ - // -------------------------------------------- // - // META - // -------------------------------------------- // - - protected static transient MConf i; - public static MConf get() { return i; } - - // -------------------------------------------- // - // OVERRIDE: ENTITY - // -------------------------------------------- // - - @Override - public MConf load(MConf that) - { - super.load(that); - - if (!Factions.get().isDatabaseInitialized()) return this; - - FactionsListenerChat.get().setup(); - - return this; - } - - // -------------------------------------------- // - // TASKS - // -------------------------------------------- // - - public double taskPlayerPowerUpdateMinutes = 1; - public double taskPlayerDataRemoveMinutes = 5; - public double taskEconLandRewardMinutes = 20; - - // -------------------------------------------- // - // REMOVE DATA - // -------------------------------------------- // - - public boolean removePlayerDataWhenBanned = true; - public double removePlayerDataAfterInactiveDays = 20.0; - - // -------------------------------------------- // - // CLAIM LIMITS - // -------------------------------------------- // - - // if someone is doing a radius claim and the process fails to claim land this many times in a row, it will exit - public int radiusClaimFailureLimit = 9; - - // the maximum radius allowed when using the claim command. - public int radiusClaimRadiusLimit = 5; - - // -------------------------------------------- // - // CHAT - // -------------------------------------------- // - - // We offer a simple standard way to set the format - public boolean chatSetFormat = false; - public EventPriority chatSetFormatAt = EventPriority.LOWEST; - public String chatSetFormatTo = "<{factions_relcolor}§l{factions_roleprefix}§r{factions_relcolor}{factions_name|rp}§f%1$s> %2$s"; - - // We offer a simple standard way to parse the chat tags - public boolean chatParseTags = true; - public EventPriority chatParseTagsAt = EventPriority.LOW; - - // HeroChat: The Faction Channel - public String herochatFactionName = "Faction"; - public String herochatFactionNick = "F"; - public String herochatFactionFormat = "{color}[&l{nick}&r{color} &l{factions_roleprefix}&r{color}{factions_title|rp}{sender}{color}] &f{msg}"; - public ChatColor herochatFactionColor = ChatColor.GREEN; - public int herochatFactionDistance = 0; - public boolean herochatFactionIsShortcutAllowed = false; - public boolean herochatFactionCrossWorld = true; - public boolean herochatFactionMuted = false; - public Set herochatFactionWorlds = new HashSet(); - - // HeroChat: The Allies Channel - public String herochatAlliesName = "Allies"; - public String herochatAlliesNick = "A"; - public String herochatAlliesFormat = "{color}[&l{nick}&r&f {factions_relcolor}&l{factions_roleprefix}&r{factions_relcolor}{factions_name|rp}{sender}{color}] &f{msg}"; - public ChatColor herochatAlliesColor = ChatColor.DARK_PURPLE; - public int herochatAlliesDistance = 0; - public boolean herochatAlliesIsShortcutAllowed = false; - public boolean herochatAlliesCrossWorld = true; - public boolean herochatAlliesMuted = false; - public Set herochatAlliesWorlds = new HashSet(); - - // -------------------------------------------- // - // COLORS - // -------------------------------------------- // - - public ChatColor colorMember = ChatColor.GREEN; - public ChatColor colorAlly = ChatColor.DARK_PURPLE; - public ChatColor colorTruce = ChatColor.LIGHT_PURPLE; - public ChatColor colorNeutral = ChatColor.WHITE; - public ChatColor colorEnemy = ChatColor.RED; - - public ChatColor colorNoPVP = ChatColor.GOLD; - public ChatColor colorFriendlyFire = ChatColor.DARK_RED; - //public ChatColor colorWilderness = ChatColor.DARK_GREEN; - - // -------------------------------------------- // - // PREFIXES - // -------------------------------------------- // - - public String prefixLeader = "**"; - public String prefixOfficer = "*"; - public String prefixMember = "+"; - public String prefixRecruit = "-"; - - // -------------------------------------------- // - // DERPY OVERRIDES - // -------------------------------------------- // - // TODO: Should worldsNoPowerLoss rather be a bukkit permission node? - // TODO: These are derpy because they possibly use an invalid design approach. - // After universe support is added. Would some of these be removed? - // Could it also be more customizeable using some sort of permission lookup map? - - // mainly for other plugins/mods that use a fake player to take actions, which shouldn't be subject to our protections - public Set playersWhoBypassAllProtection = new LinkedHashSet(); - - public Set worldsNoClaiming = new LinkedHashSet(); - public Set worldsNoPowerLoss = new LinkedHashSet(); - public Set worldsIgnorePvP = new LinkedHashSet(); - - // -------------------------------------------- // - // EXPLOITS - // -------------------------------------------- // - - public boolean handleExploitObsidianGenerators = true; - public boolean handleExploitEnderPearlClipping = true; - public boolean handleExploitTNTWaterlog = false; - - // -------------------------------------------- // - // LOGGING - // -------------------------------------------- // - - public boolean logFactionCreate = true; - public boolean logFactionDisband = true; - public boolean logFactionJoin = true; - public boolean logFactionKick = true; - public boolean logFactionLeave = true; - public boolean logLandClaims = true; - public boolean logLandUnclaims = true; - public boolean logMoneyTransactions = true; - public boolean logPlayerCommands = true; - -} \ No newline at end of file diff --git a/src/com/massivecraft/factions/event/FactionsEventAbstract.java b/src/com/massivecraft/factions/event/FactionsEventAbstract.java deleted file mode 100644 index cbed080e..00000000 --- a/src/com/massivecraft/factions/event/FactionsEventAbstract.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.massivecraft.factions.event; - -import com.massivecraft.mcore.event.MCoreEvent; - -public abstract class FactionsEventAbstract extends MCoreEvent -{ - -} diff --git a/src/com/massivecraft/factions/integration/herochat/HerochatFeatures.java b/src/com/massivecraft/factions/integration/herochat/HerochatFeatures.java deleted file mode 100644 index c63c5773..00000000 --- a/src/com/massivecraft/factions/integration/herochat/HerochatFeatures.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.massivecraft.factions.integration.herochat; - -import com.massivecraft.mcore.integration.IntegrationFeaturesAbstract; - -public class HerochatFeatures extends IntegrationFeaturesAbstract -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static HerochatFeatures i = new HerochatFeatures(); - public static HerochatFeatures get() { return i; } - private HerochatFeatures() { super("Herochat"); } - - // -------------------------------------------- // - // OVERRIDE - // -------------------------------------------- // - - @Override - public void activate() - { - HerochatEngine.get().activate(); - } - - @Override - public void deactivate() - { - HerochatEngine.get().deactivate(); - } - -} diff --git a/src/main/java/com/massivecraft/factions/Const.java b/src/main/java/com/massivecraft/factions/Const.java new file mode 100644 index 00000000..11e89366 --- /dev/null +++ b/src/main/java/com/massivecraft/factions/Const.java @@ -0,0 +1,23 @@ +package com.massivecraft.factions; + +public class Const +{ + // Collections & Aspects + public static final String BASENAME = "factions"; + public static final String BASENAME_ = BASENAME+"_"; + + public static final String COLLECTION_BOARD = BASENAME_+"board"; + public static final String COLLECTION_FACTION = BASENAME_+"faction"; + public static final String COLLECTION_UPLAYER = BASENAME_+"uplayer"; + public static final String COLLECTION_MPLAYER = BASENAME_+"mplayer"; + public static final String COLLECTION_UCONF = BASENAME_+"uconf"; + public static final String COLLECTION_MCONF = BASENAME_+"mconf"; + + public static final String ASPECT = BASENAME; + + // ASCII Map + public static final int MAP_HEIGHT = 8; + public static final int MAP_WIDTH = 39; + public static final char[] MAP_KEY_CHARS = "\\/#?$%=&^ABCDEFGHJKLMNOPQRSTUVWXYZ1234567890abcdeghjmnopqrsuvwxyz".toCharArray(); + +} diff --git a/src/com/massivecraft/factions/EconomyParticipator.java b/src/main/java/com/massivecraft/factions/EconomyParticipator.java similarity index 100% rename from src/com/massivecraft/factions/EconomyParticipator.java rename to src/main/java/com/massivecraft/factions/EconomyParticipator.java diff --git a/src/main/java/com/massivecraft/factions/EngineIdUpdate.java b/src/main/java/com/massivecraft/factions/EngineIdUpdate.java new file mode 100644 index 00000000..96afe04d --- /dev/null +++ b/src/main/java/com/massivecraft/factions/EngineIdUpdate.java @@ -0,0 +1,125 @@ +package com.massivecraft.factions; + +import java.util.Set; + +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.plugin.Plugin; + +import com.massivecraft.factions.entity.Board; +import com.massivecraft.factions.entity.BoardColl; +import com.massivecraft.factions.entity.BoardColls; +import com.massivecraft.factions.entity.Faction; +import com.massivecraft.factions.entity.FactionColl; +import com.massivecraft.factions.entity.FactionColls; +import com.massivecraft.factions.entity.MPlayerColl; +import com.massivecraft.factions.entity.UPlayerColl; +import com.massivecraft.factions.entity.UPlayerColls; +import com.massivecraft.massivecore.EngineAbstract; +import com.massivecraft.massivecore.event.EventMassiveCoreUuidUpdate; +import com.massivecraft.massivecore.util.IdUpdateUtil; +import com.massivecraft.massivecore.util.MUtil; + +public class EngineIdUpdate extends EngineAbstract +{ + // -------------------------------------------- // + // INSTANCE & CONSTRUCT + // -------------------------------------------- // + + private static EngineIdUpdate i = new EngineIdUpdate(); + public static EngineIdUpdate get() { return i; } + + // -------------------------------------------- // + // OVERRIDE + // -------------------------------------------- // + + @Override + public Plugin getPlugin() + { + return Factions.get(); + } + + // -------------------------------------------- // + // LISTENER + // -------------------------------------------- // + + @EventHandler(priority = EventPriority.MONITOR) + public void update(EventMassiveCoreUuidUpdate event) + { + for (FactionColl coll : FactionColls.get().getColls()) + { + for (Faction entity : coll.getAll()) + { + update(coll, entity); + } + } + + IdUpdateUtil.update(MPlayerColl.get()); + + for (UPlayerColl coll : UPlayerColls.get().getColls()) + { + IdUpdateUtil.update(coll); + } + + for (BoardColl coll : BoardColls.get().getColls()) + { + update(coll); + } + } + + public static void update(FactionColl coll, Faction entity) + { + // Before and After + Set before = entity.getInvitedPlayerIds(); + if (before == null) return; + Set after = IdUpdateUtil.update(before, true); + if (after == null) return; + + // NoChange + if (MUtil.equals(before, after)) return; + + // Apply + entity.setInvitedPlayerIds(after); + entity.sync(); + } + + public static void update(BoardColl coll) + { + for (Board board : coll.getAll()) + { + update(board); + } + } + + public static void update(Board board) + { + boolean changed = false; + for (TerritoryAccess ta : board.getMap().values()) + { + changed |= update(ta); + } + if (changed) + { + board.changed(); + board.sync(); + } + } + + public static boolean update(TerritoryAccess entity) + { + // Before and After + Set before = entity.playerIds; + if (before == null) return false; + Set after = IdUpdateUtil.update(before, true); + if (after == null) return false; + + // NoChange + if (MUtil.equals(before, after)) return false; + + // Apply + entity.playerIds = after; + //entity.sync(); + return true; + } + +} diff --git a/src/com/massivecraft/factions/ExtractorFactionAccountId.java b/src/main/java/com/massivecraft/factions/ExtractorFactionAccountId.java similarity index 82% rename from src/com/massivecraft/factions/ExtractorFactionAccountId.java rename to src/main/java/com/massivecraft/factions/ExtractorFactionAccountId.java index d6727d67..a9cbaac1 100644 --- a/src/com/massivecraft/factions/ExtractorFactionAccountId.java +++ b/src/main/java/com/massivecraft/factions/ExtractorFactionAccountId.java @@ -1,7 +1,7 @@ package com.massivecraft.factions; import com.massivecraft.factions.entity.Faction; -import com.massivecraft.mcore.util.extractor.Extractor; +import com.massivecraft.massivecore.util.extractor.Extractor; public class ExtractorFactionAccountId implements Extractor { @@ -23,7 +23,7 @@ public class ExtractorFactionAccountId implements Extractor { String factionId = ((Faction)o).getId(); if (factionId == null) return null; - return "faction-"+factionId; + return Factions.FACTION_MONEY_ACCOUNT_ID_PREFIX + factionId; } return null; diff --git a/src/com/massivecraft/factions/FFlag.java b/src/main/java/com/massivecraft/factions/FFlag.java similarity index 93% rename from src/com/massivecraft/factions/FFlag.java rename to src/main/java/com/massivecraft/factions/FFlag.java index 6b412549..bce7fb26 100644 --- a/src/com/massivecraft/factions/FFlag.java +++ b/src/main/java/com/massivecraft/factions/FFlag.java @@ -32,6 +32,7 @@ public enum FFlag FRIENDLYFIRE("friendlyfire", "Can friends hurt eachother here?", false), MONSTERS("monsters", "Can monsters spawn in this territory?", true), EXPLOSIONS("explosions", "Can explosions occur in this territory?", true), + OFFLINE_EXPLOSIONS("offlineexplosions", "Can explosions occur if faction is offline?", false), FIRESPREAD("firespread", "Can fire spread in territory?", true), ENDERGRIEF("endergrief", "Can endermen grief in this territory?", false), @@ -98,6 +99,7 @@ public enum FFlag if (str.startsWith("fr") || str.startsWith("ff")) return FRIENDLYFIRE; if (str.startsWith("m")) return MONSTERS; if (str.startsWith("ex")) return EXPLOSIONS; + if (str.startsWith("o")) return OFFLINE_EXPLOSIONS; if (str.startsWith("fi")) return FIRESPREAD; if (str.startsWith("en")) return ENDERGRIEF; return null; diff --git a/src/com/massivecraft/factions/FPerm.java b/src/main/java/com/massivecraft/factions/FPerm.java similarity index 95% rename from src/com/massivecraft/factions/FPerm.java rename to src/main/java/com/massivecraft/factions/FPerm.java index 429c2578..13241cb7 100644 --- a/src/com/massivecraft/factions/FPerm.java +++ b/src/main/java/com/massivecraft/factions/FPerm.java @@ -11,8 +11,8 @@ import com.massivecraft.factions.entity.BoardColls; import com.massivecraft.factions.entity.UPlayer; import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.UConf; -import com.massivecraft.mcore.ps.PS; -import com.massivecraft.mcore.util.Txt; +import com.massivecraft.massivecore.ps.PS; +import com.massivecraft.massivecore.util.Txt; /** * Permissions that you (a player) may or may not have in the territory of a certain faction. diff --git a/src/com/massivecraft/factions/FactionEqualsPredictate.java b/src/main/java/com/massivecraft/factions/FactionEqualsPredictate.java similarity index 92% rename from src/com/massivecraft/factions/FactionEqualsPredictate.java rename to src/main/java/com/massivecraft/factions/FactionEqualsPredictate.java index 07dba71c..9ec2c2c6 100644 --- a/src/com/massivecraft/factions/FactionEqualsPredictate.java +++ b/src/main/java/com/massivecraft/factions/FactionEqualsPredictate.java @@ -6,7 +6,7 @@ import org.bukkit.command.CommandSender; import com.massivecraft.factions.entity.UPlayer; import com.massivecraft.factions.entity.Faction; -import com.massivecraft.mcore.Predictate; +import com.massivecraft.massivecore.Predictate; public class FactionEqualsPredictate implements Predictate, Serializable { diff --git a/src/com/massivecraft/factions/FactionListComparator.java b/src/main/java/com/massivecraft/factions/FactionListComparator.java similarity index 92% rename from src/com/massivecraft/factions/FactionListComparator.java rename to src/main/java/com/massivecraft/factions/FactionListComparator.java index 861a7fdb..c73f6890 100644 --- a/src/com/massivecraft/factions/FactionListComparator.java +++ b/src/main/java/com/massivecraft/factions/FactionListComparator.java @@ -3,7 +3,7 @@ package com.massivecraft.factions; import java.util.Comparator; import com.massivecraft.factions.entity.Faction; -import com.massivecraft.mcore.util.MUtil; +import com.massivecraft.massivecore.util.MUtil; public class FactionListComparator implements Comparator { diff --git a/src/com/massivecraft/factions/Factions.java b/src/main/java/com/massivecraft/factions/Factions.java similarity index 82% rename from src/com/massivecraft/factions/Factions.java rename to src/main/java/com/massivecraft/factions/Factions.java index 847483b6..1220235c 100644 --- a/src/com/massivecraft/factions/Factions.java +++ b/src/main/java/com/massivecraft/factions/Factions.java @@ -29,8 +29,10 @@ import com.massivecraft.factions.entity.UConfColls; import com.massivecraft.factions.entity.UPlayerColls; import com.massivecraft.factions.entity.FactionColls; import com.massivecraft.factions.entity.MConfColl; -import com.massivecraft.factions.integration.herochat.HerochatFeatures; -import com.massivecraft.factions.integration.lwc.LwcFeatures; +import com.massivecraft.factions.integration.dynmap.IntegrationDynmap; +import com.massivecraft.factions.integration.dynmap.IntegrationDynmapFactions; +import com.massivecraft.factions.integration.herochat.IntegrationHerochat; +import com.massivecraft.factions.integration.lwc.IntegrationLwc; import com.massivecraft.factions.listeners.FactionsListenerChat; import com.massivecraft.factions.listeners.FactionsListenerEcon; import com.massivecraft.factions.listeners.FactionsListenerExploit; @@ -40,18 +42,23 @@ import com.massivecraft.factions.mixin.PowerMixinDefault; import com.massivecraft.factions.task.TaskPlayerDataRemove; import com.massivecraft.factions.task.TaskEconLandReward; import com.massivecraft.factions.task.TaskPlayerPowerUpdate; - -import com.massivecraft.mcore.Aspect; -import com.massivecraft.mcore.AspectColl; -import com.massivecraft.mcore.MPlugin; -import com.massivecraft.mcore.Multiverse; -import com.massivecraft.mcore.util.MUtil; -import com.massivecraft.mcore.xlib.gson.Gson; -import com.massivecraft.mcore.xlib.gson.GsonBuilder; +import com.massivecraft.massivecore.Aspect; +import com.massivecraft.massivecore.AspectColl; +import com.massivecraft.massivecore.MassivePlugin; +import com.massivecraft.massivecore.Multiverse; +import com.massivecraft.massivecore.util.MUtil; +import com.massivecraft.massivecore.xlib.gson.Gson; +import com.massivecraft.massivecore.xlib.gson.GsonBuilder; -public class Factions extends MPlugin +public class Factions extends MassivePlugin { + // -------------------------------------------- // + // CONSTANTS + // -------------------------------------------- // + + public final static String FACTION_MONEY_ACCOUNT_ID_PREFIX = "faction-"; + // -------------------------------------------- // // INSTANCE & CONSTRUCT // -------------------------------------------- // @@ -94,11 +101,8 @@ public class Factions extends MPlugin { if ( ! preEnable()) return; - // Load Server Config - ConfServer.get().load(); - // Initialize Aspects - this.aspect = AspectColl.get().get(Const.ASPECT_ID, true); + this.aspect = AspectColl.get().get(Const.ASPECT, true); this.aspect.register(); this.aspect.setDesc( "If the factions system even is enabled and how it's configured.", @@ -122,9 +126,10 @@ public class Factions extends MPlugin // Commands this.outerCmdFactions = new CmdFactions(); - this.outerCmdFactions.register(this); + this.outerCmdFactions.register(); // Setup Listeners + EngineIdUpdate.get().activate(); FactionsListenerMain.get().setup(); FactionsListenerChat.get().setup(); FactionsListenerExploit.get().setup(); @@ -136,14 +141,16 @@ public class Factions extends MPlugin // Integrate this.integrate( - HerochatFeatures.get(), - LwcFeatures.get() + IntegrationHerochat.get(), + IntegrationLwc.get(), + IntegrationDynmap.get(), + IntegrationDynmapFactions.get() ); // Schedule recurring non-tps-dependent tasks - TaskPlayerPowerUpdate.get().schedule(this); - TaskPlayerDataRemove.get().schedule(this); - TaskEconLandReward.get().schedule(this); + TaskPlayerPowerUpdate.get().activate(this); + TaskPlayerDataRemove.get().activate(this); + TaskEconLandReward.get().activate(this); // Register built in chat modifiers ChatModifierLc.get().register(); diff --git a/src/com/massivecraft/factions/Lang.java b/src/main/java/com/massivecraft/factions/Lang.java similarity index 81% rename from src/com/massivecraft/factions/Lang.java rename to src/main/java/com/massivecraft/factions/Lang.java index d0b5499a..f052393f 100644 --- a/src/com/massivecraft/factions/Lang.java +++ b/src/main/java/com/massivecraft/factions/Lang.java @@ -1,6 +1,6 @@ package com.massivecraft.factions; -import com.massivecraft.mcore.util.Txt; +import com.massivecraft.massivecore.util.Txt; public class Lang { diff --git a/src/com/massivecraft/factions/Perm.java b/src/main/java/com/massivecraft/factions/Perm.java similarity index 93% rename from src/com/massivecraft/factions/Perm.java rename to src/main/java/com/massivecraft/factions/Perm.java index d665fca3..1a7ffd90 100644 --- a/src/com/massivecraft/factions/Perm.java +++ b/src/main/java/com/massivecraft/factions/Perm.java @@ -2,7 +2,7 @@ package com.massivecraft.factions; import org.bukkit.permissions.Permissible; -import com.massivecraft.mcore.util.PermUtil; +import com.massivecraft.massivecore.util.PermUtil; public enum Perm { diff --git a/src/com/massivecraft/factions/PlayerRoleComparator.java b/src/main/java/com/massivecraft/factions/PlayerRoleComparator.java similarity index 100% rename from src/com/massivecraft/factions/PlayerRoleComparator.java rename to src/main/java/com/massivecraft/factions/PlayerRoleComparator.java diff --git a/src/com/massivecraft/factions/Rel.java b/src/main/java/com/massivecraft/factions/Rel.java similarity index 100% rename from src/com/massivecraft/factions/Rel.java rename to src/main/java/com/massivecraft/factions/Rel.java diff --git a/src/com/massivecraft/factions/RelationParticipator.java b/src/main/java/com/massivecraft/factions/RelationParticipator.java similarity index 100% rename from src/com/massivecraft/factions/RelationParticipator.java rename to src/main/java/com/massivecraft/factions/RelationParticipator.java diff --git a/src/com/massivecraft/factions/TerritoryAccess.java b/src/main/java/com/massivecraft/factions/TerritoryAccess.java similarity index 99% rename from src/com/massivecraft/factions/TerritoryAccess.java rename to src/main/java/com/massivecraft/factions/TerritoryAccess.java index 2b435b47..a359466c 100644 --- a/src/com/massivecraft/factions/TerritoryAccess.java +++ b/src/main/java/com/massivecraft/factions/TerritoryAccess.java @@ -32,8 +32,9 @@ public class TerritoryAccess private final Set factionIds; public Set getFactionIds() { return this.factionIds; } + // TODO: remate private final // default is empty - private final Set playerIds; + public Set playerIds; public Set getPlayerIds() { return this.playerIds; } // -------------------------------------------- // diff --git a/src/com/massivecraft/factions/adapter/BoardAdapter.java b/src/main/java/com/massivecraft/factions/adapter/BoardAdapter.java similarity index 70% rename from src/com/massivecraft/factions/adapter/BoardAdapter.java rename to src/main/java/com/massivecraft/factions/adapter/BoardAdapter.java index 1758b545..b2b060a3 100644 --- a/src/com/massivecraft/factions/adapter/BoardAdapter.java +++ b/src/main/java/com/massivecraft/factions/adapter/BoardAdapter.java @@ -3,14 +3,13 @@ package com.massivecraft.factions.adapter; import java.lang.reflect.Type; import java.util.Map; -import com.massivecraft.mcore.ps.PS; -import com.massivecraft.mcore.xlib.gson.JsonDeserializationContext; -import com.massivecraft.mcore.xlib.gson.JsonDeserializer; -import com.massivecraft.mcore.xlib.gson.JsonElement; -import com.massivecraft.mcore.xlib.gson.JsonParseException; -import com.massivecraft.mcore.xlib.gson.JsonSerializationContext; -import com.massivecraft.mcore.xlib.gson.JsonSerializer; - +import com.massivecraft.massivecore.ps.PS; +import com.massivecraft.massivecore.xlib.gson.JsonDeserializationContext; +import com.massivecraft.massivecore.xlib.gson.JsonDeserializer; +import com.massivecraft.massivecore.xlib.gson.JsonElement; +import com.massivecraft.massivecore.xlib.gson.JsonParseException; +import com.massivecraft.massivecore.xlib.gson.JsonSerializationContext; +import com.massivecraft.massivecore.xlib.gson.JsonSerializer; import com.massivecraft.factions.TerritoryAccess; import com.massivecraft.factions.entity.Board; diff --git a/src/com/massivecraft/factions/adapter/BoardMapAdapter.java b/src/main/java/com/massivecraft/factions/adapter/BoardMapAdapter.java similarity index 79% rename from src/com/massivecraft/factions/adapter/BoardMapAdapter.java rename to src/main/java/com/massivecraft/factions/adapter/BoardMapAdapter.java index 34b37d1a..e724cc7b 100644 --- a/src/com/massivecraft/factions/adapter/BoardMapAdapter.java +++ b/src/main/java/com/massivecraft/factions/adapter/BoardMapAdapter.java @@ -5,15 +5,14 @@ import java.util.Map; import java.util.Map.Entry; import java.util.concurrent.ConcurrentSkipListMap; -import com.massivecraft.mcore.ps.PS; -import com.massivecraft.mcore.xlib.gson.JsonDeserializationContext; -import com.massivecraft.mcore.xlib.gson.JsonDeserializer; -import com.massivecraft.mcore.xlib.gson.JsonElement; -import com.massivecraft.mcore.xlib.gson.JsonObject; -import com.massivecraft.mcore.xlib.gson.JsonParseException; -import com.massivecraft.mcore.xlib.gson.JsonSerializationContext; -import com.massivecraft.mcore.xlib.gson.JsonSerializer; - +import com.massivecraft.massivecore.ps.PS; +import com.massivecraft.massivecore.xlib.gson.JsonDeserializationContext; +import com.massivecraft.massivecore.xlib.gson.JsonDeserializer; +import com.massivecraft.massivecore.xlib.gson.JsonElement; +import com.massivecraft.massivecore.xlib.gson.JsonObject; +import com.massivecraft.massivecore.xlib.gson.JsonParseException; +import com.massivecraft.massivecore.xlib.gson.JsonSerializationContext; +import com.massivecraft.massivecore.xlib.gson.JsonSerializer; import com.massivecraft.factions.TerritoryAccess; public class BoardMapAdapter implements JsonDeserializer>, JsonSerializer> diff --git a/src/com/massivecraft/factions/adapter/FFlagAdapter.java b/src/main/java/com/massivecraft/factions/adapter/FFlagAdapter.java similarity index 73% rename from src/com/massivecraft/factions/adapter/FFlagAdapter.java rename to src/main/java/com/massivecraft/factions/adapter/FFlagAdapter.java index b733e445..55c7f9dc 100644 --- a/src/com/massivecraft/factions/adapter/FFlagAdapter.java +++ b/src/main/java/com/massivecraft/factions/adapter/FFlagAdapter.java @@ -3,10 +3,10 @@ package com.massivecraft.factions.adapter; import java.lang.reflect.Type; import com.massivecraft.factions.FFlag; -import com.massivecraft.mcore.xlib.gson.JsonDeserializationContext; -import com.massivecraft.mcore.xlib.gson.JsonDeserializer; -import com.massivecraft.mcore.xlib.gson.JsonElement; -import com.massivecraft.mcore.xlib.gson.JsonParseException; +import com.massivecraft.massivecore.xlib.gson.JsonDeserializationContext; +import com.massivecraft.massivecore.xlib.gson.JsonDeserializer; +import com.massivecraft.massivecore.xlib.gson.JsonElement; +import com.massivecraft.massivecore.xlib.gson.JsonParseException; public class FFlagAdapter implements JsonDeserializer { diff --git a/src/com/massivecraft/factions/adapter/FPermAdapter.java b/src/main/java/com/massivecraft/factions/adapter/FPermAdapter.java similarity index 73% rename from src/com/massivecraft/factions/adapter/FPermAdapter.java rename to src/main/java/com/massivecraft/factions/adapter/FPermAdapter.java index c723c531..d578710c 100644 --- a/src/com/massivecraft/factions/adapter/FPermAdapter.java +++ b/src/main/java/com/massivecraft/factions/adapter/FPermAdapter.java @@ -2,12 +2,11 @@ package com.massivecraft.factions.adapter; import java.lang.reflect.Type; -import com.massivecraft.mcore.xlib.gson.JsonDeserializationContext; -import com.massivecraft.mcore.xlib.gson.JsonDeserializer; -import com.massivecraft.mcore.xlib.gson.JsonElement; -import com.massivecraft.mcore.xlib.gson.JsonParseException; - import com.massivecraft.factions.FPerm; +import com.massivecraft.massivecore.xlib.gson.JsonDeserializationContext; +import com.massivecraft.massivecore.xlib.gson.JsonDeserializer; +import com.massivecraft.massivecore.xlib.gson.JsonElement; +import com.massivecraft.massivecore.xlib.gson.JsonParseException; public class FPermAdapter implements JsonDeserializer { diff --git a/src/com/massivecraft/factions/adapter/FactionPreprocessAdapter.java b/src/main/java/com/massivecraft/factions/adapter/FactionPreprocessAdapter.java similarity index 81% rename from src/com/massivecraft/factions/adapter/FactionPreprocessAdapter.java rename to src/main/java/com/massivecraft/factions/adapter/FactionPreprocessAdapter.java index a9f143a2..2028df59 100644 --- a/src/com/massivecraft/factions/adapter/FactionPreprocessAdapter.java +++ b/src/main/java/com/massivecraft/factions/adapter/FactionPreprocessAdapter.java @@ -2,14 +2,13 @@ package com.massivecraft.factions.adapter; import java.lang.reflect.Type; -import com.massivecraft.mcore.xlib.gson.JsonDeserializationContext; -import com.massivecraft.mcore.xlib.gson.JsonDeserializer; -import com.massivecraft.mcore.xlib.gson.JsonElement; -import com.massivecraft.mcore.xlib.gson.JsonObject; -import com.massivecraft.mcore.xlib.gson.JsonParseException; - import com.massivecraft.factions.Factions; import com.massivecraft.factions.entity.Faction; +import com.massivecraft.massivecore.xlib.gson.JsonDeserializationContext; +import com.massivecraft.massivecore.xlib.gson.JsonDeserializer; +import com.massivecraft.massivecore.xlib.gson.JsonElement; +import com.massivecraft.massivecore.xlib.gson.JsonObject; +import com.massivecraft.massivecore.xlib.gson.JsonParseException; public class FactionPreprocessAdapter implements JsonDeserializer { diff --git a/src/com/massivecraft/factions/adapter/RelAdapter.java b/src/main/java/com/massivecraft/factions/adapter/RelAdapter.java similarity index 72% rename from src/com/massivecraft/factions/adapter/RelAdapter.java rename to src/main/java/com/massivecraft/factions/adapter/RelAdapter.java index 3a723834..bc56b4db 100644 --- a/src/com/massivecraft/factions/adapter/RelAdapter.java +++ b/src/main/java/com/massivecraft/factions/adapter/RelAdapter.java @@ -2,12 +2,11 @@ package com.massivecraft.factions.adapter; import java.lang.reflect.Type; -import com.massivecraft.mcore.xlib.gson.JsonDeserializationContext; -import com.massivecraft.mcore.xlib.gson.JsonDeserializer; -import com.massivecraft.mcore.xlib.gson.JsonElement; -import com.massivecraft.mcore.xlib.gson.JsonParseException; - import com.massivecraft.factions.Rel; +import com.massivecraft.massivecore.xlib.gson.JsonDeserializationContext; +import com.massivecraft.massivecore.xlib.gson.JsonDeserializer; +import com.massivecraft.massivecore.xlib.gson.JsonElement; +import com.massivecraft.massivecore.xlib.gson.JsonParseException; public class RelAdapter implements JsonDeserializer { @@ -27,4 +26,5 @@ public class RelAdapter implements JsonDeserializer { return Rel.parse(json.getAsString()); } + } diff --git a/src/com/massivecraft/factions/adapter/TerritoryAccessAdapter.java b/src/main/java/com/massivecraft/factions/adapter/TerritoryAccessAdapter.java similarity index 85% rename from src/com/massivecraft/factions/adapter/TerritoryAccessAdapter.java rename to src/main/java/com/massivecraft/factions/adapter/TerritoryAccessAdapter.java index f3399165..590dac1e 100644 --- a/src/com/massivecraft/factions/adapter/TerritoryAccessAdapter.java +++ b/src/main/java/com/massivecraft/factions/adapter/TerritoryAccessAdapter.java @@ -3,17 +3,16 @@ package com.massivecraft.factions.adapter; import java.lang.reflect.Type; import java.util.Set; -import com.massivecraft.mcore.xlib.gson.JsonDeserializationContext; -import com.massivecraft.mcore.xlib.gson.JsonDeserializer; -import com.massivecraft.mcore.xlib.gson.JsonElement; -import com.massivecraft.mcore.xlib.gson.JsonObject; -import com.massivecraft.mcore.xlib.gson.JsonParseException; -import com.massivecraft.mcore.xlib.gson.JsonPrimitive; -import com.massivecraft.mcore.xlib.gson.JsonSerializationContext; -import com.massivecraft.mcore.xlib.gson.JsonSerializer; -import com.massivecraft.mcore.xlib.gson.reflect.TypeToken; - import com.massivecraft.factions.TerritoryAccess; +import com.massivecraft.massivecore.xlib.gson.JsonDeserializationContext; +import com.massivecraft.massivecore.xlib.gson.JsonDeserializer; +import com.massivecraft.massivecore.xlib.gson.JsonElement; +import com.massivecraft.massivecore.xlib.gson.JsonObject; +import com.massivecraft.massivecore.xlib.gson.JsonParseException; +import com.massivecraft.massivecore.xlib.gson.JsonPrimitive; +import com.massivecraft.massivecore.xlib.gson.JsonSerializationContext; +import com.massivecraft.massivecore.xlib.gson.JsonSerializer; +import com.massivecraft.massivecore.xlib.gson.reflect.TypeToken; public class TerritoryAccessAdapter implements JsonDeserializer, JsonSerializer { diff --git a/src/com/massivecraft/factions/chat/ChatFormatter.java b/src/main/java/com/massivecraft/factions/chat/ChatFormatter.java similarity index 94% rename from src/com/massivecraft/factions/chat/ChatFormatter.java rename to src/main/java/com/massivecraft/factions/chat/ChatFormatter.java index 6e6789bb..b473ba77 100644 --- a/src/com/massivecraft/factions/chat/ChatFormatter.java +++ b/src/main/java/com/massivecraft/factions/chat/ChatFormatter.java @@ -62,7 +62,7 @@ public class ChatFormatter public static boolean unregisterTag(ChatTag tag) { if (tag == null) return false; - return idToTag.remove(tag) != null; + return idToTag.remove(tag.getId()) != null; } // -------------------------------------------- // @@ -95,7 +95,7 @@ public class ChatFormatter public static boolean unregisterModifier(ChatModifier modifier) { if (modifier == null) return false; - return idToModifier.remove(modifier) != null; + return idToModifier.remove(modifier.getId()) != null; } // -------------------------------------------- // diff --git a/src/com/massivecraft/factions/chat/ChatModifier.java b/src/main/java/com/massivecraft/factions/chat/ChatModifier.java similarity index 100% rename from src/com/massivecraft/factions/chat/ChatModifier.java rename to src/main/java/com/massivecraft/factions/chat/ChatModifier.java diff --git a/src/com/massivecraft/factions/chat/ChatModifierAbstract.java b/src/main/java/com/massivecraft/factions/chat/ChatModifierAbstract.java similarity index 100% rename from src/com/massivecraft/factions/chat/ChatModifierAbstract.java rename to src/main/java/com/massivecraft/factions/chat/ChatModifierAbstract.java diff --git a/src/com/massivecraft/factions/chat/ChatTag.java b/src/main/java/com/massivecraft/factions/chat/ChatTag.java similarity index 100% rename from src/com/massivecraft/factions/chat/ChatTag.java rename to src/main/java/com/massivecraft/factions/chat/ChatTag.java diff --git a/src/com/massivecraft/factions/chat/ChatTagAbstract.java b/src/main/java/com/massivecraft/factions/chat/ChatTagAbstract.java similarity index 100% rename from src/com/massivecraft/factions/chat/ChatTagAbstract.java rename to src/main/java/com/massivecraft/factions/chat/ChatTagAbstract.java diff --git a/src/com/massivecraft/factions/chat/modifier/ChatModifierLc.java b/src/main/java/com/massivecraft/factions/chat/modifier/ChatModifierLc.java similarity index 100% rename from src/com/massivecraft/factions/chat/modifier/ChatModifierLc.java rename to src/main/java/com/massivecraft/factions/chat/modifier/ChatModifierLc.java diff --git a/src/com/massivecraft/factions/chat/modifier/ChatModifierLp.java b/src/main/java/com/massivecraft/factions/chat/modifier/ChatModifierLp.java similarity index 100% rename from src/com/massivecraft/factions/chat/modifier/ChatModifierLp.java rename to src/main/java/com/massivecraft/factions/chat/modifier/ChatModifierLp.java diff --git a/src/com/massivecraft/factions/chat/modifier/ChatModifierParse.java b/src/main/java/com/massivecraft/factions/chat/modifier/ChatModifierParse.java similarity index 91% rename from src/com/massivecraft/factions/chat/modifier/ChatModifierParse.java rename to src/main/java/com/massivecraft/factions/chat/modifier/ChatModifierParse.java index 5055b414..af5cbec7 100644 --- a/src/com/massivecraft/factions/chat/modifier/ChatModifierParse.java +++ b/src/main/java/com/massivecraft/factions/chat/modifier/ChatModifierParse.java @@ -3,7 +3,7 @@ package com.massivecraft.factions.chat.modifier; import org.bukkit.command.CommandSender; import com.massivecraft.factions.chat.ChatModifierAbstract; -import com.massivecraft.mcore.util.Txt; +import com.massivecraft.massivecore.util.Txt; public class ChatModifierParse extends ChatModifierAbstract { diff --git a/src/com/massivecraft/factions/chat/modifier/ChatModifierRp.java b/src/main/java/com/massivecraft/factions/chat/modifier/ChatModifierRp.java similarity index 100% rename from src/com/massivecraft/factions/chat/modifier/ChatModifierRp.java rename to src/main/java/com/massivecraft/factions/chat/modifier/ChatModifierRp.java diff --git a/src/com/massivecraft/factions/chat/modifier/ChatModifierUc.java b/src/main/java/com/massivecraft/factions/chat/modifier/ChatModifierUc.java similarity index 100% rename from src/com/massivecraft/factions/chat/modifier/ChatModifierUc.java rename to src/main/java/com/massivecraft/factions/chat/modifier/ChatModifierUc.java diff --git a/src/com/massivecraft/factions/chat/modifier/ChatModifierUcf.java b/src/main/java/com/massivecraft/factions/chat/modifier/ChatModifierUcf.java similarity index 91% rename from src/com/massivecraft/factions/chat/modifier/ChatModifierUcf.java rename to src/main/java/com/massivecraft/factions/chat/modifier/ChatModifierUcf.java index 3f3dcac4..9b0cb4e1 100644 --- a/src/com/massivecraft/factions/chat/modifier/ChatModifierUcf.java +++ b/src/main/java/com/massivecraft/factions/chat/modifier/ChatModifierUcf.java @@ -3,7 +3,7 @@ package com.massivecraft.factions.chat.modifier; import org.bukkit.command.CommandSender; import com.massivecraft.factions.chat.ChatModifierAbstract; -import com.massivecraft.mcore.util.Txt; +import com.massivecraft.massivecore.util.Txt; public class ChatModifierUcf extends ChatModifierAbstract { diff --git a/src/com/massivecraft/factions/chat/tag/ChatTagName.java b/src/main/java/com/massivecraft/factions/chat/tag/ChatTagName.java similarity index 100% rename from src/com/massivecraft/factions/chat/tag/ChatTagName.java rename to src/main/java/com/massivecraft/factions/chat/tag/ChatTagName.java diff --git a/src/com/massivecraft/factions/chat/tag/ChatTagNameforce.java b/src/main/java/com/massivecraft/factions/chat/tag/ChatTagNameforce.java similarity index 100% rename from src/com/massivecraft/factions/chat/tag/ChatTagNameforce.java rename to src/main/java/com/massivecraft/factions/chat/tag/ChatTagNameforce.java diff --git a/src/com/massivecraft/factions/chat/tag/ChatTagRelcolor.java b/src/main/java/com/massivecraft/factions/chat/tag/ChatTagRelcolor.java similarity index 90% rename from src/com/massivecraft/factions/chat/tag/ChatTagRelcolor.java rename to src/main/java/com/massivecraft/factions/chat/tag/ChatTagRelcolor.java index 273fba58..7c23c2ed 100644 --- a/src/com/massivecraft/factions/chat/tag/ChatTagRelcolor.java +++ b/src/main/java/com/massivecraft/factions/chat/tag/ChatTagRelcolor.java @@ -23,10 +23,11 @@ public class ChatTagRelcolor extends ChatTagAbstract @Override public String getReplacement(CommandSender sender, CommandSender recipient) { - if (recipient == null) return ""; - // Check disabled if (UConf.isDisabled(sender)) return ""; + + // Opt out if no recipient + if (recipient == null) return null; // Get entities UPlayer usender = UPlayer.get(sender); diff --git a/src/com/massivecraft/factions/chat/tag/ChatTagRole.java b/src/main/java/com/massivecraft/factions/chat/tag/ChatTagRole.java similarity index 92% rename from src/com/massivecraft/factions/chat/tag/ChatTagRole.java rename to src/main/java/com/massivecraft/factions/chat/tag/ChatTagRole.java index aa28729f..707d5d5f 100644 --- a/src/com/massivecraft/factions/chat/tag/ChatTagRole.java +++ b/src/main/java/com/massivecraft/factions/chat/tag/ChatTagRole.java @@ -5,7 +5,7 @@ import org.bukkit.command.CommandSender; import com.massivecraft.factions.chat.ChatTagAbstract; import com.massivecraft.factions.entity.UConf; import com.massivecraft.factions.entity.UPlayer; -import com.massivecraft.mcore.util.Txt; +import com.massivecraft.massivecore.util.Txt; public class ChatTagRole extends ChatTagAbstract { diff --git a/src/com/massivecraft/factions/chat/tag/ChatTagRoleprefix.java b/src/main/java/com/massivecraft/factions/chat/tag/ChatTagRoleprefix.java similarity index 100% rename from src/com/massivecraft/factions/chat/tag/ChatTagRoleprefix.java rename to src/main/java/com/massivecraft/factions/chat/tag/ChatTagRoleprefix.java diff --git a/src/com/massivecraft/factions/chat/tag/ChatTagRoleprefixforce.java b/src/main/java/com/massivecraft/factions/chat/tag/ChatTagRoleprefixforce.java similarity index 100% rename from src/com/massivecraft/factions/chat/tag/ChatTagRoleprefixforce.java rename to src/main/java/com/massivecraft/factions/chat/tag/ChatTagRoleprefixforce.java diff --git a/src/com/massivecraft/factions/chat/tag/ChatTagTitle.java b/src/main/java/com/massivecraft/factions/chat/tag/ChatTagTitle.java similarity index 100% rename from src/com/massivecraft/factions/chat/tag/ChatTagTitle.java rename to src/main/java/com/massivecraft/factions/chat/tag/ChatTagTitle.java diff --git a/src/com/massivecraft/factions/cmd/CmdFactions.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactions.java similarity index 86% rename from src/com/massivecraft/factions/cmd/CmdFactions.java rename to src/main/java/com/massivecraft/factions/cmd/CmdFactions.java index 199c014e..32f84adb 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactions.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactions.java @@ -1,15 +1,19 @@ package com.massivecraft.factions.cmd; -import java.util.Collections; +import java.util.List; -import com.massivecraft.factions.ConfServer; import com.massivecraft.factions.Factions; import com.massivecraft.factions.Perm; -import com.massivecraft.mcore.cmd.HelpCommand; -import com.massivecraft.mcore.cmd.VersionCommand; +import com.massivecraft.factions.entity.MConf; +import com.massivecraft.massivecore.cmd.HelpCommand; +import com.massivecraft.massivecore.cmd.VersionCommand; public class CmdFactions extends FCommand { + // -------------------------------------------- // + // FIELDS + // -------------------------------------------- // + public CmdFactionsList cmdFactionsList = new CmdFactionsList(); public CmdFactionsFaction cmdFactionsFaction = new CmdFactionsFaction(); public CmdFactionsPlayer cmdFactionsPlayer = new CmdFactionsPlayer(); @@ -47,17 +51,13 @@ public class CmdFactions extends FCommand public CmdFactionsPowerBoost cmdFactionsPowerBoost = new CmdFactionsPowerBoost(); public VersionCommand cmdFactionsVersion = new VersionCommand(Factions.get(), Perm.VERSION.node, "v", "version"); + // -------------------------------------------- // + // CONSTRUCT + // -------------------------------------------- // + public CmdFactions() { - this.aliases.addAll(ConfServer.baseCommandAliases); - - // remove any nulls from extra commas - // TODO: When is this required? Should this be added to MCore? - this.aliases.removeAll(Collections.singletonList(null)); - - this.setDesc("The faction base command"); - this.setHelp("This command contains all faction stuff."); - + // Add SubCommands this.addSubCommand(HelpCommand.get()); this.addSubCommand(this.cmdFactionsList); this.addSubCommand(this.cmdFactionsFaction); @@ -95,13 +95,20 @@ public class CmdFactions extends FCommand this.addSubCommand(this.cmdFactionsAdmin); this.addSubCommand(this.cmdFactionsPowerBoost); this.addSubCommand(this.cmdFactionsVersion); + + // Misc + this.setDesc("The faction base command"); + this.setHelp("This command contains all faction stuff."); } + // -------------------------------------------- // + // OVERRIDE + // -------------------------------------------- // + @Override - public void perform() + public List getAliases() { - this.getCommandChain().add(this); - HelpCommand.getInstance().execute(this.sender, this.args, this.commandChain); + return MConf.get().aliasesF; } } diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsAccess.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsAccess.java similarity index 58% rename from src/com/massivecraft/factions/cmd/CmdFactionsAccess.java rename to src/main/java/com/massivecraft/factions/cmd/CmdFactionsAccess.java index ab87dfd5..84c07e89 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsAccess.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsAccess.java @@ -2,35 +2,50 @@ package com.massivecraft.factions.cmd; import com.massivecraft.factions.Perm; import com.massivecraft.factions.cmd.req.ReqFactionsEnabled; -import com.massivecraft.mcore.cmd.HelpCommand; -import com.massivecraft.mcore.cmd.req.ReqHasPerm; -import com.massivecraft.mcore.cmd.req.ReqIsPlayer; +import com.massivecraft.massivecore.cmd.HelpCommand; +import com.massivecraft.massivecore.cmd.req.ReqHasPerm; +import com.massivecraft.massivecore.cmd.req.ReqIsPlayer; public class CmdFactionsAccess extends FCommand { + // -------------------------------------------- // + // FIELDS + // -------------------------------------------- // + public CmdFactionsAccessView cmdFactionsAccessView = new CmdFactionsAccessView(); public CmdFactionsAccessPlayer cmdFactionsAccessPlayer = new CmdFactionsAccessPlayer(); public CmdFactionsAccessFaction cmdFactionsAccessFaction = new CmdFactionsAccessFaction(); + // -------------------------------------------- // + // CONSTRUCT + // -------------------------------------------- // + public CmdFactionsAccess() { - this.addAliases("access"); - - this.addRequirements(ReqFactionsEnabled.get()); - this.addRequirements(ReqIsPlayer.get()); - this.addRequirements(ReqHasPerm.get(Perm.ACCESS.node)); - + // Add SubCommands this.addSubCommand(this.cmdFactionsAccessView); this.addSubCommand(this.cmdFactionsAccessPlayer); this.addSubCommand(this.cmdFactionsAccessFaction); + + // Aliases + this.addAliases("access"); + + // Requirements + this.addRequirements(ReqFactionsEnabled.get()); + this.addRequirements(ReqIsPlayer.get()); + this.addRequirements(ReqHasPerm.get(Perm.ACCESS.node)); } + // -------------------------------------------- // + // OVERRIDE + // -------------------------------------------- // + @Override public void perform() { this.getCommandChain().add(this); - HelpCommand.getInstance().execute(this.sender, this.args, this.commandChain); + HelpCommand.get().execute(this.sender, this.args, this.commandChain); } } diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsAccessAbstract.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsAccessAbstract.java similarity index 77% rename from src/com/massivecraft/factions/cmd/CmdFactionsAccessAbstract.java rename to src/main/java/com/massivecraft/factions/cmd/CmdFactionsAccessAbstract.java index 9193a4cb..7b2140ab 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsAccessAbstract.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsAccessAbstract.java @@ -9,24 +9,37 @@ import com.massivecraft.factions.TerritoryAccess; import com.massivecraft.factions.cmd.req.ReqFactionsEnabled; import com.massivecraft.factions.entity.BoardColls; import com.massivecraft.factions.entity.Faction; -import com.massivecraft.mcore.cmd.req.ReqIsPlayer; -import com.massivecraft.mcore.ps.PS; -import com.massivecraft.mcore.ps.PSFormatHumanSpace; -import com.massivecraft.mcore.util.Txt; +import com.massivecraft.massivecore.cmd.req.ReqIsPlayer; +import com.massivecraft.massivecore.ps.PS; +import com.massivecraft.massivecore.ps.PSFormatHumanSpace; +import com.massivecraft.massivecore.util.Txt; public abstract class CmdFactionsAccessAbstract extends FCommand { + // -------------------------------------------- // + // FIELDS + // -------------------------------------------- // + public PS chunk; public TerritoryAccess ta; public Faction hostFaction; + // -------------------------------------------- // + // CONSTRUCT + // -------------------------------------------- // + public CmdFactionsAccessAbstract() { + // Requirements this.addRequirements(ReqFactionsEnabled.get()); this.addRequirements(ReqIsPlayer.get()); } + // -------------------------------------------- // + // OVERRIDE + // -------------------------------------------- // + @Override public void perform() { @@ -58,4 +71,5 @@ public abstract class CmdFactionsAccessAbstract extends FCommand } return Txt.implodeCommaAnd(descriptions, Txt.parse(", "), Txt.parse(" and ")); } + } diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsAccessFaction.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsAccessFaction.java similarity index 73% rename from src/com/massivecraft/factions/cmd/CmdFactionsAccessFaction.java rename to src/main/java/com/massivecraft/factions/cmd/CmdFactionsAccessFaction.java index 8046673e..8869abee 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsAccessFaction.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsAccessFaction.java @@ -5,21 +5,32 @@ import com.massivecraft.factions.Perm; import com.massivecraft.factions.cmd.arg.ARFaction; import com.massivecraft.factions.entity.BoardColls; import com.massivecraft.factions.entity.Faction; -import com.massivecraft.mcore.cmd.arg.ARBoolean; -import com.massivecraft.mcore.cmd.req.ReqHasPerm; +import com.massivecraft.massivecore.cmd.arg.ARBoolean; +import com.massivecraft.massivecore.cmd.req.ReqHasPerm; public class CmdFactionsAccessFaction extends CmdFactionsAccessAbstract { + // -------------------------------------------- // + // CONSTRUCT + // -------------------------------------------- // + public CmdFactionsAccessFaction() { + // Aliases this.addAliases("f", "faction"); + // Args this.addRequiredArg("faction"); this.addOptionalArg("yes/no", "toggle"); - + + // Requirements this.addRequirements(ReqHasPerm.get(Perm.ACCESS_FACTION.node)); } + // -------------------------------------------- // + // OVERRIDE + // -------------------------------------------- // + @Override public void innerPerform() { @@ -40,4 +51,5 @@ public class CmdFactionsAccessFaction extends CmdFactionsAccessAbstract // Inform this.sendAccessInfo(); } + } diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsAccessPlayer.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsAccessPlayer.java similarity index 68% rename from src/com/massivecraft/factions/cmd/CmdFactionsAccessPlayer.java rename to src/main/java/com/massivecraft/factions/cmd/CmdFactionsAccessPlayer.java index e8ed2365..ec325bb1 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsAccessPlayer.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsAccessPlayer.java @@ -5,26 +5,37 @@ import com.massivecraft.factions.Perm; import com.massivecraft.factions.cmd.arg.ARUPlayer; import com.massivecraft.factions.entity.BoardColls; import com.massivecraft.factions.entity.UPlayer; -import com.massivecraft.mcore.cmd.arg.ARBoolean; -import com.massivecraft.mcore.cmd.req.ReqHasPerm; +import com.massivecraft.massivecore.cmd.arg.ARBoolean; +import com.massivecraft.massivecore.cmd.req.ReqHasPerm; public class CmdFactionsAccessPlayer extends CmdFactionsAccessAbstract { + // -------------------------------------------- // + // CONSTRUCT + // -------------------------------------------- // + public CmdFactionsAccessPlayer() { + // Aliases this.addAliases("p", "player"); - + + // Args this.addRequiredArg("player"); this.addOptionalArg("yes/no", "toggle"); - + + // Requirements this.addRequirements(ReqHasPerm.get(Perm.ACCESS_PLAYER.node)); } - + + // -------------------------------------------- // + // OVERRIDE + // -------------------------------------------- // + @Override public void innerPerform() { // Args - UPlayer uplayer = this.arg(0, ARUPlayer.getStartAny(usender)); + UPlayer uplayer = this.arg(0, ARUPlayer.getAny(usender)); if (uplayer == null) return; Boolean newValue = this.arg(1, ARBoolean.get(), !ta.isPlayerIdGranted(uplayer.getId())); @@ -40,4 +51,5 @@ public class CmdFactionsAccessPlayer extends CmdFactionsAccessAbstract // Inform this.sendAccessInfo(); } + } diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsAccessView.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsAccessView.java similarity index 52% rename from src/com/massivecraft/factions/cmd/CmdFactionsAccessView.java rename to src/main/java/com/massivecraft/factions/cmd/CmdFactionsAccessView.java index 320db24a..20a9aea6 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsAccessView.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsAccessView.java @@ -1,21 +1,31 @@ package com.massivecraft.factions.cmd; import com.massivecraft.factions.Perm; -import com.massivecraft.mcore.cmd.req.ReqHasPerm; - +import com.massivecraft.massivecore.cmd.req.ReqHasPerm; public class CmdFactionsAccessView extends CmdFactionsAccessAbstract { + // -------------------------------------------- // + // CONSTRUCT + // -------------------------------------------- // + public CmdFactionsAccessView() { + // Aliases this.addAliases("v", "view"); - + + // Requirements this.addRequirements(ReqHasPerm.get(Perm.ACCESS_VIEW.node)); } + // -------------------------------------------- // + // OVERRIDE + // -------------------------------------------- // + @Override public void innerPerform() { this.sendAccessInfo(); } + } diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsAdmin.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsAdmin.java similarity index 65% rename from src/com/massivecraft/factions/cmd/CmdFactionsAdmin.java rename to src/main/java/com/massivecraft/factions/cmd/CmdFactionsAdmin.java index 1ecfcef9..c0199338 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsAdmin.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsAdmin.java @@ -2,20 +2,31 @@ package com.massivecraft.factions.cmd; import com.massivecraft.factions.Factions; import com.massivecraft.factions.Perm; -import com.massivecraft.mcore.cmd.arg.ARBoolean; -import com.massivecraft.mcore.cmd.req.ReqHasPerm; +import com.massivecraft.massivecore.cmd.arg.ARBoolean; +import com.massivecraft.massivecore.cmd.req.ReqHasPerm; public class CmdFactionsAdmin extends FCommand { + // -------------------------------------------- // + // CONSTRUCT + // -------------------------------------------- // + public CmdFactionsAdmin() { + // Aliases this.addAliases("admin"); - + + // Args this.addOptionalArg("on/off", "flip"); - //this.addRequirements(ReqFactionsEnabled.get()); + // Requirements + // this.addRequirements(ReqFactionsEnabled.get()); this.addRequirements(ReqHasPerm.get(Perm.ADMIN.node)); } + + // -------------------------------------------- // + // OVERRIDE + // -------------------------------------------- // @Override public void perform() @@ -36,4 +47,5 @@ public class CmdFactionsAdmin extends FCommand Factions.get().log(msender.getId() + " DISABLED admin bypass mode."); } } + } diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsAutoClaim.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsAutoClaim.java similarity index 75% rename from src/com/massivecraft/factions/cmd/CmdFactionsAutoClaim.java rename to src/main/java/com/massivecraft/factions/cmd/CmdFactionsAutoClaim.java index 56859bb1..0d58ee43 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsAutoClaim.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsAutoClaim.java @@ -6,23 +6,34 @@ import com.massivecraft.factions.cmd.arg.ARFaction; import com.massivecraft.factions.cmd.req.ReqFactionsEnabled; import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.UConf; -import com.massivecraft.mcore.cmd.req.ReqHasPerm; -import com.massivecraft.mcore.cmd.req.ReqIsPlayer; -import com.massivecraft.mcore.ps.PS; +import com.massivecraft.massivecore.cmd.req.ReqHasPerm; +import com.massivecraft.massivecore.cmd.req.ReqIsPlayer; +import com.massivecraft.massivecore.ps.PS; public class CmdFactionsAutoClaim extends FCommand { + // -------------------------------------------- // + // CONSTRUCT + // -------------------------------------------- // + public CmdFactionsAutoClaim() { + // Aliases this.addAliases("autoclaim"); - + + // Args this.addOptionalArg("faction", "you"); - + + // Requirements this.addRequirements(ReqFactionsEnabled.get()); this.addRequirements(ReqHasPerm.get(Perm.AUTOCLAIM.node)); this.addRequirements(ReqIsPlayer.get()); } + // -------------------------------------------- // + // OVERRIDE + // -------------------------------------------- // + @Override public void perform() { diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsClaim.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsClaim.java similarity index 83% rename from src/com/massivecraft/factions/cmd/CmdFactionsClaim.java rename to src/main/java/com/massivecraft/factions/cmd/CmdFactionsClaim.java index 969e7a51..cab93ae4 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsClaim.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsClaim.java @@ -7,26 +7,36 @@ import com.massivecraft.factions.cmd.req.ReqFactionsEnabled; import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.MConf; import com.massivecraft.factions.task.SpiralTask; -import com.massivecraft.mcore.cmd.arg.ARInteger; -import com.massivecraft.mcore.cmd.req.ReqHasPerm; -import com.massivecraft.mcore.cmd.req.ReqIsPlayer; -import com.massivecraft.mcore.ps.PS; +import com.massivecraft.massivecore.cmd.arg.ARInteger; +import com.massivecraft.massivecore.cmd.req.ReqHasPerm; +import com.massivecraft.massivecore.cmd.req.ReqIsPlayer; +import com.massivecraft.massivecore.ps.PS; public class CmdFactionsClaim extends FCommand { + // -------------------------------------------- // + // CONSTRUCT + // -------------------------------------------- // public CmdFactionsClaim() { + // Aliases this.addAliases("claim"); - + + // Args this.addOptionalArg("radius", "1"); this.addOptionalArg("faction", "you"); - + + // Requirements this.addRequirements(ReqFactionsEnabled.get()); this.addRequirements(ReqIsPlayer.get()); this.addRequirements(ReqHasPerm.get(Perm.CLAIM.node)); } + + // -------------------------------------------- // + // OVERRIDE + // -------------------------------------------- // @Override public void perform() @@ -98,4 +108,5 @@ public class CmdFactionsClaim extends FCommand }; } + } diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsCreate.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsCreate.java similarity index 76% rename from src/com/massivecraft/factions/cmd/CmdFactionsCreate.java rename to src/main/java/com/massivecraft/factions/cmd/CmdFactionsCreate.java index 137f407b..047bc553 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsCreate.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsCreate.java @@ -13,28 +13,39 @@ import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.FactionColl; import com.massivecraft.factions.entity.FactionColls; import com.massivecraft.factions.entity.MConf; -import com.massivecraft.factions.event.FactionsEventCreate; -import com.massivecraft.factions.event.FactionsEventMembershipChange; -import com.massivecraft.factions.event.FactionsEventMembershipChange.MembershipChangeReason; -import com.massivecraft.mcore.cmd.req.ReqHasPerm; -import com.massivecraft.mcore.store.MStore; +import com.massivecraft.factions.event.EventFactionsCreate; +import com.massivecraft.factions.event.EventFactionsMembershipChange; +import com.massivecraft.factions.event.EventFactionsMembershipChange.MembershipChangeReason; +import com.massivecraft.massivecore.cmd.req.ReqHasPerm; +import com.massivecraft.massivecore.store.MStore; public class CmdFactionsCreate extends FCommand { + // -------------------------------------------- // + // CONSTRUCT + // -------------------------------------------- // + public CmdFactionsCreate() { + // Aliases this.addAliases("create"); - + + // Args this.addRequiredArg("name"); - + + // Requirements this.addRequirements(ReqFactionsEnabled.get()); this.addRequirements(ReqHasntFaction.get()); this.addRequirements(ReqHasPerm.get(Perm.CREATE.node)); } + + // -------------------------------------------- // + // OVERRIDE + // -------------------------------------------- // @Override public void perform() - { + { // Args String newName = this.arg(0); @@ -58,7 +69,7 @@ public class CmdFactionsCreate extends FCommand String factionId = MStore.createId(); // Event - FactionsEventCreate createEvent = new FactionsEventCreate(sender, coll.getUniverse(), factionId, newName); + EventFactionsCreate createEvent = new EventFactionsCreate(sender, coll.getUniverse(), factionId, newName); createEvent.run(); if (createEvent.isCancelled()) return; @@ -69,7 +80,7 @@ public class CmdFactionsCreate extends FCommand usender.setRole(Rel.LEADER); usender.setFaction(faction); - FactionsEventMembershipChange joinEvent = new FactionsEventMembershipChange(sender, usender, faction, MembershipChangeReason.CREATE); + EventFactionsMembershipChange joinEvent = new EventFactionsMembershipChange(sender, usender, faction, MembershipChangeReason.CREATE); joinEvent.run(); // NOTE: join event cannot be cancelled or you'll have an empty faction diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsDemote.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsDemote.java similarity index 81% rename from src/com/massivecraft/factions/cmd/CmdFactionsDemote.java rename to src/main/java/com/massivecraft/factions/cmd/CmdFactionsDemote.java index 462e7e59..099018f7 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsDemote.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsDemote.java @@ -5,17 +5,23 @@ import com.massivecraft.factions.Rel; import com.massivecraft.factions.cmd.arg.ARUPlayer; import com.massivecraft.factions.cmd.req.ReqFactionsEnabled; import com.massivecraft.factions.entity.UPlayer; -import com.massivecraft.mcore.cmd.req.ReqHasPerm; +import com.massivecraft.massivecore.cmd.req.ReqHasPerm; public class CmdFactionsDemote extends FCommand { + // -------------------------------------------- // + // CONSTRUCT + // -------------------------------------------- // public CmdFactionsDemote() { + // Aliases this.addAliases("demote"); - + + // Args this.addRequiredArg("player"); - + + // Requirements this.addRequirements(ReqFactionsEnabled.get()); this.addRequirements(ReqHasPerm.get(Perm.DEMOTE.node)); @@ -23,11 +29,15 @@ public class CmdFactionsDemote extends FCommand //To demote someone from officer -> member you must be a leader. //We'll handle this internally } + + // -------------------------------------------- // + // OVERRIDE + // -------------------------------------------- // @Override public void perform() { - UPlayer you = this.arg(0, ARUPlayer.getStartAny(usender)); + UPlayer you = this.arg(0, ARUPlayer.getAny(usender)); if (you == null) return; if (you.getFaction() != usenderFaction) diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsDescription.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsDescription.java similarity index 57% rename from src/com/massivecraft/factions/cmd/CmdFactionsDescription.java rename to src/main/java/com/massivecraft/factions/cmd/CmdFactionsDescription.java index f729d27f..7b17d423 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsDescription.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsDescription.java @@ -5,24 +5,36 @@ import com.massivecraft.factions.Rel; import com.massivecraft.factions.cmd.req.ReqFactionsEnabled; import com.massivecraft.factions.cmd.req.ReqHasFaction; import com.massivecraft.factions.cmd.req.ReqRoleIsAtLeast; -import com.massivecraft.factions.event.FactionsEventDescriptionChange; -import com.massivecraft.mcore.cmd.req.ReqHasPerm; -import com.massivecraft.mcore.mixin.Mixin; +import com.massivecraft.factions.entity.UPlayer; +import com.massivecraft.factions.event.EventFactionsDescriptionChange; +import com.massivecraft.massivecore.cmd.req.ReqHasPerm; +import com.massivecraft.massivecore.mixin.Mixin; public class CmdFactionsDescription extends FCommand { + // -------------------------------------------- // + // CONSTRUCT + // -------------------------------------------- // + public CmdFactionsDescription() { + // Aliases this.addAliases("desc"); - + + // Args this.addRequiredArg("desc"); this.setErrorOnToManyArgs(false); - + + // Requirements this.addRequirements(ReqFactionsEnabled.get()); this.addRequirements(ReqHasPerm.get(Perm.DESCRIPTION.node)); this.addRequirements(ReqHasFaction.get()); this.addRequirements(ReqRoleIsAtLeast.get(Rel.OFFICER)); } + + // -------------------------------------------- // + // OVERRIDE + // -------------------------------------------- // @Override public void perform() @@ -31,7 +43,7 @@ public class CmdFactionsDescription extends FCommand String newDescription = this.argConcatFrom(0); // Event - FactionsEventDescriptionChange event = new FactionsEventDescriptionChange(sender, usenderFaction, newDescription); + EventFactionsDescriptionChange event = new EventFactionsDescriptionChange(sender, usenderFaction, newDescription); event.run(); if (event.isCancelled()) return; newDescription = event.getNewDescription(); @@ -40,7 +52,10 @@ public class CmdFactionsDescription extends FCommand usenderFaction.setDescription(newDescription); // Inform - usenderFaction.msg("%s set your faction description to:\n%s", Mixin.getDisplayName(sender), usenderFaction.getDescription()); + for (UPlayer follower : usenderFaction.getUPlayers()) + { + follower.msg("%s set your faction description to:\n%s", Mixin.getDisplayName(sender, follower), usenderFaction.getDescription()); + } } } diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsDisband.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsDisband.java similarity index 70% rename from src/com/massivecraft/factions/cmd/CmdFactionsDisband.java rename to src/main/java/com/massivecraft/factions/cmd/CmdFactionsDisband.java index 8c93ec19..801e5589 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsDisband.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsDisband.java @@ -7,27 +7,39 @@ import com.massivecraft.factions.entity.UPlayerColls; import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.FactionColls; import com.massivecraft.factions.entity.MConf; -import com.massivecraft.factions.event.FactionsEventDisband; -import com.massivecraft.factions.event.FactionsEventMembershipChange; -import com.massivecraft.factions.event.FactionsEventMembershipChange.MembershipChangeReason; +import com.massivecraft.factions.event.EventFactionsDisband; +import com.massivecraft.factions.event.EventFactionsMembershipChange; +import com.massivecraft.factions.event.EventFactionsMembershipChange.MembershipChangeReason; import com.massivecraft.factions.FFlag; import com.massivecraft.factions.FPerm; import com.massivecraft.factions.Factions; import com.massivecraft.factions.Perm; -import com.massivecraft.mcore.cmd.req.ReqHasPerm; -import com.massivecraft.mcore.util.Txt; +import com.massivecraft.massivecore.cmd.req.ReqHasPerm; +import com.massivecraft.massivecore.util.IdUtil; +import com.massivecraft.massivecore.util.Txt; public class CmdFactionsDisband extends FCommand { + // -------------------------------------------- // + // CONSTRUCT + // -------------------------------------------- // + public CmdFactionsDisband() { + // Aliases this.addAliases("disband"); - + + // Args this.addOptionalArg("faction", "you"); + // Requirements this.addRequirements(ReqFactionsEnabled.get()); this.addRequirements(ReqHasPerm.get(Perm.DISBAND.node)); } + + // -------------------------------------------- // + // OVERRIDE + // -------------------------------------------- // @Override public void perform() @@ -47,7 +59,7 @@ public class CmdFactionsDisband extends FCommand } // Event - FactionsEventDisband event = new FactionsEventDisband(me, faction); + EventFactionsDisband event = new EventFactionsDisband(me, faction); event.run(); if (event.isCancelled()) return; @@ -56,7 +68,7 @@ public class CmdFactionsDisband extends FCommand // Run event for each player in the faction for (UPlayer uplayer : faction.getUPlayers()) { - FactionsEventMembershipChange membershipChangeEvent = new FactionsEventMembershipChange(sender, uplayer, FactionColls.get().get(faction).getNone(), MembershipChangeReason.DISBAND); + EventFactionsMembershipChange membershipChangeEvent = new EventFactionsMembershipChange(sender, uplayer, FactionColls.get().get(faction).getNone(), MembershipChangeReason.DISBAND); membershipChangeEvent.run(); } @@ -76,9 +88,10 @@ public class CmdFactionsDisband extends FCommand if (MConf.get().logFactionDisband) { - Factions.get().log(Txt.parse("The faction %s (%s) was disbanded by %s.", faction.getName(), faction.getId(), usender.getDisplayName())); + Factions.get().log(Txt.parse("The faction %s (%s) was disbanded by %s.", faction.getName(), faction.getId(), usender.getDisplayName(IdUtil.getConsole()))); } faction.detach(); } + } diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsFaction.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsFaction.java similarity index 85% rename from src/com/massivecraft/factions/cmd/CmdFactionsFaction.java rename to src/main/java/com/massivecraft/factions/cmd/CmdFactionsFaction.java index cf578c87..52226508 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsFaction.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsFaction.java @@ -11,31 +11,42 @@ import com.massivecraft.factions.cmd.req.ReqFactionsEnabled; import com.massivecraft.factions.entity.UConf; import com.massivecraft.factions.entity.UPlayer; import com.massivecraft.factions.entity.Faction; -import com.massivecraft.factions.event.FactionsEventChunkChangeType; +import com.massivecraft.factions.event.EventFactionsChunkChangeType; import com.massivecraft.factions.integration.Econ; import com.massivecraft.factions.FFlag; import com.massivecraft.factions.Perm; import com.massivecraft.factions.PlayerRoleComparator; import com.massivecraft.factions.Rel; -import com.massivecraft.mcore.cmd.req.ReqHasPerm; -import com.massivecraft.mcore.mixin.Mixin; -import com.massivecraft.mcore.money.Money; -import com.massivecraft.mcore.util.TimeDiffUtil; -import com.massivecraft.mcore.util.TimeUnit; -import com.massivecraft.mcore.util.Txt; +import com.massivecraft.massivecore.cmd.req.ReqHasPerm; +import com.massivecraft.massivecore.mixin.Mixin; +import com.massivecraft.massivecore.money.Money; +import com.massivecraft.massivecore.util.TimeDiffUtil; +import com.massivecraft.massivecore.util.TimeUnit; +import com.massivecraft.massivecore.util.Txt; public class CmdFactionsFaction extends FCommand { + // -------------------------------------------- // + // CONSTRUCT + // -------------------------------------------- // + public CmdFactionsFaction() { + // Aliases this.addAliases("f", "faction"); - + + // Args this.addOptionalArg("faction", "you"); - + + // Requirements this.addRequirements(ReqFactionsEnabled.get()); this.addRequirements(ReqHasPerm.get(Perm.FACTION.node)); } + // -------------------------------------------- // + // OVERRIDE + // -------------------------------------------- // + @Override public void perform() { @@ -75,7 +86,7 @@ public class CmdFactionsFaction extends FCommand { long landCount = faction.getLandCount(); - for (FactionsEventChunkChangeType type : FactionsEventChunkChangeType.values()) + for (EventFactionsChunkChangeType type : EventFactionsChunkChangeType.values()) { Double money = uconf.econChunkCost.get(type); if (money == null) continue; @@ -93,13 +104,13 @@ public class CmdFactionsFaction extends FCommand money *= -1; } - msg("Total land %s %s: %s", type.toString().toLowerCase(), word, Money.format(faction, money)); + msg("Total land %s %s: %s", type.toString().toLowerCase(), word, Money.format(money)); } // Show bank contents if (UConf.get(faction).bankEnabled) { - msg("Bank contains: "+Money.format(faction, Money.get(faction))); + msg("Bank contains: "+Money.format(Money.get(faction))); } } diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsFlag.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsFlag.java similarity index 76% rename from src/com/massivecraft/factions/cmd/CmdFactionsFlag.java rename to src/main/java/com/massivecraft/factions/cmd/CmdFactionsFlag.java index 3bd0e277..204dccf8 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsFlag.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsFlag.java @@ -6,24 +6,34 @@ import com.massivecraft.factions.cmd.arg.ARFFlag; import com.massivecraft.factions.cmd.arg.ARFaction; import com.massivecraft.factions.cmd.req.ReqFactionsEnabled; import com.massivecraft.factions.entity.Faction; -import com.massivecraft.mcore.cmd.arg.ARBoolean; -import com.massivecraft.mcore.cmd.req.ReqHasPerm; -import com.massivecraft.mcore.util.Txt; +import com.massivecraft.massivecore.cmd.arg.ARBoolean; +import com.massivecraft.massivecore.cmd.req.ReqHasPerm; +import com.massivecraft.massivecore.util.Txt; public class CmdFactionsFlag extends FCommand { + // -------------------------------------------- // + // CONSTRUCT + // -------------------------------------------- // public CmdFactionsFlag() { + // Aliases this.addAliases("flag"); - + + // Args this.addOptionalArg("faction", "you"); this.addOptionalArg("flag", "all"); this.addOptionalArg("yes/no", "read"); - + + // Requirements this.addRequirements(ReqFactionsEnabled.get()); this.addRequirements(ReqHasPerm.get(Perm.FLAG.node)); } + + // -------------------------------------------- // + // OVERRIDE + // -------------------------------------------- // @Override public void perform() diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsHome.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsHome.java similarity index 84% rename from src/com/massivecraft/factions/cmd/CmdFactionsHome.java rename to src/main/java/com/massivecraft/factions/cmd/CmdFactionsHome.java index 725a14b2..b262b613 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsHome.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsHome.java @@ -14,25 +14,35 @@ import com.massivecraft.factions.entity.BoardColls; import com.massivecraft.factions.entity.UConf; import com.massivecraft.factions.entity.UPlayer; import com.massivecraft.factions.entity.Faction; -import com.massivecraft.factions.event.FactionsEventHomeTeleport; -import com.massivecraft.mcore.cmd.req.ReqHasPerm; -import com.massivecraft.mcore.cmd.req.ReqIsPlayer; -import com.massivecraft.mcore.mixin.Mixin; -import com.massivecraft.mcore.mixin.TeleporterException; -import com.massivecraft.mcore.ps.PS; +import com.massivecraft.factions.event.EventFactionsHomeTeleport; +import com.massivecraft.massivecore.cmd.req.ReqHasPerm; +import com.massivecraft.massivecore.cmd.req.ReqIsPlayer; +import com.massivecraft.massivecore.mixin.Mixin; +import com.massivecraft.massivecore.mixin.TeleporterException; +import com.massivecraft.massivecore.ps.PS; public class CmdFactionsHome extends FCommand { + // -------------------------------------------- // + // CONSTRUCT + // -------------------------------------------- // + public CmdFactionsHome() { + // Aliases this.addAliases("home"); - + + // Requirements this.addRequirements(ReqFactionsEnabled.get()); this.addRequirements(ReqHasPerm.get(Perm.HOME.node)); this.addRequirements(ReqHasFaction.get()); this.addRequirements(ReqIsPlayer.get()); } + + // -------------------------------------------- // + // OVERRIDE + // -------------------------------------------- // @Override public void perform() @@ -123,7 +133,7 @@ public class CmdFactionsHome extends FCommand } // Event - FactionsEventHomeTeleport event = new FactionsEventHomeTeleport(sender); + EventFactionsHomeTeleport event = new EventFactionsHomeTeleport(sender); event.run(); if (event.isCancelled()) return; diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsInvite.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsInvite.java similarity index 77% rename from src/com/massivecraft/factions/cmd/CmdFactionsInvite.java rename to src/main/java/com/massivecraft/factions/cmd/CmdFactionsInvite.java index 395c8828..630c7bf8 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsInvite.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsInvite.java @@ -7,31 +7,42 @@ import com.massivecraft.factions.cmd.arg.ARUPlayer; import com.massivecraft.factions.cmd.req.ReqFactionsEnabled; import com.massivecraft.factions.cmd.req.ReqHasFaction; import com.massivecraft.factions.entity.UPlayer; -import com.massivecraft.factions.event.FactionsEventInvitedChange; -import com.massivecraft.mcore.cmd.arg.ARBoolean; -import com.massivecraft.mcore.cmd.req.ReqHasPerm; -import com.massivecraft.mcore.cmd.req.ReqIsPlayer; +import com.massivecraft.factions.event.EventFactionsInvitedChange; +import com.massivecraft.massivecore.cmd.arg.ARBoolean; +import com.massivecraft.massivecore.cmd.req.ReqHasPerm; +import com.massivecraft.massivecore.cmd.req.ReqIsPlayer; public class CmdFactionsInvite extends FCommand { + // -------------------------------------------- // + // CONSTRUCT + // -------------------------------------------- // + public CmdFactionsInvite() { + // Aliases this.addAliases("inv", "invite"); - + + // Args this.addRequiredArg("player"); this.addOptionalArg("yes/no", "toggle"); - + + // Requirements this.addRequirements(ReqFactionsEnabled.get()); this.addRequirements(ReqHasPerm.get(Perm.INVITE.node)); this.addRequirements(ReqHasFaction.get()); this.addRequirements(ReqIsPlayer.get()); } + + // -------------------------------------------- // + // OVERRIDE + // -------------------------------------------- // @Override public void perform() { // Args - UPlayer uplayer = this.arg(0, ARUPlayer.getStartAny(sender)); + UPlayer uplayer = this.arg(0, ARUPlayer.getAny(sender)); if (uplayer == null) return; Boolean newInvited = this.arg(1, ARBoolean.get(), !usenderFaction.isInvited(uplayer)); @@ -49,7 +60,7 @@ public class CmdFactionsInvite extends FCommand if ( ! FPerm.INVITE.has(usender, usenderFaction, true)) return; // Event - FactionsEventInvitedChange event = new FactionsEventInvitedChange(sender, uplayer, usenderFaction, newInvited); + EventFactionsInvitedChange event = new EventFactionsInvitedChange(sender, uplayer, usenderFaction, newInvited); event.run(); if (event.isCancelled()) return; newInvited = event.isNewInvited(); diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsJoin.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsJoin.java similarity index 82% rename from src/com/massivecraft/factions/cmd/CmdFactionsJoin.java rename to src/main/java/com/massivecraft/factions/cmd/CmdFactionsJoin.java index baec10aa..0a3e46e5 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsJoin.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsJoin.java @@ -9,23 +9,34 @@ import com.massivecraft.factions.entity.UPlayer; import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.MConf; import com.massivecraft.factions.entity.UConf; -import com.massivecraft.factions.event.FactionsEventMembershipChange; -import com.massivecraft.factions.event.FactionsEventMembershipChange.MembershipChangeReason; -import com.massivecraft.mcore.cmd.req.ReqHasPerm; -import com.massivecraft.mcore.util.Txt; +import com.massivecraft.factions.event.EventFactionsMembershipChange; +import com.massivecraft.factions.event.EventFactionsMembershipChange.MembershipChangeReason; +import com.massivecraft.massivecore.cmd.req.ReqHasPerm; +import com.massivecraft.massivecore.util.Txt; public class CmdFactionsJoin extends FCommand { + // -------------------------------------------- // + // CONSTRUCT + // -------------------------------------------- // + public CmdFactionsJoin() { + // Aliases this.addAliases("join"); - + + // Args this.addRequiredArg("faction"); this.addOptionalArg("player", "you"); - + + // Requirements this.addRequirements(ReqFactionsEnabled.get()); this.addRequirements(ReqHasPerm.get(Perm.JOIN.node)); } + + // -------------------------------------------- // + // OVERRIDE + // -------------------------------------------- // @Override public void perform() @@ -34,7 +45,7 @@ public class CmdFactionsJoin extends FCommand Faction faction = this.arg(0, ARFaction.get(sender)); if (faction == null) return; - UPlayer uplayer = this.arg(1, ARUPlayer.getStartAny(sender), usender); + UPlayer uplayer = this.arg(1, ARUPlayer.getAny(sender), usender); if (uplayer == null) return; Faction uplayerFaction = uplayer.getFaction(); @@ -82,7 +93,7 @@ public class CmdFactionsJoin extends FCommand } // Event - FactionsEventMembershipChange membershipChangeEvent = new FactionsEventMembershipChange(sender, usender, faction, MembershipChangeReason.JOIN); + EventFactionsMembershipChange membershipChangeEvent = new EventFactionsMembershipChange(sender, usender, faction, MembershipChangeReason.JOIN); membershipChangeEvent.run(); if (membershipChangeEvent.isCancelled()) return; @@ -113,4 +124,5 @@ public class CmdFactionsJoin extends FCommand } } } + } diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsKick.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsKick.java similarity index 75% rename from src/com/massivecraft/factions/cmd/CmdFactionsKick.java rename to src/main/java/com/massivecraft/factions/cmd/CmdFactionsKick.java index e07378e3..0f33a605 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsKick.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsKick.java @@ -11,28 +11,39 @@ import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.FactionColls; import com.massivecraft.factions.entity.MConf; import com.massivecraft.factions.entity.UConf; -import com.massivecraft.factions.event.FactionsEventMembershipChange; -import com.massivecraft.factions.event.FactionsEventMembershipChange.MembershipChangeReason; -import com.massivecraft.mcore.cmd.req.ReqHasPerm; +import com.massivecraft.factions.event.EventFactionsMembershipChange; +import com.massivecraft.factions.event.EventFactionsMembershipChange.MembershipChangeReason; +import com.massivecraft.massivecore.cmd.req.ReqHasPerm; +import com.massivecraft.massivecore.util.IdUtil; public class CmdFactionsKick extends FCommand { + // -------------------------------------------- // + // CONSTRUCT + // -------------------------------------------- // public CmdFactionsKick() { + // Aliases this.addAliases("kick"); - + + // Args this.addRequiredArg("player"); - + + // Requirements this.addRequirements(ReqFactionsEnabled.get()); this.addRequirements(ReqHasPerm.get(Perm.KICK.node)); } + + // -------------------------------------------- // + // OVERRIDE + // -------------------------------------------- // @Override public void perform() { // Arg - UPlayer uplayer = this.arg(0, ARUPlayer.getStartAny(sender)); + UPlayer uplayer = this.arg(0, ARUPlayer.getAny(sender)); if (uplayer == null) return; // Validate @@ -60,7 +71,7 @@ public class CmdFactionsKick extends FCommand if (!FPerm.KICK.has(usender, uplayerFaction, true)) return; // Event - FactionsEventMembershipChange event = new FactionsEventMembershipChange(sender, uplayer, FactionColls.get().get(uplayer).getNone(), MembershipChangeReason.KICK); + EventFactionsMembershipChange event = new EventFactionsMembershipChange(sender, uplayer, FactionColls.get().get(uplayer).getNone(), MembershipChangeReason.KICK); event.run(); if (event.isCancelled()) return; @@ -74,7 +85,7 @@ public class CmdFactionsKick extends FCommand if (MConf.get().logFactionKick) { - Factions.get().log(usender.getDisplayName() + " kicked " + uplayer.getName() + " from the faction " + uplayerFaction.getName()); + Factions.get().log(usender.getDisplayName(IdUtil.getConsole()) + " kicked " + uplayer.getName() + " from the faction " + uplayerFaction.getName()); } // Apply diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsLeader.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsLeader.java similarity index 82% rename from src/com/massivecraft/factions/cmd/CmdFactionsLeader.java rename to src/main/java/com/massivecraft/factions/cmd/CmdFactionsLeader.java index ec5662b8..16ba5ccf 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsLeader.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsLeader.java @@ -8,29 +8,39 @@ import com.massivecraft.factions.cmd.req.ReqFactionsEnabled; import com.massivecraft.factions.entity.UPlayer; import com.massivecraft.factions.entity.UPlayerColls; import com.massivecraft.factions.entity.Faction; -import com.massivecraft.factions.event.FactionsEventMembershipChange; -import com.massivecraft.factions.event.FactionsEventMembershipChange.MembershipChangeReason; +import com.massivecraft.factions.event.EventFactionsMembershipChange; +import com.massivecraft.factions.event.EventFactionsMembershipChange.MembershipChangeReason; import com.massivecraft.factions.util.RelationUtil; -import com.massivecraft.mcore.cmd.req.ReqHasPerm; -import com.massivecraft.mcore.util.Txt; +import com.massivecraft.massivecore.cmd.req.ReqHasPerm; +import com.massivecraft.massivecore.util.Txt; public class CmdFactionsLeader extends FCommand -{ +{ + // -------------------------------------------- // + // CONSTRUCT + // -------------------------------------------- // public CmdFactionsLeader() { + // Aliases this.addAliases("leader"); - + + // Args this.addRequiredArg("player"); this.addOptionalArg("faction", "you"); - + + // Requirements this.addRequirements(ReqFactionsEnabled.get()); this.addRequirements(ReqHasPerm.get(Perm.LEADER.node)); } + + // -------------------------------------------- // + // OVERRIDE + // -------------------------------------------- // @Override public void perform() { - UPlayer newLeader = this.arg(0, ARUPlayer.getStartAny(sender)); + UPlayer newLeader = this.arg(0, ARUPlayer.getAny(sender)); if (newLeader == null) return; Faction targetFaction = this.arg(1, ARFaction.get(sender), usenderFaction); @@ -68,7 +78,7 @@ public class CmdFactionsLeader extends FCommand // only run event when newLeader isn't actually in the faction if (newLeader.getFaction() != targetFaction) { - FactionsEventMembershipChange event = new FactionsEventMembershipChange(sender, newLeader, targetFaction, MembershipChangeReason.LEADER); + EventFactionsMembershipChange event = new EventFactionsMembershipChange(sender, newLeader, targetFaction, MembershipChangeReason.LEADER); event.run(); if (event.isCancelled()) return; } @@ -97,4 +107,5 @@ public class CmdFactionsLeader extends FCommand uplayer.msg("%s gave %s the leadership of %s.", senderIsConsole ? "A server admin" : RelationUtil.describeThatToMe(usender, uplayer, true), newLeader.describeTo(uplayer), targetFaction.describeTo(uplayer)); } } + } diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsLeave.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsLeave.java similarity index 56% rename from src/com/massivecraft/factions/cmd/CmdFactionsLeave.java rename to src/main/java/com/massivecraft/factions/cmd/CmdFactionsLeave.java index ddf36068..5ab580a3 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsLeave.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsLeave.java @@ -3,18 +3,28 @@ package com.massivecraft.factions.cmd; import com.massivecraft.factions.Perm; import com.massivecraft.factions.cmd.req.ReqFactionsEnabled; import com.massivecraft.factions.cmd.req.ReqHasFaction; -import com.massivecraft.mcore.cmd.req.ReqHasPerm; +import com.massivecraft.massivecore.cmd.req.ReqHasPerm; -public class CmdFactionsLeave extends FCommand { +public class CmdFactionsLeave extends FCommand +{ + // -------------------------------------------- // + // CONSTRUCT + // -------------------------------------------- // public CmdFactionsLeave() { + // Aliases this.addAliases("leave"); - + + // Requirements this.addRequirements(ReqFactionsEnabled.get()); this.addRequirements(ReqHasPerm.get(Perm.LEAVE.node)); this.addRequirements(ReqHasFaction.get()); } + + // -------------------------------------------- // + // OVERRIDE + // -------------------------------------------- // @Override public void perform() diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsList.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsList.java similarity index 81% rename from src/com/massivecraft/factions/cmd/CmdFactionsList.java rename to src/main/java/com/massivecraft/factions/cmd/CmdFactionsList.java index c2306117..22cc037f 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsList.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsList.java @@ -8,23 +8,34 @@ import com.massivecraft.factions.Perm; import com.massivecraft.factions.cmd.req.ReqFactionsEnabled; import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.FactionColls; -import com.massivecraft.mcore.cmd.arg.ARInteger; -import com.massivecraft.mcore.cmd.req.ReqHasPerm; -import com.massivecraft.mcore.util.Txt; +import com.massivecraft.massivecore.cmd.arg.ARInteger; +import com.massivecraft.massivecore.cmd.req.ReqHasPerm; +import com.massivecraft.massivecore.util.Txt; public class CmdFactionsList extends FCommand { + // -------------------------------------------- // + // CONSTRUCT + // -------------------------------------------- // + public CmdFactionsList() { + // Aliases this.addAliases("l", "list"); - + + // Args this.addOptionalArg("page", "1"); - + + // Requirements this.addRequirements(ReqFactionsEnabled.get()); this.addRequirements(ReqHasPerm.get(Perm.LIST.node)); } + // -------------------------------------------- // + // OVERRIDE + // -------------------------------------------- // + @Override public void perform() { @@ -69,4 +80,5 @@ public class CmdFactionsList extends FCommand sendMessage(lines); } + } diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsMap.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsMap.java similarity index 68% rename from src/com/massivecraft/factions/cmd/CmdFactionsMap.java rename to src/main/java/com/massivecraft/factions/cmd/CmdFactionsMap.java index 7e149aee..e296c061 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsMap.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsMap.java @@ -3,23 +3,34 @@ package com.massivecraft.factions.cmd; import com.massivecraft.factions.Perm; import com.massivecraft.factions.cmd.req.ReqFactionsEnabled; import com.massivecraft.factions.entity.BoardColls; -import com.massivecraft.mcore.cmd.arg.ARBoolean; -import com.massivecraft.mcore.cmd.req.ReqHasPerm; -import com.massivecraft.mcore.cmd.req.ReqIsPlayer; -import com.massivecraft.mcore.ps.PS; +import com.massivecraft.massivecore.cmd.arg.ARBoolean; +import com.massivecraft.massivecore.cmd.req.ReqHasPerm; +import com.massivecraft.massivecore.cmd.req.ReqIsPlayer; +import com.massivecraft.massivecore.ps.PS; public class CmdFactionsMap extends FCommand { + // -------------------------------------------- // + // CONSTRUCT + // -------------------------------------------- // + public CmdFactionsMap() { + // Aliases this.addAliases("map"); - + + // Args this.addOptionalArg("on/off", "once"); - + + // Requirements this.addRequirements(ReqFactionsEnabled.get()); this.addRequirements(ReqHasPerm.get(Perm.MAP.node)); this.addRequirements(ReqIsPlayer.get()); } + + // -------------------------------------------- // + // OVERRIDE + // -------------------------------------------- // @Override public void perform() diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsMoney.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsMoney.java similarity index 78% rename from src/com/massivecraft/factions/cmd/CmdFactionsMoney.java rename to src/main/java/com/massivecraft/factions/cmd/CmdFactionsMoney.java index dc20a56c..4679b1bc 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsMoney.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsMoney.java @@ -3,11 +3,14 @@ package com.massivecraft.factions.cmd; import com.massivecraft.factions.Perm; import com.massivecraft.factions.cmd.req.ReqBankCommandsEnabled; import com.massivecraft.factions.cmd.req.ReqFactionsEnabled; -import com.massivecraft.mcore.cmd.HelpCommand; -import com.massivecraft.mcore.cmd.req.ReqHasPerm; +import com.massivecraft.massivecore.cmd.req.ReqHasPerm; public class CmdFactionsMoney extends FCommand { + // -------------------------------------------- // + // FIELDS + // -------------------------------------------- // + public CmdFactionsMoneyBalance cmdMoneyBalance = new CmdFactionsMoneyBalance(); public CmdFactionsMoneyDeposit cmdMoneyDeposit = new CmdFactionsMoneyDeposit(); public CmdFactionsMoneyWithdraw cmdMoneyWithdraw = new CmdFactionsMoneyWithdraw(); @@ -15,27 +18,27 @@ public class CmdFactionsMoney extends FCommand public CmdFactionsMoneyTransferFp cmdMoneyTransferFp = new CmdFactionsMoneyTransferFp(); public CmdFactionsMoneyTransferPf cmdMoneyTransferPf = new CmdFactionsMoneyTransferPf(); + // -------------------------------------------- // + // CONSTRUCT + // -------------------------------------------- // + public CmdFactionsMoney() { - this.addAliases("money"); - - this.addRequirements(ReqFactionsEnabled.get()); - this.addRequirements(ReqBankCommandsEnabled.get()); - this.addRequirements(ReqHasPerm.get(Perm.MONEY.node)); - + // Add SubCommands this.addSubCommand(this.cmdMoneyBalance); this.addSubCommand(this.cmdMoneyDeposit); this.addSubCommand(this.cmdMoneyWithdraw); this.addSubCommand(this.cmdMoneyTransferFf); this.addSubCommand(this.cmdMoneyTransferFp); this.addSubCommand(this.cmdMoneyTransferPf); - } - - @Override - public void perform() - { - this.getCommandChain().add(this); - HelpCommand.getInstance().execute(this.sender, this.args, this.commandChain); + + // Aliases + this.addAliases("money"); + + // Requirements + this.addRequirements(ReqFactionsEnabled.get()); + this.addRequirements(ReqBankCommandsEnabled.get()); + this.addRequirements(ReqHasPerm.get(Perm.MONEY.node)); } } diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsMoneyBalance.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsMoneyBalance.java similarity index 74% rename from src/com/massivecraft/factions/cmd/CmdFactionsMoneyBalance.java rename to src/main/java/com/massivecraft/factions/cmd/CmdFactionsMoneyBalance.java index 9b12c33b..d38f1c05 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsMoneyBalance.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsMoneyBalance.java @@ -6,20 +6,31 @@ import com.massivecraft.factions.cmd.req.ReqFactionsEnabled; import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.integration.Econ; import com.massivecraft.factions.Perm; -import com.massivecraft.mcore.cmd.req.ReqHasPerm; +import com.massivecraft.massivecore.cmd.req.ReqHasPerm; public class CmdFactionsMoneyBalance extends FCommand { + // -------------------------------------------- // + // CONSTRUCT + // -------------------------------------------- // + public CmdFactionsMoneyBalance() { + // Aliases this.addAliases("b", "balance"); - + + // Args this.addOptionalArg("faction", "you"); - + + // Requirements this.addRequirements(ReqFactionsEnabled.get()); this.addRequirements(ReqHasPerm.get(Perm.MONEY_BALANCE.node)); this.addRequirements(ReqBankCommandsEnabled.get()); } + + // -------------------------------------------- // + // OVERRIDE + // -------------------------------------------- // @Override public void perform() diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsMoneyDeposit.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsMoneyDeposit.java similarity index 72% rename from src/com/massivecraft/factions/cmd/CmdFactionsMoneyDeposit.java rename to src/main/java/com/massivecraft/factions/cmd/CmdFactionsMoneyDeposit.java index 786ac1f9..542ced07 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsMoneyDeposit.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsMoneyDeposit.java @@ -8,27 +8,37 @@ import com.massivecraft.factions.cmd.req.ReqFactionsEnabled; import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.MConf; import com.massivecraft.factions.integration.Econ; -import com.massivecraft.mcore.cmd.arg.ARDouble; -import com.massivecraft.mcore.cmd.req.ReqHasPerm; -import com.massivecraft.mcore.money.Money; -import com.massivecraft.mcore.util.Txt; +import com.massivecraft.massivecore.cmd.arg.ARDouble; +import com.massivecraft.massivecore.cmd.req.ReqHasPerm; +import com.massivecraft.massivecore.money.Money; +import com.massivecraft.massivecore.util.Txt; import org.bukkit.ChatColor; - public class CmdFactionsMoneyDeposit extends FCommand { + // -------------------------------------------- // + // CONSTRUCT + // -------------------------------------------- // + public CmdFactionsMoneyDeposit() { + // Aliases this.addAliases("d", "deposit"); - + + // Args this.addRequiredArg("amount"); this.addOptionalArg("faction", "you"); - + + // Requirements this.addRequirements(ReqFactionsEnabled.get()); this.addRequirements(ReqHasPerm.get(Perm.MONEY_DEPOSIT.node)); this.addRequirements(ReqBankCommandsEnabled.get()); } + + // -------------------------------------------- // + // OVERRIDE + // -------------------------------------------- // @Override public void perform() @@ -43,7 +53,7 @@ public class CmdFactionsMoneyDeposit extends FCommand if (success && MConf.get().logMoneyTransactions) { - Factions.get().log(ChatColor.stripColor(Txt.parse("%s deposited %s in the faction bank: %s", usender.getName(), Money.format(usender, amount), faction.describeTo(null)))); + Factions.get().log(ChatColor.stripColor(Txt.parse("%s deposited %s in the faction bank: %s", usender.getName(), Money.format(amount), faction.describeTo(null)))); } } diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsMoneyTransferFf.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsMoneyTransferFf.java similarity index 71% rename from src/com/massivecraft/factions/cmd/CmdFactionsMoneyTransferFf.java rename to src/main/java/com/massivecraft/factions/cmd/CmdFactionsMoneyTransferFf.java index 05ef202c..4b4f25ea 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsMoneyTransferFf.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsMoneyTransferFf.java @@ -8,28 +8,39 @@ import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.MConf; import com.massivecraft.factions.Factions; import com.massivecraft.factions.integration.Econ; -import com.massivecraft.mcore.cmd.arg.ARDouble; -import com.massivecraft.mcore.cmd.req.ReqHasPerm; -import com.massivecraft.mcore.money.Money; -import com.massivecraft.mcore.util.Txt; +import com.massivecraft.massivecore.cmd.arg.ARDouble; +import com.massivecraft.massivecore.cmd.req.ReqHasPerm; +import com.massivecraft.massivecore.money.Money; +import com.massivecraft.massivecore.util.Txt; import org.bukkit.ChatColor; public class CmdFactionsMoneyTransferFf extends FCommand { + // -------------------------------------------- // + // CONSTRUCT + // -------------------------------------------- // + public CmdFactionsMoneyTransferFf() { + // Aliases this.addAliases("ff"); - + + // Args this.addRequiredArg("amount"); this.addRequiredArg("faction"); this.addRequiredArg("faction"); - + + // Requirements this.addRequirements(ReqFactionsEnabled.get()); this.addRequirements(ReqHasPerm.get(Perm.MONEY_F2F.node)); this.addRequirements(ReqBankCommandsEnabled.get()); } + + // -------------------------------------------- // + // OVERRIDE + // -------------------------------------------- // @Override public void perform() @@ -47,7 +58,8 @@ public class CmdFactionsMoneyTransferFf extends FCommand if (success && MConf.get().logMoneyTransactions) { - Factions.get().log(ChatColor.stripColor(Txt.parse("%s transferred %s from the faction \"%s\" to the faction \"%s\"", usender.getName(), Money.format(from, amount), from.describeTo(null), to.describeTo(null)))); + Factions.get().log(ChatColor.stripColor(Txt.parse("%s transferred %s from the faction \"%s\" to the faction \"%s\"", usender.getName(), Money.format(amount), from.describeTo(null), to.describeTo(null)))); } } + } diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsMoneyTransferFp.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsMoneyTransferFp.java similarity index 70% rename from src/com/massivecraft/factions/cmd/CmdFactionsMoneyTransferFp.java rename to src/main/java/com/massivecraft/factions/cmd/CmdFactionsMoneyTransferFp.java index 83d6a696..52c7d45a 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsMoneyTransferFp.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsMoneyTransferFp.java @@ -10,29 +10,40 @@ import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.MConf; import com.massivecraft.factions.Factions; import com.massivecraft.factions.integration.Econ; -import com.massivecraft.mcore.cmd.arg.ARDouble; -import com.massivecraft.mcore.cmd.req.ReqHasPerm; -import com.massivecraft.mcore.money.Money; -import com.massivecraft.mcore.util.Txt; +import com.massivecraft.massivecore.cmd.arg.ARDouble; +import com.massivecraft.massivecore.cmd.req.ReqHasPerm; +import com.massivecraft.massivecore.money.Money; +import com.massivecraft.massivecore.util.Txt; import org.bukkit.ChatColor; public class CmdFactionsMoneyTransferFp extends FCommand { + // -------------------------------------------- // + // CONSTRUCT + // -------------------------------------------- // + public CmdFactionsMoneyTransferFp() { + // Aliases this.addAliases("fp"); - + + // Args this.addRequiredArg("amount"); this.addRequiredArg("faction"); this.addRequiredArg("player"); - + + // Requirements this.addRequirements(ReqFactionsEnabled.get()); this.addRequirements(ReqHasPerm.get(Perm.MONEY_F2P.node)); this.addRequirements(ReqBankCommandsEnabled.get()); } + // -------------------------------------------- // + // OVERRIDE + // -------------------------------------------- // + @Override public void perform() { @@ -42,14 +53,15 @@ public class CmdFactionsMoneyTransferFp extends FCommand Faction from = this.arg(1, ARFaction.get(sender)); if (from == null) return; - UPlayer to = this.arg(2, ARUPlayer.getStartAny(sender)); + UPlayer to = this.arg(2, ARUPlayer.getAny(sender)); if (to == null) return; boolean success = Econ.transferMoney(usender, from, to, amount); if (success && MConf.get().logMoneyTransactions) { - Factions.get().log(ChatColor.stripColor(Txt.parse("%s transferred %s from the faction \"%s\" to the player \"%s\"", usender.getName(), Money.format(from, amount), from.describeTo(null), to.describeTo(null)))); + Factions.get().log(ChatColor.stripColor(Txt.parse("%s transferred %s from the faction \"%s\" to the player \"%s\"", usender.getName(), Money.format(amount), from.describeTo(null), to.describeTo(null)))); } } + } diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsMoneyTransferPf.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsMoneyTransferPf.java similarity index 70% rename from src/com/massivecraft/factions/cmd/CmdFactionsMoneyTransferPf.java rename to src/main/java/com/massivecraft/factions/cmd/CmdFactionsMoneyTransferPf.java index a20eeb08..3e146d7d 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsMoneyTransferPf.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsMoneyTransferPf.java @@ -10,28 +10,39 @@ import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.MConf; import com.massivecraft.factions.Factions; import com.massivecraft.factions.integration.Econ; -import com.massivecraft.mcore.cmd.arg.ARDouble; -import com.massivecraft.mcore.cmd.req.ReqHasPerm; -import com.massivecraft.mcore.money.Money; -import com.massivecraft.mcore.util.Txt; +import com.massivecraft.massivecore.cmd.arg.ARDouble; +import com.massivecraft.massivecore.cmd.req.ReqHasPerm; +import com.massivecraft.massivecore.money.Money; +import com.massivecraft.massivecore.util.Txt; import org.bukkit.ChatColor; public class CmdFactionsMoneyTransferPf extends FCommand { + // -------------------------------------------- // + // CONSTRUCT + // -------------------------------------------- // + public CmdFactionsMoneyTransferPf() { + // Aliases this.addAliases("pf"); - + + // Args this.addRequiredArg("amount"); this.addRequiredArg("player"); this.addRequiredArg("faction"); - + + // Requirements this.addRequirements(ReqFactionsEnabled.get()); this.addRequirements(ReqHasPerm.get(Perm.MONEY_P2F.node)); this.addRequirements(ReqBankCommandsEnabled.get()); } + + // -------------------------------------------- // + // OVERRIDE + // -------------------------------------------- // @Override public void perform() @@ -39,7 +50,7 @@ public class CmdFactionsMoneyTransferPf extends FCommand Double amount = this.arg(0, ARDouble.get()); if (amount == null) return; - UPlayer from = this.arg(1, ARUPlayer.getStartAny(sender)); + UPlayer from = this.arg(1, ARUPlayer.getAny(sender)); if (from == null) return; Faction to = this.arg(2, ARFaction.get(sender)); @@ -49,7 +60,8 @@ public class CmdFactionsMoneyTransferPf extends FCommand if (success && MConf.get().logMoneyTransactions) { - Factions.get().log(ChatColor.stripColor(Txt.parse("%s transferred %s from the player \"%s\" to the faction \"%s\"", usender.getName(), Money.format(from, amount), from.describeTo(null), to.describeTo(null)))); + Factions.get().log(ChatColor.stripColor(Txt.parse("%s transferred %s from the player \"%s\" to the faction \"%s\"", usender.getName(), Money.format(amount), from.describeTo(null), to.describeTo(null)))); } } + } diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsMoneyWithdraw.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsMoneyWithdraw.java similarity index 72% rename from src/com/massivecraft/factions/cmd/CmdFactionsMoneyWithdraw.java rename to src/main/java/com/massivecraft/factions/cmd/CmdFactionsMoneyWithdraw.java index 6d21f50e..d4750756 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsMoneyWithdraw.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsMoneyWithdraw.java @@ -9,27 +9,38 @@ import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.MConf; import com.massivecraft.factions.Factions; import com.massivecraft.factions.integration.Econ; -import com.massivecraft.mcore.cmd.arg.ARDouble; -import com.massivecraft.mcore.cmd.req.ReqHasPerm; -import com.massivecraft.mcore.money.Money; -import com.massivecraft.mcore.util.Txt; +import com.massivecraft.massivecore.cmd.arg.ARDouble; +import com.massivecraft.massivecore.cmd.req.ReqHasPerm; +import com.massivecraft.massivecore.money.Money; +import com.massivecraft.massivecore.util.Txt; import org.bukkit.ChatColor; public class CmdFactionsMoneyWithdraw extends FCommand { + // -------------------------------------------- // + // CONSTRUCT + // -------------------------------------------- // + public CmdFactionsMoneyWithdraw() { + // Aliases this.addAliases("w", "withdraw"); - + + // Args this.addRequiredArg("amount"); this.addOptionalArg("faction", "you"); - + + // Requirements this.addRequirements(ReqFactionsEnabled.get()); this.addRequirements(ReqHasPerm.get(Perm.MONEY_WITHDRAW.node)); this.addRequirements(ReqBankCommandsEnabled.get()); } + + // -------------------------------------------- // + // OVERRIDE + // -------------------------------------------- // @Override public void perform() @@ -46,7 +57,8 @@ public class CmdFactionsMoneyWithdraw extends FCommand if (success && MConf.get().logMoneyTransactions) { - Factions.get().log(ChatColor.stripColor(Txt.parse("%s withdrew %s from the faction bank: %s", usender.getName(), Money.format(from, amount), from.describeTo(null)))); + Factions.get().log(ChatColor.stripColor(Txt.parse("%s withdrew %s from the faction bank: %s", usender.getName(), Money.format(amount), from.describeTo(null)))); } } + } diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsName.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsName.java similarity index 72% rename from src/com/massivecraft/factions/cmd/CmdFactionsName.java rename to src/main/java/com/massivecraft/factions/cmd/CmdFactionsName.java index 3df516c2..af4383d2 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsName.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsName.java @@ -10,23 +10,35 @@ import com.massivecraft.factions.cmd.req.ReqRoleIsAtLeast; import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.FactionColl; import com.massivecraft.factions.entity.FactionColls; -import com.massivecraft.factions.event.FactionsEventNameChange; +import com.massivecraft.factions.entity.UConf; +import com.massivecraft.factions.event.EventFactionsNameChange; import com.massivecraft.factions.util.MiscUtil; -import com.massivecraft.mcore.cmd.req.ReqHasPerm; +import com.massivecraft.massivecore.cmd.req.ReqHasPerm; public class CmdFactionsName extends FCommand { + // -------------------------------------------- // + // CONSTRUCT + // -------------------------------------------- // + public CmdFactionsName() { + // Aliases this.addAliases("name"); - + + // Args this.addRequiredArg("new name"); - + + // Requirements this.addRequirements(ReqFactionsEnabled.get()); this.addRequirements(ReqHasPerm.get(Perm.NAME.node)); this.addRequirements(ReqHasFaction.get()); this.addRequirements(ReqRoleIsAtLeast.get(Rel.OFFICER)); } + + // -------------------------------------------- // + // OVERRIDE + // -------------------------------------------- // @Override public void perform() @@ -52,7 +64,7 @@ public class CmdFactionsName extends FCommand } // Event - FactionsEventNameChange event = new FactionsEventNameChange(sender, usenderFaction, newName); + EventFactionsNameChange event = new EventFactionsNameChange(sender, usenderFaction, newName); event.run(); if (event.isCancelled()) return; newName = event.getNewName(); @@ -63,13 +75,15 @@ public class CmdFactionsName extends FCommand // Inform usenderFaction.msg("%s changed your faction name to %s", usender.describeTo(usenderFaction, true), usenderFaction.getName(usenderFaction)); + + if (!UConf.get(usender).broadcastNameChange) return; for (Faction faction : FactionColls.get().get(usenderFaction).getAll()) { if (faction == usenderFaction) { continue; } - faction.msg("The faction %s changed their name to %s.", usender.getColorTo(faction)+oldName, usenderFaction.getName(faction)); + faction.msg("The player %s changed their faction name from %s to %s.", usender.describeTo(faction, true), usender.getColorTo(faction)+oldName, usenderFaction.getName(faction)); } } diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsOfficer.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsOfficer.java similarity index 82% rename from src/com/massivecraft/factions/cmd/CmdFactionsOfficer.java rename to src/main/java/com/massivecraft/factions/cmd/CmdFactionsOfficer.java index 17c13859..393aac15 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsOfficer.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsOfficer.java @@ -6,24 +6,35 @@ import com.massivecraft.factions.cmd.arg.ARUPlayer; import com.massivecraft.factions.cmd.req.ReqFactionsEnabled; import com.massivecraft.factions.entity.UPlayer; import com.massivecraft.factions.entity.Faction; -import com.massivecraft.mcore.cmd.req.ReqHasPerm; +import com.massivecraft.massivecore.cmd.req.ReqHasPerm; public class CmdFactionsOfficer extends FCommand { + // -------------------------------------------- // + // CONSTRUCT + // -------------------------------------------- // + public CmdFactionsOfficer() { + // Aliases this.addAliases("officer"); - + + // Args this.addRequiredArg("player"); - + + // Requirements this.addRequirements(ReqFactionsEnabled.get()); this.addRequirements(ReqHasPerm.get(Perm.OFFICER.node)); } + + // -------------------------------------------- // + // OVERRIDE + // -------------------------------------------- // @Override public void perform() { - UPlayer you = this.arg(0, ARUPlayer.getStartAny(sender)); + UPlayer you = this.arg(0, ARUPlayer.getAny(sender)); if (you == null) return; boolean permAny = Perm.OFFICER_ANY.has(sender, false); diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsOpen.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsOpen.java similarity index 69% rename from src/com/massivecraft/factions/cmd/CmdFactionsOpen.java rename to src/main/java/com/massivecraft/factions/cmd/CmdFactionsOpen.java index 8db88cbf..03686a3b 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsOpen.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsOpen.java @@ -5,23 +5,34 @@ import com.massivecraft.factions.Rel; import com.massivecraft.factions.cmd.req.ReqFactionsEnabled; import com.massivecraft.factions.cmd.req.ReqHasFaction; import com.massivecraft.factions.cmd.req.ReqRoleIsAtLeast; -import com.massivecraft.factions.event.FactionsEventOpenChange; -import com.massivecraft.mcore.cmd.arg.ARBoolean; -import com.massivecraft.mcore.cmd.req.ReqHasPerm; +import com.massivecraft.factions.event.EventFactionsOpenChange; +import com.massivecraft.massivecore.cmd.arg.ARBoolean; +import com.massivecraft.massivecore.cmd.req.ReqHasPerm; public class CmdFactionsOpen extends FCommand { + // -------------------------------------------- // + // CONSTRUCT + // -------------------------------------------- // + public CmdFactionsOpen() { + // Aliases this.addAliases("open"); - + + // Args this.addOptionalArg("yes/no", "toggle"); - + + // Requirements this.addRequirements(ReqFactionsEnabled.get()); this.addRequirements(ReqHasPerm.get(Perm.OPEN.node)); this.addRequirements(ReqHasFaction.get()); this.addRequirements(ReqRoleIsAtLeast.get(Rel.OFFICER)); } + + // -------------------------------------------- // + // OVERRIDE + // -------------------------------------------- // @Override public void perform() @@ -31,7 +42,7 @@ public class CmdFactionsOpen extends FCommand if (newOpen == null) return; // Event - FactionsEventOpenChange event = new FactionsEventOpenChange(sender, usenderFaction, newOpen); + EventFactionsOpenChange event = new EventFactionsOpenChange(sender, usenderFaction, newOpen); event.run(); if (event.isCancelled()) return; newOpen = event.isNewOpen(); diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsPerm.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsPerm.java similarity index 83% rename from src/com/massivecraft/factions/cmd/CmdFactionsPerm.java rename to src/main/java/com/massivecraft/factions/cmd/CmdFactionsPerm.java index 90676170..a75875da 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsPerm.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsPerm.java @@ -8,25 +8,36 @@ import com.massivecraft.factions.cmd.arg.ARFaction; import com.massivecraft.factions.cmd.arg.ARRel; import com.massivecraft.factions.cmd.req.ReqFactionsEnabled; import com.massivecraft.factions.entity.Faction; -import com.massivecraft.mcore.cmd.arg.ARBoolean; -import com.massivecraft.mcore.cmd.req.ReqHasPerm; -import com.massivecraft.mcore.util.Txt; +import com.massivecraft.massivecore.cmd.arg.ARBoolean; +import com.massivecraft.massivecore.cmd.req.ReqHasPerm; +import com.massivecraft.massivecore.util.Txt; public class CmdFactionsPerm extends FCommand { + // -------------------------------------------- // + // CONSTRUCT + // -------------------------------------------- // + public CmdFactionsPerm() { + // Aliases this.addAliases("perm"); - + + // Args this.addOptionalArg("faction", "you"); this.addOptionalArg("perm", "all"); this.addOptionalArg("relation", "read"); this.addOptionalArg("yes/no", "read"); this.setErrorOnToManyArgs(false); - + + // Requirements this.addRequirements(ReqFactionsEnabled.get()); this.addRequirements(ReqHasPerm.get(Perm.PERM.node)); } + + // -------------------------------------------- // + // OVERRIDE + // -------------------------------------------- // @Override public void perform() diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsPlayer.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsPlayer.java similarity index 77% rename from src/com/massivecraft/factions/cmd/CmdFactionsPlayer.java rename to src/main/java/com/massivecraft/factions/cmd/CmdFactionsPlayer.java index 821a8bd5..d039b11b 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsPlayer.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsPlayer.java @@ -6,29 +6,40 @@ import com.massivecraft.factions.Perm; import com.massivecraft.factions.cmd.arg.ARUPlayer; import com.massivecraft.factions.cmd.req.ReqFactionsEnabled; import com.massivecraft.factions.entity.UPlayer; -import com.massivecraft.mcore.Progressbar; -import com.massivecraft.mcore.cmd.req.ReqHasPerm; -import com.massivecraft.mcore.util.TimeDiffUtil; -import com.massivecraft.mcore.util.TimeUnit; -import com.massivecraft.mcore.util.Txt; +import com.massivecraft.massivecore.Progressbar; +import com.massivecraft.massivecore.cmd.req.ReqHasPerm; +import com.massivecraft.massivecore.util.TimeDiffUtil; +import com.massivecraft.massivecore.util.TimeUnit; +import com.massivecraft.massivecore.util.Txt; public class CmdFactionsPlayer extends FCommand { + // -------------------------------------------- // + // CONSTRUCT + // -------------------------------------------- // + public CmdFactionsPlayer() { + // Aliases this.addAliases("p", "player"); - + + // Args this.addOptionalArg("player", "you"); - + + // Requirements this.addRequirements(ReqFactionsEnabled.get()); this.addRequirements(ReqHasPerm.get(Perm.PLAYER.node)); } + + // -------------------------------------------- // + // OVERRIDE + // -------------------------------------------- // @Override public void perform() { // Args - UPlayer uplayer = this.arg(0, ARUPlayer.getStartAny(sender), usender); + UPlayer uplayer = this.arg(0, ARUPlayer.getAny(sender), usender); if (uplayer == null) return; // INFO: Title @@ -70,4 +81,5 @@ public class CmdFactionsPlayer extends FCommand msg("Power per Death: %.2f", uplayer.getPowerPerDeath()); } + } \ No newline at end of file diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsPowerBoost.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsPowerBoost.java similarity index 80% rename from src/com/massivecraft/factions/cmd/CmdFactionsPowerBoost.java rename to src/main/java/com/massivecraft/factions/cmd/CmdFactionsPowerBoost.java index 4478285d..26b4e2a3 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsPowerBoost.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsPowerBoost.java @@ -7,22 +7,33 @@ import com.massivecraft.factions.cmd.arg.ARFaction; import com.massivecraft.factions.cmd.req.ReqFactionsEnabled; import com.massivecraft.factions.entity.UPlayer; import com.massivecraft.factions.entity.Faction; -import com.massivecraft.mcore.cmd.arg.ARDouble; -import com.massivecraft.mcore.cmd.req.ReqHasPerm; +import com.massivecraft.massivecore.cmd.arg.ARDouble; +import com.massivecraft.massivecore.cmd.req.ReqHasPerm; public class CmdFactionsPowerBoost extends FCommand { + // -------------------------------------------- // + // CONSTRUCT + // -------------------------------------------- // + public CmdFactionsPowerBoost() { + // Aliases this.addAliases("powerboost"); - + + // Args this.addRequiredArg("p|f|player|faction"); this.addRequiredArg("name"); this.addRequiredArg("#"); - + + // Requirements this.addRequirements(ReqFactionsEnabled.get()); this.addRequirements(ReqHasPerm.get(Perm.POWERBOOST.node)); } + + // -------------------------------------------- // + // OVERRIDE + // -------------------------------------------- // @Override public void perform() @@ -47,7 +58,7 @@ public class CmdFactionsPowerBoost extends FCommand if (doPlayer) { - UPlayer targetPlayer = this.arg(1, ARUPlayer.getStartAny(sender)); + UPlayer targetPlayer = this.arg(1, ARUPlayer.getAny(sender)); if (targetPlayer == null) return; targetPlayer.setPowerBoost(targetPower); @@ -65,4 +76,5 @@ public class CmdFactionsPowerBoost extends FCommand msg(""+target+" now has a power bonus/penalty of "+targetPower+" to min and max power levels."); Factions.get().log(usender.getName()+" has set the power bonus/penalty for "+target+" to "+targetPower+"."); } + } diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsPromote.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsPromote.java similarity index 81% rename from src/com/massivecraft/factions/cmd/CmdFactionsPromote.java rename to src/main/java/com/massivecraft/factions/cmd/CmdFactionsPromote.java index 449314fc..04df2da7 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsPromote.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsPromote.java @@ -5,16 +5,23 @@ import com.massivecraft.factions.Rel; import com.massivecraft.factions.cmd.arg.ARUPlayer; import com.massivecraft.factions.cmd.req.ReqFactionsEnabled; import com.massivecraft.factions.entity.UPlayer; -import com.massivecraft.mcore.cmd.req.ReqHasPerm; +import com.massivecraft.massivecore.cmd.req.ReqHasPerm; public class CmdFactionsPromote extends FCommand { + // -------------------------------------------- // + // CONSTRUCT + // -------------------------------------------- // + public CmdFactionsPromote() { + // Aliases this.addAliases("promote"); - + + // Args this.addRequiredArg("player"); - + + // Requirements this.addRequirements(ReqFactionsEnabled.get()); this.addRequirements(ReqHasPerm.get(Perm.PROMOTE.node)); @@ -22,11 +29,15 @@ public class CmdFactionsPromote extends FCommand //To promote someone from member -> officer you must be a leader. //We'll handle this internally } + + // -------------------------------------------- // + // OVERRIDE + // -------------------------------------------- // @Override public void perform() { - UPlayer you = this.arg(0, ARUPlayer.getStartAny(sender)); + UPlayer you = this.arg(0, ARUPlayer.getAny(sender)); if (you == null) return; if (you.getFaction() != usenderFaction) diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsRelationAbstract.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsRelationAbstract.java similarity index 83% rename from src/com/massivecraft/factions/cmd/CmdFactionsRelationAbstract.java rename to src/main/java/com/massivecraft/factions/cmd/CmdFactionsRelationAbstract.java index 28a76ba6..ae731545 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsRelationAbstract.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsRelationAbstract.java @@ -1,6 +1,5 @@ package com.massivecraft.factions.cmd; -import com.massivecraft.factions.ConfServer; import com.massivecraft.factions.FFlag; import com.massivecraft.factions.Perm; import com.massivecraft.factions.Rel; @@ -9,22 +8,33 @@ import com.massivecraft.factions.cmd.req.ReqFactionsEnabled; import com.massivecraft.factions.cmd.req.ReqHasFaction; import com.massivecraft.factions.cmd.req.ReqRoleIsAtLeast; import com.massivecraft.factions.entity.Faction; -import com.massivecraft.factions.event.FactionsEventRelationChange; -import com.massivecraft.mcore.cmd.req.ReqHasPerm; +import com.massivecraft.factions.entity.MConf; +import com.massivecraft.factions.event.EventFactionsRelationChange; +import com.massivecraft.massivecore.cmd.req.ReqHasPerm; public abstract class CmdFactionsRelationAbstract extends FCommand { public Rel targetRelation; + + // -------------------------------------------- // + // CONSTRUCT + // -------------------------------------------- // public CmdFactionsRelationAbstract() { + // Aliases this.addRequiredArg("faction"); - + + // Requirements this.addRequirements(ReqFactionsEnabled.get()); this.addRequirements(ReqHasPerm.get(Perm.RELATION.node)); this.addRequirements(ReqHasFaction.get()); this.addRequirements(ReqRoleIsAtLeast.get(Rel.OFFICER)); } + + // -------------------------------------------- // + // OVERRIDE + // -------------------------------------------- // @Override public void perform() @@ -56,7 +66,7 @@ public abstract class CmdFactionsRelationAbstract extends FCommand } // Event - FactionsEventRelationChange event = new FactionsEventRelationChange(sender, usenderFaction, otherFaction, newRelation); + EventFactionsRelationChange event = new EventFactionsRelationChange(sender, usenderFaction, otherFaction, newRelation); event.run(); if (event.isCancelled()) return; newRelation = event.getNewRelation(); @@ -75,7 +85,7 @@ public abstract class CmdFactionsRelationAbstract extends FCommand else { otherFaction.msg("%s wishes to be %s.", usenderFaction.describeTo(otherFaction, true), newRelation.getColor()+newRelation.getDescFactionOne()); - otherFaction.msg("Type /"+ConfServer.baseCommandAliases.get(0)+" "+newRelation+" "+usenderFaction.getName()+" to accept."); + otherFaction.msg("Type /"+MConf.get().aliasesF.get(0)+" "+newRelation+" "+usenderFaction.getName()+" to accept."); usenderFaction.msg("%s were informed that you wish to be %s.", otherFaction.describeTo(usenderFaction, true), newRelation.getColor()+newRelation.getDescFactionOne()); } @@ -93,4 +103,5 @@ public abstract class CmdFactionsRelationAbstract extends FCommand usenderFaction.msg("This will have no effect while your faction is peaceful."); } } + } diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsRelationAlly.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsRelationAlly.java similarity index 64% rename from src/com/massivecraft/factions/cmd/CmdFactionsRelationAlly.java rename to src/main/java/com/massivecraft/factions/cmd/CmdFactionsRelationAlly.java index 87c33220..0a813f87 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsRelationAlly.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsRelationAlly.java @@ -4,10 +4,17 @@ import com.massivecraft.factions.Rel; public class CmdFactionsRelationAlly extends CmdFactionsRelationAbstract { + // -------------------------------------------- // + // CONSTRUCT + // -------------------------------------------- // + public CmdFactionsRelationAlly() { + // Aliases this.addAliases("ally"); + // Misc this.targetRelation = Rel.ALLY; } + } diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsRelationEnemy.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsRelationEnemy.java similarity index 64% rename from src/com/massivecraft/factions/cmd/CmdFactionsRelationEnemy.java rename to src/main/java/com/massivecraft/factions/cmd/CmdFactionsRelationEnemy.java index ec4dd181..e4ddf510 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsRelationEnemy.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsRelationEnemy.java @@ -4,10 +4,17 @@ import com.massivecraft.factions.Rel; public class CmdFactionsRelationEnemy extends CmdFactionsRelationAbstract { + // -------------------------------------------- // + // CONSTRUCT + // -------------------------------------------- // + public CmdFactionsRelationEnemy() { + // Aliases this.addAliases("enemy"); + // Misc this.targetRelation = Rel.ENEMY; } + } diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsRelationNeutral.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsRelationNeutral.java similarity index 65% rename from src/com/massivecraft/factions/cmd/CmdFactionsRelationNeutral.java rename to src/main/java/com/massivecraft/factions/cmd/CmdFactionsRelationNeutral.java index f616f45c..aa918a04 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsRelationNeutral.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsRelationNeutral.java @@ -4,10 +4,17 @@ import com.massivecraft.factions.Rel; public class CmdFactionsRelationNeutral extends CmdFactionsRelationAbstract { + // -------------------------------------------- // + // CONSTRUCT + // -------------------------------------------- // + public CmdFactionsRelationNeutral() { + // Aliases this.addAliases("neutral"); + // Misc this.targetRelation = Rel.NEUTRAL; } + } diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsRelationTruce.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsRelationTruce.java similarity index 64% rename from src/com/massivecraft/factions/cmd/CmdFactionsRelationTruce.java rename to src/main/java/com/massivecraft/factions/cmd/CmdFactionsRelationTruce.java index a9105dee..19aeef71 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsRelationTruce.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsRelationTruce.java @@ -4,10 +4,17 @@ import com.massivecraft.factions.Rel; public class CmdFactionsRelationTruce extends CmdFactionsRelationAbstract { + // -------------------------------------------- // + // CONSTRUCT + // -------------------------------------------- // + public CmdFactionsRelationTruce() { + // Aliases this.addAliases("truce"); + // Misc this.targetRelation = Rel.TRUCE; } + } diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsSeeChunk.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSeeChunk.java similarity index 70% rename from src/com/massivecraft/factions/cmd/CmdFactionsSeeChunk.java rename to src/main/java/com/massivecraft/factions/cmd/CmdFactionsSeeChunk.java index 9ad36a72..eae91913 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsSeeChunk.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSeeChunk.java @@ -7,21 +7,31 @@ import org.bukkit.entity.Player; import com.massivecraft.factions.Perm; import com.massivecraft.factions.util.VisualizeUtil; -import com.massivecraft.mcore.cmd.req.ReqHasPerm; -import com.massivecraft.mcore.cmd.req.ReqIsPlayer; -import com.massivecraft.mcore.ps.PS; -import com.massivecraft.mcore.ps.PSFormatHumanSpace; +import com.massivecraft.massivecore.cmd.req.ReqHasPerm; +import com.massivecraft.massivecore.cmd.req.ReqIsPlayer; +import com.massivecraft.massivecore.ps.PS; +import com.massivecraft.massivecore.ps.PSFormatHumanSpace; public class CmdFactionsSeeChunk extends FCommand { + // -------------------------------------------- // + // CONSTRUCT + // -------------------------------------------- // + public CmdFactionsSeeChunk() { + // Aliases this.addAliases("sc", "seechunk"); - - //this.addRequirements(ReqFactionsEnabled.get()); + + // Requirements + // this.addRequirements(ReqFactionsEnabled.get()); this.addRequirements(ReqHasPerm.get(Perm.SEE_CHUNK.node)); this.addRequirements(ReqIsPlayer.get()); } + + // -------------------------------------------- // + // OVERRIDE + // -------------------------------------------- // @Override public void perform() @@ -56,12 +66,13 @@ public class CmdFactionsSeeChunk extends FCommand msg("Visualized %s", chunk.toString(PSFormatHumanSpace.get())); } + @SuppressWarnings("deprecation") public static void showPillar(Player player, World world, int blockX, int blockZ) { for (int blockY = 0; blockY < world.getMaxHeight(); blockY++) { Location loc = new Location(world, blockX, blockY, blockZ); - if (loc.getBlock().getTypeId() != 0) continue; + if (loc.getBlock().getType() != Material.AIR) continue; int typeId = blockY % 5 == 0 ? Material.GLOWSTONE.getId() : Material.GLASS.getId(); VisualizeUtil.addLocation(player, loc, typeId); } diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsSethome.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSethome.java similarity index 76% rename from src/com/massivecraft/factions/cmd/CmdFactionsSethome.java rename to src/main/java/com/massivecraft/factions/cmd/CmdFactionsSethome.java index c22504e7..55b8724b 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsSethome.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSethome.java @@ -7,23 +7,34 @@ import com.massivecraft.factions.cmd.arg.ARFaction; import com.massivecraft.factions.cmd.req.ReqFactionsEnabled; import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.UConf; -import com.massivecraft.factions.event.FactionsEventHomeChange; -import com.massivecraft.mcore.cmd.req.ReqHasPerm; -import com.massivecraft.mcore.cmd.req.ReqIsPlayer; -import com.massivecraft.mcore.ps.PS; +import com.massivecraft.factions.event.EventFactionsHomeChange; +import com.massivecraft.massivecore.cmd.req.ReqHasPerm; +import com.massivecraft.massivecore.cmd.req.ReqIsPlayer; +import com.massivecraft.massivecore.ps.PS; public class CmdFactionsSethome extends FCommand { + // -------------------------------------------- // + // CONSTRUCT + // -------------------------------------------- // + public CmdFactionsSethome() { + // Aliases this.addAliases("sethome"); - + + // Args this.addOptionalArg("faction", "you"); - + + // Requirements this.addRequirements(ReqFactionsEnabled.get()); this.addRequirements(ReqIsPlayer.get()); this.addRequirements(ReqHasPerm.get(Perm.SETHOME.node)); } + + // -------------------------------------------- // + // OVERRIDE + // -------------------------------------------- // @Override public void perform() @@ -52,7 +63,7 @@ public class CmdFactionsSethome extends FCommand } // Event - FactionsEventHomeChange event = new FactionsEventHomeChange(sender, faction, newHome); + EventFactionsHomeChange event = new EventFactionsHomeChange(sender, faction, newHome); event.run(); if (event.isCancelled()) return; newHome = event.getNewHome(); diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsTitle.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsTitle.java similarity index 69% rename from src/com/massivecraft/factions/cmd/CmdFactionsTitle.java rename to src/main/java/com/massivecraft/factions/cmd/CmdFactionsTitle.java index 08b999e1..b209c682 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsTitle.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsTitle.java @@ -8,30 +8,41 @@ import com.massivecraft.factions.cmd.arg.ARUPlayer; import com.massivecraft.factions.cmd.req.ReqFactionsEnabled; import com.massivecraft.factions.cmd.req.ReqRoleIsAtLeast; import com.massivecraft.factions.entity.UPlayer; -import com.massivecraft.factions.event.FactionsEventTitleChange; -import com.massivecraft.mcore.cmd.arg.ARString; -import com.massivecraft.mcore.cmd.req.ReqHasPerm; -import com.massivecraft.mcore.util.Txt; +import com.massivecraft.factions.event.EventFactionsTitleChange; +import com.massivecraft.massivecore.cmd.arg.ARString; +import com.massivecraft.massivecore.cmd.req.ReqHasPerm; +import com.massivecraft.massivecore.util.Txt; public class CmdFactionsTitle extends FCommand { + // -------------------------------------------- // + // CONSTRUCT + // -------------------------------------------- // + public CmdFactionsTitle() { + // Aliases this.addAliases("title"); - + + // Args this.addRequiredArg("player"); this.addOptionalArg("title", ""); - + + // Requirements this.addRequirements(ReqFactionsEnabled.get()); this.addRequirements(ReqHasPerm.get(Perm.TITLE.node)); this.addRequirements(ReqRoleIsAtLeast.get(Rel.OFFICER)); } + + // -------------------------------------------- // + // OVERRIDE + // -------------------------------------------- // @Override public void perform() { // Args - UPlayer you = this.arg(0, ARUPlayer.getStartAny(sender)); + UPlayer you = this.arg(0, ARUPlayer.getAny(sender)); if (you == null) return; String newTitle = this.argConcatFrom(1, ARString.get(), ""); @@ -47,7 +58,7 @@ public class CmdFactionsTitle extends FCommand if ( ! canIAdministerYou(usender, you)) return; // Event - FactionsEventTitleChange event = new FactionsEventTitleChange(sender, you, newTitle); + EventFactionsTitleChange event = new EventFactionsTitleChange(sender, you, newTitle); event.run(); if (event.isCancelled()) return; newTitle = event.getNewTitle(); diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsUnclaim.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsUnclaim.java similarity index 66% rename from src/com/massivecraft/factions/cmd/CmdFactionsUnclaim.java rename to src/main/java/com/massivecraft/factions/cmd/CmdFactionsUnclaim.java index b25b3bc2..bb610523 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsUnclaim.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsUnclaim.java @@ -5,21 +5,31 @@ import com.massivecraft.factions.cmd.req.ReqHasFaction; import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.FactionColls; import com.massivecraft.factions.Perm; -import com.massivecraft.mcore.cmd.req.ReqHasPerm; -import com.massivecraft.mcore.cmd.req.ReqIsPlayer; -import com.massivecraft.mcore.ps.PS; +import com.massivecraft.massivecore.cmd.req.ReqHasPerm; +import com.massivecraft.massivecore.cmd.req.ReqIsPlayer; +import com.massivecraft.massivecore.ps.PS; public class CmdFactionsUnclaim extends FCommand { + // -------------------------------------------- // + // CONSTRUCT + // -------------------------------------------- // + public CmdFactionsUnclaim() { + // Aliases this.addAliases("unclaim"); - + + // Requirements this.addRequirements(ReqFactionsEnabled.get()); this.addRequirements(ReqHasPerm.get(Perm.UNCLAIM.node)); this.addRequirements(ReqHasFaction.get()); this.addRequirements(ReqIsPlayer.get()); } + + // -------------------------------------------- // + // OVERRIDE + // -------------------------------------------- // @Override public void perform() diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsUnclaimall.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsUnclaimall.java similarity index 80% rename from src/com/massivecraft/factions/cmd/CmdFactionsUnclaimall.java rename to src/main/java/com/massivecraft/factions/cmd/CmdFactionsUnclaimall.java index cea0399f..ec71a181 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsUnclaimall.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsUnclaimall.java @@ -14,21 +14,31 @@ import com.massivecraft.factions.entity.BoardColls; import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.FactionColls; import com.massivecraft.factions.entity.MConf; -import com.massivecraft.factions.event.FactionsEventChunkChange; -import com.massivecraft.mcore.cmd.req.ReqHasPerm; -import com.massivecraft.mcore.ps.PS; +import com.massivecraft.factions.event.EventFactionsChunkChange; +import com.massivecraft.massivecore.cmd.req.ReqHasPerm; +import com.massivecraft.massivecore.ps.PS; public class CmdFactionsUnclaimall extends FCommand { + // -------------------------------------------- // + // CONSTRUCT + // -------------------------------------------- // + public CmdFactionsUnclaimall() { + // Aliases this.addAliases("unclaimall"); - + + // Requirements this.addRequirements(ReqFactionsEnabled.get()); this.addRequirements(ReqHasPerm.get(Perm.UNCLAIM_ALL.node)); this.addRequirements(ReqHasFaction.get()); this.addRequirements(ReqRoleIsAtLeast.get(Rel.OFFICER)); } + + // -------------------------------------------- // + // OVERRIDE + // -------------------------------------------- // @Override public void perform() @@ -48,7 +58,7 @@ public class CmdFactionsUnclaimall extends FCommand int countFail = 0; for (PS chunk : chunks) { - FactionsEventChunkChange event = new FactionsEventChunkChange(sender, chunk, newFaction); + EventFactionsChunkChange event = new EventFactionsChunkChange(sender, chunk, newFaction); event.run(); if (event.isCancelled()) { diff --git a/src/com/massivecraft/factions/cmd/FCommand.java b/src/main/java/com/massivecraft/factions/cmd/FCommand.java similarity index 75% rename from src/com/massivecraft/factions/cmd/FCommand.java rename to src/main/java/com/massivecraft/factions/cmd/FCommand.java index eafb0959..9ccd4212 100644 --- a/src/com/massivecraft/factions/cmd/FCommand.java +++ b/src/main/java/com/massivecraft/factions/cmd/FCommand.java @@ -5,15 +5,23 @@ import com.massivecraft.factions.entity.MPlayer; import com.massivecraft.factions.entity.UConf; import com.massivecraft.factions.entity.UPlayer; import com.massivecraft.factions.entity.Faction; -import com.massivecraft.mcore.cmd.MCommand; -import com.massivecraft.mcore.util.Txt; +import com.massivecraft.massivecore.cmd.MassiveCommand; +import com.massivecraft.massivecore.util.Txt; -public abstract class FCommand extends MCommand +public abstract class FCommand extends MassiveCommand { + // -------------------------------------------- // + // FIELDS + // -------------------------------------------- // + public MPlayer msender; public UPlayer usender; public Faction usenderFaction; + // -------------------------------------------- // + // OVERRIDE + // -------------------------------------------- // + @Override public void fixSenderVars() { @@ -29,6 +37,15 @@ public abstract class FCommand extends MCommand this.usenderFaction = this.usender.getFaction(); } + + @Override + public void unsetSenderVars() + { + this.msender = null; + this.usender = null; + this.usenderFaction = null; + } + // -------------------------------------------- // // COMMONLY USED LOGIC // -------------------------------------------- // @@ -68,4 +85,5 @@ public abstract class FCommand extends MCommand return false; } + } diff --git a/src/com/massivecraft/factions/cmd/arg/ARFFlag.java b/src/main/java/com/massivecraft/factions/cmd/arg/ARFFlag.java similarity index 86% rename from src/com/massivecraft/factions/cmd/arg/ARFFlag.java rename to src/main/java/com/massivecraft/factions/cmd/arg/ARFFlag.java index 1994c3e0..4545548c 100644 --- a/src/com/massivecraft/factions/cmd/arg/ARFFlag.java +++ b/src/main/java/com/massivecraft/factions/cmd/arg/ARFFlag.java @@ -7,8 +7,8 @@ import java.util.List; import org.bukkit.command.CommandSender; import com.massivecraft.factions.FFlag; -import com.massivecraft.mcore.cmd.arg.ARAbstractSelect; -import com.massivecraft.mcore.util.Txt; +import com.massivecraft.massivecore.cmd.arg.ARAbstractSelect; +import com.massivecraft.massivecore.util.Txt; public class ARFFlag extends ARAbstractSelect { diff --git a/src/com/massivecraft/factions/cmd/arg/ARFPerm.java b/src/main/java/com/massivecraft/factions/cmd/arg/ARFPerm.java similarity index 86% rename from src/com/massivecraft/factions/cmd/arg/ARFPerm.java rename to src/main/java/com/massivecraft/factions/cmd/arg/ARFPerm.java index 7f9485e7..f8d6eb41 100644 --- a/src/com/massivecraft/factions/cmd/arg/ARFPerm.java +++ b/src/main/java/com/massivecraft/factions/cmd/arg/ARFPerm.java @@ -7,8 +7,8 @@ import java.util.List; import org.bukkit.command.CommandSender; import com.massivecraft.factions.FPerm; -import com.massivecraft.mcore.cmd.arg.ARAbstractSelect; -import com.massivecraft.mcore.util.Txt; +import com.massivecraft.massivecore.cmd.arg.ARAbstractSelect; +import com.massivecraft.massivecore.util.Txt; public class ARFPerm extends ARAbstractSelect { diff --git a/src/com/massivecraft/factions/cmd/arg/ARFaction.java b/src/main/java/com/massivecraft/factions/cmd/arg/ARFaction.java similarity index 81% rename from src/com/massivecraft/factions/cmd/arg/ARFaction.java rename to src/main/java/com/massivecraft/factions/cmd/arg/ARFaction.java index 119bbb2f..28ca3a98 100644 --- a/src/com/massivecraft/factions/cmd/arg/ARFaction.java +++ b/src/main/java/com/massivecraft/factions/cmd/arg/ARFaction.java @@ -7,9 +7,10 @@ import com.massivecraft.factions.entity.UPlayerColls; import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.FactionColl; import com.massivecraft.factions.entity.FactionColls; -import com.massivecraft.mcore.cmd.arg.ArgReaderAbstract; -import com.massivecraft.mcore.cmd.arg.ArgResult; -import com.massivecraft.mcore.util.Txt; +import com.massivecraft.massivecore.cmd.arg.ArgReaderAbstract; +import com.massivecraft.massivecore.cmd.arg.ArgResult; +import com.massivecraft.massivecore.util.IdUtil; +import com.massivecraft.massivecore.util.Txt; public class ARFaction extends ArgReaderAbstract { @@ -48,7 +49,8 @@ public class ARFaction extends ArgReaderAbstract if (result.hasResult()) return result; // UPlayer Name Exact - UPlayer uplayer = UPlayerColls.get().get(this.getColl()).get(str); + String id = IdUtil.getId(str); + UPlayer uplayer = UPlayerColls.get().get(this.getColl()).get(id); if (uplayer != null) { result.setResult(uplayer.getFaction()); diff --git a/src/com/massivecraft/factions/cmd/arg/ARRel.java b/src/main/java/com/massivecraft/factions/cmd/arg/ARRel.java similarity index 85% rename from src/com/massivecraft/factions/cmd/arg/ARRel.java rename to src/main/java/com/massivecraft/factions/cmd/arg/ARRel.java index 3f1d808c..7d8f92be 100644 --- a/src/com/massivecraft/factions/cmd/arg/ARRel.java +++ b/src/main/java/com/massivecraft/factions/cmd/arg/ARRel.java @@ -7,8 +7,8 @@ import java.util.List; import org.bukkit.command.CommandSender; import com.massivecraft.factions.Rel; -import com.massivecraft.mcore.cmd.arg.ARAbstractSelect; -import com.massivecraft.mcore.util.Txt; +import com.massivecraft.massivecore.cmd.arg.ARAbstractSelect; +import com.massivecraft.massivecore.util.Txt; public class ARRel extends ARAbstractSelect { diff --git a/src/main/java/com/massivecraft/factions/cmd/arg/ARUPlayer.java b/src/main/java/com/massivecraft/factions/cmd/arg/ARUPlayer.java new file mode 100644 index 00000000..1b67ba0c --- /dev/null +++ b/src/main/java/com/massivecraft/factions/cmd/arg/ARUPlayer.java @@ -0,0 +1,17 @@ +package com.massivecraft.factions.cmd.arg; + +import com.massivecraft.factions.entity.UPlayer; +import com.massivecraft.factions.entity.UPlayerColls; +import com.massivecraft.massivecore.cmd.arg.ArgReader; + +public class ARUPlayer +{ + // -------------------------------------------- // + // INSTANCE + // -------------------------------------------- // + + public static ArgReader getAny(Object o) { return UPlayerColls.get().get(o).getAREntity(); } + + public static ArgReader getOnline(Object o) { return UPlayerColls.get().get(o).getAREntity(true); } + +} diff --git a/src/com/massivecraft/factions/cmd/req/ReqBankCommandsEnabled.java b/src/main/java/com/massivecraft/factions/cmd/req/ReqBankCommandsEnabled.java similarity index 74% rename from src/com/massivecraft/factions/cmd/req/ReqBankCommandsEnabled.java rename to src/main/java/com/massivecraft/factions/cmd/req/ReqBankCommandsEnabled.java index 2751ed09..a77c88d3 100644 --- a/src/com/massivecraft/factions/cmd/req/ReqBankCommandsEnabled.java +++ b/src/main/java/com/massivecraft/factions/cmd/req/ReqBankCommandsEnabled.java @@ -3,9 +3,9 @@ package com.massivecraft.factions.cmd.req; import org.bukkit.command.CommandSender; import com.massivecraft.factions.entity.UConf; -import com.massivecraft.mcore.cmd.MCommand; -import com.massivecraft.mcore.cmd.req.ReqAbstract; -import com.massivecraft.mcore.util.Txt; +import com.massivecraft.massivecore.cmd.MassiveCommand; +import com.massivecraft.massivecore.cmd.req.ReqAbstract; +import com.massivecraft.massivecore.util.Txt; public class ReqBankCommandsEnabled extends ReqAbstract { @@ -23,13 +23,13 @@ public class ReqBankCommandsEnabled extends ReqAbstract // -------------------------------------------- // @Override - public boolean apply(CommandSender sender, MCommand command) + public boolean apply(CommandSender sender, MassiveCommand command) { return UConf.get(sender).econEnabled && UConf.get(sender).bankEnabled; } @Override - public String createErrorMessage(CommandSender sender, MCommand command) + public String createErrorMessage(CommandSender sender, MassiveCommand command) { UConf uconf = UConf.get(sender); if (!uconf.bankEnabled) diff --git a/src/com/massivecraft/factions/cmd/req/ReqFactionsEnabled.java b/src/main/java/com/massivecraft/factions/cmd/req/ReqFactionsEnabled.java similarity index 71% rename from src/com/massivecraft/factions/cmd/req/ReqFactionsEnabled.java rename to src/main/java/com/massivecraft/factions/cmd/req/ReqFactionsEnabled.java index e94127fa..f04b7cf3 100644 --- a/src/com/massivecraft/factions/cmd/req/ReqFactionsEnabled.java +++ b/src/main/java/com/massivecraft/factions/cmd/req/ReqFactionsEnabled.java @@ -3,8 +3,8 @@ package com.massivecraft.factions.cmd.req; import org.bukkit.command.CommandSender; import com.massivecraft.factions.entity.UConf; -import com.massivecraft.mcore.cmd.MCommand; -import com.massivecraft.mcore.cmd.req.ReqAbstract; +import com.massivecraft.massivecore.cmd.MassiveCommand; +import com.massivecraft.massivecore.cmd.req.ReqAbstract; public class ReqFactionsEnabled extends ReqAbstract { @@ -22,13 +22,13 @@ public class ReqFactionsEnabled extends ReqAbstract // -------------------------------------------- // @Override - public boolean apply(CommandSender sender, MCommand command) + public boolean apply(CommandSender sender, MassiveCommand command) { return !UConf.isDisabled(sender); } @Override - public String createErrorMessage(CommandSender sender, MCommand command) + public String createErrorMessage(CommandSender sender, MassiveCommand command) { return UConf.getDisabledMessage(sender); } diff --git a/src/com/massivecraft/factions/cmd/req/ReqHasFaction.java b/src/main/java/com/massivecraft/factions/cmd/req/ReqHasFaction.java similarity index 69% rename from src/com/massivecraft/factions/cmd/req/ReqHasFaction.java rename to src/main/java/com/massivecraft/factions/cmd/req/ReqHasFaction.java index 15db295f..d8b29f61 100644 --- a/src/com/massivecraft/factions/cmd/req/ReqHasFaction.java +++ b/src/main/java/com/massivecraft/factions/cmd/req/ReqHasFaction.java @@ -3,9 +3,9 @@ package com.massivecraft.factions.cmd.req; import org.bukkit.command.CommandSender; import com.massivecraft.factions.entity.UPlayer; -import com.massivecraft.mcore.cmd.MCommand; -import com.massivecraft.mcore.cmd.req.ReqAbstract; -import com.massivecraft.mcore.util.Txt; +import com.massivecraft.massivecore.cmd.MassiveCommand; +import com.massivecraft.massivecore.cmd.req.ReqAbstract; +import com.massivecraft.massivecore.util.Txt; public class ReqHasFaction extends ReqAbstract { @@ -23,13 +23,13 @@ public class ReqHasFaction extends ReqAbstract // -------------------------------------------- // @Override - public boolean apply(CommandSender sender, MCommand command) + public boolean apply(CommandSender sender, MassiveCommand command) { return UPlayer.get(sender).hasFaction(); } @Override - public String createErrorMessage(CommandSender sender, MCommand command) + public String createErrorMessage(CommandSender sender, MassiveCommand command) { return Txt.parse("You must belong to a faction to "+(command == null ? "do that" : command.getDesc())+"."); } diff --git a/src/com/massivecraft/factions/cmd/req/ReqHasntFaction.java b/src/main/java/com/massivecraft/factions/cmd/req/ReqHasntFaction.java similarity index 70% rename from src/com/massivecraft/factions/cmd/req/ReqHasntFaction.java rename to src/main/java/com/massivecraft/factions/cmd/req/ReqHasntFaction.java index 974a04b2..a375a275 100644 --- a/src/com/massivecraft/factions/cmd/req/ReqHasntFaction.java +++ b/src/main/java/com/massivecraft/factions/cmd/req/ReqHasntFaction.java @@ -3,9 +3,9 @@ package com.massivecraft.factions.cmd.req; import org.bukkit.command.CommandSender; import com.massivecraft.factions.entity.UPlayer; -import com.massivecraft.mcore.cmd.MCommand; -import com.massivecraft.mcore.cmd.req.ReqAbstract; -import com.massivecraft.mcore.util.Txt; +import com.massivecraft.massivecore.cmd.MassiveCommand; +import com.massivecraft.massivecore.cmd.req.ReqAbstract; +import com.massivecraft.massivecore.util.Txt; public class ReqHasntFaction extends ReqAbstract { @@ -23,13 +23,13 @@ public class ReqHasntFaction extends ReqAbstract // -------------------------------------------- // @Override - public boolean apply(CommandSender sender, MCommand command) + public boolean apply(CommandSender sender, MassiveCommand command) { return !UPlayer.get(sender).hasFaction(); } @Override - public String createErrorMessage(CommandSender sender, MCommand command) + public String createErrorMessage(CommandSender sender, MassiveCommand command) { return Txt.parse("You must leave your current faction before you "+(command == null ? "do that" : command.getDesc())+"."); } diff --git a/src/com/massivecraft/factions/cmd/req/ReqRoleIsAtLeast.java b/src/main/java/com/massivecraft/factions/cmd/req/ReqRoleIsAtLeast.java similarity index 76% rename from src/com/massivecraft/factions/cmd/req/ReqRoleIsAtLeast.java rename to src/main/java/com/massivecraft/factions/cmd/req/ReqRoleIsAtLeast.java index 3c0ba854..b708e85b 100644 --- a/src/com/massivecraft/factions/cmd/req/ReqRoleIsAtLeast.java +++ b/src/main/java/com/massivecraft/factions/cmd/req/ReqRoleIsAtLeast.java @@ -4,9 +4,9 @@ import org.bukkit.command.CommandSender; import com.massivecraft.factions.Rel; import com.massivecraft.factions.entity.UPlayer; -import com.massivecraft.mcore.cmd.MCommand; -import com.massivecraft.mcore.cmd.req.ReqAbstract; -import com.massivecraft.mcore.util.Txt; +import com.massivecraft.massivecore.cmd.MassiveCommand; +import com.massivecraft.massivecore.cmd.req.ReqAbstract; +import com.massivecraft.massivecore.util.Txt; public class ReqRoleIsAtLeast extends ReqAbstract { @@ -31,14 +31,14 @@ public class ReqRoleIsAtLeast extends ReqAbstract // -------------------------------------------- // @Override - public boolean apply(CommandSender sender, MCommand command) + public boolean apply(CommandSender sender, MassiveCommand command) { UPlayer uplayer = UPlayer.get(sender); return uplayer.getRole().isAtLeast(this.rel); } @Override - public String createErrorMessage(CommandSender sender, MCommand command) + public String createErrorMessage(CommandSender sender, MassiveCommand command) { return Txt.parse("You must be %s or higher to "+(command == null ? "do that" : command.getDesc())+".", Txt.getNicedEnum(this.rel)); } diff --git a/src/com/massivecraft/factions/entity/Board.java b/src/main/java/com/massivecraft/factions/entity/Board.java similarity index 93% rename from src/com/massivecraft/factions/entity/Board.java rename to src/main/java/com/massivecraft/factions/entity/Board.java index 1deadb7a..2cb85214 100644 --- a/src/com/massivecraft/factions/entity/Board.java +++ b/src/main/java/com/massivecraft/factions/entity/Board.java @@ -17,10 +17,10 @@ import com.massivecraft.factions.Factions; import com.massivecraft.factions.RelationParticipator; import com.massivecraft.factions.TerritoryAccess; import com.massivecraft.factions.util.AsciiCompass; -import com.massivecraft.mcore.ps.PS; -import com.massivecraft.mcore.store.Entity; -import com.massivecraft.mcore.util.Txt; -import com.massivecraft.mcore.xlib.gson.reflect.TypeToken; +import com.massivecraft.massivecore.ps.PS; +import com.massivecraft.massivecore.store.Entity; +import com.massivecraft.massivecore.util.Txt; +import com.massivecraft.massivecore.xlib.gson.reflect.TypeToken; public class Board extends Entity implements BoardInterface { diff --git a/src/com/massivecraft/factions/entity/BoardColl.java b/src/main/java/com/massivecraft/factions/entity/BoardColl.java similarity index 87% rename from src/com/massivecraft/factions/entity/BoardColl.java rename to src/main/java/com/massivecraft/factions/entity/BoardColl.java index ea17dd47..1a7987f7 100644 --- a/src/com/massivecraft/factions/entity/BoardColl.java +++ b/src/main/java/com/massivecraft/factions/entity/BoardColl.java @@ -4,14 +4,13 @@ import java.util.ArrayList; import java.util.HashSet; import java.util.Set; -import com.massivecraft.factions.ConfServer; import com.massivecraft.factions.Factions; import com.massivecraft.factions.RelationParticipator; import com.massivecraft.factions.TerritoryAccess; -import com.massivecraft.mcore.ps.PS; -import com.massivecraft.mcore.store.Coll; -import com.massivecraft.mcore.store.MStore; -import com.massivecraft.mcore.util.MUtil; +import com.massivecraft.massivecore.ps.PS; +import com.massivecraft.massivecore.store.Coll; +import com.massivecraft.massivecore.store.MStore; +import com.massivecraft.massivecore.util.MUtil; public class BoardColl extends Coll implements BoardInterface { @@ -21,7 +20,7 @@ public class BoardColl extends Coll implements BoardInterface public BoardColl(String name) { - super(name, Board.class, MStore.getDb(ConfServer.dburi), Factions.get(), true, true); + super(name, Board.class, MStore.getDb(), Factions.get(), false, true, true); } // -------------------------------------------- // diff --git a/src/com/massivecraft/factions/entity/BoardColls.java b/src/main/java/com/massivecraft/factions/entity/BoardColls.java similarity index 90% rename from src/com/massivecraft/factions/entity/BoardColls.java rename to src/main/java/com/massivecraft/factions/entity/BoardColls.java index 381e20a4..8bdaed73 100644 --- a/src/com/massivecraft/factions/entity/BoardColls.java +++ b/src/main/java/com/massivecraft/factions/entity/BoardColls.java @@ -12,11 +12,11 @@ import com.massivecraft.factions.Const; import com.massivecraft.factions.Factions; import com.massivecraft.factions.RelationParticipator; import com.massivecraft.factions.TerritoryAccess; -import com.massivecraft.mcore.Aspect; -import com.massivecraft.mcore.ps.PS; -import com.massivecraft.mcore.ps.PSBuilder; -import com.massivecraft.mcore.util.DiscUtil; -import com.massivecraft.mcore.xlib.gson.reflect.TypeToken; +import com.massivecraft.massivecore.Aspect; +import com.massivecraft.massivecore.ps.PS; +import com.massivecraft.massivecore.ps.PSBuilder; +import com.massivecraft.massivecore.util.DiscUtil; +import com.massivecraft.massivecore.xlib.gson.reflect.TypeToken; public class BoardColls extends XColls implements BoardInterface { @@ -46,7 +46,7 @@ public class BoardColls extends XColls implements BoardInterfa @Override public String getBasename() { - return Const.COLLECTION_BASENAME_BOARD; + return Const.COLLECTION_BOARD; } @Override diff --git a/src/com/massivecraft/factions/entity/BoardInterface.java b/src/main/java/com/massivecraft/factions/entity/BoardInterface.java similarity index 92% rename from src/com/massivecraft/factions/entity/BoardInterface.java rename to src/main/java/com/massivecraft/factions/entity/BoardInterface.java index db6c4d97..0e701a62 100644 --- a/src/com/massivecraft/factions/entity/BoardInterface.java +++ b/src/main/java/com/massivecraft/factions/entity/BoardInterface.java @@ -5,7 +5,7 @@ import java.util.Set; import com.massivecraft.factions.RelationParticipator; import com.massivecraft.factions.TerritoryAccess; -import com.massivecraft.mcore.ps.PS; +import com.massivecraft.massivecore.ps.PS; public interface BoardInterface { diff --git a/src/com/massivecraft/factions/entity/Faction.java b/src/main/java/com/massivecraft/factions/entity/Faction.java similarity index 93% rename from src/com/massivecraft/factions/entity/Faction.java rename to src/main/java/com/massivecraft/factions/entity/Faction.java index 38a21387..fec97b86 100644 --- a/src/com/massivecraft/factions/entity/Faction.java +++ b/src/main/java/com/massivecraft/factions/entity/Faction.java @@ -17,14 +17,13 @@ import com.massivecraft.factions.Lang; import com.massivecraft.factions.Rel; import com.massivecraft.factions.RelationParticipator; import com.massivecraft.factions.util.*; -import com.massivecraft.mcore.mixin.Mixin; -import com.massivecraft.mcore.money.Money; -import com.massivecraft.mcore.ps.PS; -import com.massivecraft.mcore.store.Entity; -import com.massivecraft.mcore.util.MUtil; -import com.massivecraft.mcore.util.SenderUtil; -import com.massivecraft.mcore.util.Txt; - +import com.massivecraft.massivecore.mixin.Mixin; +import com.massivecraft.massivecore.money.Money; +import com.massivecraft.massivecore.ps.PS; +import com.massivecraft.massivecore.store.Entity; +import com.massivecraft.massivecore.util.IdUtil; +import com.massivecraft.massivecore.util.MUtil; +import com.massivecraft.massivecore.util.Txt; public class Faction extends Entity implements EconomyParticipator { @@ -61,7 +60,7 @@ public class Faction extends Entity implements EconomyParticipator @Override public void preDetach(String id) { - Money.set(this, 0); + Money.set(this, null, 0); String universe = this.getUniverse(); @@ -897,7 +896,7 @@ public class Faction extends Entity implements EconomyParticipator } } return ret; - } + } public List getUPlayersWhereRole(Rel role) { @@ -932,7 +931,7 @@ public class Faction extends Entity implements EconomyParticipator public List getOnlineCommandSenders() { List ret = new ArrayList(); - for (CommandSender player : SenderUtil.getOnlineSenders()) + for (CommandSender player : IdUtil.getOnlineSenders()) { UPlayer uplayer = UPlayer.get(player); if (!MUtil.equals(uplayer.getUniverse(), this.getUniverse())) continue; @@ -991,7 +990,7 @@ public class Faction extends Entity implements EconomyParticipator for (UPlayer uplayer : UPlayerColls.get().get(this).getAllOnline()) { - uplayer.msg("The faction %s was disbanded.", this.getName(uplayer)); + uplayer.msg("The faction %s was disbanded.", this.getName(uplayer)); } this.detach(); @@ -1008,7 +1007,40 @@ public class Faction extends Entity implements EconomyParticipator Factions.get().log("Faction "+this.getName()+" ("+this.getId()+") leader was removed. Replacement leader: "+replacements.get(0).getName()); } } + + // -------------------------------------------- // + // FACTION ONLINE STATE + // -------------------------------------------- // + public boolean isAllUPlayersOffline() + { + return this.getUPlayersWhereOnline(true).size() == 0; + } + + public boolean isAnyUPlayersOnline() + { + return !this.isAllUPlayersOffline(); + } + + public boolean isFactionConsideredOffline() + { + return this.isAllUPlayersOffline(); + } + + public boolean isFactionConsideredOnline() + { + return !this.isFactionConsideredOffline(); + } + + public boolean isExplosionsAllowed() + { + boolean explosions = this.getFlag(FFlag.EXPLOSIONS); + boolean offlineexplosions = this.getFlag(FFlag.OFFLINE_EXPLOSIONS); + boolean online = this.isFactionConsideredOnline(); + + return (online && explosions) || (!online && offlineexplosions); + } + // -------------------------------------------- // // MESSAGES // -------------------------------------------- // @@ -1018,34 +1050,34 @@ public class Faction extends Entity implements EconomyParticipator public boolean sendMessage(String message) { - return Mixin.message(new FactionEqualsPredictate(this), message); + return Mixin.messagePredictate(new FactionEqualsPredictate(this), message); } public boolean sendMessage(String... messages) { - return Mixin.message(new FactionEqualsPredictate(this), messages); + return Mixin.messagePredictate(new FactionEqualsPredictate(this), messages); } public boolean sendMessage(Collection messages) { - return Mixin.message(new FactionEqualsPredictate(this), messages); + return Mixin.messagePredictate(new FactionEqualsPredictate(this), messages); } // CONVENIENCE MSG public boolean msg(String msg) { - return Mixin.msg(new FactionEqualsPredictate(this), msg); + return Mixin.msgPredictate(new FactionEqualsPredictate(this), msg); } public boolean msg(String msg, Object... args) { - return Mixin.msg(new FactionEqualsPredictate(this), msg, args); + return Mixin.msgPredictate(new FactionEqualsPredictate(this), msg, args); } public boolean msg(Collection msgs) { - return Mixin.msg(new FactionEqualsPredictate(this), msgs); + return Mixin.msgPredictate(new FactionEqualsPredictate(this), msgs); } } diff --git a/src/com/massivecraft/factions/entity/FactionColl.java b/src/main/java/com/massivecraft/factions/entity/FactionColl.java similarity index 93% rename from src/com/massivecraft/factions/entity/FactionColl.java rename to src/main/java/com/massivecraft/factions/entity/FactionColl.java index 76e247da..5ab6ed8d 100644 --- a/src/com/massivecraft/factions/entity/FactionColl.java +++ b/src/main/java/com/massivecraft/factions/entity/FactionColl.java @@ -4,11 +4,9 @@ import java.util.*; import org.bukkit.ChatColor; -import com.massivecraft.mcore.store.Coll; -import com.massivecraft.mcore.store.MStore; -import com.massivecraft.mcore.util.Txt; - -import com.massivecraft.factions.ConfServer; +import com.massivecraft.massivecore.store.Coll; +import com.massivecraft.massivecore.store.MStore; +import com.massivecraft.massivecore.util.Txt; import com.massivecraft.factions.FFlag; import com.massivecraft.factions.FPerm; import com.massivecraft.factions.Factions; @@ -24,7 +22,7 @@ public class FactionColl extends Coll public FactionColl(String name) { - super(name, Faction.class, MStore.getDb(ConfServer.dburi), Factions.get()); + super(name, Faction.class, MStore.getDb(), Factions.get()); } // -------------------------------------------- // @@ -102,6 +100,7 @@ public class FactionColl extends Coll faction.setFlag(FFlag.FRIENDLYFIRE, false); faction.setFlag(FFlag.MONSTERS, true); faction.setFlag(FFlag.EXPLOSIONS, true); + faction.setFlag(FFlag.OFFLINE_EXPLOSIONS, true); faction.setFlag(FFlag.FIRESPREAD, true); faction.setFlag(FFlag.ENDERGRIEF, true); @@ -134,6 +133,7 @@ public class FactionColl extends Coll faction.setFlag(FFlag.FRIENDLYFIRE, false); faction.setFlag(FFlag.MONSTERS, false); faction.setFlag(FFlag.EXPLOSIONS, false); + faction.setFlag(FFlag.OFFLINE_EXPLOSIONS, false); faction.setFlag(FFlag.FIRESPREAD, false); faction.setFlag(FFlag.ENDERGRIEF, false); @@ -166,6 +166,7 @@ public class FactionColl extends Coll faction.setFlag(FFlag.FRIENDLYFIRE, true); faction.setFlag(FFlag.MONSTERS, true); faction.setFlag(FFlag.EXPLOSIONS, true); + faction.setFlag(FFlag.OFFLINE_EXPLOSIONS, true); faction.setFlag(FFlag.FIRESPREAD, true); faction.setFlag(FFlag.ENDERGRIEF, true); diff --git a/src/com/massivecraft/factions/entity/FactionColls.java b/src/main/java/com/massivecraft/factions/entity/FactionColls.java similarity index 83% rename from src/com/massivecraft/factions/entity/FactionColls.java rename to src/main/java/com/massivecraft/factions/entity/FactionColls.java index 0c263d52..a9fcc152 100644 --- a/src/com/massivecraft/factions/entity/FactionColls.java +++ b/src/main/java/com/massivecraft/factions/entity/FactionColls.java @@ -8,11 +8,11 @@ import java.util.Set; import com.massivecraft.factions.Const; import com.massivecraft.factions.Factions; -import com.massivecraft.mcore.Aspect; -import com.massivecraft.mcore.MCore; -import com.massivecraft.mcore.util.DiscUtil; -import com.massivecraft.mcore.util.MUtil; -import com.massivecraft.mcore.xlib.gson.reflect.TypeToken; +import com.massivecraft.massivecore.Aspect; +import com.massivecraft.massivecore.MassiveCore; +import com.massivecraft.massivecore.util.DiscUtil; +import com.massivecraft.massivecore.util.MUtil; +import com.massivecraft.massivecore.xlib.gson.reflect.TypeToken; public class FactionColls extends XColls { @@ -42,7 +42,7 @@ public class FactionColls extends XColls @Override public String getBasename() { - return Const.COLLECTION_BASENAME_FACTION; + return Const.COLLECTION_FACTION; } @Override @@ -73,7 +73,7 @@ public class FactionColls extends XColls Map id2faction = Factions.get().gson.fromJson(DiscUtil.readCatch(oldFile), type); // The Coll - FactionColl coll = this.getForUniverse(MCore.DEFAULT); + FactionColl coll = this.getForUniverse(MassiveCore.DEFAULT); // Set the data for (Entry entry : id2faction.entrySet()) diff --git a/src/main/java/com/massivecraft/factions/entity/MConf.java b/src/main/java/com/massivecraft/factions/entity/MConf.java new file mode 100644 index 00000000..ffc54262 --- /dev/null +++ b/src/main/java/com/massivecraft/factions/entity/MConf.java @@ -0,0 +1,338 @@ +package com.massivecraft.factions.entity; + +import java.util.HashSet; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.TreeSet; + +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.event.EventPriority; + +import com.massivecraft.factions.Factions; +import com.massivecraft.factions.integration.dynmap.DynmapStyle; +import com.massivecraft.factions.listeners.FactionsListenerChat; +import com.massivecraft.massivecore.store.Entity; +import com.massivecraft.massivecore.util.MUtil; + +public class MConf extends Entity +{ + // -------------------------------------------- // + // META + // -------------------------------------------- // + + protected static transient MConf i; + public static MConf get() { return i; } + + // -------------------------------------------- // + // OVERRIDE: ENTITY + // -------------------------------------------- // + + @Override + public MConf load(MConf that) + { + super.load(that); + + if (!Factions.get().isDatabaseInitialized()) return this; + + FactionsListenerChat.get().setup(); + + return this; + } + + // -------------------------------------------- // + // COMMAND ALIASES + // -------------------------------------------- // + + public List aliasesF = MUtil.list("f"); + + // -------------------------------------------- // + // TASKS + // -------------------------------------------- // + + public double taskPlayerPowerUpdateMinutes = 1; + public double taskPlayerDataRemoveMinutes = 5; + public double taskEconLandRewardMinutes = 20; + + // -------------------------------------------- // + // REMOVE DATA + // -------------------------------------------- // + + public boolean removePlayerDataWhenBanned = true; + public double removePlayerDataAfterInactiveDays = 20.0; + + // -------------------------------------------- // + // CLAIM LIMITS + // -------------------------------------------- // + + // if someone is doing a radius claim and the process fails to claim land this many times in a row, it will exit + public int radiusClaimFailureLimit = 9; + + // the maximum radius allowed when using the claim command. + public int radiusClaimRadiusLimit = 5; + + // -------------------------------------------- // + // CHAT + // -------------------------------------------- // + + // We offer a simple standard way to set the format + public boolean chatSetFormat = false; + public EventPriority chatSetFormatAt = EventPriority.LOWEST; + public String chatSetFormatTo = "<{factions_relcolor}§l{factions_roleprefix}§r{factions_relcolor}{factions_name|rp}§f%1$s> %2$s"; + + // We offer a simple standard way to parse the chat tags + public boolean chatParseTags = true; + public EventPriority chatParseTagsAt = EventPriority.LOW; + + // HeroChat: The Faction Channel + public String herochatFactionName = "Faction"; + public String herochatFactionNick = "F"; + public String herochatFactionFormat = "{color}[&l{nick}&r{color} &l{factions_roleprefix}&r{color}{factions_title|rp}{sender}{color}] &f{msg}"; + public ChatColor herochatFactionColor = ChatColor.GREEN; + public int herochatFactionDistance = 0; + public boolean herochatFactionIsShortcutAllowed = false; + public boolean herochatFactionCrossWorld = true; + public boolean herochatFactionMuted = false; + public Set herochatFactionWorlds = new HashSet(); + + // HeroChat: The Allies Channel + public String herochatAlliesName = "Allies"; + public String herochatAlliesNick = "A"; + public String herochatAlliesFormat = "{color}[&l{nick}&r&f {factions_relcolor}&l{factions_roleprefix}&r{factions_relcolor}{factions_name|rp}{sender}{color}] &f{msg}"; + public ChatColor herochatAlliesColor = ChatColor.DARK_PURPLE; + public int herochatAlliesDistance = 0; + public boolean herochatAlliesIsShortcutAllowed = false; + public boolean herochatAlliesCrossWorld = true; + public boolean herochatAlliesMuted = false; + public Set herochatAlliesWorlds = new HashSet(); + + // -------------------------------------------- // + // COLORS + // -------------------------------------------- // + + public ChatColor colorMember = ChatColor.GREEN; + public ChatColor colorAlly = ChatColor.DARK_PURPLE; + public ChatColor colorTruce = ChatColor.LIGHT_PURPLE; + public ChatColor colorNeutral = ChatColor.WHITE; + public ChatColor colorEnemy = ChatColor.RED; + + public ChatColor colorNoPVP = ChatColor.GOLD; + public ChatColor colorFriendlyFire = ChatColor.DARK_RED; + //public ChatColor colorWilderness = ChatColor.DARK_GREEN; + + // -------------------------------------------- // + // PREFIXES + // -------------------------------------------- // + + public String prefixLeader = "**"; + public String prefixOfficer = "*"; + public String prefixMember = "+"; + public String prefixRecruit = "-"; + + // -------------------------------------------- // + // DERPY OVERRIDES + // -------------------------------------------- // + // TODO: Should worldsNoPowerLoss rather be a bukkit permission node? + // TODO: These are derpy because they possibly use an invalid design approach. + // After universe support is added. Would some of these be removed? + // Could it also be more customizeable using some sort of permission lookup map? + + // mainly for other plugins/mods that use a fake player to take actions, which shouldn't be subject to our protections + public Set playersWhoBypassAllProtection = new LinkedHashSet(); + + public Set worldsNoClaiming = new LinkedHashSet(); + public Set getWorldsNoClaiming() + { + Set ret = new TreeSet(String.CASE_INSENSITIVE_ORDER); + ret.addAll(this.worldsNoClaiming); + return ret; + } + + public Set worldsNoPowerLoss = new LinkedHashSet(); + public Set getWorldsNoPowerLoss() + { + Set ret = new TreeSet(String.CASE_INSENSITIVE_ORDER); + ret.addAll(this.worldsNoPowerLoss); + return ret; + } + + public Set worldsIgnorePvP = new LinkedHashSet(); + public Set getWorldsIgnlorePvP() + { + Set ret = new TreeSet(String.CASE_INSENSITIVE_ORDER); + ret.addAll(this.worldsIgnorePvP); + return ret; + } + + // -------------------------------------------- // + // EXPLOITS + // -------------------------------------------- // + + public boolean handleExploitObsidianGenerators = true; + public boolean handleExploitEnderPearlClipping = true; + public boolean handleExploitTNTWaterlog = false; + + // -------------------------------------------- // + // LOGGING + // -------------------------------------------- // + + public boolean logFactionCreate = true; + public boolean logFactionDisband = true; + public boolean logFactionJoin = true; + public boolean logFactionKick = true; + public boolean logFactionLeave = true; + public boolean logLandClaims = true; + public boolean logLandUnclaims = true; + public boolean logMoneyTransactions = true; + public boolean logPlayerCommands = true; + + // -------------------------------------------- // + // ENUMERATIONS + // -------------------------------------------- // + + public Set materialsEditOnInteract = MUtil.set( + Material.DIODE_BLOCK_OFF, + Material.DIODE_BLOCK_ON, + Material.NOTE_BLOCK, + Material.CAULDRON, + Material.SOIL + ); + + public Set materialsEditTools = MUtil.set( + Material.FIREBALL, + Material.FLINT_AND_STEEL, + Material.BUCKET, + Material.WATER_BUCKET, + Material.LAVA_BUCKET + ); + + public Set materialsDoor = MUtil.set( + Material.WOODEN_DOOR, + Material.TRAP_DOOR, + Material.FENCE_GATE + ); + + public Set materialsContainer = MUtil.set( + Material.DISPENSER, + Material.CHEST, + Material.FURNACE, + Material.BURNING_FURNACE, + Material.JUKEBOX, + Material.BREWING_STAND, + Material.ENCHANTMENT_TABLE, + Material.ANVIL, + Material.BEACON, + Material.TRAPPED_CHEST, + Material.HOPPER, + Material.DROPPER + ); + + public Set entityTypesMonsters = MUtil.set( + EntityType.BLAZE, + EntityType.CAVE_SPIDER, + EntityType.CREEPER, + EntityType.ENDERMAN, + EntityType.ENDER_DRAGON, + EntityType.GHAST, + EntityType.GIANT, + EntityType.MAGMA_CUBE, + EntityType.PIG_ZOMBIE, + EntityType.SILVERFISH, + EntityType.SKELETON, + EntityType.SLIME, + EntityType.SPIDER, + EntityType.WITCH, + EntityType.WITHER, + EntityType.ZOMBIE + ); + + // -------------------------------------------- // + // DYNMAP + // -------------------------------------------- // + + // Should the dynmap intagration be used? + public boolean dynmapUse = true; + + // Should the dynmap updates be logged to console output? + public boolean dynmapUpdateLog = false; + + // Name of the Factions layer + public String dynmapLayerName = "Factions"; + + // Should the layer be visible per default + public boolean dynmapLayerVisible = true; + + // Ordering priority in layer menu (low goes before high - default is 0) + public int dynmapLayerPriority = 2; + + // (optional) set minimum zoom level before layer is visible (0 = defalt, always visible) + public int dynmapLayerMinimumZoom = 0; + + // Format for popup - substitute values for macros + //public String dynmapInfowindowFormat = "
%regionname%
Flags
%flags%
"; + public String dynmapDescription = + "
\n" + + "%name%
\n" + + "%description%
\n" + + "
\n" + + "Leader: %players.leader%
\n" + + "Officers: %players.officers.count%
\n" + + "Members: %players.members.count%
\n" + + "Recruits: %players.recruits.count%
\n" + + "TOTAL: %players.count%
\n" + + "
\n" + + "Age: %age%
\n" + + "Bank: %money%
\n" + + "
\n" + + "Flags:
\n" + + "%open.color% | %permanent.color% | %peaceful.color% | %infpower.color% | %powerloss.color%
\n" + + "%pvp.color% | %friendlyfire.color% | %monsters.color% | %explosions.color%
\n" + + "%offlineexplosions.color% | %firespread.color% | %endergrief.color%\n" + + "
"; + + // Enable the %money% macro. Only do this if you know your economy manager is thread safe. + public boolean dynmapDescriptionMoney = false; + + // Allow players in faction to see one another on Dynmap (only relevant if Dynmap has 'player-info-protected' enabled) + public boolean dynmapVisibilityByFaction = true; + + // Optional setting to limit which regions to show. + // If empty all regions are shown. + // Specify Faction either by name or UUID. + // To show all regions on a given world, add 'world:' to the list. + public Set dynmapVisibleFactions = new LinkedHashSet(); + + // Optional setting to hide specific Factions. + // Specify Faction either by name or UUID. + // To hide all regions on a given world, add 'world:' to the list. + public Set dynmapHiddenFactions = new LinkedHashSet(); + + // Region Style + public final static transient String DYNMAP_STYLE_LINE_COLOR = "#00FF00"; + public final static transient double DYNMAP_STYLE_LINE_OPACITY = 0.8D; + public final static transient int DYNMAP_STYLE_LINE_WEIGHT = 3; + public final static transient String DYNMAP_STYLE_FILL_COLOR = "#00FF00"; + public final static transient double DYNMAP_STYLE_FILL_OPACITY = 0.35D; + public final static transient String DYNMAP_STYLE_HOME_MARKER = "greenflag"; + public final static transient boolean DYNMAP_STYLE_BOOST = false; + + public DynmapStyle dynmapDefaultStyle = new DynmapStyle() + .setStrokeColor(DYNMAP_STYLE_LINE_COLOR) + .setLineOpacity(DYNMAP_STYLE_LINE_OPACITY) + .setLineWeight(DYNMAP_STYLE_LINE_WEIGHT) + .setFillColor(DYNMAP_STYLE_FILL_COLOR) + .setFillOpacity(DYNMAP_STYLE_FILL_OPACITY) + .setHomeMarker(DYNMAP_STYLE_HOME_MARKER) + .setBoost(DYNMAP_STYLE_BOOST); + + // Optional per Faction style overrides. Any defined replace those in dynmapDefaultStyle. + // Specify Faction either by name or UUID. + public Map dynmapFactionStyles = MUtil.map( + "SafeZone", new DynmapStyle().setStrokeColor("#FF00FF").setFillColor("#FF00FF").setBoost(false), + "WarZone", new DynmapStyle().setStrokeColor("#FF0000").setFillColor("#FF0000").setBoost(false) + ); + +} \ No newline at end of file diff --git a/src/com/massivecraft/factions/entity/MConfColl.java b/src/main/java/com/massivecraft/factions/entity/MConfColl.java similarity index 62% rename from src/com/massivecraft/factions/entity/MConfColl.java rename to src/main/java/com/massivecraft/factions/entity/MConfColl.java index 4829cb52..4fed8089 100644 --- a/src/com/massivecraft/factions/entity/MConfColl.java +++ b/src/main/java/com/massivecraft/factions/entity/MConfColl.java @@ -1,11 +1,10 @@ package com.massivecraft.factions.entity; -import com.massivecraft.factions.ConfServer; import com.massivecraft.factions.Const; import com.massivecraft.factions.Factions; -import com.massivecraft.mcore.MCore; -import com.massivecraft.mcore.store.Coll; -import com.massivecraft.mcore.store.MStore; +import com.massivecraft.massivecore.MassiveCore; +import com.massivecraft.massivecore.store.Coll; +import com.massivecraft.massivecore.store.MStore; public class MConfColl extends Coll { @@ -17,7 +16,7 @@ public class MConfColl extends Coll public static MConfColl get() { return i; } private MConfColl() { - super(Const.COLLECTION_BASENAME_MCONF, MConf.class, MStore.getDb(ConfServer.dburi), Factions.get(), true, false); + super(Const.COLLECTION_MCONF, MConf.class, MStore.getDb(), Factions.get()); } // -------------------------------------------- // @@ -29,7 +28,7 @@ public class MConfColl extends Coll { super.init(); - MConf.i = this.get(MCore.INSTANCE); + MConf.i = this.get(MassiveCore.INSTANCE, true); } } diff --git a/src/com/massivecraft/factions/entity/MPlayer.java b/src/main/java/com/massivecraft/factions/entity/MPlayer.java similarity index 73% rename from src/com/massivecraft/factions/entity/MPlayer.java rename to src/main/java/com/massivecraft/factions/entity/MPlayer.java index eb67daa6..d22f614f 100644 --- a/src/com/massivecraft/factions/entity/MPlayer.java +++ b/src/main/java/com/massivecraft/factions/entity/MPlayer.java @@ -1,6 +1,7 @@ package com.massivecraft.factions.entity; -import com.massivecraft.mcore.store.SenderEntity; +import com.massivecraft.factions.Perm; +import com.massivecraft.massivecore.store.SenderEntity; public class MPlayer extends SenderEntity { @@ -44,7 +45,15 @@ public class MPlayer extends SenderEntity public void setMapAutoUpdating(boolean mapAutoUpdating) { this.mapAutoUpdating = mapAutoUpdating; this.changed(); } private boolean usingAdminMode = false; - public boolean isUsingAdminMode() { return this.usingAdminMode; } + public boolean isUsingAdminMode() + { + if (this.usingAdminMode && this.getSender() != null && !Perm.ADMIN.has(this.getSender(), false)) + { + // If we are using admin mode but don't have permissions for it we deactivate it. + this.setUsingAdminMode(false); + } + return this.usingAdminMode; + } public void setUsingAdminMode(boolean usingAdminMode) { this.usingAdminMode = usingAdminMode; this.changed(); } } diff --git a/src/com/massivecraft/factions/entity/MPlayerColl.java b/src/main/java/com/massivecraft/factions/entity/MPlayerColl.java similarity index 62% rename from src/com/massivecraft/factions/entity/MPlayerColl.java rename to src/main/java/com/massivecraft/factions/entity/MPlayerColl.java index d011666f..7afd223d 100644 --- a/src/com/massivecraft/factions/entity/MPlayerColl.java +++ b/src/main/java/com/massivecraft/factions/entity/MPlayerColl.java @@ -1,10 +1,9 @@ package com.massivecraft.factions.entity; -import com.massivecraft.factions.ConfServer; import com.massivecraft.factions.Const; import com.massivecraft.factions.Factions; -import com.massivecraft.mcore.store.MStore; -import com.massivecraft.mcore.store.SenderColl; +import com.massivecraft.massivecore.store.MStore; +import com.massivecraft.massivecore.store.SenderColl; public class MPlayerColl extends SenderColl { @@ -16,7 +15,7 @@ public class MPlayerColl extends SenderColl public static MPlayerColl get() { return i; } private MPlayerColl() { - super(Const.COLLECTION_BASENAME_MPLAYER, MPlayer.class, MStore.getDb(ConfServer.dburi), Factions.get()); + super(Const.COLLECTION_MPLAYER, MPlayer.class, MStore.getDb(), Factions.get()); } } diff --git a/src/com/massivecraft/factions/entity/UConf.java b/src/main/java/com/massivecraft/factions/entity/UConf.java similarity index 77% rename from src/com/massivecraft/factions/entity/UConf.java rename to src/main/java/com/massivecraft/factions/entity/UConf.java index 8a347d2a..2d9502b6 100644 --- a/src/com/massivecraft/factions/entity/UConf.java +++ b/src/main/java/com/massivecraft/factions/entity/UConf.java @@ -7,15 +7,16 @@ import java.util.Set; import java.util.UUID; import org.bukkit.command.CommandSender; +import org.bukkit.event.EventPriority; import com.massivecraft.factions.FFlag; import com.massivecraft.factions.FPerm; import com.massivecraft.factions.Rel; -import com.massivecraft.factions.event.FactionsEventChunkChangeType; -import com.massivecraft.mcore.store.Entity; -import com.massivecraft.mcore.store.SenderEntity; -import com.massivecraft.mcore.util.MUtil; -import com.massivecraft.mcore.util.Txt; +import com.massivecraft.factions.event.EventFactionsChunkChangeType; +import com.massivecraft.massivecore.store.Entity; +import com.massivecraft.massivecore.store.SenderEntity; +import com.massivecraft.massivecore.util.MUtil; +import com.massivecraft.massivecore.util.Txt; public class UConf extends Entity { @@ -82,6 +83,12 @@ public class UConf extends Entity public Map defaultFactionFlags = FFlag.getDefaultDefaults(); public Map> defaultFactionPerms = FPerm.getDefaultDefaults(); + // -------------------------------------------- // + // MESSAGES + // -------------------------------------------- // + + public boolean broadcastNameChange = false; + // -------------------------------------------- // // POWER // -------------------------------------------- // @@ -126,15 +133,18 @@ public class UConf extends Entity public double homesTeleportAllowedEnemyDistance = 32.0; public boolean homesTeleportIgnoreEnemiesIfInOwnTerritory = true; + public boolean homesTeleportToOnDeathActive = false; + public EventPriority homesTeleportToOnDeathPriority = EventPriority.NORMAL; + // -------------------------------------------- // // ASSORTED // -------------------------------------------- // public boolean permanentFactionsDisableLeaderPromotion = false; - public int actionDeniedPainAmount = 2; + public double actionDeniedPainAmount = 2.0D; public boolean disablePVPForFactionlessPlayers = false; public boolean enablePVPAgainstFactionlessInAttackersLand = false; - public double territoryShieldFactor = 0.3; + public double territoryShieldFactor = 0.3D; // -------------------------------------------- // // DENY COMMANDS @@ -146,14 +156,49 @@ public class UConf extends Entity // commands which will be prevented when in claimed territory of another faction public Map> denyCommandsTerritoryRelation = MUtil.map( Rel.ENEMY, MUtil.list( + // Essentials commands "home", + "homes", "sethome", + "createhome", "tpahere", "tpaccept", + "tpyes", "tpa", + "call", + "tpask", "warp", "warps", "spawn", + // Essentials e-alliases + "ehome", + "ehomes", + "esethome", + "ecreatehome", + "etpahere", + "etpaccept", + "etpyes", + "etpa", + "ecall", + "etpask", + "ewarp", + "ewarps", + "espawn", + // Essentials fallback alliases + "essentials:home", + "essentials:homes", + "essentials:sethome", + "essentials:createhome", + "essentials:tpahere", + "essentials:tpaccept", + "essentials:tpyes", + "essentials:tpa", + "essentials:call", + "essentials:tpask", + "essentials:warp", + "essentials:warps", + "essentials:spawn", + // Other plugins "wtp", "uspawn", "utp", @@ -174,11 +219,11 @@ public class UConf extends Entity // INTEGRATION: LWC // -------------------------------------------- // - public Map lwcRemoveOnChange = MUtil.map( - FactionsEventChunkChangeType.BUY, false, - FactionsEventChunkChangeType.SELL, false, - FactionsEventChunkChangeType.CONQUER, false, - FactionsEventChunkChangeType.PILLAGE, false + public Map lwcRemoveOnChange = MUtil.map( + EventFactionsChunkChangeType.BUY, false, + EventFactionsChunkChangeType.SELL, false, + EventFactionsChunkChangeType.CONQUER, false, + EventFactionsChunkChangeType.PILLAGE, false ); // -------------------------------------------- // @@ -192,11 +237,11 @@ public class UConf extends Entity public String econUniverseAccount = ""; - public Map econChunkCost = MUtil.map( - FactionsEventChunkChangeType.BUY, 30.0, - FactionsEventChunkChangeType.SELL, -20.0, - FactionsEventChunkChangeType.CONQUER, -10.0, - FactionsEventChunkChangeType.PILLAGE, -10.0 + public Map econChunkCost = MUtil.map( + EventFactionsChunkChangeType.BUY, 30.0, + EventFactionsChunkChangeType.SELL, -20.0, + EventFactionsChunkChangeType.CONQUER, -10.0, + EventFactionsChunkChangeType.PILLAGE, -10.0 ); public double econCostCreate = 200.0; diff --git a/src/com/massivecraft/factions/entity/UConfColl.java b/src/main/java/com/massivecraft/factions/entity/UConfColl.java similarity index 59% rename from src/com/massivecraft/factions/entity/UConfColl.java rename to src/main/java/com/massivecraft/factions/entity/UConfColl.java index 2898d610..76683eaf 100644 --- a/src/com/massivecraft/factions/entity/UConfColl.java +++ b/src/main/java/com/massivecraft/factions/entity/UConfColl.java @@ -1,10 +1,9 @@ package com.massivecraft.factions.entity; -import com.massivecraft.factions.ConfServer; import com.massivecraft.factions.Factions; -import com.massivecraft.mcore.MCore; -import com.massivecraft.mcore.store.Coll; -import com.massivecraft.mcore.store.MStore; +import com.massivecraft.massivecore.MassiveCore; +import com.massivecraft.massivecore.store.Coll; +import com.massivecraft.massivecore.store.MStore; public class UConfColl extends Coll { @@ -14,7 +13,7 @@ public class UConfColl extends Coll public UConfColl(String name) { - super(name, UConf.class, MStore.getDb(ConfServer.dburi), Factions.get(), true, false); + super(name, UConf.class, MStore.getDb(), Factions.get()); } // -------------------------------------------- // @@ -25,8 +24,7 @@ public class UConfColl extends Coll public void init() { super.init(); - - this.get(MCore.INSTANCE); + this.get(MassiveCore.INSTANCE, true); } } diff --git a/src/com/massivecraft/factions/entity/UConfColls.java b/src/main/java/com/massivecraft/factions/entity/UConfColls.java similarity index 81% rename from src/com/massivecraft/factions/entity/UConfColls.java rename to src/main/java/com/massivecraft/factions/entity/UConfColls.java index f0ab2fef..85e416e3 100644 --- a/src/com/massivecraft/factions/entity/UConfColls.java +++ b/src/main/java/com/massivecraft/factions/entity/UConfColls.java @@ -2,8 +2,8 @@ package com.massivecraft.factions.entity; import com.massivecraft.factions.Const; import com.massivecraft.factions.Factions; -import com.massivecraft.mcore.Aspect; -import com.massivecraft.mcore.MCore; +import com.massivecraft.massivecore.Aspect; +import com.massivecraft.massivecore.MassiveCore; public class UConfColls extends XColls { @@ -33,7 +33,7 @@ public class UConfColls extends XColls @Override public String getBasename() { - return Const.COLLECTION_BASENAME_UCONF; + return Const.COLLECTION_UCONF; } @Override @@ -41,7 +41,7 @@ public class UConfColls extends XColls { UConfColl coll = this.get(worldNameExtractable); if (coll == null) return null; - return coll.get(MCore.INSTANCE); + return coll.get(MassiveCore.INSTANCE); } } diff --git a/src/com/massivecraft/factions/entity/UPlayer.java b/src/main/java/com/massivecraft/factions/entity/UPlayer.java similarity index 92% rename from src/com/massivecraft/factions/entity/UPlayer.java rename to src/main/java/com/massivecraft/factions/entity/UPlayer.java index 46b0a1af..9c810aa0 100644 --- a/src/com/massivecraft/factions/entity/UPlayer.java +++ b/src/main/java/com/massivecraft/factions/entity/UPlayer.java @@ -13,17 +13,17 @@ import com.massivecraft.factions.Factions; import com.massivecraft.factions.Lang; import com.massivecraft.factions.Rel; import com.massivecraft.factions.RelationParticipator; -import com.massivecraft.factions.event.FactionsEventChunkChange; -import com.massivecraft.factions.event.FactionsEventMembershipChange; -import com.massivecraft.factions.event.FactionsEventMembershipChange.MembershipChangeReason; +import com.massivecraft.factions.event.EventFactionsChunkChange; +import com.massivecraft.factions.event.EventFactionsMembershipChange; +import com.massivecraft.factions.event.EventFactionsMembershipChange.MembershipChangeReason; import com.massivecraft.factions.util.RelationUtil; -import com.massivecraft.mcore.mixin.Mixin; -import com.massivecraft.mcore.ps.PS; -import com.massivecraft.mcore.ps.PSFormatHumanSpace; -import com.massivecraft.mcore.store.SenderEntity; -import com.massivecraft.mcore.util.MUtil; -import com.massivecraft.mcore.util.SenderUtil; -import com.massivecraft.mcore.util.Txt; +import com.massivecraft.massivecore.mixin.Mixin; +import com.massivecraft.massivecore.ps.PS; +import com.massivecraft.massivecore.ps.PSFormatHumanSpace; +import com.massivecraft.massivecore.store.SenderEntity; +import com.massivecraft.massivecore.util.IdUtil; +import com.massivecraft.massivecore.util.MUtil; +import com.massivecraft.massivecore.util.Txt; public class UPlayer extends SenderEntity implements EconomyParticipator @@ -74,7 +74,7 @@ public class UPlayer extends SenderEntity implements EconomyParticipato Faction faction = this.getFaction(); faction.uplayers.add(this); - Factions.get().log(Txt.parse("postAttach added %s aka %s to %s aka %s.", id, Mixin.getDisplayName(id), faction.getId(), faction.getName())); + //Factions.get().log(Txt.parse("postAttach added %s aka %s to %s aka %s.", id, Mixin.getDisplayName(id), faction.getId(), faction.getName())); } @Override @@ -87,7 +87,7 @@ public class UPlayer extends SenderEntity implements EconomyParticipato Faction faction = this.getFaction(); faction.uplayers.remove(this); - Factions.get().log(Txt.parse("preDetach removed %s aka %s to %s aka %s.", id, Mixin.getDisplayName(id), faction.getId(), faction.getName())); + //Factions.get().log(Txt.parse("preDetach removed %s aka %s to %s aka %s.", id, Mixin.getDisplayName(id), faction.getId(), faction.getName())); } // -------------------------------------------- // @@ -260,7 +260,7 @@ public class UPlayer extends SenderEntity implements EconomyParticipato factionNameDesc = faction.getName(); } - Factions.get().log(Txt.parse("setFactionId moved %s aka %s from %s aka %s to %s aka %s.", this.getId(), Mixin.getDisplayName(this.getId()), oldFactionIdDesc, oldFactionNameDesc, factionIdDesc, factionNameDesc)); + Factions.get().log(Txt.parse("setFactionId moved %s aka %s from %s aka %s to %s aka %s.", this.getId(), this.getDisplayName(IdUtil.getConsole()), oldFactionIdDesc, oldFactionNameDesc, factionIdDesc, factionNameDesc)); // Mark as changed this.changed(); @@ -475,11 +475,6 @@ public class UPlayer extends SenderEntity implements EconomyParticipato // TITLE, NAME, FACTION NAME AND CHAT // -------------------------------------------- // - public String getName() - { - return this.getFixedId(); - } - public String getFactionName() { Faction faction = this.getFaction(); @@ -587,14 +582,16 @@ public class UPlayer extends SenderEntity implements EconomyParticipato public boolean isInOwnTerritory() { - // TODO: Use Mixin to get this PS instead - return BoardColls.get().getFactionAt(Mixin.getSenderPs(this.getId())) == this.getFaction(); + PS ps = Mixin.getSenderPs(this.getId()); + if (ps == null) return false; + return BoardColls.get().getFactionAt(ps) == this.getFaction(); } public boolean isInEnemyTerritory() { - // TODO: Use Mixin to get this PS instead - return BoardColls.get().getFactionAt(Mixin.getSenderPs(this.getId())).getRelationTo(this) == Rel.ENEMY; + PS ps = Mixin.getSenderPs(this.getId()); + if (ps == null) return false; + return BoardColls.get().getFactionAt(ps).getRelationTo(this) == Rel.ENEMY; } // -------------------------------------------- // @@ -623,7 +620,7 @@ public class UPlayer extends SenderEntity implements EconomyParticipato } // Event - FactionsEventMembershipChange membershipChangeEvent = new FactionsEventMembershipChange(this.getSender(), this, myFaction, MembershipChangeReason.LEAVE); + EventFactionsMembershipChange membershipChangeEvent = new EventFactionsMembershipChange(this.getSender(), this, myFaction, MembershipChangeReason.LEAVE); membershipChangeEvent.run(); if (membershipChangeEvent.isCancelled()) return; @@ -677,7 +674,7 @@ public class UPlayer extends SenderEntity implements EconomyParticipato { if (newFaction.isNormal()) { - if (mconf.worldsNoClaiming.contains(ps.getWorld())) + if (mconf.getWorldsNoClaiming().contains(ps.getWorld())) { msg("Sorry, this world has land claiming disabled."); return false; @@ -763,7 +760,7 @@ public class UPlayer extends SenderEntity implements EconomyParticipato } // Event - FactionsEventChunkChange event = new FactionsEventChunkChange(sender, chunk, newFaction); + EventFactionsChunkChange event = new EventFactionsChunkChange(this.getSender(), chunk, newFaction); event.run(); if (event.isCancelled()) return false; @@ -783,7 +780,7 @@ public class UPlayer extends SenderEntity implements EconomyParticipato } if (MConf.get().logLandClaims) { - informees.add(UPlayer.get(SenderUtil.getConsole())); + informees.add(UPlayer.get(IdUtil.getConsole())); } String chunkString = chunk.toString(PSFormatHumanSpace.get()); diff --git a/src/com/massivecraft/factions/entity/UPlayerColl.java b/src/main/java/com/massivecraft/factions/entity/UPlayerColl.java similarity index 79% rename from src/com/massivecraft/factions/entity/UPlayerColl.java rename to src/main/java/com/massivecraft/factions/entity/UPlayerColl.java index 4682f057..5f94fe8f 100644 --- a/src/com/massivecraft/factions/entity/UPlayerColl.java +++ b/src/main/java/com/massivecraft/factions/entity/UPlayerColl.java @@ -1,13 +1,13 @@ package com.massivecraft.factions.entity; -import com.massivecraft.factions.ConfServer; import com.massivecraft.factions.Factions; import com.massivecraft.factions.Rel; -import com.massivecraft.mcore.mixin.Mixin; -import com.massivecraft.mcore.store.MStore; -import com.massivecraft.mcore.store.SenderColl; -import com.massivecraft.mcore.util.TimeUnit; -import com.massivecraft.mcore.util.Txt; +import com.massivecraft.massivecore.mixin.Mixin; +import com.massivecraft.massivecore.store.MStore; +import com.massivecraft.massivecore.store.SenderColl; +import com.massivecraft.massivecore.util.IdUtil; +import com.massivecraft.massivecore.util.TimeUnit; +import com.massivecraft.massivecore.util.Txt; public class UPlayerColl extends SenderColl { @@ -17,7 +17,7 @@ public class UPlayerColl extends SenderColl public UPlayerColl(String name) { - super(name, UPlayer.class, MStore.getDb(ConfServer.dburi), Factions.get()); + super(name, UPlayer.class, MStore.getDb(), Factions.get()); } // -------------------------------------------- // @@ -35,7 +35,7 @@ public class UPlayerColl extends SenderColl uplayer.resetFactionData(); - String message = Txt.parse("Reset data for %s in %s universe. Unknown factionId %s", uplayer.getDisplayName(), universe, factionId); + String message = Txt.parse("Reset data for %s in %s universe. Unknown factionId %s", uplayer.getDisplayName(IdUtil.getConsole()), universe, factionId); Factions.get().log(message); } } diff --git a/src/com/massivecraft/factions/entity/UPlayerColls.java b/src/main/java/com/massivecraft/factions/entity/UPlayerColls.java similarity index 83% rename from src/com/massivecraft/factions/entity/UPlayerColls.java rename to src/main/java/com/massivecraft/factions/entity/UPlayerColls.java index d0075740..1726dfd2 100644 --- a/src/com/massivecraft/factions/entity/UPlayerColls.java +++ b/src/main/java/com/massivecraft/factions/entity/UPlayerColls.java @@ -7,10 +7,10 @@ import java.util.Map.Entry; import com.massivecraft.factions.Const; import com.massivecraft.factions.Factions; -import com.massivecraft.mcore.Aspect; -import com.massivecraft.mcore.MCore; -import com.massivecraft.mcore.util.DiscUtil; -import com.massivecraft.mcore.xlib.gson.reflect.TypeToken; +import com.massivecraft.massivecore.Aspect; +import com.massivecraft.massivecore.MassiveCore; +import com.massivecraft.massivecore.util.DiscUtil; +import com.massivecraft.massivecore.xlib.gson.reflect.TypeToken; public class UPlayerColls extends XColls { @@ -40,7 +40,7 @@ public class UPlayerColls extends XColls @Override public String getBasename() { - return Const.COLLECTION_BASENAME_UPLAYER; + return Const.COLLECTION_UPLAYER; } @Override @@ -66,7 +66,7 @@ public class UPlayerColls extends XColls Map id2uplayer = Factions.get().gson.fromJson(DiscUtil.readCatch(oldFile), type); // The Coll - UPlayerColl coll = this.getForUniverse(MCore.DEFAULT); + UPlayerColl coll = this.getForUniverse(MassiveCore.DEFAULT); // Set the data for (Entry entry : id2uplayer.entrySet()) diff --git a/src/com/massivecraft/factions/entity/XColls.java b/src/main/java/com/massivecraft/factions/entity/XColls.java similarity index 67% rename from src/com/massivecraft/factions/entity/XColls.java rename to src/main/java/com/massivecraft/factions/entity/XColls.java index 1aaf486a..45a59a1a 100644 --- a/src/com/massivecraft/factions/entity/XColls.java +++ b/src/main/java/com/massivecraft/factions/entity/XColls.java @@ -1,12 +1,13 @@ package com.massivecraft.factions.entity; import org.bukkit.Bukkit; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; -import com.massivecraft.mcore.store.Coll; -import com.massivecraft.mcore.store.Colls; -import com.massivecraft.mcore.store.Entity; -import com.massivecraft.mcore.util.MUtil; -import com.massivecraft.mcore.util.SenderUtil; +import com.massivecraft.massivecore.store.Coll; +import com.massivecraft.massivecore.store.Colls; +import com.massivecraft.massivecore.store.Entity; +import com.massivecraft.massivecore.util.MUtil; public abstract class XColls, E> extends Colls { @@ -29,7 +30,7 @@ public abstract class XColls, E> extends Colls return this.getForUniverse(universe); } - if (SenderUtil.isNonplayer(o)) + if ((o instanceof CommandSender) && !(o instanceof Player)) { return this.getForWorld(Bukkit.getWorlds().get(0).getName()); } diff --git a/src/main/java/com/massivecraft/factions/event/EventFactionsAbstract.java b/src/main/java/com/massivecraft/factions/event/EventFactionsAbstract.java new file mode 100644 index 00000000..1f309537 --- /dev/null +++ b/src/main/java/com/massivecraft/factions/event/EventFactionsAbstract.java @@ -0,0 +1,8 @@ +package com.massivecraft.factions.event; + +import com.massivecraft.massivecore.event.EventMassiveCore; + +public abstract class EventFactionsAbstract extends EventMassiveCore +{ + +} diff --git a/src/com/massivecraft/factions/event/FactionsEventAbstractSender.java b/src/main/java/com/massivecraft/factions/event/EventFactionsAbstractSender.java similarity index 73% rename from src/com/massivecraft/factions/event/FactionsEventAbstractSender.java rename to src/main/java/com/massivecraft/factions/event/EventFactionsAbstractSender.java index 32aab0f8..e4907a3f 100644 --- a/src/com/massivecraft/factions/event/FactionsEventAbstractSender.java +++ b/src/main/java/com/massivecraft/factions/event/EventFactionsAbstractSender.java @@ -3,9 +3,9 @@ package com.massivecraft.factions.event; import org.bukkit.command.CommandSender; import com.massivecraft.factions.entity.UPlayer; -import com.massivecraft.mcore.event.MCoreEvent; +import com.massivecraft.massivecore.event.EventMassiveCore; -public abstract class FactionsEventAbstractSender extends MCoreEvent +public abstract class EventFactionsAbstractSender extends EventMassiveCore { // -------------------------------------------- // // FIELDS @@ -19,7 +19,7 @@ public abstract class FactionsEventAbstractSender extends MCoreEvent // CONSTRUCT // -------------------------------------------- // - public FactionsEventAbstractSender(CommandSender sender) + public EventFactionsAbstractSender(CommandSender sender) { this.sender = sender; } diff --git a/src/com/massivecraft/factions/event/FactionsEventChunkChange.java b/src/main/java/com/massivecraft/factions/event/EventFactionsChunkChange.java similarity index 69% rename from src/com/massivecraft/factions/event/FactionsEventChunkChange.java rename to src/main/java/com/massivecraft/factions/event/EventFactionsChunkChange.java index b2414c3a..bc2f7e46 100644 --- a/src/com/massivecraft/factions/event/FactionsEventChunkChange.java +++ b/src/main/java/com/massivecraft/factions/event/EventFactionsChunkChange.java @@ -6,9 +6,9 @@ import org.bukkit.event.HandlerList; import com.massivecraft.factions.entity.BoardColls; import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.UPlayer; -import com.massivecraft.mcore.ps.PS; +import com.massivecraft.massivecore.ps.PS; -public class FactionsEventChunkChange extends FactionsEventAbstractSender +public class EventFactionsChunkChange extends EventFactionsAbstractSender { // -------------------------------------------- // // REQUIRED EVENT CODE @@ -25,6 +25,7 @@ public class FactionsEventChunkChange extends FactionsEventAbstractSender private final PS chunk; public PS getChunk() { return this.chunk; } + private final Faction currentFaction; private final Faction newFaction; public Faction getNewFaction() { return this.newFaction; } @@ -32,10 +33,11 @@ public class FactionsEventChunkChange extends FactionsEventAbstractSender // CONSTRUCT // -------------------------------------------- // - public FactionsEventChunkChange(CommandSender sender, PS chunk, Faction newFaction) + public EventFactionsChunkChange(CommandSender sender, PS chunk, Faction newFaction) { super(sender); this.chunk = chunk.getChunk(true); + this.currentFaction = BoardColls.get().getFactionAt(chunk); this.newFaction = newFaction; } @@ -43,17 +45,15 @@ public class FactionsEventChunkChange extends FactionsEventAbstractSender // UTIL // -------------------------------------------- // - public FactionsEventChunkChangeType getType() + public EventFactionsChunkChangeType getType() { - Faction currentFaction = BoardColls.get().getFactionAt(chunk); - - if (currentFaction.isNone()) return FactionsEventChunkChangeType.BUY; - if (newFaction.isNormal()) return FactionsEventChunkChangeType.CONQUER; + if (currentFaction.isNone()) return EventFactionsChunkChangeType.BUY; + if (newFaction.isNormal()) return EventFactionsChunkChangeType.CONQUER; UPlayer usender = this.getUSender(); - if (usender != null && usender.getFaction() == currentFaction) return FactionsEventChunkChangeType.SELL; + if (usender != null && usender.getFaction() == currentFaction) return EventFactionsChunkChangeType.SELL; - return FactionsEventChunkChangeType.PILLAGE; + return EventFactionsChunkChangeType.PILLAGE; } } diff --git a/src/com/massivecraft/factions/event/FactionsEventChunkChangeType.java b/src/main/java/com/massivecraft/factions/event/EventFactionsChunkChangeType.java similarity index 61% rename from src/com/massivecraft/factions/event/FactionsEventChunkChangeType.java rename to src/main/java/com/massivecraft/factions/event/EventFactionsChunkChangeType.java index 851ef708..33cd4140 100644 --- a/src/com/massivecraft/factions/event/FactionsEventChunkChangeType.java +++ b/src/main/java/com/massivecraft/factions/event/EventFactionsChunkChangeType.java @@ -1,6 +1,6 @@ package com.massivecraft.factions.event; -public enum FactionsEventChunkChangeType +public enum EventFactionsChunkChangeType { BUY, SELL, diff --git a/src/com/massivecraft/factions/event/FactionsEventCreate.java b/src/main/java/com/massivecraft/factions/event/EventFactionsCreate.java similarity index 89% rename from src/com/massivecraft/factions/event/FactionsEventCreate.java rename to src/main/java/com/massivecraft/factions/event/EventFactionsCreate.java index e570641c..f6d5ba1c 100644 --- a/src/com/massivecraft/factions/event/FactionsEventCreate.java +++ b/src/main/java/com/massivecraft/factions/event/EventFactionsCreate.java @@ -3,7 +3,7 @@ package com.massivecraft.factions.event; import org.bukkit.command.CommandSender; import org.bukkit.event.HandlerList; -public class FactionsEventCreate extends FactionsEventAbstractSender +public class EventFactionsCreate extends EventFactionsAbstractSender { // -------------------------------------------- // // REQUIRED EVENT CODE @@ -30,7 +30,7 @@ public class FactionsEventCreate extends FactionsEventAbstractSender // CONSTRUCT // -------------------------------------------- // - public FactionsEventCreate(CommandSender sender, String universe, String factionId, String factionName) + public EventFactionsCreate(CommandSender sender, String universe, String factionId, String factionName) { super(sender); this.universe = universe; diff --git a/src/com/massivecraft/factions/event/FactionsEventDescriptionChange.java b/src/main/java/com/massivecraft/factions/event/EventFactionsDescriptionChange.java similarity index 86% rename from src/com/massivecraft/factions/event/FactionsEventDescriptionChange.java rename to src/main/java/com/massivecraft/factions/event/EventFactionsDescriptionChange.java index 49578143..dc9585b4 100644 --- a/src/com/massivecraft/factions/event/FactionsEventDescriptionChange.java +++ b/src/main/java/com/massivecraft/factions/event/EventFactionsDescriptionChange.java @@ -5,7 +5,7 @@ import org.bukkit.event.HandlerList; import com.massivecraft.factions.entity.Faction; -public class FactionsEventDescriptionChange extends FactionsEventAbstractSender +public class EventFactionsDescriptionChange extends EventFactionsAbstractSender { // -------------------------------------------- // // REQUIRED EVENT CODE @@ -30,7 +30,7 @@ public class FactionsEventDescriptionChange extends FactionsEventAbstractSender // CONSTRUCT // -------------------------------------------- // - public FactionsEventDescriptionChange(CommandSender sender, Faction faction, String newDescription) + public EventFactionsDescriptionChange(CommandSender sender, Faction faction, String newDescription) { super(sender); this.faction = faction; diff --git a/src/com/massivecraft/factions/event/FactionsEventDisband.java b/src/main/java/com/massivecraft/factions/event/EventFactionsDisband.java similarity index 88% rename from src/com/massivecraft/factions/event/FactionsEventDisband.java rename to src/main/java/com/massivecraft/factions/event/EventFactionsDisband.java index fa649eaa..3ad112e9 100644 --- a/src/com/massivecraft/factions/event/FactionsEventDisband.java +++ b/src/main/java/com/massivecraft/factions/event/EventFactionsDisband.java @@ -5,7 +5,7 @@ import org.bukkit.event.HandlerList; import com.massivecraft.factions.entity.Faction; -public class FactionsEventDisband extends FactionsEventAbstractSender +public class EventFactionsDisband extends EventFactionsAbstractSender { // -------------------------------------------- // // REQUIRED EVENT CODE @@ -29,7 +29,7 @@ public class FactionsEventDisband extends FactionsEventAbstractSender // CONSTRUCT // -------------------------------------------- // - public FactionsEventDisband(CommandSender sender, Faction faction) + public EventFactionsDisband(CommandSender sender, Faction faction) { super(sender); this.faction = faction; diff --git a/src/com/massivecraft/factions/event/FactionsEventHomeChange.java b/src/main/java/com/massivecraft/factions/event/EventFactionsHomeChange.java similarity index 83% rename from src/com/massivecraft/factions/event/FactionsEventHomeChange.java rename to src/main/java/com/massivecraft/factions/event/EventFactionsHomeChange.java index ac47c996..3a6290fc 100644 --- a/src/com/massivecraft/factions/event/FactionsEventHomeChange.java +++ b/src/main/java/com/massivecraft/factions/event/EventFactionsHomeChange.java @@ -4,9 +4,9 @@ import org.bukkit.command.CommandSender; import org.bukkit.event.HandlerList; import com.massivecraft.factions.entity.Faction; -import com.massivecraft.mcore.ps.PS; +import com.massivecraft.massivecore.ps.PS; -public class FactionsEventHomeChange extends FactionsEventAbstractSender +public class EventFactionsHomeChange extends EventFactionsAbstractSender { // -------------------------------------------- // // REQUIRED EVENT CODE @@ -31,7 +31,7 @@ public class FactionsEventHomeChange extends FactionsEventAbstractSender // CONSTRUCT // -------------------------------------------- // - public FactionsEventHomeChange(CommandSender sender, Faction faction, PS newHome) + public EventFactionsHomeChange(CommandSender sender, Faction faction, PS newHome) { super(sender); this.faction = faction; diff --git a/src/com/massivecraft/factions/event/FactionsEventHomeTeleport.java b/src/main/java/com/massivecraft/factions/event/EventFactionsHomeTeleport.java similarity index 80% rename from src/com/massivecraft/factions/event/FactionsEventHomeTeleport.java rename to src/main/java/com/massivecraft/factions/event/EventFactionsHomeTeleport.java index 2bbfa566..e9264f2c 100644 --- a/src/com/massivecraft/factions/event/FactionsEventHomeTeleport.java +++ b/src/main/java/com/massivecraft/factions/event/EventFactionsHomeTeleport.java @@ -3,7 +3,7 @@ package com.massivecraft.factions.event; import org.bukkit.command.CommandSender; import org.bukkit.event.HandlerList; -public class FactionsEventHomeTeleport extends FactionsEventAbstractSender +public class EventFactionsHomeTeleport extends EventFactionsAbstractSender { // -------------------------------------------- // // REQUIRED EVENT CODE @@ -17,7 +17,7 @@ public class FactionsEventHomeTeleport extends FactionsEventAbstractSender // CONSTRUCT // -------------------------------------------- // - public FactionsEventHomeTeleport(CommandSender sender) + public EventFactionsHomeTeleport(CommandSender sender) { super(sender); } diff --git a/src/com/massivecraft/factions/event/FactionsEventInvitedChange.java b/src/main/java/com/massivecraft/factions/event/EventFactionsInvitedChange.java similarity index 90% rename from src/com/massivecraft/factions/event/FactionsEventInvitedChange.java rename to src/main/java/com/massivecraft/factions/event/EventFactionsInvitedChange.java index e082375b..93bcf62b 100644 --- a/src/com/massivecraft/factions/event/FactionsEventInvitedChange.java +++ b/src/main/java/com/massivecraft/factions/event/EventFactionsInvitedChange.java @@ -6,7 +6,7 @@ import org.bukkit.event.HandlerList; import com.massivecraft.factions.entity.UPlayer; import com.massivecraft.factions.entity.Faction; -public class FactionsEventInvitedChange extends FactionsEventAbstractSender +public class EventFactionsInvitedChange extends EventFactionsAbstractSender { // -------------------------------------------- // // REQUIRED EVENT CODE @@ -34,7 +34,7 @@ public class FactionsEventInvitedChange extends FactionsEventAbstractSender // CONSTRUCT // -------------------------------------------- // - public FactionsEventInvitedChange(CommandSender sender, UPlayer uplayer, Faction faction, boolean newInvited) + public EventFactionsInvitedChange(CommandSender sender, UPlayer uplayer, Faction faction, boolean newInvited) { super(sender); this.uplayer = uplayer; diff --git a/src/com/massivecraft/factions/event/FactionsEventMembershipChange.java b/src/main/java/com/massivecraft/factions/event/EventFactionsMembershipChange.java similarity index 93% rename from src/com/massivecraft/factions/event/FactionsEventMembershipChange.java rename to src/main/java/com/massivecraft/factions/event/EventFactionsMembershipChange.java index b0ab9e3e..402f2f8b 100644 --- a/src/com/massivecraft/factions/event/FactionsEventMembershipChange.java +++ b/src/main/java/com/massivecraft/factions/event/EventFactionsMembershipChange.java @@ -6,7 +6,7 @@ import org.bukkit.event.HandlerList; import com.massivecraft.factions.entity.UPlayer; import com.massivecraft.factions.entity.Faction; -public class FactionsEventMembershipChange extends FactionsEventAbstractSender +public class EventFactionsMembershipChange extends EventFactionsAbstractSender { // -------------------------------------------- // // REQUIRED EVENT CODE @@ -40,7 +40,7 @@ public class FactionsEventMembershipChange extends FactionsEventAbstractSender // CONSTRUCT // -------------------------------------------- // - public FactionsEventMembershipChange(CommandSender sender, UPlayer uplayer, Faction newFaction, MembershipChangeReason reason) + public EventFactionsMembershipChange(CommandSender sender, UPlayer uplayer, Faction newFaction, MembershipChangeReason reason) { super(sender); this.uplayer = uplayer; diff --git a/src/com/massivecraft/factions/event/FactionsEventNameChange.java b/src/main/java/com/massivecraft/factions/event/EventFactionsNameChange.java similarity index 89% rename from src/com/massivecraft/factions/event/FactionsEventNameChange.java rename to src/main/java/com/massivecraft/factions/event/EventFactionsNameChange.java index d4c2abc2..4c5cadfb 100644 --- a/src/com/massivecraft/factions/event/FactionsEventNameChange.java +++ b/src/main/java/com/massivecraft/factions/event/EventFactionsNameChange.java @@ -5,7 +5,7 @@ import org.bukkit.event.HandlerList; import com.massivecraft.factions.entity.Faction; -public class FactionsEventNameChange extends FactionsEventAbstractSender +public class EventFactionsNameChange extends EventFactionsAbstractSender { // -------------------------------------------- // // REQUIRED EVENT CODE @@ -30,7 +30,7 @@ public class FactionsEventNameChange extends FactionsEventAbstractSender // CONSTRUCT // -------------------------------------------- // - public FactionsEventNameChange(CommandSender sender, Faction faction, String newName) + public EventFactionsNameChange(CommandSender sender, Faction faction, String newName) { super(sender); this.faction = faction; diff --git a/src/com/massivecraft/factions/event/FactionsEventOpenChange.java b/src/main/java/com/massivecraft/factions/event/EventFactionsOpenChange.java similarity index 86% rename from src/com/massivecraft/factions/event/FactionsEventOpenChange.java rename to src/main/java/com/massivecraft/factions/event/EventFactionsOpenChange.java index f931de78..b6758f4e 100644 --- a/src/com/massivecraft/factions/event/FactionsEventOpenChange.java +++ b/src/main/java/com/massivecraft/factions/event/EventFactionsOpenChange.java @@ -5,7 +5,7 @@ import org.bukkit.event.HandlerList; import com.massivecraft.factions.entity.Faction; -public class FactionsEventOpenChange extends FactionsEventAbstractSender +public class EventFactionsOpenChange extends EventFactionsAbstractSender { // -------------------------------------------- // // REQUIRED EVENT CODE @@ -30,7 +30,7 @@ public class FactionsEventOpenChange extends FactionsEventAbstractSender // CONSTRUCT // -------------------------------------------- // - public FactionsEventOpenChange(CommandSender sender, Faction faction, boolean newOpen) + public EventFactionsOpenChange(CommandSender sender, Faction faction, boolean newOpen) { super(sender); this.faction = faction; diff --git a/src/com/massivecraft/factions/event/FactionsEventPowerChange.java b/src/main/java/com/massivecraft/factions/event/EventFactionsPowerChange.java similarity index 91% rename from src/com/massivecraft/factions/event/FactionsEventPowerChange.java rename to src/main/java/com/massivecraft/factions/event/EventFactionsPowerChange.java index 59380a2e..0361086c 100644 --- a/src/com/massivecraft/factions/event/FactionsEventPowerChange.java +++ b/src/main/java/com/massivecraft/factions/event/EventFactionsPowerChange.java @@ -5,7 +5,7 @@ import org.bukkit.event.HandlerList; import com.massivecraft.factions.entity.UPlayer; -public class FactionsEventPowerChange extends FactionsEventAbstractSender +public class EventFactionsPowerChange extends EventFactionsAbstractSender { // -------------------------------------------- // // REQUIRED EVENT CODE @@ -33,7 +33,7 @@ public class FactionsEventPowerChange extends FactionsEventAbstractSender // CONSTRUCT // -------------------------------------------- // - public FactionsEventPowerChange(CommandSender sender, UPlayer uplayer, PowerChangeReason reason, double newPower) + public EventFactionsPowerChange(CommandSender sender, UPlayer uplayer, PowerChangeReason reason, double newPower) { super(sender); this.uplayer = uplayer; diff --git a/src/main/java/com/massivecraft/factions/event/EventFactionsPvpDisallowed.java b/src/main/java/com/massivecraft/factions/event/EventFactionsPvpDisallowed.java new file mode 100644 index 00000000..23ab32f6 --- /dev/null +++ b/src/main/java/com/massivecraft/factions/event/EventFactionsPvpDisallowed.java @@ -0,0 +1,52 @@ +package com.massivecraft.factions.event; + +import org.bukkit.entity.Player; +import org.bukkit.event.HandlerList; +import org.bukkit.event.entity.EntityDamageByEntityEvent; + +import com.massivecraft.factions.entity.UPlayer; + +/** + * This event is fired when PVP is disallowed between players due to any rules in Factions. + * Canceling this event allows the PVP in spite of this and stops text messages from being sent. + * + * Note that the defender field always is set but the attacker can be null. + * Some other plugins seem to fire EntityDamageByEntityEvent without an attacker. + */ +public class EventFactionsPvpDisallowed extends EventFactionsAbstract +{ + // -------------------------------------------- // + // REQUIRED EVENT CODE + // -------------------------------------------- // + + private static final HandlerList handlers = new HandlerList(); + @Override public HandlerList getHandlers() { return handlers; } + public static HandlerList getHandlerList() { return handlers; } + + // -------------------------------------------- // + // FIELDS + // -------------------------------------------- // + + private final Player attacker; + public Player getAttacker() { return this.attacker; } + public UPlayer getUAttacker() { return this.attacker == null ? null : UPlayer.get(this.attacker); } + + private final Player defender; + public Player getDefender() { return this.defender; } + public UPlayer getUDefender() { return this.defender == null ? null : UPlayer.get(this.defender); } + + private final EntityDamageByEntityEvent event; + public EntityDamageByEntityEvent getEvent() { return this.event; } + + // -------------------------------------------- // + // CONSTRUCT + // -------------------------------------------- // + + public EventFactionsPvpDisallowed(Player attacker, Player defender, EntityDamageByEntityEvent event) + { + this.attacker = attacker; + this.defender = defender; + this.event = event; + } + +} diff --git a/src/com/massivecraft/factions/event/FactionsEventRelationChange.java b/src/main/java/com/massivecraft/factions/event/EventFactionsRelationChange.java similarity index 91% rename from src/com/massivecraft/factions/event/FactionsEventRelationChange.java rename to src/main/java/com/massivecraft/factions/event/EventFactionsRelationChange.java index a46aacf1..99625ea7 100644 --- a/src/com/massivecraft/factions/event/FactionsEventRelationChange.java +++ b/src/main/java/com/massivecraft/factions/event/EventFactionsRelationChange.java @@ -7,7 +7,7 @@ import com.massivecraft.factions.Rel; import com.massivecraft.factions.entity.Faction; -public class FactionsEventRelationChange extends FactionsEventAbstractSender +public class EventFactionsRelationChange extends EventFactionsAbstractSender { // -------------------------------------------- // // REQUIRED EVENT CODE @@ -35,7 +35,7 @@ public class FactionsEventRelationChange extends FactionsEventAbstractSender // CONSTRUCT // -------------------------------------------- // - public FactionsEventRelationChange(CommandSender sender, Faction faction, Faction otherFaction, Rel newRelation) + public EventFactionsRelationChange(CommandSender sender, Faction faction, Faction otherFaction, Rel newRelation) { super(sender); this.faction = faction; diff --git a/src/com/massivecraft/factions/event/FactionsEventTitleChange.java b/src/main/java/com/massivecraft/factions/event/EventFactionsTitleChange.java similarity index 86% rename from src/com/massivecraft/factions/event/FactionsEventTitleChange.java rename to src/main/java/com/massivecraft/factions/event/EventFactionsTitleChange.java index b690631b..edcf7043 100644 --- a/src/com/massivecraft/factions/event/FactionsEventTitleChange.java +++ b/src/main/java/com/massivecraft/factions/event/EventFactionsTitleChange.java @@ -5,7 +5,7 @@ import org.bukkit.event.HandlerList; import com.massivecraft.factions.entity.UPlayer; -public class FactionsEventTitleChange extends FactionsEventAbstractSender +public class EventFactionsTitleChange extends EventFactionsAbstractSender { // -------------------------------------------- // // REQUIRED EVENT CODE @@ -30,7 +30,7 @@ public class FactionsEventTitleChange extends FactionsEventAbstractSender // CONSTRUCT // -------------------------------------------- // - public FactionsEventTitleChange(CommandSender sender, UPlayer uplayer, String newTitle) + public EventFactionsTitleChange(CommandSender sender, UPlayer uplayer, String newTitle) { super(sender); this.uplayer = uplayer; diff --git a/src/com/massivecraft/factions/integration/Econ.java b/src/main/java/com/massivecraft/factions/integration/Econ.java similarity index 75% rename from src/com/massivecraft/factions/integration/Econ.java rename to src/main/java/com/massivecraft/factions/integration/Econ.java index a46fa6ce..e6539c15 100644 --- a/src/com/massivecraft/factions/integration/Econ.java +++ b/src/main/java/com/massivecraft/factions/integration/Econ.java @@ -9,7 +9,7 @@ import com.massivecraft.factions.entity.UConf; import com.massivecraft.factions.entity.UPlayer; import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.util.RelationUtil; -import com.massivecraft.mcore.money.Money; +import com.massivecraft.massivecore.money.Money; public class Econ { @@ -21,7 +21,7 @@ public class Econ // TODO: Could we not have it enabled as long as Money.enabled is true? public static boolean isEnabled(Object universe) { - return UConf.get(universe).econEnabled && Money.enabled(universe); + return UConf.get(universe).econEnabled && Money.enabled(); } // -------------------------------------------- // @@ -59,14 +59,14 @@ public class Econ if (uconf.econUniverseAccount == null) return; if (uconf.econUniverseAccount.length() == 0) return; - if (!Money.exists(universe, uconf.econUniverseAccount)) return; + if (!Money.exists(uconf.econUniverseAccount)) return; - Money.add(universe, uconf.econUniverseAccount, delta); + Money.spawn(uconf.econUniverseAccount, null, delta); } public static void sendBalanceInfo(UPlayer to, EconomyParticipator about) { - to.msg("
%s's balance is %s.", about.describeTo(to, true), Money.format(about, Money.get(about))); + to.msg("%s's balance is %s.", about.describeTo(to, true), Money.format(Money.get(about))); } public static boolean canIControllYou(EconomyParticipator i, EconomyParticipator you) @@ -96,15 +96,14 @@ public class Econ } // Otherwise you may not! ;,,; - i.msg("%s lacks permission to control %s's money.", i.describeTo(i, true), you.describeTo(i)); return false; } public static boolean transferMoney(EconomyParticipator invoker, EconomyParticipator from, EconomyParticipator to, double amount) { - return transferMoney(invoker, from, to, amount, true); + return transferMoney(from, to, invoker, amount, true); } - public static boolean transferMoney(EconomyParticipator invoker, EconomyParticipator from, EconomyParticipator to, double amount, boolean notify) + public static boolean transferMoney(EconomyParticipator from, EconomyParticipator to, EconomyParticipator by, double amount, boolean notify) { if (!isEnabled(from)) return false; @@ -119,44 +118,41 @@ public class Econ } // Check the rights - if ( ! canIControllYou(invoker, from)) return false; + if ( ! canIControllYou(by, from)) + { + by.msg("%s lacks permission to control %s's money.", by.describeTo(by, true), from.describeTo(by)); + return false; + } // Is there enough money for the transaction to happen? if (Money.get(from) < amount) { // There was not enough money to pay - if (invoker != null && notify) + if (by != null && notify) { - invoker.msg("%s can't afford to transfer %s to %s.", from.describeTo(invoker, true), Money.format(from, amount), to.describeTo(invoker)); + by.msg("%s can't afford to transfer %s to %s.", from.describeTo(by, true), Money.format(amount), to.describeTo(by)); } return false; } // Transfer money - if (Money.subtract(from, amount)) + if (Money.move(from, to, by, amount)) { - if (Money.add(to, amount)) + if (notify) { - if (notify) - { - sendTransferInfo(invoker, from, to, amount); - } - return true; - } - else - { - // We failed. Try a rollback - Money.add(from, amount); + sendTransferInfo(by, from, to, amount); } + return true; } - - // if we get here something with the transaction failed - if (notify) + else { - invoker.msg("Unable to transfer %s to %s from %s.", Money.format(from, amount), to.describeTo(invoker), from.describeTo(invoker, true)); + // if we get here something with the transaction failed + if (by != null && notify) + { + by.msg("Unable to transfer %s to %s from %s.", Money.format(amount), to.describeTo(by), from.describeTo(by, true)); + } + return false; } - - return false; } public static Set getUPlayers(EconomyParticipator ep) @@ -190,28 +186,28 @@ public class Econ { for (UPlayer recipient : recipients) { - recipient.msg("%s was transfered from %s to %s.", Money.format(from, amount), from.describeTo(recipient), to.describeTo(recipient)); + recipient.msg("%s was transfered from %s to %s.", Money.format(amount), from.describeTo(recipient), to.describeTo(recipient)); } } else if (invoker == from) { for (UPlayer recipient : recipients) { - recipient.msg("%s gave %s to %s.", from.describeTo(recipient, true), Money.format(from, amount), to.describeTo(recipient)); + recipient.msg("%s gave %s to %s.", from.describeTo(recipient, true), Money.format(amount), to.describeTo(recipient)); } } else if (invoker == to) { for (UPlayer recipient : recipients) { - recipient.msg("%s took %s from %s.", to.describeTo(recipient, true), Money.format(from, amount), from.describeTo(recipient)); + recipient.msg("%s took %s from %s.", to.describeTo(recipient, true), Money.format(amount), from.describeTo(recipient)); } } else { for (UPlayer recipient : recipients) { - recipient.msg("%s transfered %s from %s to %s.", invoker.describeTo(recipient, true), Money.format(from, amount), from.describeTo(recipient), to.describeTo(recipient)); + recipient.msg("%s transfered %s from %s to %s.", invoker.describeTo(recipient, true), Money.format(amount), from.describeTo(recipient), to.describeTo(recipient)); } } } @@ -224,7 +220,7 @@ public class Econ { if (toDoThis != null && !toDoThis.isEmpty()) { - ep.msg("%s can't afford %s %s.", ep.describeTo(ep, true), Money.format(ep, delta), toDoThis); + ep.msg("%s can't afford %s %s.", ep.describeTo(ep, true), Money.format(delta), toDoThis); } return false; } @@ -240,7 +236,7 @@ public class Econ boolean hasActionDesctription = (actionDescription != null && !actionDescription.isEmpty()); - if (Money.add(ep, delta)) + if (Money.spawn(ep, null, delta)) { modifyUniverseMoney(ep, -delta); @@ -248,11 +244,11 @@ public class Econ { if (delta > 0) { - ep.msg("%s gained %s since did %s.", You, Money.format(ep, delta), actionDescription); + ep.msg("%s gained %s since did %s.", You, Money.format(delta), actionDescription); } else { - ep.msg("%s lost %s since did %s.", You, Money.format(ep, -delta), actionDescription); + ep.msg("%s lost %s since did %s.", You, Money.format(-delta), actionDescription); } } return true; @@ -263,11 +259,11 @@ public class Econ { if (delta > 0) { - ep.msg("%s would have gained %s since did %s, but the deposit failed.", You, Money.format(ep, delta), actionDescription); + ep.msg("%s would have gained %s since did %s, but the deposit failed.", You, Money.format(delta), actionDescription); } else { - ep.msg("%s can't afford %s to %s.", You, Money.format(ep, -delta), actionDescription); + ep.msg("%s can't afford %s to %s.", You, Money.format(-delta), actionDescription); } } return false; diff --git a/src/main/java/com/massivecraft/factions/integration/dynmap/DynmapStyle.java b/src/main/java/com/massivecraft/factions/integration/dynmap/DynmapStyle.java new file mode 100644 index 00000000..e5562250 --- /dev/null +++ b/src/main/java/com/massivecraft/factions/integration/dynmap/DynmapStyle.java @@ -0,0 +1,70 @@ +package com.massivecraft.factions.integration.dynmap; + +import com.massivecraft.factions.entity.MConf; + +public class DynmapStyle +{ + // -------------------------------------------- // + // FIELDS + // -------------------------------------------- // + + public String lineColor = null; + public int getLineColor() { return getColor(coalesce(this.lineColor, MConf.get().dynmapDefaultStyle.lineColor, MConf.DYNMAP_STYLE_LINE_COLOR)); } + public DynmapStyle setStrokeColor(String strokeColor) { this.lineColor = strokeColor; return this; } + + public Double lineOpacity = null; + public double getLineOpacity() { return coalesce(this.lineOpacity, MConf.get().dynmapDefaultStyle.lineOpacity, MConf.DYNMAP_STYLE_LINE_OPACITY); } + public DynmapStyle setLineOpacity(Double strokeOpacity) { this.lineOpacity = strokeOpacity; return this; } + + public Integer lineWeight = null; + public int getLineWeight() { return coalesce(this.lineWeight, MConf.get().dynmapDefaultStyle.lineWeight, MConf.DYNMAP_STYLE_LINE_WEIGHT); } + public DynmapStyle setLineWeight(Integer strokeWeight) { this.lineWeight = strokeWeight; return this; } + + public String fillColor = null; + public int getFillColor() { return getColor(coalesce(this.fillColor, MConf.get().dynmapDefaultStyle.fillColor, MConf.DYNMAP_STYLE_FILL_COLOR)); } + public DynmapStyle setFillColor(String fillColor) { this.fillColor = fillColor; return this; } + + public Double fillOpacity = null; + public double getFillOpacity() { return coalesce(this.fillOpacity, MConf.get().dynmapDefaultStyle.fillOpacity, MConf.DYNMAP_STYLE_FILL_OPACITY); } + public DynmapStyle setFillOpacity(Double fillOpacity) { this.fillOpacity = fillOpacity; return this; } + + // NOTE: We just return the string here. We do not return the resolved Dynmap MarkerIcon object. + // The reason is we use this class in the MConf. For serialization to work Dynmap would have to be loaded and we can't require that. + // Using dynmap is optional. + public String homeMarker = null; + public String getHomeMarker() { return coalesce(this.homeMarker, MConf.get().dynmapDefaultStyle.homeMarker, MConf.DYNMAP_STYLE_HOME_MARKER); } + public DynmapStyle setHomeMarker(String homeMarker) { this.homeMarker = homeMarker; return this; } + + public Boolean boost = null; + public boolean getBoost() { return coalesce(this.boost, MConf.get().dynmapDefaultStyle.boost, MConf.DYNMAP_STYLE_BOOST); } + public DynmapStyle setBoost(Boolean boost) { this.boost = boost; return this; } + + // -------------------------------------------- // + // UTIL + // -------------------------------------------- // + + @SafeVarargs + public static T coalesce(T... items) + { + for (T item : items) + { + if (item != null) return item; + } + return null; + } + + public static int getColor(String string) + { + int ret = 0x00FF00; + try + { + ret = Integer.parseInt(string.substring(1), 16); + } + catch (NumberFormatException nfx) + { + + } + return ret; + } + +} diff --git a/src/main/java/com/massivecraft/factions/integration/dynmap/EngineDynmap.java b/src/main/java/com/massivecraft/factions/integration/dynmap/EngineDynmap.java new file mode 100644 index 00000000..6da14517 --- /dev/null +++ b/src/main/java/com/massivecraft/factions/integration/dynmap/EngineDynmap.java @@ -0,0 +1,959 @@ +package com.massivecraft.factions.integration.dynmap; + +import java.util.ArrayDeque; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedHashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.plugin.Plugin; +import org.dynmap.DynmapAPI; +import org.dynmap.markers.AreaMarker; +import org.dynmap.markers.Marker; +import org.dynmap.markers.MarkerAPI; +import org.dynmap.markers.MarkerSet; +import org.dynmap.markers.PlayerSet; +import org.dynmap.utils.TileFlags; + +import com.massivecraft.factions.FFlag; +import com.massivecraft.factions.Factions; +import com.massivecraft.factions.Rel; +import com.massivecraft.factions.TerritoryAccess; +import com.massivecraft.factions.entity.Board; +import com.massivecraft.factions.entity.BoardColl; +import com.massivecraft.factions.entity.BoardColls; +import com.massivecraft.factions.entity.Faction; +import com.massivecraft.factions.entity.FactionColl; +import com.massivecraft.factions.entity.FactionColls; +import com.massivecraft.factions.entity.MConf; +import com.massivecraft.factions.entity.UConf; +import com.massivecraft.factions.entity.UPlayer; +import com.massivecraft.massivecore.EngineAbstract; +import com.massivecraft.massivecore.money.Money; +import com.massivecraft.massivecore.ps.PS; +import com.massivecraft.massivecore.util.TimeDiffUtil; +import com.massivecraft.massivecore.util.TimeUnit; +import com.massivecraft.massivecore.util.Txt; + +// This source code is a heavily modified version of mikeprimms plugin Dynmap-Factions. +public class EngineDynmap extends EngineAbstract +{ + // -------------------------------------------- // + // CONSTANTS + // -------------------------------------------- // + + public final static int BLOCKS_PER_CHUNK = 16; + + public final static String DYNMAP_INTEGRATION = Txt.parse("Dynmap Integration: "); + + public final static String FACTIONS = "factions"; + public final static String FACTIONS_ = FACTIONS + "_"; + + public final static String FACTIONS_MARKERSET = FACTIONS_ + "markerset"; + + public final static String FACTIONS_HOME = FACTIONS_ + "home"; + public final static String FACTIONS_HOME_ = FACTIONS_HOME + "_"; + + public final static String FACTIONS_PLAYERSET = FACTIONS_ + "playerset"; + public final static String FACTIONS_PLAYERSET_ = FACTIONS_PLAYERSET + "_"; + + public final static String FACTIONS_AREA = FACTIONS_ + "area"; + public final static String FACTIONS_AREA_ = FACTIONS_AREA + "_"; + + // -------------------------------------------- // + // INSTANCE & CONSTRUCT + // -------------------------------------------- // + + private static EngineDynmap i = new EngineDynmap(); + public static EngineDynmap get() { return i; } + private EngineDynmap() {} + + // -------------------------------------------- // + // OVERRIDE + // -------------------------------------------- // + + @Override + public Plugin getPlugin() + { + return Factions.get(); + } + + @Override + public Long getPeriod() + { + // Every 15 seconds + return 15 * 20L; + } + + @Override + public boolean isSync() + { + return false; + } + + // -------------------------------------------- // + // FIELDS + // -------------------------------------------- // + + public DynmapAPI dynmapApi; + public MarkerAPI markerApi; + public MarkerSet markerset; + + // -------------------------------------------- // + // RUN: UPDATE + // -------------------------------------------- // + + // Thread Safe / Asynchronous: Yes + @Override + public void run() + { + // Should we even use dynmap? + if (!MConf.get().dynmapUse) + { + if (this.markerset != null) + { + this.markerset.deleteMarkerSet(); + this.markerset = null; + } + return; + } + + long before = System.currentTimeMillis(); + + // We do what we can here. + // You /can/ run this method from the main server thread but it's not recommended at all. + // This method is supposed to be run async to avoid locking the main server thread. + final Map homes = createHomes(); + final Map areas = createAreas(); + final Map> playerSets = createPlayersets(); + + long after = System.currentTimeMillis(); + long duration = after-before; + updateLog("Async", duration); + + // Shedule non thread safe sync at the end! + Bukkit.getScheduler().scheduleSyncDelayedTask(Factions.get(), new Runnable() + { + @Override + public void run() + { + long before = System.currentTimeMillis(); + + if (!updateCore()) return; + + // createLayer() is thread safe but it makes use of fields set in updateCore() so we must have it after. + if (!updateLayer(createLayer())) return; + + updateHomes(homes); + updateAreas(areas); + updatePlayersets(playerSets); + + long after = System.currentTimeMillis(); + long duration = after-before; + updateLog("Sync", duration); + } + }); + } + + // Thread Safe / Asynchronous: Yes + public static void updateLog(String name, long millis) + { + if (!MConf.get().dynmapUpdateLog) return; + String message = Txt.parse("%s took %dms.", "Faction Dynmap " + name, millis); + Factions.get().log(message); + } + + // -------------------------------------------- // + // UPDATE: CORE + // -------------------------------------------- // + + // Thread Safe / Asynchronous: No + public boolean updateCore() + { + // Get DynmapAPI + this.dynmapApi = (DynmapAPI) Bukkit.getPluginManager().getPlugin("dynmap"); + if (this.dynmapApi == null) + { + severe("Could not retrieve the DynmapAPI."); + return false; + } + + // Get MarkerAPI + this.markerApi = this.dynmapApi.getMarkerAPI(); + if (this.markerApi == null) + { + severe("Could not retrieve the MarkerAPI."); + return false; + } + + return true; + } + + // -------------------------------------------- // + // UPDATE: Layer + // -------------------------------------------- // + + // Thread Safe / Asynchronous: Yes + public TempMarkerSet createLayer() + { + TempMarkerSet ret = new TempMarkerSet(); + ret.label = MConf.get().dynmapLayerName; + ret.minimumZoom = MConf.get().dynmapLayerMinimumZoom; + ret.priority = MConf.get().dynmapLayerPriority; + ret.hideByDefault = !MConf.get().dynmapLayerVisible; + return ret; + } + + // Thread Safe / Asynchronous: No + public boolean updateLayer(TempMarkerSet temp) + { + this.markerset = this.markerApi.getMarkerSet(FACTIONS_MARKERSET); + if (this.markerset == null) + { + this.markerset = temp.create(this.markerApi, FACTIONS_MARKERSET); + if (this.markerset == null) + { + severe("Could not create the Faction Markerset/Layer"); + return false; + } + } + else + { + temp.update(this.markerApi, this.markerset); + } + return true; + } + + // -------------------------------------------- // + // UPDATE: HOMES + // -------------------------------------------- // + + // Thread Safe / Asynchronous: Yes + public Map createHomes() + { + Map ret = new HashMap(); + + // Loop current factions + for (FactionColl coll : FactionColls.get().getColls()) + { + for (Faction faction : coll.getAll()) + { + PS ps = faction.getHome(); + if (ps == null) continue; + + DynmapStyle style = getStyle(faction); + + String markerId = FACTIONS_HOME_ + faction.getId(); + + TempMarker temp = new TempMarker(); + temp.label = ChatColor.stripColor(faction.getName()); + temp.world = ps.getWorld(); + temp.x = ps.getLocationX(); + temp.y = ps.getLocationY(); + temp.z = ps.getLocationZ(); + temp.iconName = style.getHomeMarker(); + temp.description = getDescription(faction); + + ret.put(markerId, temp); + } + } + + return ret; + } + + // Thread Safe / Asynchronous: No + // This method places out the faction home markers into the factions markerset. + public void updateHomes(Map homes) + { + // Put all current faction markers in a map + Map markers = new HashMap(); + for (Marker marker : this.markerset.getMarkers()) + { + markers.put(marker.getMarkerID(), marker); + } + + // Loop homes + for (Entry entry : homes.entrySet()) + { + String markerId = entry.getKey(); + TempMarker temp = entry.getValue(); + + // Get Creative + // NOTE: I remove from the map created just in the beginning of this method. + // NOTE: That way what is left at the end will be outdated markers to remove. + Marker marker = markers.remove(markerId); + if (marker == null) + { + marker = temp.create(this.markerApi, this.markerset, markerId); + if (marker == null) + { + EngineDynmap.severe("Could not get/create the home marker " + markerId); + } + } + else + { + temp.update(this.markerApi, this.markerset, marker); + } + } + + // Delete Deprecated Markers + // Only old markers should now be left + for (Marker marker : markers.values()) + { + marker.deleteMarker(); + } + } + + // -------------------------------------------- // + // UPDATE: AREAS + // -------------------------------------------- // + + // Thread Safe: YES + public Map createAreas() + { + Map>> worldFactionChunks = createWorldFactionChunks(); + return createAreas(worldFactionChunks); + } + + // Thread Safe: YES + public Map>> createWorldFactionChunks() + { + // Create map "world name --> faction --> set of chunk coords" + Map>> worldFactionChunks = new HashMap>>(); + for (BoardColl coll : BoardColls.get().getColls()) + { + // Note: The board is the world. The board id is the world name. + for (Board board : coll.getAll()) + { + String world = board.getId(); + + // Get the factionChunks creatively. + Map> factionChunks = worldFactionChunks.get(world); + if (factionChunks == null) + { + factionChunks = new HashMap>(); + worldFactionChunks.put(world, factionChunks); + } + + // Populate the factionChunks + for (Entry entry : board.getMap().entrySet()) + { + PS chunk = entry.getKey(); + TerritoryAccess territoryAccess = entry.getValue(); + String factionId = territoryAccess.getHostFactionId(); + Faction faction = FactionColls.get().getForWorld(world).get(factionId); + if (faction == null) continue; + + // Get the chunks creatively. + Set chunks = factionChunks.get(faction); + if (chunks == null) + { + chunks = new HashSet(); + factionChunks.put(faction, chunks); + } + + chunks.add(chunk); + } + } + } + return worldFactionChunks; + } + + // Thread Safe: YES + public Map createAreas(Map>> worldFactionChunks) + { + Map ret = new HashMap(); + + // For each world + for (Entry>> entry : worldFactionChunks.entrySet()) + { + String world = entry.getKey(); + Map> factionChunks = entry.getValue(); + + // For each faction and its chunks in that world + for (Entry> entry1 : factionChunks.entrySet()) + { + Faction faction = entry1.getKey(); + Set chunks = entry1.getValue(); + Map worldFactionMarkers = createAreas(world, faction, chunks); + ret.putAll(worldFactionMarkers); + } + } + + return ret; + } + + // Thread Safe: YES + // Handle specific faction on specific world + // "handle faction on world" + public Map createAreas(String world, Faction faction, Set chunks) + { + Map ret = new HashMap(); + + // If the faction is visible ... + if (!isVisible(faction, world)) return ret; + + // ... and has any chunks ... + if (chunks.isEmpty()) return ret; + + // Index of polygon for given faction + int markerIndex = 0; + + // Create the info window + String description = getDescription(faction); + + // Fetch Style + DynmapStyle style = this.getStyle(faction); + + // Loop through chunks: set flags on chunk map + TileFlags allChunkFlags = new TileFlags(); + LinkedList allChunks = new LinkedList(); + for (PS chunk : chunks) + { + allChunkFlags.setFlag(chunk.getChunkX(), chunk.getChunkZ(), true); // Set flag for chunk + allChunks.addLast(chunk); + } + + // Loop through until we don't find more areas + while (allChunks != null) + { + TileFlags ourChunkFlags = null; + LinkedList ourChunks = null; + LinkedList newChunks = null; + + int minimumX = Integer.MAX_VALUE; + int minimumZ = Integer.MAX_VALUE; + for (PS chunk : allChunks) + { + int chunkX = chunk.getChunkX(); + int chunkZ = chunk.getChunkZ(); + + // If we need to start shape, and this block is not part of one yet + if (ourChunkFlags == null && allChunkFlags.getFlag(chunkX, chunkZ)) + { + ourChunkFlags = new TileFlags(); // Create map for shape + ourChunks = new LinkedList(); + floodFillTarget(allChunkFlags, ourChunkFlags, chunkX, chunkZ); // Copy shape + ourChunks.add(chunk); // Add it to our chunk list + minimumX = chunkX; + minimumZ = chunkZ; + } + // If shape found, and we're in it, add to our node list + else if (ourChunkFlags != null && ourChunkFlags.getFlag(chunkX, chunkZ)) + { + ourChunks.add(chunk); + if (chunkX < minimumX) + { + minimumX = chunkX; + minimumZ = chunkZ; + } + else if (chunkX == minimumX && chunkZ < minimumZ) + { + minimumZ = chunkZ; + } + } + // Else, keep it in the list for the next polygon + else + { + if (newChunks == null) newChunks = new LinkedList(); + newChunks.add(chunk); + } + } + + // Replace list (null if no more to process) + allChunks = newChunks; + + if (ourChunkFlags == null) continue; + + // Trace outline of blocks - start from minx, minz going to x+ + int initialX = minimumX; + int initialZ = minimumZ; + int currentX = minimumX; + int currentZ = minimumZ; + Direction direction = Direction.XPLUS; + ArrayList linelist = new ArrayList(); + linelist.add(new int[]{ initialX, initialZ }); // Add start point + while ((currentX != initialX) || (currentZ != initialZ) || (direction != Direction.ZMINUS)) + { + switch (direction) + { + case XPLUS: // Segment in X+ direction + if (!ourChunkFlags.getFlag(currentX + 1, currentZ)) + { // Right turn? + linelist.add(new int[]{ currentX + 1, currentZ }); // Finish line + direction = Direction.ZPLUS; // Change direction + } + else if (!ourChunkFlags.getFlag(currentX + 1, currentZ - 1)) + { // Straight? + currentX++; + } + else + { // Left turn + linelist.add(new int[]{ currentX + 1, currentZ }); // Finish line + direction = Direction.ZMINUS; + currentX++; + currentZ--; + } + break; + case ZPLUS: // Segment in Z+ direction + if (!ourChunkFlags.getFlag(currentX, currentZ + 1)) + { // Right turn? + linelist.add(new int[]{ currentX + 1, currentZ + 1 }); // Finish line + direction = Direction.XMINUS; // Change direction + } + else if (!ourChunkFlags.getFlag(currentX + 1, currentZ + 1)) + { // Straight? + currentZ++; + } + else + { // Left turn + linelist.add(new int[]{ currentX + 1, currentZ + 1 }); // Finish line + direction = Direction.XPLUS; + currentX++; + currentZ++; + } + break; + case XMINUS: // Segment in X- direction + if (!ourChunkFlags.getFlag(currentX - 1, currentZ)) + { // Right turn? + linelist.add(new int[]{ currentX, currentZ + 1 }); // Finish line + direction = Direction.ZMINUS; // Change direction + } + else if (!ourChunkFlags.getFlag(currentX - 1, currentZ + 1)) + { // Straight? + currentX--; + } + else + { // Left turn + linelist.add(new int[] { currentX, currentZ + 1 }); // Finish line + direction = Direction.ZPLUS; + currentX--; + currentZ++; + } + break; + case ZMINUS: // Segment in Z- direction + if (!ourChunkFlags.getFlag(currentX, currentZ - 1)) + { // Right turn? + linelist.add(new int[]{ currentX, currentZ }); // Finish line + direction = Direction.XPLUS; // Change direction + } + else if (!ourChunkFlags.getFlag(currentX - 1, currentZ - 1)) + { // Straight? + currentZ--; + } + else + { // Left turn + linelist.add(new int[] { currentX, currentZ }); // Finish line + direction = Direction.XMINUS; + currentX--; + currentZ--; + } + break; + } + } + + int sz = linelist.size(); + double[] x = new double[sz]; + double[] z = new double[sz]; + for (int i = 0; i < sz; i++) + { + int[] line = linelist.get(i); + x[i] = (double) line[0] * (double) BLOCKS_PER_CHUNK; + z[i] = (double) line[1] * (double) BLOCKS_PER_CHUNK; + } + + // Build information for specific area + String markerId = FACTIONS_ + world + "__" + faction.getId() + "__" + markerIndex; + + TempAreaMarker temp = new TempAreaMarker(); + temp.label = faction.getName(); + temp.world = world; + temp.x = x; + temp.z = z; + temp.description = description; + + temp.lineColor = style.getLineColor(); + temp.lineOpacity = style.getLineOpacity(); + temp.lineWeight = style.getLineWeight(); + + temp.fillColor = style.getFillColor(); + temp.fillOpacity = style.getFillOpacity(); + + temp.boost = style.getBoost(); + + ret.put(markerId, temp); + + markerIndex++; + } + + return ret; + } + + // Thread Safe: NO + public void updateAreas(Map areas) + { + // Map Current + Map markers = new HashMap(); + for (AreaMarker marker : this.markerset.getAreaMarkers()) + { + markers.put(marker.getMarkerID(), marker); + } + + // Loop New + for (Entry entry : areas.entrySet()) + { + String markerId = entry.getKey(); + TempAreaMarker temp = entry.getValue(); + + // Get Creative + // NOTE: I remove from the map created just in the beginning of this method. + // NOTE: That way what is left at the end will be outdated markers to remove. + AreaMarker marker = markers.remove(markerId); + if (marker == null) + { + marker = temp.create(this.markerApi, this.markerset, markerId); + if (marker == null) + { + severe("Could not get/create the area marker " + markerId); + } + } + else + { + temp.update(this.markerApi, this.markerset, marker); + } + } + + // Only old/outdated should now be left. Delete them. + for (AreaMarker marker : markers.values()) + { + marker.deleteMarker(); + } + } + + // -------------------------------------------- // + // UPDATE: PLAYERSET + // -------------------------------------------- // + + // Thread Safe / Asynchronous: Yes + public String createPlayersetId(Faction faction) + { + if (faction == null) return null; + if (faction.isNone()) return null; + String factionId = faction.getId(); + if (factionId == null) return null; + return FACTIONS_PLAYERSET_ + factionId; + } + + // Thread Safe / Asynchronous: Yes + public Set createPlayerset(Faction faction) + { + if (faction == null) return null; + if (faction.isNone()) return null; + + Set ret = new HashSet(); + + for (UPlayer uplayer : faction.getUPlayers()) + { + // NOTE: We add both UUID and name. This might be a good idea for future proofing. + ret.add(uplayer.getId()); + ret.add(uplayer.getName()); + } + + return ret; + } + + // Thread Safe / Asynchronous: Yes + public Map> createPlayersets() + { + if (!MConf.get().dynmapVisibilityByFaction) return null; + + Map> ret = new HashMap>(); + + for (FactionColl coll : FactionColls.get().getColls()) + { + for (Faction faction : coll.getAll()) + { + String playersetId = createPlayersetId(faction); + if (playersetId == null) continue; + Set playerIds = createPlayerset(faction); + if (playerIds == null) continue; + ret.put(playersetId, playerIds); + } + } + + return ret; + } + + // Thread Safe / Asynchronous: No + public void updatePlayersets(Map> playersets) + { + // Remove + for (PlayerSet set : this.markerApi.getPlayerSets()) + { + if (!set.getSetID().startsWith(FACTIONS_PLAYERSET_)) continue; + + // (Null means remove all) + if (playersets != null && playersets.containsKey(set.getSetID())) continue; + + set.deleteSet(); + } + + // Add / Update + for (Entry> entry : playersets.entrySet()) + { + // Extract from Entry + String setId = entry.getKey(); + Set playerIds = entry.getValue(); + + // Get Creatively + PlayerSet set = this.markerApi.getPlayerSet(setId); + if (set == null) set = this.markerApi.createPlayerSet( + setId, // id + true, // symmetric + playerIds, // players + false // persistent + ); + if (set == null) + { + severe("Could not get/create the player set " + setId); + continue; + } + + // Set Content + set.setPlayers(playerIds); + } + } + + // -------------------------------------------- // + // UTIL & SHARED + // -------------------------------------------- // + + // Thread Safe / Asynchronous: Yes + private String getDescription(Faction faction) + { + String ret = "
" + MConf.get().dynmapDescription + "
"; + + // Name + String name = faction.getName(); + name = ChatColor.stripColor(name); + name = escapeHtml(name); + ret = ret.replace("%name%", name); + + // Description + String description = faction.getDescription(); + description = ChatColor.stripColor(description); + description = escapeHtml(description); + ret = ret.replace("%description%", description); + + // Age + long ageMillis = faction.getCreatedAtMillis() - System.currentTimeMillis(); + LinkedHashMap ageUnitcounts = TimeDiffUtil.limit(TimeDiffUtil.unitcounts(ageMillis, TimeUnit.getAllButMillisSecondsAndMinutes()), 3); + String age = TimeDiffUtil.formatedVerboose(ageUnitcounts, ""); + age = ChatColor.stripColor(age); + ret = ret.replace("%age%", age); + + // Money + String money = "unavailable"; + if (UConf.get(faction).bankEnabled && MConf.get().dynmapDescriptionMoney) + { + money = Money.format(Money.get(faction)); + } + ret = ret.replace("%money%", money); + + // Flags and Open + Map flags = new HashMap(); + flags.put("open", faction.isOpen()); + for (FFlag fflag : FFlag.values()) + { + flags.put(fflag.getNicename(), faction.getFlag(fflag)); + } + for (Entry entry : flags.entrySet()) + { + String flag = entry.getKey(); + boolean value = entry.getValue(); + + String bool = String.valueOf(value); + String color = boolcolor(flag, value); + String boolcolor = boolcolor(String.valueOf(value), value); + + ret = ret.replace("%" + flag + ".bool%", bool); + ret = ret.replace("%" + flag + ".color%", color); + ret = ret.replace("%" + flag + ".boolcolor%", boolcolor); + } + + // Players + List playersList = faction.getUPlayers(); + String playersCount = String.valueOf(playersList.size()); + String players = getPlayerString(playersList); + + UPlayer playersLeaderObject = faction.getLeader(); + String playersLeader = getPlayerName(playersLeaderObject); + + List playersOfficersList = faction.getUPlayersWhereRole(Rel.OFFICER); + String playersOfficersCount = String.valueOf(playersOfficersList.size()); + String playersOfficers = getPlayerString(playersOfficersList); + + List playersMembersList = faction.getUPlayersWhereRole(Rel.MEMBER); + String playersMembersCount = String.valueOf(playersMembersList.size()); + String playersMembers = getPlayerString(playersMembersList); + + List playersRecruitsList = faction.getUPlayersWhereRole(Rel.RECRUIT); + String playersRecruitsCount = String.valueOf(playersRecruitsList.size()); + String playersRecruits = getPlayerString(playersRecruitsList); + + + ret = ret.replace("%players%", players); + ret = ret.replace("%players.count%", playersCount); + ret = ret.replace("%players.leader%", playersLeader); + ret = ret.replace("%players.officers%", playersOfficers); + ret = ret.replace("%players.officers.count%", playersOfficersCount); + ret = ret.replace("%players.members%", playersMembers); + ret = ret.replace("%players.members.count%", playersMembersCount); + ret = ret.replace("%players.recruits%", playersRecruits); + ret = ret.replace("%players.recruits.count%", playersRecruitsCount); + + return ret; + } + + public static String getPlayerString(List uplayers) + { + String ret = ""; + for (UPlayer uplayer : uplayers) + { + if (ret.length() > 0) ret += ", "; + ret += getPlayerName(uplayer); + } + return ret; + } + + public static String getPlayerName(UPlayer uplayer) + { + if (uplayer == null) return "none"; + return escapeHtml(uplayer.getName()); + } + + public static String boolcolor(String string, boolean bool) + { + return "" + string + ""; + } + + public static String escapeHtml(String string) + { + StringBuilder out = new StringBuilder(Math.max(16, string.length())); + for (int i = 0; i < string.length(); i++) + { + char c = string.charAt(i); + if (c > 127 || c == '"' || c == '<' || c == '>' || c == '&') + { + out.append("&#"); + out.append((int) c); + out.append(';'); + } + else + { + out.append(c); + } + } + return out.toString(); + } + + // Thread Safe / Asynchronous: Yes + private boolean isVisible(Faction faction, String world) + { + if (faction == null) return false; + final String factionId = faction.getId(); + if (factionId == null) return false; + final String factionName = faction.getName(); + if (factionName == null) return false; + + Set visible = MConf.get().dynmapVisibleFactions; + Set hidden = MConf.get().dynmapHiddenFactions; + + if (visible.size() > 0) + { + if (!visible.contains(factionId) && !visible.contains(factionName) && !visible.contains("world:" + world)) + { + return false; + } + } + + if (hidden.size() > 0) + { + if (hidden.contains(factionId) || hidden.contains(factionName) || hidden.contains("world:" + world)) + { + return false; + } + } + + return true; + } + + // Thread Safe / Asynchronous: Yes + public DynmapStyle getStyle(Faction faction) + { + DynmapStyle ret; + + ret = MConf.get().dynmapFactionStyles.get(faction.getId()); + if (ret != null) return ret; + + ret = MConf.get().dynmapFactionStyles.get(faction.getName()); + if (ret != null) return ret; + + return MConf.get().dynmapDefaultStyle; + } + + // Thread Safe / Asynchronous: Yes + public static void info(String msg) + { + String message = DYNMAP_INTEGRATION + msg; + Factions.get().log(message); + } + + // Thread Safe / Asynchronous: Yes + public static void severe(String msg) + { + String message = DYNMAP_INTEGRATION + ChatColor.RED.toString() + msg; + Factions.get().log(message); + } + + enum Direction + { + XPLUS, ZPLUS, XMINUS, ZMINUS + }; + + // Find all contiguous blocks, set in target and clear in source + private int floodFillTarget(TileFlags source, TileFlags destination, int x, int y) + { + int cnt = 0; + ArrayDeque stack = new ArrayDeque(); + stack.push(new int[] { x, y }); + + while (stack.isEmpty() == false) + { + int[] nxt = stack.pop(); + x = nxt[0]; + y = nxt[1]; + if (source.getFlag(x, y)) + { // Set in src + source.setFlag(x, y, false); // Clear source + destination.setFlag(x, y, true); // Set in destination + cnt++; + if (source.getFlag(x + 1, y)) stack.push(new int[] { x + 1, y }); + if (source.getFlag(x - 1, y)) stack.push(new int[] { x - 1, y }); + if (source.getFlag(x, y + 1)) stack.push(new int[] { x, y + 1 }); + if (source.getFlag(x, y - 1)) stack.push(new int[] { x, y - 1 }); + } + } + return cnt; + } + + + +} diff --git a/src/main/java/com/massivecraft/factions/integration/dynmap/IntegrationDynmap.java b/src/main/java/com/massivecraft/factions/integration/dynmap/IntegrationDynmap.java new file mode 100644 index 00000000..9fa4d64c --- /dev/null +++ b/src/main/java/com/massivecraft/factions/integration/dynmap/IntegrationDynmap.java @@ -0,0 +1,31 @@ +package com.massivecraft.factions.integration.dynmap; + +import com.massivecraft.massivecore.integration.IntegrationAbstract; + +public class IntegrationDynmap extends IntegrationAbstract +{ + // -------------------------------------------- // + // INSTANCE & CONSTRUCT + // -------------------------------------------- // + + private static IntegrationDynmap i = new IntegrationDynmap(); + public static IntegrationDynmap get() { return i; } + private IntegrationDynmap() { super("dynmap"); } + + // -------------------------------------------- // + // OVERRIDE + // -------------------------------------------- // + + @Override + public void activate() + { + EngineDynmap.get().activate(); + } + + @Override + public void deactivate() + { + EngineDynmap.get().deactivate(); + } + +} diff --git a/src/main/java/com/massivecraft/factions/integration/dynmap/IntegrationDynmapFactions.java b/src/main/java/com/massivecraft/factions/integration/dynmap/IntegrationDynmapFactions.java new file mode 100644 index 00000000..20080310 --- /dev/null +++ b/src/main/java/com/massivecraft/factions/integration/dynmap/IntegrationDynmapFactions.java @@ -0,0 +1,44 @@ +package com.massivecraft.factions.integration.dynmap; + +import org.bukkit.Bukkit; +import org.bukkit.plugin.Plugin; + +import com.massivecraft.factions.Factions; +import com.massivecraft.massivecore.integration.IntegrationAbstract; +import com.massivecraft.massivecore.util.Txt; + +public class IntegrationDynmapFactions extends IntegrationAbstract +{ + // -------------------------------------------- // + // INSTANCE & CONSTRUCT + // -------------------------------------------- // + + private static IntegrationDynmapFactions i = new IntegrationDynmapFactions(); + public static IntegrationDynmapFactions get() { return i; } + private IntegrationDynmapFactions() { super("Dynmap-Factions"); } + + // -------------------------------------------- // + // OVERRIDE + // -------------------------------------------- // + + @Override + public void activate() + { + // Time for an error message! + Bukkit.getScheduler().scheduleSyncDelayedTask(Factions.get(), new Runnable() + { + @Override + public void run() + { + Factions.get().log(Txt.parse("I see you have the plugin Dynmap-Factions installed!")); + Factions.get().log(Txt.parse("That plugin is no longer required for Dynmap features.")); + Factions.get().log(Txt.parse("Factions now ship with it's own Dynmap integration.")); + Factions.get().log(Txt.parse("Now disabling Dynmap-Factions for you:")); + + Plugin plugin = Bukkit.getPluginManager().getPlugin("Dynmap-Factions"); + Bukkit.getPluginManager().disablePlugin(plugin); + } + }); + } + +} diff --git a/src/main/java/com/massivecraft/factions/integration/dynmap/TempAreaMarker.java b/src/main/java/com/massivecraft/factions/integration/dynmap/TempAreaMarker.java new file mode 100644 index 00000000..e5ebf28b --- /dev/null +++ b/src/main/java/com/massivecraft/factions/integration/dynmap/TempAreaMarker.java @@ -0,0 +1,138 @@ +package com.massivecraft.factions.integration.dynmap; + +import org.dynmap.markers.AreaMarker; +import org.dynmap.markers.MarkerAPI; +import org.dynmap.markers.MarkerSet; + +import com.massivecraft.massivecore.util.MUtil; + +public class TempAreaMarker +{ + // -------------------------------------------- // + // FIELDS + // -------------------------------------------- // + + public String label; + public String world; + public double x[]; + public double z[]; + public String description; + + public int lineColor; + public double lineOpacity; + public int lineWeight; + + public int fillColor; + public double fillOpacity; + + public boolean boost; + + // -------------------------------------------- // + // CREATE + // -------------------------------------------- // + + public AreaMarker create(MarkerAPI markerApi, MarkerSet markerset, String markerId) + { + AreaMarker ret = markerset.createAreaMarker( + markerId, + this.label, + false, + this.world, + this.x, + this.z, + false // not persistent + ); + + if (ret == null) return null; + + // Description + ret.setDescription(this.description); + + // Line Style + ret.setLineStyle(this.lineWeight, this.lineOpacity, this.lineColor); + + // Fill Style + ret.setFillStyle(this.fillOpacity, this.fillColor); + + // Boost Flag + ret.setBoostFlag(this.boost); + + return ret; + } + + // -------------------------------------------- // + // UPDATE + // -------------------------------------------- // + + public void update(MarkerAPI markerApi, MarkerSet markerset, AreaMarker marker) + { + // Corner Locations + if (!equals(marker, this.x, this.z)) + { + marker.setCornerLocations(this.x, this.z); + } + + // Label + if (!MUtil.equals(marker.getLabel(), this.label)) + { + marker.setLabel(this.label); + } + + // Description + if (!MUtil.equals(marker.getDescription(), this.description)) + { + marker.setDescription(this.description); + } + + // Line Style + if + ( + !MUtil.equals(marker.getLineWeight(), this.lineWeight) + || + !MUtil.equals(marker.getLineOpacity(), this.lineOpacity) + || + !MUtil.equals(marker.getLineColor(), this.lineColor) + ) + { + marker.setLineStyle(this.lineWeight, this.lineOpacity, this.lineColor); + } + + // Fill Style + if + ( + !MUtil.equals(marker.getFillOpacity(), this.fillOpacity) + || + !MUtil.equals(marker.getFillColor(), this.fillColor) + ) + { + marker.setFillStyle(this.fillOpacity, this.fillColor); + } + + // Boost Flag + if (!MUtil.equals(marker.getBoostFlag(), this.boost)) + { + marker.setBoostFlag(this.boost); + } + } + + // -------------------------------------------- // + // UTIL + // -------------------------------------------- // + + public static boolean equals(AreaMarker marker, double x[], double z[]) + { + int length = marker.getCornerCount(); + + if (x.length != length) return false; + if (z.length != length) return false; + + for (int i = 0; i < length; i++) + { + if (marker.getCornerX(i) != x[i]) return false; + if (marker.getCornerZ(i) != z[i]) return false; + } + + return true; + } + +} diff --git a/src/main/java/com/massivecraft/factions/integration/dynmap/TempMarker.java b/src/main/java/com/massivecraft/factions/integration/dynmap/TempMarker.java new file mode 100644 index 00000000..ce0a9980 --- /dev/null +++ b/src/main/java/com/massivecraft/factions/integration/dynmap/TempMarker.java @@ -0,0 +1,102 @@ +package com.massivecraft.factions.integration.dynmap; + +import org.dynmap.markers.Marker; +import org.dynmap.markers.MarkerAPI; +import org.dynmap.markers.MarkerIcon; +import org.dynmap.markers.MarkerSet; + +import com.massivecraft.factions.entity.MConf; +import com.massivecraft.massivecore.util.MUtil; + +public class TempMarker +{ + // -------------------------------------------- // + // FIELDS + // -------------------------------------------- // + + public String label; + public String world; + public double x; + public double y; + public double z; + public String iconName; + public String description; + + // -------------------------------------------- // + // CREATE + // -------------------------------------------- // + + public Marker create(MarkerAPI markerApi, MarkerSet markerset, String markerId) + { + Marker ret = markerset.createMarker( + markerId, + this.label, + this.world, + this.x, + this.y, + this.z, + getMarkerIcon(markerApi, this.iconName), + false // not persistent + ); + + if (ret == null) return null; + + ret.setDescription(this.description); + + return ret; + } + + // -------------------------------------------- // + // UPDATE + // -------------------------------------------- // + + public void update(MarkerAPI markerApi, MarkerSet markerset, Marker marker) + { + if + ( + marker.getWorld() != this.world + || + marker.getX() != this.x + || + marker.getY() != this.y + || + marker.getZ() != this.z + ) + { + marker.setLocation( + this.world, + this.x, + this.y, + this.z + ); + } + + if (!MUtil.equals(marker.getLabel(), this.label)) + { + marker.setLabel(this.label); + } + + MarkerIcon icon = getMarkerIcon(markerApi, this.iconName); + if (!MUtil.equals(marker.getMarkerIcon(), icon)) + { + marker.setMarkerIcon(icon); + } + + if (!MUtil.equals(marker.getDescription(), this.description)) + { + marker.setDescription(this.description); + } + } + + // -------------------------------------------- // + // UTIL + // -------------------------------------------- // + + public static MarkerIcon getMarkerIcon(MarkerAPI markerApi, String name) + { + MarkerIcon ret = markerApi.getMarkerIcon(name); + if (ret == null) ret = markerApi.getMarkerIcon(MConf.DYNMAP_STYLE_HOME_MARKER); + return ret; + } + +} diff --git a/src/main/java/com/massivecraft/factions/integration/dynmap/TempMarkerSet.java b/src/main/java/com/massivecraft/factions/integration/dynmap/TempMarkerSet.java new file mode 100644 index 00000000..50390e61 --- /dev/null +++ b/src/main/java/com/massivecraft/factions/integration/dynmap/TempMarkerSet.java @@ -0,0 +1,78 @@ +package com.massivecraft.factions.integration.dynmap; + +import org.dynmap.markers.MarkerAPI; +import org.dynmap.markers.MarkerSet; + +import com.massivecraft.massivecore.util.MUtil; + +public class TempMarkerSet +{ + // -------------------------------------------- // + // FIELDS + // -------------------------------------------- // + + public String label; + public int minimumZoom; + public int priority; + public boolean hideByDefault; + + // -------------------------------------------- // + // CREATE + // -------------------------------------------- // + + public MarkerSet create(MarkerAPI markerApi, String id) + { + MarkerSet ret = markerApi.createMarkerSet(id, this.label, null, false); // ("null, false" at the end means "all icons allowed, not perisistent") + + if (ret == null) return null; + + // Minimum Zoom + if (this.minimumZoom > 0) + { + ret.setMinZoom(this.minimumZoom); + } + + // Priority + ret.setLayerPriority(this.priority); + + // Hide by Default + ret.setHideByDefault(this.hideByDefault); + + return ret; + } + + // -------------------------------------------- // + // UPDATE + // -------------------------------------------- // + + public void update(MarkerAPI markerApi, MarkerSet markerset) + { + // Name + if (!MUtil.equals(markerset.getMarkerSetLabel(), this.label)) + { + markerset.setMarkerSetLabel(this.label); + } + + // Minimum Zoom + if (this.minimumZoom > 0) + { + if (!MUtil.equals(markerset.getMinZoom(), this.minimumZoom)) + { + markerset.setMinZoom(this.minimumZoom); + } + } + + // Priority + if (!MUtil.equals(markerset.getLayerPriority(), this.priority)) + { + markerset.setLayerPriority(this.priority); + } + + // Hide by Default + if (!MUtil.equals(markerset.getHideByDefault(), this.hideByDefault)) + { + markerset.setHideByDefault(this.hideByDefault); + } + } + +} diff --git a/src/com/massivecraft/factions/integration/herochat/FactionsChannelAbstract.java b/src/main/java/com/massivecraft/factions/integration/herochat/ChannelFactionsAbstract.java similarity index 96% rename from src/com/massivecraft/factions/integration/herochat/FactionsChannelAbstract.java rename to src/main/java/com/massivecraft/factions/integration/herochat/ChannelFactionsAbstract.java index 2c9449bf..1412d33b 100644 --- a/src/com/massivecraft/factions/integration/herochat/FactionsChannelAbstract.java +++ b/src/main/java/com/massivecraft/factions/integration/herochat/ChannelFactionsAbstract.java @@ -26,7 +26,7 @@ import com.massivecraft.factions.Rel; import com.massivecraft.factions.entity.UPlayer; import com.massivecraft.factions.entity.Faction; -public abstract class FactionsChannelAbstract implements Channel +public abstract class ChannelFactionsAbstract implements Channel { private static final Pattern msgPattern = Pattern.compile("(.*)<(.*)%1\\$s(.*)> %2\\$s"); private final ChannelStorage storage = Herochat.getChannelManager().getStorage(); diff --git a/src/com/massivecraft/factions/integration/herochat/AlliesChannel.java b/src/main/java/com/massivecraft/factions/integration/herochat/ChannelFactionsAllies.java similarity index 95% rename from src/com/massivecraft/factions/integration/herochat/AlliesChannel.java rename to src/main/java/com/massivecraft/factions/integration/herochat/ChannelFactionsAllies.java index 03b0820a..eea95905 100644 --- a/src/com/massivecraft/factions/integration/herochat/AlliesChannel.java +++ b/src/main/java/com/massivecraft/factions/integration/herochat/ChannelFactionsAllies.java @@ -8,7 +8,7 @@ import org.bukkit.ChatColor; import com.massivecraft.factions.Rel; import com.massivecraft.factions.entity.MConf; -public class AlliesChannel extends FactionsChannelAbstract +public class ChannelFactionsAllies extends ChannelFactionsAbstract { public static final Set targetRelations = EnumSet.of(Rel.MEMBER, Rel.RECRUIT, Rel.ALLY); @Override public Set getTargetRelations() { return targetRelations; } diff --git a/src/com/massivecraft/factions/integration/herochat/FactionChannel.java b/src/main/java/com/massivecraft/factions/integration/herochat/ChannelFactionsFaction.java similarity index 95% rename from src/com/massivecraft/factions/integration/herochat/FactionChannel.java rename to src/main/java/com/massivecraft/factions/integration/herochat/ChannelFactionsFaction.java index 318760a3..4d783dea 100644 --- a/src/com/massivecraft/factions/integration/herochat/FactionChannel.java +++ b/src/main/java/com/massivecraft/factions/integration/herochat/ChannelFactionsFaction.java @@ -9,7 +9,7 @@ import org.bukkit.ChatColor; import com.massivecraft.factions.Rel; import com.massivecraft.factions.entity.MConf; -public class FactionChannel extends FactionsChannelAbstract +public class ChannelFactionsFaction extends ChannelFactionsAbstract { public static final Set targetRelations = EnumSet.of(Rel.MEMBER, Rel.RECRUIT); @Override public Set getTargetRelations() { return targetRelations; } diff --git a/src/com/massivecraft/factions/integration/herochat/HerochatEngine.java b/src/main/java/com/massivecraft/factions/integration/herochat/EngineHerochat.java similarity index 80% rename from src/com/massivecraft/factions/integration/herochat/HerochatEngine.java rename to src/main/java/com/massivecraft/factions/integration/herochat/EngineHerochat.java index 61d4214d..66792016 100644 --- a/src/com/massivecraft/factions/integration/herochat/HerochatEngine.java +++ b/src/main/java/com/massivecraft/factions/integration/herochat/EngineHerochat.java @@ -13,15 +13,15 @@ import com.massivecraft.factions.chat.ChatFormatter; import com.massivecraft.factions.entity.MConf; -public class HerochatEngine implements Listener +public class EngineHerochat implements Listener { // -------------------------------------------- // // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static HerochatEngine i = new HerochatEngine(); - public static HerochatEngine get() { return i; } - private HerochatEngine() {} + private static EngineHerochat i = new EngineHerochat(); + public static EngineHerochat get() { return i; } + private EngineHerochat() {} // -------------------------------------------- // // ACTIVATE & DEACTIVATE @@ -29,8 +29,8 @@ public class HerochatEngine implements Listener public void activate() { - Herochat.getChannelManager().addChannel(new FactionChannel()); - Herochat.getChannelManager().addChannel(new AlliesChannel()); + Herochat.getChannelManager().addChannel(new ChannelFactionsFaction()); + Herochat.getChannelManager().addChannel(new ChannelFactionsAllies()); Bukkit.getPluginManager().registerEvents(this, Factions.get()); } diff --git a/src/main/java/com/massivecraft/factions/integration/herochat/IntegrationHerochat.java b/src/main/java/com/massivecraft/factions/integration/herochat/IntegrationHerochat.java new file mode 100644 index 00000000..3b70dee9 --- /dev/null +++ b/src/main/java/com/massivecraft/factions/integration/herochat/IntegrationHerochat.java @@ -0,0 +1,31 @@ +package com.massivecraft.factions.integration.herochat; + +import com.massivecraft.massivecore.integration.IntegrationAbstract; + +public class IntegrationHerochat extends IntegrationAbstract +{ + // -------------------------------------------- // + // INSTANCE & CONSTRUCT + // -------------------------------------------- // + + private static IntegrationHerochat i = new IntegrationHerochat(); + public static IntegrationHerochat get() { return i; } + private IntegrationHerochat() { super("Herochat"); } + + // -------------------------------------------- // + // OVERRIDE + // -------------------------------------------- // + + @Override + public void activate() + { + EngineHerochat.get().activate(); + } + + @Override + public void deactivate() + { + EngineHerochat.get().deactivate(); + } + +} diff --git a/src/com/massivecraft/factions/integration/lwc/LwcEngine.java b/src/main/java/com/massivecraft/factions/integration/lwc/EngineLwc.java similarity index 83% rename from src/com/massivecraft/factions/integration/lwc/LwcEngine.java rename to src/main/java/com/massivecraft/factions/integration/lwc/EngineLwc.java index a375ae03..c484cf5a 100644 --- a/src/com/massivecraft/factions/integration/lwc/LwcEngine.java +++ b/src/main/java/com/massivecraft/factions/integration/lwc/EngineLwc.java @@ -19,20 +19,20 @@ import com.massivecraft.factions.Factions; import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.UConf; import com.massivecraft.factions.entity.UPlayer; -import com.massivecraft.factions.event.FactionsEventChunkChange; -import com.massivecraft.factions.event.FactionsEventChunkChangeType; -import com.massivecraft.mcore.ps.PS; +import com.massivecraft.factions.event.EventFactionsChunkChange; +import com.massivecraft.factions.event.EventFactionsChunkChangeType; +import com.massivecraft.massivecore.ps.PS; -public class LwcEngine implements Listener +public class EngineLwc implements Listener { // -------------------------------------------- // // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static LwcEngine i = new LwcEngine(); - public static LwcEngine get() { return i; } - private LwcEngine() {} + private static EngineLwc i = new EngineLwc(); + public static EngineLwc get() { return i; } + private EngineLwc() {} // -------------------------------------------- // // ACTIVATE & DEACTIVATE @@ -53,12 +53,12 @@ public class LwcEngine implements Listener // -------------------------------------------- // @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) - public void removeProtectionsOnChunkChange(FactionsEventChunkChange event) + public void removeProtectionsOnChunkChange(EventFactionsChunkChange event) { // If we are supposed to clear at this chunk change type ... Faction newFaction = event.getNewFaction(); UConf uconf = UConf.get(newFaction); - FactionsEventChunkChangeType type = event.getType(); + EventFactionsChunkChangeType type = event.getType(); Boolean remove = uconf.lwcRemoveOnChange.get(type); if (remove == null) return; if (remove == false) return; diff --git a/src/com/massivecraft/factions/integration/lwc/LwcFeatures.java b/src/main/java/com/massivecraft/factions/integration/lwc/IntegrationLwc.java similarity index 51% rename from src/com/massivecraft/factions/integration/lwc/LwcFeatures.java rename to src/main/java/com/massivecraft/factions/integration/lwc/IntegrationLwc.java index 1e1b524c..ac5764c5 100644 --- a/src/com/massivecraft/factions/integration/lwc/LwcFeatures.java +++ b/src/main/java/com/massivecraft/factions/integration/lwc/IntegrationLwc.java @@ -1,16 +1,16 @@ package com.massivecraft.factions.integration.lwc; -import com.massivecraft.mcore.integration.IntegrationFeaturesAbstract; +import com.massivecraft.massivecore.integration.IntegrationAbstract; -public class LwcFeatures extends IntegrationFeaturesAbstract +public class IntegrationLwc extends IntegrationAbstract { // -------------------------------------------- // // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static LwcFeatures i = new LwcFeatures(); - public static LwcFeatures get() { return i; } - private LwcFeatures() { super("LWC"); } + private static IntegrationLwc i = new IntegrationLwc(); + public static IntegrationLwc get() { return i; } + private IntegrationLwc() { super("LWC"); } // -------------------------------------------- // // OVERRIDE @@ -19,13 +19,13 @@ public class LwcFeatures extends IntegrationFeaturesAbstract @Override public void activate() { - LwcEngine.get().activate(); + EngineLwc.get().activate(); } @Override public void deactivate() { - LwcEngine.get().deactivate(); + EngineLwc.get().deactivate(); } } diff --git a/src/com/massivecraft/factions/listeners/FactionsListenerChat.java b/src/main/java/com/massivecraft/factions/listeners/FactionsListenerChat.java similarity index 67% rename from src/com/massivecraft/factions/listeners/FactionsListenerChat.java rename to src/main/java/com/massivecraft/factions/listeners/FactionsListenerChat.java index 7b3a84b6..79cdc06f 100644 --- a/src/com/massivecraft/factions/listeners/FactionsListenerChat.java +++ b/src/main/java/com/massivecraft/factions/listeners/FactionsListenerChat.java @@ -3,6 +3,7 @@ package com.massivecraft.factions.listeners; import org.bukkit.Bukkit; import org.bukkit.event.Event; import org.bukkit.event.EventException; +import org.bukkit.event.EventPriority; import org.bukkit.event.HandlerList; import org.bukkit.event.Listener; import org.bukkit.event.player.AsyncPlayerChatEvent; @@ -11,6 +12,7 @@ import org.bukkit.plugin.EventExecutor; import com.massivecraft.factions.Factions; import com.massivecraft.factions.chat.ChatFormatter; import com.massivecraft.factions.entity.MConf; +import com.massivecraft.massivecore.event.EventMassiveCorePlayerToRecipientChat; public class FactionsListenerChat implements Listener { @@ -38,6 +40,12 @@ public class FactionsListenerChat implements Listener { Bukkit.getPluginManager().registerEvent(AsyncPlayerChatEvent.class, this, MConf.get().chatParseTagsAt, new ParseTagsEventExecutor(), Factions.get(), true); } + + if (MConf.get().chatParseTags) + { + Bukkit.getPluginManager().registerEvent(EventMassiveCorePlayerToRecipientChat.class, this, EventPriority.NORMAL, new ParseRelcolorEventExecutor(), Factions.get(), true); + } + } // -------------------------------------------- // @@ -51,7 +59,7 @@ public class FactionsListenerChat implements Listener { try { - if (!AsyncPlayerChatEvent.class.isAssignableFrom(event.getClass())) return; + if (!(event instanceof AsyncPlayerChatEvent)) return; setFormat((AsyncPlayerChatEvent)event); } catch (Throwable t) @@ -62,7 +70,7 @@ public class FactionsListenerChat implements Listener } public static void setFormat(AsyncPlayerChatEvent event) - { + { event.setFormat(MConf.get().chatSetFormatTo); } @@ -77,7 +85,7 @@ public class FactionsListenerChat implements Listener { try { - if (!AsyncPlayerChatEvent.class.isAssignableFrom(event.getClass())) return; + if (!(event instanceof AsyncPlayerChatEvent)) return; parseTags((AsyncPlayerChatEvent)event); } catch (Throwable t) @@ -94,4 +102,32 @@ public class FactionsListenerChat implements Listener event.setFormat(format); } + // -------------------------------------------- // + // PARSE RELCOLOR + // -------------------------------------------- // + + private class ParseRelcolorEventExecutor implements EventExecutor + { + @Override + public void execute(Listener listener, Event event) throws EventException + { + try + { + if (!(event instanceof EventMassiveCorePlayerToRecipientChat)) return; + parseRelcolor((EventMassiveCorePlayerToRecipientChat)event); + } + catch (Throwable t) + { + throw new EventException(t); + } + } + } + + public static void parseRelcolor(EventMassiveCorePlayerToRecipientChat event) + { + String format = event.getFormat(); + format = ChatFormatter.format(format, event.getSender(), event.getRecipient()); + event.setFormat(format); + } + } diff --git a/src/com/massivecraft/factions/listeners/FactionsListenerEcon.java b/src/main/java/com/massivecraft/factions/listeners/FactionsListenerEcon.java similarity index 73% rename from src/com/massivecraft/factions/listeners/FactionsListenerEcon.java rename to src/main/java/com/massivecraft/factions/listeners/FactionsListenerEcon.java index 7fd0fc12..9ba35a97 100644 --- a/src/com/massivecraft/factions/listeners/FactionsListenerEcon.java +++ b/src/main/java/com/massivecraft/factions/listeners/FactionsListenerEcon.java @@ -9,23 +9,23 @@ import com.massivecraft.factions.Factions; import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.UConf; import com.massivecraft.factions.entity.UPlayer; -import com.massivecraft.factions.event.FactionsEventAbstractSender; -import com.massivecraft.factions.event.FactionsEventChunkChange; -import com.massivecraft.factions.event.FactionsEventChunkChangeType; -import com.massivecraft.factions.event.FactionsEventCreate; -import com.massivecraft.factions.event.FactionsEventDescriptionChange; -import com.massivecraft.factions.event.FactionsEventDisband; -import com.massivecraft.factions.event.FactionsEventHomeChange; -import com.massivecraft.factions.event.FactionsEventHomeTeleport; -import com.massivecraft.factions.event.FactionsEventInvitedChange; -import com.massivecraft.factions.event.FactionsEventMembershipChange; -import com.massivecraft.factions.event.FactionsEventMembershipChange.MembershipChangeReason; -import com.massivecraft.factions.event.FactionsEventOpenChange; -import com.massivecraft.factions.event.FactionsEventRelationChange; -import com.massivecraft.factions.event.FactionsEventNameChange; -import com.massivecraft.factions.event.FactionsEventTitleChange; +import com.massivecraft.factions.event.EventFactionsAbstractSender; +import com.massivecraft.factions.event.EventFactionsChunkChange; +import com.massivecraft.factions.event.EventFactionsChunkChangeType; +import com.massivecraft.factions.event.EventFactionsCreate; +import com.massivecraft.factions.event.EventFactionsDescriptionChange; +import com.massivecraft.factions.event.EventFactionsDisband; +import com.massivecraft.factions.event.EventFactionsHomeChange; +import com.massivecraft.factions.event.EventFactionsHomeTeleport; +import com.massivecraft.factions.event.EventFactionsInvitedChange; +import com.massivecraft.factions.event.EventFactionsMembershipChange; +import com.massivecraft.factions.event.EventFactionsMembershipChange.MembershipChangeReason; +import com.massivecraft.factions.event.EventFactionsNameChange; +import com.massivecraft.factions.event.EventFactionsOpenChange; +import com.massivecraft.factions.event.EventFactionsRelationChange; +import com.massivecraft.factions.event.EventFactionsTitleChange; import com.massivecraft.factions.integration.Econ; -import com.massivecraft.mcore.money.Money; +import com.massivecraft.massivecore.money.Money; public class FactionsListenerEcon implements Listener { @@ -51,7 +51,7 @@ public class FactionsListenerEcon implements Listener // -------------------------------------------- // @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) - public void takeOnLeave(FactionsEventMembershipChange event) + public void takeOnLeave(EventFactionsMembershipChange event) { // If a player is leaving the faction ... if (event.getReason() != MembershipChangeReason.LEAVE) return; @@ -70,7 +70,7 @@ public class FactionsListenerEcon implements Listener // -------------------------------------------- // @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) - public void takeOnDisband(FactionsEventDisband event) + public void takeOnDisband(EventFactionsDisband event) { // If there is a usender ... UPlayer usender = event.getUSender(); @@ -83,9 +83,9 @@ public class FactionsListenerEcon implements Listener Faction faction = event.getFaction(); double amount = Money.get(faction); - String amountString = Money.format(faction, amount); + String amountString = Money.format(amount); - Econ.transferMoney(usender, faction, usender, amount, true); + Econ.transferMoney(faction, usender, usender, amount, true); usender.msg("You have been given the disbanded faction's bank, totaling %s.", amountString); Factions.get().log(usender.getName() + " has been given bank holdings of "+amountString+" from disbanding "+faction.getName()+"."); @@ -95,7 +95,7 @@ public class FactionsListenerEcon implements Listener // PAY FOR ACTION // -------------------------------------------- // - public static void payForAction(FactionsEventAbstractSender event, Double cost, String desc) + public static void payForAction(EventFactionsAbstractSender event, Double cost, String desc) { // If there is a sender ... UPlayer usender = event.getUSender(); @@ -113,11 +113,11 @@ public class FactionsListenerEcon implements Listener } @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) - public void payForAction(FactionsEventChunkChange event) + public void payForAction(EventFactionsChunkChange event) { Faction newFaction = event.getNewFaction(); UConf uconf = UConf.get(newFaction); - FactionsEventChunkChangeType type = event.getType(); + EventFactionsChunkChangeType type = event.getType(); Double cost = uconf.econChunkCost.get(type); String desc = type.toString().toLowerCase() + " this land"; @@ -126,7 +126,7 @@ public class FactionsListenerEcon implements Listener } @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) - public void payForAction(FactionsEventMembershipChange event) + public void payForAction(EventFactionsMembershipChange event) { Double cost = null; String desc = null; @@ -158,7 +158,7 @@ public class FactionsListenerEcon implements Listener } @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) - public void payForCommand(FactionsEventRelationChange event) + public void payForCommand(EventFactionsRelationChange event) { Double cost = UConf.get(event.getSender()).econRelCost.get(event.getNewRelation()); String desc = Factions.get().getOuterCmdFactions().cmdFactionsRelationNeutral.getDesc(); @@ -167,7 +167,7 @@ public class FactionsListenerEcon implements Listener } @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) - public void payForCommand(FactionsEventHomeChange event) + public void payForCommand(EventFactionsHomeChange event) { Double cost = UConf.get(event.getSender()).econCostSethome; String desc = Factions.get().getOuterCmdFactions().cmdFactionsSethome.getDesc(); @@ -176,7 +176,7 @@ public class FactionsListenerEcon implements Listener } @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) - public void payForCommand(FactionsEventCreate event) + public void payForCommand(EventFactionsCreate event) { Double cost = UConf.get(event.getSender()).econCostCreate; String desc = Factions.get().getOuterCmdFactions().cmdFactionsCreate.getDesc(); @@ -185,7 +185,7 @@ public class FactionsListenerEcon implements Listener } @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) - public void payForCommand(FactionsEventDescriptionChange event) + public void payForCommand(EventFactionsDescriptionChange event) { Double cost = UConf.get(event.getSender()).econCostDescription; String desc = Factions.get().getOuterCmdFactions().cmdFactionsDescription.getDesc(); @@ -194,7 +194,7 @@ public class FactionsListenerEcon implements Listener } @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) - public void payForCommand(FactionsEventNameChange event) + public void payForCommand(EventFactionsNameChange event) { Double cost = UConf.get(event.getSender()).econCostName; String desc = Factions.get().getOuterCmdFactions().cmdFactionsName.getDesc(); @@ -203,7 +203,7 @@ public class FactionsListenerEcon implements Listener } @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) - public void payForCommand(FactionsEventTitleChange event) + public void payForCommand(EventFactionsTitleChange event) { Double cost = UConf.get(event.getSender()).econCostTitle; String desc = Factions.get().getOuterCmdFactions().cmdFactionsTitle.getDesc(); @@ -212,7 +212,7 @@ public class FactionsListenerEcon implements Listener } @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) - public void payForCommand(FactionsEventOpenChange event) + public void payForCommand(EventFactionsOpenChange event) { Double cost = UConf.get(event.getSender()).econCostOpen; String desc = Factions.get().getOuterCmdFactions().cmdFactionsOpen.getDesc(); @@ -221,7 +221,7 @@ public class FactionsListenerEcon implements Listener } @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) - public void payForCommand(FactionsEventInvitedChange event) + public void payForCommand(EventFactionsInvitedChange event) { Double cost = event.isNewInvited() ? UConf.get(event.getSender()).econCostInvite : UConf.get(event.getSender()).econCostDeinvite; String desc = Factions.get().getOuterCmdFactions().cmdFactionsInvite.getDesc(); @@ -230,7 +230,7 @@ public class FactionsListenerEcon implements Listener } @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) - public void payForCommand(FactionsEventHomeTeleport event) + public void payForCommand(EventFactionsHomeTeleport event) { Double cost = UConf.get(event.getSender()).econCostHome; String desc = Factions.get().getOuterCmdFactions().cmdFactionsHome.getDesc(); diff --git a/src/com/massivecraft/factions/listeners/FactionsListenerExploit.java b/src/main/java/com/massivecraft/factions/listeners/FactionsListenerExploit.java similarity index 98% rename from src/com/massivecraft/factions/listeners/FactionsListenerExploit.java rename to src/main/java/com/massivecraft/factions/listeners/FactionsListenerExploit.java index 24971ea2..16574323 100644 --- a/src/com/massivecraft/factions/listeners/FactionsListenerExploit.java +++ b/src/main/java/com/massivecraft/factions/listeners/FactionsListenerExploit.java @@ -41,6 +41,7 @@ public class FactionsListenerExploit implements Listener // OBSIDIAN GENERATORS // -------------------------------------------- // + @SuppressWarnings("deprecation") @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void obsidianGenerators(BlockFromToEvent event) { @@ -52,7 +53,7 @@ public class FactionsListenerExploit implements Listener int target = block.getTypeId(); if ((target == 55 || target == 132) && (source == 0 || source == 10 || source == 11)) { - block.setTypeId(0); + block.setType(Material.AIR); } } @@ -106,6 +107,7 @@ public class FactionsListenerExploit implements Listener // this optional change below provides workaround for waterwalling providing perfect protection, // and makes cheap (non-obsidian) TNT cannons require minor maintenance between shots + @SuppressWarnings("deprecation") @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void tntWaterlog(EntityExplodeEvent event) { diff --git a/src/com/massivecraft/factions/listeners/FactionsListenerMain.java b/src/main/java/com/massivecraft/factions/listeners/FactionsListenerMain.java similarity index 74% rename from src/com/massivecraft/factions/listeners/FactionsListenerMain.java rename to src/main/java/com/massivecraft/factions/listeners/FactionsListenerMain.java index a1fbd963..7225d903 100644 --- a/src/com/massivecraft/factions/listeners/FactionsListenerMain.java +++ b/src/main/java/com/massivecraft/factions/listeners/FactionsListenerMain.java @@ -2,8 +2,10 @@ package com.massivecraft.factions.listeners; import java.text.MessageFormat; import java.util.Collection; +import java.util.HashMap; import java.util.Iterator; import java.util.List; +import java.util.Map; import org.bukkit.Bukkit; import org.bukkit.Location; @@ -12,9 +14,9 @@ import org.bukkit.block.Block; import org.bukkit.entity.Enderman; import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; +import org.bukkit.entity.ItemFrame; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; -import org.bukkit.entity.Projectile; import org.bukkit.entity.Wither; import org.bukkit.event.Cancellable; import org.bukkit.event.EventHandler; @@ -49,8 +51,9 @@ import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerKickEvent; import org.bukkit.event.player.PlayerMoveEvent; +import org.bukkit.event.player.PlayerRespawnEvent; +import org.bukkit.projectiles.ProjectileSource; -import com.massivecraft.factions.Const; import com.massivecraft.factions.FFlag; import com.massivecraft.factions.FPerm; import com.massivecraft.factions.Factions; @@ -63,12 +66,14 @@ import com.massivecraft.factions.entity.MConf; import com.massivecraft.factions.entity.UConf; import com.massivecraft.factions.entity.UPlayerColl; import com.massivecraft.factions.entity.UPlayerColls; -import com.massivecraft.factions.event.FactionsEventPowerChange; -import com.massivecraft.factions.event.FactionsEventPowerChange.PowerChangeReason; +import com.massivecraft.factions.event.EventFactionsPvpDisallowed; +import com.massivecraft.factions.event.EventFactionsPowerChange; +import com.massivecraft.factions.event.EventFactionsPowerChange.PowerChangeReason; import com.massivecraft.factions.util.VisualizeUtil; -import com.massivecraft.mcore.ps.PS; -import com.massivecraft.mcore.util.MUtil; -import com.massivecraft.mcore.util.Txt; +import com.massivecraft.massivecore.ps.PS; +import com.massivecraft.massivecore.util.MUtil; +import com.massivecraft.massivecore.util.PlayerUtil; +import com.massivecraft.massivecore.util.Txt; public class FactionsListenerMain implements Listener { @@ -186,6 +191,10 @@ public class FactionsListenerMain implements Listener // If a player dies ... Player player = event.getEntity(); + // ... and this is the first death event this tick ... + // (yeah other plugins can case death event to fire twice the same tick) + if (PlayerUtil.isDuplicateDeathEvent(event)) return; + // Check Disabled if (UConf.isDisabled(player)) return; @@ -200,7 +209,7 @@ public class FactionsListenerMain implements Listener return; } - if (MConf.get().worldsNoPowerLoss.contains(player.getWorld().getName())) + if (MConf.get().getWorldsNoPowerLoss().contains(player.getWorld().getName())) { uplayer.msg("You didn't lose any power due to the world you died in."); return; @@ -209,7 +218,7 @@ public class FactionsListenerMain implements Listener // ... alter the power ... double newPower = uplayer.getPower() + uplayer.getPowerPerDeath(); - FactionsEventPowerChange powerChangeEvent = new FactionsEventPowerChange(null, uplayer, PowerChangeReason.DEATH, newPower); + EventFactionsPowerChange powerChangeEvent = new EventFactionsPowerChange(null, uplayer, PowerChangeReason.DEATH, newPower); powerChangeEvent.run(); if (powerChangeEvent.isCancelled()) return; newPower = powerChangeEvent.getNewPower(); @@ -251,7 +260,10 @@ public class FactionsListenerMain implements Listener // If a harmful potion is splashing ... if (!MUtil.isHarmfulPotion(event.getPotion())) return; - Entity thrower = event.getPotion().getShooter(); + ProjectileSource projectileSource = event.getPotion().getShooter(); + if (! (projectileSource instanceof Entity)) return; + + Entity thrower = (Entity)projectileSource; // ... scan through affected entities to make sure they're all valid targets. for (LivingEntity affectedEntity : event.getAffectedEntities()) @@ -264,24 +276,33 @@ public class FactionsListenerMain implements Listener } } + // Utility method used in "canCombatDamageHappen" below. + public static boolean falseUnlessDisallowedPvpEventCancelled(Player attacker, Player defender, EntityDamageByEntityEvent event) + { + EventFactionsPvpDisallowed dpe = new EventFactionsPvpDisallowed(attacker, defender, event); + dpe.run(); + return dpe.isCancelled(); + } + public boolean canCombatDamageHappen(EntityDamageByEntityEvent event, boolean notify) - { + { + boolean ret = true; + // If the defender is a player ... Entity edefender = event.getEntity(); if (!(edefender instanceof Player)) return true; Player defender = (Player)edefender; - UPlayer fdefender = UPlayer.get(edefender); + UPlayer udefender = UPlayer.get(edefender); // Check Disabled if (UConf.isDisabled(defender)) return true; // ... and the attacker is someone else ... - Entity eattacker = event.getDamager(); - if (eattacker instanceof Projectile) - { - eattacker = ((Projectile)eattacker).getShooter(); - } - if (eattacker.equals(edefender)) return true; + Entity eattacker = MUtil.getLiableDamager(event); + + // (we check null here since there may not be an attacker) + // (lack of attacker situations can be caused by other bukkit plugins) + if (eattacker != null && eattacker.equals(edefender)) return true; // ... gather defender PS and faction information ... PS defenderPs = PS.valueOf(defender); @@ -290,14 +311,21 @@ public class FactionsListenerMain implements Listener // ... PVP flag may cause a damage block ... if (defenderPsFaction.getFlag(FFlag.PVP) == false) { + if (eattacker == null) + { + // No attacker? + // Let's behave as if it were a player + return falseUnlessDisallowedPvpEventCancelled(null, defender, event); + } if (eattacker instanceof Player) { - if (notify) + ret = falseUnlessDisallowedPvpEventCancelled((Player)eattacker, defender, event); + if (!ret && notify) { UPlayer attacker = UPlayer.get(eattacker); attacker.msg("PVP is disabled in %s.", defenderPsFaction.describeTo(attacker)); } - return false; + return ret; } return defenderPsFaction.getFlag(FFlag.MONSTERS); } @@ -305,7 +333,7 @@ public class FactionsListenerMain implements Listener // ... and if the attacker is a player ... if (!(eattacker instanceof Player)) return true; Player attacker = (Player)eattacker; - UPlayer fattacker = UPlayer.get(attacker); + UPlayer uattacker = UPlayer.get(attacker); // ... does this player bypass all protection? ... if (MConf.get().playersWhoBypassAllProtection.contains(attacker.getName())) return true; @@ -319,21 +347,23 @@ public class FactionsListenerMain implements Listener // NOTE: This check is probably not that important but we could keep it anyways. if (attackerPsFaction.getFlag(FFlag.PVP) == false) { - if (notify) fattacker.msg("PVP is disabled in %s.", attackerPsFaction.describeTo(fattacker)); - return false; + ret = falseUnlessDisallowedPvpEventCancelled(attacker, defender, event); + if (!ret && notify) uattacker.msg("PVP is disabled in %s.", attackerPsFaction.describeTo(uattacker)); + return ret; } // ... are PVP rules completely ignored in this world? ... - if (MConf.get().worldsIgnorePvP.contains(defenderPs.getWorld())) return true; + if (MConf.get().getWorldsIgnlorePvP().contains(defenderPs.getWorld())) return true; - Faction defendFaction = fdefender.getFaction(); - Faction attackFaction = fattacker.getFaction(); + Faction defendFaction = udefender.getFaction(); + Faction attackFaction = uattacker.getFaction(); UConf uconf = UConf.get(attackFaction); if (attackFaction.isNone() && uconf.disablePVPForFactionlessPlayers) { - if (notify) fattacker.msg("You can't hurt other players until you join a faction."); - return false; + ret = falseUnlessDisallowedPvpEventCancelled(attacker, defender, event); + if (!ret && notify) uattacker.msg("You can't hurt other players until you join a faction."); + return ret; } else if (defendFaction.isNone()) { @@ -344,44 +374,48 @@ public class FactionsListenerMain implements Listener } else if (uconf.disablePVPForFactionlessPlayers) { - if (notify) fattacker.msg("You can't hurt players who are not currently in a faction."); - return false; + ret = falseUnlessDisallowedPvpEventCancelled(attacker, defender, event); + if (!ret && notify) uattacker.msg("You can't hurt players who are not currently in a faction."); + return ret; } } Rel relation = defendFaction.getRelationTo(attackFaction); // Check the relation - if (fdefender.hasFaction() && relation.isFriend() && defenderPsFaction.getFlag(FFlag.FRIENDLYFIRE) == false) + if (udefender.hasFaction() && relation.isFriend() && defenderPsFaction.getFlag(FFlag.FRIENDLYFIRE) == false) { - if (notify) fattacker.msg("You can't hurt %s.", relation.getDescPlayerMany()); - return false; + ret = falseUnlessDisallowedPvpEventCancelled(attacker, defender, event); + if (!ret && notify) uattacker.msg("You can't hurt %s.", relation.getDescPlayerMany()); + return ret; } // You can not hurt neutrals in their own territory. - boolean ownTerritory = fdefender.isInOwnTerritory(); - if (fdefender.hasFaction() && ownTerritory && relation == Rel.NEUTRAL) + boolean ownTerritory = udefender.isInOwnTerritory(); + + if (udefender.hasFaction() && ownTerritory && relation == Rel.NEUTRAL) { - if (notify) + ret = falseUnlessDisallowedPvpEventCancelled(attacker, defender, event); + if (!ret && notify) { - fattacker.msg("You can't hurt %s in their own territory unless you declare them as an enemy.", fdefender.describeTo(fattacker)); - fdefender.msg("%s tried to hurt you.", fattacker.describeTo(fdefender, true)); + uattacker.msg("You can't hurt %s in their own territory unless you declare them as an enemy.", udefender.describeTo(uattacker)); + udefender.msg("%s tried to hurt you.", uattacker.describeTo(udefender, true)); } - return false; + return ret; } // Damage will be dealt. However check if the damage should be reduced. double damage = event.getDamage(); - if (damage > 0.0 && fdefender.hasFaction() && ownTerritory && uconf.territoryShieldFactor > 0) + if (damage > 0.0 && udefender.hasFaction() && ownTerritory && uconf.territoryShieldFactor > 0) { - int newDamage = (int)Math.ceil(damage * (1D - uconf.territoryShieldFactor)); + double newDamage = damage * (1D - uconf.territoryShieldFactor); event.setDamage(newDamage); // Send message if (notify) { String perc = MessageFormat.format("{0,number,#%}", (uconf.territoryShieldFactor)); // TODO does this display correctly?? - fdefender.msg("Enemy damage reduced by %s.", perc); + udefender.msg("Enemy damage reduced by %s.", perc); } } @@ -399,7 +433,8 @@ public class FactionsListenerMain implements Listener Player player = event.getPlayer(); // ... and if the if player was banned (not just kicked) ... - if (!event.getReason().equals("Banned by admin.")) return; + //if (!event.getReason().equals("Banned by admin.")) return; + if (!player.isBanned()) return; // ... and we remove player data when banned ... if (!MConf.get().removePlayerDataWhenBanned) return; @@ -466,7 +501,7 @@ public class FactionsListenerMain implements Listener // ... if there is a faction at the players location ... PS ps = PS.valueOf(player).getChunk(true); Faction factionAtPs = BoardColls.get().getFactionAt(ps); - if (factionAtPs.isNone()) return; + if (factionAtPs.isNone()) return; // TODO: An NPE can arise here? Why? // ... the command may be denied in the territory of this relation type ... Rel rel = factionAtPs.getRelationTo(uplayer); @@ -475,7 +510,7 @@ public class FactionsListenerMain implements Listener if (deniedCommands == null) return; if (!containsCommand(command, deniedCommands)) return; - uplayer.msg("You can't use \"/%s\" in %s territory.", Txt.getNicedEnum(rel), command); + uplayer.msg("You can't use \"/%s\" in %s territory.", command, Txt.getNicedEnum(rel)); event.setCancelled(true); } @@ -505,7 +540,7 @@ public class FactionsListenerMain implements Listener public void blockMonsters(CreatureSpawnEvent event) { // If a monster is spawning ... - if ( ! Const.ENTITY_TYPES_MONSTERS.contains(event.getEntityType())) return; + if ( ! MConf.get().entityTypesMonsters.contains(event.getEntityType())) return; // Check Disabled if (UConf.isDisabled(event.getLocation())) return; @@ -523,7 +558,7 @@ public class FactionsListenerMain implements Listener public void blockMonsters(EntityTargetEvent event) { // If a monster ... - if ( ! Const.ENTITY_TYPES_MONSTERS.contains(event.getEntityType())) return; + if ( ! MConf.get().entityTypesMonsters.contains(event.getEntityType())) return; // ... is targeting something ... Entity target = event.getTarget(); @@ -564,7 +599,7 @@ public class FactionsListenerMain implements Listener // ... and the faction there has explosions disabled ... Faction faction = BoardColls.get().getFactionAt(PS.valueOf(entity)); - if (faction.getFlag(FFlag.EXPLOSIONS)) return; + if (faction.isExplosionsAllowed()) return; // ... then cancel. event.setCancelled(true); @@ -573,6 +608,14 @@ public class FactionsListenerMain implements Listener @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void blockExplosion(EntityExplodeEvent event) { + // Prepare some variables: + // Current faction + Faction faction = null; + // Current allowed + Boolean allowed = true; + // Caching to speed things up. + Map faction2allowed = new HashMap(); + // If an explosion occurs at a location ... Location location = event.getLocation(); @@ -580,19 +623,29 @@ public class FactionsListenerMain implements Listener if (UConf.isDisabled(location)) return; // Check the entity. Are explosions disabled there? - if (BoardColls.get().getFactionAt(PS.valueOf(location)).getFlag(FFlag.EXPLOSIONS) == false) + faction = BoardColls.get().getFactionAt(PS.valueOf(location)); + allowed = faction.isExplosionsAllowed(); + if (allowed == false) { event.setCancelled(true); return; } + faction2allowed.put(faction, allowed); // Individually check the flag state for each block Iterator iter = event.blockList().iterator(); while (iter.hasNext()) { Block block = iter.next(); - Faction faction = BoardColls.get().getFactionAt(PS.valueOf(block)); - if (faction.getFlag(FFlag.EXPLOSIONS) == false) iter.remove(); + faction = BoardColls.get().getFactionAt(PS.valueOf(block)); + allowed = faction2allowed.get(faction); + if (allowed == null) + { + allowed = faction.isExplosionsAllowed(); + faction2allowed.put(faction, allowed); + } + + if (allowed == false) iter.remove(); } } @@ -609,7 +662,8 @@ public class FactionsListenerMain implements Listener // ... and the faction there has explosions disabled ... PS ps = PS.valueOf(event.getBlock()); Faction faction = BoardColls.get().getFactionAt(ps); - if (faction.getFlag(FFlag.EXPLOSIONS)) return; + + if (faction.isExplosionsAllowed()) return; // ... stop the block alteration. event.setCancelled(true); @@ -672,7 +726,7 @@ public class FactionsListenerMain implements Listener public void blockFireSpread(BlockSpreadEvent event) { // If fire is spreading ... - if (event.getNewState().getTypeId() != 51) return; + if (event.getNewState().getType() != Material.FIRE) return; // ... consider blocking it. blockFireSpread(event.getBlock(), event); @@ -736,6 +790,26 @@ public class FactionsListenerMain implements Listener } } + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void itemFrameDamage(EntityDamageByEntityEvent event) + { + // If the damagee is an ItemFrame ... + Entity edamagee = event.getEntity(); + if (!(edamagee instanceof ItemFrame)) return; + ItemFrame itemFrame = (ItemFrame)edamagee; + + // ... and the liable damager is a player ... + Entity edamager = MUtil.getLiableDamager(event); + if (!(edamager instanceof Player)) return; + Player player = (Player)edamager; + + // ... and the player can't build there ... + if (canPlayerBuildAt(player, PS.valueOf(itemFrame), true)) return; + + // ... then cancel the event. + event.setCancelled(true); + } + @EventHandler(priority = EventPriority.NORMAL) public void blockBuild(BlockPlaceEvent event) { @@ -850,7 +924,7 @@ public class FactionsListenerMain implements Listener // TODO: Possibly incorporate pain build... public static boolean playerCanUseItemHere(Player player, PS ps, Material material, boolean justCheck) { - if (!Const.MATERIALS_EDIT_TOOLS.contains(material)) return true; + if (!MConf.get().materialsEditTools.contains(material)) return true; String name = player.getName(); if (MConf.get().playersWhoBypassAllProtection.contains(name)) return true; @@ -872,9 +946,9 @@ public class FactionsListenerMain implements Listener PS ps = PS.valueOf(block); Material material = block.getType(); - if (Const.MATERIALS_EDIT_ON_INTERACT.contains(material) && ! FPerm.BUILD.has(me, ps, ! justCheck)) return false; - if (Const.MATERIALS_CONTAINER.contains(material) && ! FPerm.CONTAINER.has(me, ps, ! justCheck)) return false; - if (Const.MATERIALS_DOOR.contains(material) && ! FPerm.DOOR.has(me, ps, ! justCheck)) return false; + if (MConf.get().materialsEditOnInteract.contains(material) && ! FPerm.BUILD.has(me, ps, ! justCheck)) return false; + if (MConf.get().materialsContainer.contains(material) && ! FPerm.CONTAINER.has(me, ps, ! justCheck)) return false; + if (MConf.get().materialsDoor.contains(material) && ! FPerm.DOOR.has(me, ps, ! justCheck)) return false; if (material == Material.STONE_BUTTON && ! FPerm.BUTTON.has(me, ps, ! justCheck)) return false; if (material == Material.LEVER && ! FPerm.LEVER.has(me, ps, ! justCheck)) return false; return true; @@ -904,4 +978,80 @@ public class FactionsListenerMain implements Listener event.setCancelled(true); } + // -------------------------------------------- // + // TELEPORT TO HOME ON DEATH + // -------------------------------------------- // + + public void teleportToHomeOnDeath(PlayerRespawnEvent event, EventPriority priority) + { + // If a player is respawning ... + final Player player = event.getPlayer(); + final UPlayer uplayer = UPlayer.get(player); + final UConf uconf = UConf.get(player); + + // ... homes are enabled, active and at this priority ... + if (!uconf.homesEnabled) return; + if (!uconf.homesTeleportToOnDeathActive) return; + if (uconf.homesTeleportToOnDeathPriority != priority) return; + + // ... and the player has a faction ... + final Faction faction = uplayer.getFaction(); + if (faction.isNone()) return; + + // ... and the faction has a home ... + PS home = faction.getHome(); + if (home == null) return; + + // ... and the home is translatable ... + Location respawnLocation = null; + try + { + respawnLocation = home.asBukkitLocation(true); + } + catch (Exception e) + { + // The home location map may have been deleted + return; + } + + // ... then use it for the respawn location. + event.setRespawnLocation(respawnLocation); + } + + @EventHandler(priority = EventPriority.LOWEST) + public void teleportToHomeOnDeathLowest(PlayerRespawnEvent event) + { + this.teleportToHomeOnDeath(event, EventPriority.LOWEST); + } + + @EventHandler(priority = EventPriority.LOW) + public void teleportToHomeOnDeathLow(PlayerRespawnEvent event) + { + this.teleportToHomeOnDeath(event, EventPriority.LOW); + } + + @EventHandler(priority = EventPriority.NORMAL) + public void teleportToHomeOnDeathNormal(PlayerRespawnEvent event) + { + this.teleportToHomeOnDeath(event, EventPriority.NORMAL); + } + + @EventHandler(priority = EventPriority.HIGH) + public void teleportToHomeOnDeathHigh(PlayerRespawnEvent event) + { + this.teleportToHomeOnDeath(event, EventPriority.HIGH); + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void teleportToHomeOnDeathHighest(PlayerRespawnEvent event) + { + this.teleportToHomeOnDeath(event, EventPriority.HIGHEST); + } + + @EventHandler(priority = EventPriority.MONITOR) + public void teleportToHomeOnDeathMonitor(PlayerRespawnEvent event) + { + this.teleportToHomeOnDeath(event, EventPriority.MONITOR); + } + } diff --git a/src/com/massivecraft/factions/mixin/PowerMixin.java b/src/main/java/com/massivecraft/factions/mixin/PowerMixin.java similarity index 100% rename from src/com/massivecraft/factions/mixin/PowerMixin.java rename to src/main/java/com/massivecraft/factions/mixin/PowerMixin.java diff --git a/src/com/massivecraft/factions/mixin/PowerMixinDefault.java b/src/main/java/com/massivecraft/factions/mixin/PowerMixinDefault.java similarity index 100% rename from src/com/massivecraft/factions/mixin/PowerMixinDefault.java rename to src/main/java/com/massivecraft/factions/mixin/PowerMixinDefault.java diff --git a/src/com/massivecraft/factions/task/SpiralTask.java b/src/main/java/com/massivecraft/factions/task/SpiralTask.java similarity index 99% rename from src/com/massivecraft/factions/task/SpiralTask.java rename to src/main/java/com/massivecraft/factions/task/SpiralTask.java index a5dcbcc2..da23f79b 100644 --- a/src/com/massivecraft/factions/task/SpiralTask.java +++ b/src/main/java/com/massivecraft/factions/task/SpiralTask.java @@ -7,7 +7,7 @@ import org.bukkit.Location; import org.bukkit.World; import com.massivecraft.factions.Factions; -import com.massivecraft.mcore.ps.PS; +import com.massivecraft.massivecore.ps.PS; /* diff --git a/src/com/massivecraft/factions/task/TaskEconLandReward.java b/src/main/java/com/massivecraft/factions/task/TaskEconLandReward.java similarity index 91% rename from src/com/massivecraft/factions/task/TaskEconLandReward.java rename to src/main/java/com/massivecraft/factions/task/TaskEconLandReward.java index 82301dc0..365c3492 100644 --- a/src/com/massivecraft/factions/task/TaskEconLandReward.java +++ b/src/main/java/com/massivecraft/factions/task/TaskEconLandReward.java @@ -4,8 +4,8 @@ import com.massivecraft.factions.entity.FactionColl; import com.massivecraft.factions.entity.FactionColls; import com.massivecraft.factions.entity.MConf; import com.massivecraft.factions.entity.UConf; -import com.massivecraft.mcore.ModuloRepeatTask; -import com.massivecraft.mcore.util.TimeUnit; +import com.massivecraft.massivecore.ModuloRepeatTask; +import com.massivecraft.massivecore.util.TimeUnit; public class TaskEconLandReward extends ModuloRepeatTask { diff --git a/src/com/massivecraft/factions/task/TaskPlayerDataRemove.java b/src/main/java/com/massivecraft/factions/task/TaskPlayerDataRemove.java similarity index 92% rename from src/com/massivecraft/factions/task/TaskPlayerDataRemove.java rename to src/main/java/com/massivecraft/factions/task/TaskPlayerDataRemove.java index ae44854c..e006ba99 100644 --- a/src/com/massivecraft/factions/task/TaskPlayerDataRemove.java +++ b/src/main/java/com/massivecraft/factions/task/TaskPlayerDataRemove.java @@ -4,8 +4,8 @@ import com.massivecraft.factions.entity.MConf; import com.massivecraft.factions.entity.UConf; import com.massivecraft.factions.entity.UPlayerColl; import com.massivecraft.factions.entity.UPlayerColls; -import com.massivecraft.mcore.ModuloRepeatTask; -import com.massivecraft.mcore.util.TimeUnit; +import com.massivecraft.massivecore.ModuloRepeatTask; +import com.massivecraft.massivecore.util.TimeUnit; public class TaskPlayerDataRemove extends ModuloRepeatTask { diff --git a/src/com/massivecraft/factions/task/TaskPlayerPowerUpdate.java b/src/main/java/com/massivecraft/factions/task/TaskPlayerPowerUpdate.java similarity index 84% rename from src/com/massivecraft/factions/task/TaskPlayerPowerUpdate.java rename to src/main/java/com/massivecraft/factions/task/TaskPlayerPowerUpdate.java index afa70b67..ac1d8885 100644 --- a/src/com/massivecraft/factions/task/TaskPlayerPowerUpdate.java +++ b/src/main/java/com/massivecraft/factions/task/TaskPlayerPowerUpdate.java @@ -6,10 +6,10 @@ import org.bukkit.entity.Player; import com.massivecraft.factions.entity.MConf; import com.massivecraft.factions.entity.UConf; import com.massivecraft.factions.entity.UPlayer; -import com.massivecraft.factions.event.FactionsEventPowerChange; -import com.massivecraft.factions.event.FactionsEventPowerChange.PowerChangeReason; -import com.massivecraft.mcore.ModuloRepeatTask; -import com.massivecraft.mcore.util.TimeUnit; +import com.massivecraft.factions.event.EventFactionsPowerChange; +import com.massivecraft.factions.event.EventFactionsPowerChange.PowerChangeReason; +import com.massivecraft.massivecore.ModuloRepeatTask; +import com.massivecraft.massivecore.util.TimeUnit; public class TaskPlayerPowerUpdate extends ModuloRepeatTask { @@ -51,7 +51,7 @@ public class TaskPlayerPowerUpdate extends ModuloRepeatTask UPlayer uplayer = UPlayer.get(player); double newPower = uplayer.getPower() + uplayer.getPowerPerHour() * millis / TimeUnit.MILLIS_PER_HOUR; - FactionsEventPowerChange event = new FactionsEventPowerChange(null, uplayer, PowerChangeReason.TIME, newPower); + EventFactionsPowerChange event = new EventFactionsPowerChange(null, uplayer, PowerChangeReason.TIME, newPower); event.run(); if (event.isCancelled()) continue; newPower = event.getNewPower(); diff --git a/src/com/massivecraft/factions/util/AsciiCompass.java b/src/main/java/com/massivecraft/factions/util/AsciiCompass.java similarity index 100% rename from src/com/massivecraft/factions/util/AsciiCompass.java rename to src/main/java/com/massivecraft/factions/util/AsciiCompass.java diff --git a/src/com/massivecraft/factions/util/MiscUtil.java b/src/main/java/com/massivecraft/factions/util/MiscUtil.java similarity index 100% rename from src/com/massivecraft/factions/util/MiscUtil.java rename to src/main/java/com/massivecraft/factions/util/MiscUtil.java diff --git a/src/com/massivecraft/factions/util/RelationUtil.java b/src/main/java/com/massivecraft/factions/util/RelationUtil.java similarity index 94% rename from src/com/massivecraft/factions/util/RelationUtil.java rename to src/main/java/com/massivecraft/factions/util/RelationUtil.java index 2cb47981..baa10433 100644 --- a/src/com/massivecraft/factions/util/RelationUtil.java +++ b/src/main/java/com/massivecraft/factions/util/RelationUtil.java @@ -8,7 +8,7 @@ import com.massivecraft.factions.RelationParticipator; import com.massivecraft.factions.entity.UPlayer; import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.MConf; -import com.massivecraft.mcore.util.Txt; +import com.massivecraft.massivecore.util.Txt; public class RelationUtil { diff --git a/src/com/massivecraft/factions/util/VisualizeUtil.java b/src/main/java/com/massivecraft/factions/util/VisualizeUtil.java similarity index 80% rename from src/com/massivecraft/factions/util/VisualizeUtil.java rename to src/main/java/com/massivecraft/factions/util/VisualizeUtil.java index cf8213ff..0b04287b 100644 --- a/src/com/massivecraft/factions/util/VisualizeUtil.java +++ b/src/main/java/com/massivecraft/factions/util/VisualizeUtil.java @@ -6,6 +6,7 @@ import java.util.HashSet; import java.util.Map; import java.util.Map.Entry; import java.util.Set; +import java.util.UUID; import org.bukkit.Location; import org.bukkit.block.Block; @@ -17,18 +18,18 @@ import org.bukkit.entity.Player; public class VisualizeUtil { - protected static Map> playerLocations = new HashMap>(); + protected static Map> playerLocations = new HashMap>(); public static Set getPlayerLocations(Player player) { - return getPlayerLocations(player.getName()); + return getPlayerLocations(player.getUniqueId()); } - public static Set getPlayerLocations(String playerName) + public static Set getPlayerLocations(UUID uuid) { - Set ret = playerLocations.get(playerName); + Set ret = playerLocations.get(uuid); if (ret == null) { ret = new HashSet(); - playerLocations.put(playerName, ret); + playerLocations.put(uuid, ret); } return ret; } @@ -37,12 +38,14 @@ public class VisualizeUtil // SINGLE // -------------------------------------------- // + @SuppressWarnings("deprecation") public static void addLocation(Player player, Location location, int typeId, byte data) { getPlayerLocations(player).add(location); player.sendBlockChange(location, typeId, data); } + @SuppressWarnings("deprecation") public static void addLocation(Player player, Location location, int typeId) { getPlayerLocations(player).add(location); @@ -53,6 +56,7 @@ public class VisualizeUtil // MANY // -------------------------------------------- // + @SuppressWarnings("deprecation") public static void addLocations(Player player, Map locationMaterialIds) { Set ploc = getPlayerLocations(player); @@ -63,6 +67,7 @@ public class VisualizeUtil } } + @SuppressWarnings("deprecation") public static void addLocations(Player player, Collection locations, int typeId) { Set ploc = getPlayerLocations(player); @@ -73,6 +78,7 @@ public class VisualizeUtil } } + @SuppressWarnings("deprecation") public static void addBlocks(Player player, Collection blocks, int typeId) { Set ploc = getPlayerLocations(player); @@ -88,6 +94,7 @@ public class VisualizeUtil // CLEAR // -------------------------------------------- // + @SuppressWarnings("deprecation") public static void clear(Player player) { Set locations = getPlayerLocations(player); diff --git a/plugin.yml b/src/main/resources/plugin.yml similarity index 99% rename from plugin.yml rename to src/main/resources/plugin.yml index 58938411..200e72a1 100644 --- a/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,10 +1,10 @@ main: com.massivecraft.factions.Factions name: Factions -version: 2.0.3 +version: 2.6.0 website: http://massivecraft.com/factions authors: [Cayorion, Brettflan] description: §eFactions allows the players to team up and claim land as their own and start wars with other factions. This way we hope to inspire politics, intrigue, and team spirit. §aCayorion §efrom the minecraft server §aMassiveCraft §eis the lead Factions programmer. Feel free to visit us at §bhttp://massivecraft.com -depend: [mcore] +depend: [MassiveCore] softdepend: [PermissionsEx, Permissions, Essentials, EssentialsChat, HeroChat, iChat, LocalAreaChat, LWC, nChat, ChatManager, AuthMe, Vault, Spout, WorldEdit, WorldGuard, AuthDB, CaptureThePoints, CombatTag] permissions: # -------------------------------------------- #