本文整理汇总了Java中ethanjones.cubes.core.mod.event.ModEvent类的典型用法代码示例。如果您正苦于以下问题:Java ModEvent类的具体用法?Java ModEvent怎么用?Java ModEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ModEvent类属于ethanjones.cubes.core.mod.event包,在下文中一共展示了ModEvent类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import ethanjones.cubes.core.mod.event.ModEvent; //导入依赖的package包/类
protected void init() {
for (Method method : mod.getClass().getMethods()) {
if (method.getAnnotation(ModEventHandler.class) != null) {
boolean error = false;
if (Modifier.isStatic(method.getModifiers())) {
Log.error("Methods annotated with " + ModEventHandler.class.getSimpleName() + " must not be static");
error = true;
}
if (method.getParameterTypes().length != 1 || method.getParameterTypes()[0].getSuperclass() != ModEvent.class) {
Log.error("Methods annotated with " + ModEventHandler.class.getSimpleName() + " must have only one parameter which must be the " + ModEvent.class.getSimpleName() + " instance");
error = true;
}
if (error) {
Log.error("Mod:" + name + " Class:" + mod.getClass().getName() + " Method:" + method);
continue;
}
modEventHandlers.put(method.getParameterTypes()[0].asSubclass(ModEvent.class), method);
}
}
}
示例2: postModEvent
import ethanjones.cubes.core.mod.event.ModEvent; //导入依赖的package包/类
public static void postModEvent(ModEvent modEvent) {
synchronized (currentMod) {
Log.debug("Posting " + modEvent.getClass().getSimpleName());
for (ModInstance mod : mods) {
currentMod = mod;
try {
mod.event(modEvent);
} catch (Exception e) {
mod.addState(ModState.Error);
currentMod = null;
throw new CubesException(
"Exception while posting " + modEvent.getClass().getSimpleName() + " to mod " + mod.name,
e);
}
}
currentMod = null;
Log.debug("Finished posting " + modEvent.getClass().getSimpleName());
}
}
示例3: event
import ethanjones.cubes.core.mod.event.ModEvent; //导入依赖的package包/类
protected void event(ModEvent modEvent) throws Exception {
Method method = modEventHandlers.get(modEvent.getClass());
if (method == null) {
Log.debug("No method to handle " + modEvent.getClass().getSimpleName() + " in mod " + name);
return;
}
addState(modEvent.getModState());
Log.debug("Posting " + modEvent.getClass().getSimpleName() + " to mod " + name);
method.invoke(mod, modEvent);
}
示例4: event
import ethanjones.cubes.core.mod.event.ModEvent; //导入依赖的package包/类
@Override
protected void event(ModEvent modEvent) throws Exception {
if (modEvent instanceof PreInitializationEvent)
JsonLoader.firstStage(map);
if (modEvent instanceof InitializationEvent)
JsonLoader.secondStage(map);
}
示例5: postModEvent
import ethanjones.cubes.core.mod.event.ModEvent; //导入依赖的package包/类
public synchronized static void postModEvent(ModEvent modEvent) {
Log.debug("Posting " + modEvent.getClass().getSimpleName());
for (ModInstance mod : mods) {
currentMod = mod;
try {
mod.event(modEvent);
} catch (Exception e) {
mod.addState(ModState.Error);
currentMod = null;
throw new CubesException("Exception while posting " + modEvent.getClass().getSimpleName() + " to mod " + mod.name, e);
}
}
currentMod = null;
Log.debug("Finished posting " + modEvent.getClass().getSimpleName());
}
示例6: JavaModInstance
import ethanjones.cubes.core.mod.event.ModEvent; //导入依赖的package包/类
public JavaModInstance(String name, FileHandle file, AssetManager assetManager, T mod) {
super(name, file, assetManager);
this.mod = mod;
modStates = new ArrayList<ModState>();
modEventHandlers = new HashMap<Class<? extends ModEvent>, Method>();
}
示例7: event
import ethanjones.cubes.core.mod.event.ModEvent; //导入依赖的package包/类
@Override
protected void event(ModEvent modEvent) throws Exception {
if (modEvent instanceof PreInitializationEvent) JsonLoader.firstStage(map);
if (modEvent instanceof InitializationEvent) JsonLoader.secondStage(map);
}
示例8: event
import ethanjones.cubes.core.mod.event.ModEvent; //导入依赖的package包/类
protected abstract void event(ModEvent modEvent) throws Exception;