Spaces at the start of line comments

This commit is contained in:
Jaime Martinez Rincon 2020-06-20 22:28:24 +02:00
parent 29099a493f
commit 2d2a7d8f9e
15 changed files with 57 additions and 61 deletions

View File

@ -19,7 +19,7 @@ public class PlayerBalancerAddon extends JavaPlugin {
@Override
public void onDisable() {
//Nothing to do...
// Nothing to do...
}
public PluginMessageManager getManager() {

View File

@ -22,8 +22,8 @@ public class PlayerBalancerPlaceholderExpansion extends PlaceholderExpansion {
if (section == null)
return null;
//For the first call this placeholder will return 0
//For the next one, the result of the previous one
// For the first call this placeholder will return 0
// For the next one, the result of the previous one
plugin.getManager().getSectionPlayerCount(section, (count) -> {
sectionPlayerCounts.put(section, count);
});

View File

@ -27,7 +27,7 @@ public class PluginMessageManager implements PluginMessageListener {
plugin.getServer().getMessenger().registerIncomingPluginChannel(plugin, PB_CHANNEL, this);
plugin.getServer().getMessenger().registerOutgoingPluginChannel(plugin, PB_CHANNEL);
//In case we need to use BungeeCord channels
// In case we need to use BungeeCord channels
plugin.getServer().getMessenger().registerIncomingPluginChannel(plugin, BC_CHANNEL, this);
plugin.getServer().getMessenger().registerOutgoingPluginChannel(plugin, BC_CHANNEL);
}

View File

@ -78,7 +78,7 @@ public class PlayerBalancer extends Plugin {
public boolean checkUpToDate() {
try {
URLConnection con = new URL("https://api.spigotmc.org/legacy/update.php?resource=10788").openConnection();
URLConnection con = new URL("https:// api.spigotmc.org/legacy/update.php?resource=10788").openConnection();
String reply = new BufferedReader(new InputStreamReader(con.getInputStream())).readLine();
return getDescription().getVersion().equals(reply);
} catch (IOException e) {
@ -89,7 +89,7 @@ public class PlayerBalancer extends Plugin {
@Override
public void onDisable() {
//Nothing else to do than normal stop
// Nothing else to do than normal stop
this.execStop();
}
@ -198,7 +198,7 @@ public class PlayerBalancer extends Plugin {
}
if (settings.getGeneralProps().isEnabled()) {
//Do not try to do anything if the plugin has not loaded correctly
// Do not try to do anything if the plugin has not loaded correctly
if (failed) return;
if (settings.getGeneralProps().isAutoReload()) {

View File

@ -39,14 +39,10 @@ public abstract class ConnectionIntent {
.replace("{alias}", safeNull(section.getProps().getAlias()))
);
// Ensure a new copy of the section servers
List<ServerInfo> servers = new ArrayList<>(section.getServers());
//Prevents removing servers from the section
if (servers == section.getServers()) {
throw new IllegalStateException("The servers list parameter is the same reference, this cannot happen");
}
//Prevents connections to the same server
// Prevents connections to the same server
Server current = player.getServer();
if (current != null) {
servers.remove(current.getInfo());
@ -56,7 +52,7 @@ public abstract class ConnectionIntent {
ServerInfo target = this.fetchServer(player, section, section.getImplicitProvider(), servers);
if (target != null) {
this.connect(target, (response, throwable) -> {
if (response) { //only if the connect has been executed correctly
if (response) { // only if the connect has been executed correctly
MessageUtils.send(player, plugin.getSettings().getMessagesProps().getConnectedMessage(),
(str) -> str.replace("{server}", target.getName())
.replace("{section}", section.getName())

View File

@ -37,7 +37,7 @@ public enum PasteHelper {
try (FileInputStream stream = new FileInputStream(file)) {
try (InputStreamReader reader = new InputStreamReader(stream, "UTF-8")) {
String content = CharStreams.toString(reader);
HastebinPaste paste = new HastebinPaste("https://file.properties/paste/", content);
HastebinPaste paste = new HastebinPaste("https:// file.properties/paste/", content);
return paste.paste();
}
}
@ -62,7 +62,7 @@ public enum PasteHelper {
try (InputStreamReader reader = new InputStreamReader(stream, StandardCharsets.UTF_8)) {
String content = CharStreams.toString(reader);
content = content.replaceAll("[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}", "?.?.?.?");
HastebinPaste paste = new HastebinPaste("https://file.properties/paste/", content);
HastebinPaste paste = new HastebinPaste("https:// file.properties/paste/", content);
return paste.paste();
}
}
@ -86,7 +86,7 @@ public enum PasteHelper {
try (FileInputStream stream = new FileInputStream(file)) {
try (InputStreamReader reader = new InputStreamReader(stream, StandardCharsets.UTF_8)) {
String content = CharStreams.toString(reader);
HastebinPaste paste = new HastebinPaste("https://file.properties/paste/", content);
HastebinPaste paste = new HastebinPaste("https:// file.properties/paste/", content);
return paste.paste();
}
}

View File

@ -31,7 +31,7 @@ public class PluginMessageListener implements Listener {
this.plugin = plugin;
GsonBuilder builder = new GsonBuilder();
//Only serialize the name of ServerInfo
// Only serialize the name of ServerInfo
builder.registerTypeAdapter(ServerInfo.class, (JsonSerializer<ServerInfo>) (server, type, context) ->
context.serialize(server.getName())
);

View File

@ -56,7 +56,7 @@ public class ServerConnectListener implements Listener {
ServerSection section = plugin.getSectionManager().getByServer(target);
if (section != null) {
//Checks only for servers (not the section server)
// Checks only for servers (not the section server)
if (!target.equals(section.getServer())) {
if (plugin.getSectionManager().isDummy(section)) {
return null;

View File

@ -37,7 +37,7 @@ public enum PingTactic {
try {
server.ping((ping, throwable) -> {
if (ping != null) {
//using deprecated method for bungee 1.8 compatibility
// Using deprecated method for bungee 1.8 compatibility
callback.done(new ServerStatus(
ping.getDescription(),
ping.getPlayers().getOnline(),

View File

@ -236,8 +236,8 @@ public class SectionManager {
public void registerServer(ServerInfo server, ServerSection section) {
if (!isDummy(section)) {
// Checking for already we already added this server to other section
// This can only happen if another non dummy section registers this server
// Checking for already we already added this server to other section
// This can only happen if another non dummy section registers this server
if (servers.containsKey(server)) {
ServerSection other = servers.get(server);
throw new IllegalArgumentException(String.format(
@ -259,7 +259,7 @@ public class SectionManager {
public void calculateServers(ServerSection section) {
Set<ServerInfo> results = new HashSet<>();
//Searches for matches
// Searches for matches
section.getProps().getServerEntries().forEach(entry -> {
Pattern pattern = Pattern.compile(entry);
plugin.getProxy().getServers().forEach((name, server) -> {
@ -270,7 +270,7 @@ public class SectionManager {
});
});
//Checks if there are servers previously matched that are no longer valid
// Checks if there are servers previously matched that are no longer valid
section.getServers().forEach(server -> {
if (!results.contains(server)) {
servers.remove(server);
@ -281,7 +281,7 @@ public class SectionManager {
}
});
//Add matched servers to the section
// Add matched servers to the section
int addedServers = 0;
for (ServerInfo server : results) {
if (!section.getServers().contains(server)) {
@ -306,7 +306,7 @@ public class SectionManager {
public int calculatePosition(ServerSection section) {
ServerSection current = section;
//Calculate above principal
// Calculate above principal
int iterations = 0;
while (current != null) {
if (current == principal) {
@ -317,7 +317,7 @@ public class SectionManager {
iterations++;
}
//Calculate below principal
// Calculate below principal
if (principal != null) {
iterations = 0;
current = principal;

View File

@ -47,7 +47,7 @@ public class SectionServer extends BungeeServerInfo {
@Override
public boolean sendData(String channel, byte[] data, boolean queue) {
//Nothing to do
// Nothing to do
return true;
}

View File

@ -11,7 +11,7 @@ public class AdapterWrapper implements ConfigurationAdapter {
private final ConfigurationAdapter wrapped;
public AdapterWrapper(ConfigurationAdapter adapter) {
//Prevents memory leak
// Prevents memory leak
if (adapter instanceof AdapterWrapper) {
this.wrapped = ((AdapterWrapper) adapter).wrapped;
} else {

View File

@ -98,14 +98,14 @@ public class AlphanumComparator implements Comparator<String>
String thatChunk = getChunk(s2, s2Length, thatMarker);
thatMarker += thatChunk.length();
// If both chunks contain numeric characters, sort them numerically
// If both chunks contain numeric characters, sort them numerically
int result = 0;
if (isDigit(thisChunk.charAt(0)) && isDigit(thatChunk.charAt(0)))
{
// Simple chunk comparison by length.
// Simple chunk comparison by length.
int thisChunkLength = thisChunk.length();
result = thisChunkLength - thatChunk.length();
// If equal, the first different number counts
// If equal, the first different number counts
if (result == 0)
{
for (int i = 0; i < thisChunkLength; i++)

View File

@ -20,35 +20,35 @@ public final class LevenshteinDistance {
int len0 = lhs.length() + 1;
int len1 = rhs.length() + 1;
// the array of distances
// the array of distances
int[] cost = new int[len0];
int[] newcost = new int[len0];
// initial cost of skipping prefix in String s0
// initial cost of skipping prefix in String s0
for (int i = 0; i < len0; i++) cost[i] = i;
// dynamically computing the array of distances
// dynamically computing the array of distances
// transformation cost for each letter in s1
// transformation cost for each letter in s1
for (int j = 1; j < len1; j++) {
// initial cost of skipping prefix in String s1
// initial cost of skipping prefix in String s1
newcost[0] = j;
// transformation cost for each letter in s0
// transformation cost for each letter in s0
for (int i = 1; i < len0; i++) {
// matching current letters in both strings
// matching current letters in both strings
int match = (lhs.charAt(i - 1) == rhs.charAt(j - 1)) ? 0 : 1;
// computing cost for each transformation
// computing cost for each transformation
int cost_replace = cost[i - 1] + match;
int cost_insert = cost[i] + 1;
int cost_delete = newcost[i - 1] + 1;
// keep minimum cost
// keep minimum cost
newcost[i] = Math.min(Math.min(cost_insert, cost_delete), cost_replace);
}
// swap cost/newcost arrays
// swap cost/newcost arrays
int[] swap = cost;
cost = newcost;
newcost = swap;

View File

@ -56,31 +56,31 @@ public final class ServerListPing {
DataInputStream dataInputStream = new DataInputStream(socket.getInputStream())) {
ByteArrayOutputStream b = new ByteArrayOutputStream();
DataOutputStream handshake = new DataOutputStream(b);
handshake.writeByte(0x00); //packet id for handshake
writeVarInt(handshake, 4); //protocol version
writeVarInt(handshake, host.getHostString().length()); //host length
handshake.writeBytes(host.getHostString()); //host string
handshake.writeShort(host.getPort()); //port
writeVarInt(handshake, 1); //state (1 for handshake)
handshake.writeByte(0x00); // packet id for handshake
writeVarInt(handshake, 4); // protocol version
writeVarInt(handshake, host.getHostString().length()); // host length
handshake.writeBytes(host.getHostString()); // host string
handshake.writeShort(host.getPort()); // port
writeVarInt(handshake, 1); // state (1 for handshake)
writeVarInt(dataOutputStream, b.size()); //prepend size
dataOutputStream.write(b.toByteArray()); //write handshake packet
writeVarInt(dataOutputStream, b.size()); // prepend size
dataOutputStream.write(b.toByteArray()); // write handshake packet
dataOutputStream.writeByte(0x01); //size is only 1
dataOutputStream.writeByte(0x00); //packet id for ping
int size = readVarInt(dataInputStream); //size of packet
int id = readVarInt(dataInputStream); //packet id
dataOutputStream.writeByte(0x01); // size is only 1
dataOutputStream.writeByte(0x00); // packet id for ping
int size = readVarInt(dataInputStream); // size of packet
int id = readVarInt(dataInputStream); // packet id
if (id == -1) {
throw new IOException("Premature end of stream.");
}
if (id != 0x00) { //we want a status response
if (id != 0x00) { // we want a status response
throw new IOException("Invalid packetID");
}
int length = readVarInt(dataInputStream); //length of json string
int length = readVarInt(dataInputStream); // length of json string
if (length == -1) {
throw new IOException("Premature end of stream.");
}
@ -90,14 +90,14 @@ public final class ServerListPing {
}
byte[] in = new byte[length];
dataInputStream.readFully(in); //read json string
dataInputStream.readFully(in); // read json string
String json = new String(in);
long now = System.currentTimeMillis();
dataOutputStream.writeByte(0x09); //size of packet
dataOutputStream.writeByte(0x01); //0x01 for ping
dataOutputStream.writeLong(now); //time!?
dataOutputStream.writeByte(0x09); // size of packet
dataOutputStream.writeByte(0x01); // 0x01 for ping
dataOutputStream.writeLong(now); // time!?
readVarInt(dataInputStream);
id = readVarInt(dataInputStream);
@ -109,7 +109,7 @@ public final class ServerListPing {
throw new IOException("Invalid packetID");
}
long pingTime = dataInputStream.readLong(); //read response
long pingTime = dataInputStream.readLong(); // read response
StatusResponse response = gson.fromJson(json, StatusResponse.class);
response.time = (int) (now - pingTime);
return response;