use of net.md_5.bungee.api.event.ServerSwitchEvent in project BungeecordPartyAndFriends by Simonsator.
the class ServerSwitchListener method moveParty.
private void moveParty(ServerSwitchEvent pEvent) {
ServerInfo server = pEvent.getPlayer().getServer().getInfo();
if (notJoinServers.contains(server.getName()))
return;
OnlinePAFPlayer player = PAFPlayerManager.getInstance().getPlayer(pEvent.getPlayer());
PlayerParty party = PartyManager.getInstance().getParty(player);
if (party != null && party.isLeader(player) && !party.getPlayers().isEmpty()) {
for (OnlinePAFPlayer p : party.getPlayers()) if (CONNECT_DELAY == 0)
p.connect(server);
else
BukkitBungeeAdapter.getInstance().schedule(Main.getInstance(), () -> p.connect(server), CONNECT_DELAY);
party.sendMessage((PartyCommand.getInstance().getPrefix() + Main.getInstance().getMessages().getString("Party.Command.General.ServerSwitched").replace("[SERVER]", ServerDisplayNameCollection.getInstance().getServerDisplayName(server))));
}
}
use of net.md_5.bungee.api.event.ServerSwitchEvent in project DragonProxy by DragonetMC.
the class DPAddonBungee method onServerSwitch.
@EventHandler
public void onServerSwitch(ServerSwitchEvent event) {
if (!bedrockPlayers.contains(event.getPlayer().getUniqueId()))
return;
// We don't know that another server supports forwarding or not so we disable forwarding for now!
BinaryStream bis = new BinaryStream();
bis.putString("PacketFoward");
bis.putBoolean(false);
event.getPlayer().sendData("DragonProxy", bis.getBuffer());
}
use of net.md_5.bungee.api.event.ServerSwitchEvent in project Parties by AlessioDP.
the class BungeeFollowListener method onConnected.
@EventHandler
public void onConnected(ServerSwitchEvent event) {
if (!BungeeConfigMain.ADDITIONAL_FOLLOW_ENABLE)
return;
// Not connected to the network yet
if (event.getPlayer().getServer() == null)
return;
plugin.getScheduler().scheduleAsyncLater(() -> {
if (allowedServer(event.getPlayer().getServer().getInfo().getName())) {
PartyPlayerImpl player = plugin.getPlayerManager().getPlayer(event.getPlayer().getUniqueId());
PartyImpl party = plugin.getPartyManager().getParty(player.getPartyId());
if (party != null && party.isFollowEnabled() && (party.getLeader() != null && party.getLeader().equals(player.getPlayerUUID()))) {
String playerServer = event.getPlayer().getServer().getInfo().getName();
ServerInfo serverInfo = ((BungeePartiesBootstrap) plugin.getBootstrap()).getProxy().getServerInfo(playerServer);
// Calling API event
BungeePartiesPartyFollowEvent partyFollowEvent = ((BungeeEventManager) plugin.getEventManager()).preparePartyFollowEvent(party, playerServer);
plugin.getEventManager().callEvent(partyFollowEvent);
if (!partyFollowEvent.isCancelled()) {
// Let other players follow him
sendMembers(party, player, serverInfo);
}
}
}
}, ConfigMain.ADDITIONAL_FOLLOW_DELAY, TimeUnit.MILLISECONDS);
}
use of net.md_5.bungee.api.event.ServerSwitchEvent in project InteractiveChat by LOOHP.
the class InteractiveChatBungee method onSwitch.
@EventHandler
public void onSwitch(ServerSwitchEvent event) {
ServerInfo to = event.getPlayer().getServer().getInfo();
ProxiedPlayer player = event.getPlayer();
UUID uuid = player.getUniqueId();
if (!placeholderList.containsKey(to.getName())) {
try {
PluginMessageSendingBungee.requestPlaceholderList(to);
} catch (IOException e) {
e.printStackTrace();
}
}
try {
PluginMessageSendingBungee.sendPlayerListData();
} catch (IOException e1) {
e1.printStackTrace();
}
long universalTime = playerCooldownManager.getPlayerUniversalLastTimestamp(uuid);
if (universalTime >= 0) {
try {
PluginMessageSendingBungee.sendPlayerUniversalCooldown(to, uuid, universalTime);
} catch (IOException e) {
e.printStackTrace();
}
}
List<ICPlaceholder> placeholders = placeholderList.get(to.getName());
if (placeholders != null) {
for (ICPlaceholder placeholder : placeholders) {
long placeholderTime = playerCooldownManager.getPlayerPlaceholderLastTimestamp(uuid, placeholder.getInternalId());
if (placeholderTime >= 0) {
try {
PluginMessageSendingBungee.sendPlayerPlaceholderCooldown(to, uuid, placeholder, placeholderTime);
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
ProxyServer.getInstance().getScheduler().runAsync(plugin, () -> {
try {
PluginMessageSendingBungee.sendDelayAndScheme();
} catch (IOException e) {
e.printStackTrace();
}
});
ProxyServer.getInstance().getScheduler().schedule(plugin, () -> {
if (event.getPlayer().getName().equals("LOOHP") || event.getPlayer().getName().equals("AppLEskakE")) {
sendMessage(event.getPlayer(), LegacyComponentSerializer.legacySection().deserialize(ChatColor.GOLD + "InteractiveChat (Bungeecord) " + plugin.getDescription().getVersion() + " is running!"));
}
}, 100, TimeUnit.MILLISECONDS);
}
use of net.md_5.bungee.api.event.ServerSwitchEvent in project ResourcepacksPlugins by Phoenix616.
the class ServerSwitchListener method onServerSwitch.
@EventHandler
public void onServerSwitch(ServerSwitchEvent event) {
if (plugin.isEnabled()) {
final UUID playerId = event.getPlayer().getUniqueId();
plugin.unsetBackend(playerId);
ResourcePack pack = plugin.getUserManager().getUserPack(playerId);
plugin.sendPackInfo(event.getPlayer(), pack);
long sendDelay = -1;
if (event.getPlayer().getServer() != null) {
sendDelay = plugin.getPackManager().getAssignment(event.getPlayer().getServer().getInfo().getName()).getSendDelay();
}
if (sendDelay < 0) {
sendDelay = plugin.getPackManager().getGlobalAssignment().getSendDelay();
}
if (sendDelay > 0) {
plugin.getProxy().getScheduler().schedule(plugin, () -> calculatePack(playerId), sendDelay * 50, TimeUnit.MILLISECONDS);
} else {
calculatePack(playerId);
}
}
}
Aggregations