Fix naming of some things and comments

This commit is contained in:
s809
2024-09-17 09:42:22 +05:00
parent 79d2269218
commit 5369bf628a
9 changed files with 27 additions and 15 deletions
@@ -102,10 +102,14 @@ public class DarkModeDetector
for (String de : de_location.list())
{
// System.out.println(de);
if (de.contains("gnome-networkSession")) // Gnome uses GTK
if (de.contains("gnome-session")) // Gnome uses GTK
{
return GTKChecker();
}
if (de.contains("plasma_session")) // KDE plasma uses QT
{
return QTChecker();
}
}
return GTKChecker(); // GTK works best with non plasma desktops (desktops includes window managers)
}
@@ -134,7 +138,9 @@ public class DarkModeDetector
while (themeLine != null)
{ // Go through each line till you find "KWinPalette\activeBackground"
if (themeLine.contains("KWinPalette\\activeBackground"))
{
break;
}
themeLine = reader.readLine();
}
reader.close();
@@ -145,9 +151,13 @@ public class DarkModeDetector
short g = (short) Integer.parseInt("" + themeLine.charAt(index + 3) + themeLine.charAt(index + 4), 16);
short b = (short) Integer.parseInt("" + themeLine.charAt(index + 5) + themeLine.charAt(index + 6), 16);
if ((r + g + b) / 2 >= 128)
{
return false;
}
else
{
return true;
}
}
catch (Exception e)
{
@@ -170,7 +180,9 @@ public class DarkModeDetector
while ((actualReadLine = reader.readLine()) != null)
{
if (stringBuilder.length() != 0)
{
stringBuilder.append('\n');
}
stringBuilder.append(actualReadLine);
}
}
@@ -55,7 +55,7 @@ public interface INetworkObject
@Contract("_, null -> false; _, !null -> true")
default boolean tryWrite(ByteBuf outputByteBuf, Object value)
default boolean writeOptional(ByteBuf outputByteBuf, Object value)
{
boolean isNull = value != null;
outputByteBuf.writeBoolean(isNull);
@@ -63,13 +63,13 @@ public interface INetworkObject
}
@Nullable
default <T> T tryRead(ByteBuf inputByteBuf, Supplier<T> decoder)
default <T> T readOptional(ByteBuf inputByteBuf, Supplier<T> decoder)
{
return inputByteBuf.readBoolean()
? decoder.get()
: null;
}
default void tryRead(ByteBuf inputByteBuf, Runnable decoder)
default void readOptional(ByteBuf inputByteBuf, Runnable decoder)
{
if (inputByteBuf.readBoolean())
{
@@ -95,7 +95,7 @@ public abstract class AbstractTrackableMessage extends AbstractNetworkMessage
public void setSession(NetworkSession networkSession)
{
super.setSession(networkSession);
// networkSession ID is written in the most significant bits
// Session ID is written in the most significant bits
this.futureId |= (long) networkSession.id << 32;
}
@@ -64,7 +64,7 @@ public class FullDataSourceRequestMessage extends AbstractTrackableMessage imple
{
this.writeString(this.levelName, out);
out.writeLong(this.sectionPos);
if (this.tryWrite(out, this.clientTimestamp))
if (this.writeOptional(out, this.clientTimestamp))
{
out.writeLong(this.clientTimestamp);
}
@@ -75,7 +75,7 @@ public class FullDataSourceRequestMessage extends AbstractTrackableMessage imple
{
this.levelName = this.readString(in);
this.sectionPos = in.readLong();
this.clientTimestamp = this.tryRead(in, in::readLong);
this.clientTimestamp = this.readOptional(in, in::readLong);
}
@@ -58,14 +58,14 @@ public class FullDataSourceResponseMessage extends AbstractTrackableMessage
@Override
public void encodeInternal(ByteBuf out)
{
if (this.tryWrite(out, this.payload))
if (this.writeOptional(out, this.payload))
{
this.payload.encode(out);
}
}
@Override
public void decodeInternal(ByteBuf in) { this.payload = this.tryRead(in, () -> INetworkObject.decodeToInstance(new FullDataPayload(), in)); }
public void decodeInternal(ByteBuf in) { this.payload = this.readOptional(in, () -> INetworkObject.decodeToInstance(new FullDataPayload(), in)); }
@@ -134,11 +134,11 @@ public class NetworkSession extends AbstractNetworkEventSource
{
if (this.serverPlayer != null)
{
PACKET_SENDER.sendPluginServerPacket(this.serverPlayer, message);
PACKET_SENDER.sendToClient(this.serverPlayer, message);
}
else
{
PACKET_SENDER.sendPluginClientPacket(message);
PACKET_SENDER.sendToServer(message);
}
}
catch (Throwable throwable)
@@ -2,7 +2,7 @@ package com.seibel.distanthorizons.core.network.session;
import java.io.IOException;
/** The exception thrown if DH's networking networkSession has been shut down. */
/** The exception thrown if DH's networking session has been shut down. */
public class SessionClosedException extends IOException
{
public SessionClosedException(String message) { super(message); }
@@ -80,7 +80,7 @@ public class DhServerWorld extends AbstractDhWorld implements IDhServerWorld
this.getLevel(serverPlayer.getLevel()).removePlayer(serverPlayer);
this.remotePlayerConnectionHandler.unregisterLeftPlayer(serverPlayer);
// If player's left, networkSession is already closed
// If player's left, session is already closed
}
public void changePlayerLevel(IServerPlayerWrapper player, IServerLevelWrapper originLevel, IServerLevelWrapper destinationLevel)
@@ -6,8 +6,8 @@ import com.seibel.distanthorizons.coreapi.interfaces.dependencyInjection.IBindab
public interface IPluginPacketSender extends IBindable
{
/** Sends a packet from the client */
void sendPluginClientPacket(AbstractNetworkMessage message);
void sendToServer(AbstractNetworkMessage message);
/** Sends a packet from the server */
void sendPluginServerPacket(IServerPlayerWrapper serverPlayer, AbstractNetworkMessage message);
void sendToClient(IServerPlayerWrapper serverPlayer, AbstractNetworkMessage message);
}