GithubHelp home page GithubHelp logo

Scoreboards teams bug about npclib HOT 8 CLOSED

jitseb avatar jitseb commented on June 15, 2024
Scoreboards teams bug

from npclib.

Comments (8)

JitseB avatar JitseB commented on June 15, 2024

Are you using NPC#show(player, true/false)? You're not supposed to utilise this method, nor should you use NPC#hide(player, true/false). These are methods used by the internal system. NPCs should (under normal circumstances) hide and show automatically.

from npclib.

AbarcaJ avatar AbarcaJ commented on June 15, 2024

the npcs do not appears/dissappears if i don't use NPC#show for NPC#hide

from npclib.

AbarcaJ avatar AbarcaJ commented on June 15, 2024

i will try again later,...

from npclib.

AbarcaJ avatar AbarcaJ commented on June 15, 2024

I have tried but the npc does not appear / disappear if I do not use the method manually.

from npclib.

JitseB avatar JitseB commented on June 15, 2024

Could you give a snippet of the code you're using the spawn (and show) the NPCs?

from npclib.

AbarcaJ avatar AbarcaJ commented on June 15, 2024

Hello, here some part of my code,

public class NpcManager implements Listener {

private List<CustomNPC> npcs;
private final NPCLib library;
private Skin shopSkin, soloSkin, doubleSkin;
private List<String> holoText = Utils.color(Arrays.asList("&d&lHOLOGRAM &f&l- &c&l%s", "&7(Right Click)"));

public NpcManager() {
    this.npcs = new ArrayList<CustomNPC>();
    this.library = new NPCLib(Main.getMain());
    Bukkit.getPluginManager().registerEvents(this, Main.getMain());
}

public void setup() {
    this.npcs.clear();
    Utils.log("&eLoading NPCs....");
    MineSkinFetcher.fetchSkinFromIdAsync(54948, skin -> this.shopSkin = skin);
    MineSkinFetcher.fetchSkinFromIdAsync(60474, skin -> this.soloSkin = skin);
    MineSkinFetcher.fetchSkinFromIdAsync(78960, skin -> this.doubleSkin = skin);
    
    if (!Main.getMain().config.isConfigurationSection("NPCs"))
		return;
	
    Bukkit.getScheduler().runTaskLater(Main.getMain(), () -> {
    	for (String key : Main.getMain().config.getConfigurationSection("NPCs").getKeys(false)) {
			final Location loc = Utils.locFromString(Main.getMain().config.getString("NPCs." + key + ".loc"));
			String mode = Main.getMain().config.getString("NPCs." + key + ".mode");
			
			CustomNPC npc;
			if (mode.equals("SHOP")) {
				npc = addNPC(loc).getNPC();
				Main.getMain().config.set("NPCs." + key + ".id", npc.getEntityId());
				continue;
			}
			
			npc = addNPC(loc, GameMode.valueOf(mode)).getNPC();
			Main.getMain().config.set("NPCs." + key + ".id", npc.getEntityId());
		}
    	Utils.log("&eLoaded " + this.npcs.size() + " NPC(s)");
        Main.getMain().config.save();
        Main.getMain().config.reload();
    }, 60L);
}

@eventhandler
public void onJoin(PlayerJoinEvent e) {
final Player p = e.getPlayer();
for (CustomNPC npc : npcs) {
if (!npc.getNPC().isActuallyShown(p))
npc.getNPC().show(p);
}
}

@EventHandler
public void onQuit(PlayerQuitEvent e) {
	final Player p = e.getPlayer();
	for (CustomNPC npc : npcs) {
		if (npc.getNPC().isActuallyShown(p))
			npc.getNPC().hide(p);
	}
}

`

It works good, but some times when the player click the pc or walk to the npc got kicked by a error similar to this Team 09e2bc9b88 already exists in this scoreboar #Thanks and sorry for the wait!

from npclib.

JitseB avatar JitseB commented on June 15, 2024

First of all, you shouldn't use NPC#isActuallyShown, that's an internally used method.

One way to generate this error is by not correctly shutting down a server (i.e. terminating the process). If this is something you have done, it's necessary for you to delete the scoreboard file in your world folder.

I'll take a look if I can add an extra check so this will generate a warning in a future version of NPCLib.

from npclib.

AbarcaJ avatar AbarcaJ commented on June 15, 2024

oh, Thanks. Sorry for the incovenience.

from npclib.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.