mirror of
https://github.com/trainerlord/WorldSystem.git
synced 2025-01-20 20:51:27 +01:00
Merge pull request #36 from ToxiWoxi/master
Implement tab completion, fix a few unhandled errors, update some messages, adjust English translation
This commit is contained in:
commit
57744edccf
@ -13,7 +13,7 @@ ext {
|
||||
mcVersion = "1.20.2"
|
||||
}
|
||||
archivesBaseName = "WorldSystem"
|
||||
version = "2.4.36"
|
||||
version = "2.4.37"
|
||||
spigot {
|
||||
group "de.butzlabben"
|
||||
name = "WorldSystem"
|
||||
|
@ -3,7 +3,7 @@ pluginName = WorldSystem
|
||||
author = Trainerlord, Butzlabben & CrazyCloudCraft
|
||||
mcVersion = 1.20.2
|
||||
apiVersion = 1.20
|
||||
version = 2.4.35
|
||||
version = 2.4.37
|
||||
Vault = Vault
|
||||
WorldEdit = WorldEdit
|
||||
FAWE = FAWE
|
||||
|
@ -95,6 +95,7 @@ public class WorldSystem extends JavaPlugin {
|
||||
public void onEnable() {
|
||||
//////
|
||||
getCommand("ws").setExecutor(new CommandRegistry());
|
||||
getCommand("ws").setTabCompleter(new CommandRegistry());
|
||||
|
||||
// Set right version
|
||||
if (VersionUtil.getVersion() >= 13)
|
||||
|
@ -5,12 +5,19 @@ import de.butzlabben.world.command.commands.WorldAdministrateCommand;
|
||||
import de.butzlabben.world.command.commands.WorldSettingsCommands;
|
||||
import de.butzlabben.world.util.Worldutils;
|
||||
import de.butzlabben.world.wrapper.WorldTemplateProvider;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class CommandRegistry implements CommandExecutor {
|
||||
public class CommandRegistry implements TabExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
@ -101,4 +108,32 @@ public class CommandRegistry implements CommandExecutor {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
List<String> subCommands = new ArrayList<>(Arrays.asList("get", "home", "sethome", "gui", "tp", "addmember", "delmember", "leave", "tnt", "fire", "togglegm", "togglebuild", "toggletp", "togglewe", "info", "reset"));
|
||||
if (sender.hasPermission("ws.delete")) subCommands.add("delete");
|
||||
List<String> playerCompletions = Arrays.asList("addmember", "delmember", "tp","togglegm", "togglebuild", "toggletp", "togglewe", "delete");
|
||||
List<String> completions = new ArrayList<>();
|
||||
List<String> playerNames = new ArrayList<>();
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
playerNames.add(p.getName());
|
||||
}
|
||||
|
||||
if (args.length == 1) {
|
||||
for(String s : subCommands) {
|
||||
if (s.startsWith(args[0].toLowerCase())) completions.add(s);
|
||||
}
|
||||
}
|
||||
|
||||
if (args.length == 2 && playerCompletions.contains(args[0].toLowerCase())) {
|
||||
for(String s : playerNames) {
|
||||
if (s.toLowerCase().startsWith(args[1].toLowerCase())) completions.add(s);
|
||||
}
|
||||
}
|
||||
|
||||
Collections.sort(completions);
|
||||
|
||||
return completions;
|
||||
}
|
||||
}
|
||||
|
@ -31,10 +31,10 @@ public class WSCommands {
|
||||
prefix + "WorldSystem by CrazyCloudCraft v" + WorldSystem.getInstance().getDescription().getVersion());
|
||||
cs.sendMessage(prefix + "Contributors: Jubeki, montlikadani, jstoeckm2, Butzlabben");
|
||||
List<String> cmdHelp = MessageConfig.getCommandHelp();
|
||||
cmdHelp.forEach(s -> cs.sendMessage("\u00A76" + s)); //(prefix + s));
|
||||
cmdHelp.forEach(s -> cs.sendMessage("§6" + s)); //(prefix + s));
|
||||
// cs.sendMessage(prefix + "==============");
|
||||
if (cs.hasPermission("ws.delete")) {
|
||||
cs.sendMessage(MessageConfig.getDeleteCommandHelp());
|
||||
cs.sendMessage("§6" + MessageConfig.getDeleteCommandHelp());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -98,6 +98,11 @@ public class WorldAdministrateCommand {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (p.getName().toLowerCase().equals(args[1].toLowerCase())) {
|
||||
p.sendMessage(PluginConfig.getPrefix() + "§cYou cannot remove yourself!");
|
||||
return false;
|
||||
}
|
||||
|
||||
DependenceConfig dc = new DependenceConfig(p);
|
||||
if (!dc.hasWorld()) {
|
||||
p.sendMessage(MessageConfig.getNoWorldOwn());
|
||||
@ -215,6 +220,11 @@ public class WorldAdministrateCommand {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (p.getName().toLowerCase().equals(args[1].toLowerCase())) {
|
||||
p.sendMessage(PluginConfig.getPrefix() + "§cYou're already a member!");
|
||||
return false;
|
||||
}
|
||||
|
||||
DependenceConfig dc = new DependenceConfig(p);
|
||||
if (!dc.hasWorld()) {
|
||||
p.sendMessage(MessageConfig.getNoWorldOwn());
|
||||
@ -269,7 +279,7 @@ public class WorldAdministrateCommand {
|
||||
}
|
||||
WorldPlayer wp = new WorldPlayer(a, dc.getWorldname());
|
||||
if (wp.isOwnerofWorld()) {
|
||||
p.sendMessage(PluginConfig.getPrefix() + "§cYou are the owner");
|
||||
p.sendMessage(PluginConfig.getPrefix() + "§cYou cannot disable teleporting for yourself!");
|
||||
return false;
|
||||
}
|
||||
if (wp.toggleTeleport()) {
|
||||
@ -306,7 +316,7 @@ public class WorldAdministrateCommand {
|
||||
}
|
||||
WorldPlayer wp = new WorldPlayer(a, dc.getWorldname());
|
||||
if (wp.isOwnerofWorld()) {
|
||||
p.sendMessage(PluginConfig.getPrefix() + "§cYou are the owner");
|
||||
p.sendMessage(PluginConfig.getPrefix() + "§cYou cannot disable gamemode changing for yourself!");
|
||||
return false;
|
||||
}
|
||||
if (wp.toggleGamemode()) {
|
||||
@ -343,7 +353,7 @@ public class WorldAdministrateCommand {
|
||||
}
|
||||
WorldPlayer wp = new WorldPlayer(a, dc.getWorldname());
|
||||
if (wp.isOwnerofWorld()) {
|
||||
p.sendMessage(PluginConfig.getPrefix() + "§cYou are the owner");
|
||||
p.sendMessage(PluginConfig.getPrefix() + "§cYou cannot disable WorldEdit for yourself!");
|
||||
return false;
|
||||
}
|
||||
if (wp.toggleWorldEdit()) {
|
||||
@ -380,7 +390,7 @@ public class WorldAdministrateCommand {
|
||||
}
|
||||
WorldPlayer wp = new WorldPlayer(a, dc.getWorldname());
|
||||
if (wp.isOwnerofWorld()) {
|
||||
p.sendMessage(PluginConfig.getPrefix() + "§cYou are the owner");
|
||||
p.sendMessage(PluginConfig.getPrefix() + "§cYou cannot disable building for yourself!");
|
||||
return false;
|
||||
}
|
||||
if (wp.toggleBuild()) {
|
||||
|
@ -87,7 +87,7 @@ public class WorldSettingsCommands {
|
||||
}
|
||||
|
||||
} else {
|
||||
p.sendMessage(MessageConfig.getInvalidInput().replaceAll("input", args[1]));
|
||||
p.sendMessage(MessageConfig.getInvalidInput().replaceAll("%input", "\"reset " + args[1] + "\""));
|
||||
}
|
||||
} else {
|
||||
if (sw.isLoaded())
|
||||
@ -161,6 +161,11 @@ public class WorldSettingsCommands {
|
||||
if (sender instanceof Player) {
|
||||
Player p = (Player) sender;
|
||||
DependenceConfig dc = new DependenceConfig(p);
|
||||
if (!dc.hasWorld()) {
|
||||
p.sendMessage(MessageConfig.getNoWorldOwn());
|
||||
return false;
|
||||
}
|
||||
|
||||
WorldConfig wc = WorldConfig.getWorldConfig(dc.getWorldname());
|
||||
boolean tnt = wc.isTnt();
|
||||
WorldToggleTntEvent event = new WorldToggleTntEvent(p, SystemWorld.getSystemWorld(dc.getWorldname()), tnt);
|
||||
@ -192,6 +197,11 @@ public class WorldSettingsCommands {
|
||||
if (sender instanceof Player) {
|
||||
Player p = (Player) sender;
|
||||
DependenceConfig dc = new DependenceConfig(p);
|
||||
if (!dc.hasWorld()) {
|
||||
p.sendMessage(MessageConfig.getNoWorldOwn());
|
||||
return false;
|
||||
}
|
||||
|
||||
WorldConfig wc = WorldConfig.getWorldConfig(dc.getWorldname());
|
||||
boolean fire = wc.isFire();
|
||||
WorldToggleFireEvent event = new WorldToggleFireEvent(p, SystemWorld.getSystemWorld(dc.getWorldname()), fire);
|
||||
|
@ -264,7 +264,7 @@ public class MessageConfig {
|
||||
}
|
||||
|
||||
public static String getDeleteCommandHelp() {
|
||||
return getMessage("command_help.delete_command", "/ws delete §8- §7Will delete a World");
|
||||
return getRawMessage("command_help.delete_command", "/ws delete §8- §7Will delete a World");
|
||||
}
|
||||
|
||||
public static List<String> getCommandHelp() {
|
||||
|
@ -5,7 +5,7 @@ wrong_usage: "&c%usage"
|
||||
not_registered: "&cThis player hasn't joined yet!"
|
||||
|
||||
world:
|
||||
reseted: "You world was resetted sucsessfully!"
|
||||
reseted: "Your world was reset successfully!"
|
||||
still_loaded: "&cYour world is still loaded!"
|
||||
not_on: "&cYou are not in a world!"
|
||||
created: "Your world is now ready. Get there with &a/ws home"
|
||||
@ -70,20 +70,20 @@ info:
|
||||
|
||||
command_help:
|
||||
list:
|
||||
- "&6/ws get &8- &7Will give you a world"
|
||||
- "&6/ws home &8- &7Teleports you on your world"
|
||||
- "&6/ws sethome &8- &7Sets a specific home"
|
||||
- "&6/ws gui &8- &7Opens the GUI menu if you are the world owner"
|
||||
- "&6/ws tp &8- &7Teleports you on a specific world"
|
||||
- "&6/ws addmember &8- &7Adds a player to your world"
|
||||
- "&6/ws delmember &8- &7Removes a player from your world"
|
||||
- "&6/ws get &8- &7Create a world"
|
||||
- "&6/ws home &8- &7Teleport to your world's home"
|
||||
- "&6/ws sethome &8- &7Set a new home on your world"
|
||||
- "&6/ws gui &8- &7Open settings GUI (must be world owner)"
|
||||
- "&6/ws tp &8- &7Teleport to another player's world"
|
||||
- "&6/ws addmember &8- &7Add a player to your world"
|
||||
- "&6/ws delmember &8- &7Remove a player from your world"
|
||||
- "&6/ws leave &8- &7Leave a world"
|
||||
- "&6/ws tnt &8- &7Allows/Denies TNT on your world"
|
||||
- "&6/ws fire &8- &7Allows/Denies Fire on your world"
|
||||
- "&6/ws togglegm &8- &7Allows/Denies a player changing gamemode"
|
||||
- "&6/ws togglebuild &8- &7Allows/Denies a player building on your world"
|
||||
- "&6/ws toggletp &8- &7Allows/Denies a player teleporting on your world"
|
||||
- "&6/ws togglewe &8- &7Allows/Denys a player using WorldEdit"
|
||||
- "&6/ws info &8- &7Shows information about the world"
|
||||
- "&6/ws reset &8- &7Will reset your world"
|
||||
delete_command: "/ws delete &8- &7Will delete a world"
|
||||
- "&6/ws tnt &8- &7Enable or disable TNT on your world"
|
||||
- "&6/ws fire &8- &7Enable or disable fire on your world"
|
||||
- "&6/ws togglegm &8- &7Allow/deny a player to change gamemodes on your world"
|
||||
- "&6/ws togglebuild &8- &7Allow/deny a player to build on your world"
|
||||
- "&6/ws toggletp &8- &7Allow/deny a player to teleport on your world"
|
||||
- "&6/ws togglewe &8- &7Allow/deny a player using WorldEdit on your world"
|
||||
- "&6/ws info &8- &7Show information about the world you are in"
|
||||
- "&6/ws reset &8- &7Reset your world"
|
||||
delete_command: "/ws delete &8- &7Delete a world"
|
||||
|
Loading…
Reference in New Issue
Block a user