diff --git a/src/main/java/gent/zeus/mc13dtl/MC13DTL.java b/src/main/java/gent/zeus/mc13dtl/MC13DTL.java index 72660f0..f93cdcb 100644 --- a/src/main/java/gent/zeus/mc13dtl/MC13DTL.java +++ b/src/main/java/gent/zeus/mc13dtl/MC13DTL.java @@ -1,6 +1,7 @@ package gent.zeus.mc13dtl; import gent.zeus.mc13dtl.group.GroupAddCommand; +import gent.zeus.mc13dtl.group.GroupRemoveCommand; import org.bukkit.Bukkit; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.java.JavaPlugin; @@ -28,7 +29,8 @@ public class MC13DTL extends JavaPlugin { manager.registerEventHandler(LifecycleEvents.COMMANDS, event -> { Commands commands = event.registrar(); commands.register("start-game", "Start a game of 13 days to live", new GameStateCommand()); - commands.register("groupadd", "Add player to group", new GroupAddCommand()); + commands.register("groupadd", "Add player to team", new GroupAddCommand()); + commands.register("groupremove", "Remove player from team", new GroupRemoveCommand()); }); BukkitScheduler scheduler = this.getServer().getScheduler(); scheduler.runTaskTimer(this, new RandomEventRunner(), 0, 100); diff --git a/src/main/java/gent/zeus/mc13dtl/group/GroupAddCommand.java b/src/main/java/gent/zeus/mc13dtl/group/GroupAddCommand.java index 2867894..6371f4e 100644 --- a/src/main/java/gent/zeus/mc13dtl/group/GroupAddCommand.java +++ b/src/main/java/gent/zeus/mc13dtl/group/GroupAddCommand.java @@ -31,16 +31,18 @@ public class GroupAddCommand implements BasicCommand { if (team != null) { team.addPlayer(player); + team.addEntry(player.getUniqueId().toString()); player.sendRichMessage("You have been added to team " + index.toString()); + player.setGlowing(true); } } else { commandSourceStack.getSender().sendMessage("Player " + args[0] + " does not exist."); } } else { - commandSourceStack.getSender().sendMessage("groupAdd usage: /groupAdd "); + commandSourceStack.getSender().sendMessage("groupAdd usage: /groupadd "); } } catch (NumberFormatException ex) { - commandSourceStack.getSender().sendMessage("usage: /groupAdd "); + commandSourceStack.getSender().sendMessage("usage: /groupadd "); } } } diff --git a/src/main/java/gent/zeus/mc13dtl/group/GroupRemoveCommand.java b/src/main/java/gent/zeus/mc13dtl/group/GroupRemoveCommand.java index d74f7d4..cec06aa 100644 --- a/src/main/java/gent/zeus/mc13dtl/group/GroupRemoveCommand.java +++ b/src/main/java/gent/zeus/mc13dtl/group/GroupRemoveCommand.java @@ -1,4 +1,34 @@ package gent.zeus.mc13dtl.group; -public class GroupRemoveCommand { +import gent.zeus.mc13dtl.MC13DTL; +import io.papermc.paper.command.brigadier.BasicCommand; +import io.papermc.paper.command.brigadier.CommandSourceStack; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.entity.Player; +import org.bukkit.scoreboard.Team; +import org.jetbrains.annotations.NotNull; + +public class GroupRemoveCommand implements BasicCommand { + + @Override + public void execute(@NotNull CommandSourceStack commandSourceStack, @NotNull String[] args) { + if (args.length > 0) { + Player player = Bukkit.getPlayerExact(args[0]); + if (player != null) { + Team team = MC13DTL.scoreboard.getEntryTeam(player.getUniqueId().toString()); + if (team != null) { + team.removeEntry(player.getName()); + player.sendMessage("You have been removed from your team"); + } else { + commandSourceStack.getSender().sendMessage("Player not a team!"); + } + } else { + commandSourceStack.getSender().sendMessage("Player " + args[0] + " does not exist."); + } + } else { + commandSourceStack.getSender().sendMessage("group remove usage: /groupremove "); + } + } + }