Java Code Examples for org.bukkit.Bukkit.broadcastMessage()

The following are Jave code examples for showing how to use broadcastMessage() of the org.bukkit.Bukkit class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: Crescent   File: NoSwingA.java   View Source Code Vote up 6 votes
@Override
public void call(Event event) {
	if (event instanceof PlayerInteractEvent) {
		final PlayerInteractEvent pie = (PlayerInteractEvent) event;

		// Types of interacting where the arm must swing.
		if (pie.getAction() == Action.LEFT_CLICK_AIR || pie.getAction() == Action.LEFT_CLICK_BLOCK) {
			lastInteract = System.currentTimeMillis();
		}
	} else if (event instanceof PlayerAnimationEvent) {
		final PlayerAnimationEvent pae = (PlayerAnimationEvent) event;

		if (pae.getAnimationType() == PlayerAnimationType.ARM_SWING) {
			final long difference = System.currentTimeMillis() - lastInteract;

			Bukkit.broadcastMessage("swing difference: " + difference);
		}
	}
}
 
Example 2
Project: FlexMC   File: PlayerManager.java   View Source Code Vote up 6 votes
public void handlePlayerJoin( FlexPlayer player ) {
    this.players.put( player.getUuid(), player );
    List<MessageS2EPlayerList.PlayerItem> items = new ArrayList<>();
    for ( FlexPlayer target : this.getOnlinePlayers() ) {
        if( !target.equals( player ) ) {
            target.getConnectionHandler().sendMessage( new MessageS2EPlayerList( MessageS2EPlayerList.Action.ADD_PLAYER,
                    Collections.singletonList( new MessageS2EPlayerList.PlayerItem().setUuid( player.getUuid() ).setName( player.getName() ).setGameMode( player.getGameMode() ).setPing( player.getLatency() ) ) ) );
        }
        items.add( new MessageS2EPlayerList.PlayerItem().setName( target.getName() ).setUuid( target.getUuid() ).setGameMode( target.getGameMode() ).setPing( target.getLatency() ) );
    }
    player.getConnectionHandler().sendMessage( new MessageS2EPlayerList( MessageS2EPlayerList.Action.ADD_PLAYER, items ) );
    System.out.println( player.getName() + " (" + player.getUuid().toString() + ") logged in from " + player.getIpAddress() );
    player.spawnPlayer();
    player.getWorld().addEntity( player, true );

    String joinMessage = EventFactory.call( new PlayerJoinEvent( player, "§e" + player.getName() + " joined the game." ) ).getJoinMessage();
    if( joinMessage != null && !joinMessage.isEmpty() ) {
        Bukkit.broadcastMessage( joinMessage );
    }

}
 
Example 3
Project: HCFCore   File: EventTimer.java   View Source Code Vote up 6 votes
/**
 * Handles the winner for this event.
 *
 * @param winner
 *            the {@link Player} that won
 */
public void handleWinner(Player winner) {
    if (this.eventFaction == null)
        return;

    PlayerFaction playerFaction = plugin.getFactionManager().getPlayerFaction(winner);
    Bukkit.broadcastMessage(ChatColor.GOLD + "[" + "WIN" + "] " + ChatColor.RED + winner.getName() + ChatColor.AQUA
            + ChatColor.YELLOW + " has captured " + ChatColor.RED + this.eventFaction.getName()
            + ChatColor.YELLOW + " after " + ChatColor.RED + DurationFormatUtils.formatDurationWords(getUptime(), true, true) + " of up-time" + ChatColor.YELLOW + '.');

    EventType eventType = this.eventFaction.getEventType();
    World world = winner.getWorld();
    Location location = winner.getLocation();
    EventKey eventKey = plugin.getKeyManager().getEventKey();
    Collection<Inventory> inventories = eventKey.getInventories(eventType);
    ItemStack keyStack = eventKey.getItemStack(new EventKey.EventKeyData(eventType, inventories.isEmpty() ? 1 : plugin.getRandom().nextInt(inventories.size()) + 1));
    Map<Integer, ItemStack> excess = winner.getInventory().addItem(keyStack, EventSignListener.getEventSign(eventFaction.getName(), winner.getName()));
    for (ItemStack entry : excess.values()) {
        world.dropItemNaturally(location, entry);
    }

    this.clearCooldown(); // must always be cooled last as this nulls some variables.
}
 
