mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-29 08:36:45 +01:00
Updated to work with latest build of bukkit.
Changed the constructor.
This commit is contained in:
parent
774ee57048
commit
75b2c04d05
@ -0,0 +1,23 @@
|
|||||||
|
package com.bukkit.nossr50.vPlayersOnline;
|
||||||
|
|
||||||
|
import org.bukkit.Block;
|
||||||
|
import org.bukkit.BlockFace;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.event.block.BlockCanBuildEvent;
|
||||||
|
import org.bukkit.event.block.BlockListener;
|
||||||
|
import org.bukkit.event.block.BlockPhysicsEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* vPlayersOnline block listener
|
||||||
|
* @author nossr50
|
||||||
|
*/
|
||||||
|
public class vBlockListener extends BlockListener {
|
||||||
|
private final vPlayersOnline plugin;
|
||||||
|
|
||||||
|
public vBlockListener(final vPlayersOnline plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
//put all Block related code here
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,31 @@
|
|||||||
|
package com.bukkit.nossr50.vPlayersOnline;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Player;
|
||||||
|
import org.bukkit.event.player.PlayerChatEvent;
|
||||||
|
import org.bukkit.event.player.PlayerEvent;
|
||||||
|
import org.bukkit.event.player.PlayerListener;
|
||||||
|
import org.bukkit.event.player.PlayerMoveEvent;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle events for all Player related events
|
||||||
|
* @author nossr50
|
||||||
|
*/
|
||||||
|
public class vPlayerListener extends PlayerListener {
|
||||||
|
private final vPlayersOnline plugin;
|
||||||
|
|
||||||
|
public vPlayerListener(vPlayersOnline instance) {
|
||||||
|
plugin = instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onPlayerJoin(PlayerEvent event) {
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
Player players[] = plugin.getServer().getOnlinePlayers();
|
||||||
|
int x = 0;
|
||||||
|
for(Player hurrdurr: players){
|
||||||
|
x++;
|
||||||
|
}
|
||||||
|
player.sendMessage(ChatColor.GREEN + "There are " + x + " players online");
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,54 @@
|
|||||||
|
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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* vPlayersOnline for Bukkit
|
||||||
|
*
|
||||||
|
* @author nossr50
|
||||||
|
*/
|
||||||
|
public class vPlayersOnline extends JavaPlugin {
|
||||||
|
private final vPlayerListener playerListener = new vPlayerListener(this);
|
||||||
|
private final vBlockListener blockListener = new vBlockListener(this);
|
||||||
|
private final HashMap<Player, Boolean> debugees = new HashMap<Player, Boolean>();
|
||||||
|
private final String name = "vPlayersOnline";
|
||||||
|
|
||||||
|
public vPlayersOnline(PluginLoader pluginLoader, Server instance, PluginDescriptionFile desc, File folder, File plugin, ClassLoader cLoader) {
|
||||||
|
super(pluginLoader, instance, desc, folder, plugin, cLoader);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public void onEnable() {
|
||||||
|
PluginManager pm = getServer().getPluginManager();
|
||||||
|
getServer().getPluginManager().registerEvent(Event.Type.PLAYER_JOIN, playerListener, Priority.Normal, this);
|
||||||
|
getServer().getPluginManager().registerEvent(Event.Type.PLAYER_QUIT, playerListener, Priority.Normal, this);
|
||||||
|
//Displays a message when plugin is loaded
|
||||||
|
PluginDescriptionFile pdfFile = this.getDescription();
|
||||||
|
System.out.println( pdfFile.getName() + " version " + pdfFile.getVersion() + " is enabled!" );
|
||||||
|
}
|
||||||
|
public void onDisable() {
|
||||||
|
|
||||||
|
System.out.println("vPlayersOnline disabled.");
|
||||||
|
}
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
@ -1,2 +1,3 @@
|
|||||||
name: vPlayersOnline
|
name: vPlayersOnline
|
||||||
main: com.bukkit.nossr50.vPlayersOnline.vPlayersOnline
|
main: com.bukkit.nossr50.vPlayersOnline.vPlayersOnline
|
||||||
|
version: 1.1
|
Loading…
Reference in New Issue
Block a user