1. Handle ServerReadyEvent on Plugin
package com.tvd12.ezyfoxserver.embedded.test.plugin;
import com.tvd12.ezyfox.bean.annotation.EzySingleton;
import com.tvd12.ezyfox.core.annotation.EzyServerEventHandler;
import com.tvd12.ezyfoxserver.constant.EzyEventNames;
import com.tvd12.ezyfoxserver.context.EzyPluginContext;
import com.tvd12.ezyfoxserver.controller.EzyAbstractPluginEventController;
import com.tvd12.ezyfoxserver.event.EzyServerReadyEvent;
@EzySingleton
@EzyServerEventHandler(event = EzyEventNames.SERVER_READY)
public class HelloPluginServerReadyController
extends EzyAbstractPluginEventController<EzyServerReadyEvent> {
@Override
public void handle(EzyPluginContext ctx, EzyServerReadyEvent event) {
logger.info("HELLO PLUGIN - SERVER READY");
}
}
2. Handle ServerReadyEvent on App
package com.tvd12.ezyfoxserver.embedded.test.app.controller;
import com.tvd12.ezyfox.bean.annotation.EzySingleton;
import com.tvd12.ezyfox.core.annotation.EzyServerEventHandler;
import com.tvd12.ezyfoxserver.constant.EzyEventNames;
import com.tvd12.ezyfoxserver.context.EzyAppContext;
import com.tvd12.ezyfoxserver.controller.EzyAbstractAppEventController;
import com.tvd12.ezyfoxserver.event.EzyServerReadyEvent;
@EzySingleton
@EzyServerEventHandler(event = EzyEventNames.SERVER_READY)
public class HelloAppServerReadyController
extends EzyAbstractAppEventController<EzyServerReadyEvent> {
@Override
public void handle(EzyAppContext ctx, EzyServerReadyEvent event) {
logger.info("HELLO APP - SERVER READY");
}
}
3. Handle UserLoginEvent
package com.tvd12.ezyfoxserver.embedded.test.plugin;
import com.tvd12.ezyfox.bean.annotation.EzySingleton;
import com.tvd12.ezyfox.core.annotation.EzyServerEventHandler;
import com.tvd12.ezyfoxserver.constant.EzyEventNames;
import com.tvd12.ezyfoxserver.constant.EzyLoginError;
import com.tvd12.ezyfoxserver.context.EzyPluginContext;
import com.tvd12.ezyfoxserver.controller.EzyAbstractPluginEventController;
import com.tvd12.ezyfoxserver.event.EzyUserLoginEvent;
import com.tvd12.ezyfoxserver.exception.EzyLoginErrorException;
@EzySingleton
@EzyServerEventHandler(EzyEventNames.USER_LOGIN)
public class HelloUserLoginController
extends EzyAbstractPluginEventController<EzyUserLoginEvent> {
@Override
public void handle(EzyPluginContext ctx, EzyUserLoginEvent event) {
logger.info("HELLO - user {} login in", event.getUsername());
if(event.getUsername().contains("admin"))
throw new EzyLoginErrorException(EzyLoginError.INVALID_USERNAME);
}
}