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.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")
public class AdventureCMD extends PlexCommand
{
@ -24,18 +24,18 @@ public class AdventureCMD extends PlexCommand
@Override
public Component execute(CommandSender sender, String[] args)
{
Player player = (Player) sender;
if (args.length == 0)
{
if (isConsole(sender))
{
throw new CommandFailException("You must define a player when using the console!");
}
Player player = (Player) sender;
player.setGameMode(GameMode.ADVENTURE);
return tl("gameModeSetTo", "adventure");
}
if (isAdmin(sender))
if (checkRank(player, Rank.ADMIN, "plex.gamemode.adventure.others"))
{
if (args[0].equals("-a"))
{
@ -46,11 +46,11 @@ public class AdventureCMD extends PlexCommand
return tl("gameModeSetTo", "adventure");
}
Player player = getNonNullPlayer(args[0]);
Player nPlayer = getNonNullPlayer(args[0]);
// use send
send(player, tl("playerSetOtherGameMode", sender.getName(), "adventure"));
player.setGameMode(GameMode.ADVENTURE);
return tl("setOtherPlayerGameModeTo", player.getName(), "adventure");
send(nPlayer, tl("playerSetOtherGameMode", sender.getName(), "adventure"));
nPlayer.setGameMode(GameMode.ADVENTURE);
return tl("setOtherPlayerGameModeTo", nPlayer.getName(), "adventure");
}
return null;
}
@ -64,5 +64,4 @@ public class AdventureCMD extends PlexCommand
}
return ImmutableList.of();
}
}

View File

@ -16,25 +16,25 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
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")
public class CreativeCMD extends PlexCommand
{
@Override
public Component execute(CommandSender sender, String[] args)
{
Player player = (Player) sender;
if (args.length == 0)
{
if (isConsole(sender))
{
throw new CommandFailException("You must define a player when using the console!");
}
Player player = (Player) sender;
player.setGameMode(GameMode.CREATIVE);
return tl("gameModeSetTo", "creative");
}
if (isAdmin(sender))
if (checkRank(player, Rank.ADMIN, "plex.gamemode.creative.others"))
{
if (args[0].equals("-a"))
{
@ -45,11 +45,11 @@ public class CreativeCMD extends PlexCommand
return tl("gameModeSetTo", "creative");
}
Player player = getNonNullPlayer(args[0]);
Player nPlayer = getNonNullPlayer(args[0]);
// use send
send(player, tl("playerSetOtherGameMode", sender.getName(), "creative"));
player.setGameMode(GameMode.CREATIVE);
return tl("setOtherPlayerGameModeTo", player.getName(), "creative");
send(nPlayer, tl("playerSetOtherGameMode", sender.getName(), "creative"));
nPlayer.setGameMode(GameMode.CREATIVE);
return tl("setOtherPlayerGameModeTo", nPlayer.getName(), "creative");
}
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.space())
.append(Component.text(Bukkit.getMaxPlayers()).color(NamedTextColor.YELLOW))
.append(Component.newline())
.append(Component.text("players").color(NamedTextColor.GRAY))
.append(Component.newline());
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.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")
public class SpectatorCMD extends PlexCommand
{
@Override
public Component execute(CommandSender sender, String[] args)
{
Player player = (Player) sender;
if (args.length == 0)
{
if (isConsole(sender))
{
throw new CommandFailException("You must define a player when using the console!");
}
Player player = (Player) sender;
player.setGameMode(GameMode.SPECTATOR);
return tl("gameModeSetTo", "spectator");
}
if (isAdmin(sender))
if (checkRank(player, Rank.ADMIN, "plex.gamemode.spectator.others"))
{
if (args[0].equals("-a"))
{
@ -45,11 +45,11 @@ public class SpectatorCMD extends PlexCommand
return tl("gameModeSetTo", "spectator");
}
Player player = getNonNullPlayer(args[0]);
Player nPlayer = getNonNullPlayer(args[0]);
// use send
send(player, tl("playerSetOtherGameMode", sender.getName(), "spectator"));
player.setGameMode(GameMode.SPECTATOR);
return tl("setOtherPlayerGameModeTo", player.getName(), "spectator");
send(nPlayer, tl("playerSetOtherGameMode", sender.getName(), "spectator"));
nPlayer.setGameMode(GameMode.SPECTATOR);
return tl("setOtherPlayerGameModeTo", nPlayer.getName(), "spectator");
}
return null;
}

View File

@ -16,25 +16,25 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
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")
public class SurvivalCMD extends PlexCommand
{
@Override
public Component execute(CommandSender sender, String[] args)
{
Player player = (Player) sender;
if (args.length == 0)
{
if (isConsole(sender))
{
throw new CommandFailException("You must define a player when using the console!");
}
Player player = (Player) sender;
player.setGameMode(GameMode.SURVIVAL);
return tl("gameModeSetTo", "survival");
}
if (isAdmin(sender))
if (checkRank(player, Rank.ADMIN, "plex.gamemode.survival.others"))
{
if (args[0].equals("-a"))
{
@ -45,11 +45,11 @@ public class SurvivalCMD extends PlexCommand
return tl("gameModeSetTo", "survival");
}
Player player = getNonNullPlayer(args[0]);
Player nPlayer = getNonNullPlayer(args[0]);
// use send
send(player, tl("playerSetOtherGameMode", sender.getName(), "survival"));
player.setGameMode(GameMode.SURVIVAL);
return tl("setOtherPlayerGameModeTo", player.getName(), "survival");
send(nPlayer, tl("playerSetOtherGameMode", sender.getName(), "survival"));
nPlayer.setGameMode(GameMode.SURVIVAL);
return tl("setOtherPlayerGameModeTo", nPlayer.getName(), "survival");
}
return null;
}