From 2f64eb5ed0e8dda9c86845a1c03860c837778a74 Mon Sep 17 00:00:00 2001 From: Ruakij Date: Mon, 10 May 2021 15:23:29 +0200 Subject: [PATCH] Added player-messages --- .../LinkedBeaconTeleporterBlock.java | 9 ++++++++ .../LinkedBeaconTeleporterItem.java | 21 +++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/src/main/java/eu/ruekov/ruakij/LinkedBeaconTeleporters/linkedBeaconTeleporter/LinkedBeaconTeleporterBlock.java b/src/main/java/eu/ruekov/ruakij/LinkedBeaconTeleporters/linkedBeaconTeleporter/LinkedBeaconTeleporterBlock.java index 4525778..3e516b1 100644 --- a/src/main/java/eu/ruekov/ruakij/LinkedBeaconTeleporters/linkedBeaconTeleporter/LinkedBeaconTeleporterBlock.java +++ b/src/main/java/eu/ruekov/ruakij/LinkedBeaconTeleporters/linkedBeaconTeleporter/LinkedBeaconTeleporterBlock.java @@ -50,6 +50,15 @@ public class LinkedBeaconTeleporterBlock extends LinkedBeaconTeleporter { lbtItem.item() ); + // Notify Player when link was destroyed + if(this.linkedBeaconTeleporters.size() < 2){ + e.getPlayer().sendMessage("§cConnection to Teleporter with id §7"+ this.teleporterId +" §e("+ + (int)((LinkedBeaconTeleporterBlock)this.linkedBeaconTeleporters.get(0)).block.getLocation().distance( + ((LinkedBeaconTeleporterBlock)this.linkedBeaconTeleporters.get(1)).block().getLocation() + ) + +" Blocks away) §cdestroyed"); + } + return lbtItem; } diff --git a/src/main/java/eu/ruekov/ruakij/LinkedBeaconTeleporters/linkedBeaconTeleporter/LinkedBeaconTeleporterItem.java b/src/main/java/eu/ruekov/ruakij/LinkedBeaconTeleporters/linkedBeaconTeleporter/LinkedBeaconTeleporterItem.java index 9f79d5d..78e2266 100644 --- a/src/main/java/eu/ruekov/ruakij/LinkedBeaconTeleporters/linkedBeaconTeleporter/LinkedBeaconTeleporterItem.java +++ b/src/main/java/eu/ruekov/ruakij/LinkedBeaconTeleporters/linkedBeaconTeleporter/LinkedBeaconTeleporterItem.java @@ -43,6 +43,14 @@ public class LinkedBeaconTeleporterItem extends LinkedBeaconTeleporter { public LinkedBeaconTeleporterBlock place(BlockPlaceEvent e){ + // Deny placing when 2 LinkedBeaconTeleporter's are already placed + if(this.linkedBeaconTeleporters.size() == 2){ + e.getPlayer().sendMessage("§cMaximum-Amount §7(2) §cof §6LinkedBeaconTeleporters §cwith id §7"+ this.teleporterId +" §care already placed"); + + e.setCancelled(true); + return null; + } + Block block = e.getBlock(); Location loc = block.getLocation(); @@ -61,6 +69,19 @@ public class LinkedBeaconTeleporterItem extends LinkedBeaconTeleporter { lbtBlock ); + // Notify Player when no other teleporter was found (yet?) + if(this.linkedBeaconTeleporters.size() == 2){ + e.getPlayer().sendMessage("§6No other Teleporter found with with id §7"+ this.teleporterId); + } + // Notify Player when we have a full link + else if(this.linkedBeaconTeleporters.size() == 2){ + e.getPlayer().sendMessage("§aConnected to Teleporter with id §7"+ this.teleporterId +" §e("+ + (int)((LinkedBeaconTeleporterBlock)this.linkedBeaconTeleporters.get(0)).block.getLocation().distance( + ((LinkedBeaconTeleporterBlock)this.linkedBeaconTeleporters.get(1)).block().getLocation() + ) + +" Blocks away)"); + } + return lbtBlock; }