forked from LogBlock/LogBlock
Always log block data in block interact events.
Also use symbolic names instead of IDs for better readability.
This commit is contained in:
@@ -2,6 +2,7 @@ package de.diddiz.LogBlock.listeners;
|
|||||||
|
|
||||||
import static de.diddiz.LogBlock.config.Config.getWorldConfig;
|
import static de.diddiz.LogBlock.config.Config.getWorldConfig;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
@@ -21,35 +22,38 @@ public class InteractLogging extends LoggingListener
|
|||||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||||
final WorldConfig wcfg = getWorldConfig(event.getPlayer().getWorld());
|
final WorldConfig wcfg = getWorldConfig(event.getPlayer().getWorld());
|
||||||
if (wcfg != null && (event.getAction() == Action.LEFT_CLICK_BLOCK || event.getAction() == Action.RIGHT_CLICK_BLOCK)) {
|
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 Player player = event.getPlayer();
|
||||||
final Location loc = event.getClickedBlock().getLocation();
|
final Location loc = event.getClickedBlock().getLocation();
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 69:
|
case LEVER:
|
||||||
case 77:
|
case STONE_BUTTON:
|
||||||
if (wcfg.isLogging(Logging.SWITCHINTERACT))
|
if (wcfg.isLogging(Logging.SWITCHINTERACT))
|
||||||
consumer.queueBlock(player.getName(), loc, type, type, (byte)0);
|
consumer.queueBlock(player.getName(), loc, typeId, typeId, blockData);
|
||||||
break;
|
break;
|
||||||
case 107:
|
case FENCE_GATE:
|
||||||
if (event.getAction() != Action.RIGHT_CLICK_BLOCK)
|
if (event.getAction() != Action.RIGHT_CLICK_BLOCK)
|
||||||
break;
|
break;
|
||||||
case 64:
|
case WOODEN_DOOR:
|
||||||
case 96:
|
case TRAP_DOOR:
|
||||||
if (wcfg.isLogging(Logging.DOORINTERACT))
|
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;
|
break;
|
||||||
case 92:
|
case CAKE_BLOCK:
|
||||||
if (wcfg.isLogging(Logging.CAKEEAT) && player.getFoodLevel() < 20)
|
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;
|
break;
|
||||||
case 25:
|
case NOTE_BLOCK:
|
||||||
if (wcfg.isLogging(Logging.NOTEBLOCKINTERACT))
|
if (wcfg.isLogging(Logging.NOTEBLOCKINTERACT))
|
||||||
consumer.queueBlock(player.getName(), loc, 25, 25, (byte)0);
|
consumer.queueBlock(player.getName(), loc, typeId, typeId, blockData);
|
||||||
break;
|
break;
|
||||||
case 93:
|
case DIODE_BLOCK_OFF:
|
||||||
case 94:
|
case DIODE_BLOCK_ON:
|
||||||
if (wcfg.isLogging(Logging.DIODEINTERACT) && event.getAction() == Action.RIGHT_CLICK_BLOCK)
|
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;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user