This commit is contained in:
Steven Lawson 2011-09-27 11:58:00 -04:00
parent 04aaeac9c9
commit a730e9f67f
4 changed files with 89 additions and 58 deletions

View File

@ -73,13 +73,16 @@ public class TotalFreedomMod extends JavaPlugin
preprocessLogEnabled = CONFIG.getBoolean("preprocess_log", false); preprocessLogEnabled = CONFIG.getBoolean("preprocess_log", false);
PluginManager pm = this.getServer().getPluginManager(); PluginManager pm = this.getServer().getPluginManager();
pm.registerEvent(Event.Type.ENTITY_EXPLODE, entityListener, Event.Priority.High, this); 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_COMBUST, entityListener, Event.Priority.High, this);
pm.registerEvent(Event.Type.ENTITY_DAMAGE, 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.EXPLOSION_PRIME, entityListener, Event.Priority.High, this);
pm.registerEvent(Event.Type.BLOCK_IGNITE, blockListener, 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_BURN, blockListener, Event.Priority.High, this);
pm.registerEvent(Event.Type.BLOCK_PLACE, 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_COMMAND_PREPROCESS, playerListener, Event.Priority.High, this);
pm.registerEvent(Event.Type.PLAYER_INTERACT, 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); onlineUsers.append(ChatColor.WHITE);
} }
} }
sender.sendMessage(onlineStats.toString()); sender.sendMessage(onlineStats.toString());
sender.sendMessage(onlineUsers.toString()); sender.sendMessage(onlineUsers.toString());
@ -748,6 +751,12 @@ public class TotalFreedomMod extends JavaPlugin
sender.sendMessage(MSG_NO_PERMS); 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; return true;
} }
} }

View File

@ -12,69 +12,71 @@ import org.bukkit.inventory.ItemStack;
public class TotalFreedomModBlockListener extends BlockListener public class TotalFreedomModBlockListener extends BlockListener
{ {
public static TotalFreedomMod plugin; public static TotalFreedomMod plugin;
private static final Logger log = Logger.getLogger("Minecraft"); private static final Logger log = Logger.getLogger("Minecraft");
TotalFreedomModBlockListener(TotalFreedomMod instance) TotalFreedomModBlockListener(TotalFreedomMod instance)
{ {
plugin = instance; plugin = instance;
} }
@Override @Override
public void onBlockBurn(BlockBurnEvent event) public void onBlockBurn(BlockBurnEvent event)
{ {
if (!plugin.allowFire) if (!plugin.allowFire)
{ {
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
} }
@Override @Override
public void onBlockIgnite(BlockIgniteEvent event) public void onBlockIgnite(BlockIgniteEvent event)
{ {
if (!plugin.allowFire) if (!plugin.allowFire)
{ {
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
} }
@Override @Override
public void onBlockPlace(BlockPlaceEvent event) public void onBlockPlace(BlockPlaceEvent event)
{ {
ItemStack is = new ItemStack(event.getBlockPlaced().getType(), 1, (short) 0, event.getBlockPlaced().getData()); log.info("Got onBlockPlace by " + event.getPlayer().getName());
if (is.getType() == Material.LAVA || is.getType() == Material.STATIONARY_LAVA)
{ ItemStack is = new ItemStack(event.getBlockPlaced().getType(), 1, (short) 0, event.getBlockPlaced().getData());
log.info(String.format("%s placed lava @ %s", if (is.getType() == Material.LAVA || is.getType() == Material.STATIONARY_LAVA)
event.getPlayer().getName(), {
plugin.formatLocation(event.getBlock().getLocation()) 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)
{ event.getItemInHand().setType(Material.COOKIE);
log.info(String.format("%s placed water @ %s", event.getItemInHand().setAmount(1);
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",
else if (is.getType() == Material.TNT) event.getPlayer().getName(),
{ plugin.formatLocation(event.getBlock().getLocation())));
Player p = event.getPlayer(); }
else if (is.getType() == Material.TNT)
{
Player p = event.getPlayer();
if (!plugin.allowExplosions) if (!plugin.allowExplosions)
{ {
p.sendMessage(ChatColor.GRAY + "TNT is currently disabled."); p.sendMessage(ChatColor.GRAY + "TNT is currently disabled.");
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
else else
{ {
log.info(String.format("%s placed TNT @ %s", log.info(String.format("%s placed TNT @ %s",
p.getName(), p.getName(),
plugin.formatLocation(event.getBlock().getLocation()) plugin.formatLocation(event.getBlock().getLocation())));
));
} }
} }
} }
} }

View File

@ -2,6 +2,7 @@ package me.StevenLawson.TotalFreedomMod;
import java.util.logging.Logger; import java.util.logging.Logger;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.block.Action; import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerCommandPreprocessEvent;
@ -23,7 +24,23 @@ class TotalFreedomModPlayerListener extends PlayerListener
{ {
if (event.getAction() == Action.RIGHT_CLICK_BLOCK) 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(); String command = event.getMessage();
Player player = event.getPlayer(); Player player = event.getPlayer();
if (plugin.preprocessLogEnabled) if (plugin.preprocessLogEnabled)
{ {
log.info(String.format("[PREPROCESS_COMMAND] %s(%s): %s", player.getName(), ChatColor.stripColor(player.getDisplayName()), command)); log.info(String.format("[PREPROCESS_COMMAND] %s(%s): %s", player.getName(), ChatColor.stripColor(player.getDisplayName()), command));

View File

@ -55,6 +55,9 @@ commands:
say: say:
description: Broadcasts the given message as the console, includes sender. description: Broadcasts the given message as the console, includes sender.
usage: /<command> <message> usage: /<command> <message>
status:
description: Show random server info.
usage: /<command>
stop: stop:
description: Kicks everyone and stops the server. description: Kicks everyone and stops the server.
usage: /<command> usage: /<command>