From 57dbafb38503a53236830165bda7e6e554999435 Mon Sep 17 00:00:00 2001 From: Super_ Date: Mon, 2 Nov 2020 19:19:26 -0500 Subject: [PATCH] command stuff - exceptions used now - use CommandSource over CommandSender as it will generally be more versatile --- .../plex/command/IPlexCommand.java | 6 +- .../plex/command/PlexCommand.java | 124 +++++++++++++----- .../CommandParameters.java | 2 +- .../CommandPermissions.java | 2 +- .../exception/CommandArgumentException.java | 3 + .../exception/CommandFailException.java | 9 ++ .../exception/PlayerNotFoundException.java | 11 ++ .../plex/command/impl/FionnCMD.java | 24 ++-- .../plex/command/impl/OpAllCMD.java | 10 +- .../totalfreedom/plex/command/impl/OpCMD.java | 24 ++-- .../plex/command/impl/PlexCMD.java | 11 +- .../plex/command/impl/TestCMD.java | 12 +- .../plex/command/impl/WorldCMD.java | 23 ++-- .../plex/command/source/CommandSource.java | 12 +- .../me/totalfreedom/plex/util/PlexUtils.java | 14 +- src/main/resources/messages.yml | 8 +- 16 files changed, 195 insertions(+), 100 deletions(-) rename src/main/java/me/totalfreedom/plex/command/{annotations => annotation}/CommandParameters.java (84%) rename src/main/java/me/totalfreedom/plex/command/{annotations => annotation}/CommandPermissions.java (88%) create mode 100644 src/main/java/me/totalfreedom/plex/command/exception/CommandArgumentException.java create mode 100644 src/main/java/me/totalfreedom/plex/command/exception/CommandFailException.java create mode 100644 src/main/java/me/totalfreedom/plex/command/exception/PlayerNotFoundException.java diff --git a/src/main/java/me/totalfreedom/plex/command/IPlexCommand.java b/src/main/java/me/totalfreedom/plex/command/IPlexCommand.java index ef053ae..8f1395a 100644 --- a/src/main/java/me/totalfreedom/plex/command/IPlexCommand.java +++ b/src/main/java/me/totalfreedom/plex/command/IPlexCommand.java @@ -1,13 +1,13 @@ package me.totalfreedom.plex.command; -import org.bukkit.command.CommandSender; +import me.totalfreedom.plex.command.source.CommandSource; import java.util.List; public interface IPlexCommand { - void execute(CommandSender sender, String[] args); - List onTabComplete(CommandSender sender, String[] args); + void execute(CommandSource sender, String[] args); + List onTabComplete(CommandSource sender, String[] args); } diff --git a/src/main/java/me/totalfreedom/plex/command/PlexCommand.java b/src/main/java/me/totalfreedom/plex/command/PlexCommand.java index 04a2af0..473c9e0 100644 --- a/src/main/java/me/totalfreedom/plex/command/PlexCommand.java +++ b/src/main/java/me/totalfreedom/plex/command/PlexCommand.java @@ -3,16 +3,26 @@ package me.totalfreedom.plex.command; import com.google.common.collect.ImmutableList; import me.totalfreedom.plex.Plex; import me.totalfreedom.plex.cache.PlayerCache; -import me.totalfreedom.plex.command.annotations.CommandParameters; -import me.totalfreedom.plex.command.annotations.CommandPermissions; +import me.totalfreedom.plex.command.annotation.CommandParameters; +import me.totalfreedom.plex.command.annotation.CommandPermissions; +import me.totalfreedom.plex.command.exception.CommandArgumentException; +import me.totalfreedom.plex.command.exception.CommandFailException; +import me.totalfreedom.plex.command.exception.PlayerNotFoundException; +import me.totalfreedom.plex.command.source.CommandSource; import me.totalfreedom.plex.command.source.RequiredCommandSource; import me.totalfreedom.plex.player.PlexPlayer; import me.totalfreedom.plex.rank.enums.Rank; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.World; import org.bukkit.command.*; import org.bukkit.entity.Player; import java.util.Arrays; import java.util.List; +import java.util.UUID; + +import static me.totalfreedom.plex.util.PlexUtils.tl; public abstract class PlexCommand extends Command implements TabExecutor, IPlexCommand { @@ -22,6 +32,7 @@ public abstract class PlexCommand extends Command implements TabExecutor, IPlexC private final CommandPermissions perms; private final Rank level; + private CommandSource sender; private final RequiredCommandSource commandSource; public PlexCommand(String name) @@ -56,69 +67,61 @@ public abstract class PlexCommand extends Command implements TabExecutor, IPlexC public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { if (!matches(label)) return false; - if (commandSource == RequiredCommandSource.CONSOLE) + if (this.sender == null) + this.sender = new CommandSource(sender); + if (commandSource == RequiredCommandSource.CONSOLE && sender instanceof Player) { - if (sender instanceof Player) - { - //TODO: Enter console only msg - return true; - } - execute(sender, args); + send(tl("noPermissionInGame")); return true; - - } else if (commandSource == RequiredCommandSource.IN_GAME) + } + if (commandSource == RequiredCommandSource.IN_GAME) { - if (!(sender instanceof Player)) + if (sender instanceof ConsoleCommandSender) { - //TODO: Enter player only msg + send(tl("noPermissionConsole")); return true; } - Player player = (Player) sender; PlexPlayer plexPlayer = PlayerCache.getPlexPlayerMap().get(player.getUniqueId()); if (!plexPlayer.getRankFromString().isAtLeast(getLevel())) { - //TODO: Enter only and higher msg - return true; - } - execute(sender, args); - return true; - } else { - if (!(sender instanceof Player)) - { - execute(sender, args); - return true; - } else { - Player player = (Player) sender; - PlexPlayer plexPlayer = PlayerCache.getPlexPlayerMap().get(player.getUniqueId()); - if (!plexPlayer.getRankFromString().isAtLeast(getLevel())) - { - //TODO: Enter only and higher msg - return true; - } - execute(sender, args); + send(tl("noPermissionRank", ChatColor.stripColor(getLevel().getLoginMSG()))); return true; } } + try + { + execute(this.sender, args); + } + catch (CommandArgumentException ex) + { + send(getUsage().replace("", getLabel())); + } + catch (PlayerNotFoundException | CommandFailException ex) + { + send(ex.getMessage()); + } + return true; } - @Override public List tabComplete(CommandSender sender, String alias, String[] args) { if (!matches(alias)) return ImmutableList.of(); + if (this.sender == null) + this.sender = new CommandSource(sender); if (sender instanceof Player) { Player player = (Player) sender; PlexPlayer plexPlayer = PlayerCache.getPlexPlayerMap().get(player.getUniqueId()); if (plexPlayer.getRankFromString().isAtLeast(getLevel())) { - return onTabComplete(sender, args); + return onTabComplete(this.sender, args); } else { return ImmutableList.of(); } } else { - return onTabComplete(sender, args); + return onTabComplete(this.sender, args); } } @@ -146,6 +149,55 @@ public abstract class PlexCommand extends Command implements TabExecutor, IPlexC return false; } + protected void send(String s, CommandSource sender) + { + sender.send(s); + } + + protected void send(String s, Player player) + { + player.sendMessage(s); + } + + protected void send(String s) + { + if (sender == null) + return; + send(s, sender); + } + + protected Player getNonNullPlayer(String name) + { + Player player = Bukkit.getPlayer(name); + if (player == null) + throw new PlayerNotFoundException(); + return player; + } + + protected PlexPlayer getOnlinePlexPlayer(String name) + { + Player player = getNonNullPlayer(name); + PlexPlayer plexPlayer = PlayerCache.getPlexPlayer(player.getUniqueId()); + if (plexPlayer == null) + throw new PlayerNotFoundException(); + return plexPlayer; + } + + protected PlexPlayer getOfflinePlexPlayer(UUID uuid) + { + PlexPlayer plexPlayer = PlayerCache.getPlexPlayer(uuid); + if (plexPlayer == null) + throw new PlayerNotFoundException(); + return plexPlayer; + } + + protected World getNonNullWorld(String name) + { + World world = Bukkit.getWorld(name); + if (world == null) + throw new CommandFailException(tl("worldNotFound")); + return world; + } public Rank getLevel() { diff --git a/src/main/java/me/totalfreedom/plex/command/annotations/CommandParameters.java b/src/main/java/me/totalfreedom/plex/command/annotation/CommandParameters.java similarity index 84% rename from src/main/java/me/totalfreedom/plex/command/annotations/CommandParameters.java rename to src/main/java/me/totalfreedom/plex/command/annotation/CommandParameters.java index 7b9545f..f3c47d9 100644 --- a/src/main/java/me/totalfreedom/plex/command/annotations/CommandParameters.java +++ b/src/main/java/me/totalfreedom/plex/command/annotation/CommandParameters.java @@ -1,4 +1,4 @@ -package me.totalfreedom.plex.command.annotations; +package me.totalfreedom.plex.command.annotation; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; diff --git a/src/main/java/me/totalfreedom/plex/command/annotations/CommandPermissions.java b/src/main/java/me/totalfreedom/plex/command/annotation/CommandPermissions.java similarity index 88% rename from src/main/java/me/totalfreedom/plex/command/annotations/CommandPermissions.java rename to src/main/java/me/totalfreedom/plex/command/annotation/CommandPermissions.java index d212d2c..5ba2a5c 100644 --- a/src/main/java/me/totalfreedom/plex/command/annotations/CommandPermissions.java +++ b/src/main/java/me/totalfreedom/plex/command/annotation/CommandPermissions.java @@ -1,4 +1,4 @@ -package me.totalfreedom.plex.command.annotations; +package me.totalfreedom.plex.command.annotation; import me.totalfreedom.plex.command.source.RequiredCommandSource; import me.totalfreedom.plex.rank.enums.Rank; diff --git a/src/main/java/me/totalfreedom/plex/command/exception/CommandArgumentException.java b/src/main/java/me/totalfreedom/plex/command/exception/CommandArgumentException.java new file mode 100644 index 0000000..bb6c6e3 --- /dev/null +++ b/src/main/java/me/totalfreedom/plex/command/exception/CommandArgumentException.java @@ -0,0 +1,3 @@ +package me.totalfreedom.plex.command.exception; + +public class CommandArgumentException extends RuntimeException {} // lolololol \ No newline at end of file diff --git a/src/main/java/me/totalfreedom/plex/command/exception/CommandFailException.java b/src/main/java/me/totalfreedom/plex/command/exception/CommandFailException.java new file mode 100644 index 0000000..1c9c667 --- /dev/null +++ b/src/main/java/me/totalfreedom/plex/command/exception/CommandFailException.java @@ -0,0 +1,9 @@ +package me.totalfreedom.plex.command.exception; + +public class CommandFailException extends RuntimeException // this is literally just a runtime exception lol +{ + public CommandFailException(String s) + { + super(s); + } +} \ No newline at end of file diff --git a/src/main/java/me/totalfreedom/plex/command/exception/PlayerNotFoundException.java b/src/main/java/me/totalfreedom/plex/command/exception/PlayerNotFoundException.java new file mode 100644 index 0000000..04a2415 --- /dev/null +++ b/src/main/java/me/totalfreedom/plex/command/exception/PlayerNotFoundException.java @@ -0,0 +1,11 @@ +package me.totalfreedom.plex.command.exception; + +import static me.totalfreedom.plex.util.PlexUtils.tl; + +public class PlayerNotFoundException extends RuntimeException +{ + public PlayerNotFoundException() + { + super(tl("playerNotFound")); + } +} \ No newline at end of file diff --git a/src/main/java/me/totalfreedom/plex/command/impl/FionnCMD.java b/src/main/java/me/totalfreedom/plex/command/impl/FionnCMD.java index 4bf7a9d..9948442 100644 --- a/src/main/java/me/totalfreedom/plex/command/impl/FionnCMD.java +++ b/src/main/java/me/totalfreedom/plex/command/impl/FionnCMD.java @@ -2,19 +2,23 @@ package me.totalfreedom.plex.command.impl; import me.totalfreedom.plex.cache.PlayerCache; import me.totalfreedom.plex.command.PlexCommand; -import me.totalfreedom.plex.command.annotations.CommandParameters; -import me.totalfreedom.plex.command.annotations.CommandPermissions; +import me.totalfreedom.plex.command.annotation.CommandParameters; +import me.totalfreedom.plex.command.annotation.CommandPermissions; +import me.totalfreedom.plex.command.exception.CommandArgumentException; +import me.totalfreedom.plex.command.exception.CommandFailException; +import me.totalfreedom.plex.command.source.CommandSource; import me.totalfreedom.plex.command.source.RequiredCommandSource; import me.totalfreedom.plex.util.PlexUtils; import me.totalfreedom.plex.world.BlockMapChunkGenerator; import me.totalfreedom.plex.world.CustomWorld; import org.bukkit.*; -import org.bukkit.command.CommandSender; import org.bukkit.entity.*; import org.bukkit.scheduler.BukkitRunnable; import java.util.*; +import static me.totalfreedom.plex.util.PlexUtils.tl; + @CommandParameters(description = "Subliminal message.") @CommandPermissions(source = RequiredCommandSource.IN_GAME) public class FionnCMD extends PlexCommand @@ -28,14 +32,12 @@ public class FionnCMD extends PlexCommand } @Override - public void execute(CommandSender sender, String[] args) + public void execute(CommandSource sender, String[] args) { - Player player = (Player) sender; - if (!player.getUniqueId().equals(UUID.fromString("9aa3eda6-c271-440a-a578-a952ee9aee2f"))) - { - sender.sendMessage(ChatColor.RED + "You cannot run this command!"); - return; - } + if (!sender.getPlayer().getUniqueId().equals(UUID.fromString("9aa3eda6-c271-440a-a578-a952ee9aee2f"))) + throw new CommandFailException(tl("noPermission")); + if (args.length != 0) + throw new CommandArgumentException(); String name = "fionn"; LinkedHashMap map = new LinkedHashMap<>(); map.put(Material.CRIMSON_NYLIUM, 1); @@ -115,7 +117,7 @@ public class FionnCMD extends PlexCommand } @Override - public List onTabComplete(CommandSender sender, String[] args) + public List onTabComplete(CommandSource sender, String[] args) { return null; } diff --git a/src/main/java/me/totalfreedom/plex/command/impl/OpAllCMD.java b/src/main/java/me/totalfreedom/plex/command/impl/OpAllCMD.java index c82e2ca..7557150 100644 --- a/src/main/java/me/totalfreedom/plex/command/impl/OpAllCMD.java +++ b/src/main/java/me/totalfreedom/plex/command/impl/OpAllCMD.java @@ -1,12 +1,12 @@ package me.totalfreedom.plex.command.impl; import me.totalfreedom.plex.command.PlexCommand; -import me.totalfreedom.plex.command.annotations.CommandParameters; -import me.totalfreedom.plex.command.annotations.CommandPermissions; +import me.totalfreedom.plex.command.annotation.CommandParameters; +import me.totalfreedom.plex.command.annotation.CommandPermissions; +import me.totalfreedom.plex.command.source.CommandSource; import me.totalfreedom.plex.rank.enums.Rank; import me.totalfreedom.plex.util.PlexUtils; import org.bukkit.Bukkit; -import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import java.util.List; @@ -23,7 +23,7 @@ public class OpAllCMD extends PlexCommand } @Override - public void execute(CommandSender sender, String[] args) + public void execute(CommandSource sender, String[] args) { for (Player player : Bukkit.getOnlinePlayers()) player.setOp(true); @@ -31,7 +31,7 @@ public class OpAllCMD extends PlexCommand } @Override - public List onTabComplete(CommandSender sender, String[] args) { + public List onTabComplete(CommandSource sender, String[] args) { return null; } } \ No newline at end of file diff --git a/src/main/java/me/totalfreedom/plex/command/impl/OpCMD.java b/src/main/java/me/totalfreedom/plex/command/impl/OpCMD.java index 302fba5..fb6c751 100644 --- a/src/main/java/me/totalfreedom/plex/command/impl/OpCMD.java +++ b/src/main/java/me/totalfreedom/plex/command/impl/OpCMD.java @@ -1,12 +1,12 @@ package me.totalfreedom.plex.command.impl; import me.totalfreedom.plex.command.PlexCommand; -import me.totalfreedom.plex.command.annotations.CommandParameters; -import me.totalfreedom.plex.command.annotations.CommandPermissions; +import me.totalfreedom.plex.command.annotation.CommandParameters; +import me.totalfreedom.plex.command.annotation.CommandPermissions; +import me.totalfreedom.plex.command.exception.CommandArgumentException; +import me.totalfreedom.plex.command.source.CommandSource; import me.totalfreedom.plex.rank.enums.Rank; import me.totalfreedom.plex.util.PlexUtils; -import org.bukkit.Bukkit; -import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import java.util.List; @@ -23,19 +23,17 @@ public class OpCMD extends PlexCommand } @Override - public void execute(CommandSender sender, String[] args) + public void execute(CommandSource sender, String[] args) { - Player player = Bukkit.getPlayer(args[0]); - if (player == null) - { - sender.sendMessage(tl("playerNotFound")); - return; - } + if (args.length != 1) + throw new CommandArgumentException(); + Player player = getNonNullPlayer(args[0]); PlexUtils.broadcast(tl("oppedPlayer", sender.getName(), player.getName())); } @Override - public List onTabComplete(CommandSender sender, String[] args) { - return null; + public List onTabComplete(CommandSource sender, String[] args) + { + return args.length == 1 ? PlexUtils.getPlayerNameList() : null; } } \ No newline at end of file diff --git a/src/main/java/me/totalfreedom/plex/command/impl/PlexCMD.java b/src/main/java/me/totalfreedom/plex/command/impl/PlexCMD.java index 0a98ccb..ce47aee 100644 --- a/src/main/java/me/totalfreedom/plex/command/impl/PlexCMD.java +++ b/src/main/java/me/totalfreedom/plex/command/impl/PlexCMD.java @@ -1,8 +1,9 @@ package me.totalfreedom.plex.command.impl; -import me.totalfreedom.plex.command.annotations.CommandParameters; -import me.totalfreedom.plex.command.annotations.CommandPermissions; +import me.totalfreedom.plex.command.annotation.CommandParameters; +import me.totalfreedom.plex.command.annotation.CommandPermissions; import me.totalfreedom.plex.command.PlexCommand; +import me.totalfreedom.plex.command.source.CommandSource; import me.totalfreedom.plex.command.source.RequiredCommandSource; import me.totalfreedom.plex.rank.enums.Rank; import org.bukkit.command.CommandSender; @@ -19,13 +20,13 @@ public class PlexCMD extends PlexCommand } @Override - public void execute(CommandSender sender, String[] args) + public void execute(CommandSource sender, String[] args) { - sender.sendMessage("HI"); + send("HI"); } @Override - public List onTabComplete(CommandSender sender, String[] args) { + public List onTabComplete(CommandSource sender, String[] args) { return Arrays.asList("Telesphoreo", "super", "Taahh"); } } diff --git a/src/main/java/me/totalfreedom/plex/command/impl/TestCMD.java b/src/main/java/me/totalfreedom/plex/command/impl/TestCMD.java index e5b3ed9..d2d8c32 100644 --- a/src/main/java/me/totalfreedom/plex/command/impl/TestCMD.java +++ b/src/main/java/me/totalfreedom/plex/command/impl/TestCMD.java @@ -1,12 +1,12 @@ package me.totalfreedom.plex.command.impl; import com.google.common.collect.ImmutableList; -import me.totalfreedom.plex.command.annotations.CommandParameters; -import me.totalfreedom.plex.command.annotations.CommandPermissions; +import me.totalfreedom.plex.command.annotation.CommandParameters; +import me.totalfreedom.plex.command.annotation.CommandPermissions; import me.totalfreedom.plex.command.PlexCommand; +import me.totalfreedom.plex.command.source.CommandSource; import me.totalfreedom.plex.command.source.RequiredCommandSource; import me.totalfreedom.plex.rank.enums.Rank; -import org.bukkit.command.CommandSender; import java.util.Arrays; import java.util.List; @@ -22,13 +22,13 @@ public class TestCMD extends PlexCommand } @Override - public void execute(CommandSender sender, String[] args) + public void execute(CommandSource sender, String[] args) { - sender.sendMessage(tl("variableTest", sender.getName())); + send(tl("variableTest", sender.getName())); } @Override - public List onTabComplete(CommandSender sender, String[] args) { + public List onTabComplete(CommandSource sender, String[] args) { if (args.length == 1) { return Arrays.asList("WHATTHEFAWK", "LUL"); diff --git a/src/main/java/me/totalfreedom/plex/command/impl/WorldCMD.java b/src/main/java/me/totalfreedom/plex/command/impl/WorldCMD.java index e9eb256..2ae2782 100644 --- a/src/main/java/me/totalfreedom/plex/command/impl/WorldCMD.java +++ b/src/main/java/me/totalfreedom/plex/command/impl/WorldCMD.java @@ -1,20 +1,18 @@ package me.totalfreedom.plex.command.impl; import com.google.common.collect.ImmutableList; -import me.totalfreedom.plex.Plex; import me.totalfreedom.plex.command.PlexCommand; -import me.totalfreedom.plex.command.annotations.CommandParameters; -import me.totalfreedom.plex.command.annotations.CommandPermissions; +import me.totalfreedom.plex.command.annotation.CommandParameters; +import me.totalfreedom.plex.command.annotation.CommandPermissions; +import me.totalfreedom.plex.command.exception.CommandArgumentException; +import me.totalfreedom.plex.command.source.CommandSource; import me.totalfreedom.plex.command.source.RequiredCommandSource; import me.totalfreedom.plex.rank.enums.Rank; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.World; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; import static me.totalfreedom.plex.util.PlexUtils.tl; @@ -28,16 +26,17 @@ public class WorldCMD extends PlexCommand } @Override - public void execute(CommandSender sender, String[] args) + public void execute(CommandSource sender, String[] args) { - Player player = (Player) sender; - World world = Bukkit.getWorld(args[0]); - player.teleport(new Location(world, 0, world.getHighestBlockYAt(0, 0) + 1, 0, 0, 0)); - sender.sendMessage(tl("playerWorldTeleport", world.getName())); + if (args.length != 1) + throw new CommandArgumentException(); + World world = getNonNullWorld(args[0]); + sender.getPlayer().teleport(new Location(world, 0, world.getHighestBlockYAt(0, 0) + 1, 0, 0, 0)); + send(tl("playerWorldTeleport", world.getName())); } @Override - public List onTabComplete(CommandSender sender, String[] args) + public List onTabComplete(CommandSource sender, String[] args) { List worlds = new ArrayList<>(); for (World world : Bukkit.getWorlds()) diff --git a/src/main/java/me/totalfreedom/plex/command/source/CommandSource.java b/src/main/java/me/totalfreedom/plex/command/source/CommandSource.java index 17c7cde..f0f7bc6 100644 --- a/src/main/java/me/totalfreedom/plex/command/source/CommandSource.java +++ b/src/main/java/me/totalfreedom/plex/command/source/CommandSource.java @@ -18,6 +18,16 @@ public class CommandSource { this.sender = sender; this.player = sender instanceof Player ? Bukkit.getPlayer(sender.getName()) : null; - this.plexPlayer = sender instanceof Player ? PlayerCache.getPlexPlayerMap().get(((Player)sender).getUniqueId()) : null; + this.plexPlayer = sender instanceof Player ? PlayerCache.getPlexPlayerMap().get(((Player) sender).getUniqueId()) : null; + } + + public void send(String s) + { + sender.sendMessage(s); + } + + public String getName() + { + return sender.getName(); } } \ No newline at end of file diff --git a/src/main/java/me/totalfreedom/plex/util/PlexUtils.java b/src/main/java/me/totalfreedom/plex/util/PlexUtils.java index 64bd1fa..585b23e 100644 --- a/src/main/java/me/totalfreedom/plex/util/PlexUtils.java +++ b/src/main/java/me/totalfreedom/plex/util/PlexUtils.java @@ -1,6 +1,7 @@ package me.totalfreedom.plex.util; import java.sql.SQLException; +import java.util.ArrayList; import java.util.List; import java.util.Objects; import java.util.stream.Collectors; @@ -100,11 +101,6 @@ public class PlexUtils return color; } - public static void warpToWorld(Player player, World world) - { - player.teleport(new Location(world, 0, world.getHighestBlockYAt(0, 0), 0)); - } - public static void setBlocks(Location c1, Location c2, Material material) { if (!c1.getWorld().getName().equals(c1.getWorld().getName())) @@ -128,6 +124,14 @@ public class PlexUtils } } + public static List getPlayerNameList() + { + List names = new ArrayList<>(); + for (Player player : Bukkit.getOnlinePlayers()) + names.add(player.getName()); + return names; + } + public static void broadcast(String s) { Bukkit.broadcastMessage(s); diff --git a/src/main/resources/messages.yml b/src/main/resources/messages.yml index 4600e62..d4ff6bf 100644 --- a/src/main/resources/messages.yml +++ b/src/main/resources/messages.yml @@ -23,6 +23,7 @@ test: this is a test message! # 1: the command sender's username variableTest: variable test with ! playerNotFound: Player not found! +worldNotFound: World not found! noAdminWorldBlockPlace: You are not allowed to place blocks in the admin world! noAdminWorldBlockBreak: You are not allowed to break blocks in the admin world! # 1: the world you have been teleported to @@ -31,4 +32,9 @@ playerWorldTeleport: You have been teleported to . oppedAllPlayers: has opped all players on the server # 1: the person who is opping # 2: the person who has been opped -oppedPlayer: has opped \ No newline at end of file +oppedPlayer: has opped +noPermission: You cannot use this command! +# 1: the login message (uncolored) of the rank required to use the command +noPermissionRank: You must be at least rank to use this command! +noPermissionInGame: You must be in console to use this command! +noPermissionConsole: You must be in-game to use this command! \ No newline at end of file