Skip to content

Commit

Permalink
misc: rename some methods
Browse files Browse the repository at this point in the history
  • Loading branch information
MemencioPerez committed Nov 7, 2024
1 parent 9aaed8d commit 3e89a1a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public void onProxyInitialize(ProxyInitializeEvent event) {
}
}

setupLoadablePacketListeners();
setupConfigurablePacketListeners();

CommandManager commandManager = server.getCommandManager();
CommandMeta commandMeta = commandManager.metaBuilder("unsignedvelocity")
Expand All @@ -94,12 +94,16 @@ public void onProxyInitialize(ProxyInitializeEvent event) {

logger.info(miniMessage().deserialize(
"<gradient:#166D3B:#7F8C8D:#A29BFE>UnSignedVelocity</gradient> <#6892bd>has been successfully loaded"));
getPluginStatus(configuration).forEach(logger::info);
getPluginStatusMessages().forEach(logger::info);

UpdateChecker updateChecker = new UpdateChecker(logger);
updateChecker.checkForUpdates();
}

public void setupConfiguration() throws IOException {
this.configuration = Configuration.loadConfig(dataDirectory);
}

private void forciblyDisableForceKeyAuthentication() throws NoSuchFieldException, IllegalAccessException {
VelocityConfiguration velocityConfiguration = ((VelocityServer) server).getConfiguration();
Field forceKeyAuthenticationField = velocityConfiguration.getClass().getDeclaredField("forceKeyAuthentication");
Expand All @@ -116,11 +120,7 @@ private void forciblyDisableForceKeyAuthentication() throws NoSuchFieldException
}
}

public void setupConfiguration() throws IOException {
this.configuration = Configuration.loadConfig(dataDirectory);
}

public void setupLoadablePacketListeners() {
public void setupConfigurablePacketListeners() {
if (this.packetListeners != null && !this.packetListeners.isEmpty()) {
packetListeners.forEach(ConfigurablePacketListener::unregister);
}
Expand All @@ -142,7 +142,7 @@ public void setupLoadablePacketListeners() {
this.packetListeners = packetListeners;
}

public List<Component> getPluginStatus(Configuration configuration) {
public List<Component> getPluginStatusMessages() {
return List.of(
miniMessage().deserialize(
"<#6892bd>Remove Signed Key: <aqua>" + configuration.removeSignedKeyOnJoin()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public static BrigadierCommand createBrigadierCommand(final UnSignedVelocity plu
Component message;
try {
plugin.setupConfiguration();
plugin.setupLoadablePacketListeners();
plugin.setupConfigurablePacketListeners();
message = miniMessage().deserialize("<gradient:#166D3B:#7F8C8D:#A29BFE>UnSignedVelocity</gradient> <#6892bd>has been successfully reloaded");
} catch (IOException e) {
message = miniMessage().deserialize("<gradient:#166D3B:#7F8C8D:#A29BFE>UnSignedVelocity</gradient> <#6892bd>configuration failed to load, check your configuration file and try again");
Expand All @@ -52,7 +52,7 @@ public static BrigadierCommand createBrigadierCommand(final UnSignedVelocity plu
yield Command.SINGLE_SUCCESS;
}
case "status" -> {
plugin.getPluginStatus(plugin.getConfiguration()).forEach(source::sendMessage);
plugin.getPluginStatusMessages().forEach(source::sendMessage);
yield Command.SINGLE_SUCCESS;
}
default -> BrigadierCommand.FORWARD;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public void onPacketReceive(PacketReceiveEvent event) {
final User user = event.getUser();
final PacketTypeCommon packetType = event.getPacketType();
if (packetType == PacketType.Login.Client.LOGIN_START) {
if (ClientVersionUtil.doesNotEnforceSignedChatOnLogin(user)) {
if (ClientVersionUtil.doesNotEnforceKeyAuthentication(user)) {
return;
}

Expand All @@ -66,7 +66,7 @@ public void onPacketReceive(PacketReceiveEvent event) {
packet.setSignatureData(null);
event.markForReEncode(true);
} else if (packetType == PacketType.Login.Client.ENCRYPTION_RESPONSE) {
if (ClientVersionUtil.doesNotEnforceSignedChatOnLogin(user)) {
if (ClientVersionUtil.doesNotEnforceKeyAuthentication(user)) {
return;
}

Expand All @@ -90,7 +90,7 @@ public void onPacketSend(PacketSendEvent event) {
final User user = event.getUser();
final PacketTypeCommon packetType = event.getPacketType();
if (packetType == PacketType.Login.Server.ENCRYPTION_REQUEST) {
if (ClientVersionUtil.doesNotEnforceSignedChatOnLogin(user)) {
if (ClientVersionUtil.doesNotEnforceKeyAuthentication(user)) {
return;
}
WrapperLoginServerEncryptionRequest packet = new WrapperLoginServerEncryptionRequest(event);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import com.github.retrooper.packetevents.protocol.player.User;

public class ClientVersionUtil {
public static boolean doesNotEnforceSignedChatOnLogin(final User user) {
public static boolean doesNotEnforceKeyAuthentication(final User user) {
ClientVersion userClientVersion = user.getClientVersion();
return ClientVersionUtil.isNotOneOf(userClientVersion, ClientVersion.V_1_19, ClientVersion.V_1_19_1);
}
Expand Down

0 comments on commit 3e89a1a

Please sign in to comment.