本文整理汇总了Java中org.bukkit.entity.Player.sendPluginMessage方法的典型用法代码示例。如果您正苦于以下问题:Java Player.sendPluginMessage方法的具体用法?Java Player.sendPluginMessage怎么用?Java Player.sendPluginMessage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.entity.Player
的用法示例。
在下文中一共展示了Player.sendPluginMessage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sendPlayerToServer
import org.bukkit.entity.Player; //导入方法依赖的package包/类
public ListenableFuture<?> sendPlayerToServer(Player player, @Nullable String bungeeName, boolean quiet) {
if(localServer.bungee_name().equals(bungeeName) || (localServer.role() == ServerDoc.Role.LOBBY && bungeeName == null)) {
return Futures.immediateFuture(null);
}
final ByteArrayOutputStream message = new ByteArrayOutputStream();
final DataOutputStream out = new DataOutputStream(message);
try {
out.writeUTF(quiet ? "ConnectQuiet" : "Connect");
out.writeUTF(bungeeName == null ? "default" : bungeeName);
} catch(IOException e) {
return Futures.immediateFailedFuture(e);
}
player.sendPluginMessage(plugin, PLUGIN_CHANNEL, message.toByteArray());
return quitFuture(player);
}
示例2: connect
import org.bukkit.entity.Player; //导入方法依赖的package包/类
public static void connect(Player p, String server) {
if (Lobby.connectionTimes.get(p.getName()) != null) {
if (new Date().getTime() / 1000 - Lobby.getConnectionTimes().get(p.getName()).getTime() / 1000 < 1)
return;
}
Chat.log("Sending " + p.getName() + " to " + server);
Lobby.connectionTimes.put(p.getName(), new Date());
ByteArrayOutputStream b = new ByteArrayOutputStream();
DataOutputStream out = new DataOutputStream(b);
try {
out.writeUTF("Transfer");
out.writeUTF(server); // Target Server
} catch (IOException e) {
// Can never happen
}
p.sendPluginMessage(Lobby.getInstance(), "BungeeCord", b.toByteArray());
}
示例3: update
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public void update() {
Player player = Bukkit.getPlayer(playerData.getPlayerID());
try {
//Update SQL
gameServiceManager.setPlayerSettings(playerData.getPlayerBean(), this);
ByteArrayDataOutput out = ByteStreams.newDataOutput();
//Comamnd type
out.writeUTF("settingsChanges");
//The player to refresh settings on bungee
out.writeUTF(player.getUniqueId().toString());
//Send data on network channel
player.sendPluginMessage(APIPlugin.getInstance(), "Network", out.toByteArray());
} catch (Exception e) {
e.printStackTrace();
}
}
示例4: sendToaRandomServerInGroup
import org.bukkit.entity.Player; //导入方法依赖的package包/类
public void sendToaRandomServerInGroup(Plugin plugin, Player player)
{
plugin.getServer().getMessenger().registerOutgoingPluginChannel(plugin, "CloudNet");
ByteArrayDataOutput byteArrayDataOutput = ByteStreams.newDataOutput();
byteArrayDataOutput.writeUTF("Connect");
byteArrayDataOutput.writeUTF("Lobby"); //Connect to the group Lobby
player.sendPluginMessage(plugin, "CloudNet", byteArrayDataOutput.toByteArray());
}
示例5: sendToFallback
import org.bukkit.entity.Player; //导入方法依赖的package包/类
public void sendToFallback(Plugin plugin, Player player)
{
plugin.getServer().getMessenger().registerOutgoingPluginChannel(plugin, "CloudNet");
ByteArrayDataOutput byteArrayDataOutput = ByteStreams.newDataOutput();
byteArrayDataOutput.writeUTF("Fallback"); //Connect to the fallback server in the iteration
player.sendPluginMessage(plugin, "CloudNet", byteArrayDataOutput.toByteArray());
}
示例6: sendPluginMessage
import org.bukkit.entity.Player; //导入方法依赖的package包/类
public void sendPluginMessage(Plugin source, String channel, byte[] message) {
StandardMessenger.validatePluginMessage(server.getMessenger(), source, channel, message);
for (Player player : getPlayers()) {
player.sendPluginMessage(source, channel, message);
}
}
示例7: sendPluginMessage
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public void sendPluginMessage(Plugin source, String channel, byte[] message) {
StandardMessenger.validatePluginMessage(getMessenger(), source, channel, message);
for (Player player : getOnlinePlayers()) {
player.sendPluginMessage(source, channel, message);
}
}
示例8: sendToChannel
import org.bukkit.entity.Player; //导入方法依赖的package包/类
private void sendToChannel(MessageAgent agent, Player player) {
ByteArrayDataOutput out = ByteStreams.newDataOutput();
out.writeUTF(agent.getSubChannel());
agent.appendPayload(out);
byte[] data = out.toByteArray();
player.sendPluginMessage(plugin, CHANNEL, data);
// register listener
if (agent instanceof MessageCallback) {
MessageCallback callback = (MessageCallback) agent;
registerListener(callback);
}
}
示例9: sendGetServers
import org.bukkit.entity.Player; //导入方法依赖的package包/类
public void sendGetServers() {
Iterator<? extends Player> players = this.plugin.getServer().getOnlinePlayers().iterator();
if (!players.hasNext()) return;
ByteArrayDataOutput out = ByteStreams.newDataOutput();
out.writeUTF(GET_SERVERS);
Player player = players.next();
player.sendPluginMessage(this.plugin, CHANNEL_BUNGEE, out.toByteArray());
}
示例10: connect
import org.bukkit.entity.Player; //导入方法依赖的package包/类
public void connect(Player player, String server) {
ByteArrayDataOutput out = ByteStreams.newDataOutput();
out.writeUTF(CONNECT);
out.writeUTF(server);
player.sendPluginMessage(this.plugin, CHANNEL_BUNGEE, out.toByteArray());
}
示例11: onClick
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public void onClick(Player player, ItemStack stack, String action, ClickType clickType)
{
if (action.startsWith("Hub_"))
{
if (action.split("_")[1].equals(SamaGamesAPI.get().getServerName().split("_")[1]))
{
player.sendMessage(ChatColor.RED + "Vous ne pouvez pas aller sur votre hub actuel !");
return;
}
else if (this.hub.getHubRefresher().getHubByID(Integer.parseInt(action.split("_")[1])).getConnectedPlayers() >= 120)
{
player.sendMessage(ChatColor.RED + "Le hub sélectionné est plein !");
return;
}
ByteArrayDataOutput out = ByteStreams.newDataOutput();
out.writeUTF("Connect");
out.writeUTF(action);
player.sendPluginMessage(this.hub, "BungeeCord", out.toByteArray());
// TODO: Use API
// SamaGamesAPI.get().getPlayerManager().connectToServer(player.getUniqueId(), action);
}
else if (action.equals("page_back"))
{
this.hub.getGuiManager().openGui(player, new GuiSwitchHub(this.hub, (this.page - 1)));
}
else if (action.equals("page_next"))
{
this.hub.getGuiManager().openGui(player, new GuiSwitchHub(this.hub, (this.page + 1)));
}
else if (action.equals("back"))
{
this.hub.getGuiManager().openGui(player, new GuiMain(this.hub));
}
}
示例12: connectToServer
import org.bukkit.entity.Player; //导入方法依赖的package包/类
public static void connectToServer(Player player, String server) {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
DataOutputStream out = new DataOutputStream(stream);
try {
out.writeUTF("Connect");
out.writeUTF(server);
} catch (IOException e) {
e.printStackTrace();
}
player.sendPluginMessage(SkyWarsReloaded.get(), "BungeeCord", stream.toByteArray());
}
示例13: ping
import org.bukkit.entity.Player; //导入方法依赖的package包/类
void ping() {
final Player player = this.getFirstPlayer();
if (player == null)
return;
for (final String s : this.controller.getServers()) {
final ByteArrayDataOutput out = ByteStreams.newDataOutput();
out.writeUTF("ServerIP");
out.writeUTF(s);
player.sendPluginMessage(this.plugin, "BungeeCord", out.toByteArray());
}
}
示例14: teleport
import org.bukkit.entity.Player; //导入方法依赖的package包/类
public static void teleport(Player pl, String input)
{
ByteArrayOutputStream b = new ByteArrayOutputStream();
DataOutputStream out = new DataOutputStream(b);
try {
out.writeUTF("Connect");
out.writeUTF(input);
}
catch (IOException localIOException) {}
pl.sendPluginMessage(HCF.getPlugin(), "BungeeCord", b.toByteArray());
}
示例15: connectToServer
import org.bukkit.entity.Player; //导入方法依赖的package包/类
void connectToServer(Player player, String serverName) {
final ByteArrayDataOutput out = ByteStreams.newDataOutput();
out.writeUTF("Connect");
out.writeUTF(serverName);
player.sendPluginMessage(this.plugin, "BungeeCord", out.toByteArray());
}