Added hiddenBlocks

This commit is contained in:
Robin Kupper
2011-06-26 13:43:12 +02:00
parent 2bddffb293
commit 6407f10705
2 changed files with 21 additions and 9 deletions

View File

@@ -25,13 +25,12 @@ public class Config
public final boolean logBlockCreations, logBlockDestroyings, logSignTexts, logExplosions, logFire, logLeavesDecay, logLavaFlow, logChestAccess, logButtonsAndLevers, logKills;
public final boolean logCreeperExplosionsAsPlayerWhoTriggeredThese;
public final LogKillsLevel logKillsLevel;
public final Set<Integer> dontRollback;
public final Set<Integer> replaceAnyway;
public final Set<Integer> dontRollback, replaceAnyway;
public final QueryParams toolQuery, toolBlockQuery;
public final int defaultDist, defaultTime;
public final int toolID, toolblockID;
public final boolean askRollbacks, askRedos, askClearLogs, askSavequeueBeforeRollback;
public final Set<Integer> hiddenPlayers;
public final Set<Integer> hiddenPlayers, hiddenBlocks;
public static enum LogKillsLevel {
PLAYERS, MONSTERS, ANIMALS
@@ -108,6 +107,8 @@ public class Config
config.setProperty("logging.logKillsLevel", "PLAYERS");
if (!subkeys.contains("hiddenPlayers"))
config.setProperty("logging.hiddenPlayers", new ArrayList<String>());
if (!subkeys.contains("hiddenBlocks"))
config.setProperty("logging.hiddenBlocks", Arrays.asList(new Integer[]{0}));
subkeys = config.getKeys("rollback");
if (subkeys == null)
subkeys = new ArrayList<String>();
@@ -173,6 +174,14 @@ public class Config
hiddenPlayers = new HashSet<Integer>();
for (final String playerName : config.getStringList("logging.hiddenPlayers", new ArrayList<String>()))
hiddenPlayers.add(playerName.hashCode());
hiddenBlocks = new HashSet<Integer>();
for (final String blocktype : config.getStringList("logging.hiddenBlocks", new ArrayList<String>())) {
final Material mat = Material.matchMaterial(blocktype);
if (mat != null)
hiddenBlocks.add(mat.getId());
else
throw new DataFormatException("Not a valid material: '" + blocktype + "'");
}
dontRollback = new HashSet<Integer>(config.getIntList("rollback.dontRollback", null));
replaceAnyway = new HashSet<Integer>(config.getIntList("rollback.replaceAnyway", null));
try {

View File

@@ -29,7 +29,7 @@ public class Consumer extends TimerTask
{
private final Queue<BlockRow> bqueue = new LinkedBlockingQueue<BlockRow>();
private final Config config;
private final Set<Integer> hiddenplayers;
private final Set<Integer> hiddenPlayers, hiddenBlocks;
private final Queue<KillRow> kqueue = new LinkedBlockingQueue<KillRow>();
private final Map<Integer, Integer> lastAttackedEntity = new HashMap<Integer, Integer>();
private final Map<Integer, Long> lastAttackTime = new HashMap<Integer, Long>();
@@ -41,7 +41,8 @@ public class Consumer extends TimerTask
this.logblock = logblock;
log = logblock.getServer().getLogger();
config = logblock.getConfig();
hiddenplayers = config.hiddenPlayers;
hiddenPlayers = config.hiddenPlayers;
hiddenBlocks = config.hiddenBlocks;
}
/**
@@ -312,11 +313,11 @@ public class Consumer extends TimerTask
boolean hide(Player player) {
final int hash = player.getName().hashCode();
if (hiddenplayers.contains(hash)) {
hiddenplayers.remove(hash);
if (hiddenPlayers.contains(hash)) {
hiddenPlayers.remove(hash);
return false;
}
hiddenplayers.add(hash);
hiddenPlayers.add(hash);
return true;
}
@@ -331,7 +332,9 @@ public class Consumer extends TimerTask
}
private void queueBlock(String playerName, Location loc, int typeBefore, int typeAfter, byte data, String signtext, ChestAccess ca) {
if (playerName == null || loc == null || typeBefore < 0 || typeAfter < 0 || hiddenplayers.contains(playerName.hashCode()) || !config.tables.containsKey(loc.getWorld().getName().hashCode()))
if (playerName == null || loc == null || typeBefore < 0 || typeAfter < 0 || hiddenPlayers.contains(playerName.hashCode()) || !config.tables.containsKey(loc.getWorld().getName().hashCode()))
return;
if (typeBefore != typeAfter && hiddenBlocks.contains(typeBefore) && hiddenBlocks.contains(typeAfter))
return;
if (playerName.length() > 32)
playerName = playerName.substring(0, 32);