Fixed npcs have similar names causing weird behaviors with other plugins (#39)

This commit is contained in:
OmerBenGera 2022-04-22 18:27:15 +03:00
parent fdfe5655e1
commit 6fdd0b578d

View File

@ -16,10 +16,13 @@ import java.util.UUID;
public final class NPCHandler implements NPCManager {
private static int NPCS_COUNTER = 0;
private final WildLoadersPlugin plugin;
private final Map<NPCIdentifier, ChunkLoaderNPC> npcs = Maps.newConcurrentMap();
private final Map<NPCIdentifier, UUID> npcUUIDs = Maps.newConcurrentMap();
public NPCHandler(WildLoadersPlugin plugin) {
this.plugin = plugin;
}
@ -92,8 +95,7 @@ public final class NPCHandler implements NPCManager {
}
public static String getName(String worldName) {
String name = "Loader-" + worldName;
return name.length() > 16 ? name.substring(0, 16) : name;
return "Loader-" + (worldName.length() > 7 ? worldName.substring(0, 7) : worldName) + "-" + (NPCS_COUNTER++);
}
}