diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdUpgrades.java b/src/main/java/com/massivecraft/factions/cmd/CmdUpgrades.java index 898eccf9..86132870 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdUpgrades.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdUpgrades.java @@ -21,7 +21,7 @@ public class CmdUpgrades extends FCommand { @Override public void perform(CommandContext context) { if (!FactionsPlugin.getInstance().getConfig().getBoolean("fupgrades.Enabled")) { - context.fPlayer.sendMessage("This command is disabled!"); + context.fPlayer.msg(TL.COMMAND_UPGRADES_DISABLED); return; } new FUpgradesGUI().openMainMenu(context.fPlayer); diff --git a/src/main/java/com/massivecraft/factions/cmd/tnt/CmdTnt.java b/src/main/java/com/massivecraft/factions/cmd/tnt/CmdTnt.java index 042504be..115e7a72 100644 --- a/src/main/java/com/massivecraft/factions/cmd/tnt/CmdTnt.java +++ b/src/main/java/com/massivecraft/factions/cmd/tnt/CmdTnt.java @@ -17,7 +17,7 @@ public class CmdTnt extends FCommand { public CmdTnt() { super(); this.aliases.add("tnt"); - this.optionalArgs.put("add/take", ""); + this.optionalArgs.put("add/take/addall", ""); this.optionalArgs.put("amount", "number"); this.requirements = new CommandRequirements.Builder(Permission.TNT) @@ -91,7 +91,7 @@ public class CmdTnt extends FCommand { context.msg(TL.COMMAND_TNT_WIDTHDRAW_NOTENOUGH_TNT.toString()); return; } - int fullStacks = Math.round(amount / 64); + int fullStacks = amount / 64; int remainderAmt = amount - (fullStacks * 64); if ((remainderAmt == 0 && !hasAvaliableSlot(context.player, fullStacks))) { context.msg(TL.COMMAND_TNT_WIDTHDRAW_NOTENOUGH_SPACE); @@ -110,6 +110,31 @@ public class CmdTnt extends FCommand { context.msg(TL.COMMAND_TNT_WIDTHDRAW_SUCCESS); } } else if (context.args.size() == 1) { + if (context.args.get(0).equalsIgnoreCase("addall")) { + Inventory inv = context.player.getInventory(); + int invTnt = 0; + for (int i = 0; i <= inv.getSize(); i++) { + if (inv.getItem(i) == null) { continue; } + if (inv.getItem(i).getType() == Material.TNT) { + invTnt += inv.getItem(i).getAmount(); + } + } + if (invTnt <= 0) { + context.msg(TL.COMMAND_TNT_DEPOSIT_NOTENOUGH); + return; + } + if (context.faction.getTnt() + invTnt > context.faction.getTntBankLimit()) { + context.msg(TL.COMMAND_TNT_EXCEEDLIMIT); + return; + } + removeItems(context.player.getInventory(), new ItemStack(Material.TNT), invTnt); + context.player.updateInventory(); + context.faction.addTnt(invTnt); + context.msg(TL.COMMAND_TNT_DEPOSIT_SUCCESS); + context.fPlayer.sendMessage(FactionsPlugin.instance.color(TL.COMMAND_TNT_AMOUNT.toString().replace("{amount}", context.faction.getTnt() + "").replace("{maxAmount}", context.faction.getTntBankLimit() + ""))); + return; + + } context.msg(TL.GENERIC_ARGS_TOOFEW); context.msg(context.args.get(0).equalsIgnoreCase("take") || context.args.get(0).equalsIgnoreCase("t") ? TL.COMMAND_TNT_TAKE_DESCRIPTION : TL.COMMAND_TNT_ADD_DESCRIPTION); } @@ -141,6 +166,24 @@ public class CmdTnt extends FCommand { return check >= howmany; } + public static void removeItems(Inventory inventory, ItemStack item, int toRemove) { + if (toRemove <= 0 || inventory == null || item == null) + return; + for (int i = 0; i < inventory.getSize(); i++) { + ItemStack loopItem = inventory.getItem(i); + if (loopItem == null || !item.isSimilar(loopItem)) + continue; + if (toRemove <= 0) + return; + if (toRemove < loopItem.getAmount()) { + loopItem.setAmount(loopItem.getAmount() - toRemove); + return; + } + inventory.clear(i); + toRemove -= loopItem.getAmount(); + } + } + public void removeFromInventory(Inventory inventory, ItemStack item) { int amt = item.getAmount(); ItemStack[] items = inventory.getContents(); diff --git a/src/main/java/com/massivecraft/factions/integration/Econ.java b/src/main/java/com/massivecraft/factions/integration/Econ.java index d499542b..b95abd7c 100644 --- a/src/main/java/com/massivecraft/factions/integration/Econ.java +++ b/src/main/java/com/massivecraft/factions/integration/Econ.java @@ -86,7 +86,7 @@ public class Econ { FactionsPlugin.getInstance().log(Level.WARNING, "Vault does not appear to be hooked into an economy plugin."); return; } - to.sendMessage(String.format("%s's balance is %s.", about.getTag(), Econ.moneyString(econ.getBalance(about.getAccountId())))); + to.sendMessage(String.format(TL.ECON_PLAYERBALANCE.toString(), about.getTag(), Econ.moneyString(econ.getBalance(about.getAccountId())))); } public static boolean canIControllYou(EconomyParticipator i, EconomyParticipator you) { @@ -126,7 +126,7 @@ public class Econ { } // Otherwise you may not!;,,; - i.msg("%s lacks permission to control %s's money.", i.describeTo(i, true), you.describeTo(i)); + i.msg(TL.ECON_CANTCONTROLMONEY, i.describeTo(i, true), you.describeTo(i)); return false; } @@ -179,7 +179,7 @@ public class Econ { if (!econ.has(fromAcc, amount)) { // There was not enough money to pay if (invoker != null && notify) { - invoker.msg("%s can't afford to transfer %s to %s.", from.describeTo(invoker, true), moneyString(amount), to.describeTo(invoker)); + invoker.msg(TL.COMMAND_MONEYTRANSFERFF_TRANSFERCANTAFFORD, from.describeTo(invoker, true), moneyString(amount), to.describeTo(invoker)); } return false; @@ -209,7 +209,7 @@ public class Econ { // if we get here something with the transaction failed if (notify) { - invoker.msg("Unable to transfer %s to %s from %s.", moneyString(amount), to.describeTo(invoker), from.describeTo(invoker, true)); + invoker.msg(TL.ECON_UNABLETOTRANSFER, moneyString(amount), to.describeTo(invoker), from.describeTo(invoker, true)); } return false; @@ -237,19 +237,19 @@ public class Econ { if (invoker == null) { for (FPlayer recipient : recipients) { - recipient.msg("%s was transferred from %s to %s.", moneyString(amount), from.describeTo(recipient), to.describeTo(recipient)); + recipient.msg(TL.ECON_MONEYTRASFERREDFROM, moneyString(amount), from.describeTo(recipient), to.describeTo(recipient)); } } else if (invoker == from) { for (FPlayer recipient : recipients) { - recipient.msg("%s gave %s to %s.", from.describeTo(recipient, true), moneyString(amount), to.describeTo(recipient)); + recipient.msg(TL.ECON_PERSONGAVEMONEYTO, from.describeTo(recipient, true), moneyString(amount), to.describeTo(recipient)); } } else if (invoker == to) { for (FPlayer recipient : recipients) { - recipient.msg("%s took %s from %s.", to.describeTo(recipient, true), moneyString(amount), from.describeTo(recipient)); + recipient.msg(TL.ECON_PERSONTOOKMONEYFROM, to.describeTo(recipient, true), moneyString(amount), from.describeTo(recipient)); } } else { for (FPlayer recipient : recipients) { - recipient.msg("%s transferred %s from %s to %s.", invoker.describeTo(recipient, true), moneyString(amount), from.describeTo(recipient), to.describeTo(recipient)); + recipient.msg(TL.ECON_MONEYTRASFERREDFROMPERSONTOPERSON, invoker.describeTo(recipient, true), moneyString(amount), from.describeTo(recipient), to.describeTo(recipient)); } } } @@ -280,7 +280,7 @@ public class Econ { if (!affordable) { if (toDoThis != null && !toDoThis.isEmpty()) { - ep.msg("%s can't afford %s %s.", ep.describeTo(ep, true), moneyString(delta), toDoThis); + ep.msg(TL.COMMAND_MONEY_CANTAFFORD, ep.describeTo(ep, true), moneyString(delta), toDoThis); } return false; } @@ -318,13 +318,13 @@ public class Econ { if (er.transactionSuccess()) { modifyUniverseMoney(-delta); if (forDoingThis != null && !forDoingThis.isEmpty()) { - ep.msg("%s gained %s %s.", You, moneyString(delta), forDoingThis); + ep.msg(TL.COMMAND_MONEY_GAINED, You, moneyString(delta), forDoingThis); } return true; } else { // transfer to account failed if (forDoingThis != null && !forDoingThis.isEmpty()) { - ep.msg("%s would have gained %s %s, but the deposit failed.", You, moneyString(delta), forDoingThis); + ep.msg(TL.ECON_DEPOSITFAILED, You, moneyString(delta), forDoingThis); } return false; } @@ -336,13 +336,13 @@ public class Econ { // There is enough money to pay modifyUniverseMoney(-delta); if (forDoingThis != null && !forDoingThis.isEmpty()) { - ep.msg("%s lost %s %s.", You, moneyString(-delta), forDoingThis); + ep.msg(TL.ECON_MONEYLOST, You, moneyString(-delta), forDoingThis); } return true; } else { // There was not enough money to pay if (toDoThis != null && !toDoThis.isEmpty()) { - ep.msg("%s can't afford %s %s.", You, moneyString(-delta), toDoThis); + ep.msg(TL.ECON_CANTAFFORD, You, moneyString(-delta), toDoThis); } return false; } diff --git a/src/main/java/com/massivecraft/factions/util/ClipPlaceholderAPIManager.java b/src/main/java/com/massivecraft/factions/util/ClipPlaceholderAPIManager.java index 0764ff48..7be48c12 100644 --- a/src/main/java/com/massivecraft/factions/util/ClipPlaceholderAPIManager.java +++ b/src/main/java/com/massivecraft/factions/util/ClipPlaceholderAPIManager.java @@ -132,7 +132,7 @@ public class ClipPlaceholderAPIManager extends PlaceholderExpansion implements R return (powerBoost == 0.0) ? "" : (powerBoost > 0.0 ? TL.COMMAND_SHOW_BONUS.toString() : TL.COMMAND_SHOW_PENALTY.toString()) + powerBoost + ")"; case "faction_leader": FPlayer fAdmin = faction.getFPlayerAdmin(); - return fAdmin == null ? "Server" : fAdmin.getName().substring(0, fAdmin.getName().length() > 14 ? 13 : fAdmin.getName().length()); + return fAdmin == null ? TL.GENERIC_SERVER.toString() : fAdmin.getName().substring(0, fAdmin.getName().length() > 14 ? 13 : fAdmin.getName().length()); case "faction_warps": return String.valueOf(faction.getWarps().size()); case "faction_raidable": diff --git a/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFaction.java b/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFaction.java index dc0f422d..a3978468 100644 --- a/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFaction.java +++ b/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFaction.java @@ -773,7 +773,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator { return; } - msg("Your faction home has been un-set since it is no longer in your territory."); + msg(TL.COMMAND_HOME_UNSET); this.home = null; } @@ -1301,7 +1301,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator { } for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers()) { - fplayer.msg("The faction %s was disbanded.", this.getTag(fplayer)); + fplayer.msg(TL.COMMAND_DISBAND_BROADCAST_GENERIC, this.getTag(fplayer)); } FactionDisbandEvent disbandEvent = new FactionDisbandEvent(null, getId(), autoLeave ? PlayerDisbandReason.INACTIVITY : PlayerDisbandReason.LEAVE); @@ -1313,8 +1313,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator { oldLeader.setRole(Role.NORMAL); } replacements.get(0).setRole(Role.LEADER); - //TODO:TL - this.msg("Faction admin %s has been removed. %s has been promoted as the new faction admin.", oldLeader == null ? "" : oldLeader.getName(), replacements.get(0).getName()); + this.msg(TL.COMMAND_ADMIN_PROMOTED_AUTOLEAVE, oldLeader == null ? "" : oldLeader.getName(), replacements.get(0).getName()); FactionsPlugin.getInstance().log("Faction " + this.getTag() + " (" + this.getId() + ") admin was removed. Replacement admin: " + replacements.get(0).getName()); } } @@ -1448,8 +1447,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator { ownerList.append(", "); } OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(UUID.fromString(anOwnerData)); - //TODO:TL - ownerList.append(offlinePlayer != null ? offlinePlayer.getName() : "null player"); + ownerList.append(offlinePlayer != null ? offlinePlayer.getName() : TL.GENERIC_NULLPLAYER.toString()); } return ownerList.toString(); } 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 36752be8..c54e7807 100644 --- a/src/main/java/com/massivecraft/factions/zcore/util/TL.java +++ b/src/main/java/com/massivecraft/factions/zcore/util/TL.java @@ -126,6 +126,8 @@ public enum TL { COMMAND_CONTEXT_ADMINISTER_MOD_REQUIRED("&c[!] You must be a faction moderator to do that."), COMMAND_UPGRADES_DESCRIPTION("&cOpen the Upgrades Menu"), + COMMAND_UPGRADES_DISABLED("&c[!] &7Faction Upgrades are &cdisabled&7."), + COMMAND_CORNER_CANT_CLAIM("&c&l[!] &cYou may not claim this corner!"), COMMAND_CORNER_CLAIMED("\n&2&l[!] &aYou have claimed the corner successfully, totalling in &b%1$d &achunks!\n"), COMMAND_CORNER_ATTEMPTING_CLAIM("&c&l[!] &7Attempting to claim corner..."), @@ -141,6 +143,7 @@ public enum TL { COMMAND_ADMIN_DEMOTED("&c&l[!] &cYou have been demoted from the position of faction admin by &7%1$s&c"), COMMAND_ADMIN_PROMOTES("&e&l[!] &eYou have promoted &6%1$s &eto the position of faction admin."), COMMAND_ADMIN_PROMOTED("&e&l[!] &6%1$s &egave &6%2$s ðe leadership of &6%3$s&e."), + COMMAND_ADMIN_PROMOTED_AUTOLEAVE("&e&l[!] &7Faction admin &c%s&7 has been removed. &c%s&7 has been promoted as the new faction admin."), COMMAND_ADMIN_DESCRIPTION("Hand over your admin rights"), COMMAND_ADMIN_NOMEMBERS("&e&l[!] &cNo one else to promote, please disband faction."), @@ -368,6 +371,7 @@ public enum TL { COMMAND_DISBAND_IMMUTABLE("&c&l[!]&7 &7You &ccannot&7 disband &2Wilderness&7,&e SafeZone&7, or &4WarZone."), COMMAND_DISBAND_MARKEDPERMANENT("&c&l[!]&7 This faction is designated as&c permanent&7, so you cannot disband it."), COMMAND_DISBAND_BROADCAST_YOURS("&c&l[!]&7 &c%1$s&7 disbanded your &cfaction."), + COMMAND_DISBAND_BROADCAST_GENERIC("&c&l[!]&7 The Faction &c%1$s&7 was disbanded."), COMMAND_DISBAND_BROADCAST_NOTYOURS("&c&l[!]&7 &c%1$s &7disbanded the faction &c%2$s."), COMMAND_DISBAND_HOLDINGS("&c&l[!]&7 &7You have been given the disbanded &cfaction's bank&7, totaling &c%1$s."), COMMAND_DISBAND_PLAYER("&c&l[!] &7You have disbanded your &cfaction"), @@ -411,6 +415,7 @@ public enum TL { COMMAND_HOME_DISABLED("&c&l[!]&7 Sorry, Faction homes are &cdisabled on this server."), COMMAND_HOME_TELEPORTDISABLED("&c&l[!]&7 Sorry, the ability to &cteleport &7to Faction homes is &cdisabled &7on this server."), COMMAND_HOME_NOHOME("&c&l[!]&7 Your faction does &cnot &7have a home. "), + COMMAND_HOME_UNSET("&c&l[!]&7 Sorry, your faction home has been &cun-set &7since it is no longer in your territory."), COMMAND_HOME_INENEMY("&c&l[!]&7 You &ccannot teleport &7to your &cfaction home&7 while in the territory of an &cenemy faction&7."), COMMAND_HOME_WRONGWORLD("&c&l[!]&7 You &ccannot &7teleport to your &cfaction home&7 while in a different world."), COMMAND_HOME_ENEMYNEAR("&c&l[!]&7 You &ccannot teleport&7 to your faction home while an enemy is within &c%s&7 blocks of you."), @@ -547,6 +552,9 @@ public enum TL { COMMAND_MONEY_LONG("&c&l[!]&7 The faction money commands."), COMMAND_MONEY_DESCRIPTION("Faction money commands"), + COMMAND_MONEY_CANTAFFORD("&c&l[!]&7 &c%1$s&7 can't afford &c%2$s&7 %3$s"), + COMMAND_MONEY_GAINED("&c&l[!]&7 &c%1$s&7 gained &c%2$s %2%6"), + COMMAND_MONEYBALANCE_SHORT("show faction balance"), COMMAND_MONEYBALANCE_DESCRIPTION("Show your factions current money balance"), @@ -555,6 +563,8 @@ public enum TL { COMMAND_MONEYTRANSFERFF_DESCRIPTION("Transfer f -> f"), COMMAND_MONEYTRANSFERFF_TRANSFER("&c&l[!]&7 &c%1$s&7 transferred&c %2$s &7from the faction &c\"%3$s\"&7 to the faction&c \"%4$s\"&7"), + COMMAND_MONEYTRANSFERFF_TRANSFERCANTAFFORD("&c&l[!]&7 &c%1$s&7 can't afford to transfer &c%2$s &7to %3$s"), + COMMAND_MONEYTRANSFERFP_DESCRIPTION("Transfer f -> plugin"), COMMAND_MONEYTRANSFERFP_TRANSFER("&c&l[!]&7 &c%1$s &7transferred&c %2$s &7from the faction&c \"%3$s\" &7to the player &c\"%4$s\""), @@ -1016,9 +1026,11 @@ public enum TL { GENERIC_PUBLICLAND("Public faction land."), GENERIC_FACTIONLESS("factionless"), GENERIC_SERVERADMIN("A server admin"), + GENERIC_SERVER("Server"), GENERIC_DISABLED("disabled"), GENERIC_ENABLED("enabled"), GENERIC_INFINITY("∞"), + GENERIC_NULLPLAYER("null player"), GENERIC_CONSOLEONLY("This command cannot be run as a player."), GENERIC_PLAYERONLY("This command can only be used by ingame players."), GENERIC_ASKYOURLEADER(" Ask your leader to:"), @@ -1082,8 +1094,19 @@ public enum TL { ECON_OFF("no %s"), // no balance, no value, no refund, etc ECON_FORMAT("###,###.###"), + ECON_MONEYTRASFERREDFROM("%1$s was transferred from %2$s to %3$s."), + ECON_PERSONGAVEMONEYTO("%1$s gave %2$s to %3$s."), + ECON_PERSONTOOKMONEYFROM("%1$s took %2$s from %3$s."), ECON_DISABLED("Factions econ is disabled."), ECON_OVER_BAL_CAP("&4The amount &e%s &4is over Essentials' balance cap."), + ECON_MONEYLOST("&c%s &7lost &c%s &7%s."), + ECON_CANTAFFORD("&c%s &7can't afford &c%s&7 %s."), + ECON_UNABLETOTRANSFER("&7Unable to transfer &c%s&7 to &c%s&7 from &c%s&7."), + ECON_PLAYERBALANCE("&c%s&7's balance is &c%s&7."), + ECON_DEPOSITFAILED("&c%s&7 would have gained &c%s&7 %s, but the deposit failed."), + ECON_CANTCONTROLMONEY("&c%s&7 lacks permission to control &c%s&7's money."), + ECON_MONEYTRASFERREDFROMPERSONTOPERSON("%1$s transferred %2$s from %3$s to %4$s."), + /** * Relations