2011-10-09 21:57:43 +02:00
|
|
|
package com.massivecraft.factions.cmd;
|
2011-09-13 20:14:09 +02:00
|
|
|
|
2014-04-04 20:55:21 +02:00
|
|
|
import com.massivecraft.factions.FPlayer;
|
2011-10-09 18:35:39 +02:00
|
|
|
import com.massivecraft.factions.FPlayers;
|
2011-09-13 20:14:09 +02:00
|
|
|
import com.massivecraft.factions.Faction;
|
2018-10-23 01:42:57 +02:00
|
|
|
import com.massivecraft.factions.SavageFactions;
|
2011-10-09 18:35:39 +02:00
|
|
|
import com.massivecraft.factions.struct.Permission;
|
2015-01-22 00:58:33 +01:00
|
|
|
import com.massivecraft.factions.zcore.util.TL;
|
2011-09-13 20:14:09 +02:00
|
|
|
|
|
|
|
|
2014-04-04 20:55:21 +02:00
|
|
|
public class CmdPermanent extends FCommand {
|
2014-08-05 17:17:27 +02:00
|
|
|
|
2014-04-04 20:55:21 +02:00
|
|
|
public CmdPermanent() {
|
2014-07-01 22:10:18 +02:00
|
|
|
super();
|
|
|
|
this.aliases.add("permanent");
|
2014-04-04 20:55:21 +02:00
|
|
|
|
|
|
|
this.requiredArgs.add("faction tag");
|
|
|
|
//this.optionalArgs.put("", "");
|
|
|
|
|
2014-07-01 22:10:18 +02:00
|
|
|
this.permission = Permission.SET_PERMANENT.node;
|
|
|
|
this.disableOnLock = true;
|
2014-04-04 20:55:21 +02:00
|
|
|
|
2014-07-01 22:10:18 +02:00
|
|
|
senderMustBePlayer = false;
|
|
|
|
senderMustBeMember = false;
|
|
|
|
senderMustBeModerator = false;
|
2018-03-26 23:43:15 +02:00
|
|
|
senderMustBeColeader = false;
|
2014-04-04 20:55:21 +02:00
|
|
|
senderMustBeAdmin = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void perform() {
|
2014-07-01 22:10:18 +02:00
|
|
|
Faction faction = this.argAsFaction(0);
|
|
|
|
if (faction == null) {
|
|
|
|
return;
|
|
|
|
}
|
2014-04-04 20:55:21 +02:00
|
|
|
|
2014-07-01 22:10:18 +02:00
|
|
|
String change;
|
|
|
|
if (faction.isPermanent()) {
|
2015-01-22 00:58:33 +01:00
|
|
|
change = TL.COMMAND_PERMANENT_REVOKE.toString();
|
2014-07-01 22:10:18 +02:00
|
|
|
faction.setPermanent(false);
|
2014-07-01 21:52:40 +02:00
|
|
|
} else {
|
2015-01-22 00:58:33 +01:00
|
|
|
change = TL.COMMAND_PERMANENT_GRANT.toString();
|
2014-07-01 22:10:18 +02:00
|
|
|
faction.setPermanent(true);
|
2014-04-04 20:55:21 +02:00
|
|
|
}
|
|
|
|
|
2018-11-07 06:38:43 +01:00
|
|
|
SavageFactions.plugin.log((fme == null ? "A server admin" : fme.getName()) + " " + change + " the faction \"" + faction.getTag() + "\".");
|
2014-04-04 20:55:21 +02:00
|
|
|
|
|
|
|
// Inform all players
|
2014-10-19 07:37:25 +02:00
|
|
|
for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers()) {
|
2015-05-13 06:17:22 +02:00
|
|
|
String blame = (fme == null ? TL.GENERIC_SERVERADMIN.toString() : fme.describeTo(fplayer, true));
|
2014-04-04 20:55:21 +02:00
|
|
|
if (fplayer.getFaction() == faction) {
|
2015-01-22 00:58:33 +01:00
|
|
|
fplayer.msg(TL.COMMAND_PERMANENT_YOURS, blame, change);
|
2014-07-01 21:52:40 +02:00
|
|
|
} else {
|
2015-01-22 00:58:33 +01:00
|
|
|
fplayer.msg(TL.COMMAND_PERMANENT_OTHER, blame, change, faction.getTag(fplayer));
|
2014-04-04 20:55:21 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-01-22 00:58:33 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public TL getUsageTranslation() {
|
|
|
|
return TL.COMMAND_PERMANENT_DESCRIPTION;
|
|
|
|
}
|
2011-09-13 20:14:09 +02:00
|
|
|
}
|