mirror of
https://github.com/Maxlego08/zKoth.git
synced 2025-02-21 02:33:13 +01:00
Ajouts des commandes
This commit is contained in:
parent
15ccd51498
commit
2376da6259
@ -137,12 +137,12 @@ public class Koth extends ZUtils {
|
||||
public void spawn(CommandSender sender, boolean now) {
|
||||
|
||||
if (pos1 == null) {
|
||||
message(sender, Message.KOTH_SET_FIRST_POSITION_NULL);
|
||||
message(sender, Message.KOTH_SET_FIRST_POSITION_NULL, name);
|
||||
return;
|
||||
}
|
||||
|
||||
if (pos2 == null) {
|
||||
message(sender, Message.KOTH_SET_SECOND_POSITION_NULL);
|
||||
message(sender, Message.KOTH_SET_SECOND_POSITION_NULL, name);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -198,7 +198,7 @@ public class Koth extends ZUtils {
|
||||
|
||||
// Si on doit avetir
|
||||
if (Config.displayMessageCooldown.contains(cooldown))
|
||||
broadcast(Message.KOTH_SPAWN_MESSAGE_COOLDOWN, null, null);
|
||||
broadcast(Message.KOTH_SPAWN_MESSAGE_COOLDOWN, null, null, 0);
|
||||
|
||||
// On fait spawn le totem
|
||||
if (cooldown <= 0) {
|
||||
@ -227,7 +227,8 @@ public class Koth extends ZUtils {
|
||||
|
||||
isEnable = true;
|
||||
currentPlayer = null;
|
||||
broadcast(Message.KOTH_SPAWN_MESSAGE, null, null);
|
||||
buildCuboid();
|
||||
broadcast(Message.KOTH_SPAWN_MESSAGE, null, null, 0);
|
||||
|
||||
}
|
||||
|
||||
@ -239,7 +240,7 @@ public class Koth extends ZUtils {
|
||||
if (event.isCancelled())
|
||||
return;
|
||||
|
||||
broadcast(Message.KOHT_CATCH, player, listener.getFactionTag(player));
|
||||
broadcast(Message.KOHT_CATCH, player, listener.getFactionTag(player), 0);
|
||||
|
||||
if (capSec <= 0)
|
||||
capSec = Config.defaultCap;
|
||||
@ -257,17 +258,17 @@ public class Koth extends ZUtils {
|
||||
|
||||
if (currentPlayer == null) {
|
||||
task.cancel();
|
||||
broadcast(Message.KOHT_LOOSE, player, listener.getFactionTag(player));
|
||||
broadcast(Message.KOHT_LOOSE, player, listener.getFactionTag(player), tmpTimer);
|
||||
return;
|
||||
}
|
||||
|
||||
if (Config.displayMessageKothCap.contains(tmpTimer))
|
||||
broadcast(Message.KOHT_TIMER, player, listener.getFactionTag(player));
|
||||
broadcast(Message.KOHT_TIMER, player, listener.getFactionTag(player), tmpTimer);
|
||||
|
||||
if (tmpTimer == 0) {
|
||||
|
||||
task.cancel();
|
||||
broadcast(Message.KOHT_END, player, listener.getFactionTag(player));
|
||||
broadcast(Message.KOHT_END, player, listener.getFactionTag(player), 0);
|
||||
// Méthode pour win
|
||||
|
||||
}
|
||||
@ -282,7 +283,7 @@ public class Koth extends ZUtils {
|
||||
* @param currentFaction
|
||||
* @param cooldown
|
||||
*/
|
||||
private void broadcast(Message message, Player player, String currentFaction) {
|
||||
private void broadcast(Message message, Player player, String currentFaction, int cooldown) {
|
||||
String msg = message.getMessage();
|
||||
|
||||
Location location = cuboid.getCenter();
|
||||
|
@ -16,6 +16,7 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import fr.maxlego08.koth.ZKoth;
|
||||
import fr.maxlego08.koth.command.commands.CommandKoth;
|
||||
import fr.maxlego08.koth.zcore.ZPlugin;
|
||||
import fr.maxlego08.koth.zcore.enums.Message;
|
||||
import fr.maxlego08.koth.zcore.logger.Logger;
|
||||
@ -34,6 +35,8 @@ public class CommandManager extends ZUtils implements CommandExecutor {
|
||||
|
||||
public void registerCommands() {
|
||||
|
||||
registerCommand("zkoth", new CommandKoth(), "koth");
|
||||
|
||||
main.getLog().log("Loading " + getUniqueCommand() + " commands", LogType.SUCCESS);
|
||||
this.commandChecking();
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import fr.maxlego08.koth.ZKoth;
|
||||
import fr.maxlego08.koth.zcore.enums.Message;
|
||||
import fr.maxlego08.koth.zcore.enums.Permission;
|
||||
import fr.maxlego08.koth.zcore.utils.Arguments;
|
||||
import fr.maxlego08.koth.zcore.utils.inventory.IIventory;
|
||||
@ -46,7 +47,7 @@ public abstract class VCommand extends Arguments {
|
||||
*/
|
||||
private boolean ignoreParent = false;
|
||||
private boolean ignoreArgs = false;
|
||||
protected boolean DEBUG = false;
|
||||
protected boolean DEBUG = true;
|
||||
|
||||
/**
|
||||
* This is the person who executes the command
|
||||
@ -225,6 +226,17 @@ public abstract class VCommand extends Arguments {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param description
|
||||
* @return
|
||||
*/
|
||||
protected VCommand setDescription(Message description) {
|
||||
this.description = description.getMessage();
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Ajouter un argument obligatoire
|
||||
*/
|
||||
|
29
src/fr/maxlego08/koth/command/commands/CommandKoth.java
Normal file
29
src/fr/maxlego08/koth/command/commands/CommandKoth.java
Normal file
@ -0,0 +1,29 @@
|
||||
package fr.maxlego08.koth.command.commands;
|
||||
|
||||
import fr.maxlego08.koth.ZKoth;
|
||||
import fr.maxlego08.koth.command.CommandType;
|
||||
import fr.maxlego08.koth.command.VCommand;
|
||||
import fr.maxlego08.koth.zcore.enums.Permission;
|
||||
|
||||
public class CommandKoth extends VCommand {
|
||||
|
||||
private final CommandKothHelp help;
|
||||
|
||||
public CommandKoth() {
|
||||
this.setPermission(Permission.ZKOTH_HELP);
|
||||
this.addSubCommand(help = new CommandKothHelp());
|
||||
this.addSubCommand(new CommandKothCreate());
|
||||
this.addSubCommand(new CommandKothNow());
|
||||
this.addSubCommand(new CommandKothSpawn());
|
||||
this.addSubCommand(new CommandKothVersion());
|
||||
this.addSubCommand(new CommandKothSet());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CommandType perform(ZKoth main) {
|
||||
help.sender = sender;
|
||||
help.perform(main);
|
||||
return CommandType.SUCCESS;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package fr.maxlego08.koth.command.commands;
|
||||
|
||||
import fr.maxlego08.koth.ZKoth;
|
||||
import fr.maxlego08.koth.command.CommandType;
|
||||
import fr.maxlego08.koth.command.VCommand;
|
||||
import fr.maxlego08.koth.save.Config;
|
||||
import fr.maxlego08.koth.zcore.enums.Message;
|
||||
import fr.maxlego08.koth.zcore.enums.Permission;
|
||||
|
||||
public class CommandKothCreate extends VCommand {
|
||||
|
||||
public CommandKothCreate() {
|
||||
this.setPermission(Permission.ZKOTH_CREATE);
|
||||
this.addSubCommand("create");
|
||||
this.addRequireArg("koth name");
|
||||
this.addOptionalArg("time cap");
|
||||
this.setConsoleCanUse(false);
|
||||
this.setDescription(Message.DESCRIPTION_CREATE);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CommandType perform(ZKoth main) {
|
||||
|
||||
String name = argAsString(0);
|
||||
int cap = argAsInteger(1, Config.defaultCap);
|
||||
main.getManager().create(sender, name, cap);
|
||||
|
||||
return CommandType.SUCCESS;
|
||||
}
|
||||
|
||||
}
|
23
src/fr/maxlego08/koth/command/commands/CommandKothHelp.java
Normal file
23
src/fr/maxlego08/koth/command/commands/CommandKothHelp.java
Normal file
@ -0,0 +1,23 @@
|
||||
package fr.maxlego08.koth.command.commands;
|
||||
|
||||
import fr.maxlego08.koth.ZKoth;
|
||||
import fr.maxlego08.koth.command.CommandType;
|
||||
import fr.maxlego08.koth.command.VCommand;
|
||||
import fr.maxlego08.koth.zcore.enums.Message;
|
||||
import fr.maxlego08.koth.zcore.enums.Permission;
|
||||
|
||||
public class CommandKothHelp extends VCommand {
|
||||
|
||||
public CommandKothHelp() {
|
||||
this.setPermission(Permission.ZKOTH_HELP);
|
||||
this.addSubCommand("help");
|
||||
this.setDescription(Message.DESCRIPTION_HELP);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CommandType perform(ZKoth main) {
|
||||
main.getCommandManager().sendHelp("zkoth", sender);
|
||||
return CommandType.SUCCESS;
|
||||
}
|
||||
|
||||
}
|
27
src/fr/maxlego08/koth/command/commands/CommandKothNow.java
Normal file
27
src/fr/maxlego08/koth/command/commands/CommandKothNow.java
Normal file
@ -0,0 +1,27 @@
|
||||
package fr.maxlego08.koth.command.commands;
|
||||
|
||||
import fr.maxlego08.koth.ZKoth;
|
||||
import fr.maxlego08.koth.command.CommandType;
|
||||
import fr.maxlego08.koth.command.VCommand;
|
||||
import fr.maxlego08.koth.zcore.enums.Message;
|
||||
import fr.maxlego08.koth.zcore.enums.Permission;
|
||||
|
||||
public class CommandKothNow extends VCommand {
|
||||
|
||||
public CommandKothNow() {
|
||||
this.setPermission(Permission.ZKOTH_NOW);
|
||||
this.addSubCommand("now");
|
||||
this.addRequireArg("koth name");
|
||||
this.setDescription(Message.DESCRIPTION_NOW);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CommandType perform(ZKoth main) {
|
||||
|
||||
String name = argAsString(0);
|
||||
main.getManager().spawn(sender, name, true);
|
||||
|
||||
return CommandType.SUCCESS;
|
||||
}
|
||||
|
||||
}
|
33
src/fr/maxlego08/koth/command/commands/CommandKothSet.java
Normal file
33
src/fr/maxlego08/koth/command/commands/CommandKothSet.java
Normal file
@ -0,0 +1,33 @@
|
||||
package fr.maxlego08.koth.command.commands;
|
||||
|
||||
import fr.maxlego08.koth.ZKoth;
|
||||
import fr.maxlego08.koth.command.CommandType;
|
||||
import fr.maxlego08.koth.command.VCommand;
|
||||
import fr.maxlego08.koth.zcore.enums.Message;
|
||||
import fr.maxlego08.koth.zcore.enums.Permission;
|
||||
|
||||
public class CommandKothSet extends VCommand {
|
||||
|
||||
public CommandKothSet() {
|
||||
this.addSubCommand("set");
|
||||
this.setPermission(Permission.ZKOTH_SET);
|
||||
this.setDescription(Message.DESCRIPTION_SET);
|
||||
this.addRequireArg("pos1/pos2");
|
||||
this.addRequireArg("koth name");
|
||||
this.setConsoleCanUse(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CommandType perform(ZKoth main) {
|
||||
|
||||
String type = argAsString(0);
|
||||
String name = argAsString(1);
|
||||
|
||||
if (!type.equalsIgnoreCase("pos1") && !type.equalsIgnoreCase("pos2"))
|
||||
return CommandType.SYNTAX_ERROR;
|
||||
main.getManager().setPosition(sender, name, player.getLocation(), type.equalsIgnoreCase("pos1"));
|
||||
|
||||
return CommandType.SUCCESS;
|
||||
}
|
||||
|
||||
}
|
27
src/fr/maxlego08/koth/command/commands/CommandKothSpawn.java
Normal file
27
src/fr/maxlego08/koth/command/commands/CommandKothSpawn.java
Normal file
@ -0,0 +1,27 @@
|
||||
package fr.maxlego08.koth.command.commands;
|
||||
|
||||
import fr.maxlego08.koth.ZKoth;
|
||||
import fr.maxlego08.koth.command.CommandType;
|
||||
import fr.maxlego08.koth.command.VCommand;
|
||||
import fr.maxlego08.koth.zcore.enums.Message;
|
||||
import fr.maxlego08.koth.zcore.enums.Permission;
|
||||
|
||||
public class CommandKothSpawn extends VCommand {
|
||||
|
||||
public CommandKothSpawn() {
|
||||
this.setPermission(Permission.ZKOTH_SPAWN);
|
||||
this.addSubCommand("spawn");
|
||||
this.addRequireArg("koth name");
|
||||
this.setDescription(Message.DESCRIPTION_SPAWN);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CommandType perform(ZKoth main) {
|
||||
|
||||
String name = argAsString(0);
|
||||
main.getManager().spawn(sender, name, false);
|
||||
|
||||
return CommandType.SUCCESS;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package fr.maxlego08.koth.command.commands;
|
||||
|
||||
import fr.maxlego08.koth.ZKoth;
|
||||
import fr.maxlego08.koth.command.CommandType;
|
||||
import fr.maxlego08.koth.command.VCommand;
|
||||
|
||||
public class CommandKothVersion extends VCommand {
|
||||
|
||||
public CommandKothVersion() {
|
||||
this.addSubCommand("version");
|
||||
this.addSubCommand("v");
|
||||
this.addSubCommand("ver");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CommandType perform(ZKoth main) {
|
||||
|
||||
message(sender, "§eVersion du plugin§7: §a" + main.getDescription().getVersion());
|
||||
message(sender, "§eAuteur§7: §aMaxlego08");
|
||||
message(sender, "§eDiscord§7: §ahttps://discord.gg/p9Mdste");
|
||||
String user = "%%__USER__%%";
|
||||
message(sender, "§eUser account§7: §ahttps://www.spigotmc.org/members/" + user);
|
||||
|
||||
return CommandType.SUCCESS;
|
||||
}
|
||||
|
||||
}
|
@ -2,7 +2,20 @@ package fr.maxlego08.koth.zcore.enums;
|
||||
|
||||
public enum Permission {
|
||||
|
||||
ZKOTH_USE, ZKOTH_HELP,
|
||||
|
||||
ZKOTH_CREATE, ZKOTH_DELETE,
|
||||
|
||||
ZKOTH_SHOW, ZKOTH_MOVE,
|
||||
|
||||
ZKOTH_RELOAD, ZKOTH_NOW,
|
||||
|
||||
ZKOTH_SPAWN, ZKOTH_STOP,
|
||||
|
||||
ZKOTH_SET,
|
||||
|
||||
ZKOTH_SCHEDULER,
|
||||
|
||||
;
|
||||
|
||||
private final String permission;
|
||||
@ -10,9 +23,13 @@ public enum Permission {
|
||||
private Permission(String permission) {
|
||||
this.permission = permission;
|
||||
}
|
||||
|
||||
|
||||
private Permission() {
|
||||
this.permission = this.name().toLowerCase().replace("_", ".");
|
||||
}
|
||||
|
||||
public String getPermission() {
|
||||
return permission;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user