当前位置: 首页>>代码示例>>Java>>正文


Java BukkitRunnable.runTaskTimer方法代码示例

本文整理汇总了Java中org.bukkit.scheduler.BukkitRunnable.runTaskTimer方法的典型用法代码示例。如果您正苦于以下问题:Java BukkitRunnable.runTaskTimer方法的具体用法?Java BukkitRunnable.runTaskTimer怎么用?Java BukkitRunnable.runTaskTimer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bukkit.scheduler.BukkitRunnable的用法示例。


在下文中一共展示了BukkitRunnable.runTaskTimer方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: startListing

import org.bukkit.scheduler.BukkitRunnable; //导入方法依赖的package包/类
public void startListing() {
    if ( !active ) {
        scheduler = new BukkitRunnable() {
            @Override
            public void run() {
                if ( ( inventory.getContents()[slot] == null ) == ( lastItemStack == null ) ) {
                    if ( lastItemStack != null && !lastItemStack.equals( inventory.getContents()[slot] ) ) {
                        update( inventory.getContents()[slot] );
                    }
                }
                else {
                    update( inventory.getContents()[slot] );
                }
            }
        };
        scheduler.runTaskTimer(plugin, 1L, 1L );
        active = true;
    }
}
 
开发者ID:LegendOnline,项目名称:InventoryAPI,代码行数:20,代码来源:InventorySlotWatcher.java

示例2: activate

import org.bukkit.scheduler.BukkitRunnable; //导入方法依赖的package包/类
@Override
public org.bukkit.scoreboard.Scoreboard activate() {
    if (activated) return scoreboard;
    if (handler == null) throw new IllegalArgumentException("Scoreboard handler not set");
    activated = true;
    // Set to the custom scoreboard
    holder.setScoreboard(scoreboard);
    objective = scoreboard.getObjective(DisplaySlot.SIDEBAR);
    // And start updating on a desired interval
    updateTask = new BukkitRunnable() {
        @Override
        public void run() {
            update();
        }
    };
    updateTask.runTaskTimer(AlphaLibary.getInstance(), 0, updateInterval);
    return scoreboard;
}
 
开发者ID:AlphaHelixDev,项目名称:AlphaLibary,代码行数:19,代码来源:SimpleScoreboard.java

示例3: onEnable

import org.bukkit.scheduler.BukkitRunnable; //导入方法依赖的package包/类
@Override
public void onEnable(){
    plugin = this;

    getServer().getPluginManager().registerEvents(this, this);

    Config.createConfig();
    Config.loadConfig();

    DataBase.openConnection();

    int timer = Config.timer * 20;

    BukkitRunnable scheduler = new BukkitRunnable(){
        @Override
        public void run(){
            if(!check){
                DataBase.checkConnection();
                Worker.doTask();
            }
        }
    };

    scheduler.runTaskTimer(this, 0, timer);
}
 
开发者ID:BubbleMC,项目名称:BubbleMC,代码行数:26,代码来源:Main.java

示例4: timer_start

import org.bukkit.scheduler.BukkitRunnable; //导入方法依赖的package包/类
/**
 * Initialize timer.
 */
public void timer_start() {
    timerTicks = settings.gameLength;
    timer = new BukkitRunnable() {
        public void run() {
            bar_set();
            if (settings.gameLength != 0) {
                timer_tick();
                if (state == GameState.INGAME) {
                    if (--timerTicks <= 0) {
                        timer_out();
                        cancel();
                    }
                } else cancel();
            }
        }
    };
    timer.runTaskTimer(OMGPI.instance, 0L, 20L);
}
 
开发者ID:BurnyDaKath,项目名称:OMGPI,代码行数:22,代码来源:Game.java

示例5: add

import org.bukkit.scheduler.BukkitRunnable; //导入方法依赖的package包/类
public void add(ItemStack stack) {
	World world = block.getWorld();
	Location location = block.getLocation().add(0, 1, 0.5);

	ItemStack cloned = stack.clone();
	cloned.setAmount(1);
	Item entity = world.dropItem(location, cloned);
	entity.setVelocity(new Vector(0, 0, 0));
	entity.teleport(location);
	entity.setGravity(false);
	entity.setGlowing(true);
	entity.setPickupDelay(Integer.MAX_VALUE);
	stack.setAmount(stack.getAmount() - 1);

	BukkitRunnable runnable = new BukkitRunnable() {
		int tickCount = 0;
		int speed = 8;
		// Circle maths!
		double unit = 2 * Math.PI / (speed * 10);
		double divisor = speed * Math.PI;

		@Override
		public void run() {
			entity.setVelocity(
					new Vector(Math.sin(unit * tickCount) / divisor, 0, Math.cos(unit * tickCount) / divisor));

			tickCount++;
			if (tickCount == speed * 10) {
				tickCount = 0;
			}
		}
	};
	runnable.runTaskTimer(MystiCraft.getInstance(), 1, 1);
	items.put(entity, runnable);
	String spell = getSpell();
	if (spell != null) {
		book.setCustomName("Ready to craft: " + spell);
		book.setCustomNameVisible(true);
	} else {
		book.setCustomNameVisible(false);
	}
}
 
开发者ID:mcardy,项目名称:MystiCraft,代码行数:43,代码来源:CraftingOperation.java

示例6: onCommand

