From 27a442681d1985ac86bda09d077511f7328ed760 Mon Sep 17 00:00:00 2001 From: Driftay Date: Thu, 4 Jul 2019 01:12:39 -0400 Subject: [PATCH] Reformatted - F Paypal + Few Fixes w/F Alts --- .../massivecraft/factions/SaberFactions.java | 1 - .../factions/cmd/CmdAutoHelp.java | 4 +- .../factions/cmd/CmdPaypalSee.java | 37 ++++++--- .../factions/cmd/CmdPaypalSet.java | 82 +++++++++++++------ .../factions/cmd/alts/CmdAltsList.java | 5 ++ .../factions/struct/Permission.java | 2 + .../factions/zcore/persist/MemoryFPlayer.java | 10 ++- .../massivecraft/factions/zcore/util/TL.java | 9 +- 8 files changed, 100 insertions(+), 50 deletions(-) diff --git a/src/main/java/com/massivecraft/factions/SaberFactions.java b/src/main/java/com/massivecraft/factions/SaberFactions.java index 12d6a1a4..3688b673 100644 --- a/src/main/java/com/massivecraft/factions/SaberFactions.java +++ b/src/main/java/com/massivecraft/factions/SaberFactions.java @@ -568,7 +568,6 @@ public class SaberFactions extends MPlugin { List> commandsList = cmdBase.subCommands; if (Board.getInstance().getFactionAt(new FLocation(fPlayer.getPlayer().getLocation())) == Factions.getInstance().getWarZone()) { - sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&cYou cannot use autocomplete in warzone.")); return new ArrayList<>(); } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdAutoHelp.java b/src/main/java/com/massivecraft/factions/cmd/CmdAutoHelp.java index c69469d8..72fc4abe 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdAutoHelp.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdAutoHelp.java @@ -28,9 +28,7 @@ public class CmdAutoHelp extends MCommand { } MCommand pcmd = this.commandChain.get(this.commandChain.size() - 1); - ArrayList lines = new ArrayList<>(); - - lines.addAll(pcmd.helpLong); + ArrayList lines = new ArrayList<>(pcmd.helpLong); for (MCommand scmd : pcmd.subCommands) { if (scmd.visibility == CommandVisibility.VISIBLE || (scmd.visibility == CommandVisibility.SECRET && scmd.validSenderPermissions(sender, false))) { diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdPaypalSee.java b/src/main/java/com/massivecraft/factions/cmd/CmdPaypalSee.java index e1f282cc..4fdf004d 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdPaypalSee.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdPaypalSee.java @@ -8,12 +8,14 @@ import com.massivecraft.factions.zcore.util.TL; public class CmdPaypalSee extends FCommand { public CmdPaypalSee() { aliases.add("seepaypal"); + aliases.add("paypal"); - requiredArgs.add("faction"); + optionalArgs.put("faction", "yours"); - permission = Permission.ADMIN.node; + permission = Permission.PAYPAL.node; disableOnLock = false; + senderMustBePlayer = true; senderMustBeMember = true; senderMustBeModerator = false; @@ -27,21 +29,30 @@ public class CmdPaypalSee extends FCommand { fme.msg(TL.GENERIC_DISABLED); return; } - Faction faction = argAsFaction(0); - if (faction == null) - return; - - if (!faction.isWilderness() && !faction.isSafeZone() && !faction.isWarZone()) { - fme.msg(TL.COMMAND_PAYPALSEE_FACTION_NOFACTION.toString(), me.getName()); - return; - } - if (faction.getPaypal() != null) { - fme.msg(TL.COMMAND_PAYPALSEE_FACTION_PAYPAL.toString(), faction.getTag(), faction.getPaypal()); + if (args.size() == 0) { + if (myFaction.getPaypal().isEmpty()) { + msg(TL.COMMAND_PAYPAL_NOTSET); + } else { + msg(TL.PAYPALSEE_PLAYER_PAYPAL, myFaction.getPaypal()); + } + } else if (args.size() == 1) { + if (fme.isAdminBypassing()) { + Faction faction = argAsFaction(0); + if (faction != null) { + if (faction.getPaypal().isEmpty()) { + msg(TL.COMMAND_PAYPALSEE_FACTION_NOTSET, faction.getTag()); } else { - fme.msg(TL.COMMAND_PAYPALSEE_FACTION_NOTSET.toString(), faction.getTag(), faction.getPaypal()); + msg(TL.COMMAND_PAYPALSEE_FACTION_PAYPAL.toString(), faction.getTag(), faction.getPaypal()); } } + } else { + msg(TL.GENERIC_NOPERMISSION, "see another factions paypal."); + } + } else { + msg(SaberFactions.plugin.cmdBase.cmdPaypalSee.getUseageTemplate()); + } + } @Override public TL getUsageTranslation() { diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdPaypalSet.java b/src/main/java/com/massivecraft/factions/cmd/CmdPaypalSet.java index a22a874b..d661170e 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdPaypalSet.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdPaypalSet.java @@ -1,42 +1,70 @@ package com.massivecraft.factions.cmd; +import com.massivecraft.factions.Faction; import com.massivecraft.factions.SaberFactions; import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.zcore.util.TL; public class CmdPaypalSet extends FCommand { - public CmdPaypalSet() { - this.aliases.add("setpaypal"); - this.requiredArgs.add("email"); + public CmdPaypalSet() { + this.aliases.add("setpaypal"); - this.permission = Permission.PAYPALSET.node; + this.optionalArgs.put("faction", "yours"); - this.disableOnLock = false; - this.senderMustBePlayer = true; - this.senderMustBeMember = true; - this.senderMustBeModerator = false; - this.senderMustBeColeader = false; - this.senderMustBeAdmin = true; + this.requiredArgs.add("email"); - } - @Override - public void perform() { - if (!SaberFactions.plugin.getConfig().getBoolean("fpaypal.Enabled")) { - fme.msg(TL.GENERIC_DISABLED); - return; - } + this.permission = Permission.PAYPALSET.node; - String paypal = this.argAsString(0); - if(paypal == null) - return; - myFaction.paypalSet(paypal); - fme.msg(TL.COMMAND_PAYPALSET_SUCCESSFUL, paypal); - } + this.disableOnLock = false; + this.senderMustBePlayer = true; + this.senderMustBeMember = true; + this.senderMustBeModerator = false; + this.senderMustBeColeader = false; + this.senderMustBeAdmin = true; - @Override - public TL getUsageTranslation() { - return TL.COMMAND_PAYPALSET_DESCRIPTION; - } + } + + @Override + public void perform() { + if (!SaberFactions.plugin.getConfig().getBoolean("fpaypal.Enabled")) { + fme.msg(TL.GENERIC_DISABLED); + return; + } + + if (args.size() == 1) { + if (isEmail(argAsString(0))) { + myFaction.paypalSet(argAsString(0)); + msg(TL.COMMAND_PAYPALSET_SUCCESSFUL, argAsString(0)); + } else { + msg(TL.COMMAND_PAYPALSET_NOTEMAIL, argAsString(0)); + } + } else if (args.size() == 2) { + if (fme.isAdminBypassing()) { + Faction faction = argAsFaction(1); + if (faction != null) { + if (isEmail(argAsString(0))) { + myFaction.paypalSet(argAsString(0)); + msg(TL.COMMAND_PAYPALSET_ADMIN_SUCCESSFUL, faction.getTag(), argAsString(0)); + } else { + msg(TL.COMMAND_PAYPALSET_ADMIN_FAILED, argAsString(0)); + } + } + } else { + msg(TL.GENERIC_NOPERMISSION, "set another factions paypal!"); + } + } else { + msg(SaberFactions.plugin.cmdBase.cmdPaypalSet.getUseageTemplate()); + } + } + + private boolean isEmail(String email) { + return email.contains("@") && email.contains("."); + } + + @Override + public TL getUsageTranslation() { + return TL.COMMAND_PAYPALSET_DESCRIPTION; + } } diff --git a/src/main/java/com/massivecraft/factions/cmd/alts/CmdAltsList.java b/src/main/java/com/massivecraft/factions/cmd/alts/CmdAltsList.java index 44573274..0339cfa7 100644 --- a/src/main/java/com/massivecraft/factions/cmd/alts/CmdAltsList.java +++ b/src/main/java/com/massivecraft/factions/cmd/alts/CmdAltsList.java @@ -32,6 +32,11 @@ public class CmdAltsList extends FCommand { ArrayList ret = new ArrayList<>(); for (FPlayer fp : myFaction.getAltPlayers()) { + if(myFaction.getAltPlayers().isEmpty()){ + fme.sendMessage(TL.COMMAND_ALTS_LIST_NOALTS.toString()); + return; + } + String humanized = DurationFormatUtils.formatDurationWords(System.currentTimeMillis() - fp.getLastLoginTime(), true, true) + TL.COMMAND_STATUS_AGOSUFFIX; String last = fp.isOnline() ? ChatColor.GREEN + TL.COMMAND_STATUS_ONLINE.toString() : (System.currentTimeMillis() - fp.getLastLoginTime() < 432000000 ? ChatColor.YELLOW + humanized : ChatColor.RED + humanized); String power = ChatColor.YELLOW + String.valueOf(fp.getPowerRounded()) + " / " + fp.getPowerMaxRounded() + ChatColor.RESET; diff --git a/src/main/java/com/massivecraft/factions/struct/Permission.java b/src/main/java/com/massivecraft/factions/struct/Permission.java index e49411f3..60477b21 100644 --- a/src/main/java/com/massivecraft/factions/struct/Permission.java +++ b/src/main/java/com/massivecraft/factions/struct/Permission.java @@ -70,6 +70,7 @@ public enum Permission { SET_PERMANENT("setpermanent"), SET_PERMANENTPOWER("setpermanentpower"), SHOW_INVITES("showinvites"), + PAYPAL("paypal"), PAYPALSET("setpaypal"), PERMISSIONS("permissions"), POWERBOOST("powerboost"), @@ -80,6 +81,7 @@ public enum Permission { RELOAD("reload"), SAVE("save"), SPAM("spam"), + SATISTICS("statistics"), SETHOME("sethome"), SETHOME_ANY("sethome.any"), SETSTRIKES("setstrikes"), 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 3a91f69a..537ebd2e 100644 --- a/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFPlayer.java +++ b/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFPlayer.java @@ -103,9 +103,9 @@ public abstract class MemoryFPlayer implements FPlayer { this.autoWarZoneEnabled = false; this.loginPvpDisabled = Conf.noPVPDamageToOthersForXSecondsAfterLogin > 0; this.powerBoost = 0.0; + this.getKills(); + this.getDeaths(); this.showScoreboard = SaberFactions.plugin.getConfig().getBoolean("scoreboard.default-enabled", false); - this.kills = 0; - this.deaths = 0; this.mapHeight = Conf.mapHeight; if (!Conf.newPlayerStartingFactionID.equals("0") && Factions.getInstance().isValidFactionId(Conf.newPlayerStartingFactionID)) { @@ -130,13 +130,15 @@ public abstract class MemoryFPlayer implements FPlayer { this.chatMode = other.chatMode; this.spyingChat = other.spyingChat; this.lastStoodAt = other.lastStoodAt; + this.getKills(); + this.getDeaths(); this.isAdminBypassing = other.isAdminBypassing; this.showScoreboard = SaberFactions.plugin.getConfig().getBoolean("scoreboard.default-enabled", true); - this.kills = other.kills; - this.deaths = other.deaths; this.mapHeight = Conf.mapHeight; } + + public boolean isStealthEnabled() { return this.isStealthEnabled; } 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 3e4cb9a6..75eb1b73 100644 --- a/src/main/java/com/massivecraft/factions/zcore/util/TL.java +++ b/src/main/java/com/massivecraft/factions/zcore/util/TL.java @@ -162,7 +162,8 @@ public enum TL { COMMAND_ALTKICK_DESCRIPTION("Kick alts from your faction"), COMMAND_ALTKICK_NOTALT("&c&l[!] &7Player is not an alt."), COMMAND_ALTKICK_NOTMEMBER("&c&l[!] &7This player is not a member of your faction."), - + + COMMAND_ALTS_LIST_NOALTS("&c&l[!] &7You have no alts in your faction!"), COMMAND_AUTOHELP_HELPFOR("Help for command \""), COMMAND_BAN_DESCRIPTION("Ban players from joining your Faction."), @@ -521,6 +522,11 @@ public enum TL { COMMAND_OWNERLIST_OWNERS("&c&l[!]&7 Current owner(s) of this land: %1$s"), COMMAND_OWNERLIST_DESCRIPTION("List owner(s) of this claimed land"), + PAYPALSEE_PLAYER_PAYPAL("&c&l[!] &7You're factions paypal is: &b%1$s&7."), + COMMAND_PAYPAL_NOTSET("&c&l[!] &7Your faction does not have their paypal set!"), + COMMAND_PAYPALSET_ADMIN_SUCCESSFUL("&c&l[!] &7You have set &b%1$s's &7paypal to &b%2$s&7."), + COMMAND_PAYPALSET_ADMIN_FAILED("&c&l[!] &b%1$s &7is not an email!"), + COMMAND_PAYPALSET_NOTEMAIL("&c&l[!] &b%1$s &7is not an email!"), COMMAND_PAYPALSET_DESCRIPTION("&c&l[!] &7Set the email of your faction to claim rewards."), COMMAND_PAYPALSEE_DESCRIPTION("&c&l[!] &7View a specific factions paypal email with &b/f &b."), COMMAND_PAYPALSET_CREATED("&c&l[!] &7Make sure to type &b/f &7!"), @@ -661,7 +667,6 @@ public enum TL { COMMAND_SETSTRIKES_SUCCESS("&c&l[!]&7 &c{faction}'s&7 new strikes are &c{strikes}"), COMMAND_SETSTRIKES_DESCRIPTION("Set a faction's strikes"), COMMAND_STRIKEREMOVE_DESCRIPTION("Remove a faction's strikes"), - COMMAND_STRIKE_MESSAGE("&c&l[!] &7{faction} has {strikes} strikes."), COMMAND_STRIKE_NOTFOUND("&c&l[!] &7{faction} does not exist."), COMMAND_STRIKE_NEEDFACTION("&c&l[!] &7&cYou need to join a faction to view your own!"),