Example 4
Project: ProjectAres   File: KDMListener.java   View Source Code Vote up 6 votes
@EventHandler(priority = EventPriority.LOW)
public void onMatchEnd(MatchEndEvent event) {
    Match match = event.getMatch();
    Tourney plugin = Tourney.get();
    this.session.appendMatch(match, plugin.getMatchManager().getTeamManager().teamToEntrant(Iterables.getOnlyElement(event.getMatch().needMatchModule(VictoryMatchModule.class).winners(), null)));

    Entrant winningParticipation = this.session.calculateWinner();
    int matchesPlayed = this.session.getMatchesPlayed();
    if (winningParticipation != null) {
        Bukkit.broadcastMessage(ChatColor.YELLOW + "A winner has been determined!");
        Bukkit.broadcastMessage(ChatColor.AQUA + WordUtils.capitalize(winningParticipation.team().name()) + ChatColor.RESET + ChatColor.YELLOW + " wins! Congratulations!");
        plugin.clearKDMSession();
    } else if (matchesPlayed < 3) {
        Bukkit.broadcastMessage(ChatColor.YELLOW + "A winner has not yet been determined! Beginning match #" + (matchesPlayed + 1) + "...");
        match.needMatchModule(CycleMatchModule.class).startCountdown(Duration.ofSeconds(15), session.getMap());
    } else {
        Bukkit.broadcastMessage(ChatColor.YELLOW + "There is a tie! Congratulations to both teams!");
        Tourney.get().clearKDMSession();
    }
}
 
Example 5
Project: HCFCore   File: KothTracker.java   View Source Code Vote up 6 votes
@Override
public void tick(EventTimer eventTimer, EventFaction eventFaction) {
    CaptureZone captureZone = ((KothFaction) eventFaction).getCaptureZone();
    captureZone.updateScoreboardRemaining();
    long remainingMillis = captureZone.getRemainingCaptureMillis();
    if (remainingMillis <= 0L) { // has been captured.
        plugin.getTimerManager().getEventTimer().handleWinner(captureZone.getCappingPlayer());
        eventTimer.clearCooldown();
        return;
    }

    if (remainingMillis == captureZone.getDefaultCaptureMillis())
        return;

    int remainingSeconds = (int) (remainingMillis / 1000L);
    if (remainingSeconds > 0 && remainingSeconds % 30 == 0) {
        Bukkit.broadcastMessage(ChatColor.GOLD + "[" + eventFaction.getEventType().getDisplayName() + "] " + ChatColor.YELLOW + "Someone is controlling " + ChatColor.RED
                + captureZone.getDisplayName() + ChatColor.YELLOW + ". " + ChatColor.RED + '(' + DateTimeFormats.KOTH_FORMAT.format(remainingMillis) + ')');
    }
}
 
Example 6
Project: HCFCore   File: EventCancelArgument.java   View Source Code Vote up 5 votes
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    EventTimer eventTimer = plugin.getTimerManager().getEventTimer();
    Faction eventFaction = eventTimer.getEventFaction();

    if (!eventTimer.clearCooldown()) {
        sender.sendMessage(ChatColor.RED + "There is not a running event.");
        return true;
    }

    Bukkit.broadcastMessage(sender.getName() + ChatColor.YELLOW + " has cancelled " + (eventFaction == null ? "the active event" : eventFaction.getName() + ChatColor.YELLOW) + ".");
    return true;
}
 
Example 7
Project: Chambers   File: CountdownTask.java   View Source Code Vote up 5 votes
@Override
public void run() {
	Game game = Chambers.getInstance().getGameManager().getGame();
	game.setCountdownTime(game.getCountdownTime() - 1);
	if (game.getCountdownTime() == 0) {
		Chambers.getInstance().getGameManager().finallyStart();
		cancel();
	} else if (game.getCountdownTime() % 5 == 0 || game.getCountdownTime() <= 5) {
		Bukkit.broadcastMessage(ChatColor.YELLOW + "Game starting in " + ChatColor.GREEN + game.getCountdownTime() + ChatColor.YELLOW + (game.getCountdownTime() == 1 ? " second" : " seconds") + ".");
	}
}
 
Example 8
Project: HCFCore   File: KothTracker.java   View Source Code Vote up 5 votes
@Override
public void onControlLoss(Player player, CaptureZone captureZone, EventFaction eventFaction) {
    player.sendMessage(ChatColor.RED + "You are no longer in control of " + ChatColor.RED + captureZone.getDisplayName() + ChatColor.DARK_AQUA + '.');

    // Only broadcast if the KOTH has been controlled for at least 25 seconds to prevent spam.
    long remainingMillis = captureZone.getRemainingCaptureMillis();
    if (remainingMillis > 0L && captureZone.getDefaultCaptureMillis() - remainingMillis > MINIMUM_CONTROL_TIME_ANNOUNCE) {
        Bukkit.broadcastMessage(ChatColor.GOLD + "[" + eventFaction.getEventType().getDisplayName() + "] " + ChatColor.RED + captureZone.getDisplayName() + ChatColor.YELLOW + " has been knocked!"
                + " (" + captureZone.getScoreboardRemaining() + ')');
    }
}
 
