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


Java BukkitScheduler类代码示例

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


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

示例1: onEnable

import org.bukkit.scheduler.BukkitScheduler; //导入依赖的package包/类
public void onEnable() {
	registerListeners();
	registerCommands();
	ConfigManager.getInstance().setup(this);

	WorldBorder b = Bukkit.getWorld("world").getWorldBorder();
	b.setCenter(new Location(Bukkit.getWorld("world"), 0, 64, 0));
	b.setSize(SettingsManager.border);
	
	BukkitScheduler scheduler = getServer().getScheduler();
	scheduler.scheduleSyncRepeatingTask(this, new Runnable() {
		@Override
		public void run() {
			Bukkit.broadcastMessage("loop all players: :kappa:");
			if(GameManager.getGameSituation()) {
				if(GameManager.getStartTime() + 600000 > System.currentTimeMillis()) {
					b.setSize(b.getSize() - 1);
				}
			}
		}
	}, 0L, 1 * 20L);
}
 
开发者ID:masste,项目名称:McPlayUHC,代码行数:23,代码来源:McPlayUHC.java

示例2: registerTasks

import org.bukkit.scheduler.BukkitScheduler; //导入依赖的package包/类
@Override
public void registerTasks() {
    BukkitScheduler scheduler = getServer().getScheduler();

    TicksPerSecondTask ticksTask = new TicksPerSecondTask();
    scheduler.runTaskTimer(this, ticksTask, 60L, 1L);

    TpsCollector tpsCollector = new TpsCollector(core.getConnector(), ticksTask::getLastTicks);
    scheduler.runTaskTimer(this, tpsCollector, 20L, 20L);

    PingCollector pingTask = new PingCollector(core.getConnector(), () -> Bukkit.getOnlinePlayers()
            .stream()
            .mapToInt(BukkitUtil::getReflectionPing)
            .average()
            .orElse(0));
    scheduler.runTaskTimer(this, pingTask, 40L, 40L);

    scheduler.runTaskTimer(this, new BukkitWorldCollector(core.getConnector()), 5 * 60 * 20L, 5 * 60 * 20L);
    scheduler.runTaskTimer(this, playerCollector, 15 * 60 * 20L, 15 * 60 * 20L);
}
 
开发者ID:games647,项目名称:Minefana,代码行数:21,代码来源:MinefanaBukkit.java

示例3: checkForEyepatchEnchant

import org.bukkit.scheduler.BukkitScheduler; //导入依赖的package包/类
public void checkForEyepatchEnchant(){
	BukkitScheduler scheduler = Bukkit.getServer().getScheduler();
       scheduler.scheduleSyncRepeatingTask(plugin, new Runnable() {

		@Override
		public void run() {
			
			for(Player player : Bukkit.getOnlinePlayers()){
				if(player.getInventory().getHelmet() != null){
					ItemStack item = player.getInventory().getHelmet();
					if(new ItemType(item).getArmorType().equals(ArmorTypes.HEAD)){
						Armor detailItem = new Armor(item);
							HashMap<Enchantments, Integer> enchantments = detailItem.getEnchantsAndLevel();
							if(enchantments.containsKey(Enchantments.EYEPATCH)){
								if(player.getActivePotionEffects().contains(PotionEffectType.BLINDNESS)){
									player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 0, 0));
								}
							}
					}
				}
			}
			
		}
       	
       }, 0, 1);
}
 
开发者ID:DamoclesProject,项目名称:Damocles,代码行数:27,代码来源:Eyepatch.java

示例4: playSetForPlayers

import org.bukkit.scheduler.BukkitScheduler; //导入依赖的package包/类
public static void playSetForPlayers(Breakpoint plugin, BPSoundSet set, final Game game)
{
	BukkitScheduler scheduler = Bukkit.getScheduler();
	double delay = 0;
	
	for(final BPSound sound : set.getSounds())
	{
		scheduler.scheduleSyncDelayedTask(plugin, new Runnable() {
			@Override
			public void run()
			{
				playSoundForPlayers(game, sound);
			}
		}, (long) (delay * 20L));
		
		delay += sound.getLengthInSeconds();
	}
}
 
