Skip to content
This repository has been archived by the owner on Jun 7, 2022. It is now read-only.

Commit

Permalink
Merge pull request #96 from CloudNetService/development
Browse files Browse the repository at this point in the history
Merge development into master branch
  • Loading branch information
byRoadrunner authored Dec 14, 2018
2 parents 94be7cd + 1af764e commit 74d5490
Show file tree
Hide file tree
Showing 18 changed files with 137 additions and 70 deletions.
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pipeline {
}
stage('Version') {
steps {
sh 'mvn versions:set -DnewVersion=2.1.14.1'
sh 'mvn versions:set -DnewVersion=2.1.14.2'
}
}
stage('Compile') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ public static String getGroupPrefix(String groupName)
final PermissionPool permissionPool = CloudAPI.getInstance().getPermissionPool();
if (permissionPool.getGroups().containsKey(groupName))
return permissionPool.getGroups().get(groupName).getPrefix();

return null;
}

Expand All @@ -193,7 +193,7 @@ public static String getGroupSuffix(String groupName)
final PermissionPool permissionPool = CloudAPI.getInstance().getPermissionPool();
if (permissionPool.getGroups().containsKey(groupName))
return permissionPool.getGroups().get(groupName).getSuffix();

return null;
}

Expand Down Expand Up @@ -222,7 +222,7 @@ public static String getGroupDisplay(String groupName)
final PermissionPool permissionPool = CloudAPI.getInstance().getPermissionPool();
if (permissionPool.getGroups().containsKey(groupName))
return permissionPool.getGroups().get(groupName).getDisplay();

return null;
}

Expand All @@ -239,7 +239,7 @@ public static Collection<String> getImplementedGroups(String groupName)
final PermissionPool permissionPool = CloudAPI.getInstance().getPermissionPool();
if (permissionPool.getGroups().containsKey(groupName))
return Collections.unmodifiableCollection(permissionPool.getGroups().get(groupName).getImplementGroups());

return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ public CloudConfig load() throws Exception
);
this.formatSplitter = configuration.getString("general.server-name-splitter");
this.networkProperties = configuration.getSection("networkproperties").self;

if (!configuration.getSection("general").self.containsKey("disabled-modules"))
{
configuration.set("general.disabled-modules", new ArrayList<>());
Expand Down Expand Up @@ -232,7 +232,7 @@ public CloudConfig load() throws Exception
}.getType());

this.userDocument = Document.loadDocument(usersPath);

return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,15 +129,15 @@ public boolean bootstrap() throws Exception
System.out.println("Loading Modules...");
moduleManager.loadModules();
}

for (WrapperMeta wrapperMeta : config.getWrappers())
{
System.out.println("Loading Wrapper " + wrapperMeta.getId() + " @ " + wrapperMeta.getHostName());
this.wrappers.put(wrapperMeta.getId(), new Wrapper(wrapperMeta));
}

this.users = config.getUsers();

