add more commands

This commit is contained in:
Telesphoreo 2022-01-29 19:08:07 -06:00
parent 8293b1a879
commit 0a1df0fddb
5 changed files with 30 additions and 29 deletions

View File

@ -16,7 +16,7 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@CommandPermissions(level = Rank.OP, source = RequiredCommandSource.ANY) @CommandPermissions(level = Rank.OP, permission = "plex.gamemode.adventure", source = RequiredCommandSource.ANY)
@CommandParameters(name = "adventure", aliases = "gma", description = "Set your own or another player's gamemode to adventure mode") @CommandParameters(name = "adventure", aliases = "gma", description = "Set your own or another player's gamemode to adventure mode")
public class AdventureCMD extends PlexCommand public class AdventureCMD extends PlexCommand
{ {
@ -24,18 +24,18 @@ public class AdventureCMD extends PlexCommand
@Override @Override
public Component execute(CommandSender sender, String[] args) public Component execute(CommandSender sender, String[] args)
{ {
Player player = (Player) sender;
if (args.length == 0) if (args.length == 0)
{ {
if (isConsole(sender)) if (isConsole(sender))
{ {
throw new CommandFailException("You must define a player when using the console!"); throw new CommandFailException("You must define a player when using the console!");
} }
Player player = (Player) sender;
player.setGameMode(GameMode.ADVENTURE); player.setGameMode(GameMode.ADVENTURE);
return tl("gameModeSetTo", "adventure"); return tl("gameModeSetTo", "adventure");
} }
if (isAdmin(sender)) if (checkRank(player, Rank.ADMIN, "plex.gamemode.adventure.others"))
{ {
if (args[0].equals("-a")) if (args[0].equals("-a"))
{ {
@ -46,11 +46,11 @@ public class AdventureCMD extends PlexCommand
return tl("gameModeSetTo", "adventure"); return tl("gameModeSetTo", "adventure");
} }
Player player = getNonNullPlayer(args[0]); Player nPlayer = getNonNullPlayer(args[0]);
// use send // use send
send(player, tl("playerSetOtherGameMode", sender.getName(), "adventure")); send(nPlayer, tl("playerSetOtherGameMode", sender.getName(), "adventure"));
player.setGameMode(GameMode.ADVENTURE); nPlayer.setGameMode(GameMode.ADVENTURE);
return tl("setOtherPlayerGameModeTo", player.getName(), "adventure"); return tl("setOtherPlayerGameModeTo", nPlayer.getName(), "adventure");
} }
return null; return null;
} }
@ -64,5 +64,4 @@ public class AdventureCMD extends PlexCommand
} }
return ImmutableList.of(); return ImmutableList.of();
} }
} }

View File

