diff --git a/mvn-repo/com/massivecraft/Factions/maven-metadata.xml b/mvn-repo/com/massivecraft/Factions/maven-metadata.xml index 646fe7f7..9d6d93c6 100644 --- a/mvn-repo/com/massivecraft/Factions/maven-metadata.xml +++ b/mvn-repo/com/massivecraft/Factions/maven-metadata.xml @@ -8,6 +8,6 @@ 1.6.9.5-U0.2.1-RC-1.5-BETA 1.6.9.5-U0.2.1-RC-1.5-BETA-2 - 20181221181311 + 20181221214408 diff --git a/mvn-repo/com/massivecraft/Factions/maven-metadata.xml.md5 b/mvn-repo/com/massivecraft/Factions/maven-metadata.xml.md5 index 9b8faef8..d3929235 100644 --- a/mvn-repo/com/massivecraft/Factions/maven-metadata.xml.md5 +++ b/mvn-repo/com/massivecraft/Factions/maven-metadata.xml.md5 @@ -1 +1 @@ -9bdc33366d81ebbb51cec5b2a0092585 \ No newline at end of file +e9ce0bdae55853de86510ddacb671877 \ No newline at end of file diff --git a/mvn-repo/com/massivecraft/Factions/maven-metadata.xml.sha1 b/mvn-repo/com/massivecraft/Factions/maven-metadata.xml.sha1 index d9f14fac..eb588ac4 100644 --- a/mvn-repo/com/massivecraft/Factions/maven-metadata.xml.sha1 +++ b/mvn-repo/com/massivecraft/Factions/maven-metadata.xml.sha1 @@ -1 +1 @@ -cdb7b8ec048405faa43f32d2daf226382f5952d2 \ No newline at end of file +694467945b9eeace46a9acb0cfd0fddc9c87fad8 \ No newline at end of file diff --git a/src/main/java/com/massivecraft/factions/SavageFactions.java b/src/main/java/com/massivecraft/factions/SavageFactions.java index a41b0080..2db45f72 100644 --- a/src/main/java/com/massivecraft/factions/SavageFactions.java +++ b/src/main/java/com/massivecraft/factions/SavageFactions.java @@ -508,10 +508,6 @@ public class SavageFactions extends MPlugin { @Override public List onTabComplete(CommandSender sender, Command command, String alias, String[] args) { FPlayer fPlayer = FPlayers.getInstance().getByPlayer((Player) sender); - if (!fPlayer.hasFaction()) { - fPlayer.msg("Autocomplete is not available if you do not have a faction."); - return new ArrayList(); - } List completions = new ArrayList<>(); String cmd = Conf.baseCommandAliases.isEmpty() ? "/f" : "/" + Conf.baseCommandAliases.get(0); List argsList = new ArrayList<>(Arrays.asList(args)); diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdAdmin.java b/src/main/java/com/massivecraft/factions/cmd/CmdAdmin.java index afb99361..64dc592b 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdAdmin.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdAdmin.java @@ -24,7 +24,8 @@ public class CmdAdmin extends FCommand { this.permission = Permission.ADMIN.node; this.disableOnLock = true; - senderMustBePlayer = false; + + senderMustBePlayer = false; senderMustBeMember = false; senderMustBeModerator = false; senderMustBeAdmin = false; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdBanner.java b/src/main/java/com/massivecraft/factions/cmd/CmdBanner.java index 26ae7584..57713e42 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdBanner.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdBanner.java @@ -22,7 +22,8 @@ public class CmdBanner extends FCommand { this.permission = Permission.BANNER.node; this.disableOnLock = false; - senderMustBePlayer = true; + + senderMustBePlayer = true; senderMustBeMember = false; senderMustBeModerator = false; senderMustBeColeader = true; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdChat.java b/src/main/java/com/massivecraft/factions/cmd/CmdChat.java index 53742751..c6d7b97f 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdChat.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdChat.java @@ -19,6 +19,7 @@ public class CmdChat extends FCommand { this.permission = Permission.CHAT.node; this.disableOnLock = false; + senderMustBePlayer = true; senderMustBeMember = true; senderMustBeModerator = false; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdChest.java b/src/main/java/com/massivecraft/factions/cmd/CmdChest.java index 388c29a8..0f9be022 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdChest.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdChest.java @@ -19,7 +19,8 @@ public class CmdChest extends FCommand { this.permission = Permission.CHEST.node; this.disableOnLock = false; - senderMustBePlayer = true; + + senderMustBePlayer = true; senderMustBeMember = true; senderMustBeModerator = false; senderMustBeAdmin = false; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdClaim.java b/src/main/java/com/massivecraft/factions/cmd/CmdClaim.java index 2ef27129..4f620959 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdClaim.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdClaim.java @@ -24,7 +24,8 @@ public class CmdClaim extends FCommand { this.permission = Permission.CLAIM.node; this.disableOnLock = true; - senderMustBePlayer = true; + + senderMustBePlayer = true; senderMustBeMember = false; senderMustBeModerator = false; senderMustBeColeader = false; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdClaimAt.java b/src/main/java/com/massivecraft/factions/cmd/CmdClaimAt.java index e320cdde..fd5f6b9c 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdClaimAt.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdClaimAt.java @@ -17,7 +17,8 @@ public class CmdClaimAt extends FCommand { this.permission = Permission.CLAIMAT.node; this.disableOnLock = true; - senderMustBePlayer = true; + + senderMustBePlayer = true; senderMustBeMember = true; senderMustBeModerator = false; senderMustBeColeader = false; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdClaimLine.java b/src/main/java/com/massivecraft/factions/cmd/CmdClaimLine.java index 025b05ba..61919ead 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdClaimLine.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdClaimLine.java @@ -25,7 +25,8 @@ public class CmdClaimLine extends FCommand { this.permission = Permission.CLAIM_LINE.node; this.disableOnLock = true; - senderMustBePlayer = true; + + senderMustBePlayer = true; senderMustBeMember = false; senderMustBeModerator = false; senderMustBeColeader = false; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdColeader.java b/src/main/java/com/massivecraft/factions/cmd/CmdColeader.java index eab9becf..38823f9a 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdColeader.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdColeader.java @@ -23,7 +23,8 @@ public class CmdColeader extends FCommand { this.permission = Permission.COLEADER.node; this.disableOnLock = true; - senderMustBePlayer = false; + + senderMustBePlayer = false; senderMustBeMember = true; senderMustBeModerator = false; senderMustBeAdmin = true; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdCoords.java b/src/main/java/com/massivecraft/factions/cmd/CmdCoords.java index e0776501..f5b05c44 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdCoords.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdCoords.java @@ -15,7 +15,8 @@ public class CmdCoords extends FCommand { this.permission = Permission.COORD.node; this.disableOnLock = true; - senderMustBePlayer = true; + + senderMustBePlayer = true; senderMustBeMember = true; senderMustBeModerator = false; senderMustBeColeader = false; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdDeinvite.java b/src/main/java/com/massivecraft/factions/cmd/CmdDeinvite.java index f719b59b..8cce707f 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdDeinvite.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdDeinvite.java @@ -24,7 +24,8 @@ public class CmdDeinvite extends FCommand { this.permission = Permission.DEINVITE.node; this.disableOnLock = true; - senderMustBePlayer = true; + + senderMustBePlayer = true; senderMustBeMember = false; senderMustBeModerator = true; senderMustBeColeader = false; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdDelFWarp.java b/src/main/java/com/massivecraft/factions/cmd/CmdDelFWarp.java index 50ff1578..6f592b3f 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdDelFWarp.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdDelFWarp.java @@ -17,6 +17,7 @@ public class CmdDelFWarp extends FCommand { this.senderMustBeModerator = true; this.senderMustBePlayer = true; this.permission = Permission.SETWARP.node; + } @Override diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdDescription.java b/src/main/java/com/massivecraft/factions/cmd/CmdDescription.java index 98dc3509..e37f3c06 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdDescription.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdDescription.java @@ -21,7 +21,8 @@ public class CmdDescription extends FCommand { this.permission = Permission.DESCRIPTION.node; this.disableOnLock = true; - senderMustBePlayer = true; + + senderMustBePlayer = true; senderMustBeMember = false; senderMustBeModerator = false; senderMustBeColeader = true; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdDisband.java b/src/main/java/com/massivecraft/factions/cmd/CmdDisband.java index c597beb6..dcab1906 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdDisband.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdDisband.java @@ -1,88 +1,89 @@ -package com.massivecraft.factions.cmd; - -import com.massivecraft.factions.Faction; -import com.massivecraft.factions.SavageFactions; -import com.massivecraft.factions.event.FactionDisbandEvent.PlayerDisbandReason; -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 java.util.HashMap; - - -public class CmdDisband extends FCommand { - - - private static HashMap disbandMap = new HashMap<>(); - - - public CmdDisband() { - super(); - this.aliases.add("disband"); - - //this.requiredArgs.add(""); - this.optionalArgs.put("faction tag", "yours"); - - this.permission = Permission.DISBAND.node; - this.disableOnLock = true; - - senderMustBePlayer = false; - senderMustBeMember = false; - senderMustBeModerator = false; - senderMustBeColeader = false; - senderMustBeAdmin = false; - } - - @Override - public void perform() { - // The faction, default to your own.. but null if console sender. - Faction faction = this.argAsFaction(0, fme == null ? null : myFaction); - if (faction == null) { - return; - } - - if (!fme.isAdminBypassing()) { - Access access = faction.getAccess(fme, PermissableAction.DISBAND); - if (fme.getRole() != Role.LEADER && access != Access.ALLOW) { - fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "disband " + faction.getTag()); - return; - } - } - - if (!faction.isNormal()) { - msg(TL.COMMAND_DISBAND_IMMUTABLE.toString()); - return; - } - if (faction.isPermanent()) { - msg(TL.COMMAND_DISBAND_MARKEDPERMANENT.toString()); - return; - } - - - // check for tnt before disbanding. - - if (!disbandMap.containsKey(me.getUniqueId().toString()) && faction.getTnt() > 0) { - msg(TL.COMMAND_DISBAND_CONFIRM.toString().replace("{tnt}", faction.getTnt() + "")); - disbandMap.put(me.getUniqueId().toString(), faction.getId()); - Bukkit.getScheduler().scheduleSyncDelayedTask(SavageFactions.plugin, new Runnable() { - @Override - public void run() { - disbandMap.remove(me.getUniqueId().toString()); - } - }, 200L); - } else { - //Check if the faction we asked confirmation for is the one being disbanded. - if (faction.getId().equals(disbandMap.get(me.getUniqueId().toString())) || faction.getTnt() == 0) { - faction.disband(me, PlayerDisbandReason.COMMAND); - } - } - } - - @Override - public TL getUsageTranslation() { - return TL.COMMAND_DISBAND_DESCRIPTION; - } -} +package com.massivecraft.factions.cmd; + +import com.massivecraft.factions.Faction; +import com.massivecraft.factions.SavageFactions; +import com.massivecraft.factions.event.FactionDisbandEvent.PlayerDisbandReason; +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 java.util.HashMap; + + +public class CmdDisband extends FCommand { + + + private static HashMap disbandMap = new HashMap<>(); + + + public CmdDisband() { + super(); + this.aliases.add("disband"); + + //this.requiredArgs.add(""); + this.optionalArgs.put("faction tag", "yours"); + + this.permission = Permission.DISBAND.node; + this.disableOnLock = true; + + + senderMustBePlayer = false; + senderMustBeMember = false; + senderMustBeModerator = false; + senderMustBeColeader = false; + senderMustBeAdmin = false; + } + + @Override + public void perform() { + // The faction, default to your own.. but null if console sender. + Faction faction = this.argAsFaction(0, fme == null ? null : myFaction); + if (faction == null) { + return; + } + + if (!fme.isAdminBypassing()) { + Access access = faction.getAccess(fme, PermissableAction.DISBAND); + if (fme.getRole() != Role.LEADER && access != Access.ALLOW) { + fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "disband " + faction.getTag()); + return; + } + } + + if (!faction.isNormal()) { + msg(TL.COMMAND_DISBAND_IMMUTABLE.toString()); + return; + } + if (faction.isPermanent()) { + msg(TL.COMMAND_DISBAND_MARKEDPERMANENT.toString()); + return; + } + + + // check for tnt before disbanding. + + if (!disbandMap.containsKey(me.getUniqueId().toString()) && faction.getTnt() > 0) { + msg(TL.COMMAND_DISBAND_CONFIRM.toString().replace("{tnt}", faction.getTnt() + "")); + disbandMap.put(me.getUniqueId().toString(), faction.getId()); + Bukkit.getScheduler().scheduleSyncDelayedTask(SavageFactions.plugin, new Runnable() { + @Override + public void run() { + disbandMap.remove(me.getUniqueId().toString()); + } + }, 200L); + } else { + //Check if the faction we asked confirmation for is the one being disbanded. + if (faction.getId().equals(disbandMap.get(me.getUniqueId().toString())) || faction.getTnt() == 0) { + faction.disband(me, PlayerDisbandReason.COMMAND); + } + } + } + + @Override + public TL getUsageTranslation() { + return TL.COMMAND_DISBAND_DESCRIPTION; + } +} diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFWarp.java b/src/main/java/com/massivecraft/factions/cmd/CmdFWarp.java index c330f4eb..63fd1e60 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFWarp.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFWarp.java @@ -23,7 +23,8 @@ public class CmdFWarp extends FCommand { this.optionalArgs.put("warpname", "warpname"); this.optionalArgs.put("password", "password"); - this.permission = Permission.WARP.node; + + this.permission = Permission.WARP.node; this.senderMustBeMember = true; this.senderMustBeModerator = false; } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFly.java b/src/main/java/com/massivecraft/factions/cmd/CmdFly.java index ef04243a..6b84c016 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFly.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFly.java @@ -32,7 +32,8 @@ public class CmdFly extends FCommand { this.optionalArgs.put("on/off", "flip"); - this.permission = Permission.FLY.node; + + this.permission = Permission.FLY.node; this.senderMustBeMember = true; this.senderMustBeModerator = false; } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFocus.java b/src/main/java/com/massivecraft/factions/cmd/CmdFocus.java index f281a9c0..af1b816e 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFocus.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFocus.java @@ -15,6 +15,7 @@ public class CmdFocus permission = Permission.FOCUS.node; + senderMustBePlayer = true; senderMustBeMember = false; senderMustBeModerator = true; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdGetVault.java b/src/main/java/com/massivecraft/factions/cmd/CmdGetVault.java index 5ab717ce..1b295b92 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdGetVault.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdGetVault.java @@ -17,7 +17,8 @@ public class CmdGetVault extends FCommand { this.permission = Permission.GETVAULT.node; this.disableOnLock = true; - senderMustBePlayer = true; + + senderMustBePlayer = true; senderMustBeMember = true; senderMustBeModerator = false; senderMustBeColeader = false; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdHome.java b/src/main/java/com/massivecraft/factions/cmd/CmdHome.java index f3b8822c..f508953b 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdHome.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdHome.java @@ -30,7 +30,8 @@ public class CmdHome extends FCommand { this.permission = Permission.HOME.node; this.disableOnLock = false; - senderMustBePlayer = true; + + senderMustBePlayer = true; senderMustBeMember = true; senderMustBeModerator = false; senderMustBeColeader = false; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdInspect.java b/src/main/java/com/massivecraft/factions/cmd/CmdInspect.java index 6b2af666..5bfdc23e 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdInspect.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdInspect.java @@ -12,7 +12,8 @@ public class CmdInspect extends FCommand { this.permission = Permission.INSPECT.node; this.disableOnLock = true; - senderMustBePlayer = true; + + senderMustBePlayer = true; senderMustBeMember = true; senderMustBeModerator = false; senderMustBeColeader = false; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdInvite.java b/src/main/java/com/massivecraft/factions/cmd/CmdInvite.java index 59dd63f1..61fe711b 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdInvite.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdInvite.java @@ -23,7 +23,8 @@ public class CmdInvite extends FCommand { this.permission = Permission.INVITE.node; this.disableOnLock = true; - senderMustBePlayer = true; + + senderMustBePlayer = true; senderMustBeMember = false; senderMustBeModerator = false; senderMustBeColeader = false; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdJoin.java b/src/main/java/com/massivecraft/factions/cmd/CmdJoin.java index e607dd84..68ed91cc 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdJoin.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdJoin.java @@ -18,7 +18,8 @@ public class CmdJoin extends FCommand { this.permission = Permission.JOIN.node; this.disableOnLock = true; - senderMustBePlayer = true; + + senderMustBePlayer = true; senderMustBeMember = false; senderMustBeModerator = false; senderMustBeColeader = false; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdKick.java b/src/main/java/com/massivecraft/factions/cmd/CmdKick.java index b465eae2..062abecd 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdKick.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdKick.java @@ -26,7 +26,8 @@ public class CmdKick extends FCommand { this.permission = Permission.KICK.node; this.disableOnLock = false; - senderMustBePlayer = true; + + senderMustBePlayer = true; senderMustBeMember = false; senderMustBeModerator = false; senderMustBeAdmin = false; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdLeave.java b/src/main/java/com/massivecraft/factions/cmd/CmdLeave.java index f5b6b29e..a769f87b 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdLeave.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdLeave.java @@ -15,7 +15,8 @@ public class CmdLeave extends FCommand { this.permission = Permission.LEAVE.node; this.disableOnLock = true; - senderMustBePlayer = true; + + senderMustBePlayer = true; senderMustBeMember = true; senderMustBeModerator = false; senderMustBeColeader = false; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdList.java b/src/main/java/com/massivecraft/factions/cmd/CmdList.java index fd10293e..3c233e87 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdList.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdList.java @@ -31,7 +31,8 @@ public class CmdList extends FCommand { this.permission = Permission.LIST.node; this.disableOnLock = false; - senderMustBePlayer = false; + + senderMustBePlayer = false; senderMustBeMember = false; senderMustBeModerator = false; senderMustBeColeader = false; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdLock.java b/src/main/java/com/massivecraft/factions/cmd/CmdLock.java index c27603bd..5d08429d 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdLock.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdLock.java @@ -1,43 +1,44 @@ -package com.massivecraft.factions.cmd; - -import com.massivecraft.factions.struct.Permission; -import com.massivecraft.factions.zcore.util.TL; - -public class CmdLock extends FCommand { - - // TODO: This solution needs refactoring. - /* - factions.lock: - description: use the /f lock [on/off] command to temporarily lock the data files from being overwritten - default: op - */ - - public CmdLock() { - super(); - this.aliases.add("lock"); - - //this.requiredArgs.add(""); - this.optionalArgs.put("on/off", "flip"); - - this.permission = Permission.LOCK.node; - this.disableOnLock = false; - - senderMustBePlayer = false; - senderMustBeMember = false; - senderMustBeModerator = false; - senderMustBeColeader = false; - senderMustBeAdmin = false; - } - - @Override - public void perform() { - p.setLocked(this.argAsBool(0, !p.getLocked())); - msg(p.getLocked() ? TL.COMMAND_LOCK_LOCKED : TL.COMMAND_LOCK_UNLOCKED); - } - - @Override - public TL getUsageTranslation() { - return TL.COMMAND_LOCK_DESCRIPTION; - } - -} +package com.massivecraft.factions.cmd; + +import com.massivecraft.factions.struct.Permission; +import com.massivecraft.factions.zcore.util.TL; + +public class CmdLock extends FCommand { + + // TODO: This solution needs refactoring. + /* + factions.lock: + description: use the /f lock [on/off] command to temporarily lock the data files from being overwritten + default: op + */ + + public CmdLock() { + super(); + this.aliases.add("lock"); + + //this.requiredArgs.add(""); + this.optionalArgs.put("on/off", "flip"); + + this.permission = Permission.LOCK.node; + this.disableOnLock = false; + + + senderMustBePlayer = false; + senderMustBeMember = false; + senderMustBeModerator = false; + senderMustBeColeader = false; + senderMustBeAdmin = false; + } + + @Override + public void perform() { + p.setLocked(this.argAsBool(0, !p.getLocked())); + msg(p.getLocked() ? TL.COMMAND_LOCK_LOCKED : TL.COMMAND_LOCK_UNLOCKED); + } + + @Override + public TL getUsageTranslation() { + return TL.COMMAND_LOCK_DESCRIPTION; + } + +} diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdLogins.java b/src/main/java/com/massivecraft/factions/cmd/CmdLogins.java index 08900c48..d792627b 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdLogins.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdLogins.java @@ -12,7 +12,8 @@ public class CmdLogins extends FCommand { this.aliases.add("logout"); this.aliases.add("logouts"); this.senderMustBePlayer = true; - this.senderMustBeMember = true; + + this.senderMustBeMember = true; this.permission = Permission.MONITOR_LOGINS.node; } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdLowPower.java b/src/main/java/com/massivecraft/factions/cmd/CmdLowPower.java index 8b35f45c..51ba4162 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdLowPower.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdLowPower.java @@ -14,7 +14,8 @@ public class CmdLowPower extends FCommand { this.disableOnLock = false; senderMustBePlayer = true; - senderMustBeMember = true; + + senderMustBeMember = true; senderMustBeModerator = false; senderMustBeColeader = true; senderMustBeAdmin = false; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdMap.java b/src/main/java/com/massivecraft/factions/cmd/CmdMap.java index 6b87bd66..52f6f7a1 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdMap.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdMap.java @@ -19,7 +19,8 @@ public class CmdMap extends FCommand { this.permission = Permission.MAP.node; this.disableOnLock = false; - senderMustBePlayer = true; + + senderMustBePlayer = true; senderMustBeMember = false; senderMustBeModerator = false; senderMustBeColeader = false; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdMapHeight.java b/src/main/java/com/massivecraft/factions/cmd/CmdMapHeight.java index 7563f63e..72365fb2 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdMapHeight.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdMapHeight.java @@ -15,7 +15,8 @@ public class CmdMapHeight extends FCommand { this.permission = Permission.MAPHEIGHT.node; - this.senderMustBePlayer = true; + + this.senderMustBePlayer = true; } @Override diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdMod.java b/src/main/java/com/massivecraft/factions/cmd/CmdMod.java index ee78ab8c..0aaa25f0 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdMod.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdMod.java @@ -24,7 +24,8 @@ public class CmdMod extends FCommand { this.permission = Permission.MOD.node; this.disableOnLock = true; - senderMustBePlayer = false; + + senderMustBePlayer = false; senderMustBeMember = true; senderMustBeModerator = false; senderMustBeColeader = true; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdMoney.java b/src/main/java/com/massivecraft/factions/cmd/CmdMoney.java index 4c0da5f0..b1cd4e19 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdMoney.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdMoney.java @@ -35,6 +35,7 @@ public class CmdMoney extends FCommand { this.addSubCommand(this.cmdMoneyTransferFf); this.addSubCommand(this.cmdMoneyTransferFp); this.addSubCommand(this.cmdMoneyTransferPf); + } @Override diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdMoneyBalance.java b/src/main/java/com/massivecraft/factions/cmd/CmdMoneyBalance.java index db30f81f..fc3c86a9 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdMoneyBalance.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdMoneyBalance.java @@ -18,7 +18,8 @@ public class CmdMoneyBalance extends FCommand { this.permission = Permission.MONEY_BALANCE.node; this.setHelpShort(TL.COMMAND_MONEYBALANCE_SHORT.toString()); - senderMustBePlayer = false; + + senderMustBePlayer = false; senderMustBeMember = false; senderMustBeModerator = false; senderMustBeAdmin = false; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdMoneyDeposit.java b/src/main/java/com/massivecraft/factions/cmd/CmdMoneyDeposit.java index ef2b9110..258ab9e7 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdMoneyDeposit.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdMoneyDeposit.java @@ -21,7 +21,8 @@ public class CmdMoneyDeposit extends FCommand { this.permission = Permission.MONEY_DEPOSIT.node; - senderMustBePlayer = true; + + senderMustBePlayer = true; senderMustBeMember = false; senderMustBeModerator = false; senderMustBeColeader = false; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdMoneyTransferFf.java b/src/main/java/com/massivecraft/factions/cmd/CmdMoneyTransferFf.java index 24c8fc9a..5b4edaab 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdMoneyTransferFf.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdMoneyTransferFf.java @@ -23,7 +23,8 @@ public class CmdMoneyTransferFf extends FCommand { this.permission = Permission.MONEY_F2F.node; - senderMustBePlayer = false; + + senderMustBePlayer = false; senderMustBeMember = false; senderMustBeModerator = false; senderMustBeColeader = false; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdMoneyTransferFp.java b/src/main/java/com/massivecraft/factions/cmd/CmdMoneyTransferFp.java index 10d8855e..c16114f3 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdMoneyTransferFp.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdMoneyTransferFp.java @@ -22,7 +22,8 @@ public class CmdMoneyTransferFp extends FCommand { this.permission = Permission.MONEY_F2P.node; - senderMustBePlayer = false; + + senderMustBePlayer = false; senderMustBeMember = false; senderMustBeModerator = false; senderMustBeColeader = false; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdMoneyTransferPf.java b/src/main/java/com/massivecraft/factions/cmd/CmdMoneyTransferPf.java index ff549e87..7adb3d27 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdMoneyTransferPf.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdMoneyTransferPf.java @@ -22,7 +22,8 @@ public class CmdMoneyTransferPf extends FCommand { this.permission = Permission.MONEY_P2F.node; - senderMustBePlayer = false; + + senderMustBePlayer = false; senderMustBeMember = false; senderMustBeModerator = false; senderMustBeColeader = false; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdMoneyWithdraw.java b/src/main/java/com/massivecraft/factions/cmd/CmdMoneyWithdraw.java index fcbbddcd..da6d7332 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdMoneyWithdraw.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdMoneyWithdraw.java @@ -22,7 +22,8 @@ public class CmdMoneyWithdraw extends FCommand { this.permission = Permission.MONEY_WITHDRAW.node; - senderMustBePlayer = true; + + senderMustBePlayer = true; senderMustBeMember = false; senderMustBeModerator = false; senderMustBeColeader = false; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdNear.java b/src/main/java/com/massivecraft/factions/cmd/CmdNear.java index e58c2cb4..55216d26 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdNear.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdNear.java @@ -16,7 +16,8 @@ public class CmdNear extends FCommand { this.disableOnLock = true; - senderMustBePlayer = true; + + senderMustBePlayer = true; senderMustBeMember = true; senderMustBeModerator = false; senderMustBeColeader = false; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdOpen.java b/src/main/java/com/massivecraft/factions/cmd/CmdOpen.java index 460e594b..a2a28143 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdOpen.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdOpen.java @@ -18,7 +18,8 @@ public class CmdOpen extends FCommand { this.permission = Permission.OPEN.node; this.disableOnLock = false; - senderMustBePlayer = true; + + senderMustBePlayer = true; senderMustBeMember = false; senderMustBeModerator = false; senderMustBeColeader = true; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdOwner.java b/src/main/java/com/massivecraft/factions/cmd/CmdOwner.java index fa23b088..77762b0b 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdOwner.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdOwner.java @@ -18,7 +18,8 @@ public class CmdOwner extends FCommand { this.permission = Permission.OWNER.node; this.disableOnLock = true; - senderMustBePlayer = true; + + senderMustBePlayer = true; senderMustBeMember = false; senderMustBeModerator = false; senderMustBeColeader = false; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdOwnerList.java b/src/main/java/com/massivecraft/factions/cmd/CmdOwnerList.java index 4bcb5e02..0d7ab2ef 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdOwnerList.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdOwnerList.java @@ -19,7 +19,8 @@ public class CmdOwnerList extends FCommand { this.permission = Permission.OWNERLIST.node; this.disableOnLock = false; - senderMustBePlayer = true; + + senderMustBePlayer = true; senderMustBeMember = false; senderMustBeModerator = false; senderMustBeColeader = false; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdPaypalSee.java b/src/main/java/com/massivecraft/factions/cmd/CmdPaypalSee.java index 0e86ba7c..ade8d076 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdPaypalSee.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdPaypalSee.java @@ -17,6 +17,7 @@ public class CmdPaypalSee extends FCommand { senderMustBeModerator = false; senderMustBeColeader = false; senderMustBeAdmin = false; + } public void perform() { diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdPaypalSet.java b/src/main/java/com/massivecraft/factions/cmd/CmdPaypalSet.java index df792b59..35456fbd 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdPaypalSet.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdPaypalSet.java @@ -17,6 +17,7 @@ public class CmdPaypalSet extends FCommand { this.senderMustBeModerator = false; this.senderMustBeColeader = true; this.senderMustBeAdmin = false; + } public void perform() { diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdPeaceful.java b/src/main/java/com/massivecraft/factions/cmd/CmdPeaceful.java index ca966050..02f6bb29 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdPeaceful.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdPeaceful.java @@ -1,61 +1,62 @@ -package com.massivecraft.factions.cmd; - -import com.massivecraft.factions.FPlayer; -import com.massivecraft.factions.FPlayers; -import com.massivecraft.factions.Faction; -import com.massivecraft.factions.struct.Permission; -import com.massivecraft.factions.zcore.util.TL; - -public class CmdPeaceful extends FCommand { - - public CmdPeaceful() { - super(); - this.aliases.add("peaceful"); - - this.requiredArgs.add("faction tag"); - //this.optionalArgs.put("", ""); - - this.permission = Permission.SET_PEACEFUL.node; - this.disableOnLock = true; - - senderMustBePlayer = false; - senderMustBeMember = false; - senderMustBeModerator = false; - senderMustBeColeader = false; - senderMustBeAdmin = false; - } - - @Override - public void perform() { - Faction faction = this.argAsFaction(0); - if (faction == null) { - return; - } - - String change; - if (faction.isPeaceful()) { - change = TL.COMMAND_PEACEFUL_REVOKE.toString(); - faction.setPeaceful(false); - } else { - change = TL.COMMAND_PEACEFUL_GRANT.toString(); - faction.setPeaceful(true); - } - - // Inform all players - for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers()) { - String blame = (fme == null ? TL.GENERIC_SERVERADMIN.toString() : fme.describeTo(fplayer, true)); - if (fplayer.getFaction() == faction) { - fplayer.msg(TL.COMMAND_PEACEFUL_YOURS, blame, change); - } else { - fplayer.msg(TL.COMMAND_PEACEFUL_OTHER, blame, change, faction.getTag(fplayer)); - } - } - - } - - @Override - public TL getUsageTranslation() { - return TL.COMMAND_PEACEFUL_DESCRIPTION; - } - -} +package com.massivecraft.factions.cmd; + +import com.massivecraft.factions.FPlayer; +import com.massivecraft.factions.FPlayers; +import com.massivecraft.factions.Faction; +import com.massivecraft.factions.struct.Permission; +import com.massivecraft.factions.zcore.util.TL; + +public class CmdPeaceful extends FCommand { + + public CmdPeaceful() { + super(); + this.aliases.add("peaceful"); + + this.requiredArgs.add("faction tag"); + //this.optionalArgs.put("", ""); + + this.permission = Permission.SET_PEACEFUL.node; + this.disableOnLock = true; + + senderMustBePlayer = false; + senderMustBeMember = false; + senderMustBeModerator = false; + senderMustBeColeader = false; + senderMustBeAdmin = false; + + } + + @Override + public void perform() { + Faction faction = this.argAsFaction(0); + if (faction == null) { + return; + } + + String change; + if (faction.isPeaceful()) { + change = TL.COMMAND_PEACEFUL_REVOKE.toString(); + faction.setPeaceful(false); + } else { + change = TL.COMMAND_PEACEFUL_GRANT.toString(); + faction.setPeaceful(true); + } + + // Inform all players + for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers()) { + String blame = (fme == null ? TL.GENERIC_SERVERADMIN.toString() : fme.describeTo(fplayer, true)); + if (fplayer.getFaction() == faction) { + fplayer.msg(TL.COMMAND_PEACEFUL_YOURS, blame, change); + } else { + fplayer.msg(TL.COMMAND_PEACEFUL_OTHER, blame, change, faction.getTag(fplayer)); + } + } + + } + + @Override + public TL getUsageTranslation() { + return TL.COMMAND_PEACEFUL_DESCRIPTION; + } + +} diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdPerm.java b/src/main/java/com/massivecraft/factions/cmd/CmdPerm.java index cde762ea..6c942012 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdPerm.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdPerm.java @@ -35,6 +35,7 @@ public class CmdPerm extends FCommand { senderMustBeModerator = false; senderMustBeColeader = false; senderMustBeAdmin = true; + } @Override diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdPower.java b/src/main/java/com/massivecraft/factions/cmd/CmdPower.java index 5a735ebb..985d8770 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdPower.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdPower.java @@ -23,6 +23,7 @@ public class CmdPower extends FCommand { senderMustBeModerator = false; senderMustBeColeader = false; senderMustBeAdmin = false; + } @Override diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdRules.java b/src/main/java/com/massivecraft/factions/cmd/CmdRules.java index 91dbfea6..d0c75666 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdRules.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdRules.java @@ -24,6 +24,7 @@ public class CmdRules extends FCommand { senderMustBeModerator = false; senderMustBeColeader = true; senderMustBeAdmin = false; + } @Override diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdSafeunclaimall.java b/src/main/java/com/massivecraft/factions/cmd/CmdSafeunclaimall.java index 180dc9c5..520708f0 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdSafeunclaimall.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdSafeunclaimall.java @@ -27,6 +27,7 @@ public class CmdSafeunclaimall extends FCommand { senderMustBeColeader = false; senderMustBeAdmin = false; + } @Override diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdSeeChunk.java b/src/main/java/com/massivecraft/factions/cmd/CmdSeeChunk.java index 954900de..8453de7e 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdSeeChunk.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdSeeChunk.java @@ -1,153 +1,154 @@ -package com.massivecraft.factions.cmd; - - -import com.massivecraft.factions.FLocation; -import com.massivecraft.factions.SavageFactions; -import com.massivecraft.factions.struct.Permission; -import com.massivecraft.factions.util.Particles.ParticleEffect; -import com.massivecraft.factions.util.VisualizeUtil; -import com.massivecraft.factions.zcore.util.TL; -import org.bukkit.*; -import org.bukkit.entity.Player; - -import java.util.Arrays; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; - -public class CmdSeeChunk extends FCommand { - - //Used a hashmap cuz imma make a particle selection gui later, will store it where the boolean is rn. - public static HashMap seeChunkMap = new HashMap<>(); - Long interval = 10L; - private boolean useParticles; - private int length; - private ParticleEffect effect; - private int taskID = - 1; - - - //I remade it cause of people getting mad that I had the same seechunk as drtshock - - - public CmdSeeChunk() { - super(); - aliases.add("seechunk"); - aliases.add("sc"); - - permission = Permission.SEECHUNK.node; - - senderMustBePlayer = true; - senderMustBeMember = false; - senderMustBeModerator = false; - senderMustBeAdmin = false; - - this.useParticles = p.getConfig().getBoolean("see-chunk.particles", true); - interval = SavageFactions.plugin.getConfig().getLong("see-chunk.interval", 10L); - if (effect == null) { - effect = ParticleEffect.REDSTONE; - } - - } - - @Override - public void perform() { - if (seeChunkMap.containsKey(me.getName())) { - seeChunkMap.remove(me.getName()); - msg(TL.COMMAND_SEECHUNK_DISABLED); - } else { - seeChunkMap.put(me.getName(), true); - msg(TL.COMMAND_SEECHUNK_ENABLED); - manageTask(); - } - } - - private void manageTask() { - if (taskID != - 1) { - if (seeChunkMap.keySet().size() == 0) { - Bukkit.getScheduler().cancelTask(taskID); - taskID = - 1; - } - } else { - startTask(); - } - } - - private void startTask() { - taskID = Bukkit.getScheduler().scheduleSyncRepeatingTask(SavageFactions.plugin, new Runnable() { - @Override - public void run() { - Iterator itr = seeChunkMap.keySet().iterator(); - while (itr.hasNext()) { - Object nameObject = itr.next(); - String name = nameObject + ""; - Player player = Bukkit.getPlayer(name); - showBorders(player); - } - manageTask(); - } - }, 0, interval); - } - - private void showBorders(Player me) { - World world = me.getWorld(); - FLocation flocation = new FLocation(me); - int chunkX = (int) flocation.getX(); - int chunkZ = (int) flocation.getZ(); - - int blockX; - int blockZ; - - blockX = chunkX * 16; - blockZ = chunkZ * 16; - showPillar(me, world, blockX, blockZ); - - - blockX = chunkX * 16 + 15; - blockZ = chunkZ * 16; - showPillar(me, world, blockX, blockZ); - - blockX = chunkX * 16; - blockZ = chunkZ * 16 + 15; - showPillar(me, world, blockX, blockZ); - - blockX = chunkX * 16 + 15; - blockZ = chunkZ * 16 + 15; - showPillar(me, world, blockX, blockZ); - } - - private void showPillar(Player player, World world, int blockX, int blockZ) { - List onePlayer = Arrays.asList(player); - for (int blockY = 0; blockY < player.getLocation().getBlockY() + 30; blockY++) { - Location loc = new Location(world, blockX, blockY, blockZ).add(0.5, 0, 0.5); - if (loc.getBlock().getType() != Material.AIR) { - continue; - } - if (useParticles) { - if (SavageFactions.plugin.useNonPacketParticles) { - // Dust options only exists in the 1.13 API, so we use an - // alternative method to achieve this in lower versions. - if (SavageFactions.plugin.mc113) { - player.spawnParticle(Particle.REDSTONE, loc, 0, new Particle.DustOptions(Color.RED, 1)); - } else { - player.getWorld().spawnParticle(Particle.REDSTONE, loc, 0, 255, 0, 0, 1); - } - - } else { - this.effect.display(0, 0, 0, 0, 1, loc, player); - } - - - } else { - Material type = blockY % 5 == 0 ? SavageFactions.plugin.REDSTONE_LAMP_ON : SavageFactions.plugin.STAINED_GLASS; - VisualizeUtil.addLocation(player, loc, type); - } - } - } - - - @Override - public TL getUsageTranslation() { - return TL.GENERIC_PLACEHOLDER; - } - +package com.massivecraft.factions.cmd; + + +import com.massivecraft.factions.FLocation; +import com.massivecraft.factions.SavageFactions; +import com.massivecraft.factions.struct.Permission; +import com.massivecraft.factions.util.Particles.ParticleEffect; +import com.massivecraft.factions.util.VisualizeUtil; +import com.massivecraft.factions.zcore.util.TL; +import org.bukkit.*; +import org.bukkit.entity.Player; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; + +public class CmdSeeChunk extends FCommand { + + //Used a hashmap cuz imma make a particle selection gui later, will store it where the boolean is rn. + public static HashMap seeChunkMap = new HashMap<>(); + Long interval = 10L; + private boolean useParticles; + private int length; + private ParticleEffect effect; + private int taskID = - 1; + + + //I remade it cause of people getting mad that I had the same seechunk as drtshock + + + public CmdSeeChunk() { + super(); + aliases.add("seechunk"); + aliases.add("sc"); + + permission = Permission.SEECHUNK.node; + + senderMustBePlayer = true; + senderMustBeMember = false; + senderMustBeModerator = false; + senderMustBeAdmin = false; + + + this.useParticles = p.getConfig().getBoolean("see-chunk.particles", true); + interval = SavageFactions.plugin.getConfig().getLong("see-chunk.interval", 10L); + if (effect == null) { + effect = ParticleEffect.REDSTONE; + } + + } + + @Override + public void perform() { + if (seeChunkMap.containsKey(me.getName())) { + seeChunkMap.remove(me.getName()); + msg(TL.COMMAND_SEECHUNK_DISABLED); + } else { + seeChunkMap.put(me.getName(), true); + msg(TL.COMMAND_SEECHUNK_ENABLED); + manageTask(); + } + } + + private void manageTask() { + if (taskID != - 1) { + if (seeChunkMap.keySet().size() == 0) { + Bukkit.getScheduler().cancelTask(taskID); + taskID = - 1; + } + } else { + startTask(); + } + } + + private void startTask() { + taskID = Bukkit.getScheduler().scheduleSyncRepeatingTask(SavageFactions.plugin, new Runnable() { + @Override + public void run() { + Iterator itr = seeChunkMap.keySet().iterator(); + while (itr.hasNext()) { + Object nameObject = itr.next(); + String name = nameObject + ""; + Player player = Bukkit.getPlayer(name); + showBorders(player); + } + manageTask(); + } + }, 0, interval); + } + + private void showBorders(Player me) { + World world = me.getWorld(); + FLocation flocation = new FLocation(me); + int chunkX = (int) flocation.getX(); + int chunkZ = (int) flocation.getZ(); + + int blockX; + int blockZ; + + blockX = chunkX * 16; + blockZ = chunkZ * 16; + showPillar(me, world, blockX, blockZ); + + + blockX = chunkX * 16 + 15; + blockZ = chunkZ * 16; + showPillar(me, world, blockX, blockZ); + + blockX = chunkX * 16; + blockZ = chunkZ * 16 + 15; + showPillar(me, world, blockX, blockZ); + + blockX = chunkX * 16 + 15; + blockZ = chunkZ * 16 + 15; + showPillar(me, world, blockX, blockZ); + } + + private void showPillar(Player player, World world, int blockX, int blockZ) { + List onePlayer = Arrays.asList(player); + for (int blockY = 0; blockY < player.getLocation().getBlockY() + 30; blockY++) { + Location loc = new Location(world, blockX, blockY, blockZ).add(0.5, 0, 0.5); + if (loc.getBlock().getType() != Material.AIR) { + continue; + } + if (useParticles) { + if (SavageFactions.plugin.useNonPacketParticles) { + // Dust options only exists in the 1.13 API, so we use an + // alternative method to achieve this in lower versions. + if (SavageFactions.plugin.mc113) { + player.spawnParticle(Particle.REDSTONE, loc, 0, new Particle.DustOptions(Color.RED, 1)); + } else { + player.getWorld().spawnParticle(Particle.REDSTONE, loc, 0, 255, 0, 0, 1); + } + + } else { + this.effect.display(0, 0, 0, 0, 1, loc, player); + } + + + } else { + Material type = blockY % 5 == 0 ? SavageFactions.plugin.REDSTONE_LAMP_ON : SavageFactions.plugin.STAINED_GLASS; + VisualizeUtil.addLocation(player, loc, type); + } + } + } + + + @Override + public TL getUsageTranslation() { + return TL.GENERIC_PLACEHOLDER; + } + } \ No newline at end of file diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdSetBanner.java b/src/main/java/com/massivecraft/factions/cmd/CmdSetBanner.java index c73e29ac..1558b54d 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdSetBanner.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdSetBanner.java @@ -16,6 +16,7 @@ public class CmdSetBanner extends FCommand { senderMustBeModerator = false; senderMustBeAdmin = true; + } public void perform() { diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdSetDefaultRole.java b/src/main/java/com/massivecraft/factions/cmd/CmdSetDefaultRole.java index 9d029250..52593ebb 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdSetDefaultRole.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdSetDefaultRole.java @@ -19,7 +19,8 @@ public class CmdSetDefaultRole extends FCommand { this.senderMustBePlayer = true; senderMustBeColeader = false; - this.permission = Permission.DEFAULTRANK.node; + + this.permission = Permission.DEFAULTRANK.node; } @Override diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdSetFWarp.java b/src/main/java/com/massivecraft/factions/cmd/CmdSetFWarp.java index e3910af5..2c1a65c9 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdSetFWarp.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdSetFWarp.java @@ -23,7 +23,8 @@ public class CmdSetFWarp extends FCommand { this.senderMustBeMember = true; this.senderMustBeModerator = false; - this.senderMustBePlayer = true; + + this.senderMustBePlayer = true; this.permission = Permission.SETWARP.node; } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdSetMaxVaults.java b/src/main/java/com/massivecraft/factions/cmd/CmdSetMaxVaults.java index ed898836..fbf64c3a 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdSetMaxVaults.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdSetMaxVaults.java @@ -22,6 +22,7 @@ public class CmdSetMaxVaults extends FCommand { senderMustBeModerator = false; senderMustBeColeader = false; senderMustBeAdmin = false; + } @Override diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdSethome.java b/src/main/java/com/massivecraft/factions/cmd/CmdSethome.java index 2483b35d..b9440e05 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdSethome.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdSethome.java @@ -26,6 +26,7 @@ public class CmdSethome extends FCommand { senderMustBeModerator = false; senderMustBeColeader = false; senderMustBeAdmin = false; + } @Override diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdShowClaims.java b/src/main/java/com/massivecraft/factions/cmd/CmdShowClaims.java index 22e47e3a..d5180a63 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdShowClaims.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdShowClaims.java @@ -21,6 +21,7 @@ public class CmdShowClaims extends FCommand { this.senderMustBePlayer = true; + } @Override @@ -34,7 +35,7 @@ public class CmdShowClaims extends FCommand { for (String world : chunkMap.keySet()) { String message = TL.COMMAND_SHOWCLAIMS_FORMAT.toString().replace("{world}", world); sendMessage(message.replace("{chunks}", "")); // made {chunks} blank as I removed the placeholder and people wont update their config :shrug: - StringBuilder chunks = new StringBuilder(""); + StringBuilder chunks = new StringBuilder(); for (String chunkString : chunkMap.get(world)) { chunks.append(chunkString + ", "); if (chunks.toString().length() >= 2000) { diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdShowInvites.java b/src/main/java/com/massivecraft/factions/cmd/CmdShowInvites.java index 3f8ab4ee..4666ff03 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdShowInvites.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdShowInvites.java @@ -17,6 +17,7 @@ public class CmdShowInvites extends FCommand { senderMustBePlayer = true; senderMustBeMember = true; + } @Override diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdStatus.java b/src/main/java/com/massivecraft/factions/cmd/CmdStatus.java index f9d448b0..bf65781c 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdStatus.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdStatus.java @@ -21,6 +21,7 @@ public class CmdStatus extends FCommand { senderMustBeMember = true; senderMustBeModerator = false; senderMustBeAdmin = false; + } @Override @@ -29,7 +30,7 @@ public class CmdStatus extends FCommand { for (FPlayer fp : myFaction.getFPlayers()) { 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()) + " / " + String.valueOf(fp.getPowerMaxRounded()) + ChatColor.RESET; + String power = ChatColor.YELLOW + String.valueOf(fp.getPowerRounded()) + " / " + fp.getPowerMaxRounded() + ChatColor.RESET; ret.add(String.format(TL.COMMAND_STATUS_FORMAT.toString(), ChatColor.GOLD + fp.getRole().getPrefix() + fp.getName() + ChatColor.RESET, power, last).trim()); } fme.sendMessage(ret); diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdStealth.java b/src/main/java/com/massivecraft/factions/cmd/CmdStealth.java index a1e95c28..fe391273 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdStealth.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdStealth.java @@ -17,6 +17,7 @@ public class CmdStealth extends FCommand { this.senderMustBeModerator = false; this.senderMustBeColeader = false; this.senderMustBeAdmin = false; + } public void perform() { diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdStuck.java b/src/main/java/com/massivecraft/factions/cmd/CmdStuck.java index e04aa5f1..57b60fb9 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdStuck.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdStuck.java @@ -27,6 +27,7 @@ public class CmdStuck extends FCommand { senderMustBeMember = false; senderMustBeModerator = false; senderMustBeAdmin = false; + } @Override diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdTag.java b/src/main/java/com/massivecraft/factions/cmd/CmdTag.java index 6de99040..bc65ef26 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdTag.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdTag.java @@ -26,6 +26,7 @@ public class CmdTag extends FCommand { senderMustBeMember = false; senderMustBeModerator = true; senderMustBeAdmin = false; + } @Override diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdTitle.java b/src/main/java/com/massivecraft/factions/cmd/CmdTitle.java index acd7c6a9..2d716dee 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdTitle.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdTitle.java @@ -21,6 +21,7 @@ public class CmdTitle extends FCommand { senderMustBeMember = false; senderMustBeModerator = true; senderMustBeAdmin = false; + } @Override diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdTnt.java b/src/main/java/com/massivecraft/factions/cmd/CmdTnt.java index 7c858339..66a80829 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdTnt.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdTnt.java @@ -27,6 +27,7 @@ public class CmdTnt extends FCommand { senderMustBeMember = false; senderMustBeModerator = true; senderMustBeAdmin = false; + } @Override diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdTntFill.java b/src/main/java/com/massivecraft/factions/cmd/CmdTntFill.java index 407c815f..820a627d 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdTntFill.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdTntFill.java @@ -30,6 +30,7 @@ public class CmdTntFill extends FCommand { senderMustBeMember = true; senderMustBeModerator = false; senderMustBeAdmin = false; + } @Override diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdToggleAllianceChat.java b/src/main/java/com/massivecraft/factions/cmd/CmdToggleAllianceChat.java index 5bea5ac8..95664b6d 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdToggleAllianceChat.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdToggleAllianceChat.java @@ -21,6 +21,7 @@ public class CmdToggleAllianceChat extends FCommand { senderMustBeMember = true; senderMustBeModerator = false; senderMustBeAdmin = false; + } @Override diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdTop.java b/src/main/java/com/massivecraft/factions/cmd/CmdTop.java index 437a56d1..8749a24c 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdTop.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdTop.java @@ -30,9 +30,11 @@ public class CmdTop extends FCommand { senderMustBeMember = false; senderMustBeModerator = false; senderMustBeAdmin = false; + } - @Override + + @Override public void perform() { // Can sort by: money, members, online, allies, enemies, power, land. // Get all Factions and remove non player ones. diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdTpBanner.java b/src/main/java/com/massivecraft/factions/cmd/CmdTpBanner.java index 5f2d1e74..76c4306b 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdTpBanner.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdTpBanner.java @@ -21,6 +21,7 @@ public class CmdTpBanner extends FCommand { senderMustBeModerator = false; senderMustBeColeader = false; senderMustBeAdmin = false; + } @Override diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdUnban.java b/src/main/java/com/massivecraft/factions/cmd/CmdUnban.java index 5cf9a581..349afe93 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdUnban.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdUnban.java @@ -21,7 +21,8 @@ public class CmdUnban extends FCommand { senderMustBePlayer = true; senderMustBeMember = false; senderMustBeModerator = false; - senderMustBeAdmin = false; + + senderMustBeAdmin = false; } @Override diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdUnclaim.java b/src/main/java/com/massivecraft/factions/cmd/CmdUnclaim.java index 2e23ee75..66236407 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdUnclaim.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdUnclaim.java @@ -27,6 +27,7 @@ public class CmdUnclaim extends FCommand { senderMustBeMember = false; senderMustBeModerator = false; senderMustBeAdmin = false; + } @Override diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdUnclaimall.java b/src/main/java/com/massivecraft/factions/cmd/CmdUnclaimall.java index dbe0614e..5d8efb28 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdUnclaimall.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdUnclaimall.java @@ -25,6 +25,7 @@ public class CmdUnclaimall extends FCommand { senderMustBeMember = false; senderMustBeModerator = true; senderMustBeAdmin = false; + } @Override diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdUpgrades.java b/src/main/java/com/massivecraft/factions/cmd/CmdUpgrades.java index 57c25067..ee8ac071 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdUpgrades.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdUpgrades.java @@ -21,6 +21,7 @@ public class CmdUpgrades extends FCommand { senderMustBeMember = true; senderMustBeModerator = false; senderMustBeAdmin = false; + } @Override diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdVault.java b/src/main/java/com/massivecraft/factions/cmd/CmdVault.java index 77478f28..55fd8150 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdVault.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdVault.java @@ -27,6 +27,7 @@ public class CmdVault extends FCommand { senderMustBeMember = true; senderMustBeModerator = false; senderMustBeAdmin = false; + } @Override diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdWarunclaimall.java b/src/main/java/com/massivecraft/factions/cmd/CmdWarunclaimall.java index f2ceeae5..f69b3390 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdWarunclaimall.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdWarunclaimall.java @@ -25,6 +25,7 @@ public class CmdWarunclaimall extends FCommand { senderMustBeMember = false; senderMustBeModerator = false; senderMustBeAdmin = false; + } @Override diff --git a/src/main/java/com/massivecraft/factions/cmd/FCommand.java b/src/main/java/com/massivecraft/factions/cmd/FCommand.java index 1ab567f5..2f1f21b0 100644 --- a/src/main/java/com/massivecraft/factions/cmd/FCommand.java +++ b/src/main/java/com/massivecraft/factions/cmd/FCommand.java @@ -26,6 +26,7 @@ public abstract class FCommand extends MCommand { public boolean senderMustBeAdmin; public boolean senderMustBeColeader; + public boolean isMoneyCommand; public FCommand() { @@ -98,22 +99,30 @@ public abstract class FCommand extends MCommand { } if (!fme.hasFaction()) { - sender.sendMessage(p.txt.parse("You are not member of any faction.")); + if (informSenderIfNot) { + sender.sendMessage(p.txt.parse("You are not member of any faction.")); + } return false; } if (this.senderMustBeModerator && !fme.getRole().isAtLeast(Role.MODERATOR)) { - sender.sendMessage(p.txt.parse("Only faction moderators can %s.", this.getHelpShort())); + if (informSenderIfNot) { + sender.sendMessage(p.txt.parse("Only faction moderators can %s.", this.getHelpShort())); + } return false; } if (this.senderMustBeColeader && !fme.getRole().isAtLeast(Role.COLEADER)) { - sender.sendMessage(p.txt.parse("Only faction coleaders can %s.", this.getHelpShort())); + if (informSenderIfNot) { + sender.sendMessage(p.txt.parse("Only faction coleaders can %s.", this.getHelpShort())); + } return false; } if (this.senderMustBeAdmin && !fme.getRole().isAtLeast(Role.LEADER)) { - sender.sendMessage(p.txt.parse("Only faction admins can %s.", this.getHelpShort())); + if (informSenderIfNot) { + sender.sendMessage(p.txt.parse("Only faction admins can %s.", this.getHelpShort())); + } return false; } diff --git a/src/main/java/com/massivecraft/factions/zcore/MCommand.java b/src/main/java/com/massivecraft/factions/zcore/MCommand.java index 454d772e..74bbf4ac 100644 --- a/src/main/java/com/massivecraft/factions/zcore/MCommand.java +++ b/src/main/java/com/massivecraft/factions/zcore/MCommand.java @@ -1,482 +1,486 @@ -package com.massivecraft.factions.zcore; - -import com.massivecraft.factions.FPlayer; -import com.massivecraft.factions.Faction; -import com.massivecraft.factions.SavageFactions; -import com.massivecraft.factions.integration.Econ; -import com.massivecraft.factions.zcore.util.TL; -import com.massivecraft.factions.zcore.util.TextUtil; -import mkremins.fanciful.FancyMessage; -import org.apache.commons.lang.time.DurationFormatUtils; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map.Entry; -import java.util.UUID; - - -public abstract class MCommand { - - public T p; - - // The sub-commands to this command - public List> subCommands; - // The different names this commands will react to - public List aliases; - public boolean allowNoSlashAccess; - // Information on the args - public List requiredArgs; - public LinkedHashMap optionalArgs; - public boolean errorOnToManyArgs = true; - public List helpLong; - public CommandVisibility visibility; - // Some information on permissions - public boolean senderMustBePlayer; - public String permission; - // Information available on execution of the command - public CommandSender sender; // Will always be set - public Player me; // Will only be set when the sender is a player - public boolean senderIsConsole; - public List args; // Will contain the arguments, or and empty list if there are none. - public List> commandChain = new ArrayList<>(); // The command chain used to execute this command - // FIELD: Help Short - // This field may be left blank and will in such case be loaded from the permissions node instead. - // Thus make sure the permissions node description is an action description like "eat hamburgers" or "do admin stuff". - private String helpShort; - - public MCommand(T p) { - this.p = p; - - this.permission = null; - - this.allowNoSlashAccess = false; - - this.subCommands = new ArrayList<>(); - this.aliases = new ArrayList<>(); - - this.requiredArgs = new ArrayList<>(); - this.optionalArgs = new LinkedHashMap<>(); - - this.helpShort = null; - this.helpLong = new ArrayList<>(); - this.visibility = CommandVisibility.VISIBLE; - } - - public void addSubCommand(MCommand subCommand) { - subCommand.commandChain.addAll(this.commandChain); - subCommand.commandChain.add(this); - this.subCommands.add(subCommand); - } - - public String getHelpShort() { - return this.helpShort != null ? this.helpShort:getUsageTranslation().toString(); - } - - public void setHelpShort(String val) { - this.helpShort = val; - } - - public abstract TL getUsageTranslation(); - - public void setCommandSender(CommandSender sender) - { - this.sender = sender; - if (sender instanceof Player) { - this.me = (Player) sender; - this.senderIsConsole = false; - } else { - this.me = null; - this.senderIsConsole = true; - } - } - - // The commandChain is a list of the parent command chain used to get to this command. - public void execute(CommandSender sender, List args, List> commandChain) { - // Set the execution-time specific variables - setCommandSender(sender); - this.args = args; - this.commandChain = commandChain; - - // Is there a matching sub command? - if (args.size() > 0) { - for (MCommand subCommand : this.subCommands) { - if (subCommand.aliases.contains(args.get(0).toLowerCase())) { - args.remove(0); - commandChain.add(this); - subCommand.execute(sender, args, commandChain); - return; - } - } - } - - if (!validCall(this.sender, this.args)) { - return; - } - - if (!this.isEnabled()) { - return; - } - - perform(); - } - - public void execute(CommandSender sender, List args) { - execute(sender, args, new ArrayList>()); - } - - // This is where the command action is performed. - public abstract void perform(); - - - // -------------------------------------------- // - // Call Validation - // -------------------------------------------- // - - /** - * In this method we validate that all prerequisites to perform this command has been met. - * - * @param sender of the command - * @param args of the command - * @return true if valid, false if not. - */ - // TODO: There should be a boolean for silence - public boolean validCall(CommandSender sender, List args) { - return validSenderType(sender, true) && validSenderPermissions(sender, true) && validArgs(args, sender); - } - - public boolean isEnabled() { - return true; - } - - public boolean validSenderType(CommandSender sender, boolean informSenderIfNot) { - if (this.senderMustBePlayer && !(sender instanceof Player)) { - if (informSenderIfNot) { - msg(TL.GENERIC_PLAYERONLY); - } - return false; - } - return true; - } - - public boolean validSenderPermissions(CommandSender sender, boolean informSenderIfNot) { - return this.permission == null || p.perm.has(sender, this.permission, informSenderIfNot); - } - - public boolean validArgs(List args, CommandSender sender) { - if (args.size() < this.requiredArgs.size()) { - if (sender != null) { - msg(TL.GENERIC_ARGS_TOOFEW); - sender.sendMessage(this.getUseageTemplate()); - } - return false; - } - - if (args.size() > this.requiredArgs.size() + this.optionalArgs.size() && this.errorOnToManyArgs) { - if (sender != null) { - // Get the to many string slice - List theToMany = args.subList(this.requiredArgs.size() + this.optionalArgs.size(), args.size()); - msg(TL.GENERIC_ARGS_TOOMANY, TextUtil.implode(theToMany, " ")); - sender.sendMessage(this.getUseageTemplate()); - } - return false; - } - return true; - } - - public boolean validArgs(List args) { - return this.validArgs(args, null); - } - - // -------------------------------------------- // - // Help and Usage information - // -------------------------------------------- // - - public String getUseageTemplate(List> commandChain, boolean addShortHelp) { - StringBuilder ret = new StringBuilder(); - ret.append(p.txt.parseTags("")); - ret.append('/'); - - for (MCommand mc : commandChain) { - ret.append(TextUtil.implode(mc.aliases, ",")); - ret.append(' '); - } - - ret.append(TextUtil.implode(this.aliases, ",")); - - List args = new ArrayList<>(); - - for (String requiredArg : this.requiredArgs) { - args.add("<" + requiredArg + ">"); - } - - for (Entry optionalArg : this.optionalArgs.entrySet()) { - String val = optionalArg.getValue(); - if (val == null) { - val = ""; - } else { - val = "=" + val; - } - args.add("[" + optionalArg.getKey() + val + "]"); - } - - if (args.size() > 0) { - ret.append(p.txt.parseTags(" ")); - ret.append(TextUtil.implode(args, " ")); - } - - if (addShortHelp) { - ret.append(p.txt.parseTags(" ")); - ret.append(this.getHelpShort()); - } - - return ret.toString(); - } - - public String getUseageTemplate(boolean addShortHelp) { - return getUseageTemplate(this.commandChain, addShortHelp); - } - - public String getUseageTemplate() { - return getUseageTemplate(false); - } - - // -------------------------------------------- // - // Message Sending Helpers - // -------------------------------------------- // - - public void msg(String str, Object... args) { - sender.sendMessage(p.txt.parse(str, args)); - } - - public void msg(TL translation, Object... args) { - sender.sendMessage(p.txt.parse(translation.toString(), args)); - } - - public void sendMessage(String msg) { - sender.sendMessage(msg); - } - - public void sendMessage(List msgs) { - for (String msg : msgs) { - this.sendMessage(msg); - } - } - - public void sendFancyMessage(FancyMessage message) { - message.send(sender); - } - - public void sendFancyMessage(List messages) { - for (FancyMessage m : messages) { - sendFancyMessage(m); - } - } - - public List getToolTips(FPlayer player) { - List lines = new ArrayList<>(); - for (String s : p.getConfig().getStringList("tooltips.show")) { - lines.add(ChatColor.translateAlternateColorCodes('&', replaceFPlayerTags(s, player))); - } - return lines; - } - - public List getToolTips(Faction faction) { - List lines = new ArrayList<>(); - for (String s : p.getConfig().getStringList("tooltips.list")) { - lines.add(ChatColor.translateAlternateColorCodes('&', replaceFactionTags(s, faction))); - } - return lines; - } - - public String replaceFPlayerTags(String s, FPlayer player) { - if (s.contains("{balance}")) { - String balance = Econ.isSetup() ? Econ.getFriendlyBalance(player) : "no balance"; - s = s.replace("{balance}", balance); - } - if (s.contains("{lastSeen}")) { - String humanized = DurationFormatUtils.formatDurationWords(System.currentTimeMillis() - player.getLastLoginTime(), true, true) + " ago"; - String lastSeen = player.isOnline() ? ChatColor.GREEN + "Online" : (System.currentTimeMillis() - player.getLastLoginTime() < 432000000 ? ChatColor.YELLOW + humanized : ChatColor.RED + humanized); - s = s.replace("{lastSeen}", lastSeen); - } - if (s.contains("{power}")) { - String power = player.getPowerRounded() + "/" + player.getPowerMaxRounded(); - s = s.replace("{power}", power); - } - if (s.contains("{group}")) { - String group = SavageFactions.plugin.getPrimaryGroup(Bukkit.getOfflinePlayer(UUID.fromString(player.getId()))); - s = s.replace("{group}", group); - } - return s; - } - - public String replaceFactionTags(String s, Faction faction) { - if (s.contains("{power}")) { - s = s.replace("{power}", String.valueOf(faction.getPowerRounded())); - } - if (s.contains("{maxPower}")) { - s = s.replace("{maxPower}", String.valueOf(faction.getPowerMaxRounded())); - } - if (s.contains("{leader}")) { - FPlayer fLeader = faction.getFPlayerAdmin(); - String leader = fLeader == null ? "Server" : fLeader.getName().substring(0, fLeader.getName().length() > 14 ? 13 : fLeader.getName().length()); - s = s.replace("{leader}", leader); - } - if (s.contains("{chunks}")) { - s = s.replace("{chunks}", String.valueOf(faction.getLandRounded())); - } - if (s.contains("{members}")) { - s = s.replace("{members}", String.valueOf(faction.getSize())); - - } - if (s.contains("{online}")) { - s = s.replace("{online}", String.valueOf(faction.getOnlinePlayers().size())); - } - return s; - } - - // -------------------------------------------- // - // Argument Readers - // -------------------------------------------- // - - // Is set? ====================== - public boolean argIsSet(int idx) { - return this.args.size() >= idx + 1; - } - - // STRING ====================== - public String argAsString(int idx, String def) { - if (this.args.size() < idx + 1) { - return def; - } - return this.args.get(idx); - } - - public String argAsString(int idx) { - return this.argAsString(idx, null); - } - - // INT ====================== - public Integer strAsInt(String str, Integer def) { - if (str == null) { - return def; - } - try { - return Integer.parseInt(str); - } catch (Exception e) { - return def; - } - } - - public Integer argAsInt(int idx, Integer def) { - return strAsInt(this.argAsString(idx), def); - } - - public Integer argAsInt(int idx) { - return this.argAsInt(idx, null); - } - - // Double ====================== - public Double strAsDouble(String str, Double def) { - if (str == null) { - return def; - } - try { - return Double.parseDouble(str); - } catch (Exception e) { - return def; - } - } - - public Double argAsDouble(int idx, Double def) { - return strAsDouble(this.argAsString(idx), def); - } - - public Double argAsDouble(int idx) { - return this.argAsDouble(idx, null); - } - - // TODO: Go through the str conversion for the other arg-readers as well. - // Boolean ====================== - public Boolean strAsBool(String str) { - str = str.toLowerCase(); - return str.startsWith("y") || str.startsWith("t") || str.startsWith("on") || str.startsWith("+") || str.startsWith("1"); - } - - public Boolean argAsBool(int idx, boolean def) { - String str = this.argAsString(idx); - if (str == null) { - return def; - } - - return strAsBool(str); - } - - public Boolean argAsBool(int idx) { - return this.argAsBool(idx, false); - } - - // PLAYER ====================== - public Player strAsPlayer(String name, Player def, boolean msg) { - Player ret = def; - - if (name != null) { - Player player = Bukkit.getServer().getPlayer(name); - if (player != null) { - ret = player; - } - } - - if (msg && ret == null) { - this.msg(TL.GENERIC_NOPLAYERFOUND, name); - } - - return ret; - } - - public Player argAsPlayer(int idx, Player def, boolean msg) { - return this.strAsPlayer(this.argAsString(idx), def, msg); - } - - public Player argAsPlayer(int idx, Player def) { - return this.argAsPlayer(idx, def, true); - } - - public Player argAsPlayer(int idx) { - return this.argAsPlayer(idx, null); - } - - // BEST PLAYER MATCH ====================== - public Player strAsBestPlayerMatch(String name, Player def, boolean msg) { - Player ret = def; - - if (name != null) { - List players = Bukkit.getServer().matchPlayer(name); - if (players.size() > 0) { - ret = players.get(0); - } - } - - if (msg && ret == null) { - this.msg(TL.GENERIC_NOPLAYERMATCH, name); - } - - return ret; - } - - public Player argAsBestPlayerMatch(int idx, Player def, boolean msg) { - return this.strAsBestPlayerMatch(this.argAsString(idx), def, msg); - } - - public Player argAsBestPlayerMatch(int idx, Player def) { - return this.argAsBestPlayerMatch(idx, def, true); - } - - public Player argAsBestPlayerMatch(int idx) { - return this.argAsPlayer(idx, null); - } +package com.massivecraft.factions.zcore; + +import com.massivecraft.factions.FPlayer; +import com.massivecraft.factions.FPlayers; +import com.massivecraft.factions.Faction; +import com.massivecraft.factions.SavageFactions; +import com.massivecraft.factions.integration.Econ; +import com.massivecraft.factions.zcore.util.TL; +import com.massivecraft.factions.zcore.util.TextUtil; +import mkremins.fanciful.FancyMessage; +import org.apache.commons.lang.time.DurationFormatUtils; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map.Entry; +import java.util.UUID; + + +public abstract class MCommand { + + public T p; + + // The sub-commands to this command + public List> subCommands; + // The different names this commands will react to + public List aliases; + public boolean allowNoSlashAccess; + // Information on the args + public List requiredArgs; + public LinkedHashMap optionalArgs; + public boolean errorOnToManyArgs = true; + public List helpLong; + public CommandVisibility visibility; + // Some information on permissions + public boolean senderMustBePlayer; + public boolean senderMustHaveFaction; + public String permission; + // Information available on execution of the command + public CommandSender sender; // Will always be set + public Player me; // Will only be set when the sender is a player + public boolean senderIsConsole; + public List args; // Will contain the arguments, or and empty list if there are none. + public List> commandChain = new ArrayList<>(); // The command chain used to execute this command + // FIELD: Help Short + // This field may be left blank and will in such case be loaded from the permissions node instead. + // Thus make sure the permissions node description is an action description like "eat hamburgers" or "do admin stuff". + private String helpShort; + + public MCommand(T p) { + this.p = p; + + this.permission = null; + + this.allowNoSlashAccess = false; + + this.subCommands = new ArrayList<>(); + this.aliases = new ArrayList<>(); + + this.requiredArgs = new ArrayList<>(); + this.optionalArgs = new LinkedHashMap<>(); + + this.helpShort = null; + this.helpLong = new ArrayList<>(); + this.visibility = CommandVisibility.VISIBLE; + } + + public void addSubCommand(MCommand subCommand) { + subCommand.commandChain.addAll(this.commandChain); + subCommand.commandChain.add(this); + this.subCommands.add(subCommand); + } + + public String getHelpShort() { + return this.helpShort != null ? this.helpShort:getUsageTranslation().toString(); + } + + public void setHelpShort(String val) { + this.helpShort = val; + } + + public abstract TL getUsageTranslation(); + + public void setCommandSender(CommandSender sender) + { + this.sender = sender; + if (sender instanceof Player) { + this.me = (Player) sender; + this.senderIsConsole = false; + } else { + this.me = null; + this.senderIsConsole = true; + } + } + + // The commandChain is a list of the parent command chain used to get to this command. + public void execute(CommandSender sender, List args, List> commandChain) { + // Set the execution-time specific variables + setCommandSender(sender); + this.args = args; + this.commandChain = commandChain; + + // Is there a matching sub command? + if (args.size() > 0) { + for (MCommand subCommand : this.subCommands) { + if (subCommand.aliases.contains(args.get(0).toLowerCase())) { + args.remove(0); + commandChain.add(this); + subCommand.execute(sender, args, commandChain); + return; + } + } + } + + if (!validCall(this.sender, this.args)) { + return; + } + + if (!this.isEnabled()) { + return; + } + + perform(); + } + + public void execute(CommandSender sender, List args) { + execute(sender, args, new ArrayList>()); + } + + // This is where the command action is performed. + public abstract void perform(); + + + // -------------------------------------------- // + // Call Validation + // -------------------------------------------- // + + /** + * In this method we validate that all prerequisites to perform this command has been met. + * + * @param sender of the command + * @param args of the command + * @return true if valid, false if not. + */ + // TODO: There should be a boolean for silence + public boolean validCall(CommandSender sender, List args) { + return validSenderType(sender, true) && validSenderPermissions(sender, true) && validArgs(args, sender); + } + + public boolean isEnabled() { + return true; + } + + + public boolean validSenderType(CommandSender sender, boolean informSenderIfNot) { + if (this.senderMustBePlayer && !(sender instanceof Player)) { + if (informSenderIfNot) { + msg(TL.GENERIC_PLAYERONLY); + } + return false; + + } + return !this.senderMustHaveFaction || !FPlayers.getInstance().getByPlayer((Player) sender).hasFaction(); + } + + public boolean validSenderPermissions(CommandSender sender, boolean informSenderIfNot) { + return this.permission == null || p.perm.has(sender, this.permission, informSenderIfNot); + } + + public boolean validArgs(List args, CommandSender sender) { + if (args.size() < this.requiredArgs.size()) { + if (sender != null) { + msg(TL.GENERIC_ARGS_TOOFEW); + sender.sendMessage(this.getUseageTemplate()); + } + return false; + } + + if (args.size() > this.requiredArgs.size() + this.optionalArgs.size() && this.errorOnToManyArgs) { + if (sender != null) { + // Get the to many string slice + List theToMany = args.subList(this.requiredArgs.size() + this.optionalArgs.size(), args.size()); + msg(TL.GENERIC_ARGS_TOOMANY, TextUtil.implode(theToMany, " ")); + sender.sendMessage(this.getUseageTemplate()); + } + return false; + } + return true; + } + + public boolean validArgs(List args) { + return this.validArgs(args, null); + } + + // -------------------------------------------- // + // Help and Usage information + // -------------------------------------------- // + + public String getUseageTemplate(List> commandChain, boolean addShortHelp) { + StringBuilder ret = new StringBuilder(); + ret.append(p.txt.parseTags("")); + ret.append('/'); + + for (MCommand mc : commandChain) { + ret.append(TextUtil.implode(mc.aliases, ",")); + ret.append(' '); + } + + ret.append(TextUtil.implode(this.aliases, ",")); + + List args = new ArrayList<>(); + + for (String requiredArg : this.requiredArgs) { + args.add("<" + requiredArg + ">"); + } + + for (Entry optionalArg : this.optionalArgs.entrySet()) { + String val = optionalArg.getValue(); + if (val == null) { + val = ""; + } else { + val = "=" + val; + } + args.add("[" + optionalArg.getKey() + val + "]"); + } + + if (args.size() > 0) { + ret.append(p.txt.parseTags(" ")); + ret.append(TextUtil.implode(args, " ")); + } + + if (addShortHelp) { + ret.append(p.txt.parseTags(" ")); + ret.append(this.getHelpShort()); + } + + return ret.toString(); + } + + public String getUseageTemplate(boolean addShortHelp) { + return getUseageTemplate(this.commandChain, addShortHelp); + } + + public String getUseageTemplate() { + return getUseageTemplate(false); + } + + // -------------------------------------------- // + // Message Sending Helpers + // -------------------------------------------- // + + public void msg(String str, Object... args) { + sender.sendMessage(p.txt.parse(str, args)); + } + + public void msg(TL translation, Object... args) { + sender.sendMessage(p.txt.parse(translation.toString(), args)); + } + + public void sendMessage(String msg) { + sender.sendMessage(msg); + } + + public void sendMessage(List msgs) { + for (String msg : msgs) { + this.sendMessage(msg); + } + } + + public void sendFancyMessage(FancyMessage message) { + message.send(sender); + } + + public void sendFancyMessage(List messages) { + for (FancyMessage m : messages) { + sendFancyMessage(m); + } + } + + public List getToolTips(FPlayer player) { + List lines = new ArrayList<>(); + for (String s : p.getConfig().getStringList("tooltips.show")) { + lines.add(ChatColor.translateAlternateColorCodes('&', replaceFPlayerTags(s, player))); + } + return lines; + } + + public List getToolTips(Faction faction) { + List lines = new ArrayList<>(); + for (String s : p.getConfig().getStringList("tooltips.list")) { + lines.add(ChatColor.translateAlternateColorCodes('&', replaceFactionTags(s, faction))); + } + return lines; + } + + public String replaceFPlayerTags(String s, FPlayer player) { + if (s.contains("{balance}")) { + String balance = Econ.isSetup() ? Econ.getFriendlyBalance(player) : "no balance"; + s = s.replace("{balance}", balance); + } + if (s.contains("{lastSeen}")) { + String humanized = DurationFormatUtils.formatDurationWords(System.currentTimeMillis() - player.getLastLoginTime(), true, true) + " ago"; + String lastSeen = player.isOnline() ? ChatColor.GREEN + "Online" : (System.currentTimeMillis() - player.getLastLoginTime() < 432000000 ? ChatColor.YELLOW + humanized : ChatColor.RED + humanized); + s = s.replace("{lastSeen}", lastSeen); + } + if (s.contains("{power}")) { + String power = player.getPowerRounded() + "/" + player.getPowerMaxRounded(); + s = s.replace("{power}", power); + } + if (s.contains("{group}")) { + String group = SavageFactions.plugin.getPrimaryGroup(Bukkit.getOfflinePlayer(UUID.fromString(player.getId()))); + s = s.replace("{group}", group); + } + return s; + } + + public String replaceFactionTags(String s, Faction faction) { + if (s.contains("{power}")) { + s = s.replace("{power}", String.valueOf(faction.getPowerRounded())); + } + if (s.contains("{maxPower}")) { + s = s.replace("{maxPower}", String.valueOf(faction.getPowerMaxRounded())); + } + if (s.contains("{leader}")) { + FPlayer fLeader = faction.getFPlayerAdmin(); + String leader = fLeader == null ? "Server" : fLeader.getName().substring(0, fLeader.getName().length() > 14 ? 13 : fLeader.getName().length()); + s = s.replace("{leader}", leader); + } + if (s.contains("{chunks}")) { + s = s.replace("{chunks}", String.valueOf(faction.getLandRounded())); + } + if (s.contains("{members}")) { + s = s.replace("{members}", String.valueOf(faction.getSize())); + + } + if (s.contains("{online}")) { + s = s.replace("{online}", String.valueOf(faction.getOnlinePlayers().size())); + } + return s; + } + + // -------------------------------------------- // + // Argument Readers + // -------------------------------------------- // + + // Is set? ====================== + public boolean argIsSet(int idx) { + return this.args.size() >= idx + 1; + } + + // STRING ====================== + public String argAsString(int idx, String def) { + if (this.args.size() < idx + 1) { + return def; + } + return this.args.get(idx); + } + + public String argAsString(int idx) { + return this.argAsString(idx, null); + } + + // INT ====================== + public Integer strAsInt(String str, Integer def) { + if (str == null) { + return def; + } + try { + return Integer.parseInt(str); + } catch (Exception e) { + return def; + } + } + + public Integer argAsInt(int idx, Integer def) { + return strAsInt(this.argAsString(idx), def); + } + + public Integer argAsInt(int idx) { + return this.argAsInt(idx, null); + } + + // Double ====================== + public Double strAsDouble(String str, Double def) { + if (str == null) { + return def; + } + try { + return Double.parseDouble(str); + } catch (Exception e) { + return def; + } + } + + public Double argAsDouble(int idx, Double def) { + return strAsDouble(this.argAsString(idx), def); + } + + public Double argAsDouble(int idx) { + return this.argAsDouble(idx, null); + } + + // TODO: Go through the str conversion for the other arg-readers as well. + // Boolean ====================== + public Boolean strAsBool(String str) { + str = str.toLowerCase(); + return str.startsWith("y") || str.startsWith("t") || str.startsWith("on") || str.startsWith("+") || str.startsWith("1"); + } + + public Boolean argAsBool(int idx, boolean def) { + String str = this.argAsString(idx); + if (str == null) { + return def; + } + + return strAsBool(str); + } + + public Boolean argAsBool(int idx) { + return this.argAsBool(idx, false); + } + + // PLAYER ====================== + public Player strAsPlayer(String name, Player def, boolean msg) { + Player ret = def; + + if (name != null) { + Player player = Bukkit.getServer().getPlayer(name); + if (player != null) { + ret = player; + } + } + + if (msg && ret == null) { + this.msg(TL.GENERIC_NOPLAYERFOUND, name); + } + + return ret; + } + + public Player argAsPlayer(int idx, Player def, boolean msg) { + return this.strAsPlayer(this.argAsString(idx), def, msg); + } + + public Player argAsPlayer(int idx, Player def) { + return this.argAsPlayer(idx, def, true); + } + + public Player argAsPlayer(int idx) { + return this.argAsPlayer(idx, null); + } + + // BEST PLAYER MATCH ====================== + public Player strAsBestPlayerMatch(String name, Player def, boolean msg) { + Player ret = def; + + if (name != null) { + List players = Bukkit.getServer().matchPlayer(name); + if (players.size() > 0) { + ret = players.get(0); + } + } + + if (msg && ret == null) { + this.msg(TL.GENERIC_NOPLAYERMATCH, name); + } + + return ret; + } + + public Player argAsBestPlayerMatch(int idx, Player def, boolean msg) { + return this.strAsBestPlayerMatch(this.argAsString(idx), def, msg); + } + + public Player argAsBestPlayerMatch(int idx, Player def) { + return this.argAsBestPlayerMatch(idx, def, true); + } + + public Player argAsBestPlayerMatch(int idx) { + return this.argAsPlayer(idx, null); + } } \ No newline at end of file