-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
2 changed files
with
9 additions
and
14 deletions.
There are no files selected for viewing
1 change: 0 additions & 1 deletion
1
src/main/java/com/prunoideae/probejs/formatter/SpecialTypes.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 9 additions & 13 deletions
22
src/main/java/com/prunoideae/probejs/mixin/OnEventMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |