diff --git a/src/me/StevenLawson/TotalFreedomMod/TotalFreedomMod.java b/src/me/StevenLawson/TotalFreedomMod/TotalFreedomMod.java index a283b02..631aa30 100644 --- a/src/me/StevenLawson/TotalFreedomMod/TotalFreedomMod.java +++ b/src/me/StevenLawson/TotalFreedomMod/TotalFreedomMod.java @@ -73,13 +73,16 @@ public class TotalFreedomMod extends JavaPlugin preprocessLogEnabled = CONFIG.getBoolean("preprocess_log", false); PluginManager pm = this.getServer().getPluginManager(); + pm.registerEvent(Event.Type.ENTITY_EXPLODE, entityListener, Event.Priority.High, this); pm.registerEvent(Event.Type.ENTITY_COMBUST, entityListener, Event.Priority.High, this); pm.registerEvent(Event.Type.ENTITY_DAMAGE, entityListener, Event.Priority.High, this); pm.registerEvent(Event.Type.EXPLOSION_PRIME, entityListener, Event.Priority.High, this); + pm.registerEvent(Event.Type.BLOCK_IGNITE, blockListener, Event.Priority.High, this); pm.registerEvent(Event.Type.BLOCK_BURN, blockListener, Event.Priority.High, this); pm.registerEvent(Event.Type.BLOCK_PLACE, blockListener, Event.Priority.High, this); + pm.registerEvent(Event.Type.PLAYER_COMMAND_PREPROCESS, playerListener, Event.Priority.High, this); pm.registerEvent(Event.Type.PLAYER_INTERACT, playerListener, Event.Priority.High, this); @@ -199,7 +202,7 @@ public class TotalFreedomMod extends JavaPlugin onlineUsers.append(ChatColor.WHITE); } } - + sender.sendMessage(onlineStats.toString()); sender.sendMessage(onlineUsers.toString()); @@ -748,6 +751,12 @@ public class TotalFreedomMod extends JavaPlugin sender.sendMessage(MSG_NO_PERMS); } + return true; + } + else if (cmd.getName().equalsIgnoreCase("status")) + { + sender.sendMessage(ChatColor.GRAY + "Server is currently running with 'online-mode=" + (Bukkit.getOnlineMode() ? "true" : "false") + "'."); + return true; } } diff --git a/src/me/StevenLawson/TotalFreedomMod/TotalFreedomModBlockListener.java b/src/me/StevenLawson/TotalFreedomMod/TotalFreedomModBlockListener.java index fb5b2f8..7386e0e 100644 --- a/src/me/StevenLawson/TotalFreedomMod/TotalFreedomModBlockListener.java +++ b/src/me/StevenLawson/TotalFreedomMod/TotalFreedomModBlockListener.java @@ -12,69 +12,71 @@ import org.bukkit.inventory.ItemStack; public class TotalFreedomModBlockListener extends BlockListener { - public static TotalFreedomMod plugin; + public static TotalFreedomMod plugin; private static final Logger log = Logger.getLogger("Minecraft"); - TotalFreedomModBlockListener(TotalFreedomMod instance) - { - plugin = instance; - } + TotalFreedomModBlockListener(TotalFreedomMod instance) + { + plugin = instance; + } - @Override - public void onBlockBurn(BlockBurnEvent event) - { - if (!plugin.allowFire) - { - event.setCancelled(true); - return; - } - } + @Override + public void onBlockBurn(BlockBurnEvent event) + { + if (!plugin.allowFire) + { + event.setCancelled(true); + return; + } + } - @Override - public void onBlockIgnite(BlockIgniteEvent event) - { - if (!plugin.allowFire) - { - event.setCancelled(true); - return; - } - } + @Override + public void onBlockIgnite(BlockIgniteEvent event) + { + if (!plugin.allowFire) + { + event.setCancelled(true); + return; + } + } - @Override - public void onBlockPlace(BlockPlaceEvent event) - { - ItemStack is = new ItemStack(event.getBlockPlaced().getType(), 1, (short) 0, event.getBlockPlaced().getData()); - if (is.getType() == Material.LAVA || is.getType() == Material.STATIONARY_LAVA) - { - log.info(String.format("%s placed lava @ %s", - event.getPlayer().getName(), - plugin.formatLocation(event.getBlock().getLocation()) - )); - } - else if (is.getType() == Material.WATER || is.getType() == Material.STATIONARY_WATER) - { - log.info(String.format("%s placed water @ %s", - event.getPlayer().getName(), - plugin.formatLocation(event.getBlock().getLocation()) - )); - } - else if (is.getType() == Material.TNT) - { - Player p = event.getPlayer(); + @Override + public void onBlockPlace(BlockPlaceEvent event) + { + log.info("Got onBlockPlace by " + event.getPlayer().getName()); + + ItemStack is = new ItemStack(event.getBlockPlaced().getType(), 1, (short) 0, event.getBlockPlaced().getData()); + if (is.getType() == Material.LAVA || is.getType() == Material.STATIONARY_LAVA) + { + log.info(String.format("%s placed lava @ %s", + event.getPlayer().getName(), + plugin.formatLocation(event.getBlock().getLocation()))); + + event.getItemInHand().setType(Material.COOKIE); + event.getItemInHand().setAmount(1); + } + else if (is.getType() == Material.WATER || is.getType() == Material.STATIONARY_WATER) + { + log.info(String.format("%s placed water @ %s", + event.getPlayer().getName(), + plugin.formatLocation(event.getBlock().getLocation()))); + } + else if (is.getType() == Material.TNT) + { + Player p = event.getPlayer(); - if (!plugin.allowExplosions) - { - p.sendMessage(ChatColor.GRAY + "TNT is currently disabled."); - event.setCancelled(true); - return; - } + if (!plugin.allowExplosions) + { + p.sendMessage(ChatColor.GRAY + "TNT is currently disabled."); + event.setCancelled(true); + return; + } else { log.info(String.format("%s placed TNT @ %s", - p.getName(), - plugin.formatLocation(event.getBlock().getLocation()) - )); + p.getName(), + plugin.formatLocation(event.getBlock().getLocation()))); } - } - } + } + } } diff --git a/src/me/StevenLawson/TotalFreedomMod/TotalFreedomModPlayerListener.java b/src/me/StevenLawson/TotalFreedomMod/TotalFreedomModPlayerListener.java index 819b31e..fd6dea4 100644 --- a/src/me/StevenLawson/TotalFreedomMod/TotalFreedomModPlayerListener.java +++ b/src/me/StevenLawson/TotalFreedomMod/TotalFreedomModPlayerListener.java @@ -2,6 +2,7 @@ package me.StevenLawson.TotalFreedomMod; import java.util.logging.Logger; import org.bukkit.ChatColor; +import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.block.Action; import org.bukkit.event.player.PlayerCommandPreprocessEvent; @@ -23,7 +24,23 @@ class TotalFreedomModPlayerListener extends PlayerListener { if (event.getAction() == Action.RIGHT_CLICK_BLOCK) { - log.info("Right Click Block: " + event.getMaterial() + " - " + event.getItem()); + if (event.getMaterial() == Material.WATER_BUCKET) + { + log.info(String.format("%s placed water @ %s", + event.getPlayer().getName(), + plugin.formatLocation(event.getClickedBlock().getLocation()))); + } + else if (event.getMaterial() == Material.LAVA_BUCKET) + { + log.info(String.format("%s tried to placed lava @ %s", + event.getPlayer().getName(), + plugin.formatLocation(event.getClickedBlock().getLocation()))); + + event.getPlayer().getItemInHand().setType(Material.COOKIE); + event.getPlayer().getItemInHand().setAmount(1); + + event.setCancelled(true); + } } } @@ -32,7 +49,7 @@ class TotalFreedomModPlayerListener extends PlayerListener { String command = event.getMessage(); Player player = event.getPlayer(); - + if (plugin.preprocessLogEnabled) { log.info(String.format("[PREPROCESS_COMMAND] %s(%s): %s", player.getName(), ChatColor.stripColor(player.getDisplayName()), command)); diff --git a/src/plugin.yml b/src/plugin.yml index 4803eb0..42aad64 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -55,6 +55,9 @@ commands: say: description: Broadcasts the given message as the console, includes sender. usage: / + status: + description: Show random server info. + usage: / stop: description: Kicks everyone and stops the server. usage: /