Just need to add default permissions and we are ready for release.

This commit is contained in:
md_5 2013-01-22 10:39:21 +11:00
parent 4b9b2cbb96
commit ade3fe4311
4 changed files with 31 additions and 8 deletions

View File

@ -89,7 +89,7 @@ public class BungeeCord extends ProxyServer
public final PluginManager pluginManager = new PluginManager(); public final PluginManager pluginManager = new PluginManager();
@Getter @Getter
@Setter @Setter
private ReconnectHandler reconnectHandler = new YamlReconnectHandler(); private ReconnectHandler reconnectHandler;
@Getter @Getter
@Setter @Setter
private ConfigurationAdapter configurationAdapter = new YamlConfig(); private ConfigurationAdapter configurationAdapter = new YamlConfig();
@ -104,6 +104,10 @@ public class BungeeCord extends ProxyServer
getPluginManager().registerCommand(new CommandIP()); getPluginManager().registerCommand(new CommandIP());
getPluginManager().registerCommand(new CommandAlert()); getPluginManager().registerCommand(new CommandAlert());
getPluginManager().registerCommand(new CommandBungee()); getPluginManager().registerCommand(new CommandBungee());
registerChannel("BungeeCord::Disconnect");
registerChannel("BungeeCord::Connect");
registerChannel("BungeeCord::Forward");
} }
public static BungeeCord getInstance() public static BungeeCord getInstance()
@ -148,6 +152,7 @@ public class BungeeCord extends ProxyServer
public void start() throws IOException public void start() throws IOException
{ {
config.load(); config.load();
reconnectHandler = new YamlReconnectHandler();
isRunning = true; isRunning = true;
File plugins = new File("plugins"); File plugins = new File("plugins");

View File

@ -118,6 +118,7 @@ public class InitialHandler implements Runnable, PendingConnection
} catch (Exception ex) } catch (Exception ex)
{ {
disconnect("[Proxy Error] " + Util.exception(ex)); disconnect("[Proxy Error] " + Util.exception(ex));
ex.printStackTrace();
} }
} }

View File

@ -18,10 +18,10 @@ import java.util.concurrent.ConcurrentLinkedQueue;
import lombok.Getter; import lombok.Getter;
import lombok.Synchronized; import lombok.Synchronized;
import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.config.ListenerInfo;
import net.md_5.bungee.api.config.ServerInfo; import net.md_5.bungee.api.config.ServerInfo;
import net.md_5.bungee.api.connection.PendingConnection; import net.md_5.bungee.api.connection.PendingConnection;
import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.connection.Server;
import net.md_5.bungee.api.event.ChatEvent; import net.md_5.bungee.api.event.ChatEvent;
import net.md_5.bungee.api.event.PluginMessageEvent; import net.md_5.bungee.api.event.PluginMessageEvent;
import net.md_5.bungee.api.event.ServerConnectEvent; import net.md_5.bungee.api.event.ServerConnectEvent;
@ -77,7 +77,7 @@ public class UserConnection extends GenericConnection implements ProxiedPlayer
if (server == null) if (server == null)
{ {
// First join // First join
ProxyServer.getInstance().getPlayers().add(this); BungeeCord.getInstance().connections.put(name, this);
ProxyServer.getInstance().getTabListHandler().onConnect(this); ProxyServer.getInstance().getTabListHandler().onConnect(this);
} }
@ -118,6 +118,7 @@ public class UserConnection extends GenericConnection implements ProxiedPlayer
} }
server.disconnect("Quitting"); server.disconnect("Quitting");
server.getInfo().removePlayer(this);
Packet1Login login = newServer.loginPacket; Packet1Login login = newServer.loginPacket;
serverEntityId = login.entityId; serverEntityId = login.entityId;
@ -127,8 +128,6 @@ public class UserConnection extends GenericConnection implements ProxiedPlayer
// Reconnect process has finished, lets get the player moving again // Reconnect process has finished, lets get the player moving again
reconnecting = false; reconnecting = false;
// Remove from the old by server list
server.getInfo().removePlayer(this);
// Add to new // Add to new
target.addPlayer(this); target.addPlayer(this);
@ -141,8 +140,8 @@ public class UserConnection extends GenericConnection implements ProxiedPlayer
destroySelf(ex.getMessage()); destroySelf(ex.getMessage());
} catch (Exception ex) } catch (Exception ex)
{ {
destroySelf("Could not connect to server - " + ex.getClass().getSimpleName());
ex.printStackTrace(); // TODO: Remove ex.printStackTrace(); // TODO: Remove
destroySelf("Could not connect to server - " + ex.getClass().getSimpleName());
} }
} }
@ -377,6 +376,20 @@ public class UserConnection extends GenericConnection implements ProxiedPlayer
short len = in.readShort(); short len = in.readShort();
byte[] data = new byte[len]; byte[] data = new byte[len];
in.readFully(data); in.readFully(data);
if (target.equals("ALL"))
{
for (String s : BungeeCord.getInstance().getServers().keySet())
{
Server server = BungeeCord.getInstance().getServer(s);
server.sendData(channel, data);
}
} else
{
Server server = BungeeCord.getInstance().getServer(target);
server.sendData(channel, data);
}
break; break;
case "BungeeCord::Connect": case "BungeeCord::Connect":
ServerInfo server = BungeeCord.getInstance().config.getServers().get(in.readUTF()); ServerInfo server = BungeeCord.getInstance().config.getServers().get(in.readUTF());

View File

@ -25,9 +25,13 @@ public class YamlReconnectHandler implements ReconnectHandler
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public YamlReconnectHandler() public YamlReconnectHandler()
{ {
try
{
file.createNewFile();
try (FileReader rd = new FileReader(file)) try (FileReader rd = new FileReader(file))
{ {
data = yaml.loadAs(rd, Map.class); data = yaml.loadAs(rd, Map.class);
}
} catch (IOException ex) } catch (IOException ex)
{ {
ProxyServer.getInstance().getLogger().log(Level.WARNING, "Could not load reconnect locations", ex); ProxyServer.getInstance().getLogger().log(Level.WARNING, "Could not load reconnect locations", ex);