开发者ID:Limeth,项目名称:Breakpoint,代码行数:19,代码来源:SoundManager.java

示例5: testStartStop

import org.bukkit.scheduler.BukkitScheduler; //导入依赖的package包/类
@Test
public void testStartStop() {
	final BukkitScheduler scheduler = TestBukkit.getServer().getScheduler();
	reset(scheduler);
	
	assertFalse(dut.isRunning());
	
	dut.start();
	verify(scheduler).scheduleSyncRepeatingTask(pearlApi, dut, 72000, 72000);
	assertTrue(dut.isRunning());
	
	dut.start();
	verify(scheduler).scheduleSyncRepeatingTask(pearlApi, dut, 72000, 72000);
	assertTrue(dut.isRunning());
	
	dut.stop();
	verify(scheduler).cancelTask(anyInt());
	assertFalse(dut.isRunning());
}
 
开发者ID:DevotedMC,项目名称:ExilePearl,代码行数:20,代码来源:PearlDecayTaskTest.java

示例6: testStartStop

import org.bukkit.scheduler.BukkitScheduler; //导入依赖的package包/类
@Test
public void testStartStop() {
	final BukkitScheduler scheduler = getServer().getScheduler();
	reset(scheduler);
	
	assertFalse(dut.isRunning());
	
	dut.start();
	verify(scheduler).scheduleSyncRepeatingTask(pearlApi, dut, INTERVAL, INTERVAL);
	assertTrue(dut.isRunning());
	
	dut.start();
	verify(scheduler).scheduleSyncRepeatingTask(pearlApi, dut, INTERVAL, INTERVAL);
	assertTrue(dut.isRunning());
	
	dut.stop();
	verify(scheduler).cancelTask(anyInt());
	assertFalse(dut.isRunning());
}
 
开发者ID:DevotedMC,项目名称:ExilePearl,代码行数:20,代码来源:CoreDamageLoggerTest.java

示例7: testRestart

import org.bukkit.scheduler.BukkitScheduler; //导入依赖的package包/类
@Test
public void testRestart() {
	final BukkitScheduler scheduler = getServer().getScheduler();
	reset(scheduler);
	
	when(config.getDamageLogInterval()).thenReturn(40);
	dut.loadConfig(config);
	
	dut.restart();
	verify(scheduler).scheduleSyncRepeatingTask(pearlApi, dut, 40, 40);
	assertTrue(dut.isRunning());
	
	dut.restart();
	verify(scheduler).cancelTask(anyInt());
	assertTrue(dut.isRunning());
}
 
开发者ID:DevotedMC,项目名称:ExilePearl,代码行数:17,代码来源:CoreDamageLoggerTest.java

示例8: testStartStop

import org.bukkit.scheduler.BukkitScheduler; //导入依赖的package包/类
@Test
public void testStartStop() {
	final BukkitScheduler scheduler = TestBukkit.getServer().getScheduler();
	reset(scheduler);
	
	assertFalse(dut.isRunning());
	
	dut.start();
	verify(scheduler).scheduleSyncRepeatingTask(pearlApi, dut, PlayerSuicideTask.TICKS_PER_SECOND, PlayerSuicideTask.TICKS_PER_SECOND);
	assertTrue(dut.isRunning());
	
	dut.start();
	verify(scheduler).scheduleSyncRepeatingTask(pearlApi, dut, PlayerSuicideTask.TICKS_PER_SECOND, PlayerSuicideTask.TICKS_PER_SECOND);
	assertTrue(dut.isRunning());
	
	dut.stop();
	verify(scheduler).cancelTask(anyInt());
	assertFalse(dut.isRunning());
}
 
开发者ID:DevotedMC,项目名称:ExilePearl,代码行数:20,代码来源:PlayerSuicideTaskTest.java

示例9: initMockedJavaPlugin

