-
Notifications
You must be signed in to change notification settings - Fork 33
Merge development into master branch #96
Changes from 3 commits
ce0fe62
d4a865c
5707852
99649e1
1af764e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Avoid deeply nested control flow statements. |
||
this.screenInfos.getS(key).poll(); | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,7 @@ | |
|
||
|
||
|
||
|
||
</style> | ||
</head> | ||
<body> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,7 +67,8 @@ public boolean tryConnect(boolean ssl, SimpleChannelInboundHandler<Packet> defau | |
{ | ||
try | ||
{ | ||
if (ssl) sslContext = SslContextBuilder.forClient().trustManager(InsecureTrustManagerFactory.INSTANCE).build(); | ||
if (ssl) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 'if' construct must use '{}'s. |
||
sslContext = SslContextBuilder.forClient().trustManager(InsecureTrustManagerFactory.INSTANCE).build(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line is longer than 100 characters (found 118). |
||
|
||
Bootstrap bootstrap = new Bootstrap() | ||
.option(ChannelOption.AUTO_READ, true) | ||
|
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) | ||
{ | ||
|
@@ -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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line is longer than 100 characters (found 102). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Method |
||
{ | ||
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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 'if' construct must use '{}'s. |
||
|
||
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")) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 'for' construct must use '{}'s. |
||
for (String text : input.split("\n")) | ||
if (!text.trim().isEmpty()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 'if' construct must use '{}'s. |
||
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); | ||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make this anonymous inner class a lambda (sonar.java.source not set. Assuming 8 or greater.)