Preserve JARVIS menus while porting gameplay, Citizens NPCs and plugin-only CI
This commit is contained in:
parent
a16b7adc1d
commit
dbf4bb25ff
1 changed files with 2251 additions and 196035 deletions
|
|
@ -21,6 +21,8 @@ import java.util.*;
|
|||
public final class DuneNPC extends JavaPlugin implements Listener, CommandExecutor, TabCompleter {
|
||||
private DuneCore core;
|
||||
private Smugglers smugglers;
|
||||
private SmugglerCover cover;
|
||||
SmugglerCover cover() { return cover; }
|
||||
private NamespacedKey guildKey;
|
||||
private static final Set<String> PLANETS = Set.of("arrakis", "caladan", "kaitain", "giedi_prime", "sigma_draconis_iv");
|
||||
private static final class Menu implements InventoryHolder {
|
||||
|
|
@ -49,13 +51,16 @@ public final class DuneNPC extends JavaPlugin implements Listener, CommandExecut
|
|||
var registration = Bukkit.getServicesManager().getRegistration(Economy.class);
|
||||
if (registration == null) { getLogger().severe("Vault economy unavailable."); Bukkit.getPluginManager().disablePlugin(this); return; }
|
||||
guildKey = new NamespacedKey("dunerealms", "guild");
|
||||
com.dunerealms.npc.CitizensBridge.start(this,guildKey,new NamespacedKey("dunecore","smuggler"));
|
||||
smugglers = new Smugglers(this, registration.getProvider(), core.politics());
|
||||
cover = new SmugglerCover(this);
|
||||
cover.register();
|
||||
Objects.requireNonNull(getCommand("dunenpc")).setExecutor(this);
|
||||
Objects.requireNonNull(getCommand("dunenpc")).setTabCompleter(this);
|
||||
Bukkit.getPluginManager().registerEvents(this, this);
|
||||
Bukkit.getScheduler().runTask(this, () -> Bukkit.getWorlds().forEach(this::ensureGuildNpc));
|
||||
}
|
||||
@Override public void onDisable() { if (smugglers != null) smugglers.shutdown(); }
|
||||
@Override public void onDisable() { if (smugglers != null) smugglers.shutdown(); if (cover != null) cover.shutdown(); }
|
||||
private void migrateData() throws IOException {
|
||||
for (String name : List.of("smuggling.yml", "smuggler-camps.yml")) {
|
||||
File source = new File(core.getDataFolder(), name), destination = new File(getDataFolder(), name);
|
||||
|
|
@ -72,8 +77,8 @@ public final class DuneNPC extends JavaPlugin implements Listener, CommandExecut
|
|||
if (!PLANETS.contains(world.getName().toLowerCase(Locale.ROOT)) || !getConfig().getBoolean("guild-npc.enabled", true)) return;
|
||||
Location spawn = world.getSpawnLocation();
|
||||
world.getChunkAt(spawn).load();
|
||||
for (Entity entity : world.getNearbyEntities(spawn, 12, 8, 12))
|
||||
if (entity instanceof Villager && entity.getPersistentDataContainer().has(guildKey, PersistentDataType.BYTE)) return;
|
||||
for (Entity entity : world.getEntitiesByClass(LivingEntity.class))
|
||||
if (entity.getPersistentDataContainer().has(guildKey, PersistentDataType.BYTE)) return;
|
||||
int x = spawn.getBlockX() + 2, z = spawn.getBlockZ();
|
||||
for (int dx = -3; dx <= 3; dx++) for (int dz = -3; dz <= 3; dz++) {
|
||||
int bx = x + dx, bz = z + dz;
|
||||
|
|
@ -96,8 +101,7 @@ public final class DuneNPC extends JavaPlugin implements Listener, CommandExecut
|
|||
});
|
||||
}
|
||||
@EventHandler public void navigator(PlayerInteractEntityEvent event) {
|
||||
if (!(event.getRightClicked() instanceof Villager)
|
||||
|| !event.getRightClicked().getPersistentDataContainer().has(guildKey, PersistentDataType.BYTE)) return;
|
||||
if (!event.getRightClicked().getPersistentDataContainer().has(guildKey, PersistentDataType.BYTE)) return;
|
||||
event.setCancelled(true);
|
||||
if (event.getHand() == EquipmentSlot.HAND) Bukkit.dispatchCommand(event.getPlayer(), "duneess travel");
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue

Staff