當前位置: 首頁>>代碼示例>>Java>>正文


Java BukkitRunnable類代碼示例

本文整理匯總了Java中org.bukkit.scheduler.BukkitRunnable的典型用法代碼示例。如果您正苦於以下問題:Java BukkitRunnable類的具體用法?Java BukkitRunnable怎麽用?Java BukkitRunnable使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


BukkitRunnable類屬於org.bukkit.scheduler包,在下文中一共展示了BukkitRunnable類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: enableScoreboard

import org.bukkit.scheduler.BukkitRunnable; //導入依賴的package包/類
@Override
public void enableScoreboard() {
       final Scoreboard board = Bukkit.getScoreboardManager().getNewScoreboard();
       final Objective obj = board.registerNewObjective("Spigotboard", "dummy");
       
       obj.setDisplaySlot(DisplaySlot.SIDEBAR);
       obj.setDisplayName(ChatColor.translateAlternateColorCodes('&', Main.instance.getConfig().getString("title")));

       new BukkitRunnable() {
           @Override
           public void run() {
               for(Player p : Bukkit.getOnlinePlayers()) {
               	int count = Main.instance.getConfig().getList("text").size();
               	
               	PlaceholderUtils placeholders = new PlaceholderUtils(p);
                   for(Object text : Main.instance.getConfig().getList("text")){
                   	obj.getScore(ChatColor.translateAlternateColorCodes('&', placeholders.replace(text.toString()))).setScore(count);
                   	count--;
                   }
                   p.setScoreboard(board);
               }
           }
       }.runTaskTimer(Main.instance, 0, 20);
}
 
開發者ID:TheIndra55,項目名稱:SpigotBoard,代碼行數:25,代碼來源:SBScoreboard.java

示例2: setTemporarySidebar

