Minor refactoring in PlayerInteractListener and BlockExplodeListener
This commit is contained in:
parent
ae3768695f
commit
130614bfdd
3 changed files with 466 additions and 486 deletions
|
|
@ -29,10 +29,10 @@ import net.coreprotect.model.BlockGroup;
|
|||
|
||||
public class BlockExplodeListener extends Queue implements Listener {
|
||||
|
||||
protected static void processBlockExplode(String user, World world, List<Block> b) {
|
||||
protected static void processBlockExplode(String user, World world, List<Block> blockList) {
|
||||
HashMap<Location, Block> blockMap = new HashMap<>();
|
||||
|
||||
for (Block block : b) {
|
||||
for (Block block : blockList) {
|
||||
blockMap.put(block.getLocation(), block);
|
||||
}
|
||||
|
||||
|
|
@ -46,11 +46,11 @@ public class BlockExplodeListener extends Queue implements Listener {
|
|||
int z = block.getZ();
|
||||
|
||||
Location[] locationMap = new Location[5];
|
||||
locationMap[0] = new Location(world, x + 1, y, z);
|
||||
locationMap[1] = new Location(world, x - 1, y, z);
|
||||
locationMap[2] = new Location(world, x, y, z + 1);
|
||||
locationMap[3] = new Location(world, x, y, z - 1);
|
||||
locationMap[4] = new Location(world, x, y + 1, z);
|
||||
locationMap[0] = new Location(world, (x + 1), y, z);
|
||||
locationMap[1] = new Location(world, (x - 1), y, z);
|
||||
locationMap[2] = new Location(world, x, y, (z + 1));
|
||||
locationMap[3] = new Location(world, x, y, (z - 1));
|
||||
locationMap[4] = new Location(world, x, (y + 1), z);
|
||||
|
||||
int scanMin = 0;
|
||||
int scanMax = 5;
|
||||
|
|
@ -114,8 +114,7 @@ public class BlockExplodeListener extends Queue implements Listener {
|
|||
Block block = entry.getValue();
|
||||
Material blockType = block.getType();
|
||||
BlockState blockState = block.getState();
|
||||
if (Tag.SIGNS.isTagged(blockType)) {
|
||||
if (Config.getConfig(world).SIGN_TEXT) {
|
||||
if (Tag.SIGNS.isTagged(blockType) && Config.getConfig(world).SIGN_TEXT) {
|
||||
try {
|
||||
Location location = blockState.getLocation();
|
||||
Sign sign = (Sign) blockState;
|
||||
|
|
@ -131,7 +130,6 @@ public class BlockExplodeListener extends Queue implements Listener {
|
|||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Database.containerBreakCheck(user, blockType, block, null, block.getLocation());
|
||||
Queue.queueBlockBreak(user, blockState, blockType, blockState.getBlockData().getAsString(), 0);
|
||||
|
|
|
|||
|
|
@ -37,12 +37,12 @@ public final class FoodLevelChangeListener extends Queue implements Listener {
|
|||
String coordinates = x + "." + y + "." + z + "." + worldId + "." + userUUID;
|
||||
|
||||
Object[] data = CacheHandler.interactCache.get(coordinates);
|
||||
if (data != null) {
|
||||
if (data != null && data[1] == Material.CAKE) {
|
||||
long newTime = System.currentTimeMillis();
|
||||
long oldTime = (long) data[0];
|
||||
|
||||
if ((newTime - oldTime) < 20) { // 50ms = 1 tick
|
||||
final BlockState oldBlockState = (BlockState) data[1];
|
||||
final BlockState oldBlockState = (BlockState) data[2];
|
||||
|
||||
Material oldType = oldBlockState.getType();
|
||||
if (oldType.name().endsWith(Material.CAKE.name())) {
|
||||
|
|
|
|||
|
|
@ -61,14 +61,15 @@ public final class PlayerInteractListener extends Queue implements Listener {
|
|||
public static ConcurrentHashMap<String, Object[]> lastInspectorEvent = new ConcurrentHashMap<>();
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
protected void onPlayerInteract(PlayerInteractEvent event) {
|
||||
protected void onPlayerInspect(PlayerInteractEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
World world = player.getWorld();
|
||||
|
||||
if (!Boolean.TRUE.equals(ConfigHandler.inspecting.get(player.getName()))) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getAction().equals(Action.LEFT_CLICK_BLOCK)) {
|
||||
if (ConfigHandler.inspecting.get(player.getName()) != null) {
|
||||
if (ConfigHandler.inspecting.get(player.getName())) {
|
||||
// block check
|
||||
BlockState checkBlock = event.getClickedBlock().getState();
|
||||
int x = checkBlock.getX();
|
||||
int y = checkBlock.getY();
|
||||
|
|
@ -83,55 +84,53 @@ public final class PlayerInteractListener extends Queue implements Listener {
|
|||
}
|
||||
|
||||
final BlockState blockFinal = checkBlock;
|
||||
final Player playerFinal = player;
|
||||
|
||||
class BasicThread implements Runnable {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
if (ConfigHandler.converterRunning) {
|
||||
playerFinal.sendMessage(Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.UPGRADE_IN_PROGRESS));
|
||||
player.sendMessage(Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.UPGRADE_IN_PROGRESS));
|
||||
return;
|
||||
}
|
||||
if (ConfigHandler.purgeRunning) {
|
||||
playerFinal.sendMessage(Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.PURGE_IN_PROGRESS));
|
||||
player.sendMessage(Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.PURGE_IN_PROGRESS));
|
||||
return;
|
||||
}
|
||||
if (ConfigHandler.lookupThrottle.get(playerFinal.getName()) != null) {
|
||||
Object[] lookupThrottle = ConfigHandler.lookupThrottle.get(playerFinal.getName());
|
||||
if ((boolean) lookupThrottle[0] || ((System.currentTimeMillis() - (long) lookupThrottle[1])) < 100) {
|
||||
playerFinal.sendMessage(Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.DATABASE_BUSY));
|
||||
if (ConfigHandler.lookupThrottle.get(player.getName()) != null) {
|
||||
Object[] lookupThrottle = ConfigHandler.lookupThrottle.get(player.getName());
|
||||
if ((boolean) lookupThrottle[0] || (System.currentTimeMillis() - (long) lookupThrottle[1]) < 100) {
|
||||
player.sendMessage(Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.DATABASE_BUSY));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Connection connection = Database.getConnection(true);
|
||||
if (connection != null) {
|
||||
ConfigHandler.lookupThrottle.put(playerFinal.getName(), new Object[] { true, System.currentTimeMillis() });
|
||||
ConfigHandler.lookupThrottle.put(player.getName(), new Object[] { true, System.currentTimeMillis() });
|
||||
Statement statement = connection.createStatement();
|
||||
|
||||
String resultData = BlockLookup.performLookup(null, statement, blockFinal, playerFinal, 0, 1, 7);
|
||||
String resultData = BlockLookup.performLookup(null, statement, blockFinal, player, 0, 1, 7);
|
||||
if (resultData.contains("\n")) {
|
||||
for (String b : resultData.split("\n")) {
|
||||
Chat.sendComponent(playerFinal, b);
|
||||
Chat.sendComponent(player, b);
|
||||
}
|
||||
}
|
||||
else if (resultData.length() > 0) {
|
||||
Chat.sendComponent(playerFinal, resultData);
|
||||
Chat.sendComponent(player, resultData);
|
||||
}
|
||||
|
||||
statement.close();
|
||||
connection.close();
|
||||
ConfigHandler.lookupThrottle.put(playerFinal.getName(), new Object[] { false, System.currentTimeMillis() });
|
||||
ConfigHandler.lookupThrottle.put(player.getName(), new Object[] { false, System.currentTimeMillis() });
|
||||
|
||||
if (blockFinal instanceof Sign && playerFinal.getGameMode() != GameMode.CREATIVE) {
|
||||
if (blockFinal instanceof Sign && player.getGameMode() != GameMode.CREATIVE) {
|
||||
Thread.sleep(1500);
|
||||
Sign sign = (Sign) blockFinal;
|
||||
BukkitAdapter.ADAPTER.sendSignChange(playerFinal, sign);
|
||||
BukkitAdapter.ADAPTER.sendSignChange(player, sign);
|
||||
}
|
||||
}
|
||||
else {
|
||||
playerFinal.sendMessage(Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.DATABASE_BUSY));
|
||||
player.sendMessage(Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.DATABASE_BUSY));
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
|
|
@ -168,11 +167,7 @@ public final class PlayerInteractListener extends Queue implements Listener {
|
|||
player.sendBlockChange(z2.getLocation(), z2.getBlockData());
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (event.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
|
||||
if (ConfigHandler.inspecting.get(player.getName()) != null) {
|
||||
if (ConfigHandler.inspecting.get(player.getName())) {
|
||||
Block block = event.getClickedBlock();
|
||||
if (block != null) {
|
||||
final Material type = block.getType();
|
||||
|
|
@ -182,7 +177,6 @@ public final class PlayerInteractListener extends Queue implements Listener {
|
|||
|
||||
if (isInteractBlock || isContainerBlock || isSignBlock) {
|
||||
final Block clickedBlock = event.getClickedBlock();
|
||||
final Player finalPlayer = player;
|
||||
|
||||
if (isSignBlock) {
|
||||
Location location = clickedBlock.getLocation();
|
||||
|
|
@ -193,31 +187,29 @@ public final class PlayerInteractListener extends Queue implements Listener {
|
|||
public void run() {
|
||||
try {
|
||||
if (ConfigHandler.converterRunning) {
|
||||
Chat.sendMessage(finalPlayer, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.UPGRADE_IN_PROGRESS));
|
||||
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.UPGRADE_IN_PROGRESS));
|
||||
return;
|
||||
}
|
||||
|
||||
if (ConfigHandler.purgeRunning) {
|
||||
Chat.sendMessage(finalPlayer, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.PURGE_IN_PROGRESS));
|
||||
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.PURGE_IN_PROGRESS));
|
||||
return;
|
||||
}
|
||||
|
||||
if (ConfigHandler.lookupThrottle.get(finalPlayer.getName()) != null) {
|
||||
Object[] lookupThrottle = ConfigHandler.lookupThrottle.get(finalPlayer.getName());
|
||||
if ((boolean) lookupThrottle[0] || ((System.currentTimeMillis() - (long) lookupThrottle[1])) < 100) {
|
||||
System.out.println((boolean) lookupThrottle[0] + " / " + ((System.currentTimeMillis() - (long) lookupThrottle[1])));
|
||||
|
||||
Chat.sendMessage(finalPlayer, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.DATABASE_BUSY));
|
||||
if (ConfigHandler.lookupThrottle.get(player.getName()) != null) {
|
||||
Object[] lookupThrottle = ConfigHandler.lookupThrottle.get(player.getName());
|
||||
if ((boolean) lookupThrottle[0] || (System.currentTimeMillis() - (long) lookupThrottle[1]) < 100) {
|
||||
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.DATABASE_BUSY));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
ConfigHandler.lookupThrottle.put(finalPlayer.getName(), new Object[] { true, System.currentTimeMillis() });
|
||||
ConfigHandler.lookupThrottle.put(player.getName(), new Object[] { true, System.currentTimeMillis() });
|
||||
|
||||
Connection connection = Database.getConnection(true);
|
||||
if (connection != null) {
|
||||
Statement statement = connection.createStatement();
|
||||
List<String> signData = SignMessageLookup.performLookup(null, statement, location, finalPlayer, 1, 7);
|
||||
List<String> signData = SignMessageLookup.performLookup(null, statement, location, player, 1, 7);
|
||||
for (String signMessage : signData) {
|
||||
String bypass = null;
|
||||
|
||||
|
|
@ -228,7 +220,7 @@ public final class PlayerInteractListener extends Queue implements Listener {
|
|||
}
|
||||
|
||||
if (signMessage.length() > 0) {
|
||||
Chat.sendComponent(finalPlayer, signMessage, bypass);
|
||||
Chat.sendComponent(player, signMessage, bypass);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -236,14 +228,14 @@ public final class PlayerInteractListener extends Queue implements Listener {
|
|||
connection.close();
|
||||
}
|
||||
else {
|
||||
Chat.sendMessage(finalPlayer, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.DATABASE_BUSY));
|
||||
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.DATABASE_BUSY));
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
ConfigHandler.lookupThrottle.put(finalPlayer.getName(), new Object[] { false, System.currentTimeMillis() });
|
||||
ConfigHandler.lookupThrottle.put(player.getName(), new Object[] { false, System.currentTimeMillis() });
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -279,51 +271,51 @@ public final class PlayerInteractListener extends Queue implements Listener {
|
|||
public void run() {
|
||||
try {
|
||||
if (ConfigHandler.converterRunning) {
|
||||
Chat.sendMessage(finalPlayer, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.UPGRADE_IN_PROGRESS));
|
||||
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.UPGRADE_IN_PROGRESS));
|
||||
return;
|
||||
}
|
||||
|
||||
if (ConfigHandler.purgeRunning) {
|
||||
Chat.sendMessage(finalPlayer, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.PURGE_IN_PROGRESS));
|
||||
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.PURGE_IN_PROGRESS));
|
||||
return;
|
||||
}
|
||||
|
||||
if (ConfigHandler.lookupThrottle.get(finalPlayer.getName()) != null) {
|
||||
Object[] lookupThrottle = ConfigHandler.lookupThrottle.get(finalPlayer.getName());
|
||||
if ((boolean) lookupThrottle[0] || ((System.currentTimeMillis() - (long) lookupThrottle[1])) < 100) {
|
||||
Chat.sendMessage(finalPlayer, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.DATABASE_BUSY));
|
||||
if (ConfigHandler.lookupThrottle.get(player.getName()) != null) {
|
||||
Object[] lookupThrottle = ConfigHandler.lookupThrottle.get(player.getName());
|
||||
if ((boolean) lookupThrottle[0] || (System.currentTimeMillis() - (long) lookupThrottle[1]) < 100) {
|
||||
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.DATABASE_BUSY));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
ConfigHandler.lookupThrottle.put(finalPlayer.getName(), new Object[] { true, System.currentTimeMillis() });
|
||||
ConfigHandler.lookupThrottle.put(player.getName(), new Object[] { true, System.currentTimeMillis() });
|
||||
|
||||
Connection connection = Database.getConnection(true);
|
||||
if (connection != null) {
|
||||
Statement statement = connection.createStatement();
|
||||
String blockData = ChestTransactionLookup.performLookup(null, statement, finalLocation, finalPlayer, 1, 7, false);
|
||||
String blockData = ChestTransactionLookup.performLookup(null, statement, finalLocation, player, 1, 7, false);
|
||||
|
||||
if (blockData.contains("\n")) {
|
||||
for (String splitData : blockData.split("\n")) {
|
||||
Chat.sendComponent(finalPlayer, splitData);
|
||||
Chat.sendComponent(player, splitData);
|
||||
}
|
||||
}
|
||||
else {
|
||||
Chat.sendComponent(finalPlayer, blockData);
|
||||
Chat.sendComponent(player, blockData);
|
||||
}
|
||||
|
||||
statement.close();
|
||||
connection.close();
|
||||
}
|
||||
else {
|
||||
Chat.sendMessage(finalPlayer, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.DATABASE_BUSY));
|
||||
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.DATABASE_BUSY));
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
ConfigHandler.lookupThrottle.put(finalPlayer.getName(), new Object[] { false, System.currentTimeMillis() });
|
||||
ConfigHandler.lookupThrottle.put(player.getName(), new Object[] { false, System.currentTimeMillis() });
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -350,49 +342,49 @@ public final class PlayerInteractListener extends Queue implements Listener {
|
|||
public void run() {
|
||||
try {
|
||||
if (ConfigHandler.converterRunning) {
|
||||
Chat.sendMessage(finalPlayer, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.UPGRADE_IN_PROGRESS));
|
||||
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.UPGRADE_IN_PROGRESS));
|
||||
return;
|
||||
}
|
||||
if (ConfigHandler.purgeRunning) {
|
||||
Chat.sendMessage(finalPlayer, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.PURGE_IN_PROGRESS));
|
||||
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.PURGE_IN_PROGRESS));
|
||||
return;
|
||||
}
|
||||
if (ConfigHandler.lookupThrottle.get(finalPlayer.getName()) != null) {
|
||||
Object[] lookup_throttle = ConfigHandler.lookupThrottle.get(finalPlayer.getName());
|
||||
if ((boolean) lookup_throttle[0] || ((System.currentTimeMillis() - (long) lookup_throttle[1])) < 100) {
|
||||
Chat.sendMessage(finalPlayer, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.DATABASE_BUSY));
|
||||
if (ConfigHandler.lookupThrottle.get(player.getName()) != null) {
|
||||
Object[] lookupThrottle = ConfigHandler.lookupThrottle.get(player.getName());
|
||||
if ((boolean) lookupThrottle[0] || (System.currentTimeMillis() - (long) lookupThrottle[1]) < 100) {
|
||||
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.DATABASE_BUSY));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
ConfigHandler.lookupThrottle.put(finalPlayer.getName(), new Object[] { true, System.currentTimeMillis() });
|
||||
ConfigHandler.lookupThrottle.put(player.getName(), new Object[] { true, System.currentTimeMillis() });
|
||||
|
||||
Connection connection = Database.getConnection(true);
|
||||
if (connection != null) {
|
||||
Statement statement = connection.createStatement();
|
||||
String blockData = InteractionLookup.performLookup(null, statement, finalInteractBlock, finalPlayer, 0, 1, 7);
|
||||
String blockData = InteractionLookup.performLookup(null, statement, finalInteractBlock, player, 0, 1, 7);
|
||||
|
||||
if (blockData.contains("\n")) {
|
||||
for (String splitData : blockData.split("\n")) {
|
||||
Chat.sendComponent(finalPlayer, splitData);
|
||||
Chat.sendComponent(player, splitData);
|
||||
}
|
||||
}
|
||||
else {
|
||||
Chat.sendComponent(finalPlayer, blockData);
|
||||
Chat.sendComponent(player, blockData);
|
||||
}
|
||||
|
||||
statement.close();
|
||||
connection.close();
|
||||
}
|
||||
else {
|
||||
Chat.sendMessage(finalPlayer, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.DATABASE_BUSY));
|
||||
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.DATABASE_BUSY));
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
ConfigHandler.lookupThrottle.put(finalPlayer.getName(), new Object[] { false, System.currentTimeMillis() });
|
||||
ConfigHandler.lookupThrottle.put(player.getName(), new Object[] { false, System.currentTimeMillis() });
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -442,7 +434,7 @@ public final class PlayerInteractListener extends Queue implements Listener {
|
|||
|
||||
if (ConfigHandler.lookupThrottle.get(finalPlayer.getName()) != null) {
|
||||
Object[] lookupThrottle = ConfigHandler.lookupThrottle.get(finalPlayer.getName());
|
||||
if ((boolean) lookupThrottle[0] || ((System.currentTimeMillis() - (long) lookupThrottle[1])) < 100) {
|
||||
if ((boolean) lookupThrottle[0] || (System.currentTimeMillis() - (long) lookupThrottle[1]) < 100) {
|
||||
Chat.sendMessage(finalPlayer, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.DATABASE_BUSY));
|
||||
return;
|
||||
}
|
||||
|
|
@ -524,11 +516,9 @@ public final class PlayerInteractListener extends Queue implements Listener {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
protected void onPlayerInteract_Monitor(PlayerInteractEvent event) {
|
||||
protected void onPlayerInteract(PlayerInteractEvent event) {
|
||||
/* Logging for players punching out fire blocks. */
|
||||
if (event.getAction().equals(Action.LEFT_CLICK_BLOCK)) {
|
||||
World world = event.getClickedBlock().getWorld();
|
||||
|
|
@ -554,7 +544,7 @@ public final class PlayerInteractListener extends Queue implements Listener {
|
|||
|
||||
if (Tag.SIGNS.isTagged(type)) {
|
||||
// check if right clicked sign with dye
|
||||
Set<Material> DYES = EnumSet.of(Material.BLACK_DYE, Material.BLUE_DYE, Material.BROWN_DYE, Material.CYAN_DYE, Material.GRAY_DYE, Material.GREEN_DYE, Material.LIGHT_BLUE_DYE, Material.LIGHT_GRAY_DYE, Material.LIME_DYE, Material.MAGENTA_DYE, Material.ORANGE_DYE, Material.PINK_DYE, Material.PURPLE_DYE, Material.RED_DYE, Material.WHITE_DYE, Material.YELLOW_DYE);
|
||||
Set<Material> dyeSet = EnumSet.of(Material.BLACK_DYE, Material.BLUE_DYE, Material.BROWN_DYE, Material.CYAN_DYE, Material.GRAY_DYE, Material.GREEN_DYE, Material.LIGHT_BLUE_DYE, Material.LIGHT_GRAY_DYE, Material.LIME_DYE, Material.MAGENTA_DYE, Material.ORANGE_DYE, Material.PINK_DYE, Material.PURPLE_DYE, Material.RED_DYE, Material.WHITE_DYE, Material.YELLOW_DYE);
|
||||
Material handType = null;
|
||||
|
||||
ItemStack mainHand = player.getInventory().getItemInMainHand();
|
||||
|
|
@ -562,7 +552,7 @@ public final class PlayerInteractListener extends Queue implements Listener {
|
|||
handType = mainHand.getType();
|
||||
}
|
||||
|
||||
if (handType != null && (DYES.contains(handType) || handType.name().endsWith("INK_SAC")) && Config.getConfig(block.getWorld()).SIGN_TEXT) {
|
||||
if (handType != null && (dyeSet.contains(handType) || handType.name().endsWith("INK_SAC")) && Config.getConfig(block.getWorld()).SIGN_TEXT) {
|
||||
BlockState blockState = block.getState();
|
||||
Sign sign = (Sign) blockState;
|
||||
String line1 = sign.getLine(0);
|
||||
|
|
@ -574,11 +564,11 @@ public final class PlayerInteractListener extends Queue implements Listener {
|
|||
boolean oldGlowing = BukkitAdapter.ADAPTER.isGlowing(sign);
|
||||
boolean newGlowing = oldGlowing;
|
||||
|
||||
if (DYES.contains(handType)) {
|
||||
if (dyeSet.contains(handType)) {
|
||||
newColor = (DyeColor.valueOf(handType.name().replaceFirst("_DYE", ""))).getColor().asRGB();
|
||||
}
|
||||
else {
|
||||
newGlowing = (handType == Material.INK_SAC ? false : true);
|
||||
newGlowing = (handType != Material.INK_SAC);
|
||||
}
|
||||
|
||||
if (oldGlowing != newGlowing || oldColor != newColor) {
|
||||
|
|
@ -590,8 +580,7 @@ public final class PlayerInteractListener extends Queue implements Listener {
|
|||
}
|
||||
}
|
||||
else if (BlockGroup.INTERACT_BLOCKS.contains(type)) {
|
||||
if (event.getHand().equals(EquipmentSlot.HAND)) {
|
||||
if (Config.getConfig(world).PLAYER_INTERACTIONS) {
|
||||
if (event.getHand().equals(EquipmentSlot.HAND) && Config.getConfig(world).PLAYER_INTERACTIONS) {
|
||||
Block interactBlock = event.getClickedBlock();
|
||||
if (BlockGroup.DOORS.contains(type)) {
|
||||
int y = interactBlock.getY() - 1;
|
||||
|
|
@ -605,12 +594,12 @@ public final class PlayerInteractListener extends Queue implements Listener {
|
|||
Queue.queuePlayerInteraction(player.getName(), interactBlock.getState());
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (BlockGroup.LIGHTABLES.contains(type)) { // extinguishing a lit block such as a campfire
|
||||
BlockData blockData = block.getBlockData();
|
||||
if (blockData instanceof Lightable && ((Lightable) blockData).isLit() && ((BlockGroup.CANDLES.contains(type) && event.getMaterial() == Material.AIR) || (!BlockGroup.CANDLES.contains(type) && event.getMaterial().name().endsWith("_SHOVEL")))) {
|
||||
((Lightable) blockData).setLit(false);
|
||||
Queue.queueBlockPlace(player.getName(), block.getState(), type, block.getState(), type, -1, 0, blockData.getAsString());
|
||||
|
||||
/*
|
||||
BlockState blockState = block.getState();
|
||||
Bukkit.getServer().getScheduler().runTask(CoreProtect.getInstance(), () -> {
|
||||
|
|
@ -659,7 +648,7 @@ public final class PlayerInteractListener extends Queue implements Listener {
|
|||
int y = location.getBlockY();
|
||||
int z = location.getBlockZ();
|
||||
String coordinates = x + "." + y + "." + z + "." + wid + "." + userUUID;
|
||||
CacheHandler.interactCache.put(coordinates, new Object[] { time, block.getState() });
|
||||
CacheHandler.interactCache.put(coordinates, new Object[] { time, Material.CAKE, block.getState() });
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -686,13 +675,11 @@ public final class PlayerInteractListener extends Queue implements Listener {
|
|||
boolean exists = false;
|
||||
|
||||
for (Entity entity : crystalLocation.getChunk().getEntities()) {
|
||||
if (entity instanceof EnderCrystal) {
|
||||
if (entity.getLocation().getBlockX() == crystalLocation.getBlockX() && entity.getLocation().getBlockY() == crystalLocation.getBlockY() && entity.getLocation().getBlockZ() == crystalLocation.getBlockZ()) {
|
||||
if (entity instanceof EnderCrystal && entity.getLocation().getBlockX() == crystalLocation.getBlockX() && entity.getLocation().getBlockY() == crystalLocation.getBlockY() && entity.getLocation().getBlockZ() == crystalLocation.getBlockZ()) {
|
||||
exists = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!exists) {
|
||||
final Player playerFinal = player;
|
||||
|
|
@ -703,15 +690,13 @@ public final class PlayerInteractListener extends Queue implements Listener {
|
|||
int showingBottom = 0;
|
||||
|
||||
for (Entity entity : locationFinal.getChunk().getEntities()) {
|
||||
if (entity instanceof EnderCrystal) {
|
||||
if (entity.getLocation().getBlockX() == locationFinal.getBlockX() && entity.getLocation().getBlockY() == locationFinal.getBlockY() && entity.getLocation().getBlockZ() == locationFinal.getBlockZ()) {
|
||||
if (entity instanceof EnderCrystal && entity.getLocation().getBlockX() == locationFinal.getBlockX() && entity.getLocation().getBlockY() == locationFinal.getBlockY() && entity.getLocation().getBlockZ() == locationFinal.getBlockZ()) {
|
||||
EnderCrystal enderCrystal = (EnderCrystal) entity;
|
||||
showingBottom = enderCrystal.isShowingBottom() ? 1 : 0;
|
||||
blockExists = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (blockExists) {
|
||||
Queue.queueBlockPlace(playerFinal.getName(), locationFinal.getBlock().getState(), locationFinal.getBlock().getType(), locationFinal.getBlock().getState(), Material.END_CRYSTAL, showingBottom, 1, null);
|
||||
}
|
||||
|
|
@ -739,10 +724,7 @@ public final class PlayerInteractListener extends Queue implements Listener {
|
|||
}
|
||||
else if (event.getAction().equals(Action.PHYSICAL)) {
|
||||
Block block = event.getClickedBlock();
|
||||
if (block == null) {
|
||||
return;
|
||||
}
|
||||
else if (!block.getType().equals(Material.FARMLAND) && !block.getType().equals(Material.TURTLE_EGG)) {
|
||||
if (block == null || (!block.getType().equals(Material.FARMLAND) && !block.getType().equals(Material.TURTLE_EGG))) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue