From ad8c9e213d689b72ca46415788b0fc7e398cd297 Mon Sep 17 00:00:00 2001 From: minenash Date: Wed, 8 Feb 2017 16:00:22 -0500 Subject: [PATCH 1/8] Added Illumination module. --- .../modules/illumination/Illumination.java | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 src/com/redstoner/modules/illumination/Illumination.java diff --git a/src/com/redstoner/modules/illumination/Illumination.java b/src/com/redstoner/modules/illumination/Illumination.java new file mode 100644 index 0000000..65438a3 --- /dev/null +++ b/src/com/redstoner/modules/illumination/Illumination.java @@ -0,0 +1,57 @@ +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.modules.Module; + +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); + } + else { + player.addPotionEffect(effect, true); + } + } + + @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" + + "}"; + } +} From b30d8228bb31734402c0ac0d1342bfd57596ca24 Mon Sep 17 00:00:00 2001 From: minenash Date: Wed, 8 Feb 2017 17:07:50 -0500 Subject: [PATCH 2/8] Added Illumination to Main --- src/com/redstoner/misc/Main.java | 2 ++ src/com/redstoner/modules/illumination/Illumination.java | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/com/redstoner/misc/Main.java b/src/com/redstoner/misc/Main.java index 797da9c..f72f49c 100644 --- a/src/com/redstoner/misc/Main.java +++ b/src/com/redstoner/misc/Main.java @@ -14,6 +14,7 @@ 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; @@ -57,6 +58,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 index 65438a3..f962368 100644 --- a/src/com/redstoner/modules/illumination/Illumination.java +++ b/src/com/redstoner/modules/illumination/Illumination.java @@ -6,8 +6,10 @@ import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; import com.nemez.cmdmgr.Command; +import com.redstoner.annotations.Version; import com.redstoner.modules.Module; +@Version(major = 1, minor = 0, revision = 0, compatible = 1) public class Illumination implements Module{ boolean enabled = false; From e49ceec37641b2426b7a08279f47025cc9207e5e Mon Sep 17 00:00:00 2001 From: minenash Date: Wed, 8 Feb 2017 17:18:14 -0500 Subject: [PATCH 3/8] Added Chat Feedback to Illumination --- src/com/redstoner/misc/Main.java | 2 +- src/com/redstoner/modules/illumination/Illumination.java | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/com/redstoner/misc/Main.java b/src/com/redstoner/misc/Main.java index f72f49c..e7d4707 100644 --- a/src/com/redstoner/misc/Main.java +++ b/src/com/redstoner/misc/Main.java @@ -35,7 +35,7 @@ import com.redstoner.modules.webtoken.WebToken; /** Main class. Duh. * * @author Pepich */ -@Version(major = 1, minor = 4, revision = 0, compatible = -1) +@Version(major = 1, minor = 4, revision = 1, compatible = -1) public class Main extends JavaPlugin { public static JavaPlugin plugin; diff --git a/src/com/redstoner/modules/illumination/Illumination.java b/src/com/redstoner/modules/illumination/Illumination.java index f962368..5404a30 100644 --- a/src/com/redstoner/modules/illumination/Illumination.java +++ b/src/com/redstoner/modules/illumination/Illumination.java @@ -7,6 +7,7 @@ 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) @@ -20,9 +21,11 @@ public class Illumination implements Module{ 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."); } } From 3a8927169acd44e9f6b3b2715501033e68a12212 Mon Sep 17 00:00:00 2001 From: minenash Date: Thu, 9 Feb 2017 17:02:45 -0500 Subject: [PATCH 4/8] 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" + - "}"; - } -} From b0b24699378df57aa370c10a42da4173590265f6 Mon Sep 17 00:00:00 2001 From: minenash Date: Thu, 9 Feb 2017 18:10:01 -0500 Subject: [PATCH 5/8] 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 +} From a2a2334be667ae805e66a9321d5b62f76eaa4dfa Mon Sep 17 00:00:00 2001 From: minenash Date: Sat, 11 Feb 2017 11:42:19 -0500 Subject: [PATCH 6/8] 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" + + "}"; + } + +} From a5d8cbe0172e8996e226eb268047381b74f40c44 Mon Sep 17 00:00:00 2001 From: minenash Date: Sun, 12 Feb 2017 10:45:23 -0500 Subject: [PATCH 7/8] 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" + + "}"; + } +} From 6e65173ba6d86914c679c26c9151d39b1473e76a Mon Sep 17 00:00:00 2001 From: minenash Date: Sun, 12 Feb 2017 12:01:25 -0500 Subject: [PATCH 8/8] 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" + + "}"; + } + +}