StackAsk is a community where developers ask questions, share answers and learn from each others real-world experience, so every solved problem helps the next person who runs into it.
# entity/BullyUser: @Getter @Setter @ToString @EzyCollection public class BullyUser { @EzyId int id; String username; String password; } # repo/BullyUserRepo: @EzyRepository("userRepo") public interface BullyUserRepo extends EzyMongoRepository<Long, BullyUser> { } # service/BullyUserService: public interface BullyUserService { void saveUser(BullyUser user); BullyUser createUser(String username, String password); BullyUser getUser(String username); } # service/impl/BullyUserServiceImpl: @Setter @EzySingleton("userService") public class BullyUserServiceImpl implements BullyUserService { @EzyAutoBind private BullyUserRepo BullyUserRepo; @Override public void saveUser(BullyUser user) { BullyUserRepo.save(user); } @Override public BullyUser createUser(String username, String password) { BullyUser user = new BullyUser(); user.setUsername(username); user.setPassword(password); BullyUserRepo.save(user); return user; } @Override public BullyUser getUser(String username) { return BullyUserRepo.findByField("username", username); } } // [PLUGIN]/controller/UserLoginController @EzySingleton @EzyEventHandler(USER_LOGIN) public class UserLoginController extends EzyAbstractPluginEventController { @EzyAutoBind private WelcomeService welcomeService; @EzyAutoBind private BullyUserService userService; @Override public void handle(EzyPluginContext ctx, EzyUserLoginEvent event) { logger.info("{} login in", welcomeService.welcome(event.getUsername())); String username = event.getUsername(); String password = event.getPassword(); BullyUser user = userService.getUser(username); if (user == null) { logger.info("User {} does not exist, creating new user", username); user = userService.createUser(username, password); userService.saveUser(user); } } }
com.tvd12.ezyfoxserver.exception.EzyRequestHandleException: error when handle request from: Session#1(owner: null, address: /127.0.0.1:34930), command: LOGIN, data: [BullyServer, Arciesis, admin, []] at com.tvd12.ezyfoxserver.exception.EzyRequestHandleException.requestHandleException(EzyRequestHandleException.java:28) at com.tvd12.ezyfoxserver.handler.EzySimpleDataHandler.handleRequest(EzySimpleDataHandler.java:120) at com.tvd12.ezyfoxserver.handler.EzySimpleDataHandler.handleReceivedData(EzySimpleDataHandler.java:90) at com.tvd12.ezyfoxserver.handler.EzySimpleDataHandler.dataReceived(EzySimpleDataHandler.java:36) at com.tvd12.ezyfoxserver.nio.handler.EzySimpleNioDataHandler.channelRead(EzySimpleNioDataHandler.java:19) at com.tvd12.ezyfoxserver.nio.handler.EzyAbstractHandlerGroup.fireChannelRead(EzyAbstractHandlerGroup.java:118) at com.tvd12.ezyfoxserver.socket.EzySocketRequestHandler.processRequest(EzySocketRequestHandler.java:69) at com.tvd12.ezyfoxserver.socket.EzySocketRequestHandler.handleEvent(EzySocketRequestHandler.java:30) at com.tvd12.ezyfoxserver.socket.EzySocketEventLoopOneHandler$1.doEventLoop(EzySocketEventLoopOneHandler.java:19) at com.tvd12.ezyfoxserver.socket.EzySimpleSocketEventLoop.eventLoop(EzySimpleSocketEventLoop.java:24) at java.lang.Thread.run(Thread.java:750) Caused by: java.lang.NullPointerException: null at xyz.beerocraft.BullyServer.common.service.impl.BullyUserServiceImpl.getUser(BullyUserServiceImpl.java:33) at xyz.beerocraft.BullyServer.plugin.controller.UserLoginController.handle(UserLoginController.java:34) at xyz.beerocraft.BullyServer.plugin.controller.UserLoginController.handle(UserLoginController.java:17) at com.tvd12.ezyfoxserver.context.EzyAbstractContext.handleEvent(EzyAbstractContext.java:78) at com.tvd12.ezyfoxserver.command.impl.EzyBroadcastPluginsEventImpl.firePluginEvent(EzyBroadcastPluginsEventImpl.java:60) at com.tvd12.ezyfoxserver.command.impl.EzyBroadcastPluginsEventImpl.fire(EzyBroadcastPluginsEventImpl.java:42) at com.tvd12.ezyfoxserver.context.EzySimpleZoneContext.broadcastPlugins(EzySimpleZoneContext.java:84) at com.tvd12.ezyfoxserver.controller.EzyLoginController.firePluginEvent(EzyLoginController.java:82) at com.tvd12.ezyfoxserver.controller.EzyLoginController.control(EzyLoginController.java:65) at com.tvd12.ezyfoxserver.controller.EzyLoginController.handle(EzyLoginController.java:33) at com.tvd12.ezyfoxserver.controller.EzyLoginController.handle(EzyLoginController.java:21) at com.tvd12.ezyfoxserver.handler.EzySimpleDataHandler.handleRequest(EzySimpleDataHandler.java:114) ... 9 common frames omitted
2.2K Point(s)
1.2K Point(s)
313 Point(s)
178 Point(s)
138 Point(s)
Your account is signed in on the device(s) below. Sign out of at least one of them to continue signing in on this device.
Your account is signed in on the device(s) below. Sign out directly on one of those devices, or wait until the sign-in again time shown below.
If you cant access those devices, please contact the administrator to sign them out for you.
Input your email to receive reset password link, or if you remember your password, you can click