Always log block data in block interact events.

Also use symbolic names instead of IDs for better readability.
This commit is contained in:
mickael9
2012-07-20 18:56:04 +02:00
committed by md_5
parent bff2380901
commit 9eb65ba133

View File

@@ -2,6 +2,7 @@ package de.diddiz.LogBlock.listeners;
import static de.diddiz.LogBlock.config.Config.getWorldConfig;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
@@ -21,35 +22,38 @@ public class InteractLogging extends LoggingListener
public void onPlayerInteract(PlayerInteractEvent event) {
final WorldConfig wcfg = getWorldConfig(event.getPlayer().getWorld());
if (wcfg != null && (event.getAction() == Action.LEFT_CLICK_BLOCK || event.getAction() == Action.RIGHT_CLICK_BLOCK)) {
final int type = event.getClickedBlock().getTypeId();
final Material type = event.getClickedBlock().getType();
final int typeId = type.getId();
final byte blockData = event.getClickedBlock().getData();
final Player player = event.getPlayer();
final Location loc = event.getClickedBlock().getLocation();
switch (type) {
case 69:
case 77:
case LEVER:
case STONE_BUTTON:
if (wcfg.isLogging(Logging.SWITCHINTERACT))
consumer.queueBlock(player.getName(), loc, type, type, (byte)0);
consumer.queueBlock(player.getName(), loc, typeId, typeId, blockData);
break;
case 107:
case FENCE_GATE:
if (event.getAction() != Action.RIGHT_CLICK_BLOCK)
break;
case 64:
case 96:
case WOODEN_DOOR:
case TRAP_DOOR:
if (wcfg.isLogging(Logging.DOORINTERACT))
consumer.queueBlock(player.getName(), loc, type, type, (byte)((event.getClickedBlock().getData() & 4) / 4));
consumer.queueBlock(player.getName(), loc, typeId, typeId, blockData);
break;
case 92:
case CAKE_BLOCK:
if (wcfg.isLogging(Logging.CAKEEAT) && player.getFoodLevel() < 20)
consumer.queueBlock(player.getName(), loc, 92, 92, (byte)0);
consumer.queueBlock(player.getName(), loc, typeId, typeId, blockData);
break;
case 25:
case NOTE_BLOCK:
if (wcfg.isLogging(Logging.NOTEBLOCKINTERACT))
consumer.queueBlock(player.getName(), loc, 25, 25, (byte)0);
consumer.queueBlock(player.getName(), loc, typeId, typeId, blockData);
break;
case 93:
case 94:
case DIODE_BLOCK_OFF:
case DIODE_BLOCK_ON:
if (wcfg.isLogging(Logging.DIODEINTERACT) && event.getAction() == Action.RIGHT_CLICK_BLOCK)
consumer.queueBlock(player.getName(), loc, type, type, (byte)0);
consumer.queueBlock(player.getName(), loc, typeId, typeId, blockData);
break;
}
}