add groupremove command and use player uid for teams
This commit is contained in:
parent
9dc7eff01e
commit
21ab16c11e
3 changed files with 38 additions and 4 deletions
|
@ -1,6 +1,7 @@
|
||||||
package gent.zeus.mc13dtl;
|
package gent.zeus.mc13dtl;
|
||||||
|
|
||||||
import gent.zeus.mc13dtl.group.GroupAddCommand;
|
import gent.zeus.mc13dtl.group.GroupAddCommand;
|
||||||
|
import gent.zeus.mc13dtl.group.GroupRemoveCommand;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
@ -28,7 +29,8 @@ public class MC13DTL extends JavaPlugin {
|
||||||
manager.registerEventHandler(LifecycleEvents.COMMANDS, event -> {
|
manager.registerEventHandler(LifecycleEvents.COMMANDS, event -> {
|
||||||
Commands commands = event.registrar();
|
Commands commands = event.registrar();
|
||||||
commands.register("start-game", "Start a game of 13 days to live", new GameStateCommand());
|
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();
|
BukkitScheduler scheduler = this.getServer().getScheduler();
|
||||||
scheduler.runTaskTimer(this, new RandomEventRunner(), 0, 100);
|
scheduler.runTaskTimer(this, new RandomEventRunner(), 0, 100);
|
||||||
|
|
|
@ -31,16 +31,18 @@ public class GroupAddCommand implements BasicCommand {
|
||||||
|
|
||||||
if (team != null) {
|
if (team != null) {
|
||||||
team.addPlayer(player);
|
team.addPlayer(player);
|
||||||
|
team.addEntry(player.getUniqueId().toString());
|
||||||
player.sendRichMessage("<rainbow>You have been added to team " + index.toString());
|
player.sendRichMessage("<rainbow>You have been added to team " + index.toString());
|
||||||
|
player.setGlowing(true);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
commandSourceStack.getSender().sendMessage("Player " + args[0] + " does not exist.");
|
commandSourceStack.getSender().sendMessage("Player " + args[0] + " does not exist.");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
commandSourceStack.getSender().sendMessage("groupAdd usage: /groupAdd <player> <index>");
|
commandSourceStack.getSender().sendMessage("groupAdd usage: /groupadd <player> <index>");
|
||||||
}
|
}
|
||||||
} catch (NumberFormatException ex) {
|
} catch (NumberFormatException ex) {
|
||||||
commandSourceStack.getSender().sendMessage("usage: /groupAdd <player> <NUMBER>");
|
commandSourceStack.getSender().sendMessage("usage: /groupadd <player> <NUMBER>");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,34 @@
|
||||||
package gent.zeus.mc13dtl.group;
|
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 <player>");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue