From 1ee8089ca53157e1daf327a915c150a7d8f6211a Mon Sep 17 00:00:00 2001 From: Driftay Date: Fri, 21 Sep 2018 02:29:28 -0400 Subject: [PATCH] Changes Adding --- .../com/massivecraft/factions/Faction.java | 4 ++ .../massivecraft/factions/cmd/CmdCreate.java | 3 ++ .../factions/cmd/CmdPaypalSee.java | 48 ++++++++++++++++++- .../factions/cmd/CmdPaypalSet.java | 36 +++++++++++++- .../massivecraft/factions/cmd/FCmdRoot.java | 6 +++ .../factions/struct/Permission.java | 1 + .../factions/zcore/persist/MemoryFaction.java | 8 ++++ .../massivecraft/factions/zcore/util/TL.java | 8 ++++ src/main/resources/config.yml | 8 ++++ src/main/resources/plugin.yml | 2 + 10 files changed, 122 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/massivecraft/factions/Faction.java b/src/main/java/com/massivecraft/factions/Faction.java index 4549d144..08150ee9 100644 --- a/src/main/java/com/massivecraft/factions/Faction.java +++ b/src/main/java/com/massivecraft/factions/Faction.java @@ -326,4 +326,8 @@ public interface Faction extends EconomyParticipator { void remove(); Set getAllClaims(); + + String getPaypal(); + + void paypalSet(String paypal); } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdCreate.java b/src/main/java/com/massivecraft/factions/cmd/CmdCreate.java index 62a776a0..e9a5b83e 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdCreate.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdCreate.java @@ -100,6 +100,9 @@ public class CmdCreate extends FCommand { if (Conf.logFactionCreate) { P.p.log(fme.getName() + TL.COMMAND_CREATE_CREATEDLOG.toString() + tag); } + if (P.p.getConfig().getBoolean("fpaypal.Enabled")) { + this.fme.msg(TL.COMMAND_PAYPALSET_CREATED); + } } @Override diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdPaypalSee.java b/src/main/java/com/massivecraft/factions/cmd/CmdPaypalSee.java index f0d80aa7..c54e876b 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdPaypalSee.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdPaypalSee.java @@ -1,4 +1,50 @@ package com.massivecraft.factions.cmd; -public class CmdPaypalSee { +import com.massivecraft.factions.Faction; +import com.massivecraft.factions.P; +import com.massivecraft.factions.struct.Permission; +import com.massivecraft.factions.zcore.util.TL; +import org.bukkit.ChatColor; + +public class CmdPaypalSee extends FCommand{ + public CmdPaypalSee() { + aliases.add("seepaypal"); + aliases.add("getpaypal"); + requiredArgs.add("faction"); + permission = Permission.ADMIN.node; + disableOnLock = false; + senderMustBePlayer = false; + senderMustBeMember = false; + senderMustBeModerator = false; + senderMustBeColeader = false; + senderMustBeAdmin = false; + } + + public void perform() { + if (!P.p.getConfig().getBoolean("fpaypal.Enabled")) { + fme.msg(TL.GENERIC_DISABLED); + } else { + Faction faction = argAsFaction(0); + String paypal = argAsString(1); + + if (faction != null) { + if (!faction.isWilderness() && !faction.isSafeZone() && !faction.isWarZone()) { + if (faction.getPaypal() != null) { + fme.msg(TL.COMMAND_PAYPALSEE_FACTION_PAYPAL.toString(), faction.getTag(), faction.getPaypal()); + } else { + fme.msg(TL.COMMAND_PAYPALSEE_FACTION_NOTSET.toString(), faction.getTag(), faction.getPaypal()); + } + + } else { + fme.msg(TL.COMMAND_PAYPALSEE_FACTION_NOFACTION.toString(), me.getName()); + } + } + } + } + + public TL getUsageTranslation() { + return TL.COMMAND_PAYPALSEE_DESCRIPTION; + } } + + diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdPaypalSet.java b/src/main/java/com/massivecraft/factions/cmd/CmdPaypalSet.java index 6739c1c0..c4a097b8 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdPaypalSet.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdPaypalSet.java @@ -1,4 +1,38 @@ package com.massivecraft.factions.cmd; -public class CmdPaypalSet { +import com.massivecraft.factions.P; +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.aliases.add("paypal"); + this.requiredArgs.add("email"); + this.permission = Permission.PAYPALSET.node; + this.disableOnLock = false; + this.senderMustBePlayer = true; + this.senderMustBeMember = false; + this.senderMustBeModerator = false; + this.senderMustBeColeader = true; + this.senderMustBeAdmin = false; + } + + public void perform() { + if (!P.p.getConfig().getBoolean("fpaypal.Enabled")) { + fme.msg(TL.GENERIC_DISABLED); + } else { + String paypal = argAsString(0); + if (paypal != null) { + myFaction.paypalSet(paypal); + fme.msg(TL.COMMAND_PAYPALSET_SUCCESSFUL, paypal); + } + } + } + + public TL getUsageTranslation() { + return TL.COMMAND_PAYPALSET_DESCRIPTION; + } } + diff --git a/src/main/java/com/massivecraft/factions/cmd/FCmdRoot.java b/src/main/java/com/massivecraft/factions/cmd/FCmdRoot.java index bfc21e70..866ac65f 100644 --- a/src/main/java/com/massivecraft/factions/cmd/FCmdRoot.java +++ b/src/main/java/com/massivecraft/factions/cmd/FCmdRoot.java @@ -63,6 +63,8 @@ public class FCmdRoot extends FCommand { public CmdSB cmdSB = new CmdSB(); public CmdShowInvites cmdShowInvites = new CmdShowInvites(); public CmdAnnounce cmdAnnounce = new CmdAnnounce(); + public CmdPaypalSet cmdPaypalSet = new CmdPaypalSet(); + public CmdPaypalSee cmdPaypalSee = new CmdPaypalSee(); public CmdSeeChunk cmdSeeChunk = new CmdSeeChunk(); public CmdConvert cmdConvert = new CmdConvert(); public CmdFWarp cmdFWarp = new CmdFWarp(); @@ -231,6 +233,10 @@ public class FCmdRoot extends FCommand { P.p.log(Level.INFO, "Enabling FactionsTop command, this is a very basic /f top please get a dedicated /f top resource if you want land calculation etc."); this.addSubCommand(this.cmdTop); } + if (P.p.getConfig().getBoolean("fpaypal.Enabled")) { + this.addSubCommand(this.cmdPaypalSet); + this.addSubCommand(this.cmdPaypalSee); + } } diff --git a/src/main/java/com/massivecraft/factions/struct/Permission.java b/src/main/java/com/massivecraft/factions/struct/Permission.java index c26a8d6e..f33e2d9c 100644 --- a/src/main/java/com/massivecraft/factions/struct/Permission.java +++ b/src/main/java/com/massivecraft/factions/struct/Permission.java @@ -64,6 +64,7 @@ public enum Permission { SET_PERMANENT("setpermanent"), SET_PERMANENTPOWER("setpermanentpower"), SHOW_INVITES("showinvites"), + PAYPALSET("setpaypal"), PERMISSIONS("permissions"), POWERBOOST("powerboost"), POWER("power"), 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 39e6f3f0..c72d6b39 100644 --- a/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFaction.java +++ b/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFaction.java @@ -51,6 +51,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator { protected transient long lastPlayerLoggedOffTime; protected double money; protected double powerBoost; + protected String paypal; protected Map relationWish = new HashMap<>(); protected Map> claimOwnership = new ConcurrentHashMap<>(); protected transient Set fplayers = new HashSet<>(); @@ -164,6 +165,13 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator { public boolean isWarpPassword(String warp, String password) { return hasWarpPassword(warp) && warpPasswords.get(warp.toLowerCase()).equals(password); } + public String getPaypal() { + return this.paypal; + } + + public void paypalSet(String paypal) { + this.paypal = paypal; + } public boolean hasWarpPassword(String warp) { return warpPasswords.containsKey(warp.toLowerCase()); 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 3c68ae2e..343d8cd3 100644 --- a/src/main/java/com/massivecraft/factions/zcore/util/TL.java +++ b/src/main/java/com/massivecraft/factions/zcore/util/TL.java @@ -470,6 +470,14 @@ 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"), + 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!"), + COMMAND_PAYPALSET_SUCCESSFUL("&c&l[!] &7Successfully set your factions email - &b%1$s&7."), + COMMAND_PAYPALSEE_FACTION_PAYPAL("&c&l[!] &b%1$s's &7faction has their paypal set to &b%2$s&7."), + COMMAND_PAYPALSEE_FACTION_NOTSET("&c&l[!] &b%1$s's &7paypal has not yet been set!"), + COMMAND_PAYPALSEE_FACTION_NOFACTION("&c&l[!] &b%1$s &7does not have a faction!"), + COMMAND_PEACEFUL_DESCRIPTION("&c&l[!]&7Set a faction to peaceful"), COMMAND_PEACEFUL_YOURS("&c&l[!]&7%1$s has %2$s your faction"), COMMAND_PEACEFUL_OTHER("&c&l[!]&7%s has %s the faction '%s'."), diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 02f6675a..4a2f6e93 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -716,6 +716,14 @@ ftnt: Enabled: true Bank-Limit: 10000 +############################################################ +# +------------------------------------------------------+ # +# | Faction PayPal | # +# +------------------------------------------------------+ # +############################################################ +fpaypal: + Enabled: true + ############################################################ # +------------------------------------------------------+ # # | Faction Checkpoints | # diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index c25bdf8c..ccf1ece0 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -227,6 +227,8 @@ permissions: description: set permanent power for a faction factions.stuck: description: teleports player outside a faction + factions.setpaypal: + description: set paypal to faction factions.power: description: show player power info factions.power.any: