From b0358d62352882a3a4e65a9befc70803ea8ebcc6 Mon Sep 17 00:00:00 2001 From: Pepich Date: Thu, 2 Mar 2017 19:39:48 +0100 Subject: [PATCH] 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 +}