From 76d1bc0e9b78b30b672e9678eec6e0ea4191b65a Mon Sep 17 00:00:00 2001 From: Naman Date: Sat, 7 Apr 2018 16:29:24 -0500 Subject: [PATCH] SavageFactions 1.0.23 Ability to remove items from main menu in perms for choosing roles/relations by setting the slot to -1 Changed placeholder identifier back because hooks in many plugins broke :( Removed debug message from warzone fly. Changed public modifiers on relation back, as they broke the method signature. --- .../com/massivecraft/factions/cmd/CmdFly.java | 128 ++++++++++-------- .../factions/iface/EconomyParticipator.java | 6 +- .../factions/iface/RelationParticipator.java | 10 +- .../util/ClipPlaceholderAPIManager.java | 4 +- .../fperms/gui/PermissableRelationGUI.java | 3 + .../zcore/fupgrades/CropUpgrades.java | 6 +- .../factions/zcore/persist/MemoryFPlayer.java | 14 +- src/main/resources/lang.yml | 2 +- src/main/resources/plugin.yml | 2 +- 9 files changed, 90 insertions(+), 85 deletions(-) diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFly.java b/src/main/java/com/massivecraft/factions/cmd/CmdFly.java index bf5daed0..29c0b9e6 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFly.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFly.java @@ -6,6 +6,8 @@ import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Relation; import com.massivecraft.factions.util.Particles.ParticleEffect; import com.massivecraft.factions.util.WarmUpUtil; +import com.massivecraft.factions.zcore.fperms.Access; +import com.massivecraft.factions.zcore.fperms.PermissableAction; import com.massivecraft.factions.zcore.util.TL; import org.bukkit.Bukkit; import org.bukkit.GameMode; @@ -59,42 +61,49 @@ public class CmdFly extends FCommand { flyid = Bukkit.getScheduler().scheduleSyncRepeatingTask(P.p, new Runnable() { @Override public void run() { - for (String name : flyMap.keySet()) { - Player player = Bukkit.getPlayer(name); - if (player == null) { - continue; - } - if (!player.isFlying()) { - continue; - } - FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player); + checkTaskState(); + if (flyMap.keySet().size() != 0) { + for (String name : flyMap.keySet()) { + if (name == null) { + continue; + } + Player player = Bukkit.getPlayer(name); + if (player == null) { + continue; + } + if (!player.isFlying()) { + continue; + } + FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player); - if (fPlayer == null) { - continue; - } - if (player.getGameMode() == GameMode.CREATIVE || player.getGameMode() == GameMode.SPECTATOR) { - continue; - } - Faction myFaction = fPlayer.getFaction(); - if (myFaction.isWilderness()) { - fPlayer.setFlying(false); - flyMap.remove(name); - continue; - } - if (fPlayer.checkIfNearbyEnemies()) { - continue; - } - FLocation myFloc = new FLocation(player.getLocation()); - Faction toFac = Board.getInstance().getFactionAt(myFloc); - if (Board.getInstance().getFactionAt(myFloc) != myFaction) { - if (!checkBypassPerms(fPlayer, player, toFac)) { + if (fPlayer == null) { + continue; + } + if (player.getGameMode() == GameMode.CREATIVE || player.getGameMode() == GameMode.SPECTATOR) { + continue; + } + Faction myFaction = fPlayer.getFaction(); + if (myFaction.isWilderness()) { fPlayer.setFlying(false); flyMap.remove(name); continue; } + if (fPlayer.checkIfNearbyEnemies()) { + continue; + } + FLocation myFloc = new FLocation(player.getLocation()); + Faction toFac = Board.getInstance().getFactionAt(myFloc); + if (Board.getInstance().getFactionAt(myFloc) != myFaction) { + if (!checkBypassPerms(fPlayer, player, toFac)) { + fPlayer.setFlying(false); + flyMap.remove(name); + continue; + } + } + } - checkTaskState(); } + } }, 20L, 20L); } @@ -109,22 +118,29 @@ public class CmdFly extends FCommand { if (player.hasPermission("factions.fly.safezone") && toFac.isSafeZone()) { return true; } - if (player.hasPermission("factions.fly.enemy") && toFac.getRelationTo(fplayer.getFaction()) == Relation.ENEMY) { + Access access = toFac.getAccess(fplayer, PermissableAction.FLY); + if ((player.hasPermission("factions.fly.enemy") || access == Access.ALLOW) && toFac.getRelationTo(fplayer.getFaction()) == Relation.ENEMY) { return true; } - if (player.hasPermission("factions.fly.ally") && toFac.getRelationTo(fplayer.getFaction()) == Relation.ALLY) { + if ((player.hasPermission("factions.fly.ally") || access == Access.ALLOW) && toFac.getRelationTo(fplayer.getFaction()) == Relation.ALLY) { return true; } - if (player.hasPermission("factions.fly.truce") && toFac.getRelationTo(fplayer.getFaction()) == Relation.TRUCE) { + if ((player.hasPermission("factions.fly.truce") || access == Access.ALLOW) && toFac.getRelationTo(fplayer.getFaction()) == Relation.TRUCE) { return true; } - return player.hasPermission("factions.fly.neutral") && toFac.getRelationTo(fplayer.getFaction()) == Relation.NEUTRAL; + return ((player.hasPermission("factions.fly.neutral") || access == Access.ALLOW) && toFac.getRelationTo(fplayer.getFaction()) == Relation.NEUTRAL && !isSystemFaction(toFac)); } public boolean isInFlightChecker(Player player) { return flyMap.containsKey(player.getName()); } + public static Boolean isSystemFaction(Faction faction) { + return faction.isSafeZone() || + faction.isWarZone() || + faction.isWilderness(); + } + @Override public void perform() { // Disabled by default. @@ -145,24 +161,24 @@ public class CmdFly extends FCommand { return; } if (!me.hasPermission("factions.fly.warzone") && toFac.isWarZone()) { - Bukkit.broadcastMessage("oooooooow"); fme.msg(TL.COMMAND_FLY_NO_ACCESS, Board.getInstance().getFactionAt(myfloc).getTag(fme)); return; } - if (!me.hasPermission("factions.fly.enemy") && toFac.getRelationTo(myFaction)== Relation.ENEMY){ + Access access = toFac.getAccess(fme, PermissableAction.FLY); + if ((!(me.hasPermission("factions.fly.enemy") || access == Access.ALLOW)) && toFac.getRelationTo(fme.getFaction()) == Relation.ENEMY) { fme.msg(TL.COMMAND_FLY_NO_ACCESS, Board.getInstance().getFactionAt(myfloc).getTag(fme)); return; } - if (!me.hasPermission("factions.fly.ally") && toFac.getRelationTo(myFaction)== Relation.ALLY){ + if (!(me.hasPermission("factions.fly.ally") || access == Access.ALLOW) && toFac.getRelationTo(fme.getFaction()) == Relation.ALLY) { fme.msg(TL.COMMAND_FLY_NO_ACCESS, Board.getInstance().getFactionAt(myfloc).getTag(fme)); return; } - if (!me.hasPermission("factions.fly.truce") && toFac.getRelationTo(myFaction)== Relation.TRUCE){ + if (!(me.hasPermission("factions.fly.truce") || access == Access.ALLOW) && toFac.getRelationTo(fme.getFaction()) == Relation.TRUCE) { fme.msg(TL.COMMAND_FLY_NO_ACCESS, Board.getInstance().getFactionAt(myfloc).getTag(fme)); return; } - if ((!me.hasPermission("factions.fly.neutral") && toFac.getRelationTo(myFaction) == Relation.NEUTRAL && !isSystemFaction(toFac))) { + if (!(me.hasPermission("factions.fly.neutral") || access == Access.ALLOW) && toFac.getRelationTo(fme.getFaction()) == Relation.NEUTRAL && !isSystemFaction(toFac)) { fme.msg(TL.COMMAND_FLY_NO_ACCESS, Board.getInstance().getFactionAt(myfloc).getTag(fme)); return; } @@ -193,12 +209,6 @@ public class CmdFly extends FCommand { } } - public Boolean isSystemFaction(Faction faction) { - return faction.isSafeZone() || - faction.isWarZone() || - faction.isWilderness(); - } - public static void checkTaskState() { if (flyMap.keySet().size() == 0) { Bukkit.getScheduler().cancelTask(flyid); @@ -212,22 +222,24 @@ public class CmdFly extends FCommand { flyMap.remove(player.getName()); return; } - - this.doWarmUp(WarmUpUtil.Warmup.FLIGHT, TL.WARMUPS_NOTIFY_FLIGHT, "Fly", new Runnable() { - @Override - public void run() { - fme.setFlying(true); - flyMap.put(player.getName(),true); - if (id == -1){ - if (P.p.getConfig().getBoolean("ffly.Particles.Enabled")){ - startParticles(); + + if (fme.canFlyAtLocation()) + + this.doWarmUp(WarmUpUtil.Warmup.FLIGHT, TL.WARMUPS_NOTIFY_FLIGHT, "Fly", new Runnable() { + @Override + public void run() { + fme.setFlying(true); + flyMap.put(player.getName(),true); + if (id == -1){ + if (P.p.getConfig().getBoolean("ffly.Particles.Enabled")){ + startParticles(); + } + } + if (flyid == -1){ + startFlyCheck(); } } - if (flyid == -1){ - startFlyCheck(); - } - } - }, this.p.getConfig().getLong("warmups.f-fly", 0)); + }, this.p.getConfig().getLong("warmups.f-fly", 0)); } @Override diff --git a/src/main/java/com/massivecraft/factions/iface/EconomyParticipator.java b/src/main/java/com/massivecraft/factions/iface/EconomyParticipator.java index eac8aae7..30f4bc6c 100644 --- a/src/main/java/com/massivecraft/factions/iface/EconomyParticipator.java +++ b/src/main/java/com/massivecraft/factions/iface/EconomyParticipator.java @@ -4,9 +4,9 @@ import com.massivecraft.factions.zcore.util.TL; public interface EconomyParticipator extends RelationParticipator { - String getAccountId(); + public String getAccountId(); - void msg(String str, Object... args); + public void msg(String str, Object... args); - void msg(TL translation, Object... args); + public void msg(TL translation, Object... args); } \ No newline at end of file diff --git a/src/main/java/com/massivecraft/factions/iface/RelationParticipator.java b/src/main/java/com/massivecraft/factions/iface/RelationParticipator.java index 7a10d976..3bc3f669 100644 --- a/src/main/java/com/massivecraft/factions/iface/RelationParticipator.java +++ b/src/main/java/com/massivecraft/factions/iface/RelationParticipator.java @@ -5,13 +5,13 @@ import org.bukkit.ChatColor; public interface RelationParticipator { - String describeTo(RelationParticipator that); + public String describeTo(RelationParticipator that); - String describeTo(RelationParticipator that, boolean ucfirst); + public String describeTo(RelationParticipator that, boolean ucfirst); - Relation getRelationTo(RelationParticipator that); + public Relation getRelationTo(RelationParticipator that); - Relation getRelationTo(RelationParticipator that, boolean ignorePeaceful); + public Relation getRelationTo(RelationParticipator that, boolean ignorePeaceful); - ChatColor getColorTo(RelationParticipator to); + public ChatColor getColorTo(RelationParticipator to); } diff --git a/src/main/java/com/massivecraft/factions/util/ClipPlaceholderAPIManager.java b/src/main/java/com/massivecraft/factions/util/ClipPlaceholderAPIManager.java index 6ab1dd49..a15cbe75 100644 --- a/src/main/java/com/massivecraft/factions/util/ClipPlaceholderAPIManager.java +++ b/src/main/java/com/massivecraft/factions/util/ClipPlaceholderAPIManager.java @@ -18,12 +18,12 @@ public class ClipPlaceholderAPIManager extends PlaceholderExpansion implements R // Identifier for this expansion @Override public String getIdentifier() { - return "savagefactions"; + return "factionsuuid"; } @Override public String getAuthor() { - return "prosavage"; + return "drtshock"; } // Since we are registering this expansion from the dependency, this can be null diff --git a/src/main/java/com/massivecraft/factions/zcore/fperms/gui/PermissableRelationGUI.java b/src/main/java/com/massivecraft/factions/zcore/fperms/gui/PermissableRelationGUI.java index a4c68959..5bae3c3d 100644 --- a/src/main/java/com/massivecraft/factions/zcore/fperms/gui/PermissableRelationGUI.java +++ b/src/main/java/com/massivecraft/factions/zcore/fperms/gui/PermissableRelationGUI.java @@ -61,6 +61,9 @@ public class PermissableRelationGUI implements InventoryHolder, FactionGUI { for (String key : section.getConfigurationSection("slots").getKeys(false)) { int slot = section.getInt("slots." + key); + if (slot == -1) { + continue; + } if (slot + 1 > guiSize && slot > 0) { P.p.log(Level.WARNING, "Invalid slot of " + key.toUpperCase() + " in relation GUI skipping it"); continue; diff --git a/src/main/java/com/massivecraft/factions/zcore/fupgrades/CropUpgrades.java b/src/main/java/com/massivecraft/factions/zcore/fupgrades/CropUpgrades.java index c1f4311b..c4edc89f 100644 --- a/src/main/java/com/massivecraft/factions/zcore/fupgrades/CropUpgrades.java +++ b/src/main/java/com/massivecraft/factions/zcore/fupgrades/CropUpgrades.java @@ -57,15 +57,17 @@ public class CropUpgrades implements Listener { if (below.getType() == Material.SUGAR_CANE_BLOCK) { org.bukkit.block.Block above = e.getBlock().getLocation().add(0, 1, 0).getBlock(); - if (above.getType() == Material.AIR) { + if (above.getType() == Material.AIR && above.getLocation().add(0, -2, 0).getBlock().getType() != Material.AIR) { above.setType(Material.SUGAR_CANE_BLOCK); } } if (below.getType() == Material.CACTUS) { + org.bukkit.block.Block above = e.getBlock().getLocation().add(0, 1, 0).getBlock(); - if (above.getType() == Material.AIR) { + + if (above.getType() == Material.AIR && above.getLocation().add(0, -2, 0).getBlock().getType() != Material.AIR) { above.setType(Material.CACTUS); } } diff --git a/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFPlayer.java b/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFPlayer.java index a2ee60f8..da0d1887 100644 --- a/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFPlayer.java +++ b/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFPlayer.java @@ -959,19 +959,7 @@ public abstract class MemoryFPlayer implements FPlayer { public boolean canFlyAtLocation(FLocation location) { Faction faction = Board.getInstance().getFactionAt(location); - if ((!faction.isWilderness() && getPlayer().hasPermission("factions.fly.wilderness")) || (faction.isSafeZone() && getPlayer().hasPermission("factions.fly.safezone") )|| (faction.isWarZone() && getPlayer().hasPermission("factions.fly.warzone"))) { - return false; - } - if (!getPlayer().hasPermission("factions.fly.ally") && getRelationToLocation() == Relation.ALLY) { - return false; - } - if (!getPlayer().hasPermission("factions.fly.truce") && getRelationToLocation() == Relation.TRUCE) { - return false; - } - if (!getPlayer().hasPermission("factions.fly.neutral") && getRelationToLocation() == Relation.NEUTRAL) { - return false; - } - if (faction == getFaction() && getRole() == Role.ADMIN) { + if ((faction == getFaction() && getRole() == Role.ADMIN) || isAdminBypassing) { return true; } diff --git a/src/main/resources/lang.yml b/src/main/resources/lang.yml index 636d7d7d..178b6722 100644 --- a/src/main/resources/lang.yml +++ b/src/main/resources/lang.yml @@ -1,4 +1,4 @@ -# Lang file for FactionsUUID by drtshock & ProSavage +# Lang file for SavageFactions by drtshock & ProSavage # Use & for color codes. # Made with love <3 diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 6b3d9c46..76b9dd7a 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,5 +1,5 @@ name: Factions -version: ${project.version}-SF-1.0.22 +version: ${project.version}-SF-1.0.23-BETA main: com.massivecraft.factions.P authors: [Olof Larsson, Brett Flannigan, drtshock, ProSavage] softdepend: [PlayerVaults, PlaceholderAPI, MVdWPlaceholderAPI, PermissionsEx, Permissions, Essentials, EssentialsChat, HeroChat, iChat, LocalAreaChat, LWC, nChat, ChatManager, CAPI, AuthMe, Vault, Spout, WorldEdit, WorldGuard, AuthDB, CaptureThePoints, CombatTag, dynmap, FactionsTop]