diff --git a/src/main/java/com/gmail/St3venAU/plugins/ArmorStandTools/AST.java b/src/main/java/com/gmail/St3venAU/plugins/ArmorStandTools/AST.java index 4c1bfca..9e7670d 100644 --- a/src/main/java/com/gmail/St3venAU/plugins/ArmorStandTools/AST.java +++ b/src/main/java/com/gmail/St3venAU/plugins/ArmorStandTools/AST.java @@ -21,6 +21,7 @@ import org.bukkit.inventory.PlayerInventory; import org.bukkit.inventory.meta.SkullMeta; import org.bukkit.metadata.FixedMetadataValue; import org.bukkit.metadata.MetadataValue; +import org.bukkit.plugin.Plugin; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.scheduler.BukkitRunnable; @@ -38,7 +39,7 @@ public class AST extends JavaPlugin { final static HashMap selectedArmorStand = new HashMap<>(); public static final HashMap savedInventories = new HashMap<>(); - + public static Boolean hasVehiclesInstalled = false; static final HashMap> waitingForName = new HashMap<>(); // Player UUID, static final HashMap> waitingForSkull = new HashMap<>(); // Player UUID, @@ -87,6 +88,8 @@ public class AST extends JavaPlugin { } getServer().getPluginManager().registerEvents(new MainListener(), this); getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord"); + Plugin vehicles = getServer().getPluginManager().getPlugin("Vehicles"); + if (vehicles != null) hasVehiclesInstalled = Boolean.valueOf(vehicles.isEnabled()); Commands cmds = new Commands(); PluginCommand command = getCommand("astools"); if(command != null) { diff --git a/src/main/java/com/gmail/St3venAU/plugins/ArmorStandTools/MainListener.java b/src/main/java/com/gmail/St3venAU/plugins/ArmorStandTools/MainListener.java index a858462..b147a02 100644 --- a/src/main/java/com/gmail/St3venAU/plugins/ArmorStandTools/MainListener.java +++ b/src/main/java/com/gmail/St3venAU/plugins/ArmorStandTools/MainListener.java @@ -41,6 +41,8 @@ import org.bukkit.inventory.meta.SkullMeta; import org.bukkit.metadata.FixedMetadataValue; import org.bukkit.scheduler.BukkitRunnable; +import es.pollitoyeye.vehicles.enums.VehicleType; + import java.util.Arrays; import java.util.List; import java.util.UUID; @@ -53,6 +55,7 @@ public class MainListener implements Listener { public void onPlayerInteractAtEntity(PlayerInteractAtEntityEvent event) { if(!(event.getRightClicked() instanceof ArmorStand as)) return; Player p = event.getPlayer(); + if(isVehicle(as)) return; if (ArmorStandGUI.isInUse(as)) { Utils.title(p, Config.guiInUse); event.setCancelled(true); @@ -129,6 +132,22 @@ public class MainListener implements Listener { } } } + public Boolean isVehicle(ArmorStand as) { + if(!AST.hasVehiclesInstalled) return false; + String customName = as.getCustomName(); + if (customName == null) return false; + byte b; + int i; + VehicleType[] arrayOfVehicleType; + for (i = (arrayOfVehicleType = VehicleType.values()).length, b = 0; b < i; ) { + VehicleType toCheck = arrayOfVehicleType[b]; + if (customName.startsWith(String.valueOf(toCheck.getName()) + ";")) { + return true; + } + b++; + } + return false; + } @EventHandler public void onPlayerInteractEntity(PlayerInteractEntityEvent event) { diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index c4cb5be..d86fa58 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -4,7 +4,7 @@ version: ${project.version} api-version: 1.17 author: St3venAU description: Armor stand manipulation tools -softdepend: [WorldGuard, PlotSquared] +softdepend: [WorldGuard, PlotSquared, Vehicles] commands: astools: description: Give yourself the armor stand tools