Bunch of Econ, Lang.yml Additions

This commit is contained in:
Driftay 2019-11-29 04:58:59 -05:00
parent f5e9ce3d90
commit 939a60c611
6 changed files with 87 additions and 23 deletions

View File

@ -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);

View File

@ -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();

View File

@ -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("<h>%s<i> lacks permission to control <h>%s's<i> 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("<h>%s<b> can't afford to transfer <h>%s<b> to %s<b>.", 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<b> to <h>%s<b> from <h>%s<b>.", 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("<h>%s<i> was transferred from <h>%s<i> to <h>%s<i>.", 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("<h>%s<i> <h>gave %s<i> to <h>%s<i>.", 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("<h>%s<i> <h>took %s<i> from <h>%s<i>.", 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("<h>%s<i> transferred <h>%s<i> from <h>%s<i> to <h>%s<i>.", 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("<h>%s<i> can't afford <h>%s<i> %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("<h>%s<i> gained <h>%s<i> %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("<h>%s<i> would have gained <h>%s<i> %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("<h>%s<i> lost <h>%s<i> %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("<h>%s<i> can't afford <h>%s<i> %s.", You, moneyString(-delta), toDoThis);
ep.msg(TL.ECON_CANTAFFORD, You, moneyString(-delta), toDoThis);
}
return false;
}

View File

@ -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":

View File

@ -773,7 +773,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
return;
}
msg("<b>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<i> 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("<i>Faction admin <h>%s<i> has been removed. %s<i> 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();
}

View File

@ -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 &ethe 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