Want more features on Pastebin? Sign Up, it's FREE!
Guest

com.bukket.samkio.Basic.Basic.java

By: a guest on Jan 20th, 2011  |  syntax: Java  |  size: 3.09 KB  |  views: 4,959  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. //The Package
  2. package com.bukkit.samkio.Basic;
  3. //All the imports
  4. import java.io.File;
  5. import java.util.ArrayList;
  6. import java.util.HashMap;
  7. import org.bukkit.Server;
  8. import org.bukkit.block.Block;
  9. import org.bukkit.entity.Player;
  10. import org.bukkit.event.Event;
  11. import org.bukkit.plugin.PluginDescriptionFile;
  12. import org.bukkit.plugin.PluginLoader;
  13. import org.bukkit.plugin.java.JavaPlugin;
  14. import org.bukkit.plugin.PluginManager;
  15.  
  16. /**
  17.  * Basic for Bukkit
  18.  *
  19.  * @author Samkio
  20.  */
  21. //Starts the class
  22. public class Basic extends JavaPlugin{
  23.         //Links the BasicPlayerListener
  24.         private final BasicPlayerListener playerListener = new BasicPlayerListener(this);
  25.         //Links the BasicBlockListener
  26.     private final BasicBlockListener blockListener = new BasicBlockListener(this);
  27.     //Create the hashmap "basicUsers"
  28.     public final HashMap<Player, ArrayList<Block>> basicUsers = new HashMap();  
  29.     //Create the hashmap debugees
  30.     private final HashMap<Player, Boolean> debugees = new HashMap<Player, Boolean>();
  31.    
  32.         public Basic(PluginLoader pluginLoader, Server instance, PluginDescriptionFile desc, File folder, File plugin, ClassLoader cLoader)
  33.     {
  34.         super(pluginLoader, instance, desc, folder, plugin, cLoader);
  35.       }
  36.  
  37.         @Override
  38.         //When the plugin is disabled this method is called.
  39.         public void onDisable() {
  40.                 //Print "Basic Disabled" on the log.
  41.                 System.out.println("Basic Disabled");
  42.                
  43.         }
  44.  
  45.         @Override
  46.         //When the plugin is enabled this method is called.
  47.         public void onEnable() {
  48.                 //Create the pluginmanage pm.
  49.                 PluginManager pm = getServer().getPluginManager();
  50.                 //Create PlayerCommand listener
  51.             pm.registerEvent(Event.Type.PLAYER_COMMAND, this.playerListener, Event.Priority.Normal, this);
  52.             //Create BlockPlaced listener
  53.         pm.registerEvent(Event.Type.BLOCK_PLACED, blockListener, Event.Priority.Normal, this);
  54.        //Get the infomation from the yml file.
  55.         PluginDescriptionFile pdfFile = this.getDescription();
  56.         //Print that the plugin has been enabled!
  57.         System.out.println( pdfFile.getName() + " version " + pdfFile.getVersion() + " is enabled!" );
  58.                
  59.         }
  60.         //Used when debugging
  61.           public boolean isDebugging(final Player player) {
  62.                 if (debugees.containsKey(player)) {
  63.                     return debugees.get(player);
  64.                 } else {
  65.                     return false;
  66.                 }
  67.             }
  68.  
  69.             public void setDebugging(final Player player, final boolean value) {
  70.                 debugees.put(player, value);
  71.             }
  72.            
  73.             //The method enabled which checks to see if the player is in the hashmap basicUsers
  74.             public boolean enabled(Player player) {
  75.                         return this.basicUsers.containsKey(player);
  76.                 }
  77.             //The method toggleVision which if the player is on the hashmap will remove the player else it will add the player.
  78.             //Also sends user a message to notify them.
  79.             public void toggleVision(Player player) {
  80.                         if (enabled(player)) {
  81.                                 this.basicUsers.remove(player);
  82.                                 player.sendMessage("Basic disabled");
  83.                         } else {
  84.                                 this.basicUsers.put(player, null);
  85.                                 player.sendMessage("Basic enabled");
  86.                         }
  87.                 }
  88.  
  89. }
clone this paste RAW Paste Data