Yet more minor tweaks to signs
This commit is contained in:
parent
6fc8732003
commit
249b0a4fab
|
@ -122,14 +122,15 @@ public class SubSigns implements Listener {
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void create(SignChangeEvent e) {
|
public void create(SignChangeEvent e) {
|
||||||
if (!e.isCancelled() && e.getLine(0).trim().equalsIgnoreCase("[SubServers]") && plugin.lang != null) {
|
if (!e.isCancelled() && e.getLine(0).trim().equalsIgnoreCase("[SubServers]")) {
|
||||||
Player player = e.getPlayer();
|
|
||||||
String name = e.getLine(1).trim();
|
String name = e.getLine(1).trim();
|
||||||
if (name.length() > 0 && player.hasPermission("subservers.signs")) {
|
if (name.length() > 0 && plugin.lang != null) {
|
||||||
Location location = e.getBlock().getLocation();
|
Player player = e.getPlayer();
|
||||||
if (location.getBlock().getState() instanceof Sign) {
|
if (player.hasPermission("subservers.signs")) {
|
||||||
HashMap<Location, Supplier<?>> signs = new HashMap<Location, Supplier<?>>(SubSigns.signs);
|
|
||||||
Supplier<?> translator = translate(name);
|
Supplier<?> translator = translate(name);
|
||||||
|
Location location = e.getBlock().getLocation();
|
||||||
|
|
||||||
|
HashMap<Location, Supplier<?>> signs = new HashMap<Location, Supplier<?>>(SubSigns.signs);
|
||||||
signs.put(location, translator);
|
signs.put(location, translator);
|
||||||
SubSigns.data.put(new OfflineBlock(location), name);
|
SubSigns.data.put(new OfflineBlock(location), name);
|
||||||
SubSigns.signs = signs;
|
SubSigns.signs = signs;
|
||||||
|
@ -288,10 +289,12 @@ public class SubSigns implements Listener {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void interact(PlayerInteractEvent e) {
|
public void interact(PlayerInteractEvent e) {
|
||||||
if (!e.isCancelled() && e.getClickedBlock() != null && signs.containsKey(e.getClickedBlock().getLocation()) && plugin.lang != null) {
|
if (!e.isCancelled() && e.getClickedBlock() != null && e.getClickedBlock().getState() instanceof Sign) {
|
||||||
|
Supplier<?> translator = signs.get(e.getClickedBlock().getLocation());
|
||||||
|
if (translator != null && plugin.lang != null) {
|
||||||
Player player = e.getPlayer();
|
Player player = e.getPlayer();
|
||||||
if (player.hasPermission("subservers.teleport") && (e.getAction() == Action.RIGHT_CLICK_BLOCK || !player.hasPermission("subservers.signs"))) {
|
if (player.hasPermission("subservers.teleport") && (e.getAction() == Action.RIGHT_CLICK_BLOCK || !player.hasPermission("subservers.signs"))) {
|
||||||
Object object = signs.get(e.getClickedBlock().getLocation()).get();
|
Object object = translator.get();
|
||||||
|
|
||||||
Collection<? extends Server> servers;
|
Collection<? extends Server> servers;
|
||||||
if (object instanceof Server) {
|
if (object instanceof Server) {
|
||||||
|
@ -337,12 +340,13 @@ public class SubSigns implements Listener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void delete(BlockBreakEvent e) {
|
public void delete(BlockBreakEvent e) {
|
||||||
if (!e.isCancelled() && e.getBlock().getState() instanceof Sign && signs.containsKey(e.getBlock().getLocation())) {
|
if (!e.isCancelled() && e.getBlock().getState() instanceof Sign && signs.containsKey(e.getBlock().getLocation())) {
|
||||||
Player player = e.getPlayer();
|
Player player = e.getPlayer();
|
||||||
if (plugin.lang != null && player.hasPermission("subservers.signs")) {
|
if (player.hasPermission("subservers.signs") && plugin.lang != null) {
|
||||||
Location location = e.getBlock().getLocation();
|
Location location = e.getBlock().getLocation();
|
||||||
String name = data.remove(new OfflineBlock(location));
|
String name = data.remove(new OfflineBlock(location));
|
||||||
if (name != null) locations.remove(name.toLowerCase());
|
if (name != null) locations.remove(name.toLowerCase());
|
||||||
|
|
Loading…
Reference in New Issue