NetworkUtils.addAll(this.serverGroups, config.getServerGroups(), new Acceptable<ServerGroup>() {
@Override
public boolean isAccepted(ServerGroup value)
Expand Down Expand Up @@ -177,7 +177,7 @@ public boolean isAccepted(ProxyGroup value)

RUNNING = true;
Runtime.getRuntime().addShutdownHook(new Thread(this));

{
if (!optionSet.has("onlyConsole"))
{
Expand Down Expand Up @@ -240,9 +240,9 @@ public void reload() throws Exception
this.users.clear();
this.serverGroups.clear();
this.proxyGroups.clear();

this.config.load();

this.users = config.getUsers();

NetworkUtils.addAll(this.serverGroups, config.getServerGroups(), new Acceptable<ServerGroup>() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ public CommandDebug()
public void onExecuteCommand(CommandSender sender, String[] args)
{
CloudNet.getLogger().setDebugging(!CloudNet.getLogger().isDebugging());
if (CloudNet.getLogger().isDebugging()) {
if (CloudNet.getLogger().isDebugging())
{
sender.sendMessage("debugging was enabled");
} else {
} else
{
sender.sendMessage("debugging was disabled");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import de.dytanic.cloudnet.lib.player.OfflinePlayer;
import de.dytanic.cloudnet.lib.player.PlayerCommandExecution;
import de.dytanic.cloudnet.lib.player.PlayerConnection;
import de.dytanic.cloudnet.lib.scheduler.TaskScheduler;
import de.dytanic.cloudnet.lib.server.ServerGroup;
import de.dytanic.cloudnet.lib.server.ServerGroupMode;
import de.dytanic.cloudnet.lib.server.SimpleServerGroup;
Expand Down Expand Up @@ -45,7 +46,6 @@
import java.util.Collection;
import java.util.LinkedList;
import java.util.UUID;
import java.util.concurrent.ExecutorService;

/**
* Created by Tareko on 19.07.2017.
Expand All @@ -56,7 +56,6 @@ public final class NetworkManager {
private java.util.Map<UUID, CloudPlayer> waitingPlayers = NetworkUtils.newConcurrentHashMap();
private java.util.Map<UUID, CloudPlayer> onlinePlayers = NetworkUtils.newConcurrentHashMap();
private Document moduleProperties = new Document();
private ExecutorService executorService = java.util.concurrent.Executors.newFixedThreadPool(4);

private MessageConfig messageConfig;

Expand Down Expand Up @@ -101,12 +100,14 @@ public void handlePlayerLoginRequest(ProxyServer proxyServer, PlayerConnection c
OfflinePlayer offlinePlayer = null;

CloudNet.getLogger().debug("player login request " + cloudPlayerConnection.getName() + "#" + uniqueId + " database contains");
if (!playerDatabase.containsPlayer(cloudPlayerConnection.getUniqueId())) {
if (!playerDatabase.containsPlayer(cloudPlayerConnection.getUniqueId()))
{
CloudNet.getLogger().debug("player login request " + cloudPlayerConnection.getName() + "#" + uniqueId + " database register");
offlinePlayer = playerDatabase.registerPlayer(cloudPlayerConnection);
}

if (offlinePlayer == null) {
if (offlinePlayer == null)
{
CloudNet.getLogger().debug("player login request " + cloudPlayerConnection.getName() + "#" + uniqueId + " database get");
offlinePlayer = playerDatabase.getPlayer(cloudPlayerConnection.getUniqueId());
}
Expand All @@ -115,7 +116,8 @@ public void handlePlayerLoginRequest(ProxyServer proxyServer, PlayerConnection c
CloudPlayer cloudPlayer = new CloudPlayer(offlinePlayer, cloudPlayerConnection, proxyServer.getServerId());
cloudPlayer.setPlayerExecutor(CorePlayerExecutor.INSTANCE);

if (cloudPlayer.getFirstLogin() == null) {
if (cloudPlayer.getFirstLogin() == null)
{
CloudNet.getLogger().debug("player login request " + cloudPlayerConnection.getName() + "#" + uniqueId + " set firstLogin");
cloudPlayer.setFirstLogin(System.currentTimeMillis());
}
Expand Down Expand Up @@ -350,7 +352,10 @@ public boolean accept(INetworkComponent networkComponent)

public NetworkManager sendAll(Packet packet, ChannelFilter filter)
{
this.executorService.submit(() -> {
TaskScheduler.runtimeScheduler().schedule(new Runnable() {
@Override
public void run()
{
for (Wrapper cn : CloudNet.getInstance().getWrappers().values())
{
if (cn.getChannel() != null && filter.accept(cn))
Expand All @@ -368,7 +373,9 @@ public NetworkManager sendAll(Packet packet, ChannelFilter filter)
if (cloudServer.getChannel() != null && filter.accept(cloudServer))
cloudServer.sendPacket(packet);

}});
}
}
});
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import de.dytanic.cloudnet.lib.network.protocol.packet.Packet;
import de.dytanic.cloudnet.lib.network.protocol.packet.PacketSender;
import de.dytanic.cloudnetcore.CloudNet;
import io.netty.channel.ChannelFutureListener;

/**
* Created by Tareko on 27.05.2017.
Expand All @@ -35,8 +36,8 @@ default void sendPacket(Packet packet)
{
try
{
getChannel().writeAndFlush(packet);
} catch (Exception ex)
getChannel().writeAndFlush(packet).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE);
} catch (Exception ignored)
{
}
} else
Expand All @@ -47,10 +48,9 @@ public void run()
{
try
{
getChannel().writeAndFlush(packet);
} catch (Exception ex)
getChannel().writeAndFlush(packet).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE);
} catch (Exception ignored)
{

}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void appendScreenData(Collection<ScreenInfo> screenInfos)
{
this.screenInfos.getS(key).addAll(screenInfos);

while (this.screenInfos.getS(key).size() > 64)
while (this.screenInfos.getS(key).size() >= 64)
this.screenInfos.getS(key).poll();
}
}
Expand Down
1 change: 1 addition & 0 deletions cloudnet-core/src/main/resources/files/log.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@




</style>
</head>
<body>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ public boolean tryConnect(boolean ssl, SimpleChannelInboundHandler<Packet> defau
{
try
{
if (ssl) sslContext = SslContextBuilder.forClient().trustManager(InsecureTrustManagerFactory.INSTANCE).build();
if (ssl)
sslContext = SslContextBuilder.forClient().trustManager(InsecureTrustManagerFactory.INSTANCE).build();

Bootstrap bootstrap = new Bootstrap()
.option(ChannelOption.AUTO_READ, true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,20 @@
package de.dytanic.cloudnetwrapper.handlers;

import de.dytanic.cloudnet.lib.server.screen.ScreenInfo;
import de.dytanic.cloudnetwrapper.CloudNetWrapper;
import de.dytanic.cloudnetwrapper.network.packet.out.PacketOutSendScreenLine;
import de.dytanic.cloudnetwrapper.screen.AbstractScreenService;
import de.dytanic.cloudnetwrapper.server.BungeeCord;
import de.dytanic.cloudnetwrapper.server.CloudGameServer;
import de.dytanic.cloudnetwrapper.server.GameServer;
import de.dytanic.cloudnetwrapper.server.process.ServerDispatcher;

import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.Collections;

public final class ReadConsoleLogHandler implements IWrapperHandler {

private final StringBuffer stringBuffer = new StringBuffer();

private final byte[] buffer = new byte[1024];

private int len;

@Override
public void run(CloudNetWrapper obj)
{
Expand All @@ -36,32 +31,36 @@ public void run(CloudNetWrapper obj)
readConsoleLog(gameServer);
}

private synchronized void readConsoleLog(ServerDispatcher server)
private synchronized void readConsoleLog(AbstractScreenService server)
{
if (server.getInstance().isAlive() && server.getInstance().getInputStream() != null)
{
try
{
readStream(server, server.getInstance().getInputStream());
readStream(server, server.getInstance().getErrorStream());
}
}

InputStream inputStream = server.getInstance().getInputStream();
private synchronized void readStream(AbstractScreenService screenService, InputStream inputStream)
{
try
{
int len;
while (inputStream.available() > 0 && (len = inputStream.read(buffer, 0, buffer.length)) != -1)
stringBuffer.append(new String(buffer, 0, len, StandardCharsets.UTF_8));

String stringText = stringBuffer.toString();
if (!stringText.contains("\n") && !stringText.contains("\r")) return;

while (inputStream.available() > 0 && (len = inputStream.read(buffer, 0, buffer.length)) != -1)
stringBuffer.append(new String(buffer, 0, len, StandardCharsets.UTF_8));
for (String input : stringText.split("\r"))
for (String text : input.split("\n"))
if (!text.trim().isEmpty())
screenService.addCachedItem(text);

for (String input : stringBuffer.toString().split("\r"))
for (String text : input.split("\n"))
if (!text.trim().isEmpty())
{
CloudNetWrapper.getInstance().getNetworkConnection()
.sendPacket(new PacketOutSendScreenLine(Collections.singletonList(new ScreenInfo(server.getServiceId(), input))));
}
stringBuffer.setLength(0);

} catch (Exception ignored)
{
} finally
{
stringBuffer.setLength(0);
}
} catch (Exception ignored)
{
stringBuffer.setLength(0);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,41 +4,47 @@

package de.dytanic.cloudnetwrapper.network.packet.in;

import com.google.gson.reflect.TypeToken;
import de.dytanic.cloudnet.lib.DefaultType;
import de.dytanic.cloudnet.lib.network.protocol.packet.PacketInHandler;
import de.dytanic.cloudnet.lib.network.protocol.packet.PacketSender;
import de.dytanic.cloudnet.lib.server.info.ProxyInfo;
import de.dytanic.cloudnet.lib.server.info.ServerInfo;
import de.dytanic.cloudnet.lib.utility.document.Document;
import de.dytanic.cloudnetwrapper.CloudNetWrapper;
import de.dytanic.cloudnetwrapper.server.BungeeCord;
import de.dytanic.cloudnetwrapper.server.GameServer;

public final class PacketInScreen extends PacketInHandler {

@Override
public void handleInput(Document data, PacketSender packetSender)
{
/*
if (data.getObject("type", DefaultType.class) != DefaultType.BUNGEE_CORD)
{
ServerInfo server = data.getObject("serverInfo", new TypeToken<ServerInfo>() {
}.getType());
if (CloudNetWrapper.getInstance().getServers().containsKey(server.getServiceId().getServerId()))
{
GameServer gameServer = CloudNetWrapper.getInstance().getServers().get(server.getServiceId().getServerId());

if (data.getBoolean("enable"))
CloudNetWrapper.getInstance().getScreenProvider().putScreenRequest(gameServer);
gameServer.enableScreenSystem();
else
CloudNetWrapper.getInstance().getScreenProvider().cancel(gameServer);
gameServer.disableScreenSystem();
}
} else
{
ProxyInfo server = data.getObject("proxyInfo", new TypeToken<ProxyInfo>() {
}.getType());
if (CloudNetWrapper.getInstance().getProxys().containsKey(server.getServiceId().getServerId()))
{
BungeeCord gameServer = CloudNetWrapper.getInstance().getProxys().get(server.getServiceId().getServerId());
BungeeCord bungee = CloudNetWrapper.getInstance().getProxys().get(server.getServiceId().getServerId());
if (data.getBoolean("enable"))
CloudNetWrapper.getInstance().getScreenProvider().putScreenRequest(gameServer);
else if (CloudNetWrapper.getInstance().getScreenProvider().contains(gameServer))
CloudNetWrapper.getInstance().getScreenProvider().cancel(gameServer);
bungee.enableScreenSystem();
else
bungee.disableScreenSystem();
}
}
*/
}
}
Loading

0 comments on commit 74d5490

Please sign in to comment.