Java 类org.bukkit.event.player.PlayerResourcePackStatusEvent 实例源码

项目:ProjectAres    文件:ResourcePackListener.java   
@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
    );
}
项目:Hub    文件:DeveloperRoomParkour.java   
@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);
}
项目:NucleusFramework    文件:SimplePlayListTest.java   
/**
 * 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);
}
项目:Hub    文件:WelcomeTutorialNPCAction.java   
@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);
}
项目:Transport-Pipes    文件:RenderSystem.java   
@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());
    }
}
项目:PA    文件:ResourcePackListener.java   
@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;
    }
}
项目:SamaGamesCore    文件:ResourcePacksManagerImpl.java   
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()));
    }
}
项目:NucleusFramework    文件:InternalResourcePackManager.java   
@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());
        }
    });
}
项目:NucleusFramework    文件:InternalResourcePackManager.java   
private void handleStatusEvent(Player player, PlayerResourcePackStatusEvent.Status bukkitStatus) {
    PlayerResourcePacks packs = get(player);
    if (packs == null)
        return;

    ResourcePackStatus status = ResourcePackStatus.fromBukkit(bukkitStatus);
    packs.setStatus(status);
}
项目:SpigotSource    文件:PlayerConnection.java   
public void a(PacketPlayInResourcePackStatus packetplayinresourcepackstatus) {
    this.server.getPluginManager().callEvent(new PlayerResourcePackStatusEvent(getPlayer(), PlayerResourcePackStatusEvent.Status.values()[packetplayinresourcepackstatus.status.ordinal()]));
}
项目:SamaGamesAPI    文件:IResourceCallback.java   
/**
 * 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);