mirror of
https://github.com/Maxlego08/zKoth.git
synced 2024-11-13 10:34:13 +01:00
🚧 Add stop command
This commit is contained in:
parent
b074d81b9d
commit
e576ef829d
@ -57,12 +57,15 @@ public class KothManager extends ZUtils implements Savable {
|
||||
|
||||
@Override
|
||||
public void save(Persist persist) {
|
||||
this.koths.forEach(Koth::stop);
|
||||
this.selections.values().forEach(Selection::clear);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(Persist persist) {
|
||||
|
||||
this.koths.forEach(Koth::stop);
|
||||
|
||||
File[] files = this.folder.listFiles((dir, name) -> name.endsWith(".yml"));
|
||||
if (files == null) return;
|
||||
|
||||
@ -173,4 +176,16 @@ public class KothManager extends ZUtils implements Savable {
|
||||
Koth koth = optional.get();
|
||||
koth.spawn(sender, now);
|
||||
}
|
||||
|
||||
public void stopKoth(CommandSender sender, String name) {
|
||||
|
||||
Optional<Koth> optional = getKoth(name);
|
||||
if (!optional.isPresent()) {
|
||||
message(sender, Message.DOESNT_EXIST, "%name%", name);
|
||||
return;
|
||||
}
|
||||
|
||||
Koth koth = optional.get();
|
||||
koth.stop(sender);
|
||||
}
|
||||
}
|
||||
|
@ -229,13 +229,7 @@ public class ZKoth extends ZUtils implements Koth {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop(CommandSender sender) {
|
||||
|
||||
if (this.kothStatus != KothStatus.START) {
|
||||
message(sender, Message.EVENT_DISABLE);
|
||||
return;
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
KothStopEvent event = new KothStopEvent(this);
|
||||
event.call();
|
||||
|
||||
@ -259,6 +253,17 @@ public class ZKoth extends ZUtils implements Koth {
|
||||
// this.plugin.getHologram().end(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop(CommandSender sender) {
|
||||
|
||||
if (this.kothStatus != KothStatus.START) {
|
||||
message(sender, Message.EVENT_DISABLE);
|
||||
return;
|
||||
}
|
||||
|
||||
this.stop();
|
||||
}
|
||||
|
||||
private void spawn() {
|
||||
this.resetData();
|
||||
|
||||
|
@ -50,6 +50,8 @@ public interface Koth {
|
||||
|
||||
void stop(CommandSender sender);
|
||||
|
||||
void stop();
|
||||
|
||||
void playerMove(Player player, KothTeam kothTeam);
|
||||
|
||||
int getCooldownStart();
|
||||
|
@ -15,6 +15,7 @@ public class CommandKoth extends VCommand {
|
||||
this.addSubCommand(new CommandKothCreate(plugin));
|
||||
this.addSubCommand(new CommandKothNow(plugin));
|
||||
this.addSubCommand(new CommandKothSpawn(plugin));
|
||||
this.addSubCommand(new CommandKothStop(plugin));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
28
src/fr/maxlego08/koth/command/commands/CommandKothStop.java
Normal file
28
src/fr/maxlego08/koth/command/commands/CommandKothStop.java
Normal file
@ -0,0 +1,28 @@
|
||||
package fr.maxlego08.koth.command.commands;
|
||||
|
||||
import fr.maxlego08.koth.KothPlugin;
|
||||
import fr.maxlego08.koth.command.VCommand;
|
||||
import fr.maxlego08.koth.zcore.enums.Message;
|
||||
import fr.maxlego08.koth.zcore.enums.Permission;
|
||||
import fr.maxlego08.koth.zcore.utils.commands.CommandType;
|
||||
|
||||
public class CommandKothStop extends VCommand {
|
||||
|
||||
public CommandKothStop(KothPlugin plugin) {
|
||||
super(plugin);
|
||||
this.setPermission(Permission.ZKOTH_STOP);
|
||||
this.addSubCommand("stop");
|
||||
this.setDescription(Message.DESCRIPTION_SPAWN);
|
||||
this.addRequireArg("name", (a,b) -> plugin.getKothManager().getNameKoths());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CommandType perform(KothPlugin plugin) {
|
||||
|
||||
String name = argAsString(0);
|
||||
this.manager.stopKoth(sender, name);
|
||||
|
||||
return CommandType.SUCCESS;
|
||||
}
|
||||
|
||||
}
|
@ -46,6 +46,7 @@ public enum Message {
|
||||
DESCRIPTION_RELOAD("Reload configuration files"),
|
||||
DESCRIPTION_NOW("Spawn a koth without cooldown"),
|
||||
DESCRIPTION_SPAWN("Spawn a koth with cooldown"),
|
||||
DESCRIPTION_STOP("Stop a koth"),
|
||||
DESCRIPTION_AXE("Getting the selection axe"),
|
||||
DESCRIPTION_CREATE("Create new koth"),
|
||||
|
||||
|
@ -6,7 +6,7 @@ public enum Permission {
|
||||
ZKOTH_RELOAD,
|
||||
ZKOTH_NOW,
|
||||
ZKOTH_AXE,
|
||||
ZKOTH_CREATE, ZKOTH_SPAWN;
|
||||
ZKOTH_CREATE, ZKOTH_SPAWN, ZKOTH_STOP;
|
||||
|
||||
private String permission;
|
||||
|
||||
|
@ -13,7 +13,8 @@
|
||||
# /zkoth axe - zkoth.axe - Getting the selection axe
|
||||
# /zkoth create <koth name> [<koth type>] [<capture/score] - zkoth.create - Create koth
|
||||
# /zkoth now <koth name> - zkoth.now - Spawn a koth without cooldown
|
||||
# /zkoth spawn <koth name> - zkoth.now - Spawn a koth
|
||||
# /zkoth spawn <koth name> - zkoth.spawn - Spawn a koth
|
||||
# /zkoth stop <koth name> - zkoth.stop - Stop a koth
|
||||
#
|
||||
# Placeholders:
|
||||
#
|
||||
|
Loading…
Reference in New Issue
Block a user