SteamWar/BauSystem
Archiviert
13
0

Add RedstoneListener messages

Dieser Commit ist enthalten in:
yoyosource 2021-03-07 12:32:54 +01:00
Ursprung 0c17692fc3
Commit ab374ea7dd

Datei anzeigen

@ -66,7 +66,7 @@ public class RedstoneListener implements Listener {
private void activate(Location location) { private void activate(Location location) {
if (loc1 != null && loc1.equals(location)) { if (loc1 != null && loc1.equals(location)) {
if (activated != null && !activated.equals(location)) { if (activated != null && !activated.equals(location)) {
player.sendMessage("§7Aktivierungsdifferenz§8: §e" + (currentTick - tick) + " §8(§7" + locationToString(activated) + " §8->§7 " + locationToString(location) + "§8)"); player.sendMessage(BauSystem.PREFIX + "Aktivierungsdifferenz§8: §e" + (currentTick - tick) + " §8(§7" + locationToString(activated) + " §8->§7 " + locationToString(location) + "§8)");
activated = null; activated = null;
return; return;
} }
@ -74,7 +74,7 @@ public class RedstoneListener implements Listener {
tick = currentTick; tick = currentTick;
} else if (loc2 != null && loc2.equals(location)) { } else if (loc2 != null && loc2.equals(location)) {
if (activated != null && !activated.equals(location)) { if (activated != null && !activated.equals(location)) {
player.sendMessage("§7Aktivierungsdifferenz§8: §e" + (currentTick - tick) + " §8(§7" + locationToString(activated) + " §8->§7 " + locationToString(location) + "§8)"); player.sendMessage(BauSystem.PREFIX + "Aktivierungsdifferenz§8: §e" + (currentTick - tick) + " §8(§7" + locationToString(activated) + " §8->§7 " + locationToString(location) + "§8)");
activated = null; activated = null;
return; return;
} }
@ -99,24 +99,24 @@ public class RedstoneListener implements Listener {
case RIGHT_CLICK_AIR: case RIGHT_CLICK_AIR:
if (player.isSneaking()) { if (player.isSneaking()) {
playerMap.remove(event.getPlayer()); playerMap.remove(event.getPlayer());
player.sendMessage("§7Positionen gelöscht§8."); player.sendMessage(BauSystem.PREFIX + "Positionen gelöscht§8.");
} }
break; break;
case RIGHT_CLICK_BLOCK: case RIGHT_CLICK_BLOCK:
if (!validBlock(event.getPlayer(), block.getBlockData())) return; if (!validBlock(event.getPlayer(), block.getBlockData())) return;
playerMap.computeIfAbsent(event.getPlayer(), RedstoneTester::new).loc1 = block.getLocation(); playerMap.computeIfAbsent(event.getPlayer(), RedstoneTester::new).loc1 = block.getLocation();
sendLocation(event.getPlayer(), "§7POS1", block.getLocation()); sendLocation(event.getPlayer(), "POS1", block.getLocation());
break; break;
case LEFT_CLICK_BLOCK: case LEFT_CLICK_BLOCK:
if (!validBlock(event.getPlayer(), block.getBlockData())) return; if (!validBlock(event.getPlayer(), block.getBlockData())) return;
playerMap.computeIfAbsent(event.getPlayer(), RedstoneTester::new).loc2 = block.getLocation(); playerMap.computeIfAbsent(event.getPlayer(), RedstoneTester::new).loc2 = block.getLocation();
sendLocation(event.getPlayer(), "§7POS2", block.getLocation()); sendLocation(event.getPlayer(), "POS2", block.getLocation());
break; break;
} }
} }
private void sendLocation(Player player, String prefix, Location location) { private void sendLocation(Player player, String prefix, Location location) {
player.sendMessage(prefix + "§8: §e" + locationToString(location)); player.sendMessage(BauSystem.PREFIX + prefix + "§8: §e" + locationToString(location));
} }
private static String locationToString(Location location) { private static String locationToString(Location location) {
@ -126,7 +126,7 @@ public class RedstoneListener implements Listener {
private boolean validBlock(Player player, BlockData block) { private boolean validBlock(Player player, BlockData block) {
if (block instanceof Powerable) return true; if (block instanceof Powerable) return true;
if (block instanceof Piston) return true; if (block instanceof Piston) return true;
player.sendMessage("§7Unbekannte Position"); player.sendMessage(BauSystem.PREFIX + "Unbekannte Position");
return false; return false;
} }