From 3a8927169acd44e9f6b3b2715501033e68a12212 Mon Sep 17 00:00:00 2001 From: minenash Date: Thu, 9 Feb 2017 17:02:45 -0500 Subject: [PATCH 001/152] Back to defualt. --- src/com/redstoner/misc/Main.java | 2 - .../modules/illumination/Illumination.java | 62 ------------------- 2 files changed, 64 deletions(-) delete mode 100644 src/com/redstoner/modules/illumination/Illumination.java diff --git a/src/com/redstoner/misc/Main.java b/src/com/redstoner/misc/Main.java index e7d4707..8543dde 100644 --- a/src/com/redstoner/misc/Main.java +++ b/src/com/redstoner/misc/Main.java @@ -14,7 +14,6 @@ import com.redstoner.modules.chatgroups.Chatgroups; import com.redstoner.modules.check.Check; import com.redstoner.modules.cycle.Cycle; import com.redstoner.modules.damnspam.DamnSpam; -import com.redstoner.modules.illumination.Illumination; import com.redstoner.modules.imout.Imout; import com.redstoner.modules.lagchunks.LagChunks; import com.redstoner.modules.loginsecurity.LoginSecurity; @@ -58,7 +57,6 @@ public class Main extends JavaPlugin ModuleLoader.addModule(Check.class); ModuleLoader.addModule(DamnSpam.class); // TODO: ModuleLoader.addModule(Friends.class); - ModuleLoader.addModule(Illumination.class); // TODO: ModuleLoader.addModule(Imbusy.class); ModuleLoader.addModule(Imout.class); ModuleLoader.addModule(LagChunks.class); diff --git a/src/com/redstoner/modules/illumination/Illumination.java b/src/com/redstoner/modules/illumination/Illumination.java deleted file mode 100644 index 5404a30..0000000 --- a/src/com/redstoner/modules/illumination/Illumination.java +++ /dev/null @@ -1,62 +0,0 @@ -package com.redstoner.modules.illumination; - -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; -import org.bukkit.potion.PotionEffect; -import org.bukkit.potion.PotionEffectType; - -import com.nemez.cmdmgr.Command; -import com.redstoner.annotations.Version; -import com.redstoner.misc.Utils; -import com.redstoner.modules.Module; - -@Version(major = 1, minor = 0, revision = 0, compatible = 1) -public class Illumination implements Module{ - - boolean enabled = false; - PotionEffect effect = new PotionEffect(PotionEffectType.NIGHT_VISION, Integer.MAX_VALUE, 0, false, false); - - @Command(hook = "illuminate") - public void illuminate(CommandSender sender) { - Player player = (Player) sender; - if(player.hasPotionEffect(PotionEffectType.NIGHT_VISION)) { - player.removePotionEffect(PotionEffectType.NIGHT_VISION); - Utils.sendMessage(sender, null, "Night Vision Disabled."); - } - else { - player.addPotionEffect(effect, true); - Utils.sendMessage(sender, null, "Night Vision Enabled."); - } - } - - @Override - public void onEnable() { - enabled = true; - - } - - @Override - public void onDisable() { - enabled = false; - - } - - @Override - public boolean enabled() { - return enabled; - } - - @Override - public String getCommandString() { - return "command nightvision {\n" + - " [empty] {\n" + - " run illuminate;\n" + - " type player;\n" + - " help Gives the player infinte night vision;\n" + - " perm utils.illuminate;\n" + - " }\n" + - "}\n" + - "\n" + - "}"; - } -} -- 2.45.2 From b0b24699378df57aa370c10a42da4173590265f6 Mon Sep 17 00:00:00 2001 From: minenash Date: Thu, 9 Feb 2017 18:10:01 -0500 Subject: [PATCH 002/152] Added Challenge Module --- src/com/redstoner/misc/Main.java | 2 + .../modules/challenge/Challenge.java | 266 ++++++++++++++++++ 2 files changed, 268 insertions(+) create mode 100644 src/com/redstoner/modules/challenge/Challenge.java diff --git a/src/com/redstoner/misc/Main.java b/src/com/redstoner/misc/Main.java index 8543dde..5724822 100644 --- a/src/com/redstoner/misc/Main.java +++ b/src/com/redstoner/misc/Main.java @@ -9,6 +9,7 @@ import com.redstoner.misc.mysql.MysqlHandler; import com.redstoner.modules.abot.Abot; import com.redstoner.modules.adminchat.Adminchat; import com.redstoner.modules.adminnotes.AdminNotes; +import com.redstoner.modules.challenge.Challenge; import com.redstoner.modules.chatalias.Chatalias; import com.redstoner.modules.chatgroups.Chatgroups; import com.redstoner.modules.check.Check; @@ -51,6 +52,7 @@ public class Main extends JavaPlugin ModuleLoader.addModule(AdminNotes.class); // TODO: ModuleLoader.addModule(BlockplaceMods.class); // TODO: ModuleLoader.addModule(Calc.class); + ModuleLoader.addModule(Challenge.class); ModuleLoader.addModule(Chatalias.class); ModuleLoader.addModule(Cycle.class); ModuleLoader.addModule(Chatgroups.class); diff --git a/src/com/redstoner/modules/challenge/Challenge.java b/src/com/redstoner/modules/challenge/Challenge.java new file mode 100644 index 0000000..d9280ad --- /dev/null +++ b/src/com/redstoner/modules/challenge/Challenge.java @@ -0,0 +1,266 @@ +package com.redstoner.modules.challenge; + +import java.io.File; +import java.util.Random; + +import org.bukkit.command.CommandSender; +import org.json.simple.JSONArray; + +import com.nemez.cmdmgr.Command; +import com.redstoner.annotations.Version; +import com.redstoner.misc.JsonManager; +import com.redstoner.misc.Main; +import com.redstoner.misc.Utils; +import com.redstoner.modules.Module; + +@Version(major = 1, minor = 0, revision = 0, compatible = 1) +public class Challenge implements Module +{ + private boolean enabled = false; + private File challengeLocation = new File(Main.plugin.getDataFolder(), "challenges.json"); + private JSONArray challenges; + + @Override + public void onEnable() + { + challenges = JsonManager.getArray(challengeLocation); + if (challenges == null) + challenges = new JSONArray(); + enabled = true; + } + + @Override + public void onDisable() + { + saveChallenges(); + enabled = false; + } + + @Override + public boolean enabled() + { + return enabled; + } + + @SuppressWarnings("unchecked") + @Command(hook = "addchallenge") + public boolean addChallenge(CommandSender sender, String text) + { + if (challenges.contains(text)) + Utils.sendErrorMessage(sender, null, "That challenge already exists!"); + else + { + Utils.sendMessage(sender, null, "Successfully added a new challenge!"); + challenges.add("&a" + text); + saveChallenges(); + } + return true; + } + + @Command(hook = "delchallenge") + public boolean delChallenge(CommandSender sender, int id) + { + if (id < 0 || id >= challenges.size()) + { + Utils.sendErrorMessage(sender, null, "The ID must be at least 0 and at most " + challenges.size()); + return true; + } + Utils.sendMessage(sender, null, "Successfully deleted the challenge: " + challenges.remove(id), '&'); + saveChallenges(); + return true; + } + + @SuppressWarnings("unchecked") + @Command(hook = "setchallenge") + public boolean setChallenge(CommandSender sender, int id, String text) + { + if (id < 0 || id >= challenges.size()) + { + Utils.sendErrorMessage(sender, null, "The ID must be at least 0 and at most " + challenges.size()); + return true; + } + Utils.sendMessage(sender, null, "Successfully changed the challenge: &a" + challenges.get(id) + " &7to: &e" + text, '&'); + challenges.set(id, text); + saveChallenges(); + return true; + } + + @Command(hook = "challengeid") + public boolean challengeId(CommandSender sender, int id) + { + if (id < 0 || id >= challenges.size()) + { + Utils.sendErrorMessage(sender, null, "The ID must be at least 0 and at most " + (challenges.size() - 1)); + return true; + } + Utils.sendMessage(sender, null, challenges.get(id) + "", '&'); + return true; + } + + @Command(hook = "challenge") + public boolean challenge(CommandSender sender) + { + int id = (new Random()).nextInt(challenges.size()); + Utils.sendMessage(sender, null, challenges.get(id) + "", '&'); + return true; + } + + @Command(hook = "listchallenges") + public boolean listChallenges(CommandSender sender, int page) + { + page = page - 1; + int start = page * 10; + int end = start + 10; + int pages = (int) Math.ceil(challenges.size() / 10d); + if (start < 0) + { + Utils.sendErrorMessage(sender, null, "Page number too small, must be at least 0!"); + return true; + } + if (start > challenges.size()) + { + Utils.sendErrorMessage(sender, null, "Page number too big, must be at most " + pages + "!"); + return true; + } + Utils.sendModuleHeader(sender); + Utils.sendMessage(sender, "", "&ePage " + (page + 1) + "/" + pages + ":", '&'); + for (int i = start; i < end && i < challenges.size(); i++) + Utils.sendMessage(sender, "", "&a" + i + "&8: &e" + challenges.get(i), '&'); + return true; + } + + @Command(hook = "listchallengesdef") + public boolean listChallengesDefault(CommandSender sender) + { + return listChallenges(sender, 1); + } + + @Command(hook = "searchchallenge") + public boolean search(CommandSender sender, boolean insensitive, String text) + { + Utils.sendModuleHeader(sender); + boolean found = false; + if (insensitive) + { + text = text.toLowerCase(); + for (int i = 0; i < challenges.size(); i++) + { + if (((String) challenges.get(i)).toLowerCase().contains(text)) + { + Utils.sendMessage(sender, "", "&a" + i + "&8: &e" + challenges.get(i), '&'); + found = true; + } + } + } + else + { + for (int i = 0; i < challenges.size(); i++) + { + if (((String) challenges.get(i)).contains(text)) + { + Utils.sendMessage(sender, "", "&a" + i + "&8: &e" + challenges.get(i), '&'); + found = true; + } + } + } + if (!found) + { + Utils.sendMessage(sender, "", "&cCouldn't find any matching challenges.", '&'); + } + return true; + } + + @Command(hook = "matchchallenge") + public boolean match(CommandSender sender, boolean insensitive, String regex) + { + Utils.sendModuleHeader(sender); + boolean found = false; + if (insensitive) + { + regex = regex.toLowerCase(); + for (int i = 0; i < challenges.size(); i++) + { + if (((String) challenges.get(i)).toLowerCase().matches(regex)) + { + Utils.sendMessage(sender, "", "&a" + i + ": " + challenges.get(i), '&'); + found = true; + } + } + } + else + { + for (int i = 0; i < challenges.size(); i++) + { + if (((String) challenges.get(i)).matches(regex)) + { + Utils.sendMessage(sender, "", "&a" + i + ": " + challenges.get(i), '&'); + found = true; + } + } + } + if (!found) + { + Utils.sendMessage(sender, "", "&cCouldn't find any matching challenges.", '&'); + } + return true; + } + + public void saveChallenges() + { + JsonManager.save(challenges, challengeLocation); + } + + // @noformat + @Override + public String getCommandString() + { + return "command challenge {\n" + + " add [string:text...] {\n" + + " help Adds a challenge.;\n" + + " run addchallenge text;\n" + + " perm utils.challenge.add;\n" + + " }\n" + + " del [int:id] {\n" + + " help Removes a challenge.;\n" + + " run delchallenge id;\n" + + " perm utils.challenge.admin;\n" + + " }\n" + + " set [int:id] [string:text...] {\n" + + " help Sets a challenge.;\n" + + " run setchallenge id text;\n" + + " perm utils.challenge.admin;\n" + + " }\n" + + " id [int:id] {\n" + + " help Get a paticular challenge.;\n" + + " run challengeid id;\n" + + " perm utils.challenge.id;\n" + + " }\n" + + " list [int:page] {\n" + + " help Shows challenges.;\n" + + " run listchallenges page;\n" + + " perm utils.challenge.list;\n" + + " }\n" + + " list {\n" + + " help Shows challenges.;\n" + + " run listchallengesdef;\n" + + " perm utils.challenge.list;\n" + + " }\n" + + " search [flag:-i] [string:text...] {\n" + + " help Search challenges.;\n" + + " run searchchallenge -i text;\n" + + " perm utils.challenge.search;\n" + + " }\n" + + " match [flag:-i] [string:regex...] {\n" + + " help Search challenges. But better.;\n" + + " run matchchallenge -i regex;\n" + + " perm utils.challenge.match;\n" + + " }\n" + + " [empty] {\n" + + " help Gives a challenge.;\n" + + " run challenge;\n" + + " perm utils.challenge;\n" + + " }\n" + + "}"; + } + // @format +} -- 2.45.2 From a2a2334be667ae805e66a9321d5b62f76eaa4dfa Mon Sep 17 00:00:00 2001 From: minenash Date: Sat, 11 Feb 2017 11:42:19 -0500 Subject: [PATCH 003/152] Added ClearOnJoin Module --- src/com/redstoner/misc/Main.java | 2 + .../modules/clearonjoin/ClearOnJoin.java | 106 ++++++++++++++++++ 2 files changed, 108 insertions(+) create mode 100644 src/com/redstoner/modules/clearonjoin/ClearOnJoin.java diff --git a/src/com/redstoner/misc/Main.java b/src/com/redstoner/misc/Main.java index 8543dde..d61c6ce 100644 --- a/src/com/redstoner/misc/Main.java +++ b/src/com/redstoner/misc/Main.java @@ -12,6 +12,7 @@ import com.redstoner.modules.adminnotes.AdminNotes; import com.redstoner.modules.chatalias.Chatalias; import com.redstoner.modules.chatgroups.Chatgroups; import com.redstoner.modules.check.Check; +import com.redstoner.modules.clearonjoin.ClearOnJoin; import com.redstoner.modules.cycle.Cycle; import com.redstoner.modules.damnspam.DamnSpam; import com.redstoner.modules.imout.Imout; @@ -51,6 +52,7 @@ public class Main extends JavaPlugin ModuleLoader.addModule(AdminNotes.class); // TODO: ModuleLoader.addModule(BlockplaceMods.class); // TODO: ModuleLoader.addModule(Calc.class); + ModuleLoader.addModule(ClearOnJoin.class); ModuleLoader.addModule(Chatalias.class); ModuleLoader.addModule(Cycle.class); ModuleLoader.addModule(Chatgroups.class); diff --git a/src/com/redstoner/modules/clearonjoin/ClearOnJoin.java b/src/com/redstoner/modules/clearonjoin/ClearOnJoin.java new file mode 100644 index 0000000..12affd2 --- /dev/null +++ b/src/com/redstoner/modules/clearonjoin/ClearOnJoin.java @@ -0,0 +1,106 @@ +package com.redstoner.modules.clearonjoin; + +import java.io.File; + +import org.bukkit.Bukkit; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerJoinEvent; +import org.json.simple.JSONArray; + +import com.nemez.cmdmgr.Command; +import com.redstoner.misc.JsonManager; +import com.redstoner.misc.Main; +import com.redstoner.misc.Utils; +import com.redstoner.modules.Module; + +public class ClearOnJoin implements Module, Listener{ + + boolean enabled = false; + private File listLocation = new File(Main.plugin.getDataFolder(), "clearonjoins.json"); + private JSONArray list; + + @SuppressWarnings("unchecked") + @Command(hook = "clearonjoin") + public void clearOnJoin(CommandSender sender, String player) { + list.add("!" + player.toLowerCase()); + saveList(); + Utils.sendMessage(sender, null, player +"'s inventory will be cleared next time he joins."); + } + + @SuppressWarnings("unchecked") + @Command(hook = "clearonjoinself") + public void clearOnJoinSelf(CommandSender sender) { + String name = sender.getName().toLowerCase(); + if(list.contains(name)) { + list.remove(name); + Utils.sendMessage(sender, null, "Your inventory will no longer be cleared apon joining"); + saveList(); + return; + } + list.add(name); + saveList(); + Utils.sendMessage(sender, null, "Your inventory will now be cleared apon joining."); + } + + @EventHandler + public void aponJoin(PlayerJoinEvent e) + { + Player player = e.getPlayer(); + String playerName = player.getName().toLowerCase(); + if(list.contains(playerName)) { + e.getPlayer().getInventory().clear(); + Utils.sendMessage(e.getPlayer(), null, "Inventory Cleared."); + } + else if(list.contains("!" + playerName)){ + e.getPlayer().getInventory().clear(); + list.remove("!" + playerName); + saveList(); + Utils.sendMessage(e.getPlayer(), null, "Inventory Cleared."); + } + } + + public void saveList() + { + JsonManager.save(list, listLocation); + } + + @Override + public void onEnable() { + enabled = true; + list = JsonManager.getArray(listLocation); + if (list == null) list = new JSONArray(); + Bukkit.getServer().getPluginManager().registerEvents(this, Main.plugin); + } + + @Override + public void onDisable() { + saveList(); + enabled = false; + + } + + @Override + public boolean enabled() { + return enabled; + } + + @Override + public String getCommandString() { + return "command clearonjoin {\n" + + " [string:name] {\n" + + " help Clears that players inventory the nect time they join.;\n" + + " run clearonjoin name;\n" + + " perm utils.clearonjoin.other;\n" + + " }\n" + + " [empty] {\n" + + " help Clears your inventory every time you join.;\n" + + " run clearonjoinself;\n" + + " perm utils.clearonjoin.self;\n" + + " }\n" + + "}"; + } + +} -- 2.45.2 From a5d8cbe0172e8996e226eb268047381b74f40c44 Mon Sep 17 00:00:00 2001 From: minenash Date: Sun, 12 Feb 2017 10:45:23 -0500 Subject: [PATCH 004/152] Added Illumination Module --- src/com/redstoner/misc/Main.java | 2 + .../modules/illumination/Illumination.java | 62 +++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 src/com/redstoner/modules/illumination/Illumination.java diff --git a/src/com/redstoner/misc/Main.java b/src/com/redstoner/misc/Main.java index 5cc0803..a5691ec 100644 --- a/src/com/redstoner/misc/Main.java +++ b/src/com/redstoner/misc/Main.java @@ -16,6 +16,7 @@ import com.redstoner.modules.check.Check; import com.redstoner.modules.clearonjoin.ClearOnJoin; import com.redstoner.modules.cycle.Cycle; import com.redstoner.modules.damnspam.DamnSpam; +import com.redstoner.modules.illumination.Illumination; import com.redstoner.modules.imout.Imout; import com.redstoner.modules.lagchunks.LagChunks; import com.redstoner.modules.loginsecurity.LoginSecurity; @@ -61,6 +62,7 @@ public class Main extends JavaPlugin ModuleLoader.addModule(Check.class); ModuleLoader.addModule(DamnSpam.class); // TODO: ModuleLoader.addModule(Friends.class); + ModuleLoader.addModule(Illumination.class); // TODO: ModuleLoader.addModule(Imbusy.class); ModuleLoader.addModule(Imout.class); ModuleLoader.addModule(LagChunks.class); diff --git a/src/com/redstoner/modules/illumination/Illumination.java b/src/com/redstoner/modules/illumination/Illumination.java new file mode 100644 index 0000000..5404a30 --- /dev/null +++ b/src/com/redstoner/modules/illumination/Illumination.java @@ -0,0 +1,62 @@ +package com.redstoner.modules.illumination; + +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; + +import com.nemez.cmdmgr.Command; +import com.redstoner.annotations.Version; +import com.redstoner.misc.Utils; +import com.redstoner.modules.Module; + +@Version(major = 1, minor = 0, revision = 0, compatible = 1) +public class Illumination implements Module{ + + boolean enabled = false; + PotionEffect effect = new PotionEffect(PotionEffectType.NIGHT_VISION, Integer.MAX_VALUE, 0, false, false); + + @Command(hook = "illuminate") + public void illuminate(CommandSender sender) { + Player player = (Player) sender; + if(player.hasPotionEffect(PotionEffectType.NIGHT_VISION)) { + player.removePotionEffect(PotionEffectType.NIGHT_VISION); + Utils.sendMessage(sender, null, "Night Vision Disabled."); + } + else { + player.addPotionEffect(effect, true); + Utils.sendMessage(sender, null, "Night Vision Enabled."); + } + } + + @Override + public void onEnable() { + enabled = true; + + } + + @Override + public void onDisable() { + enabled = false; + + } + + @Override + public boolean enabled() { + return enabled; + } + + @Override + public String getCommandString() { + return "command nightvision {\n" + + " [empty] {\n" + + " run illuminate;\n" + + " type player;\n" + + " help Gives the player infinte night vision;\n" + + " perm utils.illuminate;\n" + + " }\n" + + "}\n" + + "\n" + + "}"; + } +} -- 2.45.2 From 6e65173ba6d86914c679c26c9151d39b1473e76a Mon Sep 17 00:00:00 2001 From: minenash Date: Sun, 12 Feb 2017 12:01:25 -0500 Subject: [PATCH 005/152] Added Naming Module --- src/com/redstoner/misc/Main.java | 2 + src/com/redstoner/modules/naming/Naming.java | 115 +++++++++++++++++++ 2 files changed, 117 insertions(+) create mode 100644 src/com/redstoner/modules/naming/Naming.java diff --git a/src/com/redstoner/misc/Main.java b/src/com/redstoner/misc/Main.java index a5691ec..0537798 100644 --- a/src/com/redstoner/misc/Main.java +++ b/src/com/redstoner/misc/Main.java @@ -24,6 +24,7 @@ import com.redstoner.modules.mentio.Mentio; import com.redstoner.modules.misc.Misc; import com.redstoner.modules.motd.Motd; import com.redstoner.modules.nametags.Nametags; +import com.redstoner.modules.naming.Naming; import com.redstoner.modules.pmtoggle.Pmtoggle; import com.redstoner.modules.reports.Reports; import com.redstoner.modules.saylol.Saylol; @@ -70,6 +71,7 @@ public class Main extends JavaPlugin ModuleLoader.addModule(Mentio.class); ModuleLoader.addModule(Misc.class); ModuleLoader.addModule(Motd.class); + ModuleLoader.addModule(Naming.class); ModuleLoader.addModule(Nametags.class); ModuleLoader.addModule(Pmtoggle.class); ModuleLoader.addModule(Reports.class); diff --git a/src/com/redstoner/modules/naming/Naming.java b/src/com/redstoner/modules/naming/Naming.java new file mode 100644 index 0000000..acbc05c --- /dev/null +++ b/src/com/redstoner/modules/naming/Naming.java @@ -0,0 +1,115 @@ +package com.redstoner.modules.naming; + +import java.util.ArrayList; +import java.util.List; + +import org.bukkit.command.CommandSender; +import org.bukkit.craftbukkit.v1_11_R1.entity.CraftPlayer; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; + +import com.nemez.cmdmgr.Command; +import com.redstoner.misc.Utils; +import com.redstoner.modules.Module; + +import net.md_5.bungee.api.ChatColor; +import net.minecraft.server.v1_11_R1.BlockPosition; +import net.minecraft.server.v1_11_R1.ChatMessage; +import net.minecraft.server.v1_11_R1.ContainerAnvil; +import net.minecraft.server.v1_11_R1.EntityHuman; +import net.minecraft.server.v1_11_R1.EntityPlayer; +import net.minecraft.server.v1_11_R1.PacketPlayOutOpenWindow; + +public class Naming implements Module{ + + boolean enabled = false; + + @Command(hook = "anvil") + public void anvil(CommandSender sender) { + EntityPlayer p = ((CraftPlayer) sender).getHandle(); + AnvilContainer container = new AnvilContainer(p); + int c = p.nextContainerCounter(); + p.playerConnection.sendPacket(new PacketPlayOutOpenWindow(c,"minecraft:anvil",new ChatMessage("Repairing",new Object[]{}),0)); + p.activeContainer = container; + p.activeContainer.windowId = c; + p.activeContainer.addSlotListener(p); + } + + @Command(hook = "name") + public void name(CommandSender sender, String name){ + name = ChatColor.translateAlternateColorCodes('&', name); + ItemStack item = ((Player)sender).getInventory().getItemInMainHand(); + ItemMeta meta = item.getItemMeta(); + meta.setDisplayName(name); + item.setItemMeta(meta); + Utils.sendMessage(sender, null, "Name set to " + name); + } + + @Command(hook = "lore") + public void lore(CommandSender sender, String name){ + List lore = new ArrayList(); + name = ChatColor.translateAlternateColorCodes('&', name); + lore.add(name); + ItemStack item = ((Player)sender).getInventory().getItemInMainHand(); + ItemMeta meta = item.getItemMeta(); + meta.setLore(lore); + item.setItemMeta(meta); + item.getItemMeta().setLore(lore); + Utils.sendMessage(sender, null, "Lore set to " + name); + } + + public class AnvilContainer extends ContainerAnvil { + public AnvilContainer(EntityHuman entity) { + super(entity.inventory, entity.world, new BlockPosition(0, 0, 0), entity); + } + public boolean a(EntityHuman entityhuman) { + return true; + } + } + @Override + public void onEnable() { + enabled = true; + + } + @Override + public void onDisable() { + enabled = false; + } + @Override + public boolean enabled() { + return enabled; + } + + @Override + public String getCommandString() { + // TODO Auto-generated method stub + return "command anvil {\n" + + " [empty] {\n" + + " run anvil;\n" + + " type player;\n" + + " help Opens anvil GUI.;\n" + + " perm utils.anvil;\n" + + " }\n" + + "}\n" + + "\n" + + "command name {\n" + + " [string:name...] {\n" + + " run name name;\n" + + " type player;\n" + + " help Names item in hand.;\n" + + " perm utils.name;\n" + + " }\n" + + "}\n" + + "\n" + + "command lore {\n" + + " [string:name...] {\n" + + " run lore name;\n" + + " type player;\n" + + " help Adds lore to item in hand.;\n" + + " perm utils.lore;\n" + + " }\n" + + "}"; + } + +} -- 2.45.2 From 3d83c1dff8dba168dfd4abf40702b016ade0ac6e Mon Sep 17 00:00:00 2001 From: Pepich Date: Sat, 18 Feb 2017 16:16:07 +0100 Subject: [PATCH 006/152] Fixed special chars to work as cgkeys properly --- src/com/redstoner/modules/chatgroups/Chatgroups.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/com/redstoner/modules/chatgroups/Chatgroups.java b/src/com/redstoner/modules/chatgroups/Chatgroups.java index 2ee0ee0..701a7e0 100644 --- a/src/com/redstoner/modules/chatgroups/Chatgroups.java +++ b/src/com/redstoner/modules/chatgroups/Chatgroups.java @@ -26,7 +26,7 @@ import com.redstoner.modules.Module; * * @author Pepich */ @AutoRegisterListener -@Version(major = 1, minor = 2, revision = 1, compatible = 1) +@Version(major = 1, minor = 2, revision = 2, compatible = 1) public class Chatgroups implements Module, Listener { private static final char defaultKey = ':'; @@ -270,7 +270,7 @@ public class Chatgroups implements Module, Listener if (event.getMessage().startsWith(getKey(player))) { event.setCancelled(true); - sendToGroup(event.getPlayer(), event.getMessage().replaceFirst(getKey(player), "")); + sendToGroup(event.getPlayer(), event.getMessage().substring(1)); } else if (cgtoggled.contains(event.getPlayer().getUniqueId())) { -- 2.45.2 From 9eec4c92408c730a469c55f6ecddcad84041dadf Mon Sep 17 00:00:00 2001 From: Pepich Date: Sat, 18 Feb 2017 16:33:18 +0100 Subject: [PATCH 007/152] Added a way to other operations than "WHERE" selectors --- .../misc/mysql/elements/MysqlTable.java | 109 ++++++++++++------ 1 file changed, 73 insertions(+), 36 deletions(-) diff --git a/src/com/redstoner/misc/mysql/elements/MysqlTable.java b/src/com/redstoner/misc/mysql/elements/MysqlTable.java index fa0008e..6656fcd 100644 --- a/src/com/redstoner/misc/mysql/elements/MysqlTable.java +++ b/src/com/redstoner/misc/mysql/elements/MysqlTable.java @@ -8,89 +8,126 @@ import java.util.List; import com.redstoner.misc.mysql.MysqlQueryHandler; -public class MysqlTable { +public class MysqlTable +{ private MysqlDatabase database; private String name; - public MysqlTable(MysqlDatabase database, String name) { + public MysqlTable(MysqlDatabase database, String name) + { this.database = database; this.name = name; } - public String getName() { + public String getName() + { return this.name; } - public MysqlField[] describe() { - try { + public MysqlField[] describe() + { + try + { List description = new ArrayList<>(); DatabaseMetaData metadata = database.getConnection().getMetaData(); ResultSet queryResults = metadata.getColumns(null, null, name, null); - - while (queryResults.next()) { - description.add(new MysqlField(queryResults.getString(4), queryResults.getString(6).split(" ")[0] + "(" + queryResults.getString(7) + ")", queryResults.getBoolean(11))); + while (queryResults.next()) + { + description.add(new MysqlField(queryResults.getString(4), + queryResults.getString(6).split(" ")[0] + "(" + queryResults.getString(7) + ")", + queryResults.getBoolean(11))); } - return description.toArray(new MysqlField[0]); - } catch (SQLException e) { + } + catch (SQLException e) + { e.printStackTrace(); return null; } } - public boolean insert(String... values) { + public boolean insert(String... values) + { MysqlField[] description = describe(); - - if (values.length > 0 && values.length == description.length) { + if (values.length > 0 && values.length == description.length) + { String val = "(\"" + String.join("\",\"", values) + "\")"; - - return MysqlQueryHandler.queryNoResult(database.getConnection(), "INSERT INTO `" + name + "` VALUES " + val + ";"); - } else { + return MysqlQueryHandler.queryNoResult(database.getConnection(), + "INSERT INTO `" + name + "` VALUES " + val + ";"); + } + else + { return false; } } - public Object[] get(String fieldName, MysqlConstraint... constraints) { - ResultSet results = MysqlQueryHandler.queryResult(database.getConnection(), "SELECT " + fieldName + " FROM `" + name + "`" + getConstraints(constraints) + ";"); - + public Object[] get(String fieldName, MysqlConstraint... constraints) + { + ResultSet results = MysqlQueryHandler.queryResult(database.getConnection(), + "SELECT " + fieldName + " FROM `" + name + "`" + getConstraints(constraints) + ";"); List resObj = new ArrayList<>(); - try { - while (results.next()) { + try + { + while (results.next()) + { resObj.add(results.getObject(1)); } - } catch (SQLException e) { + } + catch (SQLException e) + { e.printStackTrace(); return new Object[0]; } - return resObj.toArray(new Object[0]); } - public boolean delete(MysqlConstraint... constraints) { - return MysqlQueryHandler.queryNoResult(database.getConnection(), "DELETE FROM `" + name + "`" + getConstraints(constraints) + ";"); + public Object[] get(String statement) + { + ResultSet results = MysqlQueryHandler.queryResult(database.getConnection(), statement); + List resObj = new ArrayList<>(); + try + { + while (results.next()) + { + resObj.add(results.getObject(1)); + } + } + catch (SQLException e) + { + e.printStackTrace(); + return new Object[0]; + } + return resObj.toArray(new Object[0]); } - public boolean drop() { + public boolean delete(MysqlConstraint... constraints) + { + return MysqlQueryHandler.queryNoResult(database.getConnection(), + "DELETE FROM `" + name + "`" + getConstraints(constraints) + ";"); + } + + public boolean drop() + { return MysqlQueryHandler.queryNoResult(database.getConnection(), "DROP TABLE `" + name + "`;"); } - private String getConstraints(MysqlConstraint... constraints) { + private String getConstraints(MysqlConstraint... constraints) + { String cons = ""; - - if (constraints.length > 0) { + if (constraints.length > 0) + { cons += " WHERE "; - - for (int i = 0; i < constraints.length; i++) { + for (int i = 0; i < constraints.length; i++) + { MysqlConstraint constraint = constraints[i]; - - cons += constraint.getFieldName() + constraint.getOperator().toString() + "\"" + constraint.getValue() + "\""; - - if (i < constraints.length - 1) { + cons += constraint.getFieldName() + constraint.getOperator().toString() + "\"" + constraint.getValue() + + "\""; + if (i < constraints.length - 1) + { cons += " AND "; } } } - return cons; } } -- 2.45.2 From 73f7f0da5065abac10f9682294442dbb295bb573 Mon Sep 17 00:00:00 2001 From: Pepich Date: Sat, 18 Feb 2017 16:33:44 +0100 Subject: [PATCH 008/152] Fixed formatting and some smaller bugs --- src/com/redstoner/modules/check/Check.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/com/redstoner/modules/check/Check.java b/src/com/redstoner/modules/check/Check.java index d0ccefb..4a8bfc5 100644 --- a/src/com/redstoner/modules/check/Check.java +++ b/src/com/redstoner/modules/check/Check.java @@ -31,7 +31,7 @@ import com.redstoner.misc.mysql.elements.MysqlDatabase; import com.redstoner.misc.mysql.elements.MysqlTable; import com.redstoner.modules.Module; -@Version(major = 1, minor = 0, revision = 4, compatible = 1) +@Version(major = 1, minor = 0, revision = 5, compatible = 1) public class Check implements Module, Listener { private boolean enabled = false; @@ -67,7 +67,10 @@ public class Check implements Module, Listener { Utils.sendModuleHeader(sender); Utils.sendMessage(sender, "", "&7Please notice that the data may not be fully accurate!"); - OfflinePlayer oPlayer = Bukkit.getServer().getOfflinePlayer(player); + OfflinePlayer oPlayer; + oPlayer = Bukkit.getPlayer(player); + if (oPlayer == null) + oPlayer = Bukkit.getServer().getOfflinePlayer(player); sendData(sender, oPlayer); } @@ -128,7 +131,7 @@ public class Check implements Module, Listener { Long firstJoin = player.getFirstPlayed(); Date date = new Date(firstJoin); - SimpleDateFormat format = new SimpleDateFormat("y-M-d H:m"); + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm"); return format.format(date); } @@ -136,7 +139,7 @@ public class Check implements Module, Listener { Long lastSeen = player.getLastPlayed(); Date date = new Date(lastSeen); - SimpleDateFormat format = new SimpleDateFormat("y-M-d H:m"); + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm"); return format.format(date); } @@ -192,9 +195,9 @@ public class Check implements Module, Listener { // data String firstJoin = getFirstJoin(player); - String lastSeen = getFirstJoin(player); - firstJoin = (firstJoin.equals("1970-1-1 1:0")) ? "&eNever" : "&7(y-m-d h:m:s) &e" + firstJoin; - lastSeen = (lastSeen.equals("1970-1-1 1:0")) ? "&eNever" : "&7(y-m-d h:m:s) &e" + lastSeen; + String lastSeen = getLastSeen(player); + firstJoin = (firstJoin.equals("1970-01-01 01:00")) ? "&eNever" : "&7(yyyy-MM-dd hh:mm:ss) &e" + firstJoin; + lastSeen = (lastSeen.equals("1970-1-1 1:0")) ? "&eNever" : "&7(yyyy-MM-dd hh:mm:ss) &e" + lastSeen; Object[] websiteData = getWebsiteData(player); String websiteUrl = (websiteData[0] == null) ? "None" : (String) websiteData[0]; String email = (websiteData[0] == null) ? "Unknown" : (String) websiteData[1]; -- 2.45.2 From d73e15eecd2b80c00165ac2c61f02a1b57ae67f9 Mon Sep 17 00:00:00 2001 From: Pepich Date: Sat, 18 Feb 2017 17:02:04 +0100 Subject: [PATCH 009/152] Made wildcard catch only apply to regex aliases --- .../modules/chatalias/Chatalias.java | 127 +++++++++--------- 1 file changed, 67 insertions(+), 60 deletions(-) diff --git a/src/com/redstoner/modules/chatalias/Chatalias.java b/src/com/redstoner/modules/chatalias/Chatalias.java index 0e5f0b3..b00e715 100644 --- a/src/com/redstoner/modules/chatalias/Chatalias.java +++ b/src/com/redstoner/modules/chatalias/Chatalias.java @@ -11,6 +11,7 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.player.AsyncPlayerChatEvent; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.permissions.PermissionAttachmentInfo; @@ -25,7 +26,7 @@ import com.redstoner.misc.Utils; import com.redstoner.modules.Module; @AutoRegisterListener -@Version(major = 1, minor = 0, revision = 6, compatible = 1) +@Version(major = 1, minor = 0, revision = 7, compatible = 1) public class Chatalias implements Module, Listener { // to export chatalias data to json: @@ -33,8 +34,8 @@ public class Chatalias implements Module, Listener // HANDLE WITH CARE! This will create an array of null entries the size of len(data)! private boolean enabled = false; @SuppressWarnings("unused") - private final String[] commands = new String[] {"e?r", "e?m", "e?t", "e?w", "e?msg", "e?message", "e?whisper", - "e?me", "cg say", "ac"}; + private final String[] commands = new String[] {"e?r", "e?m .+? ", "e?t", "e?w", "e?msg .+? ", "e?message .+? ", + "e?whisper .+? ", "e?me", "cg say", "ac"}; private JSONObject defaults = new JSONObject(); private JSONObject aliases = new JSONObject(); @@ -44,7 +45,7 @@ public class Chatalias implements Module, Listener { defaults.put("dataFormat", "v1"); JSONObject data = new JSONObject(); - data.put("R: ^(([^\\w]|_)\\/|\\\\)", "\\/"); + data.put("N: ./", "/"); defaults.put("data", data); for (Player p : Bukkit.getOnlinePlayers()) { @@ -130,65 +131,71 @@ public class Chatalias implements Module, Listener saveAliases(uuid); } - // @EventHandler - // public void onPlayerCommand(PlayerCommandPreprocessEvent event) - // { - // if (event.isCancelled()) - // return; - // boolean listening = false; - // for (String s : commands) - // { - // if (event.getMessage().matches("^/.*:" + s)) - // { - // listening = true; - // break; - // } - // } - // if (!listening) - // return; - // Player player = event.getPlayer(); - // UUID uuid = player.getUniqueId(); - // JSONObject playerAliases = (JSONObject) aliases.get(uuid.toString()); - // String command = event.getMessage().split(" ")[0]; - // event.setMessage(event.getMessage().replace(command, "")); - // for (Object key : playerAliases.keySet()) - // { - // String keyword = (String) key; - // String replacement = (String) playerAliases.get(key); - // if (keyword.startsWith("R: ")) - // { - // keyword = keyword.replace("R: ", ""); - // event.setMessage(event.getMessage().replaceAll(keyword, replacement)); - // } - // else - // { - // if (keyword.startsWith("N: ")) - // keyword = keyword.replace("N: ", ""); - // event.setMessage(event.getMessage().replace(keyword, replacement)); - // } - // int maxLength; - // try - // { - // maxLength = Integer.valueOf(getPermissionContent(player, "utils.alias.length.")); - // } - // catch (NumberFormatException e) - // { - // maxLength = 255; - // } - // if (event.getMessage().length() > maxLength) - // { - // Utils.sendErrorMessage(player, null, "The generated message is too long!"); - // event.setCancelled(true); - // return; - // } - // } - // event.setMessage(command + event.getMessage()); - // } + @EventHandler(priority = EventPriority.LOWEST) + public void onPlayerCommand(PlayerCommandPreprocessEvent event) + { + if (event.isCancelled()) + return; + boolean listening = false; + String regex = ""; + for (String s : commands) + { + regex = "^\\/(.*:)?" + s + ".*"; + if (event.getMessage().matches(regex)) + { + listening = true; + break; + } + } + if (!listening) + return; + Player player = event.getPlayer(); + UUID uuid = player.getUniqueId(); + JSONObject playerAliases = (JSONObject) aliases.get(uuid.toString()); + String command = event.getMessage().replaceAll(regex.replaceAll("\\.\\*$", ""), ""); + command = event.getMessage().replace(command, ""); + event.setMessage(event.getMessage().replace(command, "§§")); + Utils.log(event.getMessage()); + for (Object key : playerAliases.keySet()) + { + String keyword = (String) key; + String replacement = (String) playerAliases.get(key); + if (keyword.startsWith("R: ")) + { + keyword = keyword.replace("R: ", ""); + event.setMessage(event.getMessage().replaceAll(keyword, replacement)); + } + else + { + if (keyword.startsWith("N: ")) + keyword = keyword.replace("N: ", ""); + event.setMessage(event.getMessage().replace(keyword, replacement)); + } + int maxLength; + try + { + maxLength = Integer.valueOf(getPermissionContent(player, "utils.alias.length.")); + } + catch (NumberFormatException e) + { + maxLength = 255; + } + if (event.getMessage().length() > maxLength) + { + Utils.sendErrorMessage(player, null, "The generated message is too long!"); + event.setCancelled(true); + return; + } + } + event.setMessage(command + event.getMessage().substring(2)); + Utils.log(event.getMessage()); + } + @SuppressWarnings("unchecked") @Command(hook = "addalias") public boolean addAlias(CommandSender sender, boolean regex, String keyword, String replacement) { - if (keyword.equals(".*")) + if (regex && keyword.equals(".*")) { Utils.sendErrorMessage(sender, null, "You may not define the wildcard regex as an alias."); return true; @@ -290,7 +297,7 @@ public class Chatalias implements Module, Listener { for (Object key : playerAliases.keySet()) { - tempAliases.put(key, "N: " + playerAliases.get(key)); + tempAliases.put("N: " + key, playerAliases.get(key)); } } temp.put("data", tempAliases); -- 2.45.2 From 7883bc28310fda7633a9569e34772266ecd09a6c Mon Sep 17 00:00:00 2001 From: Pepich Date: Sat, 18 Feb 2017 17:15:52 +0100 Subject: [PATCH 010/152] Fixed a bug allowing people to modify the default alias set --- .../redstoner/modules/chatalias/Chatalias.java | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/com/redstoner/modules/chatalias/Chatalias.java b/src/com/redstoner/modules/chatalias/Chatalias.java index b00e715..4e5e705 100644 --- a/src/com/redstoner/modules/chatalias/Chatalias.java +++ b/src/com/redstoner/modules/chatalias/Chatalias.java @@ -26,27 +26,21 @@ import com.redstoner.misc.Utils; import com.redstoner.modules.Module; @AutoRegisterListener -@Version(major = 1, minor = 0, revision = 7, compatible = 1) +@Version(major = 1, minor = 1, revision = 0, compatible = 1) public class Chatalias implements Module, Listener { // to export chatalias data to json: // pyeval [save_json_file("aliases/" + uuid, shared['modules']['chatalias'].data[uuid]) for uuid in shared['modules']['chatalias'].data] // HANDLE WITH CARE! This will create an array of null entries the size of len(data)! private boolean enabled = false; - @SuppressWarnings("unused") private final String[] commands = new String[] {"e?r", "e?m .+? ", "e?t", "e?w", "e?msg .+? ", "e?message .+? ", "e?whisper .+? ", "e?me", "cg say", "ac"}; - private JSONObject defaults = new JSONObject(); private JSONObject aliases = new JSONObject(); @SuppressWarnings("unchecked") @Override public void onEnable() { - defaults.put("dataFormat", "v1"); - JSONObject data = new JSONObject(); - data.put("N: ./", "/"); - defaults.put("data", data); for (Player p : Bukkit.getOnlinePlayers()) { loadAliases(p.getUniqueId()); @@ -282,11 +276,16 @@ public class Chatalias implements Module, Listener @SuppressWarnings("unchecked") private void loadAliases(UUID uuid) { + JSONObject defaults = new JSONObject(); + defaults.put("dataFormat", "v1"); + JSONObject data = new JSONObject(); + data.put("N: ./", "/"); + defaults.put("data", data); JSONObject playerAliases = JsonManager .getObject(new File(Main.plugin.getDataFolder(), "aliases/" + uuid.toString() + ".json")); if (playerAliases == null) { - playerAliases = (JSONObject) defaults.clone(); + playerAliases = defaults; } String dataFormat = (String) playerAliases.get("dataFormat"); if (dataFormat == null) -- 2.45.2 From 4978c47d5111ee3d7cb3999b346155ce8151c536 Mon Sep 17 00:00:00 2001 From: Pepich Date: Sat, 18 Feb 2017 17:20:13 +0100 Subject: [PATCH 011/152] Fixed a bug where webtoken could not generate new tokens --- .../redstoner/modules/webtoken/WebToken.java | 29 +++++++++++++++++-- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/src/com/redstoner/modules/webtoken/WebToken.java b/src/com/redstoner/modules/webtoken/WebToken.java index 5ad6632..c8b5c59 100644 --- a/src/com/redstoner/modules/webtoken/WebToken.java +++ b/src/com/redstoner/modules/webtoken/WebToken.java @@ -22,7 +22,7 @@ import com.redstoner.misc.mysql.elements.MysqlDatabase; import com.redstoner.misc.mysql.elements.MysqlTable; import com.redstoner.modules.Module; -@Version(major = 1, minor = 0, revision = 0, compatible = 1) +@Version(major = 1, minor = 1, revision = 0, compatible = 1) public class WebToken implements Module { private boolean enabled = false; @@ -67,6 +67,28 @@ public class WebToken implements Module enabled = true; } + private String getNextId() throws Exception + { + Object[] results = table.get("select id from register_tokens order by id desc limit 1;"); + if (results instanceof String[]) + { + String[] tokenResults = (String[]) results; + if (tokenResults.length == 1) + { + int id = Integer.valueOf(tokenResults[0]); + return "" + ++id; + } + else + { + return null; + } + } + else + { + throw new Exception("Token query returned invalid result!"); + } + } + private String query(String emailOrToken, UUID uuid) throws Exception { if (!(emailOrToken.equals("token") && emailOrToken.equals("email"))) @@ -164,8 +186,9 @@ public class WebToken implements Module String token = generateToken(); try { + String id = getNextId(); table.delete(new MysqlConstraint("uuid", ConstraintOperator.EQUAL, uuid)); - table.insert(uuid, token, email); + table.insert(id, uuid, token, email); player.sendMessage(ChatColor.GREEN + "Token generated!"); printToken(player, email, token); } @@ -215,7 +238,7 @@ public class WebToken implements Module " help Generates a token used for website authentication;\n" + " type player;\n" + " perm utils.webtoken;\n" + - " run gettoken;\n" + + " run gettoken email;\n" + " }\n" + "}"; } -- 2.45.2 From aeb6be68414957595edb2c23752fc7608fdcb182 Mon Sep 17 00:00:00 2001 From: Pepich Date: Sat, 18 Feb 2017 18:05:53 +0100 Subject: [PATCH 012/152] Idk what I changed but for some reason it looks like I gotta commit? ._. --- src/com/redstoner/coremods/moduleLoader/ModuleLoader.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java b/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java index 5a305b1..accb85e 100644 --- a/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java +++ b/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java @@ -82,6 +82,7 @@ public final class ModuleLoader implements CoreModule catch (Exception e) { Utils.error("Failed to load module " + module.getClass().getName()); + e.printStackTrace(); } } } -- 2.45.2 From 634da4a59d1cb2d68e4e840bdcea9857755b4cc2 Mon Sep 17 00:00:00 2001 From: Pepich Date: Sat, 18 Feb 2017 18:06:19 +0100 Subject: [PATCH 013/152] Removed unnecessary SuppressWarnings --- src/com/redstoner/modules/chatalias/Chatalias.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/com/redstoner/modules/chatalias/Chatalias.java b/src/com/redstoner/modules/chatalias/Chatalias.java index 4e5e705..ecaf531 100644 --- a/src/com/redstoner/modules/chatalias/Chatalias.java +++ b/src/com/redstoner/modules/chatalias/Chatalias.java @@ -26,7 +26,7 @@ import com.redstoner.misc.Utils; import com.redstoner.modules.Module; @AutoRegisterListener -@Version(major = 1, minor = 1, revision = 0, compatible = 1) +@Version(major = 1, minor = 1, revision = 1, compatible = 1) public class Chatalias implements Module, Listener { // to export chatalias data to json: @@ -37,7 +37,6 @@ public class Chatalias implements Module, Listener "e?whisper .+? ", "e?me", "cg say", "ac"}; private JSONObject aliases = new JSONObject(); - @SuppressWarnings("unchecked") @Override public void onEnable() { -- 2.45.2 From 04c4806dadd4a1c64c4a5c3ba9b316d3b910c93e Mon Sep 17 00:00:00 2001 From: Pepich Date: Sat, 18 Feb 2017 18:11:59 +0100 Subject: [PATCH 014/152] Added version, ran formatted, removed TODO comment --- src/com/redstoner/modules/naming/Naming.java | 74 ++++++++++++-------- 1 file changed, 45 insertions(+), 29 deletions(-) diff --git a/src/com/redstoner/modules/naming/Naming.java b/src/com/redstoner/modules/naming/Naming.java index acbc05c..04dcc1c 100644 --- a/src/com/redstoner/modules/naming/Naming.java +++ b/src/com/redstoner/modules/naming/Naming.java @@ -10,6 +10,7 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; import com.nemez.cmdmgr.Command; +import com.redstoner.annotations.Version; import com.redstoner.misc.Utils; import com.redstoner.modules.Module; @@ -21,25 +22,29 @@ import net.minecraft.server.v1_11_R1.EntityHuman; import net.minecraft.server.v1_11_R1.EntityPlayer; import net.minecraft.server.v1_11_R1.PacketPlayOutOpenWindow; -public class Naming implements Module{ - +@Version(major = 1, minor = 0, revision = 1, compatible = 1) +public class Naming implements Module +{ boolean enabled = false; @Command(hook = "anvil") - public void anvil(CommandSender sender) { + public void anvil(CommandSender sender) + { EntityPlayer p = ((CraftPlayer) sender).getHandle(); - AnvilContainer container = new AnvilContainer(p); - int c = p.nextContainerCounter(); - p.playerConnection.sendPacket(new PacketPlayOutOpenWindow(c,"minecraft:anvil",new ChatMessage("Repairing",new Object[]{}),0)); - p.activeContainer = container; - p.activeContainer.windowId = c; - p.activeContainer.addSlotListener(p); + AnvilContainer container = new AnvilContainer(p); + int c = p.nextContainerCounter(); + p.playerConnection.sendPacket( + new PacketPlayOutOpenWindow(c, "minecraft:anvil", new ChatMessage("Repairing", new Object[] {}), 0)); + p.activeContainer = container; + p.activeContainer.windowId = c; + p.activeContainer.addSlotListener(p); } @Command(hook = "name") - public void name(CommandSender sender, String name){ + public void name(CommandSender sender, String name) + { name = ChatColor.translateAlternateColorCodes('&', name); - ItemStack item = ((Player)sender).getInventory().getItemInMainHand(); + ItemStack item = ((Player) sender).getInventory().getItemInMainHand(); ItemMeta meta = item.getItemMeta(); meta.setDisplayName(name); item.setItemMeta(meta); @@ -47,11 +52,12 @@ public class Naming implements Module{ } @Command(hook = "lore") - public void lore(CommandSender sender, String name){ + public void lore(CommandSender sender, String name) + { List lore = new ArrayList(); name = ChatColor.translateAlternateColorCodes('&', name); lore.add(name); - ItemStack item = ((Player)sender).getInventory().getItemInMainHand(); + ItemStack item = ((Player) sender).getInventory().getItemInMainHand(); ItemMeta meta = item.getItemMeta(); meta.setLore(lore); item.setItemMeta(meta); @@ -59,31 +65,41 @@ public class Naming implements Module{ Utils.sendMessage(sender, null, "Lore set to " + name); } - public class AnvilContainer extends ContainerAnvil { - public AnvilContainer(EntityHuman entity) { - super(entity.inventory, entity.world, new BlockPosition(0, 0, 0), entity); - } - public boolean a(EntityHuman entityhuman) { - return true; - } - } - @Override - public void onEnable() { - enabled = true; + public class AnvilContainer extends ContainerAnvil + { + public AnvilContainer(EntityHuman entity) + { + super(entity.inventory, entity.world, new BlockPosition(0, 0, 0), entity); + } + @Override + public boolean a(EntityHuman entityhuman) + { + return true; + } } + @Override - public void onDisable() { + public void onEnable() + { + enabled = true; + } + + @Override + public void onDisable() + { enabled = false; } + @Override - public boolean enabled() { + public boolean enabled() + { return enabled; } - + + // @noformat @Override public String getCommandString() { - // TODO Auto-generated method stub return "command anvil {\n" + " [empty] {\n" + " run anvil;\n" + @@ -111,5 +127,5 @@ public class Naming implements Module{ " }\n" + "}"; } - + // @format } -- 2.45.2 From 1f20c06e91dc51a1a21b19fefdb1eda713ea5ce1 Mon Sep 17 00:00:00 2001 From: Pepich Date: Sat, 18 Feb 2017 18:13:00 +0100 Subject: [PATCH 015/152] Ran formatter, removed unnecessary newline in cmdstring --- .../modules/illumination/Illumination.java | 35 +++++++++++-------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/src/com/redstoner/modules/illumination/Illumination.java b/src/com/redstoner/modules/illumination/Illumination.java index 5404a30..cef40c2 100644 --- a/src/com/redstoner/modules/illumination/Illumination.java +++ b/src/com/redstoner/modules/illumination/Illumination.java @@ -10,42 +10,47 @@ import com.redstoner.annotations.Version; import com.redstoner.misc.Utils; import com.redstoner.modules.Module; -@Version(major = 1, minor = 0, revision = 0, compatible = 1) -public class Illumination implements Module{ - +@Version(major = 1, minor = 0, revision = 1, compatible = 1) +public class Illumination implements Module +{ boolean enabled = false; PotionEffect effect = new PotionEffect(PotionEffectType.NIGHT_VISION, Integer.MAX_VALUE, 0, false, false); @Command(hook = "illuminate") - public void illuminate(CommandSender sender) { + public void illuminate(CommandSender sender) + { Player player = (Player) sender; - if(player.hasPotionEffect(PotionEffectType.NIGHT_VISION)) { + if (player.hasPotionEffect(PotionEffectType.NIGHT_VISION)) + { player.removePotionEffect(PotionEffectType.NIGHT_VISION); Utils.sendMessage(sender, null, "Night Vision Disabled."); } - else { + else + { player.addPotionEffect(effect, true); Utils.sendMessage(sender, null, "Night Vision Enabled."); } } @Override - public void onEnable() { + public void onEnable() + { enabled = true; - } - + @Override - public void onDisable() { + public void onDisable() + { enabled = false; - } - + @Override - public boolean enabled() { + public boolean enabled() + { return enabled; } - + + // @noformat @Override public String getCommandString() { return "command nightvision {\n" + @@ -56,7 +61,7 @@ public class Illumination implements Module{ " perm utils.illuminate;\n" + " }\n" + "}\n" + - "\n" + "}"; } + // @format } -- 2.45.2 From becdd677d18964ef4f88b85da7c45785e6a172bb Mon Sep 17 00:00:00 2001 From: Pepich Date: Sat, 18 Feb 2017 18:14:08 +0100 Subject: [PATCH 016/152] Ran formatter --- .../modules/clearonjoin/ClearOnJoin.java | 50 ++++++++++++------- 1 file changed, 31 insertions(+), 19 deletions(-) diff --git a/src/com/redstoner/modules/clearonjoin/ClearOnJoin.java b/src/com/redstoner/modules/clearonjoin/ClearOnJoin.java index 12affd2..bd93561 100644 --- a/src/com/redstoner/modules/clearonjoin/ClearOnJoin.java +++ b/src/com/redstoner/modules/clearonjoin/ClearOnJoin.java @@ -11,30 +11,35 @@ import org.bukkit.event.player.PlayerJoinEvent; import org.json.simple.JSONArray; import com.nemez.cmdmgr.Command; +import com.redstoner.annotations.Version; import com.redstoner.misc.JsonManager; import com.redstoner.misc.Main; import com.redstoner.misc.Utils; import com.redstoner.modules.Module; -public class ClearOnJoin implements Module, Listener{ - +@Version(major = 1, minor = 0, revision = 0, compatible = 1) +public class ClearOnJoin implements Module, Listener +{ boolean enabled = false; private File listLocation = new File(Main.plugin.getDataFolder(), "clearonjoins.json"); private JSONArray list; @SuppressWarnings("unchecked") @Command(hook = "clearonjoin") - public void clearOnJoin(CommandSender sender, String player) { + public void clearOnJoin(CommandSender sender, String player) + { list.add("!" + player.toLowerCase()); saveList(); - Utils.sendMessage(sender, null, player +"'s inventory will be cleared next time he joins."); + Utils.sendMessage(sender, null, player + "'s inventory will be cleared next time he joins."); } @SuppressWarnings("unchecked") @Command(hook = "clearonjoinself") - public void clearOnJoinSelf(CommandSender sender) { + public void clearOnJoinSelf(CommandSender sender) + { String name = sender.getName().toLowerCase(); - if(list.contains(name)) { + if (list.contains(name)) + { list.remove(name); Utils.sendMessage(sender, null, "Your inventory will no longer be cleared apon joining"); saveList(); @@ -47,14 +52,16 @@ public class ClearOnJoin implements Module, Listener{ @EventHandler public void aponJoin(PlayerJoinEvent e) - { + { Player player = e.getPlayer(); String playerName = player.getName().toLowerCase(); - if(list.contains(playerName)) { + if (list.contains(playerName)) + { e.getPlayer().getInventory().clear(); Utils.sendMessage(e.getPlayer(), null, "Inventory Cleared."); } - else if(list.contains("!" + playerName)){ + else if (list.contains("!" + playerName)) + { e.getPlayer().getInventory().clear(); list.remove("!" + playerName); saveList(); @@ -68,27 +75,32 @@ public class ClearOnJoin implements Module, Listener{ } @Override - public void onEnable() { + public void onEnable() + { enabled = true; list = JsonManager.getArray(listLocation); - if (list == null) list = new JSONArray(); + if (list == null) + list = new JSONArray(); Bukkit.getServer().getPluginManager().registerEvents(this, Main.plugin); } - + @Override - public void onDisable() { + public void onDisable() + { saveList(); enabled = false; - } - + @Override - public boolean enabled() { + public boolean enabled() + { return enabled; } - + + // @noformat @Override - public String getCommandString() { + public String getCommandString() + { return "command clearonjoin {\n" + " [string:name] {\n" + " help Clears that players inventory the nect time they join.;\n" + @@ -102,5 +114,5 @@ public class ClearOnJoin implements Module, Listener{ " }\n" + "}"; } - + // @format } -- 2.45.2 From 4bb5a4c5843474a526a2d6b352192a2db9a11048 Mon Sep 17 00:00:00 2001 From: Pepich Date: Sat, 18 Feb 2017 18:14:37 +0100 Subject: [PATCH 017/152] Fixed cmdstring --- src/com/redstoner/modules/illumination/Illumination.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/com/redstoner/modules/illumination/Illumination.java b/src/com/redstoner/modules/illumination/Illumination.java index cef40c2..97073b8 100644 --- a/src/com/redstoner/modules/illumination/Illumination.java +++ b/src/com/redstoner/modules/illumination/Illumination.java @@ -10,7 +10,7 @@ import com.redstoner.annotations.Version; import com.redstoner.misc.Utils; import com.redstoner.modules.Module; -@Version(major = 1, minor = 0, revision = 1, compatible = 1) +@Version(major = 1, minor = 0, revision = 2, compatible = 1) public class Illumination implements Module { boolean enabled = false; @@ -52,7 +52,8 @@ public class Illumination implements Module // @noformat @Override - public String getCommandString() { + public String getCommandString() + { return "command nightvision {\n" + " [empty] {\n" + " run illuminate;\n" + @@ -60,7 +61,6 @@ public class Illumination implements Module " help Gives the player infinte night vision;\n" + " perm utils.illuminate;\n" + " }\n" + - "}\n" + "}"; } // @format -- 2.45.2 From 32ab517ac7fd5a2cd27f84cb5ba0c25114372613 Mon Sep 17 00:00:00 2001 From: Pepich Date: Sat, 18 Feb 2017 18:15:32 +0100 Subject: [PATCH 018/152] Removed unnecessary newlines from cmdstring --- src/com/redstoner/modules/naming/Naming.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/com/redstoner/modules/naming/Naming.java b/src/com/redstoner/modules/naming/Naming.java index 04dcc1c..774f5b2 100644 --- a/src/com/redstoner/modules/naming/Naming.java +++ b/src/com/redstoner/modules/naming/Naming.java @@ -22,7 +22,7 @@ import net.minecraft.server.v1_11_R1.EntityHuman; import net.minecraft.server.v1_11_R1.EntityPlayer; import net.minecraft.server.v1_11_R1.PacketPlayOutOpenWindow; -@Version(major = 1, minor = 0, revision = 1, compatible = 1) +@Version(major = 1, minor = 0, revision = 2, compatible = 1) public class Naming implements Module { boolean enabled = false; @@ -99,7 +99,8 @@ public class Naming implements Module // @noformat @Override - public String getCommandString() { + public String getCommandString() + { return "command anvil {\n" + " [empty] {\n" + " run anvil;\n" + @@ -108,7 +109,6 @@ public class Naming implements Module " perm utils.anvil;\n" + " }\n" + "}\n" + - "\n" + "command name {\n" + " [string:name...] {\n" + " run name name;\n" + @@ -117,7 +117,6 @@ public class Naming implements Module " perm utils.name;\n" + " }\n" + "}\n" + - "\n" + "command lore {\n" + " [string:name...] {\n" + " run lore name;\n" + -- 2.45.2 From 57767aab0f18a935f1561d2417fd4031c324fe1d Mon Sep 17 00:00:00 2001 From: Pepich Date: Sat, 18 Feb 2017 18:31:12 +0100 Subject: [PATCH 019/152] Fixed NPE when no challenges are defined --- src/com/redstoner/modules/challenge/Challenge.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/com/redstoner/modules/challenge/Challenge.java b/src/com/redstoner/modules/challenge/Challenge.java index d9280ad..cb97b06 100644 --- a/src/com/redstoner/modules/challenge/Challenge.java +++ b/src/com/redstoner/modules/challenge/Challenge.java @@ -13,7 +13,7 @@ import com.redstoner.misc.Main; import com.redstoner.misc.Utils; import com.redstoner.modules.Module; -@Version(major = 1, minor = 0, revision = 0, compatible = 1) +@Version(major = 1, minor = 0, revision = 1, compatible = 1) public class Challenge implements Module { private boolean enabled = false; @@ -79,7 +79,8 @@ public class Challenge implements Module Utils.sendErrorMessage(sender, null, "The ID must be at least 0 and at most " + challenges.size()); return true; } - Utils.sendMessage(sender, null, "Successfully changed the challenge: &a" + challenges.get(id) + " &7to: &e" + text, '&'); + Utils.sendMessage(sender, null, + "Successfully changed the challenge: &a" + challenges.get(id) + " &7to: &e" + text, '&'); challenges.set(id, text); saveChallenges(); return true; @@ -100,6 +101,11 @@ public class Challenge implements Module @Command(hook = "challenge") public boolean challenge(CommandSender sender) { + if (challenges.size() == 0) + { + Utils.sendErrorMessage(sender, null, "There are no challenges yet!"); + return true; + } int id = (new Random()).nextInt(challenges.size()); Utils.sendMessage(sender, null, challenges.get(id) + "", '&'); return true; -- 2.45.2 From e18501417d084a1decc07befcfc3b87bc6df2b81 Mon Sep 17 00:00:00 2001 From: Pepich Date: Sat, 18 Feb 2017 18:32:15 +0100 Subject: [PATCH 020/152] Fixed NPE when there's no lols defined --- src/com/redstoner/modules/saylol/Saylol.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/com/redstoner/modules/saylol/Saylol.java b/src/com/redstoner/modules/saylol/Saylol.java index e85ebc4..80640e9 100644 --- a/src/com/redstoner/modules/saylol/Saylol.java +++ b/src/com/redstoner/modules/saylol/Saylol.java @@ -15,7 +15,7 @@ import com.redstoner.misc.Main; import com.redstoner.misc.Utils; import com.redstoner.modules.Module; -@Version(major = 1, minor = 0, revision = 3, compatible = 1) +@Version(major = 1, minor = 0, revision = 4, compatible = 1) public class Saylol implements Module { private long lastLol = 0; @@ -123,6 +123,11 @@ public class Saylol implements Module @Command(hook = "saylol") public boolean saylol(CommandSender sender) { + if (lols.size() == 0) + { + Utils.sendErrorMessage(sender, null, "There are no lols yet!"); + return true; + } long time = System.currentTimeMillis(); if (time - lastLol < 15000) { -- 2.45.2 From c0ffbedda8a555853ea1818e24e6acd3b5edfaff Mon Sep 17 00:00:00 2001 From: Pepich Date: Sat, 18 Feb 2017 18:34:13 +0100 Subject: [PATCH 021/152] Fixed NPE for /name and /lore --- src/com/redstoner/modules/naming/Naming.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/com/redstoner/modules/naming/Naming.java b/src/com/redstoner/modules/naming/Naming.java index 774f5b2..11be1a1 100644 --- a/src/com/redstoner/modules/naming/Naming.java +++ b/src/com/redstoner/modules/naming/Naming.java @@ -22,7 +22,7 @@ import net.minecraft.server.v1_11_R1.EntityHuman; import net.minecraft.server.v1_11_R1.EntityPlayer; import net.minecraft.server.v1_11_R1.PacketPlayOutOpenWindow; -@Version(major = 1, minor = 0, revision = 2, compatible = 1) +@Version(major = 1, minor = 0, revision = 3, compatible = 1) public class Naming implements Module { boolean enabled = false; @@ -46,6 +46,11 @@ public class Naming implements Module name = ChatColor.translateAlternateColorCodes('&', name); ItemStack item = ((Player) sender).getInventory().getItemInMainHand(); ItemMeta meta = item.getItemMeta(); + if (meta == null) + { + Utils.sendErrorMessage(sender, null, "You can not rename that item!"); + return; + } meta.setDisplayName(name); item.setItemMeta(meta); Utils.sendMessage(sender, null, "Name set to " + name); @@ -59,6 +64,11 @@ public class Naming implements Module lore.add(name); ItemStack item = ((Player) sender).getInventory().getItemInMainHand(); ItemMeta meta = item.getItemMeta(); + if (meta == null) + { + Utils.sendErrorMessage(sender, null, "You can not change the lore of that item!"); + return; + } meta.setLore(lore); item.setItemMeta(meta); item.getItemMeta().setLore(lore); -- 2.45.2 From efadb07df5750e3fe6d3dd357ee606a8e031f404 Mon Sep 17 00:00:00 2001 From: Pepich Date: Sat, 18 Feb 2017 18:39:40 +0100 Subject: [PATCH 022/152] Fixed some formatting/counting mistakes --- src/com/redstoner/modules/saylol/Saylol.java | 23 ++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/com/redstoner/modules/saylol/Saylol.java b/src/com/redstoner/modules/saylol/Saylol.java index 80640e9..1966e26 100644 --- a/src/com/redstoner/modules/saylol/Saylol.java +++ b/src/com/redstoner/modules/saylol/Saylol.java @@ -15,7 +15,7 @@ import com.redstoner.misc.Main; import com.redstoner.misc.Utils; import com.redstoner.modules.Module; -@Version(major = 1, minor = 0, revision = 4, compatible = 1) +@Version(major = 1, minor = 0, revision = 5, compatible = 1) public class Saylol implements Module { private long lastLol = 0; @@ -63,9 +63,14 @@ public class Saylol implements Module @Command(hook = "dellol") public boolean delLol(CommandSender sender, int id) { + if (lols.size() == 0) + { + Utils.sendErrorMessage(sender, null, "There are no lols yet!"); + return true; + } if (id < 0 || id >= lols.size()) { - Utils.sendErrorMessage(sender, null, "The ID must be at least 0 and at most " + lols.size()); + Utils.sendErrorMessage(sender, null, "The ID must be at least 0 and at most " + (lols.size() - 1)); return true; } Utils.sendMessage(sender, null, "Successfully deleted the lol: " + lols.remove(id), '&'); @@ -77,9 +82,14 @@ public class Saylol implements Module @Command(hook = "setlol") public boolean setLol(CommandSender sender, int id, String text) { + if (lols.size() == 0) + { + Utils.sendErrorMessage(sender, null, "There are no lols yet!"); + return true; + } if (id < 0 || id >= lols.size()) { - Utils.sendErrorMessage(sender, null, "The ID must be at least 0 and at most " + lols.size()); + Utils.sendErrorMessage(sender, null, "The ID must be at least 0 and at most " + (lols.size() - 1)); return true; } Utils.sendMessage(sender, null, "Successfully changed the lol: &e" + lols.get(id) + " &7to: &e" + text, '&'); @@ -91,6 +101,11 @@ public class Saylol implements Module @Command(hook = "lolid") public boolean lolId(CommandSender sender, int id) { + if (lols.size() == 0) + { + Utils.sendErrorMessage(sender, null, "There are no lols yet!"); + return true; + } long time = System.currentTimeMillis(); if (time - lastLol < 15000) { @@ -100,7 +115,7 @@ public class Saylol implements Module } if (id < 0 || id >= lols.size()) { - Utils.sendErrorMessage(sender, null, "The ID must be at least 0 and at most " + lols.size()); + Utils.sendErrorMessage(sender, null, "The ID must be at least 0 and at most " + (lols.size() - 1)); return true; } String name; -- 2.45.2 From 323abffb5e8dcca1fc8735fd29483913f0bb050a Mon Sep 17 00:00:00 2001 From: Pepich Date: Sat, 18 Feb 2017 18:41:13 +0100 Subject: [PATCH 023/152] Made error messages consistant --- src/com/redstoner/modules/saylol/Saylol.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/com/redstoner/modules/saylol/Saylol.java b/src/com/redstoner/modules/saylol/Saylol.java index 1966e26..0b1e327 100644 --- a/src/com/redstoner/modules/saylol/Saylol.java +++ b/src/com/redstoner/modules/saylol/Saylol.java @@ -15,7 +15,7 @@ import com.redstoner.misc.Main; import com.redstoner.misc.Utils; import com.redstoner.modules.Module; -@Version(major = 1, minor = 0, revision = 5, compatible = 1) +@Version(major = 1, minor = 0, revision = 6, compatible = 1) public class Saylol implements Module { private long lastLol = 0; @@ -172,6 +172,11 @@ public class Saylol implements Module @Command(hook = "listlols") public boolean listLols(CommandSender sender, int page) { + if (lols.size() == 0) + { + Utils.sendErrorMessage(sender, null, "There are no lols yet!"); + return true; + } page = page - 1; int start = page * 10; int end = start + 10; -- 2.45.2 From 0481ed52fea87f25e1bda6cd7279b6de90c88a0f Mon Sep 17 00:00:00 2001 From: Pepich Date: Sat, 18 Feb 2017 18:41:36 +0100 Subject: [PATCH 024/152] Fixed counting/error messages --- .../modules/challenge/Challenge.java | 26 ++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/src/com/redstoner/modules/challenge/Challenge.java b/src/com/redstoner/modules/challenge/Challenge.java index cb97b06..61f3af4 100644 --- a/src/com/redstoner/modules/challenge/Challenge.java +++ b/src/com/redstoner/modules/challenge/Challenge.java @@ -13,7 +13,7 @@ import com.redstoner.misc.Main; import com.redstoner.misc.Utils; import com.redstoner.modules.Module; -@Version(major = 1, minor = 0, revision = 1, compatible = 1) +@Version(major = 1, minor = 0, revision = 2, compatible = 1) public class Challenge implements Module { private boolean enabled = false; @@ -60,9 +60,14 @@ public class Challenge implements Module @Command(hook = "delchallenge") public boolean delChallenge(CommandSender sender, int id) { + if (challenges.size() == 0) + { + Utils.sendErrorMessage(sender, null, "There are no challenges yet!"); + return true; + } if (id < 0 || id >= challenges.size()) { - Utils.sendErrorMessage(sender, null, "The ID must be at least 0 and at most " + challenges.size()); + Utils.sendErrorMessage(sender, null, "The ID must be at least 0 and at most " + (challenges.size() - 1)); return true; } Utils.sendMessage(sender, null, "Successfully deleted the challenge: " + challenges.remove(id), '&'); @@ -74,9 +79,14 @@ public class Challenge implements Module @Command(hook = "setchallenge") public boolean setChallenge(CommandSender sender, int id, String text) { + if (challenges.size() == 0) + { + Utils.sendErrorMessage(sender, null, "There are no challenges yet!"); + return true; + } if (id < 0 || id >= challenges.size()) { - Utils.sendErrorMessage(sender, null, "The ID must be at least 0 and at most " + challenges.size()); + Utils.sendErrorMessage(sender, null, "The ID must be at least 0 and at most " + (challenges.size() - 1)); return true; } Utils.sendMessage(sender, null, @@ -89,6 +99,11 @@ public class Challenge implements Module @Command(hook = "challengeid") public boolean challengeId(CommandSender sender, int id) { + if (challenges.size() == 0) + { + Utils.sendErrorMessage(sender, null, "There are no challenges yet!"); + return true; + } if (id < 0 || id >= challenges.size()) { Utils.sendErrorMessage(sender, null, "The ID must be at least 0 and at most " + (challenges.size() - 1)); @@ -114,6 +129,11 @@ public class Challenge implements Module @Command(hook = "listchallenges") public boolean listChallenges(CommandSender sender, int page) { + if (challenges.size() == 0) + { + Utils.sendErrorMessage(sender, null, "There are no challenges yet!"); + return true; + } page = page - 1; int start = page * 10; int end = start + 10; -- 2.45.2 From f511ab1a0c39364ba622eec95894cea853fcf32e Mon Sep 17 00:00:00 2001 From: Pepich Date: Sat, 18 Feb 2017 18:54:19 +0100 Subject: [PATCH 025/152] Removed %s from string --- src/com/redstoner/modules/scriptutils/Scriptutils.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/com/redstoner/modules/scriptutils/Scriptutils.java b/src/com/redstoner/modules/scriptutils/Scriptutils.java index 434b830..8d3ab40 100644 --- a/src/com/redstoner/modules/scriptutils/Scriptutils.java +++ b/src/com/redstoner/modules/scriptutils/Scriptutils.java @@ -8,7 +8,7 @@ import com.redstoner.annotations.Version; import com.redstoner.misc.Utils; import com.redstoner.modules.Module; -@Version(major = 1, minor = 0, revision = 0, compatible = 1) +@Version(major = 1, minor = 0, revision = 1, compatible = 1) public class Scriptutils implements Module { private boolean enabled = false; @@ -25,7 +25,7 @@ public class Scriptutils implements Module Utils.broadcast("", "§r", null); Utils.broadcast("", "§9" + name + " is restarting the server.", null); Utils.broadcast("", "§a§lServer is going to restart in " + timeout + " seconds.", null); - Utils.broadcast("", "§6§l%s" + reason, null); + Utils.broadcast("", "§6§l" + reason, null); Utils.broadcast("", "§r", null); Utils.broadcast("", "§r", null); Utils.broadcast("", "§2§l=============================================", null); -- 2.45.2 From 75a3885c4f361224ef8e800b117c324662a766fe Mon Sep 17 00:00:00 2001 From: Pepich Date: Sat, 18 Feb 2017 19:01:45 +0100 Subject: [PATCH 026/152] Removed debug output (again?!) --- src/com/redstoner/modules/chatalias/Chatalias.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/com/redstoner/modules/chatalias/Chatalias.java b/src/com/redstoner/modules/chatalias/Chatalias.java index ecaf531..51b7822 100644 --- a/src/com/redstoner/modules/chatalias/Chatalias.java +++ b/src/com/redstoner/modules/chatalias/Chatalias.java @@ -26,7 +26,7 @@ import com.redstoner.misc.Utils; import com.redstoner.modules.Module; @AutoRegisterListener -@Version(major = 1, minor = 1, revision = 1, compatible = 1) +@Version(major = 1, minor = 1, revision = 2, compatible = 1) public class Chatalias implements Module, Listener { // to export chatalias data to json: @@ -148,7 +148,6 @@ public class Chatalias implements Module, Listener String command = event.getMessage().replaceAll(regex.replaceAll("\\.\\*$", ""), ""); command = event.getMessage().replace(command, ""); event.setMessage(event.getMessage().replace(command, "§§")); - Utils.log(event.getMessage()); for (Object key : playerAliases.keySet()) { String keyword = (String) key; @@ -181,7 +180,6 @@ public class Chatalias implements Module, Listener } } event.setMessage(command + event.getMessage().substring(2)); - Utils.log(event.getMessage()); } @SuppressWarnings("unchecked") -- 2.45.2 From fc98fd6a01d15cff22154273a4d6bf4a3b7a9de5 Mon Sep 17 00:00:00 2001 From: Pepich Date: Sat, 18 Feb 2017 19:27:23 +0100 Subject: [PATCH 027/152] Added missing colorcode indicator --- src/com/redstoner/modules/check/Check.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/com/redstoner/modules/check/Check.java b/src/com/redstoner/modules/check/Check.java index 4a8bfc5..bebec13 100644 --- a/src/com/redstoner/modules/check/Check.java +++ b/src/com/redstoner/modules/check/Check.java @@ -31,7 +31,7 @@ import com.redstoner.misc.mysql.elements.MysqlDatabase; import com.redstoner.misc.mysql.elements.MysqlTable; import com.redstoner.modules.Module; -@Version(major = 1, minor = 0, revision = 5, compatible = 1) +@Version(major = 1, minor = 0, revision = 6, compatible = 1) public class Check implements Module, Listener { private boolean enabled = false; @@ -66,7 +66,7 @@ public class Check implements Module, Listener public void checkCommand(final CommandSender sender, final String player) { Utils.sendModuleHeader(sender); - Utils.sendMessage(sender, "", "&7Please notice that the data may not be fully accurate!"); + Utils.sendMessage(sender, "", "&7Please note that the data may not be fully accurate!", '&'); OfflinePlayer oPlayer; oPlayer = Bukkit.getPlayer(player); if (oPlayer == null) -- 2.45.2 From db2a8e18a317772f01e34dfbb04bbf98abb2cb08 Mon Sep 17 00:00:00 2001 From: Pepich Date: Wed, 1 Mar 2017 16:30:35 +0100 Subject: [PATCH 028/152] Fixed NPE --- src/com/redstoner/modules/chatgroups/Chatgroups.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/com/redstoner/modules/chatgroups/Chatgroups.java b/src/com/redstoner/modules/chatgroups/Chatgroups.java index 701a7e0..d90e826 100644 --- a/src/com/redstoner/modules/chatgroups/Chatgroups.java +++ b/src/com/redstoner/modules/chatgroups/Chatgroups.java @@ -26,7 +26,7 @@ import com.redstoner.modules.Module; * * @author Pepich */ @AutoRegisterListener -@Version(major = 1, minor = 2, revision = 2, compatible = 1) +@Version(major = 1, minor = 2, revision = 3, compatible = 1) public class Chatgroups implements Module, Listener { private static final char defaultKey = ':'; @@ -352,7 +352,7 @@ public class Chatgroups implements Module, Listener return false; } }); - if (!getGroup(Bukkit.getConsoleSender()).equals(group)) + if (getGroup(Bukkit.getConsoleSender()) == null || !getGroup(Bukkit.getConsoleSender()).equals(group)) { Utils.log(name + " in " + group + ": " + message + " §8(hidden)"); } -- 2.45.2 From 02d582f57e5bb4f103790810bb7c4a0d52e69140 Mon Sep 17 00:00:00 2001 From: Pepich Date: Thu, 2 Mar 2017 11:40:33 +0100 Subject: [PATCH 029/152] Added colors for everyone in chatgroups --- src/com/redstoner/modules/chatgroups/Chatgroups.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/com/redstoner/modules/chatgroups/Chatgroups.java b/src/com/redstoner/modules/chatgroups/Chatgroups.java index d90e826..48cdf05 100644 --- a/src/com/redstoner/modules/chatgroups/Chatgroups.java +++ b/src/com/redstoner/modules/chatgroups/Chatgroups.java @@ -26,7 +26,7 @@ import com.redstoner.modules.Module; * * @author Pepich */ @AutoRegisterListener -@Version(major = 1, minor = 2, revision = 3, compatible = 1) +@Version(major = 1, minor = 2, revision = 4, compatible = 1) public class Chatgroups implements Module, Listener { private static final char defaultKey = ':'; @@ -351,7 +351,7 @@ public class Chatgroups implements Module, Listener else return false; } - }); + }, '&'); if (getGroup(Bukkit.getConsoleSender()) == null || !getGroup(Bukkit.getConsoleSender()).equals(group)) { Utils.log(name + " in " + group + ": " + message + " §8(hidden)"); -- 2.45.2 From 54cd39f7f3772004459aa8c92df28593d4769149 Mon Sep 17 00:00:00 2001 From: Pepich Date: Thu, 2 Mar 2017 11:46:13 +0100 Subject: [PATCH 030/152] Added group join/leave messages --- .../modules/chatgroups/Chatgroups.java | 47 +++++++++++++++++-- 1 file changed, 42 insertions(+), 5 deletions(-) diff --git a/src/com/redstoner/modules/chatgroups/Chatgroups.java b/src/com/redstoner/modules/chatgroups/Chatgroups.java index 48cdf05..f9be5e1 100644 --- a/src/com/redstoner/modules/chatgroups/Chatgroups.java +++ b/src/com/redstoner/modules/chatgroups/Chatgroups.java @@ -26,7 +26,7 @@ import com.redstoner.modules.Module; * * @author Pepich */ @AutoRegisterListener -@Version(major = 1, minor = 2, revision = 4, compatible = 1) +@Version(major = 1, minor = 3, revision = 0, compatible = 1) public class Chatgroups implements Module, Listener { private static final char defaultKey = ':'; @@ -222,7 +222,12 @@ public class Chatgroups implements Module, Listener @Command(hook = "cgleave") public boolean cgLeave(CommandSender sender) { - removeGroup(sender); + String name; + if (sender instanceof Player) + name = ((Player) sender).getDisplayName(); + else + name = sender.getName(); + sendToGroup(removeGroup(sender), "&9" + name + " &7left the group!"); Utils.sendMessage(sender, null, "Successfully removed you from your group!"); cgtoggled.remove(((Player) sender).getUniqueId()); return true; @@ -236,6 +241,12 @@ public class Chatgroups implements Module, Listener @Command(hook = "cgjoin") public boolean cgJoin(CommandSender sender, String name) { + String pname; + if (sender instanceof Player) + pname = ((Player) sender).getDisplayName(); + else + pname = sender.getName(); + sendToGroup(name, "&9" + pname + " &7joined the group!"); setGroup(sender, name); Utils.sendMessage(sender, null, "Successfully joined group §6" + name); return true; @@ -309,13 +320,15 @@ public class Chatgroups implements Module, Listener /** Removes a CommandSender from their chatgroup. Will also save the groups after finishing * * @param target the CommandSender to get their group removed. */ - private void removeGroup(CommandSender target) + private String removeGroup(CommandSender target) { + String group; if (target instanceof Player) - groups.remove(((Player) target).getUniqueId().toString()); + group = (String) groups.remove(((Player) target).getUniqueId().toString()); else - groups.remove("CONSOLE"); + group = (String) groups.remove("CONSOLE"); saveGroups(); + return group; } /** This method will find the ChatgGroup key of any player. @@ -358,6 +371,30 @@ public class Chatgroups implements Module, Listener } } + /** This method sends a message to a chatgroup. + * + * @param sender the sender of the message. Also defines which group the message will be sent to. + * @param message the message to be sent. */ + private void sendToGroup(String group, String message) + { + Utils.broadcast(null, "message", new BroadcastFilter() + { + @Override + public boolean sendTo(CommandSender recipient) + { + String rgroup = getGroup(recipient); + if (rgroup != null) + return rgroup.equals(group); + else + return false; + } + }, '&'); + if (getGroup(Bukkit.getConsoleSender()) == null || !getGroup(Bukkit.getConsoleSender()).equals(group)) + { + Utils.log("In " + group + ": " + message + " §8(hidden)"); + } + } + /** Saves the groups. */ private void saveGroups() { -- 2.45.2 From 37f7a1db88d4de38732d658b0252480bdf440481 Mon Sep 17 00:00:00 2001 From: Pepich Date: Thu, 2 Mar 2017 19:23:29 +0100 Subject: [PATCH 031/152] Made check connection auto reconnect to prevent timeouts breaking stuff --- src/com/redstoner/modules/check/Check.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/com/redstoner/modules/check/Check.java b/src/com/redstoner/modules/check/Check.java index bebec13..e99de03 100644 --- a/src/com/redstoner/modules/check/Check.java +++ b/src/com/redstoner/modules/check/Check.java @@ -31,7 +31,7 @@ import com.redstoner.misc.mysql.elements.MysqlDatabase; import com.redstoner.misc.mysql.elements.MysqlTable; import com.redstoner.modules.Module; -@Version(major = 1, minor = 0, revision = 6, compatible = 1) +@Version(major = 1, minor = 0, revision = 7, compatible = 1) public class Check implements Module, Listener { private boolean enabled = false; @@ -49,7 +49,8 @@ public class Check implements Module, Listener } try { - MysqlDatabase database = MysqlHandler.INSTANCE.getDatabase((String) config.get("database")); + MysqlDatabase database = MysqlHandler.INSTANCE + .getDatabase((String) config.get("database") + "?autoReconnect=true"); table = database.getTable((String) config.get("table")); } catch (NullPointerException e) -- 2.45.2 From 51405c1f43aa4aa9788b98646048dde44ca529d3 Mon Sep 17 00:00:00 2001 From: Pepich Date: Thu, 2 Mar 2017 19:24:22 +0100 Subject: [PATCH 032/152] Made WebToken autoreconnect --- src/com/redstoner/modules/webtoken/WebToken.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/com/redstoner/modules/webtoken/WebToken.java b/src/com/redstoner/modules/webtoken/WebToken.java index c8b5c59..23bfc7e 100644 --- a/src/com/redstoner/modules/webtoken/WebToken.java +++ b/src/com/redstoner/modules/webtoken/WebToken.java @@ -22,7 +22,7 @@ import com.redstoner.misc.mysql.elements.MysqlDatabase; import com.redstoner.misc.mysql.elements.MysqlTable; import com.redstoner.modules.Module; -@Version(major = 1, minor = 1, revision = 0, compatible = 1) +@Version(major = 1, minor = 1, revision = 1, compatible = 1) public class WebToken implements Module { private boolean enabled = false; @@ -55,7 +55,7 @@ public class WebToken implements Module } try { - MysqlDatabase database = MysqlHandler.INSTANCE.getDatabase(config.get("database")); + MysqlDatabase database = MysqlHandler.INSTANCE.getDatabase(config.get("database") + "?autoReconnect=true"); table = database.getTable(config.get("table")); } catch (NullPointerException e) -- 2.45.2 From bfa6d6fa0760131ac0180925deaafccdce5a4076 Mon Sep 17 00:00:00 2001 From: Pepich Date: Thu, 2 Mar 2017 19:29:33 +0100 Subject: [PATCH 033/152] Fixed unchecked cast resulting in error when console leaves chatgroups --- src/com/redstoner/modules/chatgroups/Chatgroups.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/com/redstoner/modules/chatgroups/Chatgroups.java b/src/com/redstoner/modules/chatgroups/Chatgroups.java index f9be5e1..d0a3c89 100644 --- a/src/com/redstoner/modules/chatgroups/Chatgroups.java +++ b/src/com/redstoner/modules/chatgroups/Chatgroups.java @@ -26,7 +26,7 @@ import com.redstoner.modules.Module; * * @author Pepich */ @AutoRegisterListener -@Version(major = 1, minor = 3, revision = 0, compatible = 1) +@Version(major = 1, minor = 3, revision = 1, compatible = 1) public class Chatgroups implements Module, Listener { private static final char defaultKey = ':'; @@ -229,7 +229,8 @@ public class Chatgroups implements Module, Listener name = sender.getName(); sendToGroup(removeGroup(sender), "&9" + name + " &7left the group!"); Utils.sendMessage(sender, null, "Successfully removed you from your group!"); - cgtoggled.remove(((Player) sender).getUniqueId()); + if (sender instanceof Player) + cgtoggled.remove(((Player) sender).getUniqueId()); return true; } -- 2.45.2 From 44281b3cc040d15236f5dfcaf86d8b9d5d8e507a Mon Sep 17 00:00:00 2001 From: Pepich Date: Thu, 2 Mar 2017 19:33:04 +0100 Subject: [PATCH 034/152] Removed console output when trying to leave groups when not in one --- src/com/redstoner/modules/chatgroups/Chatgroups.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/com/redstoner/modules/chatgroups/Chatgroups.java b/src/com/redstoner/modules/chatgroups/Chatgroups.java index d0a3c89..1bb2736 100644 --- a/src/com/redstoner/modules/chatgroups/Chatgroups.java +++ b/src/com/redstoner/modules/chatgroups/Chatgroups.java @@ -26,7 +26,7 @@ import com.redstoner.modules.Module; * * @author Pepich */ @AutoRegisterListener -@Version(major = 1, minor = 3, revision = 1, compatible = 1) +@Version(major = 1, minor = 3, revision = 2, compatible = 1) public class Chatgroups implements Module, Listener { private static final char defaultKey = ':'; @@ -222,12 +222,18 @@ public class Chatgroups implements Module, Listener @Command(hook = "cgleave") public boolean cgLeave(CommandSender sender) { + String group = removeGroup(sender); + if (group == null) + { + Utils.sendErrorMessage(sender, null, "You were not in a chatgroup!"); + return true; + } String name; if (sender instanceof Player) name = ((Player) sender).getDisplayName(); else name = sender.getName(); - sendToGroup(removeGroup(sender), "&9" + name + " &7left the group!"); + sendToGroup(group, "&9" + name + " &7left the group!"); Utils.sendMessage(sender, null, "Successfully removed you from your group!"); if (sender instanceof Player) cgtoggled.remove(((Player) sender).getUniqueId()); -- 2.45.2 From b0358d62352882a3a4e65a9befc70803ea8ebcc6 Mon Sep 17 00:00:00 2001 From: Pepich Date: Thu, 2 Mar 2017 19:39:48 +0100 Subject: [PATCH 035/152] Added clear module --- src/com/redstoner/misc/Main.java | 4 +- src/com/redstoner/modules/clear/Clear.java | 60 ++++++++++++++++++++++ 2 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 src/com/redstoner/modules/clear/Clear.java diff --git a/src/com/redstoner/misc/Main.java b/src/com/redstoner/misc/Main.java index 0537798..a4e067a 100644 --- a/src/com/redstoner/misc/Main.java +++ b/src/com/redstoner/misc/Main.java @@ -13,6 +13,7 @@ import com.redstoner.modules.challenge.Challenge; import com.redstoner.modules.chatalias.Chatalias; import com.redstoner.modules.chatgroups.Chatgroups; import com.redstoner.modules.check.Check; +import com.redstoner.modules.clear.Clear; import com.redstoner.modules.clearonjoin.ClearOnJoin; import com.redstoner.modules.cycle.Cycle; import com.redstoner.modules.damnspam.DamnSpam; @@ -38,7 +39,7 @@ import com.redstoner.modules.webtoken.WebToken; /** Main class. Duh. * * @author Pepich */ -@Version(major = 1, minor = 4, revision = 1, compatible = -1) +@Version(major = 1, minor = 4, revision = 2, compatible = -1) public class Main extends JavaPlugin { public static JavaPlugin plugin; @@ -56,6 +57,7 @@ public class Main extends JavaPlugin // TODO: ModuleLoader.addModule(BlockplaceMods.class); // TODO: ModuleLoader.addModule(Calc.class); ModuleLoader.addModule(Challenge.class); + ModuleLoader.addModule(Clear.class); ModuleLoader.addModule(ClearOnJoin.class); ModuleLoader.addModule(Chatalias.class); ModuleLoader.addModule(Cycle.class); diff --git a/src/com/redstoner/modules/clear/Clear.java b/src/com/redstoner/modules/clear/Clear.java new file mode 100644 index 0000000..1ff239c --- /dev/null +++ b/src/com/redstoner/modules/clear/Clear.java @@ -0,0 +1,60 @@ +package com.redstoner.modules.clear; + +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; +import org.bukkit.inventory.Inventory; + +import com.nemez.cmdmgr.Command; +import com.redstoner.annotations.Version; +import com.redstoner.misc.Utils; +import com.redstoner.modules.Module; + +@Version(major = 1, minor = 0, revision = 0, compatible = 1) +public class Clear implements Module +{ + boolean enabled; + + @Override + public void onEnable() + { + enabled = true; + } + + @Override + public void onDisable() + { + enabled = false; + } + + @Override + public boolean enabled() + { + return enabled; + } + + @Command(hook = "clear") + public boolean clearInventory(CommandSender sender) + { + Player player = (Player) sender; + Inventory inv = player.getInventory(); + for (int i = 0; i < 36; i++) + inv.clear(i); + Utils.sendMessage(sender, null, "Cleared your inventory!"); + return true; + } + + // @noformat + @Override + public String getCommandString() + { + return "command clear{\n" + + " [empty] {\n" + + " help clears your inventory;\n" + + " type player;\n" + + " perm utils.clear;\n" + + " run clear;\n" + + " }\n" + + "}"; + } + // @format +} -- 2.45.2 From ca849074aa14aaa19749f9fd8db24fa34f3efe2e Mon Sep 17 00:00:00 2001 From: Pepich Date: Thu, 2 Mar 2017 20:07:44 +0100 Subject: [PATCH 036/152] Updated API API Version 2.0.0 Modules no longer have to keep track of their enabled status, the ModuleLoader is now responsible for this. This allows for easier module development and finer control over modules through the loader and the debugger. More features to follow in a future update. --- .../coremods/moduleLoader/ModuleLoader.java | 46 +++---- src/com/redstoner/modules/CoreModule.java | 11 +- src/com/redstoner/modules/Module.java | 16 +-- src/com/redstoner/modules/abot/Abot.java | 17 +-- .../modules/adminchat/Adminchat.java | 17 +-- .../modules/adminnotes/AdminNotes.java | 14 +- .../modules/challenge/Challenge.java | 14 +- .../modules/chatalias/Chatalias.java | 14 +- .../modules/chatgroups/Chatgroups.java | 14 +- src/com/redstoner/modules/check/Check.java | 23 +--- src/com/redstoner/modules/clear/Clear.java | 18 +-- .../modules/clearonjoin/ClearOnJoin.java | 14 +- src/com/redstoner/modules/cycle/Cycle.java | 14 +- .../redstoner/modules/damnspam/DamnSpam.java | 17 +-- .../modules/illumination/Illumination.java | 17 +-- src/com/redstoner/modules/imout/Imout.java | 17 +-- .../modules/lagchunks/LagChunks.java | 17 +-- .../modules/loginsecurity/LoginSecurity.java | 23 +--- src/com/redstoner/modules/mentio/Mentio.java | 14 +- src/com/redstoner/modules/misc/Misc.java | 17 +-- src/com/redstoner/modules/motd/Motd.java | 17 +-- .../redstoner/modules/nametags/Nametags.java | 18 +-- src/com/redstoner/modules/naming/Naming.java | 18 +-- .../redstoner/modules/pmtoggle/Pmtoggle.java | 17 +-- .../redstoner/modules/reports/Reports.java | 124 ++++++++---------- src/com/redstoner/modules/saylol/Saylol.java | 14 +- .../modules/scriptutils/Scriptutils.java | 18 +-- .../modules/skullclick/SkullClick.java | 15 +-- src/com/redstoner/modules/tag/Tag.java | 14 +- src/com/redstoner/modules/vanish/Vanish.java | 17 +-- src/com/redstoner/modules/warn/Warn.java | 18 +-- .../redstoner/modules/webtoken/WebToken.java | 26 +--- 32 files changed, 196 insertions(+), 474 deletions(-) diff --git a/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java b/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java index accb85e..6aa89a0 100644 --- a/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java +++ b/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java @@ -1,6 +1,6 @@ package com.redstoner.coremods.moduleLoader; -import java.util.ArrayList; +import java.util.HashMap; import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; @@ -21,11 +21,11 @@ import com.redstoner.modules.Module; /** The module loader, mother of all modules. Responsible for loading and taking care of all modules. * * @author Pepich */ -@Version(major = 1, minor = 3, revision = 2, compatible = -1) +@Version(major = 2, minor = 0, revision = 0, compatible = -1) public final class ModuleLoader implements CoreModule { private static ModuleLoader instance; - private static final ArrayList modules = new ArrayList(); + private static final HashMap modules = new HashMap(); private ModuleLoader() {} @@ -47,7 +47,7 @@ public final class ModuleLoader implements CoreModule try { Module module = clazz.newInstance(); - modules.add(module); + modules.put(module, false); } catch (InstantiationException | IllegalAccessException e) { @@ -60,13 +60,13 @@ public final class ModuleLoader implements CoreModule public static final void enableModules() { Debugger.notifyMethod(); - for (Module module : modules) + for (Module module : modules.keySet()) { - if (module.enabled()) + if (modules.get(module)) continue; try { - if (module.enable()) + if (module.onEnable()) { CommandManager.registerCommand(module.getCommandString(), module, Main.plugin); if (module.getClass().isAnnotationPresent(AutoRegisterListener.class) @@ -74,6 +74,7 @@ public final class ModuleLoader implements CoreModule { Bukkit.getPluginManager().registerEvents((Listener) module, Main.plugin); } + modules.put(module, true); Utils.log("Loaded module " + module.getClass().getName()); } else @@ -95,22 +96,24 @@ public final class ModuleLoader implements CoreModule public static final boolean enableModule(Class clazz) { Debugger.notifyMethod(clazz); - for (Module m : modules) + for (Module module : modules.keySet()) { - if (m.getClass().equals(clazz)) + if (module.getClass().equals(clazz)) { - if (m.enable()) + if (module.onEnable()) { - if (m.getClass().isAnnotationPresent(AutoRegisterListener.class) && (m instanceof Listener)) + if (module.getClass().isAnnotationPresent(AutoRegisterListener.class) + && (module instanceof Listener)) { - Bukkit.getPluginManager().registerEvents((Listener) m, Main.plugin); + Bukkit.getPluginManager().registerEvents((Listener) module, Main.plugin); } - Utils.log("Loaded module " + m.getClass().getName()); + Utils.log("Loaded module " + module.getClass().getName()); + modules.put(module, true); return true; } else { - Utils.error("Failed to load module " + m.getClass().getName()); + Utils.error("Failed to load module " + module.getClass().getName()); return false; } } @@ -118,9 +121,8 @@ public final class ModuleLoader implements CoreModule try { Module m = clazz.newInstance(); - modules.add(m); - m.onEnable(); - if (m.enabled()) + modules.put(m, false); + if (m.onEnable()) { if (m.getClass().isAnnotationPresent(AutoRegisterListener.class) && (m instanceof Listener)) { @@ -165,11 +167,11 @@ public final class ModuleLoader implements CoreModule { Utils.sendModuleHeader(sender); StringBuilder sb = new StringBuilder("Modules:\n"); - for (Module m : modules) + for (Module module : modules.keySet()) { - String[] classPath = m.getClass().getName().split("\\."); + String[] classPath = module.getClass().getName().split("\\."); String classname = classPath[classPath.length - 1]; - sb.append(m.enabled() ? "&a" : "&c"); + sb.append(modules.get(module) ? "&a" : "&c"); sb.append(classname); sb.append(", "); } @@ -181,9 +183,9 @@ public final class ModuleLoader implements CoreModule public static void disableModules() { - for (Module module : modules) + for (Module module : modules.keySet()) { - if (module.enabled()) + if (modules.get(module)) { module.onDisable(); } diff --git a/src/com/redstoner/modules/CoreModule.java b/src/com/redstoner/modules/CoreModule.java index 8c78308..9f71557 100644 --- a/src/com/redstoner/modules/CoreModule.java +++ b/src/com/redstoner/modules/CoreModule.java @@ -7,21 +7,16 @@ import com.redstoner.annotations.Version; * Examples are the ModuleLoader and the Debugger. * * @author Pepich */ -@Version(major = 1, minor = 0, revision = 1, compatible = -1) +@Version(major = 2, minor = 0, revision = 0, compatible = -1) public interface CoreModule extends Module { - /** Core modules should always be enabled. */ + /** Core modules don't need to be enabled. */ @Override - public default boolean enabled() + public default boolean onEnable() { return true; } - /** Core modules don't need to be enabled. */ - @Override - public default void onEnable() - {} - /** Core modules don't need to be disabled. */ @Override public default void onDisable() diff --git a/src/com/redstoner/modules/Module.java b/src/com/redstoner/modules/Module.java index 3ffba42..dc9e4eb 100644 --- a/src/com/redstoner/modules/Module.java +++ b/src/com/redstoner/modules/Module.java @@ -9,25 +9,11 @@ import com.redstoner.annotations.Version; public interface Module { /** Will be called when the module gets enabled. */ - public void onEnable(); + public boolean onEnable(); /** Will be called when the module gets disabled. */ public void onDisable(); - /** Will be called to check if a module is enabled or not. - * - * @return The status of the module, true when enabled, false when not. */ - public boolean enabled(); - - /** Default implementation for the enable() method, returning weather the module was enabled or not. - * - * @return */ - public default boolean enable() - { - onEnable(); - return enabled(); - } - /** Gets called on registration of the module. * * @return The String used for the CommandManager to register the commands. */ diff --git a/src/com/redstoner/modules/abot/Abot.java b/src/com/redstoner/modules/abot/Abot.java index 428a7ea..8103dcb 100644 --- a/src/com/redstoner/modules/abot/Abot.java +++ b/src/com/redstoner/modules/abot/Abot.java @@ -19,10 +19,9 @@ import com.redstoner.misc.Utils; import com.redstoner.modules.Module; @AutoRegisterListener -@Version(major = 1, minor = 0, revision = 1, compatible = 1) +@Version(major = 2, minor = 0, revision = 0, compatible = 2) public class Abot implements Module, Listener { - private boolean enabled = false; private File answerFile = new File(Main.plugin.getDataFolder(), "abot.json"); JSONArray answers; @@ -59,23 +58,15 @@ public class Abot implements Module, Listener } @Override - public void onEnable() + public boolean onEnable() { loadAnswers(Bukkit.getConsoleSender()); - enabled = true; + return true; } @Override public void onDisable() - { - enabled = false; - } - - @Override - public boolean enabled() - { - return enabled; - } + {} // @noformat @Override diff --git a/src/com/redstoner/modules/adminchat/Adminchat.java b/src/com/redstoner/modules/adminchat/Adminchat.java index b179752..7c5aaf4 100644 --- a/src/com/redstoner/modules/adminchat/Adminchat.java +++ b/src/com/redstoner/modules/adminchat/Adminchat.java @@ -24,17 +24,16 @@ import com.redstoner.modules.Module; * * @author Pepich */ @AutoRegisterListener -@Version(major = 1, minor = 0, revision = 6, compatible = 1) +@Version(major = 2, minor = 0, revision = 0, compatible = 2) public class Adminchat implements Module, Listener { private static final char defaultKey = ','; - private boolean enabled = false; private static final File keysLocation = new File(Main.plugin.getDataFolder(), "adminchat_keys.json"); private ArrayList actoggled; private static JSONObject keys; @Override - public void onEnable() + public boolean onEnable() { keys = JsonManager.getObject(keysLocation); if (keys == null) @@ -43,20 +42,12 @@ public class Adminchat implements Module, Listener saveKeys(); } actoggled = new ArrayList(); - this.enabled = true; + return true; } @Override public void onDisable() - { - this.enabled = false; - } - - @Override - public boolean enabled() - { - return enabled; - } + {} // @noformat @Override diff --git a/src/com/redstoner/modules/adminnotes/AdminNotes.java b/src/com/redstoner/modules/adminnotes/AdminNotes.java index ba393e5..7877735 100644 --- a/src/com/redstoner/modules/adminnotes/AdminNotes.java +++ b/src/com/redstoner/modules/adminnotes/AdminNotes.java @@ -19,20 +19,19 @@ import com.redstoner.misc.Utils; import com.redstoner.modules.Module; @AutoRegisterListener -@Version(major = 1, minor = 0, revision = 3, compatible = 1) +@Version(major = 2, minor = 0, revision = 0, compatible = 2) public class AdminNotes implements Module, Listener { - private boolean enabled = false; JSONArray notes; File saveFile = new File(Main.plugin.getDataFolder(), "adminnotes.json"); @Override - public void onEnable() + public boolean onEnable() { notes = JsonManager.getArray(saveFile); if (notes == null) notes = new JSONArray(); - enabled = true; + return true; } @EventHandler @@ -51,7 +50,6 @@ public class AdminNotes implements Module, Listener public void onDisable() { saveNotes(); - enabled = false; } @SuppressWarnings("unchecked") @@ -102,12 +100,6 @@ public class AdminNotes implements Module, Listener JsonManager.save(notes, saveFile); } - @Override - public boolean enabled() - { - return enabled; - } - // @noformat @Override public String getCommandString() diff --git a/src/com/redstoner/modules/challenge/Challenge.java b/src/com/redstoner/modules/challenge/Challenge.java index 61f3af4..0ebb831 100644 --- a/src/com/redstoner/modules/challenge/Challenge.java +++ b/src/com/redstoner/modules/challenge/Challenge.java @@ -13,33 +13,25 @@ import com.redstoner.misc.Main; import com.redstoner.misc.Utils; import com.redstoner.modules.Module; -@Version(major = 1, minor = 0, revision = 2, compatible = 1) +@Version(major = 2, minor = 0, revision = 0, compatible = 2) public class Challenge implements Module { - private boolean enabled = false; private File challengeLocation = new File(Main.plugin.getDataFolder(), "challenges.json"); private JSONArray challenges; @Override - public void onEnable() + public boolean onEnable() { challenges = JsonManager.getArray(challengeLocation); if (challenges == null) challenges = new JSONArray(); - enabled = true; + return true; } @Override public void onDisable() { saveChallenges(); - enabled = false; - } - - @Override - public boolean enabled() - { - return enabled; } @SuppressWarnings("unchecked") diff --git a/src/com/redstoner/modules/chatalias/Chatalias.java b/src/com/redstoner/modules/chatalias/Chatalias.java index 51b7822..1edb28c 100644 --- a/src/com/redstoner/modules/chatalias/Chatalias.java +++ b/src/com/redstoner/modules/chatalias/Chatalias.java @@ -26,25 +26,24 @@ import com.redstoner.misc.Utils; import com.redstoner.modules.Module; @AutoRegisterListener -@Version(major = 1, minor = 1, revision = 2, compatible = 1) +@Version(major = 2, minor = 0, revision = 0, compatible = 2) public class Chatalias implements Module, Listener { // to export chatalias data to json: // pyeval [save_json_file("aliases/" + uuid, shared['modules']['chatalias'].data[uuid]) for uuid in shared['modules']['chatalias'].data] // HANDLE WITH CARE! This will create an array of null entries the size of len(data)! - private boolean enabled = false; private final String[] commands = new String[] {"e?r", "e?m .+? ", "e?t", "e?w", "e?msg .+? ", "e?message .+? ", "e?whisper .+? ", "e?me", "cg say", "ac"}; private JSONObject aliases = new JSONObject(); @Override - public void onEnable() + public boolean onEnable() { for (Player p : Bukkit.getOnlinePlayers()) { loadAliases(p.getUniqueId()); } - enabled = true; + return true; } @Override @@ -55,13 +54,6 @@ public class Chatalias implements Module, Listener UUID uuid = UUID.fromString((String) key); saveAliases(uuid); } - enabled = false; - } - - @Override - public boolean enabled() - { - return enabled; } @EventHandler diff --git a/src/com/redstoner/modules/chatgroups/Chatgroups.java b/src/com/redstoner/modules/chatgroups/Chatgroups.java index 1bb2736..bf1e9ed 100644 --- a/src/com/redstoner/modules/chatgroups/Chatgroups.java +++ b/src/com/redstoner/modules/chatgroups/Chatgroups.java @@ -26,7 +26,7 @@ import com.redstoner.modules.Module; * * @author Pepich */ @AutoRegisterListener -@Version(major = 1, minor = 3, revision = 2, compatible = 1) +@Version(major = 2, minor = 0, revision = 0, compatible = 2) public class Chatgroups implements Module, Listener { private static final char defaultKey = ':'; @@ -34,10 +34,9 @@ public class Chatgroups implements Module, Listener private static final File keysLocation = new File(Main.plugin.getDataFolder(), "chatgroup_keys.json"); private ArrayList cgtoggled; private static JSONObject groups, keys; - private boolean enabled = false; @Override - public void onEnable() + public boolean onEnable() { groups = JsonManager.getObject(groupsLocation); if (groups == null) @@ -52,7 +51,7 @@ public class Chatgroups implements Module, Listener saveKeys(); } cgtoggled = new ArrayList(); - enabled = true; + return true; } @Override @@ -60,13 +59,6 @@ public class Chatgroups implements Module, Listener { saveKeys(); saveGroups(); - enabled = false; - } - - @Override - public boolean enabled() - { - return enabled; } // @noformat diff --git a/src/com/redstoner/modules/check/Check.java b/src/com/redstoner/modules/check/Check.java index e99de03..a2ee75f 100644 --- a/src/com/redstoner/modules/check/Check.java +++ b/src/com/redstoner/modules/check/Check.java @@ -31,21 +31,19 @@ import com.redstoner.misc.mysql.elements.MysqlDatabase; import com.redstoner.misc.mysql.elements.MysqlTable; import com.redstoner.modules.Module; -@Version(major = 1, minor = 0, revision = 7, compatible = 1) +@Version(major = 2, minor = 0, revision = 0, compatible = 2) public class Check implements Module, Listener { - private boolean enabled = false; MysqlTable table; @Override - public void onEnable() + public boolean onEnable() { Map config = JSONManager.getConfiguration("check.json"); if (config == null || !config.containsKey("database") || !config.containsKey("table")) { Utils.error("Could not load the Check config file, disabling!"); - enabled = false; - return; + return false; } try { @@ -56,10 +54,9 @@ public class Check implements Module, Listener catch (NullPointerException e) { Utils.error("Could not use the Check config, disabling!"); - enabled = false; - return; + return false; } - enabled = true; + return true; } @SuppressWarnings("deprecation") @@ -228,12 +225,6 @@ public class Check implements Module, Listener } } - @Override - public boolean enabled() - { - return enabled; - } - // @noformat @Override public String getCommandString() @@ -251,7 +242,5 @@ public class Check implements Module, Listener @Override public void onDisable() - { - enabled = false; - } + {} } diff --git a/src/com/redstoner/modules/clear/Clear.java b/src/com/redstoner/modules/clear/Clear.java index 1ff239c..139a6e0 100644 --- a/src/com/redstoner/modules/clear/Clear.java +++ b/src/com/redstoner/modules/clear/Clear.java @@ -9,28 +9,18 @@ import com.redstoner.annotations.Version; import com.redstoner.misc.Utils; import com.redstoner.modules.Module; -@Version(major = 1, minor = 0, revision = 0, compatible = 1) +@Version(major = 2, minor = 0, revision = 0, compatible = 2) public class Clear implements Module { - boolean enabled; - @Override - public void onEnable() + public boolean onEnable() { - enabled = true; + return true; } @Override public void onDisable() - { - enabled = false; - } - - @Override - public boolean enabled() - { - return enabled; - } + {} @Command(hook = "clear") public boolean clearInventory(CommandSender sender) diff --git a/src/com/redstoner/modules/clearonjoin/ClearOnJoin.java b/src/com/redstoner/modules/clearonjoin/ClearOnJoin.java index bd93561..1bb8f1b 100644 --- a/src/com/redstoner/modules/clearonjoin/ClearOnJoin.java +++ b/src/com/redstoner/modules/clearonjoin/ClearOnJoin.java @@ -17,10 +17,9 @@ import com.redstoner.misc.Main; import com.redstoner.misc.Utils; import com.redstoner.modules.Module; -@Version(major = 1, minor = 0, revision = 0, compatible = 1) +@Version(major = 2, minor = 0, revision = 0, compatible = 2) public class ClearOnJoin implements Module, Listener { - boolean enabled = false; private File listLocation = new File(Main.plugin.getDataFolder(), "clearonjoins.json"); private JSONArray list; @@ -75,26 +74,19 @@ public class ClearOnJoin implements Module, Listener } @Override - public void onEnable() + public boolean onEnable() { - enabled = true; list = JsonManager.getArray(listLocation); if (list == null) list = new JSONArray(); Bukkit.getServer().getPluginManager().registerEvents(this, Main.plugin); + return true; } @Override public void onDisable() { saveList(); - enabled = false; - } - - @Override - public boolean enabled() - { - return enabled; } // @noformat diff --git a/src/com/redstoner/modules/cycle/Cycle.java b/src/com/redstoner/modules/cycle/Cycle.java index 3295624..5f6d2a7 100644 --- a/src/com/redstoner/modules/cycle/Cycle.java +++ b/src/com/redstoner/modules/cycle/Cycle.java @@ -22,33 +22,25 @@ import com.redstoner.misc.Utils; import com.redstoner.modules.Module; @AutoRegisterListener -@Version(major = 1, minor = 0, revision = 0, compatible = 1) +@Version(major = 2, minor = 0, revision = 0, compatible = 2) public class Cycle implements Module, Listener { - private boolean enabled = false; private File cycleFile = new File(Main.plugin.getDataFolder(), "cycle.json"); private JSONArray no_cyclers; @Override - public void onEnable() + public boolean onEnable() { no_cyclers = JsonManager.getArray(cycleFile); if (no_cyclers == null) no_cyclers = new JSONArray(); - enabled = true; + return true; } @Override public void onDisable() { saveCyclers(); - enabled = false; - } - - @Override - public boolean enabled() - { - return enabled; } private void saveCyclers() diff --git a/src/com/redstoner/modules/damnspam/DamnSpam.java b/src/com/redstoner/modules/damnspam/DamnSpam.java index 3f95443..4d59484 100644 --- a/src/com/redstoner/modules/damnspam/DamnSpam.java +++ b/src/com/redstoner/modules/damnspam/DamnSpam.java @@ -37,10 +37,9 @@ import com.redstoner.misc.Utils; import com.redstoner.modules.Module; @AutoRegisterListener -@Version(major = 1, minor = 1, revision = 1, compatible = 1) +@Version(major = 2, minor = 0, revision = 0, compatible = 2) public class DamnSpam implements Module, Listener { - private boolean enabled = false; File configFile = new File(Main.plugin.getDataFolder(), "DamnSpam.json"); Map inputs; boolean changingInput = false; @@ -51,7 +50,7 @@ public class DamnSpam implements Module, Listener String timeoutErrorString = "&cThe timeout must be -1 or within 0 and " + maxTimeout; @Override - public void onEnable() + public boolean onEnable() { loadInputs(); acceptedInputs = new ArrayList(); @@ -64,7 +63,7 @@ public class DamnSpam implements Module, Listener attachedBlocks.put(Material.WOOD_BUTTON, new int[][] {{0, 8}, {5, 6, 7, 13, 14, 15}, {4, 12}, {3, 11}, {2, 10}, {1, 9}}); players = new HashMap(); - enabled = true; + return true; } public void loadInputs() @@ -344,17 +343,9 @@ public class DamnSpam implements Module, Listener } } - @Override - public boolean enabled() - { - return enabled; - } - @Override public void onDisable() - { - enabled = false; - } + {} // @noformat @Override diff --git a/src/com/redstoner/modules/illumination/Illumination.java b/src/com/redstoner/modules/illumination/Illumination.java index 97073b8..20e2926 100644 --- a/src/com/redstoner/modules/illumination/Illumination.java +++ b/src/com/redstoner/modules/illumination/Illumination.java @@ -10,10 +10,9 @@ import com.redstoner.annotations.Version; import com.redstoner.misc.Utils; import com.redstoner.modules.Module; -@Version(major = 1, minor = 0, revision = 2, compatible = 1) +@Version(major = 2, minor = 0, revision = 0, compatible = 2) public class Illumination implements Module { - boolean enabled = false; PotionEffect effect = new PotionEffect(PotionEffectType.NIGHT_VISION, Integer.MAX_VALUE, 0, false, false); @Command(hook = "illuminate") @@ -33,22 +32,14 @@ public class Illumination implements Module } @Override - public void onEnable() + public boolean onEnable() { - enabled = true; + return true; } @Override public void onDisable() - { - enabled = false; - } - - @Override - public boolean enabled() - { - return enabled; - } + {} // @noformat @Override diff --git a/src/com/redstoner/modules/imout/Imout.java b/src/com/redstoner/modules/imout/Imout.java index b083fd1..c5f1200 100644 --- a/src/com/redstoner/modules/imout/Imout.java +++ b/src/com/redstoner/modules/imout/Imout.java @@ -7,12 +7,13 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import com.nemez.cmdmgr.Command; +import com.redstoner.annotations.Version; import com.redstoner.misc.Utils; import com.redstoner.modules.Module; +@Version(major = 2, minor = 0, revision = 0, compatible = 2) public class Imout implements Module { - private boolean enabled = false; List imout_toggle_list = new ArrayList(); @Command(hook = "imout") @@ -42,22 +43,14 @@ public class Imout implements Module } @Override - public boolean enabled() + public boolean onEnable() { - return enabled; - } - - @Override - public void onEnable() - { - enabled = true; + return true; } @Override public void onDisable() - { - enabled = false; - } + {} // @noformat @Override diff --git a/src/com/redstoner/modules/lagchunks/LagChunks.java b/src/com/redstoner/modules/lagchunks/LagChunks.java index 52d772b..b0de6a6 100644 --- a/src/com/redstoner/modules/lagchunks/LagChunks.java +++ b/src/com/redstoner/modules/lagchunks/LagChunks.java @@ -16,10 +16,9 @@ import com.redstoner.annotations.Version; import com.redstoner.misc.Utils; import com.redstoner.modules.Module; -@Version(major = 1, minor = 0, revision = 0, compatible = 1) +@Version(major = 2, minor = 0, revision = 0, compatible = 2) public class LagChunks implements Module { - private boolean enabled = false; private List laggyChunks = new ArrayList(); private void scan(int amount) @@ -79,22 +78,14 @@ public class LagChunks implements Module } @Override - public boolean enabled() + public boolean onEnable() { - return enabled; - } - - @Override - public void onEnable() - { - enabled = true; + return true; } @Override public void onDisable() - { - enabled = false; - } + {} // @noformat @Override diff --git a/src/com/redstoner/modules/loginsecurity/LoginSecurity.java b/src/com/redstoner/modules/loginsecurity/LoginSecurity.java index 56f1ea7..38513ee 100644 --- a/src/com/redstoner/modules/loginsecurity/LoginSecurity.java +++ b/src/com/redstoner/modules/loginsecurity/LoginSecurity.java @@ -34,23 +34,21 @@ import com.redstoner.misc.mysql.types.text.VarChar; import com.redstoner.modules.Module; @AutoRegisterListener -@Version(major = 1, minor = 0, revision = 3, compatible = 1) +@Version(major = 2, minor = 0, revision = 0, compatible = 2) public class LoginSecurity implements Module, Listener { - private boolean enabled = false; protected static Map loggingIn; private MysqlTable table; @Override - public void onEnable() + public boolean onEnable() { Map config = JSONManager.getConfiguration("loginsecurity.json"); if (config == null || !config.containsKey("database") || !config.containsKey("table")) { Utils.sendErrorMessage(Bukkit.getConsoleSender(), null, "Could not load the LoginSecurity config file, disabling!"); - enabled = false; - return; + return false; } try { @@ -64,12 +62,11 @@ public class LoginSecurity implements Module, Listener { Utils.sendErrorMessage(Bukkit.getConsoleSender(), null, "Could not use the LoginSecurity config, disabling!"); - enabled = false; - return; + return false; } loggingIn = new HashMap<>(); Bukkit.getServer().getPluginManager().registerEvents(new CancelledEventsHandler(this), Main.plugin); - enabled = true; + return true; } public static Map getLoggingIn() @@ -263,17 +260,9 @@ public class LoginSecurity implements Module, Listener return table.insert(player.getUniqueId().toString(), toInsert); } - @Override - public boolean enabled() - { - return enabled; - } - @Override public void onDisable() - { - enabled = false; - } + {} // @noformat @Override diff --git a/src/com/redstoner/modules/mentio/Mentio.java b/src/com/redstoner/modules/mentio/Mentio.java index a063a6c..dd993a6 100644 --- a/src/com/redstoner/modules/mentio/Mentio.java +++ b/src/com/redstoner/modules/mentio/Mentio.java @@ -23,31 +23,23 @@ import com.redstoner.misc.Utils; import com.redstoner.modules.Module; @AutoRegisterListener -@Version(major = 1, minor = 0, revision = 4, compatible = 1) +@Version(major = 2, minor = 0, revision = 0, compatible = 2) public class Mentio implements Module, Listener { - private boolean enabled = false; private File mentioLocation = new File(Main.plugin.getDataFolder(), "mentio.json"); private JSONObject mentios; @Override - public void onEnable() + public boolean onEnable() { loadMentios(); - enabled = true; + return true; } @Override public void onDisable() { saveMentios(); - enabled = false; - } - - @Override - public boolean enabled() - { - return enabled; } @SuppressWarnings("unchecked") diff --git a/src/com/redstoner/modules/misc/Misc.java b/src/com/redstoner/modules/misc/Misc.java index 773ff7f..6a982e6 100644 --- a/src/com/redstoner/modules/misc/Misc.java +++ b/src/com/redstoner/modules/misc/Misc.java @@ -18,29 +18,20 @@ import com.redstoner.misc.Utils; import com.redstoner.modules.Module; @AutoRegisterListener -@Version(major = 1, minor = 0, revision = 4, compatible = 1) +@Version(major = 2, minor = 0, revision = 0, compatible = 2) public class Misc implements Module, Listener { - private boolean enabled = false; private final String[] sudoBlacklist = new String[] {".*:?esudo", ".*:?sudo", ".*:?script.*", ".*:?stop"}; @Override - public void onEnable() + public boolean onEnable() { - enabled = true; + return true; } @Override public void onDisable() - { - enabled = false; - } - - @Override - public boolean enabled() - { - return enabled; - } + {} @EventHandler public void onFirstJoin(PlayerJoinEvent event) diff --git a/src/com/redstoner/modules/motd/Motd.java b/src/com/redstoner/modules/motd/Motd.java index cea9a9b..0ce1d21 100644 --- a/src/com/redstoner/modules/motd/Motd.java +++ b/src/com/redstoner/modules/motd/Motd.java @@ -12,10 +12,9 @@ import com.redstoner.misc.Utils; import com.redstoner.modules.Module; @AutoRegisterListener -@Version(major = 1, minor = 0, revision = 1, compatible = 1) +@Version(major = 2, minor = 0, revision = 0, compatible = 2) public class Motd implements Module { - private boolean enabled = false; private String default_motd, motd; @Command(hook = "setmotd") @@ -43,23 +42,15 @@ public class Motd implements Module } @Override - public void onEnable() + public boolean onEnable() { default_motd = Bukkit.getMotd(); - enabled = true; + return true; } @Override public void onDisable() - { - enabled = false; - } - - @Override - public boolean enabled() - { - return enabled; - } + {} // @noformat @Override diff --git a/src/com/redstoner/modules/nametags/Nametags.java b/src/com/redstoner/modules/nametags/Nametags.java index 2ec8ee0..eaa0f3c 100644 --- a/src/com/redstoner/modules/nametags/Nametags.java +++ b/src/com/redstoner/modules/nametags/Nametags.java @@ -16,28 +16,18 @@ import com.redstoner.misc.Utils; import com.redstoner.modules.Module; @AutoRegisterListener -@Version(major = 1, minor = 0, revision = 1, compatible = 1) +@Version(major = 2, minor = 0, revision = 0, compatible = 2) public class Nametags implements Module, Listener { - private boolean enabled = false; - @Override - public void onEnable() + public boolean onEnable() { - enabled = true; + return true; } @Override public void onDisable() - { - enabled = false; - } - - @Override - public boolean enabled() - { - return enabled; - } + {} @EventHandler public void onPlayerJoin(PlayerJoinEvent event) diff --git a/src/com/redstoner/modules/naming/Naming.java b/src/com/redstoner/modules/naming/Naming.java index 11be1a1..715d855 100644 --- a/src/com/redstoner/modules/naming/Naming.java +++ b/src/com/redstoner/modules/naming/Naming.java @@ -22,11 +22,9 @@ import net.minecraft.server.v1_11_R1.EntityHuman; import net.minecraft.server.v1_11_R1.EntityPlayer; import net.minecraft.server.v1_11_R1.PacketPlayOutOpenWindow; -@Version(major = 1, minor = 0, revision = 3, compatible = 1) +@Version(major = 2, minor = 0, revision = 0, compatible = 2) public class Naming implements Module { - boolean enabled = false; - @Command(hook = "anvil") public void anvil(CommandSender sender) { @@ -90,22 +88,14 @@ public class Naming implements Module } @Override - public void onEnable() + public boolean onEnable() { - enabled = true; + return true; } @Override public void onDisable() - { - enabled = false; - } - - @Override - public boolean enabled() - { - return enabled; - } + {} // @noformat @Override diff --git a/src/com/redstoner/modules/pmtoggle/Pmtoggle.java b/src/com/redstoner/modules/pmtoggle/Pmtoggle.java index 27b8835..e5e983f 100644 --- a/src/com/redstoner/modules/pmtoggle/Pmtoggle.java +++ b/src/com/redstoner/modules/pmtoggle/Pmtoggle.java @@ -19,29 +19,20 @@ import com.redstoner.misc.Utils; import com.redstoner.modules.Module; @AutoRegisterListener -@Version(major = 1, minor = 0, revision = 1, compatible = 1) +@Version(major = 2, minor = 0, revision = 0, compatible = 2) public class Pmtoggle implements Module, Listener { - private boolean enabled; HashMap toggles = new HashMap(); @Override - public void onEnable() + public boolean onEnable() { - enabled = true; + return true; } @Override public void onDisable() - { - enabled = false; - } - - @Override - public boolean enabled() - { - return enabled; - } + {} @Command(hook = "pmtoggle_off", async = AsyncType.ALWAYS) public boolean pmtoggle_off(CommandSender sender) diff --git a/src/com/redstoner/modules/reports/Reports.java b/src/com/redstoner/modules/reports/Reports.java index 1cbab38..cb1022e 100644 --- a/src/com/redstoner/modules/reports/Reports.java +++ b/src/com/redstoner/modules/reports/Reports.java @@ -13,6 +13,7 @@ import org.json.simple.JSONArray; import org.json.simple.JSONObject; import com.nemez.cmdmgr.Command; +import com.redstoner.annotations.Version; import com.redstoner.misc.JsonManager; import com.redstoner.misc.Main; import com.redstoner.modules.Module; @@ -22,94 +23,79 @@ import net.md_5.bungee.api.ChatColor; /** Report module. Allows reports to be created and handled by staff * * @author Redempt */ -public class Reports implements Module { - - private boolean enabled = false; +@Version(major = 2, minor = 0, revision = 0, compatible = 2) +public class Reports implements Module +{ private int task = 0; - private JSONArray reports; private JSONArray archived; - private SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd kk:mm"); @Override - public void onEnable() { - enabled = true; - //Load reports + public boolean onEnable() + { reports = JsonManager.getArray(new File(Main.plugin.getDataFolder(), "reports.json")); archived = JsonManager.getArray(new File(Main.plugin.getDataFolder(), "archived_reports.json")); - if (reports == null) { + if (reports == null) + { reports = new JSONArray(); } - if (archived == null) { + if (archived == null) + { archived = new JSONArray(); } - //Notify online staff of open reports - task = Bukkit.getScheduler().scheduleSyncRepeatingTask(Main.plugin, () -> { - if (reports.size() <= 0) { + // Notify online staff of open reports + task = Bukkit.getScheduler().scheduleSyncRepeatingTask(Main.plugin, () -> + { + if (reports.size() <= 0) + { return; } - for (Player player : Bukkit.getOnlinePlayers()) { - if (player.hasPermission("utils.report")) { - player.sendMessage(ChatColor.RED + "There are " + ChatColor.YELLOW + reports.size() + ChatColor.RED + " open reports!"); + for (Player player : Bukkit.getOnlinePlayers()) + { + if (player.hasPermission("utils.report")) + { + player.sendMessage(ChatColor.RED + "There are " + ChatColor.YELLOW + reports.size() + ChatColor.RED + + " open reports!"); } } - }, 2400, 2400); + } , 2400, 2400); + return true; } - + @Override - public void onDisable() { - enabled = false; - //Save reports, cancel notifier task + public void onDisable() + { + // Save reports, cancel notifier task Bukkit.getScheduler().cancelTask(task); JsonManager.save(reports, new File(Main.plugin.getDataFolder(), "reports.json")); JsonManager.save(archived, new File(Main.plugin.getDataFolder(), "archived_reports.json")); } - - @Override - public boolean enabled() { - return enabled; - } @Override - public String getCommandString() { - return "command report {" - + "[string:message...] {" - + "type player;" - + "help Report a player or incident;" - + "run report message;" - + "}" - + "}" - + "command rp {" - + "perm utils.report;" - + "open {" - + "help List all open reports;" - + "run report_open;" - + "}" - + "close [int:id] {" - + "help Close a report;" - + "run report_close id;" - + "}" - + "tp [int:id] {" - + "help Teleport to the location of a report;" - + "run report_tp id;" - + "type player;" - + "}" - + "}"; + public String getCommandString() + { + return "command report {" + "[string:message...] {" + "type player;" + "help Report a player or incident;" + + "run report message;" + "}" + "}" + "command rp {" + "perm utils.report;" + "open {" + + "help List all open reports;" + "run report_open;" + "}" + "close [int:id] {" + "help Close a report;" + + "run report_close id;" + "}" + "tp [int:id] {" + "help Teleport to the location of a report;" + + "run report_tp id;" + "type player;" + "}" + "}"; } @Command(hook = "report_tp") - public void tpReport(CommandSender sender, int id) { - //Check for invalid ID + public void tpReport(CommandSender sender, int id) + { + // Check for invalid ID Player player = (Player) sender; - if (id > reports.size() - 1 || id < 0) { + if (id > reports.size() - 1 || id < 0) + { sender.sendMessage(ChatColor.RED + "Invalid ID!"); return; } JSONObject report = (JSONObject) reports.get(id); String loc = (String) report.get("location"); String[] split = loc.split(";"); - //Location from string + // Location from string int x = Integer.parseInt(split[0]); int y = Integer.parseInt(split[1]); int z = Integer.parseInt(split[2]); @@ -120,13 +106,15 @@ public class Reports implements Module { @SuppressWarnings("unchecked") @Command(hook = "report_close") - public void closeReport(CommandSender sender, int id) { - //Check for invalid ID - if (id > reports.size() - 1 || id < 0) { + public void closeReport(CommandSender sender, int id) + { + // Check for invalid ID + if (id > reports.size() - 1 || id < 0) + { sender.sendMessage(ChatColor.RED + "Invalid ID!"); return; } - //Move report to archived reports + // Move report to archived reports JSONObject report = (JSONObject) reports.get(id); reports.remove(id); archived.add(report); @@ -134,9 +122,11 @@ public class Reports implements Module { } @Command(hook = "report_open") - public void listOpen(CommandSender sender) { + public void listOpen(CommandSender sender) + { int i = 0; - for (Object object : reports) { + for (Object object : reports) + { JSONObject report = (JSONObject) object; String message = ""; message += ChatColor.DARK_GRAY + "[" + ChatColor.YELLOW + i + ChatColor.DARK_GRAY + "]"; @@ -146,26 +136,28 @@ public class Reports implements Module { sender.sendMessage(message); i++; } - if (i == 0) { + if (i == 0) + { sender.sendMessage(ChatColor.GREEN + "There are no open reports."); } } @SuppressWarnings("unchecked") @Command(hook = "report") - public void report(CommandSender sender, String message) { + public void report(CommandSender sender, String message) + { Player player = (Player) sender; - //Create report JSONObject + // Create report JSONObject JSONObject report = new JSONObject(); report.put("name", player.getName()); report.put("time", dateFormat.format(new Date())); report.put("message", message); String loc = ""; - //Location to string - loc += player.getLocation().getBlockX() + ";" + player.getLocation().getBlockY() + ";" + player.getLocation().getBlockZ() + ";" + player.getLocation().getWorld().getName(); + // Location to string + loc += player.getLocation().getBlockX() + ";" + player.getLocation().getBlockY() + ";" + + player.getLocation().getBlockZ() + ";" + player.getLocation().getWorld().getName(); report.put("location", loc); reports.add(report); sender.sendMessage(ChatColor.GREEN + "Report created!"); } - } diff --git a/src/com/redstoner/modules/saylol/Saylol.java b/src/com/redstoner/modules/saylol/Saylol.java index 0b1e327..a259ac3 100644 --- a/src/com/redstoner/modules/saylol/Saylol.java +++ b/src/com/redstoner/modules/saylol/Saylol.java @@ -15,34 +15,26 @@ import com.redstoner.misc.Main; import com.redstoner.misc.Utils; import com.redstoner.modules.Module; -@Version(major = 1, minor = 0, revision = 6, compatible = 1) +@Version(major = 2, minor = 0, revision = 0, compatible = 2) public class Saylol implements Module { private long lastLol = 0; - private boolean enabled = false; private File lolLocation = new File(Main.plugin.getDataFolder(), "lol.json"); private JSONArray lols; @Override - public void onEnable() + public boolean onEnable() { lols = JsonManager.getArray(lolLocation); if (lols == null) lols = new JSONArray(); - enabled = true; + return true; } @Override public void onDisable() { saveLols(); - enabled = false; - } - - @Override - public boolean enabled() - { - return enabled; } @SuppressWarnings("unchecked") diff --git a/src/com/redstoner/modules/scriptutils/Scriptutils.java b/src/com/redstoner/modules/scriptutils/Scriptutils.java index 8d3ab40..b1dc937 100644 --- a/src/com/redstoner/modules/scriptutils/Scriptutils.java +++ b/src/com/redstoner/modules/scriptutils/Scriptutils.java @@ -8,11 +8,9 @@ import com.redstoner.annotations.Version; import com.redstoner.misc.Utils; import com.redstoner.modules.Module; -@Version(major = 1, minor = 0, revision = 1, compatible = 1) +@Version(major = 2, minor = 0, revision = 0, compatible = 2) public class Scriptutils implements Module { - private boolean enabled = false; - /** Prints Bukkit restart message * arg 0 timeout * arg 1 $(whoami); @@ -175,22 +173,14 @@ public class Scriptutils implements Module } @Override - public void onEnable() + public boolean onEnable() { - enabled = true; + return true; } @Override public void onDisable() - { - enabled = false; - } - - @Override - public boolean enabled() - { - return enabled; - } + {} // @noformat @Override diff --git a/src/com/redstoner/modules/skullclick/SkullClick.java b/src/com/redstoner/modules/skullclick/SkullClick.java index e05e404..5608d29 100644 --- a/src/com/redstoner/modules/skullclick/SkullClick.java +++ b/src/com/redstoner/modules/skullclick/SkullClick.java @@ -16,7 +16,6 @@ import com.redstoner.modules.Module; @AutoRegisterListener public class SkullClick implements Module, Listener { - private boolean enabled = false; private boolean seen = false; @SuppressWarnings("deprecation") @@ -54,22 +53,14 @@ public class SkullClick implements Module, Listener } @Override - public boolean enabled() + public boolean onEnable() { - return enabled; - } - - @Override - public void onEnable() - { - enabled = true; + return true; } @Override public void onDisable() - { - enabled = false; - } + {} @Override public String getCommandString() diff --git a/src/com/redstoner/modules/tag/Tag.java b/src/com/redstoner/modules/tag/Tag.java index 3cec1fa..9685bf5 100644 --- a/src/com/redstoner/modules/tag/Tag.java +++ b/src/com/redstoner/modules/tag/Tag.java @@ -17,33 +17,25 @@ import com.redstoner.misc.Main; import com.redstoner.misc.Utils; import com.redstoner.modules.Module; -@Version(major = 1, minor = 0, revision = 0, compatible = 1) +@Version(major = 2, minor = 0, revision = 0, compatible = 2) public class Tag implements Module { - private boolean enabled; private File tagLocation = new File(Main.plugin.getDataFolder(), "tag.json"); private JSONObject tags; @Override - public void onEnable() + public boolean onEnable() { tags = JsonManager.getObject(tagLocation); if (tags == null) tags = new JSONObject(); - enabled = true; + return true; } @Override public void onDisable() { saveTags(); - enabled = false; - } - - @Override - public boolean enabled() - { - return enabled; } @SuppressWarnings({"deprecation", "unchecked"}) diff --git a/src/com/redstoner/modules/vanish/Vanish.java b/src/com/redstoner/modules/vanish/Vanish.java index 5567dcc..eb0ee58 100644 --- a/src/com/redstoner/modules/vanish/Vanish.java +++ b/src/com/redstoner/modules/vanish/Vanish.java @@ -19,10 +19,9 @@ import com.redstoner.misc.Utils; import com.redstoner.modules.Module; @AutoRegisterListener -@Version(major = 1, minor = 0, revision = 3, compatible = 1) +@Version(major = 2, minor = 0, revision = 0, compatible = 2) public class Vanish implements Module, Listener { - private boolean enabled = false; private ArrayList vanished = new ArrayList(); private HashMap> vanishOthers = new HashMap>(); @@ -201,22 +200,14 @@ public class Vanish implements Module, Listener } @Override - public void onEnable() + public boolean onEnable() { - enabled = true; + return true; } @Override public void onDisable() - { - enabled = false; - } - - @Override - public boolean enabled() - { - return enabled; - } + {} // @noformat @Override diff --git a/src/com/redstoner/modules/warn/Warn.java b/src/com/redstoner/modules/warn/Warn.java index e4afa4f..a62dcb6 100644 --- a/src/com/redstoner/modules/warn/Warn.java +++ b/src/com/redstoner/modules/warn/Warn.java @@ -8,11 +8,9 @@ import com.redstoner.annotations.Version; import com.redstoner.misc.Utils; import com.redstoner.modules.Module; -@Version(major = 1, minor = 0, revision = 1, compatible = 1) +@Version(major = 2, minor = 0, revision = 0, compatible = 2) public class Warn implements Module { - private boolean enabled = false; - @Command(hook = "warn") public void warn_normal(CommandSender sender) { @@ -28,22 +26,14 @@ public class Warn implements Module } @Override - public void onEnable() + public boolean onEnable() { - enabled = true; + return true; } @Override public void onDisable() - { - enabled = false; - } - - @Override - public boolean enabled() - { - return enabled; - } + {} // @noformat @Override diff --git a/src/com/redstoner/modules/webtoken/WebToken.java b/src/com/redstoner/modules/webtoken/WebToken.java index 23bfc7e..db082d3 100644 --- a/src/com/redstoner/modules/webtoken/WebToken.java +++ b/src/com/redstoner/modules/webtoken/WebToken.java @@ -22,17 +22,16 @@ import com.redstoner.misc.mysql.elements.MysqlDatabase; import com.redstoner.misc.mysql.elements.MysqlTable; import com.redstoner.modules.Module; -@Version(major = 1, minor = 1, revision = 1, compatible = 1) +@Version(major = 2, minor = 0, revision = 0, compatible = 2) public class WebToken implements Module { - private boolean enabled = false; private static final int TOKEN_LENGTH = 6; private static final String CONSONANTS = "bcdfghjklmnpqrstvwxyz"; private static final String VOWELS = "aeiou"; private MysqlTable table; @Override - public void onEnable() + public boolean onEnable() { Config config; try @@ -42,16 +41,14 @@ public class WebToken implements Module catch (IOException | ParseException e1) { e1.printStackTrace(); - enabled = false; - return; + return false; } if (config == null || !config.containsKey("database") || !config.containsKey("table")) { Utils.error("Could not load the WebToken config file, disabling!"); config.put("database", "redstoner"); config.put("table", "webtoken"); - enabled = false; - return; + return false; } try { @@ -61,10 +58,9 @@ public class WebToken implements Module catch (NullPointerException e) { Utils.error("Could not use the WebToken config, disabling!"); - enabled = false; - return; + return false; } - enabled = true; + return true; } private String getNextId() throws Exception @@ -206,15 +202,7 @@ public class WebToken implements Module @Override public void onDisable() - { - enabled = false; - } - - @Override - public boolean enabled() - { - return enabled; - } + {} // @noformat @Override -- 2.45.2 From a20169c60fac04d2c0ccac47bd9cc6eef93e0e1e Mon Sep 17 00:00:00 2001 From: Pepich Date: Thu, 2 Mar 2017 20:31:47 +0100 Subject: [PATCH 037/152] Fixed stone generators --- src/com/redstoner/modules/misc/Misc.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/com/redstoner/modules/misc/Misc.java b/src/com/redstoner/modules/misc/Misc.java index 6a982e6..3b84848 100644 --- a/src/com/redstoner/modules/misc/Misc.java +++ b/src/com/redstoner/modules/misc/Misc.java @@ -18,7 +18,7 @@ import com.redstoner.misc.Utils; import com.redstoner.modules.Module; @AutoRegisterListener -@Version(major = 2, minor = 0, revision = 0, compatible = 2) +@Version(major = 2, minor = 0, revision = 1, compatible = 2) public class Misc implements Module, Listener { private final String[] sudoBlacklist = new String[] {".*:?esudo", ".*:?sudo", ".*:?script.*", ".*:?stop"}; @@ -82,8 +82,18 @@ public class Misc implements Module, Listener @EventHandler public void onLiquidFlow(BlockFromToEvent event) { - if (event.getToBlock().getType() != Material.AIR) - event.setCancelled(true); + Material m = event.getToBlock().getType(); + switch (m) + { + case AIR: + case WATER: + case STATIONARY_WATER: + case LAVA: + case STATIONARY_LAVA: + return; + default: + event.setCancelled(true); + } } @Command(hook = "tempadddef") -- 2.45.2 From 20486543cb526b1b77218e44f575af896db8f3fd Mon Sep 17 00:00:00 2001 From: Pepich Date: Thu, 2 Mar 2017 20:44:43 +0100 Subject: [PATCH 038/152] Fixed mentio only working when a space followed on the mentio word --- src/com/redstoner/modules/mentio/Mentio.java | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/com/redstoner/modules/mentio/Mentio.java b/src/com/redstoner/modules/mentio/Mentio.java index dd993a6..968f372 100644 --- a/src/com/redstoner/modules/mentio/Mentio.java +++ b/src/com/redstoner/modules/mentio/Mentio.java @@ -23,7 +23,7 @@ import com.redstoner.misc.Utils; import com.redstoner.modules.Module; @AutoRegisterListener -@Version(major = 2, minor = 0, revision = 0, compatible = 2) +@Version(major = 2, minor = 0, revision = 1, compatible = 2) public class Mentio implements Module, Listener { private File mentioLocation = new File(Main.plugin.getDataFolder(), "mentio.json"); @@ -135,22 +135,19 @@ public class Mentio implements Module, Listener if (event.getMessage().toLowerCase().contains(mentio.toLowerCase())) { event.getRecipients().remove(player); - String temp = event.getMessage().replaceAll("(?i)" + Pattern.quote(mentio), "§§"); + String temp = event.getMessage().replaceAll("(?i)" + Pattern.quote(mentio) + ".*", ""); String lastColorCodes = "§r"; char lastChar = ' '; for (char c : temp.toCharArray()) { - if (lastChar == '§' && c == '§') - break; if (lastChar == '§') lastColorCodes += "§" + c; lastChar = c; } - // Using §§ as a placeholder as it can't occur in minecraft chat message naturally. If another plugin is stupid enough to leave that in, fuck that plugin. Utils.sendMessage(player, "", event.getFormat().replace("%1$s", event.getPlayer().getDisplayName()).replace("%2$s", - temp.replaceFirst("§§([^ ]*) ", "§a§o" + mentio + "$1 " + lastColorCodes) - .replace("§§", mentio))); + event.getMessage().replaceFirst("(?i)(" + Pattern.quote(mentio) + ")([^ ]?+)", + "§a§o$1$2" + lastColorCodes))); player.playSound(player.getLocation(), Sound.ENTITY_CHICKEN_EGG, 1, 1); return; } -- 2.45.2 From 8b2f2cce44af3c9de52761444bc33063761891de Mon Sep 17 00:00:00 2001 From: Pepich Date: Thu, 2 Mar 2017 20:50:45 +0100 Subject: [PATCH 039/152] Hid join/leave messages when vanished --- src/com/redstoner/modules/vanish/Vanish.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/com/redstoner/modules/vanish/Vanish.java b/src/com/redstoner/modules/vanish/Vanish.java index eb0ee58..d01ee19 100644 --- a/src/com/redstoner/modules/vanish/Vanish.java +++ b/src/com/redstoner/modules/vanish/Vanish.java @@ -9,8 +9,10 @@ import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerQuitEvent; import com.nemez.cmdmgr.Command; import com.redstoner.annotations.AutoRegisterListener; @@ -19,7 +21,7 @@ import com.redstoner.misc.Utils; import com.redstoner.modules.Module; @AutoRegisterListener -@Version(major = 2, minor = 0, revision = 0, compatible = 2) +@Version(major = 2, minor = 0, revision = 1, compatible = 2) public class Vanish implements Module, Listener { private ArrayList vanished = new ArrayList(); @@ -125,7 +127,7 @@ public class Vanish implements Module, Listener return true; } - @EventHandler + @EventHandler(priority = EventPriority.HIGHEST) public void onPlayerJoin(PlayerJoinEvent event) { Player player = event.getPlayer(); @@ -133,6 +135,7 @@ public class Vanish implements Module, Listener { for (Player p : Bukkit.getOnlinePlayers()) p.hidePlayer(player); + event.setJoinMessage(null); } if (player.hasPermission("utils.vanish")) return; @@ -155,11 +158,15 @@ public class Vanish implements Module, Listener } } - @EventHandler - public void onPlayerLeave(PlayerJoinEvent event) + @EventHandler(priority = EventPriority.HIGHEST) + public void onPlayerLeave(PlayerQuitEvent event) { Player player = event.getPlayer(); UUID uid = player.getUniqueId(); + if (vanished.contains(player.getUniqueId())) + { + event.setQuitMessage(null); + } if (vanishOthers.containsKey(uid)) { ArrayList toUnvanish = vanishOthers.remove(uid); -- 2.45.2 From 381682c1883ddc001b19047b32c8497645d9fb35 Mon Sep 17 00:00:00 2001 From: Pepich Date: Thu, 2 Mar 2017 21:00:41 +0100 Subject: [PATCH 040/152] Made mentio search greedy --- src/com/redstoner/modules/mentio/Mentio.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/com/redstoner/modules/mentio/Mentio.java b/src/com/redstoner/modules/mentio/Mentio.java index 968f372..ea2598d 100644 --- a/src/com/redstoner/modules/mentio/Mentio.java +++ b/src/com/redstoner/modules/mentio/Mentio.java @@ -23,7 +23,7 @@ import com.redstoner.misc.Utils; import com.redstoner.modules.Module; @AutoRegisterListener -@Version(major = 2, minor = 0, revision = 1, compatible = 2) +@Version(major = 2, minor = 0, revision = 2, compatible = 2) public class Mentio implements Module, Listener { private File mentioLocation = new File(Main.plugin.getDataFolder(), "mentio.json"); @@ -146,7 +146,7 @@ public class Mentio implements Module, Listener } Utils.sendMessage(player, "", event.getFormat().replace("%1$s", event.getPlayer().getDisplayName()).replace("%2$s", - event.getMessage().replaceFirst("(?i)(" + Pattern.quote(mentio) + ")([^ ]?+)", + event.getMessage().replaceFirst("(?i)(" + Pattern.quote(mentio) + ")([^ ]*)", "§a§o$1$2" + lastColorCodes))); player.playSound(player.getLocation(), Sound.ENTITY_CHICKEN_EGG, 1, 1); return; -- 2.45.2 From 1cccf6450f2b0354feb19d9e9d6a05adb4872548 Mon Sep 17 00:00:00 2001 From: Pepich Date: Thu, 2 Mar 2017 21:16:06 +0100 Subject: [PATCH 041/152] Made listeners monitor level to override essentials --- src/com/redstoner/modules/vanish/Vanish.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/com/redstoner/modules/vanish/Vanish.java b/src/com/redstoner/modules/vanish/Vanish.java index d01ee19..52513db 100644 --- a/src/com/redstoner/modules/vanish/Vanish.java +++ b/src/com/redstoner/modules/vanish/Vanish.java @@ -21,7 +21,7 @@ import com.redstoner.misc.Utils; import com.redstoner.modules.Module; @AutoRegisterListener -@Version(major = 2, minor = 0, revision = 1, compatible = 2) +@Version(major = 2, minor = 0, revision = 2, compatible = 2) public class Vanish implements Module, Listener { private ArrayList vanished = new ArrayList(); @@ -127,14 +127,17 @@ public class Vanish implements Module, Listener return true; } - @EventHandler(priority = EventPriority.HIGHEST) + @EventHandler(priority = EventPriority.MONITOR) public void onPlayerJoin(PlayerJoinEvent event) { Player player = event.getPlayer(); if (vanished.contains(player.getUniqueId())) { for (Player p : Bukkit.getOnlinePlayers()) - p.hidePlayer(player); + { + if (!p.hasPermission("utils.vanish")) + p.hidePlayer(player); + } event.setJoinMessage(null); } if (player.hasPermission("utils.vanish")) @@ -158,7 +161,7 @@ public class Vanish implements Module, Listener } } - @EventHandler(priority = EventPriority.HIGHEST) + @EventHandler(priority = EventPriority.MONITOR) public void onPlayerLeave(PlayerQuitEvent event) { Player player = event.getPlayer(); -- 2.45.2 From 9422b8183b9c8a9f76df2f0871dc9b90707f4187 Mon Sep 17 00:00:00 2001 From: Pepich Date: Thu, 2 Mar 2017 21:27:06 +0100 Subject: [PATCH 042/152] Made webtoken accept more datatypes --- .../redstoner/modules/webtoken/WebToken.java | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/com/redstoner/modules/webtoken/WebToken.java b/src/com/redstoner/modules/webtoken/WebToken.java index db082d3..239318c 100644 --- a/src/com/redstoner/modules/webtoken/WebToken.java +++ b/src/com/redstoner/modules/webtoken/WebToken.java @@ -22,7 +22,7 @@ import com.redstoner.misc.mysql.elements.MysqlDatabase; import com.redstoner.misc.mysql.elements.MysqlTable; import com.redstoner.modules.Module; -@Version(major = 2, minor = 0, revision = 0, compatible = 2) +@Version(major = 2, minor = 0, revision = 2, compatible = 2) public class WebToken implements Module { private static final int TOKEN_LENGTH = 6; @@ -66,18 +66,14 @@ public class WebToken implements Module private String getNextId() throws Exception { Object[] results = table.get("select id from register_tokens order by id desc limit 1;"); - if (results instanceof String[]) + if (results[0] instanceof Integer) { - String[] tokenResults = (String[]) results; - if (tokenResults.length == 1) - { - int id = Integer.valueOf(tokenResults[0]); - return "" + ++id; - } - else - { - return null; - } + return ((int) results[0]) + 1 + ""; + } + else if (results[0] instanceof String) + { + int id = Integer.valueOf((String) results[0]); + return id + 1 + ""; } else { -- 2.45.2 From a0940ba9e407d7fd817dd454f3164d4fe78afb55 Mon Sep 17 00:00:00 2001 From: Pepich Date: Thu, 2 Mar 2017 21:36:29 +0100 Subject: [PATCH 043/152] Fixed chatgroup join/leave messages --- src/com/redstoner/modules/chatgroups/Chatgroups.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/com/redstoner/modules/chatgroups/Chatgroups.java b/src/com/redstoner/modules/chatgroups/Chatgroups.java index bf1e9ed..44bd101 100644 --- a/src/com/redstoner/modules/chatgroups/Chatgroups.java +++ b/src/com/redstoner/modules/chatgroups/Chatgroups.java @@ -26,7 +26,7 @@ import com.redstoner.modules.Module; * * @author Pepich */ @AutoRegisterListener -@Version(major = 2, minor = 0, revision = 0, compatible = 2) +@Version(major = 2, minor = 0, revision = 1, compatible = 2) public class Chatgroups implements Module, Listener { private static final char defaultKey = ':'; @@ -376,7 +376,7 @@ public class Chatgroups implements Module, Listener * @param message the message to be sent. */ private void sendToGroup(String group, String message) { - Utils.broadcast(null, "message", new BroadcastFilter() + Utils.broadcast(null, message, new BroadcastFilter() { @Override public boolean sendTo(CommandSender recipient) -- 2.45.2 From f766925bde4fdc52993d5e2813c8a4c10186a15e Mon Sep 17 00:00:00 2001 From: minenash Date: Thu, 2 Mar 2017 18:36:08 -0500 Subject: [PATCH 044/152] Removed onEnable and/or onDisable --- src/com/redstoner/modules/abot/Abot.java | 6 +----- src/com/redstoner/modules/adminchat/Adminchat.java | 6 +----- src/com/redstoner/modules/check/Check.java | 6 +----- src/com/redstoner/modules/clear/Clear.java | 14 ++------------ src/com/redstoner/modules/damnspam/DamnSpam.java | 6 +----- .../modules/illumination/Illumination.java | 12 +----------- src/com/redstoner/modules/imout/Imout.java | 12 +----------- src/com/redstoner/modules/lagchunks/LagChunks.java | 12 +----------- .../modules/loginsecurity/LoginSecurity.java | 6 +----- src/com/redstoner/modules/misc/Misc.java | 12 +----------- src/com/redstoner/modules/motd/Motd.java | 6 +----- src/com/redstoner/modules/nametags/Nametags.java | 11 +---------- src/com/redstoner/modules/naming/Naming.java | 12 +----------- src/com/redstoner/modules/pmtoggle/Pmtoggle.java | 12 +----------- .../redstoner/modules/scriptutils/Scriptutils.java | 12 +----------- .../redstoner/modules/skullclick/SkullClick.java | 12 +----------- src/com/redstoner/modules/vanish/Vanish.java | 12 +----------- src/com/redstoner/modules/warn/Warn.java | 12 +----------- src/com/redstoner/modules/webtoken/WebToken.java | 6 +----- 19 files changed, 20 insertions(+), 167 deletions(-) diff --git a/src/com/redstoner/modules/abot/Abot.java b/src/com/redstoner/modules/abot/Abot.java index 8103dcb..97688e8 100644 --- a/src/com/redstoner/modules/abot/Abot.java +++ b/src/com/redstoner/modules/abot/Abot.java @@ -19,7 +19,7 @@ import com.redstoner.misc.Utils; import com.redstoner.modules.Module; @AutoRegisterListener -@Version(major = 2, minor = 0, revision = 0, compatible = 2) +@Version(major = 2, minor = 0, revision = 1, compatible = 2) public class Abot implements Module, Listener { private File answerFile = new File(Main.plugin.getDataFolder(), "abot.json"); @@ -64,10 +64,6 @@ public class Abot implements Module, Listener return true; } - @Override - public void onDisable() - {} - // @noformat @Override public String getCommandString() diff --git a/src/com/redstoner/modules/adminchat/Adminchat.java b/src/com/redstoner/modules/adminchat/Adminchat.java index 7c5aaf4..9fb529a 100644 --- a/src/com/redstoner/modules/adminchat/Adminchat.java +++ b/src/com/redstoner/modules/adminchat/Adminchat.java @@ -24,7 +24,7 @@ import com.redstoner.modules.Module; * * @author Pepich */ @AutoRegisterListener -@Version(major = 2, minor = 0, revision = 0, compatible = 2) +@Version(major = 2, minor = 0, revision = 1, compatible = 2) public class Adminchat implements Module, Listener { private static final char defaultKey = ','; @@ -45,10 +45,6 @@ public class Adminchat implements Module, Listener return true; } - @Override - public void onDisable() - {} - // @noformat @Override public String getCommandString() diff --git a/src/com/redstoner/modules/check/Check.java b/src/com/redstoner/modules/check/Check.java index a2ee75f..d6219b4 100644 --- a/src/com/redstoner/modules/check/Check.java +++ b/src/com/redstoner/modules/check/Check.java @@ -31,7 +31,7 @@ import com.redstoner.misc.mysql.elements.MysqlDatabase; import com.redstoner.misc.mysql.elements.MysqlTable; import com.redstoner.modules.Module; -@Version(major = 2, minor = 0, revision = 0, compatible = 2) +@Version(major = 2, minor = 0, revision = 1, compatible = 2) public class Check implements Module, Listener { MysqlTable table; @@ -239,8 +239,4 @@ public class Check implements Module, Listener "}"; } // @format - - @Override - public void onDisable() - {} } diff --git a/src/com/redstoner/modules/clear/Clear.java b/src/com/redstoner/modules/clear/Clear.java index 139a6e0..e50844c 100644 --- a/src/com/redstoner/modules/clear/Clear.java +++ b/src/com/redstoner/modules/clear/Clear.java @@ -9,19 +9,9 @@ import com.redstoner.annotations.Version; import com.redstoner.misc.Utils; import com.redstoner.modules.Module; -@Version(major = 2, minor = 0, revision = 0, compatible = 2) +@Version(major = 2, minor = 0, revision = 1, compatible = 2) public class Clear implements Module -{ - @Override - public boolean onEnable() - { - return true; - } - - @Override - public void onDisable() - {} - +{ @Command(hook = "clear") public boolean clearInventory(CommandSender sender) { diff --git a/src/com/redstoner/modules/damnspam/DamnSpam.java b/src/com/redstoner/modules/damnspam/DamnSpam.java index 4d59484..8b9d0fa 100644 --- a/src/com/redstoner/modules/damnspam/DamnSpam.java +++ b/src/com/redstoner/modules/damnspam/DamnSpam.java @@ -37,7 +37,7 @@ import com.redstoner.misc.Utils; import com.redstoner.modules.Module; @AutoRegisterListener -@Version(major = 2, minor = 0, revision = 0, compatible = 2) +@Version(major = 2, minor = 0, revision = 1, compatible = 2) public class DamnSpam implements Module, Listener { File configFile = new File(Main.plugin.getDataFolder(), "DamnSpam.json"); @@ -343,10 +343,6 @@ public class DamnSpam implements Module, Listener } } - @Override - public void onDisable() - {} - // @noformat @Override public String getCommandString() diff --git a/src/com/redstoner/modules/illumination/Illumination.java b/src/com/redstoner/modules/illumination/Illumination.java index 20e2926..b18276c 100644 --- a/src/com/redstoner/modules/illumination/Illumination.java +++ b/src/com/redstoner/modules/illumination/Illumination.java @@ -10,7 +10,7 @@ import com.redstoner.annotations.Version; import com.redstoner.misc.Utils; import com.redstoner.modules.Module; -@Version(major = 2, minor = 0, revision = 0, compatible = 2) +@Version(major = 2, minor = 0, revision = 1, compatible = 2) public class Illumination implements Module { PotionEffect effect = new PotionEffect(PotionEffectType.NIGHT_VISION, Integer.MAX_VALUE, 0, false, false); @@ -31,16 +31,6 @@ public class Illumination implements Module } } - @Override - public boolean onEnable() - { - return true; - } - - @Override - public void onDisable() - {} - // @noformat @Override public String getCommandString() diff --git a/src/com/redstoner/modules/imout/Imout.java b/src/com/redstoner/modules/imout/Imout.java index c5f1200..463800f 100644 --- a/src/com/redstoner/modules/imout/Imout.java +++ b/src/com/redstoner/modules/imout/Imout.java @@ -11,7 +11,7 @@ import com.redstoner.annotations.Version; import com.redstoner.misc.Utils; import com.redstoner.modules.Module; -@Version(major = 2, minor = 0, revision = 0, compatible = 2) +@Version(major = 2, minor = 0, revision = 1, compatible = 2) public class Imout implements Module { List imout_toggle_list = new ArrayList(); @@ -42,16 +42,6 @@ public class Imout implements Module Utils.broadcast(symbol, " §7" + name, null); } - @Override - public boolean onEnable() - { - return true; - } - - @Override - public void onDisable() - {} - // @noformat @Override public String getCommandString() diff --git a/src/com/redstoner/modules/lagchunks/LagChunks.java b/src/com/redstoner/modules/lagchunks/LagChunks.java index b0de6a6..abbf048 100644 --- a/src/com/redstoner/modules/lagchunks/LagChunks.java +++ b/src/com/redstoner/modules/lagchunks/LagChunks.java @@ -16,7 +16,7 @@ import com.redstoner.annotations.Version; import com.redstoner.misc.Utils; import com.redstoner.modules.Module; -@Version(major = 2, minor = 0, revision = 0, compatible = 2) +@Version(major = 2, minor = 0, revision = 1, compatible = 2) public class LagChunks implements Module { private List laggyChunks = new ArrayList(); @@ -77,16 +77,6 @@ public class LagChunks implements Module } } - @Override - public boolean onEnable() - { - return true; - } - - @Override - public void onDisable() - {} - // @noformat @Override public String getCommandString() diff --git a/src/com/redstoner/modules/loginsecurity/LoginSecurity.java b/src/com/redstoner/modules/loginsecurity/LoginSecurity.java index 38513ee..38129c5 100644 --- a/src/com/redstoner/modules/loginsecurity/LoginSecurity.java +++ b/src/com/redstoner/modules/loginsecurity/LoginSecurity.java @@ -34,7 +34,7 @@ import com.redstoner.misc.mysql.types.text.VarChar; import com.redstoner.modules.Module; @AutoRegisterListener -@Version(major = 2, minor = 0, revision = 0, compatible = 2) +@Version(major = 2, minor = 0, revision = 1, compatible = 2) public class LoginSecurity implements Module, Listener { protected static Map loggingIn; @@ -260,10 +260,6 @@ public class LoginSecurity implements Module, Listener return table.insert(player.getUniqueId().toString(), toInsert); } - @Override - public void onDisable() - {} - // @noformat @Override public String getCommandString() diff --git a/src/com/redstoner/modules/misc/Misc.java b/src/com/redstoner/modules/misc/Misc.java index 3b84848..cc9d89c 100644 --- a/src/com/redstoner/modules/misc/Misc.java +++ b/src/com/redstoner/modules/misc/Misc.java @@ -18,21 +18,11 @@ import com.redstoner.misc.Utils; import com.redstoner.modules.Module; @AutoRegisterListener -@Version(major = 2, minor = 0, revision = 1, compatible = 2) +@Version(major = 2, minor = 0, revision = 2, compatible = 2) public class Misc implements Module, Listener { private final String[] sudoBlacklist = new String[] {".*:?esudo", ".*:?sudo", ".*:?script.*", ".*:?stop"}; - @Override - public boolean onEnable() - { - return true; - } - - @Override - public void onDisable() - {} - @EventHandler public void onFirstJoin(PlayerJoinEvent event) { diff --git a/src/com/redstoner/modules/motd/Motd.java b/src/com/redstoner/modules/motd/Motd.java index 0ce1d21..95e578f 100644 --- a/src/com/redstoner/modules/motd/Motd.java +++ b/src/com/redstoner/modules/motd/Motd.java @@ -12,7 +12,7 @@ import com.redstoner.misc.Utils; import com.redstoner.modules.Module; @AutoRegisterListener -@Version(major = 2, minor = 0, revision = 0, compatible = 2) +@Version(major = 2, minor = 0, revision = 1, compatible = 2) public class Motd implements Module { private String default_motd, motd; @@ -48,10 +48,6 @@ public class Motd implements Module return true; } - @Override - public void onDisable() - {} - // @noformat @Override public String getCommandString() diff --git a/src/com/redstoner/modules/nametags/Nametags.java b/src/com/redstoner/modules/nametags/Nametags.java index eaa0f3c..8733df1 100644 --- a/src/com/redstoner/modules/nametags/Nametags.java +++ b/src/com/redstoner/modules/nametags/Nametags.java @@ -16,18 +16,9 @@ import com.redstoner.misc.Utils; import com.redstoner.modules.Module; @AutoRegisterListener -@Version(major = 2, minor = 0, revision = 0, compatible = 2) +@Version(major = 2, minor = 0, revision = 1, compatible = 2) public class Nametags implements Module, Listener { - @Override - public boolean onEnable() - { - return true; - } - - @Override - public void onDisable() - {} @EventHandler public void onPlayerJoin(PlayerJoinEvent event) diff --git a/src/com/redstoner/modules/naming/Naming.java b/src/com/redstoner/modules/naming/Naming.java index 715d855..c117b4b 100644 --- a/src/com/redstoner/modules/naming/Naming.java +++ b/src/com/redstoner/modules/naming/Naming.java @@ -22,7 +22,7 @@ import net.minecraft.server.v1_11_R1.EntityHuman; import net.minecraft.server.v1_11_R1.EntityPlayer; import net.minecraft.server.v1_11_R1.PacketPlayOutOpenWindow; -@Version(major = 2, minor = 0, revision = 0, compatible = 2) +@Version(major = 2, minor = 0, revision = 1, compatible = 2) public class Naming implements Module { @Command(hook = "anvil") @@ -87,16 +87,6 @@ public class Naming implements Module } } - @Override - public boolean onEnable() - { - return true; - } - - @Override - public void onDisable() - {} - // @noformat @Override public String getCommandString() diff --git a/src/com/redstoner/modules/pmtoggle/Pmtoggle.java b/src/com/redstoner/modules/pmtoggle/Pmtoggle.java index e5e983f..c5df720 100644 --- a/src/com/redstoner/modules/pmtoggle/Pmtoggle.java +++ b/src/com/redstoner/modules/pmtoggle/Pmtoggle.java @@ -19,21 +19,11 @@ import com.redstoner.misc.Utils; import com.redstoner.modules.Module; @AutoRegisterListener -@Version(major = 2, minor = 0, revision = 0, compatible = 2) +@Version(major = 2, minor = 0, revision = 1, compatible = 2) public class Pmtoggle implements Module, Listener { HashMap toggles = new HashMap(); - @Override - public boolean onEnable() - { - return true; - } - - @Override - public void onDisable() - {} - @Command(hook = "pmtoggle_off", async = AsyncType.ALWAYS) public boolean pmtoggle_off(CommandSender sender) { diff --git a/src/com/redstoner/modules/scriptutils/Scriptutils.java b/src/com/redstoner/modules/scriptutils/Scriptutils.java index b1dc937..9818817 100644 --- a/src/com/redstoner/modules/scriptutils/Scriptutils.java +++ b/src/com/redstoner/modules/scriptutils/Scriptutils.java @@ -8,7 +8,7 @@ import com.redstoner.annotations.Version; import com.redstoner.misc.Utils; import com.redstoner.modules.Module; -@Version(major = 2, minor = 0, revision = 0, compatible = 2) +@Version(major = 2, minor = 0, revision = 1, compatible = 2) public class Scriptutils implements Module { /** Prints Bukkit restart message @@ -172,16 +172,6 @@ public class Scriptutils implements Module Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "stop"); } - @Override - public boolean onEnable() - { - return true; - } - - @Override - public void onDisable() - {} - // @noformat @Override public String getCommandString() diff --git a/src/com/redstoner/modules/skullclick/SkullClick.java b/src/com/redstoner/modules/skullclick/SkullClick.java index 5608d29..d4bddb2 100644 --- a/src/com/redstoner/modules/skullclick/SkullClick.java +++ b/src/com/redstoner/modules/skullclick/SkullClick.java @@ -12,7 +12,7 @@ import com.redstoner.annotations.Version; import com.redstoner.misc.Utils; import com.redstoner.modules.Module; -@Version(major = 1, minor = 0, revision = 0, compatible = 1) +@Version(major = 1, minor = 0, revision = 1, compatible = 1) @AutoRegisterListener public class SkullClick implements Module, Listener { @@ -52,16 +52,6 @@ public class SkullClick implements Module, Listener } } - @Override - public boolean onEnable() - { - return true; - } - - @Override - public void onDisable() - {} - @Override public String getCommandString() { diff --git a/src/com/redstoner/modules/vanish/Vanish.java b/src/com/redstoner/modules/vanish/Vanish.java index 52513db..d7eb372 100644 --- a/src/com/redstoner/modules/vanish/Vanish.java +++ b/src/com/redstoner/modules/vanish/Vanish.java @@ -21,7 +21,7 @@ import com.redstoner.misc.Utils; import com.redstoner.modules.Module; @AutoRegisterListener -@Version(major = 2, minor = 0, revision = 2, compatible = 2) +@Version(major = 2, minor = 0, revision = 3, compatible = 2) public class Vanish implements Module, Listener { private ArrayList vanished = new ArrayList(); @@ -209,16 +209,6 @@ public class Vanish implements Module, Listener p.showPlayer(player); } - @Override - public boolean onEnable() - { - return true; - } - - @Override - public void onDisable() - {} - // @noformat @Override public String getCommandString() diff --git a/src/com/redstoner/modules/warn/Warn.java b/src/com/redstoner/modules/warn/Warn.java index a62dcb6..53202a1 100644 --- a/src/com/redstoner/modules/warn/Warn.java +++ b/src/com/redstoner/modules/warn/Warn.java @@ -8,7 +8,7 @@ import com.redstoner.annotations.Version; import com.redstoner.misc.Utils; import com.redstoner.modules.Module; -@Version(major = 2, minor = 0, revision = 0, compatible = 2) +@Version(major = 2, minor = 0, revision = 1, compatible = 2) public class Warn implements Module { @Command(hook = "warn") @@ -25,16 +25,6 @@ public class Warn implements Module Utils.broadcast(null, "§2Possible lag incoming! - §9" + name, null); } - @Override - public boolean onEnable() - { - return true; - } - - @Override - public void onDisable() - {} - // @noformat @Override public String getCommandString() diff --git a/src/com/redstoner/modules/webtoken/WebToken.java b/src/com/redstoner/modules/webtoken/WebToken.java index 239318c..0418a38 100644 --- a/src/com/redstoner/modules/webtoken/WebToken.java +++ b/src/com/redstoner/modules/webtoken/WebToken.java @@ -22,7 +22,7 @@ import com.redstoner.misc.mysql.elements.MysqlDatabase; import com.redstoner.misc.mysql.elements.MysqlTable; import com.redstoner.modules.Module; -@Version(major = 2, minor = 0, revision = 2, compatible = 2) +@Version(major = 2, minor = 0, revision = 3, compatible = 2) public class WebToken implements Module { private static final int TOKEN_LENGTH = 6; @@ -196,10 +196,6 @@ public class WebToken implements Module } } - @Override - public void onDisable() - {} - // @noformat @Override public String getCommandString() -- 2.45.2 From 2e308f2c7b247d8176735bbefdaa49fb320fcdf7 Mon Sep 17 00:00:00 2001 From: minenash Date: Thu, 2 Mar 2017 18:37:29 -0500 Subject: [PATCH 045/152] Added defaults for onEnable and onDisable --- src/com/redstoner/modules/Module.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/com/redstoner/modules/Module.java b/src/com/redstoner/modules/Module.java index dc9e4eb..8caa732 100644 --- a/src/com/redstoner/modules/Module.java +++ b/src/com/redstoner/modules/Module.java @@ -5,14 +5,17 @@ import com.redstoner.annotations.Version; /** Interface for the Module class. Modules must always have an empty constructor to be invoked by the ModuleLoader. * * @author Pepich */ -@Version(major = 1, minor = 1, revision = 1, compatible = 1) +@Version(major = 1, minor = 2, revision = 0, compatible = 1) public interface Module { /** Will be called when the module gets enabled. */ - public boolean onEnable(); + public default boolean onEnable() { + return true; + } /** Will be called when the module gets disabled. */ - public void onDisable(); + public default void onDisable() + {} /** Gets called on registration of the module. * -- 2.45.2 From a900dc18d42497f0fd9379d0607e6cfb7fcda7de Mon Sep 17 00:00:00 2001 From: Minenash Date: Fri, 3 Mar 2017 20:34:25 -0500 Subject: [PATCH 046/152] Added FirstSeen Module --- src/com/redstoner/misc/Main.java | 4 +- .../modules/firstseen/FirstSeen.java | 62 +++++++++++++++++++ 2 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 src/com/redstoner/modules/firstseen/FirstSeen.java diff --git a/src/com/redstoner/misc/Main.java b/src/com/redstoner/misc/Main.java index a4e067a..715a28e 100644 --- a/src/com/redstoner/misc/Main.java +++ b/src/com/redstoner/misc/Main.java @@ -17,6 +17,7 @@ import com.redstoner.modules.clear.Clear; import com.redstoner.modules.clearonjoin.ClearOnJoin; import com.redstoner.modules.cycle.Cycle; import com.redstoner.modules.damnspam.DamnSpam; +import com.redstoner.modules.firstseen.FirstSeen; import com.redstoner.modules.illumination.Illumination; import com.redstoner.modules.imout.Imout; import com.redstoner.modules.lagchunks.LagChunks; @@ -39,7 +40,7 @@ import com.redstoner.modules.webtoken.WebToken; /** Main class. Duh. * * @author Pepich */ -@Version(major = 1, minor = 4, revision = 2, compatible = -1) +@Version(major = 1, minor = 5, revision = 0, compatible = -1) public class Main extends JavaPlugin { public static JavaPlugin plugin; @@ -64,6 +65,7 @@ public class Main extends JavaPlugin ModuleLoader.addModule(Chatgroups.class); ModuleLoader.addModule(Check.class); ModuleLoader.addModule(DamnSpam.class); + ModuleLoader.addModule(FirstSeen.class); // TODO: ModuleLoader.addModule(Friends.class); ModuleLoader.addModule(Illumination.class); // TODO: ModuleLoader.addModule(Imbusy.class); diff --git a/src/com/redstoner/modules/firstseen/FirstSeen.java b/src/com/redstoner/modules/firstseen/FirstSeen.java new file mode 100644 index 0000000..81ea56a --- /dev/null +++ b/src/com/redstoner/modules/firstseen/FirstSeen.java @@ -0,0 +1,62 @@ +package com.redstoner.modules.firstseen; + +import java.text.SimpleDateFormat; +import java.util.Date; + +import org.bukkit.Bukkit; +import org.bukkit.OfflinePlayer; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import com.nemez.cmdmgr.Command; +import com.redstoner.annotations.Version; +import com.redstoner.misc.Utils; +import com.redstoner.modules.Module; + +@Version(major = 2, minor = 0, revision = 0, compatible = 2) +public class FirstSeen implements Module{ + + @SuppressWarnings("deprecation") + @Command(hook = "firstseenP") + public void firstseen(CommandSender sender, String person) + { + Player player = (Player) sender; + Utils.sendMessage(sender, "", "&7Please note that the data may not be fully accurate!", '&'); + OfflinePlayer oPlayer = Bukkit.getPlayer(person); + if (oPlayer == null) + oPlayer = Bukkit.getServer().getOfflinePlayer(person); + Long firstJoin = oPlayer.getFirstPlayed(); + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm"); + String disDate = format.format( new Date(firstJoin) ); + if( disDate.equals("1969-12-31 19:00") ) { + Utils.sendMessage(player, null, "&3" + oPlayer.getName() + "&c has never joined.", '&'); + } + else { + Utils.sendMessage(player, null, "&3" + oPlayer.getName() + " &efirst joined&a " + disDate + "&e.", '&'); + } + } + @Command(hook = "firstseen") + public void firstseen(CommandSender sender) + { + firstseen(sender, sender.getName()); + } + + + @Override + public String getCommandString() { + return "command firstseen {\n" + + " [empty] {\n" + + " run firstseen;\n" + + " type player;\n" + + " help Gives the date and time they first joined;\n" + + " perm utils.firstseen;\n" + + " }\n" + + " [string:person] {\n" + + " run firstseenP person;\n" + + " type player;\n" + + " help Gives the date and time when a player first joined;\n" + + " perm utils.firstseen.other;\n" + + " }\n" + + "}"; + } +} -- 2.45.2 From 858d290d759fc6e5b1ae6499d6bb2eea92b46c43 Mon Sep 17 00:00:00 2001 From: Minenash Date: Fri, 3 Mar 2017 20:42:51 -0500 Subject: [PATCH 047/152] Fixed Colors --- src/com/redstoner/modules/challenge/Challenge.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/com/redstoner/modules/challenge/Challenge.java b/src/com/redstoner/modules/challenge/Challenge.java index 0ebb831..454ad38 100644 --- a/src/com/redstoner/modules/challenge/Challenge.java +++ b/src/com/redstoner/modules/challenge/Challenge.java @@ -13,7 +13,7 @@ import com.redstoner.misc.Main; import com.redstoner.misc.Utils; import com.redstoner.modules.Module; -@Version(major = 2, minor = 0, revision = 0, compatible = 2) +@Version(major = 2, minor = 0, revision = 1, compatible = 2) public class Challenge implements Module { private File challengeLocation = new File(Main.plugin.getDataFolder(), "challenges.json"); @@ -43,7 +43,7 @@ public class Challenge implements Module else { Utils.sendMessage(sender, null, "Successfully added a new challenge!"); - challenges.add("&a" + text); + challenges.add(text); saveChallenges(); } return true; @@ -101,7 +101,7 @@ public class Challenge implements Module Utils.sendErrorMessage(sender, null, "The ID must be at least 0 and at most " + (challenges.size() - 1)); return true; } - Utils.sendMessage(sender, null, challenges.get(id) + "", '&'); + Utils.sendMessage(sender, null, "&a" + challenges.get(id), '&'); return true; } @@ -114,7 +114,6 @@ public class Challenge implements Module return true; } int id = (new Random()).nextInt(challenges.size()); - Utils.sendMessage(sender, null, challenges.get(id) + "", '&'); return true; } -- 2.45.2 From c4c6db7f61fb2a12b8f1207d368740cf82520609 Mon Sep 17 00:00:00 2001 From: Minenash Date: Fri, 3 Mar 2017 20:45:44 -0500 Subject: [PATCH 048/152] Fixed accidental line deletion. --- src/com/redstoner/modules/challenge/Challenge.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/com/redstoner/modules/challenge/Challenge.java b/src/com/redstoner/modules/challenge/Challenge.java index 454ad38..0d020a8 100644 --- a/src/com/redstoner/modules/challenge/Challenge.java +++ b/src/com/redstoner/modules/challenge/Challenge.java @@ -114,6 +114,7 @@ public class Challenge implements Module return true; } int id = (new Random()).nextInt(challenges.size()); + Utils.sendMessage(sender, null, "&a" + challenges.get(id), '&'); return true; } -- 2.45.2 From d1a68a36ba2ce123f545b29b95a47e95c76049da Mon Sep 17 00:00:00 2001 From: Minenash Date: Fri, 3 Mar 2017 21:19:07 -0500 Subject: [PATCH 049/152] Added a period. --- src/com/redstoner/modules/clearonjoin/ClearOnJoin.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/com/redstoner/modules/clearonjoin/ClearOnJoin.java b/src/com/redstoner/modules/clearonjoin/ClearOnJoin.java index 1bb8f1b..8d1f1ee 100644 --- a/src/com/redstoner/modules/clearonjoin/ClearOnJoin.java +++ b/src/com/redstoner/modules/clearonjoin/ClearOnJoin.java @@ -17,7 +17,7 @@ import com.redstoner.misc.Main; import com.redstoner.misc.Utils; import com.redstoner.modules.Module; -@Version(major = 2, minor = 0, revision = 0, compatible = 2) +@Version(major = 2, minor = 0, revision = 1, compatible = 2) public class ClearOnJoin implements Module, Listener { private File listLocation = new File(Main.plugin.getDataFolder(), "clearonjoins.json"); @@ -40,7 +40,7 @@ public class ClearOnJoin implements Module, Listener if (list.contains(name)) { list.remove(name); - Utils.sendMessage(sender, null, "Your inventory will no longer be cleared apon joining"); + Utils.sendMessage(sender, null, "Your inventory will no longer be cleared apon joining."); saveList(); return; } -- 2.45.2 From e26775eea17812270baf1e7c9ef8c9bf6bb5b15a Mon Sep 17 00:00:00 2001 From: Minenash Date: Sat, 4 Mar 2017 11:20:05 -0500 Subject: [PATCH 050/152] Fixed stuff. --- src/com/redstoner/modules/clearonjoin/ClearOnJoin.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/com/redstoner/modules/clearonjoin/ClearOnJoin.java b/src/com/redstoner/modules/clearonjoin/ClearOnJoin.java index 8d1f1ee..57c68a3 100644 --- a/src/com/redstoner/modules/clearonjoin/ClearOnJoin.java +++ b/src/com/redstoner/modules/clearonjoin/ClearOnJoin.java @@ -29,7 +29,7 @@ public class ClearOnJoin implements Module, Listener { list.add("!" + player.toLowerCase()); saveList(); - Utils.sendMessage(sender, null, player + "'s inventory will be cleared next time he joins."); + Utils.sendMessage(sender, null, player + "'s inventory will be cleared next time they joins."); } @SuppressWarnings("unchecked") @@ -40,17 +40,17 @@ public class ClearOnJoin implements Module, Listener if (list.contains(name)) { list.remove(name); - Utils.sendMessage(sender, null, "Your inventory will no longer be cleared apon joining."); + Utils.sendMessage(sender, null, "Your inventory will no longer be cleared upon joining."); saveList(); return; } list.add(name); saveList(); - Utils.sendMessage(sender, null, "Your inventory will now be cleared apon joining."); + Utils.sendMessage(sender, null, "Your inventory will now be cleared upon joining."); } @EventHandler - public void aponJoin(PlayerJoinEvent e) + public void uponJoin(PlayerJoinEvent e) { Player player = e.getPlayer(); String playerName = player.getName().toLowerCase(); -- 2.45.2 From 57899690b2fd4a16216562f43134af63018ac70d Mon Sep 17 00:00:00 2001 From: Minenash Date: Sat, 4 Mar 2017 11:20:43 -0500 Subject: [PATCH 051/152] Fixed version num --- .../modules/clearonjoin/ClearOnJoin.java | 20 +++++++------------ 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/src/com/redstoner/modules/clearonjoin/ClearOnJoin.java b/src/com/redstoner/modules/clearonjoin/ClearOnJoin.java index 57c68a3..f17a4d5 100644 --- a/src/com/redstoner/modules/clearonjoin/ClearOnJoin.java +++ b/src/com/redstoner/modules/clearonjoin/ClearOnJoin.java @@ -17,7 +17,7 @@ import com.redstoner.misc.Main; import com.redstoner.misc.Utils; import com.redstoner.modules.Module; -@Version(major = 2, minor = 0, revision = 1, compatible = 2) +@Version(major = 2, minor = 1, revision = 0, compatible = 2) public class ClearOnJoin implements Module, Listener { private File listLocation = new File(Main.plugin.getDataFolder(), "clearonjoins.json"); @@ -36,7 +36,7 @@ public class ClearOnJoin implements Module, Listener @Command(hook = "clearonjoinself") public void clearOnJoinSelf(CommandSender sender) { - String name = sender.getName().toLowerCase(); + String name = ((Player)sender).getUniqueId().toString(); if (list.contains(name)) { list.remove(name); @@ -53,18 +53,18 @@ public class ClearOnJoin implements Module, Listener public void uponJoin(PlayerJoinEvent e) { Player player = e.getPlayer(); - String playerName = player.getName().toLowerCase(); + String playerName = player.getUniqueId().toString(); if (list.contains(playerName)) { e.getPlayer().getInventory().clear(); - Utils.sendMessage(e.getPlayer(), null, "Inventory Cleared."); + Utils.sendMessage(player, null, "Inventory cleared."); } else if (list.contains("!" + playerName)) { - e.getPlayer().getInventory().clear(); + player.getInventory().clear(); list.remove("!" + playerName); saveList(); - Utils.sendMessage(e.getPlayer(), null, "Inventory Cleared."); + Utils.sendMessage(player, null, "Inventory cleared."); } } @@ -83,19 +83,13 @@ public class ClearOnJoin implements Module, Listener return true; } - @Override - public void onDisable() - { - saveList(); - } - // @noformat @Override public String getCommandString() { return "command clearonjoin {\n" + " [string:name] {\n" + - " help Clears that players inventory the nect time they join.;\n" + + " help Clears that player's inventory the nect time they join.;\n" + " run clearonjoin name;\n" + " perm utils.clearonjoin.other;\n" + " }\n" + -- 2.45.2 From 56a3a262abd7db2078a4c7c101a5e85190cf2aa6 Mon Sep 17 00:00:00 2001 From: Minenash Date: Sat, 4 Mar 2017 11:52:11 -0500 Subject: [PATCH 052/152] Changed to UUID saving and Fixed grammar/spelling errors. --- .../redstoner/modules/clearonjoin/ClearOnJoin.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/com/redstoner/modules/clearonjoin/ClearOnJoin.java b/src/com/redstoner/modules/clearonjoin/ClearOnJoin.java index f17a4d5..b818563 100644 --- a/src/com/redstoner/modules/clearonjoin/ClearOnJoin.java +++ b/src/com/redstoner/modules/clearonjoin/ClearOnJoin.java @@ -23,13 +23,13 @@ public class ClearOnJoin implements Module, Listener private File listLocation = new File(Main.plugin.getDataFolder(), "clearonjoins.json"); private JSONArray list; - @SuppressWarnings("unchecked") + @SuppressWarnings({ "unchecked", "deprecation" }) @Command(hook = "clearonjoin") public void clearOnJoin(CommandSender sender, String player) { - list.add("!" + player.toLowerCase()); + list.add("!" + Bukkit.getServer().getOfflinePlayer(player).getUniqueId().toString()); saveList(); - Utils.sendMessage(sender, null, player + "'s inventory will be cleared next time they joins."); + Utils.sendMessage(sender, null, player + "'s inventory will be cleared next time they join."); } @SuppressWarnings("unchecked") @@ -53,8 +53,9 @@ public class ClearOnJoin implements Module, Listener public void uponJoin(PlayerJoinEvent e) { Player player = e.getPlayer(); - String playerName = player.getUniqueId().toString(); - if (list.contains(playerName)) + String playerUUID = player.getUniqueId().toString(); + String playerName = player.getName(); + if (list.contains(playerName) || list.contains(playerUUID)) { e.getPlayer().getInventory().clear(); Utils.sendMessage(player, null, "Inventory cleared."); @@ -89,7 +90,7 @@ public class ClearOnJoin implements Module, Listener { return "command clearonjoin {\n" + " [string:name] {\n" + - " help Clears that player's inventory the nect time they join.;\n" + + " help Clears that player's inventory the next time they join.;\n" + " run clearonjoin name;\n" + " perm utils.clearonjoin.other;\n" + " }\n" + -- 2.45.2 From cacc6a2b951308e25b204d0418519096182ba57a Mon Sep 17 00:00:00 2001 From: Pepich Date: Fri, 10 Mar 2017 13:44:00 +0100 Subject: [PATCH 053/152] Expanded functionality of VersionHelper --- src/com/redstoner/misc/VersionHelper.java | 108 ++++++++++++++++++++-- 1 file changed, 98 insertions(+), 10 deletions(-) diff --git a/src/com/redstoner/misc/VersionHelper.java b/src/com/redstoner/misc/VersionHelper.java index 86a5381..f815c7c 100644 --- a/src/com/redstoner/misc/VersionHelper.java +++ b/src/com/redstoner/misc/VersionHelper.java @@ -1,34 +1,79 @@ package com.redstoner.misc; +import java.lang.annotation.Annotation; + import com.redstoner.annotations.Version; import com.redstoner.exceptions.MissingVersionException; /** This class can be used to compare modules against the loader version or against each other to prevent dependency issues. * * @author Pepich */ -@Version(major = 1, minor = 0, revision = 0, compatible = -1) +@Version(major = 2, minor = 1, revision = 0, compatible = 0) public final class VersionHelper { private VersionHelper() {} - /** Checks two modules versions for compatibility. + /** Checks two classes versions for compatibility. * - * @param base The base to compare to. + * @param base The API to compare to. * @param module The module to compare. - * @return true, when the Major version of the base is bigger than the compatible version of the module, and the Version number of the base is smaller or equal to the Version number of the module. + * @return true, when the module is up to date with the API, or the API supports outdated modules. * @throws MissingVersionException When one of the parameters is not annotated with a @Version annotation. */ - public static boolean isCompatible(Class base, Class module) throws MissingVersionException + public static boolean isCompatible(Class api, Class module) throws MissingVersionException { - if (!base.isAnnotationPresent(Version.class)) - throw new MissingVersionException("The base object is not annotated with a version."); + if (!api.isAnnotationPresent(Version.class)) + throw new MissingVersionException("The API is not annotated with a version."); if (!module.isAnnotationPresent(Version.class)) throw new MissingVersionException("The module is not annotated with a version."); - Version baseVersion = base.getClass().getAnnotation(Version.class); + Version apiVersion = api.getClass().getAnnotation(Version.class); Version moduleVersion = module.getClass().getAnnotation(Version.class); - if (baseVersion.major() > moduleVersion.major()) + return isCompatible(apiVersion, moduleVersion); + } + + /** Checks two classes versions for compatibility. + * + * @param base The API to compare to. + * @param module The module to compare. + * @return true, when the module is up to date with the API, or the API supports outdated modules. + * @throws MissingVersionException When one of the parameters is not annotated with a @Version annotation. */ + public static boolean isCompatible(Version apiVersion, Class module) throws MissingVersionException + { + if (!module.isAnnotationPresent(Version.class)) + throw new MissingVersionException("The module is not annotated with a version."); + Version moduleVersion = module.getClass().getAnnotation(Version.class); + return isCompatible(apiVersion, moduleVersion); + } + + /** Checks two classes versions for compatibility. + * + * @param base The API to compare to. + * @param module The module to compare. + * @return true, when the module is up to date with the API, or the API supports outdated modules. + * @throws MissingVersionException When one of the parameters is not annotated with a @Version annotation. */ + public static boolean isCompatible(Class api, Version moduleVersion) throws MissingVersionException + { + if (!api.isAnnotationPresent(Version.class)) + throw new MissingVersionException("The API is not annotated with a version."); + Version apiVersion = api.getClass().getAnnotation(Version.class); + return isCompatible(apiVersion, moduleVersion); + } + + /** Checks two versions for compatibility. + * + * @param base The API version to compare to. + * @param module The module version to compare. + * @return true, when the module is up to date with the API, or the API supports outdated modules. + * @throws MissingVersionException When one of the parameters is not annotated with a @Version annotation. */ + public static boolean isCompatible(Version apiVersion, Version moduleVersion) + { + if (apiVersion.major() >= moduleVersion.compatible()) + return true; + if (apiVersion.compatible() == -1) return false; - return baseVersion.major() >= moduleVersion.compatible(); + if (apiVersion.compatible() <= moduleVersion.major()) + return true; + return false; } /** Returns the version of a given class as a String. @@ -43,4 +88,47 @@ public final class VersionHelper Version ver = clazz.getAnnotation(Version.class); return ver.major() + "." + ver.minor() + "." + ver.revision() + "." + ver.compatible(); } + + /** This method creates a new Version to use for compatibility checks. + * + * @param major The major version + * @param minor The minor version + * @param revision The revision + * @param compatible The compatibility tag + * @return */ + public static Version create(int major, int minor, int revision, int compatible) + { + return new Version() + { + @Override + public Class annotationType() + { + return Version.class; + } + + @Override + public int revision() + { + return revision; + } + + @Override + public int minor() + { + return minor; + } + + @Override + public int major() + { + return major; + } + + @Override + public int compatible() + { + return compatible; + } + }; + } } -- 2.45.2 From 7b21e33aac57999c88b21f45394bcbabc11ade9e Mon Sep 17 00:00:00 2001 From: Pepich Date: Fri, 10 Mar 2017 13:44:53 +0100 Subject: [PATCH 054/152] Command registration is now up to the module --- src/com/redstoner/modules/Module.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/com/redstoner/modules/Module.java b/src/com/redstoner/modules/Module.java index 8caa732..78488b7 100644 --- a/src/com/redstoner/modules/Module.java +++ b/src/com/redstoner/modules/Module.java @@ -5,20 +5,31 @@ import com.redstoner.annotations.Version; /** Interface for the Module class. Modules must always have an empty constructor to be invoked by the ModuleLoader. * * @author Pepich */ -@Version(major = 1, minor = 2, revision = 0, compatible = 1) +@Version(major = 3, minor = 0, revision = 0, compatible = 2) public interface Module { /** Will be called when the module gets enabled. */ - public default boolean onEnable() { + public default boolean onEnable() + { return true; } + /** This methods gets called after all modules were enabled, please use this method to register commands and similar.
+ * It will only get called if and only if the module was successfully enabled. */ + public default void postEnable() + {} + /** Will be called when the module gets disabled. */ public default void onDisable() {} /** Gets called on registration of the module. + * THIS WAS ONLY KEPT FOR COMPATIBILITY REASONS. Please register commands yourself instead using the "postEnable" method. * * @return The String used for the CommandManager to register the commands. */ - public String getCommandString(); + @Deprecated + public default String getCommandString() + { + return null; + } } -- 2.45.2 From 63edc545e8ce16d28457755c2904b0fd02dc8f5d Mon Sep 17 00:00:00 2001 From: Pepich Date: Fri, 10 Mar 2017 13:45:14 +0100 Subject: [PATCH 055/152] Expanded functionality to allow more control in the module --- .../coremods/moduleLoader/ModuleLoader.java | 39 +++++++++++++++---- 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java b/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java index 6aa89a0..e5e3c62 100644 --- a/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java +++ b/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java @@ -4,6 +4,7 @@ import java.util.HashMap; import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; +import org.bukkit.event.HandlerList; import org.bukkit.event.Listener; import com.nemez.cmdmgr.Command; @@ -13,15 +14,17 @@ import com.redstoner.annotations.AutoRegisterListener; import com.redstoner.annotations.Debugable; import com.redstoner.annotations.Version; import com.redstoner.coremods.debugger.Debugger; +import com.redstoner.exceptions.MissingVersionException; import com.redstoner.misc.Main; import com.redstoner.misc.Utils; +import com.redstoner.misc.VersionHelper; import com.redstoner.modules.CoreModule; import com.redstoner.modules.Module; /** The module loader, mother of all modules. Responsible for loading and taking care of all modules. * * @author Pepich */ -@Version(major = 2, minor = 0, revision = 0, compatible = -1) +@Version(major = 3, minor = 0, revision = 0, compatible = 2) public final class ModuleLoader implements CoreModule { private static ModuleLoader instance; @@ -68,12 +71,8 @@ public final class ModuleLoader implements CoreModule { if (module.onEnable()) { - CommandManager.registerCommand(module.getCommandString(), module, Main.plugin); - if (module.getClass().isAnnotationPresent(AutoRegisterListener.class) - && (module instanceof Listener)) - { - Bukkit.getPluginManager().registerEvents((Listener) module, Main.plugin); - } + if (VersionHelper.isCompatible(VersionHelper.create(2, 0, 0, -1), module.getClass())) + CommandManager.registerCommand(module.getCommandString(), module, Main.plugin); modules.put(module, true); Utils.log("Loaded module " + module.getClass().getName()); } @@ -86,6 +85,28 @@ public final class ModuleLoader implements CoreModule e.printStackTrace(); } } + Utils.log("Modules enabled, running post initialization."); + for (Module module : modules.keySet()) + { + if (modules.get(module)) + { + try + { + if (VersionHelper.isCompatible(VersionHelper.create(3, 0, 0, 3), module.getClass())) + { + module.postEnable(); + } + } + catch (MissingVersionException e) + { + e.printStackTrace(); + } + if (module.getClass().isAnnotationPresent(AutoRegisterListener.class) && (module instanceof Listener)) + { + Bukkit.getPluginManager().registerEvents((Listener) module, Main.plugin); + } + } + } } /** This method enables a specific module. If no module with that name is known to the loader yet it will be added to the list. @@ -188,6 +209,10 @@ public final class ModuleLoader implements CoreModule if (modules.get(module)) { module.onDisable(); + if (module.getClass().isAnnotationPresent(AutoRegisterListener.class) && (module instanceof Listener)) + { + HandlerList.unregisterAll((Listener) module); + } } } } -- 2.45.2 From 0fcf9b385611bec06df8aa751224c4e3d232daf3 Mon Sep 17 00:00:00 2001 From: Pepich Date: Fri, 10 Mar 2017 13:45:45 +0100 Subject: [PATCH 056/152] Added unsubscribe command --- .../redstoner/coremods/debugger/Debugger.java | 235 ++++++++++-------- 1 file changed, 132 insertions(+), 103 deletions(-) diff --git a/src/com/redstoner/coremods/debugger/Debugger.java b/src/com/redstoner/coremods/debugger/Debugger.java index 8aa7ef9..fb0f1e7 100644 --- a/src/com/redstoner/coremods/debugger/Debugger.java +++ b/src/com/redstoner/coremods/debugger/Debugger.java @@ -1,5 +1,6 @@ package com.redstoner.coremods.debugger; +import java.lang.reflect.Method; import java.util.ArrayList; import java.util.HashMap; @@ -16,14 +17,17 @@ import com.redstoner.misc.Main; import com.redstoner.misc.Utils; import com.redstoner.modules.CoreModule; +import net.md_5.bungee.api.ChatColor; + /** The Debugger class, first Module to be loaded, responsible for debug interactions such as subscribing to method calls and getting field values on runtime. * * @author Pepich */ -@Version(major = 1, minor = 0, revision = 4, compatible = -1) +@Version(major = 3, minor = 0, revision = 0, compatible = -1) public final class Debugger implements CoreModule, Listener { private static Debugger instance; private static HashMap> subs; + private static final boolean enabled = true; private Debugger() { @@ -37,81 +41,71 @@ public final class Debugger implements CoreModule, Listener CommandManager.registerCommand(instance.getCommandString(), instance, Main.plugin); } - public static void notifyMethod(Object... params) + public static void notifyMethod(CommandSender recipient, Object... params) { Exception e = new Exception(); String method = e.getStackTrace()[1].getMethodName(); + if (!method.equals("notifyMethod")) + notifyMethod((Object) recipient, params); String classname = e.getStackTrace()[1].getClassName(); - for (Player p : Bukkit.getOnlinePlayers()) - if (subs.containsKey(p)) - { - boolean subscribed = false; - for (String s : subs.get(p)) - { - if (s.equals(classname + "." + method)) - { - subscribed = true; - break; - } - } - if (subscribed) - { - StringBuilder sb = new StringBuilder(method); - sb.append("("); - if (params != null) - { - for (Object obj : params) - { - if (obj == null) - sb.append("NULL"); - else - sb.append(obj.toString()); - sb.append(", "); - } - sb.delete(sb.length() - 2, sb.length()); - } - sb.append(")\nTypes:\n"); - int i = 0; - for (Object obj : params) - sb.append(i++ + ": " + (obj == null ? "NULL" : obj.getClass().getName()) + "\n"); - p.sendMessage(sb.toString()); - } - } - CommandSender p = Bukkit.getConsoleSender(); - if (subs.containsKey(p)) + if (!classname.equals("com.redstoner.coremods.debugger.Debugger")) + notifyMethod((Object) recipient, params); + for (StackTraceElement element : e.getStackTrace()) { - boolean subscribed = false; - for (String s : subs.get(p)) + if (element.getMethodName().equals("notifyMethod")) + continue; + classname = element.getClassName(); + method = element.getMethodName(); + break; + } + boolean subscribed = false; + for (String s : subs.get(recipient)) + { + if (s.equals(classname + "." + method)) { - if (s.equals(classname + "." + method)) - { - subscribed = true; - break; - } - } - if (subscribed) - { - StringBuilder sb = new StringBuilder(method); - sb.append("("); - if (params != null) - { - for (Object obj : params) - { - if (obj == null) - sb.append("NULL"); - else - sb.append(obj.toString()); - sb.append(", "); - } - sb.delete(sb.length() - 2, sb.length()); - } - sb.append(")\nTypes:\n"); - int i = 0; - for (Object obj : params) - sb.append(i++ + ": " + (obj == null ? "NULL" : obj.getClass().getName()) + "\n"); - p.sendMessage(sb.toString()); + subscribed = true; + break; } } + if (subscribed) + { + StringBuilder sb = new StringBuilder("&7"); + sb.append(method); + sb.append("("); + if (params != null) + { + for (Object obj : params) + { + if (obj == null) + sb.append("&cNULL"); + else + sb.append(obj.toString()); + sb.append("&7, &e"); + } + sb.delete(sb.length() - 6, sb.length()); + } + sb.append("&7)\n&eTypes:\n&7"); + int i = 0; + for (Object obj : params) + sb.append(i++ + ": &e" + (obj == null ? "&cNULL" : obj.getClass().getName()) + "&7\n"); + String message = "&2---=[ DEBUGGER ]=---\n" + sb.toString(); + message = ChatColor.translateAlternateColorCodes('&', message); + recipient.sendMessage(message); + } + } + + public static void notifyMethod(Object... params) + { + if (!enabled) + { + return; + } + for (Player p : Bukkit.getOnlinePlayers()) + if (subs.containsKey(p)) + notifyMethod(p, params); + CommandSender p = Bukkit.getConsoleSender(); + if (subs.containsKey(p)) + notifyMethod(p, params); } // @noformat @@ -124,6 +118,11 @@ public final class Debugger implements CoreModule, Listener " perm jutils.debugger.subscribe;\n" + " run subscribe classname methodname;\n" + " }\n" + + " unsubscribe [string:classname] [string:methodname] {\n" + + " help Unsubscribes from all calls of the corresponding debugable method.;\n" + + " perm jutils.debugger.subscribe;\n" + + " run unsubscribe classname methodname;\n" + + " }\n" + "}"; } // @format @@ -132,41 +131,71 @@ public final class Debugger implements CoreModule, Listener @Debugable public boolean subscribeCommand(CommandSender sender, String classname, String methodname) { - Utils.sendMessage(sender, null, "Debugger is currently disabled!"); + if (!enabled) + { + Utils.sendMessage(sender, null, "Debugger is currently disabled!"); + return true; + } + Class clazz = null; + try + { + clazz = Class.forName(classname); + } + catch (ClassNotFoundException e) + { + Utils.sendErrorMessage(sender, null, "Could not find the class: " + classname); + return true; + } + boolean found = false; + for (Method m : clazz.getMethods()) + { + if (m.getName().matches(methodname)) + { + if (m.isAnnotationPresent(Debugable.class)) + { + found = true; + if (!subs.containsKey(sender)) + subs.put(sender, new ArrayList()); + subs.get(sender).add(classname + "." + methodname); + break; + } + } + } + if (!found) + { + Utils.sendErrorMessage(sender, null, "The method you chose either doesn't exist or is not debugable!"); + return true; + } + Utils.sendMessage(sender, null, "Successfully subsribed to the method &e" + classname + ":" + methodname, '&'); + return true; + } + + @Command(hook = "unsubscribe") + @Debugable + public boolean unsubscribeCommand(CommandSender sender, String classname, String methodname) + { + if (!enabled) + { + Utils.sendMessage(sender, null, "Debugger is currently disabled!"); + return true; + } + if (subs.containsKey(sender)) + { + if (subs.get(sender).remove(classname + "." + methodname)) + { + Utils.sendMessage(sender, null, + "Successfully unsubscribed from the method &e" + classname + ":" + methodname, '&'); + } + else + { + Utils.sendErrorMessage(sender, null, "You were not listening to &e" + classname + ":" + methodname, + '&'); + } + } + else + { + Utils.sendErrorMessage(sender, null, "You are not listening to any methods!"); + } return true; - // Class clazz = null; - // try - // { - // clazz = Class.forName(classname); - // } - // catch (ClassNotFoundException e) - // { - // e.printStackTrace(); - // // TODO: Add error message - // return true; - // } - // boolean found = false; - // for (Method m : clazz.getMethods()) - // { - // if (m.getName().matches(methodname)) - // { - // if (m.isAnnotationPresent(Debugable.class)) - // { - // found = true; - // if (!subs.containsKey(sender)) - // subs.put(sender, new ArrayList()); - // subs.get(sender).add(classname + "." + methodname); - // break; - // } - // } - // } - // if (!found) - // { - // System.err.println("2"); - // // TODO: Add error message - // return true; - // } - // Utils.sendMessage(sender, null, "YAY"); - // return true; } } -- 2.45.2 From 507f11577d67e32070460b9304dc81c690d2250e Mon Sep 17 00:00:00 2001 From: Pepich Date: Fri, 10 Mar 2017 13:46:31 +0100 Subject: [PATCH 057/152] Initial commit for planned modules --- src/com/redstoner/modules/chatonly/ChatOnly.java | 8 ++++++++ src/com/redstoner/modules/essentials/Essentials.java | 8 ++++++++ 2 files changed, 16 insertions(+) create mode 100644 src/com/redstoner/modules/chatonly/ChatOnly.java create mode 100644 src/com/redstoner/modules/essentials/Essentials.java diff --git a/src/com/redstoner/modules/chatonly/ChatOnly.java b/src/com/redstoner/modules/chatonly/ChatOnly.java new file mode 100644 index 0000000..dd41de6 --- /dev/null +++ b/src/com/redstoner/modules/chatonly/ChatOnly.java @@ -0,0 +1,8 @@ +package com.redstoner.modules.chatonly; + +import com.redstoner.annotations.Version; +import com.redstoner.modules.Module; + +@Version(major = 3, minor = 0, revision = 0, compatible = 3) +public class ChatOnly implements Module +{} diff --git a/src/com/redstoner/modules/essentials/Essentials.java b/src/com/redstoner/modules/essentials/Essentials.java new file mode 100644 index 0000000..98f6ce5 --- /dev/null +++ b/src/com/redstoner/modules/essentials/Essentials.java @@ -0,0 +1,8 @@ +package com.redstoner.modules.essentials; + +import com.redstoner.annotations.Version; +import com.redstoner.modules.Module; + +@Version(major = 3, minor = 0, revision = 0, compatible = 3) +public class Essentials implements Module +{} -- 2.45.2 From 34037a186c5fcd7c174d0dff428e7e3afe5a7516 Mon Sep 17 00:00:00 2001 From: Pepich Date: Fri, 10 Mar 2017 13:47:18 +0100 Subject: [PATCH 058/152] Added new modules to main class --- src/com/redstoner/misc/Main.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/com/redstoner/misc/Main.java b/src/com/redstoner/misc/Main.java index 715a28e..bd016ce 100644 --- a/src/com/redstoner/misc/Main.java +++ b/src/com/redstoner/misc/Main.java @@ -12,11 +12,13 @@ import com.redstoner.modules.adminnotes.AdminNotes; import com.redstoner.modules.challenge.Challenge; import com.redstoner.modules.chatalias.Chatalias; import com.redstoner.modules.chatgroups.Chatgroups; +import com.redstoner.modules.chatonly.ChatOnly; import com.redstoner.modules.check.Check; import com.redstoner.modules.clear.Clear; import com.redstoner.modules.clearonjoin.ClearOnJoin; import com.redstoner.modules.cycle.Cycle; import com.redstoner.modules.damnspam.DamnSpam; +import com.redstoner.modules.essentials.Essentials; import com.redstoner.modules.firstseen.FirstSeen; import com.redstoner.modules.illumination.Illumination; import com.redstoner.modules.imout.Imout; @@ -40,7 +42,7 @@ import com.redstoner.modules.webtoken.WebToken; /** Main class. Duh. * * @author Pepich */ -@Version(major = 1, minor = 5, revision = 0, compatible = -1) +@Version(major = 1, minor = 6, revision = 0, compatible = -1) public class Main extends JavaPlugin { public static JavaPlugin plugin; @@ -58,6 +60,7 @@ public class Main extends JavaPlugin // TODO: ModuleLoader.addModule(BlockplaceMods.class); // TODO: ModuleLoader.addModule(Calc.class); ModuleLoader.addModule(Challenge.class); + ModuleLoader.addModule(ChatOnly.class); ModuleLoader.addModule(Clear.class); ModuleLoader.addModule(ClearOnJoin.class); ModuleLoader.addModule(Chatalias.class); @@ -65,6 +68,7 @@ public class Main extends JavaPlugin ModuleLoader.addModule(Chatgroups.class); ModuleLoader.addModule(Check.class); ModuleLoader.addModule(DamnSpam.class); + ModuleLoader.addModule(Essentials.class); ModuleLoader.addModule(FirstSeen.class); // TODO: ModuleLoader.addModule(Friends.class); ModuleLoader.addModule(Illumination.class); -- 2.45.2 From 1c9d972aa57df7287e02ba06c90aaf40a3e285c0 Mon Sep 17 00:00:00 2001 From: Pepich Date: Fri, 10 Mar 2017 14:21:05 +0100 Subject: [PATCH 059/152] Fixed compatibility check to no longer throw NPE --- src/com/redstoner/misc/VersionHelper.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/com/redstoner/misc/VersionHelper.java b/src/com/redstoner/misc/VersionHelper.java index f815c7c..9e7bf35 100644 --- a/src/com/redstoner/misc/VersionHelper.java +++ b/src/com/redstoner/misc/VersionHelper.java @@ -8,7 +8,7 @@ import com.redstoner.exceptions.MissingVersionException; /** This class can be used to compare modules against the loader version or against each other to prevent dependency issues. * * @author Pepich */ -@Version(major = 2, minor = 1, revision = 0, compatible = 0) +@Version(major = 2, minor = 1, revision = 1, compatible = 0) public final class VersionHelper { private VersionHelper() @@ -26,8 +26,8 @@ public final class VersionHelper throw new MissingVersionException("The API is not annotated with a version."); if (!module.isAnnotationPresent(Version.class)) throw new MissingVersionException("The module is not annotated with a version."); - Version apiVersion = api.getClass().getAnnotation(Version.class); - Version moduleVersion = module.getClass().getAnnotation(Version.class); + Version apiVersion = api.getAnnotation(Version.class); + Version moduleVersion = module.getAnnotation(Version.class); return isCompatible(apiVersion, moduleVersion); } @@ -41,7 +41,7 @@ public final class VersionHelper { if (!module.isAnnotationPresent(Version.class)) throw new MissingVersionException("The module is not annotated with a version."); - Version moduleVersion = module.getClass().getAnnotation(Version.class); + Version moduleVersion = module.getAnnotation(Version.class); return isCompatible(apiVersion, moduleVersion); } @@ -55,7 +55,7 @@ public final class VersionHelper { if (!api.isAnnotationPresent(Version.class)) throw new MissingVersionException("The API is not annotated with a version."); - Version apiVersion = api.getClass().getAnnotation(Version.class); + Version apiVersion = api.getAnnotation(Version.class); return isCompatible(apiVersion, moduleVersion); } -- 2.45.2 From becd57dcdfc9bf4d09e7930427b4a80b9cbe17f5 Mon Sep 17 00:00:00 2001 From: Pepich Date: Fri, 10 Mar 2017 15:20:41 +0100 Subject: [PATCH 060/152] Added warn level info message. Renamed "log" to "info" --- src/com/redstoner/misc/Utils.java | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/src/com/redstoner/misc/Utils.java b/src/com/redstoner/misc/Utils.java index 8973b86..8ffeea5 100644 --- a/src/com/redstoner/misc/Utils.java +++ b/src/com/redstoner/misc/Utils.java @@ -13,7 +13,7 @@ import net.md_5.bungee.api.ChatColor; /** The utils class containing utility functions. Those include but are not limited to sending formatted messages, broadcasts and more. * * @author Pepich */ -@Version(major = 1, minor = 1, revision = 8, compatible = 1) +@Version(major = 1, minor = 2, revision = 9, compatible = 1) public final class Utils { /** Hidden constructor. Do not instantiate UTILS classes! :) */ @@ -28,7 +28,7 @@ public final class Utils @Debugable public static void sendMessage(CommandSender recipient, String prefix, String message) { - Debugger.notifyMethod(recipient, message, prefix); + Debugger.notifyMethod((Object) recipient, prefix, message); if (prefix == null) prefix = "§8[§2" + getCaller() + "§8]: "; recipient.sendMessage(prefix + "§7" + message); @@ -149,11 +149,20 @@ public final class Utils } } - /** Used to make an info output to console. Supports &x color codes. + /** Deprecated. Use Utils.info(message) instead. + * + * @param message The message to be put into console. Prefixes are automatically generated. */ + @Deprecated + public static void log(String message) + { + info(message); + } + + /** Prints an info message into console. * * @param message The message to be put into console. Prefixes are automatically generated. */ @Debugable - public static void log(String message) + public static void info(String message) { Debugger.notifyMethod(message); String classname = getCaller(); @@ -161,6 +170,15 @@ public final class Utils Bukkit.getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', prefix + "§7" + message)); } + @Debugable + public static void warn(String message) + { + Debugger.notifyMethod(message); + String classname = getCaller(); + String prefix = "§e[WARN]: §8[§2" + classname + "§8]: "; + Bukkit.getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', prefix + "§7" + message)); + } + /** Used to make an error output to console. Supports &x color codes. * * @param message The message to be put into console. Prefixes are automatically generated. Color defaults to red if not specified otherwise. */ -- 2.45.2 From f2631772d16064b49010a592840992419e192ee1 Mon Sep 17 00:00:00 2001 From: Pepich Date: Fri, 10 Mar 2017 15:46:49 +0100 Subject: [PATCH 061/152] Updated documentation --- src/com/redstoner/misc/Utils.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/com/redstoner/misc/Utils.java b/src/com/redstoner/misc/Utils.java index 8ffeea5..732c813 100644 --- a/src/com/redstoner/misc/Utils.java +++ b/src/com/redstoner/misc/Utils.java @@ -13,7 +13,7 @@ import net.md_5.bungee.api.ChatColor; /** The utils class containing utility functions. Those include but are not limited to sending formatted messages, broadcasts and more. * * @author Pepich */ -@Version(major = 1, minor = 2, revision = 9, compatible = 1) +@Version(major = 1, minor = 2, revision = 10, compatible = 1) public final class Utils { /** Hidden constructor. Do not instantiate UTILS classes! :) */ @@ -158,9 +158,9 @@ public final class Utils info(message); } - /** Prints an info message into console. + /** Prints an info message into console. Supports &x color codes. * - * @param message The message to be put into console. Prefixes are automatically generated. */ + * @param message The message to be put into console. Prefixes are automatically generated. Color defaults to grey. */ @Debugable public static void info(String message) { @@ -170,18 +170,21 @@ public final class Utils Bukkit.getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', prefix + "§7" + message)); } + /** Prints a warning message into console. Supports &x color codes. + * + * @param message The message to be put into console. Prefixes are automatically generated. Color defaults to grey. */ @Debugable public static void warn(String message) { Debugger.notifyMethod(message); String classname = getCaller(); - String prefix = "§e[WARN]: §8[§2" + classname + "§8]: "; + String prefix = "§e[WARN]: §8[§e" + classname + "§8]: "; Bukkit.getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', prefix + "§7" + message)); } /** Used to make an error output to console. Supports &x color codes. * - * @param message The message to be put into console. Prefixes are automatically generated. Color defaults to red if not specified otherwise. */ + * @param message The message to be put into console. Prefixes are automatically generated. Color defaults to red. */ @Debugable public static void error(String message) { -- 2.45.2 From 4df0754970cbb59a499718774a0a00bc06e6608a Mon Sep 17 00:00:00 2001 From: Pepich Date: Fri, 10 Mar 2017 15:54:51 +0100 Subject: [PATCH 062/152] Added getDate method --- src/com/redstoner/misc/Utils.java | 17 ++- .../modules/essentials/Essentials.java | 115 +++++++++++++++++- 2 files changed, 130 insertions(+), 2 deletions(-) diff --git a/src/com/redstoner/misc/Utils.java b/src/com/redstoner/misc/Utils.java index 732c813..cf78bb8 100644 --- a/src/com/redstoner/misc/Utils.java +++ b/src/com/redstoner/misc/Utils.java @@ -1,5 +1,8 @@ package com.redstoner.misc; +import java.text.SimpleDateFormat; +import java.util.Date; + import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -13,9 +16,12 @@ import net.md_5.bungee.api.ChatColor; /** The utils class containing utility functions. Those include but are not limited to sending formatted messages, broadcasts and more. * * @author Pepich */ -@Version(major = 1, minor = 2, revision = 10, compatible = 1) +@Version(major = 1, minor = 2, revision = 11, compatible = 1) public final class Utils { + /** The SimpleDateFormat used for getting the current date. */ + public static SimpleDateFormat dateFormat = new SimpleDateFormat("[yyyy-MM-dd HH:mm:ss]"); + /** Hidden constructor. Do not instantiate UTILS classes! :) */ private Utils() {} @@ -216,4 +222,13 @@ public final class Utils { recipient.sendMessage("§2--=[ " + getCaller() + " ]=--"); } + + /** Provides a uniform way of getting the date for all modules. + * + * @return The current date in the format "[dd-mm-yyyy hh:mm:ss]" */ + public static String getDate() + { + Date date = new Date(System.currentTimeMillis()); + return dateFormat.format(date); + } } diff --git a/src/com/redstoner/modules/essentials/Essentials.java b/src/com/redstoner/modules/essentials/Essentials.java index 98f6ce5..cd048a7 100644 --- a/src/com/redstoner/modules/essentials/Essentials.java +++ b/src/com/redstoner/modules/essentials/Essentials.java @@ -1,8 +1,121 @@ package com.redstoner.modules.essentials; +import java.io.File; +import java.util.HashMap; +import java.util.UUID; + +import org.bukkit.Bukkit; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.json.simple.JSONObject; + +import com.nemez.cmdmgr.Command; +import com.nemez.cmdmgr.CommandManager; +import com.redstoner.annotations.AutoRegisterListener; import com.redstoner.annotations.Version; +import com.redstoner.exceptions.PlayerNotFoundException; +import com.redstoner.misc.JsonManager; +import com.redstoner.misc.Main; +import com.redstoner.misc.Utils; import com.redstoner.modules.Module; +@AutoRegisterListener @Version(major = 3, minor = 0, revision = 0, compatible = 3) public class Essentials implements Module -{} +{ + static HashMap players; + private final File saveFile = new File(Main.plugin.getDataFolder(), "knownPlayers.json"); + private static JSONObject knownNames; + + @Override + public boolean onEnable() + { + knownNames = JsonManager.getObject(saveFile); + if (knownNames == null) + { + Utils.warn("Couldn't find existing"); + } + players = new HashMap(); + for (Player p : Bukkit.getOnlinePlayers()) + { + players.put(p.getUniqueId(), Essentials.getPlayer(p)); + } + return true; + } + + @Override + public void postEnable() + { + Utils.info("Creating command links for essentials. This may take a while..."); + CommandManager.registerCommand(this.getClass().getResourceAsStream("Essentials.cmd"), this, Main.plugin); + } + + @Command(hook = "kickDef") + public void kick(CommandSender sender, String name) + { + kick(sender, name, EssentialsDefaults.kickMessage); + } + + @Command(hook = "kick") + public void kick(CommandSender sender, String name, String reason) + { + try + { + getPlayer(name).kick(getName(sender), reason); + } + catch (PlayerNotFoundException e) + { + Utils.sendErrorMessage(sender, null, e.getMessage()); + } + } + + @EventHandler + public void onPlayerJoin(PlayerJoinEvent e) + { + players.put(e.getPlayer().getUniqueId(), getPlayer(e.getPlayer())); + } + + @EventHandler + public void onPlayerLeave(PlayerQuitEvent e) + { + UUID uuid = e.getPlayer().getUniqueId(); + players.get(uuid).onLeave(); + players.remove(uuid); + } + + public static EssentialsPlayer getPlayer(UUID uuid) throws PlayerNotFoundException + { + Player player = Bukkit.getPlayer(uuid); + if (player == null) + throw new PlayerNotFoundException(); + return getPlayer(player); + } + + public static EssentialsPlayer getPlayer(Player player) + { + if (players.containsKey(player.getUniqueId())) + return players.get(player.getUniqueId()); + return new EssentialsPlayer(player); + } + + public static EssentialsPlayer getPlayer(String name) throws PlayerNotFoundException + { + Player player = Bukkit.getPlayer(name); + if (player == null) + throw new PlayerNotFoundException(); + return getPlayer(player); + } + + public static String getName(CommandSender sender) + { + String name = "&9"; + if (sender instanceof Player) + name += ((Player) sender).getDisplayName(); + else + name += sender.getName(); + return name; + } +} -- 2.45.2 From 81c10e62c201183493dbe1f8e1968eaeba7a8751 Mon Sep 17 00:00:00 2001 From: Pepich Date: Fri, 10 Mar 2017 20:49:23 +0100 Subject: [PATCH 063/152] Added getName method, made documentation more clear --- src/com/redstoner/misc/Utils.java | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/com/redstoner/misc/Utils.java b/src/com/redstoner/misc/Utils.java index cf78bb8..7012b32 100644 --- a/src/com/redstoner/misc/Utils.java +++ b/src/com/redstoner/misc/Utils.java @@ -16,7 +16,7 @@ import net.md_5.bungee.api.ChatColor; /** The utils class containing utility functions. Those include but are not limited to sending formatted messages, broadcasts and more. * * @author Pepich */ -@Version(major = 1, minor = 2, revision = 11, compatible = 1) +@Version(major = 1, minor = 2, revision = 12, compatible = 1) public final class Utils { /** The SimpleDateFormat used for getting the current date. */ @@ -164,7 +164,7 @@ public final class Utils info(message); } - /** Prints an info message into console. Supports &x color codes. + /** Prints an info message into console. Supports "&" color codes. * * @param message The message to be put into console. Prefixes are automatically generated. Color defaults to grey. */ @Debugable @@ -176,7 +176,7 @@ public final class Utils Bukkit.getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', prefix + "§7" + message)); } - /** Prints a warning message into console. Supports &x color codes. + /** Prints a warning message into console. Supports "&" color codes. * * @param message The message to be put into console. Prefixes are automatically generated. Color defaults to grey. */ @Debugable @@ -188,7 +188,7 @@ public final class Utils Bukkit.getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', prefix + "§7" + message)); } - /** Used to make an error output to console. Supports &x color codes. + /** Used to make an error output to console. Supports "&" color codes. * * @param message The message to be put into console. Prefixes are automatically generated. Color defaults to red. */ @Debugable @@ -231,4 +231,16 @@ public final class Utils Date date = new Date(System.currentTimeMillis()); return dateFormat.format(date); } + + /** Provides a uniform way of getting the (display)name of a CommandSender. + * + * @param sender The CommandSender to get the name of. + * @return The DisplayName of the CommandSender or if not a player, the name in blue. */ + public static String getName(CommandSender sender) + { + if (sender instanceof Player) + return ((Player) sender).getDisplayName(); + else + return "&9" + sender.getName(); + } } -- 2.45.2 From 68d0c545410864eaef9e3de5a028e10565a253e8 Mon Sep 17 00:00:00 2001 From: Minenash Date: Tue, 14 Mar 2017 15:34:31 -0400 Subject: [PATCH 064/152] Changed Utils.log to Utils.info --- src/com/redstoner/coremods/moduleLoader/ModuleLoader.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java b/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java index e5e3c62..a4bef5b 100644 --- a/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java +++ b/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java @@ -74,7 +74,7 @@ public final class ModuleLoader implements CoreModule if (VersionHelper.isCompatible(VersionHelper.create(2, 0, 0, -1), module.getClass())) CommandManager.registerCommand(module.getCommandString(), module, Main.plugin); modules.put(module, true); - Utils.log("Loaded module " + module.getClass().getName()); + Utils.info("Loaded module " + module.getClass().getName()); } else Utils.error("Failed to load module " + module.getClass().getName()); @@ -85,7 +85,7 @@ public final class ModuleLoader implements CoreModule e.printStackTrace(); } } - Utils.log("Modules enabled, running post initialization."); + Utils.info("Modules enabled, running post initialization."); for (Module module : modules.keySet()) { if (modules.get(module)) @@ -128,7 +128,7 @@ public final class ModuleLoader implements CoreModule { Bukkit.getPluginManager().registerEvents((Listener) module, Main.plugin); } - Utils.log("Loaded module " + module.getClass().getName()); + Utils.info("Loaded module " + module.getClass().getName()); modules.put(module, true); return true; } @@ -149,7 +149,7 @@ public final class ModuleLoader implements CoreModule { Bukkit.getPluginManager().registerEvents((Listener) m, Main.plugin); } - Utils.log("Loaded module " + m.getClass().getName()); + Utils.info("Loaded module " + m.getClass().getName()); return true; } else -- 2.45.2 From 29460573f7b79eb3930a8e54ed6033a1095a1236 Mon Sep 17 00:00:00 2001 From: Pepich Date: Thu, 23 Mar 2017 11:33:40 +0100 Subject: [PATCH 065/152] Updated log outputs to API v3 --- .../redstoner/coremods/moduleLoader/ModuleLoader.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java b/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java index e5e3c62..0f170cf 100644 --- a/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java +++ b/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java @@ -24,7 +24,7 @@ import com.redstoner.modules.Module; /** The module loader, mother of all modules. Responsible for loading and taking care of all modules. * * @author Pepich */ -@Version(major = 3, minor = 0, revision = 0, compatible = 2) +@Version(major = 3, minor = 0, revision = 1, compatible = 2) public final class ModuleLoader implements CoreModule { private static ModuleLoader instance; @@ -74,7 +74,7 @@ public final class ModuleLoader implements CoreModule if (VersionHelper.isCompatible(VersionHelper.create(2, 0, 0, -1), module.getClass())) CommandManager.registerCommand(module.getCommandString(), module, Main.plugin); modules.put(module, true); - Utils.log("Loaded module " + module.getClass().getName()); + Utils.info("Loaded module " + module.getClass().getName()); } else Utils.error("Failed to load module " + module.getClass().getName()); @@ -85,7 +85,7 @@ public final class ModuleLoader implements CoreModule e.printStackTrace(); } } - Utils.log("Modules enabled, running post initialization."); + Utils.info("Modules enabled, running post initialization."); for (Module module : modules.keySet()) { if (modules.get(module)) @@ -128,7 +128,7 @@ public final class ModuleLoader implements CoreModule { Bukkit.getPluginManager().registerEvents((Listener) module, Main.plugin); } - Utils.log("Loaded module " + module.getClass().getName()); + Utils.info("Loaded module " + module.getClass().getName()); modules.put(module, true); return true; } @@ -149,7 +149,7 @@ public final class ModuleLoader implements CoreModule { Bukkit.getPluginManager().registerEvents((Listener) m, Main.plugin); } - Utils.log("Loaded module " + m.getClass().getName()); + Utils.info("Loaded module " + m.getClass().getName()); return true; } else -- 2.45.2 From 0db0c9b5f6012d788b4e7562ccc672e1d3074921 Mon Sep 17 00:00:00 2001 From: Pepich Date: Fri, 24 Mar 2017 10:56:57 +0100 Subject: [PATCH 066/152] Moved moduleloader cmd into seperate file; Prepared load cmd --- .../coremods/moduleLoader/ModuleLoader.cmd | 13 ++++++++++ .../coremods/moduleLoader/ModuleLoader.java | 25 +++++++------------ 2 files changed, 22 insertions(+), 16 deletions(-) create mode 100644 src/com/redstoner/coremods/moduleLoader/ModuleLoader.cmd diff --git a/src/com/redstoner/coremods/moduleLoader/ModuleLoader.cmd b/src/com/redstoner/coremods/moduleLoader/ModuleLoader.cmd new file mode 100644 index 0000000..9dd5445 --- /dev/null +++ b/src/com/redstoner/coremods/moduleLoader/ModuleLoader.cmd @@ -0,0 +1,13 @@ +command modules { + list { + help Lists all modules. Color indicates status: §aENABLED §cDISABLED; + perm jutils.admin; + run list; + } + load [string:name...] { + help (Re)-Loads a module. WARNING: Handle with care! This has direct affect on code being executed. This command will temporarily halt the main thread until the class loading operation was completed.; + perm jtuils.admin; + run load name; + type console; + } +} \ No newline at end of file diff --git a/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java b/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java index 0f170cf..ab0e3ec 100644 --- a/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java +++ b/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java @@ -1,5 +1,6 @@ package com.redstoner.coremods.moduleLoader; +import java.io.File; import java.util.HashMap; import org.bukkit.Bukkit; @@ -24,7 +25,7 @@ import com.redstoner.modules.Module; /** The module loader, mother of all modules. Responsible for loading and taking care of all modules. * * @author Pepich */ -@Version(major = 3, minor = 0, revision = 1, compatible = 2) +@Version(major = 3, minor = 1, revision = 0, compatible = 2) public final class ModuleLoader implements CoreModule { private static ModuleLoader instance; @@ -37,7 +38,8 @@ public final class ModuleLoader implements CoreModule { if (instance == null) instance = new ModuleLoader(); - CommandManager.registerCommand(instance.getCommandString(), instance, Main.plugin); + CommandManager.registerCommand(ModuleLoader.class.getResourceAsStream("ModuleLoader.cmd"), instance, + Main.plugin); } /** This method will add a module to the module list, without enabling it @@ -165,20 +167,6 @@ public final class ModuleLoader implements CoreModule } } - // @noformat - @Override - public String getCommandString() - { - return "command modules {\n" + - " list{\n" + - " help Lists all modules. Color indicates status: §aENABLED §cDISABLED;\n" + - " perm jutils.admin;\n" + - " run list;\n" + - " }\n" + - "}"; - } - // @format - /** This method lists all modules to the specified CommandSender. The modules will be color coded correspondingly to their enabled status. * * @param sender The person to send the info to, usually the issuer of the command or the console sender. @@ -216,4 +204,9 @@ public final class ModuleLoader implements CoreModule } } } + + public static boolean loadModule(File f) + { + return false; + } } -- 2.45.2 From dbca8263a05c3e6320abaa74aadb110417feab8d Mon Sep 17 00:00:00 2001 From: Pepich Date: Wed, 29 Mar 2017 09:30:15 +0200 Subject: [PATCH 067/152] Added dynamic loading functionality, Updated API to v3.1.0 --- .../coremods/moduleLoader/ModuleLoader.java | 238 +++++++++++++++--- src/com/redstoner/misc/VersionHelper.java | 11 +- 2 files changed, 216 insertions(+), 33 deletions(-) diff --git a/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java b/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java index ab0e3ec..cf1dd98 100644 --- a/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java +++ b/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java @@ -1,9 +1,14 @@ package com.redstoner.coremods.moduleLoader; import java.io.File; +import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLClassLoader; import java.util.HashMap; import org.bukkit.Bukkit; +import org.bukkit.World; import org.bukkit.command.CommandSender; import org.bukkit.event.HandlerList; import org.bukkit.event.Listener; @@ -22,6 +27,8 @@ import com.redstoner.misc.VersionHelper; import com.redstoner.modules.CoreModule; import com.redstoner.modules.Module; +import net.minecraft.server.v1_11_R1.MinecraftServer; + /** The module loader, mother of all modules. Responsible for loading and taking care of all modules. * * @author Pepich */ @@ -30,9 +37,21 @@ public final class ModuleLoader implements CoreModule { private static ModuleLoader instance; private static final HashMap modules = new HashMap(); + private static URL[] urls; + private static URLClassLoader mainLoader; private ModuleLoader() - {} + { + try + { + urls = new URL[] {(new File(Main.plugin.getDataFolder(), "classes")).toURI().toURL()}; + mainLoader = new URLClassLoader(urls, this.getClass().getClassLoader()); + } + catch (MalformedURLException e) + { + System.out.println("Sumtin is wong with ya filesüstem m8. Fix eeeet or I won't werk!"); + } + } public static void init() { @@ -42,10 +61,12 @@ public final class ModuleLoader implements CoreModule Main.plugin); } - /** This method will add a module to the module list, without enabling it + /** This method will add a module to the module list, without enabling it.
+ * This method is deprecated, use addDynamicModule(String name) instead. When using this method, dynamic reloading of the module will not be supported. * * @param clazz The class of the module to be added. */ @Debugable + @Deprecated public static final void addModule(Class clazz) { Debugger.notifyMethod(clazz); @@ -60,6 +81,20 @@ public final class ModuleLoader implements CoreModule } } + @Debugable + private static final void addLoadedModule(Module m) + { + Debugger.notifyMethod(m); + if (modules.containsKey(m)) + if (modules.get(m)) + { + Utils.error( + "Module m was already loaded and enabled. Disable the module before attempting to reload it."); + return; + } + modules.put(m, false); + } + /** Call this to enable all not-yet enabled modules that are known to the loader. */ @Debugable public static final void enableModules() @@ -69,23 +104,7 @@ public final class ModuleLoader implements CoreModule { if (modules.get(module)) continue; - try - { - if (module.onEnable()) - { - if (VersionHelper.isCompatible(VersionHelper.create(2, 0, 0, -1), module.getClass())) - CommandManager.registerCommand(module.getCommandString(), module, Main.plugin); - modules.put(module, true); - Utils.info("Loaded module " + module.getClass().getName()); - } - else - Utils.error("Failed to load module " + module.getClass().getName()); - } - catch (Exception e) - { - Utils.error("Failed to load module " + module.getClass().getName()); - e.printStackTrace(); - } + enableLoadedModule(module); } Utils.info("Modules enabled, running post initialization."); for (Module module : modules.keySet()) @@ -111,11 +130,13 @@ public final class ModuleLoader implements CoreModule } } - /** This method enables a specific module. If no module with that name is known to the loader yet it will be added to the list. + /** This method enables a specific module. If no module with that name is known to the loader yet it will be added to the list.
+ * This method is deprecated, use enableDynamicModule instead. When using this method, dynamic reloading of the module will not be supported. * * @param clazz The class of the module to be enabled. * @return true, when the module was successfully enabled. */ @Debugable + @Deprecated public static final boolean enableModule(Class clazz) { Debugger.notifyMethod(clazz); @@ -123,6 +144,11 @@ public final class ModuleLoader implements CoreModule { if (module.getClass().equals(clazz)) { + if (modules.get(module)) + { + Utils.info("Module was already enabled! Ignoring module.!"); + return true; + } if (module.onEnable()) { if (module.getClass().isAnnotationPresent(AutoRegisterListener.class) @@ -130,13 +156,13 @@ public final class ModuleLoader implements CoreModule { Bukkit.getPluginManager().registerEvents((Listener) module, Main.plugin); } - Utils.info("Loaded module " + module.getClass().getName()); + Utils.info("Enabled module " + module.getClass().getName()); modules.put(module, true); return true; } else { - Utils.error("Failed to load module " + module.getClass().getName()); + Utils.error("Failed to enable module " + module.getClass().getName()); return false; } } @@ -151,12 +177,12 @@ public final class ModuleLoader implements CoreModule { Bukkit.getPluginManager().registerEvents((Listener) m, Main.plugin); } - Utils.info("Loaded module " + m.getClass().getName()); + Utils.info("Loaded and enabled module " + m.getClass().getName()); return true; } else { - Utils.error("Failed to load module " + m.getClass().getName()); + Utils.error("Failed to enable module " + m.getClass().getName()); return false; } } @@ -167,6 +193,32 @@ public final class ModuleLoader implements CoreModule } } + @SuppressWarnings("deprecation") + private static final void enableLoadedModule(Module module) + { + try + { + if (module.onEnable()) + { + if (VersionHelper.isCompatible(VersionHelper.create(2, 0, 0, -1), module.getClass())) + CommandManager.registerCommand(module.getCommandString(), module, Main.plugin); + modules.put(module, true); + if (VersionHelper.isCompatible(VersionHelper.create(3, 0, 0, 3), module.getClass())) + { + module.postEnable(); + } + Utils.info("Loaded module " + module.getClass().getName()); + } + else + Utils.error("Failed to load module " + module.getClass().getName()); + } + catch (Exception e) + { + Utils.error("Failed to load module " + module.getClass().getName()); + e.printStackTrace(); + } + } + /** This method lists all modules to the specified CommandSender. The modules will be color coded correspondingly to their enabled status. * * @param sender The person to send the info to, usually the issuer of the command or the console sender. @@ -194,19 +246,141 @@ public final class ModuleLoader implements CoreModule { for (Module module : modules.keySet()) { - if (modules.get(module)) + disableModule(module); + } + } + + public static void disableModule(Module module) + { + if (modules.get(module)) + { + module.onDisable(); + if (module.getClass().isAnnotationPresent(AutoRegisterListener.class) && (module instanceof Listener)) { - module.onDisable(); - if (module.getClass().isAnnotationPresent(AutoRegisterListener.class) && (module instanceof Listener)) - { - HandlerList.unregisterAll((Listener) module); - } + HandlerList.unregisterAll((Listener) module); } } } - public static boolean loadModule(File f) + @Command(hook = "load") + public boolean loadModule(CommandSender sender, String name) { - return false; + addDynamicModule(name); + return true; + } + + public static final void addDynamicModule(String name) + { + Object[] status = getServerStatus(); + for (Module m : modules.keySet()) + { + if (m.getClass().getName().equals(name)) + { + Utils.info( + "Found existing module, attempting override. WARNING! This operation will halt the main thread until it is completed."); + Utils.info("Current server status:"); + Utils.info("Current system time: " + status[0]); + Utils.info("Current tick: " + status[1]); + Utils.info("Last TPS: " + status[2]); + Utils.info("Entity count: " + status[3]); + Utils.info("Player count: " + status[4]); + Utils.info("Attempting to load new class definition before disabling and removing the old module:"); + boolean differs = false; + Utils.info("Old class definition: Class@" + m.getClass().hashCode()); + ClassLoader delegateParent = Module.class.getClassLoader(); + Class newClass = null; + try (URLClassLoader cl = new URLClassLoader(urls, delegateParent)) + { + newClass = cl.loadClass(m.getClass().getName()); + Utils.info("Found new class definition: Class@" + newClass.hashCode()); + differs = m.getClass() != newClass; + } + catch (IOException | ClassNotFoundException e) + { + Utils.error("Could not find a class definition, aborting now!"); + e.printStackTrace(); + return; + } + if (!differs) + { + Utils.warn("New class definition equals old definition, are you sure you did everything right?"); + Utils.info("Aborting now..."); + return; + } + Utils.info("Found new class definition, attempting to instantiate:"); + Module module = null; + try + { + module = (Module) newClass.newInstance(); + } + catch (InstantiationException | IllegalAccessException e) + { + Utils.error("Could not instantiate the module, aborting!"); + e.printStackTrace(); + return; + } + Utils.info("Instantiated new class definition, checking versions:"); + Version oldVersion = m.getClass().getAnnotation(Version.class); + Utils.info("Current version: " + VersionHelper.getString(oldVersion)); + Version newVersion = module.getClass().getAnnotation(Version.class); + Utils.info("Version of remote class: " + VersionHelper.getString(newVersion)); + if (oldVersion.equals(newVersion)) + { + Utils.error("Detected equal module versions, aborting now..."); + return; + } + Utils.info("Versions differ, disabling old module:"); + disableModule(m); + Utils.info("Disabled module, overriding the implementation:"); + modules.remove(m); + modules.put(module, false); + Utils.info("Successfully updated class definition. Enabling new implementation:"); + enableLoadedModule(module); + Object[] newStatus = getServerStatus(); + Utils.info("Task complete! Took " + ((long) newStatus[0] - (long) status[0]) + "ms to finish!"); + Utils.info("Current server status:"); + Utils.info("Current system time: " + newStatus[0]); + Utils.info("Current tick: " + newStatus[1]); + Utils.info("Last TPS: " + newStatus[2]); + Utils.info("Entity count: " + newStatus[3]); + Utils.info("Player count: " + newStatus[4]); + return; + } + } + try + { + Class clazz = mainLoader.loadClass(name); + Module module = (Module) clazz.newInstance(); + addLoadedModule(module); + enableLoadedModule(module); + } + catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) + { + if (!name.startsWith("com.redstoner.modules.")) + { + Utils.warn( + "Couldn't find class definition, suspecting missing path. Autocompleting path, trying again."); + addDynamicModule("com.redstoner.modules." + name); + } + else + e.printStackTrace(); + } + } + + @SuppressWarnings("deprecation") + private static final Object[] getServerStatus() + { + final Object[] status = new Object[5]; + status[0] = System.currentTimeMillis(); + status[1] = MinecraftServer.currentTick; + status[2] = MinecraftServer.getServer().recentTps[0]; + int i = 0; + for (World w : Bukkit.getWorlds()) + { + i += w.getEntities().size(); + } + status[3] = i; + status[4] = Bukkit.getOnlinePlayers().size(); + return status; } } diff --git a/src/com/redstoner/misc/VersionHelper.java b/src/com/redstoner/misc/VersionHelper.java index 9e7bf35..2c4a266 100644 --- a/src/com/redstoner/misc/VersionHelper.java +++ b/src/com/redstoner/misc/VersionHelper.java @@ -8,7 +8,7 @@ import com.redstoner.exceptions.MissingVersionException; /** This class can be used to compare modules against the loader version or against each other to prevent dependency issues. * * @author Pepich */ -@Version(major = 2, minor = 1, revision = 1, compatible = 0) +@Version(major = 2, minor = 1, revision = 2, compatible = 0) public final class VersionHelper { private VersionHelper() @@ -86,6 +86,15 @@ public final class VersionHelper if (!clazz.isAnnotationPresent(Version.class)) throw new MissingVersionException("The given class is not associated with a version."); Version ver = clazz.getAnnotation(Version.class); + return getString(ver); + } + + /** Returns the String representation of a version. + * + * @param ver The version to be represented. + * @return The String representation. */ + public static String getString(Version ver) + { return ver.major() + "." + ver.minor() + "." + ver.revision() + "." + ver.compatible(); } -- 2.45.2 From 0f2d3657433cb6194d63564600318d3bdf532327 Mon Sep 17 00:00:00 2001 From: Pepich Date: Wed, 29 Mar 2017 09:31:57 +0200 Subject: [PATCH 068/152] Updated to API v3.1 --- src/com/redstoner/misc/Main.java | 110 +++++++++++-------------------- 1 file changed, 39 insertions(+), 71 deletions(-) diff --git a/src/com/redstoner/misc/Main.java b/src/com/redstoner/misc/Main.java index bd016ce..92ee7d7 100644 --- a/src/com/redstoner/misc/Main.java +++ b/src/com/redstoner/misc/Main.java @@ -6,43 +6,11 @@ import com.redstoner.annotations.Version; import com.redstoner.coremods.debugger.Debugger; import com.redstoner.coremods.moduleLoader.ModuleLoader; import com.redstoner.misc.mysql.MysqlHandler; -import com.redstoner.modules.abot.Abot; -import com.redstoner.modules.adminchat.Adminchat; -import com.redstoner.modules.adminnotes.AdminNotes; -import com.redstoner.modules.challenge.Challenge; -import com.redstoner.modules.chatalias.Chatalias; -import com.redstoner.modules.chatgroups.Chatgroups; -import com.redstoner.modules.chatonly.ChatOnly; -import com.redstoner.modules.check.Check; -import com.redstoner.modules.clear.Clear; -import com.redstoner.modules.clearonjoin.ClearOnJoin; -import com.redstoner.modules.cycle.Cycle; -import com.redstoner.modules.damnspam.DamnSpam; -import com.redstoner.modules.essentials.Essentials; -import com.redstoner.modules.firstseen.FirstSeen; -import com.redstoner.modules.illumination.Illumination; -import com.redstoner.modules.imout.Imout; -import com.redstoner.modules.lagchunks.LagChunks; -import com.redstoner.modules.loginsecurity.LoginSecurity; -import com.redstoner.modules.mentio.Mentio; -import com.redstoner.modules.misc.Misc; -import com.redstoner.modules.motd.Motd; -import com.redstoner.modules.nametags.Nametags; -import com.redstoner.modules.naming.Naming; -import com.redstoner.modules.pmtoggle.Pmtoggle; -import com.redstoner.modules.reports.Reports; -import com.redstoner.modules.saylol.Saylol; -import com.redstoner.modules.scriptutils.Scriptutils; -import com.redstoner.modules.skullclick.SkullClick; -import com.redstoner.modules.tag.Tag; -import com.redstoner.modules.vanish.Vanish; -import com.redstoner.modules.warn.Warn; -import com.redstoner.modules.webtoken.WebToken; /** Main class. Duh. * * @author Pepich */ -@Version(major = 1, minor = 6, revision = 0, compatible = -1) +@Version(major = 3, minor = 0, revision = 0, compatible = -1) public class Main extends JavaPlugin { public static JavaPlugin plugin; @@ -54,44 +22,44 @@ public class Main extends JavaPlugin Debugger.init(); ModuleLoader.init(); MysqlHandler.init(); - ModuleLoader.addModule(Abot.class); - ModuleLoader.addModule(Adminchat.class); - ModuleLoader.addModule(AdminNotes.class); - // TODO: ModuleLoader.addModule(BlockplaceMods.class); - // TODO: ModuleLoader.addModule(Calc.class); - ModuleLoader.addModule(Challenge.class); - ModuleLoader.addModule(ChatOnly.class); - ModuleLoader.addModule(Clear.class); - ModuleLoader.addModule(ClearOnJoin.class); - ModuleLoader.addModule(Chatalias.class); - ModuleLoader.addModule(Cycle.class); - ModuleLoader.addModule(Chatgroups.class); - ModuleLoader.addModule(Check.class); - ModuleLoader.addModule(DamnSpam.class); - ModuleLoader.addModule(Essentials.class); - ModuleLoader.addModule(FirstSeen.class); - // TODO: ModuleLoader.addModule(Friends.class); - ModuleLoader.addModule(Illumination.class); - // TODO: ModuleLoader.addModule(Imbusy.class); - ModuleLoader.addModule(Imout.class); - ModuleLoader.addModule(LagChunks.class); - ModuleLoader.addModule(LoginSecurity.class); - ModuleLoader.addModule(Mentio.class); - ModuleLoader.addModule(Misc.class); - ModuleLoader.addModule(Motd.class); - ModuleLoader.addModule(Naming.class); - ModuleLoader.addModule(Nametags.class); - ModuleLoader.addModule(Pmtoggle.class); - ModuleLoader.addModule(Reports.class); - ModuleLoader.addModule(Saylol.class); - ModuleLoader.addModule(Scriptutils.class); - // TODO: ModuleLoader.addModule(Serversigns.class); - // TODO: ModuleLoader.addModule(Signalstrength.class); - ModuleLoader.addModule(SkullClick.class); - ModuleLoader.addModule(Tag.class); - ModuleLoader.addModule(Vanish.class); - ModuleLoader.addModule(Warn.class); - ModuleLoader.addModule(WebToken.class); + ModuleLoader.addDynamicModule("com.redstoner.modules.abot.Abot"); + ModuleLoader.addDynamicModule("com.redstoner.modules.adminchat.Adminchat"); + ModuleLoader.addDynamicModule("com.redstoner.modules.adminnotes.AdminNotes"); + // TODO: ModuleLoader.addDynamicModule("com.redstoner.modules.blockplacemods.BlockplaceMods"); + // TODO: ModuleLoader.addDynamicModule("com.redstoner.modules.calc.Calc"); + ModuleLoader.addDynamicModule("com.redstoner.modules.challenge.Challenge"); + ModuleLoader.addDynamicModule("com.redstoner.modules.chatonly.ChatOnly"); + ModuleLoader.addDynamicModule("com.redstoner.modules.clear.Clear"); + ModuleLoader.addDynamicModule("com.redstoner.modules.clearonjoin.ClearOnJoin"); + ModuleLoader.addDynamicModule("com.redstoner.modules.chatalias.Chatalias"); + ModuleLoader.addDynamicModule("com.redstoner.modules.cycle.Cycle"); + ModuleLoader.addDynamicModule("com.redstoner.modules.chatgroups.Chatgroups"); + ModuleLoader.addDynamicModule("com.redstoner.modules.check.Check"); + ModuleLoader.addDynamicModule("com.redstoner.modules.damnspam.DamnSpam"); + // ModuleLoader.addDynamicModule("com.redstoner.modules.essentials.Essentials"); + ModuleLoader.addDynamicModule("com.redstoner.modules.firstseen.FirstSeen"); + // TODO: ModuleLoader.addDynamicModule("com.redstoner.modules.friends.Friends"); + ModuleLoader.addDynamicModule("com.redstoner.modules.illumination.Illumination"); + // TODO: ModuleLoader.addDynamicModule("com.redstoner.modules.imbusy.Imbusy"); + ModuleLoader.addDynamicModule("com.redstoner.modules.imout.Imout"); + ModuleLoader.addDynamicModule("com.redstoner.modules.lagchunks.LagChunks"); + ModuleLoader.addDynamicModule("com.redstoner.modules.loginsecurity.LoginSecurity"); + ModuleLoader.addDynamicModule("com.redstoner.modules.mentio.Mentio"); + ModuleLoader.addDynamicModule("com.redstoner.modules.misc.Misc"); + ModuleLoader.addDynamicModule("com.redstoner.modules.motd.Motd"); + ModuleLoader.addDynamicModule("com.redstoner.modules.naming.Naming"); + ModuleLoader.addDynamicModule("com.redstoner.modules.nametags.Nametags"); + ModuleLoader.addDynamicModule("com.redstoner.modules.pmtoggle.Pmtoggle"); + ModuleLoader.addDynamicModule("com.redstoner.modules.reports.Reports"); + ModuleLoader.addDynamicModule("com.redstoner.modules.saylol.Saylol"); + ModuleLoader.addDynamicModule("com.redstoner.modules.scriptutils.Scriptutils"); + // TODO: ModuleLoader.addDynamicModule("com.redstoner.modules.serversigns.Serversigns"); + // TODO: ModuleLoader.addDynamicModule("com.redstoner.modules.signalstrength.Signalstrength"); + ModuleLoader.addDynamicModule("com.redstoner.modules.skullclick.SkullClick"); + ModuleLoader.addDynamicModule("com.redstoner.modules.tag.Tag"); + ModuleLoader.addDynamicModule("com.redstoner.modules.vanish.Vanish"); + ModuleLoader.addDynamicModule("com.redstoner.modules.warn.Warn"); + ModuleLoader.addDynamicModule("com.redstoner.modules.webtoken.WebToken"); // And enable them ModuleLoader.enableModules(); } -- 2.45.2 From 8f8859277e45b791f613a1db8e14c3e6f8d0dafa Mon Sep 17 00:00:00 2001 From: Pepich Date: Wed, 29 Mar 2017 09:32:17 +0200 Subject: [PATCH 069/152] Disallowed sudoing the modules command as of API v3.1 --- src/com/redstoner/modules/misc/Misc.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/com/redstoner/modules/misc/Misc.java b/src/com/redstoner/modules/misc/Misc.java index cc9d89c..5750e19 100644 --- a/src/com/redstoner/modules/misc/Misc.java +++ b/src/com/redstoner/modules/misc/Misc.java @@ -18,11 +18,12 @@ import com.redstoner.misc.Utils; import com.redstoner.modules.Module; @AutoRegisterListener -@Version(major = 2, minor = 0, revision = 2, compatible = 2) +@Version(major = 2, minor = 0, revision = 3, compatible = 2) public class Misc implements Module, Listener { - private final String[] sudoBlacklist = new String[] {".*:?esudo", ".*:?sudo", ".*:?script.*", ".*:?stop"}; - + private final String[] sudoBlacklist = new String[] {".?+:?esudo", ".?+:?sudo", ".?+:?script.*", ".?+:?stop", + ".?+:?modules"}; + @EventHandler public void onFirstJoin(PlayerJoinEvent event) { -- 2.45.2 From b5eebeddab4364f7c56e2e70bab4a8012d35f59a Mon Sep 17 00:00:00 2001 From: Pepich Date: Wed, 29 Mar 2017 12:47:35 +0200 Subject: [PATCH 070/152] Fixed mutli-class modules to be unrelodaable --- .../coremods/moduleLoader/ModuleLoader.java | 51 +++++++++++++++++-- 1 file changed, 47 insertions(+), 4 deletions(-) diff --git a/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java b/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java index fc57b57..78be0aa 100644 --- a/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java +++ b/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java @@ -32,13 +32,14 @@ import net.minecraft.server.v1_11_R1.MinecraftServer; /** The module loader, mother of all modules. Responsible for loading and taking care of all modules. * * @author Pepich */ -@Version(major = 3, minor = 1, revision = 0, compatible = 2) +@Version(major = 3, minor = 1, revision = 1, compatible = 2) public final class ModuleLoader implements CoreModule { private static ModuleLoader instance; private static final HashMap modules = new HashMap(); private static URL[] urls; private static URLClassLoader mainLoader; + private static HashMap loaders = new HashMap(); private ModuleLoader() { @@ -306,24 +307,41 @@ public final class ModuleLoader implements CoreModule Utils.info("Attempting to load new class definition before disabling and removing the old module:"); boolean differs = false; Utils.info("Old class definition: Class@" + m.getClass().hashCode()); - ClassLoader delegateParent = Module.class.getClassLoader(); + ClassLoader delegateParent = mainLoader.getParent(); Class newClass = null; - try (URLClassLoader cl = new URLClassLoader(urls, delegateParent)) + URLClassLoader cl = new URLClassLoader(urls, delegateParent); + try { newClass = cl.loadClass(m.getClass().getName()); Utils.info("Found new class definition: Class@" + newClass.hashCode()); differs = m.getClass() != newClass; } - catch (IOException | ClassNotFoundException e) + catch (ClassNotFoundException e) { Utils.error("Could not find a class definition, aborting now!"); e.printStackTrace(); + try + { + cl.close(); + } + catch (IOException e1) + { + e1.printStackTrace(); + } return; } if (!differs) { Utils.warn("New class definition equals old definition, are you sure you did everything right?"); Utils.info("Aborting now..."); + try + { + cl.close(); + } + catch (IOException e) + { + e.printStackTrace(); + } return; } Utils.info("Found new class definition, attempting to instantiate:"); @@ -336,6 +354,14 @@ public final class ModuleLoader implements CoreModule { Utils.error("Could not instantiate the module, aborting!"); e.printStackTrace(); + try + { + cl.close(); + } + catch (IOException e1) + { + e1.printStackTrace(); + } return; } Utils.info("Instantiated new class definition, checking versions:"); @@ -346,13 +372,30 @@ public final class ModuleLoader implements CoreModule if (oldVersion.equals(newVersion)) { Utils.error("Detected equal module versions, aborting now..."); + try + { + cl.close(); + } + catch (IOException e) + { + e.printStackTrace(); + } return; } Utils.info("Versions differ, disabling old module:"); disableModule(m); Utils.info("Disabled module, overriding the implementation:"); modules.remove(m); + try + { + loaders.remove(m).close(); + } + catch (IOException e) + { + e.printStackTrace(); + } modules.put(module, false); + loaders.put(module, cl); Utils.info("Successfully updated class definition. Enabling new implementation:"); enableLoadedModule(module); Object[] newStatus = getServerStatus(); -- 2.45.2 From d9ffac4678381c4f482ac60f90700223a8a86f3c Mon Sep 17 00:00:00 2001 From: Pepich Date: Wed, 29 Mar 2017 14:46:33 +0200 Subject: [PATCH 071/152] Made module auto loading config based --- src/com/redstoner/misc/Main.java | 131 ++++++++++++++++++++++--------- 1 file changed, 92 insertions(+), 39 deletions(-) diff --git a/src/com/redstoner/misc/Main.java b/src/com/redstoner/misc/Main.java index 92ee7d7..8880806 100644 --- a/src/com/redstoner/misc/Main.java +++ b/src/com/redstoner/misc/Main.java @@ -1,5 +1,11 @@ package com.redstoner.misc; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.util.List; + +import org.bukkit.configuration.InvalidConfigurationException; import org.bukkit.plugin.java.JavaPlugin; import com.redstoner.annotations.Version; @@ -10,56 +16,103 @@ import com.redstoner.misc.mysql.MysqlHandler; /** Main class. Duh. * * @author Pepich */ -@Version(major = 3, minor = 0, revision = 0, compatible = -1) +@Version(major = 3, minor = 0, revision = 1, compatible = -1) public class Main extends JavaPlugin { public static JavaPlugin plugin; + public static File configFile; @Override public void onEnable() { plugin = this; + configFile = new File(this.getDataFolder(), "config.yml"); Debugger.init(); ModuleLoader.init(); MysqlHandler.init(); - ModuleLoader.addDynamicModule("com.redstoner.modules.abot.Abot"); - ModuleLoader.addDynamicModule("com.redstoner.modules.adminchat.Adminchat"); - ModuleLoader.addDynamicModule("com.redstoner.modules.adminnotes.AdminNotes"); - // TODO: ModuleLoader.addDynamicModule("com.redstoner.modules.blockplacemods.BlockplaceMods"); - // TODO: ModuleLoader.addDynamicModule("com.redstoner.modules.calc.Calc"); - ModuleLoader.addDynamicModule("com.redstoner.modules.challenge.Challenge"); - ModuleLoader.addDynamicModule("com.redstoner.modules.chatonly.ChatOnly"); - ModuleLoader.addDynamicModule("com.redstoner.modules.clear.Clear"); - ModuleLoader.addDynamicModule("com.redstoner.modules.clearonjoin.ClearOnJoin"); - ModuleLoader.addDynamicModule("com.redstoner.modules.chatalias.Chatalias"); - ModuleLoader.addDynamicModule("com.redstoner.modules.cycle.Cycle"); - ModuleLoader.addDynamicModule("com.redstoner.modules.chatgroups.Chatgroups"); - ModuleLoader.addDynamicModule("com.redstoner.modules.check.Check"); - ModuleLoader.addDynamicModule("com.redstoner.modules.damnspam.DamnSpam"); - // ModuleLoader.addDynamicModule("com.redstoner.modules.essentials.Essentials"); - ModuleLoader.addDynamicModule("com.redstoner.modules.firstseen.FirstSeen"); - // TODO: ModuleLoader.addDynamicModule("com.redstoner.modules.friends.Friends"); - ModuleLoader.addDynamicModule("com.redstoner.modules.illumination.Illumination"); - // TODO: ModuleLoader.addDynamicModule("com.redstoner.modules.imbusy.Imbusy"); - ModuleLoader.addDynamicModule("com.redstoner.modules.imout.Imout"); - ModuleLoader.addDynamicModule("com.redstoner.modules.lagchunks.LagChunks"); - ModuleLoader.addDynamicModule("com.redstoner.modules.loginsecurity.LoginSecurity"); - ModuleLoader.addDynamicModule("com.redstoner.modules.mentio.Mentio"); - ModuleLoader.addDynamicModule("com.redstoner.modules.misc.Misc"); - ModuleLoader.addDynamicModule("com.redstoner.modules.motd.Motd"); - ModuleLoader.addDynamicModule("com.redstoner.modules.naming.Naming"); - ModuleLoader.addDynamicModule("com.redstoner.modules.nametags.Nametags"); - ModuleLoader.addDynamicModule("com.redstoner.modules.pmtoggle.Pmtoggle"); - ModuleLoader.addDynamicModule("com.redstoner.modules.reports.Reports"); - ModuleLoader.addDynamicModule("com.redstoner.modules.saylol.Saylol"); - ModuleLoader.addDynamicModule("com.redstoner.modules.scriptutils.Scriptutils"); - // TODO: ModuleLoader.addDynamicModule("com.redstoner.modules.serversigns.Serversigns"); - // TODO: ModuleLoader.addDynamicModule("com.redstoner.modules.signalstrength.Signalstrength"); - ModuleLoader.addDynamicModule("com.redstoner.modules.skullclick.SkullClick"); - ModuleLoader.addDynamicModule("com.redstoner.modules.tag.Tag"); - ModuleLoader.addDynamicModule("com.redstoner.modules.vanish.Vanish"); - ModuleLoader.addDynamicModule("com.redstoner.modules.warn.Warn"); - ModuleLoader.addDynamicModule("com.redstoner.modules.webtoken.WebToken"); + try + { + if (!configFile.exists()) + { + configFile.getParentFile().mkdirs(); + configFile.createNewFile(); + } + getConfig().load(configFile); + } + catch (FileNotFoundException e) + {} + catch (IOException e) + { + e.printStackTrace(); + } + catch (InvalidConfigurationException e) + { + configFile.delete(); + try + { + configFile.createNewFile(); + } + catch (IOException e1) + { + e1.printStackTrace(); + } + Utils.error("Invalid config file! Creating new, blank file!"); + } + List autoload = this.getConfig().getStringList("autoLoad"); + if (autoload == null || autoload.isEmpty()) + { + getConfig().set("autoLoad", new String[] {"# Add the modules here!"}); + saveConfig(); + try + { + getConfig().save(configFile); + } + catch (IOException e) + { + e.printStackTrace(); + } + } + for (String s : autoload) + if (!s.startsWith("#")) + ModuleLoader.addDynamicModule(s); + // ModuleLoader.addDynamicModule("com.redstoner.modules.abot.Abot"); + // ModuleLoader.addDynamicModule("com.redstoner.modules.adminchat.Adminchat"); + // ModuleLoader.addDynamicModule("com.redstoner.modules.adminnotes.AdminNotes"); + // // TODO: ModuleLoader.addDynamicModule("com.redstoner.modules.blockplacemods.BlockplaceMods"); + // // TODO: ModuleLoader.addDynamicModule("com.redstoner.modules.calc.Calc"); + // ModuleLoader.addDynamicModule("com.redstoner.modules.challenge.Challenge"); + // ModuleLoader.addDynamicModule("com.redstoner.modules.chatonly.ChatOnly"); + // ModuleLoader.addDynamicModule("com.redstoner.modules.clear.Clear"); + // ModuleLoader.addDynamicModule("com.redstoner.modules.clearonjoin.ClearOnJoin"); + // ModuleLoader.addDynamicModule("com.redstoner.modules.chatalias.Chatalias"); + // ModuleLoader.addDynamicModule("com.redstoner.modules.cycle.Cycle"); + // ModuleLoader.addDynamicModule("com.redstoner.modules.chatgroups.Chatgroups"); + // ModuleLoader.addDynamicModule("com.redstoner.modules.check.Check"); + // ModuleLoader.addDynamicModule("com.redstoner.modules.damnspam.DamnSpam"); + // // ModuleLoader.addDynamicModule("com.redstoner.modules.essentials.Essentials"); + // ModuleLoader.addDynamicModule("com.redstoner.modules.firstseen.FirstSeen"); + // // TODO: ModuleLoader.addDynamicModule("com.redstoner.modules.friends.Friends"); + // ModuleLoader.addDynamicModule("com.redstoner.modules.illumination.Illumination"); + // // TODO: ModuleLoader.addDynamicModule("com.redstoner.modules.imbusy.Imbusy"); + // ModuleLoader.addDynamicModule("com.redstoner.modules.imout.Imout"); + // ModuleLoader.addDynamicModule("com.redstoner.modules.lagchunks.LagChunks"); + // ModuleLoader.addDynamicModule("com.redstoner.modules.loginsecurity.LoginSecurity"); + // ModuleLoader.addDynamicModule("com.redstoner.modules.mentio.Mentio"); + // ModuleLoader.addDynamicModule("com.redstoner.modules.misc.Misc"); + // ModuleLoader.addDynamicModule("com.redstoner.modules.motd.Motd"); + // ModuleLoader.addDynamicModule("com.redstoner.modules.naming.Naming"); + // ModuleLoader.addDynamicModule("com.redstoner.modules.nametags.Nametags"); + // ModuleLoader.addDynamicModule("com.redstoner.modules.pmtoggle.Pmtoggle"); + // ModuleLoader.addDynamicModule("com.redstoner.modules.reports.Reports"); + // ModuleLoader.addDynamicModule("com.redstoner.modules.saylol.Saylol"); + // ModuleLoader.addDynamicModule("com.redstoner.modules.scriptutils.Scriptutils"); + // // TODO: ModuleLoader.addDynamicModule("com.redstoner.modules.serversigns.Serversigns"); + // // TODO: ModuleLoader.addDynamicModule("com.redstoner.modules.signalstrength.Signalstrength"); + // ModuleLoader.addDynamicModule("com.redstoner.modules.skullclick.SkullClick"); + // ModuleLoader.addDynamicModule("com.redstoner.modules.tag.Tag"); + // ModuleLoader.addDynamicModule("com.redstoner.modules.vanish.Vanish"); + // ModuleLoader.addDynamicModule("com.redstoner.modules.warn.Warn"); + // ModuleLoader.addDynamicModule("com.redstoner.modules.webtoken.WebToken"); // And enable them ModuleLoader.enableModules(); } -- 2.45.2 From 7e01ec6c560fdf4e806d8a70e9f54b3eac28eaed Mon Sep 17 00:00:00 2001 From: Pepich Date: Wed, 29 Mar 2017 14:51:46 +0200 Subject: [PATCH 072/152] Suppressing deprecation warning for seamless backwards compatibility --- src/com/redstoner/coremods/moduleLoader/ModuleLoader.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java b/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java index 78be0aa..565c7dd 100644 --- a/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java +++ b/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java @@ -32,7 +32,7 @@ import net.minecraft.server.v1_11_R1.MinecraftServer; /** The module loader, mother of all modules. Responsible for loading and taking care of all modules. * * @author Pepich */ -@Version(major = 3, minor = 1, revision = 1, compatible = 2) +@Version(major = 3, minor = 1, revision = 2, compatible = 2) public final class ModuleLoader implements CoreModule { private static ModuleLoader instance; @@ -97,6 +97,7 @@ public final class ModuleLoader implements CoreModule } /** Call this to enable all not-yet enabled modules that are known to the loader. */ + @SuppressWarnings("deprecation") @Debugable public static final void enableModules() { -- 2.45.2 From 54bd7ba4acd8d4662fc522609d2c6f75e9dda02a Mon Sep 17 00:00:00 2001 From: Pepich Date: Wed, 29 Mar 2017 14:56:42 +0200 Subject: [PATCH 073/152] Moved loadFromConfig functionality from Main to ModuleLoader --- .../coremods/moduleLoader/ModuleLoader.java | 59 ++++++++++++++++++- src/com/redstoner/misc/Main.java | 58 +----------------- 2 files changed, 61 insertions(+), 56 deletions(-) diff --git a/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java b/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java index 565c7dd..0db7683 100644 --- a/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java +++ b/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java @@ -1,15 +1,19 @@ package com.redstoner.coremods.moduleLoader; import java.io.File; +import java.io.FileNotFoundException; import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; import java.net.URLClassLoader; import java.util.HashMap; +import java.util.List; import org.bukkit.Bukkit; import org.bukkit.World; import org.bukkit.command.CommandSender; +import org.bukkit.configuration.InvalidConfigurationException; +import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.event.HandlerList; import org.bukkit.event.Listener; @@ -32,7 +36,7 @@ import net.minecraft.server.v1_11_R1.MinecraftServer; /** The module loader, mother of all modules. Responsible for loading and taking care of all modules. * * @author Pepich */ -@Version(major = 3, minor = 1, revision = 2, compatible = 2) +@Version(major = 3, minor = 1, revision = 3, compatible = 2) public final class ModuleLoader implements CoreModule { private static ModuleLoader instance; @@ -40,11 +44,15 @@ public final class ModuleLoader implements CoreModule private static URL[] urls; private static URLClassLoader mainLoader; private static HashMap loaders = new HashMap(); + private static File configFile; + private static FileConfiguration config; private ModuleLoader() { try { + config = Main.plugin.getConfig(); + configFile = new File(Main.plugin.getDataFolder(), "config.yml"); urls = new URL[] {(new File(Main.plugin.getDataFolder(), "classes")).toURI().toURL()}; mainLoader = new URLClassLoader(urls, this.getClass().getClassLoader()); } @@ -62,6 +70,55 @@ public final class ModuleLoader implements CoreModule Main.plugin); } + public static final void loadFromConfig() + { + try + { + if (!configFile.exists()) + { + configFile.getParentFile().mkdirs(); + configFile.createNewFile(); + } + config.load(configFile); + } + catch (FileNotFoundException e) + {} + catch (IOException e) + { + e.printStackTrace(); + } + catch (InvalidConfigurationException e) + { + configFile.delete(); + try + { + configFile.createNewFile(); + } + catch (IOException e1) + { + e1.printStackTrace(); + } + Utils.error("Invalid config file! Creating new, blank file!"); + } + List autoload = config.getStringList("autoLoad"); + if (autoload == null || autoload.isEmpty()) + { + config.set("autoLoad", new String[] {"# Add the modules here!"}); + Main.plugin.saveConfig(); + try + { + config.save(configFile); + } + catch (IOException e) + { + e.printStackTrace(); + } + } + for (String s : autoload) + if (!s.startsWith("#")) + ModuleLoader.addDynamicModule(s); + } + /** This method will add a module to the module list, without enabling it.
* This method is deprecated, use addDynamicModule(String name) instead. When using this method, dynamic reloading of the module will not be supported. * diff --git a/src/com/redstoner/misc/Main.java b/src/com/redstoner/misc/Main.java index 8880806..76dc291 100644 --- a/src/com/redstoner/misc/Main.java +++ b/src/com/redstoner/misc/Main.java @@ -1,11 +1,5 @@ package com.redstoner.misc; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.util.List; - -import org.bukkit.configuration.InvalidConfigurationException; import org.bukkit.plugin.java.JavaPlugin; import com.redstoner.annotations.Version; @@ -16,65 +10,19 @@ import com.redstoner.misc.mysql.MysqlHandler; /** Main class. Duh. * * @author Pepich */ -@Version(major = 3, minor = 0, revision = 1, compatible = -1) +@Version(major = 3, minor = 1, revision = 0, compatible = -1) public class Main extends JavaPlugin { public static JavaPlugin plugin; - public static File configFile; @Override public void onEnable() { plugin = this; - configFile = new File(this.getDataFolder(), "config.yml"); Debugger.init(); - ModuleLoader.init(); MysqlHandler.init(); - try - { - if (!configFile.exists()) - { - configFile.getParentFile().mkdirs(); - configFile.createNewFile(); - } - getConfig().load(configFile); - } - catch (FileNotFoundException e) - {} - catch (IOException e) - { - e.printStackTrace(); - } - catch (InvalidConfigurationException e) - { - configFile.delete(); - try - { - configFile.createNewFile(); - } - catch (IOException e1) - { - e1.printStackTrace(); - } - Utils.error("Invalid config file! Creating new, blank file!"); - } - List autoload = this.getConfig().getStringList("autoLoad"); - if (autoload == null || autoload.isEmpty()) - { - getConfig().set("autoLoad", new String[] {"# Add the modules here!"}); - saveConfig(); - try - { - getConfig().save(configFile); - } - catch (IOException e) - { - e.printStackTrace(); - } - } - for (String s : autoload) - if (!s.startsWith("#")) - ModuleLoader.addDynamicModule(s); + ModuleLoader.init(); + ModuleLoader.loadFromConfig(); // ModuleLoader.addDynamicModule("com.redstoner.modules.abot.Abot"); // ModuleLoader.addDynamicModule("com.redstoner.modules.adminchat.Adminchat"); // ModuleLoader.addDynamicModule("com.redstoner.modules.adminnotes.AdminNotes"); -- 2.45.2 From 3ee9f7be1bd4e2cd73f35fe0cfd643185e754801 Mon Sep 17 00:00:00 2001 From: Pepich Date: Wed, 29 Mar 2017 21:39:57 +0200 Subject: [PATCH 074/152] Fixed NPE --- src/com/redstoner/coremods/moduleLoader/ModuleLoader.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java b/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java index 0db7683..411b70c 100644 --- a/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java +++ b/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java @@ -446,7 +446,8 @@ public final class ModuleLoader implements CoreModule modules.remove(m); try { - loaders.remove(m).close(); + if (loaders.containsKey(m)) + loaders.remove(m).close(); } catch (IOException e) { -- 2.45.2 From 5b9537c650d5dd05b839708cac9ccea366cb9ec9 Mon Sep 17 00:00:00 2001 From: Pepich Date: Thu, 30 Mar 2017 14:46:20 +0200 Subject: [PATCH 075/152] Dynamically loaded modules will have their autolisteners now respected --- src/com/redstoner/coremods/moduleLoader/ModuleLoader.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java b/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java index 411b70c..e65c9a1 100644 --- a/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java +++ b/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java @@ -36,7 +36,7 @@ import net.minecraft.server.v1_11_R1.MinecraftServer; /** The module loader, mother of all modules. Responsible for loading and taking care of all modules. * * @author Pepich */ -@Version(major = 3, minor = 1, revision = 3, compatible = 2) +@Version(major = 3, minor = 1, revision = 4, compatible = 2) public final class ModuleLoader implements CoreModule { private static ModuleLoader instance; @@ -286,6 +286,10 @@ public final class ModuleLoader implements CoreModule module.postEnable(); } Utils.info("Loaded module " + module.getClass().getName()); + if (module.getClass().isAnnotationPresent(AutoRegisterListener.class) && (module instanceof Listener)) + { + Bukkit.getPluginManager().registerEvents((Listener) module, Main.plugin); + } } else Utils.error("Failed to load module " + module.getClass().getName()); -- 2.45.2 From bcaabdce17bc9553fa136769600de44de28d6650 Mon Sep 17 00:00:00 2001 From: Pepich Date: Thu, 30 Mar 2017 14:46:43 +0200 Subject: [PATCH 076/152] Removed unnecessary comments (see config file) --- src/com/redstoner/misc/Main.java | 40 +------------------------------- 1 file changed, 1 insertion(+), 39 deletions(-) diff --git a/src/com/redstoner/misc/Main.java b/src/com/redstoner/misc/Main.java index 76dc291..ad684a9 100644 --- a/src/com/redstoner/misc/Main.java +++ b/src/com/redstoner/misc/Main.java @@ -10,7 +10,7 @@ import com.redstoner.misc.mysql.MysqlHandler; /** Main class. Duh. * * @author Pepich */ -@Version(major = 3, minor = 1, revision = 0, compatible = -1) +@Version(major = 3, minor = 1, revision = 1, compatible = -1) public class Main extends JavaPlugin { public static JavaPlugin plugin; @@ -23,44 +23,6 @@ public class Main extends JavaPlugin MysqlHandler.init(); ModuleLoader.init(); ModuleLoader.loadFromConfig(); - // ModuleLoader.addDynamicModule("com.redstoner.modules.abot.Abot"); - // ModuleLoader.addDynamicModule("com.redstoner.modules.adminchat.Adminchat"); - // ModuleLoader.addDynamicModule("com.redstoner.modules.adminnotes.AdminNotes"); - // // TODO: ModuleLoader.addDynamicModule("com.redstoner.modules.blockplacemods.BlockplaceMods"); - // // TODO: ModuleLoader.addDynamicModule("com.redstoner.modules.calc.Calc"); - // ModuleLoader.addDynamicModule("com.redstoner.modules.challenge.Challenge"); - // ModuleLoader.addDynamicModule("com.redstoner.modules.chatonly.ChatOnly"); - // ModuleLoader.addDynamicModule("com.redstoner.modules.clear.Clear"); - // ModuleLoader.addDynamicModule("com.redstoner.modules.clearonjoin.ClearOnJoin"); - // ModuleLoader.addDynamicModule("com.redstoner.modules.chatalias.Chatalias"); - // ModuleLoader.addDynamicModule("com.redstoner.modules.cycle.Cycle"); - // ModuleLoader.addDynamicModule("com.redstoner.modules.chatgroups.Chatgroups"); - // ModuleLoader.addDynamicModule("com.redstoner.modules.check.Check"); - // ModuleLoader.addDynamicModule("com.redstoner.modules.damnspam.DamnSpam"); - // // ModuleLoader.addDynamicModule("com.redstoner.modules.essentials.Essentials"); - // ModuleLoader.addDynamicModule("com.redstoner.modules.firstseen.FirstSeen"); - // // TODO: ModuleLoader.addDynamicModule("com.redstoner.modules.friends.Friends"); - // ModuleLoader.addDynamicModule("com.redstoner.modules.illumination.Illumination"); - // // TODO: ModuleLoader.addDynamicModule("com.redstoner.modules.imbusy.Imbusy"); - // ModuleLoader.addDynamicModule("com.redstoner.modules.imout.Imout"); - // ModuleLoader.addDynamicModule("com.redstoner.modules.lagchunks.LagChunks"); - // ModuleLoader.addDynamicModule("com.redstoner.modules.loginsecurity.LoginSecurity"); - // ModuleLoader.addDynamicModule("com.redstoner.modules.mentio.Mentio"); - // ModuleLoader.addDynamicModule("com.redstoner.modules.misc.Misc"); - // ModuleLoader.addDynamicModule("com.redstoner.modules.motd.Motd"); - // ModuleLoader.addDynamicModule("com.redstoner.modules.naming.Naming"); - // ModuleLoader.addDynamicModule("com.redstoner.modules.nametags.Nametags"); - // ModuleLoader.addDynamicModule("com.redstoner.modules.pmtoggle.Pmtoggle"); - // ModuleLoader.addDynamicModule("com.redstoner.modules.reports.Reports"); - // ModuleLoader.addDynamicModule("com.redstoner.modules.saylol.Saylol"); - // ModuleLoader.addDynamicModule("com.redstoner.modules.scriptutils.Scriptutils"); - // // TODO: ModuleLoader.addDynamicModule("com.redstoner.modules.serversigns.Serversigns"); - // // TODO: ModuleLoader.addDynamicModule("com.redstoner.modules.signalstrength.Signalstrength"); - // ModuleLoader.addDynamicModule("com.redstoner.modules.skullclick.SkullClick"); - // ModuleLoader.addDynamicModule("com.redstoner.modules.tag.Tag"); - // ModuleLoader.addDynamicModule("com.redstoner.modules.vanish.Vanish"); - // ModuleLoader.addDynamicModule("com.redstoner.modules.warn.Warn"); - // ModuleLoader.addDynamicModule("com.redstoner.modules.webtoken.WebToken"); // And enable them ModuleLoader.enableModules(); } -- 2.45.2 From ca0582cafe933a34fe416329724caaf05b940bd8 Mon Sep 17 00:00:00 2001 From: Pepich Date: Thu, 30 Mar 2017 18:25:20 +0200 Subject: [PATCH 077/152] Fixed postinit to be run twice, as well as double linking listeners --- .../coremods/moduleLoader/ModuleLoader.java | 43 +------------------ 1 file changed, 1 insertion(+), 42 deletions(-) diff --git a/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java b/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java index e65c9a1..8126252 100644 --- a/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java +++ b/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java @@ -24,7 +24,6 @@ import com.redstoner.annotations.AutoRegisterListener; import com.redstoner.annotations.Debugable; import com.redstoner.annotations.Version; import com.redstoner.coremods.debugger.Debugger; -import com.redstoner.exceptions.MissingVersionException; import com.redstoner.misc.Main; import com.redstoner.misc.Utils; import com.redstoner.misc.VersionHelper; @@ -36,7 +35,7 @@ import net.minecraft.server.v1_11_R1.MinecraftServer; /** The module loader, mother of all modules. Responsible for loading and taking care of all modules. * * @author Pepich */ -@Version(major = 3, minor = 1, revision = 4, compatible = 2) +@Version(major = 3, minor = 1, revision = 5, compatible = 2) public final class ModuleLoader implements CoreModule { private static ModuleLoader instance; @@ -154,7 +153,6 @@ public final class ModuleLoader implements CoreModule } /** Call this to enable all not-yet enabled modules that are known to the loader. */ - @SuppressWarnings("deprecation") @Debugable public static final void enableModules() { @@ -164,45 +162,6 @@ public final class ModuleLoader implements CoreModule if (modules.get(module)) continue; enableLoadedModule(module); - try - { - if (module.onEnable()) - { - if (VersionHelper.isCompatible(VersionHelper.create(2, 0, 0, -1), module.getClass())) - CommandManager.registerCommand(module.getCommandString(), module, Main.plugin); - modules.put(module, true); - Utils.info("Loaded module " + module.getClass().getName()); - } - else - Utils.error("Failed to load module " + module.getClass().getName()); - } - catch (Exception e) - { - Utils.error("Failed to load module " + module.getClass().getName()); - e.printStackTrace(); - } - } - Utils.info("Modules enabled, running post initialization."); - for (Module module : modules.keySet()) - { - if (modules.get(module)) - { - try - { - if (VersionHelper.isCompatible(VersionHelper.create(3, 0, 0, 3), module.getClass())) - { - module.postEnable(); - } - } - catch (MissingVersionException e) - { - e.printStackTrace(); - } - if (module.getClass().isAnnotationPresent(AutoRegisterListener.class) && (module instanceof Listener)) - { - Bukkit.getPluginManager().registerEvents((Listener) module, Main.plugin); - } - } } } -- 2.45.2 From bb95bf2700c8cec7049a1608b6e7f74c5d6d4ea7 Mon Sep 17 00:00:00 2001 From: Pepich Date: Fri, 31 Mar 2017 14:19:23 +0200 Subject: [PATCH 078/152] Fixed sendErrorMessage throwing NPEs --- src/com/redstoner/misc/Utils.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/com/redstoner/misc/Utils.java b/src/com/redstoner/misc/Utils.java index 7012b32..3bd02c2 100644 --- a/src/com/redstoner/misc/Utils.java +++ b/src/com/redstoner/misc/Utils.java @@ -16,7 +16,7 @@ import net.md_5.bungee.api.ChatColor; /** The utils class containing utility functions. Those include but are not limited to sending formatted messages, broadcasts and more. * * @author Pepich */ -@Version(major = 1, minor = 2, revision = 12, compatible = 1) +@Version(major = 1, minor = 2, revision = 13, compatible = 1) public final class Utils { /** The SimpleDateFormat used for getting the current date. */ @@ -48,7 +48,7 @@ public final class Utils @Debugable public static void sendErrorMessage(CommandSender recipient, String prefix, String message) { - Debugger.notifyMethod(recipient, prefix, message); + Debugger.notifyMethod((Object) recipient, prefix, message); if (prefix == null) prefix = "§8[§c" + getCaller() + "§8]: "; recipient.sendMessage(prefix + "§7" + message); -- 2.45.2 From 771b83c7d1496aee31d1ae6c38ae58caaf956afd Mon Sep 17 00:00:00 2001 From: Pepich Date: Fri, 5 May 2017 00:07:07 +0200 Subject: [PATCH 079/152] Added getModule function --- .../coremods/moduleLoader/ModuleLoader.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java b/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java index 8126252..7739db9 100644 --- a/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java +++ b/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java @@ -35,7 +35,7 @@ import net.minecraft.server.v1_11_R1.MinecraftServer; /** The module loader, mother of all modules. Responsible for loading and taking care of all modules. * * @author Pepich */ -@Version(major = 3, minor = 1, revision = 5, compatible = 2) +@Version(major = 3, minor = 1, revision = 6, compatible = 2) public final class ModuleLoader implements CoreModule { private static ModuleLoader instance; @@ -467,4 +467,16 @@ public final class ModuleLoader implements CoreModule status[4] = Bukkit.getOnlinePlayers().size(); return status; } + + /** Finds a module by name for other modules to reference it. + * + * @param name the name of the module. Use the full path if you are not sure about the module's SimpleClassName being unique. + * @return the instance of the module or @null it none could be found */ + public static Module getModule(String name) + { + for (Module m : modules.keySet()) + if (m.getClass().getSimpleName().equals(name) || m.getClass().getName().equals(name)) + return m; + return null; + } } -- 2.45.2 From e88276967c0618c113d9e26d378217b1c1c88f54 Mon Sep 17 00:00:00 2001 From: Pepich Date: Fri, 5 May 2017 00:07:35 +0200 Subject: [PATCH 080/152] idk git stop complaining? I did nothing with these --- src/com/redstoner/misc/Utils.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/com/redstoner/misc/Utils.java b/src/com/redstoner/misc/Utils.java index 3bd02c2..4d06ca3 100644 --- a/src/com/redstoner/misc/Utils.java +++ b/src/com/redstoner/misc/Utils.java @@ -10,6 +10,7 @@ import org.bukkit.entity.Player; import com.redstoner.annotations.Debugable; import com.redstoner.annotations.Version; import com.redstoner.coremods.debugger.Debugger; +import com.redstoner.modules.CoreModule; import net.md_5.bungee.api.ChatColor; @@ -17,15 +18,11 @@ import net.md_5.bungee.api.ChatColor; * * @author Pepich */ @Version(major = 1, minor = 2, revision = 13, compatible = 1) -public final class Utils +public final class Utils implements CoreModule { /** The SimpleDateFormat used for getting the current date. */ public static SimpleDateFormat dateFormat = new SimpleDateFormat("[yyyy-MM-dd HH:mm:ss]"); - /** Hidden constructor. Do not instantiate UTILS classes! :) */ - private Utils() - {} - /** This will send a message to the specified recipient. It will generate the module prefix if you want it to. * * @param recipient Whom to sent the message to. -- 2.45.2 From bc22232b0beef104df3e2af7f20cbc69493b0a5c Mon Sep 17 00:00:00 2001 From: Pepich Date: Fri, 5 May 2017 00:11:25 +0200 Subject: [PATCH 081/152] Reverted last commit (derp) --- src/com/redstoner/misc/Utils.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/com/redstoner/misc/Utils.java b/src/com/redstoner/misc/Utils.java index 4d06ca3..3bd02c2 100644 --- a/src/com/redstoner/misc/Utils.java +++ b/src/com/redstoner/misc/Utils.java @@ -10,7 +10,6 @@ import org.bukkit.entity.Player; import com.redstoner.annotations.Debugable; import com.redstoner.annotations.Version; import com.redstoner.coremods.debugger.Debugger; -import com.redstoner.modules.CoreModule; import net.md_5.bungee.api.ChatColor; @@ -18,11 +17,15 @@ import net.md_5.bungee.api.ChatColor; * * @author Pepich */ @Version(major = 1, minor = 2, revision = 13, compatible = 1) -public final class Utils implements CoreModule +public final class Utils { /** The SimpleDateFormat used for getting the current date. */ public static SimpleDateFormat dateFormat = new SimpleDateFormat("[yyyy-MM-dd HH:mm:ss]"); + /** Hidden constructor. Do not instantiate UTILS classes! :) */ + private Utils() + {} + /** This will send a message to the specified recipient. It will generate the module prefix if you want it to. * * @param recipient Whom to sent the message to. -- 2.45.2 From 205cdb2d8635ddcfd56f5b359309f7e9f241a0a5 Mon Sep 17 00:00:00 2001 From: Pepich Date: Fri, 5 May 2017 00:19:42 +0200 Subject: [PATCH 082/152] Removed old files after moving over to new Repository --- src/com/redstoner/modules/abot/Abot.java | 80 ---- .../modules/adminchat/Adminchat.java | 235 ---------- .../modules/adminnotes/AdminNotes.java | 131 ------ .../modules/challenge/Challenge.java | 284 ------------ .../modules/chatalias/Chatalias.java | 335 -------------- .../modules/chatgroups/Chatgroups.java | 408 ------------------ .../redstoner/modules/chatonly/ChatOnly.java | 8 - src/com/redstoner/modules/check/Check.java | 242 ----------- src/com/redstoner/modules/clear/Clear.java | 40 -- .../modules/clearonjoin/ClearOnJoin.java | 105 ----- src/com/redstoner/modules/cycle/Cycle.java | 159 ------- .../redstoner/modules/damnspam/DamnSpam.java | 367 ---------------- .../redstoner/modules/damnspam/SpamInput.java | 17 - .../modules/essentials/Essentials.java | 188 -------- .../modules/firstseen/FirstSeen.java | 62 --- .../modules/illumination/Illumination.java | 48 --- src/com/redstoner/modules/imout/Imout.java | 59 --- .../modules/lagchunks/LagChunks.java | 106 ----- .../modules/lagchunks/LaggyChunk.java | 21 - .../loginsecurity/CancelledEventsHandler.java | 95 ---- .../loginsecurity/CryptographyHandler.java | 53 --- .../modules/loginsecurity/LoginSecurity.java | 318 -------------- .../loginsecurity/RepeatingLoginRunnable.java | 37 -- src/com/redstoner/modules/mentio/Mentio.java | 192 --------- src/com/redstoner/modules/misc/Misc.java | 212 --------- src/com/redstoner/modules/motd/Motd.java | 71 --- .../redstoner/modules/nametags/Nametags.java | 123 ------ src/com/redstoner/modules/naming/Naming.java | 120 ------ .../redstoner/modules/pmtoggle/Pmtoggle.java | 100 ----- .../redstoner/modules/reports/Reports.java | 163 ------- src/com/redstoner/modules/saylol/Saylol.java | 327 -------------- .../modules/scriptutils/Scriptutils.java | 300 ------------- .../modules/skullclick/SkullClick.java | 60 --- src/com/redstoner/modules/tag/Tag.java | 167 ------- src/com/redstoner/modules/vanish/Vanish.java | 243 ----------- src/com/redstoner/modules/warn/Warn.java | 51 --- .../redstoner/modules/webtoken/WebToken.java | 226 ---------- 37 files changed, 5753 deletions(-) delete mode 100644 src/com/redstoner/modules/abot/Abot.java delete mode 100644 src/com/redstoner/modules/adminchat/Adminchat.java delete mode 100644 src/com/redstoner/modules/adminnotes/AdminNotes.java delete mode 100644 src/com/redstoner/modules/challenge/Challenge.java delete mode 100644 src/com/redstoner/modules/chatalias/Chatalias.java delete mode 100644 src/com/redstoner/modules/chatgroups/Chatgroups.java delete mode 100644 src/com/redstoner/modules/chatonly/ChatOnly.java delete mode 100644 src/com/redstoner/modules/check/Check.java delete mode 100644 src/com/redstoner/modules/clear/Clear.java delete mode 100644 src/com/redstoner/modules/clearonjoin/ClearOnJoin.java delete mode 100644 src/com/redstoner/modules/cycle/Cycle.java delete mode 100644 src/com/redstoner/modules/damnspam/DamnSpam.java delete mode 100644 src/com/redstoner/modules/damnspam/SpamInput.java delete mode 100644 src/com/redstoner/modules/essentials/Essentials.java delete mode 100644 src/com/redstoner/modules/firstseen/FirstSeen.java delete mode 100644 src/com/redstoner/modules/illumination/Illumination.java delete mode 100644 src/com/redstoner/modules/imout/Imout.java delete mode 100644 src/com/redstoner/modules/lagchunks/LagChunks.java delete mode 100644 src/com/redstoner/modules/lagchunks/LaggyChunk.java delete mode 100644 src/com/redstoner/modules/loginsecurity/CancelledEventsHandler.java delete mode 100644 src/com/redstoner/modules/loginsecurity/CryptographyHandler.java delete mode 100644 src/com/redstoner/modules/loginsecurity/LoginSecurity.java delete mode 100644 src/com/redstoner/modules/loginsecurity/RepeatingLoginRunnable.java delete mode 100644 src/com/redstoner/modules/mentio/Mentio.java delete mode 100644 src/com/redstoner/modules/misc/Misc.java delete mode 100644 src/com/redstoner/modules/motd/Motd.java delete mode 100644 src/com/redstoner/modules/nametags/Nametags.java delete mode 100644 src/com/redstoner/modules/naming/Naming.java delete mode 100644 src/com/redstoner/modules/pmtoggle/Pmtoggle.java delete mode 100644 src/com/redstoner/modules/reports/Reports.java delete mode 100644 src/com/redstoner/modules/saylol/Saylol.java delete mode 100644 src/com/redstoner/modules/scriptutils/Scriptutils.java delete mode 100644 src/com/redstoner/modules/skullclick/SkullClick.java delete mode 100644 src/com/redstoner/modules/tag/Tag.java delete mode 100644 src/com/redstoner/modules/vanish/Vanish.java delete mode 100644 src/com/redstoner/modules/warn/Warn.java delete mode 100644 src/com/redstoner/modules/webtoken/WebToken.java diff --git a/src/com/redstoner/modules/abot/Abot.java b/src/com/redstoner/modules/abot/Abot.java deleted file mode 100644 index 97688e8..0000000 --- a/src/com/redstoner/modules/abot/Abot.java +++ /dev/null @@ -1,80 +0,0 @@ -package com.redstoner.modules.abot; - -import java.io.File; - -import org.bukkit.Bukkit; -import org.bukkit.command.CommandSender; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.player.AsyncPlayerChatEvent; -import org.json.simple.JSONArray; -import org.json.simple.JSONObject; - -import com.nemez.cmdmgr.Command; -import com.redstoner.annotations.AutoRegisterListener; -import com.redstoner.annotations.Version; -import com.redstoner.misc.JsonManager; -import com.redstoner.misc.Main; -import com.redstoner.misc.Utils; -import com.redstoner.modules.Module; - -@AutoRegisterListener -@Version(major = 2, minor = 0, revision = 1, compatible = 2) -public class Abot implements Module, Listener -{ - private File answerFile = new File(Main.plugin.getDataFolder(), "abot.json"); - JSONArray answers; - - @EventHandler - public void onPlayerChat(AsyncPlayerChatEvent event) - { - for (Object rawObject : answers) - { - JSONObject entry = (JSONObject) rawObject; - JSONArray regexes = (JSONArray) entry.get("regex"); - for (Object regex : regexes) - { - if (event.getMessage().toLowerCase().matches((String) regex)) - { - Object hideperm = entry.get("hide-perm"); - if (hideperm == null || !event.getPlayer().hasPermission((String) hideperm)) - { - event.setCancelled(true); - Utils.sendMessage(event.getPlayer(), null, (String) entry.get("message"), '&'); - return; - } - } - } - } - } - - @Command(hook = "abot_reload") - public void loadAnswers(CommandSender sender) - { - answers = JsonManager.getArray(answerFile); - if (answers == null) - answers = new JSONArray(); - Utils.sendMessage(sender, null, "Loaded the abot.json file!"); - } - - @Override - public boolean onEnable() - { - loadAnswers(Bukkit.getConsoleSender()); - return true; - } - - // @noformat - @Override - public String getCommandString() - { - return "command abot {\n" + - " reload {" + - " help Reloads answes from the .json file.;\n" + - " run abot_reload;\n" + - " perm utils.abot.reload;" + - " }\n" + - "}"; - } - // format -} diff --git a/src/com/redstoner/modules/adminchat/Adminchat.java b/src/com/redstoner/modules/adminchat/Adminchat.java deleted file mode 100644 index 9fb529a..0000000 --- a/src/com/redstoner/modules/adminchat/Adminchat.java +++ /dev/null @@ -1,235 +0,0 @@ -package com.redstoner.modules.adminchat; - -import java.io.File; -import java.util.ArrayList; -import java.util.UUID; - -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.player.AsyncPlayerChatEvent; -import org.json.simple.JSONObject; - -import com.nemez.cmdmgr.Command; -import com.redstoner.annotations.AutoRegisterListener; -import com.redstoner.annotations.Version; -import com.redstoner.misc.BroadcastFilter; -import com.redstoner.misc.JsonManager; -import com.redstoner.misc.Main; -import com.redstoner.misc.Utils; -import com.redstoner.modules.Module; - -/** AdminChat module. Allows staff to chat to other staff using /ac \ as well as a one char prefix or a toggle. - * - * @author Pepich */ -@AutoRegisterListener -@Version(major = 2, minor = 0, revision = 1, compatible = 2) -public class Adminchat implements Module, Listener -{ - private static final char defaultKey = ','; - private static final File keysLocation = new File(Main.plugin.getDataFolder(), "adminchat_keys.json"); - private ArrayList actoggled; - private static JSONObject keys; - - @Override - public boolean onEnable() - { - keys = JsonManager.getObject(keysLocation); - if (keys == null) - { - keys = new JSONObject(); - saveKeys(); - } - actoggled = new ArrayList(); - return true; - } - - // @noformat - @Override - public String getCommandString() - { - return "command ac {\n" + - " [string:message...] {\n" + - " help Sends a message in Admin Chat;\n" + - " perm utils.ac;\n" + - " run ac_msg message;\n" + - " }\n" + - "}\n" + - " \n" + - "command ackey {\n" + - " [string:key] {\n" + - " help Sets your Admin Chat key;\n" + - " perm utils.ac;\n" + - " type player;\n" + - " run setackey key;\n" + - " }\n" + - "}\n" + - "\n" + - "command act {\n" + - " on {\n" + - " help Turns on act;\n" + - " perm utils.ac;\n" + - " run act_on;\n" + - " }\n" + - " off {\n" + - " help Turns off act;\n" + - " perm utils.ac;\n" + - " run act_off;\n" + - " }\n" + - " [empty] {\n" + - " help toggles Admin Chat;\n" + - " perm utils.ac;\n" + - " run act;\n" + - " }\n" + - "}"; - } - // @format - - @Command(hook = "ac_msg") - public boolean acSay(CommandSender sender, String message) - { - String name; - if (sender instanceof Player) - name = ((Player) sender).getDisplayName(); - else - name = sender.getName(); - Utils.broadcast("§8[§cAC§8] §9" + name + "§8: §b", message, new BroadcastFilter() - { - @Override - public boolean sendTo(CommandSender recipient) - { - return recipient.hasPermission("utils.ac"); - } - }, '&'); - return true; - } - - /** Let's a Player toggle their auto-cg status to allow for automatically sending chat messages to their chatgroup. - * - * @param sender the issuer of the command. - * @param _void ignored. - * @return true. */ - @Command(hook = "act") - public boolean acToggleCommand(CommandSender sender) - { - if (actoggled.contains(((Player) sender).getUniqueId())) - { - actoggled.remove(((Player) sender).getUniqueId()); - Utils.sendMessage(sender, null, "ACT now §cdisabled"); - } - else - { - actoggled.add(((Player) sender).getUniqueId()); - Utils.sendMessage(sender, null, "ACT now §aenabled"); - } - return true; - } - - /** Let's a Player toggle their auto-cg status to allow for automatically sending chat messages to their chatgroup. - * - * @param sender the issuer of the command. - * @return true. */ - @Command(hook = "act_on") - public boolean acToggleOnCommand(CommandSender sender) - { - if (!actoggled.contains(((Player) sender).getUniqueId())) - { - actoggled.add(((Player) sender).getUniqueId()); - Utils.sendMessage(sender, null, "ACT now §aenabled"); - } - else - Utils.sendMessage(sender, null, "ACT was already enabled"); - return true; - } - - /** Let's a Player toggle their auto-cg status to allow for automatically sending chat messages to their chatgroup. - * - * @param sender the issuer of the command. - * @return true. */ - @Command(hook = "act_off") - public boolean acToggleOffCommand(CommandSender sender) - { - if (actoggled.contains(((Player) sender).getUniqueId())) - { - actoggled.remove(((Player) sender).getUniqueId()); - Utils.sendMessage(sender, null, "ACT now §cdisabled"); - } - else - { - Utils.sendMessage(sender, null, "ACT was already disabled"); - } - return true; - } - - /** Deals with chat events to allow for cgkeys and cgtoggle. - * - * @param event the chat event containing the player and the message. */ - @EventHandler - public void onPlayerChat(AsyncPlayerChatEvent event) - { - Player player = event.getPlayer(); - if (!player.hasPermission("utils.ac")) - return; - if (event.getMessage().startsWith(getKey(player))) - { - event.setCancelled(true); - acSay(event.getPlayer(), event.getMessage().replaceFirst(getKey(player), "")); - } - else if (actoggled.contains(event.getPlayer().getUniqueId())) - { - event.setCancelled(true); - acSay(event.getPlayer(), event.getMessage()); - } - } - - /** Sets the ackey of a Player. - * - * @param sender the issuer of the command. - * @param key the key to be set. Set to NULL or "" to get your current key. - * @return true. */ - @SuppressWarnings("unchecked") - @Command(hook = "setackey") - public boolean setAcKey(CommandSender sender, String key) - { - if (key.length() > 1) - { - Utils.sendErrorMessage(sender, null, - "Could not set your key to §6" + key + " §7, it can be at most one char."); - return true; - } - if (key == null || key.length() == 0) - { - getAcKey(sender); - return true; - } - Utils.sendMessage(sender, null, "Set your key to §6" + key); - keys.put(((Player) sender).getUniqueId().toString(), key + ""); - saveKeys(); - return true; - } - - /** This method will find the ChatgGroup key of any player. - * - * @param player the player to get the key from. - * @return the key. */ - public static String getKey(Player player) - { - String key = (String) keys.get(player.getUniqueId().toString()); - return (key == null ? "" + defaultKey : key); - } - - /** Prints a Players ackey to their chat. - * - * @param sender the issuer of the command. */ - public void getAcKey(CommandSender sender) - { - Utils.sendMessage(sender, null, "Your current ackey is §6" + getKey((Player) sender)); - } - - /** Saves the keys. */ - private void saveKeys() - { - JsonManager.save(keys, keysLocation); - } -} diff --git a/src/com/redstoner/modules/adminnotes/AdminNotes.java b/src/com/redstoner/modules/adminnotes/AdminNotes.java deleted file mode 100644 index 7877735..0000000 --- a/src/com/redstoner/modules/adminnotes/AdminNotes.java +++ /dev/null @@ -1,131 +0,0 @@ -package com.redstoner.modules.adminnotes; - -import java.io.File; -import java.text.SimpleDateFormat; - -import org.bukkit.ChatColor; -import org.bukkit.command.CommandSender; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.player.PlayerJoinEvent; -import org.json.simple.JSONArray; - -import com.nemez.cmdmgr.Command; -import com.redstoner.annotations.AutoRegisterListener; -import com.redstoner.annotations.Version; -import com.redstoner.misc.JsonManager; -import com.redstoner.misc.Main; -import com.redstoner.misc.Utils; -import com.redstoner.modules.Module; - -@AutoRegisterListener -@Version(major = 2, minor = 0, revision = 0, compatible = 2) -public class AdminNotes implements Module, Listener -{ - JSONArray notes; - File saveFile = new File(Main.plugin.getDataFolder(), "adminnotes.json"); - - @Override - public boolean onEnable() - { - notes = JsonManager.getArray(saveFile); - if (notes == null) - notes = new JSONArray(); - return true; - } - - @EventHandler - public void onJoin(PlayerJoinEvent e) - { - if (e.getPlayer().hasPermission("utils.adminnotes")) - { - if (notes.size() > 0) - { - Utils.sendMessage(e.getPlayer(), null, "§cThere are " + notes.size() + " open notes!"); - } - } - } - - @Override - public void onDisable() - { - saveNotes(); - } - - @SuppressWarnings("unchecked") - @Command(hook = "an_create") - public void createNote(CommandSender sender, String note) - { - JSONArray temp = new JSONArray(); - temp.add(sender.getName()); - temp.add(note); - temp.add((double) System.currentTimeMillis() / 1000); - notes.add(temp); - Utils.sendMessage(sender, null, "§aNote added!"); - saveNotes(); - } - - @Command(hook = "an_del") - public void delNote(CommandSender sender, int id) - { - if (id < notes.size() && id >= 0 && notes.get(id) != null) - { - notes.remove(id); - Utils.sendMessage(sender, null, "§aNote " + id + " has been removed!"); - saveNotes(); - } - else - { - Utils.sendMessage(sender, null, "§cThat note does not exist!"); - } - } - - @Command(hook = "an_list") - public void list(CommandSender sender) - { - Utils.sendModuleHeader(sender); - for (Object note : notes) - { - String string = ChatColor.YELLOW + "" + notes.indexOf(note) + ": "; - string += "§a" + ((JSONArray) note).get(1); - string += "\n§e - " + ((JSONArray) note).get(0) + ", §6"; - SimpleDateFormat format = new SimpleDateFormat("MMM dd, yyyy HH:mm"); - string += format.format((double) ((JSONArray) note).get(2) * 1000); - Utils.sendMessage(sender, "", string); - } - } - - public void saveNotes() - { - JsonManager.save(notes, saveFile); - } - - // @noformat - @Override - public String getCommandString() - { - return "command an {\n" + - " perm utils.adminnotes;\n" + - " \n" + - " add [string:note...] {\n" + - " type player;\n" + - " help Creates a new admin note;\n" + - " run an_create note;\n" + - " perm utils.an;" + - " }\n" + - " \n" + - " del [int:id] {\n" + - " help Deletes an admin note;\n" + - " run an_del id;\n" + - " perm utils.an;" + - " }\n" + - " \n" + - " list {\n" + - " help Lists all notes;\n" + - " run an_list;\n" + - " perm utils.an;" + - " }\n" + - "}"; - } - // @format -} diff --git a/src/com/redstoner/modules/challenge/Challenge.java b/src/com/redstoner/modules/challenge/Challenge.java deleted file mode 100644 index 0d020a8..0000000 --- a/src/com/redstoner/modules/challenge/Challenge.java +++ /dev/null @@ -1,284 +0,0 @@ -package com.redstoner.modules.challenge; - -import java.io.File; -import java.util.Random; - -import org.bukkit.command.CommandSender; -import org.json.simple.JSONArray; - -import com.nemez.cmdmgr.Command; -import com.redstoner.annotations.Version; -import com.redstoner.misc.JsonManager; -import com.redstoner.misc.Main; -import com.redstoner.misc.Utils; -import com.redstoner.modules.Module; - -@Version(major = 2, minor = 0, revision = 1, compatible = 2) -public class Challenge implements Module -{ - private File challengeLocation = new File(Main.plugin.getDataFolder(), "challenges.json"); - private JSONArray challenges; - - @Override - public boolean onEnable() - { - challenges = JsonManager.getArray(challengeLocation); - if (challenges == null) - challenges = new JSONArray(); - return true; - } - - @Override - public void onDisable() - { - saveChallenges(); - } - - @SuppressWarnings("unchecked") - @Command(hook = "addchallenge") - public boolean addChallenge(CommandSender sender, String text) - { - if (challenges.contains(text)) - Utils.sendErrorMessage(sender, null, "That challenge already exists!"); - else - { - Utils.sendMessage(sender, null, "Successfully added a new challenge!"); - challenges.add(text); - saveChallenges(); - } - return true; - } - - @Command(hook = "delchallenge") - public boolean delChallenge(CommandSender sender, int id) - { - if (challenges.size() == 0) - { - Utils.sendErrorMessage(sender, null, "There are no challenges yet!"); - return true; - } - if (id < 0 || id >= challenges.size()) - { - Utils.sendErrorMessage(sender, null, "The ID must be at least 0 and at most " + (challenges.size() - 1)); - return true; - } - Utils.sendMessage(sender, null, "Successfully deleted the challenge: " + challenges.remove(id), '&'); - saveChallenges(); - return true; - } - - @SuppressWarnings("unchecked") - @Command(hook = "setchallenge") - public boolean setChallenge(CommandSender sender, int id, String text) - { - if (challenges.size() == 0) - { - Utils.sendErrorMessage(sender, null, "There are no challenges yet!"); - return true; - } - if (id < 0 || id >= challenges.size()) - { - Utils.sendErrorMessage(sender, null, "The ID must be at least 0 and at most " + (challenges.size() - 1)); - return true; - } - Utils.sendMessage(sender, null, - "Successfully changed the challenge: &a" + challenges.get(id) + " &7to: &e" + text, '&'); - challenges.set(id, text); - saveChallenges(); - return true; - } - - @Command(hook = "challengeid") - public boolean challengeId(CommandSender sender, int id) - { - if (challenges.size() == 0) - { - Utils.sendErrorMessage(sender, null, "There are no challenges yet!"); - return true; - } - if (id < 0 || id >= challenges.size()) - { - Utils.sendErrorMessage(sender, null, "The ID must be at least 0 and at most " + (challenges.size() - 1)); - return true; - } - Utils.sendMessage(sender, null, "&a" + challenges.get(id), '&'); - return true; - } - - @Command(hook = "challenge") - public boolean challenge(CommandSender sender) - { - if (challenges.size() == 0) - { - Utils.sendErrorMessage(sender, null, "There are no challenges yet!"); - return true; - } - int id = (new Random()).nextInt(challenges.size()); - Utils.sendMessage(sender, null, "&a" + challenges.get(id), '&'); - return true; - } - - @Command(hook = "listchallenges") - public boolean listChallenges(CommandSender sender, int page) - { - if (challenges.size() == 0) - { - Utils.sendErrorMessage(sender, null, "There are no challenges yet!"); - return true; - } - page = page - 1; - int start = page * 10; - int end = start + 10; - int pages = (int) Math.ceil(challenges.size() / 10d); - if (start < 0) - { - Utils.sendErrorMessage(sender, null, "Page number too small, must be at least 0!"); - return true; - } - if (start > challenges.size()) - { - Utils.sendErrorMessage(sender, null, "Page number too big, must be at most " + pages + "!"); - return true; - } - Utils.sendModuleHeader(sender); - Utils.sendMessage(sender, "", "&ePage " + (page + 1) + "/" + pages + ":", '&'); - for (int i = start; i < end && i < challenges.size(); i++) - Utils.sendMessage(sender, "", "&a" + i + "&8: &e" + challenges.get(i), '&'); - return true; - } - - @Command(hook = "listchallengesdef") - public boolean listChallengesDefault(CommandSender sender) - { - return listChallenges(sender, 1); - } - - @Command(hook = "searchchallenge") - public boolean search(CommandSender sender, boolean insensitive, String text) - { - Utils.sendModuleHeader(sender); - boolean found = false; - if (insensitive) - { - text = text.toLowerCase(); - for (int i = 0; i < challenges.size(); i++) - { - if (((String) challenges.get(i)).toLowerCase().contains(text)) - { - Utils.sendMessage(sender, "", "&a" + i + "&8: &e" + challenges.get(i), '&'); - found = true; - } - } - } - else - { - for (int i = 0; i < challenges.size(); i++) - { - if (((String) challenges.get(i)).contains(text)) - { - Utils.sendMessage(sender, "", "&a" + i + "&8: &e" + challenges.get(i), '&'); - found = true; - } - } - } - if (!found) - { - Utils.sendMessage(sender, "", "&cCouldn't find any matching challenges.", '&'); - } - return true; - } - - @Command(hook = "matchchallenge") - public boolean match(CommandSender sender, boolean insensitive, String regex) - { - Utils.sendModuleHeader(sender); - boolean found = false; - if (insensitive) - { - regex = regex.toLowerCase(); - for (int i = 0; i < challenges.size(); i++) - { - if (((String) challenges.get(i)).toLowerCase().matches(regex)) - { - Utils.sendMessage(sender, "", "&a" + i + ": " + challenges.get(i), '&'); - found = true; - } - } - } - else - { - for (int i = 0; i < challenges.size(); i++) - { - if (((String) challenges.get(i)).matches(regex)) - { - Utils.sendMessage(sender, "", "&a" + i + ": " + challenges.get(i), '&'); - found = true; - } - } - } - if (!found) - { - Utils.sendMessage(sender, "", "&cCouldn't find any matching challenges.", '&'); - } - return true; - } - - public void saveChallenges() - { - JsonManager.save(challenges, challengeLocation); - } - - // @noformat - @Override - public String getCommandString() - { - return "command challenge {\n" + - " add [string:text...] {\n" + - " help Adds a challenge.;\n" + - " run addchallenge text;\n" + - " perm utils.challenge.add;\n" + - " }\n" + - " del [int:id] {\n" + - " help Removes a challenge.;\n" + - " run delchallenge id;\n" + - " perm utils.challenge.admin;\n" + - " }\n" + - " set [int:id] [string:text...] {\n" + - " help Sets a challenge.;\n" + - " run setchallenge id text;\n" + - " perm utils.challenge.admin;\n" + - " }\n" + - " id [int:id] {\n" + - " help Get a paticular challenge.;\n" + - " run challengeid id;\n" + - " perm utils.challenge.id;\n" + - " }\n" + - " list [int:page] {\n" + - " help Shows challenges.;\n" + - " run listchallenges page;\n" + - " perm utils.challenge.list;\n" + - " }\n" + - " list {\n" + - " help Shows challenges.;\n" + - " run listchallengesdef;\n" + - " perm utils.challenge.list;\n" + - " }\n" + - " search [flag:-i] [string:text...] {\n" + - " help Search challenges.;\n" + - " run searchchallenge -i text;\n" + - " perm utils.challenge.search;\n" + - " }\n" + - " match [flag:-i] [string:regex...] {\n" + - " help Search challenges. But better.;\n" + - " run matchchallenge -i regex;\n" + - " perm utils.challenge.match;\n" + - " }\n" + - " [empty] {\n" + - " help Gives a challenge.;\n" + - " run challenge;\n" + - " perm utils.challenge;\n" + - " }\n" + - "}"; - } - // @format -} diff --git a/src/com/redstoner/modules/chatalias/Chatalias.java b/src/com/redstoner/modules/chatalias/Chatalias.java deleted file mode 100644 index 1edb28c..0000000 --- a/src/com/redstoner/modules/chatalias/Chatalias.java +++ /dev/null @@ -1,335 +0,0 @@ -package com.redstoner.modules.chatalias; - -import java.io.File; -import java.util.Set; -import java.util.UUID; - -import org.bukkit.Bukkit; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; -import org.bukkit.event.player.AsyncPlayerChatEvent; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; -import org.bukkit.event.player.PlayerJoinEvent; -import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.permissions.PermissionAttachmentInfo; -import org.json.simple.JSONObject; - -import com.nemez.cmdmgr.Command; -import com.redstoner.annotations.AutoRegisterListener; -import com.redstoner.annotations.Version; -import com.redstoner.misc.JsonManager; -import com.redstoner.misc.Main; -import com.redstoner.misc.Utils; -import com.redstoner.modules.Module; - -@AutoRegisterListener -@Version(major = 2, minor = 0, revision = 0, compatible = 2) -public class Chatalias implements Module, Listener -{ - // to export chatalias data to json: - // pyeval [save_json_file("aliases/" + uuid, shared['modules']['chatalias'].data[uuid]) for uuid in shared['modules']['chatalias'].data] - // HANDLE WITH CARE! This will create an array of null entries the size of len(data)! - private final String[] commands = new String[] {"e?r", "e?m .+? ", "e?t", "e?w", "e?msg .+? ", "e?message .+? ", - "e?whisper .+? ", "e?me", "cg say", "ac"}; - private JSONObject aliases = new JSONObject(); - - @Override - public boolean onEnable() - { - for (Player p : Bukkit.getOnlinePlayers()) - { - loadAliases(p.getUniqueId()); - } - return true; - } - - @Override - public void onDisable() - { - for (Object key : aliases.keySet()) - { - UUID uuid = UUID.fromString((String) key); - saveAliases(uuid); - } - } - - @EventHandler - public void onPlayerJoin(PlayerJoinEvent event) - { - loadAliases(event.getPlayer().getUniqueId()); - } - - @EventHandler - public void onPlayerLeave(PlayerQuitEvent event) - { - aliases.remove(event.getPlayer().getUniqueId().toString()); - } - - @SuppressWarnings("unchecked") - @EventHandler(priority = EventPriority.LOWEST) - public void onPlayerChat(AsyncPlayerChatEvent event) - { - Player player = event.getPlayer(); - UUID uuid = player.getUniqueId(); - JSONObject playerAliases = (JSONObject) aliases.get(uuid.toString()); - boolean changed = false; - for (Object key : playerAliases.keySet()) - { - String keyword = (String) key; - String replacement = (String) playerAliases.get(key); - if (keyword.startsWith("R: ")) - { - keyword = keyword.replace("R: ", ""); - event.setMessage(event.getMessage().replaceAll(keyword, replacement)); - } - else - { - if (keyword.startsWith("N: ")) - keyword = keyword.replace("N: ", ""); - else - { - changed = true; - playerAliases.put("N: " + key, replacement); - } - event.setMessage(event.getMessage().replace(keyword, replacement)); - } - int maxLength; - try - { - maxLength = Integer.valueOf(getPermissionContent(player, "utils.alias.length.")); - } - catch (NumberFormatException e) - { - maxLength = 255; - } - if (event.getMessage().length() > maxLength) - { - Utils.sendErrorMessage(player, null, "The generated message is too long!"); - event.setCancelled(true); - return; - } - } - if (changed) - saveAliases(uuid); - } - - @EventHandler(priority = EventPriority.LOWEST) - public void onPlayerCommand(PlayerCommandPreprocessEvent event) - { - if (event.isCancelled()) - return; - boolean listening = false; - String regex = ""; - for (String s : commands) - { - regex = "^\\/(.*:)?" + s + ".*"; - if (event.getMessage().matches(regex)) - { - listening = true; - break; - } - } - if (!listening) - return; - Player player = event.getPlayer(); - UUID uuid = player.getUniqueId(); - JSONObject playerAliases = (JSONObject) aliases.get(uuid.toString()); - String command = event.getMessage().replaceAll(regex.replaceAll("\\.\\*$", ""), ""); - command = event.getMessage().replace(command, ""); - event.setMessage(event.getMessage().replace(command, "§§")); - for (Object key : playerAliases.keySet()) - { - String keyword = (String) key; - String replacement = (String) playerAliases.get(key); - if (keyword.startsWith("R: ")) - { - keyword = keyword.replace("R: ", ""); - event.setMessage(event.getMessage().replaceAll(keyword, replacement)); - } - else - { - if (keyword.startsWith("N: ")) - keyword = keyword.replace("N: ", ""); - event.setMessage(event.getMessage().replace(keyword, replacement)); - } - int maxLength; - try - { - maxLength = Integer.valueOf(getPermissionContent(player, "utils.alias.length.")); - } - catch (NumberFormatException e) - { - maxLength = 255; - } - if (event.getMessage().length() > maxLength) - { - Utils.sendErrorMessage(player, null, "The generated message is too long!"); - event.setCancelled(true); - return; - } - } - event.setMessage(command + event.getMessage().substring(2)); - } - - @SuppressWarnings("unchecked") - @Command(hook = "addalias") - public boolean addAlias(CommandSender sender, boolean regex, String keyword, String replacement) - { - if (regex && keyword.equals(".*")) - { - Utils.sendErrorMessage(sender, null, "You may not define the wildcard regex as an alias."); - return true; - } - Player player = (Player) sender; - UUID uuid = player.getUniqueId(); - JSONObject data = (JSONObject) aliases.get(uuid.toString()); - keyword = (regex ? "R: " : "N: ") + keyword; - if (!data.containsKey(keyword)) - { - int maxAmount; - try - { - maxAmount = Integer.valueOf(getPermissionContent(player, "utils.alias.amount.")); - } - catch (NumberFormatException e) - { - maxAmount = 25; - } - if (data.size() == maxAmount) - { - Utils.sendErrorMessage(sender, null, "You already reached your maximum of aliases!"); - return true; - } - } - data.put(keyword, replacement); - if (sender.hasPermission("essentials.chat.color")) - Utils.sendMessage(sender, null, - "Successfully created alias " + keyword.substring(3) + " §7-> " + replacement + " §7for you.", '&'); - else - Utils.sendMessage(sender, null, - "Successfully created alias " + keyword.substring(3) + " §7-> " + replacement + " §7for you."); - saveAliases(uuid); - return true; - } - - @Command(hook = "delalias") - public boolean delAlias(CommandSender sender, boolean regex, String keyword) - { - Player player = (Player) sender; - UUID uuid = player.getUniqueId(); - JSONObject data = (JSONObject) aliases.get(uuid.toString()); - keyword = (regex ? "R: " : "N: ") + keyword; - if (data.remove(keyword) != null) - { - Utils.sendMessage(sender, null, "Successfully removed the alias!"); - saveAliases(uuid); - return true; - } - else - { - Utils.sendErrorMessage(sender, null, - "That alias doesn't exist! Hint: regex/no regex does matter for this."); - return true; - } - } - - @Command(hook = "listaliases") - public boolean listAliases(CommandSender sender) - { - Utils.sendModuleHeader(sender); - Player player = (Player) sender; - UUID uuid = player.getUniqueId(); - JSONObject data = (JSONObject) aliases.get(uuid.toString()); - for (Object key : data.keySet()) - { - if (sender.hasPermission("essentials.chat.color")) - Utils.sendMessage(sender, "", (String) key + " §7-> " + data.get(key), '&'); - else - Utils.sendMessage(sender, "", (String) key + " §7-> " + data.get(key)); - } - return true; - } - - private String getPermissionContent(Player player, String permnode) - { - Set perms = player.getEffectivePermissions(); - for (PermissionAttachmentInfo perm : perms) - if (perm.getPermission().toString().startsWith(permnode)) - return perm.getPermission().replace(permnode, ""); - return null; - } - - @SuppressWarnings("unchecked") - private void loadAliases(UUID uuid) - { - JSONObject defaults = new JSONObject(); - defaults.put("dataFormat", "v1"); - JSONObject data = new JSONObject(); - data.put("N: ./", "/"); - defaults.put("data", data); - JSONObject playerAliases = JsonManager - .getObject(new File(Main.plugin.getDataFolder(), "aliases/" + uuid.toString() + ".json")); - if (playerAliases == null) - { - playerAliases = defaults; - } - String dataFormat = (String) playerAliases.get("dataFormat"); - if (dataFormat == null) - { - JSONObject temp = new JSONObject(); - temp.put("dataFormat", "v1"); - JSONObject tempAliases = new JSONObject(); - { - for (Object key : playerAliases.keySet()) - { - tempAliases.put("N: " + key, playerAliases.get(key)); - } - } - temp.put("data", tempAliases); - aliases.put(uuid.toString(), temp.get("data")); - } - else if (dataFormat.equals("v1")) - aliases.put(uuid.toString(), playerAliases.get("data")); - else - { - Utils.error("Unknown data format for alias set of player " + uuid.toString()); - aliases.put(uuid.toString(), ((JSONObject) defaults.get("data")).clone()); - saveAliases(uuid); - } - } - - @SuppressWarnings("unchecked") - private void saveAliases(UUID uuid) - { - JSONObject temp = new JSONObject(); - temp.put("dataFormat", "v1"); - temp.put("data", aliases.get(uuid.toString())); - JsonManager.save(temp, new File(Main.plugin.getDataFolder(), "aliases/" + uuid.toString() + ".json")); - } - - // @noformat - @Override - public String getCommandString() - { - return "command alias {\n" + - " add [flag:-r] [string:keyword] [string:replacement...] {\n" + - " help Adds a new alias. Set -r to make it a regex-alias.;\n" + - " run addalias -r keyword replacement;\n" + - " }\n" + - " del [flag:-r] [string:keyword] {\n" + - " help Deletes an alias. -r indicates if it was a regex-alias.;\n" + - " run delalias -r keyword;\n" + - " }\n" + - " list {\n" + - " help Lists your aliases.;\n" + - " run listaliases;\n" + - " }\n" + - " perm utils.alias;\n" + - " type player;\n" + - "}"; - } - // @format -} diff --git a/src/com/redstoner/modules/chatgroups/Chatgroups.java b/src/com/redstoner/modules/chatgroups/Chatgroups.java deleted file mode 100644 index 44bd101..0000000 --- a/src/com/redstoner/modules/chatgroups/Chatgroups.java +++ /dev/null @@ -1,408 +0,0 @@ -package com.redstoner.modules.chatgroups; - -import java.io.File; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.UUID; - -import org.bukkit.Bukkit; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.player.AsyncPlayerChatEvent; -import org.json.simple.JSONObject; - -import com.nemez.cmdmgr.Command; -import com.redstoner.annotations.AutoRegisterListener; -import com.redstoner.annotations.Version; -import com.redstoner.misc.BroadcastFilter; -import com.redstoner.misc.JsonManager; -import com.redstoner.misc.Main; -import com.redstoner.misc.Utils; -import com.redstoner.modules.Module; - -/** The ChatGroups module. Allows people to have private sub-chats that can be accessed via a single char prefix or a toggle. - * - * @author Pepich */ -@AutoRegisterListener -@Version(major = 2, minor = 0, revision = 1, compatible = 2) -public class Chatgroups implements Module, Listener -{ - private static final char defaultKey = ':'; - private static final File groupsLocation = new File(Main.plugin.getDataFolder(), "chatgroups.json"); - private static final File keysLocation = new File(Main.plugin.getDataFolder(), "chatgroup_keys.json"); - private ArrayList cgtoggled; - private static JSONObject groups, keys; - - @Override - public boolean onEnable() - { - groups = JsonManager.getObject(groupsLocation); - if (groups == null) - { - groups = new JSONObject(); - saveGroups(); - } - keys = JsonManager.getObject(keysLocation); - if (keys == null) - { - keys = new JSONObject(); - saveKeys(); - } - cgtoggled = new ArrayList(); - return true; - } - - @Override - public void onDisable() - { - saveKeys(); - saveGroups(); - } - - // @noformat - @Override - public String getCommandString() - { - return "command cgt {\n" + - " [empty] {\n" + - " help Toggles your cgtoggle status.;\n"+ - " type player;\n" + - " run cgtoggle;\n" + - " }\n" + - "}\n" + - "command cgkey {\n" + - " [string:key] {\n" + - " help Sets your chatgroup key.;\n" + - " run setcgkey key;\n" + - " type player;\n" + - " }\n" + - "}\n" + - "command cgsay {\n" + - " [string:message...] {\n" + - " help Chats in your chatgroup.;\n"+ - " run cgsay message;\n" + - " }\n" + - "}\n" + - "command cg {\n" + - " join [string:group] {\n" + - " help Joins a chatgroup.;\n" + - " run cgjoin group;\n" + - " }\n" + - " leave {\n" + - " help Leaves your chatgroup.;\n" + - " run cgleave;\n" + - " }\n" + - " info {\n" + - " help Displays info about your chatgroup.;\n" + - " run cginfo;\n" + - " }\n" + - - "}"; - } - // @format - - /** Prints chatgroup info (like players in the group, groupname) to the sender. - * - * @param sender the issuer of the command. - * @return true. */ - @SuppressWarnings("unchecked") - @Command(hook = "cginfo") - public boolean cgInfo(CommandSender sender) - { - String group = getGroup(sender); - if (group == null) - Utils.sendErrorMessage(sender, null, "You are not in a chatgroup!"); - else - { - Utils.sendModuleHeader(sender); - Utils.sendMessage(sender, "", "Your current chatgroup is: §6" + group); - ArrayList players = new ArrayList(); - Iterator iter = groups.keySet().iterator(); - while (iter.hasNext()) - { - String id = iter.next(); - if (((String) groups.get(id)).equals(group)) - { - if (!id.equals("CONSOLE")) - { - UUID uuid = UUID.fromString(id); - Player p = Bukkit.getPlayer(uuid); - if (p != null) - players.add(p.getDisplayName()); - else - players.add(Bukkit.getOfflinePlayer(UUID.fromString(id)).getName()); - } - else - players.add(id); - } - } - StringBuilder sb = new StringBuilder("&6Other players in this group: &9"); - for (String player : players) - { - sb.append(player); - sb.append("&7, &9"); - } - sb.delete(sb.length() - 2, sb.length()); - Utils.sendMessage(sender, "", sb.toString(), '&'); - } - return true; - } - - /** Prints a Players cgkey to their chat. - * - * @param sender the issuer of the command. */ - public void getCgKey(CommandSender sender) - { - Utils.sendMessage(sender, null, "Your current cgkey is §6" + getKey((Player) sender)); - } - - /** Sets the cgkey of a Player. - * - * @param sender the issuer of the command. - * @param key the key to be set. Set to NULL or "" to get your current key. - * @return true. */ - @SuppressWarnings("unchecked") - @Command(hook = "setcgkey") - public boolean setCgKey(CommandSender sender, String key) - { - if (key.length() > 1) - { - Utils.sendErrorMessage(sender, null, - "Could not set your key to §6" + key + " §7, it can be at most one char."); - return true; - } - if (key == null || key.length() == 0) - { - getCgKey(sender); - return true; - } - Utils.sendMessage(sender, null, "Set your key to §6" + key); - keys.put(((Player) sender).getUniqueId().toString(), key + ""); - saveKeys(); - return true; - } - - /** Let's a Player toggle their auto-cg status to allow for automatically sending chat messages to their chatgroup. - * - * @param sender the issuer of the command. - * @return true. */ - @Command(hook = "cgtoggle") - public boolean cgToggleCommand(CommandSender sender) - { - if (getGroup(sender) != null) - if (cgtoggled.contains(((Player) sender).getUniqueId())) - { - cgtoggled.remove(((Player) sender).getUniqueId()); - Utils.sendMessage(sender, null, "CGT now §cdisabled"); - } - else - { - cgtoggled.add(((Player) sender).getUniqueId()); - Utils.sendMessage(sender, null, "CGT now §aenabled"); - } - else - Utils.sendErrorMessage(sender, null, "You are not in a chatgroup!"); - return true; - } - - /** Lets a CommandSender leave their group. - * - * @param sender the command issuer. - * @return true. */ - @Command(hook = "cgleave") - public boolean cgLeave(CommandSender sender) - { - String group = removeGroup(sender); - if (group == null) - { - Utils.sendErrorMessage(sender, null, "You were not in a chatgroup!"); - return true; - } - String name; - if (sender instanceof Player) - name = ((Player) sender).getDisplayName(); - else - name = sender.getName(); - sendToGroup(group, "&9" + name + " &7left the group!"); - Utils.sendMessage(sender, null, "Successfully removed you from your group!"); - if (sender instanceof Player) - cgtoggled.remove(((Player) sender).getUniqueId()); - return true; - } - - /** Lets a CommandSender join a group. - * - * @param sender the command issuer. - * @param name the name of the group. - * @return true. */ - @Command(hook = "cgjoin") - public boolean cgJoin(CommandSender sender, String name) - { - String pname; - if (sender instanceof Player) - pname = ((Player) sender).getDisplayName(); - else - pname = sender.getName(); - sendToGroup(name, "&9" + pname + " &7joined the group!"); - setGroup(sender, name); - Utils.sendMessage(sender, null, "Successfully joined group §6" + name); - return true; - } - - /** Sends a message to a group. - * - * @param sender the sender of the message - the message will be sent to the group of the sender. - * @param message the message to be sent. - * @return true. */ - @Command(hook = "cgsay") - public boolean cgSay(CommandSender sender, String message) - { - String group = getGroup(sender); - if (group != null) - sendToGroup(sender, message); - else - Utils.sendErrorMessage(sender, null, "You are not in a chatgroup right now!"); - return true; - } - - /** Deals with chat events to allow for cgkeys and cgtoggle. - * - * @param event the chat event containing the player and the message. */ - @EventHandler - public void onPlayerChat(AsyncPlayerChatEvent event) - { - String group = getGroup(event.getPlayer()); - Player player = event.getPlayer(); - if (group != null) - { - if (event.getMessage().startsWith(getKey(player))) - { - event.setCancelled(true); - sendToGroup(event.getPlayer(), event.getMessage().substring(1)); - } - else if (cgtoggled.contains(event.getPlayer().getUniqueId())) - { - event.setCancelled(true); - sendToGroup(event.getPlayer(), event.getMessage()); - } - } - } - - /** Finds the group of a CommandSender. - * - * @param target the CommandSender to get the group of. - * @return the group of the target or NULL if he doesn't have one. */ - public static String getGroup(CommandSender target) - { - if (target instanceof Player) - return (String) groups.get(((Player) target).getUniqueId().toString()); - else - return (String) groups.get("CONSOLE"); - } - - /** Sets the group of the CommandSender. - * - * @param target the CommandSender to set the group of. - * @param group the name of the group to join. */ - @SuppressWarnings("unchecked") - private void setGroup(CommandSender target, String group) - { - if (target instanceof Player) - groups.put(((Player) target).getUniqueId().toString(), group); - else - groups.put("CONSOLE", group); - saveGroups(); - } - - /** Removes a CommandSender from their chatgroup. Will also save the groups after finishing - * - * @param target the CommandSender to get their group removed. */ - private String removeGroup(CommandSender target) - { - String group; - if (target instanceof Player) - group = (String) groups.remove(((Player) target).getUniqueId().toString()); - else - group = (String) groups.remove("CONSOLE"); - saveGroups(); - return group; - } - - /** This method will find the ChatgGroup key of any player. - * - * @param player the player to get the key from. - * @return the key. */ - public static String getKey(Player player) - { - String key = (String) keys.get(player.getUniqueId().toString()); - return (key == null ? "" + defaultKey : key); - } - - /** This method sends a message to a chatgroup. - * - * @param sender the sender of the message. Also defines which group the message will be sent to. - * @param message the message to be sent. */ - private void sendToGroup(CommandSender sender, String message) - { - String name; - if (sender instanceof Player) - name = ((Player) sender).getDisplayName(); - else - name = sender.getName(); - String group = getGroup(sender); - Utils.broadcast("§8[§bCG§8] §9", name + "§8: §6" + message, new BroadcastFilter() - { - @Override - public boolean sendTo(CommandSender recipient) - { - String rgroup = getGroup(recipient); - if (rgroup != null) - return rgroup.equals(group); - else - return false; - } - }, '&'); - if (getGroup(Bukkit.getConsoleSender()) == null || !getGroup(Bukkit.getConsoleSender()).equals(group)) - { - Utils.log(name + " in " + group + ": " + message + " §8(hidden)"); - } - } - - /** This method sends a message to a chatgroup. - * - * @param sender the sender of the message. Also defines which group the message will be sent to. - * @param message the message to be sent. */ - private void sendToGroup(String group, String message) - { - Utils.broadcast(null, message, new BroadcastFilter() - { - @Override - public boolean sendTo(CommandSender recipient) - { - String rgroup = getGroup(recipient); - if (rgroup != null) - return rgroup.equals(group); - else - return false; - } - }, '&'); - if (getGroup(Bukkit.getConsoleSender()) == null || !getGroup(Bukkit.getConsoleSender()).equals(group)) - { - Utils.log("In " + group + ": " + message + " §8(hidden)"); - } - } - - /** Saves the groups. */ - private void saveGroups() - { - JsonManager.save(groups, groupsLocation); - } - - /** Saves the keys. */ - private void saveKeys() - { - JsonManager.save(keys, keysLocation); - } -} diff --git a/src/com/redstoner/modules/chatonly/ChatOnly.java b/src/com/redstoner/modules/chatonly/ChatOnly.java deleted file mode 100644 index dd41de6..0000000 --- a/src/com/redstoner/modules/chatonly/ChatOnly.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.redstoner.modules.chatonly; - -import com.redstoner.annotations.Version; -import com.redstoner.modules.Module; - -@Version(major = 3, minor = 0, revision = 0, compatible = 3) -public class ChatOnly implements Module -{} diff --git a/src/com/redstoner/modules/check/Check.java b/src/com/redstoner/modules/check/Check.java deleted file mode 100644 index d6219b4..0000000 --- a/src/com/redstoner/modules/check/Check.java +++ /dev/null @@ -1,242 +0,0 @@ -package com.redstoner.modules.check; - -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.Serializable; -import java.net.MalformedURLException; -import java.net.URL; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.Map; -import java.util.Scanner; - -import org.bukkit.Bukkit; -import org.bukkit.OfflinePlayer; -import org.bukkit.command.CommandSender; -import org.bukkit.event.Listener; -import org.json.simple.JSONArray; -import org.json.simple.JSONObject; -import org.json.simple.parser.JSONParser; -import org.json.simple.parser.ParseException; - -import com.nemez.cmdmgr.Command; -import com.nemez.cmdmgr.Command.AsyncType; -import com.redstoner.annotations.Version; -import com.redstoner.misc.Utils; -import com.redstoner.misc.mysql.JSONManager; -import com.redstoner.misc.mysql.MysqlHandler; -import com.redstoner.misc.mysql.elements.ConstraintOperator; -import com.redstoner.misc.mysql.elements.MysqlConstraint; -import com.redstoner.misc.mysql.elements.MysqlDatabase; -import com.redstoner.misc.mysql.elements.MysqlTable; -import com.redstoner.modules.Module; - -@Version(major = 2, minor = 0, revision = 1, compatible = 2) -public class Check implements Module, Listener -{ - MysqlTable table; - - @Override - public boolean onEnable() - { - Map config = JSONManager.getConfiguration("check.json"); - if (config == null || !config.containsKey("database") || !config.containsKey("table")) - { - Utils.error("Could not load the Check config file, disabling!"); - return false; - } - try - { - MysqlDatabase database = MysqlHandler.INSTANCE - .getDatabase((String) config.get("database") + "?autoReconnect=true"); - table = database.getTable((String) config.get("table")); - } - catch (NullPointerException e) - { - Utils.error("Could not use the Check config, disabling!"); - return false; - } - return true; - } - - @SuppressWarnings("deprecation") - @Command(hook = "checkCommand", async = AsyncType.ALWAYS) - public void checkCommand(final CommandSender sender, final String player) - { - Utils.sendModuleHeader(sender); - Utils.sendMessage(sender, "", "&7Please note that the data may not be fully accurate!", '&'); - OfflinePlayer oPlayer; - oPlayer = Bukkit.getPlayer(player); - if (oPlayer == null) - oPlayer = Bukkit.getServer().getOfflinePlayer(player); - sendData(sender, oPlayer); - } - - public String read(URL url) - { - String data = ""; - try - { - Scanner in = new Scanner(new InputStreamReader(url.openStream())); - while (in.hasNextLine()) - { - data += in.nextLine(); - } - in.close(); - return data; - } - catch (IOException e) - { - e.printStackTrace(); - } - return null; - } - - public JSONObject getIpInfo(OfflinePlayer player) - { - String ip = ""; - if (player.isOnline()) - { - ip = player.getPlayer().getAddress().getHostString(); - } - else - { - try - { - ip = (String) table.get("last_ip", new MysqlConstraint("uuid", ConstraintOperator.EQUAL, - player.getUniqueId().toString().replace("-", "")))[0]; - } - catch (Exception e) - { - e.printStackTrace(); - return null; - } - } - try - { - URL ipinfo = new URL("http://ipinfo.io/" + ip + "/json"); - String rawJson = read(ipinfo); - return (JSONObject) new JSONParser().parse(rawJson); - } - catch (Exception e) - { - e.printStackTrace(); - } - return null; - } - - public String getFirstJoin(OfflinePlayer player) - { - Long firstJoin = player.getFirstPlayed(); - Date date = new Date(firstJoin); - SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm"); - return format.format(date); - } - - public String getLastSeen(OfflinePlayer player) - { - Long lastSeen = player.getLastPlayed(); - Date date = new Date(lastSeen); - SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm"); - return format.format(date); - } - - public Object[] getWebsiteData(OfflinePlayer player) - { - MysqlConstraint constraint = new MysqlConstraint("uuid", ConstraintOperator.EQUAL, - player.getUniqueId().toString().replace("-", "")); - try - { - int id = (int) table.get("id", constraint)[0]; - String email = (String) table.get("email", constraint)[0]; - boolean confirmed = (boolean) table.get("confirmed", constraint)[0]; - return new Object[] {"https://redstoner.com/users/" + id, email, confirmed}; - } - catch (Exception e) - { - return new Object[] {null}; - } - } - - public String getCountry(JSONObject data) - { - return (String) data.get("country"); - } - - public String getAllNames(OfflinePlayer player) - { - String uuid = player.getUniqueId().toString().replace("-", ""); - String nameString = ""; - try - { - String rawJson = read(new URL("https://api.mojang.com/user/profiles/" + uuid + "/names")); - System.out.println("name for " + uuid + " : " + rawJson); - JSONArray names = (JSONArray) new JSONParser().parse(rawJson); - for (Object obj : names) - { - nameString += ((JSONObject) obj).get("name") + ", "; - } - nameString = nameString.substring(0, nameString.length() - 2); - return nameString; - } - catch (MalformedURLException | ParseException e) - { - e.printStackTrace(); - } - return null; - } - - public void sendData(CommandSender sender, OfflinePlayer player) - { - JSONObject ipInfo = getIpInfo(player); - try - { - // data - String firstJoin = getFirstJoin(player); - String lastSeen = getLastSeen(player); - firstJoin = (firstJoin.equals("1970-01-01 01:00")) ? "&eNever" : "&7(yyyy-MM-dd hh:mm:ss) &e" + firstJoin; - lastSeen = (lastSeen.equals("1970-1-1 1:0")) ? "&eNever" : "&7(yyyy-MM-dd hh:mm:ss) &e" + lastSeen; - Object[] websiteData = getWebsiteData(player); - String websiteUrl = (websiteData[0] == null) ? "None" : (String) websiteData[0]; - String email = (websiteData[0] == null) ? "Unknown" : (String) websiteData[1]; - boolean emailNotConfirmed = (websiteData[0] == null) ? false : !((boolean) websiteData[2]); - String country = (ipInfo == null) ? "Unknown" : getCountry(ipInfo); - String namesUsed = getAllNames(player); - if (namesUsed == null) - namesUsed = "None"; - // messages - Utils.sendMessage(sender, "", "&7Data provided by Redstoner:", '&'); - Utils.sendMessage(sender, "", "&6> UUID: &e" + player.getUniqueId(), '&'); - Utils.sendMessage(sender, "", "&6> First joined: " + firstJoin, '&'); - Utils.sendMessage(sender, "", "&6> Last seen: " + lastSeen, '&'); - Utils.sendMessage(sender, "", "&6> Website account: &e" + websiteUrl, '&'); - Utils.sendMessage(sender, "", "&6> email: &e" + email, '&'); - if (emailNotConfirmed) - Utils.sendMessage(sender, "", "&6> &4Email NOT Confirmed!", '&'); - Utils.sendMessage(sender, "", "&7Data provided by ipinfo:", '&'); - Utils.sendMessage(sender, "", "&6> Country: &e" + country, '&'); - Utils.sendMessage(sender, "", "&7Data provided by Mojang:", '&'); - Utils.sendMessage(sender, "", "&6> All ingame names used so far: &e" + namesUsed, '&'); - } - catch (Exception e) - { - e.printStackTrace(); - Utils.sendErrorMessage(sender, null, "&cSorry, something went wrong while fetching data", '&'); - } - } - - // @noformat - @Override - public String getCommandString() - { - return "command check {\n" + - " perm utils.check;\n" + - " \n" + - " [string:player] {\n" + - " run checkCommand player;\n" + - " help Get info on a player;\n" + - " }\n" + - "}"; - } - // @format -} diff --git a/src/com/redstoner/modules/clear/Clear.java b/src/com/redstoner/modules/clear/Clear.java deleted file mode 100644 index e50844c..0000000 --- a/src/com/redstoner/modules/clear/Clear.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.redstoner.modules.clear; - -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; -import org.bukkit.inventory.Inventory; - -import com.nemez.cmdmgr.Command; -import com.redstoner.annotations.Version; -import com.redstoner.misc.Utils; -import com.redstoner.modules.Module; - -@Version(major = 2, minor = 0, revision = 1, compatible = 2) -public class Clear implements Module -{ - @Command(hook = "clear") - public boolean clearInventory(CommandSender sender) - { - Player player = (Player) sender; - Inventory inv = player.getInventory(); - for (int i = 0; i < 36; i++) - inv.clear(i); - Utils.sendMessage(sender, null, "Cleared your inventory!"); - return true; - } - - // @noformat - @Override - public String getCommandString() - { - return "command clear{\n" + - " [empty] {\n" + - " help clears your inventory;\n" + - " type player;\n" + - " perm utils.clear;\n" + - " run clear;\n" + - " }\n" + - "}"; - } - // @format -} diff --git a/src/com/redstoner/modules/clearonjoin/ClearOnJoin.java b/src/com/redstoner/modules/clearonjoin/ClearOnJoin.java deleted file mode 100644 index b818563..0000000 --- a/src/com/redstoner/modules/clearonjoin/ClearOnJoin.java +++ /dev/null @@ -1,105 +0,0 @@ -package com.redstoner.modules.clearonjoin; - -import java.io.File; - -import org.bukkit.Bukkit; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.player.PlayerJoinEvent; -import org.json.simple.JSONArray; - -import com.nemez.cmdmgr.Command; -import com.redstoner.annotations.Version; -import com.redstoner.misc.JsonManager; -import com.redstoner.misc.Main; -import com.redstoner.misc.Utils; -import com.redstoner.modules.Module; - -@Version(major = 2, minor = 1, revision = 0, compatible = 2) -public class ClearOnJoin implements Module, Listener -{ - private File listLocation = new File(Main.plugin.getDataFolder(), "clearonjoins.json"); - private JSONArray list; - - @SuppressWarnings({ "unchecked", "deprecation" }) - @Command(hook = "clearonjoin") - public void clearOnJoin(CommandSender sender, String player) - { - list.add("!" + Bukkit.getServer().getOfflinePlayer(player).getUniqueId().toString()); - saveList(); - Utils.sendMessage(sender, null, player + "'s inventory will be cleared next time they join."); - } - - @SuppressWarnings("unchecked") - @Command(hook = "clearonjoinself") - public void clearOnJoinSelf(CommandSender sender) - { - String name = ((Player)sender).getUniqueId().toString(); - if (list.contains(name)) - { - list.remove(name); - Utils.sendMessage(sender, null, "Your inventory will no longer be cleared upon joining."); - saveList(); - return; - } - list.add(name); - saveList(); - Utils.sendMessage(sender, null, "Your inventory will now be cleared upon joining."); - } - - @EventHandler - public void uponJoin(PlayerJoinEvent e) - { - Player player = e.getPlayer(); - String playerUUID = player.getUniqueId().toString(); - String playerName = player.getName(); - if (list.contains(playerName) || list.contains(playerUUID)) - { - e.getPlayer().getInventory().clear(); - Utils.sendMessage(player, null, "Inventory cleared."); - } - else if (list.contains("!" + playerName)) - { - player.getInventory().clear(); - list.remove("!" + playerName); - saveList(); - Utils.sendMessage(player, null, "Inventory cleared."); - } - } - - public void saveList() - { - JsonManager.save(list, listLocation); - } - - @Override - public boolean onEnable() - { - list = JsonManager.getArray(listLocation); - if (list == null) - list = new JSONArray(); - Bukkit.getServer().getPluginManager().registerEvents(this, Main.plugin); - return true; - } - - // @noformat - @Override - public String getCommandString() - { - return "command clearonjoin {\n" + - " [string:name] {\n" + - " help Clears that player's inventory the next time they join.;\n" + - " run clearonjoin name;\n" + - " perm utils.clearonjoin.other;\n" + - " }\n" + - " [empty] {\n" + - " help Clears your inventory every time you join.;\n" + - " run clearonjoinself;\n" + - " perm utils.clearonjoin.self;\n" + - " }\n" + - "}"; - } - // @format -} diff --git a/src/com/redstoner/modules/cycle/Cycle.java b/src/com/redstoner/modules/cycle/Cycle.java deleted file mode 100644 index 5f6d2a7..0000000 --- a/src/com/redstoner/modules/cycle/Cycle.java +++ /dev/null @@ -1,159 +0,0 @@ -package com.redstoner.modules.cycle; - -import java.io.File; -import java.util.UUID; - -import org.bukkit.GameMode; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.player.PlayerItemHeldEvent; -import org.bukkit.inventory.Inventory; -import org.bukkit.inventory.ItemStack; -import org.json.simple.JSONArray; - -import com.nemez.cmdmgr.Command; -import com.redstoner.annotations.AutoRegisterListener; -import com.redstoner.annotations.Version; -import com.redstoner.misc.JsonManager; -import com.redstoner.misc.Main; -import com.redstoner.misc.Utils; -import com.redstoner.modules.Module; - -@AutoRegisterListener -@Version(major = 2, minor = 0, revision = 0, compatible = 2) -public class Cycle implements Module, Listener -{ - private File cycleFile = new File(Main.plugin.getDataFolder(), "cycle.json"); - private JSONArray no_cyclers; - - @Override - public boolean onEnable() - { - no_cyclers = JsonManager.getArray(cycleFile); - if (no_cyclers == null) - no_cyclers = new JSONArray(); - return true; - } - - @Override - public void onDisable() - { - saveCyclers(); - } - - private void saveCyclers() - { - JsonManager.save(no_cyclers, cycleFile); - } - - @Command(hook = "cycle_on") - public boolean cycleOn(CommandSender sender) - { - UUID uid = ((Player) sender).getUniqueId(); - if (no_cyclers.remove(uid.toString())) - { - Utils.sendMessage(sender, null, "Cycle enabled!"); - saveCyclers(); - } - else - Utils.sendMessage(sender, null, "Cycle was already enabled!"); - return true; - } - - @SuppressWarnings("unchecked") - @Command(hook = "cycle_off") - public boolean cycleOff(CommandSender sender) - { - UUID uid = ((Player) sender).getUniqueId(); - if (!no_cyclers.contains(uid.toString())) - { - Utils.sendMessage(sender, null, "Cycle disabled!"); - no_cyclers.add(uid.toString()); - saveCyclers(); - } - else - Utils.sendMessage(sender, null, "Cycle was already disabled!"); - return true; - } - - @EventHandler - public void onInventoryCycle(PlayerItemHeldEvent event) - { - Player player = event.getPlayer(); - UUID uid = player.getUniqueId(); - if (!player.getGameMode().equals(GameMode.CREATIVE) || player.isSneaking() - || no_cyclers.contains(uid.toString())) - return; - int prev_slot = event.getPreviousSlot(); - int new_slot = event.getNewSlot(); - if (prev_slot == 0 && new_slot == 8) - shift(player, true); - else if (prev_slot == 8 && new_slot == 0) - shift(player, false); - } - - private void shift(Player player, boolean down) - { - Inventory inv = player.getInventory(); - ItemStack[] items = inv.getStorageContents(); - int shift = down ? -9 : 9; - shift = (shift + items.length) % items.length; - for (int i = 0; i < 4; i++) - { - items = join(subset(items, shift, items.length), subset(items, 0, shift)); - ItemStack[] hotbar = subset(items, 0, 9); - boolean found = false; - for (ItemStack item : hotbar) - if (item != null) - { - found = true; - break; - } - if (found) - break; - } - inv.setStorageContents(items); - } - - private ItemStack[] subset(ItemStack[] items, int start, int end) - { - ItemStack[] result = new ItemStack[end - start]; - for (int i = start; i < end; i++) - { - result[i - start] = items[i]; - } - return result; - } - - private ItemStack[] join(ItemStack[] items1, ItemStack[] items2) - { - ItemStack[] result = new ItemStack[items1.length + items2.length]; - for (int i = 0; i < items1.length; i++) - result[i] = items1[i]; - int offset = items1.length; - for (int i = 0; i < items2.length; i++) - result[i + offset] = items2[i]; - return result; - } - - // @noformat - @Override - public String getCommandString() - { - return "command cycle {\n" + - " on {\n" + - " help Turns on cycle;\n" + - " type player;\n" + - " run cycle_on;\n" + - " }\n" + - " off {\n" + - " help Turns off cycle;\n" + - " type player;\n" + - " run cycle_off;\n" + - " }\n" + - "}"; - } - // format -} diff --git a/src/com/redstoner/modules/damnspam/DamnSpam.java b/src/com/redstoner/modules/damnspam/DamnSpam.java deleted file mode 100644 index 8b9d0fa..0000000 --- a/src/com/redstoner/modules/damnspam/DamnSpam.java +++ /dev/null @@ -1,367 +0,0 @@ -package com.redstoner.modules.damnspam; - -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileReader; -import java.io.IOException; -import java.io.PrintWriter; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.block.Block; -import org.bukkit.block.BlockFace; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; -import org.bukkit.event.Cancellable; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; -import org.bukkit.event.block.Action; -import org.bukkit.event.block.BlockBreakEvent; -import org.bukkit.event.player.PlayerInteractEvent; -import org.json.simple.JSONObject; -import org.json.simple.parser.JSONParser; -import org.json.simple.parser.ParseException; - -import com.nemez.cmdmgr.Command; -import com.redstoner.annotations.AutoRegisterListener; -import com.redstoner.annotations.Version; -import com.redstoner.misc.Main; -import com.redstoner.misc.Utils; -import com.redstoner.modules.Module; - -@AutoRegisterListener -@Version(major = 2, minor = 0, revision = 1, compatible = 2) -public class DamnSpam implements Module, Listener -{ - File configFile = new File(Main.plugin.getDataFolder(), "DamnSpam.json"); - Map inputs; - boolean changingInput = false; - List acceptedInputs; - HashMap attachedBlocks; - HashMap players; - int maxTimeout = 240; - String timeoutErrorString = "&cThe timeout must be -1 or within 0 and " + maxTimeout; - - @Override - public boolean onEnable() - { - loadInputs(); - acceptedInputs = new ArrayList(); - Collections.addAll(acceptedInputs, Material.WOOD_BUTTON, Material.STONE_BUTTON, Material.LEVER); - attachedBlocks = new HashMap(); - attachedBlocks.put(Material.LEVER, - new int[][] {{0, 7, 8, 15}, {5, 6, 13, 14}, {4, 12}, {3, 11}, {2, 10}, {1, 9}}); - attachedBlocks.put(Material.STONE_BUTTON, - new int[][] {{0, 8}, {5, 6, 7, 13, 14, 15}, {4, 12}, {3, 11}, {2, 10}, {1, 9}}); - attachedBlocks.put(Material.WOOD_BUTTON, - new int[][] {{0, 8}, {5, 6, 7, 13, 14, 15}, {4, 12}, {3, 11}, {2, 10}, {1, 9}}); - players = new HashMap(); - return true; - } - - public void loadInputs() - { - inputs = new HashMap(); - try - { - FileReader reader = new FileReader(configFile); - JSONObject json = (JSONObject) new JSONParser().parse(reader); - for (Object key : json.keySet()) - { - JSONObject inputData = (JSONObject) json.get(key); - String uuid = (String) inputData.get("creator"); - Double timeoutOn = (Double) inputData.get("timeout_on"); - Double timeoutOff = (Double) inputData.get("timeout_off"); - Double lastTime = (Double) inputData.get("last_time"); - inputs.put((String) key, new SpamInput(uuid, timeoutOff, timeoutOn, lastTime)); - } - } - catch (IOException | ParseException e) - { - e.printStackTrace(); - } - } - - @SuppressWarnings("unchecked") - public void saveInputs() - { - JSONObject json = new JSONObject(); - for (String key : inputs.keySet()) - { - JSONObject jsonInput = new JSONObject(); - SpamInput input = inputs.get(key); - jsonInput.put("creator", input.player); - jsonInput.put("timeout_on", input.timeoutOn); - jsonInput.put("timeout_off", input.timeoutOff); - jsonInput.put("last_time", input.lastTime); - json.put(key, jsonInput); - } - try - { - PrintWriter writer = new PrintWriter(configFile); - writer.write(json.toJSONString()); - writer.close(); - } - catch (FileNotFoundException e) - { - e.printStackTrace(); - } - } - - public String locationString(Location loc) - { - return loc.getWorld().getName() + ";" + loc.getBlockX() + ";" + loc.getBlockY() + ";" + loc.getBlockZ(); - } - - public boolean isAcceptableTimeout(double timeout) - { - return (timeout > 0 && timeout <= maxTimeout) || timeout == -1; - } - - public boolean canBuild(Player player, Block block) - { - BlockBreakEvent event = new BlockBreakEvent(block, player); - Bukkit.getPluginManager().callEvent(event); - return !event.isCancelled(); - } - - @Command(hook = "damnspamSingle") - public void damnspam(CommandSender sender, double seconds) - { - boolean destroyingInput = false; - seconds = (double) Math.round(seconds * 100) / 100; - if (seconds == 0) - destroyingInput = true; - else if (!isAcceptableTimeout(seconds)) - { - Utils.sendMessage(sender, null, "&cThe timeout must be -1 or within 0 and " + maxTimeout, '&'); - return; - } - Utils.sendMessage(sender, null, "&aPlease click the input you would like to set.", '&'); - setPlayer((Player) sender, destroyingInput, seconds, seconds); - } - - @Command(hook = "damnspamDouble") - public void damnspam(CommandSender sender, double secondsOff, double secondsOn) - { - boolean destroyingInput = false; - secondsOn = (double) Math.round(secondsOn * 100) / 100; - secondsOff = (double) Math.round(secondsOff * 100) / 100; - if (secondsOn == 0 && secondsOff == 0) - { - destroyingInput = true; - } - else if (!(isAcceptableTimeout(secondsOn) && isAcceptableTimeout(secondsOff))) - { - Utils.sendMessage(sender, null, "&cThe timeout must be -1 or within 0 and " + maxTimeout, '&'); - return; - } - Utils.sendMessage(sender, null, "&aPlease click the input you would like to set.", '&'); - setPlayer((Player) sender, destroyingInput, secondsOff, secondsOn); - } - - public void setPlayer(Player player, boolean destroying, double timeoutOff, double timeoutOn) - { - SpamInput input = null; - if (!destroying) - { - input = new SpamInput(player.getUniqueId().toString(), timeoutOff, timeoutOn, 0); - } - players.put(player, input); - } - - public boolean attemptInputRegister(Player player, Block block, Cancellable event) - { - if (players.containsKey(player)) - { - if (!acceptedInputs.contains(block.getType())) - { - Utils.sendMessage(player, null, "&cThat block is not an acceptable input!", '&'); - return true; - } - String typeStr = block.getType().toString().toLowerCase().replace("_", " "); - String locationStr = locationString(block.getLocation()); - changingInput = true; - boolean buildCheck = canBuild(player, block); - changingInput = false; - if (!buildCheck) - { - Utils.sendMessage(player, null, - "&cThere is no timeout to remove on this " + typeStr + "(by setting the timeout to 0)", '&'); - return true; - } - SpamInput input = players.get(player); - if (input == null) - { - if (!inputs.containsKey(locationStr)) - { - Utils.sendMessage(player, null, - "&cThere is no timeout to remove on this " + typeStr + "(by setting the timeout to 0)", - '&'); - return true; - } - inputs.remove(locationStr); - Utils.sendMessage(player, null, "&aSuccessfully removed the timeout for this " + typeStr, '&'); - } - else - { - inputs.put(locationStr, players.get(player)); - Utils.sendMessage(player, null, "&aSuccessfully set a timeout for this " + typeStr, '&'); - } - event.setCancelled(true); - players.remove(player); - saveInputs(); - return true; - } - return false; - } - - public void checkBlockBreak(BlockBreakEvent event, Block block) - { - if (!acceptedInputs.contains(block.getType())) - return; - String posStr = locationString(block.getLocation()); - if (!inputs.containsKey(posStr)) - return; - SpamInput input = inputs.get(posStr); - Player sender = event.getPlayer(); - String typeStr = block.getType().toString().toLowerCase().replace("_", " "); - String inputStr = (block.getLocation().equals(event.getBlock()) ? "this " + typeStr - : "the " + typeStr + " attached to that block"); - if (!sender.isSneaking()) - { - Utils.sendMessage(sender, null, "&cYou cannot destroy " + inputStr, '&'); - Utils.sendMessage(sender, "", "&c&nSneak&c and break or set the timeout to 0 if you want to remove it.", - '&'); - event.setCancelled(true); - return; - } - if (sender.hasPermission("damnspam.admin") || sender.getUniqueId().toString().equals(input.player)) - { - inputs.remove(posStr); - saveInputs(); - Utils.sendMessage(sender, null, "&aSuccesfully removed " + inputStr, '&'); - } - else - { - Utils.sendMessage(sender, null, "&cYou are not allowed to remove " + inputStr, '&'); - event.setCancelled(true); - } - } - - @SuppressWarnings("deprecation") - public List getAttachedBlocks(Block block) - { - List blocks = new ArrayList(); - BlockFace[] directions = {BlockFace.DOWN, BlockFace.UP, BlockFace.NORTH, BlockFace.SOUTH, BlockFace.WEST, - BlockFace.EAST}; - for (int i = 0; i < directions.length; i++) - { - Block side = block.getRelative(directions[i]); - int[][] dvalues = attachedBlocks.get(side.getType()); - if (dvalues != null) - { - boolean onSide = false; - for (int val : dvalues[i]) - { - if (side.getData() == (byte) val) - { - onSide = true; - break; - } - } - if (onSide) - blocks.add(side); - } - } - return blocks; - } - - @EventHandler(priority = EventPriority.NORMAL) - public void onBreak(BlockBreakEvent event) - { - if (changingInput || event.isCancelled()) - return; - boolean register = attemptInputRegister(event.getPlayer(), event.getBlock(), event); - if (!register) - { - Block block = event.getBlock(); - checkBlockBreak(event, block); - for (Block affected : getAttachedBlocks(block)) - { - checkBlockBreak(event, affected); - } - } - } - - @SuppressWarnings("deprecation") - @EventHandler(priority = EventPriority.HIGHEST) - public void onInteract(PlayerInteractEvent event) - { - boolean register = attemptInputRegister(event.getPlayer(), event.getClickedBlock(), event); - if (!register && event.getAction().equals(Action.RIGHT_CLICK_BLOCK) && !event.isCancelled()) - { - Player sender = event.getPlayer(); - Block block = event.getClickedBlock(); - String posStr = locationString(block.getLocation()); - SpamInput data = inputs.get(posStr); - if (data != null) - { - String btype = block.getType().toString().toLowerCase().replace("_", " "); - double checktime = 0; - if (btype.equals("lever") && block.getData() < 8) - checktime = data.timeoutOff; - else - checktime = data.timeoutOn; - double timeLeft = (data.lastTime + checktime) - - ((double) Math.round((double) System.currentTimeMillis() / 10) / 100); - timeLeft = (double) Math.round(timeLeft * 100) / 100; - if (checktime == -1) - { - event.setCancelled(true); - Utils.sendMessage(sender, null, "&cThis " + btype + " is locked permanently by /damnspam.", '&'); - } - else if (timeLeft > 0) - { - event.setCancelled(true); - Utils.sendMessage(sender, null, "&cThis " + btype + " has a damnspam timeout of " + checktime - + ", with " + timeLeft + " left.", '&'); - } - else - { - data.lastTime = (double) Math.round((double) System.currentTimeMillis() / 10) / 100; - } - inputs.put(posStr, data); - } - } - } - - // @noformat - @Override - public String getCommandString() - { - return "command damnspam {\n" + - " perm utils.damnspam;\n" + - " \n" + - " [double:seconds] {\n" + - " run damnspamSingle seconds;\n" + - " help Set single input cooldown for button or lever.;\n" + - " type player;\n" + - " }\n" + - " \n" + - " [double:secondsOff] [double:secondsOn] {\n" + - " run damnspamDouble secondsOff secondsOn;\n" + - " help Set input cooldown after it's been turned off and turned on (for lever only).;\n" + - " type player;\n" + - " }\n" + - "}"; - } - // @format -} diff --git a/src/com/redstoner/modules/damnspam/SpamInput.java b/src/com/redstoner/modules/damnspam/SpamInput.java deleted file mode 100644 index 9735dd9..0000000 --- a/src/com/redstoner/modules/damnspam/SpamInput.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.redstoner.modules.damnspam; - -public class SpamInput { - - protected String player; - protected double timeoutOn; - protected double timeoutOff; - protected double lastTime; - - protected SpamInput(String player, double timeoutOff, double timeoutOn, double lastTime) { - this.player = player; - this.timeoutOff = timeoutOff; - this.timeoutOn = timeoutOn; - this.lastTime = lastTime; - } - -} diff --git a/src/com/redstoner/modules/essentials/Essentials.java b/src/com/redstoner/modules/essentials/Essentials.java deleted file mode 100644 index b7bdf22..0000000 --- a/src/com/redstoner/modules/essentials/Essentials.java +++ /dev/null @@ -1,188 +0,0 @@ -package com.redstoner.modules.essentials; - -import java.io.File; -import java.util.Date; -import java.util.HashMap; -import java.util.UUID; - -import org.bukkit.Bukkit; -import org.bukkit.OfflinePlayer; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.player.PlayerJoinEvent; -import org.bukkit.event.player.PlayerQuitEvent; -import org.json.simple.JSONObject; - -import com.nemez.cmdmgr.Command; -import com.nemez.cmdmgr.CommandManager; -import com.redstoner.annotations.AutoRegisterListener; -import com.redstoner.annotations.Version; -import com.redstoner.exceptions.PlayerNotFoundException; -import com.redstoner.misc.JsonManager; -import com.redstoner.misc.Main; -import com.redstoner.misc.Utils; -import com.redstoner.modules.Module; - -@AutoRegisterListener -@Version(major = 3, minor = 0, revision = 0, compatible = 3) -public class Essentials implements Module -{ - static HashMap players; - private final File saveFile = new File(Main.plugin.getDataFolder(), "knownPlayers.json"); - private static JSONObject knownNames; - - @Override - public boolean onEnable() - { - knownNames = JsonManager.getObject(saveFile); - if (knownNames == null) - { - Utils.warn("Couldn't find existing"); - } - players = new HashMap(); - for (Player p : Bukkit.getOnlinePlayers()) - { - players.put(p.getUniqueId(), Essentials.getPlayer(p)); - } - return true; - } - - @Override - public void postEnable() - { - Utils.info("Creating command links for essentials. This may take a while..."); - CommandManager.registerCommand(this.getClass().getResourceAsStream("Essentials.cmd"), this, Main.plugin); - } - - @Command(hook = "kickDef") - public void kick(CommandSender sender, String name) - { - kick(sender, name, EssentialsDefaults.kick); - } - - @Command(hook = "kick") - public void kick(CommandSender sender, String name, String reason) - { - try - { - getPlayer(name).kick(Utils.getName(sender), reason); - } - catch (PlayerNotFoundException e) - { - Utils.sendErrorMessage(sender, null, e.getMessage()); - } - } - - @Command(hook = "banDef") - public void ban(CommandSender sender, String name) - { - ban(sender, name, EssentialsDefaults.ban); - } - - @Command(hook = "ban") - public void ban(CommandSender sender, String name, String reason) - { - try - { - getOfflinePlayer(name).ban(sender.getName(), reason, null); - } - catch (PlayerNotFoundException e) - { - Utils.sendErrorMessage(sender, null, e.getMessage()); - } - } - - @Command(hook = "tbanDefDR") - public void tempban(CommandSender sender, String name) - { - tempban(sender, name, EssentialsDefaults.tbanD, EssentialsDefaults.tbanR); - } - - @Command(hook = "tbanDefR") - public void tbanD(CommandSender sender, String name, String duration) - { - tempban(sender, name, duration, EssentialsDefaults.tbanR); - } - - @Command(hook = "tbanDefD") - public void tbanR(CommandSender sender, String name, String reason) - { - tempban(sender, name, EssentialsDefaults.tbanD, reason); - } - - @Command(hook = "tban") - public void tempban(CommandSender sender, String name, String duration, String reason) - { - try - { - getOfflinePlayer(name).ban(Utils.getName(sender), reason, - new Date((new Date()).getTime() + Long.parseLong(duration))); - } - catch (PlayerNotFoundException | NumberFormatException e) - { - Utils.sendErrorMessage(sender, null, e.getMessage()); - } - } - - @EventHandler - public void onPlayerJoin(PlayerJoinEvent e) - { - players.put(e.getPlayer().getUniqueId(), getPlayer(e.getPlayer())); - } - - @EventHandler - public void onPlayerLeave(PlayerQuitEvent e) - { - UUID uuid = e.getPlayer().getUniqueId(); - players.get(uuid).onLeave(); - players.remove(uuid); - } - - public static EssentialsPlayer getPlayer(UUID uuid) throws PlayerNotFoundException - { - Player player = Bukkit.getPlayer(uuid); - if (player == null) - throw new PlayerNotFoundException(); - return getPlayer(player); - } - - public static EssentialsPlayer getPlayer(Player player) - { - if (players.containsKey(player.getUniqueId())) - return players.get(player.getUniqueId()); - return new EssentialsPlayer(player); - } - - public static EssentialsPlayer getPlayer(String name) throws PlayerNotFoundException - { - Player player = Bukkit.getPlayer(name); - if (player == null) - throw new PlayerNotFoundException(); - return getPlayer(player); - } - - public static EssentialsOfflinePlayer getOfflinePlayer(UUID uuid) throws PlayerNotFoundException - { - OfflinePlayer player = Bukkit.getOfflinePlayer(uuid); - if (player == null) - throw new PlayerNotFoundException(); - return getOfflinePlayer(player); - } - - public static EssentialsOfflinePlayer getOfflinePlayer(OfflinePlayer player) - { - if (players.containsKey(player.getUniqueId())) - return players.get(player.getUniqueId()); - return new EssentialsOfflinePlayer(player); - } - - @Deprecated - public static EssentialsOfflinePlayer getOfflinePlayer(String name) throws PlayerNotFoundException - { - OfflinePlayer player = Bukkit.getOfflinePlayer(name); - if (player == null) - throw new PlayerNotFoundException(); - return getOfflinePlayer(player); - } -} diff --git a/src/com/redstoner/modules/firstseen/FirstSeen.java b/src/com/redstoner/modules/firstseen/FirstSeen.java deleted file mode 100644 index 81ea56a..0000000 --- a/src/com/redstoner/modules/firstseen/FirstSeen.java +++ /dev/null @@ -1,62 +0,0 @@ -package com.redstoner.modules.firstseen; - -import java.text.SimpleDateFormat; -import java.util.Date; - -import org.bukkit.Bukkit; -import org.bukkit.OfflinePlayer; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import com.nemez.cmdmgr.Command; -import com.redstoner.annotations.Version; -import com.redstoner.misc.Utils; -import com.redstoner.modules.Module; - -@Version(major = 2, minor = 0, revision = 0, compatible = 2) -public class FirstSeen implements Module{ - - @SuppressWarnings("deprecation") - @Command(hook = "firstseenP") - public void firstseen(CommandSender sender, String person) - { - Player player = (Player) sender; - Utils.sendMessage(sender, "", "&7Please note that the data may not be fully accurate!", '&'); - OfflinePlayer oPlayer = Bukkit.getPlayer(person); - if (oPlayer == null) - oPlayer = Bukkit.getServer().getOfflinePlayer(person); - Long firstJoin = oPlayer.getFirstPlayed(); - SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm"); - String disDate = format.format( new Date(firstJoin) ); - if( disDate.equals("1969-12-31 19:00") ) { - Utils.sendMessage(player, null, "&3" + oPlayer.getName() + "&c has never joined.", '&'); - } - else { - Utils.sendMessage(player, null, "&3" + oPlayer.getName() + " &efirst joined&a " + disDate + "&e.", '&'); - } - } - @Command(hook = "firstseen") - public void firstseen(CommandSender sender) - { - firstseen(sender, sender.getName()); - } - - - @Override - public String getCommandString() { - return "command firstseen {\n" + - " [empty] {\n" + - " run firstseen;\n" + - " type player;\n" + - " help Gives the date and time they first joined;\n" + - " perm utils.firstseen;\n" + - " }\n" + - " [string:person] {\n" + - " run firstseenP person;\n" + - " type player;\n" + - " help Gives the date and time when a player first joined;\n" + - " perm utils.firstseen.other;\n" + - " }\n" + - "}"; - } -} diff --git a/src/com/redstoner/modules/illumination/Illumination.java b/src/com/redstoner/modules/illumination/Illumination.java deleted file mode 100644 index b18276c..0000000 --- a/src/com/redstoner/modules/illumination/Illumination.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.redstoner.modules.illumination; - -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; -import org.bukkit.potion.PotionEffect; -import org.bukkit.potion.PotionEffectType; - -import com.nemez.cmdmgr.Command; -import com.redstoner.annotations.Version; -import com.redstoner.misc.Utils; -import com.redstoner.modules.Module; - -@Version(major = 2, minor = 0, revision = 1, compatible = 2) -public class Illumination implements Module -{ - PotionEffect effect = new PotionEffect(PotionEffectType.NIGHT_VISION, Integer.MAX_VALUE, 0, false, false); - - @Command(hook = "illuminate") - public void illuminate(CommandSender sender) - { - Player player = (Player) sender; - if (player.hasPotionEffect(PotionEffectType.NIGHT_VISION)) - { - player.removePotionEffect(PotionEffectType.NIGHT_VISION); - Utils.sendMessage(sender, null, "Night Vision Disabled."); - } - else - { - player.addPotionEffect(effect, true); - Utils.sendMessage(sender, null, "Night Vision Enabled."); - } - } - - // @noformat - @Override - public String getCommandString() - { - return "command nightvision {\n" + - " [empty] {\n" + - " run illuminate;\n" + - " type player;\n" + - " help Gives the player infinte night vision;\n" + - " perm utils.illuminate;\n" + - " }\n" + - "}"; - } - // @format -} diff --git a/src/com/redstoner/modules/imout/Imout.java b/src/com/redstoner/modules/imout/Imout.java deleted file mode 100644 index 463800f..0000000 --- a/src/com/redstoner/modules/imout/Imout.java +++ /dev/null @@ -1,59 +0,0 @@ -package com.redstoner.modules.imout; - -import java.util.ArrayList; -import java.util.List; - -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import com.nemez.cmdmgr.Command; -import com.redstoner.annotations.Version; -import com.redstoner.misc.Utils; -import com.redstoner.modules.Module; - -@Version(major = 2, minor = 0, revision = 1, compatible = 2) -public class Imout implements Module -{ - List imout_toggle_list = new ArrayList(); - - @Command(hook = "imout") - public void onImoutCommand(CommandSender sender) - { - String symbol; - Player s = (Player) sender; - String name = sender.getName(); - if (imout_toggle_list.contains(name)) - { - symbol = "§a§l+"; - Utils.sendModuleHeader(sender); - Utils.sendMessage(sender, "", "§eWelcome back! You are no longer hidden"); - s.performCommand("vanish off"); - s.performCommand("act off"); - imout_toggle_list.remove(name); - } - else - { - symbol = "§c§l-"; - sender.sendMessage("§eYou just left... Or didn't you?"); - s.performCommand("vanish on"); - s.performCommand("act on"); - imout_toggle_list.add(name); - } - Utils.broadcast(symbol, " §7" + name, null); - } - - // @noformat - @Override - public String getCommandString() - { - return "command imout {\n" + - " [empty] {\n" + - " help Makes you magically disappear;\n" + - " type player;\n" + - " perm utils.imout;\n" + - " run imout;\n" + - " }\n" + - "}"; - } - // @format -} diff --git a/src/com/redstoner/modules/lagchunks/LagChunks.java b/src/com/redstoner/modules/lagchunks/LagChunks.java deleted file mode 100644 index abbf048..0000000 --- a/src/com/redstoner/modules/lagchunks/LagChunks.java +++ /dev/null @@ -1,106 +0,0 @@ -package com.redstoner.modules.lagchunks; - -import java.util.ArrayList; -import java.util.List; - -import org.bukkit.Bukkit; -import org.bukkit.Chunk; -import org.bukkit.Location; -import org.bukkit.World; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import com.nemez.cmdmgr.Command; -import com.nemez.cmdmgr.Command.AsyncType; -import com.redstoner.annotations.Version; -import com.redstoner.misc.Utils; -import com.redstoner.modules.Module; - -@Version(major = 2, minor = 0, revision = 1, compatible = 2) -public class LagChunks implements Module -{ - private List laggyChunks = new ArrayList(); - - private void scan(int amount) - { - laggyChunks.clear(); - for (World world : Bukkit.getServer().getWorlds()) - { - for (Chunk chunk : world.getLoadedChunks()) - { - if (chunk.getEntities().length > amount) - { - Location entLoc = chunk.getEntities()[0].getLocation(); - laggyChunks.add(new LaggyChunk(entLoc.getBlockX(), entLoc.getBlockY(), entLoc.getBlockZ(), world, - chunk.getEntities().length)); - } - } - } - } - - @Command(hook = "list_cmd") - public void list(CommandSender sender) - { - if (laggyChunks.size() > 0) - { - Utils.sendModuleHeader(sender); - for (LaggyChunk lc : laggyChunks) - { - Utils.sendMessage(sender, "", "§b[§a" + laggyChunks.indexOf(lc) + "§b]: §a" + lc.x + "§7, §a" + lc.y - + "§7, §a" + lc.z + " §7(" + lc.world.getName() + ") §a- §b" + lc.amount + " entities"); - } - Utils.sendMessage(sender, "", "§2-------------------"); - } - else - Utils.sendMessage(sender, null, "Couldn't find any chunks with that many entities."); - } - - @Command(hook = "scan_cmd", async = AsyncType.ALWAYS) - public void scan_cmd(CommandSender sender, int amount) - { - scan(amount); - list(sender); - } - - @Command(hook = "tp") - public void tp(CommandSender sender, int number) - { - Player player = (Player) sender; - if (number < laggyChunks.size()) - { - player.teleport(laggyChunks.get(number).getLocation()); - Utils.sendMessage(player, null, "§aTeleported to chunk " + number + "!"); - } - else - { - Utils.sendErrorMessage(sender, null, "§4Invalid chunk number! Use §e/lc list §4to show laggy chunks!"); - } - } - - // @noformat - @Override - public String getCommandString() - { - return "command lc {\n" + - " perm utils.lagchunks;\n" + - " \n" + - " list {\n" + - " run list_cmd;\n" + - " help re-lists already scanned chunks;\n" + - " }\n" + - " \n" + - " [int:amount] {\n" + - " run scan_cmd amount;\n" + - " help scans for laggy chunks;\n" + - " }\n" + - " \n" + - " tp [int:number] {\n" + - " run tp number;\n" + - " help teleports to the specified chunk;\n" + - " type player;\n" + - " }\n" + - "}\n" + - " "; - } - // @format -} diff --git a/src/com/redstoner/modules/lagchunks/LaggyChunk.java b/src/com/redstoner/modules/lagchunks/LaggyChunk.java deleted file mode 100644 index 3ff4d6f..0000000 --- a/src/com/redstoner/modules/lagchunks/LaggyChunk.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.redstoner.modules.lagchunks; - -import org.bukkit.Location; -import org.bukkit.World; - -public class LaggyChunk { - public final int x, y, z, amount; - public final World world; - - public LaggyChunk(int x, int y, int z, World world, int amount) { - this.x = x; - this.y = y; - this.z = z; - this.world = world; - this.amount = amount; - } - - public Location getLocation() { - return new Location(world, x, y, z); - } -} diff --git a/src/com/redstoner/modules/loginsecurity/CancelledEventsHandler.java b/src/com/redstoner/modules/loginsecurity/CancelledEventsHandler.java deleted file mode 100644 index e39d781..0000000 --- a/src/com/redstoner/modules/loginsecurity/CancelledEventsHandler.java +++ /dev/null @@ -1,95 +0,0 @@ -package com.redstoner.modules.loginsecurity; - -import org.bukkit.ChatColor; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; -import org.bukkit.event.inventory.InventoryClickEvent; -import org.bukkit.event.player.AsyncPlayerChatEvent; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; -import org.bukkit.event.player.PlayerDropItemEvent; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.event.player.PlayerItemHeldEvent; -import org.bukkit.event.player.PlayerMoveEvent; -import org.bukkit.event.player.PlayerPickupArrowEvent; -import org.bukkit.event.player.PlayerPickupItemEvent; - -public class CancelledEventsHandler implements Listener { - private LoginSecurity mainClass; - - public CancelledEventsHandler(LoginSecurity mainClass) { - this.mainClass = mainClass; - } - - @EventHandler - public void onMove(PlayerMoveEvent e) { - if (isLoggingIn(e.getPlayer())) { - e.getPlayer().teleport(LoginSecurity.loggingIn.get(e.getPlayer().getUniqueId())); - } - } - - @EventHandler(priority = EventPriority.HIGHEST) - public void onChat(AsyncPlayerChatEvent e) { - if (isLoggingIn(e.getPlayer())) { - e.getPlayer().sendMessage(ChatColor.RED + "You must login before you can chat!"); - e.setCancelled(true); - } - } - - @EventHandler(priority = EventPriority.HIGHEST) - public void onCommand(PlayerCommandPreprocessEvent e) { - String command = e.getMessage(); - - if (!command.startsWith("/login") && isLoggingIn(e.getPlayer())) { - e.getPlayer().sendMessage(ChatColor.RED + "You must login before you can execute commands!"); - e.setCancelled(true); - } - } - - @EventHandler(priority = EventPriority.HIGHEST) - public void onItemHold(PlayerItemHeldEvent e) { - if (isLoggingIn(e.getPlayer())) { - e.setCancelled(true); - } - } - - @EventHandler(priority = EventPriority.HIGHEST) - public void onItemPickup(PlayerPickupItemEvent e) { - if (isLoggingIn(e.getPlayer())) { - e.setCancelled(true); - } - } - - @EventHandler(priority = EventPriority.HIGHEST) - public void onItemDrop(PlayerDropItemEvent e) { - if (isLoggingIn(e.getPlayer())) { - e.setCancelled(true); - } - } - - @EventHandler(priority = EventPriority.HIGHEST) - public void onInteract(PlayerInteractEvent e) { - if (isLoggingIn(e.getPlayer())) { - e.setCancelled(true); - } - } - - @EventHandler(priority = EventPriority.HIGHEST) - public void onArrowPickup(PlayerPickupArrowEvent e) { - if (isLoggingIn(e.getPlayer())) { - e.setCancelled(true); - } - } - - @EventHandler(priority = EventPriority.HIGHEST) - public void onInvClick(InventoryClickEvent e) { - if (e.getWhoClicked() instanceof Player && isLoggingIn((Player) e.getWhoClicked())) { - e.setCancelled(true); - } - } - - private boolean isLoggingIn(Player player) { - return mainClass.isLoggingIn(player); - } -} diff --git a/src/com/redstoner/modules/loginsecurity/CryptographyHandler.java b/src/com/redstoner/modules/loginsecurity/CryptographyHandler.java deleted file mode 100644 index 48e81a9..0000000 --- a/src/com/redstoner/modules/loginsecurity/CryptographyHandler.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.redstoner.modules.loginsecurity; - -import java.security.NoSuchAlgorithmException; -import java.security.NoSuchProviderException; -import java.security.SecureRandom; -import java.security.spec.InvalidKeySpecException; -import java.security.spec.KeySpec; -import java.util.Base64; - -import javax.crypto.SecretKeyFactory; -import javax.crypto.spec.PBEKeySpec; - -public class CryptographyHandler { - public static String hash(String password, String salt) { - String algorithm = "PBKDF2WithHmacSHA256"; - int derivedKeyLength = 256; - int iterations = 200000; - byte[] decodedSalt = Base64.getDecoder().decode(salt.getBytes()); - - KeySpec spec = new PBEKeySpec(password.toCharArray(), decodedSalt, iterations, derivedKeyLength); - - byte[] hashed = null; - - try { - SecretKeyFactory f = SecretKeyFactory.getInstance(algorithm); - - hashed = f.generateSecret(spec).getEncoded(); - } catch (InvalidKeySpecException | NoSuchAlgorithmException e) { - e.printStackTrace(); - } - - return Base64.getEncoder().encodeToString(hashed).substring(0, 43); - } - - public static boolean verify(String password, String salt, String hash) { - return hash(password, salt).equals(hash); - } - - public static boolean verify(String password, String stored) { - String[] split = stored.split("\\$"); - - return verify(password, split[3], split[4]); - } - - public static String generateSalt() throws NoSuchAlgorithmException, NoSuchProviderException { - SecureRandom random = SecureRandom.getInstance("SHA1PRNG"); - - byte[] salt = new byte[16]; - random.nextBytes(salt); - - return Base64.getEncoder().encodeToString(salt).substring(0, 22); - } -} diff --git a/src/com/redstoner/modules/loginsecurity/LoginSecurity.java b/src/com/redstoner/modules/loginsecurity/LoginSecurity.java deleted file mode 100644 index 38129c5..0000000 --- a/src/com/redstoner/modules/loginsecurity/LoginSecurity.java +++ /dev/null @@ -1,318 +0,0 @@ -package com.redstoner.modules.loginsecurity; - -import java.io.Serializable; -import java.security.NoSuchAlgorithmException; -import java.security.NoSuchProviderException; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; - -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.Location; -import org.bukkit.OfflinePlayer; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.player.PlayerJoinEvent; -import org.bukkit.scheduler.BukkitScheduler; - -import com.nemez.cmdmgr.Command; -import com.redstoner.annotations.AutoRegisterListener; -import com.redstoner.annotations.Version; -import com.redstoner.misc.Main; -import com.redstoner.misc.Utils; -import com.redstoner.misc.mysql.JSONManager; -import com.redstoner.misc.mysql.MysqlHandler; -import com.redstoner.misc.mysql.elements.ConstraintOperator; -import com.redstoner.misc.mysql.elements.MysqlConstraint; -import com.redstoner.misc.mysql.elements.MysqlDatabase; -import com.redstoner.misc.mysql.elements.MysqlField; -import com.redstoner.misc.mysql.elements.MysqlTable; -import com.redstoner.misc.mysql.types.text.VarChar; -import com.redstoner.modules.Module; - -@AutoRegisterListener -@Version(major = 2, minor = 0, revision = 1, compatible = 2) -public class LoginSecurity implements Module, Listener -{ - protected static Map loggingIn; - private MysqlTable table; - - @Override - public boolean onEnable() - { - Map config = JSONManager.getConfiguration("loginsecurity.json"); - if (config == null || !config.containsKey("database") || !config.containsKey("table")) - { - Utils.sendErrorMessage(Bukkit.getConsoleSender(), null, - "Could not load the LoginSecurity config file, disabling!"); - return false; - } - try - { - MysqlDatabase database = MysqlHandler.INSTANCE.getDatabase((String) config.get("database")); - MysqlField uuid = new MysqlField("uuid", new VarChar(36), true); - MysqlField pass = new MysqlField("pass", new VarChar(88), true); - database.createTableIfNotExists((String) config.get("table"), uuid, pass); - table = database.getTable((String) config.get("table")); - } - catch (NullPointerException e) - { - Utils.sendErrorMessage(Bukkit.getConsoleSender(), null, - "Could not use the LoginSecurity config, disabling!"); - return false; - } - loggingIn = new HashMap<>(); - Bukkit.getServer().getPluginManager().registerEvents(new CancelledEventsHandler(this), Main.plugin); - return true; - } - - public static Map getLoggingIn() - { - return loggingIn; - } - - @Command(hook = "register") - public void register(CommandSender sender, String password) - { - Player player = (Player) sender; - if (isRegistered(player)) - { - player.sendMessage(ChatColor.GREEN + "You are already registered!"); - return; - } - try - { - if (registerPlayer(player, password)) - { - player.sendMessage(ChatColor.GREEN + "Succesfully registered!"); - return; - } - } - catch (NoSuchAlgorithmException | NoSuchProviderException e) - { - e.printStackTrace(); - } - player.sendMessage(ChatColor.RED + "Failed to register, please contact an admin!"); - } - - @Command(hook = "login") - public void login(CommandSender sender, String password) - { - Player player = (Player) sender; - if (!isRegistered(player)) - { - player.sendMessage(ChatColor.RED + "You are not registered!"); - return; - } - if (CryptographyHandler.verify(password, getHash(player))) - { - loggingIn.remove(player.getUniqueId()); - } - else - { - player.sendMessage(ChatColor.RED + "Wrong password!"); - } - } - - @Command(hook = "cgpass") - public void cgpass(CommandSender sender, String oldPassword, String newPassword) - { - Player player = (Player) sender; - if (!isRegistered(player)) - { - player.sendMessage(ChatColor.RED + "You are not registered!"); - return; - } - if (!CryptographyHandler.verify(oldPassword, getHash(player))) - { - player.sendMessage(ChatColor.RED + "The old password you entered is wrong!"); - return; - } - if (oldPassword.equals(newPassword)) - { - player.sendMessage(ChatColor.RED + "You entered the same password!"); - return; - } - if (table.delete(getUuidConstraint(player))) - { - try - { - registerPlayer(player, newPassword); - player.sendMessage(ChatColor.GREEN + "Succesfully changed password!"); - } - catch (NoSuchAlgorithmException | NoSuchProviderException e) - { - e.printStackTrace(); - player.sendMessage(ChatColor.RED + "Failed to set new password!"); - } - } - else - { - player.sendMessage(ChatColor.RED + "Failed to remove old password from database!"); - } - } - - @Command(hook = "rmpass") - public void rmpass(CommandSender sender, String oldPassword) - { - Player player = (Player) sender; - if (!isRegistered(player)) - { - player.sendMessage(ChatColor.RED + "You are not registered!"); - return; - } - if (!CryptographyHandler.verify(oldPassword, getHash(player))) - { - player.sendMessage(ChatColor.RED + "The old password you entered is wrong!"); - return; - } - if (table.delete(getUuidConstraint(player))) - { - player.sendMessage(ChatColor.GREEN + "Succesfully removed password!"); - } - else - { - player.sendMessage(ChatColor.RED + "Failed to remove old password from database!"); - } - } - - @Command(hook = "rmotherpass") - public void rmotherpass(CommandSender sender, String playerName) - { - if (playerName.equals("")) - { - sender.sendMessage(ChatColor.RED + "That's not a valid player!"); - return; - } - @SuppressWarnings("deprecation") - OfflinePlayer player = Bukkit.getOfflinePlayer(playerName); - if (!isRegistered(player)) - { - sender.sendMessage(ChatColor.RED + "That player is not registered!"); - return; - } - if (table.delete(getUuidConstraint(player))) - { - sender.sendMessage(ChatColor.GREEN + "Successfully removed " + playerName + "'s password!"); - } - else - { - sender.sendMessage(ChatColor.RED + "Failed to remove " + playerName + "'s password!"); - } - } - - @EventHandler - public void onJoin(PlayerJoinEvent e) - { - Player player = e.getPlayer(); - if (!isRegistered(player)) - { - return; - } - Utils.sendMessage(player, null, "You'll have to log in within 60s or you'll be kicked!"); - loggingIn.put(player.getUniqueId(), player.getLocation()); - BukkitScheduler scheduler = Bukkit.getScheduler(); - RepeatingLoginRunnable repeatingRunnable = new RepeatingLoginRunnable(this, player); - repeatingRunnable.setId(scheduler.scheduleSyncRepeatingTask(Main.plugin, repeatingRunnable, 0L, 2L)); - scheduler.scheduleSyncDelayedTask(Main.plugin, new Runnable() - { - @Override - public void run() - { - if (isLoggingIn(player)) - { - scheduler.cancelTask(repeatingRunnable.getId()); - player.kickPlayer("You didn't login in time!"); - } - } - }, 1200L); - } - - public boolean isLoggingIn(Player player) - { - return loggingIn.containsKey(player.getUniqueId()); - } - - public MysqlConstraint getUuidConstraint(OfflinePlayer player) - { - return new MysqlConstraint("uuid", ConstraintOperator.EQUAL, player.getUniqueId().toString()); - } - - public boolean isRegistered(OfflinePlayer player) - { - return table.get("uuid", getUuidConstraint(player)).length > 0; - } - - public String getHash(OfflinePlayer player) - { - return (String) table.get("pass", getUuidConstraint(player))[0]; - } - - public boolean registerPlayer(Player player, String password) - throws NoSuchAlgorithmException, NoSuchProviderException - { - String salt = CryptographyHandler.generateSalt(); - String hash = CryptographyHandler.hash(password, salt); - String toInsert = "$pbkdf2-sha256$200000$" + salt + "$" + hash; - return table.insert(player.getUniqueId().toString(), toInsert); - } - - // @noformat - @Override - public String getCommandString() - { - return "command register {\n" + - " perm utils.loginsecurity;\n" + - " \n" + - " [string:password] {\n" + - " run register password;\n" + - " help Protects your account with a password;\n" + - " type player;\n" + - " }\n" + - "}\n" + - "\n" + - "command login {\n" + - " perm utils.loginsecurity;\n" + - " \n" + - " [string:password] {\n" + - " run login password;\n" + - " help Logs you in;\n" + - " type player;\n" + - " }\n" + - "}\n" + - "\n" + - "command cgpass {\n" + - " perm utils.loginsecurity;\n" + - " \n" + - " [string:oldPassword] [string:newPassword] {\n" + - " run cgpass oldPassword newPassword;\n" + - " help Changes your password to the specified one;\n" + - " type player;\n" + - " }\n" + - "}\n" + - "\n" + - "command rmpass {\n" + - " perm utils.loginsecurity;\n" + - " \n" + - " [string:oldPassword] {\n" + - " run rmpass oldPassword;\n" + - " help Removes the password of your account;\n" + - " type player;\n" + - " }\n" + - "}\n" + - "\n" + - "command rmotherpass {\n" + - " perm utils.loginsecurity.admin;\n" + - " \n" + - " [string:playerName] {\n" + - " run rmotherpass playerName;\n" + - " help removes the password of another player;\n" + - " perm utils.loginsecurity.admin;\n" + - " }\n" + - "}"; - } - // @format -} diff --git a/src/com/redstoner/modules/loginsecurity/RepeatingLoginRunnable.java b/src/com/redstoner/modules/loginsecurity/RepeatingLoginRunnable.java deleted file mode 100644 index 4e8db6d..0000000 --- a/src/com/redstoner/modules/loginsecurity/RepeatingLoginRunnable.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.redstoner.modules.loginsecurity; - -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.entity.Player; - -public class RepeatingLoginRunnable implements Runnable { - private int id = -1; - private Player player; - private LoginSecurity mainClass; - - public RepeatingLoginRunnable(LoginSecurity mainClass, Player player) { - this.player = player; - this.mainClass = mainClass; - } - - @Override - public void run() { - if (!player.isOnline()) { - LoginSecurity.loggingIn.remove(player.getUniqueId()); - Bukkit.getScheduler().cancelTask(id); - } - - if (!mainClass.isLoggingIn(player)) { - player.sendMessage(ChatColor.GREEN + "Successfully logged in!"); - Bukkit.getScheduler().cancelTask(id); - } - } - - public void setId(int id) { - this.id = id; - } - - public int getId() { - return id; - } -} diff --git a/src/com/redstoner/modules/mentio/Mentio.java b/src/com/redstoner/modules/mentio/Mentio.java deleted file mode 100644 index ea2598d..0000000 --- a/src/com/redstoner/modules/mentio/Mentio.java +++ /dev/null @@ -1,192 +0,0 @@ -package com.redstoner.modules.mentio; - -import java.io.File; -import java.util.UUID; -import java.util.regex.Pattern; - -import org.bukkit.Sound; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; -import org.bukkit.event.player.AsyncPlayerChatEvent; -import org.json.simple.JSONArray; -import org.json.simple.JSONObject; - -import com.nemez.cmdmgr.Command; -import com.redstoner.annotations.AutoRegisterListener; -import com.redstoner.annotations.Version; -import com.redstoner.misc.JsonManager; -import com.redstoner.misc.Main; -import com.redstoner.misc.Utils; -import com.redstoner.modules.Module; - -@AutoRegisterListener -@Version(major = 2, minor = 0, revision = 2, compatible = 2) -public class Mentio implements Module, Listener -{ - private File mentioLocation = new File(Main.plugin.getDataFolder(), "mentio.json"); - private JSONObject mentios; - - @Override - public boolean onEnable() - { - loadMentios(); - return true; - } - - @Override - public void onDisable() - { - saveMentios(); - } - - @SuppressWarnings("unchecked") - @Command(hook = "addmentio") - public boolean addMentio(CommandSender sender, String trigger) - { - Player player = (Player) sender; - UUID uuid = player.getUniqueId(); - JSONArray playerMentios = (JSONArray) mentios.get(uuid.toString()); - if (playerMentios == null) - { - playerMentios = new JSONArray(); - playerMentios.add(player.getName()); - playerMentios.add(player.getDisplayName().split(" ")[0].replaceAll("§[0-9a-fk-o]", "")); - } - if (playerMentios.contains(trigger)) - Utils.sendErrorMessage(sender, null, "You already had that as a mentio!"); - else - { - playerMentios.add(trigger); - Utils.sendMessage(sender, null, "Successfully added the trigger §e" + trigger + " §7for you!"); - mentios.put(uuid.toString(), playerMentios); - saveMentios(); - } - return true; - } - - @SuppressWarnings("unchecked") - @Command(hook = "delmentio") - public boolean delMentio(CommandSender sender, String trigger) - { - Player player = (Player) sender; - UUID uuid = player.getUniqueId(); - JSONArray playerMentios = (JSONArray) mentios.get(uuid.toString()); - if (playerMentios == null) - { - playerMentios = new JSONArray(); - playerMentios.add(player.getName()); - playerMentios.add(player.getDisplayName().split(" ")[0].replaceAll("§[0-9a-fk-o]", "")); - } - if (!playerMentios.remove(trigger)) - Utils.sendErrorMessage(sender, null, "You didn't have that as a mentio!"); - else - { - Utils.sendMessage(sender, null, "Successfully removed the trigger §e" + trigger + " §7for you!"); - mentios.put(uuid.toString(), playerMentios); - saveMentios(); - } - return true; - } - - @SuppressWarnings("unchecked") - @Command(hook = "listmentios") - public boolean listMentios(CommandSender sender) - { - Utils.sendModuleHeader(sender); - Player player = (Player) sender; - UUID uuid = player.getUniqueId(); - JSONArray playerMentios = (JSONArray) mentios.get(uuid.toString()); - if (playerMentios == null) - { - playerMentios = new JSONArray(); - playerMentios.add(player.getName()); - playerMentios.add(player.getDisplayName().split(" ")[0].replaceAll("§[0-9a-fk-or]", "")); - } - for (Object raw : playerMentios) - { - String mentio = (String) raw; - Utils.sendMessage(sender, "&2 -> &e", mentio, '&'); - } - return true; - } - - @SuppressWarnings("unchecked") - @EventHandler(priority = EventPriority.MONITOR) - public void onPlayerChat(AsyncPlayerChatEvent event) - { - if (event.isCancelled()) - return; - for (Player player : event.getRecipients()) - { - UUID uuid = player.getUniqueId(); - JSONArray playerMentios = (JSONArray) mentios.get(uuid.toString()); - if (playerMentios == null) - { - playerMentios = new JSONArray(); - playerMentios.add(player.getName()); - playerMentios.add(player.getDisplayName().split(" ")[0].replaceAll("§[0-9a-fk-o]", "")); - } - for (Object raw : playerMentios) - { - String mentio = (String) raw; - if (event.getMessage().toLowerCase().contains(mentio.toLowerCase())) - { - event.getRecipients().remove(player); - String temp = event.getMessage().replaceAll("(?i)" + Pattern.quote(mentio) + ".*", ""); - String lastColorCodes = "§r"; - char lastChar = ' '; - for (char c : temp.toCharArray()) - { - if (lastChar == '§') - lastColorCodes += "§" + c; - lastChar = c; - } - Utils.sendMessage(player, "", - event.getFormat().replace("%1$s", event.getPlayer().getDisplayName()).replace("%2$s", - event.getMessage().replaceFirst("(?i)(" + Pattern.quote(mentio) + ")([^ ]*)", - "§a§o$1$2" + lastColorCodes))); - player.playSound(player.getLocation(), Sound.ENTITY_CHICKEN_EGG, 1, 1); - return; - } - } - } - } - - private void loadMentios() - { - mentios = JsonManager.getObject(mentioLocation); - if (mentios == null) - mentios = new JSONObject(); - } - - private void saveMentios() - { - JsonManager.save(mentios, mentioLocation); - } - - // @noformat - @Override - public String getCommandString() - { - return "command mentio {\n" + - " add [string:trigger] {\n" + - " help Triggers you when the trigger gets said.;\n" + - " run addmentio trigger;\n" + - " }\n" + - " delete [string:trigger] {\n" + - " help Deletes a mentio.;\n" + - " run delmentio trigger;\n" + - " }\n" + - " list {\n" + - " help Lists your mentios.;\n" + - " run listmentios;\n" + - " }\n" + - " perm utils.mentio;\n" + - " type player;\n" + - "}"; - } - // @format -} diff --git a/src/com/redstoner/modules/misc/Misc.java b/src/com/redstoner/modules/misc/Misc.java deleted file mode 100644 index 5750e19..0000000 --- a/src/com/redstoner/modules/misc/Misc.java +++ /dev/null @@ -1,212 +0,0 @@ -package com.redstoner.modules.misc; - -import org.bukkit.Bukkit; -import org.bukkit.Material; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.block.BlockFromToEvent; -import org.bukkit.event.player.PlayerJoinEvent; -import org.bukkit.event.player.PlayerTeleportEvent; -import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; - -import com.nemez.cmdmgr.Command; -import com.redstoner.annotations.AutoRegisterListener; -import com.redstoner.annotations.Version; -import com.redstoner.misc.Utils; -import com.redstoner.modules.Module; - -@AutoRegisterListener -@Version(major = 2, minor = 0, revision = 3, compatible = 2) -public class Misc implements Module, Listener -{ - private final String[] sudoBlacklist = new String[] {".?+:?esudo", ".?+:?sudo", ".?+:?script.*", ".?+:?stop", - ".?+:?modules"}; - - @EventHandler - public void onFirstJoin(PlayerJoinEvent event) - { - Player player = event.getPlayer(); - if (!player.hasPlayedBefore()) - { - Utils.broadcast("", "\n&a&lPlease welcome &f" + player.getDisplayName() + " &a<o Redstoner!\n", null, - '&'); - Utils.sendMessage(player, "", " \n \n \n \n \n \n \n \n \n \n \n \n ", '&'); - Utils.sendMessage(player, "", " &4Welcome to the Redstoner Server!", '&'); - Utils.sendMessage(player, "", " &6Before you ask us things, take a quick", '&'); - Utils.sendMessage(player, "", " &6look at &a&nredstoner.com/info", '&'); - Utils.sendMessage(player, "", " \n&6thank you and happy playing ;)", '&'); - Utils.sendMessage(player, "", " \n \n", '&'); - } - Material spawnBlock = player.getLocation().getBlock().getType(); - if (spawnBlock == Material.PORTAL || spawnBlock == Material.ENDER_PORTAL) - { - Utils.sendMessage(player, "", "&4Looks like you spawned in a portal... Let me help you out", '&'); - Utils.sendMessage(player, "", "&6You can use /back if you &nreally&6 want to go back", '&'); - player.teleport(player.getWorld().getSpawnLocation()); - } - } - // Fixes /up 0 grief - // @EventHandler - // public void onPlayerCommand(PlayerCommandPreprocessEvent event) - // { - // String args[] = event.getMessage().split(" "); - // if (args[0].equals("/up") || args[0].equals("/worldedit:up")) - // event.setMessage("/" + event.getMessage()); - // } - - // Disables spectator teleportation - @EventHandler - public void onSpectatorTeleort(PlayerTeleportEvent event) - { - Player player = event.getPlayer(); - if (!event.isCancelled() && event.getCause() == TeleportCause.SPECTATE - && !player.hasPermission("utils.tp.spectate")) - { - event.setCancelled(true); - Utils.sendErrorMessage(event.getPlayer(), null, "Spectator teleportation is disabled!"); - } - } - - // Disables water and lava breaking stuff - @EventHandler - public void onLiquidFlow(BlockFromToEvent event) - { - Material m = event.getToBlock().getType(); - switch (m) - { - case AIR: - case WATER: - case STATIONARY_WATER: - case LAVA: - case STATIONARY_LAVA: - return; - default: - event.setCancelled(true); - } - } - - @Command(hook = "tempadddef") - public boolean tempAddDef(CommandSender sender, String user, String group) - { - return tempAdd(sender, user, group, "604800"); - } - - @Command(hook = "tempadd") - public boolean tempAdd(CommandSender sender, String user, String group, String duration) - { - // Use it to make a proper duration output later. Too lazy rn. - @SuppressWarnings("unused") - int i = 0; - try - { - i = Integer.valueOf(duration); - } - catch (NumberFormatException e) - { - Utils.sendErrorMessage(sender, null, "That is not a valid number!"); - return true; - } - Bukkit.dispatchCommand(sender, "pex user " + user + " group add " + group + " * " + duration); - Utils.sendMessage(sender, null, "Added to group " + group + "for " + duration + " seconds."); - return true; - } - - @Command(hook = "echo") - public boolean echo(CommandSender sender, String text) - { - Utils.sendMessage(sender, "", "&f" + text, '&'); - return true; - } - - @Command(hook = "me") - public boolean me(CommandSender sender, String text) - { - String name; - if (sender instanceof Player) - name = ((Player) sender).getDisplayName(); - else - name = "§9" + sender.getName(); - if (sender.hasPermission("essentials.chat.color")) - Utils.broadcast(" §7- " + name + " §7⇦ ", text, null, '&'); - else - Utils.broadcast(" §7- " + name + " §7⇦ ", text, null); - return true; - } - - @Command(hook = "sudo") - public boolean sudo(CommandSender sender, String name, String command) - { - CommandSender target; - if (name.equalsIgnoreCase("console")) - { - target = Bukkit.getConsoleSender(); - } - else - target = Bukkit.getPlayer(name); - if (target == null) - { - Utils.sendErrorMessage(sender, null, "That player couldn't be found!"); - return true; - } - if (command.startsWith("/") || target.equals(Bukkit.getConsoleSender())) - { - String[] args = command.split(" "); - for (String regex : sudoBlacklist) - { - if (args[0].matches(regex)) - { - Utils.sendErrorMessage(sender, null, "You can't sudo anyone into using that command!"); - return true; - } - } - Bukkit.dispatchCommand(target, command.replaceFirst("/", "")); - Utils.sendMessage(sender, null, "Sudoed " + name + " into running " + command); - } - else - { - ((Player) target).chat(command); - Utils.sendMessage(sender, null, "Sudoed " + name + " into saying " + command); - } - return true; - } - - // @noformat - @Override - public String getCommandString() - { - return "command tempadd {\n" + - " perm pex;\n" + - " [string:user] [string:group] {\n" + - " help Adds a user to a group for 1w.;\n" + - " run tempadddef user group;\n" + - " }\n" + - " [string:user] [string:group] [string:duration] {\n" + - " help Adds a user to a group for a specified duration.;\n" + - " run tempadd user group duration;\n" + - " }\n" + - "}\n" + - "command echo {\n" + - " [string:text...] {\n" + - " help Echoes back to you.;\n" + - " run echo text;\n" + - " }\n" + - "}\n" + - "command me {\n" + - " perm utils.me;\n" + - " [string:text...] {\n" + - " help /me's in chat.;\n" + - " run me text;\n" + - " }\n" + - "}\n" + - "command sudo {\n" + - " perm utils.sudo;\n" + - " [string:name] [string:command...] {\n" + - " help Sudo'es another user (or console);\n" + - " run sudo name command;\n" + - " }\n" + - "}"; - } - // @format -} diff --git a/src/com/redstoner/modules/motd/Motd.java b/src/com/redstoner/modules/motd/Motd.java deleted file mode 100644 index 95e578f..0000000 --- a/src/com/redstoner/modules/motd/Motd.java +++ /dev/null @@ -1,71 +0,0 @@ -package com.redstoner.modules.motd; - -import org.bukkit.Bukkit; -import org.bukkit.command.CommandSender; -import org.bukkit.event.EventHandler; -import org.bukkit.event.server.ServerListPingEvent; - -import com.nemez.cmdmgr.Command; -import com.redstoner.annotations.AutoRegisterListener; -import com.redstoner.annotations.Version; -import com.redstoner.misc.Utils; -import com.redstoner.modules.Module; - -@AutoRegisterListener -@Version(major = 2, minor = 0, revision = 1, compatible = 2) -public class Motd implements Module -{ - private String default_motd, motd; - - @Command(hook = "setmotd") - public boolean setMotd(CommandSender sender, String motd) - { - if (motd.equals("--reset")) - this.motd = default_motd; - else - this.motd = motd; - Utils.sendMessage(sender, null, "The new motd is:\n" + this.motd, '&'); - return true; - } - - @Command(hook = "getmotd") - public boolean getMotd(CommandSender sender) - { - Utils.sendMessage(sender, null, motd, '&'); - return true; - } - - @EventHandler - public void onServerPing(ServerListPingEvent event) - { - event.setMotd(motd); - } - - @Override - public boolean onEnable() - { - default_motd = Bukkit.getMotd(); - return true; - } - - // @noformat - @Override - public String getCommandString() - { - return "command setmotd {\n" + - " [string:motd...] {\n" + - " help Sets the motd. Use --reset to reset to default;\n" + - " run setmotd motd;\n" + - " perm utils.setmotd;" + - " }\n" + - "}\n" + - "command getmotd {\n" + - " [empty] {\n" + - " help Returns the motd;\n" + - " run getmotd;\n" + - " perm utils.getmotd;" + - " }\n" + - "}"; - } - // @format -} diff --git a/src/com/redstoner/modules/nametags/Nametags.java b/src/com/redstoner/modules/nametags/Nametags.java deleted file mode 100644 index 8733df1..0000000 --- a/src/com/redstoner/modules/nametags/Nametags.java +++ /dev/null @@ -1,123 +0,0 @@ -package com.redstoner.modules.nametags; - -import org.bukkit.Bukkit; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; -import org.bukkit.event.player.PlayerJoinEvent; -import org.bukkit.event.server.ServerCommandEvent; - -import com.nemez.cmdmgr.Command; -import com.redstoner.annotations.AutoRegisterListener; -import com.redstoner.annotations.Version; -import com.redstoner.misc.Utils; -import com.redstoner.modules.Module; - -@AutoRegisterListener -@Version(major = 2, minor = 0, revision = 1, compatible = 2) -public class Nametags implements Module, Listener -{ - - @EventHandler - public void onPlayerJoin(PlayerJoinEvent event) - { - sortSpecific(event.getPlayer()); - } - - @EventHandler - public void commandPreprocessEvent(PlayerCommandPreprocessEvent event) - { - if (event.getMessage().contains("promote") || event.getMessage().contains("demote") - || event.getMessage().matches("pex user .* group (set|add|leave)")) - { - String[] args = event.getMessage().split(" "); - for (String s : args) - { - Player p = Bukkit.getPlayer(s); - if (p != null) - sortSpecific(p); - } - } - } - - @EventHandler - public void consoleCommand(ServerCommandEvent event) - { - if (event.getCommand().contains("promote") || event.getCommand().contains("demote") - || event.getCommand().matches("pex user .* group (set|add|leave)")) - { - String[] args = event.getCommand().split(" "); - for (String s : args) - { - Player p = Bukkit.getPlayer(s); - if (p != null) - sortSpecific(p); - } - } - } - - @Command(hook = "sort") - public boolean sortAll(CommandSender sender) - { - for (Player p : Bukkit.getOnlinePlayers()) - sortSpecific(p); - Utils.sendMessage(sender, null, "Sorted tab for ya!"); - return true; - } - - @Command(hook = "sortspecific") - public boolean sortSpecific(CommandSender sender, String player) - { - Player p = Bukkit.getPlayer(player); - if (p == null) - { - Utils.sendErrorMessage(sender, null, "That player couldn't be found!"); - return true; - } - else - sortSpecific(p); - Utils.sendMessage(sender, null, "Sorted §e" + player + " §7for ya!"); - return true; - } - - public void sortSpecific(Player player) - { - Bukkit.dispatchCommand(Bukkit.getConsoleSender(), - "scoreboard teams join " + getTeam(player) + " " + player.getName()); - } - - private String getTeam(Player player) - { - String[] teams = new String[] {"admin", "mod", "trainingmod", "trusted", "builder", "member", "visitor"}; - char prefix = 'a'; - for (String team : teams) - { - if (player.hasPermission("group." + team)) - { - return prefix + "_" + team; - } - prefix++; - } - return "g_visitor"; - } - - // @noformat - @Override - public String getCommandString() - { - return "command tab {\n" + - " sort {\n" + - " help Resorts the entirety of tab.;\n" + - " run sort;\n" + - " }\n" + - " sort [string:player] {\n" + - " help Resorts one player.;\n" + - " run sortspecific player;\n" + - " }\n" + - " perm utils.tab.admin;\n" + - "}"; - } - // @format -} diff --git a/src/com/redstoner/modules/naming/Naming.java b/src/com/redstoner/modules/naming/Naming.java deleted file mode 100644 index c117b4b..0000000 --- a/src/com/redstoner/modules/naming/Naming.java +++ /dev/null @@ -1,120 +0,0 @@ -package com.redstoner.modules.naming; - -import java.util.ArrayList; -import java.util.List; - -import org.bukkit.command.CommandSender; -import org.bukkit.craftbukkit.v1_11_R1.entity.CraftPlayer; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.ItemMeta; - -import com.nemez.cmdmgr.Command; -import com.redstoner.annotations.Version; -import com.redstoner.misc.Utils; -import com.redstoner.modules.Module; - -import net.md_5.bungee.api.ChatColor; -import net.minecraft.server.v1_11_R1.BlockPosition; -import net.minecraft.server.v1_11_R1.ChatMessage; -import net.minecraft.server.v1_11_R1.ContainerAnvil; -import net.minecraft.server.v1_11_R1.EntityHuman; -import net.minecraft.server.v1_11_R1.EntityPlayer; -import net.minecraft.server.v1_11_R1.PacketPlayOutOpenWindow; - -@Version(major = 2, minor = 0, revision = 1, compatible = 2) -public class Naming implements Module -{ - @Command(hook = "anvil") - public void anvil(CommandSender sender) - { - EntityPlayer p = ((CraftPlayer) sender).getHandle(); - AnvilContainer container = new AnvilContainer(p); - int c = p.nextContainerCounter(); - p.playerConnection.sendPacket( - new PacketPlayOutOpenWindow(c, "minecraft:anvil", new ChatMessage("Repairing", new Object[] {}), 0)); - p.activeContainer = container; - p.activeContainer.windowId = c; - p.activeContainer.addSlotListener(p); - } - - @Command(hook = "name") - public void name(CommandSender sender, String name) - { - name = ChatColor.translateAlternateColorCodes('&', name); - ItemStack item = ((Player) sender).getInventory().getItemInMainHand(); - ItemMeta meta = item.getItemMeta(); - if (meta == null) - { - Utils.sendErrorMessage(sender, null, "You can not rename that item!"); - return; - } - meta.setDisplayName(name); - item.setItemMeta(meta); - Utils.sendMessage(sender, null, "Name set to " + name); - } - - @Command(hook = "lore") - public void lore(CommandSender sender, String name) - { - List lore = new ArrayList(); - name = ChatColor.translateAlternateColorCodes('&', name); - lore.add(name); - ItemStack item = ((Player) sender).getInventory().getItemInMainHand(); - ItemMeta meta = item.getItemMeta(); - if (meta == null) - { - Utils.sendErrorMessage(sender, null, "You can not change the lore of that item!"); - return; - } - meta.setLore(lore); - item.setItemMeta(meta); - item.getItemMeta().setLore(lore); - Utils.sendMessage(sender, null, "Lore set to " + name); - } - - public class AnvilContainer extends ContainerAnvil - { - public AnvilContainer(EntityHuman entity) - { - super(entity.inventory, entity.world, new BlockPosition(0, 0, 0), entity); - } - - @Override - public boolean a(EntityHuman entityhuman) - { - return true; - } - } - - // @noformat - @Override - public String getCommandString() - { - return "command anvil {\n" + - " [empty] {\n" + - " run anvil;\n" + - " type player;\n" + - " help Opens anvil GUI.;\n" + - " perm utils.anvil;\n" + - " }\n" + - "}\n" + - "command name {\n" + - " [string:name...] {\n" + - " run name name;\n" + - " type player;\n" + - " help Names item in hand.;\n" + - " perm utils.name;\n" + - " }\n" + - "}\n" + - "command lore {\n" + - " [string:name...] {\n" + - " run lore name;\n" + - " type player;\n" + - " help Adds lore to item in hand.;\n" + - " perm utils.lore;\n" + - " }\n" + - "}"; - } - // @format -} diff --git a/src/com/redstoner/modules/pmtoggle/Pmtoggle.java b/src/com/redstoner/modules/pmtoggle/Pmtoggle.java deleted file mode 100644 index c5df720..0000000 --- a/src/com/redstoner/modules/pmtoggle/Pmtoggle.java +++ /dev/null @@ -1,100 +0,0 @@ -package com.redstoner.modules.pmtoggle; - -import java.util.HashMap; -import java.util.Map.Entry; - -import org.bukkit.Bukkit; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.player.AsyncPlayerChatEvent; -import org.bukkit.event.player.PlayerQuitEvent; - -import com.nemez.cmdmgr.Command; -import com.nemez.cmdmgr.Command.AsyncType; -import com.redstoner.annotations.AutoRegisterListener; -import com.redstoner.annotations.Version; -import com.redstoner.misc.Utils; -import com.redstoner.modules.Module; - -@AutoRegisterListener -@Version(major = 2, minor = 0, revision = 1, compatible = 2) -public class Pmtoggle implements Module, Listener -{ - HashMap toggles = new HashMap(); - - @Command(hook = "pmtoggle_off", async = AsyncType.ALWAYS) - public boolean pmtoggle_off(CommandSender sender) - { - Player player = (Player) sender; - if (toggles.remove(player) != null) - Utils.sendMessage(player, null, "Your pmtoggle was removed!"); - else - Utils.sendMessage(player, null, "You didn't have pmtoggle enabled! Use /pmtoggle to enabled it."); - return true; - } - - @Command(hook = "pmtoggle", async = AsyncType.ALWAYS) - public boolean pmtoggle(CommandSender sender, String player) - { - Player p = Bukkit.getPlayer(player); - if (p == null && !player.equals("CONSOLE")) - { - Utils.sendMessage(sender, null, "§cThat player couldn't be found!"); - return true; - } - toggles.put((Player) sender, player); - Utils.sendMessage(sender, null, "Locked your pmtoggle onto §6" + player + "§7."); - return true; - } - - @EventHandler - public void onPlayerChat(AsyncPlayerChatEvent event) - { - Player player = event.getPlayer(); - if (toggles.containsKey(player)) - { - Bukkit.dispatchCommand(player, "m " + toggles.get(player) + " " + event.getMessage()); - event.setCancelled(true); - } - } - - @EventHandler - public void onPlayerQuit(PlayerQuitEvent event) - { - toggles.remove(event.getPlayer()); - String player = event.getPlayer().getName(); - if (toggles.containsValue(player)) - { - for (Entry entry : toggles.entrySet()) - { - if (entry.getValue().equals(player)) - { - toggles.remove(player); - Utils.sendMessage(entry.getKey(), null, - "We removed your pmtoggle for &6" + player + "&7, as they left the game.", '&'); - } - } - } - } - - // @noformat - @Override - public String getCommandString() - { - return "command pmtoggle {\n" + - " [empty] {\n" + - " help Turns off your toggle.;\n" + - " type player;\n" + - " run pmtoggle_off;\n" + - " }\n" + - " [string:player] {\n" + - " help Turns on your pmtoggle and locks onto .;\n" + - " type player;\n" + - " run pmtoggle player;\n" + - " }\n" + - "}"; - } - // @format -} diff --git a/src/com/redstoner/modules/reports/Reports.java b/src/com/redstoner/modules/reports/Reports.java deleted file mode 100644 index cb1022e..0000000 --- a/src/com/redstoner/modules/reports/Reports.java +++ /dev/null @@ -1,163 +0,0 @@ -package com.redstoner.modules.reports; - -import java.io.File; -import java.text.SimpleDateFormat; -import java.util.Date; - -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.World; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; -import org.json.simple.JSONArray; -import org.json.simple.JSONObject; - -import com.nemez.cmdmgr.Command; -import com.redstoner.annotations.Version; -import com.redstoner.misc.JsonManager; -import com.redstoner.misc.Main; -import com.redstoner.modules.Module; - -import net.md_5.bungee.api.ChatColor; - -/** Report module. Allows reports to be created and handled by staff - * - * @author Redempt */ -@Version(major = 2, minor = 0, revision = 0, compatible = 2) -public class Reports implements Module -{ - private int task = 0; - private JSONArray reports; - private JSONArray archived; - private SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd kk:mm"); - - @Override - public boolean onEnable() - { - reports = JsonManager.getArray(new File(Main.plugin.getDataFolder(), "reports.json")); - archived = JsonManager.getArray(new File(Main.plugin.getDataFolder(), "archived_reports.json")); - if (reports == null) - { - reports = new JSONArray(); - } - if (archived == null) - { - archived = new JSONArray(); - } - // Notify online staff of open reports - task = Bukkit.getScheduler().scheduleSyncRepeatingTask(Main.plugin, () -> - { - if (reports.size() <= 0) - { - return; - } - for (Player player : Bukkit.getOnlinePlayers()) - { - if (player.hasPermission("utils.report")) - { - player.sendMessage(ChatColor.RED + "There are " + ChatColor.YELLOW + reports.size() + ChatColor.RED - + " open reports!"); - } - } - } , 2400, 2400); - return true; - } - - @Override - public void onDisable() - { - // Save reports, cancel notifier task - Bukkit.getScheduler().cancelTask(task); - JsonManager.save(reports, new File(Main.plugin.getDataFolder(), "reports.json")); - JsonManager.save(archived, new File(Main.plugin.getDataFolder(), "archived_reports.json")); - } - - @Override - public String getCommandString() - { - return "command report {" + "[string:message...] {" + "type player;" + "help Report a player or incident;" - + "run report message;" + "}" + "}" + "command rp {" + "perm utils.report;" + "open {" - + "help List all open reports;" + "run report_open;" + "}" + "close [int:id] {" + "help Close a report;" - + "run report_close id;" + "}" + "tp [int:id] {" + "help Teleport to the location of a report;" - + "run report_tp id;" + "type player;" + "}" + "}"; - } - - @Command(hook = "report_tp") - public void tpReport(CommandSender sender, int id) - { - // Check for invalid ID - Player player = (Player) sender; - if (id > reports.size() - 1 || id < 0) - { - sender.sendMessage(ChatColor.RED + "Invalid ID!"); - return; - } - JSONObject report = (JSONObject) reports.get(id); - String loc = (String) report.get("location"); - String[] split = loc.split(";"); - // Location from string - int x = Integer.parseInt(split[0]); - int y = Integer.parseInt(split[1]); - int z = Integer.parseInt(split[2]); - World world = Bukkit.getWorld(split[3]); - Location location = new Location(world, x, y, z); - player.teleport(location); - } - - @SuppressWarnings("unchecked") - @Command(hook = "report_close") - public void closeReport(CommandSender sender, int id) - { - // Check for invalid ID - if (id > reports.size() - 1 || id < 0) - { - sender.sendMessage(ChatColor.RED + "Invalid ID!"); - return; - } - // Move report to archived reports - JSONObject report = (JSONObject) reports.get(id); - reports.remove(id); - archived.add(report); - sender.sendMessage(ChatColor.GREEN + "Report #" + id + " closed!"); - } - - @Command(hook = "report_open") - public void listOpen(CommandSender sender) - { - int i = 0; - for (Object object : reports) - { - JSONObject report = (JSONObject) object; - String message = ""; - message += ChatColor.DARK_GRAY + "[" + ChatColor.YELLOW + i + ChatColor.DARK_GRAY + "]"; - message += "[" + ChatColor.YELLOW + report.get("time") + ChatColor.DARK_GRAY + "] "; - message += ChatColor.DARK_AQUA + "" + report.get("name"); - message += ChatColor.WHITE + ": " + ChatColor.YELLOW + report.get("message"); - sender.sendMessage(message); - i++; - } - if (i == 0) - { - sender.sendMessage(ChatColor.GREEN + "There are no open reports."); - } - } - - @SuppressWarnings("unchecked") - @Command(hook = "report") - public void report(CommandSender sender, String message) - { - Player player = (Player) sender; - // Create report JSONObject - JSONObject report = new JSONObject(); - report.put("name", player.getName()); - report.put("time", dateFormat.format(new Date())); - report.put("message", message); - String loc = ""; - // Location to string - loc += player.getLocation().getBlockX() + ";" + player.getLocation().getBlockY() + ";" - + player.getLocation().getBlockZ() + ";" + player.getLocation().getWorld().getName(); - report.put("location", loc); - reports.add(report); - sender.sendMessage(ChatColor.GREEN + "Report created!"); - } -} diff --git a/src/com/redstoner/modules/saylol/Saylol.java b/src/com/redstoner/modules/saylol/Saylol.java deleted file mode 100644 index a259ac3..0000000 --- a/src/com/redstoner/modules/saylol/Saylol.java +++ /dev/null @@ -1,327 +0,0 @@ -package com.redstoner.modules.saylol; - -import java.io.File; -import java.util.Random; - -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; -import org.json.simple.JSONArray; - -import com.nemez.cmdmgr.Command; -import com.redstoner.annotations.Version; -import com.redstoner.misc.BroadcastFilter; -import com.redstoner.misc.JsonManager; -import com.redstoner.misc.Main; -import com.redstoner.misc.Utils; -import com.redstoner.modules.Module; - -@Version(major = 2, minor = 0, revision = 0, compatible = 2) -public class Saylol implements Module -{ - private long lastLol = 0; - private File lolLocation = new File(Main.plugin.getDataFolder(), "lol.json"); - private JSONArray lols; - - @Override - public boolean onEnable() - { - lols = JsonManager.getArray(lolLocation); - if (lols == null) - lols = new JSONArray(); - return true; - } - - @Override - public void onDisable() - { - saveLols(); - } - - @SuppressWarnings("unchecked") - @Command(hook = "addlol") - public boolean addLol(CommandSender sender, String text) - { - if (lols.contains(text)) - Utils.sendErrorMessage(sender, null, "This lol already exists!"); - else - { - Utils.sendMessage(sender, null, "Successfully added a new lol!"); - lols.add("&e" + text); - saveLols(); - } - return true; - } - - @Command(hook = "dellol") - public boolean delLol(CommandSender sender, int id) - { - if (lols.size() == 0) - { - Utils.sendErrorMessage(sender, null, "There are no lols yet!"); - return true; - } - if (id < 0 || id >= lols.size()) - { - Utils.sendErrorMessage(sender, null, "The ID must be at least 0 and at most " + (lols.size() - 1)); - return true; - } - Utils.sendMessage(sender, null, "Successfully deleted the lol: " + lols.remove(id), '&'); - saveLols(); - return true; - } - - @SuppressWarnings("unchecked") - @Command(hook = "setlol") - public boolean setLol(CommandSender sender, int id, String text) - { - if (lols.size() == 0) - { - Utils.sendErrorMessage(sender, null, "There are no lols yet!"); - return true; - } - if (id < 0 || id >= lols.size()) - { - Utils.sendErrorMessage(sender, null, "The ID must be at least 0 and at most " + (lols.size() - 1)); - return true; - } - Utils.sendMessage(sender, null, "Successfully changed the lol: &e" + lols.get(id) + " &7to: &e" + text, '&'); - lols.set(id, text); - saveLols(); - return true; - } - - @Command(hook = "lolid") - public boolean lolId(CommandSender sender, int id) - { - if (lols.size() == 0) - { - Utils.sendErrorMessage(sender, null, "There are no lols yet!"); - return true; - } - long time = System.currentTimeMillis(); - if (time - lastLol < 15000) - { - Utils.sendErrorMessage(sender, null, - "You can't use saylol for another " + (14 - (int) Math.ceil((time - lastLol) / 1000)) + "s."); - return true; - } - if (id < 0 || id >= lols.size()) - { - Utils.sendErrorMessage(sender, null, "The ID must be at least 0 and at most " + (lols.size() - 1)); - return true; - } - String name; - if (sender instanceof Player) - name = ((Player) sender).getDisplayName(); - else - name = "&9" + sender.getName(); - Utils.broadcast("&8[&blol&8] ", name + "&8: &e" + lols.get(id), new BroadcastFilter() - { - @Override - public boolean sendTo(CommandSender recipient) - { - return recipient.hasPermission("utils.lol.see"); - } - }, '&'); - lastLol = time; - return true; - } - - @Command(hook = "saylol") - public boolean saylol(CommandSender sender) - { - if (lols.size() == 0) - { - Utils.sendErrorMessage(sender, null, "There are no lols yet!"); - return true; - } - long time = System.currentTimeMillis(); - if (time - lastLol < 15000) - { - Utils.sendErrorMessage(sender, null, - "You can't use saylol for another " + (14 - (int) Math.ceil((time - lastLol) / 1000)) + "s."); - return true; - } - String name; - if (sender instanceof Player) - name = ((Player) sender).getDisplayName(); - else - name = "&9" + sender.getName(); - Random random = new Random(); - int id = random.nextInt(lols.size()); - Utils.broadcast("&8[&blol&8] ", name + "&8: &e" + lols.get(id), new BroadcastFilter() - { - @Override - public boolean sendTo(CommandSender recipient) - { - return recipient.hasPermission("utils.lol.see"); - } - }, '&'); - lastLol = time; - return true; - } - - @Command(hook = "listlols") - public boolean listLols(CommandSender sender, int page) - { - if (lols.size() == 0) - { - Utils.sendErrorMessage(sender, null, "There are no lols yet!"); - return true; - } - page = page - 1; - int start = page * 10; - int end = start + 10; - int pages = (int) Math.ceil(lols.size() / 10d); - if (start < 0) - { - Utils.sendErrorMessage(sender, null, "Page number too small, must be at least 0!"); - return true; - } - if (start > lols.size()) - { - Utils.sendErrorMessage(sender, null, "Page number too big, must be at most " + pages + "!"); - return true; - } - Utils.sendModuleHeader(sender); - Utils.sendMessage(sender, "", "&ePage " + (page + 1) + "/" + pages + ":", '&'); - for (int i = start; i < end && i < lols.size(); i++) - Utils.sendMessage(sender, "", "&a" + i + "&8: &e" + lols.get(i), '&'); - return true; - } - - @Command(hook = "listlolsdef") - public boolean listLolsDefault(CommandSender sender) - { - return listLols(sender, 1); - } - - @Command(hook = "searchlol") - public boolean search(CommandSender sender, boolean insensitive, String text) - { - Utils.sendModuleHeader(sender); - boolean found = false; - if (insensitive) - { - text = text.toLowerCase(); - for (int i = 0; i < lols.size(); i++) - { - if (((String) lols.get(i)).toLowerCase().contains(text)) - { - Utils.sendMessage(sender, "", "&a" + i + "&8: &e" + lols.get(i), '&'); - found = true; - } - } - } - else - { - for (int i = 0; i < lols.size(); i++) - { - if (((String) lols.get(i)).contains(text)) - { - Utils.sendMessage(sender, "", "&a" + i + "&8: &e" + lols.get(i), '&'); - found = true; - } - } - } - if (!found) - { - Utils.sendMessage(sender, "", "&cCouldn't find any matching lols.", '&'); - } - return true; - } - - @Command(hook = "matchlol") - public boolean match(CommandSender sender, boolean insensitive, String regex) - { - Utils.sendModuleHeader(sender); - boolean found = false; - if (insensitive) - { - regex = regex.toLowerCase(); - for (int i = 0; i < lols.size(); i++) - { - if (((String) lols.get(i)).toLowerCase().matches(regex)) - { - Utils.sendMessage(sender, "", "&a" + i + ": " + lols.get(i), '&'); - found = true; - } - } - } - else - { - for (int i = 0; i < lols.size(); i++) - { - if (((String) lols.get(i)).matches(regex)) - { - Utils.sendMessage(sender, "", "&a" + i + ": " + lols.get(i), '&'); - found = true; - } - } - } - if (!found) - { - Utils.sendMessage(sender, "", "&cCouldn't find any matching lols.", '&'); - } - return true; - } - - public void saveLols() - { - JsonManager.save(lols, lolLocation); - } - - // @noformat - @Override - public String getCommandString() - { - return "command lol {\n" + - " add [string:text...] {\n" + - " help Lols a text.;\n" + - " run addlol text;\n" + - " perm utils.lol.admin;\n" + - " }\n" + - " del [int:id] {\n" + - " help Unlols a lol.;\n" + - " run dellol id;\n" + - " perm utils.lol.admin;\n" + - " }\n" + - " set [int:id] [string:text...] {\n" + - " help Relols a lol.;\n" + - " run setlol id text;\n" + - " perm utils.lol.admin;\n" + - " }\n" + - " id [int:id] {\n" + - " help Lols specifically.;\n" + - " run lolid id;\n" + - " perm utils.lol.id;\n" + - " }\n" + - " list [int:page] {\n" + - " help Shows lols.;\n" + - " run listlols page;\n" + - " perm utils.lol.list;\n" + - " }\n" + - " list {\n" + - " help Shows lols.;\n" + - " run listlolsdef;\n" + - " perm utils.lol.list;\n" + - " }\n" + - " search [flag:-i] [string:text...] {\n" + - " help Search lols.;\n" + - " run searchlol -i text;\n" + - " perm utils.lol.search;\n" + - " }\n" + - " match [flag:-i] [string:regex...] {\n" + - " help Search lols. But better.;\n" + - " run matchlol -i regex;\n" + - " perm utils.lol.match;\n" + - " }\n" + - " [empty] {\n" + - " help Lols.;\n" + - " run saylol;\n" + - " perm utils.lol;\n" + - " }\n" + - "}"; - } - // @format -} diff --git a/src/com/redstoner/modules/scriptutils/Scriptutils.java b/src/com/redstoner/modules/scriptutils/Scriptutils.java deleted file mode 100644 index 9818817..0000000 --- a/src/com/redstoner/modules/scriptutils/Scriptutils.java +++ /dev/null @@ -1,300 +0,0 @@ -package com.redstoner.modules.scriptutils; - -import org.bukkit.Bukkit; -import org.bukkit.command.CommandSender; - -import com.nemez.cmdmgr.Command; -import com.redstoner.annotations.Version; -import com.redstoner.misc.Utils; -import com.redstoner.modules.Module; - -@Version(major = 2, minor = 0, revision = 1, compatible = 2) -public class Scriptutils implements Module -{ - /** Prints Bukkit restart message - * arg 0 timeout - * arg 1 $(whoami); - * arg 2: reason */ - @Command(hook = "script_restart") - public void print_restart(CommandSender sender, String timeout, String name, String reason) - { - Utils.broadcast("", "§2§l=============================================", null); - Utils.broadcast("", "§r", null); - Utils.broadcast("", "§r", null); - Utils.broadcast("", "§9" + name + " is restarting the server.", null); - Utils.broadcast("", "§a§lServer is going to restart in " + timeout + " seconds.", null); - Utils.broadcast("", "§6§l" + reason, null); - Utils.broadcast("", "§r", null); - Utils.broadcast("", "§r", null); - Utils.broadcast("", "§2§l=============================================", null); - } - - /** Prints the Bukkit shut down message - * arg 0 timeout - * arg 1 $(whoami); - * arg 2: reason */ - @Command(hook = "script_stop") - public void print_stop(CommandSender sender, String timeout, String name, String reason) - { - Utils.broadcast("", "§2§l=============================================", null); - Utils.broadcast("", "§r", null); - Utils.broadcast("", "§r", null); - Utils.broadcast("", "§9" + name + " is shutting down the server.", null); - Utils.broadcast("", "§a§lServer is going to shut down in " + timeout + " seconds.", null); - Utils.broadcast("", "§6§l" + reason, null); - Utils.broadcast("", "§r", null); - Utils.broadcast("", "§r", null); - Utils.broadcast("", "§2§l=============================================", null); - } - - /** Prints the shut down abort message */ - @Command(hook = "script_stop_abort") - public void abort_stop(CommandSender sender) - { - Utils.broadcast("", "§4§oShut down has been aborted.", null); - } - - /** Prints the restart abort message */ - @Command(hook = "script_restart_abort") - public void abort_restart(CommandSender sender) - { - Utils.broadcast("", "§4§oRestart has been aborted.", null); - } - - /** Prints the backup started message, saves all worlds and turns off world saving */ - @Command(hook = "script_backup_begin") - public void print_backup_begin(CommandSender sender) - { - Utils.broadcast("", "§4 =§2 Starting backup now.", null); - Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "save-all"); - Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "save-off"); - } - - /** Prints the backup finished message and turns on world saving */ - @Command(hook = "script_backup_end") - public void print_backup_end(CommandSender sender) - { - Utils.broadcast("", "§4 =§2 Backup completed.", null); - Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "save-on"); - } - - /** Prints the backup error message and turns on world saving */ - @Command(hook = "script_backup_error") - public void print_backup_error(CommandSender sender) - { - Utils.broadcast("", "§4 =§c§l Error while backing up!", null); - Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "save-on"); - } - - /** Prints the world trimming started message and starts trimming */ - @Command(hook = "script_trim") - public void print_backup_trim(CommandSender sender) - { - Utils.broadcast("", "§4 =§3 Deleting all chunks beyond border now.", null); - Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "wb Creative trim 1000000 15"); - Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "wb trim confirm"); - } - - /** Prints the trimming finished message - * arg 0 size difference of world - * arg 1: world border trim data */ - @Command(hook = "script_trim_result") - public void print_backup_trim_res(CommandSender sender, String size, String data) - { - Utils.broadcast("", "§4 =§3 Chunk deletion saved " + data + " (§a" + size + "MB§3)", null); - } - - /** Prints the database backup started message and admin-chat warning */ - @Command(hook = "script_backup_database_begin") - public void print_backup_db_begin(CommandSender sender) - { - Utils.broadcast("", "§6 =§2 Starting database backup now.", null); - Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "ac §aLogblock may be unavailable!"); - } - - /** Prints the database dumps compression started message */ - @Command(hook = "script_backup_database_dumps") - public void print_backup_db_dumps(CommandSender sender) - { - Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "ac §aDumps completed, logblock available again."); - Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "ac §aNow compressing dumps, will take a while..."); - } - - /** Prints the database finished message and backup size in admin-chat - * arg 0 size of backup */ - @Command(hook = "script_backup_database_end") - public void print_backup_db_end(CommandSender sender, String size) - { - Utils.broadcast("", "§6 =§2 Database backup completed.", null); - Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "ac §abackup size: §2" + size + "MB§a."); - } - - /** Prints the database backup error message */ - @Command(hook = "script_backup_database_error") - public void print_backup_db_error(CommandSender sender) - { - Utils.broadcast("", "§6 =§c§l Error while backing up database!", null); - } - - /** Prints the database backup abort message */ - @Command(hook = "script_backup_database_abort") - public void print_backup_db_abort(CommandSender sender) - { - Utils.broadcast("", "§6 =§2 Database backup aborted.", null); - } - - /** Prints the spigot update message */ - @Command(hook = "script_spigot_update") - public void print_update(CommandSender sender) - { - Utils.broadcast("", "§9 =§2 A new Spigot version has been downloaded!", null); - Utils.broadcast("", "§9 =§2 Update will be applied after the next reboot.", null); - } - - /** Prints the admin-chat warning for disk is filled - * arg 0 fill percentage */ - @Command(hook = "script_disk_filled") - public void print_disk_filled(CommandSender sender, String percentage) - { - Bukkit.dispatchCommand(Bukkit.getConsoleSender(), - "ac §4§lWARNING:§6 Disk is filled > 96% (" + percentage + "%);"); - Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "ac §4 Server will shut down at 98%!"); - Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "ac §4 Contact an admin §nimmediately§4!"); - } - - /** Saves all worlds, kicks players and shuts down the server - * arg 0: reason */ - @Command(hook = "script_shutdown") - public void shutdown(CommandSender sender, String reason) - { - Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "save-all"); - Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "kickall " + reason); - Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "stop"); - } - - // @noformat - @Override - public String getCommandString() - { - return "command script_restart {\n" + - " [string:timeout] [string:name] [string:reason] {\n" + - " help Prints bukkit restart message;\n" + - " type console;\n" + - " run script_restart timeout name reason;\n" + - " }\n" + - "}\n" + - "command script_stop {\n" + - " [string:timeout] [string:name] [string:reason] {\n" + - " help Prints bukkit shut down message;\n" + - " type console;\n" + - " run script_stop timeout name reason;\n" + - " }\n" + - "}\n" + - "command script_restart_abort {\n" + - " [empty] {\n" + - " help Prints the restart abort message;\n" + - " type console;\n" + - " run script_restart_abort;\n" + - " }\n" + - "}\n" + - "command script_stop_abort {\n" + - " [empty] {\n" + - " help Prints the shut down abort message;\n" + - " type console;\n" + - " run script_stop_abort;\n" + - " }\n" + - "}\n" + - "command script_backup_begin {\n" + - " [empty] {\n" + - " help Prints the backup started message, saves all worlds and turns off world saving;\n" + - " type console;\n" + - " run script_backup_begin;\n" + - " }\n" + - "}\n" + - "command script_backup_end {\n" + - " [empty] {\n" + - " help Prints the backup finished message and turns on world saving;\n" + - " type console;\n" + - " run script_backup_end;\n" + - " }\n" + - "}\n" + - "command script_backup_error {\n" + - " [empty] {\n" + - " help Prints the backup error message and turns on world saving;\n" + - " type console;\n" + - " run script_backup_error;\n" + - " }\n" + - "}\n" + - "command script_trim {\n" + - " [empty] {\n" + - " help Prints the world trimming started message and starts trimming;\n" + - " type console;\n" + - " run script_trim;\n" + - " }\n" + - "}\n" + - "command script_trim_result {\n" + - " [string:size] [string:data...] {\n" + - " help Prints the trimming finished message;\n" + - " type console;\n" + - " run script_trim_result size data;\n" + - " }\n" + - "}\n" + - "command script_backup_database_begin {\n" + - " [empty] {\n" + - " help Prints the database backup started message and admin-chat warning;\n" + - " type console;\n" + - " run script_backup_database_begin;\n" + - " }\n" + - "}\n" + - "command script_backup_database_dumps {\n" + - " [empty] {\n" + - " help Prints the database dumps cmpression started message;\n" + - " type console;\n" + - " run script_backup_database_dumps;\n" + - " }\n" + - "}\n" + - "command script_backup_database_end {\n" + - " [string:size] {\n" + - " help Prints the database finished message and backup size in admin-chat;\n" + - " type console;\n" + - " run script_backup_database_end size;\n" + - " }\n" + - "}\n" + - "command script_backup_database_error {\n" + - " [empty] {\n" + - " help Prints the database backup error message;\n" + - " type console;\n" + - " run script_backup_database_error;\n" + - " }\n" + - "}\n" + - "command script_backup_database_abort {\n" + - " [empty] {\n" + - " help Prints the database backup abort message;\n" + - " type console;\n" + - " run script_backup_database_abort;\n" + - " }\n" + - "}\n" + - "command script_spigot_update {\n" + - " [empty] {\n" + - " help Prints the spigot update message;\n" + - " type console;\n" + - " run script_spigot_update;\n" + - " }\n" + - "}\n" + - "command script_disk_filled {\n" + - " [string:percentage] {\n" + - " help Prints the admin-chat warning for disk is filled;\n" + - " type console;\n" + - " run script_disk_filled percentage;\n" + - " }\n" + - "}\n" + - "command script_shutdown {\n" + - " [string:reason] {\n" + - " help Saves all worlds, kicks players and shuts down the server;\n" + - " type console;\n" + - " run script_shutdown reason;\n" + - " }\n" + - "}"; - } - // @format -} diff --git a/src/com/redstoner/modules/skullclick/SkullClick.java b/src/com/redstoner/modules/skullclick/SkullClick.java deleted file mode 100644 index d4bddb2..0000000 --- a/src/com/redstoner/modules/skullclick/SkullClick.java +++ /dev/null @@ -1,60 +0,0 @@ -package com.redstoner.modules.skullclick; - -import org.bukkit.block.BlockState; -import org.bukkit.block.Skull; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.block.Action; -import org.bukkit.event.player.PlayerInteractEvent; - -import com.redstoner.annotations.AutoRegisterListener; -import com.redstoner.annotations.Version; -import com.redstoner.misc.Utils; -import com.redstoner.modules.Module; - -@Version(major = 1, minor = 0, revision = 1, compatible = 1) -@AutoRegisterListener -public class SkullClick implements Module, Listener -{ - private boolean seen = false; - - @SuppressWarnings("deprecation") - @EventHandler - public void onClick(PlayerInteractEvent e) - { - // For some reason the event gets fired twice, this fixes it. Lol. - if (seen) - { - seen = false; - return; - } - seen = true; - if (e.getAction() == Action.RIGHT_CLICK_BLOCK && !e.isCancelled()) - { - BlockState block = e.getClickedBlock().getState(); - if (block instanceof Skull) - { - Skull skull = (Skull) block; - String owner = skull.getOwner(); - if (owner == null || owner.equals("")) - { - Utils.sendMessage(e.getPlayer(), null, "§eThat skull has no owner."); - } - else - { - Utils.sendMessage(e.getPlayer(), null, "§eThat's " + owner + "."); - } - if (!e.getPlayer().isSneaking()) - { - e.setCancelled(true); - } - } - } - } - - @Override - public String getCommandString() - { - return null; - } -} diff --git a/src/com/redstoner/modules/tag/Tag.java b/src/com/redstoner/modules/tag/Tag.java deleted file mode 100644 index 9685bf5..0000000 --- a/src/com/redstoner/modules/tag/Tag.java +++ /dev/null @@ -1,167 +0,0 @@ -package com.redstoner.modules.tag; - -import java.io.File; -import java.util.UUID; - -import org.bukkit.Bukkit; -import org.bukkit.OfflinePlayer; -import org.bukkit.command.CommandSender; -import org.json.simple.JSONArray; -import org.json.simple.JSONObject; - -import com.nemez.cmdmgr.Command; -import com.nemez.cmdmgr.Command.AsyncType; -import com.redstoner.annotations.Version; -import com.redstoner.misc.JsonManager; -import com.redstoner.misc.Main; -import com.redstoner.misc.Utils; -import com.redstoner.modules.Module; - -@Version(major = 2, minor = 0, revision = 0, compatible = 2) -public class Tag implements Module -{ - private File tagLocation = new File(Main.plugin.getDataFolder(), "tag.json"); - private JSONObject tags; - - @Override - public boolean onEnable() - { - tags = JsonManager.getObject(tagLocation); - if (tags == null) - tags = new JSONObject(); - return true; - } - - @Override - public void onDisable() - { - saveTags(); - } - - @SuppressWarnings({"deprecation", "unchecked"}) - @Command(hook = "addtag", async = AsyncType.ALWAYS) - public boolean addTag(CommandSender sender, String name, String tag) - { - OfflinePlayer player = Bukkit.getOfflinePlayer(name); - if (player == null) - { - Utils.sendErrorMessage(sender, null, "That player doesn't exist!"); - return true; - } - Utils.sendModuleHeader(sender); - UUID uuid = player.getUniqueId(); - JSONArray tagArray; - if (tags.containsKey(uuid.toString())) - tagArray = (JSONArray) tags.get(uuid.toString()); - else - tagArray = new JSONArray(); - tagArray.add(tag); - if (!tags.containsKey(uuid.toString())) - tags.put(uuid.toString(), tagArray); - Utils.sendMessage(sender, null, "Successfully added note &e" + tag + " &7to player &e" + name + "&7!", '&'); - saveTags(); - return true; - } - - @SuppressWarnings("deprecation") - @Command(hook = "deltag", async = AsyncType.ALWAYS) - public boolean delTag(CommandSender sender, String name, int id) - { - if (id < 1) - { - Utils.sendErrorMessage(sender, null, "The ID you entered is too small, it must be at least 1!"); - return true; - } - OfflinePlayer player = Bukkit.getOfflinePlayer(name); - if (player == null) - { - Utils.sendErrorMessage(sender, null, "That player doesn't exist!"); - return true; - } - UUID uuid = player.getUniqueId(); - if (!tags.containsKey(uuid.toString())) - { - Utils.sendMessage(sender, null, "&eThere are no notes about that player.", '&'); - return true; - } - JSONArray tagArray = (JSONArray) tags.get(uuid.toString()); - int size = tagArray.size(); - if (size == 0) - { - Utils.sendErrorMessage(sender, null, - "Empty entry found! You might consider running a database cleanup, contact an admin to do this."); - Utils.log("Found empty tag entry. Database cleanup is recommended."); - return true; - } - if (id > size) - { - Utils.sendErrorMessage(sender, null, "The number you entered is too big! It must be at most " + size + "!"); - return true; - } - Utils.sendMessage(sender, null, "Successfully removed note: &e" + tagArray.remove(id - 1), '&'); - if (tagArray.size() == 0) - tags.remove(uuid.toString()); - saveTags(); - return true; - } - - @SuppressWarnings("deprecation") - @Command(hook = "checktag", async = AsyncType.ALWAYS) - public boolean checkTags(CommandSender sender, String name) - { - OfflinePlayer player = Bukkit.getOfflinePlayer(name); - if (player == null) - { - Utils.sendErrorMessage(sender, null, "That player doesn't exist!"); - return true; - } - Utils.sendModuleHeader(sender); - UUID uuid = player.getUniqueId(); - if (!tags.containsKey(uuid.toString())) - { - Utils.sendMessage(sender, "", "&eThere are no notes about that player.", '&'); - return true; - } - JSONArray tagArray = (JSONArray) tags.get(uuid.toString()); - int size = tagArray.size(); - Utils.sendMessage(sender, "", "There are " + size + " notes about this player:"); - if (size == 0) - { - tags.remove(uuid.toString()); - saveTags(); - return true; - } - for (int i = 0; i < size; i++) - Utils.sendMessage(sender, "", "&a" + (i + 1) + "&8: &e" + tagArray.get(i), '&'); - return true; - } - - public void saveTags() - { - JsonManager.save(tags, tagLocation); - } - - // @noformat - @Override - public String getCommandString() - { - return "command tag {\n" + - " add [string:player] [string:tag...] {\n" + - " help Tags a player.;\n" + - " run addtag player tag;\n" + - " perm utils.tag;\n" + - " }\n" + - " del [string:player] [int:id] {\n" + - " help Removes a tag.;\n" + - " run deltag player id;\n" + - " perm utils.tag;\n" + - " }\n" + - " check [string:player] {\n" + - " help Lists all tags of a player.;\n" + - " run checktag player;\n" + - " perm utils.tag;\n" + - " }\n" + - "}"; - } - // @format -} diff --git a/src/com/redstoner/modules/vanish/Vanish.java b/src/com/redstoner/modules/vanish/Vanish.java deleted file mode 100644 index d7eb372..0000000 --- a/src/com/redstoner/modules/vanish/Vanish.java +++ /dev/null @@ -1,243 +0,0 @@ -package com.redstoner.modules.vanish; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map.Entry; -import java.util.UUID; - -import org.bukkit.Bukkit; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; -import org.bukkit.event.player.PlayerJoinEvent; -import org.bukkit.event.player.PlayerQuitEvent; - -import com.nemez.cmdmgr.Command; -import com.redstoner.annotations.AutoRegisterListener; -import com.redstoner.annotations.Version; -import com.redstoner.misc.Utils; -import com.redstoner.modules.Module; - -@AutoRegisterListener -@Version(major = 2, minor = 0, revision = 3, compatible = 2) -public class Vanish implements Module, Listener -{ - private ArrayList vanished = new ArrayList(); - private HashMap> vanishOthers = new HashMap>(); - - @Command(hook = "vanish") - public boolean vanish(CommandSender sender) - { - UUID uid = ((Player) sender).getUniqueId(); - if (vanished.contains(uid)) - { - vanished.remove(uid); - Utils.sendMessage(sender, null, "You are no longer vanished!"); - unvanishPlayer((Player) sender); - } - else - { - vanished.add(uid); - Utils.sendMessage(sender, null, "You are now vanished!"); - vanishPlayer((Player) sender); - } - return true; - } - - @Command(hook = "vanish_on") - public boolean vanishOn(CommandSender sender) - { - UUID uid = ((Player) sender).getUniqueId(); - if (vanished.contains(uid)) - Utils.sendMessage(sender, null, - "You were already vanished, however we refreshed the vanish for you just to be sure!"); - else - { - vanished.add(uid); - Utils.sendMessage(sender, null, "You are now vanished!"); - } - vanishPlayer((Player) sender); - return true; - } - - @Command(hook = "vanish_off") - public boolean vanishOff(CommandSender sender) - { - UUID uid = ((Player) sender).getUniqueId(); - if (!vanished.contains(uid)) - Utils.sendMessage(sender, null, - "You were not vanished, however we refreshed the vanish for you just to be sure!"); - else - { - vanished.remove(uid); - Utils.sendMessage(sender, null, "You are no longer vanished!"); - } - unvanishPlayer((Player) sender); - return true; - } - - @Command(hook = "vanish_other") - public boolean vanishOther(CommandSender sender, String name) - { - Player player = Bukkit.getPlayer(name); - if (player == null) - { - Utils.sendMessage(sender, null, "&cPlayer &6" + name + " &ccould not be found!", '&'); - return true; - } - UUID uid = player.getUniqueId(); - if (player.hasPermission("utils.vanish")) - { - if (vanished.contains(uid)) - { - vanished.remove(uid); - Utils.sendMessage(sender, null, "Successfully unvanished player &6" + name, '&'); - Utils.sendMessage(player, null, "You are no longer vanished!"); - } - else - { - vanished.add(uid); - Utils.sendMessage(sender, null, "Successfully vanished player &6" + name, '&'); - Utils.sendMessage(player, null, "You are now vanished!"); - } - return true; - } - for (Entry> entry : vanishOthers.entrySet()) - { - if (entry.getValue().contains(uid)) - { - entry.getValue().remove(uid); - Utils.sendMessage(sender, null, "Successfully unvanished player &6" + name, '&'); - Utils.sendMessage(player, null, "You are no longer vanished!"); - if (entry.getValue().size() == 0) - vanishOthers.remove(entry.getKey()); - return true; - } - } - UUID uuid = ((Player) sender).getUniqueId(); - ArrayList toAddTo = vanishOthers.get(uuid); - if (toAddTo == null) - toAddTo = new ArrayList(); - toAddTo.add(uid); - vanishOthers.put(uuid, toAddTo); - Utils.sendMessage(sender, null, "Successfully vanished player &6" + name, '&'); - Utils.sendMessage(player, null, "You are now vanished!"); - return true; - } - - @EventHandler(priority = EventPriority.MONITOR) - public void onPlayerJoin(PlayerJoinEvent event) - { - Player player = event.getPlayer(); - if (vanished.contains(player.getUniqueId())) - { - for (Player p : Bukkit.getOnlinePlayers()) - { - if (!p.hasPermission("utils.vanish")) - p.hidePlayer(player); - } - event.setJoinMessage(null); - } - if (player.hasPermission("utils.vanish")) - return; - for (UUID uid : vanished) - { - Player p = Bukkit.getPlayer(uid); - if (p == null) - continue; - player.hidePlayer(p); - } - for (Entry> entry : vanishOthers.entrySet()) - { - for (UUID uid : entry.getValue()) - { - Player p = Bukkit.getPlayer(uid); - if (p == null) - continue; - player.hidePlayer(p); - } - } - } - - @EventHandler(priority = EventPriority.MONITOR) - public void onPlayerLeave(PlayerQuitEvent event) - { - Player player = event.getPlayer(); - UUID uid = player.getUniqueId(); - if (vanished.contains(player.getUniqueId())) - { - event.setQuitMessage(null); - } - if (vanishOthers.containsKey(uid)) - { - ArrayList toUnvanish = vanishOthers.remove(uid); - for (UUID uuid : toUnvanish) - { - Player p = Bukkit.getPlayer(uuid); - if (p != null) - unvanishPlayer(p); - } - } - boolean wasVanished = false; - for (Entry> entry : vanishOthers.entrySet()) - { - if (entry.getValue().contains(uid)) - { - entry.getValue().remove(uid); - wasVanished = true; - break; - } - } - if (wasVanished) - unvanishPlayer(player); - } - - private void vanishPlayer(Player player) - { - for (Player p : Bukkit.getOnlinePlayers()) - { - if (!p.hasPermission("utils.vanish")) - p.hidePlayer(player); - } - } - - private void unvanishPlayer(Player player) - { - for (Player p : Bukkit.getOnlinePlayers()) - p.showPlayer(player); - } - - // @noformat - @Override - public String getCommandString() - { - return "command vanish {\n" + - " [empty] {\n" + - " help Toggles your vanish status.;\n" + - " type player;\n" + - " run vanish;\n" + - " perm utils.vanish;\n" + - " }\n" + - " on {\n" + - " help Turns your vanish on.;\n" + - " type player;\n" + - " run vanish_on;\n" + - " perm utils.vanish;\n" + - " }\n" + - " off {\n" + - " help Turns your vanish off.;\n" + - " type player;\n" + - " run vanish_off;\n" + - " perm utils.vanish;\n" + - " }\n" + - " [string:name] {\n" + - " help Toggles someone elses vanish;\n" + - " run vanish_other name;\n" + - " perm utils.vanishother;\n" + - " }\n" + - "}"; - } - // @format -} diff --git a/src/com/redstoner/modules/warn/Warn.java b/src/com/redstoner/modules/warn/Warn.java deleted file mode 100644 index 53202a1..0000000 --- a/src/com/redstoner/modules/warn/Warn.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.redstoner.modules.warn; - -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import com.nemez.cmdmgr.Command; -import com.redstoner.annotations.Version; -import com.redstoner.misc.Utils; -import com.redstoner.modules.Module; - -@Version(major = 2, minor = 0, revision = 1, compatible = 2) -public class Warn implements Module -{ - @Command(hook = "warn") - public void warn_normal(CommandSender sender) - { - String name = ((Player) sender).getDisplayName(); - Utils.broadcast(null, "§2Lag incoming! - §9" + name, null); - } - - @Command(hook = "warnp") - public void warn_possible(CommandSender sender) - { - String name = ((Player) sender).getDisplayName(); - Utils.broadcast(null, "§2Possible lag incoming! - §9" + name, null); - } - - // @noformat - @Override - public String getCommandString() - { - return "command warn {\n" + - " [empty] {\n" + - " run warn;\n" + - " type player;\n" + - " help Warns other players about definite lag;\n" + - " perm utils.warn;\n" + - " }\n" + - "}\n" + - "\n" + - "command warnp {\n" + - " [empty] {\n" + - " run warnp;\n" + - " type player;\n" + - " help Warns other players about possible lag;\n" + - " perm utils.warn;\n" + - " }\n" + - "}"; - } - //@format -} diff --git a/src/com/redstoner/modules/webtoken/WebToken.java b/src/com/redstoner/modules/webtoken/WebToken.java deleted file mode 100644 index 0418a38..0000000 --- a/src/com/redstoner/modules/webtoken/WebToken.java +++ /dev/null @@ -1,226 +0,0 @@ -package com.redstoner.modules.webtoken; - -import java.io.IOException; -import java.util.Random; -import java.util.UUID; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.bukkit.ChatColor; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; -import org.json.simple.parser.ParseException; - -import com.nemez.cmdmgr.Command; -import com.redstoner.annotations.Version; -import com.redstoner.misc.Utils; -import com.redstoner.misc.mysql.Config; -import com.redstoner.misc.mysql.MysqlHandler; -import com.redstoner.misc.mysql.elements.ConstraintOperator; -import com.redstoner.misc.mysql.elements.MysqlConstraint; -import com.redstoner.misc.mysql.elements.MysqlDatabase; -import com.redstoner.misc.mysql.elements.MysqlTable; -import com.redstoner.modules.Module; - -@Version(major = 2, minor = 0, revision = 3, compatible = 2) -public class WebToken implements Module -{ - private static final int TOKEN_LENGTH = 6; - private static final String CONSONANTS = "bcdfghjklmnpqrstvwxyz"; - private static final String VOWELS = "aeiou"; - private MysqlTable table; - - @Override - public boolean onEnable() - { - Config config; - try - { - config = Config.getConfig("WebToken.json"); - } - catch (IOException | ParseException e1) - { - e1.printStackTrace(); - return false; - } - if (config == null || !config.containsKey("database") || !config.containsKey("table")) - { - Utils.error("Could not load the WebToken config file, disabling!"); - config.put("database", "redstoner"); - config.put("table", "webtoken"); - return false; - } - try - { - MysqlDatabase database = MysqlHandler.INSTANCE.getDatabase(config.get("database") + "?autoReconnect=true"); - table = database.getTable(config.get("table")); - } - catch (NullPointerException e) - { - Utils.error("Could not use the WebToken config, disabling!"); - return false; - } - return true; - } - - private String getNextId() throws Exception - { - Object[] results = table.get("select id from register_tokens order by id desc limit 1;"); - if (results[0] instanceof Integer) - { - return ((int) results[0]) + 1 + ""; - } - else if (results[0] instanceof String) - { - int id = Integer.valueOf((String) results[0]); - return id + 1 + ""; - } - else - { - throw new Exception("Token query returned invalid result!"); - } - } - - private String query(String emailOrToken, UUID uuid) throws Exception - { - if (!(emailOrToken.equals("token") && emailOrToken.equals("email"))) - { - throw new Exception("Invalid database query: " + emailOrToken); - } - Object[] results = table.get(emailOrToken, - new MysqlConstraint("uuid", ConstraintOperator.EQUAL, uuid.toString().replaceAll("-", ""))); - if (results instanceof String[]) - { - String[] tokenResults = (String[]) results; - if (tokenResults.length == 1) - { - return tokenResults[0]; - } - else - { - return null; - } - } - else - { - throw new Exception("Token query returned invalid result!"); - } - } - - private boolean match(String string, String regex) - { - Pattern pattern = Pattern.compile(regex); - Matcher matcher = pattern.matcher(string); - return matcher.find(); - } - - private void printToken(Player player, String email, String token) - { - Utils.sendModuleHeader(player); - Utils.sendMessage(player, "", "§aEmail: " + email); - Utils.sendMessage(player, "", "§aToken: " + token); - Utils.sendMessage(player, "", "§cIMPORTANT: never share the token with anyone!"); - Utils.sendMessage(player, "", "§cIt could be used to claim your website account!"); - } - - private String generateToken() - { - String token = ""; - Random random = new Random(); - int start = random.nextInt(2); - for (int i = 0; i < TOKEN_LENGTH; i++) - { - if (i % 2 == start) - { - token += CONSONANTS.charAt(random.nextInt(21)); - } - else - { - token += VOWELS.charAt(random.nextInt(5)); - } - } - return token; - } - - @Command(hook = "token") - public void token(CommandSender sender) - { - Player player = (Player) sender; - UUID uuid = player.getUniqueId(); - try - { - String token = query("token", uuid); - if (token == null) - { - Utils.sendErrorMessage(player, null, "§cYou don't have a token yet! Use " + ChatColor.YELLOW - + "/gettoken " + ChatColor.RED + " to get one."); - } - else - { - String email = query("email", uuid); - printToken(player, email, token); - } - } - catch (Exception e) - { - Utils.sendErrorMessage(player, null, "Error getting your token, please contact an admin!"); - e.printStackTrace(); - } - } - - @Command(hook = "gettoken") - public void token(CommandSender sender, String email) - { - Player player = (Player) sender; - if (match(email, "^.+@(.+\\..{2,}|\\[[0-9a-fA-F:.]+\\])$")) - { - String uuid = player.getUniqueId().toString().replaceAll("-", ""); - String token = generateToken(); - try - { - String id = getNextId(); - table.delete(new MysqlConstraint("uuid", ConstraintOperator.EQUAL, uuid)); - table.insert(id, uuid, token, email); - player.sendMessage(ChatColor.GREEN + "Token generated!"); - printToken(player, email, token); - } - catch (Exception e) - { - Utils.sendErrorMessage(player, null, "Error getting your token, please contact an admin!"); - e.printStackTrace(); - } - } - else - { - Utils.sendErrorMessage(player, null, "Hmm... That doesn't look like a valid email!"); - } - } - - // @noformat - @Override - public String getCommandString() - { - return "command token {\n" + - " perm utils.webtoken;\n" + - " \n" + - " [empty] {\n" + - " help Displays an already generated token;\n" + - " type player;\n" + - " perm utils.webtoken;\n" + - " run token;\n" + - " }\n" + - "}\n" + - "\n" + - "command gettoken {\n" + - " perm utils.webtoken;\n" + - " \n" + - " [string:email...] {\n" + - " help Generates a token used for website authentication;\n" + - " type player;\n" + - " perm utils.webtoken;\n" + - " run gettoken email;\n" + - " }\n" + - "}"; - } - // @format -} -- 2.45.2 From 1ee4a123d24fc85b494ed64b863f1658cc1cfbda Mon Sep 17 00:00:00 2001 From: Pepich Date: Fri, 5 May 2017 09:21:19 +0200 Subject: [PATCH 083/152] Updated API to version 3.2 --- src/com/redstoner/misc/Main.java | 2 +- src/com/redstoner/misc/Utils.java | 19 +++++++++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/com/redstoner/misc/Main.java b/src/com/redstoner/misc/Main.java index ad684a9..e6ef372 100644 --- a/src/com/redstoner/misc/Main.java +++ b/src/com/redstoner/misc/Main.java @@ -10,7 +10,7 @@ import com.redstoner.misc.mysql.MysqlHandler; /** Main class. Duh. * * @author Pepich */ -@Version(major = 3, minor = 1, revision = 1, compatible = -1) +@Version(major = 3, minor = 2, revision = 0, compatible = -1) public class Main extends JavaPlugin { public static JavaPlugin plugin; diff --git a/src/com/redstoner/misc/Utils.java b/src/com/redstoner/misc/Utils.java index 3bd02c2..3a51344 100644 --- a/src/com/redstoner/misc/Utils.java +++ b/src/com/redstoner/misc/Utils.java @@ -16,7 +16,7 @@ import net.md_5.bungee.api.ChatColor; /** The utils class containing utility functions. Those include but are not limited to sending formatted messages, broadcasts and more. * * @author Pepich */ -@Version(major = 1, minor = 2, revision = 13, compatible = 1) +@Version(major = 1, minor = 3, revision = 0, compatible = 1) public final class Utils { /** The SimpleDateFormat used for getting the current date. */ @@ -202,7 +202,7 @@ public final class Utils /** This method will find the next parent caller and return their class name, omitting package names. * - * @return */ + * @return the Name of the calling class. */ private static final String getCaller() { StackTraceElement[] stackTrace = (new Exception()).getStackTrace(); @@ -214,6 +214,21 @@ public final class Utils return classname; } + /** This method will find the next parent caller and return their class name, omitting package names. + * + * @param directCaller used to prevent this method from returning the caller itself. Null if supposed to be ignored. + * @return the name of the calling class. */ + public static final String getCaller(Class directCaller) + { + StackTraceElement[] stackTrace = (new Exception()).getStackTrace(); + String classname = (directCaller == null ? "Utils" : directCaller.getName()); + for (int i = 0; classname.equals(directCaller.getName()); i++) + { + classname = stackTrace[i].getClassName().replaceAll(".*\\.", ""); + } + return classname; + } + /** Displays the module header to the recipient.
* Format: &2--=[ %MODULE% ]=-- * -- 2.45.2 From 71906eb107889fd4e2eaa5687ca05560fa5cb192 Mon Sep 17 00:00:00 2001 From: Pepich Date: Fri, 5 May 2017 09:43:31 +0200 Subject: [PATCH 084/152] Updated to APIv3.2 Commands can now be unregistered. Requires CommandManager as of 2017/05/05 09:44 --- .../coremods/moduleLoader/ModuleLoader.cmd | 10 ++- .../coremods/moduleLoader/ModuleLoader.java | 87 ++++++++++++++++++- 2 files changed, 91 insertions(+), 6 deletions(-) diff --git a/src/com/redstoner/coremods/moduleLoader/ModuleLoader.cmd b/src/com/redstoner/coremods/moduleLoader/ModuleLoader.cmd index 9dd5445..e88cafa 100644 --- a/src/com/redstoner/coremods/moduleLoader/ModuleLoader.cmd +++ b/src/com/redstoner/coremods/moduleLoader/ModuleLoader.cmd @@ -1,13 +1,19 @@ command modules { list { help Lists all modules. Color indicates status: §aENABLED §cDISABLED; - perm jutils.admin; + perm jutils.modules.list; run list; } load [string:name...] { help (Re)-Loads a module. WARNING: Handle with care! This has direct affect on code being executed. This command will temporarily halt the main thread until the class loading operation was completed.; - perm jtuils.admin; + perm jtuils.modules.admin; run load name; type console; } + unload [string:name...] { + help Unloads a module. WARNING: Handle with care! This has direct affect on code being executed. This command will temporarily halt the main thread until the class loading operation was completed.; + perm jutils.modules.admin; + run unload name; + type console; + } } \ No newline at end of file diff --git a/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java b/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java index 7739db9..71fe3a3 100644 --- a/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java +++ b/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java @@ -3,9 +3,11 @@ package com.redstoner.coremods.moduleLoader; import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; +import java.lang.reflect.Method; import java.net.MalformedURLException; import java.net.URL; import java.net.URLClassLoader; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -35,7 +37,7 @@ import net.minecraft.server.v1_11_R1.MinecraftServer; /** The module loader, mother of all modules. Responsible for loading and taking care of all modules. * * @author Pepich */ -@Version(major = 3, minor = 1, revision = 6, compatible = 2) +@Version(major = 3, minor = 2, revision = 0, compatible = 2) public final class ModuleLoader implements CoreModule { private static ModuleLoader instance; @@ -99,10 +101,10 @@ public final class ModuleLoader implements CoreModule } Utils.error("Invalid config file! Creating new, blank file!"); } - List autoload = config.getStringList("autoLoad"); - if (autoload == null || autoload.isEmpty()) + List coremods = config.getStringList("coremods"); + if (coremods == null || coremods.isEmpty()) { - config.set("autoLoad", new String[] {"# Add the modules here!"}); + config.set("coremods", new String[] {"# Add the coremodules here!"}); Main.plugin.saveConfig(); try { @@ -113,6 +115,23 @@ public final class ModuleLoader implements CoreModule e.printStackTrace(); } } + List autoload = config.getStringList("autoload"); + if (autoload == null || autoload.isEmpty()) + { + config.set("autoload", new String[] {"# Add the modules here!"}); + Main.plugin.saveConfig(); + try + { + config.save(configFile); + } + catch (IOException e) + { + e.printStackTrace(); + } + } + for (String s : coremods) + if (!s.startsWith("#")) + ModuleLoader.addDynamicModule(s); for (String s : autoload) if (!s.startsWith("#")) ModuleLoader.addDynamicModule(s); @@ -300,9 +319,24 @@ public final class ModuleLoader implements CoreModule { HandlerList.unregisterAll((Listener) module); } + String[] commands = getAllHooks(module).toArray(new String[] {}); + CommandManager.unregisterAll(commands); } } + private static ArrayList getAllHooks(Module module) + { + ArrayList commands = new ArrayList(); + for (Method m : module.getClass().getMethods()) + { + Command cmd = m.getDeclaredAnnotation(Command.class); + if (cmd == null) + continue; + commands.add(cmd.hook()); + } + return commands; + } + @Command(hook = "load") public boolean loadModule(CommandSender sender, String name) { @@ -310,6 +344,13 @@ public final class ModuleLoader implements CoreModule return true; } + @Command(hook = "unload") + public boolean unloadModule(CommandSender sender, String name) + { + removeDynamicModule(name); + return true; + } + public static final void addDynamicModule(String name) { Object[] status = getServerStatus(); @@ -451,6 +492,44 @@ public final class ModuleLoader implements CoreModule } } + public static final void removeDynamicModule(String name) + { + Object[] status = getServerStatus(); + for (Module m : modules.keySet()) + { + if (m.getClass().getName().equals(name)) + { + Utils.info( + "Found existing module, attempting unload. WARNING! This operation will halt the main thread until it is completed."); + Utils.info("Current server status:"); + Utils.info("Current system time: " + status[0]); + Utils.info("Current tick: " + status[1]); + Utils.info("Last TPS: " + status[2]); + Utils.info("Entity count: " + status[3]); + Utils.info("Player count: " + status[4]); + Utils.info("Attempting to disable module properly:"); + disableModule(m); + Utils.info("Disabled module, overriding the implementation:"); + Object[] newStatus = getServerStatus(); + Utils.info("Task complete! Took " + ((long) newStatus[0] - (long) status[0]) + "ms to finish!"); + Utils.info("Current server status:"); + Utils.info("Current system time: " + newStatus[0]); + Utils.info("Current tick: " + newStatus[1]); + Utils.info("Last TPS: " + newStatus[2]); + Utils.info("Entity count: " + newStatus[3]); + Utils.info("Player count: " + newStatus[4]); + return; + } + } + if (!name.startsWith("com.redstoner.modules.")) + { + Utils.warn("Couldn't find class definition, suspecting missing path. Autocompleting path, trying again."); + removeDynamicModule("com.redstoner.modules." + name); + } + else + Utils.error("Couldn't find module! Couldn't "); + } + @SuppressWarnings("deprecation") private static final Object[] getServerStatus() { -- 2.45.2 From 55badbb875ca656fe481d560a001b744746bec82 Mon Sep 17 00:00:00 2001 From: Pepich Date: Fri, 5 May 2017 10:07:37 +0200 Subject: [PATCH 085/152] Fixed modules not being removed from memory properly --- src/com/redstoner/coremods/moduleLoader/ModuleLoader.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java b/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java index 71fe3a3..35f7e75 100644 --- a/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java +++ b/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java @@ -37,7 +37,7 @@ import net.minecraft.server.v1_11_R1.MinecraftServer; /** The module loader, mother of all modules. Responsible for loading and taking care of all modules. * * @author Pepich */ -@Version(major = 3, minor = 2, revision = 0, compatible = 2) +@Version(major = 3, minor = 2, revision = 2, compatible = 2) public final class ModuleLoader implements CoreModule { private static ModuleLoader instance; @@ -132,6 +132,7 @@ public final class ModuleLoader implements CoreModule for (String s : coremods) if (!s.startsWith("#")) ModuleLoader.addDynamicModule(s); + enableModules(); for (String s : autoload) if (!s.startsWith("#")) ModuleLoader.addDynamicModule(s); @@ -509,6 +510,7 @@ public final class ModuleLoader implements CoreModule Utils.info("Player count: " + status[4]); Utils.info("Attempting to disable module properly:"); disableModule(m); + modules.remove(m); Utils.info("Disabled module, overriding the implementation:"); Object[] newStatus = getServerStatus(); Utils.info("Task complete! Took " + ((long) newStatus[0] - (long) status[0]) + "ms to finish!"); -- 2.45.2 From 538560a8cd55c525c10a0fa48f4aedab06c62bbc Mon Sep 17 00:00:00 2001 From: Pepich Date: Fri, 5 May 2017 10:08:44 +0200 Subject: [PATCH 086/152] Fixed potential memory leak --- .../redstoner/coremods/moduleLoader/ModuleLoader.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java b/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java index 35f7e75..4503332 100644 --- a/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java +++ b/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java @@ -37,7 +37,7 @@ import net.minecraft.server.v1_11_R1.MinecraftServer; /** The module loader, mother of all modules. Responsible for loading and taking care of all modules. * * @author Pepich */ -@Version(major = 3, minor = 2, revision = 2, compatible = 2) +@Version(major = 3, minor = 2, revision = 3, compatible = 2) public final class ModuleLoader implements CoreModule { private static ModuleLoader instance; @@ -322,6 +322,13 @@ public final class ModuleLoader implements CoreModule } String[] commands = getAllHooks(module).toArray(new String[] {}); CommandManager.unregisterAll(commands); + try + { + loaders.get(module).close(); + } + catch (IOException e) + {} + loaders.remove(module); } } -- 2.45.2 From df786c7c3ebb9c585f51954f980b9a176fec88b0 Mon Sep 17 00:00:00 2001 From: Pepich Date: Fri, 5 May 2017 10:10:40 +0200 Subject: [PATCH 087/152] Fixed NPE --- .../redstoner/coremods/moduleLoader/ModuleLoader.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java b/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java index 4503332..d7cf640 100644 --- a/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java +++ b/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java @@ -324,11 +324,16 @@ public final class ModuleLoader implements CoreModule CommandManager.unregisterAll(commands); try { - loaders.get(module).close(); + URLClassLoader loader = loaders.get(module); + if (loader != null) + loader.close(); } catch (IOException e) {} - loaders.remove(module); + finally + { + loaders.remove(module); + } } } -- 2.45.2 From d2e8b5fa36cd4e7c81b4c3ef53feb4e86796e38f Mon Sep 17 00:00:00 2001 From: Pepich Date: Fri, 5 May 2017 10:10:54 +0200 Subject: [PATCH 088/152] Updated version --- src/com/redstoner/coremods/moduleLoader/ModuleLoader.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java b/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java index d7cf640..c0f829f 100644 --- a/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java +++ b/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java @@ -37,7 +37,7 @@ import net.minecraft.server.v1_11_R1.MinecraftServer; /** The module loader, mother of all modules. Responsible for loading and taking care of all modules. * * @author Pepich */ -@Version(major = 3, minor = 2, revision = 3, compatible = 2) +@Version(major = 3, minor = 2, revision = 4, compatible = 2) public final class ModuleLoader implements CoreModule { private static ModuleLoader instance; -- 2.45.2 From e6625fd37907497d4c69e71e839f58070b4b205b Mon Sep 17 00:00:00 2001 From: Pepich Date: Fri, 5 May 2017 10:23:30 +0200 Subject: [PATCH 089/152] Moved colorify method into Utils class --- src/com/redstoner/misc/Utils.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/com/redstoner/misc/Utils.java b/src/com/redstoner/misc/Utils.java index 3a51344..ee9a67d 100644 --- a/src/com/redstoner/misc/Utils.java +++ b/src/com/redstoner/misc/Utils.java @@ -16,7 +16,7 @@ import net.md_5.bungee.api.ChatColor; /** The utils class containing utility functions. Those include but are not limited to sending formatted messages, broadcasts and more. * * @author Pepich */ -@Version(major = 1, minor = 3, revision = 0, compatible = 1) +@Version(major = 1, minor = 3, revision = 1, compatible = 1) public final class Utils { /** The SimpleDateFormat used for getting the current date. */ @@ -258,4 +258,20 @@ public final class Utils else return "&9" + sender.getName(); } + + /** This method "colorifies" a message using proper permissions. + * + * @param message the message to be colored. + * @param sender the command sender whose permissions shall be applied. + * @return the colorified message. */ + public static String colorify(String message, CommandSender sender) + { + if (sender.hasPermission("essentials.chat.color")) + message = message.replaceAll("&([0-9a-fA-FrR])", "§$1"); + if (sender.hasPermission("essentials.chat.format")) + message = message.replaceAll("&(l-oL-OrR)", "§$1"); + if (sender.hasPermission("essentials.chat.magic")) + message = message.replaceAll("&([kKrR])", "§$1"); + return message.replace("&§", "&"); + } } -- 2.45.2 From 7f5994c4860ccdb48bde83c4fa52e0293692cb62 Mon Sep 17 00:00:00 2001 From: Pepich Date: Fri, 5 May 2017 10:26:35 +0200 Subject: [PATCH 090/152] Improved color handling (&&a now is a literal '&a' instead of green) --- src/com/redstoner/misc/Utils.java | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/com/redstoner/misc/Utils.java b/src/com/redstoner/misc/Utils.java index ee9a67d..10cb395 100644 --- a/src/com/redstoner/misc/Utils.java +++ b/src/com/redstoner/misc/Utils.java @@ -16,7 +16,7 @@ import net.md_5.bungee.api.ChatColor; /** The utils class containing utility functions. Those include but are not limited to sending formatted messages, broadcasts and more. * * @author Pepich */ -@Version(major = 1, minor = 3, revision = 1, compatible = 1) +@Version(major = 1, minor = 3, revision = 2, compatible = 1) public final class Utils { /** The SimpleDateFormat used for getting the current date. */ @@ -64,8 +64,8 @@ public final class Utils { if (prefix == null) prefix = "§8[§2" + getCaller() + "§8]: "; - sendMessage(recipient, ChatColor.translateAlternateColorCodes(alternateColorCode, prefix), - ChatColor.translateAlternateColorCodes(alternateColorCode, message)); + sendMessage(recipient, ChatColor.translateAlternateColorCodes(alternateColorCode, prefix).replace("&§", "&"), + ChatColor.translateAlternateColorCodes(alternateColorCode, message).replace("&§", "&")); } /** Invokes sendErrorMessage. This method will additionally translate alternate color codes for you. @@ -78,8 +78,9 @@ public final class Utils { if (prefix == null) prefix = "§8[§c" + getCaller() + "§8]: "; - sendErrorMessage(recipient, ChatColor.translateAlternateColorCodes(alternateColorCode, prefix), - ChatColor.translateAlternateColorCodes(alternateColorCode, message)); + sendErrorMessage(recipient, + ChatColor.translateAlternateColorCodes(alternateColorCode, prefix).replace("&§", "&"), + ChatColor.translateAlternateColorCodes(alternateColorCode, message).replace("&§", "&")); } /** This method broadcasts a message to all players (and console) that are allowed by the filter. Set the filter to NULL to broadcast to everyone.
@@ -106,8 +107,8 @@ public final class Utils { if (prefix == null) prefix = "§8[§2" + getCaller() + "§8]: "; - return broadcast(ChatColor.translateAlternateColorCodes(alternateColorCode, prefix), - ChatColor.translateAlternateColorCodes(alternateColorCode, message), filter, null); + return broadcast(ChatColor.translateAlternateColorCodes(alternateColorCode, prefix).replace("&§", "&"), + ChatColor.translateAlternateColorCodes(alternateColorCode, message).replace("&§", "&"), filter, null); } /** This method broadcasts a message to all players and console that are allowed by the filter. Set the filter to NULL to broadcast to everyone.
@@ -173,7 +174,8 @@ public final class Utils Debugger.notifyMethod(message); String classname = getCaller(); String prefix = "§8[§2" + classname + "§8]: "; - Bukkit.getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', prefix + "§7" + message)); + Bukkit.getConsoleSender() + .sendMessage(ChatColor.translateAlternateColorCodes('&', prefix + "§7" + message).replace("&§", "&")); } /** Prints a warning message into console. Supports "&" color codes. @@ -185,7 +187,8 @@ public final class Utils Debugger.notifyMethod(message); String classname = getCaller(); String prefix = "§e[WARN]: §8[§e" + classname + "§8]: "; - Bukkit.getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', prefix + "§7" + message)); + Bukkit.getConsoleSender() + .sendMessage(ChatColor.translateAlternateColorCodes('&', prefix + "§7" + message).replace("&§", "&")); } /** Used to make an error output to console. Supports "&" color codes. @@ -197,7 +200,8 @@ public final class Utils Debugger.notifyMethod(message); String classname = getCaller(); String prefix = "§c[ERROR]: §8[§c" + classname + "§8]: "; - Bukkit.getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', prefix + "§7" + message)); + Bukkit.getConsoleSender() + .sendMessage(ChatColor.translateAlternateColorCodes('&', prefix + "§7" + message).replace("&§", "&")); } /** This method will find the next parent caller and return their class name, omitting package names. -- 2.45.2 From db6ac8ed385f1a4322f6a5381e0ba8aa43d0c41a Mon Sep 17 00:00:00 2001 From: Pepich Date: Fri, 5 May 2017 10:51:44 +0200 Subject: [PATCH 091/152] Added option to change "module-header-name" --- src/com/redstoner/misc/Utils.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/com/redstoner/misc/Utils.java b/src/com/redstoner/misc/Utils.java index 10cb395..1ee7a27 100644 --- a/src/com/redstoner/misc/Utils.java +++ b/src/com/redstoner/misc/Utils.java @@ -16,7 +16,7 @@ import net.md_5.bungee.api.ChatColor; /** The utils class containing utility functions. Those include but are not limited to sending formatted messages, broadcasts and more. * * @author Pepich */ -@Version(major = 1, minor = 3, revision = 2, compatible = 1) +@Version(major = 1, minor = 3, revision = 3, compatible = 1) public final class Utils { /** The SimpleDateFormat used for getting the current date. */ @@ -239,7 +239,17 @@ public final class Utils * @param recipient Whom to display the header to. */ public static void sendModuleHeader(CommandSender recipient) { - recipient.sendMessage("§2--=[ " + getCaller() + " ]=--"); + sendModuleHeader(recipient, getCaller()); + } + + /** Displays the module header to the recipient.
+ * Format: &2--=[ %HEADER% ]=-- + * + * @param recipient Whom to display the header to. + * @param header The module name. */ + public static void sendModuleHeader(CommandSender recipient, String header) + { + recipient.sendMessage("§2--=[ " + header + " ]=--"); } /** Provides a uniform way of getting the date for all modules. -- 2.45.2 From da9d34118241d86fa948cf89408edc3a57f3756f Mon Sep 17 00:00:00 2001 From: Pepich Date: Tue, 9 May 2017 11:19:28 +0200 Subject: [PATCH 092/152] Fixed "external" getCaller method --- src/com/redstoner/misc/Utils.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/com/redstoner/misc/Utils.java b/src/com/redstoner/misc/Utils.java index 1ee7a27..34922be 100644 --- a/src/com/redstoner/misc/Utils.java +++ b/src/com/redstoner/misc/Utils.java @@ -16,7 +16,7 @@ import net.md_5.bungee.api.ChatColor; /** The utils class containing utility functions. Those include but are not limited to sending formatted messages, broadcasts and more. * * @author Pepich */ -@Version(major = 1, minor = 3, revision = 3, compatible = 1) +@Version(major = 1, minor = 3, revision = 4, compatible = 1) public final class Utils { /** The SimpleDateFormat used for getting the current date. */ @@ -226,7 +226,7 @@ public final class Utils { StackTraceElement[] stackTrace = (new Exception()).getStackTrace(); String classname = (directCaller == null ? "Utils" : directCaller.getName()); - for (int i = 0; classname.equals(directCaller.getName()); i++) + for (int i = 0; classname.equals(directCaller.getName()) || classname.equals("Utils"); i++) { classname = stackTrace[i].getClassName().replaceAll(".*\\.", ""); } -- 2.45.2 From ed4da2e766e32b7dfe565f4a2f6863c16b72ee27 Mon Sep 17 00:00:00 2001 From: Pepich Date: Tue, 9 May 2017 11:24:11 +0200 Subject: [PATCH 093/152] Updated getCaller method --- src/com/redstoner/misc/Utils.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/com/redstoner/misc/Utils.java b/src/com/redstoner/misc/Utils.java index 34922be..c5491c5 100644 --- a/src/com/redstoner/misc/Utils.java +++ b/src/com/redstoner/misc/Utils.java @@ -222,11 +222,11 @@ public final class Utils * * @param directCaller used to prevent this method from returning the caller itself. Null if supposed to be ignored. * @return the name of the calling class. */ - public static final String getCaller(Class directCaller) + public static final String getCaller(String directCaller) { StackTraceElement[] stackTrace = (new Exception()).getStackTrace(); - String classname = (directCaller == null ? "Utils" : directCaller.getName()); - for (int i = 0; classname.equals(directCaller.getName()) || classname.equals("Utils"); i++) + String classname = (directCaller == null ? "Utils" : directCaller); + for (int i = 0; classname.equals(directCaller) || classname.equals("Utils"); i++) { classname = stackTrace[i].getClassName().replaceAll(".*\\.", ""); } -- 2.45.2 From 0140aeee026a1ff4a1e4247f1203c4fcf5b459c8 Mon Sep 17 00:00:00 2001 From: Pepich Date: Tue, 9 May 2017 11:24:30 +0200 Subject: [PATCH 094/152] Updated version ._. --- src/com/redstoner/misc/Utils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/com/redstoner/misc/Utils.java b/src/com/redstoner/misc/Utils.java index c5491c5..a06b966 100644 --- a/src/com/redstoner/misc/Utils.java +++ b/src/com/redstoner/misc/Utils.java @@ -16,7 +16,7 @@ import net.md_5.bungee.api.ChatColor; /** The utils class containing utility functions. Those include but are not limited to sending formatted messages, broadcasts and more. * * @author Pepich */ -@Version(major = 1, minor = 3, revision = 4, compatible = 1) +@Version(major = 1, minor = 3, revision = 5, compatible = 1) public final class Utils { /** The SimpleDateFormat used for getting the current date. */ -- 2.45.2 From 45093f653f751c8273e4ab04a2016f32a2f5278f Mon Sep 17 00:00:00 2001 From: Pepich Date: Thu, 11 May 2017 14:09:23 +0200 Subject: [PATCH 095/152] Added custom manifest file to jar to make cmdmanager an external lib --- manifest.mf | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 manifest.mf diff --git a/manifest.mf b/manifest.mf new file mode 100644 index 0000000..0850661 --- /dev/null +++ b/manifest.mf @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Class-Path: ../lib/CommandManager.jar + -- 2.45.2 From b218d77d20aad147a1ebbc97d6ec93a54fcab772 Mon Sep 17 00:00:00 2001 From: Pepich Date: Sun, 14 May 2017 23:53:32 +0200 Subject: [PATCH 096/152] Removed improperly placed "@throws" from javadocs --- src/com/redstoner/misc/VersionHelper.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/com/redstoner/misc/VersionHelper.java b/src/com/redstoner/misc/VersionHelper.java index 2c4a266..1b20b16 100644 --- a/src/com/redstoner/misc/VersionHelper.java +++ b/src/com/redstoner/misc/VersionHelper.java @@ -8,7 +8,7 @@ import com.redstoner.exceptions.MissingVersionException; /** This class can be used to compare modules against the loader version or against each other to prevent dependency issues. * * @author Pepich */ -@Version(major = 2, minor = 1, revision = 2, compatible = 0) +@Version(major = 2, minor = 1, revision = 3, compatible = 0) public final class VersionHelper { private VersionHelper() @@ -63,8 +63,7 @@ public final class VersionHelper * * @param base The API version to compare to. * @param module The module version to compare. - * @return true, when the module is up to date with the API, or the API supports outdated modules. - * @throws MissingVersionException When one of the parameters is not annotated with a @Version annotation. */ + * @return true, when the module is up to date with the API, or the API supports outdated modules. */ public static boolean isCompatible(Version apiVersion, Version moduleVersion) { if (apiVersion.major() >= moduleVersion.compatible()) -- 2.45.2 From f6d3537d93e9275ffeca04b963594c488afc743f Mon Sep 17 00:00:00 2001 From: Pepich Date: Mon, 29 May 2017 14:18:08 +0200 Subject: [PATCH 097/152] Changed getCaller() to no longer abuse Exceptions --- src/com/redstoner/misc/Utils.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/com/redstoner/misc/Utils.java b/src/com/redstoner/misc/Utils.java index a06b966..e7975e0 100644 --- a/src/com/redstoner/misc/Utils.java +++ b/src/com/redstoner/misc/Utils.java @@ -16,7 +16,7 @@ import net.md_5.bungee.api.ChatColor; /** The utils class containing utility functions. Those include but are not limited to sending formatted messages, broadcasts and more. * * @author Pepich */ -@Version(major = 1, minor = 3, revision = 5, compatible = 1) +@Version(major = 1, minor = 3, revision = 6, compatible = 1) public final class Utils { /** The SimpleDateFormat used for getting the current date. */ @@ -209,7 +209,7 @@ public final class Utils * @return the Name of the calling class. */ private static final String getCaller() { - StackTraceElement[] stackTrace = (new Exception()).getStackTrace(); + StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace(); String classname = "Utils"; for (int i = 0; classname.equals("Utils"); i++) { @@ -224,7 +224,7 @@ public final class Utils * @return the name of the calling class. */ public static final String getCaller(String directCaller) { - StackTraceElement[] stackTrace = (new Exception()).getStackTrace(); + StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace(); String classname = (directCaller == null ? "Utils" : directCaller); for (int i = 0; classname.equals(directCaller) || classname.equals("Utils"); i++) { -- 2.45.2 From 438c1ae72ec8ecce40d45d2234d829191c270ca7 Mon Sep 17 00:00:00 2001 From: Pepich Date: Wed, 31 May 2017 13:17:09 +0200 Subject: [PATCH 098/152] Fixed getCaller always returning "Thread" --- src/com/redstoner/misc/Utils.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/com/redstoner/misc/Utils.java b/src/com/redstoner/misc/Utils.java index e7975e0..01eeea8 100644 --- a/src/com/redstoner/misc/Utils.java +++ b/src/com/redstoner/misc/Utils.java @@ -16,7 +16,7 @@ import net.md_5.bungee.api.ChatColor; /** The utils class containing utility functions. Those include but are not limited to sending formatted messages, broadcasts and more. * * @author Pepich */ -@Version(major = 1, minor = 3, revision = 6, compatible = 1) +@Version(major = 1, minor = 3, revision = 7, compatible = 1) public final class Utils { /** The SimpleDateFormat used for getting the current date. */ @@ -209,7 +209,7 @@ public final class Utils * @return the Name of the calling class. */ private static final String getCaller() { - StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace(); + StackTraceElement[] stackTrace = (new Exception()).getStackTrace(); String classname = "Utils"; for (int i = 0; classname.equals("Utils"); i++) { @@ -224,7 +224,7 @@ public final class Utils * @return the name of the calling class. */ public static final String getCaller(String directCaller) { - StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace(); + StackTraceElement[] stackTrace = (new Exception()).getStackTrace(); String classname = (directCaller == null ? "Utils" : directCaller); for (int i = 0; classname.equals(directCaller) || classname.equals("Utils"); i++) { -- 2.45.2 From f82e5412853c93d535345a3c29217f3e2b58bafa Mon Sep 17 00:00:00 2001 From: Pepich Date: Sat, 10 Jun 2017 00:39:08 +0200 Subject: [PATCH 099/152] Made ModuleLoader compatible with 1.12 (exclusively) --- src/com/redstoner/coremods/moduleLoader/ModuleLoader.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java b/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java index c0f829f..555d841 100644 --- a/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java +++ b/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java @@ -32,12 +32,12 @@ import com.redstoner.misc.VersionHelper; import com.redstoner.modules.CoreModule; import com.redstoner.modules.Module; -import net.minecraft.server.v1_11_R1.MinecraftServer; +import net.minecraft.server.v1_12_R1.MinecraftServer; /** The module loader, mother of all modules. Responsible for loading and taking care of all modules. * * @author Pepich */ -@Version(major = 3, minor = 2, revision = 4, compatible = 2) +@Version(major = 3, minor = 2, revision = 5, compatible = 2) public final class ModuleLoader implements CoreModule { private static ModuleLoader instance; -- 2.45.2 From 25294b4e5f9ea1c64d7c3e671839844f09444ff5 Mon Sep 17 00:00:00 2001 From: Pepich Date: Mon, 12 Jun 2017 16:18:29 +0200 Subject: [PATCH 100/152] Switched to bukkit ChatColor instead of Bungee --- src/com/redstoner/misc/Utils.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/com/redstoner/misc/Utils.java b/src/com/redstoner/misc/Utils.java index 01eeea8..973f31f 100644 --- a/src/com/redstoner/misc/Utils.java +++ b/src/com/redstoner/misc/Utils.java @@ -4,6 +4,7 @@ import java.text.SimpleDateFormat; import java.util.Date; import org.bukkit.Bukkit; +import org.bukkit.ChatColor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -11,12 +12,10 @@ import com.redstoner.annotations.Debugable; import com.redstoner.annotations.Version; import com.redstoner.coremods.debugger.Debugger; -import net.md_5.bungee.api.ChatColor; - /** The utils class containing utility functions. Those include but are not limited to sending formatted messages, broadcasts and more. * * @author Pepich */ -@Version(major = 1, minor = 3, revision = 7, compatible = 1) +@Version(major = 1, minor = 3, revision = 8, compatible = 1) public final class Utils { /** The SimpleDateFormat used for getting the current date. */ -- 2.45.2 From ca3aee41a63263c15211dddaaac9402a10c0b2d7 Mon Sep 17 00:00:00 2001 From: Pepich Date: Sat, 8 Jul 2017 12:12:30 +0200 Subject: [PATCH 101/152] Preparation for APIv4, general code cleanup --- src/com/redstoner/annotations/Commands.java | 12 ++ .../coremods/moduleLoader/ModuleLoader.java | 123 +++++++++--------- src/com/redstoner/misc/CommandHolderType.java | 13 ++ src/com/redstoner/misc/Main.java | 4 +- src/com/redstoner/misc/Utils.java | 86 ++++++------ 5 files changed, 125 insertions(+), 113 deletions(-) create mode 100644 src/com/redstoner/annotations/Commands.java create mode 100644 src/com/redstoner/misc/CommandHolderType.java diff --git a/src/com/redstoner/annotations/Commands.java b/src/com/redstoner/annotations/Commands.java new file mode 100644 index 0000000..1388de4 --- /dev/null +++ b/src/com/redstoner/annotations/Commands.java @@ -0,0 +1,12 @@ +package com.redstoner.annotations; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Target; + +import com.redstoner.misc.CommandHolderType; + +@Target(ElementType.TYPE) +public @interface Commands +{ + CommandHolderType value(); +} diff --git a/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java b/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java index 555d841..bedb50e 100644 --- a/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java +++ b/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java @@ -3,6 +3,7 @@ package com.redstoner.coremods.moduleLoader; import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; +import java.io.InputStream; import java.lang.reflect.Method; import java.net.MalformedURLException; import java.net.URL; @@ -12,7 +13,6 @@ import java.util.HashMap; import java.util.List; import org.bukkit.Bukkit; -import org.bukkit.World; import org.bukkit.command.CommandSender; import org.bukkit.configuration.InvalidConfigurationException; import org.bukkit.configuration.file.FileConfiguration; @@ -23,6 +23,7 @@ import com.nemez.cmdmgr.Command; import com.nemez.cmdmgr.Command.AsyncType; import com.nemez.cmdmgr.CommandManager; import com.redstoner.annotations.AutoRegisterListener; +import com.redstoner.annotations.Commands; import com.redstoner.annotations.Debugable; import com.redstoner.annotations.Version; import com.redstoner.coremods.debugger.Debugger; @@ -32,12 +33,10 @@ import com.redstoner.misc.VersionHelper; import com.redstoner.modules.CoreModule; import com.redstoner.modules.Module; -import net.minecraft.server.v1_12_R1.MinecraftServer; - /** The module loader, mother of all modules. Responsible for loading and taking care of all modules. * * @author Pepich */ -@Version(major = 3, minor = 2, revision = 5, compatible = 2) +@Version(major = 4, minor = 0, revision = 0, compatible = 2) public final class ModuleLoader implements CoreModule { private static ModuleLoader instance; @@ -47,6 +46,7 @@ public final class ModuleLoader implements CoreModule private static HashMap loaders = new HashMap(); private static File configFile; private static FileConfiguration config; + private static boolean debugMode = false; private ModuleLoader() { @@ -60,6 +60,7 @@ public final class ModuleLoader implements CoreModule catch (MalformedURLException e) { System.out.println("Sumtin is wong with ya filesüstem m8. Fix eeeet or I won't werk!"); + Bukkit.getPluginManager().disablePlugin(Main.plugin); } } @@ -129,6 +130,19 @@ public final class ModuleLoader implements CoreModule e.printStackTrace(); } } + if (!config.contains("debugMode")) + { + config.set("debugMode", false); + try + { + config.save(configFile); + } + catch (IOException e) + { + e.printStackTrace(); + } + } + debugMode = config.getBoolean("debugMode"); for (String s : coremods) if (!s.startsWith("#")) ModuleLoader.addDynamicModule(s); @@ -136,6 +150,7 @@ public final class ModuleLoader implements CoreModule for (String s : autoload) if (!s.startsWith("#")) ModuleLoader.addDynamicModule(s); + enableModules(); } /** This method will add a module to the module list, without enabling it.
@@ -257,13 +272,36 @@ public final class ModuleLoader implements CoreModule { if (module.onEnable()) { + modules.put(module, true); if (VersionHelper.isCompatible(VersionHelper.create(2, 0, 0, -1), module.getClass())) CommandManager.registerCommand(module.getCommandString(), module, Main.plugin); - modules.put(module, true); - if (VersionHelper.isCompatible(VersionHelper.create(3, 0, 0, 3), module.getClass())) + if (VersionHelper.isCompatible(VersionHelper.create(4, 0, 0, 3), module.getClass())) { module.postEnable(); } + if (VersionHelper.isCompatible(VersionHelper.create(4, 0, 0, 4), module.getClass())) + { + Commands ann = module.getClass().getAnnotation(Commands.class); + if (ann != null) + { + switch (ann.value()) + { + case File: + File f = new File(module.getClass().getName() + ".cmd"); + CommandManager.registerCommand(f, module, Main.plugin); + break; + case Stream: + InputStream stream = module.getClass() + .getResourceAsStream(module.getClass().getSimpleName() + ".cmd"); + CommandManager.registerCommand(stream, module, Main.plugin); + case String: + CommandManager.registerCommand(module.getCommandString(), module, Main.plugin); + break; + case None: + break; + } + } + } Utils.info("Loaded module " + module.getClass().getName()); if (module.getClass().isAnnotationPresent(AutoRegisterListener.class) && (module instanceof Listener)) { @@ -366,19 +404,12 @@ public final class ModuleLoader implements CoreModule public static final void addDynamicModule(String name) { - Object[] status = getServerStatus(); for (Module m : modules.keySet()) { if (m.getClass().getName().equals(name)) { Utils.info( "Found existing module, attempting override. WARNING! This operation will halt the main thread until it is completed."); - Utils.info("Current server status:"); - Utils.info("Current system time: " + status[0]); - Utils.info("Current tick: " + status[1]); - Utils.info("Last TPS: " + status[2]); - Utils.info("Entity count: " + status[3]); - Utils.info("Player count: " + status[4]); Utils.info("Attempting to load new class definition before disabling and removing the old module:"); boolean differs = false; Utils.info("Old class definition: Class@" + m.getClass().hashCode()); @@ -446,18 +477,24 @@ public final class ModuleLoader implements CoreModule Utils.info("Version of remote class: " + VersionHelper.getString(newVersion)); if (oldVersion.equals(newVersion)) { - Utils.error("Detected equal module versions, aborting now..."); - try + Utils.error("Detected equal module versions, " + (debugMode + ? " aborting now... Set debugMode to true in your config if you want to continue!" + : " continueing anyways.")); + if (!debugMode) { - cl.close(); + try + { + cl.close(); + } + catch (IOException e) + { + e.printStackTrace(); + } + return; } - catch (IOException e) - { - e.printStackTrace(); - } - return; } - Utils.info("Versions differ, disabling old module:"); + else + Utils.info("Versions differ, disabling old module:"); disableModule(m); Utils.info("Disabled module, overriding the implementation:"); modules.remove(m); @@ -474,14 +511,6 @@ public final class ModuleLoader implements CoreModule loaders.put(module, cl); Utils.info("Successfully updated class definition. Enabling new implementation:"); enableLoadedModule(module); - Object[] newStatus = getServerStatus(); - Utils.info("Task complete! Took " + ((long) newStatus[0] - (long) status[0]) + "ms to finish!"); - Utils.info("Current server status:"); - Utils.info("Current system time: " + newStatus[0]); - Utils.info("Current tick: " + newStatus[1]); - Utils.info("Last TPS: " + newStatus[2]); - Utils.info("Entity count: " + newStatus[3]); - Utils.info("Player count: " + newStatus[4]); return; } } @@ -507,31 +536,16 @@ public final class ModuleLoader implements CoreModule public static final void removeDynamicModule(String name) { - Object[] status = getServerStatus(); for (Module m : modules.keySet()) { if (m.getClass().getName().equals(name)) { Utils.info( "Found existing module, attempting unload. WARNING! This operation will halt the main thread until it is completed."); - Utils.info("Current server status:"); - Utils.info("Current system time: " + status[0]); - Utils.info("Current tick: " + status[1]); - Utils.info("Last TPS: " + status[2]); - Utils.info("Entity count: " + status[3]); - Utils.info("Player count: " + status[4]); Utils.info("Attempting to disable module properly:"); disableModule(m); modules.remove(m); - Utils.info("Disabled module, overriding the implementation:"); - Object[] newStatus = getServerStatus(); - Utils.info("Task complete! Took " + ((long) newStatus[0] - (long) status[0]) + "ms to finish!"); - Utils.info("Current server status:"); - Utils.info("Current system time: " + newStatus[0]); - Utils.info("Current tick: " + newStatus[1]); - Utils.info("Last TPS: " + newStatus[2]); - Utils.info("Entity count: " + newStatus[3]); - Utils.info("Player count: " + newStatus[4]); + Utils.info("Disabled module."); return; } } @@ -544,23 +558,6 @@ public final class ModuleLoader implements CoreModule Utils.error("Couldn't find module! Couldn't "); } - @SuppressWarnings("deprecation") - private static final Object[] getServerStatus() - { - final Object[] status = new Object[5]; - status[0] = System.currentTimeMillis(); - status[1] = MinecraftServer.currentTick; - status[2] = MinecraftServer.getServer().recentTps[0]; - int i = 0; - for (World w : Bukkit.getWorlds()) - { - i += w.getEntities().size(); - } - status[3] = i; - status[4] = Bukkit.getOnlinePlayers().size(); - return status; - } - /** Finds a module by name for other modules to reference it. * * @param name the name of the module. Use the full path if you are not sure about the module's SimpleClassName being unique. diff --git a/src/com/redstoner/misc/CommandHolderType.java b/src/com/redstoner/misc/CommandHolderType.java new file mode 100644 index 0000000..19b9dda --- /dev/null +++ b/src/com/redstoner/misc/CommandHolderType.java @@ -0,0 +1,13 @@ +package com.redstoner.misc; + +import com.redstoner.annotations.Version; + +/** @author Pepich */ +@Version(major = 4, minor = 0, revision = 0, compatible = -1) +public enum CommandHolderType +{ + Stream, + File, + @Deprecated String, + None +} diff --git a/src/com/redstoner/misc/Main.java b/src/com/redstoner/misc/Main.java index e6ef372..6c42f34 100644 --- a/src/com/redstoner/misc/Main.java +++ b/src/com/redstoner/misc/Main.java @@ -10,7 +10,7 @@ import com.redstoner.misc.mysql.MysqlHandler; /** Main class. Duh. * * @author Pepich */ -@Version(major = 3, minor = 2, revision = 0, compatible = -1) +@Version(major = 4, minor = 0, revision = 0, compatible = -1) public class Main extends JavaPlugin { public static JavaPlugin plugin; @@ -19,9 +19,11 @@ public class Main extends JavaPlugin public void onEnable() { plugin = this; + // Configger.init(); Debugger.init(); MysqlHandler.init(); ModuleLoader.init(); + // Load modules from config ModuleLoader.loadFromConfig(); // And enable them ModuleLoader.enableModules(); diff --git a/src/com/redstoner/misc/Utils.java b/src/com/redstoner/misc/Utils.java index 973f31f..d449e6f 100644 --- a/src/com/redstoner/misc/Utils.java +++ b/src/com/redstoner/misc/Utils.java @@ -1,10 +1,10 @@ package com.redstoner.misc; import java.text.SimpleDateFormat; +import java.util.ArrayList; import java.util.Date; import org.bukkit.Bukkit; -import org.bukkit.ChatColor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -15,7 +15,7 @@ import com.redstoner.coremods.debugger.Debugger; /** The utils class containing utility functions. Those include but are not limited to sending formatted messages, broadcasts and more. * * @author Pepich */ -@Version(major = 1, minor = 3, revision = 8, compatible = 1) +@Version(major = 4, minor = 0, revision = 0, compatible = 1) public final class Utils { /** The SimpleDateFormat used for getting the current date. */ @@ -63,8 +63,7 @@ public final class Utils { if (prefix == null) prefix = "§8[§2" + getCaller() + "§8]: "; - sendMessage(recipient, ChatColor.translateAlternateColorCodes(alternateColorCode, prefix).replace("&§", "&"), - ChatColor.translateAlternateColorCodes(alternateColorCode, message).replace("&§", "&")); + sendMessage(recipient, colorify(prefix, alternateColorCode), colorify(message, alternateColorCode)); } /** Invokes sendErrorMessage. This method will additionally translate alternate color codes for you. @@ -77,21 +76,7 @@ public final class Utils { if (prefix == null) prefix = "§8[§c" + getCaller() + "§8]: "; - sendErrorMessage(recipient, - ChatColor.translateAlternateColorCodes(alternateColorCode, prefix).replace("&§", "&"), - ChatColor.translateAlternateColorCodes(alternateColorCode, message).replace("&§", "&")); - } - - /** This method broadcasts a message to all players (and console) that are allowed by the filter. Set the filter to NULL to broadcast to everyone.
- * This will not be logged to console except when you return true in the filter. - * - * @param message the message to be sent around - * @param filter the BroadcastFilter to be applied.
- * Write a class implementing the interface and pass it to this method, the "sendTo()" method will be called for each recipient. - * @return the amount of people that received the message. */ - public static int broadcast(String prefix, String message, BroadcastFilter filter) - { - return broadcast(prefix, message, filter, null); + sendErrorMessage(recipient, colorify(prefix, '&'), colorify(message, '&')); } /** This method broadcasts a message to all players (and console) that are allowed by the filter. Set the filter to NULL to broadcast to everyone.
@@ -106,8 +91,8 @@ public final class Utils { if (prefix == null) prefix = "§8[§2" + getCaller() + "§8]: "; - return broadcast(ChatColor.translateAlternateColorCodes(alternateColorCode, prefix).replace("&§", "&"), - ChatColor.translateAlternateColorCodes(alternateColorCode, message).replace("&§", "&"), filter, null); + message = colorify(message, alternateColorCode); + return broadcast(prefix, message, filter); } /** This method broadcasts a message to all players and console that are allowed by the filter. Set the filter to NULL to broadcast to everyone.
@@ -121,20 +106,16 @@ public final class Utils * @param logmessage the log message to appear in console. Set to null to not log this (you can still log the original message by returning true in the filter). * @return the amount of people that received the message. */ @Debugable - public static int broadcast(String prefix, String message, BroadcastFilter filter, String logmessage) + public static int broadcast(String prefix, String message, BroadcastFilter filter) { if (prefix == null) prefix = "§8[§2" + getCaller() + "§8]: "; - Debugger.notifyMethod(message, filter, logmessage); - if (logmessage != null) - sendMessage(Bukkit.getConsoleSender(), prefix, logmessage); if (filter == null) { for (Player p : Bukkit.getOnlinePlayers()) p.sendMessage(prefix + message); - if (logmessage == null) - Bukkit.getConsoleSender().sendMessage(prefix + message); - return Bukkit.getOnlinePlayers().size(); + Bukkit.getConsoleSender().sendMessage(prefix + message); + return Bukkit.getOnlinePlayers().size() + 1; } else { @@ -145,12 +126,11 @@ public final class Utils p.sendMessage(prefix + message); count++; } - if (logmessage == null) - if (filter.sendTo(Bukkit.getConsoleSender())) - { - Bukkit.getConsoleSender().sendMessage(prefix + message); - count++; - } + if (filter.sendTo(Bukkit.getConsoleSender())) + { + Bukkit.getConsoleSender().sendMessage(prefix + message); + count++; + } return count; } } @@ -173,8 +153,7 @@ public final class Utils Debugger.notifyMethod(message); String classname = getCaller(); String prefix = "§8[§2" + classname + "§8]: "; - Bukkit.getConsoleSender() - .sendMessage(ChatColor.translateAlternateColorCodes('&', prefix + "§7" + message).replace("&§", "&")); + Bukkit.getConsoleSender().sendMessage(colorify(prefix + "§7" + message, Bukkit.getConsoleSender(), '&')); } /** Prints a warning message into console. Supports "&" color codes. @@ -186,8 +165,7 @@ public final class Utils Debugger.notifyMethod(message); String classname = getCaller(); String prefix = "§e[WARN]: §8[§e" + classname + "§8]: "; - Bukkit.getConsoleSender() - .sendMessage(ChatColor.translateAlternateColorCodes('&', prefix + "§7" + message).replace("&§", "&")); + Bukkit.getConsoleSender().sendMessage(colorify(prefix + "§7" + message, Bukkit.getConsoleSender(), '&')); } /** Used to make an error output to console. Supports "&" color codes. @@ -199,8 +177,7 @@ public final class Utils Debugger.notifyMethod(message); String classname = getCaller(); String prefix = "§c[ERROR]: §8[§c" + classname + "§8]: "; - Bukkit.getConsoleSender() - .sendMessage(ChatColor.translateAlternateColorCodes('&', prefix + "§7" + message).replace("&§", "&")); + Bukkit.getConsoleSender().sendMessage(colorify(prefix + "§7" + message, Bukkit.getConsoleSender(), '&')); } /** This method will find the next parent caller and return their class name, omitting package names. @@ -221,11 +198,13 @@ public final class Utils * * @param directCaller used to prevent this method from returning the caller itself. Null if supposed to be ignored. * @return the name of the calling class. */ - public static final String getCaller(String directCaller) + public static final String getCaller(ArrayList directCaller) { + if (directCaller == null || directCaller.size() == 0) + return getCaller(); StackTraceElement[] stackTrace = (new Exception()).getStackTrace(); - String classname = (directCaller == null ? "Utils" : directCaller); - for (int i = 0; classname.equals(directCaller) || classname.equals("Utils"); i++) + String classname = "Utils"; + for (int i = 0; directCaller.contains(classname) || classname.equals("Utils"); i++) { classname = stackTrace[i].getClassName().replaceAll(".*\\.", ""); } @@ -269,7 +248,16 @@ public final class Utils if (sender instanceof Player) return ((Player) sender).getDisplayName(); else - return "&9" + sender.getName(); + return "§9" + sender.getName(); + } + + /** This method "colorifies" a message. + * + * @param message the message to be colored. + * @return the colorified message. */ + public static String colorify(String message, char alternateColorcode) + { + return colorify(message, Bukkit.getConsoleSender(), alternateColorcode); } /** This method "colorifies" a message using proper permissions. @@ -277,14 +265,14 @@ public final class Utils * @param message the message to be colored. * @param sender the command sender whose permissions shall be applied. * @return the colorified message. */ - public static String colorify(String message, CommandSender sender) + public static String colorify(String message, CommandSender sender, char alternateColorcode) { if (sender.hasPermission("essentials.chat.color")) - message = message.replaceAll("&([0-9a-fA-FrR])", "§$1"); + message = message.replaceAll(alternateColorcode + "([0-9a-fA-FrR])", "§$1"); if (sender.hasPermission("essentials.chat.format")) - message = message.replaceAll("&(l-oL-OrR)", "§$1"); + message = message.replaceAll(alternateColorcode + "(l-oL-OrR)", "§$1"); if (sender.hasPermission("essentials.chat.magic")) - message = message.replaceAll("&([kKrR])", "§$1"); - return message.replace("&§", "&"); + message = message.replaceAll(alternateColorcode + "([kKrR])", "§$1"); + return message.replace(alternateColorcode + "§", alternateColorcode + ""); } } -- 2.45.2 From 5855fce2e46372435185f1f1a185555220f69388 Mon Sep 17 00:00:00 2001 From: Pepich Date: Sat, 8 Jul 2017 12:18:32 +0200 Subject: [PATCH 102/152] Made previous change to getCaller grant backwards compatibility --- src/com/redstoner/misc/Utils.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/com/redstoner/misc/Utils.java b/src/com/redstoner/misc/Utils.java index d449e6f..98081a0 100644 --- a/src/com/redstoner/misc/Utils.java +++ b/src/com/redstoner/misc/Utils.java @@ -1,8 +1,9 @@ package com.redstoner.misc; import java.text.SimpleDateFormat; -import java.util.ArrayList; +import java.util.Arrays; import java.util.Date; +import java.util.List; import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; @@ -15,7 +16,7 @@ import com.redstoner.coremods.debugger.Debugger; /** The utils class containing utility functions. Those include but are not limited to sending formatted messages, broadcasts and more. * * @author Pepich */ -@Version(major = 4, minor = 0, revision = 0, compatible = 1) +@Version(major = 4, minor = 0, revision = 1, compatible = 1) public final class Utils { /** The SimpleDateFormat used for getting the current date. */ @@ -198,13 +199,14 @@ public final class Utils * * @param directCaller used to prevent this method from returning the caller itself. Null if supposed to be ignored. * @return the name of the calling class. */ - public static final String getCaller(ArrayList directCaller) + public static final String getCaller(String... directCaller) { - if (directCaller == null || directCaller.size() == 0) + if (directCaller == null || directCaller.length == 0) return getCaller(); StackTraceElement[] stackTrace = (new Exception()).getStackTrace(); String classname = "Utils"; - for (int i = 0; directCaller.contains(classname) || classname.equals("Utils"); i++) + List callers = Arrays.asList(directCaller); + for (int i = 0; callers.contains(classname) || classname.equals("Utils"); i++) { classname = stackTrace[i].getClassName().replaceAll(".*\\.", ""); } -- 2.45.2 From 110e5996328bd977693ada88a324b257eafa9914 Mon Sep 17 00:00:00 2001 From: Pepich Date: Sat, 8 Jul 2017 12:45:27 +0200 Subject: [PATCH 103/152] Added getID method --- src/com/redstoner/misc/Utils.java | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/src/com/redstoner/misc/Utils.java b/src/com/redstoner/misc/Utils.java index 98081a0..f094b20 100644 --- a/src/com/redstoner/misc/Utils.java +++ b/src/com/redstoner/misc/Utils.java @@ -16,10 +16,10 @@ import com.redstoner.coremods.debugger.Debugger; /** The utils class containing utility functions. Those include but are not limited to sending formatted messages, broadcasts and more. * * @author Pepich */ -@Version(major = 4, minor = 0, revision = 1, compatible = 1) +@Version(major = 4, minor = 0, revision = 2, compatible = 1) public final class Utils { - /** The SimpleDateFormat used for getting the current date. */ + /** The @SimpleDateFormat used for getting the current date. */ public static SimpleDateFormat dateFormat = new SimpleDateFormat("[yyyy-MM-dd HH:mm:ss]"); /** Hidden constructor. Do not instantiate UTILS classes! :) */ @@ -241,10 +241,10 @@ public final class Utils return dateFormat.format(date); } - /** Provides a uniform way of getting the (display)name of a CommandSender. + /** Provides a uniform way of getting the (display)name of a @CommandSender. * - * @param sender The CommandSender to get the name of. - * @return The DisplayName of the CommandSender or if not a player, the name in blue. */ + * @param sender The @CommandSender to get the name of. + * @return The DisplayName of the @CommandSender or if not a @Player, the name in blue. */ public static String getName(CommandSender sender) { if (sender instanceof Player) @@ -253,6 +253,20 @@ public final class Utils return "§9" + sender.getName(); } + /** Provides a uniform way of getting the UUID of a @CommandSender. + * + * @param sender The @CommandSender to get the UUID of. + * @return The UUID of the @CommandSender or if not a player, "CONSOLE" in blue. */ + public static String getID(CommandSender sender) + { + String id; + if (sender instanceof Player) + id = ((Player) sender).getUniqueId().toString(); + else + id = "CONSOLE"; + return id; + } + /** This method "colorifies" a message. * * @param message the message to be colored. @@ -265,7 +279,7 @@ public final class Utils /** This method "colorifies" a message using proper permissions. * * @param message the message to be colored. - * @param sender the command sender whose permissions shall be applied. + * @param sender the @CommandSender whose permissions shall be applied. * @return the colorified message. */ public static String colorify(String message, CommandSender sender, char alternateColorcode) { -- 2.45.2 From 14af1d6fff72ddba243c241b4e7909b0029f80f7 Mon Sep 17 00:00:00 2001 From: Minenash Date: Sat, 8 Jul 2017 15:11:24 -0400 Subject: [PATCH 104/152] Added sendMessage and sendErrorMessage methods w/o the prefix argument. --- src/com/redstoner/misc/Utils.java | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/com/redstoner/misc/Utils.java b/src/com/redstoner/misc/Utils.java index f094b20..fbb7a09 100644 --- a/src/com/redstoner/misc/Utils.java +++ b/src/com/redstoner/misc/Utils.java @@ -26,6 +26,26 @@ public final class Utils private Utils() {} + /** This will send a message to the specified recipient. It will generate the module prefix. + * + * @param recipient Whom to sent the message to. + * @param message The message to sent. Will default to &7 (light_grey) if not specified otherwise. */ + @Debugable + public static void sendMessage(CommandSender recipient, String message) + { + sendMessage(recipient, null, message); + } + + /** This will send a message to the specified recipient. It will generate the module prefix. Also, this will be logged to console as a warning. + * + * @param recipient Whom to sent the message to. + * @param message The message to sent. Will default to &7 (light_grey) if not specified otherwise. */ + @Debugable + public static void sendErrorMessage(CommandSender recipient, String message) + { + sendErrorMessage(recipient, null, message); + } + /** This will send a message to the specified recipient. It will generate the module prefix if you want it to. * * @param recipient Whom to sent the message to. -- 2.45.2 From c81082600f40d11286a6dc1e7acc9bcfb90616d4 Mon Sep 17 00:00:00 2001 From: Pepich Date: Sun, 9 Jul 2017 13:28:07 +0200 Subject: [PATCH 105/152] Updated plugin.yml --- plugin.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugin.yml b/plugin.yml index f6362a2..922a2b4 100644 --- a/plugin.yml +++ b/plugin.yml @@ -1,4 +1,4 @@ -name: JavaUtils -version: 1.0.0 +name: ModuleLoader +version: 4.0.0 authors: [pepich1851] main: com.redstoner.misc.Main \ No newline at end of file -- 2.45.2 From 4524fd19f04430ca4c7648373da8dabb30f71ae2 Mon Sep 17 00:00:00 2001 From: Pepich Date: Thu, 27 Jul 2017 16:26:04 +0200 Subject: [PATCH 106/152] General cleanup, reseting all versions to 4.0 in preparation of release --- src/com/redstoner/annotations/Debugable.java | 14 -- .../redstoner/coremods/debugger/Debugger.java | 201 ------------------ .../coremods/moduleLoader/ModuleLoader.java | 151 +++++++------ src/com/redstoner/misc/Main.java | 2 - src/com/redstoner/misc/Utils.java | 17 +- 5 files changed, 83 insertions(+), 302 deletions(-) delete mode 100644 src/com/redstoner/annotations/Debugable.java delete mode 100644 src/com/redstoner/coremods/debugger/Debugger.java diff --git a/src/com/redstoner/annotations/Debugable.java b/src/com/redstoner/annotations/Debugable.java deleted file mode 100644 index be6ec1c..0000000 --- a/src/com/redstoner/annotations/Debugable.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.redstoner.annotations; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** Debugable annotation, to be added to methods that invoke the Debugger.notifyMethod method for debugging purposes. - * - * @author Pepich */ -@Target(ElementType.METHOD) -@Retention(RetentionPolicy.RUNTIME) -public @interface Debugable -{} diff --git a/src/com/redstoner/coremods/debugger/Debugger.java b/src/com/redstoner/coremods/debugger/Debugger.java deleted file mode 100644 index fb0f1e7..0000000 --- a/src/com/redstoner/coremods/debugger/Debugger.java +++ /dev/null @@ -1,201 +0,0 @@ -package com.redstoner.coremods.debugger; - -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.HashMap; - -import org.bukkit.Bukkit; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; -import org.bukkit.event.Listener; - -import com.nemez.cmdmgr.Command; -import com.nemez.cmdmgr.CommandManager; -import com.redstoner.annotations.Debugable; -import com.redstoner.annotations.Version; -import com.redstoner.misc.Main; -import com.redstoner.misc.Utils; -import com.redstoner.modules.CoreModule; - -import net.md_5.bungee.api.ChatColor; - -/** The Debugger class, first Module to be loaded, responsible for debug interactions such as subscribing to method calls and getting field values on runtime. - * - * @author Pepich */ -@Version(major = 3, minor = 0, revision = 0, compatible = -1) -public final class Debugger implements CoreModule, Listener -{ - private static Debugger instance; - private static HashMap> subs; - private static final boolean enabled = true; - - private Debugger() - { - subs = new HashMap<>(); - } - - public static void init() - { - if (instance == null) - instance = new Debugger(); - CommandManager.registerCommand(instance.getCommandString(), instance, Main.plugin); - } - - public static void notifyMethod(CommandSender recipient, Object... params) - { - Exception e = new Exception(); - String method = e.getStackTrace()[1].getMethodName(); - if (!method.equals("notifyMethod")) - notifyMethod((Object) recipient, params); - String classname = e.getStackTrace()[1].getClassName(); - if (!classname.equals("com.redstoner.coremods.debugger.Debugger")) - notifyMethod((Object) recipient, params); - for (StackTraceElement element : e.getStackTrace()) - { - if (element.getMethodName().equals("notifyMethod")) - continue; - classname = element.getClassName(); - method = element.getMethodName(); - break; - } - boolean subscribed = false; - for (String s : subs.get(recipient)) - { - if (s.equals(classname + "." + method)) - { - subscribed = true; - break; - } - } - if (subscribed) - { - StringBuilder sb = new StringBuilder("&7"); - sb.append(method); - sb.append("("); - if (params != null) - { - for (Object obj : params) - { - if (obj == null) - sb.append("&cNULL"); - else - sb.append(obj.toString()); - sb.append("&7, &e"); - } - sb.delete(sb.length() - 6, sb.length()); - } - sb.append("&7)\n&eTypes:\n&7"); - int i = 0; - for (Object obj : params) - sb.append(i++ + ": &e" + (obj == null ? "&cNULL" : obj.getClass().getName()) + "&7\n"); - String message = "&2---=[ DEBUGGER ]=---\n" + sb.toString(); - message = ChatColor.translateAlternateColorCodes('&', message); - recipient.sendMessage(message); - } - } - - public static void notifyMethod(Object... params) - { - if (!enabled) - { - return; - } - for (Player p : Bukkit.getOnlinePlayers()) - if (subs.containsKey(p)) - notifyMethod(p, params); - CommandSender p = Bukkit.getConsoleSender(); - if (subs.containsKey(p)) - notifyMethod(p, params); - } - - // @noformat - @Override - public String getCommandString() - { - return "command debugger {\n" + - " subscribe [string:classname] [string:methodname] {\n" + - " help Subscribes to all calls of the corresponding debugable method.;\n" + - " perm jutils.debugger.subscribe;\n" + - " run subscribe classname methodname;\n" + - " }\n" + - " unsubscribe [string:classname] [string:methodname] {\n" + - " help Unsubscribes from all calls of the corresponding debugable method.;\n" + - " perm jutils.debugger.subscribe;\n" + - " run unsubscribe classname methodname;\n" + - " }\n" + - "}"; - } - // @format - - @Command(hook = "subscribe") - @Debugable - public boolean subscribeCommand(CommandSender sender, String classname, String methodname) - { - if (!enabled) - { - Utils.sendMessage(sender, null, "Debugger is currently disabled!"); - return true; - } - Class clazz = null; - try - { - clazz = Class.forName(classname); - } - catch (ClassNotFoundException e) - { - Utils.sendErrorMessage(sender, null, "Could not find the class: " + classname); - return true; - } - boolean found = false; - for (Method m : clazz.getMethods()) - { - if (m.getName().matches(methodname)) - { - if (m.isAnnotationPresent(Debugable.class)) - { - found = true; - if (!subs.containsKey(sender)) - subs.put(sender, new ArrayList()); - subs.get(sender).add(classname + "." + methodname); - break; - } - } - } - if (!found) - { - Utils.sendErrorMessage(sender, null, "The method you chose either doesn't exist or is not debugable!"); - return true; - } - Utils.sendMessage(sender, null, "Successfully subsribed to the method &e" + classname + ":" + methodname, '&'); - return true; - } - - @Command(hook = "unsubscribe") - @Debugable - public boolean unsubscribeCommand(CommandSender sender, String classname, String methodname) - { - if (!enabled) - { - Utils.sendMessage(sender, null, "Debugger is currently disabled!"); - return true; - } - if (subs.containsKey(sender)) - { - if (subs.get(sender).remove(classname + "." + methodname)) - { - Utils.sendMessage(sender, null, - "Successfully unsubscribed from the method &e" + classname + ":" + methodname, '&'); - } - else - { - Utils.sendErrorMessage(sender, null, "You were not listening to &e" + classname + ":" + methodname, - '&'); - } - } - else - { - Utils.sendErrorMessage(sender, null, "You are not listening to any methods!"); - } - return true; - } -} diff --git a/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java b/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java index bedb50e..63878db 100644 --- a/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java +++ b/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java @@ -24,9 +24,7 @@ import com.nemez.cmdmgr.Command.AsyncType; import com.nemez.cmdmgr.CommandManager; import com.redstoner.annotations.AutoRegisterListener; import com.redstoner.annotations.Commands; -import com.redstoner.annotations.Debugable; import com.redstoner.annotations.Version; -import com.redstoner.coremods.debugger.Debugger; import com.redstoner.misc.Main; import com.redstoner.misc.Utils; import com.redstoner.misc.VersionHelper; @@ -153,45 +151,9 @@ public final class ModuleLoader implements CoreModule enableModules(); } - /** This method will add a module to the module list, without enabling it.
- * This method is deprecated, use addDynamicModule(String name) instead. When using this method, dynamic reloading of the module will not be supported. - * - * @param clazz The class of the module to be added. */ - @Debugable - @Deprecated - public static final void addModule(Class clazz) - { - Debugger.notifyMethod(clazz); - try - { - Module module = clazz.newInstance(); - modules.put(module, false); - } - catch (InstantiationException | IllegalAccessException e) - { - Utils.error("Could not add " + clazz.getName() + " to the list, constructor not accessible."); - } - } - - @Debugable - private static final void addLoadedModule(Module m) - { - Debugger.notifyMethod(m); - if (modules.containsKey(m)) - if (modules.get(m)) - { - Utils.error( - "Module m was already loaded and enabled. Disable the module before attempting to reload it."); - return; - } - modules.put(m, false); - } - /** Call this to enable all not-yet enabled modules that are known to the loader. */ - @Debugable public static final void enableModules() { - Debugger.notifyMethod(); for (Module module : modules.keySet()) { if (modules.get(module)) @@ -205,11 +167,9 @@ public final class ModuleLoader implements CoreModule * * @param clazz The class of the module to be enabled. * @return true, when the module was successfully enabled. */ - @Debugable @Deprecated public static final boolean enableModule(Class clazz) { - Debugger.notifyMethod(clazz); for (Module module : modules.keySet()) { if (module.getClass().equals(clazz)) @@ -410,7 +370,7 @@ public final class ModuleLoader implements CoreModule { Utils.info( "Found existing module, attempting override. WARNING! This operation will halt the main thread until it is completed."); - Utils.info("Attempting to load new class definition before disabling and removing the old module:"); + Utils.info("Attempting to load new class definition before disabling and removing the old module"); boolean differs = false; Utils.info("Old class definition: Class@" + m.getClass().hashCode()); ClassLoader delegateParent = mainLoader.getParent(); @@ -438,19 +398,27 @@ public final class ModuleLoader implements CoreModule } if (!differs) { - Utils.warn("New class definition equals old definition, are you sure you did everything right?"); - Utils.info("Aborting now..."); - try + if (!debugMode) { - cl.close(); + Utils.warn( + "New class definition equals old definition, are you sure you did everything right?"); + Utils.info("Aborting now..."); + try + { + cl.close(); + } + catch (IOException e) + { + e.printStackTrace(); + } + return; } - catch (IOException e) - { - e.printStackTrace(); - } - return; + else + Utils.warn( + "New class definition equals old definition, but debugMode is enabled. Loading anyways."); } - Utils.info("Found new class definition, attempting to instantiate:"); + else + Utils.info("Found new class definition, attempting to instantiate:"); Module module = null; try { @@ -470,33 +438,38 @@ public final class ModuleLoader implements CoreModule } return; } - Utils.info("Instantiated new class definition, checking versions:"); + Utils.info("Instantiated new class definition, checking versions"); Version oldVersion = m.getClass().getAnnotation(Version.class); Utils.info("Current version: " + VersionHelper.getString(oldVersion)); Version newVersion = module.getClass().getAnnotation(Version.class); Utils.info("Version of remote class: " + VersionHelper.getString(newVersion)); if (oldVersion.equals(newVersion)) { - Utils.error("Detected equal module versions, " + (debugMode - ? " aborting now... Set debugMode to true in your config if you want to continue!" - : " continueing anyways.")); if (!debugMode) { - try + Utils.error("Detected equal module versions, " + (debugMode + ? " aborting now... Set debugMode to true in your config if you want to continue!" + : " continueing anyways.")); + if (!debugMode) { - cl.close(); + try + { + cl.close(); + } + catch (IOException e) + { + e.printStackTrace(); + } + return; } - catch (IOException e) - { - e.printStackTrace(); - } - return; } + else + Utils.warn("New version equals old version, but debugMode is enabled. Loading anyways."); } else - Utils.info("Versions differ, disabling old module:"); + Utils.info("Versions differ, disabling old module"); disableModule(m); - Utils.info("Disabled module, overriding the implementation:"); + Utils.info("Disabled module, overriding the implementation"); modules.remove(m); try { @@ -518,15 +491,27 @@ public final class ModuleLoader implements CoreModule { Class clazz = mainLoader.loadClass(name); Module module = (Module) clazz.newInstance(); - addLoadedModule(module); + modules.put(module, false); enableLoadedModule(module); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) { + if (name.endsWith(".class")) + { + Utils.warn( + "Couldn't find class definition, but path ends with .class -> Attempting again with removed file suffix."); + addDynamicModule(name.replaceAll(".class$", "")); + } + if (!name.contains(".")) + { + Utils.warn( + "Couldn't find class definition, suspecting incomplete path. Attempting autocompletion of path by adding a packet name and trying again."); + addDynamicModule(name.toLowerCase() + "." + name); + } if (!name.startsWith("com.redstoner.modules.")) { Utils.warn( - "Couldn't find class definition, suspecting missing path. Autocompleting path, trying again."); + "Couldn't find class definition, suspecting incomplete path. Attempting autocompletion of packet name and trying again."); addDynamicModule("com.redstoner.modules." + name); } else @@ -551,11 +536,27 @@ public final class ModuleLoader implements CoreModule } if (!name.startsWith("com.redstoner.modules.")) { - Utils.warn("Couldn't find class definition, suspecting missing path. Autocompleting path, trying again."); - removeDynamicModule("com.redstoner.modules." + name); + if (name.endsWith(".class")) + { + Utils.warn( + "Couldn't find class definition, but path ends with .class -> Attempting again with removed file suffix."); + addDynamicModule(name.replaceAll(".class$", "")); + } + if (!name.contains(".")) + { + Utils.warn( + "Couldn't find class definition, suspecting incomplete path. Attempting autocompletion of path by adding a packet name and trying again."); + addDynamicModule(name.toLowerCase() + "." + name); + } + if (!name.startsWith("com.redstoner.modules.")) + { + Utils.warn( + "Couldn't find class definition, suspecting incomplete path. Attempting autocompletion of packet name and trying again."); + addDynamicModule("com.redstoner.modules." + name); + } } else - Utils.error("Couldn't find module! Couldn't "); + Utils.error("Couldn't find module! Couldn't disable nonexisting module!"); } /** Finds a module by name for other modules to reference it. @@ -569,4 +570,16 @@ public final class ModuleLoader implements CoreModule return m; return null; } + + /** Finds a module by name for other modules to reference it. + * + * @param name the name of the module. Use the full path if you are not sure about the module's SimpleClassName being unique. + * @return the instance of the module or @null it none could be found */ + public static boolean exists(String name) + { + for (Module m : modules.keySet()) + if (m.getClass().getSimpleName().equals(name) || m.getClass().getName().equals(name)) + return true; + return false; + } } diff --git a/src/com/redstoner/misc/Main.java b/src/com/redstoner/misc/Main.java index 6c42f34..ddc8355 100644 --- a/src/com/redstoner/misc/Main.java +++ b/src/com/redstoner/misc/Main.java @@ -3,7 +3,6 @@ package com.redstoner.misc; import org.bukkit.plugin.java.JavaPlugin; import com.redstoner.annotations.Version; -import com.redstoner.coremods.debugger.Debugger; import com.redstoner.coremods.moduleLoader.ModuleLoader; import com.redstoner.misc.mysql.MysqlHandler; @@ -20,7 +19,6 @@ public class Main extends JavaPlugin { plugin = this; // Configger.init(); - Debugger.init(); MysqlHandler.init(); ModuleLoader.init(); // Load modules from config diff --git a/src/com/redstoner/misc/Utils.java b/src/com/redstoner/misc/Utils.java index fbb7a09..80f5a8b 100644 --- a/src/com/redstoner/misc/Utils.java +++ b/src/com/redstoner/misc/Utils.java @@ -9,14 +9,12 @@ import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -import com.redstoner.annotations.Debugable; import com.redstoner.annotations.Version; -import com.redstoner.coremods.debugger.Debugger; /** The utils class containing utility functions. Those include but are not limited to sending formatted messages, broadcasts and more. * * @author Pepich */ -@Version(major = 4, minor = 0, revision = 2, compatible = 1) +@Version(major = 4, minor = 0, revision = 0, compatible = 1) public final class Utils { /** The @SimpleDateFormat used for getting the current date. */ @@ -30,7 +28,6 @@ public final class Utils * * @param recipient Whom to sent the message to. * @param message The message to sent. Will default to &7 (light_grey) if not specified otherwise. */ - @Debugable public static void sendMessage(CommandSender recipient, String message) { sendMessage(recipient, null, message); @@ -40,7 +37,6 @@ public final class Utils * * @param recipient Whom to sent the message to. * @param message The message to sent. Will default to &7 (light_grey) if not specified otherwise. */ - @Debugable public static void sendErrorMessage(CommandSender recipient, String message) { sendErrorMessage(recipient, null, message); @@ -51,10 +47,8 @@ public final class Utils * @param recipient Whom to sent the message to. * @param prefix The prefix for the message. If null, the default prefix will be used: &8[&2MODULE&8] * @param message The message to sent. Will default to &7 (light_grey) if not specified otherwise. */ - @Debugable public static void sendMessage(CommandSender recipient, String prefix, String message) { - Debugger.notifyMethod((Object) recipient, prefix, message); if (prefix == null) prefix = "§8[§2" + getCaller() + "§8]: "; recipient.sendMessage(prefix + "§7" + message); @@ -65,10 +59,8 @@ public final class Utils * @param recipient Whom to sent the message to. * @param prefix The prefix for the message. If null, the default prefix will be used: &8[&cMODULE&8] * @param message The message to sent. Will default to &7 (light_grey) if not specified otherwise. */ - @Debugable public static void sendErrorMessage(CommandSender recipient, String prefix, String message) { - Debugger.notifyMethod((Object) recipient, prefix, message); if (prefix == null) prefix = "§8[§c" + getCaller() + "§8]: "; recipient.sendMessage(prefix + "§7" + message); @@ -126,7 +118,6 @@ public final class Utils * Write a class implementing the interface and pass it to this method, the "sendTo()" method will be called for each recipient. * @param logmessage the log message to appear in console. Set to null to not log this (you can still log the original message by returning true in the filter). * @return the amount of people that received the message. */ - @Debugable public static int broadcast(String prefix, String message, BroadcastFilter filter) { if (prefix == null) @@ -168,10 +159,8 @@ public final class Utils /** Prints an info message into console. Supports "&" color codes. * * @param message The message to be put into console. Prefixes are automatically generated. Color defaults to grey. */ - @Debugable public static void info(String message) { - Debugger.notifyMethod(message); String classname = getCaller(); String prefix = "§8[§2" + classname + "§8]: "; Bukkit.getConsoleSender().sendMessage(colorify(prefix + "§7" + message, Bukkit.getConsoleSender(), '&')); @@ -180,10 +169,8 @@ public final class Utils /** Prints a warning message into console. Supports "&" color codes. * * @param message The message to be put into console. Prefixes are automatically generated. Color defaults to grey. */ - @Debugable public static void warn(String message) { - Debugger.notifyMethod(message); String classname = getCaller(); String prefix = "§e[WARN]: §8[§e" + classname + "§8]: "; Bukkit.getConsoleSender().sendMessage(colorify(prefix + "§7" + message, Bukkit.getConsoleSender(), '&')); @@ -192,10 +179,8 @@ public final class Utils /** Used to make an error output to console. Supports "&" color codes. * * @param message The message to be put into console. Prefixes are automatically generated. Color defaults to red. */ - @Debugable public static void error(String message) { - Debugger.notifyMethod(message); String classname = getCaller(); String prefix = "§c[ERROR]: §8[§c" + classname + "§8]: "; Bukkit.getConsoleSender().sendMessage(colorify(prefix + "§7" + message, Bukkit.getConsoleSender(), '&')); -- 2.45.2 From a5c54126bc3491dc1fb8f8fc206e7202d541dff0 Mon Sep 17 00:00:00 2001 From: Pepich Date: Thu, 27 Jul 2017 16:27:07 +0200 Subject: [PATCH 107/152] Added ChatAPI and ChestAPI to manifest.mf --- manifest.mf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.mf b/manifest.mf index 0850661..c8b23f2 100644 --- a/manifest.mf +++ b/manifest.mf @@ -1,3 +1,3 @@ Manifest-Version: 1.0 -Class-Path: ../lib/CommandManager.jar +Class-Path: ../lib/CommandManager.jar ../lib/ChatAPI.jar ../lib/ChestAPI.jar -- 2.45.2 From 5ccfe4b121d4a29fa4d1b8b8880be3bfa756a710 Mon Sep 17 00:00:00 2001 From: Pepich Date: Sun, 17 Sep 2017 15:35:08 +0200 Subject: [PATCH 108/152] Update to APIv4. I hope this no borke git. --- src/com/redstoner/annotations/Commands.java | 3 + .../coremods/moduleLoader/ModuleLoader.cmd | 21 +- .../coremods/moduleLoader/ModuleLoader.java | 364 +++++++++++++----- src/com/redstoner/misc/CommandHolderType.java | 2 +- src/com/redstoner/misc/JsonManager.java | 76 ++-- src/com/redstoner/misc/Main.java | 5 +- src/com/redstoner/misc/Utils.java | 170 +------- src/com/redstoner/misc/VersionHelper.java | 9 + src/com/redstoner/modules/Module.java | 27 +- src/com/redstoner/modules/ModuleLogger.java | 76 ++++ 10 files changed, 443 insertions(+), 310 deletions(-) create mode 100644 src/com/redstoner/modules/ModuleLogger.java diff --git a/src/com/redstoner/annotations/Commands.java b/src/com/redstoner/annotations/Commands.java index 1388de4..537bff0 100644 --- a/src/com/redstoner/annotations/Commands.java +++ b/src/com/redstoner/annotations/Commands.java @@ -1,11 +1,14 @@ package com.redstoner.annotations; import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import com.redstoner.misc.CommandHolderType; @Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) public @interface Commands { CommandHolderType value(); diff --git a/src/com/redstoner/coremods/moduleLoader/ModuleLoader.cmd b/src/com/redstoner/coremods/moduleLoader/ModuleLoader.cmd index e88cafa..eadeeb7 100644 --- a/src/com/redstoner/coremods/moduleLoader/ModuleLoader.cmd +++ b/src/com/redstoner/coremods/moduleLoader/ModuleLoader.cmd @@ -1,18 +1,33 @@ command modules { + [empty] { + help Lists all modules. Color indicates status: §aENABLED §cDISABLED; + perm moduleloader.modules.list; + run list; + } list { help Lists all modules. Color indicates status: §aENABLED §cDISABLED; - perm jutils.modules.list; + perm moduleloader.modules.list; run list; } + -v { + help Lists all modules. Color indicates status: §aENABLED §cDISABLED; + perm moduleloader.modules.list; + run listv; + } + list -v { + help Lists all modules. Color indicates status: §aENABLED §cDISABLED; + perm moduleloader.modules.list; + run listv; + } load [string:name...] { help (Re)-Loads a module. WARNING: Handle with care! This has direct affect on code being executed. This command will temporarily halt the main thread until the class loading operation was completed.; - perm jtuils.modules.admin; + perm moduleloader.modules.admin; run load name; type console; } unload [string:name...] { help Unloads a module. WARNING: Handle with care! This has direct affect on code being executed. This command will temporarily halt the main thread until the class loading operation was completed.; - perm jutils.modules.admin; + perm moduleloader.modules.admin; run unload name; type console; } diff --git a/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java b/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java index 63878db..5666b2a 100644 --- a/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java +++ b/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java @@ -25,16 +25,19 @@ import com.nemez.cmdmgr.CommandManager; import com.redstoner.annotations.AutoRegisterListener; import com.redstoner.annotations.Commands; import com.redstoner.annotations.Version; +import com.redstoner.exceptions.MissingVersionException; import com.redstoner.misc.Main; -import com.redstoner.misc.Utils; import com.redstoner.misc.VersionHelper; import com.redstoner.modules.CoreModule; import com.redstoner.modules.Module; +import com.redstoner.modules.ModuleLogger; + +import net.nemez.chatapi.click.Message; /** The module loader, mother of all modules. Responsible for loading and taking care of all modules. * * @author Pepich */ -@Version(major = 4, minor = 0, revision = 0, compatible = 2) +@Version(major = 4, minor = 0, revision = 0, compatible = 4) public final class ModuleLoader implements CoreModule { private static ModuleLoader instance; @@ -45,6 +48,7 @@ public final class ModuleLoader implements CoreModule private static File configFile; private static FileConfiguration config; private static boolean debugMode = false; + private static HashMap loggers = new HashMap(); private ModuleLoader() { @@ -66,6 +70,7 @@ public final class ModuleLoader implements CoreModule { if (instance == null) instance = new ModuleLoader(); + loggers.put(instance, new ModuleLogger("ModuleLoader")); CommandManager.registerCommand(ModuleLoader.class.getResourceAsStream("ModuleLoader.cmd"), instance, Main.plugin); } @@ -98,7 +103,7 @@ public final class ModuleLoader implements CoreModule { e1.printStackTrace(); } - Utils.error("Invalid config file! Creating new, blank file!"); + instance.getLogger().error("Invalid config file! Creating new, blank file!"); } List coremods = config.getStringList("coremods"); if (coremods == null || coremods.isEmpty()) @@ -143,23 +148,21 @@ public final class ModuleLoader implements CoreModule debugMode = config.getBoolean("debugMode"); for (String s : coremods) if (!s.startsWith("#")) - ModuleLoader.addDynamicModule(s); - enableModules(); + if (!ModuleLoader.addDynamicModule(s)) + { + instance.getLogger().error("Couldn't autocomplete path for module name: " + s + + "! If you're on a case sensitive filesystem, please take note that case correction does not work. Make sure that the classname has proper capitalisation."); + + } for (String s : autoload) if (!s.startsWith("#")) - ModuleLoader.addDynamicModule(s); - enableModules(); - } - - /** Call this to enable all not-yet enabled modules that are known to the loader. */ - public static final void enableModules() - { - for (Module module : modules.keySet()) - { - if (modules.get(module)) - continue; - enableLoadedModule(module); - } + if (!ModuleLoader.addDynamicModule(s)) + { + instance.getLogger().error("Couldn't autocomplete path for module name: " + s + + "! If you're on a case sensitive filesystem, please take note that case correction does not work. Make sure that the classname has proper capitalisation."); + + } + updateConfig(); } /** This method enables a specific module. If no module with that name is known to the loader yet it will be added to the list.
@@ -176,7 +179,7 @@ public final class ModuleLoader implements CoreModule { if (modules.get(module)) { - Utils.info("Module was already enabled! Ignoring module.!"); + instance.getLogger().info("Module was already enabled! Ignoring module.!"); return true; } if (module.onEnable()) @@ -186,14 +189,14 @@ public final class ModuleLoader implements CoreModule { Bukkit.getPluginManager().registerEvents((Listener) module, Main.plugin); } - Utils.info("Enabled module " + module.getClass().getName()); - Utils.info("Loaded module " + module.getClass().getName()); + instance.getLogger().info("Enabled module " + module.getClass().getName()); + instance.getLogger().info("Loaded module " + module.getClass().getName()); modules.put(module, true); return true; } else { - Utils.error("Failed to enable module " + module.getClass().getName()); + instance.getLogger().error("Failed to enable module " + module.getClass().getName()); return false; } } @@ -208,33 +211,36 @@ public final class ModuleLoader implements CoreModule { Bukkit.getPluginManager().registerEvents((Listener) m, Main.plugin); } - Utils.info("Loaded and enabled module " + m.getClass().getName()); - Utils.info("Loaded module " + m.getClass().getName()); + instance.getLogger().info("Loaded and enabled module " + m.getClass().getName()); + instance.getLogger().info("Loaded module " + m.getClass().getName()); return true; } else { - Utils.error("Failed to enable module " + m.getClass().getName()); + instance.getLogger().error("Failed to enable module " + m.getClass().getName()); return false; } } catch (InstantiationException | IllegalAccessException e) { - Utils.error("Could not add " + clazz.getName() + " to the list, constructor not accessible."); + instance.getLogger() + .error("Could not add " + clazz.getName() + " to the list, constructor not accessible."); return false; } } - @SuppressWarnings("deprecation") - private static final void enableLoadedModule(Module module) + private static final void enableLoadedModule(Module module, Version oldVersion) { try { + loggers.put(module, new ModuleLogger(module.getClass().getSimpleName())); if (module.onEnable()) { modules.put(module, true); - if (VersionHelper.isCompatible(VersionHelper.create(2, 0, 0, -1), module.getClass())) - CommandManager.registerCommand(module.getCommandString(), module, Main.plugin); + if (oldVersion.toString().equals("0.0.0.0")) + module.firstLoad(); + else if (!VersionHelper.getVersion(module.getClass()).equals(oldVersion)) + module.migrate(oldVersion); if (VersionHelper.isCompatible(VersionHelper.create(4, 0, 0, 3), module.getClass())) { module.postEnable(); @@ -247,7 +253,8 @@ public final class ModuleLoader implements CoreModule switch (ann.value()) { case File: - File f = new File(module.getClass().getName() + ".cmd"); + File f = new File("plugins/ModuleLoader/classes/" + + module.getClass().getName().replace(".", "/") + ".cmd"); CommandManager.registerCommand(f, module, Main.plugin); break; case Stream: @@ -262,18 +269,16 @@ public final class ModuleLoader implements CoreModule } } } - Utils.info("Loaded module " + module.getClass().getName()); + instance.getLogger().info("Loaded module " + module.getClass().getName()); if (module.getClass().isAnnotationPresent(AutoRegisterListener.class) && (module instanceof Listener)) - { Bukkit.getPluginManager().registerEvents((Listener) module, Main.plugin); - } } else - Utils.error("Failed to load module " + module.getClass().getName()); + instance.getLogger().error("Failed to load module " + module.getClass().getName()); } catch (Exception e) { - Utils.error("Failed to load module " + module.getClass().getName()); + instance.getLogger().error("Failed to load module " + module.getClass().getName()); e.printStackTrace(); } } @@ -285,19 +290,52 @@ public final class ModuleLoader implements CoreModule @Command(hook = "list", async = AsyncType.ALWAYS) public boolean listModulesCommand(CommandSender sender) { - Utils.sendModuleHeader(sender); - StringBuilder sb = new StringBuilder("Modules:\n"); - for (Module module : modules.keySet()) + Message m = new Message(sender, null); + m.appendText(getLogger().getHeader()); + m.appendText("§2Modules:\n&e"); + Module[] modules = ModuleLoader.modules.keySet().toArray(new Module[] {}); + for (int i = 0; i < modules.length; i++) { + Module module = modules[i]; String[] classPath = module.getClass().getName().split("\\."); String classname = classPath[classPath.length - 1]; - sb.append(modules.get(module) ? "&a" : "&c"); - sb.append(classname); - sb.append(", "); + m.appendText((ModuleLoader.modules.get(module) ? "§a" : "§c") + classname); + if (i + 1 < modules.length) + m.appendText("§7, "); } - sb.delete(sb.length() - 2, sb.length()); - Utils.sendMessage(sender, " §e", sb.toString(), '&'); - Utils.sendMessage(sender, " §7", "For more detailed information, consult the debugger."); + m.send(); + return true; + } + + /** This method lists all modules to the specified CommandSender. The modules will be color coded correspondingly to their enabled status. + * + * @param sender The person to send the info to, usually the issuer of the command or the console sender. + * @return true. */ + @Command(hook = "listv", async = AsyncType.ALWAYS) + public boolean listModulesCommandVersion(CommandSender sender) + { + Message m = new Message(sender, null); + m.appendText(getLogger().getHeader()); + m.appendText("§2Modules:\n&e"); + Module[] modules = ModuleLoader.modules.keySet().toArray(new Module[] {}); + for (int i = 0; i < modules.length; i++) + { + Module module = modules[i]; + String[] classPath = module.getClass().getName().split("\\."); + String classname = classPath[classPath.length - 1]; + try + { + m.appendText((ModuleLoader.modules.get(module) ? "§a" : "§c") + classname + "§e(" + + VersionHelper.getVersion(module.getClass()) + ")"); + } + catch (MissingVersionException e) + { + m.appendText((ModuleLoader.modules.get(module) ? "§a" : "§c") + classname + "§c" + "(Unknown Version)"); + } + if (i + 1 < modules.length) + m.appendText("§7, "); + } + m.send(); return true; } @@ -351,40 +389,55 @@ public final class ModuleLoader implements CoreModule @Command(hook = "load") public boolean loadModule(CommandSender sender, String name) { - addDynamicModule(name); + if (!addDynamicModule(name)) + { + instance.getLogger().message(sender, true, "Couldn't autocomplete path for module name: " + name + + "! If you're on a case sensitive filesystem, please take note that case correction does not work. Make sure that the classname has proper capitalisation."); + + } + updateConfig(); return true; } @Command(hook = "unload") public boolean unloadModule(CommandSender sender, String name) { - removeDynamicModule(name); + if (!removeDynamicModule(name)) + instance.getLogger().error("Couldn't find module! Couldn't disable nonexisting module!"); return true; } - public static final void addDynamicModule(String name) + public static final boolean addDynamicModule(String raw_name) { + String[] raw = raw_name.split(" "); + String name = raw[0]; + Version oldVersion; + if (raw.length > 1) + oldVersion = VersionHelper.getVersion(raw[1]); + else + oldVersion = VersionHelper.create(0, 0, 0, 0); for (Module m : modules.keySet()) { if (m.getClass().getName().equals(name)) { - Utils.info( + instance.getLogger().info( "Found existing module, attempting override. WARNING! This operation will halt the main thread until it is completed."); - Utils.info("Attempting to load new class definition before disabling and removing the old module"); + instance.getLogger() + .info("Attempting to load new class definition before disabling and removing the old module"); boolean differs = false; - Utils.info("Old class definition: Class@" + m.getClass().hashCode()); + instance.getLogger().info("Old class definition: Class@" + m.getClass().hashCode()); ClassLoader delegateParent = mainLoader.getParent(); Class newClass = null; URLClassLoader cl = new URLClassLoader(urls, delegateParent); try { newClass = cl.loadClass(m.getClass().getName()); - Utils.info("Found new class definition: Class@" + newClass.hashCode()); + instance.getLogger().info("Found new class definition: Class@" + newClass.hashCode()); differs = m.getClass() != newClass; } catch (ClassNotFoundException e) { - Utils.error("Could not find a class definition, aborting now!"); + instance.getLogger().error("Could not find a class definition, aborting now!"); e.printStackTrace(); try { @@ -394,15 +447,15 @@ public final class ModuleLoader implements CoreModule { e1.printStackTrace(); } - return; + return false; } if (!differs) { if (!debugMode) { - Utils.warn( + instance.getLogger().warn( "New class definition equals old definition, are you sure you did everything right?"); - Utils.info("Aborting now..."); + instance.getLogger().info("Aborting now..."); try { cl.close(); @@ -411,14 +464,14 @@ public final class ModuleLoader implements CoreModule { e.printStackTrace(); } - return; + return false; } else - Utils.warn( + instance.getLogger().warn( "New class definition equals old definition, but debugMode is enabled. Loading anyways."); } else - Utils.info("Found new class definition, attempting to instantiate:"); + instance.getLogger().info("Found new class definition, attempting to instantiate:"); Module module = null; try { @@ -426,7 +479,7 @@ public final class ModuleLoader implements CoreModule } catch (InstantiationException | IllegalAccessException e) { - Utils.error("Could not instantiate the module, aborting!"); + instance.getLogger().error("Could not instantiate the module, aborting!"); e.printStackTrace(); try { @@ -436,20 +489,21 @@ public final class ModuleLoader implements CoreModule { e1.printStackTrace(); } - return; + return false; } - Utils.info("Instantiated new class definition, checking versions"); - Version oldVersion = m.getClass().getAnnotation(Version.class); - Utils.info("Current version: " + VersionHelper.getString(oldVersion)); + instance.getLogger().info("Instantiated new class definition, checking versions"); + oldVersion = m.getClass().getAnnotation(Version.class); + instance.getLogger().info("Current version: " + VersionHelper.getString(oldVersion)); Version newVersion = module.getClass().getAnnotation(Version.class); - Utils.info("Version of remote class: " + VersionHelper.getString(newVersion)); + instance.getLogger().info("Version of remote class: " + VersionHelper.getString(newVersion)); if (oldVersion.equals(newVersion)) { if (!debugMode) { - Utils.error("Detected equal module versions, " + (debugMode - ? " aborting now... Set debugMode to true in your config if you want to continue!" - : " continueing anyways.")); + instance.getLogger() + .error("Detected equal module versions, " + (debugMode + ? " aborting now... Set debugMode to true in your config if you want to continue!" + : " continueing anyways.")); if (!debugMode) { try @@ -460,16 +514,17 @@ public final class ModuleLoader implements CoreModule { e.printStackTrace(); } - return; + return false; } } else - Utils.warn("New version equals old version, but debugMode is enabled. Loading anyways."); + instance.getLogger() + .warn("New version equals old version, but debugMode is enabled. Loading anyways."); } else - Utils.info("Versions differ, disabling old module"); + instance.getLogger().info("Versions differ, disabling old module"); disableModule(m); - Utils.info("Disabled module, overriding the implementation"); + instance.getLogger().info("Disabled module, overriding the implementation"); modules.remove(m); try { @@ -482,81 +537,115 @@ public final class ModuleLoader implements CoreModule } modules.put(module, false); loaders.put(module, cl); - Utils.info("Successfully updated class definition. Enabling new implementation:"); - enableLoadedModule(module); - return; + instance.getLogger().info("Successfully updated class definition. Enabling new implementation:"); + enableLoadedModule(module, oldVersion); + return true; } } + ClassLoader delegateParent = mainLoader.getParent(); + URLClassLoader cl = new URLClassLoader(urls, delegateParent); try { - Class clazz = mainLoader.loadClass(name); + Class clazz = cl.loadClass(name); Module module = (Module) clazz.newInstance(); modules.put(module, false); - enableLoadedModule(module); + loaders.put(module, cl); + enableLoadedModule(module, oldVersion); + return true; } - catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) + catch (NoClassDefFoundError | ClassNotFoundException | InstantiationException | IllegalAccessException e) { + try + { + cl.close(); + } + catch (IOException e1) + {} + if (e instanceof NoClassDefFoundError) + { + NoClassDefFoundError exception = (NoClassDefFoundError) e; + String[] exMessage = exception.getMessage().split(" "); + String moduleName = exMessage[exMessage.length - 1] + .substring(0, exMessage[exMessage.length - 1].length() + - (exMessage[exMessage.length - 1].endsWith(")") ? 1 : 0)) + .replace("/", "."); + if (!moduleName.equalsIgnoreCase(name)) + { + instance.getLogger() + .error("Class &e" + moduleName + "&r couldn't be found! Suspecting a missing dependency!"); + return false; + } + else + instance.getLogger().warn( + "Couldn't find class definition, attempting to get proper classname from thrown Exception."); + if (addDynamicModule(moduleName)) + return true; + } if (name.endsWith(".class")) { - Utils.warn( + instance.getLogger().warn( "Couldn't find class definition, but path ends with .class -> Attempting again with removed file suffix."); - addDynamicModule(name.replaceAll(".class$", "")); + if (addDynamicModule(name.replaceAll(".class$", ""))) + return true; } if (!name.contains(".")) { - Utils.warn( - "Couldn't find class definition, suspecting incomplete path. Attempting autocompletion of path by adding a packet name and trying again."); - addDynamicModule(name.toLowerCase() + "." + name); + instance.getLogger().warn( + "Couldn't find class definition, suspecting incomplete path. Attempting autocompletion of path by adding a package name and trying again."); + if (addDynamicModule(name.toLowerCase() + "." + name)) + return true; } - if (!name.startsWith("com.redstoner.modules.")) + if (!name.startsWith("com.redstoner.modules.") && name.contains(".")) { - Utils.warn( - "Couldn't find class definition, suspecting incomplete path. Attempting autocompletion of packet name and trying again."); - addDynamicModule("com.redstoner.modules." + name); + instance.getLogger().warn( + "Couldn't find class definition, suspecting incomplete path. Attempting autocompletion of package name and trying again."); + if (addDynamicModule("com.redstoner.modules." + name)) + return true; } - else - e.printStackTrace(); } + return false; } - public static final void removeDynamicModule(String name) + public static final boolean removeDynamicModule(String name) { for (Module m : modules.keySet()) { if (m.getClass().getName().equals(name)) { - Utils.info( + instance.getLogger().info( "Found existing module, attempting unload. WARNING! This operation will halt the main thread until it is completed."); - Utils.info("Attempting to disable module properly:"); + instance.getLogger().info("Attempting to disable module properly:"); disableModule(m); modules.remove(m); - Utils.info("Disabled module."); - return; + instance.getLogger().info("Disabled module."); + return true; } } if (!name.startsWith("com.redstoner.modules.")) { if (name.endsWith(".class")) { - Utils.warn( + instance.getLogger().warn( "Couldn't find class definition, but path ends with .class -> Attempting again with removed file suffix."); - addDynamicModule(name.replaceAll(".class$", "")); + if (removeDynamicModule(name.replaceAll(".class$", ""))) + return true; } if (!name.contains(".")) { - Utils.warn( - "Couldn't find class definition, suspecting incomplete path. Attempting autocompletion of path by adding a packet name and trying again."); - addDynamicModule(name.toLowerCase() + "." + name); + instance.getLogger().warn( + "Couldn't find class definition, suspecting incomplete path. Attempting autocompletion of path by adding a package name and trying again."); + if (removeDynamicModule(name.toLowerCase() + "." + name)) + return true; } if (!name.startsWith("com.redstoner.modules.")) { - Utils.warn( - "Couldn't find class definition, suspecting incomplete path. Attempting autocompletion of packet name and trying again."); - addDynamicModule("com.redstoner.modules." + name); + instance.getLogger().warn( + "Couldn't find class definition, suspecting incomplete path. Attempting autocompletion of package name and trying again."); + if (removeDynamicModule("com.redstoner.modules." + name)) + return true; } } - else - Utils.error("Couldn't find module! Couldn't disable nonexisting module!"); + return false; } /** Finds a module by name for other modules to reference it. @@ -566,7 +655,7 @@ public final class ModuleLoader implements CoreModule public static Module getModule(String name) { for (Module m : modules.keySet()) - if (m.getClass().getSimpleName().equals(name) || m.getClass().getName().equals(name)) + if (m.getClass().getSimpleName().equalsIgnoreCase(name) || m.getClass().getName().equalsIgnoreCase(name)) return m; return null; } @@ -582,4 +671,69 @@ public final class ModuleLoader implements CoreModule return true; return false; } + + public static ModuleLogger getModuleLogger(Module module) + { + return loggers.get(module); + } + + public static void updateConfig() + { + List coremods = config.getStringList("coremods"); + ArrayList new_coremods = new ArrayList(); + List autoload = config.getStringList("autoload"); + ArrayList new_autoload = new ArrayList(); + + for (String s : coremods) + { + if (s.startsWith("#")) + { + new_coremods.add(s); + } + else + { + s = s.split(" ")[0]; + try + { + new_coremods.add(getModule(s).getClass().getName() + " " + + VersionHelper.getVersion(getModule(s).getClass())); + } + catch (Exception e) + { + new_coremods.add(s + " " + VersionHelper.getString(VersionHelper.create(0, 0, 0, 0))); + } + } + } + for (String s : autoload) + { + if (s.startsWith("#")) + { + new_autoload.add(s); + } + else + { + s = s.split(" ")[0]; + try + { + new_autoload.add(getModule(s).getClass().getName() + " " + + VersionHelper.getVersion(getModule(s).getClass())); + } + catch (Exception e) + { + new_autoload.add(s + " " + VersionHelper.getString(VersionHelper.create(0, 0, 0, 0))); + } + } + } + + config.set("coremods", new_coremods); + config.set("autoload", new_autoload); + try + { + config.save(configFile); + } + catch (IOException e) + { + e.printStackTrace(); + } + } } diff --git a/src/com/redstoner/misc/CommandHolderType.java b/src/com/redstoner/misc/CommandHolderType.java index 19b9dda..7c4383e 100644 --- a/src/com/redstoner/misc/CommandHolderType.java +++ b/src/com/redstoner/misc/CommandHolderType.java @@ -8,6 +8,6 @@ public enum CommandHolderType { Stream, File, - @Deprecated String, + String, None } diff --git a/src/com/redstoner/misc/JsonManager.java b/src/com/redstoner/misc/JsonManager.java index 998d137..cad716c 100644 --- a/src/com/redstoner/misc/JsonManager.java +++ b/src/com/redstoner/misc/JsonManager.java @@ -55,25 +55,35 @@ public class JsonManager @Override public void run() { - if (destination.exists()) - destination.delete(); - else if (!destination.getParentFile().exists()) - destination.getParentFile().mkdirs(); - try - { - destination.createNewFile(); - FileWriter writer = new FileWriter(destination); - object.writeJSONString(writer); - writer.flush(); - writer.close(); - } - catch (IOException e) - {} + saveSync(object, destination); } }); t.start(); } + /** Saves a JSONObject to a file. Will create the necessary FileStructure like folders and the file itself.
+ * Note that this operation will be run on the same thread that you are calling it from! + * + * @param object the JSONObject to save. + * @param destination the file to write to. */ + public static void saveSync(JSONObject object, File destination) + { + if (destination.exists()) + destination.delete(); + else if (!destination.getParentFile().exists()) + destination.getParentFile().mkdirs(); + try + { + destination.createNewFile(); + FileWriter writer = new FileWriter(destination); + object.writeJSONString(writer); + writer.flush(); + writer.close(); + } + catch (IOException e) + {} + } + /** Loads a JSONArray from a file. * * @param source the file to load from. @@ -106,22 +116,32 @@ public class JsonManager @Override public void run() { - if (destination.exists()) - destination.delete(); - else if (!destination.getParentFile().exists()) - destination.getParentFile().mkdirs(); - try - { - destination.createNewFile(); - FileWriter writer = new FileWriter(destination); - array.writeJSONString(writer); - writer.flush(); - writer.close(); - } - catch (IOException e) - {} + saveSync(array, destination); } }); t.start(); } + + /** Saves a JSONArray to a file. Will create the necessary FileStructure like folders and the file itself.
+ * Note that this operation will be run on the same thread that you are calling it from! + * + * @param object the JSONArray to save. + * @param destination the file to write to. */ + public static void saveSync(JSONArray array, File destination) + { + if (destination.exists()) + destination.delete(); + else if (!destination.getParentFile().exists()) + destination.getParentFile().mkdirs(); + try + { + destination.createNewFile(); + FileWriter writer = new FileWriter(destination); + array.writeJSONString(writer); + writer.flush(); + writer.close(); + } + catch (IOException e) + {} + } } diff --git a/src/com/redstoner/misc/Main.java b/src/com/redstoner/misc/Main.java index ddc8355..b24e532 100644 --- a/src/com/redstoner/misc/Main.java +++ b/src/com/redstoner/misc/Main.java @@ -6,6 +6,8 @@ import com.redstoner.annotations.Version; import com.redstoner.coremods.moduleLoader.ModuleLoader; import com.redstoner.misc.mysql.MysqlHandler; +import net.nemez.chatapi.ChatAPI; + /** Main class. Duh. * * @author Pepich */ @@ -18,13 +20,12 @@ public class Main extends JavaPlugin public void onEnable() { plugin = this; + ChatAPI.initialize(this); // Configger.init(); MysqlHandler.init(); ModuleLoader.init(); // Load modules from config ModuleLoader.loadFromConfig(); - // And enable them - ModuleLoader.enableModules(); } @Override diff --git a/src/com/redstoner/misc/Utils.java b/src/com/redstoner/misc/Utils.java index 80f5a8b..937ba1f 100644 --- a/src/com/redstoner/misc/Utils.java +++ b/src/com/redstoner/misc/Utils.java @@ -11,6 +11,8 @@ import org.bukkit.entity.Player; import com.redstoner.annotations.Version; +import net.nemez.chatapi.ChatAPI; + /** The utils class containing utility functions. Those include but are not limited to sending formatted messages, broadcasts and more. * * @author Pepich */ @@ -24,90 +26,6 @@ public final class Utils private Utils() {} - /** This will send a message to the specified recipient. It will generate the module prefix. - * - * @param recipient Whom to sent the message to. - * @param message The message to sent. Will default to &7 (light_grey) if not specified otherwise. */ - public static void sendMessage(CommandSender recipient, String message) - { - sendMessage(recipient, null, message); - } - - /** This will send a message to the specified recipient. It will generate the module prefix. Also, this will be logged to console as a warning. - * - * @param recipient Whom to sent the message to. - * @param message The message to sent. Will default to &7 (light_grey) if not specified otherwise. */ - public static void sendErrorMessage(CommandSender recipient, String message) - { - sendErrorMessage(recipient, null, message); - } - - /** This will send a message to the specified recipient. It will generate the module prefix if you want it to. - * - * @param recipient Whom to sent the message to. - * @param prefix The prefix for the message. If null, the default prefix will be used: &8[&2MODULE&8] - * @param message The message to sent. Will default to &7 (light_grey) if not specified otherwise. */ - public static void sendMessage(CommandSender recipient, String prefix, String message) - { - if (prefix == null) - prefix = "§8[§2" + getCaller() + "§8]: "; - recipient.sendMessage(prefix + "§7" + message); - } - - /** This will send a message to the specified recipient. It will generate the module prefix if you want it to. Also, this will be logged to console as a warning. - * - * @param recipient Whom to sent the message to. - * @param prefix The prefix for the message. If null, the default prefix will be used: &8[&cMODULE&8] - * @param message The message to sent. Will default to &7 (light_grey) if not specified otherwise. */ - public static void sendErrorMessage(CommandSender recipient, String prefix, String message) - { - if (prefix == null) - prefix = "§8[§c" + getCaller() + "§8]: "; - recipient.sendMessage(prefix + "§7" + message); - } - - /** Invokes sendMessage. This method will additionally translate alternate color codes for you. - * - * @param recipient Whom to sent the message to. - * @param prefix The prefix for the message. If null, the default prefix will be used: &8[&cMODULE&8] - * @param message The message to sent. Will default to &7 (light_grey) if not specified otherwise. - * @param alternateColorCode The alternate color code indicator to use. If set to '&' then "&7" would be translated to "§7". Works with any char. */ - public static void sendMessage(CommandSender recipient, String prefix, String message, char alternateColorCode) - { - if (prefix == null) - prefix = "§8[§2" + getCaller() + "§8]: "; - sendMessage(recipient, colorify(prefix, alternateColorCode), colorify(message, alternateColorCode)); - } - - /** Invokes sendErrorMessage. This method will additionally translate alternate color codes for you. - * - * @param recipient Whom to sent the message to. - * @param prefix The prefix for the message. If null, the default prefix will be used: &8[&cMODULE&8] - * @param message The message to sent. Will default to &7 (light_grey) if not specified otherwise. - * @param alternateColorCode The alternate color code indicator to use. If set to '&' then "&7" would be translated to "§7". Works with any char. */ - public static void sendErrorMessage(CommandSender recipient, String prefix, String message, char alternateColorCode) - { - if (prefix == null) - prefix = "§8[§c" + getCaller() + "§8]: "; - sendErrorMessage(recipient, colorify(prefix, '&'), colorify(message, '&')); - } - - /** This method broadcasts a message to all players (and console) that are allowed by the filter. Set the filter to NULL to broadcast to everyone.
- * This will not be logged to console except when you return true in the filter. - * - * @param message the message to be sent around - * @param filter the BroadcastFilter to be applied.
- * Write a class implementing the interface and pass it to this method, the "sendTo()" method will be called for each recipient. - * @param alternateColorCode The alternate color code indicator to use. If set to '&' then "&7" would be translated to "§7". Works with any char. - * @return the amount of people that received the message. */ - public static int broadcast(String prefix, String message, BroadcastFilter filter, char alternateColorCode) - { - if (prefix == null) - prefix = "§8[§2" + getCaller() + "§8]: "; - message = colorify(message, alternateColorCode); - return broadcast(prefix, message, filter); - } - /** This method broadcasts a message to all players and console that are allowed by the filter. Set the filter to NULL to broadcast to everyone.
* If you want to, you can set a message that will be logged to console. Set to null to not log anything.
* You can still allow console in the filter to log the original message. @@ -120,6 +38,7 @@ public final class Utils * @return the amount of people that received the message. */ public static int broadcast(String prefix, String message, BroadcastFilter filter) { + message = ChatAPI.colorify(null, message); if (prefix == null) prefix = "§8[§2" + getCaller() + "§8]: "; if (filter == null) @@ -147,45 +66,6 @@ public final class Utils } } - /** Deprecated. Use Utils.info(message) instead. - * - * @param message The message to be put into console. Prefixes are automatically generated. */ - @Deprecated - public static void log(String message) - { - info(message); - } - - /** Prints an info message into console. Supports "&" color codes. - * - * @param message The message to be put into console. Prefixes are automatically generated. Color defaults to grey. */ - public static void info(String message) - { - String classname = getCaller(); - String prefix = "§8[§2" + classname + "§8]: "; - Bukkit.getConsoleSender().sendMessage(colorify(prefix + "§7" + message, Bukkit.getConsoleSender(), '&')); - } - - /** Prints a warning message into console. Supports "&" color codes. - * - * @param message The message to be put into console. Prefixes are automatically generated. Color defaults to grey. */ - public static void warn(String message) - { - String classname = getCaller(); - String prefix = "§e[WARN]: §8[§e" + classname + "§8]: "; - Bukkit.getConsoleSender().sendMessage(colorify(prefix + "§7" + message, Bukkit.getConsoleSender(), '&')); - } - - /** Used to make an error output to console. Supports "&" color codes. - * - * @param message The message to be put into console. Prefixes are automatically generated. Color defaults to red. */ - public static void error(String message) - { - String classname = getCaller(); - String prefix = "§c[ERROR]: §8[§c" + classname + "§8]: "; - Bukkit.getConsoleSender().sendMessage(colorify(prefix + "§7" + message, Bukkit.getConsoleSender(), '&')); - } - /** This method will find the next parent caller and return their class name, omitting package names. * * @return the Name of the calling class. */ @@ -218,25 +98,6 @@ public final class Utils return classname; } - /** Displays the module header to the recipient.
- * Format: &2--=[ %MODULE% ]=-- - * - * @param recipient Whom to display the header to. */ - public static void sendModuleHeader(CommandSender recipient) - { - sendModuleHeader(recipient, getCaller()); - } - - /** Displays the module header to the recipient.
- * Format: &2--=[ %HEADER% ]=-- - * - * @param recipient Whom to display the header to. - * @param header The module name. */ - public static void sendModuleHeader(CommandSender recipient, String header) - { - recipient.sendMessage("§2--=[ " + header + " ]=--"); - } - /** Provides a uniform way of getting the date for all modules. * * @return The current date in the format "[dd-mm-yyyy hh:mm:ss]" */ @@ -271,29 +132,4 @@ public final class Utils id = "CONSOLE"; return id; } - - /** This method "colorifies" a message. - * - * @param message the message to be colored. - * @return the colorified message. */ - public static String colorify(String message, char alternateColorcode) - { - return colorify(message, Bukkit.getConsoleSender(), alternateColorcode); - } - - /** This method "colorifies" a message using proper permissions. - * - * @param message the message to be colored. - * @param sender the @CommandSender whose permissions shall be applied. - * @return the colorified message. */ - public static String colorify(String message, CommandSender sender, char alternateColorcode) - { - if (sender.hasPermission("essentials.chat.color")) - message = message.replaceAll(alternateColorcode + "([0-9a-fA-FrR])", "§$1"); - if (sender.hasPermission("essentials.chat.format")) - message = message.replaceAll(alternateColorcode + "(l-oL-OrR)", "§$1"); - if (sender.hasPermission("essentials.chat.magic")) - message = message.replaceAll(alternateColorcode + "([kKrR])", "§$1"); - return message.replace(alternateColorcode + "§", alternateColorcode + ""); - } } diff --git a/src/com/redstoner/misc/VersionHelper.java b/src/com/redstoner/misc/VersionHelper.java index 1b20b16..e4a9403 100644 --- a/src/com/redstoner/misc/VersionHelper.java +++ b/src/com/redstoner/misc/VersionHelper.java @@ -97,6 +97,15 @@ public final class VersionHelper return ver.major() + "." + ver.minor() + "." + ver.revision() + "." + ver.compatible(); } + public static Version getVersion(String ver) + { + String[] raw = ver.split("\\."); + if (raw.length != 4) + return null; + return VersionHelper.create(Integer.parseInt(raw[0]), Integer.parseInt(raw[1]), Integer.parseInt(raw[2]), + Integer.parseInt(raw[3])); + } + /** This method creates a new Version to use for compatibility checks. * * @param major The major version diff --git a/src/com/redstoner/modules/Module.java b/src/com/redstoner/modules/Module.java index 78488b7..1c89e15 100644 --- a/src/com/redstoner/modules/Module.java +++ b/src/com/redstoner/modules/Module.java @@ -1,11 +1,12 @@ package com.redstoner.modules; import com.redstoner.annotations.Version; +import com.redstoner.coremods.moduleLoader.ModuleLoader; /** Interface for the Module class. Modules must always have an empty constructor to be invoked by the ModuleLoader. * * @author Pepich */ -@Version(major = 3, minor = 0, revision = 0, compatible = 2) +@Version(major = 4, minor = 0, revision = 0, compatible = 0) public interface Module { /** Will be called when the module gets enabled. */ @@ -23,13 +24,31 @@ public interface Module public default void onDisable() {} - /** Gets called on registration of the module. - * THIS WAS ONLY KEPT FOR COMPATIBILITY REASONS. Please register commands yourself instead using the "postEnable" method. + /** Gets called on registration of the module, when this option is selected for command registration * * @return The String used for the CommandManager to register the commands. */ - @Deprecated public default String getCommandString() { return null; } + + public default ModuleLogger getLogger() + { + return ModuleLoader.getModuleLogger(this); + } + + /** This method gets run the very first time a module gets loaded. You can use this to set up file structures or background data. */ + public default void firstLoad() + {} + + /** This method gets run every time a module gets loaded and its version has changed. + * + * @param old The version of the previous module. */ + public default void migrate(Version old) + {} + + default void setPrefix(final String name) + { + getLogger().setName(name); + } } diff --git a/src/com/redstoner/modules/ModuleLogger.java b/src/com/redstoner/modules/ModuleLogger.java new file mode 100644 index 0000000..8141976 --- /dev/null +++ b/src/com/redstoner/modules/ModuleLogger.java @@ -0,0 +1,76 @@ +package com.redstoner.modules; + +import org.bukkit.Bukkit; +import org.bukkit.command.CommandSender; + +import com.redstoner.annotations.Version; + +import net.nemez.chatapi.ChatAPI; +import net.nemez.chatapi.click.Message; + +@Version(major = 4, minor = 0, revision = 0, compatible = -1) +public class ModuleLogger +{ + public static final String PREFIX_WARN = "§8[§eWARN§8]:§7 "; + public static final String PREFIX_ERROR = "§8[§cERROR§8]:§7 "; + + private String name; + + public ModuleLogger(final String name) + { + this.name = name; + } + + public void info(final String message) + { + Bukkit.getConsoleSender().sendMessage(getPrefix() + ChatAPI.colorify(null, message)); + } + + public void warn(final String message) + { + Bukkit.getConsoleSender().sendMessage(PREFIX_WARN + getPrefix() + ChatAPI.colorify(null, message)); + } + + public void error(final String message) + { + Bukkit.getConsoleSender().sendMessage(PREFIX_ERROR + getPrefix() + ChatAPI.colorify(null, message)); + } + + public void message(final CommandSender recipient, final String... message) + { + message(recipient, false, message); + } + + public void message(final CommandSender recipient, final boolean error, final String... message) + { + Message m = new Message(recipient, null); + if (message.length == 1) + m.appendText(getPrefix(error) + message[0]); + else + { + m.appendText(getHeader()); + m.appendText("&7" + String.join("\n&7", message)); + } + m.send(); + } + + public String getPrefix() + { + return getPrefix(false); + } + + public String getPrefix(final boolean error) + { + return "§8[§" + (error ? 'c' : '2') + name + "§8]§7 "; + } + + public String getHeader() + { + return "§2--=[ " + name + " ]=--\n"; + } + + protected final void setName(final String name) + { + this.name = name; + } +} -- 2.45.2 From d2810d09f7fae9698dbd8228dff70a8e1e84d4ef Mon Sep 17 00:00:00 2001 From: Pepich Date: Fri, 13 Oct 2017 18:03:40 +0200 Subject: [PATCH 109/152] Broadcast no longer color translates --- src/com/redstoner/misc/Utils.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/com/redstoner/misc/Utils.java b/src/com/redstoner/misc/Utils.java index 937ba1f..0902382 100644 --- a/src/com/redstoner/misc/Utils.java +++ b/src/com/redstoner/misc/Utils.java @@ -11,12 +11,10 @@ import org.bukkit.entity.Player; import com.redstoner.annotations.Version; -import net.nemez.chatapi.ChatAPI; - /** The utils class containing utility functions. Those include but are not limited to sending formatted messages, broadcasts and more. * * @author Pepich */ -@Version(major = 4, minor = 0, revision = 0, compatible = 1) +@Version(major = 4, minor = 0, revision = 1, compatible = 1) public final class Utils { /** The @SimpleDateFormat used for getting the current date. */ @@ -38,7 +36,6 @@ public final class Utils * @return the amount of people that received the message. */ public static int broadcast(String prefix, String message, BroadcastFilter filter) { - message = ChatAPI.colorify(null, message); if (prefix == null) prefix = "§8[§2" + getCaller() + "§8]: "; if (filter == null) -- 2.45.2 From 95896beadc320393514d645935ee18020f82e977 Mon Sep 17 00:00:00 2001 From: Pepich Date: Mon, 16 Oct 2017 20:42:25 +0200 Subject: [PATCH 110/152] Fixed improper version respecting --- .../coremods/moduleLoader/ModuleLoader.java | 33 +++++++++---------- 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java b/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java index 5666b2a..b4fbbe4 100644 --- a/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java +++ b/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java @@ -37,18 +37,18 @@ import net.nemez.chatapi.click.Message; /** The module loader, mother of all modules. Responsible for loading and taking care of all modules. * * @author Pepich */ -@Version(major = 4, minor = 0, revision = 0, compatible = 4) +@Version(major = 4, minor = 0, revision = 1, compatible = 4) public final class ModuleLoader implements CoreModule { private static ModuleLoader instance; - private static final HashMap modules = new HashMap(); + private static final HashMap modules = new HashMap<>(); private static URL[] urls; private static URLClassLoader mainLoader; - private static HashMap loaders = new HashMap(); + private static HashMap loaders = new HashMap<>(); private static File configFile; private static FileConfiguration config; private static boolean debugMode = false; - private static HashMap loggers = new HashMap(); + private static HashMap loggers = new HashMap<>(); private ModuleLoader() { @@ -152,7 +152,7 @@ public final class ModuleLoader implements CoreModule { instance.getLogger().error("Couldn't autocomplete path for module name: " + s + "! If you're on a case sensitive filesystem, please take note that case correction does not work. Make sure that the classname has proper capitalisation."); - + } for (String s : autoload) if (!s.startsWith("#")) @@ -160,7 +160,7 @@ public final class ModuleLoader implements CoreModule { instance.getLogger().error("Couldn't autocomplete path for module name: " + s + "! If you're on a case sensitive filesystem, please take note that case correction does not work. Make sure that the classname has proper capitalisation."); - + } updateConfig(); } @@ -237,14 +237,12 @@ public final class ModuleLoader implements CoreModule if (module.onEnable()) { modules.put(module, true); - if (oldVersion.toString().equals("0.0.0.0")) + if (VersionHelper.getString(oldVersion).equals("0.0.0.0")) module.firstLoad(); - else if (!VersionHelper.getVersion(module.getClass()).equals(oldVersion)) + else if (!VersionHelper.getVersion(module.getClass()).equals(VersionHelper.getString(oldVersion))) module.migrate(oldVersion); if (VersionHelper.isCompatible(VersionHelper.create(4, 0, 0, 3), module.getClass())) - { module.postEnable(); - } if (VersionHelper.isCompatible(VersionHelper.create(4, 0, 0, 4), module.getClass())) { Commands ann = module.getClass().getAnnotation(Commands.class); @@ -375,7 +373,7 @@ public final class ModuleLoader implements CoreModule private static ArrayList getAllHooks(Module module) { - ArrayList commands = new ArrayList(); + ArrayList commands = new ArrayList<>(); for (Method m : module.getClass().getMethods()) { Command cmd = m.getDeclaredAnnotation(Command.class); @@ -393,7 +391,7 @@ public final class ModuleLoader implements CoreModule { instance.getLogger().message(sender, true, "Couldn't autocomplete path for module name: " + name + "! If you're on a case sensitive filesystem, please take note that case correction does not work. Make sure that the classname has proper capitalisation."); - + } updateConfig(); return true; @@ -500,10 +498,9 @@ public final class ModuleLoader implements CoreModule { if (!debugMode) { - instance.getLogger() - .error("Detected equal module versions, " + (debugMode - ? " aborting now... Set debugMode to true in your config if you want to continue!" - : " continueing anyways.")); + instance.getLogger().error("Detected equal module versions, " + (debugMode + ? " aborting now... Set debugMode to true in your config if you want to continue!" + : " continueing anyways.")); if (!debugMode) { try @@ -680,9 +677,9 @@ public final class ModuleLoader implements CoreModule public static void updateConfig() { List coremods = config.getStringList("coremods"); - ArrayList new_coremods = new ArrayList(); + ArrayList new_coremods = new ArrayList<>(); List autoload = config.getStringList("autoload"); - ArrayList new_autoload = new ArrayList(); + ArrayList new_autoload = new ArrayList<>(); for (String s : coremods) { -- 2.45.2 From 55635334d0954352b7f3712782d603b11664d5a0 Mon Sep 17 00:00:00 2001 From: Pepich Date: Wed, 25 Oct 2017 18:47:16 +0200 Subject: [PATCH 111/152] Made Vault a soft dependency --- plugin.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugin.yml b/plugin.yml index 922a2b4..5a3ff61 100644 --- a/plugin.yml +++ b/plugin.yml @@ -1,4 +1,5 @@ name: ModuleLoader version: 4.0.0 authors: [pepich1851] -main: com.redstoner.misc.Main \ No newline at end of file +main: com.redstoner.misc.Main +softdepend: [Vault] \ No newline at end of file -- 2.45.2 From b3fd71263326bff3c5f1255d3709e28bc791805c Mon Sep 17 00:00:00 2001 From: minenash Date: Sun, 14 Jan 2018 17:28:53 -0500 Subject: [PATCH 112/152] Added isUUID --- src/com/redstoner/misc/Utils.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/com/redstoner/misc/Utils.java b/src/com/redstoner/misc/Utils.java index 0902382..d5415f4 100644 --- a/src/com/redstoner/misc/Utils.java +++ b/src/com/redstoner/misc/Utils.java @@ -4,6 +4,7 @@ import java.text.SimpleDateFormat; import java.util.Arrays; import java.util.Date; import java.util.List; +import java.util.regex.Pattern; import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; @@ -20,6 +21,9 @@ public final class Utils /** The @SimpleDateFormat used for getting the current date. */ public static SimpleDateFormat dateFormat = new SimpleDateFormat("[yyyy-MM-dd HH:mm:ss]"); + /** The Pattern for a UUID*/ + private static final Pattern UUID_pattern = Pattern.compile("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}"); + /** Hidden constructor. Do not instantiate UTILS classes! :) */ private Utils() {} @@ -129,4 +133,14 @@ public final class Utils id = "CONSOLE"; return id; } + + /** Checks if the string is an UUID. + * + * @param toCheck String to check. + * @return if the string is an UUID. + */ + public static boolean isUUID(String toCheck) + { + return UUID_pattern.matcher(toCheck).matches(); + } } -- 2.45.2 From d41eb32af7f49de3ec6c2a2621d0a1660319a97f Mon Sep 17 00:00:00 2001 From: minenash Date: Sun, 14 Jan 2018 17:29:38 -0500 Subject: [PATCH 113/152] Fixed Version number --- src/com/redstoner/misc/Utils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/com/redstoner/misc/Utils.java b/src/com/redstoner/misc/Utils.java index d5415f4..d8bea31 100644 --- a/src/com/redstoner/misc/Utils.java +++ b/src/com/redstoner/misc/Utils.java @@ -15,7 +15,7 @@ import com.redstoner.annotations.Version; /** The utils class containing utility functions. Those include but are not limited to sending formatted messages, broadcasts and more. * * @author Pepich */ -@Version(major = 4, minor = 0, revision = 1, compatible = 1) +@Version(major = 4, minor = 0, revision = 2, compatible = 1) public final class Utils { /** The @SimpleDateFormat used for getting the current date. */ -- 2.45.2 From 6c4b9f357318f6032a4afe703cb1e3d0ec8c21b4 Mon Sep 17 00:00:00 2001 From: minenash Date: Sun, 14 Jan 2018 17:40:27 -0500 Subject: [PATCH 114/152] Fixed spelling in JavaDocs --- src/com/redstoner/misc/Utils.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/com/redstoner/misc/Utils.java b/src/com/redstoner/misc/Utils.java index d8bea31..7102e2f 100644 --- a/src/com/redstoner/misc/Utils.java +++ b/src/com/redstoner/misc/Utils.java @@ -134,10 +134,10 @@ public final class Utils return id; } - /** Checks if the string is an UUID. + /** Checks if the string is a UUID. * * @param toCheck String to check. - * @return if the string is an UUID. + * @return if the string is a UUID. */ public static boolean isUUID(String toCheck) { -- 2.45.2 From 6179b901b6ce880611fd10a0f7620425dcda3766 Mon Sep 17 00:00:00 2001 From: minenash Date: Sun, 11 Mar 2018 17:29:31 -0400 Subject: [PATCH 115/152] Fixed bug where module name would have a $# at the end. Made getCaller slightly more efficient. --- src/com/redstoner/misc/Utils.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/com/redstoner/misc/Utils.java b/src/com/redstoner/misc/Utils.java index 7102e2f..8186bcb 100644 --- a/src/com/redstoner/misc/Utils.java +++ b/src/com/redstoner/misc/Utils.java @@ -23,6 +23,8 @@ public final class Utils /** The Pattern for a UUID*/ private static final Pattern UUID_pattern = Pattern.compile("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}"); + private static final Pattern Class_pattern = Pattern.compile(".*\\."); + private static final Pattern NoDolarSign_pattern = Pattern.compile("\\$\\d*"); /** Hidden constructor. Do not instantiate UTILS classes! :) */ private Utils() @@ -76,7 +78,7 @@ public final class Utils String classname = "Utils"; for (int i = 0; classname.equals("Utils"); i++) { - classname = stackTrace[i].getClassName().replaceAll(".*\\.", ""); + classname = Class_pattern.matcher(stackTrace[i].getClassName()).replaceAll(""); } return classname; } @@ -94,8 +96,9 @@ public final class Utils List callers = Arrays.asList(directCaller); for (int i = 0; callers.contains(classname) || classname.equals("Utils"); i++) { - classname = stackTrace[i].getClassName().replaceAll(".*\\.", ""); + classname = Class_pattern.matcher(stackTrace[i].getClassName()).replaceAll(""); } + classname = NoDolarSign_pattern.matcher(classname).replaceAll(""); return classname; } -- 2.45.2 From 54a6cbf4c86421ddec4852b2d764442f5b1c5b28 Mon Sep 17 00:00:00 2001 From: Pepich Date: Mon, 12 Mar 2018 02:44:11 +0100 Subject: [PATCH 116/152] Fixed racecondition on saving --- src/com/redstoner/misc/JsonManager.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/com/redstoner/misc/JsonManager.java b/src/com/redstoner/misc/JsonManager.java index cad716c..13b51b6 100644 --- a/src/com/redstoner/misc/JsonManager.java +++ b/src/com/redstoner/misc/JsonManager.java @@ -15,7 +15,7 @@ import com.redstoner.annotations.Version; /** This class provides simple JSON handling, like storing and loading from and to files. * * @author Pepich */ -@Version(major = 1, minor = 0, revision = 1, compatible = -1) +@Version(major = 1, minor = 0, revision = 2, compatible = -1) public class JsonManager { private JsonManager() @@ -76,7 +76,8 @@ public class JsonManager { destination.createNewFile(); FileWriter writer = new FileWriter(destination); - object.writeJSONString(writer); + String json_string = object.toJSONString(); + writer.write(json_string); writer.flush(); writer.close(); } @@ -137,7 +138,8 @@ public class JsonManager { destination.createNewFile(); FileWriter writer = new FileWriter(destination); - array.writeJSONString(writer); + String json_string = array.toJSONString(); + writer.write(json_string); writer.flush(); writer.close(); } -- 2.45.2 From 4810dcf339a59f49305e184fc22abf839d41c310 Mon Sep 17 00:00:00 2001 From: David Date: Tue, 6 Nov 2018 16:16:01 +0100 Subject: [PATCH 117/152] Moved files to use the gradle structure --- .../java}/com/redstoner/annotations/AutoRegisterListener.java | 0 src/{ => main/java}/com/redstoner/annotations/Commands.java | 0 src/{ => main/java}/com/redstoner/annotations/Version.java | 0 .../java}/com/redstoner/coremods/moduleLoader/ModuleLoader.cmd | 0 .../java}/com/redstoner/coremods/moduleLoader/ModuleLoader.java | 0 .../java}/com/redstoner/exceptions/MissingVersionException.java | 0 .../com/redstoner/exceptions/NonSaveableConfigException.java | 0 src/{ => main/java}/com/redstoner/misc/BroadcastFilter.java | 0 src/{ => main/java}/com/redstoner/misc/CommandHolderType.java | 0 src/{ => main/java}/com/redstoner/misc/JsonManager.java | 0 src/{ => main/java}/com/redstoner/misc/Main.java | 0 src/{ => main/java}/com/redstoner/misc/Utils.java | 0 src/{ => main/java}/com/redstoner/misc/VersionHelper.java | 0 src/{ => main/java}/com/redstoner/misc/mysql/Config.java | 0 src/{ => main/java}/com/redstoner/misc/mysql/JSONManager.java | 0 src/{ => main/java}/com/redstoner/misc/mysql/MysqlHandler.java | 0 .../java}/com/redstoner/misc/mysql/MysqlQueryHandler.java | 0 .../com/redstoner/misc/mysql/elements/ConstraintOperator.java | 0 .../java}/com/redstoner/misc/mysql/elements/MysqlConstraint.java | 0 .../java}/com/redstoner/misc/mysql/elements/MysqlDatabase.java | 0 .../java}/com/redstoner/misc/mysql/elements/MysqlField.java | 0 .../java}/com/redstoner/misc/mysql/elements/MysqlResult.java | 0 .../java}/com/redstoner/misc/mysql/elements/MysqlTable.java | 0 src/{ => main/java}/com/redstoner/misc/mysql/types/MysqlType.java | 0 src/{ => main/java}/com/redstoner/misc/mysql/types/date/Date.java | 0 .../java}/com/redstoner/misc/mysql/types/date/DateTime.java | 0 src/{ => main/java}/com/redstoner/misc/mysql/types/date/Time.java | 0 .../java}/com/redstoner/misc/mysql/types/date/TimeStamp.java | 0 src/{ => main/java}/com/redstoner/misc/mysql/types/date/Year.java | 0 .../java}/com/redstoner/misc/mysql/types/number/BigInt.java | 0 .../java}/com/redstoner/misc/mysql/types/number/Decimal.java | 0 .../java}/com/redstoner/misc/mysql/types/number/Double.java | 0 .../java}/com/redstoner/misc/mysql/types/number/Float.java | 0 .../java}/com/redstoner/misc/mysql/types/number/Int.java | 0 .../java}/com/redstoner/misc/mysql/types/number/MediumInt.java | 0 .../java}/com/redstoner/misc/mysql/types/number/SmallInt.java | 0 .../java}/com/redstoner/misc/mysql/types/number/TinyInt.java | 0 src/{ => main/java}/com/redstoner/misc/mysql/types/text/Blob.java | 0 src/{ => main/java}/com/redstoner/misc/mysql/types/text/Char.java | 0 src/{ => main/java}/com/redstoner/misc/mysql/types/text/Enum.java | 0 .../java}/com/redstoner/misc/mysql/types/text/LongBlob.java | 0 .../java}/com/redstoner/misc/mysql/types/text/LongText.java | 0 .../java}/com/redstoner/misc/mysql/types/text/MediumBlob.java | 0 .../java}/com/redstoner/misc/mysql/types/text/MediumText.java | 0 src/{ => main/java}/com/redstoner/misc/mysql/types/text/Set.java | 0 src/{ => main/java}/com/redstoner/misc/mysql/types/text/Text.java | 0 .../java}/com/redstoner/misc/mysql/types/text/TinyText.java | 0 .../java}/com/redstoner/misc/mysql/types/text/VarChar.java | 0 src/{ => main/java}/com/redstoner/modules/CoreModule.java | 0 src/{ => main/java}/com/redstoner/modules/Module.java | 0 src/{ => main/java}/com/redstoner/modules/ModuleLogger.java | 0 plugin.yml => src/main/resources/plugin.yml | 0 52 files changed, 0 insertions(+), 0 deletions(-) rename src/{ => main/java}/com/redstoner/annotations/AutoRegisterListener.java (100%) rename src/{ => main/java}/com/redstoner/annotations/Commands.java (100%) rename src/{ => main/java}/com/redstoner/annotations/Version.java (100%) rename src/{ => main/java}/com/redstoner/coremods/moduleLoader/ModuleLoader.cmd (100%) rename src/{ => main/java}/com/redstoner/coremods/moduleLoader/ModuleLoader.java (100%) rename src/{ => main/java}/com/redstoner/exceptions/MissingVersionException.java (100%) rename src/{ => main/java}/com/redstoner/exceptions/NonSaveableConfigException.java (100%) rename src/{ => main/java}/com/redstoner/misc/BroadcastFilter.java (100%) rename src/{ => main/java}/com/redstoner/misc/CommandHolderType.java (100%) rename src/{ => main/java}/com/redstoner/misc/JsonManager.java (100%) rename src/{ => main/java}/com/redstoner/misc/Main.java (100%) rename src/{ => main/java}/com/redstoner/misc/Utils.java (100%) rename src/{ => main/java}/com/redstoner/misc/VersionHelper.java (100%) rename src/{ => main/java}/com/redstoner/misc/mysql/Config.java (100%) rename src/{ => main/java}/com/redstoner/misc/mysql/JSONManager.java (100%) rename src/{ => main/java}/com/redstoner/misc/mysql/MysqlHandler.java (100%) rename src/{ => main/java}/com/redstoner/misc/mysql/MysqlQueryHandler.java (100%) rename src/{ => main/java}/com/redstoner/misc/mysql/elements/ConstraintOperator.java (100%) rename src/{ => main/java}/com/redstoner/misc/mysql/elements/MysqlConstraint.java (100%) rename src/{ => main/java}/com/redstoner/misc/mysql/elements/MysqlDatabase.java (100%) rename src/{ => main/java}/com/redstoner/misc/mysql/elements/MysqlField.java (100%) rename src/{ => main/java}/com/redstoner/misc/mysql/elements/MysqlResult.java (100%) rename src/{ => main/java}/com/redstoner/misc/mysql/elements/MysqlTable.java (100%) rename src/{ => main/java}/com/redstoner/misc/mysql/types/MysqlType.java (100%) rename src/{ => main/java}/com/redstoner/misc/mysql/types/date/Date.java (100%) rename src/{ => main/java}/com/redstoner/misc/mysql/types/date/DateTime.java (100%) rename src/{ => main/java}/com/redstoner/misc/mysql/types/date/Time.java (100%) rename src/{ => main/java}/com/redstoner/misc/mysql/types/date/TimeStamp.java (100%) rename src/{ => main/java}/com/redstoner/misc/mysql/types/date/Year.java (100%) rename src/{ => main/java}/com/redstoner/misc/mysql/types/number/BigInt.java (100%) rename src/{ => main/java}/com/redstoner/misc/mysql/types/number/Decimal.java (100%) rename src/{ => main/java}/com/redstoner/misc/mysql/types/number/Double.java (100%) rename src/{ => main/java}/com/redstoner/misc/mysql/types/number/Float.java (100%) rename src/{ => main/java}/com/redstoner/misc/mysql/types/number/Int.java (100%) rename src/{ => main/java}/com/redstoner/misc/mysql/types/number/MediumInt.java (100%) rename src/{ => main/java}/com/redstoner/misc/mysql/types/number/SmallInt.java (100%) rename src/{ => main/java}/com/redstoner/misc/mysql/types/number/TinyInt.java (100%) rename src/{ => main/java}/com/redstoner/misc/mysql/types/text/Blob.java (100%) rename src/{ => main/java}/com/redstoner/misc/mysql/types/text/Char.java (100%) rename src/{ => main/java}/com/redstoner/misc/mysql/types/text/Enum.java (100%) rename src/{ => main/java}/com/redstoner/misc/mysql/types/text/LongBlob.java (100%) rename src/{ => main/java}/com/redstoner/misc/mysql/types/text/LongText.java (100%) rename src/{ => main/java}/com/redstoner/misc/mysql/types/text/MediumBlob.java (100%) rename src/{ => main/java}/com/redstoner/misc/mysql/types/text/MediumText.java (100%) rename src/{ => main/java}/com/redstoner/misc/mysql/types/text/Set.java (100%) rename src/{ => main/java}/com/redstoner/misc/mysql/types/text/Text.java (100%) rename src/{ => main/java}/com/redstoner/misc/mysql/types/text/TinyText.java (100%) rename src/{ => main/java}/com/redstoner/misc/mysql/types/text/VarChar.java (100%) rename src/{ => main/java}/com/redstoner/modules/CoreModule.java (100%) rename src/{ => main/java}/com/redstoner/modules/Module.java (100%) rename src/{ => main/java}/com/redstoner/modules/ModuleLogger.java (100%) rename plugin.yml => src/main/resources/plugin.yml (100%) diff --git a/src/com/redstoner/annotations/AutoRegisterListener.java b/src/main/java/com/redstoner/annotations/AutoRegisterListener.java similarity index 100% rename from src/com/redstoner/annotations/AutoRegisterListener.java rename to src/main/java/com/redstoner/annotations/AutoRegisterListener.java diff --git a/src/com/redstoner/annotations/Commands.java b/src/main/java/com/redstoner/annotations/Commands.java similarity index 100% rename from src/com/redstoner/annotations/Commands.java rename to src/main/java/com/redstoner/annotations/Commands.java diff --git a/src/com/redstoner/annotations/Version.java b/src/main/java/com/redstoner/annotations/Version.java similarity index 100% rename from src/com/redstoner/annotations/Version.java rename to src/main/java/com/redstoner/annotations/Version.java diff --git a/src/com/redstoner/coremods/moduleLoader/ModuleLoader.cmd b/src/main/java/com/redstoner/coremods/moduleLoader/ModuleLoader.cmd similarity index 100% rename from src/com/redstoner/coremods/moduleLoader/ModuleLoader.cmd rename to src/main/java/com/redstoner/coremods/moduleLoader/ModuleLoader.cmd diff --git a/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java b/src/main/java/com/redstoner/coremods/moduleLoader/ModuleLoader.java similarity index 100% rename from src/com/redstoner/coremods/moduleLoader/ModuleLoader.java rename to src/main/java/com/redstoner/coremods/moduleLoader/ModuleLoader.java diff --git a/src/com/redstoner/exceptions/MissingVersionException.java b/src/main/java/com/redstoner/exceptions/MissingVersionException.java similarity index 100% rename from src/com/redstoner/exceptions/MissingVersionException.java rename to src/main/java/com/redstoner/exceptions/MissingVersionException.java diff --git a/src/com/redstoner/exceptions/NonSaveableConfigException.java b/src/main/java/com/redstoner/exceptions/NonSaveableConfigException.java similarity index 100% rename from src/com/redstoner/exceptions/NonSaveableConfigException.java rename to src/main/java/com/redstoner/exceptions/NonSaveableConfigException.java diff --git a/src/com/redstoner/misc/BroadcastFilter.java b/src/main/java/com/redstoner/misc/BroadcastFilter.java similarity index 100% rename from src/com/redstoner/misc/BroadcastFilter.java rename to src/main/java/com/redstoner/misc/BroadcastFilter.java diff --git a/src/com/redstoner/misc/CommandHolderType.java b/src/main/java/com/redstoner/misc/CommandHolderType.java similarity index 100% rename from src/com/redstoner/misc/CommandHolderType.java rename to src/main/java/com/redstoner/misc/CommandHolderType.java diff --git a/src/com/redstoner/misc/JsonManager.java b/src/main/java/com/redstoner/misc/JsonManager.java similarity index 100% rename from src/com/redstoner/misc/JsonManager.java rename to src/main/java/com/redstoner/misc/JsonManager.java diff --git a/src/com/redstoner/misc/Main.java b/src/main/java/com/redstoner/misc/Main.java similarity index 100% rename from src/com/redstoner/misc/Main.java rename to src/main/java/com/redstoner/misc/Main.java diff --git a/src/com/redstoner/misc/Utils.java b/src/main/java/com/redstoner/misc/Utils.java similarity index 100% rename from src/com/redstoner/misc/Utils.java rename to src/main/java/com/redstoner/misc/Utils.java diff --git a/src/com/redstoner/misc/VersionHelper.java b/src/main/java/com/redstoner/misc/VersionHelper.java similarity index 100% rename from src/com/redstoner/misc/VersionHelper.java rename to src/main/java/com/redstoner/misc/VersionHelper.java diff --git a/src/com/redstoner/misc/mysql/Config.java b/src/main/java/com/redstoner/misc/mysql/Config.java similarity index 100% rename from src/com/redstoner/misc/mysql/Config.java rename to src/main/java/com/redstoner/misc/mysql/Config.java diff --git a/src/com/redstoner/misc/mysql/JSONManager.java b/src/main/java/com/redstoner/misc/mysql/JSONManager.java similarity index 100% rename from src/com/redstoner/misc/mysql/JSONManager.java rename to src/main/java/com/redstoner/misc/mysql/JSONManager.java diff --git a/src/com/redstoner/misc/mysql/MysqlHandler.java b/src/main/java/com/redstoner/misc/mysql/MysqlHandler.java similarity index 100% rename from src/com/redstoner/misc/mysql/MysqlHandler.java rename to src/main/java/com/redstoner/misc/mysql/MysqlHandler.java diff --git a/src/com/redstoner/misc/mysql/MysqlQueryHandler.java b/src/main/java/com/redstoner/misc/mysql/MysqlQueryHandler.java similarity index 100% rename from src/com/redstoner/misc/mysql/MysqlQueryHandler.java rename to src/main/java/com/redstoner/misc/mysql/MysqlQueryHandler.java diff --git a/src/com/redstoner/misc/mysql/elements/ConstraintOperator.java b/src/main/java/com/redstoner/misc/mysql/elements/ConstraintOperator.java similarity index 100% rename from src/com/redstoner/misc/mysql/elements/ConstraintOperator.java rename to src/main/java/com/redstoner/misc/mysql/elements/ConstraintOperator.java diff --git a/src/com/redstoner/misc/mysql/elements/MysqlConstraint.java b/src/main/java/com/redstoner/misc/mysql/elements/MysqlConstraint.java similarity index 100% rename from src/com/redstoner/misc/mysql/elements/MysqlConstraint.java rename to src/main/java/com/redstoner/misc/mysql/elements/MysqlConstraint.java diff --git a/src/com/redstoner/misc/mysql/elements/MysqlDatabase.java b/src/main/java/com/redstoner/misc/mysql/elements/MysqlDatabase.java similarity index 100% rename from src/com/redstoner/misc/mysql/elements/MysqlDatabase.java rename to src/main/java/com/redstoner/misc/mysql/elements/MysqlDatabase.java diff --git a/src/com/redstoner/misc/mysql/elements/MysqlField.java b/src/main/java/com/redstoner/misc/mysql/elements/MysqlField.java similarity index 100% rename from src/com/redstoner/misc/mysql/elements/MysqlField.java rename to src/main/java/com/redstoner/misc/mysql/elements/MysqlField.java diff --git a/src/com/redstoner/misc/mysql/elements/MysqlResult.java b/src/main/java/com/redstoner/misc/mysql/elements/MysqlResult.java similarity index 100% rename from src/com/redstoner/misc/mysql/elements/MysqlResult.java rename to src/main/java/com/redstoner/misc/mysql/elements/MysqlResult.java diff --git a/src/com/redstoner/misc/mysql/elements/MysqlTable.java b/src/main/java/com/redstoner/misc/mysql/elements/MysqlTable.java similarity index 100% rename from src/com/redstoner/misc/mysql/elements/MysqlTable.java rename to src/main/java/com/redstoner/misc/mysql/elements/MysqlTable.java diff --git a/src/com/redstoner/misc/mysql/types/MysqlType.java b/src/main/java/com/redstoner/misc/mysql/types/MysqlType.java similarity index 100% rename from src/com/redstoner/misc/mysql/types/MysqlType.java rename to src/main/java/com/redstoner/misc/mysql/types/MysqlType.java diff --git a/src/com/redstoner/misc/mysql/types/date/Date.java b/src/main/java/com/redstoner/misc/mysql/types/date/Date.java similarity index 100% rename from src/com/redstoner/misc/mysql/types/date/Date.java rename to src/main/java/com/redstoner/misc/mysql/types/date/Date.java diff --git a/src/com/redstoner/misc/mysql/types/date/DateTime.java b/src/main/java/com/redstoner/misc/mysql/types/date/DateTime.java similarity index 100% rename from src/com/redstoner/misc/mysql/types/date/DateTime.java rename to src/main/java/com/redstoner/misc/mysql/types/date/DateTime.java diff --git a/src/com/redstoner/misc/mysql/types/date/Time.java b/src/main/java/com/redstoner/misc/mysql/types/date/Time.java similarity index 100% rename from src/com/redstoner/misc/mysql/types/date/Time.java rename to src/main/java/com/redstoner/misc/mysql/types/date/Time.java diff --git a/src/com/redstoner/misc/mysql/types/date/TimeStamp.java b/src/main/java/com/redstoner/misc/mysql/types/date/TimeStamp.java similarity index 100% rename from src/com/redstoner/misc/mysql/types/date/TimeStamp.java rename to src/main/java/com/redstoner/misc/mysql/types/date/TimeStamp.java diff --git a/src/com/redstoner/misc/mysql/types/date/Year.java b/src/main/java/com/redstoner/misc/mysql/types/date/Year.java similarity index 100% rename from src/com/redstoner/misc/mysql/types/date/Year.java rename to src/main/java/com/redstoner/misc/mysql/types/date/Year.java diff --git a/src/com/redstoner/misc/mysql/types/number/BigInt.java b/src/main/java/com/redstoner/misc/mysql/types/number/BigInt.java similarity index 100% rename from src/com/redstoner/misc/mysql/types/number/BigInt.java rename to src/main/java/com/redstoner/misc/mysql/types/number/BigInt.java diff --git a/src/com/redstoner/misc/mysql/types/number/Decimal.java b/src/main/java/com/redstoner/misc/mysql/types/number/Decimal.java similarity index 100% rename from src/com/redstoner/misc/mysql/types/number/Decimal.java rename to src/main/java/com/redstoner/misc/mysql/types/number/Decimal.java diff --git a/src/com/redstoner/misc/mysql/types/number/Double.java b/src/main/java/com/redstoner/misc/mysql/types/number/Double.java similarity index 100% rename from src/com/redstoner/misc/mysql/types/number/Double.java rename to src/main/java/com/redstoner/misc/mysql/types/number/Double.java diff --git a/src/com/redstoner/misc/mysql/types/number/Float.java b/src/main/java/com/redstoner/misc/mysql/types/number/Float.java similarity index 100% rename from src/com/redstoner/misc/mysql/types/number/Float.java rename to src/main/java/com/redstoner/misc/mysql/types/number/Float.java diff --git a/src/com/redstoner/misc/mysql/types/number/Int.java b/src/main/java/com/redstoner/misc/mysql/types/number/Int.java similarity index 100% rename from src/com/redstoner/misc/mysql/types/number/Int.java rename to src/main/java/com/redstoner/misc/mysql/types/number/Int.java diff --git a/src/com/redstoner/misc/mysql/types/number/MediumInt.java b/src/main/java/com/redstoner/misc/mysql/types/number/MediumInt.java similarity index 100% rename from src/com/redstoner/misc/mysql/types/number/MediumInt.java rename to src/main/java/com/redstoner/misc/mysql/types/number/MediumInt.java diff --git a/src/com/redstoner/misc/mysql/types/number/SmallInt.java b/src/main/java/com/redstoner/misc/mysql/types/number/SmallInt.java similarity index 100% rename from src/com/redstoner/misc/mysql/types/number/SmallInt.java rename to src/main/java/com/redstoner/misc/mysql/types/number/SmallInt.java diff --git a/src/com/redstoner/misc/mysql/types/number/TinyInt.java b/src/main/java/com/redstoner/misc/mysql/types/number/TinyInt.java similarity index 100% rename from src/com/redstoner/misc/mysql/types/number/TinyInt.java rename to src/main/java/com/redstoner/misc/mysql/types/number/TinyInt.java diff --git a/src/com/redstoner/misc/mysql/types/text/Blob.java b/src/main/java/com/redstoner/misc/mysql/types/text/Blob.java similarity index 100% rename from src/com/redstoner/misc/mysql/types/text/Blob.java rename to src/main/java/com/redstoner/misc/mysql/types/text/Blob.java diff --git a/src/com/redstoner/misc/mysql/types/text/Char.java b/src/main/java/com/redstoner/misc/mysql/types/text/Char.java similarity index 100% rename from src/com/redstoner/misc/mysql/types/text/Char.java rename to src/main/java/com/redstoner/misc/mysql/types/text/Char.java diff --git a/src/com/redstoner/misc/mysql/types/text/Enum.java b/src/main/java/com/redstoner/misc/mysql/types/text/Enum.java similarity index 100% rename from src/com/redstoner/misc/mysql/types/text/Enum.java rename to src/main/java/com/redstoner/misc/mysql/types/text/Enum.java diff --git a/src/com/redstoner/misc/mysql/types/text/LongBlob.java b/src/main/java/com/redstoner/misc/mysql/types/text/LongBlob.java similarity index 100% rename from src/com/redstoner/misc/mysql/types/text/LongBlob.java rename to src/main/java/com/redstoner/misc/mysql/types/text/LongBlob.java diff --git a/src/com/redstoner/misc/mysql/types/text/LongText.java b/src/main/java/com/redstoner/misc/mysql/types/text/LongText.java similarity index 100% rename from src/com/redstoner/misc/mysql/types/text/LongText.java rename to src/main/java/com/redstoner/misc/mysql/types/text/LongText.java diff --git a/src/com/redstoner/misc/mysql/types/text/MediumBlob.java b/src/main/java/com/redstoner/misc/mysql/types/text/MediumBlob.java similarity index 100% rename from src/com/redstoner/misc/mysql/types/text/MediumBlob.java rename to src/main/java/com/redstoner/misc/mysql/types/text/MediumBlob.java diff --git a/src/com/redstoner/misc/mysql/types/text/MediumText.java b/src/main/java/com/redstoner/misc/mysql/types/text/MediumText.java similarity index 100% rename from src/com/redstoner/misc/mysql/types/text/MediumText.java rename to src/main/java/com/redstoner/misc/mysql/types/text/MediumText.java diff --git a/src/com/redstoner/misc/mysql/types/text/Set.java b/src/main/java/com/redstoner/misc/mysql/types/text/Set.java similarity index 100% rename from src/com/redstoner/misc/mysql/types/text/Set.java rename to src/main/java/com/redstoner/misc/mysql/types/text/Set.java diff --git a/src/com/redstoner/misc/mysql/types/text/Text.java b/src/main/java/com/redstoner/misc/mysql/types/text/Text.java similarity index 100% rename from src/com/redstoner/misc/mysql/types/text/Text.java rename to src/main/java/com/redstoner/misc/mysql/types/text/Text.java diff --git a/src/com/redstoner/misc/mysql/types/text/TinyText.java b/src/main/java/com/redstoner/misc/mysql/types/text/TinyText.java similarity index 100% rename from src/com/redstoner/misc/mysql/types/text/TinyText.java rename to src/main/java/com/redstoner/misc/mysql/types/text/TinyText.java diff --git a/src/com/redstoner/misc/mysql/types/text/VarChar.java b/src/main/java/com/redstoner/misc/mysql/types/text/VarChar.java similarity index 100% rename from src/com/redstoner/misc/mysql/types/text/VarChar.java rename to src/main/java/com/redstoner/misc/mysql/types/text/VarChar.java diff --git a/src/com/redstoner/modules/CoreModule.java b/src/main/java/com/redstoner/modules/CoreModule.java similarity index 100% rename from src/com/redstoner/modules/CoreModule.java rename to src/main/java/com/redstoner/modules/CoreModule.java diff --git a/src/com/redstoner/modules/Module.java b/src/main/java/com/redstoner/modules/Module.java similarity index 100% rename from src/com/redstoner/modules/Module.java rename to src/main/java/com/redstoner/modules/Module.java diff --git a/src/com/redstoner/modules/ModuleLogger.java b/src/main/java/com/redstoner/modules/ModuleLogger.java similarity index 100% rename from src/com/redstoner/modules/ModuleLogger.java rename to src/main/java/com/redstoner/modules/ModuleLogger.java diff --git a/plugin.yml b/src/main/resources/plugin.yml similarity index 100% rename from plugin.yml rename to src/main/resources/plugin.yml -- 2.45.2 From 41741bebc47ddcdc4ff62a2b2af0cf4c50480833 Mon Sep 17 00:00:00 2001 From: David Date: Wed, 7 Nov 2018 17:47:29 +0100 Subject: [PATCH 118/152] gitignore + created gradle build file and moved manifest props into it --- .gitignore | 2 ++ build.gradle | 33 +++++++++++++++++++++++++++++++++ manifest.mf | 3 --- 3 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 .gitignore create mode 100644 build.gradle delete mode 100644 manifest.mf diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f06dfad --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.gradle +build \ No newline at end of file diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..08dc139 --- /dev/null +++ b/build.gradle @@ -0,0 +1,33 @@ +buildscript { + repositories { + jcenter() + } + dependencies { + classpath "com.github.jengelman.gradle.plugins:shadow:4.0.2" + } +} + +apply plugin: "com.github.johnrengelman.shadow" +apply plugin: "java" + +repositories { + jcenter() + maven { url "https://jitpack.io" } + + maven { url "https://hub.spigotmc.org/nexus/content/repositories/snapshots/" } + maven { url "https://oss.sonatype.org/content/repositories/snapshots" } +} + +dependencies { + implementation "com.github.RedstonerServer:CommandManager:master-SNAPSHOT" + implementation "com.github.RedstonerServer:ChatAPI:master-SNAPSHOT" + implementation "com.github.RedstonerServer:ChestAPI:master-SNAPSHOT" + + compileOnly 'org.spigotmc:spigot-api:1.13.1-R0.1-SNAPSHOT' +} + +jar { + manifest { + attributes "Class-Path": "../lib/CommandManager.jar ../lib/ChatAPI.jar ../lib/ChestAPI.jar" + } +} \ No newline at end of file diff --git a/manifest.mf b/manifest.mf deleted file mode 100644 index c8b23f2..0000000 --- a/manifest.mf +++ /dev/null @@ -1,3 +0,0 @@ -Manifest-Version: 1.0 -Class-Path: ../lib/CommandManager.jar ../lib/ChatAPI.jar ../lib/ChestAPI.jar - -- 2.45.2 From f2a6c967ba6b32a267b58989cd9379aa964db274 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Pani=C4=87?= Date: Sat, 10 Nov 2018 21:26:36 +0100 Subject: [PATCH 119/152] Added stuff to gitignore --- .gitignore | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index f06dfad..0c9a815 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,8 @@ .gradle -build \ No newline at end of file +.classpath +.project + +/.settings/ + +/build/ +/bin/ -- 2.45.2 From 919d4870e5dfb00eb5d2fb0efc5b109fe62340f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Pani=C4=87?= Date: Sat, 10 Nov 2018 21:26:57 +0100 Subject: [PATCH 120/152] Added the sourceJar gradle task --- build.gradle | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/build.gradle b/build.gradle index 08dc139..aa99102 100644 --- a/build.gradle +++ b/build.gradle @@ -30,4 +30,9 @@ jar { manifest { attributes "Class-Path": "../lib/CommandManager.jar ../lib/ChatAPI.jar ../lib/ChestAPI.jar" } +} + +task sourceJar(type: Jar, dependsOn: classes) { + classifier 'sources' + from sourceSets.main.allSource } \ No newline at end of file -- 2.45.2 From 6a90e47e77a3d9c5af792e98d7539e9d082a0e2f Mon Sep 17 00:00:00 2001 From: Minenash Date: Mon, 12 Nov 2018 12:43:34 -0500 Subject: [PATCH 121/152] Fixed memory leak in Config's load method. --- src/com/redstoner/misc/mysql/Config.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/com/redstoner/misc/mysql/Config.java b/src/com/redstoner/misc/mysql/Config.java index d403c7b..519b20a 100644 --- a/src/com/redstoner/misc/mysql/Config.java +++ b/src/com/redstoner/misc/mysql/Config.java @@ -66,7 +66,9 @@ public class Config private JSONObject loadConfig(File file) throws IOException, ParseException { FileReader reader = new FileReader(file); - return (JSONObject) parser.parse(reader); + JSONObject object = (JSONObject) parser.parse(reader); + reader.close(); + return object; } @Override -- 2.45.2 From d838bc4963a22b7301d72b861486ed4c9174c704 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Pani=C4=87?= Date: Tue, 13 Nov 2018 23:11:34 +0100 Subject: [PATCH 122/152] Updated spigot to 1.13.2 --- build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index aa99102..bd7d0bb 100644 --- a/build.gradle +++ b/build.gradle @@ -23,7 +23,7 @@ dependencies { implementation "com.github.RedstonerServer:ChatAPI:master-SNAPSHOT" implementation "com.github.RedstonerServer:ChestAPI:master-SNAPSHOT" - compileOnly 'org.spigotmc:spigot-api:1.13.1-R0.1-SNAPSHOT' + compileOnly 'org.spigotmc:spigot-api:1.13.2-R0.1-SNAPSHOT' } jar { @@ -35,4 +35,4 @@ jar { task sourceJar(type: Jar, dependsOn: classes) { classifier 'sources' from sourceSets.main.allSource -} \ No newline at end of file +} -- 2.45.2 From 9326b93fbbf75d997b0765a152994a1970f9abc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Pani=C4=87?= Date: Wed, 14 Nov 2018 00:43:38 +0100 Subject: [PATCH 123/152] Moved ModuleLoader command file to resources --- .../com/redstoner/coremods/moduleLoader/ModuleLoader.cmd | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/main/{java => resources}/com/redstoner/coremods/moduleLoader/ModuleLoader.cmd (100%) diff --git a/src/main/java/com/redstoner/coremods/moduleLoader/ModuleLoader.cmd b/src/main/resources/com/redstoner/coremods/moduleLoader/ModuleLoader.cmd similarity index 100% rename from src/main/java/com/redstoner/coremods/moduleLoader/ModuleLoader.cmd rename to src/main/resources/com/redstoner/coremods/moduleLoader/ModuleLoader.cmd -- 2.45.2 From 0ef0d4f74ef17c7a7dabf118248f14e4843edd6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Pani=C4=87?= Date: Wed, 14 Nov 2018 00:43:55 +0100 Subject: [PATCH 124/152] Added .idea to gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 0c9a815..0e1715c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ .gradle .classpath .project +.idea /.settings/ -- 2.45.2 From fd3823f2d9beb2f33c6eac019c8bea0fb090eb50 Mon Sep 17 00:00:00 2001 From: Minenash Date: Tue, 11 Dec 2018 18:34:43 -0500 Subject: [PATCH 125/152] Added ChatAPI Message support in broadcasts --- src/com/redstoner/misc/Utils.java | 42 +++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/src/com/redstoner/misc/Utils.java b/src/com/redstoner/misc/Utils.java index 8186bcb..d950d67 100644 --- a/src/com/redstoner/misc/Utils.java +++ b/src/com/redstoner/misc/Utils.java @@ -12,6 +12,9 @@ import org.bukkit.entity.Player; import com.redstoner.annotations.Version; +import net.nemez.chatapi.ChatAPI; +import net.nemez.chatapi.click.Message; + /** The utils class containing utility functions. Those include but are not limited to sending formatted messages, broadcasts and more. * * @author Pepich */ @@ -69,6 +72,45 @@ public final class Utils } } + /** This method broadcasts a message to all players and console that are allowed by the filter. Set the filter to NULL to broadcast to everyone.
+ * If you want to, you can set a message that will be logged to console. Set to null to not log anything.
+ * You can still allow console in the filter to log the original message. + * + * @param prefix The prefix for the message. Set to NULL to let it auto generate. + * @param message the message to be sent around + * @param filter the BroadcastFilter to be applied.
+ * Write a class implementing the interface and pass it to this method, the "sendTo()" method will be called for each recipient. + * @param logmessage the log message to appear in console. Set to null to not log this (you can still log the original message by returning true in the filter). + */ + public static int broadcast(String prefix, Message message, BroadcastFilter filter) + { + if (prefix == null) + prefix = "§8[§2" + getCaller() + "§8]: "; + if (filter == null) + { + for (Player p : Bukkit.getOnlinePlayers()) + ChatAPI.createMessage(p).appendText(prefix).appendMessage(message).send(); + Bukkit.getConsoleSender().sendMessage(prefix + message); + return Bukkit.getOnlinePlayers().size() + 1; + } + else + { + int count = 0; + for (Player p : Bukkit.getOnlinePlayers()) + if (filter.sendTo(p)) + { + ChatAPI.createMessage(p).appendText(prefix).appendMessage(message).send(); + count++; + } + if (filter.sendTo(Bukkit.getConsoleSender())) + { + Bukkit.getConsoleSender().sendMessage(prefix + message); + count++; + } + return count; + } + } + /** This method will find the next parent caller and return their class name, omitting package names. * * @return the Name of the calling class. */ -- 2.45.2 From bc4ec4561ed1200497a5edcd03738ec9c0a16072 Mon Sep 17 00:00:00 2001 From: Logan Fick Date: Tue, 11 Dec 2018 18:39:17 -0500 Subject: [PATCH 126/152] Reverted commit unintentionally pushed to master. --- src/com/redstoner/misc/Utils.java | 42 ------------------------------- 1 file changed, 42 deletions(-) diff --git a/src/com/redstoner/misc/Utils.java b/src/com/redstoner/misc/Utils.java index d950d67..8186bcb 100644 --- a/src/com/redstoner/misc/Utils.java +++ b/src/com/redstoner/misc/Utils.java @@ -12,9 +12,6 @@ import org.bukkit.entity.Player; import com.redstoner.annotations.Version; -import net.nemez.chatapi.ChatAPI; -import net.nemez.chatapi.click.Message; - /** The utils class containing utility functions. Those include but are not limited to sending formatted messages, broadcasts and more. * * @author Pepich */ @@ -72,45 +69,6 @@ public final class Utils } } - /** This method broadcasts a message to all players and console that are allowed by the filter. Set the filter to NULL to broadcast to everyone.
- * If you want to, you can set a message that will be logged to console. Set to null to not log anything.
- * You can still allow console in the filter to log the original message. - * - * @param prefix The prefix for the message. Set to NULL to let it auto generate. - * @param message the message to be sent around - * @param filter the BroadcastFilter to be applied.
- * Write a class implementing the interface and pass it to this method, the "sendTo()" method will be called for each recipient. - * @param logmessage the log message to appear in console. Set to null to not log this (you can still log the original message by returning true in the filter). - */ - public static int broadcast(String prefix, Message message, BroadcastFilter filter) - { - if (prefix == null) - prefix = "§8[§2" + getCaller() + "§8]: "; - if (filter == null) - { - for (Player p : Bukkit.getOnlinePlayers()) - ChatAPI.createMessage(p).appendText(prefix).appendMessage(message).send(); - Bukkit.getConsoleSender().sendMessage(prefix + message); - return Bukkit.getOnlinePlayers().size() + 1; - } - else - { - int count = 0; - for (Player p : Bukkit.getOnlinePlayers()) - if (filter.sendTo(p)) - { - ChatAPI.createMessage(p).appendText(prefix).appendMessage(message).send(); - count++; - } - if (filter.sendTo(Bukkit.getConsoleSender())) - { - Bukkit.getConsoleSender().sendMessage(prefix + message); - count++; - } - return count; - } - } - /** This method will find the next parent caller and return their class name, omitting package names. * * @return the Name of the calling class. */ -- 2.45.2 From da695a7fc0928b3fdf7a5d47a755d64b8818fa39 Mon Sep 17 00:00:00 2001 From: Minenash Date: Tue, 11 Dec 2018 18:41:11 -0500 Subject: [PATCH 127/152] Added ChatAPI Message in broadcasts --- src/main/java/com/redstoner/misc/Utils.java | 42 +++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/src/main/java/com/redstoner/misc/Utils.java b/src/main/java/com/redstoner/misc/Utils.java index 8186bcb..d950d67 100644 --- a/src/main/java/com/redstoner/misc/Utils.java +++ b/src/main/java/com/redstoner/misc/Utils.java @@ -12,6 +12,9 @@ import org.bukkit.entity.Player; import com.redstoner.annotations.Version; +import net.nemez.chatapi.ChatAPI; +import net.nemez.chatapi.click.Message; + /** The utils class containing utility functions. Those include but are not limited to sending formatted messages, broadcasts and more. * * @author Pepich */ @@ -69,6 +72,45 @@ public final class Utils } } + /** This method broadcasts a message to all players and console that are allowed by the filter. Set the filter to NULL to broadcast to everyone.
+ * If you want to, you can set a message that will be logged to console. Set to null to not log anything.
+ * You can still allow console in the filter to log the original message. + * + * @param prefix The prefix for the message. Set to NULL to let it auto generate. + * @param message the message to be sent around + * @param filter the BroadcastFilter to be applied.
+ * Write a class implementing the interface and pass it to this method, the "sendTo()" method will be called for each recipient. + * @param logmessage the log message to appear in console. Set to null to not log this (you can still log the original message by returning true in the filter). + */ + public static int broadcast(String prefix, Message message, BroadcastFilter filter) + { + if (prefix == null) + prefix = "§8[§2" + getCaller() + "§8]: "; + if (filter == null) + { + for (Player p : Bukkit.getOnlinePlayers()) + ChatAPI.createMessage(p).appendText(prefix).appendMessage(message).send(); + Bukkit.getConsoleSender().sendMessage(prefix + message); + return Bukkit.getOnlinePlayers().size() + 1; + } + else + { + int count = 0; + for (Player p : Bukkit.getOnlinePlayers()) + if (filter.sendTo(p)) + { + ChatAPI.createMessage(p).appendText(prefix).appendMessage(message).send(); + count++; + } + if (filter.sendTo(Bukkit.getConsoleSender())) + { + Bukkit.getConsoleSender().sendMessage(prefix + message); + count++; + } + return count; + } + } + /** This method will find the next parent caller and return their class name, omitting package names. * * @return the Name of the calling class. */ -- 2.45.2 From ee8596f9daacf61bb3fa4ed35bb52aaa1b2d45e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Pani=C4=87?= Date: Wed, 12 Dec 2018 22:54:19 +0100 Subject: [PATCH 128/152] Jitpack rebuild -- 2.45.2 From 0aafd3e302866f0d3eafa6324b4f264c3e596cda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Pani=C4=87?= Date: Wed, 12 Dec 2018 23:08:39 +0100 Subject: [PATCH 129/152] Jitpack force rebuild -- 2.45.2 From fb81c65ccbc604c5f30e613be45112addc6f852e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Pani=C4=87?= Date: Wed, 12 Dec 2018 23:25:19 +0100 Subject: [PATCH 130/152] Jitpack force rebuild (hopefully last one) -- 2.45.2 From 82fbf34f3ae12c59d27b516c476e938f33298e2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Pani=C4=87?= Date: Sat, 15 Dec 2018 22:08:28 +0100 Subject: [PATCH 131/152] Added getPlugin function --- .../com/redstoner/coremods/moduleLoader/ModuleLoader.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/com/redstoner/coremods/moduleLoader/ModuleLoader.java b/src/main/java/com/redstoner/coremods/moduleLoader/ModuleLoader.java index b4fbbe4..062bda2 100644 --- a/src/main/java/com/redstoner/coremods/moduleLoader/ModuleLoader.java +++ b/src/main/java/com/redstoner/coremods/moduleLoader/ModuleLoader.java @@ -33,6 +33,7 @@ import com.redstoner.modules.Module; import com.redstoner.modules.ModuleLogger; import net.nemez.chatapi.click.Message; +import org.bukkit.plugin.java.JavaPlugin; /** The module loader, mother of all modules. Responsible for loading and taking care of all modules. * @@ -733,4 +734,8 @@ public final class ModuleLoader implements CoreModule e.printStackTrace(); } } + + public static JavaPlugin getPlugin() { + return Main.plugin; + } } -- 2.45.2 From f0713d781ad98a50f3a0e8fc58517269537a37e2 Mon Sep 17 00:00:00 2001 From: Minenash Date: Fri, 28 Dec 2018 12:53:24 -0500 Subject: [PATCH 132/152] Added Descriptor Files and redid `/modules [list]` --- .../coremods/moduleLoader/ModuleLoader.cmd | 10 -- .../coremods/moduleLoader/ModuleLoader.java | 122 +++++++++++------- .../java/com/redstoner/misc/ModuleInfo.java | 81 ++++++++++++ 3 files changed, 153 insertions(+), 60 deletions(-) rename src/main/{resources => java}/com/redstoner/coremods/moduleLoader/ModuleLoader.cmd (77%) create mode 100644 src/main/java/com/redstoner/misc/ModuleInfo.java diff --git a/src/main/resources/com/redstoner/coremods/moduleLoader/ModuleLoader.cmd b/src/main/java/com/redstoner/coremods/moduleLoader/ModuleLoader.cmd similarity index 77% rename from src/main/resources/com/redstoner/coremods/moduleLoader/ModuleLoader.cmd rename to src/main/java/com/redstoner/coremods/moduleLoader/ModuleLoader.cmd index eadeeb7..4e06bd0 100644 --- a/src/main/resources/com/redstoner/coremods/moduleLoader/ModuleLoader.cmd +++ b/src/main/java/com/redstoner/coremods/moduleLoader/ModuleLoader.cmd @@ -9,16 +9,6 @@ command modules { perm moduleloader.modules.list; run list; } - -v { - help Lists all modules. Color indicates status: §aENABLED §cDISABLED; - perm moduleloader.modules.list; - run listv; - } - list -v { - help Lists all modules. Color indicates status: §aENABLED §cDISABLED; - perm moduleloader.modules.list; - run listv; - } load [string:name...] { help (Re)-Loads a module. WARNING: Handle with care! This has direct affect on code being executed. This command will temporarily halt the main thread until the class loading operation was completed.; perm moduleloader.modules.admin; diff --git a/src/main/java/com/redstoner/coremods/moduleLoader/ModuleLoader.java b/src/main/java/com/redstoner/coremods/moduleLoader/ModuleLoader.java index 062bda2..4281d58 100644 --- a/src/main/java/com/redstoner/coremods/moduleLoader/ModuleLoader.java +++ b/src/main/java/com/redstoner/coremods/moduleLoader/ModuleLoader.java @@ -1,6 +1,7 @@ package com.redstoner.coremods.moduleLoader; import java.io.File; +import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; @@ -9,6 +10,7 @@ import java.net.MalformedURLException; import java.net.URL; import java.net.URLClassLoader; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; import java.util.List; @@ -18,6 +20,7 @@ import org.bukkit.configuration.InvalidConfigurationException; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.event.HandlerList; import org.bukkit.event.Listener; +import org.bukkit.plugin.java.JavaPlugin; import com.nemez.cmdmgr.Command; import com.nemez.cmdmgr.Command.AsyncType; @@ -25,15 +28,14 @@ import com.nemez.cmdmgr.CommandManager; import com.redstoner.annotations.AutoRegisterListener; import com.redstoner.annotations.Commands; import com.redstoner.annotations.Version; -import com.redstoner.exceptions.MissingVersionException; import com.redstoner.misc.Main; +import com.redstoner.misc.ModuleInfo; import com.redstoner.misc.VersionHelper; import com.redstoner.modules.CoreModule; import com.redstoner.modules.Module; import com.redstoner.modules.ModuleLogger; import net.nemez.chatapi.click.Message; -import org.bukkit.plugin.java.JavaPlugin; /** The module loader, mother of all modules. Responsible for loading and taking care of all modules. * @@ -43,6 +45,8 @@ public final class ModuleLoader implements CoreModule { private static ModuleLoader instance; private static final HashMap modules = new HashMap<>(); + private static HashMap moduleInfos = new HashMap<>(); + private static HashMap> categorizes = new HashMap<>(); private static URL[] urls; private static URLClassLoader mainLoader; private static HashMap loaders = new HashMap<>(); @@ -71,7 +75,9 @@ public final class ModuleLoader implements CoreModule { if (instance == null) instance = new ModuleLoader(); - loggers.put(instance, new ModuleLogger("ModuleLoader")); + ModuleInfo info = new ModuleInfo(ModuleLoader.class.getResourceAsStream("module.info"), instance); + moduleInfos.put(instance, info); + loggers.put(instance, new ModuleLogger(info.getDisplayName())); CommandManager.registerCommand(ModuleLoader.class.getResourceAsStream("ModuleLoader.cmd"), instance, Main.plugin); } @@ -234,7 +240,33 @@ public final class ModuleLoader implements CoreModule { try { - loggers.put(module, new ModuleLogger(module.getClass().getSimpleName())); + String basePath = "plugins/ModuleLoader/classes/" + module.getClass().getName().replace(".", "/"); + + InputStream file; + try { + file = new FileInputStream( + new File(basePath.substring(0, basePath.lastIndexOf('/')+1) + "module.info")); + } + catch(Exception e) { + file = null; + } + + ModuleInfo info = new ModuleInfo(file, module); + + moduleInfos.put(module, info); + + String category = info.getCategory(); + if (!categorizes.containsKey(category)) + categorizes.put(category, new ArrayList<>(Arrays.asList(module))); + else { + List modsInCat = categorizes.get(category); + modsInCat.add(module); + categorizes.put(category, modsInCat); + } + + loggers.put(module, new ModuleLogger(info.getDisplayName())); + + if (module.onEnable()) { modules.put(module, true); @@ -242,9 +274,9 @@ public final class ModuleLoader implements CoreModule module.firstLoad(); else if (!VersionHelper.getVersion(module.getClass()).equals(VersionHelper.getString(oldVersion))) module.migrate(oldVersion); - if (VersionHelper.isCompatible(VersionHelper.create(4, 0, 0, 3), module.getClass())) + if (VersionHelper.isCompatible(VersionHelper.create(5, 0, 0, 3), module.getClass())) module.postEnable(); - if (VersionHelper.isCompatible(VersionHelper.create(4, 0, 0, 4), module.getClass())) + if (VersionHelper.isCompatible(VersionHelper.create(5, 0, 0, 4), module.getClass())) { Commands ann = module.getClass().getAnnotation(Commands.class); if (ann != null) @@ -289,50 +321,31 @@ public final class ModuleLoader implements CoreModule @Command(hook = "list", async = AsyncType.ALWAYS) public boolean listModulesCommand(CommandSender sender) { - Message m = new Message(sender, null); - m.appendText(getLogger().getHeader()); - m.appendText("§2Modules:\n&e"); - Module[] modules = ModuleLoader.modules.keySet().toArray(new Module[] {}); - for (int i = 0; i < modules.length; i++) - { - Module module = modules[i]; - String[] classPath = module.getClass().getName().split("\\."); - String classname = classPath[classPath.length - 1]; - m.appendText((ModuleLoader.modules.get(module) ? "§a" : "§c") + classname); - if (i + 1 < modules.length) - m.appendText("§7, "); - } - m.send(); - return true; - } - - /** This method lists all modules to the specified CommandSender. The modules will be color coded correspondingly to their enabled status. - * - * @param sender The person to send the info to, usually the issuer of the command or the console sender. - * @return true. */ - @Command(hook = "listv", async = AsyncType.ALWAYS) - public boolean listModulesCommandVersion(CommandSender sender) - { - Message m = new Message(sender, null); - m.appendText(getLogger().getHeader()); - m.appendText("§2Modules:\n&e"); - Module[] modules = ModuleLoader.modules.keySet().toArray(new Module[] {}); - for (int i = 0; i < modules.length; i++) - { - Module module = modules[i]; - String[] classPath = module.getClass().getName().split("\\."); - String classname = classPath[classPath.length - 1]; - try - { - m.appendText((ModuleLoader.modules.get(module) ? "§a" : "§c") + classname + "§e(" - + VersionHelper.getVersion(module.getClass()) + ")"); + boolean hasCategorys = hasCategories(); + Message m = new Message(sender, null); + ModuleInfo ml_info = moduleInfos.get(instance); + + m.appendText("§2--=[ ") + .appendTextHover("§2" + ml_info.getDisplayName(), ml_info.getModuleInfoHover()) + .appendText("§2 ]=--\nModules:\n"); + + for (String cat: categorizes.keySet()) { + if (hasCategorys) + m.appendText("\n&7" + cat + ":\n"); + + int curModule = 1; + List mods = categorizes.get(cat); + for (Module mod : mods) { + + ModuleInfo info = moduleInfos.get(mod); + m.appendTextHover((modules.get(mod) ? "§a" : "§c") + info.getDisplayName(), info.getModuleInfoHover()); + + if (curModule != mods.size()) + m.appendText("&7, "); + curModule++; } - catch (MissingVersionException e) - { - m.appendText((ModuleLoader.modules.get(module) ? "§a" : "§c") + classname + "§c" + "(Unknown Version)"); - } - if (i + 1 < modules.length) - m.appendText("§7, "); + m.appendText("\n"); + } m.send(); return true; @@ -524,6 +537,9 @@ public final class ModuleLoader implements CoreModule disableModule(m); instance.getLogger().info("Disabled module, overriding the implementation"); modules.remove(m); + categorizes.get(moduleInfos.get(m).getCategory()).remove(m); + moduleInfos.remove(m); + try { if (loaders.containsKey(m)) @@ -615,6 +631,8 @@ public final class ModuleLoader implements CoreModule instance.getLogger().info("Attempting to disable module properly:"); disableModule(m); modules.remove(m); + categorizes.get(moduleInfos.get(m).getCategory()).remove(m); + moduleInfos.remove(m); instance.getLogger().info("Disabled module."); return true; } @@ -734,8 +752,12 @@ public final class ModuleLoader implements CoreModule e.printStackTrace(); } } - + public static JavaPlugin getPlugin() { return Main.plugin; } + + public static boolean hasCategories() { + return !(categorizes.size() == 1 && categorizes.containsKey("Other")); + } } diff --git a/src/main/java/com/redstoner/misc/ModuleInfo.java b/src/main/java/com/redstoner/misc/ModuleInfo.java new file mode 100644 index 0000000..e96e813 --- /dev/null +++ b/src/main/java/com/redstoner/misc/ModuleInfo.java @@ -0,0 +1,81 @@ +package com.redstoner.misc; + +import java.io.InputStream; +import java.io.InputStreamReader; + +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.configuration.file.YamlConfiguration; + +import com.redstoner.coremods.moduleLoader.ModuleLoader; +import com.redstoner.exceptions.MissingVersionException; +import com.redstoner.modules.Module; + +public class ModuleInfo { + + private String simpleName; + private String displayName; + private String category; + private String description; + private String version; + + private String warning; + + public ModuleInfo(InputStream descriptor, Module module) { + try { + InputStreamReader reader = new InputStreamReader(descriptor); + FileConfiguration config = YamlConfiguration.loadConfiguration(reader); + + displayName = config.getString("displayName"); + category = config.getString("category"); + description = config.getString("description"); + } + catch (Exception e) { + warning = "Descriptor file could not be loaded, using the class's name."; + } + + simpleName = module.getClass().getSimpleName(); + + if (displayName == null) + displayName = simpleName; + + if (category == null) + category = "Other"; + + try { + version = VersionHelper.getVersion(module.getClass()); + } catch (MissingVersionException e) {} + } + + public String getSimpleName() { + return simpleName; + } + + public String getDisplayName() { + return displayName; + } + + public String getCategory() { + return category; + } + + public String getDescription() { + return description; + } + + public String getWarning() { + return warning; + } + + public String getVersion() { + return version; + } + + public String getModuleInfoHover() { + return "&8&o" + getSimpleName() + "\n" + + "&r&e" + (getVersion() == null? "&cVersion Missing" : getVersion()) + + "&r&9" + (ModuleLoader.hasCategories()? "\n" + getCategory() : "") + + "&r&7" + (getDescription() == null? "" : "\n\n" + getDescription()); + } + + +} -- 2.45.2 From 57998e85502d116df2d9a780a7303947ecca85cc Mon Sep 17 00:00:00 2001 From: Minenash Date: Fri, 28 Dec 2018 13:01:52 -0500 Subject: [PATCH 133/152] Added prefix for logger's info --- src/main/java/com/redstoner/modules/ModuleLogger.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/redstoner/modules/ModuleLogger.java b/src/main/java/com/redstoner/modules/ModuleLogger.java index 8141976..11d71b6 100644 --- a/src/main/java/com/redstoner/modules/ModuleLogger.java +++ b/src/main/java/com/redstoner/modules/ModuleLogger.java @@ -13,6 +13,7 @@ public class ModuleLogger { public static final String PREFIX_WARN = "§8[§eWARN§8]:§7 "; public static final String PREFIX_ERROR = "§8[§cERROR§8]:§7 "; + public static final String PREFIX_INFO = "§8[§fINFO§8]:§7 "; private String name; @@ -23,7 +24,7 @@ public class ModuleLogger public void info(final String message) { - Bukkit.getConsoleSender().sendMessage(getPrefix() + ChatAPI.colorify(null, message)); + Bukkit.getConsoleSender().sendMessage(PREFIX_INFO + getPrefix() + ChatAPI.colorify(null, message)); } public void warn(final String message) -- 2.45.2 From 47e0796eff750e30a75ee0045988a1665ed2e87e Mon Sep 17 00:00:00 2001 From: Minenash Date: Fri, 28 Dec 2018 15:33:20 -0500 Subject: [PATCH 134/152] Now only looks for the info file if the module has a major version of 5 --- .../coremods/moduleLoader/ModuleLoader.java | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/redstoner/coremods/moduleLoader/ModuleLoader.java b/src/main/java/com/redstoner/coremods/moduleLoader/ModuleLoader.java index 4281d58..8b3ca6f 100644 --- a/src/main/java/com/redstoner/coremods/moduleLoader/ModuleLoader.java +++ b/src/main/java/com/redstoner/coremods/moduleLoader/ModuleLoader.java @@ -240,18 +240,20 @@ public final class ModuleLoader implements CoreModule { try { - String basePath = "plugins/ModuleLoader/classes/" + module.getClass().getName().replace(".", "/"); + InputStream infoFile = null; - InputStream file; - try { - file = new FileInputStream( - new File(basePath.substring(0, basePath.lastIndexOf('/')+1) + "module.info")); - } - catch(Exception e) { - file = null; - } + if (VersionHelper.isCompatible(VersionHelper.create(5, 0, 0, 5), module.getClass())) { + String basePath = "plugins/ModuleLoader/classes/" + module.getClass().getName().replace(".", "/"); - ModuleInfo info = new ModuleInfo(file, module); + try { + infoFile = new FileInputStream( + new File(basePath.substring(0, basePath.lastIndexOf('/')+1) + "module.info")); + } + catch(Exception e) { + infoFile = null; + } + } + ModuleInfo info = new ModuleInfo(infoFile, module); moduleInfos.put(module, info); -- 2.45.2 From 259c4b8d376e93087a8fb025fadeea27821c9fab Mon Sep 17 00:00:00 2001 From: Minenash Date: Sun, 30 Dec 2018 15:54:33 -0500 Subject: [PATCH 135/152] Fixed Version --- .../java/com/redstoner/coremods/moduleLoader/ModuleLoader.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/redstoner/coremods/moduleLoader/ModuleLoader.java b/src/main/java/com/redstoner/coremods/moduleLoader/ModuleLoader.java index 8b3ca6f..109fc27 100644 --- a/src/main/java/com/redstoner/coremods/moduleLoader/ModuleLoader.java +++ b/src/main/java/com/redstoner/coremods/moduleLoader/ModuleLoader.java @@ -40,7 +40,7 @@ import net.nemez.chatapi.click.Message; /** The module loader, mother of all modules. Responsible for loading and taking care of all modules. * * @author Pepich */ -@Version(major = 4, minor = 0, revision = 1, compatible = 4) +@Version(major = 5, minor = 0, revision = 0, compatible = 5) public final class ModuleLoader implements CoreModule { private static ModuleLoader instance; -- 2.45.2 From bf0b5994f0db5e3550583de49daf6b489d63c790 Mon Sep 17 00:00:00 2001 From: Minenash Date: Sat, 12 Jan 2019 18:05:11 -0500 Subject: [PATCH 136/152] Fixed broadcast(String, Message, BroadcastFilter) sending to console --- src/main/java/com/redstoner/misc/Utils.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/redstoner/misc/Utils.java b/src/main/java/com/redstoner/misc/Utils.java index d950d67..fa94bc0 100644 --- a/src/main/java/com/redstoner/misc/Utils.java +++ b/src/main/java/com/redstoner/misc/Utils.java @@ -90,7 +90,7 @@ public final class Utils { for (Player p : Bukkit.getOnlinePlayers()) ChatAPI.createMessage(p).appendText(prefix).appendMessage(message).send(); - Bukkit.getConsoleSender().sendMessage(prefix + message); + Bukkit.getConsoleSender().sendMessage(prefix + message.getRawMessage()); return Bukkit.getOnlinePlayers().size() + 1; } else @@ -104,7 +104,7 @@ public final class Utils } if (filter.sendTo(Bukkit.getConsoleSender())) { - Bukkit.getConsoleSender().sendMessage(prefix + message); + Bukkit.getConsoleSender().sendMessage(prefix + message.getRawMessage()); count++; } return count; -- 2.45.2 From ae5494f203e2141197a1b6e5472612032c409fb1 Mon Sep 17 00:00:00 2001 From: Minenash Date: Sun, 13 Jan 2019 00:42:29 -0500 Subject: [PATCH 137/152] Fixed module loading, with caveats*. * Unfortunately it still won't remove the commands from the TabComplete * ChatAPI's error message for now unregistered commands, have been changed to lessen the confusion. --- .../coremods/moduleLoader/ModuleLoader.java | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/src/main/java/com/redstoner/coremods/moduleLoader/ModuleLoader.java b/src/main/java/com/redstoner/coremods/moduleLoader/ModuleLoader.java index 109fc27..0a4cdf9 100644 --- a/src/main/java/com/redstoner/coremods/moduleLoader/ModuleLoader.java +++ b/src/main/java/com/redstoner/coremods/moduleLoader/ModuleLoader.java @@ -5,7 +5,6 @@ import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; -import java.lang.reflect.Method; import java.net.MalformedURLException; import java.net.URL; import java.net.URLClassLoader; @@ -40,7 +39,7 @@ import net.nemez.chatapi.click.Message; /** The module loader, mother of all modules. Responsible for loading and taking care of all modules. * * @author Pepich */ -@Version(major = 5, minor = 0, revision = 0, compatible = 5) +@Version(major = 5, minor = 1, revision = 0, compatible = 5) public final class ModuleLoader implements CoreModule { private static ModuleLoader instance; @@ -370,8 +369,7 @@ public final class ModuleLoader implements CoreModule { HandlerList.unregisterAll((Listener) module); } - String[] commands = getAllHooks(module).toArray(new String[] {}); - CommandManager.unregisterAll(commands); + CommandManager.unregisterAllWithFallback(module.getClass().getSimpleName()); try { URLClassLoader loader = loaders.get(module); @@ -387,19 +385,6 @@ public final class ModuleLoader implements CoreModule } } - private static ArrayList getAllHooks(Module module) - { - ArrayList commands = new ArrayList<>(); - for (Method m : module.getClass().getMethods()) - { - Command cmd = m.getDeclaredAnnotation(Command.class); - if (cmd == null) - continue; - commands.add(cmd.hook()); - } - return commands; - } - @Command(hook = "load") public boolean loadModule(CommandSender sender, String name) { -- 2.45.2 From c402986304796a1777379d305d0b0cb77268b7fb Mon Sep 17 00:00:00 2001 From: Minenash Date: Fri, 1 Feb 2019 23:16:25 -0500 Subject: [PATCH 138/152] Added the ability to hide or replace the log message for commands Mainly used for sensitive information, like passwords --- .../coremods/moduleLoader/ModuleLoader.java | 4 +- .../com/redstoner/logging/Log4JFilter.java | 54 +++++++++++ .../redstoner/logging/PrivateLogManager.java | 89 +++++++++++++++++++ src/main/java/com/redstoner/misc/Main.java | 6 +- src/main/java/com/redstoner/misc/Utils.java | 12 +++ 5 files changed, 163 insertions(+), 2 deletions(-) create mode 100644 src/main/java/com/redstoner/logging/Log4JFilter.java create mode 100644 src/main/java/com/redstoner/logging/PrivateLogManager.java diff --git a/src/main/java/com/redstoner/coremods/moduleLoader/ModuleLoader.java b/src/main/java/com/redstoner/coremods/moduleLoader/ModuleLoader.java index 0a4cdf9..3886dd1 100644 --- a/src/main/java/com/redstoner/coremods/moduleLoader/ModuleLoader.java +++ b/src/main/java/com/redstoner/coremods/moduleLoader/ModuleLoader.java @@ -27,6 +27,7 @@ import com.nemez.cmdmgr.CommandManager; import com.redstoner.annotations.AutoRegisterListener; import com.redstoner.annotations.Commands; import com.redstoner.annotations.Version; +import com.redstoner.logging.PrivateLogManager; import com.redstoner.misc.Main; import com.redstoner.misc.ModuleInfo; import com.redstoner.misc.VersionHelper; @@ -39,7 +40,7 @@ import net.nemez.chatapi.click.Message; /** The module loader, mother of all modules. Responsible for loading and taking care of all modules. * * @author Pepich */ -@Version(major = 5, minor = 1, revision = 0, compatible = 5) +@Version(major = 5, minor = 2, revision = 0, compatible = 5) public final class ModuleLoader implements CoreModule { private static ModuleLoader instance; @@ -370,6 +371,7 @@ public final class ModuleLoader implements CoreModule HandlerList.unregisterAll((Listener) module); } CommandManager.unregisterAllWithFallback(module.getClass().getSimpleName()); + PrivateLogManager.unregister(module); try { URLClassLoader loader = loaders.get(module); diff --git a/src/main/java/com/redstoner/logging/Log4JFilter.java b/src/main/java/com/redstoner/logging/Log4JFilter.java new file mode 100644 index 0000000..1ebed09 --- /dev/null +++ b/src/main/java/com/redstoner/logging/Log4JFilter.java @@ -0,0 +1,54 @@ +package com.redstoner.logging; + +import org.apache.logging.log4j.Level; +import org.apache.logging.log4j.Marker; +import org.apache.logging.log4j.core.LogEvent; +import org.apache.logging.log4j.core.Logger; +import org.apache.logging.log4j.core.filter.AbstractFilter; +import org.apache.logging.log4j.message.Message; + +public class Log4JFilter extends AbstractFilter { + + private static final long serialVersionUID = -5594073755007974254L; + + private static Result validateMessage(Message message) { + if (message == null) { + return Result.NEUTRAL; + } + return validateMessage(message.getFormattedMessage()); + } + + private static Result validateMessage(String message) { + return PrivateLogManager.isHidden(message) + ? Result.DENY + : Result.NEUTRAL; + } + + @Override + public Result filter(LogEvent event) { + Message candidate = null; + if (event != null) { + candidate = event.getMessage(); + } + return validateMessage(candidate); + } + + @Override + public Result filter(Logger logger, Level level, Marker marker, Message msg, Throwable t) { + return validateMessage(msg); + } + + @Override + public Result filter(Logger logger, Level level, Marker marker, String msg, Object... params) { + return validateMessage(msg); + } + + @Override + public Result filter(Logger logger, Level level, Marker marker, Object msg, Throwable t) { + String candidate = null; + if (msg != null) { + candidate = msg.toString(); + } + return validateMessage(candidate); + } +} \ No newline at end of file diff --git a/src/main/java/com/redstoner/logging/PrivateLogManager.java b/src/main/java/com/redstoner/logging/PrivateLogManager.java new file mode 100644 index 0000000..e8451e0 --- /dev/null +++ b/src/main/java/com/redstoner/logging/PrivateLogManager.java @@ -0,0 +1,89 @@ +package com.redstoner.logging; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; + +import org.apache.logging.log4j.LogManager; + +import com.redstoner.misc.Utils; +import com.redstoner.modules.Module; +import com.redstoner.modules.ModuleLogger; + +public class PrivateLogManager { + + private static Map registrar = new HashMap<>(); + private static Map commands = new HashMap<>(); + + private static final String ISSUED_COMMAND_TEXT = "issued server command: /"; + private static final int ISSUED_COMMAND_TEXT_LENGTH = ISSUED_COMMAND_TEXT.length(); + + private static ModuleLogger logger; + + public static void initialize() { + org.apache.logging.log4j.core.Logger logger; + logger = (org.apache.logging.log4j.core.Logger) LogManager.getRootLogger(); + logger.addFilter(new Log4JFilter()); + PrivateLogManager.logger = new ModuleLogger("PrivateLogManager"); + } + + public static void register(Module module, String command, String replacement) { + command = command.toLowerCase(); + registrar.put(command, module); + commands.put(command, replacement); + logger.info(module.getClass().getSimpleName() + " registered &e/" + command + + (replacement.equals("")? "&7. Command will not be logged!" + : "&7, using replacement, &e" + replacement + "&7.")); + } + + public static void unregister(Module module) { + String unregestered = ""; + Iterator> i = registrar.entrySet().iterator(); + while (i.hasNext()) { + Map.Entry entry = i.next(); + if (entry.getValue() == module) { + i.remove(); + commands.remove(entry.getKey()); + unregestered += "&e" + entry.getKey() + "&7, "; + } + } + if (!unregestered.equals("")) + logger.info("Unregistered " + unregestered.substring(0, unregestered.length() - 2) + "&7 for module, " + module.getClass().getSimpleName() + "."); + } + + public static void unregister(Module module, String... toRemove) { + String unregestered = ""; + for (int i = 0; i < toRemove.length; i++) { + String command = toRemove[i].toLowerCase(); + registrar.remove(command); + if (commands.remove(command) != null) + unregestered += "&e" + command + "&7, "; + } + if (!unregestered.equals("")) + logger.info(module.getClass().getSimpleName() + " unregistered " + unregestered.substring(0, unregestered.length() - 2) + "&7."); + } + + public static boolean isHidden(String message) { + if (message == null) + return false; + + int index = message.indexOf(ISSUED_COMMAND_TEXT); + if (index == -1) + return false; + + String command = message.substring(index + ISSUED_COMMAND_TEXT_LENGTH); + + int spaceIndex = command.indexOf(" "); + command = spaceIndex == -1? command.toLowerCase() : command.substring(0, spaceIndex).toLowerCase(); + + String replacement = commands.get(command); + if (replacement == null) + return false; + if (replacement.equals("")) + return true; + + String player = message.substring(0, message.indexOf(" ")); + Utils.run(() -> System.out.println(replacement.replace("$s", player))); + return true; + } +} diff --git a/src/main/java/com/redstoner/misc/Main.java b/src/main/java/com/redstoner/misc/Main.java index b24e532..40894ee 100644 --- a/src/main/java/com/redstoner/misc/Main.java +++ b/src/main/java/com/redstoner/misc/Main.java @@ -4,6 +4,7 @@ import org.bukkit.plugin.java.JavaPlugin; import com.redstoner.annotations.Version; import com.redstoner.coremods.moduleLoader.ModuleLoader; +import com.redstoner.logging.PrivateLogManager; import com.redstoner.misc.mysql.MysqlHandler; import net.nemez.chatapi.ChatAPI; @@ -11,7 +12,7 @@ import net.nemez.chatapi.ChatAPI; /** Main class. Duh. * * @author Pepich */ -@Version(major = 4, minor = 0, revision = 0, compatible = -1) +@Version(major = 5, minor = 1, revision = 0, compatible = -1) public class Main extends JavaPlugin { public static JavaPlugin plugin; @@ -20,6 +21,9 @@ public class Main extends JavaPlugin public void onEnable() { plugin = this; + + PrivateLogManager.initialize(); + ChatAPI.initialize(this); // Configger.init(); MysqlHandler.init(); diff --git a/src/main/java/com/redstoner/misc/Utils.java b/src/main/java/com/redstoner/misc/Utils.java index fa94bc0..e3fd68c 100644 --- a/src/main/java/com/redstoner/misc/Utils.java +++ b/src/main/java/com/redstoner/misc/Utils.java @@ -11,6 +11,7 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import com.redstoner.annotations.Version; +import com.redstoner.coremods.moduleLoader.ModuleLoader; import net.nemez.chatapi.ChatAPI; import net.nemez.chatapi.click.Message; @@ -188,4 +189,15 @@ public final class Utils { return UUID_pattern.matcher(toCheck).matches(); } + + public static void run(Runnable r) { + run(r, 0); + } + + public static void run(Runnable r, int delay) { + Bukkit.getScheduler().scheduleSyncDelayedTask(ModuleLoader.getPlugin(), r, delay); + } + + + } -- 2.45.2 From 46be8ab62c7cd8567cfef174105808d32d4fc225 Mon Sep 17 00:00:00 2001 From: Logan Fick Date: Thu, 7 Feb 2019 16:40:44 -0500 Subject: [PATCH 139/152] Added Travis CI configuration file. --- .travis.yml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..ab48fcd --- /dev/null +++ b/.travis.yml @@ -0,0 +1,5 @@ +language: java + +jdk: + - openjdk8 + - oraclejdk8 -- 2.45.2 From bdd8ee823396e1aab0a2c864d9d80853f7a16cbd Mon Sep 17 00:00:00 2001 From: Logan Fick Date: Fri, 8 Feb 2019 08:43:42 -0500 Subject: [PATCH 140/152] Added Gradle wrapper. --- gradle/wrapper/gradle-wrapper.jar | Bin 0 -> 56172 bytes gradle/wrapper/gradle-wrapper.properties | 5 + gradlew | 172 +++++++++++++++++++++++ gradlew.bat | 84 +++++++++++ 4 files changed, 261 insertions(+) create mode 100644 gradle/wrapper/gradle-wrapper.jar create mode 100644 gradle/wrapper/gradle-wrapper.properties create mode 100755 gradlew create mode 100644 gradlew.bat diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000000000000000000000000000000000000..28861d273a5d270fd8f65dd74570c17c9c507736 GIT binary patch literal 56172 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

ZM+x{iQDVZRnLYbdXrQjU&=u%hsN4|smH&B~F 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 b+=;!jU|P+J`>$CfFsoU|bwOU-ceCsYH7qU$ literal 0 HcmV?d00001 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..115e6ac --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-4.10-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew new file mode 100755 index 0000000..cccdd3d --- /dev/null +++ b/gradlew @@ -0,0 +1,172 @@ +#!/usr/bin/env sh + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn () { + echo "$*" +} + +die () { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; + NONSTOP* ) + nonstop=true + ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} +APP_ARGS=$(save "$@") + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong +if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then + cd "$(dirname "$0")" +fi + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..e95643d --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,84 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega -- 2.45.2 From 335a5b57d322a0a9e3b43729e240206af05c09bb Mon Sep 17 00:00:00 2001 From: Logan Fick Date: Fri, 8 Feb 2019 09:30:00 -0500 Subject: [PATCH 141/152] Added missing Log4j dependency. --- build.gradle | 2 ++ 1 file changed, 2 insertions(+) diff --git a/build.gradle b/build.gradle index bd7d0bb..bc4ba04 100644 --- a/build.gradle +++ b/build.gradle @@ -22,6 +22,8 @@ dependencies { implementation "com.github.RedstonerServer:CommandManager:master-SNAPSHOT" implementation "com.github.RedstonerServer:ChatAPI:master-SNAPSHOT" implementation "com.github.RedstonerServer:ChestAPI:master-SNAPSHOT" + + compile group: 'org.apache.logging.log4j', name: 'log4j-1.2-api', version: '2.11.1' compileOnly 'org.spigotmc:spigot-api:1.13.2-R0.1-SNAPSHOT' } -- 2.45.2 From 95482305f38259ad8e1188cbf66ac458390145f1 Mon Sep 17 00:00:00 2001 From: Logan Fick Date: Fri, 8 Feb 2019 17:16:59 -0500 Subject: [PATCH 142/152] Improved coverage of gitignore file. --- .gitignore | 145 ++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 139 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 0e1715c..956145f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,142 @@ +# Created by https://www.gitignore.io/api/java,linux,gradle,intellij +# Edit at https://www.gitignore.io/?templates=java,linux,gradle,intellij + +### Intellij ### +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/modules.xml +# .idea/*.iml +# .idea/modules + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser + +### Intellij Patch ### +# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 + +# *.iml +# modules.xml +# .idea/misc.xml +# *.ipr + +# Sonarlint plugin +.idea/sonarlint + +### Java ### +# Compiled class file +*.class + +# Log file +*.log + +# BlueJ files +*.ctxt + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.jar +*.war +*.nar +*.ear +*.zip +*.tar.gz +*.rar + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* + +### Linux ### +*~ + +# temporary files which can be created if a process still has a handle open of a deleted file +.fuse_hidden* + +# KDE directory preferences +.directory + +# Linux trash folder which might appear on any partition or disk +.Trash-* + +# .nfs files are created when an open file is removed but is still being accessed +.nfs* + +### Gradle ### .gradle -.classpath -.project -.idea +build/ -/.settings/ +# Ignore Gradle GUI config +gradle-app.setting -/build/ -/bin/ +# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) +!gradle-wrapper.jar + +# Cache of project +.gradletasknamecache + +# # Work around https://youtrack.jetbrains.com/issue/IDEA-116898 +# gradle/wrapper/gradle-wrapper.properties + +### Gradle Patch ### +**/build/ + +# End of https://www.gitignore.io/api/java,linux,gradle,intellij \ No newline at end of file -- 2.45.2 From 3df7778efc4a562c28d7c701446d2c9052f662d2 Mon Sep 17 00:00:00 2001 From: Logan Fick Date: Fri, 8 Feb 2019 17:20:36 -0500 Subject: [PATCH 143/152] Licensed ModuleLoader under Creative Commons Zero v1.0 Universal. --- LICENSE.txt | 116 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 LICENSE.txt diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..3bbbc1e --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,116 @@ +CC0 1.0 Universal + +Statement of Purpose + +The laws of most jurisdictions throughout the world automatically confer +exclusive Copyright and Related Rights (defined below) upon the creator and +subsequent owner(s) (each and all, an "owner") of an original work of +authorship and/or a database (each, a "Work"). + +Certain owners wish to permanently relinquish those rights to a Work for the +purpose of contributing to a commons of creative, cultural and scientific +works ("Commons") that the public can reliably and without fear of later +claims of infringement build upon, modify, incorporate in other works, reuse +and redistribute as freely as possible in any form whatsoever and for any +purposes, including without limitation commercial purposes. These owners may +contribute to the Commons to promote the ideal of a free culture and the +further production of creative, cultural and scientific works, or to gain +reputation or greater distribution for their Work in part through the use and +efforts of others. + +For these and/or other purposes and motivations, and without any expectation +of additional consideration or compensation, the person associating CC0 with a +Work (the "Affirmer"), to the extent that he or she is an owner of Copyright +and Related Rights in the Work, voluntarily elects to apply CC0 to the Work +and publicly distribute the Work under its terms, with knowledge of his or her +Copyright and Related Rights in the Work and the meaning and intended legal +effect of CC0 on those rights. + +1. Copyright and Related Rights. A Work made available under CC0 may be +protected by copyright and related or neighboring rights ("Copyright and +Related Rights"). Copyright and Related Rights include, but are not limited +to, the following: + + i. the right to reproduce, adapt, distribute, perform, display, communicate, + and translate a Work; + + ii. moral rights retained by the original author(s) and/or performer(s); + + iii. publicity and privacy rights pertaining to a person's image or likeness + depicted in a Work; + + iv. rights protecting against unfair competition in regards to a Work, + subject to the limitations in paragraph 4(a), below; + + v. rights protecting the extraction, dissemination, use and reuse of data in + a Work; + + vi. database rights (such as those arising under Directive 96/9/EC of the + European Parliament and of the Council of 11 March 1996 on the legal + protection of databases, and under any national implementation thereof, + including any amended or successor version of such directive); and + + vii. other similar, equivalent or corresponding rights throughout the world + based on applicable law or treaty, and any national implementations thereof. + +2. Waiver. To the greatest extent permitted by, but not in contravention of, +applicable law, Affirmer hereby overtly, fully, permanently, irrevocably and +unconditionally waives, abandons, and surrenders all of Affirmer's Copyright +and Related Rights and associated claims and causes of action, whether now +known or unknown (including existing as well as future claims and causes of +action), in the Work (i) in all territories worldwide, (ii) for the maximum +duration provided by applicable law or treaty (including future time +extensions), (iii) in any current or future medium and for any number of +copies, and (iv) for any purpose whatsoever, including without limitation +commercial, advertising or promotional purposes (the "Waiver"). Affirmer makes +the Waiver for the benefit of each member of the public at large and to the +detriment of Affirmer's heirs and successors, fully intending that such Waiver +shall not be subject to revocation, rescission, cancellation, termination, or +any other legal or equitable action to disrupt the quiet enjoyment of the Work +by the public as contemplated by Affirmer's express Statement of Purpose. + +3. Public License Fallback. Should any part of the Waiver for any reason be +judged legally invalid or ineffective under applicable law, then the Waiver +shall be preserved to the maximum extent permitted taking into account +Affirmer's express Statement of Purpose. In addition, to the extent the Waiver +is so judged Affirmer hereby grants to each affected person a royalty-free, +non transferable, non sublicensable, non exclusive, irrevocable and +unconditional license to exercise Affirmer's Copyright and Related Rights in +the Work (i) in all territories worldwide, (ii) for the maximum duration +provided by applicable law or treaty (including future time extensions), (iii) +in any current or future medium and for any number of copies, and (iv) for any +purpose whatsoever, including without limitation commercial, advertising or +promotional purposes (the "License"). The License shall be deemed effective as +of the date CC0 was applied by Affirmer to the Work. Should any part of the +License for any reason be judged legally invalid or ineffective under +applicable law, such partial invalidity or ineffectiveness shall not +invalidate the remainder of the License, and in such case Affirmer hereby +affirms that he or she will not (i) exercise any of his or her remaining +Copyright and Related Rights in the Work or (ii) assert any associated claims +and causes of action with respect to the Work, in either case contrary to +Affirmer's express Statement of Purpose. + +4. Limitations and Disclaimers. + + a. No trademark or patent rights held by Affirmer are waived, abandoned, + surrendered, licensed or otherwise affected by this document. + + b. Affirmer offers the Work as-is and makes no representations or warranties + of any kind concerning the Work, express, implied, statutory or otherwise, + including without limitation warranties of title, merchantability, fitness + for a particular purpose, non infringement, or the absence of latent or + other defects, accuracy, or the present or absence of errors, whether or not + discoverable, all to the greatest extent permissible under applicable law. + + c. Affirmer disclaims responsibility for clearing rights of other persons + that may apply to the Work or any use thereof, including without limitation + any person's Copyright and Related Rights in the Work. Further, Affirmer + disclaims responsibility for obtaining any necessary consents, permissions + or other rights required for any use of the Work. + + d. Affirmer understands and acknowledges that Creative Commons is not a + party to this document and has no duty or obligation with respect to this + CC0 or use of the Work. + +For more information, please see + \ No newline at end of file -- 2.45.2 From 5ca44c3419b0c7067ed09fc6e3378d2431161c8c Mon Sep 17 00:00:00 2001 From: Logan Fick Date: Fri, 8 Feb 2019 18:21:44 -0500 Subject: [PATCH 144/152] Added IntelliJ IDEA configuration files. --- .idea/codeStyles/Project.xml | 72 ++++++++++++++++++++++++++++ .idea/codeStyles/codeStyleConfig.xml | 5 ++ .idea/compiler.xml | 9 ++++ .idea/encodings.xml | 4 ++ .idea/misc.xml | 29 +++++++++++ .idea/modules.xml | 10 ++++ .idea/modules/ModuleLoader.main.iml | 28 +++++++++++ .idea/modules/ModuleLoader.test.iml | 18 +++++++ ModuleLoader.iml | 13 +++++ 9 files changed, 188 insertions(+) create mode 100644 .idea/codeStyles/Project.xml create mode 100644 .idea/codeStyles/codeStyleConfig.xml create mode 100644 .idea/compiler.xml create mode 100644 .idea/encodings.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/modules/ModuleLoader.main.iml create mode 100644 .idea/modules/ModuleLoader.test.iml create mode 100644 ModuleLoader.iml diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..69ba39f --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,72 @@ + + + + \ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..79ee123 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..a579497 --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..15a15b2 --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..f91b814 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + Manifest + + + Spelling + + + + + SpellCheckingInspection + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..aab47ff --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules/ModuleLoader.main.iml b/.idea/modules/ModuleLoader.main.iml new file mode 100644 index 0000000..16c918c --- /dev/null +++ b/.idea/modules/ModuleLoader.main.iml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules/ModuleLoader.test.iml b/.idea/modules/ModuleLoader.test.iml new file mode 100644 index 0000000..8ebdafa --- /dev/null +++ b/.idea/modules/ModuleLoader.test.iml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ModuleLoader.iml b/ModuleLoader.iml new file mode 100644 index 0000000..558676c --- /dev/null +++ b/ModuleLoader.iml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file -- 2.45.2 From 3e9626f67abcc0efa52bdac0c721b8b987680a59 Mon Sep 17 00:00:00 2001 From: Logan Fick Date: Fri, 8 Feb 2019 18:33:07 -0500 Subject: [PATCH 145/152] Fixed usage of incorrect Java version. --- .idea/compiler.xml | 4 ++-- .idea/modules/ModuleLoader.main.iml | 2 +- .idea/modules/ModuleLoader.test.iml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.idea/compiler.xml b/.idea/compiler.xml index a579497..fba829b 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -2,8 +2,8 @@ - - + + \ No newline at end of file diff --git a/.idea/modules/ModuleLoader.main.iml b/.idea/modules/ModuleLoader.main.iml index 16c918c..cefd623 100644 --- a/.idea/modules/ModuleLoader.main.iml +++ b/.idea/modules/ModuleLoader.main.iml @@ -1,6 +1,6 @@ - + diff --git a/.idea/modules/ModuleLoader.test.iml b/.idea/modules/ModuleLoader.test.iml index 8ebdafa..59e0e7d 100644 --- a/.idea/modules/ModuleLoader.test.iml +++ b/.idea/modules/ModuleLoader.test.iml @@ -1,6 +1,6 @@ - + -- 2.45.2 From 6dfe3195cd6d939997deb8e89cce220ba625b8ac Mon Sep 17 00:00:00 2001 From: Logan Fick Date: Fri, 8 Feb 2019 18:47:48 -0500 Subject: [PATCH 146/152] Properly fixed usage of incorrect Java version. --- .idea/misc.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.idea/misc.xml b/.idea/misc.xml index f91b814..530d61c 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -23,7 +23,7 @@ - + - \ No newline at end of file + -- 2.45.2 From 7ca3bc7379215b7726480ebb14c3dd07fe521f62 Mon Sep 17 00:00:00 2001 From: Logan Fick Date: Fri, 8 Feb 2019 18:49:51 -0500 Subject: [PATCH 147/152] Reformatted code. --- .../annotations/AutoRegisterListener.java | 17 +- .../com/redstoner/annotations/Commands.java | 11 +- .../com/redstoner/annotations/Version.java | 43 +- .../coremods/moduleLoader/ModuleLoader.java | 708 +++++++----------- .../exceptions/MissingVersionException.java | 23 +- .../NonSaveableConfigException.java | 10 +- .../com/redstoner/logging/Log4JFilter.java | 74 +- .../redstoner/logging/PrivateLogManager.java | 81 +- .../com/redstoner/misc/BroadcastFilter.java | 16 +- .../com/redstoner/misc/CommandHolderType.java | 5 +- .../java/com/redstoner/misc/JsonManager.java | 165 ++-- src/main/java/com/redstoner/misc/Main.java | 31 +- .../java/com/redstoner/misc/ModuleInfo.java | 66 +- src/main/java/com/redstoner/misc/Utils.java | 235 +++--- .../com/redstoner/misc/VersionHelper.java | 198 ++--- .../java/com/redstoner/misc/mysql/Config.java | 261 +++---- .../com/redstoner/misc/mysql/JSONManager.java | 121 ++- .../redstoner/misc/mysql/MysqlHandler.java | 105 +-- .../misc/mysql/MysqlQueryHandler.java | 14 +- .../mysql/elements/ConstraintOperator.java | 2 +- .../misc/mysql/elements/MysqlConstraint.java | 2 +- .../misc/mysql/elements/MysqlDatabase.java | 106 +-- .../misc/mysql/elements/MysqlField.java | 14 +- .../misc/mysql/elements/MysqlResult.java | 4 +- .../misc/mysql/elements/MysqlTable.java | 166 ++-- .../redstoner/misc/mysql/types/MysqlType.java | 44 +- .../misc/mysql/types/number/Int.java | 4 +- .../redstoner/misc/mysql/types/text/Char.java | 4 +- .../redstoner/misc/mysql/types/text/Enum.java | 12 +- .../redstoner/misc/mysql/types/text/Set.java | 12 +- .../misc/mysql/types/text/VarChar.java | 4 +- .../com/redstoner/modules/CoreModule.java | 21 +- .../java/com/redstoner/modules/Module.java | 77 +- .../com/redstoner/modules/ModuleLogger.java | 80 +- 34 files changed, 1214 insertions(+), 1522 deletions(-) diff --git a/src/main/java/com/redstoner/annotations/AutoRegisterListener.java b/src/main/java/com/redstoner/annotations/AutoRegisterListener.java index fabdb5f..7e36c9e 100644 --- a/src/main/java/com/redstoner/annotations/AutoRegisterListener.java +++ b/src/main/java/com/redstoner/annotations/AutoRegisterListener.java @@ -5,11 +5,12 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -/** The auto register annotation, to be put onto Classes that implement listener when you are too lazy to register the events yourself. - * - * @author Pepich */ -@Target(ElementType.TYPE) -@Retention(RetentionPolicy.RUNTIME) -@Version(major = 1, minor = 0, revision = 1, compatible = 1) -public @interface AutoRegisterListener -{} +/** + * The auto register annotation, to be put onto Classes that implement listener when you are too lazy to register the events yourself. + * + * @author Pepich + */ +@Target (ElementType.TYPE) +@Retention (RetentionPolicy.RUNTIME) +@Version (major = 1, minor = 0, revision = 1, compatible = 1) +public @interface AutoRegisterListener {} diff --git a/src/main/java/com/redstoner/annotations/Commands.java b/src/main/java/com/redstoner/annotations/Commands.java index 537bff0..d5ea130 100644 --- a/src/main/java/com/redstoner/annotations/Commands.java +++ b/src/main/java/com/redstoner/annotations/Commands.java @@ -1,15 +1,14 @@ package com.redstoner.annotations; +import com.redstoner.misc.CommandHolderType; + import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -import com.redstoner.misc.CommandHolderType; - -@Target(ElementType.TYPE) -@Retention(RetentionPolicy.RUNTIME) -public @interface Commands -{ +@Target (ElementType.TYPE) +@Retention (RetentionPolicy.RUNTIME) +public @interface Commands { CommandHolderType value(); } diff --git a/src/main/java/com/redstoner/annotations/Version.java b/src/main/java/com/redstoner/annotations/Version.java index 52d5145..2137c3f 100644 --- a/src/main/java/com/redstoner/annotations/Version.java +++ b/src/main/java/com/redstoner/annotations/Version.java @@ -1,32 +1,33 @@ package com.redstoner.annotations; -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; +import java.lang.annotation.*; -/** The Version annotation, to be applied to all Classes that are part of the project. - * - * @author Pepich */ -@Target(ElementType.TYPE) +/** + * The Version annotation, to be applied to all Classes that are part of the project. + * + * @author Pepich + */ +@Target (ElementType.TYPE) @Documented -@Retention(RetentionPolicy.RUNTIME) -public @interface Version -{ - /** The major indicator of the version. Will be used for compatibility detection. - * - * @return the major version as an int */ +@Retention (RetentionPolicy.RUNTIME) +public @interface Version { + /** + * The major indicator of the version. Will be used for compatibility detection. + * + * @return the major version as an int + */ int major(); - + int minor(); - + int revision(); - - /** The compatibility part of the version number. Will be used for compatibility detection.
+ + /** + * The compatibility part of the version number. Will be used for compatibility detection.
* Set to -1 if it is supposed to be always compatible.
* Defaults to 1. - * - * @return the smallest compatible version as an int. */ + * + * @return the smallest compatible version as an int. + */ int compatible() default 1; } diff --git a/src/main/java/com/redstoner/coremods/moduleLoader/ModuleLoader.java b/src/main/java/com/redstoner/coremods/moduleLoader/ModuleLoader.java index 3886dd1..0397f59 100644 --- a/src/main/java/com/redstoner/coremods/moduleLoader/ModuleLoader.java +++ b/src/main/java/com/redstoner/coremods/moduleLoader/ModuleLoader.java @@ -1,26 +1,5 @@ package com.redstoner.coremods.moduleLoader; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLClassLoader; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; - -import org.bukkit.Bukkit; -import org.bukkit.command.CommandSender; -import org.bukkit.configuration.InvalidConfigurationException; -import org.bukkit.configuration.file.FileConfiguration; -import org.bukkit.event.HandlerList; -import org.bukkit.event.Listener; -import org.bukkit.plugin.java.JavaPlugin; - import com.nemez.cmdmgr.Command; import com.nemez.cmdmgr.Command.AsyncType; import com.nemez.cmdmgr.CommandManager; @@ -34,243 +13,216 @@ import com.redstoner.misc.VersionHelper; import com.redstoner.modules.CoreModule; import com.redstoner.modules.Module; import com.redstoner.modules.ModuleLogger; - import net.nemez.chatapi.click.Message; +import org.bukkit.Bukkit; +import org.bukkit.command.CommandSender; +import org.bukkit.configuration.InvalidConfigurationException; +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.event.HandlerList; +import org.bukkit.event.Listener; +import org.bukkit.plugin.java.JavaPlugin; -/** The module loader, mother of all modules. Responsible for loading and taking care of all modules. - * - * @author Pepich */ -@Version(major = 5, minor = 2, revision = 0, compatible = 5) -public final class ModuleLoader implements CoreModule -{ - private static ModuleLoader instance; - private static final HashMap modules = new HashMap<>(); - private static HashMap moduleInfos = new HashMap<>(); - private static HashMap> categorizes = new HashMap<>(); - private static URL[] urls; - private static URLClassLoader mainLoader; - private static HashMap loaders = new HashMap<>(); - private static File configFile; - private static FileConfiguration config; - private static boolean debugMode = false; - private static HashMap loggers = new HashMap<>(); - - private ModuleLoader() - { - try - { +import java.io.*; +import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLClassLoader; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; + +/** + * The module loader, mother of all modules. Responsible for loading and taking care of all modules. + * + * @author Pepich + */ +@Version (major = 5, minor = 2, revision = 0, compatible = 5) +public final class ModuleLoader implements CoreModule { + private static final HashMap modules = new HashMap<>(); + private static ModuleLoader instance; + private static HashMap moduleInfos = new HashMap<>(); + private static HashMap> categorizes = new HashMap<>(); + private static URL[] urls; + private static URLClassLoader mainLoader; + private static HashMap loaders = new HashMap<>(); + private static File configFile; + private static FileConfiguration config; + private static boolean debugMode = false; + private static HashMap loggers = new HashMap<>(); + + private ModuleLoader() { + try { config = Main.plugin.getConfig(); configFile = new File(Main.plugin.getDataFolder(), "config.yml"); - urls = new URL[] {(new File(Main.plugin.getDataFolder(), "classes")).toURI().toURL()}; + urls = new URL[] { (new File(Main.plugin.getDataFolder(), "classes")).toURI().toURL() }; mainLoader = new URLClassLoader(urls, this.getClass().getClassLoader()); - } - catch (MalformedURLException e) - { + } catch (MalformedURLException e) { System.out.println("Sumtin is wong with ya filesüstem m8. Fix eeeet or I won't werk!"); Bukkit.getPluginManager().disablePlugin(Main.plugin); } } - - public static void init() - { + + public static void init() { if (instance == null) instance = new ModuleLoader(); ModuleInfo info = new ModuleInfo(ModuleLoader.class.getResourceAsStream("module.info"), instance); moduleInfos.put(instance, info); loggers.put(instance, new ModuleLogger(info.getDisplayName())); CommandManager.registerCommand(ModuleLoader.class.getResourceAsStream("ModuleLoader.cmd"), instance, - Main.plugin); + Main.plugin + ); } - - public static final void loadFromConfig() - { - try - { - if (!configFile.exists()) - { + + public static final void loadFromConfig() { + try { + if (!configFile.exists()) { configFile.getParentFile().mkdirs(); configFile.createNewFile(); } config.load(configFile); - } - catch (FileNotFoundException e) - {} - catch (IOException e) - { + } catch (FileNotFoundException e) { + } catch (IOException e) { e.printStackTrace(); - } - catch (InvalidConfigurationException e) - { + } catch (InvalidConfigurationException e) { configFile.delete(); - try - { + try { configFile.createNewFile(); - } - catch (IOException e1) - { + } catch (IOException e1) { e1.printStackTrace(); } instance.getLogger().error("Invalid config file! Creating new, blank file!"); } List coremods = config.getStringList("coremods"); - if (coremods == null || coremods.isEmpty()) - { - config.set("coremods", new String[] {"# Add the coremodules here!"}); + if (coremods == null || coremods.isEmpty()) { + config.set("coremods", new String[] { "# Add the coremodules here!" }); Main.plugin.saveConfig(); - try - { + try { config.save(configFile); - } - catch (IOException e) - { + } catch (IOException e) { e.printStackTrace(); } } List autoload = config.getStringList("autoload"); - if (autoload == null || autoload.isEmpty()) - { - config.set("autoload", new String[] {"# Add the modules here!"}); + if (autoload == null || autoload.isEmpty()) { + config.set("autoload", new String[] { "# Add the modules here!" }); Main.plugin.saveConfig(); - try - { + try { config.save(configFile); - } - catch (IOException e) - { + } catch (IOException e) { e.printStackTrace(); } } - if (!config.contains("debugMode")) - { + if (!config.contains("debugMode")) { config.set("debugMode", false); - try - { + try { config.save(configFile); - } - catch (IOException e) - { + } catch (IOException e) { e.printStackTrace(); } } debugMode = config.getBoolean("debugMode"); - for (String s : coremods) + for (String s : coremods) { if (!s.startsWith("#")) - if (!ModuleLoader.addDynamicModule(s)) - { + if (!ModuleLoader.addDynamicModule(s)) { instance.getLogger().error("Couldn't autocomplete path for module name: " + s - + "! If you're on a case sensitive filesystem, please take note that case correction does not work. Make sure that the classname has proper capitalisation."); - + + "! If you're on a case sensitive filesystem, please take note that case correction does not work. Make sure that the classname has proper capitalisation."); + } - for (String s : autoload) + } + for (String s : autoload) { if (!s.startsWith("#")) - if (!ModuleLoader.addDynamicModule(s)) - { + if (!ModuleLoader.addDynamicModule(s)) { instance.getLogger().error("Couldn't autocomplete path for module name: " + s - + "! If you're on a case sensitive filesystem, please take note that case correction does not work. Make sure that the classname has proper capitalisation."); - + + "! If you're on a case sensitive filesystem, please take note that case correction does not work. Make sure that the classname has proper capitalisation."); + } + } updateConfig(); } - - /** This method enables a specific module. If no module with that name is known to the loader yet it will be added to the list.
+ + /** + * This method enables a specific module. If no module with that name is known to the loader yet it will be added to the list.
* This method is deprecated, use enableDynamicModule instead. When using this method, dynamic reloading of the module will not be supported. - * + * * @param clazz The class of the module to be enabled. - * @return true, when the module was successfully enabled. */ + * + * @return true, when the module was successfully enabled. + */ @Deprecated - public static final boolean enableModule(Class clazz) - { - for (Module module : modules.keySet()) - { - if (module.getClass().equals(clazz)) - { - if (modules.get(module)) - { + public static final boolean enableModule(Class clazz) { + for (Module module : modules.keySet()) { + if (module.getClass().equals(clazz)) { + if (modules.get(module)) { instance.getLogger().info("Module was already enabled! Ignoring module.!"); return true; } - if (module.onEnable()) - { + if (module.onEnable()) { if (module.getClass().isAnnotationPresent(AutoRegisterListener.class) - && (module instanceof Listener)) - { + && (module instanceof Listener)) { Bukkit.getPluginManager().registerEvents((Listener) module, Main.plugin); } instance.getLogger().info("Enabled module " + module.getClass().getName()); instance.getLogger().info("Loaded module " + module.getClass().getName()); modules.put(module, true); return true; - } - else - { + } else { instance.getLogger().error("Failed to enable module " + module.getClass().getName()); return false; } } } - try - { + try { Module m = clazz.newInstance(); modules.put(m, false); - if (m.onEnable()) - { - if (m.getClass().isAnnotationPresent(AutoRegisterListener.class) && (m instanceof Listener)) - { + if (m.onEnable()) { + if (m.getClass().isAnnotationPresent(AutoRegisterListener.class) && (m instanceof Listener)) { Bukkit.getPluginManager().registerEvents((Listener) m, Main.plugin); } instance.getLogger().info("Loaded and enabled module " + m.getClass().getName()); instance.getLogger().info("Loaded module " + m.getClass().getName()); return true; - } - else - { + } else { instance.getLogger().error("Failed to enable module " + m.getClass().getName()); return false; } - } - catch (InstantiationException | IllegalAccessException e) - { + } catch (InstantiationException | IllegalAccessException e) { instance.getLogger() - .error("Could not add " + clazz.getName() + " to the list, constructor not accessible."); + .error("Could not add " + clazz.getName() + " to the list, constructor not accessible."); return false; } } - - private static final void enableLoadedModule(Module module, Version oldVersion) - { - try - { + + private static final void enableLoadedModule(Module module, Version oldVersion) { + try { InputStream infoFile = null; - + if (VersionHelper.isCompatible(VersionHelper.create(5, 0, 0, 5), module.getClass())) { - String basePath = "plugins/ModuleLoader/classes/" + module.getClass().getName().replace(".", "/"); - + String basePath = "plugins/ModuleLoader/classes/" + module.getClass().getName().replace(".", "/"); + try { infoFile = new FileInputStream( - new File(basePath.substring(0, basePath.lastIndexOf('/')+1) + "module.info")); - } - catch(Exception e) { + new File(basePath.substring(0, basePath.lastIndexOf('/') + 1) + "module.info")); + } catch (Exception e) { infoFile = null; } } ModuleInfo info = new ModuleInfo(infoFile, module); - + moduleInfos.put(module, info); - + String category = info.getCategory(); - if (!categorizes.containsKey(category)) + if (!categorizes.containsKey(category)) categorizes.put(category, new ArrayList<>(Arrays.asList(module))); else { List modsInCat = categorizes.get(category); modsInCat.add(module); categorizes.put(category, modsInCat); } - - loggers.put(module, new ModuleLogger(info.getDisplayName())); - - - if (module.onEnable()) - { + + loggers.put(module, new ModuleLogger(info.getDisplayName())); + + + if (module.onEnable()) { modules.put(module, true); if (VersionHelper.getString(oldVersion).equals("0.0.0.0")) module.firstLoad(); @@ -278,21 +230,18 @@ public final class ModuleLoader implements CoreModule module.migrate(oldVersion); if (VersionHelper.isCompatible(VersionHelper.create(5, 0, 0, 3), module.getClass())) module.postEnable(); - if (VersionHelper.isCompatible(VersionHelper.create(5, 0, 0, 4), module.getClass())) - { + if (VersionHelper.isCompatible(VersionHelper.create(5, 0, 0, 4), module.getClass())) { Commands ann = module.getClass().getAnnotation(Commands.class); - if (ann != null) - { - switch (ann.value()) - { + if (ann != null) { + switch (ann.value()) { case File: File f = new File("plugins/ModuleLoader/classes/" - + module.getClass().getName().replace(".", "/") + ".cmd"); + + module.getClass().getName().replace(".", "/") + ".cmd"); CommandManager.registerCommand(f, module, Main.plugin); break; case Stream: InputStream stream = module.getClass() - .getResourceAsStream(module.getClass().getSimpleName() + ".cmd"); + .getResourceAsStream(module.getClass().getSimpleName() + ".cmd"); CommandManager.registerCommand(stream, module, Main.plugin); case String: CommandManager.registerCommand(module.getCommandString(), module, Main.plugin); @@ -305,189 +254,97 @@ public final class ModuleLoader implements CoreModule instance.getLogger().info("Loaded module " + module.getClass().getName()); if (module.getClass().isAnnotationPresent(AutoRegisterListener.class) && (module instanceof Listener)) Bukkit.getPluginManager().registerEvents((Listener) module, Main.plugin); - } - else + } else instance.getLogger().error("Failed to load module " + module.getClass().getName()); - } - catch (Exception e) - { + } catch (Exception e) { instance.getLogger().error("Failed to load module " + module.getClass().getName()); e.printStackTrace(); } } - - /** This method lists all modules to the specified CommandSender. The modules will be color coded correspondingly to their enabled status. - * - * @param sender The person to send the info to, usually the issuer of the command or the console sender. - * @return true. */ - @Command(hook = "list", async = AsyncType.ALWAYS) - public boolean listModulesCommand(CommandSender sender) - { - boolean hasCategorys = hasCategories(); - Message m = new Message(sender, null); - ModuleInfo ml_info = moduleInfos.get(instance); - - m.appendText("§2--=[ ") - .appendTextHover("§2" + ml_info.getDisplayName(), ml_info.getModuleInfoHover()) - .appendText("§2 ]=--\nModules:\n"); - - for (String cat: categorizes.keySet()) { - if (hasCategorys) - m.appendText("\n&7" + cat + ":\n"); - - int curModule = 1; - List mods = categorizes.get(cat); - for (Module mod : mods) { - - ModuleInfo info = moduleInfos.get(mod); - m.appendTextHover((modules.get(mod) ? "§a" : "§c") + info.getDisplayName(), info.getModuleInfoHover()); - - if (curModule != mods.size()) - m.appendText("&7, "); - curModule++; - } - m.appendText("\n"); - - } - m.send(); - return true; - } - - public static void disableModules() - { - for (Module module : modules.keySet()) - { + + public static void disableModules() { + for (Module module : modules.keySet()) { disableModule(module); } } - - public static void disableModule(Module module) - { - if (modules.get(module)) - { + + public static void disableModule(Module module) { + if (modules.get(module)) { module.onDisable(); - if (module.getClass().isAnnotationPresent(AutoRegisterListener.class) && (module instanceof Listener)) - { + if (module.getClass().isAnnotationPresent(AutoRegisterListener.class) && (module instanceof Listener)) { HandlerList.unregisterAll((Listener) module); } CommandManager.unregisterAllWithFallback(module.getClass().getSimpleName()); PrivateLogManager.unregister(module); - try - { + try { URLClassLoader loader = loaders.get(module); if (loader != null) loader.close(); - } - catch (IOException e) - {} - finally - { + } catch (IOException e) { + } finally { loaders.remove(module); } } } - - @Command(hook = "load") - public boolean loadModule(CommandSender sender, String name) - { - if (!addDynamicModule(name)) - { - instance.getLogger().message(sender, true, "Couldn't autocomplete path for module name: " + name - + "! If you're on a case sensitive filesystem, please take note that case correction does not work. Make sure that the classname has proper capitalisation."); - - } - updateConfig(); - return true; - } - - @Command(hook = "unload") - public boolean unloadModule(CommandSender sender, String name) - { - if (!removeDynamicModule(name)) - instance.getLogger().error("Couldn't find module! Couldn't disable nonexisting module!"); - return true; - } - - public static final boolean addDynamicModule(String raw_name) - { - String[] raw = raw_name.split(" "); - String name = raw[0]; - Version oldVersion; + + public static final boolean addDynamicModule(String raw_name) { + String[] raw = raw_name.split(" "); + String name = raw[0]; + Version oldVersion; if (raw.length > 1) oldVersion = VersionHelper.getVersion(raw[1]); else oldVersion = VersionHelper.create(0, 0, 0, 0); - for (Module m : modules.keySet()) - { - if (m.getClass().getName().equals(name)) - { + for (Module m : modules.keySet()) { + if (m.getClass().getName().equals(name)) { instance.getLogger().info( "Found existing module, attempting override. WARNING! This operation will halt the main thread until it is completed."); instance.getLogger() - .info("Attempting to load new class definition before disabling and removing the old module"); + .info("Attempting to load new class definition before disabling and removing the old module"); boolean differs = false; instance.getLogger().info("Old class definition: Class@" + m.getClass().hashCode()); - ClassLoader delegateParent = mainLoader.getParent(); - Class newClass = null; - URLClassLoader cl = new URLClassLoader(urls, delegateParent); - try - { + ClassLoader delegateParent = mainLoader.getParent(); + Class newClass = null; + URLClassLoader cl = new URLClassLoader(urls, delegateParent); + try { newClass = cl.loadClass(m.getClass().getName()); instance.getLogger().info("Found new class definition: Class@" + newClass.hashCode()); differs = m.getClass() != newClass; - } - catch (ClassNotFoundException e) - { + } catch (ClassNotFoundException e) { instance.getLogger().error("Could not find a class definition, aborting now!"); e.printStackTrace(); - try - { + try { cl.close(); - } - catch (IOException e1) - { + } catch (IOException e1) { e1.printStackTrace(); } return false; } - if (!differs) - { - if (!debugMode) - { + if (!differs) { + if (!debugMode) { instance.getLogger().warn( "New class definition equals old definition, are you sure you did everything right?"); instance.getLogger().info("Aborting now..."); - try - { + try { cl.close(); - } - catch (IOException e) - { + } catch (IOException e) { e.printStackTrace(); } return false; - } - else + } else instance.getLogger().warn( "New class definition equals old definition, but debugMode is enabled. Loading anyways."); - } - else + } else instance.getLogger().info("Found new class definition, attempting to instantiate:"); Module module = null; - try - { + try { module = (Module) newClass.newInstance(); - } - catch (InstantiationException | IllegalAccessException e) - { + } catch (InstantiationException | IllegalAccessException e) { instance.getLogger().error("Could not instantiate the module, aborting!"); e.printStackTrace(); - try - { + try { cl.close(); - } - catch (IOException e1) - { + } catch (IOException e1) { e1.printStackTrace(); } return false; @@ -497,45 +354,34 @@ public final class ModuleLoader implements CoreModule instance.getLogger().info("Current version: " + VersionHelper.getString(oldVersion)); Version newVersion = module.getClass().getAnnotation(Version.class); instance.getLogger().info("Version of remote class: " + VersionHelper.getString(newVersion)); - if (oldVersion.equals(newVersion)) - { - if (!debugMode) - { + if (oldVersion.equals(newVersion)) { + if (!debugMode) { instance.getLogger().error("Detected equal module versions, " + (debugMode - ? " aborting now... Set debugMode to true in your config if you want to continue!" - : " continueing anyways.")); - if (!debugMode) - { - try - { + ? " aborting now... Set debugMode to true in your config if you want to continue!" + : " continueing anyways.")); + if (!debugMode) { + try { cl.close(); - } - catch (IOException e) - { + } catch (IOException e) { e.printStackTrace(); } return false; } - } - else + } else instance.getLogger() - .warn("New version equals old version, but debugMode is enabled. Loading anyways."); - } - else + .warn("New version equals old version, but debugMode is enabled. Loading anyways."); + } else instance.getLogger().info("Versions differ, disabling old module"); disableModule(m); instance.getLogger().info("Disabled module, overriding the implementation"); modules.remove(m); categorizes.get(moduleInfos.get(m).getCategory()).remove(m); moduleInfos.remove(m); - - try - { + + try { if (loaders.containsKey(m)) loaders.remove(m).close(); - } - catch (IOException e) - { + } catch (IOException e) { e.printStackTrace(); } modules.put(module, false); @@ -545,61 +391,50 @@ public final class ModuleLoader implements CoreModule return true; } } - ClassLoader delegateParent = mainLoader.getParent(); - URLClassLoader cl = new URLClassLoader(urls, delegateParent); - try - { - Class clazz = cl.loadClass(name); - Module module = (Module) clazz.newInstance(); + ClassLoader delegateParent = mainLoader.getParent(); + URLClassLoader cl = new URLClassLoader(urls, delegateParent); + try { + Class clazz = cl.loadClass(name); + Module module = (Module) clazz.newInstance(); modules.put(module, false); loaders.put(module, cl); enableLoadedModule(module, oldVersion); return true; - } - catch (NoClassDefFoundError | ClassNotFoundException | InstantiationException | IllegalAccessException e) - { - try - { + } catch (NoClassDefFoundError | ClassNotFoundException | InstantiationException | IllegalAccessException e) { + try { cl.close(); + } catch (IOException e1) { } - catch (IOException e1) - {} - if (e instanceof NoClassDefFoundError) - { + if (e instanceof NoClassDefFoundError) { NoClassDefFoundError exception = (NoClassDefFoundError) e; - String[] exMessage = exception.getMessage().split(" "); + String[] exMessage = exception.getMessage().split(" "); String moduleName = exMessage[exMessage.length - 1] .substring(0, exMessage[exMessage.length - 1].length() - - (exMessage[exMessage.length - 1].endsWith(")") ? 1 : 0)) + - (exMessage[exMessage.length - 1].endsWith(")") ? 1 : 0)) .replace("/", "."); - if (!moduleName.equalsIgnoreCase(name)) - { + if (!moduleName.equalsIgnoreCase(name)) { instance.getLogger() - .error("Class &e" + moduleName + "&r couldn't be found! Suspecting a missing dependency!"); + .error("Class &e" + moduleName + "&r couldn't be found! Suspecting a missing dependency!"); return false; - } - else + } else instance.getLogger().warn( "Couldn't find class definition, attempting to get proper classname from thrown Exception."); if (addDynamicModule(moduleName)) return true; } - if (name.endsWith(".class")) - { + if (name.endsWith(".class")) { instance.getLogger().warn( "Couldn't find class definition, but path ends with .class -> Attempting again with removed file suffix."); if (addDynamicModule(name.replaceAll(".class$", ""))) return true; } - if (!name.contains(".")) - { + if (!name.contains(".")) { instance.getLogger().warn( "Couldn't find class definition, suspecting incomplete path. Attempting autocompletion of path by adding a package name and trying again."); if (addDynamicModule(name.toLowerCase() + "." + name)) return true; } - if (!name.startsWith("com.redstoner.modules.") && name.contains(".")) - { + if (!name.startsWith("com.redstoner.modules.") && name.contains(".")) { instance.getLogger().warn( "Couldn't find class definition, suspecting incomplete path. Attempting autocompletion of package name and trying again."); if (addDynamicModule("com.redstoner.modules." + name)) @@ -608,13 +443,10 @@ public final class ModuleLoader implements CoreModule } return false; } - - public static final boolean removeDynamicModule(String name) - { - for (Module m : modules.keySet()) - { - if (m.getClass().getName().equals(name)) - { + + public static final boolean removeDynamicModule(String name) { + for (Module m : modules.keySet()) { + if (m.getClass().getName().equals(name)) { instance.getLogger().info( "Found existing module, attempting unload. WARNING! This operation will halt the main thread until it is completed."); instance.getLogger().info("Attempting to disable module properly:"); @@ -626,24 +458,20 @@ public final class ModuleLoader implements CoreModule return true; } } - if (!name.startsWith("com.redstoner.modules.")) - { - if (name.endsWith(".class")) - { + if (!name.startsWith("com.redstoner.modules.")) { + if (name.endsWith(".class")) { instance.getLogger().warn( "Couldn't find class definition, but path ends with .class -> Attempting again with removed file suffix."); if (removeDynamicModule(name.replaceAll(".class$", ""))) return true; } - if (!name.contains(".")) - { + if (!name.contains(".")) { instance.getLogger().warn( "Couldn't find class definition, suspecting incomplete path. Attempting autocompletion of path by adding a package name and trying again."); if (removeDynamicModule(name.toLowerCase() + "." + name)) return true; } - if (!name.startsWith("com.redstoner.modules.")) - { + if (!name.startsWith("com.redstoner.modules.")) { instance.getLogger().warn( "Couldn't find class definition, suspecting incomplete path. Attempting autocompletion of package name and trying again."); if (removeDynamicModule("com.redstoner.modules." + name)) @@ -652,101 +480,145 @@ public final class ModuleLoader implements CoreModule } return false; } - - /** Finds a module by name for other modules to reference it. - * + + /** + * Finds a module by name for other modules to reference it. + * * @param name the name of the module. Use the full path if you are not sure about the module's SimpleClassName being unique. - * @return the instance of the module or @null it none could be found */ - public static Module getModule(String name) - { - for (Module m : modules.keySet()) + * + * @return the instance of the module or @null it none could be found + */ + public static Module getModule(String name) { + for (Module m : modules.keySet()) { if (m.getClass().getSimpleName().equalsIgnoreCase(name) || m.getClass().getName().equalsIgnoreCase(name)) return m; + } return null; } - - /** Finds a module by name for other modules to reference it. - * + + /** + * Finds a module by name for other modules to reference it. + * * @param name the name of the module. Use the full path if you are not sure about the module's SimpleClassName being unique. - * @return the instance of the module or @null it none could be found */ - public static boolean exists(String name) - { - for (Module m : modules.keySet()) + * + * @return the instance of the module or @null it none could be found + */ + public static boolean exists(String name) { + for (Module m : modules.keySet()) { if (m.getClass().getSimpleName().equals(name) || m.getClass().getName().equals(name)) return true; + } return false; } - - public static ModuleLogger getModuleLogger(Module module) - { + + public static ModuleLogger getModuleLogger(Module module) { return loggers.get(module); } - - public static void updateConfig() - { - List coremods = config.getStringList("coremods"); + + public static void updateConfig() { + List coremods = config.getStringList("coremods"); ArrayList new_coremods = new ArrayList<>(); - List autoload = config.getStringList("autoload"); + List autoload = config.getStringList("autoload"); ArrayList new_autoload = new ArrayList<>(); - - for (String s : coremods) - { - if (s.startsWith("#")) - { + + for (String s : coremods) { + if (s.startsWith("#")) { new_coremods.add(s); - } - else - { + } else { s = s.split(" ")[0]; - try - { + try { new_coremods.add(getModule(s).getClass().getName() + " " - + VersionHelper.getVersion(getModule(s).getClass())); - } - catch (Exception e) - { + + VersionHelper.getVersion(getModule(s).getClass())); + } catch (Exception e) { new_coremods.add(s + " " + VersionHelper.getString(VersionHelper.create(0, 0, 0, 0))); } } } - for (String s : autoload) - { - if (s.startsWith("#")) - { + for (String s : autoload) { + if (s.startsWith("#")) { new_autoload.add(s); - } - else - { + } else { s = s.split(" ")[0]; - try - { + try { new_autoload.add(getModule(s).getClass().getName() + " " - + VersionHelper.getVersion(getModule(s).getClass())); - } - catch (Exception e) - { + + VersionHelper.getVersion(getModule(s).getClass())); + } catch (Exception e) { new_autoload.add(s + " " + VersionHelper.getString(VersionHelper.create(0, 0, 0, 0))); } } } - + config.set("coremods", new_coremods); config.set("autoload", new_autoload); - try - { + try { config.save(configFile); - } - catch (IOException e) - { + } catch (IOException e) { e.printStackTrace(); } } - + public static JavaPlugin getPlugin() { return Main.plugin; } - + + /** + * This method lists all modules to the specified CommandSender. The modules will be color coded correspondingly to their enabled status. + * + * @param sender The person to send the info to, usually the issuer of the command or the console sender. + * + * @return true. + */ + @Command (hook = "list", async = AsyncType.ALWAYS) + public boolean listModulesCommand(CommandSender sender) { + boolean hasCategorys = hasCategories(); + Message m = new Message(sender, null); + ModuleInfo ml_info = moduleInfos.get(instance); + + m.appendText("§2--=[ ") + .appendTextHover("§2" + ml_info.getDisplayName(), ml_info.getModuleInfoHover()) + .appendText("§2 ]=--\nModules:\n"); + + for (String cat : categorizes.keySet()) { + if (hasCategorys) + m.appendText("\n&7" + cat + ":\n"); + + int curModule = 1; + List mods = categorizes.get(cat); + for (Module mod : mods) { + + ModuleInfo info = moduleInfos.get(mod); + m.appendTextHover((modules.get(mod) ? "§a" : "§c") + info.getDisplayName(), info.getModuleInfoHover()); + + if (curModule != mods.size()) + m.appendText("&7, "); + curModule++; + } + m.appendText("\n"); + + } + m.send(); + return true; + } + public static boolean hasCategories() { return !(categorizes.size() == 1 && categorizes.containsKey("Other")); } + + @Command (hook = "load") + public boolean loadModule(CommandSender sender, String name) { + if (!addDynamicModule(name)) { + instance.getLogger().message(sender, true, "Couldn't autocomplete path for module name: " + name + + "! If you're on a case sensitive filesystem, please take note that case correction does not work. Make sure that the classname has proper capitalisation."); + + } + updateConfig(); + return true; + } + + @Command (hook = "unload") + public boolean unloadModule(CommandSender sender, String name) { + if (!removeDynamicModule(name)) + instance.getLogger().error("Couldn't find module! Couldn't disable nonexisting module!"); + return true; + } } diff --git a/src/main/java/com/redstoner/exceptions/MissingVersionException.java b/src/main/java/com/redstoner/exceptions/MissingVersionException.java index 62032b6..3ea1f17 100644 --- a/src/main/java/com/redstoner/exceptions/MissingVersionException.java +++ b/src/main/java/com/redstoner/exceptions/MissingVersionException.java @@ -2,21 +2,20 @@ package com.redstoner.exceptions; import com.redstoner.annotations.Version; -/** To be thrown when a module is not annotated with its version. If this gets thrown, then oh boy, you're in trouble now. - * - * @author Pepich */ -@Version(major = 1, minor = 0, revision = 0, compatible = -1) -public class MissingVersionException extends Exception -{ +/** + * To be thrown when a module is not annotated with its version. If this gets thrown, then oh boy, you're in trouble now. + * + * @author Pepich + */ +@Version (major = 1, minor = 0, revision = 0, compatible = -1) +public class MissingVersionException extends Exception { private static final long serialVersionUID = 4940161335512222539L; - - public MissingVersionException() - { + + public MissingVersionException() { super(); } - - public MissingVersionException(String message) - { + + public MissingVersionException(String message) { super(message); } } diff --git a/src/main/java/com/redstoner/exceptions/NonSaveableConfigException.java b/src/main/java/com/redstoner/exceptions/NonSaveableConfigException.java index df33bff..926e9b2 100644 --- a/src/main/java/com/redstoner/exceptions/NonSaveableConfigException.java +++ b/src/main/java/com/redstoner/exceptions/NonSaveableConfigException.java @@ -1,9 +1,9 @@ package com.redstoner.exceptions; public class NonSaveableConfigException extends Exception { - private static final long serialVersionUID = -7271481973389455510L; - - public NonSaveableConfigException() { - super("This config does not support saving!"); - } + private static final long serialVersionUID = -7271481973389455510L; + + public NonSaveableConfigException() { + super("This config does not support saving!"); + } } diff --git a/src/main/java/com/redstoner/logging/Log4JFilter.java b/src/main/java/com/redstoner/logging/Log4JFilter.java index 1ebed09..bdc94d4 100644 --- a/src/main/java/com/redstoner/logging/Log4JFilter.java +++ b/src/main/java/com/redstoner/logging/Log4JFilter.java @@ -1,5 +1,5 @@ package com.redstoner.logging; - + import org.apache.logging.log4j.Level; import org.apache.logging.log4j.Marker; import org.apache.logging.log4j.core.LogEvent; @@ -9,46 +9,46 @@ import org.apache.logging.log4j.message.Message; public class Log4JFilter extends AbstractFilter { - private static final long serialVersionUID = -5594073755007974254L; + private static final long serialVersionUID = -5594073755007974254L; - private static Result validateMessage(Message message) { - if (message == null) { - return Result.NEUTRAL; - } - return validateMessage(message.getFormattedMessage()); - } + @Override + public Result filter(LogEvent event) { + Message candidate = null; + if (event != null) { + candidate = event.getMessage(); + } + return validateMessage(candidate); + } - private static Result validateMessage(String message) { - return PrivateLogManager.isHidden(message) - ? Result.DENY - : Result.NEUTRAL; - } + private static Result validateMessage(Message message) { + if (message == null) { + return Result.NEUTRAL; + } + return validateMessage(message.getFormattedMessage()); + } - @Override - public Result filter(LogEvent event) { - Message candidate = null; - if (event != null) { - candidate = event.getMessage(); - } - return validateMessage(candidate); - } + private static Result validateMessage(String message) { + return PrivateLogManager.isHidden(message) + ? Result.DENY + : Result.NEUTRAL; + } - @Override - public Result filter(Logger logger, Level level, Marker marker, Message msg, Throwable t) { - return validateMessage(msg); - } + @Override + public Result filter(Logger logger, Level level, Marker marker, Message msg, Throwable t) { + return validateMessage(msg); + } - @Override - public Result filter(Logger logger, Level level, Marker marker, String msg, Object... params) { - return validateMessage(msg); - } + @Override + public Result filter(Logger logger, Level level, Marker marker, String msg, Object... params) { + return validateMessage(msg); + } - @Override - public Result filter(Logger logger, Level level, Marker marker, Object msg, Throwable t) { - String candidate = null; - if (msg != null) { - candidate = msg.toString(); - } - return validateMessage(candidate); - } + @Override + public Result filter(Logger logger, Level level, Marker marker, Object msg, Throwable t) { + String candidate = null; + if (msg != null) { + candidate = msg.toString(); + } + return validateMessage(candidate); + } } \ No newline at end of file diff --git a/src/main/java/com/redstoner/logging/PrivateLogManager.java b/src/main/java/com/redstoner/logging/PrivateLogManager.java index e8451e0..ce6a68c 100644 --- a/src/main/java/com/redstoner/logging/PrivateLogManager.java +++ b/src/main/java/com/redstoner/logging/PrivateLogManager.java @@ -1,44 +1,41 @@ package com.redstoner.logging; +import com.redstoner.misc.Utils; +import com.redstoner.modules.Module; +import com.redstoner.modules.ModuleLogger; +import org.apache.logging.log4j.LogManager; + import java.util.HashMap; import java.util.Iterator; import java.util.Map; -import org.apache.logging.log4j.LogManager; - -import com.redstoner.misc.Utils; -import com.redstoner.modules.Module; -import com.redstoner.modules.ModuleLogger; - public class PrivateLogManager { + private static final String ISSUED_COMMAND_TEXT = "issued server command: /"; + private static final int ISSUED_COMMAND_TEXT_LENGTH = ISSUED_COMMAND_TEXT.length(); private static Map registrar = new HashMap<>(); - private static Map commands = new HashMap<>(); - - private static final String ISSUED_COMMAND_TEXT = "issued server command: /"; - private static final int ISSUED_COMMAND_TEXT_LENGTH = ISSUED_COMMAND_TEXT.length(); - + private static Map commands = new HashMap<>(); private static ModuleLogger logger; - + public static void initialize() { org.apache.logging.log4j.core.Logger logger; - logger = (org.apache.logging.log4j.core.Logger) LogManager.getRootLogger(); - logger.addFilter(new Log4JFilter()); - PrivateLogManager.logger = new ModuleLogger("PrivateLogManager"); + logger = (org.apache.logging.log4j.core.Logger) LogManager.getRootLogger(); + logger.addFilter(new Log4JFilter()); + PrivateLogManager.logger = new ModuleLogger("PrivateLogManager"); } - + public static void register(Module module, String command, String replacement) { command = command.toLowerCase(); registrar.put(command, module); commands.put(command, replacement); logger.info(module.getClass().getSimpleName() + " registered &e/" + command - + (replacement.equals("")? "&7. Command will not be logged!" - : "&7, using replacement, &e" + replacement + "&7.")); + + (replacement.equals("") ? "&7. Command will not be logged!" + : "&7, using replacement, &e" + replacement + "&7.")); } - + public static void unregister(Module module) { - String unregestered = ""; - Iterator> i = registrar.entrySet().iterator(); + String unregestered = ""; + Iterator> i = registrar.entrySet().iterator(); while (i.hasNext()) { Map.Entry entry = i.next(); if (entry.getValue() == module) { @@ -50,7 +47,7 @@ public class PrivateLogManager { if (!unregestered.equals("")) logger.info("Unregistered " + unregestered.substring(0, unregestered.length() - 2) + "&7 for module, " + module.getClass().getSimpleName() + "."); } - + public static void unregister(Module module, String... toRemove) { String unregestered = ""; for (int i = 0; i < toRemove.length; i++) { @@ -62,27 +59,27 @@ public class PrivateLogManager { if (!unregestered.equals("")) logger.info(module.getClass().getSimpleName() + " unregistered " + unregestered.substring(0, unregestered.length() - 2) + "&7."); } - + public static boolean isHidden(String message) { - if (message == null) - return false; - - int index = message.indexOf(ISSUED_COMMAND_TEXT); - if (index == -1) - return false; - - String command = message.substring(index + ISSUED_COMMAND_TEXT_LENGTH); - - int spaceIndex = command.indexOf(" "); - command = spaceIndex == -1? command.toLowerCase() : command.substring(0, spaceIndex).toLowerCase(); - - String replacement = commands.get(command); - if (replacement == null) - return false; - if (replacement.equals("")) - return true; - - String player = message.substring(0, message.indexOf(" ")); + if (message == null) + return false; + + int index = message.indexOf(ISSUED_COMMAND_TEXT); + if (index == -1) + return false; + + String command = message.substring(index + ISSUED_COMMAND_TEXT_LENGTH); + + int spaceIndex = command.indexOf(" "); + command = spaceIndex == -1 ? command.toLowerCase() : command.substring(0, spaceIndex).toLowerCase(); + + String replacement = commands.get(command); + if (replacement == null) + return false; + if (replacement.equals("")) + return true; + + String player = message.substring(0, message.indexOf(" ")); Utils.run(() -> System.out.println(replacement.replace("$s", player))); return true; } diff --git a/src/main/java/com/redstoner/misc/BroadcastFilter.java b/src/main/java/com/redstoner/misc/BroadcastFilter.java index 1f0ce04..a0098b6 100644 --- a/src/main/java/com/redstoner/misc/BroadcastFilter.java +++ b/src/main/java/com/redstoner/misc/BroadcastFilter.java @@ -1,14 +1,14 @@ package com.redstoner.misc; +import com.redstoner.annotations.Version; import org.bukkit.command.CommandSender; -import com.redstoner.annotations.Version; - -/** Classes implementing this interface can be used to define a filter for the Utils.broadcast method for sending a message to more than one, but less than all users. - * - * @author Pepich */ -@Version(major = 1, minor = 0, revision = 0, compatible = 1) -public interface BroadcastFilter -{ +/** + * Classes implementing this interface can be used to define a filter for the Utils.broadcast method for sending a message to more than one, but less than all users. + * + * @author Pepich + */ +@Version (major = 1, minor = 0, revision = 0, compatible = 1) +public interface BroadcastFilter { public boolean sendTo(CommandSender recipient); } diff --git a/src/main/java/com/redstoner/misc/CommandHolderType.java b/src/main/java/com/redstoner/misc/CommandHolderType.java index 7c4383e..3c64127 100644 --- a/src/main/java/com/redstoner/misc/CommandHolderType.java +++ b/src/main/java/com/redstoner/misc/CommandHolderType.java @@ -3,9 +3,8 @@ package com.redstoner.misc; import com.redstoner.annotations.Version; /** @author Pepich */ -@Version(major = 4, minor = 0, revision = 0, compatible = -1) -public enum CommandHolderType -{ +@Version (major = 4, minor = 0, revision = 0, compatible = -1) +public enum CommandHolderType { Stream, File, String, diff --git a/src/main/java/com/redstoner/misc/JsonManager.java b/src/main/java/com/redstoner/misc/JsonManager.java index 13b51b6..498933f 100644 --- a/src/main/java/com/redstoner/misc/JsonManager.java +++ b/src/main/java/com/redstoner/misc/JsonManager.java @@ -1,149 +1,144 @@ package com.redstoner.misc; +import com.redstoner.annotations.Version; +import org.json.simple.JSONArray; +import org.json.simple.JSONObject; +import org.json.simple.parser.JSONParser; +import org.json.simple.parser.ParseException; + import java.io.File; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; -import org.json.simple.JSONArray; -import org.json.simple.JSONObject; -import org.json.simple.parser.JSONParser; -import org.json.simple.parser.ParseException; +/** + * This class provides simple JSON handling, like storing and loading from and to files. + * + * @author Pepich + */ +@Version (major = 1, minor = 0, revision = 2, compatible = -1) +public class JsonManager { + private JsonManager() {} -import com.redstoner.annotations.Version; - -/** This class provides simple JSON handling, like storing and loading from and to files. - * - * @author Pepich */ -@Version(major = 1, minor = 0, revision = 2, compatible = -1) -public class JsonManager -{ - private JsonManager() - {} - - /** Loads a JSONObject from a file. - * + /** + * Loads a JSONObject from a file. + * * @param source the file to load from. - * @return the JSONObject or null if the source does not contain a valid JSONObject. */ - public static JSONObject getObject(File source) - { + * + * @return the JSONObject or null if the source does not contain a valid JSONObject. + */ + public static JSONObject getObject(File source) { if (!source.exists()) return null; JSONParser parser = new JSONParser(); - try - { - FileReader reader = new FileReader(source); - Object rawObject = parser.parse(reader); + try { + FileReader reader = new FileReader(source); + Object rawObject = parser.parse(reader); reader.close(); JSONObject jsonObject = (JSONObject) rawObject; return jsonObject; + } catch (IOException | ParseException e) { } - catch (IOException | ParseException e) - {} return null; } - - /** Saves a JSONObject to a file. Will create the necessary FileStructure like folders and the file itself.
+ + /** + * Saves a JSONObject to a file. Will create the necessary FileStructure like folders and the file itself.
* Note that this operation will be run on a different thread and you do not need to take care of that yourself. - * - * @param object the JSONObject to save. - * @param destination the file to write to. */ - public static void save(JSONObject object, File destination) - { - Thread t = new Thread(new Runnable() - { + * + * @param object the JSONObject to save. + * @param destination the file to write to. + */ + public static void save(JSONObject object, File destination) { + Thread t = new Thread(new Runnable() { @Override - public void run() - { + public void run() { saveSync(object, destination); } }); t.start(); } - - /** Saves a JSONObject to a file. Will create the necessary FileStructure like folders and the file itself.
+ + /** + * Saves a JSONObject to a file. Will create the necessary FileStructure like folders and the file itself.
* Note that this operation will be run on the same thread that you are calling it from! - * - * @param object the JSONObject to save. - * @param destination the file to write to. */ - public static void saveSync(JSONObject object, File destination) - { + * + * @param object the JSONObject to save. + * @param destination the file to write to. + */ + public static void saveSync(JSONObject object, File destination) { if (destination.exists()) destination.delete(); else if (!destination.getParentFile().exists()) destination.getParentFile().mkdirs(); - try - { + try { destination.createNewFile(); - FileWriter writer = new FileWriter(destination); - String json_string = object.toJSONString(); + FileWriter writer = new FileWriter(destination); + String json_string = object.toJSONString(); writer.write(json_string); writer.flush(); writer.close(); + } catch (IOException e) { } - catch (IOException e) - {} } - - /** Loads a JSONArray from a file. - * + + /** + * Loads a JSONArray from a file. + * * @param source the file to load from. - * @return the JSONArray or null if the source does not contain a valid JSONArray. */ - public static JSONArray getArray(File source) - { + * + * @return the JSONArray or null if the source does not contain a valid JSONArray. + */ + public static JSONArray getArray(File source) { if (!source.exists()) return null; JSONParser parser = new JSONParser(); - try - { - Object rawObject = parser.parse(new FileReader(source)); + try { + Object rawObject = parser.parse(new FileReader(source)); JSONArray jsonArray = (JSONArray) rawObject; return jsonArray; + } catch (IOException | ParseException e) { } - catch (IOException | ParseException e) - {} return null; } - - /** Saves a JSONArray to a file. Will create the necessary FileStructure like folders and the file itself.
+ + /** + * Saves a JSONArray to a file. Will create the necessary FileStructure like folders and the file itself.
* Note that this operation will be run on a different thread and you do not need to take care of that yourself. - * - * @param object the JSONArray to save. - * @param destination the file to write to. */ - public static void save(JSONArray array, File destination) - { - Thread t = new Thread(new Runnable() - { + * + * @param object the JSONArray to save. + * @param destination the file to write to. + */ + public static void save(JSONArray array, File destination) { + Thread t = new Thread(new Runnable() { @Override - public void run() - { + public void run() { saveSync(array, destination); } }); t.start(); } - - /** Saves a JSONArray to a file. Will create the necessary FileStructure like folders and the file itself.
+ + /** + * Saves a JSONArray to a file. Will create the necessary FileStructure like folders and the file itself.
* Note that this operation will be run on the same thread that you are calling it from! - * - * @param object the JSONArray to save. - * @param destination the file to write to. */ - public static void saveSync(JSONArray array, File destination) - { + * + * @param object the JSONArray to save. + * @param destination the file to write to. + */ + public static void saveSync(JSONArray array, File destination) { if (destination.exists()) destination.delete(); else if (!destination.getParentFile().exists()) destination.getParentFile().mkdirs(); - try - { + try { destination.createNewFile(); - FileWriter writer = new FileWriter(destination); - String json_string = array.toJSONString(); + FileWriter writer = new FileWriter(destination); + String json_string = array.toJSONString(); writer.write(json_string); writer.flush(); writer.close(); + } catch (IOException e) { } - catch (IOException e) - {} } } diff --git a/src/main/java/com/redstoner/misc/Main.java b/src/main/java/com/redstoner/misc/Main.java index 40894ee..e6de0d0 100644 --- a/src/main/java/com/redstoner/misc/Main.java +++ b/src/main/java/com/redstoner/misc/Main.java @@ -1,29 +1,27 @@ package com.redstoner.misc; -import org.bukkit.plugin.java.JavaPlugin; - import com.redstoner.annotations.Version; import com.redstoner.coremods.moduleLoader.ModuleLoader; import com.redstoner.logging.PrivateLogManager; import com.redstoner.misc.mysql.MysqlHandler; - import net.nemez.chatapi.ChatAPI; +import org.bukkit.plugin.java.JavaPlugin; -/** Main class. Duh. - * - * @author Pepich */ -@Version(major = 5, minor = 1, revision = 0, compatible = -1) -public class Main extends JavaPlugin -{ +/** + * Main class. Duh. + * + * @author Pepich + */ +@Version (major = 5, minor = 1, revision = 0, compatible = -1) +public class Main extends JavaPlugin { public static JavaPlugin plugin; - + @Override - public void onEnable() - { + public void onEnable() { plugin = this; - + PrivateLogManager.initialize(); - + ChatAPI.initialize(this); // Configger.init(); MysqlHandler.init(); @@ -31,10 +29,9 @@ public class Main extends JavaPlugin // Load modules from config ModuleLoader.loadFromConfig(); } - + @Override - public void onDisable() - { + public void onDisable() { ModuleLoader.disableModules(); } } diff --git a/src/main/java/com/redstoner/misc/ModuleInfo.java b/src/main/java/com/redstoner/misc/ModuleInfo.java index e96e813..0b670b9 100644 --- a/src/main/java/com/redstoner/misc/ModuleInfo.java +++ b/src/main/java/com/redstoner/misc/ModuleInfo.java @@ -1,14 +1,13 @@ package com.redstoner.misc; -import java.io.InputStream; -import java.io.InputStreamReader; - -import org.bukkit.configuration.file.FileConfiguration; -import org.bukkit.configuration.file.YamlConfiguration; - import com.redstoner.coremods.moduleLoader.ModuleLoader; import com.redstoner.exceptions.MissingVersionException; import com.redstoner.modules.Module; +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.configuration.file.YamlConfiguration; + +import java.io.InputStream; +import java.io.InputStreamReader; public class ModuleInfo { @@ -17,41 +16,55 @@ public class ModuleInfo { private String category; private String description; private String version; - + private String warning; - + public ModuleInfo(InputStream descriptor, Module module) { try { InputStreamReader reader = new InputStreamReader(descriptor); FileConfiguration config = YamlConfiguration.loadConfiguration(reader); - + displayName = config.getString("displayName"); category = config.getString("category"); description = config.getString("description"); - } - catch (Exception e) { + } catch (Exception e) { warning = "Descriptor file could not be loaded, using the class's name."; } - + simpleName = module.getClass().getSimpleName(); - + if (displayName == null) displayName = simpleName; - + if (category == null) category = "Other"; - + try { version = VersionHelper.getVersion(module.getClass()); } catch (MissingVersionException e) {} } + public String getDisplayName() { + return displayName; + } + + public String getWarning() { + return warning; + } + + public String getModuleInfoHover() { + return "&8&o" + getSimpleName() + "\n" + + "&r&e" + (getVersion() == null ? "&cVersion Missing" : getVersion()) + + "&r&9" + (ModuleLoader.hasCategories() ? "\n" + getCategory() : "") + + "&r&7" + (getDescription() == null ? "" : "\n\n" + getDescription()); + } + public String getSimpleName() { return simpleName; } - - public String getDisplayName() { - return displayName; + + public String getVersion() { + return version; } public String getCategory() { @@ -62,20 +75,5 @@ public class ModuleInfo { return description; } - public String getWarning() { - return warning; - } - - public String getVersion() { - return version; - } - - public String getModuleInfoHover() { - return "&8&o" + getSimpleName() + "\n" - + "&r&e" + (getVersion() == null? "&cVersion Missing" : getVersion()) - + "&r&9" + (ModuleLoader.hasCategories()? "\n" + getCategory() : "") - + "&r&7" + (getDescription() == null? "" : "\n\n" + getDescription()); - } - - + } diff --git a/src/main/java/com/redstoner/misc/Utils.java b/src/main/java/com/redstoner/misc/Utils.java index e3fd68c..d53a39e 100644 --- a/src/main/java/com/redstoner/misc/Utils.java +++ b/src/main/java/com/redstoner/misc/Utils.java @@ -1,177 +1,172 @@ package com.redstoner.misc; +import com.redstoner.annotations.Version; +import com.redstoner.coremods.moduleLoader.ModuleLoader; +import net.nemez.chatapi.ChatAPI; +import net.nemez.chatapi.click.Message; +import org.bukkit.Bukkit; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + import java.text.SimpleDateFormat; import java.util.Arrays; import java.util.Date; import java.util.List; import java.util.regex.Pattern; -import org.bukkit.Bukkit; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import com.redstoner.annotations.Version; -import com.redstoner.coremods.moduleLoader.ModuleLoader; - -import net.nemez.chatapi.ChatAPI; -import net.nemez.chatapi.click.Message; - -/** The utils class containing utility functions. Those include but are not limited to sending formatted messages, broadcasts and more. - * - * @author Pepich */ -@Version(major = 4, minor = 0, revision = 2, compatible = 1) -public final class Utils -{ +/** + * The utils class containing utility functions. Those include but are not limited to sending formatted messages, broadcasts and more. + * + * @author Pepich + */ +@Version (major = 4, minor = 0, revision = 2, compatible = 1) +public final class Utils { + /** The Pattern for a UUID */ + private static final Pattern UUID_pattern = Pattern.compile("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}"); + private static final Pattern Class_pattern = Pattern.compile(".*\\."); + private static final Pattern NoDolarSign_pattern = Pattern.compile("\\$\\d*"); /** The @SimpleDateFormat used for getting the current date. */ public static SimpleDateFormat dateFormat = new SimpleDateFormat("[yyyy-MM-dd HH:mm:ss]"); - - /** The Pattern for a UUID*/ - private static final Pattern UUID_pattern = Pattern.compile("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}"); - private static final Pattern Class_pattern = Pattern.compile(".*\\."); - private static final Pattern NoDolarSign_pattern = Pattern.compile("\\$\\d*"); - + /** Hidden constructor. Do not instantiate UTILS classes! :) */ - private Utils() - {} - - /** This method broadcasts a message to all players and console that are allowed by the filter. Set the filter to NULL to broadcast to everyone.
+ private Utils() {} + + /** + * This method broadcasts a message to all players and console that are allowed by the filter. Set the filter to NULL to broadcast to everyone.
* If you want to, you can set a message that will be logged to console. Set to null to not log anything.
* You can still allow console in the filter to log the original message. - * - * @param prefix The prefix for the message. Set to NULL to let it auto generate. - * @param message the message to be sent around - * @param filter the BroadcastFilter to be applied.
- * Write a class implementing the interface and pass it to this method, the "sendTo()" method will be called for each recipient. + * + * @param prefix The prefix for the message. Set to NULL to let it auto generate. + * @param message the message to be sent around + * @param filter the BroadcastFilter to be applied.
+ * Write a class implementing the interface and pass it to this method, the "sendTo()" method will be called for each recipient. * @param logmessage the log message to appear in console. Set to null to not log this (you can still log the original message by returning true in the filter). - * @return the amount of people that received the message. */ - public static int broadcast(String prefix, String message, BroadcastFilter filter) - { + * + * @return the amount of people that received the message. + */ + public static int broadcast(String prefix, String message, BroadcastFilter filter) { if (prefix == null) prefix = "§8[§2" + getCaller() + "§8]: "; - if (filter == null) - { - for (Player p : Bukkit.getOnlinePlayers()) - p.sendMessage(prefix + message); + if (filter == null) { + for (Player p : Bukkit.getOnlinePlayers()) { p.sendMessage(prefix + message); } Bukkit.getConsoleSender().sendMessage(prefix + message); return Bukkit.getOnlinePlayers().size() + 1; - } - else - { + } else { int count = 0; - for (Player p : Bukkit.getOnlinePlayers()) - if (filter.sendTo(p)) - { + for (Player p : Bukkit.getOnlinePlayers()) { + if (filter.sendTo(p)) { p.sendMessage(prefix + message); count++; } - if (filter.sendTo(Bukkit.getConsoleSender())) - { + } + if (filter.sendTo(Bukkit.getConsoleSender())) { Bukkit.getConsoleSender().sendMessage(prefix + message); count++; } return count; } } - - /** This method broadcasts a message to all players and console that are allowed by the filter. Set the filter to NULL to broadcast to everyone.
+ + /** + * This method will find the next parent caller and return their class name, omitting package names. + * + * @return the Name of the calling class. + */ + private static final String getCaller() { + StackTraceElement[] stackTrace = (new Exception()).getStackTrace(); + String classname = "Utils"; + for (int i = 0; classname.equals("Utils"); i++) { + classname = Class_pattern.matcher(stackTrace[i].getClassName()).replaceAll(""); + } + return classname; + } + + /** + * This method broadcasts a message to all players and console that are allowed by the filter. Set the filter to NULL to broadcast to everyone.
* If you want to, you can set a message that will be logged to console. Set to null to not log anything.
* You can still allow console in the filter to log the original message. - * - * @param prefix The prefix for the message. Set to NULL to let it auto generate. - * @param message the message to be sent around - * @param filter the BroadcastFilter to be applied.
- * Write a class implementing the interface and pass it to this method, the "sendTo()" method will be called for each recipient. + * + * @param prefix The prefix for the message. Set to NULL to let it auto generate. + * @param message the message to be sent around + * @param filter the BroadcastFilter to be applied.
+ * Write a class implementing the interface and pass it to this method, the "sendTo()" method will be called for each recipient. * @param logmessage the log message to appear in console. Set to null to not log this (you can still log the original message by returning true in the filter). */ - public static int broadcast(String prefix, Message message, BroadcastFilter filter) - { + public static int broadcast(String prefix, Message message, BroadcastFilter filter) { if (prefix == null) prefix = "§8[§2" + getCaller() + "§8]: "; - if (filter == null) - { - for (Player p : Bukkit.getOnlinePlayers()) - ChatAPI.createMessage(p).appendText(prefix).appendMessage(message).send(); + if (filter == null) { + for (Player p : Bukkit.getOnlinePlayers()) { ChatAPI.createMessage(p).appendText(prefix).appendMessage(message).send(); } Bukkit.getConsoleSender().sendMessage(prefix + message.getRawMessage()); return Bukkit.getOnlinePlayers().size() + 1; - } - else - { + } else { int count = 0; - for (Player p : Bukkit.getOnlinePlayers()) - if (filter.sendTo(p)) - { + for (Player p : Bukkit.getOnlinePlayers()) { + if (filter.sendTo(p)) { ChatAPI.createMessage(p).appendText(prefix).appendMessage(message).send(); count++; } - if (filter.sendTo(Bukkit.getConsoleSender())) - { + } + if (filter.sendTo(Bukkit.getConsoleSender())) { Bukkit.getConsoleSender().sendMessage(prefix + message.getRawMessage()); count++; } return count; } } - - /** This method will find the next parent caller and return their class name, omitting package names. - * - * @return the Name of the calling class. */ - private static final String getCaller() - { - StackTraceElement[] stackTrace = (new Exception()).getStackTrace(); - String classname = "Utils"; - for (int i = 0; classname.equals("Utils"); i++) - { - classname = Class_pattern.matcher(stackTrace[i].getClassName()).replaceAll(""); - } - return classname; - } - - /** This method will find the next parent caller and return their class name, omitting package names. - * + + /** + * This method will find the next parent caller and return their class name, omitting package names. + * * @param directCaller used to prevent this method from returning the caller itself. Null if supposed to be ignored. - * @return the name of the calling class. */ - public static final String getCaller(String... directCaller) - { + * + * @return the name of the calling class. + */ + public static final String getCaller(String... directCaller) { if (directCaller == null || directCaller.length == 0) return getCaller(); StackTraceElement[] stackTrace = (new Exception()).getStackTrace(); - String classname = "Utils"; - List callers = Arrays.asList(directCaller); - for (int i = 0; callers.contains(classname) || classname.equals("Utils"); i++) - { + String classname = "Utils"; + List callers = Arrays.asList(directCaller); + for (int i = 0; callers.contains(classname) || classname.equals("Utils"); i++) { classname = Class_pattern.matcher(stackTrace[i].getClassName()).replaceAll(""); } classname = NoDolarSign_pattern.matcher(classname).replaceAll(""); return classname; } - - /** Provides a uniform way of getting the date for all modules. - * - * @return The current date in the format "[dd-mm-yyyy hh:mm:ss]" */ - public static String getDate() - { + + /** + * Provides a uniform way of getting the date for all modules. + * + * @return The current date in the format "[dd-mm-yyyy hh:mm:ss]" + */ + public static String getDate() { Date date = new Date(System.currentTimeMillis()); return dateFormat.format(date); } - - /** Provides a uniform way of getting the (display)name of a @CommandSender. - * + + /** + * Provides a uniform way of getting the (display)name of a @CommandSender. + * * @param sender The @CommandSender to get the name of. - * @return The DisplayName of the @CommandSender or if not a @Player, the name in blue. */ - public static String getName(CommandSender sender) - { + * + * @return The DisplayName of the @CommandSender or if not a @Player, the name in blue. + */ + public static String getName(CommandSender sender) { if (sender instanceof Player) return ((Player) sender).getDisplayName(); else return "§9" + sender.getName(); } - - /** Provides a uniform way of getting the UUID of a @CommandSender. - * + + /** + * Provides a uniform way of getting the UUID of a @CommandSender. + * * @param sender The @CommandSender to get the UUID of. - * @return The UUID of the @CommandSender or if not a player, "CONSOLE" in blue. */ - public static String getID(CommandSender sender) - { + * + * @return The UUID of the @CommandSender or if not a player, "CONSOLE" in blue. + */ + public static String getID(CommandSender sender) { String id; if (sender instanceof Player) id = ((Player) sender).getUniqueId().toString(); @@ -179,25 +174,25 @@ public final class Utils id = "CONSOLE"; return id; } - - /** Checks if the string is a UUID. - * + + /** + * Checks if the string is a UUID. + * * @param toCheck String to check. + * * @return if the string is a UUID. */ - public static boolean isUUID(String toCheck) - { - return UUID_pattern.matcher(toCheck).matches(); + public static boolean isUUID(String toCheck) { + return UUID_pattern.matcher(toCheck).matches(); } - + public static void run(Runnable r) { run(r, 0); } - + public static void run(Runnable r, int delay) { Bukkit.getScheduler().scheduleSyncDelayedTask(ModuleLoader.getPlugin(), r, delay); } - - - + + } diff --git a/src/main/java/com/redstoner/misc/VersionHelper.java b/src/main/java/com/redstoner/misc/VersionHelper.java index e4a9403..6cfc872 100644 --- a/src/main/java/com/redstoner/misc/VersionHelper.java +++ b/src/main/java/com/redstoner/misc/VersionHelper.java @@ -1,27 +1,30 @@ package com.redstoner.misc; -import java.lang.annotation.Annotation; - import com.redstoner.annotations.Version; import com.redstoner.exceptions.MissingVersionException; -/** This class can be used to compare modules against the loader version or against each other to prevent dependency issues. - * - * @author Pepich */ -@Version(major = 2, minor = 1, revision = 3, compatible = 0) -public final class VersionHelper -{ - private VersionHelper() - {} - - /** Checks two classes versions for compatibility. - * - * @param base The API to compare to. +import java.lang.annotation.Annotation; + +/** + * This class can be used to compare modules against the loader version or against each other to prevent dependency issues. + * + * @author Pepich + */ +@Version (major = 2, minor = 1, revision = 3, compatible = 0) +public final class VersionHelper { + private VersionHelper() {} + + /** + * Checks two classes versions for compatibility. + * + * @param base The API to compare to. * @param module The module to compare. + * * @return true, when the module is up to date with the API, or the API supports outdated modules. - * @throws MissingVersionException When one of the parameters is not annotated with a @Version annotation. */ - public static boolean isCompatible(Class api, Class module) throws MissingVersionException - { + * + * @throws MissingVersionException When one of the parameters is not annotated with a @Version annotation. + */ + public static boolean isCompatible(Class api, Class module) throws MissingVersionException { if (!api.isAnnotationPresent(Version.class)) throw new MissingVersionException("The API is not annotated with a version."); if (!module.isAnnotationPresent(Version.class)) @@ -30,42 +33,16 @@ public final class VersionHelper Version moduleVersion = module.getAnnotation(Version.class); return isCompatible(apiVersion, moduleVersion); } - - /** Checks two classes versions for compatibility. - * - * @param base The API to compare to. - * @param module The module to compare. - * @return true, when the module is up to date with the API, or the API supports outdated modules. - * @throws MissingVersionException When one of the parameters is not annotated with a @Version annotation. */ - public static boolean isCompatible(Version apiVersion, Class module) throws MissingVersionException - { - if (!module.isAnnotationPresent(Version.class)) - throw new MissingVersionException("The module is not annotated with a version."); - Version moduleVersion = module.getAnnotation(Version.class); - return isCompatible(apiVersion, moduleVersion); - } - - /** Checks two classes versions for compatibility. - * - * @param base The API to compare to. - * @param module The module to compare. - * @return true, when the module is up to date with the API, or the API supports outdated modules. - * @throws MissingVersionException When one of the parameters is not annotated with a @Version annotation. */ - public static boolean isCompatible(Class api, Version moduleVersion) throws MissingVersionException - { - if (!api.isAnnotationPresent(Version.class)) - throw new MissingVersionException("The API is not annotated with a version."); - Version apiVersion = api.getAnnotation(Version.class); - return isCompatible(apiVersion, moduleVersion); - } - - /** Checks two versions for compatibility. - * - * @param base The API version to compare to. + + /** + * Checks two versions for compatibility. + * + * @param base The API version to compare to. * @param module The module version to compare. - * @return true, when the module is up to date with the API, or the API supports outdated modules. */ - public static boolean isCompatible(Version apiVersion, Version moduleVersion) - { + * + * @return true, when the module is up to date with the API, or the API supports outdated modules. + */ + public static boolean isCompatible(Version apiVersion, Version moduleVersion) { if (apiVersion.major() >= moduleVersion.compatible()) return true; if (apiVersion.compatible() == -1) @@ -74,76 +51,111 @@ public final class VersionHelper return true; return false; } - - /** Returns the version of a given class as a String. - * + + /** + * Checks two classes versions for compatibility. + * + * @param base The API to compare to. + * @param module The module to compare. + * + * @return true, when the module is up to date with the API, or the API supports outdated modules. + * + * @throws MissingVersionException When one of the parameters is not annotated with a @Version annotation. + */ + public static boolean isCompatible(Version apiVersion, Class module) throws MissingVersionException { + if (!module.isAnnotationPresent(Version.class)) + throw new MissingVersionException("The module is not annotated with a version."); + Version moduleVersion = module.getAnnotation(Version.class); + return isCompatible(apiVersion, moduleVersion); + } + + /** + * Checks two classes versions for compatibility. + * + * @param base The API to compare to. + * @param module The module to compare. + * + * @return true, when the module is up to date with the API, or the API supports outdated modules. + * + * @throws MissingVersionException When one of the parameters is not annotated with a @Version annotation. + */ + public static boolean isCompatible(Class api, Version moduleVersion) throws MissingVersionException { + if (!api.isAnnotationPresent(Version.class)) + throw new MissingVersionException("The API is not annotated with a version."); + Version apiVersion = api.getAnnotation(Version.class); + return isCompatible(apiVersion, moduleVersion); + } + + /** + * Returns the version of a given class as a String. + * * @param clazz The class to grab the version number from. + * * @return The version number of the class in format major.minor.revision.compatible. - * @throws MissingVersionException If the class is not annotated with @Version. */ - public static String getVersion(Class clazz) throws MissingVersionException - { + * + * @throws MissingVersionException If the class is not annotated with @Version. + */ + public static String getVersion(Class clazz) throws MissingVersionException { if (!clazz.isAnnotationPresent(Version.class)) throw new MissingVersionException("The given class is not associated with a version."); Version ver = clazz.getAnnotation(Version.class); return getString(ver); } - - /** Returns the String representation of a version. - * + + /** + * Returns the String representation of a version. + * * @param ver The version to be represented. - * @return The String representation. */ - public static String getString(Version ver) - { + * + * @return The String representation. + */ + public static String getString(Version ver) { return ver.major() + "." + ver.minor() + "." + ver.revision() + "." + ver.compatible(); } - - public static Version getVersion(String ver) - { + + public static Version getVersion(String ver) { String[] raw = ver.split("\\."); if (raw.length != 4) return null; return VersionHelper.create(Integer.parseInt(raw[0]), Integer.parseInt(raw[1]), Integer.parseInt(raw[2]), - Integer.parseInt(raw[3])); + Integer.parseInt(raw[3]) + ); } - - /** This method creates a new Version to use for compatibility checks. - * - * @param major The major version - * @param minor The minor version - * @param revision The revision + + /** + * This method creates a new Version to use for compatibility checks. + * + * @param major The major version + * @param minor The minor version + * @param revision The revision * @param compatible The compatibility tag - * @return */ - public static Version create(int major, int minor, int revision, int compatible) - { - return new Version() - { + * + * @return + */ + public static Version create(int major, int minor, int revision, int compatible) { + return new Version() { @Override - public Class annotationType() - { + public Class annotationType() { return Version.class; } - + @Override - public int revision() - { + public int revision() { return revision; } - + @Override - public int minor() - { + public int minor() { return minor; } - + @Override - public int major() - { + public int major() { return major; } - + @Override - public int compatible() - { + public int compatible() { return compatible; } }; diff --git a/src/main/java/com/redstoner/misc/mysql/Config.java b/src/main/java/com/redstoner/misc/mysql/Config.java index 519b20a..b88b0c2 100644 --- a/src/main/java/com/redstoner/misc/mysql/Config.java +++ b/src/main/java/com/redstoner/misc/mysql/Config.java @@ -1,215 +1,170 @@ package com.redstoner.misc.mysql; -import java.io.File; -import java.io.FileReader; -import java.io.IOException; -import java.io.PrintWriter; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; - +import com.redstoner.exceptions.NonSaveableConfigException; +import com.redstoner.misc.Main; import org.json.simple.JSONArray; import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser; import org.json.simple.parser.ParseException; -import com.redstoner.exceptions.NonSaveableConfigException; -import com.redstoner.misc.Main; +import java.io.File; +import java.io.FileReader; +import java.io.IOException; +import java.io.PrintWriter; +import java.util.*; +import java.util.Map.Entry; -public class Config -{ - private File file; +public class Config { + private File file; private JSONObject config; private JSONParser parser; - - public Config() - { + + public Config() { file = null; parser = new JSONParser(); config = new JSONObject(); } - - public Config(JSONObject config) - { + + public Config(JSONObject config) { this.file = null; this.parser = new JSONParser(); this.config = config; } - - private Config(File file) throws IOException, ParseException - { + + private Config(File file) throws IOException, ParseException { this.file = file; parser = new JSONParser(); - if (file.exists()) - { + if (file.exists()) { config = loadConfig(file); - } - else - { + } else { config = new JSONObject(); } } - - public static final Config getConfig(String fileName) throws IOException, ParseException - { - return new Config(new File(Main.plugin.getDataFolder(), fileName)); - } - - public static final Config getConfig(File file) throws IOException, ParseException - { - return new Config(file); - } - - private JSONObject loadConfig(File file) throws IOException, ParseException - { + + private JSONObject loadConfig(File file) throws IOException, ParseException { FileReader reader = new FileReader(file); JSONObject object = (JSONObject) parser.parse(reader); reader.close(); return object; } - + + public static final Config getConfig(String fileName) throws IOException, ParseException { + return new Config(new File(Main.plugin.getDataFolder(), fileName)); + } + + public static final Config getConfig(File file) throws IOException, ParseException { + return new Config(file); + } + @Override - public String toString() - { + public String toString() { return config.toJSONString(); } - - public JSONObject asObject() - { + + public JSONObject asObject() { return config; } - - public void save() throws IOException, NonSaveableConfigException - { - if (file == null) - { + + public void save() throws IOException, NonSaveableConfigException { + if (file == null) { throw new NonSaveableConfigException(); } PrintWriter writer = new PrintWriter(file); writer.write(config.toJSONString()); writer.close(); } - - public void refresh() throws IOException, ParseException, NonSaveableConfigException - { - if (file == null) - { + + public void refresh() throws IOException, ParseException, NonSaveableConfigException { + if (file == null) { throw new NonSaveableConfigException(); } loadConfig(file); } - - public void setFile(String fileName) - { + + public void setFile(String fileName) { file = new File(Main.plugin.getDataFolder(), fileName); } - - public void setFile(File file) - { + + public void setFile(File file) { this.file = file; } - - @SuppressWarnings("unchecked") - public void put(String key, String value) - { + + @SuppressWarnings ("unchecked") + public void put(String key, String value) { config.put(key, value); } - - @SuppressWarnings("unchecked") - public void put(String key, List value) - { + + @SuppressWarnings ("unchecked") + public void put(String key, List value) { JSONArray array = new JSONArray(); - for (String entry : value) - { + for (String entry : value) { array.add(entry); } config.put(key, array); } - - @SuppressWarnings("unchecked") - public void putArray(String key, JSONArray value) - { + + @SuppressWarnings ("unchecked") + public void putArray(String key, JSONArray value) { config.put(key, value); } - - @SuppressWarnings("unchecked") - public void put(String key, Map value) - { + + @SuppressWarnings ("unchecked") + public void put(String key, Map value) { JSONObject object = new JSONObject(); - for (String valKey : value.keySet()) - { + for (String valKey : value.keySet()) { String valVal = value.get(valKey); object.put(valKey, valVal); } config.put(key, object); } - - @SuppressWarnings("unchecked") - public void put(String key, JSONObject value) - { + + @SuppressWarnings ("unchecked") + public void put(String key, JSONObject value) { config.put(key, value); } - - @SuppressWarnings("unchecked") - public void putAll(Map entry) - { - for (String key : entry.keySet()) - { + + @SuppressWarnings ("unchecked") + public void putAll(Map entry) { + for (String key : entry.keySet()) { String value = entry.get(key); config.put(key, value); } } - - public boolean containsKey(String key) - { - return config.containsKey(key); - } - - public String get(String key) - { - if (containsKey(key)) - { + + public String get(String key) { + if (containsKey(key)) { Object value = config.get(key); - if (value instanceof String) - { + if (value instanceof String) { return (String) value; } } return null; } - - public String getOrDefault(String key, String defaultValue) - { - if (containsKey(key)) - { + + public boolean containsKey(String key) { + return config.containsKey(key); + } + + public String getOrDefault(String key, String defaultValue) { + if (containsKey(key)) { Object value = config.get(key); - if (value instanceof String) - { + if (value instanceof String) { return (String) value; } return null; - } - else - { + } else { return defaultValue; } } - - @SuppressWarnings("unchecked") - public List getList(String key) - { - if (containsKey(key)) - { + + @SuppressWarnings ("unchecked") + public List getList(String key) { + if (containsKey(key)) { Object value = config.get(key); - if (value instanceof JSONArray) - { - JSONArray array = (JSONArray) value; + if (value instanceof JSONArray) { + JSONArray array = (JSONArray) value; List output = new ArrayList(); - for (String entry : (String[]) array.toArray(new String[0])) - { + for (String entry : (String[]) array.toArray(new String[0])) { output.add(entry); } return output; @@ -217,34 +172,27 @@ public class Config } return null; } - - public JSONArray getArray(String key) - { - if (containsKey(key)) - { + + public JSONArray getArray(String key) { + if (containsKey(key)) { Object value = config.get(key); - if (value instanceof JSONArray) - { + if (value instanceof JSONArray) { JSONArray array = (JSONArray) value; return array; } } return null; } - - public Map getMap(String key) - { - if (containsKey(key)) - { + + public Map getMap(String key) { + if (containsKey(key)) { Object value = config.get(key); - if (value instanceof JSONObject) - { + if (value instanceof JSONObject) { JSONObject object = (JSONObject) value; - @SuppressWarnings("unchecked") + @SuppressWarnings ("unchecked") Set> entrySet = object.entrySet(); Map output = new HashMap(); - for (Map.Entry entry : entrySet) - { + for (Map.Entry entry : entrySet) { output.put(entry.getKey(), entry.getValue()); } return output; @@ -252,29 +200,24 @@ public class Config } return null; } - - public JSONObject getObject(String key) - { - if (containsKey(key)) - { + + public JSONObject getObject(String key) { + if (containsKey(key)) { Object value = config.get(key); - if (value instanceof JSONObject) - { + if (value instanceof JSONObject) { JSONObject object = (JSONObject) value; return object; } } return null; } - - public void remove(String key) - { + + public void remove(String key) { config.remove(key); } - - @SuppressWarnings("unchecked") - public Set> getAll() - { + + @SuppressWarnings ("unchecked") + public Set> getAll() { return config.entrySet(); } } diff --git a/src/main/java/com/redstoner/misc/mysql/JSONManager.java b/src/main/java/com/redstoner/misc/mysql/JSONManager.java index ae248d5..6084e8d 100644 --- a/src/main/java/com/redstoner/misc/mysql/JSONManager.java +++ b/src/main/java/com/redstoner/misc/mysql/JSONManager.java @@ -1,106 +1,79 @@ package com.redstoner.misc.mysql; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileReader; -import java.io.FileWriter; -import java.io.IOException; -import java.io.PrintWriter; -import java.io.Serializable; -import java.io.UnsupportedEncodingException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - +import com.redstoner.misc.Main; import org.json.simple.JSONArray; import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser; import org.json.simple.parser.ParseException; -import com.redstoner.misc.Main; +import java.io.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; -public class JSONManager -{ - public static Map getConfiguration(String fileName) - { +public class JSONManager { + public static Map getConfiguration(String fileName) { File file = new File(Main.plugin.getDataFolder(), fileName); - if (!file.exists()) - { - try - { + if (!file.exists()) { + try { PrintWriter writer = new PrintWriter(file.getAbsolutePath(), "UTF-8"); writer.println("{}"); writer.close(); - } - catch (FileNotFoundException | UnsupportedEncodingException e) - { + } catch (FileNotFoundException | UnsupportedEncodingException e) { e.printStackTrace(); } } - try - { + try { return loadMap(file); - } - catch (IOException | ParseException e) - { + } catch (IOException | ParseException e) { e.printStackTrace(); return null; } } - - public static void saveConfiguration(Map config, String fileName) - { - try - { - saveMap(new File(Main.plugin.getDataFolder(), fileName), config); - } - catch (IOException e) - { - e.printStackTrace(); - } - } - - @SuppressWarnings("unchecked") - public static void saveList(File file, List entries) throws IOException - { - JSONArray array = new JSONArray(); - array.addAll(entries); - FileWriter writer = new FileWriter(file); - writer.write(array.toJSONString()); - writer.close(); - } - - public static List loadList(File file) throws IOException, ParseException - { - FileReader read = new FileReader(file); - List entries = new ArrayList<>(); - JSONArray array = (JSONArray) new JSONParser().parse(read); - for (Object o : array) - { - entries.add((Serializable) o); + + public static Map loadMap(File file) throws IOException, ParseException { + FileReader reader = new FileReader(file); + JSONObject map = (JSONObject) new JSONParser().parse(reader); + Map entries = new HashMap<>(); + for (Object o : map.keySet()) { + entries.put((Serializable) o, (Serializable) map.get(o)); } return entries; } - - @SuppressWarnings("unchecked") - public static void saveMap(File file, Map entries) throws IOException - { + + public static void saveConfiguration(Map config, String fileName) { + try { + saveMap(new File(Main.plugin.getDataFolder(), fileName), config); + } catch (IOException e) { + e.printStackTrace(); + } + } + + @SuppressWarnings ("unchecked") + public static void saveMap(File file, Map entries) throws IOException { JSONObject map = new JSONObject(); map.putAll(entries); FileWriter writer = new FileWriter(file); writer.write(map.toJSONString()); writer.close(); } - - public static Map loadMap(File file) throws IOException, ParseException - { - FileReader reader = new FileReader(file); - JSONObject map = (JSONObject) new JSONParser().parse(reader); - Map entries = new HashMap<>(); - for (Object o : map.keySet()) - { - entries.put((Serializable) o, (Serializable) map.get(o)); + + @SuppressWarnings ("unchecked") + public static void saveList(File file, List entries) throws IOException { + JSONArray array = new JSONArray(); + array.addAll(entries); + FileWriter writer = new FileWriter(file); + writer.write(array.toJSONString()); + writer.close(); + } + + public static List loadList(File file) throws IOException, ParseException { + FileReader read = new FileReader(file); + List entries = new ArrayList<>(); + JSONArray array = (JSONArray) new JSONParser().parse(read); + for (Object o : array) { + entries.add((Serializable) o); } return entries; } diff --git a/src/main/java/com/redstoner/misc/mysql/MysqlHandler.java b/src/main/java/com/redstoner/misc/mysql/MysqlHandler.java index 909d276..d76227a 100644 --- a/src/main/java/com/redstoner/misc/mysql/MysqlHandler.java +++ b/src/main/java/com/redstoner/misc/mysql/MysqlHandler.java @@ -1,113 +1,86 @@ package com.redstoner.misc.mysql; +import com.redstoner.misc.Main; +import com.redstoner.misc.mysql.elements.MysqlDatabase; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.json.simple.parser.ParseException; + import java.io.File; import java.io.IOException; import java.io.Serializable; -import java.sql.Connection; -import java.sql.DatabaseMetaData; -import java.sql.DriverManager; -import java.sql.ResultSet; -import java.sql.SQLException; +import java.sql.*; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.json.simple.parser.ParseException; - -import com.redstoner.misc.Main; -import com.redstoner.misc.mysql.elements.MysqlDatabase; - -public class MysqlHandler -{ +public class MysqlHandler { public static MysqlHandler INSTANCE; - private String url, username, password; - - public MysqlHandler(String hostname, int port, String username, String password) - { + private String url, username, password; + + public MysqlHandler(String hostname, int port, String username, String password) { this.url = "jdbc:mysql://" + hostname + ":" + port + "/"; this.username = username; this.password = password; } - - public static void init() - { - Map mysqlCredentials = new HashMap<>(); - File mysqlCredentialsFile = new File(Main.plugin.getDataFolder(), "mysqlCredentials.json"); - if (mysqlCredentialsFile.exists()) - { - try - { + + public static void init() { + Map mysqlCredentials = new HashMap<>(); + File mysqlCredentialsFile = new File(Main.plugin.getDataFolder(), "mysqlCredentials.json"); + if (mysqlCredentialsFile.exists()) { + try { mysqlCredentials = JSONManager.loadMap(mysqlCredentialsFile); - } - catch (IOException | ParseException e) - { + } catch (IOException | ParseException e) { e.printStackTrace(); } - } - else - { + } else { Bukkit.getConsoleSender().sendMessage( ChatColor.RED + "MySQL config does not exist, creating an example one, things might (will) break!"); mysqlCredentials.put("hostname", "localhost"); mysqlCredentials.put("port", "3306"); mysqlCredentials.put("username", "your username here"); mysqlCredentials.put("password", "your password here"); - try - { + try { JSONManager.saveMap(mysqlCredentialsFile, mysqlCredentials); - } - catch (IOException e) - { + } catch (IOException e) { e.printStackTrace(); } } String hostname = (String) mysqlCredentials.get("hostname"); - int port = Integer.valueOf((String) mysqlCredentials.get("port")); + int port = Integer.valueOf((String) mysqlCredentials.get("port")); String username = (String) mysqlCredentials.get("username"); String password = (String) mysqlCredentials.get("password"); INSTANCE = new MysqlHandler(hostname, port, username, password); } - - private Connection getConnection(String databaseName) throws IllegalStateException - { + + public MysqlDatabase getDatabase(String databaseName) { + return new MysqlDatabase(getConnection(databaseName)); + } + + private Connection getConnection(String databaseName) throws IllegalStateException { Connection connection = null; - try - { + try { connection = DriverManager.getConnection(url + databaseName, username, password); - } - catch (SQLException e) - { + } catch (SQLException e) { throw new IllegalStateException("Cannot connect to the database!", e); } return connection; } - - public MysqlDatabase getDatabase(String databaseName) - { - return new MysqlDatabase(getConnection(databaseName)); - } - - public List getDatabases() - { - try - { - List databases = new ArrayList<>(); - Connection connection = DriverManager.getConnection(url.substring(0, url.length()), username, password); - DatabaseMetaData metadata = connection.getMetaData(); - ResultSet queryResults = metadata.getCatalogs(); - while (queryResults.next()) - { + + public List getDatabases() { + try { + List databases = new ArrayList<>(); + Connection connection = DriverManager.getConnection(url.substring(0, url.length()), username, password); + DatabaseMetaData metadata = connection.getMetaData(); + ResultSet queryResults = metadata.getCatalogs(); + while (queryResults.next()) { String databaseName = queryResults.getString("TABLE_CAT"); databases.add(new MysqlDatabase(getConnection(databaseName))); } connection.close(); return databases; - } - catch (SQLException e) - { + } catch (SQLException e) { e.printStackTrace(); return null; } diff --git a/src/main/java/com/redstoner/misc/mysql/MysqlQueryHandler.java b/src/main/java/com/redstoner/misc/mysql/MysqlQueryHandler.java index f89a08a..df46cab 100644 --- a/src/main/java/com/redstoner/misc/mysql/MysqlQueryHandler.java +++ b/src/main/java/com/redstoner/misc/mysql/MysqlQueryHandler.java @@ -1,29 +1,25 @@ package com.redstoner.misc.mysql; -import java.sql.CallableStatement; -import java.sql.Connection; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Statement; +import java.sql.*; public class MysqlQueryHandler { public static ResultSet queryResult(Connection connection, String query) { try { Statement statement = connection.createStatement(); - ResultSet results = statement.executeQuery(query); - + ResultSet results = statement.executeQuery(query); + return results; } catch (SQLException e) { e.printStackTrace(); return null; } } - + public static boolean queryNoResult(Connection connection, String query) { try { CallableStatement statement = connection.prepareCall(query); statement.execute(); - + return true; } catch (SQLException e) { e.printStackTrace(); diff --git a/src/main/java/com/redstoner/misc/mysql/elements/ConstraintOperator.java b/src/main/java/com/redstoner/misc/mysql/elements/ConstraintOperator.java index 45cb33c..1e8d523 100644 --- a/src/main/java/com/redstoner/misc/mysql/elements/ConstraintOperator.java +++ b/src/main/java/com/redstoner/misc/mysql/elements/ConstraintOperator.java @@ -2,7 +2,7 @@ package com.redstoner.misc.mysql.elements; public enum ConstraintOperator { LESS_THAN, GREATER_THAN, EQUAL, NOT_EQUAL, LESS_THAN_OR_EQUAL, GREATER_THAN_OR_EQUAL; - + public String toString() { switch (this) { case LESS_THAN: diff --git a/src/main/java/com/redstoner/misc/mysql/elements/MysqlConstraint.java b/src/main/java/com/redstoner/misc/mysql/elements/MysqlConstraint.java index d651344..8b99d12 100644 --- a/src/main/java/com/redstoner/misc/mysql/elements/MysqlConstraint.java +++ b/src/main/java/com/redstoner/misc/mysql/elements/MysqlConstraint.java @@ -3,7 +3,7 @@ package com.redstoner.misc.mysql.elements; public class MysqlConstraint { private String fieldName, value; private ConstraintOperator operator; - + public MysqlConstraint(String fieldName, ConstraintOperator operator, String value) { this.fieldName = fieldName; this.operator = operator; diff --git a/src/main/java/com/redstoner/misc/mysql/elements/MysqlDatabase.java b/src/main/java/com/redstoner/misc/mysql/elements/MysqlDatabase.java index 91c0fe4..3f1c288 100644 --- a/src/main/java/com/redstoner/misc/mysql/elements/MysqlDatabase.java +++ b/src/main/java/com/redstoner/misc/mysql/elements/MysqlDatabase.java @@ -1,5 +1,7 @@ package com.redstoner.misc.mysql.elements; +import com.redstoner.misc.mysql.MysqlQueryHandler; + import java.sql.Connection; import java.sql.DatabaseMetaData; import java.sql.ResultSet; @@ -7,15 +9,55 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.List; -import com.redstoner.misc.mysql.MysqlQueryHandler; - public class MysqlDatabase { private Connection connection; - + public MysqlDatabase(Connection connection) { this.connection = connection; } - + + public MysqlTable getTable(String name) { + return new MysqlTable(this, name); + } + + public boolean createTable(String name, MysqlField... description) { + return MysqlQueryHandler.queryNoResult(connection, "CREATE TABLE `" + name + "` " + getDescription(description) + ";"); + } + + private String getDescription(MysqlField... description) { + String desc = "("; + + for (int i = 0; i < description.length; i++) { + String nil = ""; + + if (description[i].canBeNull()) { + nil = " NOT NULL"; + } + + desc += "`" + description[i].getName() + "` " + description[i].getType().getName() + nil; + + if (i < description.length - 1) { + desc += ","; + } + } + + desc += ")"; + + return desc; + } + + public boolean createTableIfNotExists(String name, MysqlField... description) { + return MysqlQueryHandler.queryNoResult(connection, "CREATE TABLE IF NOT EXISTS `" + name + "` " + getDescription(description) + ";"); + } + + public boolean dropTable(String name) { + return MysqlQueryHandler.queryNoResult(connection, "DROP TABLE `" + name + "`;"); + } + + public boolean drop() { + return MysqlQueryHandler.queryNoResult(connection, "DROP DATABASE `" + getName() + "`;"); + } + public String getName() { try { return connection.getCatalog(); @@ -24,67 +66,25 @@ public class MysqlDatabase { return null; } } - - public MysqlTable getTable(String name) { - return new MysqlTable(this, name); - } - - public boolean createTable(String name, MysqlField... description) { - return MysqlQueryHandler.queryNoResult(connection, "CREATE TABLE `" + name + "` " + getDescription(description) + ";"); - } - - public boolean createTableIfNotExists(String name, MysqlField... description) { - return MysqlQueryHandler.queryNoResult(connection, "CREATE TABLE IF NOT EXISTS `" + name + "` " + getDescription(description) + ";"); - } - - public boolean dropTable(String name) { - return MysqlQueryHandler.queryNoResult(connection, "DROP TABLE `" + name + "`;"); - } - - public boolean drop() { - return MysqlQueryHandler.queryNoResult(connection, "DROP DATABASE `" + getName() + "`;"); - } - + public List getTables() { try { - List tables = new ArrayList<>(); - DatabaseMetaData metadata = connection.getMetaData(); - ResultSet queryResults = metadata.getTables(null, null, "%", null); - + List tables = new ArrayList<>(); + DatabaseMetaData metadata = connection.getMetaData(); + ResultSet queryResults = metadata.getTables(null, null, "%", null); + while (queryResults.next()) { tables.add(new MysqlTable(this, queryResults.getString(3))); } - + return tables; } catch (SQLException e) { e.printStackTrace(); return null; } } - + protected Connection getConnection() { return connection; } - - private String getDescription(MysqlField... description) { - String desc = "("; - - for (int i = 0; i < description.length; i++) { - String nil = ""; - - if (description[i].canBeNull()) { - nil = " NOT NULL"; - } - - desc += "`" + description[i].getName() + "` " + description[i].getType().getName() + nil; - - if (i < description.length - 1) { - desc += ","; - } - } - - desc += ")"; - - return desc; - } } diff --git a/src/main/java/com/redstoner/misc/mysql/elements/MysqlField.java b/src/main/java/com/redstoner/misc/mysql/elements/MysqlField.java index 61cba2e..68b6fcc 100644 --- a/src/main/java/com/redstoner/misc/mysql/elements/MysqlField.java +++ b/src/main/java/com/redstoner/misc/mysql/elements/MysqlField.java @@ -3,30 +3,30 @@ package com.redstoner.misc.mysql.elements; import com.redstoner.misc.mysql.types.MysqlType; public class MysqlField { - private String name; + private String name; private MysqlType type; - private boolean canBeNull; - + private boolean canBeNull; + public MysqlField(String name, MysqlType type, boolean canBeNull) { this.name = name; this.type = type; this.canBeNull = canBeNull; } - + public MysqlField(String name, String type, boolean canBeNull) { this.name = name; this.type = MysqlType.getTypeFromString(type); this.canBeNull = canBeNull; } - + public String getName() { return name; } - + public MysqlType getType() { return type; } - + public boolean canBeNull() { return canBeNull; } diff --git a/src/main/java/com/redstoner/misc/mysql/elements/MysqlResult.java b/src/main/java/com/redstoner/misc/mysql/elements/MysqlResult.java index 6db0769..1b4f246 100644 --- a/src/main/java/com/redstoner/misc/mysql/elements/MysqlResult.java +++ b/src/main/java/com/redstoner/misc/mysql/elements/MysqlResult.java @@ -5,11 +5,11 @@ import java.sql.SQLException; public class MysqlResult { private ResultSet results; - + public MysqlResult(ResultSet results) { this.results = results; } - + public Object getObject(int columnIndex, Class type) throws SQLException { return results.getObject(columnIndex, type); } diff --git a/src/main/java/com/redstoner/misc/mysql/elements/MysqlTable.java b/src/main/java/com/redstoner/misc/mysql/elements/MysqlTable.java index 6656fcd..e6a7617 100644 --- a/src/main/java/com/redstoner/misc/mysql/elements/MysqlTable.java +++ b/src/main/java/com/redstoner/misc/mysql/elements/MysqlTable.java @@ -1,133 +1,113 @@ package com.redstoner.misc.mysql.elements; +import com.redstoner.misc.mysql.MysqlQueryHandler; + import java.sql.DatabaseMetaData; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; -import com.redstoner.misc.mysql.MysqlQueryHandler; - -public class MysqlTable -{ +public class MysqlTable { private MysqlDatabase database; - private String name; - - public MysqlTable(MysqlDatabase database, String name) - { + private String name; + + public MysqlTable(MysqlDatabase database, String name) { this.database = database; this.name = name; } - - public String getName() - { + + public String getName() { return this.name; } - - public MysqlField[] describe() - { - try - { - List description = new ArrayList<>(); - DatabaseMetaData metadata = database.getConnection().getMetaData(); - ResultSet queryResults = metadata.getColumns(null, null, name, null); - while (queryResults.next()) - { - description.add(new MysqlField(queryResults.getString(4), + + public boolean insert(String... values) { + MysqlField[] description = describe(); + if (values.length > 0 && values.length == description.length) { + String val = "(\"" + String.join("\",\"", values) + "\")"; + return MysqlQueryHandler.queryNoResult( + database.getConnection(), + "INSERT INTO `" + name + "` VALUES " + val + ";" + ); + } else { + return false; + } + } + + public MysqlField[] describe() { + try { + List description = new ArrayList<>(); + DatabaseMetaData metadata = database.getConnection().getMetaData(); + ResultSet queryResults = metadata.getColumns(null, null, name, null); + while (queryResults.next()) { + description.add(new MysqlField( + queryResults.getString(4), queryResults.getString(6).split(" ")[0] + "(" + queryResults.getString(7) + ")", - queryResults.getBoolean(11))); + queryResults.getBoolean(11) + )); } return description.toArray(new MysqlField[0]); - } - catch (SQLException e) - { + } catch (SQLException e) { e.printStackTrace(); return null; } } - - public boolean insert(String... values) - { - MysqlField[] description = describe(); - if (values.length > 0 && values.length == description.length) - { - String val = "(\"" + String.join("\",\"", values) + "\")"; - return MysqlQueryHandler.queryNoResult(database.getConnection(), - "INSERT INTO `" + name + "` VALUES " + val + ";"); - } - else - { - return false; - } - } - - public Object[] get(String fieldName, MysqlConstraint... constraints) - { - ResultSet results = MysqlQueryHandler.queryResult(database.getConnection(), - "SELECT " + fieldName + " FROM `" + name + "`" + getConstraints(constraints) + ";"); + + public Object[] get(String fieldName, MysqlConstraint... constraints) { + ResultSet results = MysqlQueryHandler.queryResult( + database.getConnection(), + "SELECT " + fieldName + " FROM `" + name + "`" + getConstraints(constraints) + ";" + ); List resObj = new ArrayList<>(); - try - { - while (results.next()) - { + try { + while (results.next()) { resObj.add(results.getObject(1)); } - } - catch (SQLException e) - { + } catch (SQLException e) { e.printStackTrace(); return new Object[0]; } return resObj.toArray(new Object[0]); } - - public Object[] get(String statement) - { - ResultSet results = MysqlQueryHandler.queryResult(database.getConnection(), statement); - List resObj = new ArrayList<>(); - try - { - while (results.next()) - { - resObj.add(results.getObject(1)); - } - } - catch (SQLException e) - { - e.printStackTrace(); - return new Object[0]; - } - return resObj.toArray(new Object[0]); - } - - public boolean delete(MysqlConstraint... constraints) - { - return MysqlQueryHandler.queryNoResult(database.getConnection(), - "DELETE FROM `" + name + "`" + getConstraints(constraints) + ";"); - } - - public boolean drop() - { - return MysqlQueryHandler.queryNoResult(database.getConnection(), "DROP TABLE `" + name + "`;"); - } - - private String getConstraints(MysqlConstraint... constraints) - { + + private String getConstraints(MysqlConstraint... constraints) { String cons = ""; - if (constraints.length > 0) - { + if (constraints.length > 0) { cons += " WHERE "; - for (int i = 0; i < constraints.length; i++) - { + for (int i = 0; i < constraints.length; i++) { MysqlConstraint constraint = constraints[i]; cons += constraint.getFieldName() + constraint.getOperator().toString() + "\"" + constraint.getValue() - + "\""; - if (i < constraints.length - 1) - { + + "\""; + if (i < constraints.length - 1) { cons += " AND "; } } } return cons; } + + public Object[] get(String statement) { + ResultSet results = MysqlQueryHandler.queryResult(database.getConnection(), statement); + List resObj = new ArrayList<>(); + try { + while (results.next()) { + resObj.add(results.getObject(1)); + } + } catch (SQLException e) { + e.printStackTrace(); + return new Object[0]; + } + return resObj.toArray(new Object[0]); + } + + public boolean delete(MysqlConstraint... constraints) { + return MysqlQueryHandler.queryNoResult( + database.getConnection(), + "DELETE FROM `" + name + "`" + getConstraints(constraints) + ";" + ); + } + + public boolean drop() { + return MysqlQueryHandler.queryNoResult(database.getConnection(), "DROP TABLE `" + name + "`;"); + } } diff --git a/src/main/java/com/redstoner/misc/mysql/types/MysqlType.java b/src/main/java/com/redstoner/misc/mysql/types/MysqlType.java index 86413f9..4a1c32f 100644 --- a/src/main/java/com/redstoner/misc/mysql/types/MysqlType.java +++ b/src/main/java/com/redstoner/misc/mysql/types/MysqlType.java @@ -1,45 +1,21 @@ package com.redstoner.misc.mysql.types; -import com.redstoner.misc.mysql.types.date.Date; -import com.redstoner.misc.mysql.types.date.DateTime; -import com.redstoner.misc.mysql.types.date.Time; -import com.redstoner.misc.mysql.types.date.TimeStamp; -import com.redstoner.misc.mysql.types.date.Year; -import com.redstoner.misc.mysql.types.number.BigInt; -import com.redstoner.misc.mysql.types.number.Decimal; +import com.redstoner.misc.mysql.types.date.*; import com.redstoner.misc.mysql.types.number.Double; import com.redstoner.misc.mysql.types.number.Float; -import com.redstoner.misc.mysql.types.number.Int; -import com.redstoner.misc.mysql.types.number.MediumInt; -import com.redstoner.misc.mysql.types.number.SmallInt; -import com.redstoner.misc.mysql.types.number.TinyInt; -import com.redstoner.misc.mysql.types.text.Blob; -import com.redstoner.misc.mysql.types.text.Char; +import com.redstoner.misc.mysql.types.number.*; import com.redstoner.misc.mysql.types.text.Enum; -import com.redstoner.misc.mysql.types.text.LongBlob; -import com.redstoner.misc.mysql.types.text.LongText; -import com.redstoner.misc.mysql.types.text.MediumBlob; -import com.redstoner.misc.mysql.types.text.MediumText; -import com.redstoner.misc.mysql.types.text.Set; -import com.redstoner.misc.mysql.types.text.Text; -import com.redstoner.misc.mysql.types.text.TinyText; -import com.redstoner.misc.mysql.types.text.VarChar; +import com.redstoner.misc.mysql.types.text.*; -public abstract class MysqlType -{ - public abstract String getName(); - - public static MysqlType getTypeFromString(String type) - { +public abstract class MysqlType { + public static MysqlType getTypeFromString(String type) { String[] splitType = type.split("\\("); - String toSwitch = splitType[0].toUpperCase(); - String value = ""; - if (type.contains("(") && type.endsWith(")")) - { + String toSwitch = splitType[0].toUpperCase(); + String value = ""; + if (type.contains("(") && type.endsWith(")")) { value = splitType[1].substring(0, splitType[1].length() - 1); } - switch (toSwitch) - { + switch (toSwitch) { case "CHAR": return new Char(Integer.valueOf(value)); case "ENUM": @@ -93,4 +69,6 @@ public abstract class MysqlType } return null; } + + public abstract String getName(); } diff --git a/src/main/java/com/redstoner/misc/mysql/types/number/Int.java b/src/main/java/com/redstoner/misc/mysql/types/number/Int.java index 4256f7b..7b2fbfd 100644 --- a/src/main/java/com/redstoner/misc/mysql/types/number/Int.java +++ b/src/main/java/com/redstoner/misc/mysql/types/number/Int.java @@ -4,11 +4,11 @@ import com.redstoner.misc.mysql.types.MysqlType; public class Int extends MysqlType { private int maxSize; - + public Int(int maxSize) { this.maxSize = maxSize; } - + @Override public String getName() { return "INT(" + maxSize + ")"; diff --git a/src/main/java/com/redstoner/misc/mysql/types/text/Char.java b/src/main/java/com/redstoner/misc/mysql/types/text/Char.java index ece068c..4d4a938 100644 --- a/src/main/java/com/redstoner/misc/mysql/types/text/Char.java +++ b/src/main/java/com/redstoner/misc/mysql/types/text/Char.java @@ -4,11 +4,11 @@ import com.redstoner.misc.mysql.types.MysqlType; public class Char extends MysqlType { private int size; - + public Char(int size) { this.size = size; } - + @Override public String getName() { return "CHAR(" + size + ")"; diff --git a/src/main/java/com/redstoner/misc/mysql/types/text/Enum.java b/src/main/java/com/redstoner/misc/mysql/types/text/Enum.java index e68476d..6200292 100644 --- a/src/main/java/com/redstoner/misc/mysql/types/text/Enum.java +++ b/src/main/java/com/redstoner/misc/mysql/types/text/Enum.java @@ -4,24 +4,24 @@ import com.redstoner.misc.mysql.types.MysqlType; public class Enum extends MysqlType { private String[] possibleValues; - + public Enum(String... possibleValues) { this.possibleValues = possibleValues; } - + @Override public String getName() { String name = "ENUM("; - + for (int i = 0; i < possibleValues.length; i++) { name += "'" + possibleValues[i] + "'"; - + if (i != possibleValues.length - 1) { name += ","; } } - + return name + ")"; } - + } diff --git a/src/main/java/com/redstoner/misc/mysql/types/text/Set.java b/src/main/java/com/redstoner/misc/mysql/types/text/Set.java index 4e12ce6..f82f02b 100644 --- a/src/main/java/com/redstoner/misc/mysql/types/text/Set.java +++ b/src/main/java/com/redstoner/misc/mysql/types/text/Set.java @@ -4,24 +4,24 @@ import com.redstoner.misc.mysql.types.MysqlType; public class Set extends MysqlType { private String[] possibleValues; - + public Set(String... possibleValues) { this.possibleValues = possibleValues; } - + @Override public String getName() { String name = "SET("; - + for (int i = 0; i < possibleValues.length; i++) { name += "'" + possibleValues[i] + "'"; - + if (i != possibleValues.length - 1) { name += ","; } } - + return name + ")"; } - + } diff --git a/src/main/java/com/redstoner/misc/mysql/types/text/VarChar.java b/src/main/java/com/redstoner/misc/mysql/types/text/VarChar.java index cb28ad1..65b6416 100644 --- a/src/main/java/com/redstoner/misc/mysql/types/text/VarChar.java +++ b/src/main/java/com/redstoner/misc/mysql/types/text/VarChar.java @@ -4,11 +4,11 @@ import com.redstoner.misc.mysql.types.MysqlType; public class VarChar extends MysqlType { private int maxSize; - + public VarChar(int maxSize) { this.maxSize = maxSize; } - + @Override public String getName() { return "VARCHAR(" + maxSize + ")"; diff --git a/src/main/java/com/redstoner/modules/CoreModule.java b/src/main/java/com/redstoner/modules/CoreModule.java index 9f71557..77ca178 100644 --- a/src/main/java/com/redstoner/modules/CoreModule.java +++ b/src/main/java/com/redstoner/modules/CoreModule.java @@ -2,23 +2,22 @@ package com.redstoner.modules; import com.redstoner.annotations.Version; -/** This class shall be used for "CoreModules", which are acting on a lower level than modules and are also exempted from being disabled or reloaded on the go.
+/** + * This class shall be used for "CoreModules", which are acting on a lower level than modules and are also exempted from being disabled or reloaded on the go.
* Please note that CoreModules will not be known to the ModuleLoader itself!
* Examples are the ModuleLoader and the Debugger. - * - * @author Pepich */ -@Version(major = 2, minor = 0, revision = 0, compatible = -1) -public interface CoreModule extends Module -{ + * + * @author Pepich + */ +@Version (major = 2, minor = 0, revision = 0, compatible = -1) +public interface CoreModule extends Module { /** Core modules don't need to be enabled. */ @Override - public default boolean onEnable() - { + public default boolean onEnable() { return true; } - + /** Core modules don't need to be disabled. */ @Override - public default void onDisable() - {} + public default void onDisable() {} } diff --git a/src/main/java/com/redstoner/modules/Module.java b/src/main/java/com/redstoner/modules/Module.java index 1c89e15..67c1063 100644 --- a/src/main/java/com/redstoner/modules/Module.java +++ b/src/main/java/com/redstoner/modules/Module.java @@ -3,52 +3,51 @@ package com.redstoner.modules; import com.redstoner.annotations.Version; import com.redstoner.coremods.moduleLoader.ModuleLoader; -/** Interface for the Module class. Modules must always have an empty constructor to be invoked by the ModuleLoader. - * - * @author Pepich */ -@Version(major = 4, minor = 0, revision = 0, compatible = 0) -public interface Module -{ +/** + * Interface for the Module class. Modules must always have an empty constructor to be invoked by the ModuleLoader. + * + * @author Pepich + */ +@Version (major = 4, minor = 0, revision = 0, compatible = 0) +public interface Module { /** Will be called when the module gets enabled. */ - public default boolean onEnable() - { + public default boolean onEnable() { return true; } - - /** This methods gets called after all modules were enabled, please use this method to register commands and similar.
- * It will only get called if and only if the module was successfully enabled. */ - public default void postEnable() - {} - + + /** + * This methods gets called after all modules were enabled, please use this method to register commands and similar.
+ * It will only get called if and only if the module was successfully enabled. + */ + public default void postEnable() {} + /** Will be called when the module gets disabled. */ - public default void onDisable() - {} - - /** Gets called on registration of the module, when this option is selected for command registration - * - * @return The String used for the CommandManager to register the commands. */ - public default String getCommandString() - { + public default void onDisable() {} + + /** + * Gets called on registration of the module, when this option is selected for command registration + * + * @return The String used for the CommandManager to register the commands. + */ + public default String getCommandString() { return null; } - - public default ModuleLogger getLogger() - { - return ModuleLoader.getModuleLogger(this); - } - + /** This method gets run the very first time a module gets loaded. You can use this to set up file structures or background data. */ - public default void firstLoad() - {} - - /** This method gets run every time a module gets loaded and its version has changed. - * - * @param old The version of the previous module. */ - public default void migrate(Version old) - {} - - default void setPrefix(final String name) - { + public default void firstLoad() {} + + /** + * This method gets run every time a module gets loaded and its version has changed. + * + * @param old The version of the previous module. + */ + public default void migrate(Version old) {} + + default void setPrefix(final String name) { getLogger().setName(name); } + + public default ModuleLogger getLogger() { + return ModuleLoader.getModuleLogger(this); + } } diff --git a/src/main/java/com/redstoner/modules/ModuleLogger.java b/src/main/java/com/redstoner/modules/ModuleLogger.java index 11d71b6..b68343b 100644 --- a/src/main/java/com/redstoner/modules/ModuleLogger.java +++ b/src/main/java/com/redstoner/modules/ModuleLogger.java @@ -1,77 +1,63 @@ package com.redstoner.modules; +import com.redstoner.annotations.Version; +import net.nemez.chatapi.ChatAPI; +import net.nemez.chatapi.click.Message; import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; -import com.redstoner.annotations.Version; - -import net.nemez.chatapi.ChatAPI; -import net.nemez.chatapi.click.Message; - -@Version(major = 4, minor = 0, revision = 0, compatible = -1) -public class ModuleLogger -{ - public static final String PREFIX_WARN = "§8[§eWARN§8]:§7 "; +@Version (major = 4, minor = 0, revision = 0, compatible = -1) +public class ModuleLogger { + public static final String PREFIX_WARN = "§8[§eWARN§8]:§7 "; public static final String PREFIX_ERROR = "§8[§cERROR§8]:§7 "; - public static final String PREFIX_INFO = "§8[§fINFO§8]:§7 "; - + public static final String PREFIX_INFO = "§8[§fINFO§8]:§7 "; + private String name; - - public ModuleLogger(final String name) - { + + public ModuleLogger(final String name) { this.name = name; } - - public void info(final String message) - { + + public void info(final String message) { Bukkit.getConsoleSender().sendMessage(PREFIX_INFO + getPrefix() + ChatAPI.colorify(null, message)); } - - public void warn(final String message) - { + + public String getPrefix() { + return getPrefix(false); + } + + public String getPrefix(final boolean error) { + return "§8[§" + (error ? 'c' : '2') + name + "§8]§7 "; + } + + public void warn(final String message) { Bukkit.getConsoleSender().sendMessage(PREFIX_WARN + getPrefix() + ChatAPI.colorify(null, message)); } - - public void error(final String message) - { + + public void error(final String message) { Bukkit.getConsoleSender().sendMessage(PREFIX_ERROR + getPrefix() + ChatAPI.colorify(null, message)); } - - public void message(final CommandSender recipient, final String... message) - { + + public void message(final CommandSender recipient, final String... message) { message(recipient, false, message); } - - public void message(final CommandSender recipient, final boolean error, final String... message) - { + + public void message(final CommandSender recipient, final boolean error, final String... message) { Message m = new Message(recipient, null); if (message.length == 1) m.appendText(getPrefix(error) + message[0]); - else - { + else { m.appendText(getHeader()); m.appendText("&7" + String.join("\n&7", message)); } m.send(); } - - public String getPrefix() - { - return getPrefix(false); - } - - public String getPrefix(final boolean error) - { - return "§8[§" + (error ? 'c' : '2') + name + "§8]§7 "; - } - - public String getHeader() - { + + public String getHeader() { return "§2--=[ " + name + " ]=--\n"; } - - protected final void setName(final String name) - { + + protected final void setName(final String name) { this.name = name; } } -- 2.45.2 From 30e33a4e58d4277af3e3deaa6efc99b4f79e38d3 Mon Sep 17 00:00:00 2001 From: Logan Fick Date: Fri, 8 Feb 2019 19:04:08 -0500 Subject: [PATCH 148/152] Updated dependencies. --- .idea/misc.xml | 5 +---- .idea/modules/ModuleLoader.main.iml | 17 ++++++++--------- .idea/modules/ModuleLoader.test.iml | 5 ++--- build.gradle | 11 +++++------ .../coremods/moduleLoader/ModuleLoader.java | 2 +- src/main/resources/plugin.yml | 2 +- 6 files changed, 18 insertions(+), 24 deletions(-) diff --git a/.idea/misc.xml b/.idea/misc.xml index 530d61c..3e68e4d 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,8 +1,5 @@ - - - @@ -26,4 +23,4 @@ - + \ No newline at end of file diff --git a/.idea/modules/ModuleLoader.main.iml b/.idea/modules/ModuleLoader.main.iml index cefd623..50a1428 100644 --- a/.idea/modules/ModuleLoader.main.iml +++ b/.idea/modules/ModuleLoader.main.iml @@ -10,19 +10,18 @@ - - - + + + + + + + + - - - - - - \ No newline at end of file diff --git a/.idea/modules/ModuleLoader.test.iml b/.idea/modules/ModuleLoader.test.iml index 59e0e7d..b9fa95c 100644 --- a/.idea/modules/ModuleLoader.test.iml +++ b/.idea/modules/ModuleLoader.test.iml @@ -8,9 +8,8 @@ - - - + + diff --git a/build.gradle b/build.gradle index bc4ba04..5d62467 100644 --- a/build.gradle +++ b/build.gradle @@ -19,10 +19,9 @@ repositories { } dependencies { - implementation "com.github.RedstonerServer:CommandManager:master-SNAPSHOT" - implementation "com.github.RedstonerServer:ChatAPI:master-SNAPSHOT" - implementation "com.github.RedstonerServer:ChestAPI:master-SNAPSHOT" - + implementation "com.github.RedstonerServer:CommandManager:v1" + implementation "com.github.RedstonerServer:ChatAPI:v1" + compile group: 'org.apache.logging.log4j', name: 'log4j-1.2-api', version: '2.11.1' compileOnly 'org.spigotmc:spigot-api:1.13.2-R0.1-SNAPSHOT' @@ -30,11 +29,11 @@ dependencies { jar { manifest { - attributes "Class-Path": "../lib/CommandManager.jar ../lib/ChatAPI.jar ../lib/ChestAPI.jar" + attributes "Class-Path": "../lib/CommandManager.jar ../lib/ChatAPI.jar" } } task sourceJar(type: Jar, dependsOn: classes) { classifier 'sources' from sourceSets.main.allSource -} +} \ No newline at end of file diff --git a/src/main/java/com/redstoner/coremods/moduleLoader/ModuleLoader.java b/src/main/java/com/redstoner/coremods/moduleLoader/ModuleLoader.java index 0397f59..bdf8091 100644 --- a/src/main/java/com/redstoner/coremods/moduleLoader/ModuleLoader.java +++ b/src/main/java/com/redstoner/coremods/moduleLoader/ModuleLoader.java @@ -36,7 +36,7 @@ import java.util.List; * * @author Pepich */ -@Version (major = 5, minor = 2, revision = 0, compatible = 5) +@Version (major = 5, minor = 2, revision = 1, compatible = 5) public final class ModuleLoader implements CoreModule { private static final HashMap modules = new HashMap<>(); private static ModuleLoader instance; diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 5a3ff61..404bd2b 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,5 +1,5 @@ name: ModuleLoader -version: 4.0.0 +version: 5.2.1 authors: [pepich1851] main: com.redstoner.misc.Main softdepend: [Vault] \ No newline at end of file -- 2.45.2 From cb4b081672f5dbaa892d945427e6fe143309ba70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Pani=C4=87?= Date: Sun, 10 Feb 2019 00:44:06 +0100 Subject: [PATCH 149/152] Added bin folder to gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 956145f..67cd9d6 100644 --- a/.gitignore +++ b/.gitignore @@ -123,6 +123,7 @@ hs_err_pid* ### Gradle ### .gradle build/ +bin/ # Ignore Gradle GUI config gradle-app.setting -- 2.45.2 From d67e0015b67614c8c53826a598b8a26a0b3a2e8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Pani=C4=87?= Date: Sun, 10 Feb 2019 01:07:29 +0100 Subject: [PATCH 150/152] Fixed gradle resources --- build.gradle | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/build.gradle b/build.gradle index 5d62467..a1ece9c 100644 --- a/build.gradle +++ b/build.gradle @@ -36,4 +36,16 @@ jar { task sourceJar(type: Jar, dependsOn: classes) { classifier 'sources' from sourceSets.main.allSource +} + +sourceSets { + main { + resources { + srcDir 'src/main/java' + include '**/*.cmd' + + srcDir 'src/main/resources' + include '**/*.yml' + } + } } \ No newline at end of file -- 2.45.2 From ec716782e278dc92e3e3c75e036f08a345422d25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Pani=C4=87?= Date: Sun, 10 Feb 2019 02:16:04 +0100 Subject: [PATCH 151/152] Made versions show directly in chat if you add -v to /modules --- .../coremods/moduleLoader/ModuleLoader.cmd | 12 ++++++++++++ .../coremods/moduleLoader/ModuleLoader.java | 16 +++++++++++++--- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/redstoner/coremods/moduleLoader/ModuleLoader.cmd b/src/main/java/com/redstoner/coremods/moduleLoader/ModuleLoader.cmd index 4e06bd0..69dd38d 100644 --- a/src/main/java/com/redstoner/coremods/moduleLoader/ModuleLoader.cmd +++ b/src/main/java/com/redstoner/coremods/moduleLoader/ModuleLoader.cmd @@ -4,10 +4,22 @@ command modules { perm moduleloader.modules.list; run list; } + -v { + help Lists all modules and their versions. Color indicates status: §aENABLED §cDISABLED; + perm moduleloader.modules.list; + run listversions; + } + + list { help Lists all modules. Color indicates status: §aENABLED §cDISABLED; perm moduleloader.modules.list; run list; + } + list -v { + help Lists all modules and their versions. Color indicates status: §aENABLED §cDISABLED; + perm moduleloader.modules.list; + run listversions; } load [string:name...] { help (Re)-Loads a module. WARNING: Handle with care! This has direct affect on code being executed. This command will temporarily halt the main thread until the class loading operation was completed.; diff --git a/src/main/java/com/redstoner/coremods/moduleLoader/ModuleLoader.java b/src/main/java/com/redstoner/coremods/moduleLoader/ModuleLoader.java index bdf8091..ec478a0 100644 --- a/src/main/java/com/redstoner/coremods/moduleLoader/ModuleLoader.java +++ b/src/main/java/com/redstoner/coremods/moduleLoader/ModuleLoader.java @@ -561,15 +561,25 @@ public final class ModuleLoader implements CoreModule { return Main.plugin; } + @Command (hook = "list", async = AsyncType.ALWAYS) + public boolean listModulesCommand(CommandSender sender) { + return listModules(sender, false); + } + + @Command (hook = "listversions", async = AsyncType.ALWAYS) + public boolean listModulesVerionsCommand(CommandSender sender) { + return listModules(sender, true); + } + /** * This method lists all modules to the specified CommandSender. The modules will be color coded correspondingly to their enabled status. * * @param sender The person to send the info to, usually the issuer of the command or the console sender. + * @param showVersions Should we show the versions directly in chat. * * @return true. */ - @Command (hook = "list", async = AsyncType.ALWAYS) - public boolean listModulesCommand(CommandSender sender) { + public boolean listModules(CommandSender sender, boolean showVersions) { boolean hasCategorys = hasCategories(); Message m = new Message(sender, null); ModuleInfo ml_info = moduleInfos.get(instance); @@ -587,7 +597,7 @@ public final class ModuleLoader implements CoreModule { for (Module mod : mods) { ModuleInfo info = moduleInfos.get(mod); - m.appendTextHover((modules.get(mod) ? "§a" : "§c") + info.getDisplayName(), info.getModuleInfoHover()); + m.appendTextHover((modules.get(mod) ? "§a" : "§c") + info.getDisplayName() + (showVersions ? " &e" + info.getVersion() : ""), info.getModuleInfoHover()); if (curModule != mods.size()) m.appendText("&7, "); -- 2.45.2 From 7d3e2a04b2d7603e446cb898633a203d7bcba4d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Pani=C4=87?= Date: Wed, 17 Apr 2019 19:55:42 +0200 Subject: [PATCH 152/152] Bumped version + added devs as authors --- src/main/resources/plugin.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 404bd2b..fc576a8 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,5 +1,5 @@ name: ModuleLoader -version: 5.2.1 -authors: [pepich1851] +version: 5.2.2 +authors: [pepich1851, psrcek, LogalDeveloper, Minenash] main: com.redstoner.misc.Main -softdepend: [Vault] \ No newline at end of file +softdepend: [Vault] -- 2.45.2