import org.bukkit.scheduler.BukkitRunnable; //導入依賴的package包/類
public void setTemporarySidebar(final SidebarProvider provider, final long expiration) {
    if (this.removed.get()) {
        throw new IllegalStateException("Cannot update whilst board is removed");
    }
    this.temporaryProvider = provider;
    this.updateObjective();
    new BukkitRunnable() {
        public void run() {
            if (PlayerBoard.this.removed.get()) {
                this.cancel();
                return;
            }
            if (PlayerBoard.this.temporaryProvider == provider) {
                PlayerBoard.access$4(PlayerBoard.this, null);
                PlayerBoard.this.updateObjective();
            }
        }
    }.runTaskLaterAsynchronously((Plugin)this.plugin, expiration);
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:20,代碼來源:PlayerBoard.java

示例3: onPlayerRespawn

import org.bukkit.scheduler.BukkitRunnable; //導入依賴的package包/類
@EventHandler
public void onPlayerRespawn(PlayerRespawnEvent event) {
	final Gamer g = Gamer.get(event.getPlayer());
	
	new BukkitRunnable() {

		@Override
		public void run() {
			Team t = Nexus.getRotary().getCurrentMap().getTeam(g);
			
			if (t == null) {
				g.teleport(Nexus.getRotary().getCurrentMap().getSpawnLocation());
				return;
			}
			
			g.addPotionEffect(new PotionEffect(PotionEffectType.HEAL, 20 * 5, 3));
			
			g.teleport(t.getSpawnLocation());
			g.run("give-kit");
		}
		
	}.runTaskLater(Nexus.getPlugin(), 1);
}
 
開發者ID:thekeenant,項目名稱:mczone,代碼行數:24,代碼來源:GameEvents.java

示例4: lobbyScoreboard

import org.bukkit.scheduler.BukkitRunnable; //導入依賴的package包/類
public void lobbyScoreboard() {
    ScoreboardUtil board = new ScoreboardUtil(PAData.LOBBY.getPrefix(), "lobby");
    new BukkitRunnable() {
        @Override
        public void run() {
            if (u.getPlayer() == null) {
                board.reset();
                cancel();
                return;
            }

            if (!u.isOnline()) {
                board.reset();
                cancel();
                return;
            }

            board.setName(PAData.LOBBY.getOldPrefix());
            board.text(3, "§d ");
            board.text(2, "Rango: §" + PACmd.Grupo.groupColor(u.getUserData().getGrupo()) + u.getUserData().getGrupo().toString());
            board.text(1, "§d ");
            board.text(0, PACore.getIP().replace('&', '§'));
            board.build(u.getPlayer());
        }
    }.runTaskTimer(PALobby.getInstance(), 1, 20);
}
 
開發者ID:cadox8,項目名稱:PA,代碼行數:27,代碼來源:Helpers.java

示例5: onGameStart

import org.bukkit.scheduler.BukkitRunnable; //導入依賴的package包/類
@Override
public void onGameStart() {
    this.allowPVP = true;
    new BukkitRunnable() {
        public void run() {
            if(getAPI().getGameManager().getGameState() != GameState.INGAME) {
                this.cancel();
                return;
            }
            for(Player player : Bukkit.getOnlinePlayers()) {
                if(!getAPI().getGameManager().isAlive(player)) continue;
                if(hill.contains(player.getLocation())) {
                    ScoreSidebar scoreSidebar = (ScoreSidebar) getSidebar();
                    scoreSidebar.setScore(player, (scoreSidebar.getScore(player)+1));
                }
            }
        }
    }.runTaskTimer(this.getAPI().getPlugin(), 0, 20L);
}
 
開發者ID:ArcadiaPlugins,項目名稱:Arcadia-Spigot,代碼行數:20,代碼來源:KingOfTheHillGame.java

示例6: afterEquipChange

import org.bukkit.scheduler.BukkitRunnable; //導入依賴的package包/類
@EventHandler(priority = EventPriority.MONITOR)
public void afterEquipChange(final InventoryDragEvent event) {
    final Player player = (Player) event.getWhoClicked();

    if (!InventoryManager.playerIsLoaded(player)) {
        return;
    }

    new BukkitRunnable() {
        @Override
        public void run() {
            InventoryView inventoryView = event.getView();
            for (int slot : event.getRawSlots()) {
                ItemStack item = inventoryView.getItem(slot);
                if (CustomItem.isCustomItem(item)) {
                    ItemManager.updateStats((Player) event.getWhoClicked());
                }
            }
        }
    }.runTaskLater(RPGInventory.getInstance(), 1);
}
 
開發者ID:EndlessCodeGroup,項目名稱:RPGInventory,代碼行數:22,代碼來源:ItemListener.java

示例7: spawn

import org.bukkit.scheduler.BukkitRunnable; //導入依賴的package包/類
public void spawn(OpenPlayer player) {
        PlayerConnection connection = player.getConnection();

        connection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, this.entity));
        connection.sendPacket(new PacketPlayOutNamedEntitySpawn(this.entity));

//        if (this.sleeping) {
//            connection.sendPacket(new PacketPlayOutBed(this.entity, new BlockPosition(this.entity.locX, this.entity.locY - 1, this.entity.locZ)));
//        }

        new BukkitRunnable() {
            @Override
            public void run() {
                connection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, entity));
            }
        }.runTaskLater(Main.getInstance(), 20 * 5);
    }
 
開發者ID:Dragovorn,項目名稱:OpenRPG,代碼行數:18,代碼來源:NPC.java

示例8: game_start

import org.bukkit.scheduler.BukkitRunnable; //導入依賴的package包/類
/**
 * Start game: discovery or get ready to start.
 */
