From a5d8cbe0172e8996e226eb268047381b74f40c44 Mon Sep 17 00:00:00 2001 From: minenash Date: Sun, 12 Feb 2017 10:45:23 -0500 Subject: [PATCH] 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" + + "}"; + } +}