New version of cache-like syntax approach
This commit is contained in:
@@ -0,0 +1,11 @@
|
|||||||
|
package mc.core.events.cachelike;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class EventHandlerBase {
|
||||||
|
private List<PreprocessorContext> contextList;
|
||||||
|
|
||||||
|
protected void push(PreprocessorContext context){
|
||||||
|
contextList.add(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
package mc.core.events.cachelike;
|
|
||||||
|
|
||||||
import mc.core.events.LoginEvent;
|
|
||||||
|
|
||||||
public class SampleHandler {
|
|
||||||
|
|
||||||
@Preprocessor(preprocessor = (new PreprocessorContext<LoginEvent>() {
|
|
||||||
@Override
|
|
||||||
protected void init() {
|
|
||||||
|
|
||||||
}
|
|
||||||
}).class)
|
|
||||||
public void onLogin(LoginEvent event){
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
package mc.core.events.cachelike;
|
package mc.core.events.cachelike;
|
||||||
|
|
||||||
public @interface Preprocessor {
|
public @interface Preprocessor {
|
||||||
Class<PreprocessorContext> preprocessor();
|
int index();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package mc.core.events.cachelike;
|
||||||
|
|
||||||
|
import mc.core.events.LoginEvent;
|
||||||
|
|
||||||
|
public class SampleHandler extends EventHandlerBase {
|
||||||
|
|
||||||
|
public SampleHandler() {
|
||||||
|
push(new PreprocessorContext() {
|
||||||
|
@Override
|
||||||
|
protected void init() {
|
||||||
|
System.out.println("I am context #0!");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Preprocessor(index = 0) // Map constructor #0 to this event handler
|
||||||
|
public void onLogin(LoginEvent event){
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user