use of net.md_5.bungee.event.EventHandler in project CloudNet by Dytanic.
the class ProxiedListener method handlePost.
@EventHandler
public void handlePost(PostLoginEvent e) {
CloudProxy.getInstance().update();
CloudAPI.getInstance().getNetworkConnection().sendPacket(new PacketOutLoginSuccess(e.getPlayer().getUniqueId()));
if (CloudProxy.getInstance().getProxyGroup().getProxyConfig().isFastConnect()) {
try {
Field channelWrapper;
try {
channelWrapper = UserConnection.class.getDeclaredField("ch");
channelWrapper.setAccessible(true);
} catch (Exception ex) {
channelWrapper = UserConnection.class.getField("ch");
channelWrapper.setAccessible(true);
}
Field field;
try {
field = ChannelWrapper.class.getDeclaredField("ch");
field.setAccessible(true);
} catch (Exception ex) {
field = ChannelWrapper.class.getField("ch");
field.setAccessible(true);
}
Channel channel = (Channel) field.get(channelWrapper.get(e.getPlayer()));
channel.pipeline().addAfter("packet-encoder", "cloudConnection", new MessageToMessageEncoder<DefinedPacket>() {
@Override
protected void encode(ChannelHandlerContext channelHandlerContext, DefinedPacket definedPacket, List<Object> out) throws Exception {
if (definedPacket instanceof Respawn) {
if (((Respawn) definedPacket).getDimension() != ((UserConnection) e.getPlayer()).getDimension())
((Respawn) definedPacket).setDimension(((UserConnection) e.getPlayer()).getDimension());
}
out.add(definedPacket);
}
});
} catch (IllegalAccessException | NoSuchFieldException e1) {
e1.printStackTrace();
}
}
}
use of net.md_5.bungee.event.EventHandler in project CloudNet by Dytanic.
the class ProxiedListener method handlePlayerServerSwitch.
@EventHandler(priority = EventPriority.HIGHEST)
public void handlePlayerServerSwitch(ServerSwitchEvent e) {
CloudPlayer cloudPlayer = CloudProxy.getInstance().getCloudPlayers().get(e.getPlayer().getUniqueId());
cloudPlayer.setServer(e.getPlayer().getServer().getInfo().getName());
CloudAPI.getInstance().getNetworkConnection().sendPacket(new PacketOutUpdateOnlinePlayer(cloudPlayer));
CloudAPI.getInstance().sendCustomSubProxyMessage("cloudnet_internal", "player_server_switch", new Document("player", cloudPlayer).append("server", e.getPlayer().getServer().getInfo().getName()));
if (CloudProxy.getInstance().getProxyGroup() != null && CloudProxy.getInstance().getProxyGroup().getProxyConfig().isEnabled() && CloudProxy.getInstance().getProxyGroup().getProxyConfig().getTabList().isEnabled())
initTabHeaderFooter(e.getPlayer());
}
use of net.md_5.bungee.event.EventHandler in project commands by aikar.
the class ACFBungeeListener method onPlayerJoin.
@EventHandler
public void onPlayerJoin(PostLoginEvent loginEvent) {
ProxiedPlayer player = loginEvent.getPlayer();
// the client settings are sent after a successful login
Runnable task = () -> manager.readLocale(player);
plugin.getProxy().getScheduler().schedule(plugin, task, 1, TimeUnit.SECONDS);
}
use of net.md_5.bungee.event.EventHandler in project commands by aikar.
the class ACFBungeeListener method onDisconnect.
@EventHandler
public void onDisconnect(PlayerDisconnectEvent disconnectEvent) {
// cleanup
ProxiedPlayer player = disconnectEvent.getPlayer();
manager.issuersLocale.remove(player.getUniqueId());
}
use of net.md_5.bungee.event.EventHandler in project solinia3-core by mixxit.
the class SoliniaPlayer method setInteraction.
@Override
public void setInteraction(UUID interaction, ISoliniaNPC npc) {
if (interaction == null) {
this.interaction = interaction;
this.getBukkitPlayer().sendMessage(ChatColor.GRAY + "* You are no longer interacting");
return;
}
Entity e = Bukkit.getEntity(interaction);
if (e == null)
return;
if (!(e instanceof LivingEntity))
return;
if (((Creature) e).getTarget() != null) {
if (interaction != null) {
this.getBukkitPlayer().sendMessage(ChatColor.GRAY + "* You are no longer interacting");
interaction = null;
}
return;
}
if (Bukkit.getEntity(interaction) instanceof Wolf) {
Wolf w = (Wolf) Bukkit.getEntity(interaction);
if (w.getOwner() != null)
return;
}
this.interaction = interaction;
if (npc != null) {
this.getBukkitPlayer().sendMessage(ChatColor.GRAY + "* You are now interacting with " + Bukkit.getEntity(interaction).getName() + " [" + npc.getId() + "] - Anything you type will be heared by the NPC and possibly responded to. Words in pink are trigger words you can type");
if (npc.getMerchantid() > 0) {
try {
StateManager.getInstance().getEntityManager().getLivingEntity((LivingEntity) e).say("i have a [" + ChatColor.LIGHT_PURPLE + "SHOP" + ChatColor.AQUA + "] available if you are interested in buying or selling something", getBukkitPlayer());
} catch (CoreStateInitException cse) {
//
}
}
for (ISoliniaNPCEventHandler eventHandler : npc.getEventHandlers()) {
if (!eventHandler.getInteractiontype().equals(InteractionType.ITEM))
continue;
// See if player has any items that are wanted
int itemId = Integer.parseInt(eventHandler.getTriggerdata());
if (itemId == 0)
continue;
if (Utils.getPlayerTotalCountOfItemId(getBukkitPlayer(), itemId) < 1)
continue;
try {
ISoliniaItem item = StateManager.getInstance().getConfigurationManager().getItem(itemId);
TextComponent tc = new TextComponent();
tc.setText(ChatColor.YELLOW + "[QUEST] ");
TextComponent tc2 = new TextComponent();
tc2.setText(ChatColor.GRAY + "- Click here to give " + item.getDisplayname() + ChatColor.RESET);
tc2.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/npcgive " + itemId));
tc.addExtra(tc2);
getBukkitPlayer().spigot().sendMessage(tc);
} catch (CoreStateInitException eNotInitialised) {
continue;
}
}
}
}
Aggregations