From 6bf4598d575b4a90ea78bd0d9063d4087e81b556 Mon Sep 17 00:00:00 2001 From: Naman Date: Tue, 24 Apr 2018 19:32:26 -0500 Subject: [PATCH] 1.2-STABLE /f tntfill wont spam chat anymore, I changed the tntfill_success option, so you're gonna wanna delete that to rengerate it. If you havent edited the lang.yml just delete it and restart /f stuck wont tp players outside the border anymore. Nametags & Tab has placeholderapi support added use {relationcolor} and {faction} for relational color and faction ( These were already built in ) They can be edited in the lang.yml the option is default_prefix. /f perms now has tntfill, tntbank, and vault permission options --- .../java/com/massivecraft/factions/P.java | 2 +- .../massivecraft/factions/cmd/CmdStuck.java | 3 +- .../com/massivecraft/factions/cmd/CmdTnt.java | 10 +++ .../massivecraft/factions/cmd/CmdTntFill.java | 68 +++++++++++++++++-- .../massivecraft/factions/cmd/CmdVault.java | 7 ++ .../factions/scoreboards/FTeamWrapper.java | 3 + .../zcore/fperms/PermissableAction.java | 5 +- .../massivecraft/factions/zcore/util/TL.java | 2 +- src/main/resources/config.yml | 9 ++- 9 files changed, 98 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/massivecraft/factions/P.java b/src/main/java/com/massivecraft/factions/P.java index e09387d7..7b702fa4 100644 --- a/src/main/java/com/massivecraft/factions/P.java +++ b/src/main/java/com/massivecraft/factions/P.java @@ -51,7 +51,7 @@ public class P extends MPlugin { public static Permission perms = null; - + ItemStack item = new ItemStack(Material.CAKE); // Persistence related private boolean locked = false; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdStuck.java b/src/main/java/com/massivecraft/factions/cmd/CmdStuck.java index 31c2b636..0d432132 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdStuck.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdStuck.java @@ -73,7 +73,8 @@ public class CmdStuck extends FCommand { public boolean work() { FLocation chunk = currentFLocation(); Faction faction = board.getFactionAt(chunk); - if (faction.isWilderness()) { + int buffer = P.p.getConfig().getInt("world-border.buffer", 0); + if (faction.isWilderness() && !chunk.isOutsideWorldBorder(buffer)) { int cx = FLocation.chunkToBlock((int) chunk.getX()); int cz = FLocation.chunkToBlock((int) chunk.getZ()); int y = world.getHighestBlockYAt(cx, cz); diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdTnt.java b/src/main/java/com/massivecraft/factions/cmd/CmdTnt.java index fa516812..0f7c80d7 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdTnt.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdTnt.java @@ -2,6 +2,8 @@ package com.massivecraft.factions.cmd; import com.massivecraft.factions.P; import com.massivecraft.factions.struct.Permission; +import com.massivecraft.factions.zcore.fperms.Access; +import com.massivecraft.factions.zcore.fperms.PermissableAction; import com.massivecraft.factions.zcore.util.TL; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -17,6 +19,7 @@ public class CmdTnt extends FCommand { this.optionalArgs.put("add/take", ""); this.optionalArgs.put("amount", "number"); + this.permission = Permission.TNT.node; this.disableOnLock = true; @@ -32,6 +35,13 @@ public class CmdTnt extends FCommand { fme.msg(TL.COMMAND_TNT_DISABLED_MSG); return; } + + Access access = fme.getFaction().getAccess(fme, PermissableAction.TNTBANK); + if (access.equals(Access.DENY)) { + fme.msg(TL.GENERIC_NOPERMISSION, "tntbank"); + } + + if (args.size() == 2) { if (args.get(0).equalsIgnoreCase("add")) { int testNumber = -1; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdTntFill.java b/src/main/java/com/massivecraft/factions/cmd/CmdTntFill.java index baf44634..604ff658 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdTntFill.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdTntFill.java @@ -3,6 +3,8 @@ package com.massivecraft.factions.cmd; import com.massivecraft.factions.P; import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Role; +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.Location; @@ -34,6 +36,13 @@ public class CmdTntFill extends FCommand { @Override public void perform(){ + Access access = fme.getFaction().getAccess(fme, PermissableAction.TNTFILL); + if (access.equals(Access.DENY)) { + fme.msg(TL.GENERIC_NOPERMISSION, "tntfill"); + } + + + msg(TL.COMMAND_TNTFILL_HEADER); int radius = argAsInt(0,16); int amount = argAsInt(1,16); @@ -58,6 +67,7 @@ public class CmdTntFill extends FCommand { } boolean bankMode = fme.getRole().isAtLeast(Role.MODERATOR); Location start = me.getLocation(); + int counter = 0; for (double x = start.getX() - radius; x <= start.getX() + radius; x++) { for (double y = start.getY() - radius; y <= start.getY() + radius; y++) { for (double z = start.getZ() - radius; z <= start.getZ() + radius; z++) { @@ -71,13 +81,17 @@ public class CmdTntFill extends FCommand { if (!inventoryContains(me.getInventory(), new ItemStack(Material.TNT,amount))){ if (!fme.getRole().isAtLeast(Role.MODERATOR)){ msg(TL.COMMAND_TNTFILL_NOTENOUGH); + sendMessage(TL.COMMAND_TNTFILL_SUCCESS.toString().replace("{amount}",amount + "").replace("{dispensers}",counter+ "")); + me.updateInventory(); return; } else if (bankMode){ - msg(TL.COMMAND_TNTFILL_MOD.toString().replace("{role}",fme.getRole().nicename)); + //msg(TL.COMMAND_TNTFILL_MOD.toString().replace("{role}",fme.getRole().nicename)); bankMode = true; - me.performCommand("f tnt take " + amount); + removeFromBank(amount); if (!inventoryContains(me.getInventory(), new ItemStack(Material.TNT,amount))){ msg(TL.COMMAND_TNTFILL_NOTENOUGH); + sendMessage(TL.COMMAND_TNTFILL_SUCCESS.toString().replace("{amount}",amount + "").replace("{dispensers}",counter+ "")); + me.updateInventory(); return; } } @@ -92,18 +106,64 @@ public class CmdTntFill extends FCommand { dispenser.addItem(tnt); takeTnt(remainderAmt); } - sendMessage(TL.COMMAND_TNTFILL_SUCCESS.toString().replace("{amount}",amount + "").replace("{x}",(int) x + "") - .replace("{y}",(int) y + "").replace("{z}",(int) z + "")); + //sendMessage(TL.COMMAND_TNTFILL_SUCCESS.toString().replace("{amount}",amount + "").replace("{x}",(int) x + "").replace("{y}",(int) y + "").replace("{z}",(int) z + "")); + counter++; } } } } } + if (bankMode) { + msg(TL.COMMAND_TNTFILL_MOD.toString().replace("{role}",fme.getRole().nicename)); + } + sendMessage(TL.COMMAND_TNTFILL_SUCCESS.toString().replace("{amount}",amount + "").replace("{dispensers}",counter+ "")); + me.updateInventory(); + + } + + private void removeFromBank(int amount){ + int testNumber = -1; + try { + testNumber = Integer.parseInt(args.get(1)); + } catch (NumberFormatException e) { + fme.msg(TL.COMMAND_TNT_INVALID_NUM); + return; + } + if (amount < 0) { + fme.msg(TL.COMMAND_TNT_POSITIVE); + return; + } + if (fme.getFaction().getTnt() < amount) { + fme.msg(TL.COMMAND_TNT_WIDTHDRAW_NOTENOUGH); + return; + } + int fullStacks = amount / 64; + int remainderAmt = amount % 64; + if ((remainderAmt == 0 && getEmptySlots(me) <= fullStacks)) { + fme.msg(TL.COMMAND_TNT_WIDTHDRAW_NOTENOUGH); + return; + } + if (getEmptySlots(me) + 1 <= fullStacks) { + fme.msg(TL.COMMAND_TNT_WIDTHDRAW_NOTENOUGH); + return; + } + ItemStack tnt64 = new ItemStack(Material.TNT, 64); + for (int i = 0; i <= fullStacks - 1; i++) { + me.getInventory().addItem(tnt64); + } + if (remainderAmt != 0) { + ItemStack tnt = new ItemStack(Material.TNT, remainderAmt); + me.getInventory().addItem(tnt); + } + fme.getFaction().takeTnt(amount); + me.updateInventory(); + } + public void takeTnt(int amount){ Inventory inv = me.getInventory(); int invTnt = 0; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdVault.java b/src/main/java/com/massivecraft/factions/cmd/CmdVault.java index 2f6032b1..89ff5f8e 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdVault.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdVault.java @@ -10,6 +10,8 @@ import com.massivecraft.factions.Conf; import com.massivecraft.factions.FLocation; import com.massivecraft.factions.P; import com.massivecraft.factions.struct.Permission; +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.Location; @@ -39,10 +41,15 @@ public class CmdVault extends FCommand { @Override public void perform() { + if (!P.p.getConfig().getBoolean("fvault.Enabled")){ fme.sendMessage("This command is disabled!"); return; } + Access access = fme.getFaction().getAccess(fme, PermissableAction.VAULT); + if (access.equals(Access.DENY)) { + fme.msg(TL.GENERIC_NOPERMISSION, "vault"); + } if (fme.isInVault()){ me.closeInventory(); diff --git a/src/main/java/com/massivecraft/factions/scoreboards/FTeamWrapper.java b/src/main/java/com/massivecraft/factions/scoreboards/FTeamWrapper.java index 8ac6a541..070d5d55 100644 --- a/src/main/java/com/massivecraft/factions/scoreboards/FTeamWrapper.java +++ b/src/main/java/com/massivecraft/factions/scoreboards/FTeamWrapper.java @@ -2,6 +2,7 @@ package com.massivecraft.factions.scoreboards; import com.massivecraft.factions.*; import com.massivecraft.factions.zcore.util.TL; +import me.clip.placeholderapi.PlaceholderAPI; import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; import org.bukkit.scoreboard.Scoreboard; @@ -169,6 +170,8 @@ public class FTeamWrapper { Team team = teams.get(fboard); String prefix = TL.DEFAULT_PREFIX.toString(); + prefix = PlaceholderAPI.setPlaceholders(fplayer.getPlayer(),prefix); + prefix = PlaceholderAPI.setBracketPlaceholders(fplayer.getPlayer(),prefix); prefix = prefix.replace("{relationcolor}", faction.getRelationTo(fplayer).getColor().toString()); prefix = prefix.replace("{faction}", faction.getTag().substring(0, Math.min("{faction}".length() + 16 - prefix.length(), faction.getTag().length()))); if (team.getPrefix() == null || !team.getPrefix().equals(prefix)) { diff --git a/src/main/java/com/massivecraft/factions/zcore/fperms/PermissableAction.java b/src/main/java/com/massivecraft/factions/zcore/fperms/PermissableAction.java index 07887910..40904dd2 100644 --- a/src/main/java/com/massivecraft/factions/zcore/fperms/PermissableAction.java +++ b/src/main/java/com/massivecraft/factions/zcore/fperms/PermissableAction.java @@ -34,7 +34,10 @@ public enum PermissableAction { PROMOTE("promote"), SETWARP("setwarp"), WARP("warp"), - FLY("fly"),; + FLY("fly"), + VAULT("vault"), + TNTBANK("tntbank"), + TNTFILL("tntfill"); private String name; diff --git a/src/main/java/com/massivecraft/factions/zcore/util/TL.java b/src/main/java/com/massivecraft/factions/zcore/util/TL.java index afd568b8..76b98a50 100644 --- a/src/main/java/com/massivecraft/factions/zcore/util/TL.java +++ b/src/main/java/com/massivecraft/factions/zcore/util/TL.java @@ -674,7 +674,7 @@ public enum TL { COMMAND_TNT_DESCRIPTION("add/widthraw from faction's tnt bank"), COMMAND_TNTFILL_HEADER("&c&l[!] &7Filling tnt in dispensers..."), - COMMAND_TNTFILL_SUCCESS("&c&l[!] &7Filled &c{amount}&7 Tnt in dispenser at {x} {y} {z}"), + COMMAND_TNTFILL_SUCCESS("&c&l[!] &7Filled &c{amount}&7 Tnt in &c{dispensers} &7dispensers"), COMMAND_TNTFILL_NOTENOUGH("&c&l[!] &7Not enough tnt in inventory."), COMMAND_TNTFILL_RADIUSMAX("&c&l[!] &7The max radius is {max}"), COMMAND_TNTFILL_AMOUNTMAX("&c&l[!] &7The max amount is {max}"), diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 0b3a9a47..c45b3498 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -501,6 +501,9 @@ fperm-gui: ban: 27 disband: 28 fly: 29 + vault: 30 + tntbank: 31 + tntfill: 32 # Material to show, if the material is colorable eg: Wool, Stained Clay it will update with it's access color materials: build: STAINED_CLAY @@ -524,6 +527,9 @@ fperm-gui: ban: STAINED_CLAY disband: STAINED_CLAY fly: STAINED_CLAY + vault: STAINED_CLAY + tntbank: STAINED_CLAY + tntfill: STAINED_CLAY # Same dummy items format as above dummy-items: '0': @@ -536,9 +542,6 @@ fperm-gui: - 8 - 29 - 30 - - 31 - - 32 - - 33 - 34 - 35 # {action} Action name eg: Setwarp, Kick