Guest User

Untitled

a guest
May 24th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.24 KB | None | 0 0
  1. package me.Fire_Head431.MyPackage;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.HashMap;
  5. import java.util.logging.Logger;
  6.  
  7. import org.bukkit.block.Block;
  8. import org.bukkit.command.Command;
  9. import org.bukkit.command.CommandSender;
  10. import org.bukkit.entity.Player;
  11. import org.bukkit.event.Event;
  12. import org.bukkit.plugin.PluginDescriptionFile;
  13. import org.bukkit.plugin.PluginManager;
  14. import org.bukkit.plugin.java.JavaPlugin;
  15.  
  16. public class Basic extends JavaPlugin {
  17.  
  18. public static Basic plugin;
  19.  
  20. public final Logger logger = Logger.getLogger("Minecraft");
  21.  
  22. private final BasicBlockListener blockListener = new BasicBlockListener(
  23. this);
  24.  
  25. public final HashMap<Player, ArrayList<Block>> basicUsers = new HashMap<Player, ArrayList<Block>>();
  26. // Creating HashMap.
  27. private final HashMap<Player, Boolean> debugees = new HashMap<Player, Boolean>();
  28.  
  29. @Override
  30. public void onDisable() {
  31.  
  32. this.logger.info("TNTNotify has been Disabled!");
  33.  
  34. }
  35.  
  36. @Override
  37. public void onEnable() {
  38. PluginManager pm = getServer().getPluginManager();
  39.  
  40. pm.registerEvent(Event.Type.BLOCK_PLACE, this.blockListener,
  41. Event.Priority.Normal, this);
  42. PluginDescriptionFile pdfFile = this.getDescription();
  43. this.logger.info(pdfFile.getName() + " version " + pdfFile.getVersion()
  44. + "is enabled!");
  45. }
  46.  
  47. public boolean onCommand(CommandSender sender, Command cmd,
  48. String commandLabel, String[] args) {
  49. if (commandLabel.equalsIgnoreCase("notify")
  50. || commandLabel.equalsIgnoreCase("n"))
  51. toggleVision((Player) sender);
  52. return false;
  53. }
  54.  
  55. public boolean isDebugging(final Player player) {
  56. if (debugees.containsKey(player)) {
  57. return debugees.get(player);
  58. } else {
  59. return false;
  60.  
  61. }
  62. }
  63.  
  64. public void setDebugging(final Player player, final boolean value) {
  65. debugees.put(player, value);
  66. }
  67.  
  68. // the method enabled which checks to see the player is in the hashmap
  69.  
  70. public boolean enabled(Player player) {
  71. return this.basicUsers.containsKey(player);
  72. }
  73.  
  74. public void toggleVision(Player player) {
  75. if (enabled(player)) {
  76. this.basicUsers.remove(player);
  77. player.sendMessage("TNTNotify disabled");
  78. } else {
  79. this.basicUsers.put(player, null);
  80. player.sendMessage("TNTNotify enabled");
  81. }
  82.  
  83. }
  84. }
Add Comment
Please, Sign In to add comment