mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-25 14:46:46 +01:00
Small plugin for bukkit I wrote to learn bukkit/eclipse.
This commit is contained in:
parent
95c9ab266a
commit
7a497cd2b0
7
vPlayersOnline/.classpath
Normal file
7
vPlayersOnline/.classpath
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<classpath>
|
||||||
|
<classpathentry kind="src" path="src"/>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
|
||||||
|
<classpathentry kind="lib" path="C:/MC Server/bukkit.jar"/>
|
||||||
|
<classpathentry kind="output" path="bin"/>
|
||||||
|
</classpath>
|
17
vPlayersOnline/.project
Normal file
17
vPlayersOnline/.project
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<projectDescription>
|
||||||
|
<name>vPlayersOnline</name>
|
||||||
|
<comment></comment>
|
||||||
|
<projects>
|
||||||
|
</projects>
|
||||||
|
<buildSpec>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
</buildSpec>
|
||||||
|
<natures>
|
||||||
|
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||||
|
</natures>
|
||||||
|
</projectDescription>
|
12
vPlayersOnline/.settings/org.eclipse.jdt.core.prefs
Normal file
12
vPlayersOnline/.settings/org.eclipse.jdt.core.prefs
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#Fri Jan 14 13:46:19 PST 2011
|
||||||
|
eclipse.preferences.version=1
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||||
|
org.eclipse.jdt.core.compiler.compliance=1.6
|
||||||
|
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||||
|
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||||
|
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||||
|
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||||
|
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||||
|
org.eclipse.jdt.core.compiler.source=1.6
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
3
vPlayersOnline/bin/plugin.yml
Normal file
3
vPlayersOnline/bin/plugin.yml
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
name: PlayersOnline
|
||||||
|
main: com.bukkit.nossr50.vPlayersOnline.vPlayersOnline
|
||||||
|
version: 1.0
|
@ -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
|
||||||
|
}
|
@ -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");
|
||||||
|
}
|
||||||
|
}
|
@ -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<Player, Boolean> debugees = new HashMap<Player, Boolean>();
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
3
vPlayersOnline/src/plugin.yml
Normal file
3
vPlayersOnline/src/plugin.yml
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
name: PlayersOnline
|
||||||
|
main: com.bukkit.nossr50.vPlayersOnline.vPlayersOnline
|
||||||
|
version: 1.0
|
Loading…
Reference in New Issue
Block a user