Yet more minor tweaks to signs

This commit is contained in:
ME1312 2022-03-19 13:05:24 -04:00
parent 6fc8732003
commit 249b0a4fab
No known key found for this signature in database
GPG Key ID: FEFFE2F698E88FA8
1 changed files with 48 additions and 44 deletions

View File

@ -122,14 +122,15 @@ public class SubSigns implements Listener {
@EventHandler(priority = EventPriority.MONITOR)
public void create(SignChangeEvent e) {
if (!e.isCancelled() && e.getLine(0).trim().equalsIgnoreCase("[SubServers]") && plugin.lang != null) {
Player player = e.getPlayer();
if (!e.isCancelled() && e.getLine(0).trim().equalsIgnoreCase("[SubServers]")) {
String name = e.getLine(1).trim();
if (name.length() > 0 && player.hasPermission("subservers.signs")) {
Location location = e.getBlock().getLocation();
if (location.getBlock().getState() instanceof Sign) {
HashMap<Location, Supplier<?>> signs = new HashMap<Location, Supplier<?>>(SubSigns.signs);
if (name.length() > 0 && plugin.lang != null) {
Player player = e.getPlayer();
if (player.hasPermission("subservers.signs")) {
Supplier<?> translator = translate(name);
Location location = e.getBlock().getLocation();
HashMap<Location, Supplier<?>> signs = new HashMap<Location, Supplier<?>>(SubSigns.signs);
signs.put(location, translator);
SubSigns.data.put(new OfflineBlock(location), name);
SubSigns.signs = signs;
@ -288,10 +289,12 @@ public class SubSigns implements Listener {
@SuppressWarnings("unchecked")
@EventHandler(priority = EventPriority.MONITOR)
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();
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;
if (object instanceof Server) {
@ -337,12 +340,13 @@ public class SubSigns implements Listener {
}
}
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void delete(BlockBreakEvent e) {
if (!e.isCancelled() && e.getBlock().getState() instanceof Sign && signs.containsKey(e.getBlock().getLocation())) {
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();
String name = data.remove(new OfflineBlock(location));
if (name != null) locations.remove(name.toLowerCase());