mirror of
https://github.com/HibiscusMC/HMCCosmetics.git
synced 2026-01-04 15:41:45 +00:00
Merge remote-tracking branch 'origin/master'
# Conflicts: # common/src/main/java/io/github/fisher2911/hmccosmetics/hook/CitizensHook.java
This commit is contained in:
@@ -8,11 +8,7 @@ import io.github.fisher2911.hmccosmetics.gui.ArmorItem;
|
||||
import io.github.fisher2911.hmccosmetics.task.InfiniteTask;
|
||||
import io.github.fisher2911.hmccosmetics.user.NPCUser;
|
||||
import net.citizensnpcs.api.CitizensAPI;
|
||||
import net.citizensnpcs.api.event.NPCDeathEvent;
|
||||
import net.citizensnpcs.api.event.NPCDespawnEvent;
|
||||
import net.citizensnpcs.api.event.NPCRemoveEvent;
|
||||
import net.citizensnpcs.api.event.NPCSpawnEvent;
|
||||
import net.citizensnpcs.api.event.PlayerCreateNPCEvent;
|
||||
import net.citizensnpcs.api.event.*;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Entity;
|
||||
@@ -22,11 +18,7 @@ import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class CitizensHook implements Hook, Listener {
|
||||
@@ -73,19 +65,23 @@ public class CitizensHook implements Hook, Listener {
|
||||
final NPC npc = CitizensAPI.getNPCRegistry().getById(id);
|
||||
if (npc == null) return false;
|
||||
final NPCUser user = this.npcs.get(npc.getId());
|
||||
final Entity entity = npc.getEntity();
|
||||
if (entity == null) return false;
|
||||
if (user == null) {
|
||||
Threads.getInstance().execute(() -> this.database.loadNPCUser(
|
||||
npc.getId(),
|
||||
npc.getEntity(),
|
||||
npcUser ->
|
||||
Bukkit.getScheduler().runTask(
|
||||
this.plugin,
|
||||
() -> {
|
||||
this.npcs.put(npc.getId(), npcUser);
|
||||
this.setNpcCosmetic(npcUser, armorItem);
|
||||
}
|
||||
)
|
||||
));
|
||||
Threads.getInstance().execute(() -> {
|
||||
this.database.loadNPCUser(
|
||||
npc.getId(),
|
||||
entity,
|
||||
npcUser ->
|
||||
Bukkit.getScheduler().runTask(
|
||||
this.plugin,
|
||||
() -> {
|
||||
this.npcs.put(npc.getId(), npcUser);
|
||||
this.setNpcCosmetic(npcUser, armorItem);
|
||||
}
|
||||
)
|
||||
);
|
||||
});
|
||||
return true;
|
||||
}
|
||||
return this.setNpcCosmetic(user, armorItem);
|
||||
@@ -120,7 +116,7 @@ public class CitizensHook implements Hook, Listener {
|
||||
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
|
||||
public void onNpcLoad(final PlayerCreateNPCEvent event) {
|
||||
this.loadNpc(event.getNPC());
|
||||
this.loadNpc(event.getNPC());
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
|
||||
@@ -132,7 +128,6 @@ public class CitizensHook implements Hook, Listener {
|
||||
if (Bukkit.getPlayer(npc.getUniqueId()) != null) return;
|
||||
final Entity entity = npc.getEntity();
|
||||
if (entity == null) return;
|
||||
|
||||
Bukkit.getScheduler().runTaskLater(this.plugin,
|
||||
() -> Threads.getInstance().execute(() -> this.database.loadNPCUser(
|
||||
npc.getId(),
|
||||
|
||||
Reference in New Issue
Block a user