org.spongepowered.api.text.chat.ChatTypes Java Examples
The following examples show how to use
org.spongepowered.api.text.chat.ChatTypes.
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: SpongeUtil.java From GriefDefender with MIT License | 5 votes |
public static ChatType getSpongeChatType(com.griefdefender.api.ChatType chatType) { switch (chatType.getName()) { case "CHAT" : return ChatTypes.CHAT; case "ACTION_BAR" : return ChatTypes.ACTION_BAR; } return ChatTypes.SYSTEM; }
Example #2
Source File: ClaimDelayTask.java From EagleFactions with MIT License | 5 votes |
@Override public void accept(Task task) { if(!chunkPosition.equals(player.getLocation().getChunkPosition())) { player.sendMessage(Text.of(PluginInfo.ERROR_PREFIX, TextColors.RED, Messages.YOU_MOVED_FROM_THE_CHUNK)); task.cancel(); } if(currentWaitSeconds >= claimDelay) { final Optional<Faction> optionalFaction = this.factionLogic.getFactionByPlayerUUID(player.getUniqueId()); if(!optionalFaction.isPresent()) { player.sendMessage(Text.of(PluginInfo.ERROR_PREFIX, TextColors.RED, Messages.YOU_MUST_BE_IN_FACTION_IN_ORDER_TO_USE_THIS_COMMAND)); task.cancel(); } if(shouldClaimByItems) { boolean didSucceed = this.factionLogic.addClaimByItems(player, optionalFaction.get(), player.getWorld().getUniqueId(), chunkPosition); if(didSucceed) player.sendMessage(Text.of(PluginInfo.PLUGIN_PREFIX, Messages.LAND + " ", TextColors.GOLD, chunkPosition.toString(), TextColors.WHITE, " " + Messages.HAS_BEEN_SUCCESSFULLY + " ", TextColors.GOLD, Messages.CLAIMED, TextColors.WHITE, "!")); else player.sendMessage(Text.of(PluginInfo.ERROR_PREFIX, TextColors.RED, Messages.YOU_DONT_HAVE_ENOUGH_RESOURCES_TO_CLAIM_A_TERRITORY)); } else { factionLogic.addClaim(optionalFaction.get(), new Claim(player.getWorld().getUniqueId(), chunkPosition)); player.sendMessage(Text.of(PluginInfo.PLUGIN_PREFIX, Messages.LAND + " ", TextColors.GOLD, chunkPosition.toString(), TextColors.WHITE, " " + Messages.HAS_BEEN_SUCCESSFULLY + " ", TextColors.GOLD, Messages.CLAIMED, TextColors.WHITE, "!")); } task.cancel(); } else { player.sendMessage(ChatTypes.ACTION_BAR, Text.of(PluginInfo.PLUGIN_PREFIX, TextColors.RESET, currentWaitSeconds)); currentWaitSeconds++; } }
Example #3
Source File: HomeCommand.java From EagleFactions with MIT License | 5 votes |
private void teleportHome(Player player, Vector3i lastBlockPosition, FactionHome factionHome) { if (this.factionsConfig.getHomeDelayTime() == 0 || player.hasPermission(PluginPermissions.HOME_COMMAND_NO_DELAY)) { teleport(player, factionHome); return; } player.sendMessage(ChatTypes.ACTION_BAR, Text.of(Messages.STAND_STILL_FOR + " ", TextColors.GOLD, this.factionsConfig.getHomeDelayTime() + " " + Messages.SECONDS, TextColors.RESET, "!")); final EagleFactionsScheduler eagleFactionsScheduler = EagleFactionsScheduler.getInstance(); eagleFactionsScheduler.scheduleWithDelayedInterval(new ParticlesUtil.HomeParticles(player), 0, TimeUnit.SECONDS, 50, TimeUnit.MILLISECONDS); eagleFactionsScheduler.scheduleWithDelayedInterval(new EagleFactionsConsumerTask<Task>() { int seconds = factionsConfig.getHomeDelayTime(); @Override public void accept(Task task) { if (!player.getLocation().getBlockPosition().equals(lastBlockPosition)) { player.sendMessage(ChatTypes.ACTION_BAR, Text.of(TextColors.RED, Messages.YOU_MOVED + " " + Messages.TELEPORTING_HAS_BEEN_CANCELLED)); task.cancel(); return; } if (seconds <= 0) { teleport(player, factionHome); task.cancel(); } else { player.sendMessage(ChatTypes.ACTION_BAR, Text.of(TextColors.AQUA, MessageLoader.parseMessage(Messages.TELEPORTING_TO_FACTION_HOME, TextColors.AQUA, ImmutableMap.of(Placeholders.NUMBER, Text.of(TextColors.GOLD, seconds))))); seconds--; } } }, 2, TimeUnit.SECONDS, 1, TimeUnit.SECONDS); }
Example #4
Source File: HomeCommand.java From EagleFactions with MIT License | 5 votes |
private void teleport(final Player player, final FactionHome factionHome) { final Optional<World> optionalWorld = Sponge.getServer().getWorld(factionHome.getWorldUUID()); if (!optionalWorld.isPresent()) { player.sendMessage(Text.of(PluginInfo.ERROR_PREFIX, TextColors.RED, Messages.MISSING_OR_CORRUPTED_HOME)); return; } player.setLocationSafely(new Location<>(optionalWorld.get(), factionHome.getBlockPosition())); player.sendMessage(ChatTypes.ACTION_BAR, Text.of(TextColors.GREEN, Messages.YOU_WERE_TELEPORTED_TO_FACTIONS_HOME)); startHomeCooldown(player.getUniqueId()); }
Example #5
Source File: VirtualChestActions.java From VirtualChest with GNU Lesser General Public License v3.0 | 5 votes |
private CompletableFuture<CommandResult> processTitle(CommandResult parent, String command, ClassToInstanceMap<Context> contextMap) { Text text = TextSerializers.FORMATTING_CODE.deserialize(command); contextMap.getInstance(Context.PLAYER).getPlayer().ifPresent(p -> p.sendMessage(ChatTypes.ACTION_BAR, text)); return CompletableFuture.completedFuture(CommandResult.success()); }
Example #6
Source File: PlayerMoveListener.java From Nations with MIT License | 4 votes |
@Listener public void onPlayerMove(MoveEntityEvent event, @First Player player) { if (event.getFromTransform().getLocation().getBlockX() == event.getToTransform().getLocation().getBlockX() && event.getFromTransform().getLocation().getBlockZ() == event.getToTransform().getLocation().getBlockZ()) { return; } if (!ConfigHandler.getNode("worlds").getNode(event.getToTransform().getExtent().getName()).getNode("enabled").getBoolean()) { return; } Location<World> loc = event.getToTransform().getLocation(); Nation nation = DataHandler.getNation(loc); Nation lastNationWalkedOn = DataHandler.getLastNationWalkedOn(player.getUniqueId()); Zone zone = null; if (nation != null) { zone = nation.getZone(loc); } Zone lastZoneWalkedOn = DataHandler.getLastZoneWalkedOn(player.getUniqueId()); if ((nation == null && lastNationWalkedOn == null) || (nation != null && lastNationWalkedOn != null && nation.getUUID().equals(lastNationWalkedOn.getUUID()))) { if ((zone == null && lastZoneWalkedOn == null) || (zone != null && lastZoneWalkedOn != null && zone.getUUID().equals(lastZoneWalkedOn.getUUID()))) { return; } } DataHandler.setLastNationWalkedOn(player.getUniqueId(), nation); DataHandler.setLastZoneWalkedOn(player.getUniqueId(), zone); String toast; if (nation == null) { toast = ConfigHandler.getNode("toast", "wild").getString(); } else { toast = (zone == null ? ConfigHandler.getNode("toast", "nation").getString() : ConfigHandler.getNode("toast", "zone").getString()); } String formatPresident = ""; if (nation != null && !nation.isAdmin()) { formatPresident = ConfigHandler.getNode("toast", "formatPresident").getString() .replaceAll("\\{TITLE\\}", DataHandler.getCitizenTitle(nation.getPresident())) .replaceAll("\\{NAME\\}", DataHandler.getPlayerName(nation.getPresident())); } String formatZoneName = ""; String formatZoneOwner = ""; String formatZonePrice = ""; if (zone != null) { if (zone.isNamed()) formatZoneName = ConfigHandler.getNode("toast", "formatZoneName").getString().replaceAll("\\{ARG\\}", zone.getName()) + " "; if (zone.isOwned()) formatZoneOwner = ConfigHandler.getNode("toast", "formatZoneOwner").getString().replaceAll("\\{ARG\\}", DataHandler.getPlayerName(zone.getOwner())) + " "; if (zone.isForSale()) formatZonePrice = ConfigHandler.getNode("toast", "formatZonePrice").getString().replaceAll("\\{ARG\\}", Utils.formatPricePlain(zone.getPrice())) + " "; } String formatPvp; if (DataHandler.getFlag("pvp", loc)) { formatPvp = ConfigHandler.getNode("toast", "formatPvp").getString().replaceAll("\\{ARG\\}", LanguageHandler.TOAST_PVP); } else { formatPvp = ConfigHandler.getNode("toast", "formatNoPvp").getString().replaceAll("\\{ARG\\}", LanguageHandler.TOAST_NOPVP); } if (nation != null) { toast = toast.replaceAll("\\{NATION\\}", nation.getName()); } else { toast = toast.replaceAll("\\{WILD\\}", LanguageHandler.TOAST_WILDNAME); } Text finalToast = TextSerializers.FORMATTING_CODE.deserialize(toast .replaceAll("\\{FORMATPRESIDENT\\}", formatPresident) .replaceAll("\\{FORMATZONENAME\\}", formatZoneName) .replaceAll("\\{FORMATZONEOWNER\\}", formatZoneOwner) .replaceAll("\\{FORMATZONEPRICE\\}", formatZonePrice) .replaceAll("\\{FORMATPVP\\}", formatPvp)); player.sendMessage(ChatTypes.ACTION_BAR, finalToast); MessageChannel.TO_CONSOLE.send(Text.of(player.getName(), " entered area ", finalToast)); }
Example #7
Source File: SpongePlayer.java From PlotMe-Core with GNU General Public License v3.0 | 4 votes |
@Override public void sendMessage(String message) { player.sendMessage(ChatTypes.CHAT, message); }
Example #8
Source File: BorderClaimEvent.java From GriefPrevention with MIT License | 2 votes |
/** * Sets the exit message for this event only. * The message will send as the chat type {@link ChatTypes#CHAT} * * Note: Setting message to {@code null} will hide the message. * If no message is set, the {@link ClaimData#getFarewell()} will be used. * * For changing the ChatType see {@link BorderClaimEvent#setExitMessage(Text, ChatType)} * * @param message The message to set */ default void setExitMessage(@Nullable Text message) { setExitMessage(message, ChatTypes.CHAT); }
Example #9
Source File: BorderClaimEvent.java From GriefPrevention with MIT License | 2 votes |
/** * Sets the enter message for this event only. * The message will send as the chat type {@link ChatTypes#CHAT} * * Note: Setting message to {@code null} will hide the message. * If no message is set, the {@link ClaimData#getGreeting()} will be used. * * For changing the ChatType see {@link BorderClaimEvent#setEnterMessage(Text, ChatType)} * * @param message The message to set */ default void setEnterMessage(@Nullable Text message) { setEnterMessage(message, ChatTypes.CHAT); }