From 67aba9081bb73aeaa822b059e8ca6defc8352a2f Mon Sep 17 00:00:00 2001 From: Freya Murphy Date: Sat, 6 Sep 2025 23:11:25 -0400 Subject: rename pacakges dev.tylerm -> cat.freya --- src/main/java/cat/freya/khs/command/map/Add.java | 53 ++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 src/main/java/cat/freya/khs/command/map/Add.java (limited to 'src/main/java/cat/freya/khs/command/map/Add.java') diff --git a/src/main/java/cat/freya/khs/command/map/Add.java b/src/main/java/cat/freya/khs/command/map/Add.java new file mode 100644 index 0000000..ddbc384 --- /dev/null +++ b/src/main/java/cat/freya/khs/command/map/Add.java @@ -0,0 +1,53 @@ +package cat.freya.khs.command.map; + +import cat.freya.khs.Main; +import cat.freya.khs.command.util.ICommand; +import cat.freya.khs.configuration.Config; +import cat.freya.khs.configuration.Localization; +import cat.freya.khs.configuration.Map; +import cat.freya.khs.configuration.Maps; +import cat.freya.khs.game.util.Status; +import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; + +import java.util.Collections; +import java.util.List; + +public class Add implements ICommand { + + public void execute(Player sender, String[] args) { + if (Main.getInstance().getGame().getStatus() != Status.STANDBY) { + sender.sendMessage(Config.errorPrefix + Localization.message("GAME_INPROGRESS")); + return; + } + Map map = Maps.getMap(args[0]); + if(map != null) { + sender.sendMessage(Config.errorPrefix + Localization.message("MAP_ALREADY_EXISTS")); + } else if(!args[0].matches("[a-zA-Z0-9]*") || args[0].length() < 1) { + sender.sendMessage(Config.errorPrefix + Localization.message("INVALID_MAP_NAME")); + } else { + Maps.setMap(args[0], new Map(args[0])); + sender.sendMessage(Config.messagePrefix + Localization.message("MAP_CREATED").addAmount(args[0])); + } + } + + public String getLabel() { + return "add"; + } + + public String getUsage() { + return ""; + } + + public String getDescription() { + return "Add a map to the plugin!"; + } + + public List autoComplete(@NotNull String parameter, @NotNull String typed) { + if(parameter.equals("name")) { + return Collections.singletonList("name"); + } + return null; + } + +} -- cgit v1.2.3-freya