From f0d8a2979d66ccaa951151d4eb9114c91ad1afc7 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Fri, 14 Jan 2011 15:44:40 -0800 Subject: [PATCH] Changing the directory --- .../vPlayersOnline/POBlockListener.java | 18 +++++ .../vPlayersOnline/POPlayerListener.java | 29 ++++++++ .../vPlayersOnline/vPlayersOnline.java | 66 +++++++++++++++++++ 3 files changed, 113 insertions(+) create mode 100644 vPlayersOnline/src/com/bukkit/nossr50/vPlayersOnline/POBlockListener.java create mode 100644 vPlayersOnline/src/com/bukkit/nossr50/vPlayersOnline/POPlayerListener.java create mode 100644 vPlayersOnline/src/com/bukkit/nossr50/vPlayersOnline/vPlayersOnline.java diff --git a/vPlayersOnline/src/com/bukkit/nossr50/vPlayersOnline/POBlockListener.java b/vPlayersOnline/src/com/bukkit/nossr50/vPlayersOnline/POBlockListener.java new file mode 100644 index 000000000..1e6ef1fa6 --- /dev/null +++ b/vPlayersOnline/src/com/bukkit/nossr50/vPlayersOnline/POBlockListener.java @@ -0,0 +1,18 @@ +package com.bukkit.nossr50.vPlayersOnline; + +import org.bukkit.event.block.BlockListener; + + +/** + * vPlayersOnline block listener + * @author nossr50 + */ +public class POBlockListener extends BlockListener { + private final vPlayersOnline plugin; + + public POBlockListener(final vPlayersOnline plugin) { + this.plugin = plugin; + } + + //put all Block related code here +} diff --git a/vPlayersOnline/src/com/bukkit/nossr50/vPlayersOnline/POPlayerListener.java b/vPlayersOnline/src/com/bukkit/nossr50/vPlayersOnline/POPlayerListener.java new file mode 100644 index 000000000..15bed9851 --- /dev/null +++ b/vPlayersOnline/src/com/bukkit/nossr50/vPlayersOnline/POPlayerListener.java @@ -0,0 +1,29 @@ +package com.bukkit.nossr50.vPlayersOnline; + +import org.bukkit.Player; +import org.bukkit.Color; +import org.bukkit.event.player.PlayerEvent; +import org.bukkit.event.player.PlayerListener; + +/** + * Handle events for all Player related events + * @author nossr50 + */ +public class POPlayerListener extends PlayerListener { + private final vPlayersOnline plugin; + + public POPlayerListener(vPlayersOnline instance) { + this.plugin = instance; + } + + //Insert Player related code here + public void onPlayerJoin(PlayerEvent event) { + Player player = event.getPlayer(); + Player players[] = plugin.getServer().getOnlinePlayers(); + int x = 0; + for(Player herp: players){ + x++; + } + player.sendMessage("There are " + x + " players online"); + } + } \ No newline at end of file diff --git a/vPlayersOnline/src/com/bukkit/nossr50/vPlayersOnline/vPlayersOnline.java b/vPlayersOnline/src/com/bukkit/nossr50/vPlayersOnline/vPlayersOnline.java new file mode 100644 index 000000000..44861b655 --- /dev/null +++ b/vPlayersOnline/src/com/bukkit/nossr50/vPlayersOnline/vPlayersOnline.java @@ -0,0 +1,66 @@ +package com.bukkit.nossr50.vPlayersOnline; +import java.io.File; +import java.util.HashMap; +import org.bukkit.Player; +import org.bukkit.Server; +import org.bukkit.event.Event.Priority; +import org.bukkit.event.Event; +import org.bukkit.plugin.PluginDescriptionFile; +import org.bukkit.plugin.PluginLoader; +import org.bukkit.plugin.java.JavaPlugin; +import org.bukkit.plugin.PluginManager; + +/** + * PlayersOnline for Bukkit + * + * @author nossr50 + */ +public class vPlayersOnline extends JavaPlugin { + private final POPlayerListener playerListener = new POPlayerListener(this); + private final POBlockListener blockListener = new POBlockListener(this); + private final HashMap debugees = new HashMap(); + public final static String name = "vPlayersOnline"; + public final static String version = "1.0"; + + + public vPlayersOnline(PluginLoader pluginLoader, Server instance, PluginDescriptionFile desc, File plugin, ClassLoader cLoader) { + super(pluginLoader, instance, desc, plugin, cLoader); + + // TODO: Place any custom initialization code here + + // NOTE: Event registration should be done in onEnable not here as all events are unregistered when a plugin is disabled + } + + + + public void onEnable() { + // TODO: Place any custom enable code here including the registration of any events + // Register our events + getServer().getPluginManager().registerEvent(Event.Type.PLAYER_JOIN, playerListener, Priority.Normal, this); + getServer().getPluginManager().registerEvent(Event.Type.PLAYER_QUIT, playerListener, Priority.Normal, this); + PluginManager pm = getServer().getPluginManager(); + // EXAMPLE: Custom code, here we just output some info so we can check all is well + PluginDescriptionFile pdfFile = this.getDescription(); + System.out.println( pdfFile.getName() + " version " + pdfFile.getVersion() + " is enabled!" ); + } + public void onDisable() { + // TODO: Place any custom disable code here + + // NOTE: All registered events are automatically unregistered when a plugin is disabled + + // EXAMPLE: Custom code, here we just output some info so we can check all is well + System.out.println("Goodbye world!"); + } + public boolean isDebugging(final Player player) { + if (debugees.containsKey(player)) { + return debugees.get(player); + } else { + return false; + } + } + + public void setDebugging(final Player player, final boolean value) { + debugees.put(player, value); + } +} +