Fixed the spam issue with a real fix.
This commit is contained in:
parent
ee3c5446e2
commit
266c598b76
@ -8,6 +8,6 @@
|
|||||||
<version>1.6.9.5-U0.2.1-RC-1.5-BETA</version>
|
<version>1.6.9.5-U0.2.1-RC-1.5-BETA</version>
|
||||||
<version>1.6.9.5-U0.2.1-RC-1.5-BETA-2</version>
|
<version>1.6.9.5-U0.2.1-RC-1.5-BETA-2</version>
|
||||||
</versions>
|
</versions>
|
||||||
<lastUpdated>20181221181311</lastUpdated>
|
<lastUpdated>20181221214408</lastUpdated>
|
||||||
</versioning>
|
</versioning>
|
||||||
</metadata>
|
</metadata>
|
||||||
|
@ -1 +1 @@
|
|||||||
9bdc33366d81ebbb51cec5b2a0092585
|
e9ce0bdae55853de86510ddacb671877
|
@ -1 +1 @@
|
|||||||
cdb7b8ec048405faa43f32d2daf226382f5952d2
|
694467945b9eeace46a9acb0cfd0fddc9c87fad8
|
@ -508,10 +508,6 @@ public class SavageFactions extends MPlugin {
|
|||||||
@Override
|
@Override
|
||||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||||
FPlayer fPlayer = FPlayers.getInstance().getByPlayer((Player) sender);
|
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<String>();
|
|
||||||
}
|
|
||||||
List<String> completions = new ArrayList<>();
|
List<String> completions = new ArrayList<>();
|
||||||
String cmd = Conf.baseCommandAliases.isEmpty() ? "/f" : "/" + Conf.baseCommandAliases.get(0);
|
String cmd = Conf.baseCommandAliases.isEmpty() ? "/f" : "/" + Conf.baseCommandAliases.get(0);
|
||||||
List<String> argsList = new ArrayList<>(Arrays.asList(args));
|
List<String> argsList = new ArrayList<>(Arrays.asList(args));
|
||||||
|
@ -24,7 +24,8 @@ public class CmdAdmin extends FCommand {
|
|||||||
this.permission = Permission.ADMIN.node;
|
this.permission = Permission.ADMIN.node;
|
||||||
this.disableOnLock = true;
|
this.disableOnLock = true;
|
||||||
|
|
||||||
senderMustBePlayer = false;
|
|
||||||
|
senderMustBePlayer = false;
|
||||||
senderMustBeMember = false;
|
senderMustBeMember = false;
|
||||||
senderMustBeModerator = false;
|
senderMustBeModerator = false;
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = false;
|
||||||
|
@ -22,7 +22,8 @@ public class CmdBanner extends FCommand {
|
|||||||
this.permission = Permission.BANNER.node;
|
this.permission = Permission.BANNER.node;
|
||||||
this.disableOnLock = false;
|
this.disableOnLock = false;
|
||||||
|
|
||||||
senderMustBePlayer = true;
|
|
||||||
|
senderMustBePlayer = true;
|
||||||
senderMustBeMember = false;
|
senderMustBeMember = false;
|
||||||
senderMustBeModerator = false;
|
senderMustBeModerator = false;
|
||||||
senderMustBeColeader = true;
|
senderMustBeColeader = true;
|
||||||
|
@ -19,6 +19,7 @@ public class CmdChat extends FCommand {
|
|||||||
this.permission = Permission.CHAT.node;
|
this.permission = Permission.CHAT.node;
|
||||||
this.disableOnLock = false;
|
this.disableOnLock = false;
|
||||||
|
|
||||||
|
|
||||||
senderMustBePlayer = true;
|
senderMustBePlayer = true;
|
||||||
senderMustBeMember = true;
|
senderMustBeMember = true;
|
||||||
senderMustBeModerator = false;
|
senderMustBeModerator = false;
|
||||||
|
@ -19,7 +19,8 @@ public class CmdChest extends FCommand {
|
|||||||
this.permission = Permission.CHEST.node;
|
this.permission = Permission.CHEST.node;
|
||||||
this.disableOnLock = false;
|
this.disableOnLock = false;
|
||||||
|
|
||||||
senderMustBePlayer = true;
|
|
||||||
|
senderMustBePlayer = true;
|
||||||
senderMustBeMember = true;
|
senderMustBeMember = true;
|
||||||
senderMustBeModerator = false;
|
senderMustBeModerator = false;
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = false;
|
||||||
|
@ -24,7 +24,8 @@ public class CmdClaim extends FCommand {
|
|||||||
this.permission = Permission.CLAIM.node;
|
this.permission = Permission.CLAIM.node;
|
||||||
this.disableOnLock = true;
|
this.disableOnLock = true;
|
||||||
|
|
||||||
senderMustBePlayer = true;
|
|
||||||
|
senderMustBePlayer = true;
|
||||||
senderMustBeMember = false;
|
senderMustBeMember = false;
|
||||||
senderMustBeModerator = false;
|
senderMustBeModerator = false;
|
||||||
senderMustBeColeader = false;
|
senderMustBeColeader = false;
|
||||||
|
@ -17,7 +17,8 @@ public class CmdClaimAt extends FCommand {
|
|||||||
this.permission = Permission.CLAIMAT.node;
|
this.permission = Permission.CLAIMAT.node;
|
||||||
this.disableOnLock = true;
|
this.disableOnLock = true;
|
||||||
|
|
||||||
senderMustBePlayer = true;
|
|
||||||
|
senderMustBePlayer = true;
|
||||||
senderMustBeMember = true;
|
senderMustBeMember = true;
|
||||||
senderMustBeModerator = false;
|
senderMustBeModerator = false;
|
||||||
senderMustBeColeader = false;
|
senderMustBeColeader = false;
|
||||||
|
@ -25,7 +25,8 @@ public class CmdClaimLine extends FCommand {
|
|||||||
this.permission = Permission.CLAIM_LINE.node;
|
this.permission = Permission.CLAIM_LINE.node;
|
||||||
this.disableOnLock = true;
|
this.disableOnLock = true;
|
||||||
|
|
||||||
senderMustBePlayer = true;
|
|
||||||
|
senderMustBePlayer = true;
|
||||||
senderMustBeMember = false;
|
senderMustBeMember = false;
|
||||||
senderMustBeModerator = false;
|
senderMustBeModerator = false;
|
||||||
senderMustBeColeader = false;
|
senderMustBeColeader = false;
|
||||||
|
@ -23,7 +23,8 @@ public class CmdColeader extends FCommand {
|
|||||||
this.permission = Permission.COLEADER.node;
|
this.permission = Permission.COLEADER.node;
|
||||||
this.disableOnLock = true;
|
this.disableOnLock = true;
|
||||||
|
|
||||||
senderMustBePlayer = false;
|
|
||||||
|
senderMustBePlayer = false;
|
||||||
senderMustBeMember = true;
|
senderMustBeMember = true;
|
||||||
senderMustBeModerator = false;
|
senderMustBeModerator = false;
|
||||||
senderMustBeAdmin = true;
|
senderMustBeAdmin = true;
|
||||||
|
@ -15,7 +15,8 @@ public class CmdCoords extends FCommand {
|
|||||||
this.permission = Permission.COORD.node;
|
this.permission = Permission.COORD.node;
|
||||||
this.disableOnLock = true;
|
this.disableOnLock = true;
|
||||||
|
|
||||||
senderMustBePlayer = true;
|
|
||||||
|
senderMustBePlayer = true;
|
||||||
senderMustBeMember = true;
|
senderMustBeMember = true;
|
||||||
senderMustBeModerator = false;
|
senderMustBeModerator = false;
|
||||||
senderMustBeColeader = false;
|
senderMustBeColeader = false;
|
||||||
|
@ -24,7 +24,8 @@ public class CmdDeinvite extends FCommand {
|
|||||||
this.permission = Permission.DEINVITE.node;
|
this.permission = Permission.DEINVITE.node;
|
||||||
this.disableOnLock = true;
|
this.disableOnLock = true;
|
||||||
|
|
||||||
senderMustBePlayer = true;
|
|
||||||
|
senderMustBePlayer = true;
|
||||||
senderMustBeMember = false;
|
senderMustBeMember = false;
|
||||||
senderMustBeModerator = true;
|
senderMustBeModerator = true;
|
||||||
senderMustBeColeader = false;
|
senderMustBeColeader = false;
|
||||||
|
@ -17,6 +17,7 @@ public class CmdDelFWarp extends FCommand {
|
|||||||
this.senderMustBeModerator = true;
|
this.senderMustBeModerator = true;
|
||||||
this.senderMustBePlayer = true;
|
this.senderMustBePlayer = true;
|
||||||
this.permission = Permission.SETWARP.node;
|
this.permission = Permission.SETWARP.node;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -21,7 +21,8 @@ public class CmdDescription extends FCommand {
|
|||||||
this.permission = Permission.DESCRIPTION.node;
|
this.permission = Permission.DESCRIPTION.node;
|
||||||
this.disableOnLock = true;
|
this.disableOnLock = true;
|
||||||
|
|
||||||
senderMustBePlayer = true;
|
|
||||||
|
senderMustBePlayer = true;
|
||||||
senderMustBeMember = false;
|
senderMustBeMember = false;
|
||||||
senderMustBeModerator = false;
|
senderMustBeModerator = false;
|
||||||
senderMustBeColeader = true;
|
senderMustBeColeader = true;
|
||||||
|
@ -1,88 +1,89 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
package com.massivecraft.factions.cmd;
|
||||||
|
|
||||||
import com.massivecraft.factions.Faction;
|
import com.massivecraft.factions.Faction;
|
||||||
import com.massivecraft.factions.SavageFactions;
|
import com.massivecraft.factions.SavageFactions;
|
||||||
import com.massivecraft.factions.event.FactionDisbandEvent.PlayerDisbandReason;
|
import com.massivecraft.factions.event.FactionDisbandEvent.PlayerDisbandReason;
|
||||||
import com.massivecraft.factions.struct.Permission;
|
import com.massivecraft.factions.struct.Permission;
|
||||||
import com.massivecraft.factions.struct.Role;
|
import com.massivecraft.factions.struct.Role;
|
||||||
import com.massivecraft.factions.zcore.fperms.Access;
|
import com.massivecraft.factions.zcore.fperms.Access;
|
||||||
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
||||||
import com.massivecraft.factions.zcore.util.TL;
|
import com.massivecraft.factions.zcore.util.TL;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
|
||||||
public class CmdDisband extends FCommand {
|
public class CmdDisband extends FCommand {
|
||||||
|
|
||||||
|
|
||||||
private static HashMap<String, String> disbandMap = new HashMap<>();
|
private static HashMap<String, String> disbandMap = new HashMap<>();
|
||||||
|
|
||||||
|
|
||||||
public CmdDisband() {
|
public CmdDisband() {
|
||||||
super();
|
super();
|
||||||
this.aliases.add("disband");
|
this.aliases.add("disband");
|
||||||
|
|
||||||
//this.requiredArgs.add("");
|
//this.requiredArgs.add("");
|
||||||
this.optionalArgs.put("faction tag", "yours");
|
this.optionalArgs.put("faction tag", "yours");
|
||||||
|
|
||||||
this.permission = Permission.DISBAND.node;
|
this.permission = Permission.DISBAND.node;
|
||||||
this.disableOnLock = true;
|
this.disableOnLock = true;
|
||||||
|
|
||||||
senderMustBePlayer = false;
|
|
||||||
senderMustBeMember = false;
|
senderMustBePlayer = false;
|
||||||
senderMustBeModerator = false;
|
senderMustBeMember = false;
|
||||||
senderMustBeColeader = false;
|
senderMustBeModerator = false;
|
||||||
senderMustBeAdmin = false;
|
senderMustBeColeader = false;
|
||||||
}
|
senderMustBeAdmin = false;
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public void perform() {
|
@Override
|
||||||
// The faction, default to your own.. but null if console sender.
|
public void perform() {
|
||||||
Faction faction = this.argAsFaction(0, fme == null ? null : myFaction);
|
// The faction, default to your own.. but null if console sender.
|
||||||
if (faction == null) {
|
Faction faction = this.argAsFaction(0, fme == null ? null : myFaction);
|
||||||
return;
|
if (faction == null) {
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
if (!fme.isAdminBypassing()) {
|
|
||||||
Access access = faction.getAccess(fme, PermissableAction.DISBAND);
|
if (!fme.isAdminBypassing()) {
|
||||||
if (fme.getRole() != Role.LEADER && access != Access.ALLOW) {
|
Access access = faction.getAccess(fme, PermissableAction.DISBAND);
|
||||||
fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "disband " + faction.getTag());
|
if (fme.getRole() != Role.LEADER && access != Access.ALLOW) {
|
||||||
return;
|
fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "disband " + faction.getTag());
|
||||||
}
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (!faction.isNormal()) {
|
|
||||||
msg(TL.COMMAND_DISBAND_IMMUTABLE.toString());
|
if (!faction.isNormal()) {
|
||||||
return;
|
msg(TL.COMMAND_DISBAND_IMMUTABLE.toString());
|
||||||
}
|
return;
|
||||||
if (faction.isPermanent()) {
|
}
|
||||||
msg(TL.COMMAND_DISBAND_MARKEDPERMANENT.toString());
|
if (faction.isPermanent()) {
|
||||||
return;
|
msg(TL.COMMAND_DISBAND_MARKEDPERMANENT.toString());
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// check for tnt before disbanding.
|
|
||||||
|
// check for tnt before disbanding.
|
||||||
if (!disbandMap.containsKey(me.getUniqueId().toString()) && faction.getTnt() > 0) {
|
|
||||||
msg(TL.COMMAND_DISBAND_CONFIRM.toString().replace("{tnt}", faction.getTnt() + ""));
|
if (!disbandMap.containsKey(me.getUniqueId().toString()) && faction.getTnt() > 0) {
|
||||||
disbandMap.put(me.getUniqueId().toString(), faction.getId());
|
msg(TL.COMMAND_DISBAND_CONFIRM.toString().replace("{tnt}", faction.getTnt() + ""));
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(SavageFactions.plugin, new Runnable() {
|
disbandMap.put(me.getUniqueId().toString(), faction.getId());
|
||||||
@Override
|
Bukkit.getScheduler().scheduleSyncDelayedTask(SavageFactions.plugin, new Runnable() {
|
||||||
public void run() {
|
@Override
|
||||||
disbandMap.remove(me.getUniqueId().toString());
|
public void run() {
|
||||||
}
|
disbandMap.remove(me.getUniqueId().toString());
|
||||||
}, 200L);
|
}
|
||||||
} else {
|
}, 200L);
|
||||||
//Check if the faction we asked confirmation for is the one being disbanded.
|
} else {
|
||||||
if (faction.getId().equals(disbandMap.get(me.getUniqueId().toString())) || faction.getTnt() == 0) {
|
//Check if the faction we asked confirmation for is the one being disbanded.
|
||||||
faction.disband(me, PlayerDisbandReason.COMMAND);
|
if (faction.getId().equals(disbandMap.get(me.getUniqueId().toString())) || faction.getTnt() == 0) {
|
||||||
}
|
faction.disband(me, PlayerDisbandReason.COMMAND);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public TL getUsageTranslation() {
|
@Override
|
||||||
return TL.COMMAND_DISBAND_DESCRIPTION;
|
public TL getUsageTranslation() {
|
||||||
}
|
return TL.COMMAND_DISBAND_DESCRIPTION;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
@ -23,7 +23,8 @@ public class CmdFWarp extends FCommand {
|
|||||||
this.optionalArgs.put("warpname", "warpname");
|
this.optionalArgs.put("warpname", "warpname");
|
||||||
this.optionalArgs.put("password", "password");
|
this.optionalArgs.put("password", "password");
|
||||||
|
|
||||||
this.permission = Permission.WARP.node;
|
|
||||||
|
this.permission = Permission.WARP.node;
|
||||||
this.senderMustBeMember = true;
|
this.senderMustBeMember = true;
|
||||||
this.senderMustBeModerator = false;
|
this.senderMustBeModerator = false;
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,8 @@ public class CmdFly extends FCommand {
|
|||||||
|
|
||||||
this.optionalArgs.put("on/off", "flip");
|
this.optionalArgs.put("on/off", "flip");
|
||||||
|
|
||||||
this.permission = Permission.FLY.node;
|
|
||||||
|
this.permission = Permission.FLY.node;
|
||||||
this.senderMustBeMember = true;
|
this.senderMustBeMember = true;
|
||||||
this.senderMustBeModerator = false;
|
this.senderMustBeModerator = false;
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@ public class CmdFocus
|
|||||||
|
|
||||||
permission = Permission.FOCUS.node;
|
permission = Permission.FOCUS.node;
|
||||||
|
|
||||||
|
|
||||||
senderMustBePlayer = true;
|
senderMustBePlayer = true;
|
||||||
senderMustBeMember = false;
|
senderMustBeMember = false;
|
||||||
senderMustBeModerator = true;
|
senderMustBeModerator = true;
|
||||||
|
@ -17,7 +17,8 @@ public class CmdGetVault extends FCommand {
|
|||||||
this.permission = Permission.GETVAULT.node;
|
this.permission = Permission.GETVAULT.node;
|
||||||
this.disableOnLock = true;
|
this.disableOnLock = true;
|
||||||
|
|
||||||
senderMustBePlayer = true;
|
|
||||||
|
senderMustBePlayer = true;
|
||||||
senderMustBeMember = true;
|
senderMustBeMember = true;
|
||||||
senderMustBeModerator = false;
|
senderMustBeModerator = false;
|
||||||
senderMustBeColeader = false;
|
senderMustBeColeader = false;
|
||||||
|
@ -30,7 +30,8 @@ public class CmdHome extends FCommand {
|
|||||||
this.permission = Permission.HOME.node;
|
this.permission = Permission.HOME.node;
|
||||||
this.disableOnLock = false;
|
this.disableOnLock = false;
|
||||||
|
|
||||||
senderMustBePlayer = true;
|
|
||||||
|
senderMustBePlayer = true;
|
||||||
senderMustBeMember = true;
|
senderMustBeMember = true;
|
||||||
senderMustBeModerator = false;
|
senderMustBeModerator = false;
|
||||||
senderMustBeColeader = false;
|
senderMustBeColeader = false;
|
||||||
|
@ -12,7 +12,8 @@ public class CmdInspect extends FCommand {
|
|||||||
this.permission = Permission.INSPECT.node;
|
this.permission = Permission.INSPECT.node;
|
||||||
this.disableOnLock = true;
|
this.disableOnLock = true;
|
||||||
|
|
||||||
senderMustBePlayer = true;
|
|
||||||
|
senderMustBePlayer = true;
|
||||||
senderMustBeMember = true;
|
senderMustBeMember = true;
|
||||||
senderMustBeModerator = false;
|
senderMustBeModerator = false;
|
||||||
senderMustBeColeader = false;
|
senderMustBeColeader = false;
|
||||||
|
@ -23,7 +23,8 @@ public class CmdInvite extends FCommand {
|
|||||||
this.permission = Permission.INVITE.node;
|
this.permission = Permission.INVITE.node;
|
||||||
this.disableOnLock = true;
|
this.disableOnLock = true;
|
||||||
|
|
||||||
senderMustBePlayer = true;
|
|
||||||
|
senderMustBePlayer = true;
|
||||||
senderMustBeMember = false;
|
senderMustBeMember = false;
|
||||||
senderMustBeModerator = false;
|
senderMustBeModerator = false;
|
||||||
senderMustBeColeader = false;
|
senderMustBeColeader = false;
|
||||||
|
@ -18,7 +18,8 @@ public class CmdJoin extends FCommand {
|
|||||||
this.permission = Permission.JOIN.node;
|
this.permission = Permission.JOIN.node;
|
||||||
this.disableOnLock = true;
|
this.disableOnLock = true;
|
||||||
|
|
||||||
senderMustBePlayer = true;
|
|
||||||
|
senderMustBePlayer = true;
|
||||||
senderMustBeMember = false;
|
senderMustBeMember = false;
|
||||||
senderMustBeModerator = false;
|
senderMustBeModerator = false;
|
||||||
senderMustBeColeader = false;
|
senderMustBeColeader = false;
|
||||||
|
@ -26,7 +26,8 @@ public class CmdKick extends FCommand {
|
|||||||
this.permission = Permission.KICK.node;
|
this.permission = Permission.KICK.node;
|
||||||
this.disableOnLock = false;
|
this.disableOnLock = false;
|
||||||
|
|
||||||
senderMustBePlayer = true;
|
|
||||||
|
senderMustBePlayer = true;
|
||||||
senderMustBeMember = false;
|
senderMustBeMember = false;
|
||||||
senderMustBeModerator = false;
|
senderMustBeModerator = false;
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = false;
|
||||||
|
@ -15,7 +15,8 @@ public class CmdLeave extends FCommand {
|
|||||||
this.permission = Permission.LEAVE.node;
|
this.permission = Permission.LEAVE.node;
|
||||||
this.disableOnLock = true;
|
this.disableOnLock = true;
|
||||||
|
|
||||||
senderMustBePlayer = true;
|
|
||||||
|
senderMustBePlayer = true;
|
||||||
senderMustBeMember = true;
|
senderMustBeMember = true;
|
||||||
senderMustBeModerator = false;
|
senderMustBeModerator = false;
|
||||||
senderMustBeColeader = false;
|
senderMustBeColeader = false;
|
||||||
|
@ -31,7 +31,8 @@ public class CmdList extends FCommand {
|
|||||||
this.permission = Permission.LIST.node;
|
this.permission = Permission.LIST.node;
|
||||||
this.disableOnLock = false;
|
this.disableOnLock = false;
|
||||||
|
|
||||||
senderMustBePlayer = false;
|
|
||||||
|
senderMustBePlayer = false;
|
||||||
senderMustBeMember = false;
|
senderMustBeMember = false;
|
||||||
senderMustBeModerator = false;
|
senderMustBeModerator = false;
|
||||||
senderMustBeColeader = false;
|
senderMustBeColeader = false;
|
||||||
|
@ -1,43 +1,44 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
package com.massivecraft.factions.cmd;
|
||||||
|
|
||||||
import com.massivecraft.factions.struct.Permission;
|
import com.massivecraft.factions.struct.Permission;
|
||||||
import com.massivecraft.factions.zcore.util.TL;
|
import com.massivecraft.factions.zcore.util.TL;
|
||||||
|
|
||||||
public class CmdLock extends FCommand {
|
public class CmdLock extends FCommand {
|
||||||
|
|
||||||
// TODO: This solution needs refactoring.
|
// TODO: This solution needs refactoring.
|
||||||
/*
|
/*
|
||||||
factions.lock:
|
factions.lock:
|
||||||
description: use the /f lock [on/off] command to temporarily lock the data files from being overwritten
|
description: use the /f lock [on/off] command to temporarily lock the data files from being overwritten
|
||||||
default: op
|
default: op
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public CmdLock() {
|
public CmdLock() {
|
||||||
super();
|
super();
|
||||||
this.aliases.add("lock");
|
this.aliases.add("lock");
|
||||||
|
|
||||||
//this.requiredArgs.add("");
|
//this.requiredArgs.add("");
|
||||||
this.optionalArgs.put("on/off", "flip");
|
this.optionalArgs.put("on/off", "flip");
|
||||||
|
|
||||||
this.permission = Permission.LOCK.node;
|
this.permission = Permission.LOCK.node;
|
||||||
this.disableOnLock = false;
|
this.disableOnLock = false;
|
||||||
|
|
||||||
senderMustBePlayer = false;
|
|
||||||
senderMustBeMember = false;
|
senderMustBePlayer = false;
|
||||||
senderMustBeModerator = false;
|
senderMustBeMember = false;
|
||||||
senderMustBeColeader = false;
|
senderMustBeModerator = false;
|
||||||
senderMustBeAdmin = false;
|
senderMustBeColeader = false;
|
||||||
}
|
senderMustBeAdmin = false;
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public void perform() {
|
@Override
|
||||||
p.setLocked(this.argAsBool(0, !p.getLocked()));
|
public void perform() {
|
||||||
msg(p.getLocked() ? TL.COMMAND_LOCK_LOCKED : TL.COMMAND_LOCK_UNLOCKED);
|
p.setLocked(this.argAsBool(0, !p.getLocked()));
|
||||||
}
|
msg(p.getLocked() ? TL.COMMAND_LOCK_LOCKED : TL.COMMAND_LOCK_UNLOCKED);
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public TL getUsageTranslation() {
|
@Override
|
||||||
return TL.COMMAND_LOCK_DESCRIPTION;
|
public TL getUsageTranslation() {
|
||||||
}
|
return TL.COMMAND_LOCK_DESCRIPTION;
|
||||||
|
}
|
||||||
}
|
|
||||||
|
}
|
||||||
|
@ -12,7 +12,8 @@ public class CmdLogins extends FCommand {
|
|||||||
this.aliases.add("logout");
|
this.aliases.add("logout");
|
||||||
this.aliases.add("logouts");
|
this.aliases.add("logouts");
|
||||||
this.senderMustBePlayer = true;
|
this.senderMustBePlayer = true;
|
||||||
this.senderMustBeMember = true;
|
|
||||||
|
this.senderMustBeMember = true;
|
||||||
this.permission = Permission.MONITOR_LOGINS.node;
|
this.permission = Permission.MONITOR_LOGINS.node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,8 @@ public class CmdLowPower extends FCommand {
|
|||||||
this.disableOnLock = false;
|
this.disableOnLock = false;
|
||||||
|
|
||||||
senderMustBePlayer = true;
|
senderMustBePlayer = true;
|
||||||
senderMustBeMember = true;
|
|
||||||
|
senderMustBeMember = true;
|
||||||
senderMustBeModerator = false;
|
senderMustBeModerator = false;
|
||||||
senderMustBeColeader = true;
|
senderMustBeColeader = true;
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = false;
|
||||||
|
@ -19,7 +19,8 @@ public class CmdMap extends FCommand {
|
|||||||
this.permission = Permission.MAP.node;
|
this.permission = Permission.MAP.node;
|
||||||
this.disableOnLock = false;
|
this.disableOnLock = false;
|
||||||
|
|
||||||
senderMustBePlayer = true;
|
|
||||||
|
senderMustBePlayer = true;
|
||||||
senderMustBeMember = false;
|
senderMustBeMember = false;
|
||||||
senderMustBeModerator = false;
|
senderMustBeModerator = false;
|
||||||
senderMustBeColeader = false;
|
senderMustBeColeader = false;
|
||||||
|
@ -15,7 +15,8 @@ public class CmdMapHeight extends FCommand {
|
|||||||
|
|
||||||
this.permission = Permission.MAPHEIGHT.node;
|
this.permission = Permission.MAPHEIGHT.node;
|
||||||
|
|
||||||
this.senderMustBePlayer = true;
|
|
||||||
|
this.senderMustBePlayer = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -24,7 +24,8 @@ public class CmdMod extends FCommand {
|
|||||||
this.permission = Permission.MOD.node;
|
this.permission = Permission.MOD.node;
|
||||||
this.disableOnLock = true;
|
this.disableOnLock = true;
|
||||||
|
|
||||||
senderMustBePlayer = false;
|
|
||||||
|
senderMustBePlayer = false;
|
||||||
senderMustBeMember = true;
|
senderMustBeMember = true;
|
||||||
senderMustBeModerator = false;
|
senderMustBeModerator = false;
|
||||||
senderMustBeColeader = true;
|
senderMustBeColeader = true;
|
||||||
|
@ -35,6 +35,7 @@ public class CmdMoney extends FCommand {
|
|||||||
this.addSubCommand(this.cmdMoneyTransferFf);
|
this.addSubCommand(this.cmdMoneyTransferFf);
|
||||||
this.addSubCommand(this.cmdMoneyTransferFp);
|
this.addSubCommand(this.cmdMoneyTransferFp);
|
||||||
this.addSubCommand(this.cmdMoneyTransferPf);
|
this.addSubCommand(this.cmdMoneyTransferPf);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -18,7 +18,8 @@ public class CmdMoneyBalance extends FCommand {
|
|||||||
this.permission = Permission.MONEY_BALANCE.node;
|
this.permission = Permission.MONEY_BALANCE.node;
|
||||||
this.setHelpShort(TL.COMMAND_MONEYBALANCE_SHORT.toString());
|
this.setHelpShort(TL.COMMAND_MONEYBALANCE_SHORT.toString());
|
||||||
|
|
||||||
senderMustBePlayer = false;
|
|
||||||
|
senderMustBePlayer = false;
|
||||||
senderMustBeMember = false;
|
senderMustBeMember = false;
|
||||||
senderMustBeModerator = false;
|
senderMustBeModerator = false;
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = false;
|
||||||
|
@ -21,7 +21,8 @@ public class CmdMoneyDeposit extends FCommand {
|
|||||||
|
|
||||||
this.permission = Permission.MONEY_DEPOSIT.node;
|
this.permission = Permission.MONEY_DEPOSIT.node;
|
||||||
|
|
||||||
senderMustBePlayer = true;
|
|
||||||
|
senderMustBePlayer = true;
|
||||||
senderMustBeMember = false;
|
senderMustBeMember = false;
|
||||||
senderMustBeModerator = false;
|
senderMustBeModerator = false;
|
||||||
senderMustBeColeader = false;
|
senderMustBeColeader = false;
|
||||||
|
@ -23,7 +23,8 @@ public class CmdMoneyTransferFf extends FCommand {
|
|||||||
|
|
||||||
this.permission = Permission.MONEY_F2F.node;
|
this.permission = Permission.MONEY_F2F.node;
|
||||||
|
|
||||||
senderMustBePlayer = false;
|
|
||||||
|
senderMustBePlayer = false;
|
||||||
senderMustBeMember = false;
|
senderMustBeMember = false;
|
||||||
senderMustBeModerator = false;
|
senderMustBeModerator = false;
|
||||||
senderMustBeColeader = false;
|
senderMustBeColeader = false;
|
||||||
|
@ -22,7 +22,8 @@ public class CmdMoneyTransferFp extends FCommand {
|
|||||||
|
|
||||||
this.permission = Permission.MONEY_F2P.node;
|
this.permission = Permission.MONEY_F2P.node;
|
||||||
|
|
||||||
senderMustBePlayer = false;
|
|
||||||
|
senderMustBePlayer = false;
|
||||||
senderMustBeMember = false;
|
senderMustBeMember = false;
|
||||||
senderMustBeModerator = false;
|
senderMustBeModerator = false;
|
||||||
senderMustBeColeader = false;
|
senderMustBeColeader = false;
|
||||||
|
@ -22,7 +22,8 @@ public class CmdMoneyTransferPf extends FCommand {
|
|||||||
|
|
||||||
this.permission = Permission.MONEY_P2F.node;
|
this.permission = Permission.MONEY_P2F.node;
|
||||||
|
|
||||||
senderMustBePlayer = false;
|
|
||||||
|
senderMustBePlayer = false;
|
||||||
senderMustBeMember = false;
|
senderMustBeMember = false;
|
||||||
senderMustBeModerator = false;
|
senderMustBeModerator = false;
|
||||||
senderMustBeColeader = false;
|
senderMustBeColeader = false;
|
||||||
|
@ -22,7 +22,8 @@ public class CmdMoneyWithdraw extends FCommand {
|
|||||||
|
|
||||||
this.permission = Permission.MONEY_WITHDRAW.node;
|
this.permission = Permission.MONEY_WITHDRAW.node;
|
||||||
|
|
||||||
senderMustBePlayer = true;
|
|
||||||
|
senderMustBePlayer = true;
|
||||||
senderMustBeMember = false;
|
senderMustBeMember = false;
|
||||||
senderMustBeModerator = false;
|
senderMustBeModerator = false;
|
||||||
senderMustBeColeader = false;
|
senderMustBeColeader = false;
|
||||||
|
@ -16,7 +16,8 @@ public class CmdNear extends FCommand {
|
|||||||
|
|
||||||
this.disableOnLock = true;
|
this.disableOnLock = true;
|
||||||
|
|
||||||
senderMustBePlayer = true;
|
|
||||||
|
senderMustBePlayer = true;
|
||||||
senderMustBeMember = true;
|
senderMustBeMember = true;
|
||||||
senderMustBeModerator = false;
|
senderMustBeModerator = false;
|
||||||
senderMustBeColeader = false;
|
senderMustBeColeader = false;
|
||||||
|
@ -18,7 +18,8 @@ public class CmdOpen extends FCommand {
|
|||||||
this.permission = Permission.OPEN.node;
|
this.permission = Permission.OPEN.node;
|
||||||
this.disableOnLock = false;
|
this.disableOnLock = false;
|
||||||
|
|
||||||
senderMustBePlayer = true;
|
|
||||||
|
senderMustBePlayer = true;
|
||||||
senderMustBeMember = false;
|
senderMustBeMember = false;
|
||||||
senderMustBeModerator = false;
|
senderMustBeModerator = false;
|
||||||
senderMustBeColeader = true;
|
senderMustBeColeader = true;
|
||||||
|
@ -18,7 +18,8 @@ public class CmdOwner extends FCommand {
|
|||||||
this.permission = Permission.OWNER.node;
|
this.permission = Permission.OWNER.node;
|
||||||
this.disableOnLock = true;
|
this.disableOnLock = true;
|
||||||
|
|
||||||
senderMustBePlayer = true;
|
|
||||||
|
senderMustBePlayer = true;
|
||||||
senderMustBeMember = false;
|
senderMustBeMember = false;
|
||||||
senderMustBeModerator = false;
|
senderMustBeModerator = false;
|
||||||
senderMustBeColeader = false;
|
senderMustBeColeader = false;
|
||||||
|
@ -19,7 +19,8 @@ public class CmdOwnerList extends FCommand {
|
|||||||
this.permission = Permission.OWNERLIST.node;
|
this.permission = Permission.OWNERLIST.node;
|
||||||
this.disableOnLock = false;
|
this.disableOnLock = false;
|
||||||
|
|
||||||
senderMustBePlayer = true;
|
|
||||||
|
senderMustBePlayer = true;
|
||||||
senderMustBeMember = false;
|
senderMustBeMember = false;
|
||||||
senderMustBeModerator = false;
|
senderMustBeModerator = false;
|
||||||
senderMustBeColeader = false;
|
senderMustBeColeader = false;
|
||||||
|
@ -17,6 +17,7 @@ public class CmdPaypalSee extends FCommand {
|
|||||||
senderMustBeModerator = false;
|
senderMustBeModerator = false;
|
||||||
senderMustBeColeader = false;
|
senderMustBeColeader = false;
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void perform() {
|
public void perform() {
|
||||||
|
@ -17,6 +17,7 @@ public class CmdPaypalSet extends FCommand {
|
|||||||
this.senderMustBeModerator = false;
|
this.senderMustBeModerator = false;
|
||||||
this.senderMustBeColeader = true;
|
this.senderMustBeColeader = true;
|
||||||
this.senderMustBeAdmin = false;
|
this.senderMustBeAdmin = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void perform() {
|
public void perform() {
|
||||||
|
@ -1,61 +1,62 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
package com.massivecraft.factions.cmd;
|
||||||
|
|
||||||
import com.massivecraft.factions.FPlayer;
|
import com.massivecraft.factions.FPlayer;
|
||||||
import com.massivecraft.factions.FPlayers;
|
import com.massivecraft.factions.FPlayers;
|
||||||
import com.massivecraft.factions.Faction;
|
import com.massivecraft.factions.Faction;
|
||||||
import com.massivecraft.factions.struct.Permission;
|
import com.massivecraft.factions.struct.Permission;
|
||||||
import com.massivecraft.factions.zcore.util.TL;
|
import com.massivecraft.factions.zcore.util.TL;
|
||||||
|
|
||||||
public class CmdPeaceful extends FCommand {
|
public class CmdPeaceful extends FCommand {
|
||||||
|
|
||||||
public CmdPeaceful() {
|
public CmdPeaceful() {
|
||||||
super();
|
super();
|
||||||
this.aliases.add("peaceful");
|
this.aliases.add("peaceful");
|
||||||
|
|
||||||
this.requiredArgs.add("faction tag");
|
this.requiredArgs.add("faction tag");
|
||||||
//this.optionalArgs.put("", "");
|
//this.optionalArgs.put("", "");
|
||||||
|
|
||||||
this.permission = Permission.SET_PEACEFUL.node;
|
this.permission = Permission.SET_PEACEFUL.node;
|
||||||
this.disableOnLock = true;
|
this.disableOnLock = true;
|
||||||
|
|
||||||
senderMustBePlayer = false;
|
senderMustBePlayer = false;
|
||||||
senderMustBeMember = false;
|
senderMustBeMember = false;
|
||||||
senderMustBeModerator = false;
|
senderMustBeModerator = false;
|
||||||
senderMustBeColeader = false;
|
senderMustBeColeader = false;
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = false;
|
||||||
}
|
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public void perform() {
|
@Override
|
||||||
Faction faction = this.argAsFaction(0);
|
public void perform() {
|
||||||
if (faction == null) {
|
Faction faction = this.argAsFaction(0);
|
||||||
return;
|
if (faction == null) {
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
String change;
|
|
||||||
if (faction.isPeaceful()) {
|
String change;
|
||||||
change = TL.COMMAND_PEACEFUL_REVOKE.toString();
|
if (faction.isPeaceful()) {
|
||||||
faction.setPeaceful(false);
|
change = TL.COMMAND_PEACEFUL_REVOKE.toString();
|
||||||
} else {
|
faction.setPeaceful(false);
|
||||||
change = TL.COMMAND_PEACEFUL_GRANT.toString();
|
} else {
|
||||||
faction.setPeaceful(true);
|
change = TL.COMMAND_PEACEFUL_GRANT.toString();
|
||||||
}
|
faction.setPeaceful(true);
|
||||||
|
}
|
||||||
// Inform all players
|
|
||||||
for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers()) {
|
// Inform all players
|
||||||
String blame = (fme == null ? TL.GENERIC_SERVERADMIN.toString() : fme.describeTo(fplayer, true));
|
for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers()) {
|
||||||
if (fplayer.getFaction() == faction) {
|
String blame = (fme == null ? TL.GENERIC_SERVERADMIN.toString() : fme.describeTo(fplayer, true));
|
||||||
fplayer.msg(TL.COMMAND_PEACEFUL_YOURS, blame, change);
|
if (fplayer.getFaction() == faction) {
|
||||||
} else {
|
fplayer.msg(TL.COMMAND_PEACEFUL_YOURS, blame, change);
|
||||||
fplayer.msg(TL.COMMAND_PEACEFUL_OTHER, blame, change, faction.getTag(fplayer));
|
} else {
|
||||||
}
|
fplayer.msg(TL.COMMAND_PEACEFUL_OTHER, blame, change, faction.getTag(fplayer));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public TL getUsageTranslation() {
|
@Override
|
||||||
return TL.COMMAND_PEACEFUL_DESCRIPTION;
|
public TL getUsageTranslation() {
|
||||||
}
|
return TL.COMMAND_PEACEFUL_DESCRIPTION;
|
||||||
|
}
|
||||||
}
|
|
||||||
|
}
|
||||||
|
@ -35,6 +35,7 @@ public class CmdPerm extends FCommand {
|
|||||||
senderMustBeModerator = false;
|
senderMustBeModerator = false;
|
||||||
senderMustBeColeader = false;
|
senderMustBeColeader = false;
|
||||||
senderMustBeAdmin = true;
|
senderMustBeAdmin = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -23,6 +23,7 @@ public class CmdPower extends FCommand {
|
|||||||
senderMustBeModerator = false;
|
senderMustBeModerator = false;
|
||||||
senderMustBeColeader = false;
|
senderMustBeColeader = false;
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -24,6 +24,7 @@ public class CmdRules extends FCommand {
|
|||||||
senderMustBeModerator = false;
|
senderMustBeModerator = false;
|
||||||
senderMustBeColeader = true;
|
senderMustBeColeader = true;
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -27,6 +27,7 @@ public class CmdSafeunclaimall extends FCommand {
|
|||||||
senderMustBeColeader = false;
|
senderMustBeColeader = false;
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = false;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,153 +1,154 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
package com.massivecraft.factions.cmd;
|
||||||
|
|
||||||
|
|
||||||
import com.massivecraft.factions.FLocation;
|
import com.massivecraft.factions.FLocation;
|
||||||
import com.massivecraft.factions.SavageFactions;
|
import com.massivecraft.factions.SavageFactions;
|
||||||
import com.massivecraft.factions.struct.Permission;
|
import com.massivecraft.factions.struct.Permission;
|
||||||
import com.massivecraft.factions.util.Particles.ParticleEffect;
|
import com.massivecraft.factions.util.Particles.ParticleEffect;
|
||||||
import com.massivecraft.factions.util.VisualizeUtil;
|
import com.massivecraft.factions.util.VisualizeUtil;
|
||||||
import com.massivecraft.factions.zcore.util.TL;
|
import com.massivecraft.factions.zcore.util.TL;
|
||||||
import org.bukkit.*;
|
import org.bukkit.*;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class CmdSeeChunk extends FCommand {
|
public class CmdSeeChunk extends FCommand {
|
||||||
|
|
||||||
//Used a hashmap cuz imma make a particle selection gui later, will store it where the boolean is rn.
|
//Used a hashmap cuz imma make a particle selection gui later, will store it where the boolean is rn.
|
||||||
public static HashMap<String, Boolean> seeChunkMap = new HashMap<>();
|
public static HashMap<String, Boolean> seeChunkMap = new HashMap<>();
|
||||||
Long interval = 10L;
|
Long interval = 10L;
|
||||||
private boolean useParticles;
|
private boolean useParticles;
|
||||||
private int length;
|
private int length;
|
||||||
private ParticleEffect effect;
|
private ParticleEffect effect;
|
||||||
private int taskID = - 1;
|
private int taskID = - 1;
|
||||||
|
|
||||||
|
|
||||||
//I remade it cause of people getting mad that I had the same seechunk as drtshock
|
//I remade it cause of people getting mad that I had the same seechunk as drtshock
|
||||||
|
|
||||||
|
|
||||||
public CmdSeeChunk() {
|
public CmdSeeChunk() {
|
||||||
super();
|
super();
|
||||||
aliases.add("seechunk");
|
aliases.add("seechunk");
|
||||||
aliases.add("sc");
|
aliases.add("sc");
|
||||||
|
|
||||||
permission = Permission.SEECHUNK.node;
|
permission = Permission.SEECHUNK.node;
|
||||||
|
|
||||||
senderMustBePlayer = true;
|
senderMustBePlayer = true;
|
||||||
senderMustBeMember = false;
|
senderMustBeMember = false;
|
||||||
senderMustBeModerator = false;
|
senderMustBeModerator = false;
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = false;
|
||||||
|
|
||||||
this.useParticles = p.getConfig().getBoolean("see-chunk.particles", true);
|
|
||||||
interval = SavageFactions.plugin.getConfig().getLong("see-chunk.interval", 10L);
|
this.useParticles = p.getConfig().getBoolean("see-chunk.particles", true);
|
||||||
if (effect == null) {
|
interval = SavageFactions.plugin.getConfig().getLong("see-chunk.interval", 10L);
|
||||||
effect = ParticleEffect.REDSTONE;
|
if (effect == null) {
|
||||||
}
|
effect = ParticleEffect.REDSTONE;
|
||||||
|
}
|
||||||
}
|
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public void perform() {
|
@Override
|
||||||
if (seeChunkMap.containsKey(me.getName())) {
|
public void perform() {
|
||||||
seeChunkMap.remove(me.getName());
|
if (seeChunkMap.containsKey(me.getName())) {
|
||||||
msg(TL.COMMAND_SEECHUNK_DISABLED);
|
seeChunkMap.remove(me.getName());
|
||||||
} else {
|
msg(TL.COMMAND_SEECHUNK_DISABLED);
|
||||||
seeChunkMap.put(me.getName(), true);
|
} else {
|
||||||
msg(TL.COMMAND_SEECHUNK_ENABLED);
|
seeChunkMap.put(me.getName(), true);
|
||||||
manageTask();
|
msg(TL.COMMAND_SEECHUNK_ENABLED);
|
||||||
}
|
manageTask();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
private void manageTask() {
|
|
||||||
if (taskID != - 1) {
|
private void manageTask() {
|
||||||
if (seeChunkMap.keySet().size() == 0) {
|
if (taskID != - 1) {
|
||||||
Bukkit.getScheduler().cancelTask(taskID);
|
if (seeChunkMap.keySet().size() == 0) {
|
||||||
taskID = - 1;
|
Bukkit.getScheduler().cancelTask(taskID);
|
||||||
}
|
taskID = - 1;
|
||||||
} else {
|
}
|
||||||
startTask();
|
} else {
|
||||||
}
|
startTask();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
private void startTask() {
|
|
||||||
taskID = Bukkit.getScheduler().scheduleSyncRepeatingTask(SavageFactions.plugin, new Runnable() {
|
private void startTask() {
|
||||||
@Override
|
taskID = Bukkit.getScheduler().scheduleSyncRepeatingTask(SavageFactions.plugin, new Runnable() {
|
||||||
public void run() {
|
@Override
|
||||||
Iterator<String> itr = seeChunkMap.keySet().iterator();
|
public void run() {
|
||||||
while (itr.hasNext()) {
|
Iterator<String> itr = seeChunkMap.keySet().iterator();
|
||||||
Object nameObject = itr.next();
|
while (itr.hasNext()) {
|
||||||
String name = nameObject + "";
|
Object nameObject = itr.next();
|
||||||
Player player = Bukkit.getPlayer(name);
|
String name = nameObject + "";
|
||||||
showBorders(player);
|
Player player = Bukkit.getPlayer(name);
|
||||||
}
|
showBorders(player);
|
||||||
manageTask();
|
}
|
||||||
}
|
manageTask();
|
||||||
}, 0, interval);
|
}
|
||||||
}
|
}, 0, interval);
|
||||||
|
}
|
||||||
private void showBorders(Player me) {
|
|
||||||
World world = me.getWorld();
|
private void showBorders(Player me) {
|
||||||
FLocation flocation = new FLocation(me);
|
World world = me.getWorld();
|
||||||
int chunkX = (int) flocation.getX();
|
FLocation flocation = new FLocation(me);
|
||||||
int chunkZ = (int) flocation.getZ();
|
int chunkX = (int) flocation.getX();
|
||||||
|
int chunkZ = (int) flocation.getZ();
|
||||||
int blockX;
|
|
||||||
int blockZ;
|
int blockX;
|
||||||
|
int blockZ;
|
||||||
blockX = chunkX * 16;
|
|
||||||
blockZ = chunkZ * 16;
|
blockX = chunkX * 16;
|
||||||
showPillar(me, world, blockX, blockZ);
|
blockZ = chunkZ * 16;
|
||||||
|
showPillar(me, world, blockX, blockZ);
|
||||||
|
|
||||||
blockX = chunkX * 16 + 15;
|
|
||||||
blockZ = chunkZ * 16;
|
blockX = chunkX * 16 + 15;
|
||||||
showPillar(me, world, blockX, blockZ);
|
blockZ = chunkZ * 16;
|
||||||
|
showPillar(me, world, blockX, blockZ);
|
||||||
blockX = chunkX * 16;
|
|
||||||
blockZ = chunkZ * 16 + 15;
|
blockX = chunkX * 16;
|
||||||
showPillar(me, world, blockX, blockZ);
|
blockZ = chunkZ * 16 + 15;
|
||||||
|
showPillar(me, world, blockX, blockZ);
|
||||||
blockX = chunkX * 16 + 15;
|
|
||||||
blockZ = chunkZ * 16 + 15;
|
blockX = chunkX * 16 + 15;
|
||||||
showPillar(me, world, blockX, blockZ);
|
blockZ = chunkZ * 16 + 15;
|
||||||
}
|
showPillar(me, world, blockX, blockZ);
|
||||||
|
}
|
||||||
private void showPillar(Player player, World world, int blockX, int blockZ) {
|
|
||||||
List<Player> onePlayer = Arrays.asList(player);
|
private void showPillar(Player player, World world, int blockX, int blockZ) {
|
||||||
for (int blockY = 0; blockY < player.getLocation().getBlockY() + 30; blockY++) {
|
List<Player> onePlayer = Arrays.asList(player);
|
||||||
Location loc = new Location(world, blockX, blockY, blockZ).add(0.5, 0, 0.5);
|
for (int blockY = 0; blockY < player.getLocation().getBlockY() + 30; blockY++) {
|
||||||
if (loc.getBlock().getType() != Material.AIR) {
|
Location loc = new Location(world, blockX, blockY, blockZ).add(0.5, 0, 0.5);
|
||||||
continue;
|
if (loc.getBlock().getType() != Material.AIR) {
|
||||||
}
|
continue;
|
||||||
if (useParticles) {
|
}
|
||||||
if (SavageFactions.plugin.useNonPacketParticles) {
|
if (useParticles) {
|
||||||
// Dust options only exists in the 1.13 API, so we use an
|
if (SavageFactions.plugin.useNonPacketParticles) {
|
||||||
// alternative method to achieve this in lower versions.
|
// Dust options only exists in the 1.13 API, so we use an
|
||||||
if (SavageFactions.plugin.mc113) {
|
// alternative method to achieve this in lower versions.
|
||||||
player.spawnParticle(Particle.REDSTONE, loc, 0, new Particle.DustOptions(Color.RED, 1));
|
if (SavageFactions.plugin.mc113) {
|
||||||
} else {
|
player.spawnParticle(Particle.REDSTONE, loc, 0, new Particle.DustOptions(Color.RED, 1));
|
||||||
player.getWorld().spawnParticle(Particle.REDSTONE, loc, 0, 255, 0, 0, 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 {
|
||||||
}
|
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;
|
} else {
|
||||||
VisualizeUtil.addLocation(player, loc, type);
|
Material type = blockY % 5 == 0 ? SavageFactions.plugin.REDSTONE_LAMP_ON : SavageFactions.plugin.STAINED_GLASS;
|
||||||
}
|
VisualizeUtil.addLocation(player, loc, type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public TL getUsageTranslation() {
|
@Override
|
||||||
return TL.GENERIC_PLACEHOLDER;
|
public TL getUsageTranslation() {
|
||||||
}
|
return TL.GENERIC_PLACEHOLDER;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -16,6 +16,7 @@ public class CmdSetBanner extends FCommand {
|
|||||||
senderMustBeModerator = false;
|
senderMustBeModerator = false;
|
||||||
senderMustBeAdmin = true;
|
senderMustBeAdmin = true;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void perform() {
|
public void perform() {
|
||||||
|
@ -19,7 +19,8 @@ public class CmdSetDefaultRole extends FCommand {
|
|||||||
this.senderMustBePlayer = true;
|
this.senderMustBePlayer = true;
|
||||||
senderMustBeColeader = false;
|
senderMustBeColeader = false;
|
||||||
|
|
||||||
this.permission = Permission.DEFAULTRANK.node;
|
|
||||||
|
this.permission = Permission.DEFAULTRANK.node;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -23,7 +23,8 @@ public class CmdSetFWarp extends FCommand {
|
|||||||
|
|
||||||
this.senderMustBeMember = true;
|
this.senderMustBeMember = true;
|
||||||
this.senderMustBeModerator = false;
|
this.senderMustBeModerator = false;
|
||||||
this.senderMustBePlayer = true;
|
|
||||||
|
this.senderMustBePlayer = true;
|
||||||
|
|
||||||
this.permission = Permission.SETWARP.node;
|
this.permission = Permission.SETWARP.node;
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@ public class CmdSetMaxVaults extends FCommand {
|
|||||||
senderMustBeModerator = false;
|
senderMustBeModerator = false;
|
||||||
senderMustBeColeader = false;
|
senderMustBeColeader = false;
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -26,6 +26,7 @@ public class CmdSethome extends FCommand {
|
|||||||
senderMustBeModerator = false;
|
senderMustBeModerator = false;
|
||||||
senderMustBeColeader = false;
|
senderMustBeColeader = false;
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -21,6 +21,7 @@ public class CmdShowClaims extends FCommand {
|
|||||||
this.senderMustBePlayer = true;
|
this.senderMustBePlayer = true;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -34,7 +35,7 @@ public class CmdShowClaims extends FCommand {
|
|||||||
for (String world : chunkMap.keySet()) {
|
for (String world : chunkMap.keySet()) {
|
||||||
String message = TL.COMMAND_SHOWCLAIMS_FORMAT.toString().replace("{world}", world);
|
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:
|
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)) {
|
for (String chunkString : chunkMap.get(world)) {
|
||||||
chunks.append(chunkString + ", ");
|
chunks.append(chunkString + ", ");
|
||||||
if (chunks.toString().length() >= 2000) {
|
if (chunks.toString().length() >= 2000) {
|
||||||
|
@ -17,6 +17,7 @@ public class CmdShowInvites extends FCommand {
|
|||||||
|
|
||||||
senderMustBePlayer = true;
|
senderMustBePlayer = true;
|
||||||
senderMustBeMember = true;
|
senderMustBeMember = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -21,6 +21,7 @@ public class CmdStatus extends FCommand {
|
|||||||
senderMustBeMember = true;
|
senderMustBeMember = true;
|
||||||
senderMustBeModerator = false;
|
senderMustBeModerator = false;
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -29,7 +30,7 @@ public class CmdStatus extends FCommand {
|
|||||||
for (FPlayer fp : myFaction.getFPlayers()) {
|
for (FPlayer fp : myFaction.getFPlayers()) {
|
||||||
String humanized = DurationFormatUtils.formatDurationWords(System.currentTimeMillis() - fp.getLastLoginTime(), true, true) + TL.COMMAND_STATUS_AGOSUFFIX;
|
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 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());
|
ret.add(String.format(TL.COMMAND_STATUS_FORMAT.toString(), ChatColor.GOLD + fp.getRole().getPrefix() + fp.getName() + ChatColor.RESET, power, last).trim());
|
||||||
}
|
}
|
||||||
fme.sendMessage(ret);
|
fme.sendMessage(ret);
|
||||||
|
@ -17,6 +17,7 @@ public class CmdStealth extends FCommand {
|
|||||||
this.senderMustBeModerator = false;
|
this.senderMustBeModerator = false;
|
||||||
this.senderMustBeColeader = false;
|
this.senderMustBeColeader = false;
|
||||||
this.senderMustBeAdmin = false;
|
this.senderMustBeAdmin = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void perform() {
|
public void perform() {
|
||||||
|
@ -27,6 +27,7 @@ public class CmdStuck extends FCommand {
|
|||||||
senderMustBeMember = false;
|
senderMustBeMember = false;
|
||||||
senderMustBeModerator = false;
|
senderMustBeModerator = false;
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -26,6 +26,7 @@ public class CmdTag extends FCommand {
|
|||||||
senderMustBeMember = false;
|
senderMustBeMember = false;
|
||||||
senderMustBeModerator = true;
|
senderMustBeModerator = true;
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -21,6 +21,7 @@ public class CmdTitle extends FCommand {
|
|||||||
senderMustBeMember = false;
|
senderMustBeMember = false;
|
||||||
senderMustBeModerator = true;
|
senderMustBeModerator = true;
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -27,6 +27,7 @@ public class CmdTnt extends FCommand {
|
|||||||
senderMustBeMember = false;
|
senderMustBeMember = false;
|
||||||
senderMustBeModerator = true;
|
senderMustBeModerator = true;
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -30,6 +30,7 @@ public class CmdTntFill extends FCommand {
|
|||||||
senderMustBeMember = true;
|
senderMustBeMember = true;
|
||||||
senderMustBeModerator = false;
|
senderMustBeModerator = false;
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -21,6 +21,7 @@ public class CmdToggleAllianceChat extends FCommand {
|
|||||||
senderMustBeMember = true;
|
senderMustBeMember = true;
|
||||||
senderMustBeModerator = false;
|
senderMustBeModerator = false;
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -30,9 +30,11 @@ public class CmdTop extends FCommand {
|
|||||||
senderMustBeMember = false;
|
senderMustBeMember = false;
|
||||||
senderMustBeModerator = false;
|
senderMustBeModerator = false;
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
|
@Override
|
||||||
public void perform() {
|
public void perform() {
|
||||||
// Can sort by: money, members, online, allies, enemies, power, land.
|
// Can sort by: money, members, online, allies, enemies, power, land.
|
||||||
// Get all Factions and remove non player ones.
|
// Get all Factions and remove non player ones.
|
||||||
|
@ -21,6 +21,7 @@ public class CmdTpBanner extends FCommand {
|
|||||||
senderMustBeModerator = false;
|
senderMustBeModerator = false;
|
||||||
senderMustBeColeader = false;
|
senderMustBeColeader = false;
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -21,7 +21,8 @@ public class CmdUnban extends FCommand {
|
|||||||
senderMustBePlayer = true;
|
senderMustBePlayer = true;
|
||||||
senderMustBeMember = false;
|
senderMustBeMember = false;
|
||||||
senderMustBeModerator = false;
|
senderMustBeModerator = false;
|
||||||
senderMustBeAdmin = false;
|
|
||||||
|
senderMustBeAdmin = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -27,6 +27,7 @@ public class CmdUnclaim extends FCommand {
|
|||||||
senderMustBeMember = false;
|
senderMustBeMember = false;
|
||||||
senderMustBeModerator = false;
|
senderMustBeModerator = false;
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -25,6 +25,7 @@ public class CmdUnclaimall extends FCommand {
|
|||||||
senderMustBeMember = false;
|
senderMustBeMember = false;
|
||||||
senderMustBeModerator = true;
|
senderMustBeModerator = true;
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -21,6 +21,7 @@ public class CmdUpgrades extends FCommand {
|
|||||||
senderMustBeMember = true;
|
senderMustBeMember = true;
|
||||||
senderMustBeModerator = false;
|
senderMustBeModerator = false;
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -27,6 +27,7 @@ public class CmdVault extends FCommand {
|
|||||||
senderMustBeMember = true;
|
senderMustBeMember = true;
|
||||||
senderMustBeModerator = false;
|
senderMustBeModerator = false;
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -25,6 +25,7 @@ public class CmdWarunclaimall extends FCommand {
|
|||||||
senderMustBeMember = false;
|
senderMustBeMember = false;
|
||||||
senderMustBeModerator = false;
|
senderMustBeModerator = false;
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -26,6 +26,7 @@ public abstract class FCommand extends MCommand<SavageFactions> {
|
|||||||
public boolean senderMustBeAdmin;
|
public boolean senderMustBeAdmin;
|
||||||
public boolean senderMustBeColeader;
|
public boolean senderMustBeColeader;
|
||||||
|
|
||||||
|
|
||||||
public boolean isMoneyCommand;
|
public boolean isMoneyCommand;
|
||||||
|
|
||||||
public FCommand() {
|
public FCommand() {
|
||||||
@ -98,22 +99,30 @@ public abstract class FCommand extends MCommand<SavageFactions> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!fme.hasFaction()) {
|
if (!fme.hasFaction()) {
|
||||||
sender.sendMessage(p.txt.parse("<b>You are not member of any faction."));
|
if (informSenderIfNot) {
|
||||||
|
sender.sendMessage(p.txt.parse("<b>You are not member of any faction."));
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.senderMustBeModerator && !fme.getRole().isAtLeast(Role.MODERATOR)) {
|
if (this.senderMustBeModerator && !fme.getRole().isAtLeast(Role.MODERATOR)) {
|
||||||
sender.sendMessage(p.txt.parse("<b>Only faction moderators can %s.", this.getHelpShort()));
|
if (informSenderIfNot) {
|
||||||
|
sender.sendMessage(p.txt.parse("<b>Only faction moderators can %s.", this.getHelpShort()));
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.senderMustBeColeader && !fme.getRole().isAtLeast(Role.COLEADER)) {
|
if (this.senderMustBeColeader && !fme.getRole().isAtLeast(Role.COLEADER)) {
|
||||||
sender.sendMessage(p.txt.parse("<b>Only faction coleaders can %s.", this.getHelpShort()));
|
if (informSenderIfNot) {
|
||||||
|
sender.sendMessage(p.txt.parse("<b>Only faction coleaders can %s.", this.getHelpShort()));
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.senderMustBeAdmin && !fme.getRole().isAtLeast(Role.LEADER)) {
|
if (this.senderMustBeAdmin && !fme.getRole().isAtLeast(Role.LEADER)) {
|
||||||
sender.sendMessage(p.txt.parse("<b>Only faction admins can %s.", this.getHelpShort()));
|
if (informSenderIfNot) {
|
||||||
|
sender.sendMessage(p.txt.parse("<b>Only faction admins can %s.", this.getHelpShort()));
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,482 +1,486 @@
|
|||||||
package com.massivecraft.factions.zcore;
|
package com.massivecraft.factions.zcore;
|
||||||
|
|
||||||
import com.massivecraft.factions.FPlayer;
|
import com.massivecraft.factions.FPlayer;
|
||||||
import com.massivecraft.factions.Faction;
|
import com.massivecraft.factions.FPlayers;
|
||||||
import com.massivecraft.factions.SavageFactions;
|
import com.massivecraft.factions.Faction;
|
||||||
import com.massivecraft.factions.integration.Econ;
|
import com.massivecraft.factions.SavageFactions;
|
||||||
import com.massivecraft.factions.zcore.util.TL;
|
import com.massivecraft.factions.integration.Econ;
|
||||||
import com.massivecraft.factions.zcore.util.TextUtil;
|
import com.massivecraft.factions.zcore.util.TL;
|
||||||
import mkremins.fanciful.FancyMessage;
|
import com.massivecraft.factions.zcore.util.TextUtil;
|
||||||
import org.apache.commons.lang.time.DurationFormatUtils;
|
import mkremins.fanciful.FancyMessage;
|
||||||
import org.bukkit.Bukkit;
|
import org.apache.commons.lang.time.DurationFormatUtils;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.LinkedHashMap;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.Map.Entry;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.Map.Entry;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
public abstract class MCommand<T extends MPlugin> {
|
|
||||||
|
public abstract class MCommand<T extends MPlugin> {
|
||||||
public T p;
|
|
||||||
|
public T p;
|
||||||
// The sub-commands to this command
|
|
||||||
public List<MCommand<?>> subCommands;
|
// The sub-commands to this command
|
||||||
// The different names this commands will react to
|
public List<MCommand<?>> subCommands;
|
||||||
public List<String> aliases;
|
// The different names this commands will react to
|
||||||
public boolean allowNoSlashAccess;
|
public List<String> aliases;
|
||||||
// Information on the args
|
public boolean allowNoSlashAccess;
|
||||||
public List<String> requiredArgs;
|
// Information on the args
|
||||||
public LinkedHashMap<String, String> optionalArgs;
|
public List<String> requiredArgs;
|
||||||
public boolean errorOnToManyArgs = true;
|
public LinkedHashMap<String, String> optionalArgs;
|
||||||
public List<String> helpLong;
|
public boolean errorOnToManyArgs = true;
|
||||||
public CommandVisibility visibility;
|
public List<String> helpLong;
|
||||||
// Some information on permissions
|
public CommandVisibility visibility;
|
||||||
public boolean senderMustBePlayer;
|
// Some information on permissions
|
||||||
public String permission;
|
public boolean senderMustBePlayer;
|
||||||
// Information available on execution of the command
|
public boolean senderMustHaveFaction;
|
||||||
public CommandSender sender; // Will always be set
|
public String permission;
|
||||||
public Player me; // Will only be set when the sender is a player
|
// Information available on execution of the command
|
||||||
public boolean senderIsConsole;
|
public CommandSender sender; // Will always be set
|
||||||
public List<String> args; // Will contain the arguments, or and empty list if there are none.
|
public Player me; // Will only be set when the sender is a player
|
||||||
public List<MCommand<?>> commandChain = new ArrayList<>(); // The command chain used to execute this command
|
public boolean senderIsConsole;
|
||||||
// FIELD: Help Short
|
public List<String> args; // Will contain the arguments, or and empty list if there are none.
|
||||||
// This field may be left blank and will in such case be loaded from the permissions node instead.
|
public List<MCommand<?>> commandChain = new ArrayList<>(); // The command chain used to execute this command
|
||||||
// Thus make sure the permissions node description is an action description like "eat hamburgers" or "do admin stuff".
|
// FIELD: Help Short
|
||||||
private String helpShort;
|
// 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".
|
||||||
public MCommand(T p) {
|
private String helpShort;
|
||||||
this.p = p;
|
|
||||||
|
public MCommand(T p) {
|
||||||
this.permission = null;
|
this.p = p;
|
||||||
|
|
||||||
this.allowNoSlashAccess = false;
|
this.permission = null;
|
||||||
|
|
||||||
this.subCommands = new ArrayList<>();
|
this.allowNoSlashAccess = false;
|
||||||
this.aliases = new ArrayList<>();
|
|
||||||
|
this.subCommands = new ArrayList<>();
|
||||||
this.requiredArgs = new ArrayList<>();
|
this.aliases = new ArrayList<>();
|
||||||
this.optionalArgs = new LinkedHashMap<>();
|
|
||||||
|
this.requiredArgs = new ArrayList<>();
|
||||||
this.helpShort = null;
|
this.optionalArgs = new LinkedHashMap<>();
|
||||||
this.helpLong = new ArrayList<>();
|
|
||||||
this.visibility = CommandVisibility.VISIBLE;
|
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);
|
public void addSubCommand(MCommand<?> subCommand) {
|
||||||
this.subCommands.add(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 String getHelpShort() {
|
||||||
|
return this.helpShort != null ? this.helpShort:getUsageTranslation().toString();
|
||||||
public void setHelpShort(String val) {
|
}
|
||||||
this.helpShort = val;
|
|
||||||
}
|
public void setHelpShort(String val) {
|
||||||
|
this.helpShort = val;
|
||||||
public abstract TL getUsageTranslation();
|
}
|
||||||
|
|
||||||
public void setCommandSender(CommandSender sender)
|
public abstract TL getUsageTranslation();
|
||||||
{
|
|
||||||
this.sender = sender;
|
public void setCommandSender(CommandSender sender)
|
||||||
if (sender instanceof Player) {
|
{
|
||||||
this.me = (Player) sender;
|
this.sender = sender;
|
||||||
this.senderIsConsole = false;
|
if (sender instanceof Player) {
|
||||||
} else {
|
this.me = (Player) sender;
|
||||||
this.me = null;
|
this.senderIsConsole = false;
|
||||||
this.senderIsConsole = true;
|
} 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<String> args, List<MCommand<?>> commandChain) {
|
|
||||||
// Set the execution-time specific variables
|
// The commandChain is a list of the parent command chain used to get to this command.
|
||||||
setCommandSender(sender);
|
public void execute(CommandSender sender, List<String> args, List<MCommand<?>> commandChain) {
|
||||||
this.args = args;
|
// Set the execution-time specific variables
|
||||||
this.commandChain = commandChain;
|
setCommandSender(sender);
|
||||||
|
this.args = args;
|
||||||
// Is there a matching sub command?
|
this.commandChain = commandChain;
|
||||||
if (args.size() > 0) {
|
|
||||||
for (MCommand<?> subCommand : this.subCommands) {
|
// Is there a matching sub command?
|
||||||
if (subCommand.aliases.contains(args.get(0).toLowerCase())) {
|
if (args.size() > 0) {
|
||||||
args.remove(0);
|
for (MCommand<?> subCommand : this.subCommands) {
|
||||||
commandChain.add(this);
|
if (subCommand.aliases.contains(args.get(0).toLowerCase())) {
|
||||||
subCommand.execute(sender, args, commandChain);
|
args.remove(0);
|
||||||
return;
|
commandChain.add(this);
|
||||||
}
|
subCommand.execute(sender, args, commandChain);
|
||||||
}
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (!validCall(this.sender, this.args)) {
|
}
|
||||||
return;
|
|
||||||
}
|
if (!validCall(this.sender, this.args)) {
|
||||||
|
return;
|
||||||
if (!this.isEnabled()) {
|
}
|
||||||
return;
|
|
||||||
}
|
if (!this.isEnabled()) {
|
||||||
|
return;
|
||||||
perform();
|
}
|
||||||
}
|
|
||||||
|
perform();
|
||||||
public void execute(CommandSender sender, List<String> args) {
|
}
|
||||||
execute(sender, args, new ArrayList<MCommand<?>>());
|
|
||||||
}
|
public void execute(CommandSender sender, List<String> args) {
|
||||||
|
execute(sender, args, new ArrayList<MCommand<?>>());
|
||||||
// This is where the command action is performed.
|
}
|
||||||
public abstract void perform();
|
|
||||||
|
// This is where the command action is performed.
|
||||||
|
public abstract void perform();
|
||||||
// -------------------------------------------- //
|
|
||||||
// Call Validation
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
// Call Validation
|
||||||
/**
|
// -------------------------------------------- //
|
||||||
* In this method we validate that all prerequisites to perform this command has been met.
|
|
||||||
*
|
/**
|
||||||
* @param sender of the command
|
* In this method we validate that all prerequisites to perform this command has been met.
|
||||||
* @param args of the command
|
*
|
||||||
* @return true if valid, false if not.
|
* @param sender of the command
|
||||||
*/
|
* @param args of the command
|
||||||
// TODO: There should be a boolean for silence
|
* @return true if valid, false if not.
|
||||||
public boolean validCall(CommandSender sender, List<String> args) {
|
*/
|
||||||
return validSenderType(sender, true) && validSenderPermissions(sender, true) && validArgs(args, sender);
|
// TODO: There should be a boolean for silence
|
||||||
}
|
public boolean validCall(CommandSender sender, List<String> args) {
|
||||||
|
return validSenderType(sender, true) && validSenderPermissions(sender, true) && validArgs(args, sender);
|
||||||
public boolean isEnabled() {
|
}
|
||||||
return true;
|
|
||||||
}
|
public boolean isEnabled() {
|
||||||
|
return true;
|
||||||
public boolean validSenderType(CommandSender sender, boolean informSenderIfNot) {
|
}
|
||||||
if (this.senderMustBePlayer && !(sender instanceof Player)) {
|
|
||||||
if (informSenderIfNot) {
|
|
||||||
msg(TL.GENERIC_PLAYERONLY);
|
public boolean validSenderType(CommandSender sender, boolean informSenderIfNot) {
|
||||||
}
|
if (this.senderMustBePlayer && !(sender instanceof Player)) {
|
||||||
return false;
|
if (informSenderIfNot) {
|
||||||
}
|
msg(TL.GENERIC_PLAYERONLY);
|
||||||
return true;
|
}
|
||||||
}
|
return false;
|
||||||
|
|
||||||
public boolean validSenderPermissions(CommandSender sender, boolean informSenderIfNot) {
|
}
|
||||||
return this.permission == null || p.perm.has(sender, this.permission, informSenderIfNot);
|
return !this.senderMustHaveFaction || !FPlayers.getInstance().getByPlayer((Player) sender).hasFaction();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean validArgs(List<String> args, CommandSender sender) {
|
public boolean validSenderPermissions(CommandSender sender, boolean informSenderIfNot) {
|
||||||
if (args.size() < this.requiredArgs.size()) {
|
return this.permission == null || p.perm.has(sender, this.permission, informSenderIfNot);
|
||||||
if (sender != null) {
|
}
|
||||||
msg(TL.GENERIC_ARGS_TOOFEW);
|
|
||||||
sender.sendMessage(this.getUseageTemplate());
|
public boolean validArgs(List<String> args, CommandSender sender) {
|
||||||
}
|
if (args.size() < this.requiredArgs.size()) {
|
||||||
return false;
|
if (sender != null) {
|
||||||
}
|
msg(TL.GENERIC_ARGS_TOOFEW);
|
||||||
|
sender.sendMessage(this.getUseageTemplate());
|
||||||
if (args.size() > this.requiredArgs.size() + this.optionalArgs.size() && this.errorOnToManyArgs) {
|
}
|
||||||
if (sender != null) {
|
return false;
|
||||||
// Get the to many string slice
|
}
|
||||||
List<String> theToMany = args.subList(this.requiredArgs.size() + this.optionalArgs.size(), args.size());
|
|
||||||
msg(TL.GENERIC_ARGS_TOOMANY, TextUtil.implode(theToMany, " "));
|
if (args.size() > this.requiredArgs.size() + this.optionalArgs.size() && this.errorOnToManyArgs) {
|
||||||
sender.sendMessage(this.getUseageTemplate());
|
if (sender != null) {
|
||||||
}
|
// Get the to many string slice
|
||||||
return false;
|
List<String> theToMany = args.subList(this.requiredArgs.size() + this.optionalArgs.size(), args.size());
|
||||||
}
|
msg(TL.GENERIC_ARGS_TOOMANY, TextUtil.implode(theToMany, " "));
|
||||||
return true;
|
sender.sendMessage(this.getUseageTemplate());
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
public boolean validArgs(List<String> args) {
|
}
|
||||||
return this.validArgs(args, null);
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------- //
|
public boolean validArgs(List<String> args) {
|
||||||
// Help and Usage information
|
return this.validArgs(args, null);
|
||||||
// -------------------------------------------- //
|
}
|
||||||
|
|
||||||
public String getUseageTemplate(List<MCommand<?>> commandChain, boolean addShortHelp) {
|
// -------------------------------------------- //
|
||||||
StringBuilder ret = new StringBuilder();
|
// Help and Usage information
|
||||||
ret.append(p.txt.parseTags("<c>"));
|
// -------------------------------------------- //
|
||||||
ret.append('/');
|
|
||||||
|
public String getUseageTemplate(List<MCommand<?>> commandChain, boolean addShortHelp) {
|
||||||
for (MCommand<?> mc : commandChain) {
|
StringBuilder ret = new StringBuilder();
|
||||||
ret.append(TextUtil.implode(mc.aliases, ","));
|
ret.append(p.txt.parseTags("<c>"));
|
||||||
ret.append(' ');
|
ret.append('/');
|
||||||
}
|
|
||||||
|
for (MCommand<?> mc : commandChain) {
|
||||||
ret.append(TextUtil.implode(this.aliases, ","));
|
ret.append(TextUtil.implode(mc.aliases, ","));
|
||||||
|
ret.append(' ');
|
||||||
List<String> args = new ArrayList<>();
|
}
|
||||||
|
|
||||||
for (String requiredArg : this.requiredArgs) {
|
ret.append(TextUtil.implode(this.aliases, ","));
|
||||||
args.add("<" + requiredArg + ">");
|
|
||||||
}
|
List<String> args = new ArrayList<>();
|
||||||
|
|
||||||
for (Entry<String, String> optionalArg : this.optionalArgs.entrySet()) {
|
for (String requiredArg : this.requiredArgs) {
|
||||||
String val = optionalArg.getValue();
|
args.add("<" + requiredArg + ">");
|
||||||
if (val == null) {
|
}
|
||||||
val = "";
|
|
||||||
} else {
|
for (Entry<String, String> optionalArg : this.optionalArgs.entrySet()) {
|
||||||
val = "=" + val;
|
String val = optionalArg.getValue();
|
||||||
}
|
if (val == null) {
|
||||||
args.add("[" + optionalArg.getKey() + val + "]");
|
val = "";
|
||||||
}
|
} else {
|
||||||
|
val = "=" + val;
|
||||||
if (args.size() > 0) {
|
}
|
||||||
ret.append(p.txt.parseTags("<plugin> "));
|
args.add("[" + optionalArg.getKey() + val + "]");
|
||||||
ret.append(TextUtil.implode(args, " "));
|
}
|
||||||
}
|
|
||||||
|
if (args.size() > 0) {
|
||||||
if (addShortHelp) {
|
ret.append(p.txt.parseTags("<plugin> "));
|
||||||
ret.append(p.txt.parseTags(" <i>"));
|
ret.append(TextUtil.implode(args, " "));
|
||||||
ret.append(this.getHelpShort());
|
}
|
||||||
}
|
|
||||||
|
if (addShortHelp) {
|
||||||
return ret.toString();
|
ret.append(p.txt.parseTags(" <i>"));
|
||||||
}
|
ret.append(this.getHelpShort());
|
||||||
|
}
|
||||||
public String getUseageTemplate(boolean addShortHelp) {
|
|
||||||
return getUseageTemplate(this.commandChain, addShortHelp);
|
return ret.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUseageTemplate() {
|
public String getUseageTemplate(boolean addShortHelp) {
|
||||||
return getUseageTemplate(false);
|
return getUseageTemplate(this.commandChain, addShortHelp);
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------- //
|
public String getUseageTemplate() {
|
||||||
// Message Sending Helpers
|
return getUseageTemplate(false);
|
||||||
// -------------------------------------------- //
|
}
|
||||||
|
|
||||||
public void msg(String str, Object... args) {
|
// -------------------------------------------- //
|
||||||
sender.sendMessage(p.txt.parse(str, args));
|
// Message Sending Helpers
|
||||||
}
|
// -------------------------------------------- //
|
||||||
|
|
||||||
public void msg(TL translation, Object... args) {
|
public void msg(String str, Object... args) {
|
||||||
sender.sendMessage(p.txt.parse(translation.toString(), args));
|
sender.sendMessage(p.txt.parse(str, args));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendMessage(String msg) {
|
public void msg(TL translation, Object... args) {
|
||||||
sender.sendMessage(msg);
|
sender.sendMessage(p.txt.parse(translation.toString(), args));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendMessage(List<String> msgs) {
|
public void sendMessage(String msg) {
|
||||||
for (String msg : msgs) {
|
sender.sendMessage(msg);
|
||||||
this.sendMessage(msg);
|
}
|
||||||
}
|
|
||||||
}
|
public void sendMessage(List<String> msgs) {
|
||||||
|
for (String msg : msgs) {
|
||||||
public void sendFancyMessage(FancyMessage message) {
|
this.sendMessage(msg);
|
||||||
message.send(sender);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendFancyMessage(List<FancyMessage> messages) {
|
public void sendFancyMessage(FancyMessage message) {
|
||||||
for (FancyMessage m : messages) {
|
message.send(sender);
|
||||||
sendFancyMessage(m);
|
}
|
||||||
}
|
|
||||||
}
|
public void sendFancyMessage(List<FancyMessage> messages) {
|
||||||
|
for (FancyMessage m : messages) {
|
||||||
public List<String> getToolTips(FPlayer player) {
|
sendFancyMessage(m);
|
||||||
List<String> lines = new ArrayList<>();
|
}
|
||||||
for (String s : p.getConfig().getStringList("tooltips.show")) {
|
}
|
||||||
lines.add(ChatColor.translateAlternateColorCodes('&', replaceFPlayerTags(s, player)));
|
|
||||||
}
|
public List<String> getToolTips(FPlayer player) {
|
||||||
return lines;
|
List<String> lines = new ArrayList<>();
|
||||||
}
|
for (String s : p.getConfig().getStringList("tooltips.show")) {
|
||||||
|
lines.add(ChatColor.translateAlternateColorCodes('&', replaceFPlayerTags(s, player)));
|
||||||
public List<String> getToolTips(Faction faction) {
|
}
|
||||||
List<String> lines = new ArrayList<>();
|
return lines;
|
||||||
for (String s : p.getConfig().getStringList("tooltips.list")) {
|
}
|
||||||
lines.add(ChatColor.translateAlternateColorCodes('&', replaceFactionTags(s, faction)));
|
|
||||||
}
|
public List<String> getToolTips(Faction faction) {
|
||||||
return lines;
|
List<String> lines = new ArrayList<>();
|
||||||
}
|
for (String s : p.getConfig().getStringList("tooltips.list")) {
|
||||||
|
lines.add(ChatColor.translateAlternateColorCodes('&', replaceFactionTags(s, faction)));
|
||||||
public String replaceFPlayerTags(String s, FPlayer player) {
|
}
|
||||||
if (s.contains("{balance}")) {
|
return lines;
|
||||||
String balance = Econ.isSetup() ? Econ.getFriendlyBalance(player) : "no balance";
|
}
|
||||||
s = s.replace("{balance}", balance);
|
|
||||||
}
|
public String replaceFPlayerTags(String s, FPlayer player) {
|
||||||
if (s.contains("{lastSeen}")) {
|
if (s.contains("{balance}")) {
|
||||||
String humanized = DurationFormatUtils.formatDurationWords(System.currentTimeMillis() - player.getLastLoginTime(), true, true) + " ago";
|
String balance = Econ.isSetup() ? Econ.getFriendlyBalance(player) : "no balance";
|
||||||
String lastSeen = player.isOnline() ? ChatColor.GREEN + "Online" : (System.currentTimeMillis() - player.getLastLoginTime() < 432000000 ? ChatColor.YELLOW + humanized : ChatColor.RED + humanized);
|
s = s.replace("{balance}", balance);
|
||||||
s = s.replace("{lastSeen}", lastSeen);
|
}
|
||||||
}
|
if (s.contains("{lastSeen}")) {
|
||||||
if (s.contains("{power}")) {
|
String humanized = DurationFormatUtils.formatDurationWords(System.currentTimeMillis() - player.getLastLoginTime(), true, true) + " ago";
|
||||||
String power = player.getPowerRounded() + "/" + player.getPowerMaxRounded();
|
String lastSeen = player.isOnline() ? ChatColor.GREEN + "Online" : (System.currentTimeMillis() - player.getLastLoginTime() < 432000000 ? ChatColor.YELLOW + humanized : ChatColor.RED + humanized);
|
||||||
s = s.replace("{power}", power);
|
s = s.replace("{lastSeen}", lastSeen);
|
||||||
}
|
}
|
||||||
if (s.contains("{group}")) {
|
if (s.contains("{power}")) {
|
||||||
String group = SavageFactions.plugin.getPrimaryGroup(Bukkit.getOfflinePlayer(UUID.fromString(player.getId())));
|
String power = player.getPowerRounded() + "/" + player.getPowerMaxRounded();
|
||||||
s = s.replace("{group}", group);
|
s = s.replace("{power}", power);
|
||||||
}
|
}
|
||||||
return s;
|
if (s.contains("{group}")) {
|
||||||
}
|
String group = SavageFactions.plugin.getPrimaryGroup(Bukkit.getOfflinePlayer(UUID.fromString(player.getId())));
|
||||||
|
s = s.replace("{group}", group);
|
||||||
public String replaceFactionTags(String s, Faction faction) {
|
}
|
||||||
if (s.contains("{power}")) {
|
return s;
|
||||||
s = s.replace("{power}", String.valueOf(faction.getPowerRounded()));
|
}
|
||||||
}
|
|
||||||
if (s.contains("{maxPower}")) {
|
public String replaceFactionTags(String s, Faction faction) {
|
||||||
s = s.replace("{maxPower}", String.valueOf(faction.getPowerMaxRounded()));
|
if (s.contains("{power}")) {
|
||||||
}
|
s = s.replace("{power}", String.valueOf(faction.getPowerRounded()));
|
||||||
if (s.contains("{leader}")) {
|
}
|
||||||
FPlayer fLeader = faction.getFPlayerAdmin();
|
if (s.contains("{maxPower}")) {
|
||||||
String leader = fLeader == null ? "Server" : fLeader.getName().substring(0, fLeader.getName().length() > 14 ? 13 : fLeader.getName().length());
|
s = s.replace("{maxPower}", String.valueOf(faction.getPowerMaxRounded()));
|
||||||
s = s.replace("{leader}", leader);
|
}
|
||||||
}
|
if (s.contains("{leader}")) {
|
||||||
if (s.contains("{chunks}")) {
|
FPlayer fLeader = faction.getFPlayerAdmin();
|
||||||
s = s.replace("{chunks}", String.valueOf(faction.getLandRounded()));
|
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("{members}")) {
|
}
|
||||||
s = s.replace("{members}", String.valueOf(faction.getSize()));
|
if (s.contains("{chunks}")) {
|
||||||
|
s = s.replace("{chunks}", String.valueOf(faction.getLandRounded()));
|
||||||
}
|
}
|
||||||
if (s.contains("{online}")) {
|
if (s.contains("{members}")) {
|
||||||
s = s.replace("{online}", String.valueOf(faction.getOnlinePlayers().size()));
|
s = s.replace("{members}", String.valueOf(faction.getSize()));
|
||||||
}
|
|
||||||
return s;
|
}
|
||||||
}
|
if (s.contains("{online}")) {
|
||||||
|
s = s.replace("{online}", String.valueOf(faction.getOnlinePlayers().size()));
|
||||||
// -------------------------------------------- //
|
}
|
||||||
// Argument Readers
|
return s;
|
||||||
// -------------------------------------------- //
|
}
|
||||||
|
|
||||||
// Is set? ======================
|
// -------------------------------------------- //
|
||||||
public boolean argIsSet(int idx) {
|
// Argument Readers
|
||||||
return this.args.size() >= idx + 1;
|
// -------------------------------------------- //
|
||||||
}
|
|
||||||
|
// Is set? ======================
|
||||||
// STRING ======================
|
public boolean argIsSet(int idx) {
|
||||||
public String argAsString(int idx, String def) {
|
return this.args.size() >= idx + 1;
|
||||||
if (this.args.size() < idx + 1) {
|
}
|
||||||
return def;
|
|
||||||
}
|
// STRING ======================
|
||||||
return this.args.get(idx);
|
public String argAsString(int idx, String def) {
|
||||||
}
|
if (this.args.size() < idx + 1) {
|
||||||
|
return def;
|
||||||
public String argAsString(int idx) {
|
}
|
||||||
return this.argAsString(idx, null);
|
return this.args.get(idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
// INT ======================
|
public String argAsString(int idx) {
|
||||||
public Integer strAsInt(String str, Integer def) {
|
return this.argAsString(idx, null);
|
||||||
if (str == null) {
|
}
|
||||||
return def;
|
|
||||||
}
|
// INT ======================
|
||||||
try {
|
public Integer strAsInt(String str, Integer def) {
|
||||||
return Integer.parseInt(str);
|
if (str == null) {
|
||||||
} catch (Exception e) {
|
return def;
|
||||||
return def;
|
}
|
||||||
}
|
try {
|
||||||
}
|
return Integer.parseInt(str);
|
||||||
|
} catch (Exception e) {
|
||||||
public Integer argAsInt(int idx, Integer def) {
|
return def;
|
||||||
return strAsInt(this.argAsString(idx), def);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer argAsInt(int idx) {
|
public Integer argAsInt(int idx, Integer def) {
|
||||||
return this.argAsInt(idx, null);
|
return strAsInt(this.argAsString(idx), def);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Double ======================
|
public Integer argAsInt(int idx) {
|
||||||
public Double strAsDouble(String str, Double def) {
|
return this.argAsInt(idx, null);
|
||||||
if (str == null) {
|
}
|
||||||
return def;
|
|
||||||
}
|
// Double ======================
|
||||||
try {
|
public Double strAsDouble(String str, Double def) {
|
||||||
return Double.parseDouble(str);
|
if (str == null) {
|
||||||
} catch (Exception e) {
|
return def;
|
||||||
return def;
|
}
|
||||||
}
|
try {
|
||||||
}
|
return Double.parseDouble(str);
|
||||||
|
} catch (Exception e) {
|
||||||
public Double argAsDouble(int idx, Double def) {
|
return def;
|
||||||
return strAsDouble(this.argAsString(idx), def);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Double argAsDouble(int idx) {
|
public Double argAsDouble(int idx, Double def) {
|
||||||
return this.argAsDouble(idx, null);
|
return strAsDouble(this.argAsString(idx), def);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Go through the str conversion for the other arg-readers as well.
|
public Double argAsDouble(int idx) {
|
||||||
// Boolean ======================
|
return this.argAsDouble(idx, null);
|
||||||
public Boolean strAsBool(String str) {
|
}
|
||||||
str = str.toLowerCase();
|
|
||||||
return str.startsWith("y") || str.startsWith("t") || str.startsWith("on") || str.startsWith("+") || str.startsWith("1");
|
// TODO: Go through the str conversion for the other arg-readers as well.
|
||||||
}
|
// Boolean ======================
|
||||||
|
public Boolean strAsBool(String str) {
|
||||||
public Boolean argAsBool(int idx, boolean def) {
|
str = str.toLowerCase();
|
||||||
String str = this.argAsString(idx);
|
return str.startsWith("y") || str.startsWith("t") || str.startsWith("on") || str.startsWith("+") || str.startsWith("1");
|
||||||
if (str == null) {
|
}
|
||||||
return def;
|
|
||||||
}
|
public Boolean argAsBool(int idx, boolean def) {
|
||||||
|
String str = this.argAsString(idx);
|
||||||
return strAsBool(str);
|
if (str == null) {
|
||||||
}
|
return def;
|
||||||
|
}
|
||||||
public Boolean argAsBool(int idx) {
|
|
||||||
return this.argAsBool(idx, false);
|
return strAsBool(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
// PLAYER ======================
|
public Boolean argAsBool(int idx) {
|
||||||
public Player strAsPlayer(String name, Player def, boolean msg) {
|
return this.argAsBool(idx, false);
|
||||||
Player ret = def;
|
}
|
||||||
|
|
||||||
if (name != null) {
|
// PLAYER ======================
|
||||||
Player player = Bukkit.getServer().getPlayer(name);
|
public Player strAsPlayer(String name, Player def, boolean msg) {
|
||||||
if (player != null) {
|
Player ret = def;
|
||||||
ret = player;
|
|
||||||
}
|
if (name != null) {
|
||||||
}
|
Player player = Bukkit.getServer().getPlayer(name);
|
||||||
|
if (player != null) {
|
||||||
if (msg && ret == null) {
|
ret = player;
|
||||||
this.msg(TL.GENERIC_NOPLAYERFOUND, name);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
if (msg && ret == null) {
|
||||||
}
|
this.msg(TL.GENERIC_NOPLAYERFOUND, name);
|
||||||
|
}
|
||||||
public Player argAsPlayer(int idx, Player def, boolean msg) {
|
|
||||||
return this.strAsPlayer(this.argAsString(idx), def, msg);
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Player argAsPlayer(int idx, Player def) {
|
public Player argAsPlayer(int idx, Player def, boolean msg) {
|
||||||
return this.argAsPlayer(idx, def, true);
|
return this.strAsPlayer(this.argAsString(idx), def, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Player argAsPlayer(int idx) {
|
public Player argAsPlayer(int idx, Player def) {
|
||||||
return this.argAsPlayer(idx, null);
|
return this.argAsPlayer(idx, def, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// BEST PLAYER MATCH ======================
|
public Player argAsPlayer(int idx) {
|
||||||
public Player strAsBestPlayerMatch(String name, Player def, boolean msg) {
|
return this.argAsPlayer(idx, null);
|
||||||
Player ret = def;
|
}
|
||||||
|
|
||||||
if (name != null) {
|
// BEST PLAYER MATCH ======================
|
||||||
List<Player> players = Bukkit.getServer().matchPlayer(name);
|
public Player strAsBestPlayerMatch(String name, Player def, boolean msg) {
|
||||||
if (players.size() > 0) {
|
Player ret = def;
|
||||||
ret = players.get(0);
|
|
||||||
}
|
if (name != null) {
|
||||||
}
|
List<Player> players = Bukkit.getServer().matchPlayer(name);
|
||||||
|
if (players.size() > 0) {
|
||||||
if (msg && ret == null) {
|
ret = players.get(0);
|
||||||
this.msg(TL.GENERIC_NOPLAYERMATCH, name);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
if (msg && ret == null) {
|
||||||
}
|
this.msg(TL.GENERIC_NOPLAYERMATCH, name);
|
||||||
|
}
|
||||||
public Player argAsBestPlayerMatch(int idx, Player def, boolean msg) {
|
|
||||||
return this.strAsBestPlayerMatch(this.argAsString(idx), def, msg);
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Player argAsBestPlayerMatch(int idx, Player def) {
|
public Player argAsBestPlayerMatch(int idx, Player def, boolean msg) {
|
||||||
return this.argAsBestPlayerMatch(idx, def, true);
|
return this.strAsBestPlayerMatch(this.argAsString(idx), def, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Player argAsBestPlayerMatch(int idx) {
|
public Player argAsBestPlayerMatch(int idx, Player def) {
|
||||||
return this.argAsPlayer(idx, null);
|
return this.argAsBestPlayerMatch(idx, def, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Player argAsBestPlayerMatch(int idx) {
|
||||||
|
return this.argAsPlayer(idx, null);
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user