Archived
0

New version of cache-like syntax approach

This commit is contained in:
Daniil
2018-07-31 14:32:53 +07:00
parent 03974934a0
commit 1a03c517f6
4 changed files with 33 additions and 17 deletions

View File

@@ -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);
}
}

View File

@@ -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){
}
}

View File

@@ -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();
} }

View File

@@ -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){
}
}