@EventHandler public void confirm(final PlayerResourcePackStatusEvent event) { logger.fine("Player " + event.getPlayer().getName() + " sent res pack status " + event.getStatus()); final UserDoc.ResourcePackStatus status; switch(event.getStatus()) { case ACCEPTED: status = UserDoc.ResourcePackStatus.ACCEPTED; break; case DECLINED: status = UserDoc.ResourcePackStatus.DECLINED; break; case SUCCESSFULLY_LOADED: status = UserDoc.ResourcePackStatus.LOADED; break; case FAILED_DOWNLOAD: status = UserDoc.ResourcePackStatus.FAILED; break; default: throw new IllegalStateException("Unknown status " + event.getStatus()); } userService.update( Users.playerId(event.getPlayer()), (UserDoc.ResourcePackResponse) () -> status ); }
@EventHandler public void onPlayerResourcePackStatus(PlayerResourcePackStatusEvent event) { if (!this.expected.contains(event.getPlayer().getUniqueId()) || event.getStatus() != PlayerResourcePackStatusEvent.Status.SUCCESSFULLY_LOADED) return; this.playMusic(event.getPlayer()); new BukkitRunnable() { @Override public void run() { if (expected.contains(event.getPlayer().getUniqueId())) playMusic(event.getPlayer()); else this.cancel(); } }.runTaskTimer(this.hub, MUSIC_LENGTH, MUSIC_LENGTH); }
/** * Make sure Nucleus and Bukkit are initialized. */ @BeforeClass public static void init() { NucleusTest.init(); Plugin plugin = BukkitTester.mockPlugin("dummy"); String yml = FileUtils.scanTextFile(SoundManagerTest.class, "/resource-sounds.yml", StandardCharsets.UTF_8); YamlDataNode dataNode = new YamlDataNode(plugin, yml); dataNode.load(); Player player = BukkitTester.login("dummy"); PlayerResourcePackStatusEvent event1 = new PlayerResourcePackStatusEvent( player, PlayerResourcePackStatusEvent.Status.ACCEPTED); Bukkit.getPluginManager().callEvent(event1); BukkitTester.pause(20); PlayerResourcePackStatusEvent event2 = new PlayerResourcePackStatusEvent( player, PlayerResourcePackStatusEvent.Status.SUCCESSFULLY_LOADED); Bukkit.getPluginManager().callEvent(event2); BukkitTester.pause(20); }
@EventHandler public void onPlayerResourcePackStatus(PlayerResourcePackStatusEvent event) { if (!this.expected.contains(event.getPlayer().getUniqueId()) || event.getStatus() != PlayerResourcePackStatusEvent.Status.SUCCESSFULLY_LOADED) return; this.expected.remove(event.getPlayer().getUniqueId()); this.hub.getServer().getScheduler().runTaskLater(this.hub, () -> this.tutorial.start(event.getPlayer().getUniqueId()), 20L); }
@EventHandler public void onResourcePackStatus(PlayerResourcePackStatusEvent e) { if (e.getStatus() == Status.DECLINED || e.getStatus() == Status.FAILED_DOWNLOAD) { ductManager.changePlayerRenderSystem(e.getPlayer(), 0); e.getPlayer().sendMessage("§cResourcepack Download failed!"); e.getPlayer().sendMessage("§cDid you enable \"Server Resourcepacks\" in your server list?"); } else { loadedResourcePackPlayers.add(e.getPlayer()); } }
@EventHandler(ignoreCancelled = true) public void onResourcePlayer(PlayerResourcePackStatusEvent e) { Player p = e.getPlayer(); switch (e.getStatus()) { case DECLINED: case FAILED_DOWNLOAD: Title.sendTitle(p, 1, 7, 1, ChatColor.RED + "Debes aceptar el ResourcePack", ""); plugin.getServer().getScheduler().runTaskLater(plugin, () -> PAServer.getUser(p).sendToLobby(), 60L); break; } }
private void handle(Player sender, PacketPlayInResourcePackStatus.EnumResourcePackStatus state) { Player player = sender; if (forceUrl == null) return; if (state.equals(PacketPlayInResourcePackStatus.EnumResourcePackStatus.DECLINED) || state.equals(PacketPlayInResourcePackStatus.EnumResourcePackStatus.FAILED_DOWNLOAD)) { if (callback == null || callback.automaticKick(player)) { Bukkit.getScheduler().runTask(SamaGamesAPI.get().getPlugin(), () -> player.kickPlayer(rejectMessage)); } APIPlugin.getInstance().getLogger().info("Player " + player.getName() + " rejected resource pack"); currentlyDownloading.remove(player.getUniqueId()); } else if(state.equals(PacketPlayInResourcePackStatus.EnumResourcePackStatus.SUCCESSFULLY_LOADED)) { currentlyDownloading.remove(player.getUniqueId()); APIPlugin.getInstance().getLogger().info("Player " + player.getName() + " successfully downloaded resource pack"); Bukkit.getScheduler().runTaskAsynchronously(APIPlugin.getInstance(), () -> { Jedis jedis = api.getBungeeResource(); jedis.sadd("playersWithPack", player.getUniqueId().toString()); jedis.close(); }); //Call when it's done if (callback != null) callback.callback(player, PlayerResourcePackStatusEvent.Status.valueOf(state.toString())); } }
@EventHandler(priority = EventPriority.MONITOR) private void onResourcePackStatus(final PlayerResourcePackStatusEvent event) { Scheduler.runTaskSync(Nucleus.getPlugin(), new Runnable() { @Override public void run() { handleStatusEvent(event.getPlayer(), event.getStatus()); } }); }
private void handleStatusEvent(Player player, PlayerResourcePackStatusEvent.Status bukkitStatus) { PlayerResourcePacks packs = get(player); if (packs == null) return; ResourcePackStatus status = ResourcePackStatus.fromBukkit(bukkitStatus); packs.setStatus(status); }
public void a(PacketPlayInResourcePackStatus packetplayinresourcepackstatus) { this.server.getPluginManager().callEvent(new PlayerResourcePackStatusEvent(getPlayer(), PlayerResourcePackStatusEvent.Status.values()[packetplayinresourcepackstatus.status.ordinal()])); }
/** * Called when the download status is changed * WARNING DON'T KICK THE PLAYER HERE * * @param player The player downloading the pack * @param status The download status */ void callback(Player player, PlayerResourcePackStatusEvent.Status status);