public void game_start() {
    if (state == GameState.PRELOBBY) {
        event_game_preStart();
        if (settings.hasDiscovery) {
            OMGPlayer.link.values().forEach(p -> gamePreparer.player_start_discovery(p));
            event_game_discovery();
            state = GameState.DISCOVERY;
            broadcast(ChatColor.AQUA + "You have " + (settings.discoveryLength / 20) + " seconds to discover the map.");
            discoveryStartDelay = new BukkitRunnable() {
                public void run() {
                    game_readyToStart();
                }
            };
            discoveryStartDelay.runTaskLater(this, settings.discoveryLength);
        } else {
            OMGPlayer.link.values().forEach(p -> gamePreparer.player_start_nonDiscovery(p));
            game_readyToStart();
        }
    }
}
 
開發者ID:BurnyDaKath,項目名稱:OMGPI,代碼行數:24,代碼來源:Game.java

示例9: displayOn

import org.bukkit.scheduler.BukkitRunnable; //導入依賴的package包/類
@Override
public void displayOn(Inventory inventory, int locX, int locY) {
    frames[0].displayOn(inventory, locX, locY);

    new BukkitRunnable(){
        private int iterator;

        @Override
        public void run() {
            if (inventory.getViewers().isEmpty()) {
                this.cancel();
            } else {
                nextFrame().displayOn(inventory, locX, locY);
            }
        }

        private final Element nextFrame() {
            iterator = iterator + 1 < frames.length
                ? iterator + 1
                : 0;

            return frames[iterator];
        }
    }.runTaskTimer(plugin, 1, period);
}
 
開發者ID:Personinblack,項目名稱:black,代碼行數:26,代碼來源:LiveElement.java

示例10: PlayerTab

import org.bukkit.scheduler.BukkitRunnable; //導入依賴的package包/類
public PlayerTab(Player player) {
    this.player = player;

    entries = new ArrayList<>();

    clear();

    if (!player.getScoreboard().equals(Bukkit.getScoreboardManager().getMainScoreboard())) {
        scoreboard = player.getScoreboard();
        assemble();
    } else {
        new BukkitRunnable() {
            @Override
            public void run() {
                scoreboard = Bukkit.getScoreboardManager().getNewScoreboard();
                player.setScoreboard(scoreboard);
                assemble();
            }
        }.runTask(PracticePlugin.getInstance());
    }

    playerTabs.add(this);
}
 
開發者ID:ijoeleoli,項目名稱:ZorahPractice,代碼行數:24,代碼來源:PlayerTab.java

示例11: walk

import org.bukkit.scheduler.BukkitRunnable; //導入依賴的package包/類
private void walk(Location location, Runnable callback)
{
    this.graou.getGraouEntity().getPathfinderGoalWalkToTile().setTileToWalk(location.getX(), location.getY(), location.getZ());

    new BukkitRunnable()
    {
        @Override
        public void run()
        {
            Optional<Entity> entity = ProximityUtils.getNearbyEntities(location, 3.0D).stream()
                    .filter(e -> e.getUniqueId() != null)
                    .filter(e -> e.getUniqueId() == OpeningAnimationRunnable.this.graou.getGraouEntity().getUniqueID())
                    .findAny();

            if (entity.isPresent())
            {
                OpeningAnimationRunnable.this.graou.getGraouEntity().getPathfinderGoalWalkToTile().cancel();
                OpeningAnimationRunnable.this.hub.getServer().getScheduler().runTask(OpeningAnimationRunnable.this.hub, callback);

                this.cancel();
            }
        }
    }.runTaskTimer(this.hub, 5L, 5L);
}
 
開發者ID:SamaGames,項目名稱:Hub,代碼行數:25,代碼來源:OpeningAnimationRunnable.java

示例12: sendMessage

import org.bukkit.scheduler.BukkitRunnable; //導入依賴的package包/類
public static void sendMessage(final String channel, final String msg) {
    if (!connected) {
        return;
    }
    Jedis jedis = pool.getResource();
    new BukkitRunnable(){

        public void run() {
            if (!Main.connected) {
                return;
            }
            try {
            	jedis.publish(channel, msg);
            }
            catch (Exception e) {
                e.printStackTrace();
            }
            jedis.close();
        }
    }.runTaskAsynchronously(plugin);
}
 
