Added logging for dragon egg teleportation (#303)
This commit is contained in:
parent
97eb0d777b
commit
5eabee6504
2 changed files with 61 additions and 6 deletions
|
|
@ -87,6 +87,39 @@ public final class BlockFromToListener extends Queue implements Listener {
|
||||||
CacheHandler.lookupCache.put("" + x + "." + y + "." + z + "." + wid + "", new Object[] { unixtimestamp, f, type });
|
CacheHandler.lookupCache.put("" + x + "." + y + "." + z + "." + wid + "", new Object[] { unixtimestamp, f, type });
|
||||||
Queue.queueBlockPlace(f, toBlock.getState(), block.getType(), toBlockState, type, -1, 0, blockData.getAsString());
|
Queue.queueBlockPlace(f, toBlock.getState(), block.getType(), toBlockState, type, -1, 0, blockData.getAsString());
|
||||||
}
|
}
|
||||||
|
else if (type.equals(Material.DRAGON_EGG)) {
|
||||||
|
Location location = block.getLocation();
|
||||||
|
int worldId = Util.getWorldId(location.getWorld().getName());
|
||||||
|
int x = location.getBlockX();
|
||||||
|
int y = location.getBlockY();
|
||||||
|
int z = location.getBlockZ();
|
||||||
|
String coordinates = x + "." + y + "." + z + "." + worldId + "." + type.name();
|
||||||
|
String user = "#entity";
|
||||||
|
|
||||||
|
Object[] data = CacheHandler.interactCache.get(coordinates);
|
||||||
|
if (data != null && data[1] == Material.DRAGON_EGG) {
|
||||||
|
long newTime = System.currentTimeMillis();
|
||||||
|
long oldTime = (long) data[0];
|
||||||
|
|
||||||
|
if ((newTime - oldTime) < 20) { // 50ms = 1 tick
|
||||||
|
user = (String) data[2];
|
||||||
|
}
|
||||||
|
CacheHandler.interactCache.remove(coordinates);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Config.getConfig(block.getWorld()).BLOCK_BREAK) {
|
||||||
|
Queue.queueBlockBreak(user, block.getState(), block.getType(), block.getBlockData().getAsString(), 0);
|
||||||
|
}
|
||||||
|
if (Config.getConfig(block.getWorld()).BLOCK_PLACE) {
|
||||||
|
Block toBlock = event.getToBlock();
|
||||||
|
BlockState toBlockState = toBlock.getState();
|
||||||
|
if (Config.getConfig(world).BLOCK_MOVEMENT) {
|
||||||
|
toBlockState = BlockUtil.gravityScan(toBlock.getLocation(), type, user).getState();
|
||||||
|
}
|
||||||
|
|
||||||
|
Queue.queueBlockPlace(user, toBlockState, block.getType(), toBlockState, type, -1, 0, blockData.getAsString());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -528,7 +528,13 @@ public final class PlayerInteractListener extends Queue implements Listener {
|
||||||
/* Logging for players punching out fire blocks. */
|
/* Logging for players punching out fire blocks. */
|
||||||
if (event.getAction().equals(Action.LEFT_CLICK_BLOCK)) {
|
if (event.getAction().equals(Action.LEFT_CLICK_BLOCK)) {
|
||||||
World world = event.getClickedBlock().getWorld();
|
World world = event.getClickedBlock().getWorld();
|
||||||
if (event.useInteractedBlock() != Event.Result.DENY && Config.getConfig(world).BLOCK_BREAK) {
|
if (event.useInteractedBlock() != Event.Result.DENY) {
|
||||||
|
Block block = event.getClickedBlock();
|
||||||
|
if (block.getType() == Material.DRAGON_EGG) {
|
||||||
|
clickedDragonEgg(event.getPlayer(), block);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Config.getConfig(world).BLOCK_BREAK) {
|
||||||
Block relativeBlock = event.getClickedBlock().getRelative(event.getBlockFace());
|
Block relativeBlock = event.getClickedBlock().getRelative(event.getBlockFace());
|
||||||
|
|
||||||
if (BlockGroup.FIRE.contains(relativeBlock.getType())) {
|
if (BlockGroup.FIRE.contains(relativeBlock.getType())) {
|
||||||
|
|
@ -538,6 +544,7 @@ public final class PlayerInteractListener extends Queue implements Listener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if (event.getAction().equals(Action.RIGHT_CLICK_BLOCK) || event.getAction().equals(Action.RIGHT_CLICK_AIR)) {
|
else if (event.getAction().equals(Action.RIGHT_CLICK_BLOCK) || event.getAction().equals(Action.RIGHT_CLICK_AIR)) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
Block block = event.getClickedBlock();
|
Block block = event.getClickedBlock();
|
||||||
|
|
@ -663,6 +670,9 @@ public final class PlayerInteractListener extends Queue implements Listener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (type == Material.DRAGON_EGG) {
|
||||||
|
clickedDragonEgg(player, block);
|
||||||
|
}
|
||||||
|
|
||||||
if (isCake || type == Material.CAKE) {
|
if (isCake || type == Material.CAKE) {
|
||||||
boolean placeCandle = false;
|
boolean placeCandle = false;
|
||||||
|
|
@ -802,4 +812,16 @@ public final class PlayerInteractListener extends Queue implements Listener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void clickedDragonEgg(Player player, Block block) {
|
||||||
|
Location location = block.getLocation();
|
||||||
|
long time = System.currentTimeMillis();
|
||||||
|
int wid = Util.getWorldId(location.getWorld().getName());
|
||||||
|
int x = location.getBlockX();
|
||||||
|
int y = location.getBlockY();
|
||||||
|
int z = location.getBlockZ();
|
||||||
|
String coordinates = x + "." + y + "." + z + "." + wid + "." + Material.DRAGON_EGG.name();
|
||||||
|
CacheHandler.interactCache.put(coordinates, new Object[] { time, Material.DRAGON_EGG, player.getName() });
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue