diff --git a/pom.xml b/pom.xml index 0c74cbd..b8c1a9a 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ net.t2code T2CodeLib - 15.7 + 15.8_dev diff --git a/src/main/java/net/t2code/t2codelib/SPIGOT/api/minecraftVersion/T2CmcVersion.java b/src/main/java/net/t2code/t2codelib/SPIGOT/api/minecraftVersion/T2CmcVersion.java index 1d3ce59..73f98ff 100644 --- a/src/main/java/net/t2code/t2codelib/SPIGOT/api/minecraftVersion/T2CmcVersion.java +++ b/src/main/java/net/t2code/t2codelib/SPIGOT/api/minecraftVersion/T2CmcVersion.java @@ -21,6 +21,7 @@ public class T2CmcVersion { mc1_18 = nms.contains("1_18"); mc1_19 = nms.contains("1_19"); mc1_20 = nms.contains("1_20"); + mc1_21 = nms.contains("1_21"); nms1_8_R1 = nms.contains("1_8_R1"); nms1_8_R2 = nms.contains("1_8_R2"); @@ -44,6 +45,7 @@ public class T2CmcVersion { nms1_19_R2 = nms.contains("1_19_R2"); nms1_20_R1 = nms.contains("1_20_R1"); nms1_20_R2 = nms.contains("1_20_R2"); + nms1_21_R1 = nms.contains("1_21_R1"); } private static String mcVersion; @@ -61,6 +63,7 @@ public class T2CmcVersion { private static boolean mc1_18; private static boolean mc1_19; private static boolean mc1_20; + private static boolean mc1_21; private static String nms; private static boolean nms1_8_R1; @@ -85,6 +88,7 @@ public class T2CmcVersion { private static boolean nms1_19_R2; private static boolean nms1_20_R1; private static boolean nms1_20_R2; + private static boolean nms1_21_R1; public static String getMcVersion() { return mcVersion; @@ -145,6 +149,9 @@ public class T2CmcVersion { public static boolean isMc1_20() { return mc1_20; } + public static boolean isMc1_21() { + return mc1_21; + } public static String getNms() { return nms; @@ -237,6 +244,9 @@ public class T2CmcVersion { public static boolean isNms1_20_R2() { return nms1_20_R2; } + public static boolean isNms1_21_R1() { + return nms1_21_R1; + } public static boolean minMc1_8() { diff --git a/src/main/java/net/t2code/t2codelib/SPIGOT/system/T2CodeLibMain.java b/src/main/java/net/t2code/t2codelib/SPIGOT/system/T2CodeLibMain.java index 6937306..1be92ed 100644 --- a/src/main/java/net/t2code/t2codelib/SPIGOT/system/T2CodeLibMain.java +++ b/src/main/java/net/t2code/t2codelib/SPIGOT/system/T2CodeLibMain.java @@ -65,7 +65,20 @@ public final class T2CodeLibMain extends JavaPlugin { if (T2CmcVersion.isNms1_20_R2()) { T2Csend.console(prefix + " §4!!!!!!!!!!!!!!!!!!!!"); T2Csend.console(prefix); - T2Csend.warning(plugin, "The 1.20.* (R2) is a very fresh / new version. If there are any bugs in our plugins, please report them to us via our Discord: http://dc.t2code.net"); + T2Csend.warning(plugin, "The 1.20.* (NMS R2) is a very fresh / new version. If there are any bugs in our plugins, please report them to us via our Discord: http://dc.t2code.net"); + T2Csend.console(prefix); + T2Csend.console(prefix + " §4!!!!!!!!!!!!!!!!!!!!"); + if (!SelectLibConfig.getT2cTestDevelopment()) { + try { + Thread.sleep(5000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + }if (T2CmcVersion.isMc1_21()) { + T2Csend.console(prefix + " §4!!!!!!!!!!!!!!!!!!!!"); + T2Csend.console(prefix); + T2Csend.warning(plugin, "The 1.21 is a very fresh / new version. If there are any bugs in our plugins, please report them to us via our Discord: http://dc.t2code.net"); T2Csend.console(prefix); T2Csend.console(prefix + " §4!!!!!!!!!!!!!!!!!!!!"); if (!SelectLibConfig.getT2cTestDevelopment()) { diff --git a/src/main/java/net/t2code/t2codelib/SPIGOT/system/cmd/CmdExecuter.java b/src/main/java/net/t2code/t2codelib/SPIGOT/system/cmd/CmdExecuter.java index 54ed09a..3a5a02f 100644 --- a/src/main/java/net/t2code/t2codelib/SPIGOT/system/cmd/CmdExecuter.java +++ b/src/main/java/net/t2code/t2codelib/SPIGOT/system/cmd/CmdExecuter.java @@ -45,6 +45,13 @@ public class CmdExecuter implements CommandExecutor, TabCompleter { } Commands.info(sender); return false; + case "permtoggle": + if (!sender.hasPermission("t2code.permtoggle.use")) { + T2Csend.sender(sender, "§4No Permission §8t2code.permtoggle.use"); + return false; + } + Commands.permtoggle(sender, args); + return false; case "updateinfo": if (!sender.hasPermission("t2code.admin")) { T2Csend.sender(sender, "§4No Permission §8t2code.admin"); @@ -52,13 +59,13 @@ public class CmdExecuter implements CommandExecutor, TabCompleter { } Commands.updateInfo(sender, args); return false; - // case "plugininfo": todo - // if (!sender.hasPermission("t2code.admin")) { - // T2Csend.sender(sender, "§4No Permission §8t2code.admin"); - // return false; - // } - // Commands.updateInfo(sender, args); - // return false; + // case "plugininfo": todo + // if (!sender.hasPermission("t2code.admin")) { + // T2Csend.sender(sender, "§4No Permission §8t2code.admin"); + // return false; + // } + // Commands.updateInfo(sender, args); + // return false; case "reloadconfig": if (!sender.hasPermission("t2code.admin")) { T2Csend.sender(sender, "§4No Permission §8t2code.admin"); diff --git a/src/main/java/net/t2code/t2codelib/SPIGOT/system/cmd/Commands.java b/src/main/java/net/t2code/t2codelib/SPIGOT/system/cmd/Commands.java index af30b16..5421480 100644 --- a/src/main/java/net/t2code/t2codelib/SPIGOT/system/cmd/Commands.java +++ b/src/main/java/net/t2code/t2codelib/SPIGOT/system/cmd/Commands.java @@ -1,9 +1,11 @@ package net.t2code.t2codelib.SPIGOT.system.cmd; +import net.t2code.t2codelib.SPIGOT.api.commands.T2Ccmd; import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend; import net.t2code.t2codelib.SPIGOT.api.messages.T2Ctemplate; import net.t2code.t2codelib.SPIGOT.api.update.T2CupdateAPI; import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain; +import net.t2code.t2codelib.SPIGOT.system.config.config.SelectLibConfig; import net.t2code.t2codelib.Util; import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; @@ -83,4 +85,23 @@ public class Commands { protected static void updateInfo(CommandSender sender, String[] args) { T2Csend.sender(sender, T2CupdateAPI.updateInfo(args, sender instanceof Player)); } + + public static void permtoggle(CommandSender sender, String[] args) { + Player player = (Player) Bukkit.getOfflinePlayer(args[1]); + if (player == null) { + T2Csend.sender(sender, "§4Player §6" + args[1] + " §4not exist!"); + return; + } + String permission = args[2]; + + if (player.hasPermission(permission)) { + T2Ccmd.console(SelectLibConfig.getCommandPermToggleCommand().replace("[player]",player.getName()).replace("[perm]",permission).replace("[value]", "false")); + T2Csend.sender(sender, "§2Permission §8'§6" + permission + "§8' §2was set to §6false §2for the player §6" + player.getName() + "§2."); + } else { + T2Ccmd.console(SelectLibConfig.getCommandPermToggleCommand().replace("[player]",player.getName()).replace("[perm]",permission).replace("[value]", "true")); + T2Csend.sender(sender, "§2Permission §8'§6" + permission + "§8' §2was set to §6true §2for the player §6" + player.getName() + "§2."); + } + + + } } diff --git a/src/main/java/net/t2code/t2codelib/SPIGOT/system/config/config/ConfigCreate.java b/src/main/java/net/t2code/t2codelib/SPIGOT/system/config/config/ConfigCreate.java index 448ed4d..7db005a 100644 --- a/src/main/java/net/t2code/t2codelib/SPIGOT/system/config/config/ConfigCreate.java +++ b/src/main/java/net/t2code/t2codelib/SPIGOT/system/config/config/ConfigCreate.java @@ -33,6 +33,8 @@ public class ConfigCreate { T2Cconfig.set("BungeeCord.Enable", T2CodeLibMain.getIsBungee(), yamlConfiguration); T2Cconfig.set("Player.Inventories.CloseByServerStop", true, yamlConfiguration); + T2Cconfig.set("Command.PermToggle.PermissionSetCommand","lp user [player] permission set [perm] [value]",yamlConfiguration); + try { yamlConfiguration.save(config); } catch (IOException e) { diff --git a/src/main/java/net/t2code/t2codelib/SPIGOT/system/config/config/SelectLibConfig.java b/src/main/java/net/t2code/t2codelib/SPIGOT/system/config/config/SelectLibConfig.java index 3cc7bb0..91a0a42 100644 --- a/src/main/java/net/t2code/t2codelib/SPIGOT/system/config/config/SelectLibConfig.java +++ b/src/main/java/net/t2code/t2codelib/SPIGOT/system/config/config/SelectLibConfig.java @@ -28,6 +28,8 @@ public class SelectLibConfig { private static Boolean bungee; @Getter private static Boolean inventoriesCloseByServerStop; + @Getter + private static String commandPermToggleCommand; public static void onSelect() { File config = new File(T2CodeLibMain.getPath(), "config.yml"); @@ -46,5 +48,6 @@ public class SelectLibConfig { developerTool = yamlConfiguration.getBoolean("Plugin.Not recommended to disable.developerTool"); bungee = yamlConfiguration.getBoolean("BungeeCord.Enable"); inventoriesCloseByServerStop = yamlConfiguration.getBoolean("Player.Inventories.CloseByServerStop"); + commandPermToggleCommand = yamlConfiguration.getString("Command.PermToggle.PermissionSetCommand"); } } diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 229c15e..75a1fb7 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -29,3 +29,7 @@ commands: permissions: t2code.admin: default: op + children: + t2code.permtoggle.use: true + t2code.permtoggle.use: + default: op