mirror of
https://github.com/Miasmusa/Shadow.git
synced 2024-11-14 19:04:54 -05:00
performance
This commit is contained in:
parent
e59a170363
commit
265efbe1ae
5 changed files with 19 additions and 14 deletions
|
@ -24,7 +24,7 @@ public class Test extends Command {
|
|||
for (Module module : ModuleRegistry.getModules()) {
|
||||
if (module instanceof AddonModule) continue;
|
||||
String cname = module.getClass().getSimpleName();
|
||||
sb.append(String.format("registerModule(%s.class);",cname)).append("\n");
|
||||
sb.append(String.format("registerModule(%s.class);", cname)).append("\n");
|
||||
}
|
||||
try {
|
||||
Files.writeString(new File("bruh.txt").toPath(), sb.toString(), StandardOpenOption.CREATE);
|
||||
|
|
|
@ -190,18 +190,18 @@ public class ModuleRegistry {
|
|||
Module instance = null;
|
||||
for (Constructor<?> declaredConstructor : moduleClass.getDeclaredConstructors()) {
|
||||
if (declaredConstructor.getParameterCount() != 0) {
|
||||
throw new IllegalArgumentException(moduleClass.getName()+" has invalid constructor: expected "+moduleClass.getName()+"(), got "+declaredConstructor);
|
||||
throw new IllegalArgumentException(moduleClass.getName() + " has invalid constructor: expected " + moduleClass.getName() + "(), got " + declaredConstructor);
|
||||
}
|
||||
try {
|
||||
instance = (Module) declaredConstructor.newInstance();
|
||||
} catch (Exception e) {
|
||||
throw new IllegalArgumentException("Failed to make instance of "+moduleClass.getName(), e);
|
||||
throw new IllegalArgumentException("Failed to make instance of " + moduleClass.getName(), e);
|
||||
}
|
||||
}
|
||||
if (instance == null) {
|
||||
throw new IllegalArgumentException("Failed to make instance of "+moduleClass.getName());
|
||||
throw new IllegalArgumentException("Failed to make instance of " + moduleClass.getName());
|
||||
}
|
||||
ShadowMain.log(Level.INFO, "Initialized " + instance.getName()+" via "+moduleClass.getName());
|
||||
ShadowMain.log(Level.INFO, "Initialized " + instance.getName() + " via " + moduleClass.getName());
|
||||
vanillaModules.add(instance);
|
||||
}
|
||||
|
||||
|
@ -355,7 +355,7 @@ public class ModuleRegistry {
|
|||
while (reloadInProgress.get()) {
|
||||
Thread.onSpinWait();
|
||||
}
|
||||
ShadowMain.log(Level.INFO, "Lock opened within "+(System.currentTimeMillis()-lockStart)+" ms ("+(System.nanoTime()-lockStartns)+" ns)");
|
||||
ShadowMain.log(Level.INFO, "Lock opened within " + (System.currentTimeMillis() - lockStart) + " ms (" + (System.nanoTime() - lockStartns) + " ns)");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -44,11 +44,11 @@ public class FilterBypass extends Module {
|
|||
// if (!this.isEnabled()) return;
|
||||
if (!blockPackets) return;
|
||||
if (event.getPacket() instanceof ChatMessageC2SPacket packet) {
|
||||
event.setCancelled(true);
|
||||
String message = packet.getChatMessage();
|
||||
if (message.startsWith("/") || message.startsWith(">")) {
|
||||
if (message.startsWith("/")) {
|
||||
return;
|
||||
}
|
||||
event.setCancelled(true);
|
||||
StringBuilder rvmsg = new StringBuilder(message).reverse();
|
||||
String msgformatted = "\u202E " + rvmsg;
|
||||
blockPackets = false;
|
||||
|
|
|
@ -43,14 +43,16 @@ public class Events {
|
|||
public static ListenerEntry registerEventHandler(EventType event, Consumer<? extends Event> handler) {
|
||||
return registerEventHandler((int) Math.floor(Math.random() * 0xFFFFFF), event, handler);
|
||||
}
|
||||
|
||||
public static void unregisterEventHandlerClass(Object instance) {
|
||||
for (ListenerEntry entry : new ArrayList<>(entries)) {
|
||||
if (entry.owner.equals(instance.getClass())) {
|
||||
ShadowMain.log(Level.INFO, "Unregistering "+entry.type+":"+entry.id);
|
||||
ShadowMain.log(Level.INFO, "Unregistering " + entry.type + ":" + entry.id);
|
||||
entries.remove(entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void registerEventHandlerClass(Object instance) {
|
||||
for (Method declaredMethod : instance.getClass().getDeclaredMethods()) {
|
||||
for (Annotation declaredAnnotation : declaredMethod.getDeclaredAnnotations()) {
|
||||
|
@ -78,10 +80,13 @@ public class Events {
|
|||
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
public static boolean fireEvent(EventType event, Event argument) {
|
||||
for (ListenerEntry entry : entries) {
|
||||
if (entry.type == event) {
|
||||
((Consumer) entry.eventListener()).accept(argument);
|
||||
}
|
||||
List<ListenerEntry> le = entries.stream().filter(listenerEntry -> listenerEntry.type == event).toList();
|
||||
if (le.size() == 0) {
|
||||
// ShadowMain.log(Level.INFO, "no one cares about "+event+" so we're gonna skip it");
|
||||
return false;
|
||||
}
|
||||
for (ListenerEntry entry : le) {
|
||||
((Consumer) entry.eventListener()).accept(argument);
|
||||
}
|
||||
return argument.isCancelled();
|
||||
}
|
||||
|
|
|
@ -90,7 +90,7 @@ public class GameRendererMixin {
|
|||
}
|
||||
}
|
||||
|
||||
@Redirect(at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;raycast(DFZ)Lnet/minecraft/util/hit/HitResult;"), method = "updateTargetedEntity",require = 0)
|
||||
@Redirect(at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;raycast(DFZ)Lnet/minecraft/util/hit/HitResult;"), method = "updateTargetedEntity", require = 0)
|
||||
HitResult replaceFreelookHitResult(Entity instance, double maxDistance, float tickDelta, boolean includeFluids) {
|
||||
if (ModuleRegistry.getByClass(FreeLook.class).isEnabled()) {
|
||||
Vec3d vec3d = instance.getCameraPosVec(tickDelta);
|
||||
|
|
Loading…
Reference in a new issue