Skip to content

Commit

Permalink
changed mixin
Browse files Browse the repository at this point in the history
i hate it
  • Loading branch information
Prunoideae committed Mar 15, 2022
1 parent f2b1465 commit dfde77a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.prunoideae.probejs.formatter;

import com.prunoideae.probejs.formatter.formatter.FormatterType;
import com.prunoideae.probejs.info.TypeInfo;

import java.util.function.*;

Expand Down
22 changes: 9 additions & 13 deletions src/main/java/com/prunoideae/probejs/mixin/OnEventMixin.java
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
package com.prunoideae.probejs.mixin;

import com.prunoideae.probejs.plugin.WrappedEventHandler;
import dev.latvian.mods.kubejs.BuiltinKubeJSPlugin;
import dev.latvian.mods.kubejs.event.EventsJS;
import dev.latvian.mods.kubejs.event.IEventHandler;
import dev.latvian.mods.kubejs.script.BindingsEvent;
import dev.latvian.mods.kubejs.util.ListJS;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyVariable;

@Mixin(BuiltinKubeJSPlugin.class)
@Mixin(EventsJS.class)
public class OnEventMixin {

@Overwrite(remap = false)
private static Object onEvent(BindingsEvent event, Object[] args) {
for (Object o : ListJS.orSelf(args[0])) {
String e = String.valueOf(o);
event.type.manager.get().events.listen(e, new WrappedEventHandler(e, (IEventHandler) args[1]));

}
return null;
@ModifyVariable(method = "listen", argsOnly = true, at = @At("HEAD"), remap = false)
private IEventHandler listen(IEventHandler handler, String id) {
if (!(handler instanceof WrappedEventHandler))
return new WrappedEventHandler(id, handler);
return handler;
}
}

0 comments on commit dfde77a

Please sign in to comment.