import org.bukkit.scheduler.BukkitScheduler; //导入依赖的package包/类
public static void initMockedJavaPlugin() throws Exception
{
	BukkitScheduler mockedScheduler = mock(BukkitScheduler.class);
	when(mockedScheduler.runTask(any(org.bukkit.plugin.Plugin.class), any(Runnable.class))).thenAnswer(new Answer<Object>() {
		@Override
		public Object answer(InvocationOnMock invocationOnMock) throws Throwable
		{
			((Runnable) invocationOnMock.getArguments()[1]).run();
			return null;
		}
	});
	Server mockedServer = mock(Server.class);
	when(mockedServer.getScheduler()).thenReturn(mockedScheduler);
	mockedJavaPlugin = PowerMockito.mock(JavaPlugin.class);
	when(mockedJavaPlugin.getLogger()).thenReturn(Logger.getLogger("TestLogger"));
	when(mockedJavaPlugin.getDataFolder()).thenReturn(new File(""));
	when(mockedJavaPlugin.getServer()).thenReturn(mockedServer);
}
 
开发者ID:GeorgH93,项目名称:Bukkit_Bungee_PluginLib,代码行数:19,代码来源:TestObjects.java

示例10: setUpPlugin

import org.bukkit.scheduler.BukkitScheduler; //导入依赖的package包/类
@Before
public void setUpPlugin() throws IOException {
    dataFolder = temporaryFolder.newFolder();

    // Wire various Bukkit components
    setField(Bukkit.class, "server", null, server);
    given(server.getLogger()).willReturn(mock(Logger.class));
    given(server.getScheduler()).willReturn(mock(BukkitScheduler.class));
    given(server.getPluginManager()).willReturn(pluginManager);
    given(server.getVersion()).willReturn("1.9.4-RC1");

    // SettingsManager always returns the default
    given(settings.getProperty(any(Property.class))).willAnswer(new Answer<Object>() {
        @Override
        public Object answer(InvocationOnMock invocation) throws Throwable {
            return ((Property<?>) invocation.getArguments()[0]).getDefaultValue();
        }
    });

    // PluginDescriptionFile is final and so cannot be mocked
    PluginDescriptionFile descriptionFile = new PluginDescriptionFile(
        "PerWorldInventory", "N/A", PerWorldInventory.class.getCanonicalName());
    JavaPluginLoader pluginLoader = new JavaPluginLoader(server);
    plugin = new PerWorldInventory(pluginLoader, descriptionFile, dataFolder, null);
    setField(JavaPlugin.class, "logger", plugin, mock(PluginLogger.class));
}
 
开发者ID:Gnat008,项目名称:PerWorldInventory,代码行数:27,代码来源:PerWorldInventoryInitializationTest.java

示例11: init

import org.bukkit.scheduler.BukkitScheduler; //导入依赖的package包/类
@Override
public void init() {
    this.loadConfig();
    if (!this.setUpLanguage()) return;
    this.setUpAPI();
    this.registerModes();
    this.registerStages();
    this.registerCommands();
    final PluginManager pm = this.getChatterbox().getServer().getPluginManager();
    pm.registerEvents(new ChannelListener(this), this.getChatterbox());
    final BukkitScheduler bs = this.getChatterbox().getServer().getScheduler();
    bs.scheduleSyncRepeatingTask(this.getChatterbox(), new SaveChannelsTask(this), 36000L, 36000L);
    // Turn ConfigChannels into IRCConfigChannels
    this.transformConfigChannels();
    // Create saved channels and set modes on config channels
    this.loadFromIRCChannelsConfig();
    // Make sure all players join their previous channels that have just been made
    this.getChatterbox().getServer().getOnlinePlayers().stream()
        .map(player -> this.getChatterboxAPI().getPlayerAPI().getCPlayer(player))
        .forEach(CPlayer::joinPreviousChannels);
    this.getLogger().info("Loaded.");
}
 
开发者ID:Chatterbox,项目名称:hooks,代码行数:23,代码来源:IRCChannels.java

示例12: init

