Cooldown and F Spam System Implemented
This commit is contained in:
@@ -16,6 +16,7 @@ public class CmdAHome extends FCommand {
|
||||
|
||||
this.permission = Permission.AHOME.node;
|
||||
this.disableOnLock = false;
|
||||
this.disableOnSpam = false;
|
||||
|
||||
senderMustBePlayer = false;
|
||||
senderMustBeMember = false;
|
||||
|
||||
@@ -23,6 +23,7 @@ public class CmdAdmin extends FCommand {
|
||||
|
||||
this.permission = Permission.ADMIN.node;
|
||||
this.disableOnLock = true;
|
||||
this.disableOnSpam = true;
|
||||
|
||||
|
||||
senderMustBePlayer = false;
|
||||
|
||||
@@ -20,6 +20,7 @@ public class CmdAlts extends FCommand {
|
||||
|
||||
this.permission = Permission.ALTS.node;
|
||||
this.disableOnLock = false;
|
||||
this.disableOnSpam = false;
|
||||
|
||||
senderMustBePlayer = true;
|
||||
senderMustBeMember = true;
|
||||
|
||||
@@ -16,6 +16,8 @@ public class CmdAltsList extends FCommand{
|
||||
this.aliases.add("list");
|
||||
|
||||
this.permission = Permission.LIST.node;
|
||||
this.disableOnLock = false;
|
||||
this.disableOnSpam = false;
|
||||
|
||||
senderMustBePlayer = true;
|
||||
senderMustBeMember = true;
|
||||
|
||||
@@ -19,6 +19,7 @@ public class CmdAnnounce extends FCommand {
|
||||
|
||||
this.permission = Permission.ANNOUNCE.node;
|
||||
this.disableOnLock = false;
|
||||
this.disableOnSpam = false;
|
||||
|
||||
senderMustBePlayer = true;
|
||||
senderMustBeMember = true;
|
||||
|
||||
@@ -16,6 +16,7 @@ public class CmdAutoClaim extends FCommand {
|
||||
|
||||
this.permission = Permission.AUTOCLAIM.node;
|
||||
this.disableOnLock = true;
|
||||
this.disableOnSpam = false;
|
||||
|
||||
senderMustBePlayer = true;
|
||||
senderMustBeMember = false;
|
||||
|
||||
@@ -23,6 +23,7 @@ public class CmdBan extends FCommand {
|
||||
|
||||
this.permission = Permission.BAN.node;
|
||||
this.disableOnLock = true;
|
||||
this.disableOnSpam = false;
|
||||
|
||||
senderMustBePlayer = true;
|
||||
senderMustBeMember = false;
|
||||
|
||||
@@ -23,6 +23,7 @@ public class CmdBanlist extends FCommand {
|
||||
|
||||
this.permission = Permission.BAN.node;
|
||||
this.disableOnLock = true;
|
||||
this.disableOnSpam = false;
|
||||
|
||||
senderMustBePlayer = true;
|
||||
senderMustBeMember = false;
|
||||
|
||||
@@ -24,6 +24,7 @@ public class CmdCreate extends FCommand {
|
||||
|
||||
this.permission = Permission.CREATE.node;
|
||||
this.disableOnLock = true;
|
||||
this.disableOnSpam = true;
|
||||
|
||||
senderMustBePlayer = true;
|
||||
senderMustBeMember = false;
|
||||
@@ -41,6 +42,11 @@ public class CmdCreate extends FCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!fme.isCooldownEnded("create")) {
|
||||
fme.msg(TL.COMMAND_ONCOOOLDOWN, fme.getCooldown("create"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (Factions.getInstance().isTagTaken(tag)) {
|
||||
msg(TL.COMMAND_CREATE_INUSE);
|
||||
return;
|
||||
@@ -108,6 +114,9 @@ public class CmdCreate extends FCommand {
|
||||
if (SavageFactions.plugin.getConfig().getBoolean("fpaypal.Enabled")) {
|
||||
this.fme.msg(TL.COMMAND_PAYPALSET_CREATED);
|
||||
}
|
||||
|
||||
fme.setCooldown("create", System.currentTimeMillis() + (SavageFactions.plugin.getConfig().getInt("fcooldowns.f-create") * 1000));
|
||||
|
||||
if (Conf.useCustomDefaultPermissions) {
|
||||
faction.setDefaultPerms();
|
||||
if (Conf.usePermissionHints)
|
||||
|
||||
@@ -28,7 +28,7 @@ public class CmdDisband extends FCommand {
|
||||
|
||||
this.permission = Permission.DISBAND.node;
|
||||
this.disableOnLock = true;
|
||||
|
||||
this.disableOnSpam = true;
|
||||
|
||||
senderMustBePlayer = false;
|
||||
senderMustBeMember = false;
|
||||
@@ -46,6 +46,12 @@ public class CmdDisband extends FCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (!fme.isCooldownEnded("disband")) {
|
||||
fme.msg(TL.COMMAND_ONCOOOLDOWN, fme.getCooldown("disband"));
|
||||
return;
|
||||
}
|
||||
|
||||
boolean isMyFaction = fme != null && faction == myFaction;
|
||||
|
||||
if (isMyFaction) {
|
||||
@@ -89,6 +95,7 @@ public class CmdDisband extends FCommand {
|
||||
UtilFly.checkFly(this.fme, Board.getInstance().getFactionAt(new FLocation(follower)));
|
||||
if (follower.getFaction() == faction) {
|
||||
follower.msg(TL.COMMAND_DISBAND_BROADCAST_YOURS, amountString);
|
||||
fme.setCooldown("disband", System.currentTimeMillis() + (SavageFactions.plugin.getConfig().getInt("fcooldowns.f-disband") * 1000));
|
||||
} else {
|
||||
follower.msg(TL.COMMAND_DISBAND_BROADCAST_NOTYOURS, amountString, faction.getTag(follower));
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.massivecraft.factions.cmd;
|
||||
import com.massivecraft.factions.Conf;
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.FPlayers;
|
||||
import com.massivecraft.factions.SavageFactions;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
|
||||
@@ -17,6 +18,7 @@ public class CmdOpen extends FCommand {
|
||||
|
||||
this.permission = Permission.OPEN.node;
|
||||
this.disableOnLock = false;
|
||||
this.disableOnSpam = true;
|
||||
|
||||
|
||||
senderMustBePlayer = true;
|
||||
@@ -33,6 +35,11 @@ public class CmdOpen extends FCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!fme.isCooldownEnded("open")) {
|
||||
fme.msg(TL.COMMAND_ONCOOOLDOWN, fme.getCooldown("open"));
|
||||
return;
|
||||
}
|
||||
|
||||
myFaction.setOpen(this.argAsBool(0, !myFaction.getOpen()));
|
||||
|
||||
String open = myFaction.getOpen() ? TL.COMMAND_OPEN_OPEN.toString() : TL.COMMAND_OPEN_CLOSED.toString();
|
||||
@@ -45,6 +52,7 @@ public class CmdOpen extends FCommand {
|
||||
}
|
||||
fplayer.msg(TL.COMMAND_OPEN_CHANGED, myFaction.getTag(fplayer.getFaction()), open);
|
||||
}
|
||||
fme.setCooldown("open", System.currentTimeMillis() + (SavageFactions.plugin.getConfig().getInt("fcooldowns.f-open") * 1000));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -19,6 +19,7 @@ public class CmdShow extends FCommand {
|
||||
public CmdShow() {
|
||||
this.aliases.add("show");
|
||||
this.aliases.add("who");
|
||||
this.aliases.add("f");
|
||||
|
||||
// add defaults to /f show in case config doesnt have it
|
||||
defaults.add("{header}");
|
||||
|
||||
34
src/main/java/com/massivecraft/factions/cmd/CmdSpam.java
Normal file
34
src/main/java/com/massivecraft/factions/cmd/CmdSpam.java
Normal file
@@ -0,0 +1,34 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.Conf;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
|
||||
public class CmdSpam extends FCommand {
|
||||
|
||||
public CmdSpam(){
|
||||
this.aliases.add("spam");
|
||||
|
||||
this.optionalArgs.put("on/off", "flip");
|
||||
|
||||
this.permission = Permission.SPAM.node;
|
||||
this.disableOnLock = false;
|
||||
this.disableOnSpam = false;
|
||||
|
||||
senderMustBePlayer = false;
|
||||
senderMustBeMember = false;
|
||||
senderMustBeModerator = false;
|
||||
senderMustBeAdmin = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform() {
|
||||
p.setSpam(this.argAsBool(0, !p.getSpam()));
|
||||
msg(p.getSpam() ? TL.COMMAND_SPAM_ENABLED : TL.COMMAND_SPAM_DISABLED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TL getUsageTranslation() {
|
||||
return TL.COMMAND_SPAM_DESCRIPTION;
|
||||
}
|
||||
}
|
||||
@@ -21,6 +21,7 @@ public class CmdTag extends FCommand {
|
||||
|
||||
this.permission = Permission.TAG.node;
|
||||
this.disableOnLock = true;
|
||||
this.disableOnSpam = true;
|
||||
|
||||
senderMustBePlayer = true;
|
||||
senderMustBeMember = false;
|
||||
@@ -33,6 +34,13 @@ public class CmdTag extends FCommand {
|
||||
public void perform() {
|
||||
String tag = this.argAsString(0);
|
||||
|
||||
|
||||
if (!fme.isCooldownEnded("tag")) {
|
||||
fme.msg(TL.COMMAND_ONCOOOLDOWN, fme.getCooldown("tag"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// TODO does not first test cover selfcase?
|
||||
if (Factions.getInstance().isTagTaken(tag) && !MiscUtil.getComparisonString(tag).equals(myFaction.getComparisonTag())) {
|
||||
msg(TL.COMMAND_TAG_TAKEN);
|
||||
@@ -78,7 +86,7 @@ public class CmdTag extends FCommand {
|
||||
fplayer.msg(TL.COMMAND_TAG_CHANGED, fme.getColorTo(faction) + oldtag, myFaction.getTag(faction));
|
||||
}
|
||||
}
|
||||
|
||||
fme.setCooldown("tag", System.currentTimeMillis() + (SavageFactions.plugin.getConfig().getInt("fcooldowns.f-tag") * 1000));
|
||||
FTeamWrapper.updatePrefixes(myFaction);
|
||||
}
|
||||
|
||||
|
||||
@@ -108,6 +108,7 @@ public class FCmdRoot extends FCommand {
|
||||
public CmdStrike cmdStrike = new CmdStrike();
|
||||
public CmdStrikeSet cmdStrikeSet = new CmdStrikeSet();
|
||||
public CmdAlts cmdAlts = new CmdAlts();
|
||||
public CmdSpam cmdSpam = new CmdSpam();
|
||||
|
||||
|
||||
|
||||
@@ -222,6 +223,7 @@ public class FCmdRoot extends FCommand {
|
||||
this.addSubCommand(this.cmdChest);
|
||||
this.addSubCommand(this.cmdSetBanner);
|
||||
this.addSubCommand(this.cmdStrikeSet);
|
||||
this.addSubCommand(this.cmdSpam);
|
||||
|
||||
|
||||
if(SavageFactions.plugin.getConfig().getBoolean("f-alts.Enabled")){
|
||||
|
||||
@@ -18,6 +18,7 @@ public abstract class FCommand extends MCommand<SavageFactions> {
|
||||
public static final SimpleDateFormat sdf = new SimpleDateFormat(TL.DATE_FORMAT.toString());
|
||||
|
||||
public boolean disableOnLock;
|
||||
public boolean disableOnSpam;
|
||||
|
||||
public FPlayer fme;
|
||||
public Faction myFaction;
|
||||
@@ -34,6 +35,7 @@ public abstract class FCommand extends MCommand<SavageFactions> {
|
||||
|
||||
// Due to safety reasons it defaults to disable on lock.
|
||||
disableOnLock = true;
|
||||
disableOnSpam = false;
|
||||
|
||||
// The money commands must be disabled if money should not be used.
|
||||
isMoneyCommand = false;
|
||||
@@ -69,6 +71,11 @@ public abstract class FCommand extends MCommand<SavageFactions> {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(p.getSpam() && this.disableOnSpam){
|
||||
msg("<b>Anti-Spam is currently enabled! Please try again later.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.isMoneyCommand && !Conf.econEnabled) {
|
||||
msg("<b>Faction economy features are disabled on this server.");
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user