import org.bukkit.scheduler.BukkitRunnable; //导入方法依赖的package包/类
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    if (args.length == 0) {
        sender.sendMessage(Main.PREFIX + "Usage: /nineslots <info|enable|disable>");
        return true;
    }

    if (args[0].equalsIgnoreCase("info")) {
        sender.sendMessage(Main.PREFIX + "Plugin creator: §aLeonTG");
        sender.sendMessage(Main.PREFIX + "Version: §a" + plugin.getDescription().getVersion());
        sender.sendMessage(Main.PREFIX + "Description:");
        sender.sendMessage("§8» §f" + plugin.getDescription().getDescription());
        return true;
    }

    if (args[0].equalsIgnoreCase("enable")) {
        if (!sender.hasPermission(PERMISSION)) {
            sender.sendMessage(ChatColor.RED + "You don't have permission.");
            return true;
        }

        if (enabled) {
            sender.sendMessage(Main.PREFIX + "Nine Slots is already enabled.");
            return true;
        }

        plugin.broadcast(Main.PREFIX + "Nine Slots has been enabled.");
        enabled = true;

        Bukkit.getPluginManager().registerEvents(listener, plugin);

        task = new BukkitRunnable() {
            @Override
            public void run() {
                for (Player online : Bukkit.getOnlinePlayers()) {
                    for (int i = 9; i < 36; i++) {
                        online.getInventory().setItem(i, Main.BLOCKED_ITEM);
                    }
                }
            }
        };

        task.runTaskTimer(plugin, 0L, 100L);
        return true;
    }

    if (args[0].equalsIgnoreCase("disable")) {
        if (!sender.hasPermission(PERMISSION)) {
            sender.sendMessage(ChatColor.RED + "You don't have permission.");
            return true;
        }

        if (!enabled) {
            sender.sendMessage(Main.PREFIX + "Nine Slots is not enabled.");
            return true;
        }

        plugin.broadcast(Main.PREFIX + "Nine Slots has been disabled.");
        enabled = false;

        HandlerList.unregisterAll(listener);

        if (task != null) {
            task.cancel();
        }

        task = null;
        return true;
    }

    sender.sendMessage(Main.PREFIX + "Usage: /nineslots <info|enable|disable>");
    return true;
}
 
开发者ID:LeonTG,项目名称:NineSlots,代码行数:74,代码来源:NineSlotsCommand.java

示例7: onEnable

import org.bukkit.scheduler.BukkitRunnable; //导入方法依赖的package包/类
/**
 * Basic game enabling and loading method.<br>
 * <br>
 * For proper runs use:<br>
 * name = "GameName";<br>
 * super.onEnable();<br>
 * <br>
 * If you create teams add:<br>
 * team = new OMGTeam(...);<br>
 * Inventories.update();
 */
public void onEnable() {
    Bukkit.getPluginManager().registerEvents(this, this);
    Bukkit.getPluginManager().registerEvents(new BukkitEventHandler(), OMGPI.instance);

    gamefig = new Gamefig();
    state = GameState.PRELOBBY;
    gamePreparer = new ClijmartTeamAsserter();
    shootSources = new HashMap<>();

    mapsDirectory = new File(getDataFolder() + File.separator + "maps");

    defaultTeam = new OMGTeam("default", ChatColor.YELLOW + "Default", ChatColor.YELLOW + "", true, GameMode.ADVENTURE);
    spectatorTeam = new OMGTeam("spectator", ChatColor.GRAY + "Spectator", ChatColor.GRAY + "", false, GameMode.SPECTATOR);

    OMGKit.dir = new File(getDataFolder() + File.separator + "kits");
    OMGKit def = new OMGKit("Default");
    def.setUnpresent("displayItem", "{id:stone,Count:1,tag:{display:{Name:\"Default\"}}}");
    def.save();
    String[] kitarr = OMGKit.dir.list();
    List<String> kits = kitarr == null ? new ArrayList<>() : Arrays.asList(kitarr);
    kits.stream().filter(k -> k.endsWith(".kit") && OMGKit.kits.stream().noneMatch(k1 -> (k1 + ".kit").equalsIgnoreCase(k))).forEach(k -> new OMGKit(k.replaceAll("\\.kit", "")));

    OMGLoot.dir = new File(getDataFolder() + File.separator + "loots");
    String[] lootarr = OMGLoot.dir.list();
    List<String> loots = lootarr == null ? new ArrayList<>() : Arrays.asList(lootarr);
    loots.stream().filter(l -> l.endsWith(".loot") && OMGLoot.loots.stream().noneMatch(l1 -> (l1 + ".loot").equalsIgnoreCase(l))).forEach(l -> new OMGLoot(l.replaceAll("\\.loot", "")));

    settings = new GameSettings(this);

    infoBar = Bukkit.createBossBar(ChatColor.AQUA + "", BarColor.WHITE, BarStyle.SOLID);
    infoBar.setVisible(false);

    voteSystem = new VoteSystem();

    countdown = new Countdown();
    updator = new BukkitRunnable() {
        public void run() {
            update();
        }
    };
    updator.runTaskTimer(this, 0, 1);

    Inventories.update();

    Bukkit.getOnlinePlayers().forEach(p -> {
        while (OMGPlayer.get(p) == null) event_player_join(new OMGPlayer(p));
    });
    OMGPI.iLog(name + " initialized, can be played.");
}
 
开发者ID:BurnyDaKath,项目名称:OMGPI,代码行数:61,代码来源:Game.java


注:本文中的org.bukkit.scheduler.BukkitRunnable.runTaskTimer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。