Java Code Examples for org.bukkit.entity.Player#sendMessage()
The following examples show how to use
org.bukkit.entity.Player#sendMessage() .
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: TauntOption.java From SkyWarsReloaded with GNU General Public License v3.0 | 6 votes |
/**Does the taunt for a player */ public void performTaunt(Player player) { if (!this.getKey().equalsIgnoreCase("none")) { SkyWarsReloaded.getNMS().playGameSound(player.getLocation(), sound, volume, pitch, useCustomSound); doTauntParticles(player.getUniqueId().toString()); if (this.getMessage() != null && this.getMessage().length() != 0) { String prefix = new Messaging.MessageFormatter().setVariable("player", player.getDisplayName()).format("taunt.prefix"); List<Player> players = player.getWorld().getPlayers(); for (Player p: players) { if(p.getLocation().distance(player.getLocation()) < this.getVolume()*15) { p.sendMessage(ChatColor.translateAlternateColorCodes('&', prefix + " " + this.getMessage())); } } } } }
Example 2
Source File: AutojoinCommand.java From BedWars with GNU Lesser General Public License v3.0 | 6 votes |
@Override public boolean execute(CommandSender sender, List<String> args) { Player player = (Player) sender; if (Main.isPlayerInGame(player)) { player.sendMessage(i18n("you_are_already_in_some_game")); return true; } Game game = Main.getInstance().getFirstWaitingGame(); if (game == null) { player.sendMessage(i18n("there_is_no_empty_game")); } else { game.joinToGame(player); } return true; }
Example 3
Source File: PlayerChat.java From FunnyGuilds with Apache License 2.0 | 6 votes |
private void sendMessageToGuild(Guild guild, Player player, String message) { if (guild == null || player == null || !player.isOnline()) { return; } for (User user : guild.getOnlineMembers()) { Player p = user.getPlayer(); if (p == null) { continue; } if (!p.equals(player) || !user.getCache().isSpy()) { p.sendMessage(message); } } }
Example 4
Source File: PunishmentCommands.java From CardinalPGM with MIT License | 6 votes |
@Command(aliases = {"mute"}, usage = "<player>", desc = "Prevents a player from talking.", min = 1) @CommandPermissions("cardinal.punish.mute") public static void mute(CommandContext cmd, CommandSender sender) throws CommandException { Player player = Bukkit.getPlayer(cmd.getString(0)); if (player == null) { throw new CommandException(ChatConstant.ERROR_NO_PLAYER_MATCH.getMessage(ChatUtil.getLocale(sender))); } if (!sender.isOp() && player.isOp()) { throw new CommandException(ChatConstant.ERROR_PLAYER_NOT_AFFECTED.getMessage(ChatUtil.getLocale(sender))); } if (GameHandler.getGameHandler().getMatch().getModules().getModule(PermissionModule.class).isMuted(player)) { throw new CommandException(ChatConstant.ERROR_PLAYER_ALREADY_MUTED.getMessage(ChatUtil.getLocale(sender))); } sender.sendMessage(new UnlocalizedChatMessage(ChatColor.RED + "{0}", new LocalizedChatMessage(ChatConstant.GENERIC_MUTED, Players.getName(player))).getMessage(ChatUtil.getLocale(sender))); player.sendMessage(new UnlocalizedChatMessage(ChatColor.RED + "{0}", new LocalizedChatMessage(ChatConstant.GENERIC_MUTED_BY, Players.getName(sender))).getMessage(ChatUtil.getLocale(player))); GameHandler.getGameHandler().getMatch().getModules().getModule(PermissionModule.class).mute(player); }
Example 5
Source File: CompatibilityHelper.java From WorldEditSelectionVisualizer with MIT License | 5 votes |
public void sendActionBar(Player player, String message) { if (!supportActionBar) { player.sendMessage(message); return; } SpigotActionBarAdapter.sendActionBar(player, message); }
Example 6
Source File: CivMessage.java From civcraft with GNU General Public License v2.0 | 5 votes |
public static void sendCamp(Camp camp, String message) { for (Resident resident : camp.getMembers()) { try { Player player = CivGlobal.getPlayer(resident); player.sendMessage(CivColor.Yellow+"[Camp] "+CivColor.Yellow+message); CivLog.info("[Camp:"+camp.getName()+"] "+message); } catch (CivException e) { //player not online. } } }
Example 7
Source File: Listeners.java From PlayerVaults with GNU General Public License v3.0 | 5 votes |
@EventHandler(ignoreCancelled = true) public void onDrag(InventoryDragEvent event) { if (!(event.getWhoClicked() instanceof Player)) { return; } Player player = (Player) event.getWhoClicked(); Inventory clickedInventory = event.getInventory(); if (clickedInventory != null) { VaultViewInfo info = PlayerVaults.getInstance().getInVault().get(player.getUniqueId().toString()); if (info != null) { int num = info.getNumber(); String inventoryTitle = event.getView().getTitle(); String title = Lang.VAULT_TITLE.toString().replace("%number", String.valueOf(num)).replace("%p", info.getVaultName()); if ((inventoryTitle != null && inventoryTitle.equalsIgnoreCase(title)) && event.getNewItems() != null) { for (ItemStack item : event.getNewItems().values()) { try { item.toString(); } catch (Exception e) { player.sendMessage(Lang.TITLE.toString() + Lang.BLOCKED_BAD_ITEM); event.setCancelled(true); continue; } if (!player.hasPermission("playervaults.bypassblockeditems") && PlayerVaults.getInstance().isBlockedMaterial(item.getType())) { event.setCancelled(true); player.sendMessage(Lang.TITLE.toString() + Lang.BLOCKED_ITEM.toString().replace("%m", item.getType().name())); return; } } } } } }
Example 8
Source File: SpawnCommand.java From AuthMeReloaded with GNU General Public License v3.0 | 5 votes |
@Override public void runCommand(Player player, List<String> arguments) { if (spawnLoader.getSpawn() == null) { player.sendMessage("[AuthMe] Spawn has failed, please try to define the spawn"); } else { player.teleport(spawnLoader.getSpawn()); } }
Example 9
Source File: AddholoCommand.java From BedWars with GNU Lesser General Public License v3.0 | 5 votes |
@Override public boolean execute(CommandSender sender, List<String> args) { Player player = (Player) sender; if (!Main.isHologramsEnabled()) { player.sendMessage(i18n("holo_not_enabled")); } else { Main.getHologramInteraction().addHologramLocation(player.getEyeLocation()); Main.getHologramInteraction().updateHolograms(); player.sendMessage(i18n("holo_added")); } return true; }
Example 10
Source File: SpawnerMineListener.java From MineableSpawners with MIT License | 5 votes |
private void handleStillBreak(BlockBreakEvent e, Player player, String msg, String reason) { if (!plugin.getConfigurationHandler().getBoolean("mining", "still-break")) { e.setCancelled(true); player.sendMessage(Chat.format(msg)); return; } if (msg.length() > 0) { player.sendMessage(plugin.getConfigurationHandler().getMessage("mining", "still-break").replace("%requirement%", reason)); } }
Example 11
Source File: WarpGUI.java From IridiumSkyblock with GNU General Public License v2.0 | 5 votes |
@EventHandler @Override public void onInventoryClick(InventoryClickEvent e) { if (e.getInventory().equals(getInventory())) { Player p = (Player) e.getWhoClicked(); User u = User.getUser(p); e.setCancelled(true); if (e.getClickedInventory() == null || !e.getClickedInventory().equals(getInventory())) return; if (warps.containsKey(e.getSlot())) { Island.Warp warp = warps.get(e.getSlot()); if (e.getClick().equals(ClickType.RIGHT)) { u.getIsland().removeWarp(warps.get(e.getSlot())); getInventory().clear(); addContent(); } else { if (warp.getPassword().isEmpty()) { p.teleport(warp.getLocation()); p.sendMessage(Utils.color(IridiumSkyblock.getMessages().teleporting.replace("%prefix%", IridiumSkyblock.getConfiguration().prefix))); } else { p.sendMessage(Utils.color(IridiumSkyblock.getMessages().enterPassword.replace("%prefix%", IridiumSkyblock.getConfiguration().prefix))); u.warp = warp; } } p.closeInventory(); } } }
Example 12
Source File: Pos2Command.java From RedProtect with GNU General Public License v3.0 | 5 votes |
@Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { if (sender instanceof ConsoleCommandSender) { HandleHelpPage(sender, 1); return true; } Player player = (Player) sender; String claimmode = RedProtect.get().config.getWorldClaimType(player.getWorld().getName()); if (!claimmode.equalsIgnoreCase("WAND") && !claimmode.equalsIgnoreCase("BOTH") && !RedProtect.get().ph.hasCommandPerm(player, "redefine")) { return true; } if (args.length == 0) { Location pl = player.getLocation(); RedProtect.get().secondLocationSelections.put(player, pl); player.sendMessage(RedProtect.get().lang.get("playerlistener.wand2") + RedProtect.get().lang.get("general.color") + " (" + ChatColor.GOLD + pl.getBlockX() + RedProtect.get().lang.get("general.color") + ", " + ChatColor.GOLD + pl.getBlockY() + RedProtect.get().lang.get("general.color") + ", " + ChatColor.GOLD + pl.getBlockZ() + RedProtect.get().lang.get("general.color") + ")."); //show preview border if (RedProtect.get().firstLocationSelections.containsKey(player) && RedProtect.get().secondLocationSelections.containsKey(player)) { Location loc1 = RedProtect.get().firstLocationSelections.get(player); Location loc2 = RedProtect.get().secondLocationSelections.get(player); if (RedProtect.get().hooks.worldEdit && RedProtect.get().config.configRoot().hooks.useWECUI) { WEHook.setSelectionRP(player, loc1, loc2); } if (loc1.getWorld().equals(loc2.getWorld()) && loc1.distanceSquared(loc2) > RedProtect.get().config.configRoot().region_settings.max_scan && !RedProtect.get().ph.hasPerm(player, "redprotect.bypass.define-max-distance")) { double dist = loc1.distanceSquared(loc2); RedProtect.get().lang.sendMessage(player, String.format(RedProtect.get().lang.get("regionbuilder.selection.maxdefine"), RedProtect.get().config.configRoot().region_settings.max_scan, (int) dist)); } else { RedProtect.get().getUtil().addBorder(player, new Region("", loc1, loc2, player.getWorld().getName())); } } return true; } RedProtect.get().lang.sendCommandHelp(sender, "pos2", true); return true; }
Example 13
Source File: SetMainLobbyCommand.java From BedwarsRel with GNU General Public License v3.0 | 5 votes |
@Override public boolean execute(CommandSender sender, ArrayList<String> args) { if (!super.hasPermission(sender)) { return false; } Player player = (Player) sender; Game game = this.getPlugin().getGameManager().getGame(args.get(0)); if (game == null) { player.sendMessage(ChatWriter.pluginMessage(ChatColor.RED + BedwarsRel ._l(player, "errors.gamenotfound", ImmutableMap.of("game", args.get(0).toString())))); return false; } if (game.getState() != GameState.STOPPED) { sender.sendMessage( ChatWriter.pluginMessage(ChatColor.RED + BedwarsRel ._l(sender, "errors.notwhilegamerunning"))); return false; } game.setMainLobby(player.getLocation()); player.sendMessage( ChatWriter.pluginMessage(ChatColor.GREEN + BedwarsRel._l(player, "success.mainlobbyset"))); return true; }
Example 14
Source File: XPMain.java From AnnihilationPro with MIT License | 5 votes |
@EventHandler(priority = EventPriority.NORMAL) public void test(PlayerCommandPreprocessEvent e) { Player player = e.getPlayer(); String[] args = e.getMessage().split(" "); if(args[0].equals("/test") && player.getName().equalsIgnoreCase("Mr_Little_Kitty")) { AnniPlayer p = AnniPlayer.getPlayer(player.getUniqueId()); if(p != null) { Object obj = p.getData("Kits"); if(obj != null) { if(obj instanceof List) { @SuppressWarnings("unchecked") List<String> list = (List<String>)obj; if(!list.isEmpty()) { for(String str : list) player.sendMessage("Has: "+str); } else player.sendMessage("Nope 4"); } else player.sendMessage("Nope 3"); } else player.sendMessage("Nope 2"); } else player.sendMessage("Nope 1"); } }
Example 15
Source File: SupplyCrate.java From CratesPlus with GNU General Public License v3.0 | 5 votes |
public boolean give(OfflinePlayer offlinePlayer, Integer amount) { if (offlinePlayer == null || !offlinePlayer.isOnline()) return false; // TODO add offline player support Player player = (Player) offlinePlayer; if (player.getInventory().firstEmpty() == -1) { // TODO Inventory full, do something for this! player.sendMessage(ChatColor.RED + "Inventory full, I'll do something for this soon..."); return false; } else { player.getInventory().addItem(getCrateItemStack(amount)); return true; } }
Example 16
Source File: EvolveEffect.java From Civs with GNU General Public License v3.0 | 4 votes |
@EventHandler public void onRegionUpkeep(RegionUpkeepEvent event) { Location l = event.getRegion().getLocation(); Region r = event.getRegion(); RegionType rt = (RegionType) ItemManager.getInstance().getItemType(r.getType()); if (!r.getEffects().containsKey(KEY)) { return; } int evolve; try { evolve = Integer.parseInt(r.getEffects().get(KEY).split("\\.")[1]); } catch (Exception e) { Civs.logger.severe("Invalid evolve config in " + rt.getName() + ".yml"); return; } if (r.getExp() < evolve) { return; } String evolveTarget = r.getEffects().get(KEY).split("\\.")[0].toLowerCase(); for (UUID uuid : r.getOwners()) { Player player = Bukkit.getPlayer(uuid); Civilian civilian = CivilianManager.getInstance().getCivilian(uuid); String locationString = r.getLocation().getWorld().getName() + " " + (int) r.getLocation().getX() + (int) r.getLocation().getY() + (int) r.getLocation().getZ(); String typeName = LocaleManager.getInstance().getTranslation(civilian.getLocale(), r.getType().toLowerCase() + "-name"); String evolveName = LocaleManager.getInstance().getTranslation(civilian.getLocale(), evolveTarget.toLowerCase() + "-name"); if (player != null && player.isOnline()) { player.sendMessage(Civs.getPrefix() + LocaleManager.getInstance().getTranslation(civilian.getLocale(), "region-evolved") .replace("$1", typeName) .replace("$2", evolveName)); } } RegionType regionType = (RegionType) ItemManager.getInstance().getItemType(evolveTarget); if (regionType == null) { Civs.logger.severe("Invalid evolveTarget " + evolveTarget); return; } r.setExp(0); r.setType(regionType.getName()); r.setEffects((HashMap<String, String>) regionType.getEffects().clone()); RegionManager.getInstance().saveRegion(r); }
Example 17
Source File: ChestSlimefunGuide.java From Slimefun4 with GNU General Public License v3.0 | 4 votes |
private void printErrorMessage(Player p, Throwable x) { p.sendMessage(ChatColor.DARK_RED + "An internal server error has occurred. Please inform an admin, check the console for further info."); Slimefun.getLogger().log(Level.SEVERE, "An error has occurred while trying to open a SlimefunItem in the guide!", x); }
Example 18
Source File: InviteHandler.java From uSkyBlock with GNU General Public License v3.0 | 4 votes |
private synchronized boolean accept(final Player player) { UUID uuid = player.getUniqueId(); us.talabrek.ultimateskyblock.api.IslandInfo oldIsland = plugin.getIslandInfo(player); if (oldIsland != null && oldIsland.isParty()) { player.sendMessage(tr("\u00a74You can't use that command right now. Leave your current party first.")); return false; } Invite invite = inviteMap.remove(uuid); if (invite != null) { if (invite.getTimeoutTask() != null) { invite.getTimeoutTask().cancel(); } PlayerInfo pi = plugin.getPlayerInfo(player); final IslandInfo island = plugin.getIslandInfo(invite.getIslandName()); boolean deleteOldIsland = false; if (pi.getHasIsland() && pi.getIslandLocation() != null) { String islandName = WorldGuardHandler.getIslandNameAt(pi.getIslandLocation()); deleteOldIsland = !island.getName().equals(islandName); } Map<UUID, String> uuids = waitingInvites.get(invite.getIslandName()); if (uuids != null) { uuids.remove(uuid); } Runnable joinIsland = new Runnable() { @Override public void run() { player.sendMessage(tr("\u00a7aYou have joined an island! Use /island party to see the other members.")); addPlayerToParty(player, island); plugin.getTeleportLogic().homeTeleport(player, true); plugin.clearPlayerInventory(player); } }; if (deleteOldIsland) { plugin.deletePlayerIsland(player.getName(), joinIsland); } else { joinIsland.run(); } return true; } return false; }
Example 19
Source File: IslandInfo.java From uSkyBlock with GNU General Public License v3.0 | 4 votes |
public void sendMessageToOnlineMembers(String msg) { String message = tr("\u00a7cSKY \u00a7f> \u00a77 {0}", msg); for (Player player : getOnlineMembers()) { player.sendMessage(message); } }
Example 20
Source File: ItemListener.java From MineTinker with GNU General Public License v3.0 | 4 votes |
@EventHandler(ignoreCancelled = true) public void onItemBreak(PlayerItemBreakEvent event) { Player player = event.getPlayer(); ItemStack item = event.getBrokenItem(); if (!MineTinker.getPlugin().getConfig().getBoolean("UnbreakableTools", true)) { return; } if (Lists.WORLDS.contains(player.getWorld().getName())) { return; } if (!modManager.isToolViable(item) && !modManager.isArmorViable(item)) { return; } if (!MineTinker.getPlugin().getConfig().getBoolean("ItemBehaviour.StopBreakEvent", true)) { return; } if (MineTinker.getPlugin().getConfig().getBoolean("ItemBehaviour.AlertPlayerOnBreak", true)) { player.sendMessage(LanguageManager.getString("Alert.OnItemBreak", player)); } ItemMeta meta = item.getItemMeta(); if (meta instanceof Damageable) { ((Damageable) meta).setDamage(item.getType().getMaxDurability() - 1); } if (meta instanceof CrossbowMeta) { //TODO: Crossbow will still shoot arrow ((CrossbowMeta) meta).setChargedProjectiles(new ArrayList<>()); } item.setItemMeta(meta); if (player.getInventory().addItem(item).size() != 0) { //adds items to (full) inventory if (!MineTinker.getPlugin().getConfig().getBoolean("ItemBehaviour.DisableDroppingBehaviour")) { PlayerDropItemEvent dropItemEvent = new PlayerDropItemEvent(player, player.getWorld().dropItem(player.getLocation(), item)); Bukkit.getPluginManager().callEvent(dropItemEvent); //To trigger item behaviour } else { player.getWorld().dropItem(player.getLocation(), item); } } // no else as it gets added in if-clause }