forked from LogBlock/LogBlock
@@ -3,9 +3,12 @@ package de.diddiz.LogBlock;
|
|||||||
import static de.diddiz.util.MaterialName.materialName;
|
import static de.diddiz.util.MaterialName.materialName;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
|
||||||
|
import de.diddiz.util.BukkitUtils;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
|
||||||
import de.diddiz.LogBlock.config.Config;
|
import de.diddiz.LogBlock.config.Config;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
|
||||||
public class BlockChange implements LookupCacheElement
|
public class BlockChange implements LookupCacheElement
|
||||||
{
|
{
|
||||||
@@ -64,18 +67,31 @@ public class BlockChange implements LookupCacheElement
|
|||||||
msg.append("took ").append(-ca.itemAmount).append("x ").append(materialName(ca.itemType, ca.itemData));
|
msg.append("took ").append(-ca.itemAmount).append("x ").append(materialName(ca.itemType, ca.itemData));
|
||||||
else
|
else
|
||||||
msg.append("put in ").append(ca.itemAmount).append("x ").append(materialName(ca.itemType, ca.itemData));
|
msg.append("put in ").append(ca.itemAmount).append("x ").append(materialName(ca.itemType, ca.itemData));
|
||||||
} else if (type == 23 || type == 54 || type == 61 || type == 62)
|
} else if (BukkitUtils.getContainerBlocks().contains(Material.getMaterial(type)))
|
||||||
msg.append("opened ").append(materialName(type));
|
msg.append("opened ").append(materialName(type));
|
||||||
else if (type == 64 || type == 71 || type == 96 || type == 107)
|
else if (type == 64 || type == 71)
|
||||||
msg.append(data == 0 ? "opened" : "closed").append(" ").append(materialName(type));
|
// This is a problem that will have to be addressed in LB 2,
|
||||||
|
// there is no way to tell from the top half of the block if
|
||||||
|
// the door is opened or closed.
|
||||||
|
msg.append("moved ").append(materialName(type));
|
||||||
|
// Trapdoor
|
||||||
|
else if (type == 96)
|
||||||
|
msg.append((data < 8 || data > 11) ? "opened" : "closed").append(" ").append(materialName(type));
|
||||||
|
// Fence gate
|
||||||
|
else if (type == 107)
|
||||||
|
msg.append(data > 3 ? "opened" : "closed").append(" ").append(materialName(type));
|
||||||
else if (type == 69)
|
else if (type == 69)
|
||||||
msg.append("switched ").append(materialName(type));
|
msg.append("switched ").append(materialName(type));
|
||||||
else if (type == 77 || type == 143)
|
else if (type == 77 || type == 143)
|
||||||
msg.append("pressed ").append(materialName(type));
|
msg.append("pressed ").append(materialName(type));
|
||||||
else if (type == 92)
|
else if (type == 92)
|
||||||
msg.append("ate a piece of ").append(materialName(type));
|
msg.append("ate a piece of ").append(materialName(type));
|
||||||
else if (type == 25 || type == 93 || type == 94)
|
else if (type == 25 || type == 93 || type == 94 || type == 149 || type == 150)
|
||||||
msg.append("changed ").append(materialName(type));
|
msg.append("changed ").append(materialName(type));
|
||||||
|
else if (type == 70 || type == 72 || type == 147 || type == 148)
|
||||||
|
msg.append("stepped on ").append(materialName(type));
|
||||||
|
else if (type == 132)
|
||||||
|
msg.append("ran into ").append(materialName(type));
|
||||||
} else if (type == 0)
|
} else if (type == 0)
|
||||||
msg.append("destroyed ").append(materialName(replaced, data));
|
msg.append("destroyed ").append(materialName(replaced, data));
|
||||||
else if (replaced == 0)
|
else if (replaced == 0)
|
||||||
|
@@ -149,8 +149,11 @@ public class LogBlock extends JavaPlugin
|
|||||||
if (isLogging(Logging.CHESTACCESS)) {
|
if (isLogging(Logging.CHESTACCESS)) {
|
||||||
pm.registerEvents(new ChestAccessLogging(this), this);
|
pm.registerEvents(new ChestAccessLogging(this), this);
|
||||||
}
|
}
|
||||||
if (isLogging(Logging.SWITCHINTERACT) || isLogging(Logging.DOORINTERACT) || isLogging(Logging.CAKEEAT) || isLogging(Logging.DIODEINTERACT) || isLogging(Logging.NOTEBLOCKINTERACT))
|
if (isLogging(Logging.SWITCHINTERACT) || isLogging(Logging.DOORINTERACT) || isLogging(Logging.CAKEEAT) || isLogging(Logging.DIODEINTERACT) || isLogging(Logging.COMPARATORINTERACT) || isLogging(Logging.NOTEBLOCKINTERACT) || isLogging(Logging.PRESUREPLATEINTERACT) || isLogging(Logging.TRIPWIREINTERACT) || isLogging(Logging.CROPTRAMPLE))
|
||||||
pm.registerEvents(new InteractLogging(this), this);
|
pm.registerEvents(new InteractLogging(this), this);
|
||||||
|
if (isLogging(Logging.CREATURECROPTRAMPLE)) {
|
||||||
|
pm.registerEvents(new CreatureInteractLogging(this), this);
|
||||||
|
}
|
||||||
if (isLogging(Logging.KILL))
|
if (isLogging(Logging.KILL))
|
||||||
pm.registerEvents(new KillLogging(this), this);
|
pm.registerEvents(new KillLogging(this), this);
|
||||||
if (isLogging(Logging.CHAT))
|
if (isLogging(Logging.CHAT))
|
||||||
@@ -161,6 +164,8 @@ public class LogBlock extends JavaPlugin
|
|||||||
pm.registerEvents(new WitherLogging(this), this);
|
pm.registerEvents(new WitherLogging(this), this);
|
||||||
if (isLogging(Logging.NATURALSTRUCTUREGROW) || isLogging(Logging.BONEMEALSTRUCTUREGROW))
|
if (isLogging(Logging.NATURALSTRUCTUREGROW) || isLogging(Logging.BONEMEALSTRUCTUREGROW))
|
||||||
pm.registerEvents(new StructureGrowLogging(this), this);
|
pm.registerEvents(new StructureGrowLogging(this), this);
|
||||||
|
if (isLogging(Logging.GRASSGROWTH) || isLogging(Logging.MYCELIUMSPREAD) || isLogging(Logging.VINEGROWTH) || isLogging(Logging.MUSHROOMSPREAD))
|
||||||
|
pm.registerEvents(new BlockSpreadLogging(this), this);
|
||||||
if (logPlayerInfo)
|
if (logPlayerInfo)
|
||||||
pm.registerEvents(new PlayerInfoLogging(this), this);
|
pm.registerEvents(new PlayerInfoLogging(this), this);
|
||||||
}
|
}
|
||||||
|
@@ -5,9 +5,12 @@ public enum Logging
|
|||||||
BLOCKPLACE(true), BLOCKBREAK(true), SIGNTEXT, TNTEXPLOSION(true), CREEPEREXPLOSION(true),
|
BLOCKPLACE(true), BLOCKBREAK(true), SIGNTEXT, TNTEXPLOSION(true), CREEPEREXPLOSION(true),
|
||||||
GHASTFIREBALLEXPLOSION(true), ENDERDRAGON(true), MISCEXPLOSION, FIRE(true), LEAVESDECAY,
|
GHASTFIREBALLEXPLOSION(true), ENDERDRAGON(true), MISCEXPLOSION, FIRE(true), LEAVESDECAY,
|
||||||
LAVAFLOW, WATERFLOW, CHESTACCESS, KILL, CHAT, SNOWFORM, SNOWFADE, DOORINTERACT,
|
LAVAFLOW, WATERFLOW, CHESTACCESS, KILL, CHAT, SNOWFORM, SNOWFADE, DOORINTERACT,
|
||||||
SWITCHINTERACT, CAKEEAT, ENDERMEN, NOTEBLOCKINTERACT, DIODEINTERACT, NATURALSTRUCTUREGROW,
|
SWITCHINTERACT, CAKEEAT, ENDERMEN, NOTEBLOCKINTERACT, DIODEINTERACT, COMPARATORINTERACT,
|
||||||
WITHER(true), WITHER_SKULL(true),
|
PRESUREPLATEINTERACT, TRIPWIREINTERACT, CREATURECROPTRAMPLE, CROPTRAMPLE,
|
||||||
BONEMEALSTRUCTUREGROW, WORLDEDIT, TNTMINECARTEXPLOSION(true);
|
NATURALSTRUCTUREGROW, GRASSGROWTH, MYCELIUMSPREAD, VINEGROWTH, MUSHROOMSPREAD,
|
||||||
|
WITHER(true), WITHER_SKULL(true), BONEMEALSTRUCTUREGROW,
|
||||||
|
WORLDEDIT, TNTMINECARTEXPLOSION(true);
|
||||||
|
|
||||||
public static final int length = Logging.values().length;
|
public static final int length = Logging.values().length;
|
||||||
private final boolean defaultEnabled;
|
private final boolean defaultEnabled;
|
||||||
|
|
||||||
|
@@ -209,11 +209,6 @@ public class WorldEditor implements Runnable
|
|||||||
final Block secBlock = bed.isHeadOfBed() ? block.getRelative(bed.getFacing().getOppositeFace()) : block.getRelative(bed.getFacing());
|
final Block secBlock = bed.isHeadOfBed() ? block.getRelative(bed.getFacing().getOppositeFace()) : block.getRelative(bed.getFacing());
|
||||||
if (secBlock.getTypeId() == 0 && !secBlock.setTypeIdAndData(26, (byte)(bed.getData() | 8), true))
|
if (secBlock.getTypeId() == 0 && !secBlock.setTypeIdAndData(26, (byte)(bed.getData() | 8), true))
|
||||||
throw new WorldEditorException(secBlock.getTypeId(), 26, secBlock.getLocation());
|
throw new WorldEditorException(secBlock.getTypeId(), 26, secBlock.getLocation());
|
||||||
} else if (curtype == 64 || curtype == 71) {
|
|
||||||
final byte blockData = block.getData();
|
|
||||||
final Block secBlock = (blockData & 8) == 8 ? block.getRelative(BlockFace.DOWN) : block.getRelative(BlockFace.UP);
|
|
||||||
if (secBlock.getTypeId() == 0 && !secBlock.setTypeIdAndData(curtype, (byte)(blockData | 8), true))
|
|
||||||
throw new WorldEditorException(secBlock.getTypeId(), curtype, secBlock.getLocation());
|
|
||||||
} else if ((curtype == 29 || curtype == 33) && (block.getData() & 8) > 0) {
|
} else if ((curtype == 29 || curtype == 33) && (block.getData() & 8) > 0) {
|
||||||
final PistonBaseMaterial piston = (PistonBaseMaterial)block.getState().getData();
|
final PistonBaseMaterial piston = (PistonBaseMaterial)block.getState().getData();
|
||||||
final Block secBlock = block.getRelative(piston.getFacing());
|
final Block secBlock = block.getRelative(piston.getFacing());
|
||||||
|
@@ -31,13 +31,14 @@ public class BlockBreakLogging extends LoggingListener
|
|||||||
|
|
||||||
final String playerName = event.getPlayer().getName();
|
final String playerName = event.getPlayer().getName();
|
||||||
final Block origin = event.getBlock();
|
final Block origin = event.getBlock();
|
||||||
final int type = origin.getTypeId();
|
final int typeId = origin.getTypeId();
|
||||||
|
final Material type = origin.getType();
|
||||||
|
|
||||||
if (wcfg.isLogging(Logging.SIGNTEXT) && (type == 63 || type == 68)) {
|
if (wcfg.isLogging(Logging.SIGNTEXT) && (typeId == 63 || typeId == 68)) {
|
||||||
consumer.queueSignBreak(playerName, (Sign) origin.getState());
|
consumer.queueSignBreak(playerName, (Sign) origin.getState());
|
||||||
} else if (wcfg.isLogging(Logging.CHESTACCESS) && (type == 23 || type == 54 || type == 61)) {
|
} else if (wcfg.isLogging(Logging.CHESTACCESS) && BukkitUtils.getContainerBlocks().contains(type)) {
|
||||||
consumer.queueContainerBreak(playerName, origin.getState());
|
consumer.queueContainerBreak(playerName, origin.getState());
|
||||||
} else if (origin.getType() == Material.ICE) {
|
} else if (type == Material.ICE) {
|
||||||
// When in creative mode ice doesn't form water
|
// When in creative mode ice doesn't form water
|
||||||
if (event.getPlayer().getGameMode().equals(GameMode.CREATIVE)) {
|
if (event.getPlayer().getGameMode().equals(GameMode.CREATIVE)) {
|
||||||
consumer.queueBlockBreak(playerName, origin.getState());
|
consumer.queueBlockBreak(playerName, origin.getState());
|
||||||
|
@@ -0,0 +1,52 @@
|
|||||||
|
package de.diddiz.LogBlock.listeners;
|
||||||
|
|
||||||
|
import de.diddiz.LogBlock.LogBlock;
|
||||||
|
import de.diddiz.LogBlock.Logging;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.block.BlockSpreadEvent;
|
||||||
|
|
||||||
|
import static de.diddiz.LogBlock.config.Config.isLogging;
|
||||||
|
|
||||||
|
public class BlockSpreadLogging extends LoggingListener
|
||||||
|
{
|
||||||
|
|
||||||
|
public BlockSpreadLogging(LogBlock lb) {
|
||||||
|
super(lb);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
|
public void onBlockSpread(BlockSpreadEvent event) {
|
||||||
|
|
||||||
|
String name;
|
||||||
|
|
||||||
|
World world = event.getBlock().getWorld();
|
||||||
|
Material type = event.getSource().getType();
|
||||||
|
|
||||||
|
switch (type) {
|
||||||
|
case GRASS:
|
||||||
|
if (!isLogging(world, Logging.GRASSGROWTH)) return;
|
||||||
|
name = "GrassGrowth";
|
||||||
|
break;
|
||||||
|
case MYCEL:
|
||||||
|
if (!isLogging(world, Logging.MYCELIUMSPREAD)) return;
|
||||||
|
name = "MyceliumSpread";
|
||||||
|
break;
|
||||||
|
case VINE:
|
||||||
|
if (!isLogging(world, Logging.VINEGROWTH)) return;
|
||||||
|
name = "VineGrowth";
|
||||||
|
break;
|
||||||
|
case RED_MUSHROOM:
|
||||||
|
case BROWN_MUSHROOM:
|
||||||
|
if (!isLogging(world, Logging.MUSHROOMSPREAD)) return;
|
||||||
|
name = "MushroomSpread";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
consumer.queueBlockReplace(name, event.getBlock().getState(), event.getNewState());
|
||||||
|
}
|
||||||
|
}
|
@@ -1,5 +1,6 @@
|
|||||||
package de.diddiz.LogBlock.listeners;
|
package de.diddiz.LogBlock.listeners;
|
||||||
|
|
||||||
|
import static de.diddiz.LogBlock.config.Config.isLogging;
|
||||||
import static de.diddiz.util.BukkitUtils.compareInventories;
|
import static de.diddiz.util.BukkitUtils.compareInventories;
|
||||||
import static de.diddiz.util.BukkitUtils.compressInventory;
|
import static de.diddiz.util.BukkitUtils.compressInventory;
|
||||||
import static de.diddiz.util.BukkitUtils.getInventoryHolderLocation;
|
import static de.diddiz.util.BukkitUtils.getInventoryHolderLocation;
|
||||||
@@ -7,6 +8,8 @@ import static de.diddiz.util.BukkitUtils.getInventoryHolderType;
|
|||||||
import static de.diddiz.util.BukkitUtils.rawData;
|
import static de.diddiz.util.BukkitUtils.rawData;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import de.diddiz.LogBlock.Logging;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.block.BlockState;
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.block.DoubleChest;
|
import org.bukkit.block.DoubleChest;
|
||||||
@@ -29,6 +32,8 @@ public class ChestAccessLogging extends LoggingListener
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
public void onInventoryClose(InventoryCloseEvent event) {
|
public void onInventoryClose(InventoryCloseEvent event) {
|
||||||
|
|
||||||
|
if (!isLogging(event.getPlayer().getWorld(), Logging.CHESTACCESS)) return;
|
||||||
InventoryHolder holder = event.getInventory().getHolder();
|
InventoryHolder holder = event.getInventory().getHolder();
|
||||||
if (holder instanceof BlockState || holder instanceof DoubleChest) {
|
if (holder instanceof BlockState || holder instanceof DoubleChest) {
|
||||||
final HumanEntity player = event.getPlayer();
|
final HumanEntity player = event.getPlayer();
|
||||||
@@ -47,6 +52,8 @@ public class ChestAccessLogging extends LoggingListener
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
public void onInventoryOpen(InventoryOpenEvent event) {
|
public void onInventoryOpen(InventoryOpenEvent event) {
|
||||||
|
|
||||||
|
if (!isLogging(event.getPlayer().getWorld(), Logging.CHESTACCESS)) return;
|
||||||
if (event.getInventory() != null) {
|
if (event.getInventory() != null) {
|
||||||
InventoryHolder holder = event.getInventory().getHolder();
|
InventoryHolder holder = event.getInventory().getHolder();
|
||||||
if (holder instanceof BlockState || holder instanceof DoubleChest) {
|
if (holder instanceof BlockState || holder instanceof DoubleChest) {
|
||||||
|
@@ -0,0 +1,57 @@
|
|||||||
|
package de.diddiz.LogBlock.listeners;
|
||||||
|
|
||||||
|
import de.diddiz.LogBlock.LogBlock;
|
||||||
|
import de.diddiz.LogBlock.Logging;
|
||||||
|
import de.diddiz.LogBlock.config.WorldConfig;
|
||||||
|
import de.diddiz.util.BukkitUtils;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.BlockFace;
|
||||||
|
import org.bukkit.entity.EntityType;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.entity.EntityInteractEvent;
|
||||||
|
|
||||||
|
import static de.diddiz.LogBlock.config.Config.getWorldConfig;
|
||||||
|
|
||||||
|
public class CreatureInteractLogging extends LoggingListener
|
||||||
|
{
|
||||||
|
public CreatureInteractLogging(LogBlock lb) {
|
||||||
|
super(lb);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
|
public void onEntityInteract(EntityInteractEvent event) {
|
||||||
|
final WorldConfig wcfg = getWorldConfig(event.getEntity().getWorld());
|
||||||
|
|
||||||
|
final EntityType entityType = event.getEntityType();
|
||||||
|
|
||||||
|
// Mobs only
|
||||||
|
if (event.getEntity() instanceof Player || entityType == null) return;
|
||||||
|
|
||||||
|
if (wcfg != null) {
|
||||||
|
final Block clicked = event.getBlock();
|
||||||
|
final Material type = clicked.getType();
|
||||||
|
final int typeId = type.getId();
|
||||||
|
final byte blockData = clicked.getData();
|
||||||
|
final Location loc = clicked.getLocation();
|
||||||
|
|
||||||
|
switch (type) {
|
||||||
|
case SOIL:
|
||||||
|
if (wcfg.isLogging(Logging.CREATURECROPTRAMPLE)) {
|
||||||
|
// 3 = Dirt ID
|
||||||
|
consumer.queueBlock(entityType.getName(), loc, typeId, 3, blockData);
|
||||||
|
// Log the crop on top as being broken
|
||||||
|
Block trampledCrop = clicked.getRelative(BlockFace.UP);
|
||||||
|
if (BukkitUtils.getCropBlocks().contains(trampledCrop.getType())) {
|
||||||
|
consumer.queueBlockBreak("CreatureTrample", trampledCrop.getState());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@@ -1,8 +1,12 @@
|
|||||||
package de.diddiz.LogBlock.listeners;
|
package de.diddiz.LogBlock.listeners;
|
||||||
|
|
||||||
import static de.diddiz.LogBlock.config.Config.getWorldConfig;
|
import static de.diddiz.LogBlock.config.Config.getWorldConfig;
|
||||||
|
|
||||||
|
import de.diddiz.util.BukkitUtils;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.BlockFace;
|
||||||
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,34 +25,33 @@ public class InteractLogging extends LoggingListener
|
|||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
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) {
|
||||||
final Material type = event.getClickedBlock().getType();
|
final Block clicked = event.getClickedBlock();
|
||||||
|
final Material type = clicked.getType();
|
||||||
final int typeId = type.getId();
|
final int typeId = type.getId();
|
||||||
final byte blockData = event.getClickedBlock().getData();
|
final byte blockData = clicked.getData();
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
final Location loc = event.getClickedBlock().getLocation();
|
final Location loc = clicked.getLocation();
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case LEVER:
|
case LEVER:
|
||||||
case WOOD_BUTTON:
|
case WOOD_BUTTON:
|
||||||
case STONE_BUTTON:
|
case STONE_BUTTON:
|
||||||
if (wcfg.isLogging(Logging.SWITCHINTERACT))
|
if (wcfg.isLogging(Logging.SWITCHINTERACT) && event.getAction() == Action.RIGHT_CLICK_BLOCK)
|
||||||
consumer.queueBlock(player.getName(), loc, typeId, typeId, blockData);
|
consumer.queueBlock(player.getName(), loc, typeId, typeId, blockData);
|
||||||
break;
|
break;
|
||||||
case FENCE_GATE:
|
case FENCE_GATE:
|
||||||
if (event.getAction() != Action.RIGHT_CLICK_BLOCK)
|
|
||||||
break;
|
|
||||||
case WOODEN_DOOR:
|
case WOODEN_DOOR:
|
||||||
case TRAP_DOOR:
|
case TRAP_DOOR:
|
||||||
if (wcfg.isLogging(Logging.DOORINTERACT))
|
if (wcfg.isLogging(Logging.DOORINTERACT) && event.getAction() == Action.RIGHT_CLICK_BLOCK)
|
||||||
consumer.queueBlock(player.getName(), loc, typeId, typeId, blockData);
|
consumer.queueBlock(player.getName(), loc, typeId, typeId, blockData);
|
||||||
break;
|
break;
|
||||||
case CAKE_BLOCK:
|
case CAKE_BLOCK:
|
||||||
if (wcfg.isLogging(Logging.CAKEEAT) && player.getFoodLevel() < 20)
|
if (wcfg.isLogging(Logging.CAKEEAT) && event.getAction() == Action.RIGHT_CLICK_BLOCK && player.getFoodLevel() < 20)
|
||||||
consumer.queueBlock(player.getName(), loc, typeId, typeId, blockData);
|
consumer.queueBlock(player.getName(), loc, typeId, typeId, blockData);
|
||||||
break;
|
break;
|
||||||
case NOTE_BLOCK:
|
case NOTE_BLOCK:
|
||||||
if (wcfg.isLogging(Logging.NOTEBLOCKINTERACT))
|
if (wcfg.isLogging(Logging.NOTEBLOCKINTERACT) && event.getAction() == Action.RIGHT_CLICK_BLOCK)
|
||||||
consumer.queueBlock(player.getName(), loc, typeId, typeId, blockData);
|
consumer.queueBlock(player.getName(), loc, typeId, typeId, blockData);
|
||||||
break;
|
break;
|
||||||
case DIODE_BLOCK_OFF:
|
case DIODE_BLOCK_OFF:
|
||||||
@@ -56,6 +59,36 @@ public class InteractLogging extends LoggingListener
|
|||||||
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, typeId, typeId, blockData);
|
consumer.queueBlock(player.getName(), loc, typeId, typeId, blockData);
|
||||||
break;
|
break;
|
||||||
|
case REDSTONE_COMPARATOR_OFF:
|
||||||
|
case REDSTONE_COMPARATOR_ON:
|
||||||
|
if (wcfg.isLogging(Logging.COMPARATORINTERACT) && event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||||
|
consumer.queueBlock(player.getName(), loc, typeId, typeId, blockData);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case WOOD_PLATE:
|
||||||
|
case STONE_PLATE:
|
||||||
|
case IRON_PLATE:
|
||||||
|
case GOLD_PLATE:
|
||||||
|
if (wcfg.isLogging(Logging.PRESUREPLATEINTERACT) && event.getAction() == Action.PHYSICAL) {
|
||||||
|
consumer.queueBlock(player.getName(), loc, typeId, typeId, blockData);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case TRIPWIRE:
|
||||||
|
if (wcfg.isLogging(Logging.TRIPWIREINTERACT) && event.getAction() == Action.PHYSICAL) {
|
||||||
|
consumer.queueBlock(player.getName(), loc, typeId, typeId, blockData);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SOIL:
|
||||||
|
if (wcfg.isLogging(Logging.CROPTRAMPLE) && event.getAction() == Action.PHYSICAL) {
|
||||||
|
// 3 = Dirt ID
|
||||||
|
consumer.queueBlock(player.getName(), loc, typeId, 3, blockData);
|
||||||
|
// Log the crop on top as being broken
|
||||||
|
Block trampledCrop = clicked.getRelative(BlockFace.UP);
|
||||||
|
if (BukkitUtils.getCropBlocks().contains(trampledCrop.getType())) {
|
||||||
|
consumer.queueBlockBreak(player.getName(), trampledCrop.getState());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -45,7 +45,12 @@ public class ToolListener implements Listener
|
|||||||
final int type = event.getMaterial().getId();
|
final int type = event.getMaterial().getId();
|
||||||
final Tool tool = toolsByType.get(type);
|
final Tool tool = toolsByType.get(type);
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
if (tool != null && (action == Action.RIGHT_CLICK_BLOCK || action == Action.LEFT_CLICK_BLOCK) && isLogged(player.getWorld()) && logblock.hasPermission(player, "logblock.tools." + tool.name)) {
|
if (tool != null && (action == Action.RIGHT_CLICK_BLOCK || action == Action.LEFT_CLICK_BLOCK) && logblock.hasPermission(player, "logblock.tools." + tool.name)) {
|
||||||
|
if (!isLogged(player.getWorld())) {
|
||||||
|
player.sendMessage(ChatColor.RED + "This world is not currently logged.");
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
final ToolBehavior behavior = action == Action.RIGHT_CLICK_BLOCK ? tool.rightClickBehavior : tool.leftClickBehavior;
|
final ToolBehavior behavior = action == Action.RIGHT_CLICK_BLOCK ? tool.rightClickBehavior : tool.leftClickBehavior;
|
||||||
final ToolData toolData = getSession(player).toolData.get(tool);
|
final ToolData toolData = getSession(player).toolData.get(tool);
|
||||||
if (behavior != ToolBehavior.NONE && toolData.enabled) {
|
if (behavior != ToolBehavior.NONE && toolData.enabled) {
|
||||||
|
@@ -32,6 +32,9 @@ public class BukkitUtils
|
|||||||
private static final Set<Material> relativeTopFallables;
|
private static final Set<Material> relativeTopFallables;
|
||||||
private static final Set<Material> fallingEntityKillers;
|
private static final Set<Material> fallingEntityKillers;
|
||||||
|
|
||||||
|
private static final Set<Material> cropBlocks;
|
||||||
|
private static final Set<Material> containerBlocks;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
blockEquivalents = new HashSet<Set<Integer>>(7);
|
blockEquivalents = new HashSet<Set<Integer>>(7);
|
||||||
blockEquivalents.add(new HashSet<Integer>(Arrays.asList(2, 3, 60)));
|
blockEquivalents.add(new HashSet<Integer>(Arrays.asList(2, 3, 60)));
|
||||||
@@ -130,6 +133,25 @@ public class BukkitUtils
|
|||||||
fallingEntityKillers.add(Material.REDSTONE_COMPARATOR_ON);
|
fallingEntityKillers.add(Material.REDSTONE_COMPARATOR_ON);
|
||||||
fallingEntityKillers.add(Material.REDSTONE_COMPARATOR_OFF);
|
fallingEntityKillers.add(Material.REDSTONE_COMPARATOR_OFF);
|
||||||
fallingEntityKillers.add(Material.DAYLIGHT_DETECTOR);
|
fallingEntityKillers.add(Material.DAYLIGHT_DETECTOR);
|
||||||
|
|
||||||
|
// Crop Blocks
|
||||||
|
cropBlocks = new HashSet<Material>(5);
|
||||||
|
cropBlocks.add(Material.CROPS);
|
||||||
|
cropBlocks.add(Material.MELON_STEM);
|
||||||
|
cropBlocks.add(Material.PUMPKIN_STEM);
|
||||||
|
cropBlocks.add(Material.CARROT);
|
||||||
|
cropBlocks.add(Material.POTATO);
|
||||||
|
|
||||||
|
// Container Blocks
|
||||||
|
containerBlocks = new HashSet<Material>(6);
|
||||||
|
containerBlocks.add(Material.CHEST);
|
||||||
|
containerBlocks.add(Material.TRAPPED_CHEST);
|
||||||
|
containerBlocks.add(Material.DISPENSER);
|
||||||
|
containerBlocks.add(Material.DROPPER);
|
||||||
|
containerBlocks.add(Material.HOPPER);
|
||||||
|
containerBlocks.add(Material.BREWING_STAND);
|
||||||
|
// Doesn't actually have a block inventory
|
||||||
|
// containerBlocks.add(Material.ENDER_CHEST);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final BlockFace[] relativeBlockFaces = new BlockFace[] {
|
private static final BlockFace[] relativeBlockFaces = new BlockFace[] {
|
||||||
@@ -264,6 +286,14 @@ public class BukkitUtils
|
|||||||
return fallingEntityKillers;
|
return fallingEntityKillers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Set<Material> getCropBlocks() {
|
||||||
|
return cropBlocks;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Set<Material> getContainerBlocks() {
|
||||||
|
return containerBlocks;
|
||||||
|
}
|
||||||
|
|
||||||
public static String entityName(Entity entity) {
|
public static String entityName(Entity entity) {
|
||||||
if (entity instanceof Player)
|
if (entity instanceof Player)
|
||||||
return ((Player)entity).getName();
|
return ((Player)entity).getName();
|
||||||
|
@@ -73,6 +73,18 @@ public class LoggingUtil {
|
|||||||
if (BukkitUtils.getRelativeTopBreakabls().contains(checkBlock.getType())) {
|
if (BukkitUtils.getRelativeTopBreakabls().contains(checkBlock.getType())) {
|
||||||
if (wcfg.isLogging(Logging.SIGNTEXT) && checkBlock.getType() == Material.SIGN_POST) {
|
if (wcfg.isLogging(Logging.SIGNTEXT) && checkBlock.getType() == Material.SIGN_POST) {
|
||||||
consumer.queueSignBreak(playerName, (Sign) checkBlock.getState());
|
consumer.queueSignBreak(playerName, (Sign) checkBlock.getState());
|
||||||
|
} else if (checkBlock.getType() == Material.IRON_DOOR || checkBlock.getType() == Material.WOOD_DOOR) {
|
||||||
|
Block doorBlock = checkBlock;
|
||||||
|
// If the doorBlock is the top half a door the player simply punched a door
|
||||||
|
// this will be handled later.
|
||||||
|
if (doorBlock.getData() != 8 && doorBlock.getData() != 9) {
|
||||||
|
doorBlock = doorBlock.getRelative(BlockFace.UP);
|
||||||
|
// Fall back check just in case the top half wasn't a door
|
||||||
|
if (doorBlock.getType() == Material.IRON_DOOR || doorBlock.getType() == Material.WOOD_DOOR) {
|
||||||
|
consumer.queueBlockBreak(playerName, doorBlock.getState());
|
||||||
|
}
|
||||||
|
consumer.queueBlockBreak(playerName, checkBlock.getState());
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
consumer.queueBlockBreak(playerName, checkBlock.getState());
|
consumer.queueBlockBreak(playerName, checkBlock.getState());
|
||||||
}
|
}
|
||||||
@@ -142,6 +154,23 @@ public class LoggingUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Special door check
|
||||||
|
if (origin.getType() == Material.IRON_DOOR || origin.getType() == Material.WOOD_DOOR) {
|
||||||
|
Block doorBlock = origin;
|
||||||
|
|
||||||
|
// Up or down?
|
||||||
|
if (origin.getData() != 8 && origin.getData() != 9) {
|
||||||
|
doorBlock = doorBlock.getRelative(BlockFace.UP);
|
||||||
|
} else {
|
||||||
|
doorBlock = doorBlock.getRelative(BlockFace.DOWN);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (doorBlock.getType() == Material.IRON_DOOR || doorBlock.getType() == Material.WOOD_DOOR) {
|
||||||
|
consumer.queueBlockBreak(playerName, doorBlock.getState());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Do this down here so that the block is added after blocks sitting on it
|
// Do this down here so that the block is added after blocks sitting on it
|
||||||
consumer.queueBlockBreak(playerName, origin.getState());
|
consumer.queueBlockBreak(playerName, origin.getState());
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user