fix events
All checks were successful
/ Build BaseBand (push) Successful in 2m38s

This commit is contained in:
Daniella / Tove 2024-10-05 03:33:07 +02:00
parent 8b326ad8c9
commit f0df260901
Signed by: TudbuT
GPG key ID: B3CF345217F202D3
28 changed files with 81 additions and 2 deletions

View file

@ -28,6 +28,8 @@ public class EventBus {
Method[] methods = subscriberClass.getDeclaredMethods();
for (Method method : methods) {
if(method.getDeclaredAnnotation(Listen.class) == null)
continue;
Class<?>[] parameterTypes = method.getParameterTypes();
if (parameterTypes.length == 1 && Event.class.isAssignableFrom(parameterTypes[0])) {
subscriberMethods.add(new SubscriberMethod(subscriber, method));

View file

@ -0,0 +1,11 @@
package de.com.baseband.client.event;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface Listen {
}

View file

@ -50,6 +50,7 @@ public class StaticEventHandler {
}
}
@Listen
public void onPacketIn(PacketEvent.Receive event) {
if (event.getPacket() instanceof SPacketEntityStatus) {
SPacketEntityStatus packet = (SPacketEntityStatus) event.getPacket();

View file

@ -1,5 +1,6 @@
package de.com.baseband.client.feature.background;
import de.com.baseband.client.event.Listen;
import de.com.baseband.client.event.events.PacketEvent;
import de.com.baseband.client.feature.Feature;
import de.com.baseband.client.feature.category.Background;
@ -19,6 +20,7 @@ public class ServerSafeguard extends Feature {
public int showError = 0;
@Listen
public void onServerJoin(PacketEvent.Send event) {
if(event.getPacket() instanceof C00Handshake && ((C00Handshake) event.getPacket()).getRequestedState() == EnumConnectionState.LOGIN) {
ServerData currentServerData = mc.getCurrentServerData();

View file

@ -1,6 +1,7 @@
package de.com.baseband.client.feature.modules.chat;
import de.com.baseband.client.BaseBand;
import de.com.baseband.client.event.Listen;
import de.com.baseband.client.event.events.PacketEvent;
import de.com.baseband.client.feature.Feature;
import de.com.baseband.client.feature.category.ChatCategory;
@ -129,6 +130,7 @@ public class ChatCrypt extends Feature {
String sentOriginal = null;
String sentEncrypted = null;
@Listen
public void onPacketRead(PacketEvent.Receive e) {
if (e.getPacket() instanceof SPacketChat) {
String message = ((SPacketChat) e.getPacket()).getChatComponent().getUnformattedText();
@ -195,6 +197,7 @@ public class ChatCrypt extends Feature {
}
@Listen
public void onPacketWrite(PacketEvent.Send e) {
if (e.getPacket() instanceof CPacketChatMessage && send) {
String s = ((CPacketChatMessage) e.getPacket()).getMessage();

View file

@ -2,6 +2,7 @@ package de.com.baseband.client.feature.modules.chat;
import com.mojang.realmsclient.gui.ChatFormatting;
import de.com.baseband.client.BaseBand;
import de.com.baseband.client.event.Listen;
import de.com.baseband.client.event.events.PacketEvent;
import de.com.baseband.client.feature.Feature;
import de.com.baseband.client.feature.category.ChatCategory;
@ -84,6 +85,7 @@ public class ChatExtras extends Feature {
}
@Listen
public void onChat(PacketEvent.Receive event) {
if (event.getPacket() instanceof SPacketChat && antiPopLag) {
String message = ((SPacketChat) event.getPacket()).getChatComponent().getUnformattedText();

View file

@ -1,6 +1,7 @@
package de.com.baseband.client.feature.modules.chat;
import de.com.baseband.client.BaseBand;
import de.com.baseband.client.event.Listen;
import de.com.baseband.client.event.events.PacketEvent;
import de.com.baseband.client.feature.Feature;
import de.com.baseband.client.feature.category.ChatCategory;
@ -48,6 +49,7 @@ public class ChatFilter extends Feature {
return "ChatFilter";
}
@Listen
public void onPacketRead(PacketEvent.Receive event) {
if(event.getPacket() instanceof SPacketChat) {
SPacketChat packet = ((SPacketChat) event.getPacket());

View file

@ -1,5 +1,6 @@
package de.com.baseband.client.feature.modules.chat;
import de.com.baseband.client.event.Listen;
import de.com.baseband.client.event.events.PlayerDestroyEvent;
import de.com.baseband.client.feature.Feature;
import de.com.baseband.client.feature.category.ChatCategory;
@ -39,6 +40,7 @@ public class TPAccept extends Feature {
}
}
@Listen
public void onDestroy(PlayerDestroyEvent event) {
if(destroy)
setEnabled(false);

View file

@ -1,6 +1,7 @@
package de.com.baseband.client.feature.modules.client;
import de.com.baseband.client.BaseBand;
import de.com.baseband.client.event.Listen;
import de.com.baseband.client.event.remote.events.RemoteConfigEvent;
import de.com.baseband.client.event.remote.events.RemoteSendMessageEvent;
import de.com.baseband.client.feature.Feature;
@ -44,11 +45,13 @@ public class AltControl extends Feature {
BaseBand.REMOTE_EVENT_BUS.end();
}
@Listen
public void onRemoteSendChat(RemoteSendMessageEvent event) {
BaseBand.notify("[AltControl] Received a message to send.");
Chat.simulateSend(event.message, false);
}
@Listen
public void onConfig(RemoteConfigEvent event) {
BaseBand.notify("[AltControl] Received a config.");

View file

@ -3,6 +3,7 @@ package de.com.baseband.client.feature.modules.client;
import baritone.api.process.IBaritoneProcess;
import baritone.api.selection.ISelectionManager;
import baritone.api.utils.BetterBlockPos;
import de.com.baseband.client.event.Listen;
import de.com.baseband.client.event.events.SelectEvent;
import de.com.baseband.client.feature.Feature;
import de.com.baseband.client.feature.category.ClientCategory;
@ -35,6 +36,7 @@ public class Baritone extends Feature {
meta = (baritoneProcess == null ? "Idle" : baritoneProcess.displayName());
}
@Listen
public void onSelect(SelectEvent event) {
ISelectionManager selectionManager = BaritoneManager.getBaritone().getSelectionManager();
selectionManager.removeAllSelections();

View file

@ -1,6 +1,7 @@
package de.com.baseband.client.feature.modules.client;
import de.com.baseband.client.BaseBand;
import de.com.baseband.client.event.Listen;
import de.com.baseband.client.event.events.PacketEvent;
import de.com.baseband.client.event.events.PlayerDestroyEvent;
import de.com.baseband.client.feature.Feature;
@ -150,10 +151,12 @@ public class Client extends Feature {
RotationManager.onTick();
}
@Listen
public void onPlayerDestroy(PlayerDestroyEvent event) {
ServerDataManager.onPlayerDestroy();
}
@Listen
public void onPacket(PacketEvent.Receive packetEvent) {
Packet<?> packet = packetEvent.getPacket();
if (packet instanceof SPacketTimeUpdate) {

View file

@ -1,6 +1,7 @@
package de.com.baseband.client.feature.modules.client;
import de.com.baseband.client.BaseBand;
import de.com.baseband.client.event.Listen;
import de.com.baseband.client.event.events.*;
import de.com.baseband.client.feature.Feature;
import de.com.baseband.client.feature.category.ClientCategory;
@ -32,24 +33,28 @@ public class Notifier extends Feature {
return "Notifier";
}
@Listen
public void onPlayerEnterView(PlayerEnteredViewEvent event) {
if(visualRange && !event.playerInfo.getGameProfile().getId().equals(mc.getSession().getProfile().getId())) {
BaseBand.notify("[" + this + "] Player §aentered§r render distance: " + event.playerInfo.getGameProfile().getName());
}
}
@Listen
public void onPlayerLeaveView(PlayerLeftViewEvent event) {
if(visualRange && !event.playerInfo.getGameProfile().getId().equals(mc.getSession().getProfile().getId())) {
BaseBand.notify("[" + this + "] Player §cleft§r render distance: " + event.playerInfo.getGameProfile().getName());
}
}
@Listen
public void onPlayerJoin(PlayerJoinedEvent event) {
if(joins && !event.playerInfo.getGameProfile().getId().equals(mc.getSession().getProfile().getId())) {
BaseBand.notify("[" + this + "] Player §ajoined§r: " + event.playerInfo.getGameProfile().getName());
}
}
@Listen
public void onPlayerLeave(PlayerLeftEvent event) {
if(joins && !event.playerInfo.getGameProfile().getId().equals(mc.getSession().getProfile().getId())) {
BaseBand.notify("[" + this + "] Player §cleft§r: " + event.playerInfo.getGameProfile().getName());
@ -70,6 +75,7 @@ public class Notifier extends Feature {
}
}
@Listen
public void packetEvent(PacketEvent.Receive event) {
if(event.getPacket() instanceof SPacketEntityTeleport && traceTeleport) {
SPacketEntityTeleport packet2 = (SPacketEntityTeleport) event.getPacket();
@ -89,6 +95,7 @@ public class Notifier extends Feature {
}
}
@Listen
public void totemPop(TotemPopEvent event) {
if(popList.get(event.getEntity().getName()) == null) {
popList.put(event.getEntity().getName(), 1);

View file

@ -1,9 +1,9 @@
package de.com.baseband.client.feature.modules.client;
import de.com.baseband.client.event.Listen;
import de.com.baseband.client.event.events.PacketEvent;
import de.com.baseband.client.feature.Feature;
import de.com.baseband.client.feature.category.ClientCategory;
import de.com.baseband.client.feature.category.Experimental;
import de.com.baseband.client.registry.annotation.Config;
import de.com.baseband.client.registry.annotation.Description;
import de.com.baseband.client.registry.annotation.Trigger;
@ -64,6 +64,7 @@ public class PacketCounter extends Feature {
return "PacketCounter";
}
@Listen
public void onPacket(PacketEvent event) {
if(event instanceof PacketEvent.Send) {
totUp ++;

View file

@ -1,6 +1,7 @@
package de.com.baseband.client.feature.modules.client;
import de.com.baseband.client.BaseBand;
import de.com.baseband.client.event.Listen;
import de.com.baseband.client.event.events.PrePacketEvent;
import de.com.baseband.client.feature.Feature;
import de.com.baseband.client.feature.category.ClientCategory;
@ -103,6 +104,7 @@ public class Ping extends Feature {
}
}
@Listen
public void onPacket(PrePacketEvent.Send e) {
if(allowSend == e.getPacket() || notIngame())
return;
@ -113,6 +115,7 @@ public class Ping extends Feature {
}
}
@Listen
public void onPacket(PrePacketEvent.Receive e) {
if(allowRecv == e.getPacket() || notIngame())
return;

View file

@ -1,5 +1,6 @@
package de.com.baseband.client.feature.modules.client;
import de.com.baseband.client.event.Listen;
import de.com.baseband.client.event.events.PacketEvent;
import de.com.baseband.client.event.events.PlayerDestroyEvent;
import de.com.baseband.client.feature.Feature;
@ -63,6 +64,7 @@ public class Timer extends Feature {
multiplierLock = null;
}
@Listen
public void onPlayerDestroy(PlayerDestroyEvent event) {
if(destroy) {
toggle();
@ -134,6 +136,7 @@ public class Timer extends Feature {
}
}
@Listen
public void onPacket(PacketEvent.Receive event) {
if(event.getPacket() instanceof SPacketPlayerPosLook) {
lbCounter += 40;

View file

@ -1,5 +1,6 @@
package de.com.baseband.client.feature.modules.ingame;
import de.com.baseband.client.event.Listen;
import de.com.baseband.client.event.events.BaritoneEvent;
import de.com.baseband.client.event.events.PacketEvent;
import de.com.baseband.client.feature.Feature;
@ -86,12 +87,14 @@ public class AutoEat extends Feature {
}
}
@Listen
public void baritone(BaritoneEvent e) {
if(!e.isCancelled()) {
e.setCancelled(eating);
}
}
@Listen
public void onPacket(PacketEvent.Send event) {
if(!eating)
return;

View file

@ -1,5 +1,6 @@
package de.com.baseband.client.feature.modules.ingame;
import de.com.baseband.client.event.Listen;
import de.com.baseband.client.event.events.MotionUpdateEvent;
import de.com.baseband.client.feature.Feature;
import de.com.baseband.client.feature.category.Ingame;
@ -19,6 +20,7 @@ public class AutoMount extends Feature {
Entity entity = null;
@Listen
public void preMotion(MotionUpdateEvent.Pre event) {
if(entity != null && mc.player.getRidingEntity() == null) {
Vec2f rot = BlockUtils.lookTo(mc.player.getPositionEyes(1), entity.getPositionVector());
@ -27,6 +29,7 @@ public class AutoMount extends Feature {
}
}
@Listen
public void postMotion(MotionUpdateEvent.Post event) {
if(entity != null && mc.player.getRidingEntity() == null) {
mc.playerController.interactWithEntity(mc.player, entity, EnumHand.MAIN_HAND);

View file

@ -1,5 +1,6 @@
package de.com.baseband.client.feature.modules.ingame;
import de.com.baseband.client.event.Listen;
import de.com.baseband.client.event.events.PacketEvent;
import de.com.baseband.client.feature.Feature;
import de.com.baseband.client.feature.category.Ingame;
@ -27,6 +28,7 @@ public class ColourSign extends Feature {
meta = mode.name();
}
@Listen
public void packetOut(PacketEvent event) {
if (event.getPacket() instanceof CPacketUpdateSign) {
ICPacketUpdateSign updateSignAccessor = ((ICPacketUpdateSign) event.getPacket());

View file

@ -1,5 +1,6 @@
package de.com.baseband.client.feature.modules.ingame;
import de.com.baseband.client.event.Listen;
import de.com.baseband.client.event.events.DamageBlockEvent;
import de.com.baseband.client.event.events.PacketEvent;
import de.com.baseband.client.feature.Feature;
@ -40,6 +41,7 @@ public class InteractionTweaks extends Feature {
@Config("Show On HUD")
public boolean showOnHUD;
@Listen
public void onPacketSend(PacketEvent.Send event) {
if (event.getPacket() instanceof CPacketPlayerTryUseItemOnBlock) {
CPacketPlayerTryUseItemOnBlock packet2 = (CPacketPlayerTryUseItemOnBlock) event.getPacket();
@ -127,7 +129,7 @@ public class InteractionTweaks extends Feature {
meta = mode.toString();
}
@Listen
public void damageBlock(DamageBlockEvent event) {
if(isNotUnbreakable(event.getBlockPos())) {
if (noBreakDelay) {

View file

@ -1,5 +1,6 @@
package de.com.baseband.client.feature.modules.ingame;
import de.com.baseband.client.event.Listen;
import de.com.baseband.client.event.events.PacketEvent;
import de.com.baseband.client.feature.Feature;
import de.com.baseband.client.feature.category.Experimental;
@ -14,6 +15,7 @@ public class Inventory extends Feature {
@Description("Allows you to put stuff into your crafting slots!")
public boolean xCarry = false;
@Listen
public void onPacket(PacketEvent.Send event) {
if(xCarry && event.getPacket() instanceof CPacketCloseWindow)
event.setCancelled(true);

View file

@ -1,5 +1,6 @@
package de.com.baseband.client.feature.modules.movement;
import de.com.baseband.client.event.Listen;
import de.com.baseband.client.event.events.MoveEvent;
import de.com.baseband.client.feature.Feature;
import de.com.baseband.client.feature.category.Movement;
@ -29,6 +30,7 @@ public class AntiLevitation extends Feature {
}
}
@Listen
public void motion(MoveEvent event) {
if(mode == Mode.Motion && mc.player.isPotionActive(MobEffects.LEVITATION)) {
if(event.y > 0) {

View file

@ -1,5 +1,6 @@
package de.com.baseband.client.feature.modules.movement;
import de.com.baseband.client.event.Listen;
import de.com.baseband.client.event.events.MoveEvent;
import de.com.baseband.client.event.events.PacketEvent;
import de.com.baseband.client.feature.Feature;
@ -255,6 +256,7 @@ public class ElytraFly extends Feature {
lastTakeoffTry = 0;
}
@Listen
public void onPacket(PacketEvent.Send event) {
if(!autoTakeoff || !wasOnGround)
return;
@ -270,6 +272,7 @@ public class ElytraFly extends Feature {
}
}
@Listen
public void move(MoveEvent e) {
if(!mixinMode)
return;

View file

@ -1,5 +1,6 @@
package de.com.baseband.client.feature.modules.movement;
import de.com.baseband.client.event.Listen;
import de.com.baseband.client.event.events.PacketEvent;
import de.com.baseband.client.feature.Feature;
import de.com.baseband.client.feature.category.Movement;
@ -49,6 +50,7 @@ public class NoFall extends Feature {
int cancelElytraNT = 0;
boolean ranThisFall = false;
@Listen
public void onSend(PacketEvent.Send event) {
if (!(event.getPacket() instanceof CPacketPlayer) || mc.player.isElytraFlying())
return;
@ -79,6 +81,7 @@ public class NoFall extends Feature {
}
}
@Listen
public void onReceive(PacketEvent.Receive event) {
if(event.getPacket() instanceof SPacketEntityMetadata) {
SPacketEntityMetadata packet = (SPacketEntityMetadata) event.getPacket();

View file

@ -1,5 +1,6 @@
package de.com.baseband.client.feature.modules.movement;
import de.com.baseband.client.event.Listen;
import de.com.baseband.client.event.events.PacketEvent;
import de.com.baseband.client.feature.Feature;
import de.com.baseband.client.feature.category.Movement;
@ -29,6 +30,7 @@ public class Velocity extends Feature {
event.setCanceled(true);
}
@Listen
public void packetRead(PacketEvent.Receive event) {
if (event.getPacket() instanceof SPacketEntityVelocity) {
SPacketEntityVelocity velocity = (SPacketEntityVelocity) event.getPacket();

View file

@ -1,5 +1,6 @@
package de.com.baseband.client.feature.modules.render;
import de.com.baseband.client.event.Listen;
import de.com.baseband.client.event.events.PlayerDestroyEvent;
import de.com.baseband.client.feature.Feature;
import de.com.baseband.client.feature.category.Render;
@ -37,6 +38,7 @@ public class Freecam extends Feature {
mc.setRenderViewEntity(player);
}
@Listen
public void onPlayerDestroy(PlayerDestroyEvent event) {
toggle();
}

View file

@ -1,5 +1,6 @@
package de.com.baseband.client.feature.modules.render;
import de.com.baseband.client.event.Listen;
import de.com.baseband.client.event.events.PacketEvent;
import de.com.baseband.client.feature.Feature;
import de.com.baseband.client.feature.category.Experimental;
@ -15,6 +16,7 @@ public class NoParticles extends Feature {
@Config("Client")
public boolean client = false;
@Listen
public void onPacket(PacketEvent.Receive event) {
if(server && event.getPacket() instanceof SPacketParticles) {
event.setCancelled(true);

View file

@ -1,6 +1,7 @@
package de.com.baseband.client.feature.modules.render;
import com.mojang.authlib.GameProfile;
import de.com.baseband.client.event.Listen;
import de.com.baseband.client.event.events.PlayerJoinedEvent;
import de.com.baseband.client.event.events.PlayerLeftEvent;
import de.com.baseband.client.event.events.PlayerLeftViewEvent;
@ -50,12 +51,14 @@ public class PlayerLog extends Feature {
HashMap<UUID, Pair<Lock, EntityPlayer>> originalPlayers = new HashMap<>();
HashMap<GameProfile, AxisAlignedBB> boxes = new HashMap<>();
@Listen
public void onPlayerLeaveView(PlayerLeftViewEvent event) {
Lock lock = new Lock();
lock.lock(1000);
originalPlayers.put(event.playerInfo.getGameProfile().getId(), new ImmutablePair<>(lock, event.player));
}
@Listen
public void onPlayerLeave(PlayerLeftEvent event) {
Pair<Lock, EntityPlayer> pair = originalPlayers.get(event.playerInfo.getGameProfile().getId());
if(pair != null) {
@ -63,6 +66,7 @@ public class PlayerLog extends Feature {
}
}
@Listen
public void onPlayerJoin(PlayerJoinedEvent event) {
if(removeOnRejoin)
boxes.remove(event.playerInfo.getGameProfile());

View file

@ -1,6 +1,7 @@
package de.com.baseband.client.feature.modules.render;
import de.com.baseband.client.event.KeyManager;
import de.com.baseband.client.event.Listen;
import de.com.baseband.client.event.events.PlayerLeftViewEvent;
import de.com.baseband.client.feature.Feature;
import de.com.baseband.client.feature.background.PlayerListHandler;
@ -119,6 +120,7 @@ public class PlayerSelector extends Feature {
}
}
@Listen
public void onPlayerLeftView(PlayerLeftViewEvent event) {
if(event.index == cursor)
mode = Mode.LIST;