mirror of
https://github.com/songoda/EpicAnchors.git
synced 2024-11-29 13:36:10 +01:00
Merge branch 'development'
This commit is contained in:
commit
e0735d2615
@ -4,7 +4,7 @@ stages:
|
||||
variables:
|
||||
name: "EpicAnchors"
|
||||
path: "/builds/$CI_PROJECT_PATH"
|
||||
version: "1.4.3"
|
||||
version: "1.4.4"
|
||||
|
||||
build:
|
||||
stage: build
|
||||
|
@ -20,6 +20,7 @@ import com.songoda.epicanchors.utils.Methods;
|
||||
import org.apache.commons.lang.math.NumberUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
@ -122,7 +123,7 @@ public class EpicAnchors extends SongodaPlugin {
|
||||
}
|
||||
|
||||
public void clearHologram(Anchor anchor) {
|
||||
HologramManager.removeHologram(anchor.getLocation());
|
||||
HologramManager.removeHologram(correctHeight(anchor.getLocation()));
|
||||
}
|
||||
|
||||
public void updateHologram(Anchor anchor) {
|
||||
@ -132,8 +133,15 @@ public class EpicAnchors extends SongodaPlugin {
|
||||
if (anchor.getLocation().getBlock().getType() != Settings.MATERIAL.getMaterial().getMaterial()) return;
|
||||
// grab the name
|
||||
String name = Methods.formatName(anchor.getTicksLeft(), false).trim();
|
||||
Location location = correctHeight(anchor.getLocation());
|
||||
// create the hologram
|
||||
HologramManager.updateHologram(anchor.getLocation(), name);
|
||||
HologramManager.updateHologram(location, name);
|
||||
}
|
||||
|
||||
private Location correctHeight(Location location) {
|
||||
if (location.getBlock().getType() != CompatibleMaterial.END_PORTAL_FRAME.getMaterial())
|
||||
location.add(0, .05, 0);
|
||||
return location;
|
||||
}
|
||||
|
||||
private void loadAnchorsFromFile() {
|
||||
|
@ -7,11 +7,14 @@ import com.songoda.core.utils.ItemUtils;
|
||||
import com.songoda.epicanchors.EpicAnchors;
|
||||
import com.songoda.epicanchors.anchor.Anchor;
|
||||
import com.songoda.epicanchors.gui.GUIOverview;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
@ -23,7 +26,7 @@ public class InteractListeners implements Listener {
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onBlockInteract(PlayerInteractEvent event) {
|
||||
if (event.getClickedBlock() == null) return;
|
||||
|
||||
@ -32,12 +35,18 @@ public class InteractListeners implements Listener {
|
||||
if (anchor == null) return;
|
||||
event.setCancelled(true);
|
||||
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (event.getAction() != Action.RIGHT_CLICK_BLOCK) {
|
||||
BlockBreakEvent blockBreakEvent = new BlockBreakEvent(event.getClickedBlock(), player);
|
||||
Bukkit.getPluginManager().callEvent(blockBreakEvent);
|
||||
if (blockBreakEvent.isCancelled())
|
||||
return;
|
||||
|
||||
anchor.bust();
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = event.getPlayer();
|
||||
ItemStack item = player.getItemInHand();
|
||||
|
||||
if (instance.getCoreConfig().getMaterial("Main.Anchor Block Material", CompatibleMaterial.AIR).matches(item)) {
|
||||
|
Loading…
Reference in New Issue
Block a user