Example 9
Project: KingdomFactions   File: BroadcastCommand.java   View Source Code Vote up 5 votes
@Override
public void execute() {
	String message = "";
	for (String part : getArgs()) {
		if (message != "")
			message += " ";
		message += part;
	}
	Bukkit.broadcastMessage(ChatColor.BLACK + "[" + ChatColor.DARK_RED +"BROADCAST" + ChatColor.BLACK + "] " + ChatColor.WHITE + ChatColor.translateAlternateColorCodes('&', message));
	broadcast(PlayerModule.getInstance().getPlayer(getSender()).getFormattedName() + ChatColor.YELLOW + " broadcasted: " + message);
}
 
Example 10
Project: OpenUHC   File: Inventors.java   View Source Code Vote up 5 votes
/**
 * Checks if a player has crafted an item for the first time and announces it if this is the case.
 *
 * @param event The event
 */
@EventHandler(ignoreCancelled = true)
public void onCraftItem(CraftItemEvent event) {
  Material type = event.getRecipe().getResult().getType();
  if (!invented.contains(type)) {
    invented.add(type);
    Bukkit.broadcastMessage(
        event.getWhoClicked().getName() + ChatColor.GRAY + " has invented the " + ChatColor.AQUA + type.name()
    );
  }
}
 
Example 11
Project: Chambers   File: GameManager.java   View Source Code Vote up 5 votes
/**
 * Starts the Game
 */
public void start() {
	game.setStatus(GameStatus.STARTING);
	Bukkit.getOnlinePlayers().stream().forEach(player -> player.getInventory().clear());
	new CountdownTask().runTaskTimerAsynchronously(Chambers.getInstance(), 0L, 20L);
	Bukkit.broadcastMessage(ChatColor.YELLOW + "The countdown is now starting");
}
 
Example 12
Project: Bssentials-Reloaded   File: Brodcast.java   View Source Code Vote up 5 votes
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
	if(!hasPerm(sender, Permissions.BRODCAST)) {
		sender.sendMessage(NPP);
		return true;
	}
	
	if(args.length == 0) Bukkit.broadcastMessage(prefix);
	
	String s = StringUtils.join(args, " ");
	Bukkit.broadcastMessage(prefix + trans(s));
	return true;
}
 
Example 13
Project: EscapeLag   File: NetWorker.java   View Source Code Vote up 5 votes
public static void DownloadAntiAttack() {
    if (Bukkit.getPluginManager().getPlugin("AntiAttack") != null) {
        Bukkit.broadcastMessage("§a§l[EscapeLag]§c错误!您的服务器已经安装了AntiAttack反压测模块!无需再次安装!");
        return;
    }
    try {
        File AntiAttackFile = new File("/plugins", "AntiAttack.jar");
        DowloadFile("https://www.relatev.com/files/AntiAttack/AntiAttack.jar", AntiAttackFile);
        Bukkit.broadcastMessage("§a§l[EscapeLag]§b成功下载了AntiAttack反压测插件,重启即可生效!");
    } catch (IOException ex) {
    }
}
 
Example 14
Project: RuntimeTransformer   File: EntityLivingTransformer.java   View Source Code Vote up 4 votes
@Inject(InjectionType.INSERT)
private boolean d(DamageSource src) {
    Bukkit.broadcastMessage("Checked " + this.getName() + " for totem @ " + (int) this.locX + ", " + (int) this.locY + ", " + (int) this.locZ + "!");
    throw null; // Let original method continue execution
}
 
Example 15
Project: HCFCore   File: KothSetCapDelayArgument.java   View Source Code Vote up 4 votes
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    if (args.length < 3) {
        sender.sendMessage(ChatColor.RED + "Usage: " + getUsage(label));
        return true;
    }

    Faction faction = plugin.getFactionManager().getFaction(args[1]);

    if (faction == null || !(faction instanceof KothFaction)) {
        sender.sendMessage(ChatColor.RED + "There is not a KOTH arena named '" + args[1] + "'.");
        return true;
    }

    long duration = JavaUtils.parse(StringUtils.join(args, ' ', 2, args.length));

    if (duration == -1L) {
        sender.sendMessage(ChatColor.RED + "Invalid duration, use the correct format: 10m 1s");
        return true;
    }

    KothFaction kothFaction = (KothFaction) faction;
    CaptureZone captureZone = kothFaction.getCaptureZone();

    if (captureZone == null) {
        sender.sendMessage(ChatColor.RED + kothFaction.getDisplayName(sender) + ChatColor.RED + " does not have a capture zone.");
        return true;
    }

    // Update the remaining time if it is less.
    if (captureZone.isActive() && duration < captureZone.getRemainingCaptureMillis()) {
        captureZone.setRemainingCaptureMillis(duration);
    }

    captureZone.setDefaultCaptureMillis(duration);
    sender.sendMessage(ChatColor.YELLOW + "Set the capture delay of KOTH arena " + ChatColor.WHITE + kothFaction.getDisplayName(sender) + ChatColor.YELLOW + " to " + ChatColor.WHITE
            + DurationFormatUtils.formatDurationWords(duration, true, true) + ChatColor.WHITE + '.');
    Bukkit.broadcastMessage(ChatColor.YELLOW + "The capture time of " + ChatColor.RED + kothFaction.getDisplayName(sender) + ChatColor.YELLOW + " has been set to " + ChatColor.RED
            + DurationFormatUtils.formatDurationWords(duration, true, true) + ChatColor.YELLOW + '.');

    return true;
}
 
