diff options
Diffstat (limited to 'sample')
4 files changed, 0 insertions, 175 deletions
diff --git a/sample/src/com/dinnerbone/bukkit/sample/SampleBlockListener.java b/sample/src/com/dinnerbone/bukkit/sample/SampleBlockListener.java deleted file mode 100644 index 57f27e46..00000000 --- a/sample/src/com/dinnerbone/bukkit/sample/SampleBlockListener.java +++ /dev/null @@ -1,42 +0,0 @@ - -package com.dinnerbone.bukkit.sample; - -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; - -/** - * Sample block listener - * @author Dinnerbone - */ -public class SampleBlockListener extends BlockListener { - private final SamplePlugin plugin; - - public SampleBlockListener(final SamplePlugin plugin) { - this.plugin = plugin; - } - - @Override - public void onBlockPhysics(BlockPhysicsEvent event) { - Block block = event.getBlock(); - - if ((block.getType() == Material.Sand) || (block.getType() == Material.Gravel)) { - Block above = block.getFace(BlockFace.Up); - if (above.getType() == Material.IronBlock) { - event.setCancelled(true); - } - } - } - - @Override - public void onBlockCanBuild(BlockCanBuildEvent event) { - Material mat = event.getMaterial(); - - if (mat.equals(Material.Cactus)) { - event.setBuildable(true); - } - } -} diff --git a/sample/src/com/dinnerbone/bukkit/sample/SamplePlayerListener.java b/sample/src/com/dinnerbone/bukkit/sample/SamplePlayerListener.java deleted file mode 100644 index 4196188e..00000000 --- a/sample/src/com/dinnerbone/bukkit/sample/SamplePlayerListener.java +++ /dev/null @@ -1,73 +0,0 @@ - -package com.dinnerbone.bukkit.sample; - -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; - -/** - * Handle events for all Player related events - * @author Dinnerbone - */ -public class SamplePlayerListener extends PlayerListener { - private final SamplePlugin plugin; - - public SamplePlayerListener(SamplePlugin instance) { - plugin = instance; - } - - @Override - public void onPlayerJoin(PlayerEvent event) { - System.out.println(event.getPlayer().getName() + " joined the server! :D"); - } - - @Override - public void onPlayerQuit(PlayerEvent event) { - System.out.println(event.getPlayer().getName() + " left the server! :'("); - } - - @Override - public void onPlayerCommand(PlayerChatEvent event) { - String[] split = event.getMessage().split(" "); - Player player = event.getPlayer(); - - if (split[0].equalsIgnoreCase("/pos")) { - if (split.length == 1) { - Location location = player.getLocation(); - player.sendMessage("You are currently at " + location.getX() +"," + location.getY() + "," + location.getZ() + - " with " + location.getYaw() + " yaw and " + location.getPitch() + " pitch"); - } else if (split.length == 4) { - try { - double x = Double.parseDouble(split[1]); - double y = Double.parseDouble(split[2]); - double z = Double.parseDouble(split[3]); - - player.teleportTo(new Location(player.getWorld(), x, y, z)); - } catch (NumberFormatException ex) { - player.sendMessage("Given location is invalid"); - } - } else { - player.sendMessage("Usage: '/pos' to get current position, or '/pos x y z' to teleport to x,y,z"); - } - - event.setCancelled(true); - } else if (split[0].equalsIgnoreCase("/debug")) { - plugin.setDebugging(player, !plugin.isDebugging(player)); - - event.setCancelled(true); - } - } - - @Override - public void onPlayerMove(PlayerMoveEvent event) { - if (plugin.isDebugging(event.getPlayer())) { - Location from = event.getFrom(); - Location to = event.getTo(); - - System.out.println(String.format("From %.2f,%.2f,%.2f to %.2f,%.2f,%.2f", from.getX(), from.getY(), from.getZ(), to.getX(), to.getY(), to.getZ())); - } - } -} diff --git a/sample/src/com/dinnerbone/bukkit/sample/SamplePlugin.java b/sample/src/com/dinnerbone/bukkit/sample/SamplePlugin.java deleted file mode 100644 index 4d0de3d4..00000000 --- a/sample/src/com/dinnerbone/bukkit/sample/SamplePlugin.java +++ /dev/null @@ -1,58 +0,0 @@ - -package com.dinnerbone.bukkit.sample; - -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; - -/** - * Sample plugin for Bukkit - * - * @author Dinnerbone - */ -public class SamplePlugin extends JavaPlugin { - private final SamplePlayerListener playerListener = new SamplePlayerListener(this); - private final SampleBlockListener blockListener = new SampleBlockListener(this); - private final HashMap<Player, Boolean> debugees = new HashMap<Player, Boolean>(); - - public SamplePlugin(PluginLoader pluginLoader, Server instance, PluginDescriptionFile desc, File plugin, ClassLoader cLoader) { - super(pluginLoader, instance, desc, plugin, cLoader); - - registerEvents(); - } - - public void onDisable() { - System.out.println("Goodbye world!"); - } - - public void onEnable() { - System.out.println("Hello world!"); - } - - private void registerEvents() { - getServer().getPluginManager().registerEvent(Event.Type.PLAYER_JOIN, playerListener, Priority.Normal, this); - getServer().getPluginManager().registerEvent(Event.Type.PLAYER_QUIT, playerListener, Priority.Normal, this); - getServer().getPluginManager().registerEvent(Event.Type.PLAYER_COMMAND, playerListener, Priority.Normal, this); - getServer().getPluginManager().registerEvent(Event.Type.PLAYER_MOVE, playerListener, Priority.Normal, this); - getServer().getPluginManager().registerEvent(Event.Type.BLOCK_PHYSICS, blockListener, Priority.Normal, this); - getServer().getPluginManager().registerEvent(Event.Type.BLOCK_CANBUILD, blockListener, Priority.Normal, this); - } - - 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); - } -} diff --git a/sample/src/plugin.yml b/sample/src/plugin.yml deleted file mode 100644 index e4d19dc7..00000000 --- a/sample/src/plugin.yml +++ /dev/null @@ -1,2 +0,0 @@ -name: Sample Plugin -main: com.dinnerbone.bukkit.sample.SamplePlugin |