当前位置: 首页>>代码示例>>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;未经允许,请勿转载。