@ -16,25 +16,25 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@CommandPermissions(level = Rank.OP, source = RequiredCommandSource.ANY) @CommandPermissions(level = Rank.OP, permission = "plex.gamemode.creative", source = RequiredCommandSource.ANY)
@CommandParameters(name = "creative", aliases = "gmc", description = "Set your own or another player's gamemode to creative mode") @CommandParameters(name = "creative", aliases = "gmc", description = "Set your own or another player's gamemode to creative mode")
public class CreativeCMD extends PlexCommand public class CreativeCMD extends PlexCommand
{ {
@Override @Override
public Component execute(CommandSender sender, String[] args) public Component execute(CommandSender sender, String[] args)
{ {
Player player = (Player) sender;
if (args.length == 0) if (args.length == 0)
{ {
if (isConsole(sender)) if (isConsole(sender))
{ {
throw new CommandFailException("You must define a player when using the console!"); throw new CommandFailException("You must define a player when using the console!");
} }
Player player = (Player) sender;
player.setGameMode(GameMode.CREATIVE); player.setGameMode(GameMode.CREATIVE);
return tl("gameModeSetTo", "creative"); return tl("gameModeSetTo", "creative");
} }
if (isAdmin(sender)) if (checkRank(player, Rank.ADMIN, "plex.gamemode.creative.others"))
{ {
if (args[0].equals("-a")) if (args[0].equals("-a"))
{ {
@ -45,11 +45,11 @@ public class CreativeCMD extends PlexCommand
return tl("gameModeSetTo", "creative"); return tl("gameModeSetTo", "creative");
} }
Player player = getNonNullPlayer(args[0]); Player nPlayer = getNonNullPlayer(args[0]);
// use send // use send
send(player, tl("playerSetOtherGameMode", sender.getName(), "creative")); send(nPlayer, tl("playerSetOtherGameMode", sender.getName(), "creative"));
player.setGameMode(GameMode.CREATIVE); nPlayer.setGameMode(GameMode.CREATIVE);
return tl("setOtherPlayerGameModeTo", player.getName(), "creative"); return tl("setOtherPlayerGameModeTo", nPlayer.getName(), "creative");
} }
return null; return null;
} }

View File

@ -27,6 +27,8 @@ public class ListCMD extends PlexCommand
.append(Component.text(players.size() > 1 ? "players " : "player " + "online out of").color(NamedTextColor.GRAY)) .append(Component.text(players.size() > 1 ? "players " : "player " + "online out of").color(NamedTextColor.GRAY))
.append(Component.space()) .append(Component.space())
.append(Component.text(Bukkit.getMaxPlayers()).color(NamedTextColor.YELLOW)) .append(Component.text(Bukkit.getMaxPlayers()).color(NamedTextColor.YELLOW))
.append(Component.newline())
.append(Component.text("players").color(NamedTextColor.GRAY))
.append(Component.newline()); .append(Component.newline());
for (int i = 0; i < players.size(); i++) for (int i = 0; i < players.size(); i++)
{ {

View File

@ -16,25 +16,25 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@CommandPermissions(level = Rank.ADMIN, source = RequiredCommandSource.ANY) @CommandPermissions(level = Rank.ADMIN, permission = "plex.gamemode.spectator", source = RequiredCommandSource.ANY)
@CommandParameters(name = "spectator", aliases = "gmsp", description = "Set your own or another player's gamemode to spectator mode") @CommandParameters(name = "spectator", aliases = "gmsp", description = "Set your own or another player's gamemode to spectator mode")
public class SpectatorCMD extends PlexCommand public class SpectatorCMD extends PlexCommand
{ {
@Override @Override
public Component execute(CommandSender sender, String[] args) public Component execute(CommandSender sender, String[] args)
{ {
Player player = (Player) sender;
if (args.length == 0) if (args.length == 0)
{ {
if (isConsole(sender)) if (isConsole(sender))
{ {
throw new CommandFailException("You must define a player when using the console!"); throw new CommandFailException("You must define a player when using the console!");
} }
Player player = (Player) sender;
player.setGameMode(GameMode.SPECTATOR); player.setGameMode(GameMode.SPECTATOR);
return tl("gameModeSetTo", "spectator"); return tl("gameModeSetTo", "spectator");
} }
if (isAdmin(sender)) if (checkRank(player, Rank.ADMIN, "plex.gamemode.spectator.others"))
{ {
if (args[0].equals("-a")) if (args[0].equals("-a"))
{ {
@ -45,11 +45,11 @@ public class SpectatorCMD extends PlexCommand
return tl("gameModeSetTo", "spectator"); return tl("gameModeSetTo", "spectator");
} }
Player player = getNonNullPlayer(args[0]); Player nPlayer = getNonNullPlayer(args[0]);
// use send // use send
send(player, tl("playerSetOtherGameMode", sender.getName(), "spectator")); send(nPlayer, tl("playerSetOtherGameMode", sender.getName(), "spectator"));
player.setGameMode(GameMode.SPECTATOR); nPlayer.setGameMode(GameMode.SPECTATOR);
return tl("setOtherPlayerGameModeTo", player.getName(), "spectator"); return tl("setOtherPlayerGameModeTo", nPlayer.getName(), "spectator");
} }
return null; return null;
} }

View File

@ -16,25 +16,25 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@CommandPermissions(level = Rank.OP, source = RequiredCommandSource.ANY) @CommandPermissions(level = Rank.OP, permission = "plex.gamemode.survival", source = RequiredCommandSource.ANY)
@CommandParameters(name = "survival", aliases = "gms", description = "Set your own or another player's gamemode to survival mode") @CommandParameters(name = "survival", aliases = "gms", description = "Set your own or another player's gamemode to survival mode")
public class SurvivalCMD extends PlexCommand public class SurvivalCMD extends PlexCommand
{ {
@Override @Override
public Component execute(CommandSender sender, String[] args) public Component execute(CommandSender sender, String[] args)
{ {
Player player = (Player) sender;
if (args.length == 0) if (args.length == 0)
{ {
if (isConsole(sender)) if (isConsole(sender))
{ {
throw new CommandFailException("You must define a player when using the console!"); throw new CommandFailException("You must define a player when using the console!");
} }
Player player = (Player) sender;
player.setGameMode(GameMode.SURVIVAL); player.setGameMode(GameMode.SURVIVAL);
return tl("gameModeSetTo", "survival"); return tl("gameModeSetTo", "survival");
} }
if (isAdmin(sender)) if (checkRank(player, Rank.ADMIN, "plex.gamemode.survival.others"))
{ {
if (args[0].equals("-a")) if (args[0].equals("-a"))
{ {
@ -45,11 +45,11 @@ public class SurvivalCMD extends PlexCommand
return tl("gameModeSetTo", "survival"); return tl("gameModeSetTo", "survival");
} }
Player player = getNonNullPlayer(args[0]); Player nPlayer = getNonNullPlayer(args[0]);
// use send // use send
send(player, tl("playerSetOtherGameMode", sender.getName(), "survival")); send(nPlayer, tl("playerSetOtherGameMode", sender.getName(), "survival"));
player.setGameMode(GameMode.SURVIVAL); nPlayer.setGameMode(GameMode.SURVIVAL);
return tl("setOtherPlayerGameModeTo", player.getName(), "survival"); return tl("setOtherPlayerGameModeTo", nPlayer.getName(), "survival");
} }
return null; return null;
} }