mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-01-01 14:07:54 +01:00
Implemented /plan m disable kickcount #389
This commit is contained in:
parent
16ab5070be
commit
8f506740d6
@ -181,6 +181,7 @@ public class Plan extends BukkitPlugin<Plan> implements IPlan {
|
||||
if (!reloading) {
|
||||
registerListeners();
|
||||
}
|
||||
PlanPlayerListener.setCountKicks(true);
|
||||
registerTasks();
|
||||
|
||||
this.api = new API(this);
|
||||
|
@ -44,5 +44,6 @@ public class ManageCommand extends TreeCommand<Plan> {
|
||||
commands.add(new ManageClearCommand(plugin));
|
||||
commands.add(new ManageDumpCommand(plugin));
|
||||
commands.add(new ManageSetupCommand(plugin));
|
||||
commands.add(new ManageDisableCommand());
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,45 @@
|
||||
package main.java.com.djrapitops.plan.command.commands.manage;
|
||||
|
||||
import com.djrapitops.plugin.command.CommandType;
|
||||
import com.djrapitops.plugin.command.ISender;
|
||||
import com.djrapitops.plugin.command.SubCommand;
|
||||
import main.java.com.djrapitops.plan.Permissions;
|
||||
import main.java.com.djrapitops.plan.locale.Locale;
|
||||
import main.java.com.djrapitops.plan.locale.Msg;
|
||||
import main.java.com.djrapitops.plan.systems.listeners.PlanPlayerListener;
|
||||
import main.java.com.djrapitops.plan.utilities.Check;
|
||||
|
||||
/**
|
||||
* This manage SubCommand is used to disable some features of the plugin temporarily.
|
||||
*
|
||||
* @author Rsl1122
|
||||
* @since 4.0.4
|
||||
*/
|
||||
public class ManageDisableCommand extends SubCommand {
|
||||
/**
|
||||
* Class Constructor.
|
||||
*/
|
||||
public ManageDisableCommand() {
|
||||
super("disable",
|
||||
CommandType.CONSOLE_WITH_ARGUMENTS,
|
||||
Permissions.MANAGE.getPermission(),
|
||||
"Used to disable some features of the Plugin temporarily",
|
||||
"<feature>");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(ISender sender, String commandLabel, String[] args) {
|
||||
if (!Check.isTrue(args.length >= 1, Locale.get(Msg.CMD_FAIL_REQ_ARGS).parse(this.getArguments()), sender)) {
|
||||
return true;
|
||||
}
|
||||
switch (args[0].toLowerCase()) {
|
||||
case "kickcount":
|
||||
PlanPlayerListener.setCountKicks(false);
|
||||
sender.sendMessage("§aDisabled Kick Counting temporarily until next plugin reload.");
|
||||
break;
|
||||
default:
|
||||
sender.sendMessage("§eDefine a feature to disable! (currently supports only kickCount)");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
@ -26,6 +26,8 @@ import java.util.UUID;
|
||||
*/
|
||||
public class PlanPlayerListener implements Listener {
|
||||
|
||||
private static boolean countKicks = true;
|
||||
|
||||
private final Plan plugin;
|
||||
private final DataCache cache;
|
||||
|
||||
@ -61,7 +63,7 @@ public class PlanPlayerListener implements Listener {
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerKick(PlayerKickEvent event) {
|
||||
if (event.isCancelled()) {
|
||||
if (!countKicks || event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
UUID uuid = event.getPlayer().getUniqueId();
|
||||
@ -132,4 +134,8 @@ public class PlanPlayerListener implements Listener {
|
||||
plugin.addToProcessQueue(new FirstLeaveProcessor(uuid, time, messagesSent));
|
||||
}
|
||||
}
|
||||
|
||||
public static void setCountKicks(boolean value) {
|
||||
countKicks = value;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user