|
25 | 25 | import org.bukkit.event.inventory.CraftItemEvent; |
26 | 26 | import org.bukkit.event.inventory.PrepareItemCraftEvent; |
27 | 27 | import org.bukkit.event.player.PlayerInteractEvent; |
| 28 | +import org.bukkit.event.player.PlayerTeleportEvent; |
28 | 29 | import org.bukkit.inventory.ItemFlag; |
29 | 30 | import org.bukkit.inventory.ItemStack; |
30 | 31 | import org.bukkit.inventory.meta.BlockDataMeta; |
@@ -94,12 +95,12 @@ public void playerInteractRelayEvent (PlayerInteractEvent ev) { |
94 | 95 | Location loq = baseLoq.clone(); |
95 | 96 | if (ev.getPlayer().getWorld().getKey().equals(loq.getWorld().getKey()) && ev.getPlayer().getWorld().getKey().asString().equalsIgnoreCase("minecraft:the_end")) { |
96 | 97 | if (loq.getBlock().getType().equals(Material.LODESTONE)) { |
97 | | - ev.getPlayer().teleport(loq.add(.5, 1, .5).setDirection(ev.getPlayer().getLocation().getDirection())); |
| 98 | + ev.getPlayer().teleport(loq.add(.5, 1, .5).setDirection(ev.getPlayer().getLocation().getDirection()), PlayerTeleportEvent.TeleportCause.PLUGIN); |
98 | 99 | ev.getClickedBlock().setType(Material.DEAD_HORN_CORAL_BLOCK); |
99 | 100 | ev.setUseItemInHand(Event.Result.ALLOW); |
100 | 101 | ev.getClickedBlock().getWorld().playSound(ev.getClickedBlock().getLocation(), Sound.BLOCK_RESPAWN_ANCHOR_DEPLETE, SoundCategory.BLOCKS, 1F, 1F); |
101 | 102 | BukkitTask tpTask = new TpSfxTask(ev.getPlayer()).runTaskLater(EndRelay.instance, 1); |
102 | | - Bukkit.getLogger().info(ev.getPlayer().getName() + " just teleported, if there's some kind of \"moved too quickly\" error."); |
| 103 | + Bukkit.getLogger().warning("vvvvvvv " + ev.getPlayer().getName() + " just teleported, ignore the potential \"moved too quickly\" error below."); |
103 | 104 | } else { |
104 | 105 | //no lodestone |
105 | 106 | ev.getClickedBlock().setType(Material.DEAD_HORN_CORAL_BLOCK); |
@@ -153,6 +154,16 @@ public void onCraftAnchor(CraftItemEvent ev) { |
153 | 154 | if (!compass.getWorld().equals(ev.getView().getPlayer().getWorld())) ev.getView().getPlayer().getLocation().createExplosion(7F); |
154 | 155 | ItemStack item = new ItemStack(EndRelay.instance.endAnchor.getType()); |
155 | 156 | ItemMeta meta = item.getItemMeta(); |
| 157 | + if (ev.isShiftClick()) { |
| 158 | + int count = 64; |
| 159 | + for(ItemStack it : ev.getInventory().getMatrix()) { |
| 160 | + if (it.getAmount() < count) count = it.getAmount(); |
| 161 | + } |
| 162 | + item.setAmount(count); |
| 163 | + for(ItemStack ite : ev.getInventory().getMatrix()) { |
| 164 | + ite.setAmount(ite.getAmount() - count); |
| 165 | + } |
| 166 | + } |
156 | 167 | meta.customName(Component.text("End Relay").style(Style.style(TextDecoration.ITALIC))); |
157 | 168 | item.setItemMeta(meta); |
158 | 169 | item.setData(DataComponentTypes.LODESTONE_TRACKER, LodestoneTracker.lodestoneTracker(compass, true)); |
|
0 commit comments