Java Code Examples for org.spongepowered.api.event.Order#LATE
The following examples show how to use
org.spongepowered.api.event.Order#LATE .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SpongePlugin.java From ViaRewind with MIT License | 5 votes |
@Listener(order = Order.LATE) public void onGameStart(GameInitializationEvent e) { // Setup Logger this.logger = new LoggerWrapper(loggerSlf4j); // Init! ViaRewindConfigImpl conf = new ViaRewindConfigImpl(configDir.resolve("config.yml").toFile()); conf.reloadConfig(); this.init(conf); }
Example 2
Source File: ChatListener.java From Nations with MIT License | 5 votes |
@Listener(order = Order.LATE) public void onPlayerChat(MessageChannelEvent.Chat e, @First Player p) { Nation nation = DataHandler.getNationOfPlayer(p.getUniqueId()); if (nation == null) { return; } MessageChannel chan = MessageChannel.TO_ALL; Optional<MessageChannel> channel = e.getChannel(); if (channel.isPresent()) { chan = channel.get(); } MessageFormatter formater = e.getFormatter(); if (chan.equals(MessageChannel.TO_ALL) && ConfigHandler.getNode("others", "enableNationTag").getBoolean(true)) { e.setMessage(Text.of(TextSerializers.FORMATTING_CODE.deserialize(ConfigHandler.getNode("others", "publicChatFormat").getString().replaceAll("\\{NATION\\}", nation.getTag()).replaceAll("\\{TITLE\\}", DataHandler.getCitizenTitle(p.getUniqueId()))), formater.getHeader().toText()), formater.getBody().toText()); } else if (chan instanceof NationMessageChannel) { e.setMessage(Text.of(TextSerializers.FORMATTING_CODE.deserialize(ConfigHandler.getNode("others", "nationChatFormat").getString().replaceAll("\\{NATION\\}", nation.getTag()).replaceAll("\\{TITLE\\}", DataHandler.getCitizenTitle(p.getUniqueId()))), formater.getHeader().toText()), Text.of(TextColors.YELLOW, formater.getBody().toText())); DataHandler.getSpyChannel().send(p, Text.of(TextSerializers.FORMATTING_CODE.deserialize(ConfigHandler.getNode("others", "nationSpyChatTag").getString()), TextColors.RESET, e.getMessage())); } }
Example 3
Source File: SpongePlugin.java From ViaBackwards with MIT License | 5 votes |
@Listener(order = Order.LATE) public void onGameStart(GameInitializationEvent e) { // Setup Logger this.logger = new LoggerWrapper(loggerSlf4j); // Init! this.init(configPath.resolve("config.yml").toFile()); }
Example 4
Source File: ConnectionListener.java From FlexibleLogin with MIT License | 5 votes |
@Listener(order = Order.LATE) public void checkCaseSensitive(Auth authEvent, @First GameProfile profile) { String playerName = profile.getName().get(); if (settings.getGeneral().isCaseSensitiveNameCheck()) { plugin.getDatabase().exists(playerName) .filter(databaseName -> !playerName.equals(databaseName)) .ifPresent(databaseName -> { authEvent.setMessage(settings.getText().getInvalidCase(databaseName)); authEvent.setCancelled(true); }); } }
Example 5
Source File: BanListener.java From UltimateCore with MIT License | 5 votes |
@Listener(order = Order.LATE) public void onMotd(ClientPingServerEvent event) { try { ModuleConfig config = Modules.BAN.get().getConfig().get(); if (!config.get().getNode("ban-motd", "enabled").getBoolean()) return; String ip = event.getClient().getAddress().getAddress().toString().replace("/", ""); GlobalDataFile file = new GlobalDataFile("ipcache"); if (file.get().getChildrenMap().keySet().contains(ip)) { //Player GameProfile profile = Sponge.getServer().getGameProfileManager().get(UUID.fromString(file.get().getNode(ip, "uuid").getString())).get(); InetAddress address = InetAddress.getByName(ip); //Check if banned BanService bs = Sponge.getServiceManager().provide(BanService.class).get(); UserStorageService us = Sponge.getServiceManager().provide(UserStorageService.class).get(); if (bs.isBanned(profile) || bs.isBanned(address)) { Text motd = VariableUtil.replaceVariables(Messages.toText(config.get().getNode("ban-motd", "text").getString()), us.get(profile.getUniqueId()).orElse(null)); //Replace ban vars Ban ban = bs.isBanned(profile) ? bs.getBanFor(profile).get() : bs.getBanFor(address).get(); Long time = ban.getExpirationDate().map(date -> (date.toEpochMilli() - System.currentTimeMillis())).orElse(-1L); motd = TextUtil.replace(motd, "%time%", (time == -1L ? Messages.getFormatted("core.time.ever") : Text.of(TimeUtil.format(time)))); motd = TextUtil.replace(motd, "%reason%", ban.getReason().orElse(Messages.getFormatted("ban.command.ban.defaultreason"))); event.getResponse().setDescription(motd); } } } catch (Exception ex) { ex.printStackTrace(); } }
Example 6
Source File: ServerlistListener.java From UltimateCore with MIT License | 5 votes |
@Listener(order = Order.LATE) public void onJoin(ClientConnectionEvent.Join event) { try { Player p = event.getTargetEntity(); ModuleConfig config = Modules.SERVERLIST.get().getConfig().get(); //Join motd if (config.get().getNode("joinmessage", "enable").getBoolean()) { List<String> joinmsgs = config.get().getNode("joinmessage", "joinmessages").getList(TypeToken.of(String.class)); Text joinmsg = VariableUtil.replaceVariables(Messages.toText(joinmsgs.get(random.nextInt(joinmsgs.size()))), p); p.sendMessage(joinmsg); } } catch (ObjectMappingException e) { ErrorLogger.log(e, "Failed to construct join message."); } }
Example 7
Source File: DefaultListener.java From UltimateCore with MIT License | 5 votes |
@Listener(order = Order.LATE) public void onDisconnect(ClientConnectionEvent.Disconnect event) { Player p = event.getTargetEntity(); UltimateUser user = UltimateCore.get().getUserService().getUser(p); for (String key : UltimateUser.onlinekeys) { user.datas.remove(key); } }
Example 8
Source File: LPSpongeBootstrap.java From LuckPerms with MIT License | 4 votes |
@Listener(order = Order.LATE) public void onLateEnable(GamePreInitializationEvent event) { this.plugin.lateEnable(); }