Example 16
Project: Lotto   File: LottoGame.java   View Source Code Vote up 4 votes
public void end()
{
    closed = true;

    Bukkit.broadcastMessage(lotto.getPrefix() + "LOTTO CLOSED! Total pot: " + ChatColor.GOLD + EconomyAPI.getAPI().format(getPot()) + ChatColor.YELLOW + "! Announcing winner in 5 seconds...");

    Bukkit.getScheduler().runTaskLater(lotto, () -> {
        Random random = new Random();

        double p = random.nextInt(getPot().intValueExact()  + 1);
        double cumulativeProb = 0.0;

        LottoParticipant winner = null;

        Collections.shuffle(participants);

        for (LottoParticipant participant : participants) {
            cumulativeProb += participant.getBet().doubleValue();

            if (p <= cumulativeProb) {
                winner = participant;
                break;
            }
        }

        if (winner == null)
        {
            Bukkit.getLogger().severe("Failed to select winner for Lotto! Game: " + toString());
            return;
        }

        OfflinePlayer player = Bukkit.getOfflinePlayer(winner.getParticipant());

        Bukkit.broadcastMessage(lotto.getPrefix() + player.getName() + " won this Lotto game with a total pot of " + ChatColor.GOLD + EconomyAPI.getAPI().format(getPot()) + ChatColor.YELLOW + "! Congratulations!");

        Optional<Account> account = EconomyAPI.getAPI().getAccount(player.getUniqueId());

        account.ifPresent(account1 -> EconomyAPI.getAPI()
            .transact(EconomyAPI.getAPI().createTransaction(account1, TransactionType.DEPOSIT, getPot()))
            .addListener((t) -> {
                    if (!player.isOnline())
                        return;

                    Player onlinePlayer = (Player) player;

                    if (t.getResult().getStatus() == TransactionStatus.SUCCESS)
                    {
                        onlinePlayer.sendMessage(lotto.getPrefix() + "The pot money has been successfully transferred to your account!");
                    }
                    else
                    {
                        onlinePlayer.sendMessage(lotto.getPrefix() + ChatColor.RED + "Error transferring money to your account! (" + t.getResult().getStatus() + ")");
                    }
                }
            ));

        lotto.setCurrentGame(null);
    }, 100L);
}
 
Example 17
Project: AntiCheat   File: PunishmentsManager.java   View Source Code Vote up 4 votes
private void broadcastSamaritan(String message)
{
    String prefix = ChatColor.RED + "[" + ChatColor.GRAY + "Samaritan" + ChatColor.RED + "] ";
    Bukkit.broadcastMessage(prefix + ChatColor.RED + message);
}
 
Example 18
Project: HCFCore   File: KothTracker.java   View Source Code Vote up 4 votes
@Override
public void onContest(EventFaction eventFaction, EventTimer eventTimer) {
    Bukkit.broadcastMessage(ChatColor.GOLD + "[" + eventFaction.getEventType().getDisplayName() + "] " + ChatColor.RED + eventFaction.getName() + ChatColor.YELLOW + " can now be contested. "
            + ChatColor.RED + '(' + DateTimeFormats.KOTH_FORMAT.format(eventTimer.getRemaining()) + ')');
}
 
Example 19
Project: EscapeLag   File: AzureAPI.java   View Source Code Vote up 4 votes
public static void bc(final String prefix, final String context) {
    if (isBlank(context)) return;
    Bukkit.broadcastMessage(prefix + context);
}
 
Example 20
Project: Chambers   File: KothManager.java   View Source Code Vote up 2 votes
/**
 * Broadcast a message in the KOTH message format
 * 
 * @param message - the message you wish to send in KOTH format
 */
public void broadcastMessage(String message) {
	Bukkit.broadcastMessage(getKothFormat() + message);
}