From 806550a6256ebc283355d14058f42b7d3c53f4ba Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Sun, 12 Aug 2018 12:28:36 +0200 Subject: [PATCH 1/2] Added silent/loud option to primerestart Also using Tabs for formatting --- .idea/inspectionProfiles/Project_Default.xml | 11 +++++++ .../buttondevteam/core/PlayerListener.java | 6 ++-- .../core/PrimeRestartCommand.java | 33 +++++++++++-------- 3 files changed, 35 insertions(+), 15 deletions(-) create mode 100644 .idea/inspectionProfiles/Project_Default.xml diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..4f1aeda --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,11 @@ + + + + \ No newline at end of file diff --git a/ButtonCore/src/main/java/buttondevteam/core/PlayerListener.java b/ButtonCore/src/main/java/buttondevteam/core/PlayerListener.java index c85ecea..af8220e 100755 --- a/ButtonCore/src/main/java/buttondevteam/core/PlayerListener.java +++ b/ButtonCore/src/main/java/buttondevteam/core/PlayerListener.java @@ -40,11 +40,13 @@ public class PlayerListener implements Listener { && !event.getQuitMessage().equalsIgnoreCase("Server closed") && !event.getQuitMessage().equalsIgnoreCase("Server is restarting")) { if (Bukkit.getOnlinePlayers().size() <= 1) { - Bukkit.broadcastMessage("§cNobody is online anymore. Restarting."); + if (PrimeRestartCommand.isLoud()) + Bukkit.broadcastMessage("§cNobody is online anymore. Restarting."); Bukkit.spigot().restart(); } else if (!(event.getPlayer() instanceof IDiscordSender) && System.nanoTime() - 10 * 1000000000L - lasttime > 0) { //Ten seconds passed since last reminder lasttime = System.nanoTime(); - Bukkit.broadcastMessage(ChatColor.DARK_RED + "The server will restart as soon as nobody is online."); + if (PrimeRestartCommand.isLoud()) + Bukkit.broadcastMessage(ChatColor.DARK_RED + "The server will restart as soon as nobody is online."); } } } diff --git a/ButtonCore/src/main/java/buttondevteam/core/PrimeRestartCommand.java b/ButtonCore/src/main/java/buttondevteam/core/PrimeRestartCommand.java index 5ab0bcc..1f03451 100644 --- a/ButtonCore/src/main/java/buttondevteam/core/PrimeRestartCommand.java +++ b/ButtonCore/src/main/java/buttondevteam/core/PrimeRestartCommand.java @@ -11,26 +11,33 @@ import org.bukkit.command.CommandSender; public class PrimeRestartCommand extends TBMCCommandBase { @Override public boolean OnCommand(CommandSender sender, String alias, String[] args) { - if (Bukkit.getOnlinePlayers().size() > 0) { - sender.sendMessage("§bPlayers online, restart delayed."); - Bukkit.broadcastMessage(ChatColor.DARK_RED + "The server will restart as soon as nobody is online."); - plsrestart = true; - } else { - sender.sendMessage("§bNobody is online. Restarting now."); - Bukkit.broadcastMessage("§cNobody is online. Restarting server."); - Bukkit.spigot().restart(); - } - return true; + loud = args.length > 0; + if (Bukkit.getOnlinePlayers().size() > 0) { + sender.sendMessage("§bPlayers online, restart delayed."); + if (loud) + Bukkit.broadcastMessage(ChatColor.DARK_RED + "The server will restart as soon as nobody is online."); + plsrestart = true; + } else { + sender.sendMessage("§bNobody is online. Restarting now."); + if (loud) + Bukkit.broadcastMessage("§cNobody is online. Restarting server."); + Bukkit.spigot().restart(); + } + return true; } - @Getter - private static boolean plsrestart = false; + @Getter + private static boolean plsrestart = false; + @Getter + private static boolean loud = false; @Override public String[] GetHelpText(String alias) { return new String[]{ // "§6---- Prime restart ----", // - "Restarts the server as soon as nobody is online." // + "Restarts the server as soon as nobody is online.", // + "To be loud, type something after, like /primerestart lol (it doesn't matter what you write)", // + "To be silent, don't type anything" // }; } } From 718d8d073ce006d1b5c75ba2570238966d77d4ba Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Tue, 4 Sep 2018 21:49:30 +0200 Subject: [PATCH 2/2] Added /member mod command --- ..._milkbowl_VaultAPI_master_8dc0859cba_1.xml | 13 ----- BuildConfigUpdater/BuildConfigUpdater.iml | 1 + .../java/buttondevteam/core/MainPlugin.java | 1 + .../buttondevteam/core/MemberCommand.java | 55 +++++++++++++++++++ ButtonCore/src/main/resources/plugin.yml | 4 +- 5 files changed, 60 insertions(+), 14 deletions(-) delete mode 100755 .idea/libraries/Maven__com_github_milkbowl_VaultAPI_master_8dc0859cba_1.xml create mode 100644 ButtonCore/src/main/java/buttondevteam/core/MemberCommand.java diff --git a/.idea/libraries/Maven__com_github_milkbowl_VaultAPI_master_8dc0859cba_1.xml b/.idea/libraries/Maven__com_github_milkbowl_VaultAPI_master_8dc0859cba_1.xml deleted file mode 100755 index 2f453df..0000000 --- a/.idea/libraries/Maven__com_github_milkbowl_VaultAPI_master_8dc0859cba_1.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/BuildConfigUpdater/BuildConfigUpdater.iml b/BuildConfigUpdater/BuildConfigUpdater.iml index 4902d56..9cd800b 100644 --- a/BuildConfigUpdater/BuildConfigUpdater.iml +++ b/BuildConfigUpdater/BuildConfigUpdater.iml @@ -13,6 +13,7 @@ + diff --git a/ButtonCore/src/main/java/buttondevteam/core/MainPlugin.java b/ButtonCore/src/main/java/buttondevteam/core/MainPlugin.java index beb7651..233bdef 100755 --- a/ButtonCore/src/main/java/buttondevteam/core/MainPlugin.java +++ b/ButtonCore/src/main/java/buttondevteam/core/MainPlugin.java @@ -43,6 +43,7 @@ public class MainPlugin extends JavaPlugin { TBMCChatAPI.AddCommand(this, UpdatePluginCommand.class); TBMCChatAPI.AddCommand(this, ScheduledRestartCommand.class); TBMCChatAPI.AddCommand(this, PrimeRestartCommand.class); + TBMCChatAPI.AddCommand(this, MemberCommand.class); TBMCCoreAPI.RegisterEventsForExceptions(new PlayerListener(), this); TBMCCoreAPI.RegisterUserClass(TBMCPlayerBase.class); TBMCChatAPI.RegisterChatChannel(Channel.GlobalChat = new Channel("§fOOC§f", Color.White, "ooc", null)); diff --git a/ButtonCore/src/main/java/buttondevteam/core/MemberCommand.java b/ButtonCore/src/main/java/buttondevteam/core/MemberCommand.java new file mode 100644 index 0000000..8f02d05 --- /dev/null +++ b/ButtonCore/src/main/java/buttondevteam/core/MemberCommand.java @@ -0,0 +1,55 @@ +package buttondevteam.core; + +import buttondevteam.lib.chat.CommandClass; +import buttondevteam.lib.chat.TBMCCommandBase; +import lombok.val; +import org.bukkit.Bukkit; +import org.bukkit.command.CommandSender; + +@CommandClass(modOnly = true, path = "member") +public class MemberCommand extends TBMCCommandBase { + @Override + public boolean OnCommand(CommandSender sender, String alias, String[] args) { + if (args.length < 2) + return false; + final boolean add; + if (args[0].equalsIgnoreCase("add")) + add = true; + else if (args[0].equalsIgnoreCase("remove")) + add = false; + else + return false; + Bukkit.getScheduler().runTaskAsynchronously(MainPlugin.Instance, () -> { + if (MainPlugin.permission == null) { + sender.sendMessage("§cError: No permission plugin found!"); + return; + } + val op = Bukkit.getOfflinePlayer(args[1]); + if (!op.hasPlayedBefore()) { + sender.sendMessage("§cCannot find player or haven't played before."); + return; + } + if (add) { + if (MainPlugin.permission.playerAddGroup(null, op, "member")) + sender.sendMessage("§b" + op.getName() + " added as a member!"); + else + sender.sendMessage("§cFailed to add " + op.getName() + " as a member!"); + } else { + if (MainPlugin.permission.playerRemoveGroup(null, op, "member")) + sender.sendMessage("§b" + op.getName() + " removed as a member!"); + else + sender.sendMessage("§bFailed to remove " + op.getName() + " as a member!"); + } + }); + return true; + } + + @Override + public String[] GetHelpText(String alias) { + return new String[]{ // + "06---- Member ----", // + "Add or remove server members.", // + "Usage: /member " // + }; + } +} diff --git a/ButtonCore/src/main/resources/plugin.yml b/ButtonCore/src/main/resources/plugin.yml index c638c1c..4e53d6c 100755 --- a/ButtonCore/src/main/resources/plugin.yml +++ b/ButtonCore/src/main/resources/plugin.yml @@ -10,4 +10,6 @@ commands: primerestart: description: Restarts the server as soon as nobody is online. randomtp: - description: teleport player to random location within world border. Every five players teleport to the same general area, and then a new general area is randomly selected for the next five players. \ No newline at end of file + description: teleport player to random location within world border. Every five players teleport to the same general area, and then a new general area is randomly selected for the next five players. + member: + description: Add or remove a member \ No newline at end of file