Added door logging

This commit is contained in:
Robin Kupper
2011-08-22 12:56:58 +02:00
parent 73361ec1c1
commit 14a39dff07
4 changed files with 14 additions and 6 deletions

View File

@@ -61,11 +61,13 @@ public class BlockChange implements LookupCacheElement
if (ca.itemType == 0 || ca.itemAmount == 0)
msg.append("looked inside " + materialName(type));
else if (ca.itemAmount < 0)
msg.append("took " + ca.itemAmount * -1 + "x " + materialName(ca.itemType, ca.itemData));
msg.append("took " + -ca.itemAmount + "x " + materialName(ca.itemType, ca.itemData));
else
msg.append("put in " + ca.itemAmount + "x " + materialName(ca.itemType, ca.itemData));
} else if (type == 23 || type == 54 || type == 61 || type == 62)
msg.append("opened " + materialName(type));
else if (type == 64 || type == 71 || type == 96)
msg.append((data == 0 ? "opened" : "closed") + " " + materialName(type));
else if (type == 69)
msg.append("swiched " + materialName(type));
else if (type == 77)

View File

@@ -25,7 +25,7 @@ public class Config
public final boolean useBukkitScheduler;
public final int keepLogDays;
public final boolean dumpDeletedLog;
public boolean logBlockPlacings, logBlockBreaks, logSignTexts, logExplosions, logFire, logLeavesDecay, logLavaFlow, logWaterFlow, logChestAccess, logButtonsAndLevers, logKills, logChat, logSnowForm, logSnowFade;
public boolean logBlockPlacings, logBlockBreaks, logSignTexts, logExplosions, logFire, logLeavesDecay, logLavaFlow, logWaterFlow, logChestAccess, logButtonsAndLevers, logKills, logChat, logSnowForm, logSnowFade, logDoors;
public final boolean logCreeperExplosionsAsPlayerWhoTriggeredThese;
public final LogKillsLevel logKillsLevel;
public final Set<Integer> dontRollback, replaceAnyway;
@@ -178,6 +178,8 @@ public class Config
logSnowForm = true;
if (wcfg.logSnowFade)
logSnowFade = true;
if (wcfg.logDoors)
logDoors = true;
}
}
}
@@ -185,7 +187,7 @@ public class Config
class WorldConfig
{
public final String table;
public final boolean logBlockPlacings, logBlockBreaks, logSignTexts, logExplosions, logFire, logLeavesDecay, logLavaFlow, logWaterFlow, logChestAccess, logButtonsAndLevers, logKills, logChat, logSnowForm, logSnowFade;
public final boolean logBlockPlacings, logBlockBreaks, logSignTexts, logExplosions, logFire, logLeavesDecay, logLavaFlow, logWaterFlow, logChestAccess, logButtonsAndLevers, logKills, logChat, logSnowForm, logSnowFade, logDoors;
public WorldConfig(File file) {
final Map<String, Object> def = new HashMap<String, Object>();
@@ -204,6 +206,7 @@ class WorldConfig
def.put("logChat", false);
def.put("logSnowForm", false);
def.put("logSnowFade", false);
def.put("logDoors", false);
final Configuration config = new Configuration(file);
config.load();
for (final Entry<String, Object> e : def.entrySet())
@@ -225,5 +228,6 @@ class WorldConfig
logChat = config.getBoolean("logChat", false);
logSnowForm = config.getBoolean("logSnowForm", false);
logSnowFade = config.getBoolean("logSnowFade", false);
logDoors = config.getBoolean("logDoors", false);
}
}

View File

@@ -37,10 +37,12 @@ class LBPlayerListener extends PlayerListener
@Override
public void onPlayerInteract(PlayerInteractEvent event) {
final WorldConfig wcfg = worlds.get(event.getPlayer().getWorld().getName().hashCode());
if (!event.isCancelled() && wcfg != null && wcfg.logButtonsAndLevers && (event.getAction() == Action.LEFT_CLICK_BLOCK || event.getAction() == Action.RIGHT_CLICK_BLOCK)) {
if (!event.isCancelled() && wcfg != null && (event.getAction() == Action.LEFT_CLICK_BLOCK || event.getAction() == Action.RIGHT_CLICK_BLOCK)) {
final int type = event.getClickedBlock().getTypeId();
if (type == 69 || type == 77)
if (wcfg.logButtonsAndLevers && (type == 69 || type == 77))
consumer.queueBlock(event.getPlayer().getName(), event.getClickedBlock().getLocation(), type, type, (byte)0);
else if (wcfg.logDoors && (type == 64 || type == 96))
consumer.queueBlock(event.getPlayer().getName(), event.getClickedBlock().getLocation(), type, type, (byte)((event.getClickedBlock().getData() & 4) / 4));
}
}

View File

@@ -199,7 +199,7 @@ public class LogBlock extends JavaPlugin
pm.registerEvent(Type.CUSTOM_EVENT, new LBChestAccessListener(this), Priority.Monitor, this);
else
log.warning("[LogBlock] BukkitContrib not found. Can't log chest accesses.");
if (config.logButtonsAndLevers)
if (config.logButtonsAndLevers || config.logDoors)
pm.registerEvent(Type.PLAYER_INTERACT, lbPlayerListener, Priority.Monitor, this);
if (config.logKills)
pm.registerEvent(Type.ENTITY_DAMAGE, lbEntityListener, Priority.Monitor, this);