diff --git a/lib/Essentials.jar b/lib/Essentials.jar deleted file mode 100644 index e5eb8479..00000000 Binary files a/lib/Essentials.jar and /dev/null differ diff --git a/lib/EssentialsChat_2.x.jar b/lib/EssentialsChat_2.x.jar deleted file mode 100644 index f4b54b72..00000000 Binary files a/lib/EssentialsChat_2.x.jar and /dev/null differ diff --git a/lib/EssentialsChat_3_dev.jar b/lib/EssentialsChat_3_dev.jar deleted file mode 100644 index ec0a3cfa..00000000 Binary files a/lib/EssentialsChat_3_dev.jar and /dev/null differ diff --git a/lib/MCore.jar b/lib/MCore.jar deleted file mode 100644 index 4cc81d78..00000000 Binary files a/lib/MCore.jar and /dev/null differ diff --git a/lib/craftbukkit.jar b/lib/craftbukkit.jar deleted file mode 100644 index 2dd04de2..00000000 Binary files a/lib/craftbukkit.jar and /dev/null differ diff --git a/src/com/massivecraft/factions/ConfServer.java b/src/com/massivecraft/factions/ConfServer.java index 710e6949..465bce4d 100644 --- a/src/com/massivecraft/factions/ConfServer.java +++ b/src/com/massivecraft/factions/ConfServer.java @@ -36,8 +36,10 @@ public class ConfServer extends SimpleConfig //public static ChatColor colorWilderness = ChatColor.DARK_GREEN; public static Map factionFlagDefaults; - public static Map factionFlagIsChangeable; + //public static Map factionFlagIsChangeable; public static Map> factionPermDefaults; + + // TODO: Shouldn't this be a constant rather? public static Rel factionRankDefault = Rel.RECRUIT; // Power @@ -108,6 +110,10 @@ public class ConfServer extends SimpleConfig public static String herochatAllyName = "Allies"; + // TODO: Does anyone toggle this feature on I wonder? + // It could work for small servers but never for big ones. + // Why not conform to big server setups at once? + // POSSIBLY: Remove this option public static boolean broadcastDescriptionChanges = false; public static double autoLeaveAfterDaysOfInactivity = 10.0; @@ -140,18 +146,15 @@ public class ConfServer extends SimpleConfig public static boolean homesEnabled = true; public static boolean homesMustBeInClaimedTerritory = true; - public static boolean homesTeleportToOnDeath = true; - public static boolean homesRespawnFromNoPowerLossWorlds = true; public static boolean homesTeleportCommandEnabled = true; - public static boolean homesTeleportCommandEssentialsIntegration = true; - public static boolean homesTeleportCommandSmokeEffectEnabled = true; public static boolean homesTeleportAllowedFromEnemyTerritory = true; public static boolean homesTeleportAllowedFromDifferentWorld = true; public static double homesTeleportAllowedEnemyDistance = 32.0; public static boolean homesTeleportIgnoreEnemiesIfInOwnTerritory = true; - + // TODO: This one should not be in the config should it? It should be built into the enum? public static Rel friendlyFireFromRel = Rel.TRUCE; + public static boolean disablePVPForFactionlessPlayers = false; public static boolean enablePVPAgainstFactionlessInAttackersLand = false; @@ -261,6 +264,8 @@ public class ConfServer extends SimpleConfig public static Set playersWhoBypassAllProtection = new LinkedHashSet(); public static Set worldsNoClaiming = new LinkedHashSet(); + + // TODO: Should worldsNoPowerLoss rather be a bukkit permission node? public static Set worldsNoPowerLoss = new LinkedHashSet(); public static Set worldsIgnorePvP = new LinkedHashSet(); // TODO: A better solution Would be to have One wilderness faction per world. diff --git a/src/com/massivecraft/factions/Faction.java b/src/com/massivecraft/factions/Faction.java index 4a506559..9c4a7361 100644 --- a/src/com/massivecraft/factions/Faction.java +++ b/src/com/massivecraft/factions/Faction.java @@ -5,7 +5,6 @@ import java.util.Map.Entry; import org.bukkit.Bukkit; import org.bukkit.ChatColor; -import org.bukkit.Location; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -73,31 +72,12 @@ public class Faction extends Entity implements EconomyParticipator private Map relationWish = null; - // FIELD: home - // TODO: Use a PS instead! - private LazyLocation home; - public void setHome(Location home) { this.home = new LazyLocation(home); } - public boolean hasHome() { return this.getHome() != null; } - public Location getHome() - { - confirmValidHome(); - return (this.home != null) ? this.home.getLocation() : null; - } - public void confirmValidHome() - { - if (!ConfServer.homesMustBeInClaimedTerritory || this.home == null || (this.home.getLocation() != null && BoardColl.get().getFactionAt(PS.valueOf(this.home.getLocation())) == this)) - return; - - msg("Your faction home has been un-set since it is no longer in your territory."); - this.home = null; - } + private PS home = null; - // FIELD: cape - private String cape; - public String getCape() { return cape; } - public void setCape(String val) { this.cape = val; SpoutFeatures.updateCape(this, null); } + // The cape field is a URL used by the Spout integration features. + private String cape = null; - // The powerBoost is a custom increase/decrease to default and max power for this faction + // The powerBoost is a custom increase/decrease to default and max power for this faction. private Double powerBoost = null; // The flag overrides are the modifications to the default values @@ -455,6 +435,58 @@ public class Faction extends Entity implements EconomyParticipator this.deinvite(fplayer.getId()); } + // -------------------------------------------- // + // FIELD: home + // -------------------------------------------- // + + // TODO: Checkery is a bit weird? + + public PS getHome() + { + this.verifyHomeIsValid(); + return this.home; + } + + public void verifyHomeIsValid() + { + if (this.isValidHome(this.home)) return; + this.home = null; + msg("Your faction home has been un-set since it is no longer in your territory."); + } + + public boolean isValidHome(PS ps) + { + if (ps == null) return true; + if (!ConfServer.homesMustBeInClaimedTerritory) return true; + if (BoardColl.get().getFactionAt(ps) == this) return true; + return false; + } + + public boolean hasHome() + { + return this.getHome() != null; + } + + public void setHome(PS home) + { + this.home = home; + } + + // -------------------------------------------- // + // FIELD: cape + // -------------------------------------------- // + + public String getCape() + { + return cape; + } + + public void setCape(String cape) + { + this.cape = cape; + SpoutFeatures.updateCape(this, null); + } + // -------------------------------------------- // // FIELD: powerBoost // -------------------------------------------- // diff --git a/src/com/massivecraft/factions/Factions.java b/src/com/massivecraft/factions/Factions.java index 88f5ec46..c08c4bd8 100644 --- a/src/com/massivecraft/factions/Factions.java +++ b/src/com/massivecraft/factions/Factions.java @@ -4,13 +4,11 @@ import com.massivecraft.factions.adapters.BoardAdapter; import com.massivecraft.factions.adapters.BoardMapAdapter; import com.massivecraft.factions.adapters.FFlagAdapter; import com.massivecraft.factions.adapters.FPermAdapter; -import com.massivecraft.factions.adapters.LazyLocationAdapter; import com.massivecraft.factions.adapters.RelAdapter; import com.massivecraft.factions.adapters.TerritoryAccessAdapter; import com.massivecraft.factions.cmd.*; import com.massivecraft.factions.integration.herochat.HerochatFeatures; import com.massivecraft.factions.integration.Econ; -import com.massivecraft.factions.integration.EssentialsFeatures; import com.massivecraft.factions.integration.LWCFeatures; import com.massivecraft.factions.integration.SpoutFeatures; import com.massivecraft.factions.integration.Worldguard; @@ -21,7 +19,6 @@ import com.massivecraft.factions.listeners.FactionsExploitListener; import com.massivecraft.factions.listeners.FactionsPlayerListener; import com.massivecraft.factions.util.AutoLeaveTask; import com.massivecraft.factions.util.EconLandRewardTask; -import com.massivecraft.factions.util.LazyLocation; import com.massivecraft.mcore.MPlugin; import com.massivecraft.mcore.xlib.gson.GsonBuilder; @@ -77,7 +74,6 @@ public class Factions extends MPlugin this.outerCmdFactions = new CmdFactions(); this.outerCmdFactions.register(this); - EssentialsFeatures.setup(); SpoutFeatures.setup(); Econ.setup(); HerochatFeatures.setup(); @@ -119,7 +115,6 @@ public class Factions extends MPlugin public GsonBuilder getGsonBuilder() { return super.getGsonBuilder() - .registerTypeAdapter(LazyLocation.class, new LazyLocationAdapter()) .registerTypeAdapter(TerritoryAccess.class, TerritoryAccessAdapter.get()) .registerTypeAdapter(Board.class, BoardAdapter.get()) .registerTypeAdapter(Board.MAP_TYPE, BoardMapAdapter.get()) @@ -132,7 +127,6 @@ public class Factions extends MPlugin @Override public void onDisable() { - EssentialsFeatures.unhookChat(); if (AutoLeaveTask != null) { this.getServer().getScheduler().cancelTask(AutoLeaveTask); diff --git a/src/com/massivecraft/factions/TerritoryAccess.java b/src/com/massivecraft/factions/TerritoryAccess.java index 086399f3..c2621190 100644 --- a/src/com/massivecraft/factions/TerritoryAccess.java +++ b/src/com/massivecraft/factions/TerritoryAccess.java @@ -3,6 +3,7 @@ package com.massivecraft.factions; import java.util.LinkedHashSet; import java.util.Set; +import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; public class TerritoryAccess @@ -98,7 +99,7 @@ public class TerritoryAccess { if (testSubject instanceof String) return hostFactionId.equals((String)testSubject); - else if (testSubject instanceof Player) + else if (testSubject instanceof CommandSender) return hostFactionId.equals(FPlayerColl.get().get(testSubject).getFactionId()); else if (testSubject instanceof FPlayer) return hostFactionId.equals(((FPlayer)testSubject).getFactionId()); diff --git a/src/com/massivecraft/factions/adapters/LazyLocationAdapter.java b/src/com/massivecraft/factions/adapters/LazyLocationAdapter.java deleted file mode 100644 index bf8449ac..00000000 --- a/src/com/massivecraft/factions/adapters/LazyLocationAdapter.java +++ /dev/null @@ -1,74 +0,0 @@ -package com.massivecraft.factions.adapters; - -import java.lang.reflect.Type; -import java.util.logging.Level; - -import com.massivecraft.factions.Factions; -import com.massivecraft.factions.util.LazyLocation; - -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; - - -public class LazyLocationAdapter implements JsonDeserializer, JsonSerializer -{ - private static final String WORLD = "world"; - private static final String X = "x"; - private static final String Y = "y"; - private static final String Z = "z"; - private static final String YAW = "yaw"; - private static final String PITCH = "pitch"; - - @Override - public LazyLocation deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException - { - try - { - JsonObject obj = json.getAsJsonObject(); - - String worldName = obj.get(WORLD).getAsString(); - double x = obj.get(X).getAsDouble(); - double y = obj.get(Y).getAsDouble(); - double z = obj.get(Z).getAsDouble(); - float yaw = obj.get(YAW).getAsFloat(); - float pitch = obj.get(PITCH).getAsFloat(); - - return new LazyLocation(worldName, x, y, z, yaw, pitch); - - } - catch (Exception ex) - { - ex.printStackTrace(); - Factions.get().log(Level.WARNING, "Error encountered while deserializing a LazyLocation."); - return null; - } - } - - @Override - public JsonElement serialize(LazyLocation src, Type typeOfSrc, JsonSerializationContext context) { - JsonObject obj = new JsonObject(); - - try - { - obj.addProperty(WORLD, src.getWorldName()); - obj.addProperty(X, src.getX()); - obj.addProperty(Y, src.getY()); - obj.addProperty(Z, src.getZ()); - obj.addProperty(YAW, src.getYaw()); - obj.addProperty(PITCH, src.getPitch()); - - return obj; - } - catch (Exception ex) - { - ex.printStackTrace(); - Factions.get().log(Level.WARNING, "Error encountered while serializing a LazyLocation."); - return obj; - } - } -} diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsHome.java b/src/com/massivecraft/factions/cmd/CmdFactionsHome.java index 8359dd1f..83722f2b 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsHome.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsHome.java @@ -1,8 +1,5 @@ package com.massivecraft.factions.cmd; -import java.util.ArrayList; -import java.util.List; - import org.bukkit.Location; import org.bukkit.World; import org.bukkit.entity.Player; @@ -17,11 +14,11 @@ import com.massivecraft.factions.Factions; import com.massivecraft.factions.Perm; import com.massivecraft.factions.Rel; import com.massivecraft.factions.cmd.req.ReqRoleIsAtLeast; -import com.massivecraft.factions.integration.EssentialsFeatures; 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.mcore.util.SmokeUtil; public class CmdFactionsHome extends FCommand @@ -64,7 +61,7 @@ public class CmdFactionsHome extends FCommand return; } - if ( ! ConfServer.homesTeleportAllowedFromDifferentWorld && me.getWorld().getUID() != myFaction.getHome().getWorld().getUID()) + if (!ConfServer.homesTeleportAllowedFromDifferentWorld && !me.getWorld().getName().equalsIgnoreCase(myFaction.getHome().getWorld())) { fme.msg("You cannot teleport to your faction home while in a different world."); return; @@ -121,24 +118,17 @@ public class CmdFactionsHome extends FCommand } } - // if Essentials teleport handling is enabled and available, pass the teleport off to it (for delay and cooldown) - if (EssentialsFeatures.handleTeleport(me, myFaction.getHome())) return; - - // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay - if ( ! payForCommand(ConfServer.econCostHome, "to teleport to your faction home", "for teleporting to your faction home")) return; - - // Create a smoke effect - if (ConfServer.homesTeleportCommandSmokeEffectEnabled) + try { - List smokeLocations = new ArrayList(); - smokeLocations.add(loc); - smokeLocations.add(loc.add(0, 1, 0)); - smokeLocations.add(myFaction.getHome()); - smokeLocations.add(myFaction.getHome().clone().add(0, 1, 0)); - SmokeUtil.spawnCloudRandom(smokeLocations, 3f); + Mixin.teleport(me, myFaction.getHome(), "your faction home", sender); + + // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay + if ( ! payForCommand(ConfServer.econCostHome, "to teleport to your faction home", "for teleporting to your faction home")) return; + } + catch (TeleporterException e) + { + me.sendMessage(e.getMessage()); } - - me.teleport(myFaction.getHome()); } } diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsSethome.java b/src/com/massivecraft/factions/cmd/CmdFactionsSethome.java index 0e6afbc8..5b6cc1d5 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsSethome.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsSethome.java @@ -1,6 +1,5 @@ package com.massivecraft.factions.cmd; -import com.massivecraft.factions.BoardColl; import com.massivecraft.factions.ConfServer; import com.massivecraft.factions.FPerm; import com.massivecraft.factions.Faction; @@ -26,6 +25,7 @@ public class CmdFactionsSethome extends FCommand @Override public void perform() { + // TODO: Make a command REQ instead? if ( ! ConfServer.homesEnabled) { fme.msg("Sorry, Faction homes are disabled on this server."); @@ -35,18 +35,13 @@ public class CmdFactionsSethome extends FCommand Faction faction = this.arg(0, ARFaction.get(), myFaction); if (faction == null) return; - // Can the player set the home for this faction? + // Has faction permission? if ( ! FPerm.SETHOME.has(sender, faction, true)) return; + PS ps = PS.valueOf(me.getLocation()); + // Can the player set the faction home HERE? - if - ( - ! fme.isUsingAdminMode() - && - ConfServer.homesMustBeInClaimedTerritory - && - BoardColl.get().getFactionAt(PS.valueOf(me)) != faction - ) + if (!fme.isUsingAdminMode() && !faction.isValidHome(ps)) { fme.msg("Sorry, your faction home can only be set inside your own claimed territory."); return; @@ -55,7 +50,7 @@ public class CmdFactionsSethome extends FCommand // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay if ( ! payForCommand(ConfServer.econCostSethome, "to set the faction home", "for setting the faction home")) return; - faction.setHome(me.getLocation()); + faction.setHome(ps); faction.msg("%s set the home for your faction. You can now use:", fme.describeTo(myFaction, true)); faction.sendMessage(Factions.get().getOuterCmdFactions().cmdFactionsHome.getUseageTemplate()); diff --git a/src/com/massivecraft/factions/integration/EssentialsFeatures.java b/src/com/massivecraft/factions/integration/EssentialsFeatures.java deleted file mode 100644 index de646447..00000000 --- a/src/com/massivecraft/factions/integration/EssentialsFeatures.java +++ /dev/null @@ -1,119 +0,0 @@ -package com.massivecraft.factions.integration; - -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; -import org.bukkit.Location; -import org.bukkit.plugin.Plugin; - -import com.massivecraft.factions.ConfServer; -import com.massivecraft.factions.Factions; -import com.massivecraft.factions.listeners.FactionsChatListener; - -import com.earth2me.essentials.IEssentials; -import com.earth2me.essentials.Teleport; -import com.earth2me.essentials.Trade; -import com.earth2me.essentials.chat.EssentialsChat; -import com.earth2me.essentials.chat.EssentialsLocalChatEvent; - - -/* - * This Essentials integration handler is for newer 3.x.x versions of Essentials which don't have "IEssentialsChatListener" - * If an older version is detected in the setup() method below, handling is passed off to EssentialsOldVersionFeatures - */ - -// silence deprecation warnings with this old interface -@SuppressWarnings("deprecation") -public class EssentialsFeatures -{ - private static EssentialsChat essChat; - private static IEssentials essentials; - - public static void setup() - { - // integrate main essentials plugin - // TODO: this is the old Essentials method not supported in 3.0... probably needs to eventually be moved to EssentialsOldVersionFeatures and new method implemented - if (essentials == null) - { - Plugin ess = Bukkit.getPluginManager().getPlugin("Essentials"); - if (ess != null && ess.isEnabled()) - essentials = (IEssentials)ess; - } - - // integrate chat - if (essChat != null) return; - - Plugin test = Bukkit.getServer().getPluginManager().getPlugin("EssentialsChat"); - if (test == null || !test.isEnabled()) return; - - essChat = (EssentialsChat)test; - - // try newer Essentials 3.x integration method - try - { - Class.forName("com.earth2me.essentials.chat.EssentialsLocalChatEvent"); - integrateChat(essChat); - } - catch (ClassNotFoundException ex) - { - - } - } - - public static void unhookChat() - { - if (essChat == null) return; - } - - // return false if feature is disabled or Essentials isn't available - public static boolean handleTeleport(Player player, Location loc) - { - if ( ! ConfServer.homesTeleportCommandEssentialsIntegration || essentials == null) return false; - - Teleport teleport = (Teleport) essentials.getUser(player).getTeleport(); - Trade trade = new Trade(ConfServer.econCostHome, essentials); - try - { - teleport.teleport(loc, trade); - } - catch (Exception e) - { - player.sendMessage(ChatColor.RED.toString()+e.getMessage()); - } - return true; - } - - - public static void integrateChat(EssentialsChat instance) - { - essChat = instance; - try - { - Bukkit.getServer().getPluginManager().registerEvents(new LocalChatListener(), Factions.get()); - Factions.get().log("Found and will integrate chat with newer "+essChat.getDescription().getFullName()); - } - catch (NoSuchMethodError ex) - { - essChat = null; - } - } - - private static class LocalChatListener implements Listener - { - @EventHandler(priority = EventPriority.NORMAL) - public void onPlayerChat(EssentialsLocalChatEvent event) - { - Player speaker = event.getPlayer(); - String format = event.getFormat(); - - format = FactionsChatListener.parseTags(format, speaker); - - event.setFormat(format); - // NOTE: above doesn't do relation coloring. if/when we can get a local recipient list from EssentialsLocalChatEvent, we'll probably - // want to pass it on to FactionsPlayerListener.onPlayerChat(PlayerChatEvent event) rather than duplicating code - } - } -} diff --git a/src/com/massivecraft/factions/integration/SpoutFeatures.java b/src/com/massivecraft/factions/integration/SpoutFeatures.java index cade4d32..14439496 100644 --- a/src/com/massivecraft/factions/integration/SpoutFeatures.java +++ b/src/com/massivecraft/factions/integration/SpoutFeatures.java @@ -81,6 +81,7 @@ public class SpoutFeatures String cape = faction.getCape(); if (cape == null) { + // TODO: This URL is outdated? cape = "http://s3.amazonaws.com/MinecraftCloaks/" + player.getName() + ".png"; } diff --git a/src/com/massivecraft/factions/listeners/FactionsPlayerListener.java b/src/com/massivecraft/factions/listeners/FactionsPlayerListener.java index 1bc2b8c0..087e1ce1 100644 --- a/src/com/massivecraft/factions/listeners/FactionsPlayerListener.java +++ b/src/com/massivecraft/factions/listeners/FactionsPlayerListener.java @@ -21,7 +21,6 @@ import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerKickEvent; import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.event.player.PlayerRespawnEvent; import org.bukkit.util.NumberConversions; import com.massivecraft.factions.BoardColl; @@ -227,33 +226,6 @@ public class FactionsPlayerListener implements Listener return true; } - @EventHandler(priority = EventPriority.HIGH) - public void onPlayerRespawn(PlayerRespawnEvent event) - { - FPlayer me = FPlayerColl.get().get(event.getPlayer()); - - me.getPower(); // update power, so they won't have gained any while dead - - Location home = me.getFaction().getHome(); // TODO: WARNING FOR NPE HERE THE ORIO FOR RESPAWN SHOULD BE ASSIGNABLE FROM CONFIG. - if - ( - ConfServer.homesEnabled - && - ConfServer.homesTeleportToOnDeath - && - home != null - && - ( - ConfServer.homesRespawnFromNoPowerLossWorlds - || - ! ConfServer.worldsNoPowerLoss.contains(event.getPlayer().getWorld().getName()) - ) - ) - { - event.setRespawnLocation(home); - } - } - // For some reason onPlayerInteract() sometimes misses bucket events depending on distance (something like 2-3 blocks away isn't detected), // but these separate bucket events below always fire without fail @EventHandler(priority = EventPriority.NORMAL)