3
0
Mirror von https://github.com/St3venAU/ArmorStandTools.git synchronisiert 2024-12-28 04:20:08 +01:00

Added support for Vehicles

Dieser Commit ist enthalten in:
SoyDary 2022-05-12 23:28:41 -05:00
Ursprung ed0b0db409
Commit aa69a4e91d
3 geänderte Dateien mit 24 neuen und 2 gelöschten Zeilen

Datei anzeigen

@ -21,6 +21,7 @@ import org.bukkit.inventory.PlayerInventory;
import org.bukkit.inventory.meta.SkullMeta; import org.bukkit.inventory.meta.SkullMeta;
import org.bukkit.metadata.FixedMetadataValue; import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.metadata.MetadataValue; import org.bukkit.metadata.MetadataValue;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
@ -38,7 +39,7 @@ public class AST extends JavaPlugin {
final static HashMap<UUID, ArmorStand> selectedArmorStand = new HashMap<>(); final static HashMap<UUID, ArmorStand> selectedArmorStand = new HashMap<>();
public static final HashMap<UUID, ItemStack[]> savedInventories = new HashMap<>(); public static final HashMap<UUID, ItemStack[]> savedInventories = new HashMap<>();
public static Boolean hasVehiclesInstalled = false;
static final HashMap<UUID, AbstractMap.SimpleEntry<UUID, Integer>> waitingForName = new HashMap<>(); // Player UUID, <ArmorStand UUID, Task ID> static final HashMap<UUID, AbstractMap.SimpleEntry<UUID, Integer>> waitingForName = new HashMap<>(); // Player UUID, <ArmorStand UUID, Task ID>
static final HashMap<UUID, AbstractMap.SimpleEntry<UUID, Integer>> waitingForSkull = new HashMap<>(); // Player UUID, <ArmorStand UUID, Task ID> static final HashMap<UUID, AbstractMap.SimpleEntry<UUID, Integer>> waitingForSkull = new HashMap<>(); // Player UUID, <ArmorStand UUID, Task ID>
@ -87,6 +88,8 @@ public class AST extends JavaPlugin {
} }
getServer().getPluginManager().registerEvents(new MainListener(), this); getServer().getPluginManager().registerEvents(new MainListener(), this);
getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord"); getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
Plugin vehicles = getServer().getPluginManager().getPlugin("Vehicles");
if (vehicles != null) hasVehiclesInstalled = Boolean.valueOf(vehicles.isEnabled());
Commands cmds = new Commands(); Commands cmds = new Commands();
PluginCommand command = getCommand("astools"); PluginCommand command = getCommand("astools");
if(command != null) { if(command != null) {

Datei anzeigen

@ -41,6 +41,8 @@ import org.bukkit.inventory.meta.SkullMeta;
import org.bukkit.metadata.FixedMetadataValue; import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
import es.pollitoyeye.vehicles.enums.VehicleType;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
@ -53,6 +55,7 @@ public class MainListener implements Listener {
public void onPlayerInteractAtEntity(PlayerInteractAtEntityEvent event) { public void onPlayerInteractAtEntity(PlayerInteractAtEntityEvent event) {
if(!(event.getRightClicked() instanceof ArmorStand as)) return; if(!(event.getRightClicked() instanceof ArmorStand as)) return;
Player p = event.getPlayer(); Player p = event.getPlayer();
if(isVehicle(as)) return;
if (ArmorStandGUI.isInUse(as)) { if (ArmorStandGUI.isInUse(as)) {
Utils.title(p, Config.guiInUse); Utils.title(p, Config.guiInUse);
event.setCancelled(true); 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 @EventHandler
public void onPlayerInteractEntity(PlayerInteractEntityEvent event) { public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {

Datei anzeigen

@ -4,7 +4,7 @@ version: ${project.version}
api-version: 1.17 api-version: 1.17
author: St3venAU author: St3venAU
description: Armor stand manipulation tools description: Armor stand manipulation tools
softdepend: [WorldGuard, PlotSquared] softdepend: [WorldGuard, PlotSquared, Vehicles]
commands: commands:
astools: astools:
description: Give yourself the armor stand tools description: Give yourself the armor stand tools