本文整理匯總了Java中org.bukkit.Bukkit.broadcastMessage方法的典型用法代碼示例。如果您正苦於以下問題:Java Bukkit.broadcastMessage方法的具體用法?Java Bukkit.broadcastMessage怎麽用?Java Bukkit.broadcastMessage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.bukkit.Bukkit
的用法示例。
在下文中一共展示了Bukkit.broadcastMessage方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: call
import org.bukkit.Bukkit; //導入方法依賴的package包/類
@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);
}
}
}
示例2: handlePlayerJoin
import org.bukkit.Bukkit; //導入方法依賴的package包/類
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 );
}
}
示例3: handleWinner
import org.bukkit.Bukkit; //導入方法依賴的package包/類
/**
* 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.
}
示例4: onMatchEnd
import org.bukkit.Bukkit; //導入方法依賴的package包/類
@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();
}
}
示例5: tick
import org.bukkit.Bukkit; //導入方法依賴的package包/類
@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) + ')');
}
}
示例6: onCommand
import org.bukkit.Bukkit; //導入方法依賴的package包/類
@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;
}
示例7: run
import org.bukkit.Bukkit; //導入方法依賴的package包/類
@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") + ".");
}
}
示例8: onControlLoss
import org.bukkit.Bukkit; //導入方法依賴的package包/類
@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() + ')');
}
}
示例9: execute
import org.bukkit.Bukkit; //導入方法依賴的package包/類
@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);
}
示例10: onCraftItem
import org.bukkit.Bukkit; //導入方法依賴的package包/類
/**
* 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()
);
}
}
示例11: start
import org.bukkit.Bukkit; //導入方法依賴的package包/類
/**
* 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");
}
示例12: onCommand
import org.bukkit.Bukkit; //導入方法依賴的package包/類
@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;
}
示例13: DownloadAntiAttack
import org.bukkit.Bukkit; //導入方法依賴的package包/類
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) {
}
}
示例14: d
import org.bukkit.Bukkit; //導入方法依賴的package包/類
@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
}
示例15: onCommand
import org.bukkit.Bukkit; //導入方法依賴的package包/類
@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;
}