import org.bukkit.scheduler.BukkitScheduler; //导入依赖的package包/类
public void init(Plugin plugin)
{
    BukkitScheduler bs;
    PluginManager   pm;
    String          wn;

    if (radius < 1) {
        for (World w : Bukkit.getWorlds()) {
            wn = w.getName();

            if (worlds.contains(wn))
                subregions.add(new SubRegion(this, wn, 0, 0, true));
        }
    }

    if (event > 0) {
        pm = plugin.getServer().getPluginManager();
        pm.registerEvents(this, plugin);
    }

    if (sweep > 0) {
        bs     = plugin.getServer().getScheduler();
        taskid = bs.scheduleSyncRepeatingTask(plugin, this, sweep, sweep);
    }
}
 
开发者ID:jgeboski,项目名称:MobSweeper,代码行数:26,代码来源:Region.java

示例13: start

import org.bukkit.scheduler.BukkitScheduler; //导入依赖的package包/类
public void start() {
    if (!isRunning) {
        BukkitScheduler scheduler = plugin.getServer().getScheduler();
        taskID = scheduler.scheduleSyncRepeatingTask(plugin,
                new Runnable() {
                    public void run() {
                        onSecond();
                    }
                }, 20L, 20L);
        isRunning = true;
    }

    time = -startTime;

    for (Player p : Bukkit.getOnlinePlayers())
        BarUtil.setMessageAndPercent(p, ChatColor.GREEN + "Starting in "
                + -time, 1F);

    plugin.getSignHandler().updateSigns(GameTeam.RED);
    plugin.getSignHandler().updateSigns(GameTeam.BLUE);
    plugin.getSignHandler().updateSigns(GameTeam.GREEN);
    plugin.getSignHandler().updateSigns(GameTeam.YELLOW);
}
 
开发者ID:cancabron,项目名称:Annihilation,代码行数:24,代码来源:PhaseManager.java

示例14: startThreads

import org.bukkit.scheduler.BukkitScheduler; //导入依赖的package包/类
public static void startThreads() {
    BukkitScheduler scheduler = Bukkit.getScheduler();

    // Start sync demigods runnable
    scheduler.scheduleSyncRepeatingTask(StoaPlugin.getInst(), SYNC, 20, 20);
    MessageUtil.sendDebug("Main Demigods SYNC runnable enabled...");

    // Start async demigods runnable
    scheduler.scheduleAsyncRepeatingTask(StoaPlugin.getInst(), ASYNC, 20, 20);
    MessageUtil.sendDebug("Main Demigods ASYNC runnable enabled...");

    // Start favor runnable
    scheduler.scheduleAsyncRepeatingTask(StoaPlugin.getInst(), FAVOR, 20, (StoaPlugin.config().getInt("regeneration_rates.favor") * 20));
    MessageUtil.sendDebug("Favor regeneration runnable enabled...");

    // Enable Deity runnables
    for (Deity deity : Stoa.getMythos().getDeities())
        for (Ability ability : deity.getAbilities())
            if (ability.getRunnable() != null)
                scheduler.scheduleSyncRepeatingTask(StoaPlugin.getInst(), ability.getRunnable(), ability.getDelay(), ability.getRepeat());

    // Triggers
    ThreadUtil.registerSyncAsyncRunnables(StoaPlugin.getInst(), Stoa.getMythos().getSyncAsyncTasks());
}
 
开发者ID:DemigodsRPG,项目名称:Stoa,代码行数:25,代码来源:TaskManager.java

示例15: load

import org.bukkit.scheduler.BukkitScheduler; //导入依赖的package包/类
public void load() {
    BukkitScheduler scheduler = plugin.getServer().getScheduler();
    if (task != null) {
        task.cancel();
        task = null;
    }
    ConfigurationSection arenaConfiguration = loadDataFile("arenas");
    load(arenaConfiguration);

    ConfigurationSection arenaData = loadDataFile("data");
    loadData(arenaData);

    plugin.reloadConfig();
    Configuration config = plugin.getConfig();
    pathTemplate = config.getString("path_template", pathTemplate);
    tickInterval = config.getInt("tick_interval", 40);

    task = scheduler.runTaskTimer(plugin, this, 1, tickInterval);
}
 
开发者ID:elBukkit,项目名称:MagicArenas,代码行数:20,代码来源:ArenaController.java


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