開發者ID:WheezyGold7931,項目名稱:skLib,代碼行數:22,代碼來源:Main.java

示例13: game_stop

import org.bukkit.scheduler.BukkitRunnable; //導入依賴的package包/類
/**
 * Stop the game and reload OMGPI.
 */
public void game_stop() {
    if (state == GameState.INGAME) {
        OMGPlayer.link.values().forEach(p -> {
            if (p.team != spectatorTeam) {
                p.setTeam(spectatorTeam);
                if (p.played) player_reward(p, "winner");
            } else if (p.played) player_reward(p, "loser");
            p.play_sound_levelup();
        });
        broadcast(ChatColor.AQUA + "You will be sent to the prelobby in 10 seconds.");
        state = GameState.ENDING;
        if (infoBar != null) infoBar.removeAll();
        new BukkitRunnable() {
            public void run() {
                event_game_stop();
                OMGPI.instance.reload();
            }
        }.runTaskLater(OMGPI.instance, 200L);
    }
}
 
開發者ID:BurnyDaKath,項目名稱:OMGPI,代碼行數:24,代碼來源:Game.java

示例14:

import org.bukkit.scheduler.BukkitRunnable; //導入依賴的package包/類
@EventHandler(ignoreCancelled=true, priority=EventPriority.LOW)
/*     */   public void onPlayerDeath(PlayerDeathEvent event) {
/*  99 */     final Player player = event.getEntity();
/* 100 */     final Deathban deathban = this.plugin.getDeathbanManager().applyDeathBan(player, event.getDeathMessage());
/* 101 */     long remaining = deathban.getRemaining();
/* 102 */     if ((remaining <= 0L) || (player.hasPermission("hcf.deathban.bypass"))) {
/* 103 */       return;
/*     */     }
/*     */
/* 106 */     if ((RESPAWN_KICK_DELAY_MILLIS <= 0L) || (remaining < RESPAWN_KICK_DELAY_MILLIS)) {
/* 107 */       handleKick(player, deathban);
/* 108 */       return;
/*     */     }
/*     */
/*     */
/* 112 */     this.respawnTickTasks.put(player.getUniqueId(), new BukkitRunnable()
/*     */     {
            /*     */       public void run() {
/* 115 */         DeathbanListener.this.handleKick(player, deathban);
/*     */       }
/* 117 */     }.runTaskLater(this.plugin, RESPAWN_KICK_DELAY_TICKS).getTaskId());
/*     */   }
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:23,代碼來源:DeathbanListener.java

示例15: postSpawn

import org.bukkit.scheduler.BukkitRunnable; //導入依賴的package包/類
@Override
public void postSpawn(HCF plugin) {
    if (this.world.addEntity((Entity)this)) {
        Bukkit.getConsoleSender().sendMessage(String.format((Object)ChatColor.GOLD + "Combat logger of " + this.getName() + " has spawned at %.2f, %.2f, %.2f", this.locX, this.locY, this.locZ));
        MinecraftServer.getServer().getPlayerList().playerFileData.load((EntityHuman)this);
    } else {
        Bukkit.getConsoleSender().sendMessage(String.format((Object)ChatColor.RED + "Combat logger of " + this.getName() + " failed to spawned at %.2f, %.2f, %.2f", this.locX, this.locY, this.locZ));
    }
    this.removalTask = new BukkitRunnable(){

        public void run() {
            MinecraftServer.getServer().getPlayerList().sendAll((Packet)PacketPlayOutPlayerInfo.removePlayer((EntityPlayer)LoggerEntityHuman.this.getBukkitEntity().getHandle()));
            LoggerEntityHuman.this.destroy();
        }
    }.runTaskLater((Plugin)plugin, SettingsYML.COMBAT_LOG_DESPAWN_TICKS);
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:17,代碼來源:LoggerEntityHuman.java


注:本文中的org.bukkit.scheduler.BukkitRunnable類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。