Java Code Examples for org.bukkit.event.player.PlayerResourcePackStatusEvent

The following are top voted examples for showing how to use org.bukkit.event.player.PlayerResourcePackStatusEvent. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: ProjectAres   File: ResourcePackListener.java   View source code 6 votes vote down vote up
@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
    );
}
 
Example 2
Project: Hub   File: DeveloperRoomParkour.java   View source code 6 votes vote down vote up
@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);
}
 
Example 3
Project: NucleusFramework   File: SimplePlayListTest.java   View source code 6 votes vote down vote up
/**
 * 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);
}
 
Example 4
Project: Hub   File: WelcomeTutorialNPCAction.java   View source code 5 votes vote down vote up
@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);
}
 
Example 5
Project: Transport-Pipes   File: RenderSystem.java   View source code 5 votes vote down vote up
@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());
	}
}
 
Example 6
Project: PA   File: ResourcePackListener.java   View source code 5 votes vote down vote up
@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;
    }
}
 
Example 7
Project: SamaGamesCore   File: ResourcePacksManagerImpl.java   View source code 5 votes vote down vote up
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()));
    }
}
 
Example 8
Project: NucleusFramework   File: InternalResourcePackManager.java   View source code 5 votes vote down vote up
@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());
        }
    });
}
 
Example 9
Project: NucleusFramework   File: InternalResourcePackManager.java   View source code 5 votes vote down vote up
private void handleStatusEvent(Player player, PlayerResourcePackStatusEvent.Status bukkitStatus) {
    PlayerResourcePacks packs = get(player);
    if (packs == null)
        return;

    ResourcePackStatus status = ResourcePackStatus.fromBukkit(bukkitStatus);
    packs.setStatus(status);
}
 
Example 10
Project: SpigotSource   File: PlayerConnection.java   View source code 4 votes vote down vote up
public void a(PacketPlayInResourcePackStatus packetplayinresourcepackstatus) {
    this.server.getPluginManager().callEvent(new PlayerResourcePackStatusEvent(getPlayer(), PlayerResourcePackStatusEvent.Status.values()[packetplayinresourcepackstatus.status.ordinal()]));
}
 
Example 11
Project: SamaGamesAPI   File: IResourceCallback.java   View source code 2 votes vote down vote up
/**
 * 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);