Skip to content

Commit

Permalink
Fixed BungeeCord connector bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
keksexception committed May 23, 2020
1 parent 8a3337c commit b5372c5
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 26 deletions.
23 changes: 2 additions & 21 deletions LobbyNPCs/src/de/raffi/lobbynpcs/commands/LobbyNPCCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public boolean onCommand(CommandSender sender, Command arg1, String arg2, String

@Override
public void onHandlerRemoved(boolean b) {
InputHandler.getInputFrom(p, ConfigLobbyNPCs.PREFIX+"§6Enter the skin name of the npc (name is used to get cape etc.)", new MessageHandler() {
InputHandler.getInputFrom(p, ConfigLobbyNPCs.PREFIX+"§6Enter the name of the npc", new MessageHandler() {

@Override
public void onMessageDenied(String message) {p.sendMessage("§cError: String length is bigger than maximum of 16!");}
Expand All @@ -73,7 +73,7 @@ public void onHandlerRemoved() {

@Override
public void onHandlerRemoved(boolean b) {
InputHandler.getInputFrom(p, ConfigLobbyNPCs.PREFIX+6On what server should a player get send to (servername)?", new MessageHandler() {
InputHandler.getInputFrom(p, ConfigLobbyNPCs.PREFIX+6To what server should a player get send to (servername)?", new MessageHandler() {

@Override
public void onMessageDenied(String message) {
Expand Down Expand Up @@ -126,25 +126,6 @@ public void accept() {
} else {
createNPC(p, loc, npcName, fetch, skinName, showInTab, server, item, autoRotate, forcefield, sneak, false);
}
/*NPC npc = new NPC(loc, npcName, fetch, skinName);
if(item != null)
npc.setHandItem(item);
npc.setRemovedFromTablist(!showInTab);
npc.register();
npc.enableAutoSpawn();
LobbyNPCManager.setAutoRotate(npc, autoRotate);
LobbyNPCManager.setServer(npc, server);
LobbyNPCManager.setItem(npc, item);
LobbyNPCManager.setForcefield(npc, forcefield);
LobbyNPCManager.setAutoSneak(npc, state);
LobbyNPCManager.setProperty(npc, "server", server);
LobbyNPCManager.setProperty(npc, "rotate", autoRotate);
LobbyNPCManager.setProperty(npc, "forcefield", forcefield);
LobbyNPCManager.setProperty(npc, "sneak", state);
p.sendMessage(ConfigLobbyNPCs.PREFIX+"§aCreated NPC successfully. Rejoin to see a change.");*/

}

Expand Down
3 changes: 1 addition & 2 deletions LobbyNPCs/src/de/raffi/lobbynpcs/listener/NPCListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import de.raffi.lobbynpcs.utils.InventoryManager;
import de.raffi.lobbynpcs.utils.LabyModHook;
import de.raffi.lobbynpcs.utils.LobbyNPCManager;
import de.raffi.pluginlib.bungeecord.BungeeAPI;
import de.raffi.pluginlib.event.PlayerInteractAtNPCEvent;
import de.raffi.pluginlib.npc.NPC;
import de.raffi.pluginlib.npc.NPCManager;
Expand Down Expand Up @@ -70,7 +69,7 @@ public void onInteract(PlayerInteractAtNPCEvent e) {
if(System.currentTimeMillis()-allow.get(e.getPlayer())>ConfigLobbyNPCs.NPC_COOLDOWN) {
allow.put(e.getPlayer(), System.currentTimeMillis());
e.getPlayer().sendMessage(ConfigLobbyNPCs.connectingMessage);
BungeeAPI.sendToServer(LobbyNPCs.getInstance(), (String) LobbyNPCManager.getProperty(e.getNPC(), "server"), e.getPlayer());
de.raffi.lobbynpcs.utils.Bungee.sendToServer((String) LobbyNPCManager.getProperty(e.getNPC(), "server"), e.getPlayer());
}

}
Expand Down
3 changes: 1 addition & 2 deletions LobbyNPCs/src/de/raffi/lobbynpcs/main/LobbyNPCs.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import de.raffi.lobbynpcs.listener.NPCListener;
import de.raffi.lobbynpcs.utils.ConfigLobbyNPCs;
import de.raffi.lobbynpcs.utils.LobbyNPCManager;
import de.raffi.pluginlib.bungeecord.BungeeAPI;
import de.raffi.pluginlib.compability.npchandler.NPCHandlerManager;
import de.raffi.pluginlib.main.PluginLib;
import de.raffi.pluginlib.test.setup.PluginSetup;
Expand Down Expand Up @@ -49,7 +48,7 @@ public void onEnable() {


try {
Bukkit.getScheduler().scheduleSyncDelayedTask(this, ()->BungeeAPI.registerChannel(this),30);
getServer().getMessenger().registerOutgoingPluginChannel(getInstance(), "BungeeCord");
} catch (Exception e) {
e.printStackTrace();
}
Expand Down
23 changes: 23 additions & 0 deletions LobbyNPCs/src/de/raffi/lobbynpcs/utils/Bungee.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package de.raffi.lobbynpcs.utils;

import org.bukkit.entity.Player;

import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams;

import de.raffi.lobbynpcs.main.LobbyNPCs;

public class Bungee {



public static final void sendToServer(String server, Player player) {
ByteArrayDataOutput out = ByteStreams.newDataOutput();
out.writeUTF("Connect");
out.writeUTF(server);
player.sendPluginMessage(LobbyNPCs.getInstance(), "BungeeCord", out.toByteArray());
}



}
2 changes: 1 addition & 1 deletion LobbyNPCs/src/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: LobbyNPCs
version: 1.1-r2
version: 1.1-r3
main: de.raffi.lobbynpcs.main.LobbyNPCs
authors: [keksexception]
loadbefore: [PluginLib]
Expand Down

0 comments on commit b5372c5

Please sign in to comment.