refactor: make packetReceived listeners private

Intelligent IDEA Replacing Feature.
This commit is contained in:
ChomeNS
2025-03-31 16:55:52 +07:00
parent dddead69ba
commit bb0900eeb6
13 changed files with 37 additions and 37 deletions

View File

@@ -1 +1 @@
2307
2309

View File

@@ -229,13 +229,13 @@ public class Bot extends SessionAdapter {
else if (packet instanceof ClientboundCustomPayloadPacket t_packet) packetReceived(t_packet);
}
public void packetReceived (ClientboundLoginFinishedPacket packet) {
private void packetReceived (ClientboundLoginFinishedPacket packet) {
profile = packet.getProfile();
session.setFlag(BuiltinFlags.CLIENT_TRANSFERRING, false);
}
public void packetReceived (ClientboundLoginPacket ignoredPacket) {
private void packetReceived (ClientboundLoginPacket ignoredPacket) {
loggedIn = true;
loginTime = System.currentTimeMillis();
@@ -248,11 +248,11 @@ public class Bot extends SessionAdapter {
if (options.creayun) chat.send("/server creative");
}
public void packetReceived (ClientboundCustomQueryPacket packet) {
private void packetReceived (ClientboundCustomQueryPacket packet) {
session.send(new ServerboundCustomQueryAnswerPacket(packet.getMessageId(), null));
}
public void packetReceived (ClientboundCustomPayloadPacket packet) {
private void packetReceived (ClientboundCustomPayloadPacket packet) {
if (!packet.getChannel().asString().equals("minecraft:register")) return;
session.send(
@@ -263,7 +263,7 @@ public class Bot extends SessionAdapter {
);
}
public void packetReceived (ClientboundCookieRequestPacket packet) {
private void packetReceived (ClientboundCookieRequestPacket packet) {
session.send(
new ServerboundCookieResponsePacket(
packet.getKey(),
@@ -272,11 +272,11 @@ public class Bot extends SessionAdapter {
);
}
public void packetReceived (ClientboundStoreCookiePacket packet) {
private void packetReceived (ClientboundStoreCookiePacket packet) {
cookies.put(packet.getKey(), packet.getPayload());
}
public void packetReceived (ClientboundTransferPacket ignoredPacket) {
private void packetReceived (ClientboundTransferPacket ignoredPacket) {
this.isTransferring = true;
session.disconnect(Component.translatable("disconnect.transfer"));
@@ -284,7 +284,7 @@ public class Bot extends SessionAdapter {
// we're not meant to send client information at finish configuration,
// but if it works it works™
public void packetReceived (ClientboundFinishConfigurationPacket ignoredPacket) {
private void packetReceived (ClientboundFinishConfigurationPacket ignoredPacket) {
// for voicechat
session.send(new ServerboundCustomPayloadPacket(
Key.key("minecraft:brand"),
@@ -319,7 +319,7 @@ public class Bot extends SessionAdapter {
// they actually implemented this, but at this commit:
// https://github.com/GeyserMC/MCProtocolLib/commit/f8460356db2b92fbf7cb506757fe8f87a011a1f7#diff-a9066adbcb6d5503f5edefe3ec95465cf755f1585e02b732a6fa907afe7c7177R67-L103
// they removed it, for some reason
public void packetReceived (ClientboundLoginCompressionPacket packet) {
private void packetReceived (ClientboundLoginCompressionPacket packet) {
if (packet.getThreshold() < 0) {
session.setCompression(null);
}

View File

@@ -40,11 +40,11 @@ public class BossbarManagerPlugin extends Bot.Listener implements PlayersPlugin.
}
@Override
public void packetReceived(Session session, Packet packet) {
public void packetReceived (Session session, Packet packet) {
if (packet instanceof ClientboundBossEventPacket t_packet) packetReceived(t_packet);
}
public void packetReceived(ClientboundBossEventPacket packet) {
private void packetReceived (ClientboundBossEventPacket packet) {
if (!enabled || actionBar || !bot.options.useCore) return;
try {

View File

@@ -84,7 +84,7 @@ public class ChatPlugin extends Bot.Listener {
else if (packet instanceof ClientboundRegistryDataPacket t_packet) packetReceived(t_packet);
}
public void packetReceived (ClientboundSystemChatPacket packet) {
private void packetReceived (ClientboundSystemChatPacket packet) {
final Component component = packet.getContent();
if (
@@ -169,7 +169,7 @@ public class ChatPlugin extends Bot.Listener {
);
}
public void packetReceived (ClientboundPlayerChatPacket packet) {
private void packetReceived (ClientboundPlayerChatPacket packet) {
final UUID senderUUID = packet.getSender();
final PlayerEntry entry = bot.players.getEntry(senderUUID);
@@ -208,7 +208,7 @@ public class ChatPlugin extends Bot.Listener {
}
}
public void packetReceived (ClientboundDisguisedChatPacket packet) {
private void packetReceived (ClientboundDisguisedChatPacket packet) {
final Component component = packet.getMessage();
PlayerMessage parsedFromMessage = null;

View File

@@ -48,7 +48,7 @@ public class ExtrasMessengerPlugin extends Bot.Listener {
if (packet instanceof ClientboundCustomPayloadPacket t_packet) packetReceived(t_packet);
}
public void packetReceived (ClientboundCustomPayloadPacket packet) {
private void packetReceived (ClientboundCustomPayloadPacket packet) {
final Key packetChannel = packet.getChannel();
if (packetChannel.equals(MINECRAFT_REGISTER_KEY)) {

View File

@@ -49,7 +49,7 @@ public class PlayersPlugin extends Bot.Listener implements TickPlugin.Listener {
else if (packet instanceof ClientboundPlayerInfoRemovePacket t_packet) packetReceived(t_packet);
}
public void packetReceived (ClientboundPlayerInfoUpdatePacket packet) {
private void packetReceived (ClientboundPlayerInfoUpdatePacket packet) {
final EnumSet<PlayerListEntryAction> actions = packet.getActions();
for (PlayerListEntryAction action : actions) {
@@ -64,7 +64,7 @@ public class PlayersPlugin extends Bot.Listener implements TickPlugin.Listener {
}
}
public void packetReceived (ClientboundPlayerInfoRemovePacket packet) {
private void packetReceived (ClientboundPlayerInfoRemovePacket packet) {
final List<UUID> uuids = packet.getProfileIds();
for (UUID uuid : uuids) removePlayer(uuid);

View File

@@ -70,7 +70,7 @@ public class PositionPlugin extends Bot.Listener implements TickPlugin.Listener
else if (packet instanceof ClientboundEntityPositionSyncPacket t_packet) packetReceived(t_packet);
}
public void packetReceived (ClientboundPlayerPositionPacket packet) {
private void packetReceived (ClientboundPlayerPositionPacket packet) {
if (bot.session != null) bot.session.send(new ServerboundAcceptTeleportationPacket(packet.getId()));
position = packet.getPosition();
@@ -78,7 +78,7 @@ public class PositionPlugin extends Bot.Listener implements TickPlugin.Listener
for (Listener listener : listeners) { listener.positionChange(position); }
}
public void packetReceived (ClientboundAddEntityPacket packet) {
private void packetReceived (ClientboundAddEntityPacket packet) {
if (packet.getType() != EntityType.PLAYER) return;
final PlayerEntry entry = bot.players.getEntry(packet.getUuid());
@@ -94,7 +94,7 @@ public class PositionPlugin extends Bot.Listener implements TickPlugin.Listener
rotationMap.put(packet.getEntityId(), new Rotation(packet.getYaw(), packet.getPitch()));
}
public void packetReceived (ClientboundRemoveEntitiesPacket packet) {
private void packetReceived (ClientboundRemoveEntitiesPacket packet) {
final int[] ids = packet.getEntityIds();
for (int id : ids) {
@@ -104,7 +104,7 @@ public class PositionPlugin extends Bot.Listener implements TickPlugin.Listener
}
}
public void packetReceived (ClientboundEntityPositionSyncPacket packet) {
private void packetReceived (ClientboundEntityPositionSyncPacket packet) {
final PlayerEntry player = entityIdMap.get(packet.getId());
if (player == null) return;
@@ -121,7 +121,7 @@ public class PositionPlugin extends Bot.Listener implements TickPlugin.Listener
for (Listener listener : listeners) listener.playerMoved(player, position, rotation);
}
public void packetReceived (ClientboundMoveEntityRotPacket packet) {
private void packetReceived (ClientboundMoveEntityRotPacket packet) {
final PlayerEntry player = entityIdMap.get(packet.getEntityId());
if (player == null) return;
@@ -133,7 +133,7 @@ public class PositionPlugin extends Bot.Listener implements TickPlugin.Listener
for (Listener listener : listeners) listener.playerMoved(player, getPlayerPosition(player.profile.getName()), rotation);
}
public void packetReceived (ClientboundMoveEntityPosPacket packet) {
private void packetReceived (ClientboundMoveEntityPosPacket packet) {
final PlayerEntry player = entityIdMap.get(packet.getEntityId());
if (player == null) return;
@@ -158,7 +158,7 @@ public class PositionPlugin extends Bot.Listener implements TickPlugin.Listener
for (Listener listener : listeners) listener.playerMoved(player, position, getPlayerRotation(player.profile.getName()));
}
public void packetReceived (ClientboundMoveEntityPosRotPacket packet) {
private void packetReceived (ClientboundMoveEntityPosRotPacket packet) {
final PlayerEntry player = entityIdMap.get(packet.getEntityId());
if (player == null) return;

View File

@@ -163,7 +163,7 @@ public class SelfCarePlugin
else if (packet instanceof ClientboundSetPassengersPacket t_packet) packetReceived(t_packet);
}
public void packetReceived (ClientboundLoginPacket packet) {
private void packetReceived (ClientboundLoginPacket packet) {
this.entityId = packet.getEntityId();
this.gamemode = packet.getCommonPlayerSpawnInfo().getGameMode();
@@ -183,7 +183,7 @@ public class SelfCarePlugin
checkTask = bot.executor.scheduleAtFixedRate(task, 0, bot.config.selfCare.delay, TimeUnit.MILLISECONDS);
}
public void packetReceived (ClientboundGameEventPacket packet) {
private void packetReceived (ClientboundGameEventPacket packet) {
final GameEvent notification = packet.getNotification();
final GameEventValue value = packet.getValue();
@@ -195,7 +195,7 @@ public class SelfCarePlugin
if (notification == GameEvent.CHANGE_GAMEMODE) gamemode = (GameMode) value;
}
public void packetReceived (ClientboundEntityEventPacket packet) {
private void packetReceived (ClientboundEntityEventPacket packet) {
final EntityEvent event = packet.getEvent();
final int id = packet.getEntityId();
@@ -208,7 +208,7 @@ public class SelfCarePlugin
else if (event == EntityEvent.PLAYER_OP_PERMISSION_LEVEL_4) permissionLevel = 4;
}
public void packetReceived (ClientboundOpenScreenPacket packet) {
private void packetReceived (ClientboundOpenScreenPacket packet) {
// instantly closes the window when received the packet
// also should this be in self care?
bot.session.send(
@@ -218,7 +218,7 @@ public class SelfCarePlugin
);
}
public void packetReceived (ClientboundSetPassengersPacket packet) {
private void packetReceived (ClientboundSetPassengersPacket packet) {
if (
Arrays.stream(packet.getPassengerIds())
.noneMatch(id -> id == entityId)

View File

@@ -27,7 +27,7 @@ public class ServerFeaturesPlugin extends Bot.Listener {
if (packet instanceof ClientboundCommandsPacket t_packet) packetReceived(t_packet);
}
public void packetReceived (ClientboundCommandsPacket packet) {
private void packetReceived (ClientboundCommandsPacket packet) {
for (CommandNode node : packet.getNodes()) {
if (!node.isExecutable() || node.getType() != CommandType.LITERAL) continue;

View File

@@ -115,7 +115,7 @@ public class TPSPlugin extends Bot.Listener implements TickPlugin.Listener {
else if (packet instanceof ClientboundLoginPacket t_packet) packetReceived(t_packet);
}
public void packetReceived (ClientboundSetTimePacket ignoredPacket) {
private void packetReceived (ClientboundSetTimePacket ignoredPacket) {
long now = System.currentTimeMillis();
float timeElapsed = (float) (now - timeLastTimeUpdate) / 1000.0F;
tickRates[nextIndex] = MathUtilities.clamp(20.0f / timeElapsed, 0.0f, 20.0f);
@@ -123,7 +123,7 @@ public class TPSPlugin extends Bot.Listener implements TickPlugin.Listener {
timeLastTimeUpdate = now;
}
public void packetReceived (ClientboundLoginPacket ignoredPacket) {
private void packetReceived (ClientboundLoginPacket ignoredPacket) {
Arrays.fill(tickRates, 0);
nextIndex = 0;
timeGameJoined = timeLastTimeUpdate = System.currentTimeMillis();

View File

@@ -38,7 +38,7 @@ public class TabCompletePlugin extends Bot.Listener {
if (packet instanceof ClientboundCommandSuggestionsPacket t_packet) packetReceived(t_packet);
}
public void packetReceived (ClientboundCommandSuggestionsPacket packet) {
private void packetReceived (ClientboundCommandSuggestionsPacket packet) {
final int id = packet.getTransactionId();
if (!transactions.containsKey(id)) return;

View File

@@ -42,7 +42,7 @@ public class TeamPlugin extends Bot.Listener {
if (packet instanceof ClientboundSetPlayerTeamPacket t_packet) packetReceived(t_packet);
}
public void packetReceived(ClientboundSetPlayerTeamPacket packet) {
private void packetReceived (ClientboundSetPlayerTeamPacket packet) {
switch (packet.getAction()) {
case CREATE -> {
final Team team = new Team(

View File

@@ -48,7 +48,7 @@ public class VoiceChatPlugin extends Bot.Listener {
else if (packet instanceof ClientboundCustomPayloadPacket t_packet) packetReceived(t_packet);
}
public void packetReceived(ClientboundLoginPacket ignored) {
private void packetReceived (ClientboundLoginPacket ignored) {
// totally didn't use a real minecraft client with voicechat mod to get this
bot.session.send(new ServerboundCustomPayloadPacket(
@@ -64,7 +64,7 @@ public class VoiceChatPlugin extends Bot.Listener {
running = true;
}
public void packetReceived(ClientboundCustomPayloadPacket _packet) {
private void packetReceived (ClientboundCustomPayloadPacket _packet) {
if (_packet.getChannel().equals(Key.key("voicechat:secret"))) { // fard
final byte[] bytes = _packet.getData();
final FriendlyByteBuf buf = new FriendlyByteBuf(Unpooled.wrappedBuffer(bytes));