diff --git a/pom.xml b/pom.xml
index 2a7c8ba..0bfe29b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -66,9 +66,9 @@
provided
- net.citizensnpcs
- citizens-main
- 2.0.29-SNAPSHOT
+ de.cubeside.CubesideNPCs
+ CubesideNPCs
+ 0.0.2-Challenge-Test
provided
diff --git a/src/main/java/de/fanta/challengesjoinentities/ChallengesJoinEntities.java b/src/main/java/de/fanta/challengesjoinentities/ChallengesJoinEntities.java
index 118f5f8..d4126a6 100644
--- a/src/main/java/de/fanta/challengesjoinentities/ChallengesJoinEntities.java
+++ b/src/main/java/de/fanta/challengesjoinentities/ChallengesJoinEntities.java
@@ -1,9 +1,9 @@
package de.fanta.challengesjoinentities;
import de.cubeside.nmsutils.NMSUtils;
+import de.cubeside.npcs.CubesideNPCs;
import de.fanta.challengesjoinentities.adventure.AdventureMapsConfig;
import de.fanta.challengesjoinentities.adventure.CategoriesConfig;
-import de.fanta.challengesjoinentities.adventure.Category;
import de.fanta.challengesjoinentities.commands.AdventureCommand.AdventureAddCategoryCommand;
import de.fanta.challengesjoinentities.commands.AdventureCommand.AdventureAddMapCommand;
import de.fanta.challengesjoinentities.commands.AdventureCommand.AdventureLoadCommand;
@@ -24,8 +24,6 @@
import de.fanta.challengesjoinentities.loadgui.ChallengeLoadGUI;
import de.iani.cubesideutils.bukkit.commands.CommandRouter;
import de.iani.playerUUIDCache.PlayerUUIDCache;
-import net.citizensnpcs.api.CitizensAPI;
-import net.citizensnpcs.api.npc.NPC;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextComponent;
import net.kyori.adventure.text.format.TextColor;
@@ -39,7 +37,6 @@
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.java.JavaPlugin;
-import org.junit.experimental.categories.Categories;
import java.util.HashMap;
import java.util.HashSet;
@@ -59,14 +56,14 @@
public static final TextComponent PREFIX_COMPONENT = Component.text("[", BRACKETS).append(Component.text("Lobby", TextColor.fromHexString("#52ff9d"))).append(Component.text("] ", BRACKETS));
private static ChallengesJoinEntities plugin;
- private Config config;
- private ChallengesGlobalDataHelper globalDataHelper;
private final Map entityData;
private final Map entityServerMapping;
private final Set availableServers;
+ public NMSUtils nmsUtils;
+ private Config config;
+ private ChallengesGlobalDataHelper globalDataHelper;
private CategoriesConfig categoriesConfig;
private AdventureMapsConfig adventureMapsConfig;
- public NMSUtils nmsUtils;
private PlayerUUIDCache playerUUIDCache;
@@ -76,6 +73,10 @@
this.availableServers = new HashSet<>();
}
+ public static ChallengesJoinEntities getPlugin() {
+ return plugin;
+ }
+
@Override
public void onEnable() {
plugin = this;
@@ -159,12 +160,10 @@
if (entityData.containsKey(serverName)) {
despawnNPC(entityData.get(serverName).getEntityUUID(), serverDisplayName);
}
- if (plugin.getServer().getPluginManager().getPlugin("Citizens") == null) {
+ if (plugin.getServer().getPluginManager().getPlugin("CubesideNPCs") == null) {
return;
}
- NPC npc = CitizensAPI.getNPCRegistry().createNPC(EntityType.PLAYER, serverDisplayName);
- npc.spawn(location);
- addPiglin(npc.getUniqueId(), serverName, gpLocationName, serverDisplayName, saveToConfig);
+ addPiglin(CubesideNPCs.getPlugin().spawnNPC(serverDisplayName, location), serverName, gpLocationName, serverDisplayName, saveToConfig);
globalDataHelper.requestInitialData(serverName);
}
@@ -177,16 +176,11 @@
}
public void despawnNPC(UUID piglinUUID, String serverName) {
- if (plugin.getServer().getPluginManager().getPlugin("Citizens") == null) {
+ if (plugin.getServer().getPluginManager().getPlugin("CubesideNPCs") == null) {
return;
}
- NPC npc = CitizensAPI.getNPCRegistry().getByUniqueId(piglinUUID);
- System.out.println(npc);
- if (npc != null) {
- System.out.println("Destroy: " + piglinUUID);
- Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "npc remove " + npc.getId());
- removePiglin(serverName);
- }
+ CubesideNPCs.getPlugin().removeNPC(piglinUUID);
+ removePiglin(serverName);
}
public void addPiglin(UUID piglinUUID, String serverName, String gpLocationName, String serverDisplayName, boolean saveToConfig) {
@@ -272,18 +266,8 @@
if (data == null) {
return;
}
-
String customName = data.createCustomEntityName();
-
- NPC npc = CitizensAPI.getNPCRegistry().getByUniqueId(entity.getUniqueId());
-
- if (npc != null) {
- npc.setName(customName);
- } else {
- entity.setCustomName(customName);
- }
-
-
+ entity.setCustomName(customName);
}
public void updatePiglinBehaviour(String serverName) {
@@ -336,10 +320,6 @@
return playerUUIDCache;
}
- public static ChallengesJoinEntities getPlugin() {
- return plugin;
- }
-
public AdventureMapsConfig getAdventureMapsConfig() {
return this.adventureMapsConfig;
}
diff --git a/src/main/java/de/fanta/challengesjoinentities/listeners/EntityListener.java b/src/main/java/de/fanta/challengesjoinentities/listeners/EntityListener.java
index 72c9874..d3621ff 100644
--- a/src/main/java/de/fanta/challengesjoinentities/listeners/EntityListener.java
+++ b/src/main/java/de/fanta/challengesjoinentities/listeners/EntityListener.java
@@ -5,11 +5,7 @@
import de.fanta.challengesjoinentities.JoinEntityData;
import de.speedy64.globalport.GlobalApi;
import io.papermc.paper.event.entity.EntityMoveEvent;
-import net.citizensnpcs.api.event.NPCClickEvent;
-import net.citizensnpcs.api.event.NPCDamageByEntityEvent;
-import net.citizensnpcs.api.event.NPCRightClickEvent;
import org.bukkit.GameMode;
-import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
@@ -67,19 +63,6 @@
}
}
- @EventHandler
- public void onNPCClick(NPCRightClickEvent e) {
- Player p = e.getClicker();
- onPlayerClickEntity(p, e.getNPC().getUniqueId());
- }
-
- @EventHandler
- public void onNPCRightClick(NPCDamageByEntityEvent e) {
- if (e.getDamager() instanceof Player p) {
- onPlayerClickEntity(p, e.getNPC().getUniqueId());
- }
- }
-
public void onPlayerClickEntity(Player player, UUID clicked) {
if (player == null || clicked == null) {
return;
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
index 470ed0d..5c49cad 100644
--- a/src/main/resources/plugin.yml
+++ b/src/main/resources/plugin.yml
@@ -5,7 +5,7 @@
api-version: 1.13
depend: [GlobalClient, CubesideUtils, GlobalPort, CubesideNMSUtils]
-softdepend: [Challenges, Citizens]
+softdepend: [Challenges, CubesideNPCs]
commands:
piglins: