Skocz do zawartości
  • 0

Problem z pluginem


kerpson
 Udostępnij

Pytanie

Mam pewien problem. Pisalem sobie plugin. Zrobilem to tak gdy gracz wejdzie na serwer otwiera mu sie okienko z regulaminem. No ale jak wejde od razu mnie wyrzuca z serwera...

 ---- Internal Server Error             <--- Taki mam blad

Kod pluginu.

public class Main extends JavaPlugin implements Listener{
	
	Inventory inv;
	
	@Override
	public void onEnable(){
		Bukkit.getServer().getPluginManager().registerEvents(this, this);
		saveDefaultConfig();
		getCommand("pomoc").setExecutor(new Pomoc());
		getCommand("vip").setExecutor(new VipCmd());
		getCommand("svip").setExecutor(new SVipCmd());
		getCommand("yt").setExecutor(new YtCmd());
		System.out.println("Wlaczanie...");
	}
	@Override
	public void onDisable(){
		System.out.println("Wylaczanie...");
	}
	
	@EventHandler
	public void onJoin(PlayerJoinEvent e){
		
		Player p = (Player) e.getPlayer();
		
		if(p instanceof Player){
			createMenu(p);
		}
	
	}
	public void createMenu(Player p){
		Inventory inv = Bukkit.getServer().createInventory(null,9,"§6§lRegulamin");
		
		ItemStack book = new ItemStack(Material.BOOK, 1);
		ItemMeta bookim = book.getItemMeta();
		ArrayList <String> booklore = new ArrayList<String>();
		booklore.add("§c» §4Zakaz gry na cheatach");
		booklore.add("§c» §4Nie badz noobem i nie niszcz gdy innym");
		booklore.add("§c» §4Gra na cheatach = §c§lBAN , TEMPBAN");
		bookim.setLore(booklore);
		bookim.setDisplayName("§1. §4§lCHEATY");
		book.setItemMeta(bookim);
		
		inv.setItem(0, book);
		
		p.openInventory(inv);
	}
}

Bledy z konsoli:

 

java.lang.IllegalArgumentException: Listener already listening
	at net.minecraft.server.v1_8_R3.Container.addSlotListener(Container.java:56) ~[spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24]
	at net.minecraft.server.v1_8_R3.EntityPlayer.syncInventory(EntityPlayer.java:174) ~[spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24]
	at net.minecraft.server.v1_8_R3.PlayerList.a(PlayerList.java:174) ~[spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24]
	at net.minecraft.server.v1_8_R3.LoginListener.b(LoginListener.java:144) ~[spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24]
	at net.minecraft.server.v1_8_R3.LoginListener.c(LoginListener.java:54) ~[spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24]
	at net.minecraft.server.v1_8_R3.NetworkManager.a(NetworkManager.java:231) ~[spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24]
	at net.minecraft.server.v1_8_R3.ServerConnection.c(ServerConnection.java:148) [spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24]
	at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:814) [spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24]
	at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:374) [spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24]
	at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:654) [spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24]
	at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:557) [spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24]
	at java.lang.Thread.run(Thread.java:748) [?:1.8.0_151]

 

Edytowane przez HotAngel2K17
Odnośnik do komentarza
Udostępnij na innych stronach

2 odpowiedzi na to pytanie

Rekomendowane odpowiedzi

  • 0

wywal to:

		if(p instanceof Player){

bo chyba np. Enderman na serwer nie wbija tylko sie respi :ancap:

Sprobuj otworzyc to sekunde po dolaczeniu gracza, czyli np.

new BukkitRunnable() {
	@Override
	public void run() {
		if (p.isOnline())
			openRules(p);
	}
}.runTaskLater(plugin,20L); //20L = 1 sekunda

- powinno rozwiazac twoj problem

 

no i:

		Inventory inv = Bukkit.getServer().createInventory(null,9,"§6§lRegulamin");
		
		ItemStack book = new ItemStack(Material.BOOK, 1);
		ItemMeta bookim = book.getItemMeta();
		ArrayList <String> booklore = new ArrayList<String>();
		booklore.add("§c» §4Zakaz gry na cheatach");
		booklore.add("§c» §4Nie badz noobem i nie niszcz gdy innym");
		booklore.add("§c» §4Gra na cheatach = §c§lBAN , TEMPBAN");
		bookim.setLore(booklore);
		bookim.setDisplayName("§1. §4§lCHEATY");
		book.setItemMeta(bookim);
		
		inv.setItem(0, book);

rob to tylko raz, w onEnable. i wywal to z metody createMenu - lub po prostu otwieraj graczu ksiazke, a nie inventory z ksiazka.

 

@edit pisalem to zanim GotoFinal skomentowal, jesli bym to widzial to juz bym nie skomentowal :>

Możesz spróbować wrzucić otwieranie inventory do taska, by było opóźnione o np jeden tick, pewnie wina starej wersji silnika.

 

Edytowane przez yooniks
'bo' zamiast 'po'
Odnośnik do komentarza
Udostępnij na innych stronach

Nieaktywny
Ten temat został zamknięty. Brak możliwości dodania odpowiedzi.
 Udostępnij

  • Ostatnio przeglądający   0 użytkowników

    • Brak zarejestrowanych użytkowników przeglądających tę stronę.
×
×
  • Dodaj nową pozycję...