本文整理匯總了Java中org.bukkit.scheduler.BukkitScheduler.scheduleSyncRepeatingTask方法的典型用法代碼示例。如果您正苦於以下問題:Java BukkitScheduler.scheduleSyncRepeatingTask方法的具體用法?Java BukkitScheduler.scheduleSyncRepeatingTask怎麽用?Java BukkitScheduler.scheduleSyncRepeatingTask使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.bukkit.scheduler.BukkitScheduler
的用法示例。
在下文中一共展示了BukkitScheduler.scheduleSyncRepeatingTask方法的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);
}
示例2: 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);
}
示例3: 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.");
}
示例4: 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);
}
}
示例5: 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);
}
示例6: 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());
}
示例7: start
import org.bukkit.scheduler.BukkitScheduler; //導入方法依賴的package包/類
public void start() {
if (!isRunning) {
BukkitScheduler scheduler = plugin.getServer().getScheduler();
taskID = scheduler.scheduleSyncRepeatingTask(plugin,
new Runnable() {
@Override
public void run() {
onSecond();
}
}, 20L, 20L);
isRunning = true;
}
time = -startTime;
for (Player p : Bukkit.getOnlinePlayers())
ActionAPI.sendPlayerAnnouncement(p, ChatColor.DARK_AQUA
+ "Welcome to CrafterNexus!");
plugin.getSignHandler().updateSigns(GameTeam.RED);
plugin.getSignHandler().updateSigns(GameTeam.BLUE);
plugin.getSignHandler().updateSigns(GameTeam.GREEN);
plugin.getSignHandler().updateSigns(GameTeam.YELLOW);
}
示例8: messageManager
import org.bukkit.scheduler.BukkitScheduler; //導入方法依賴的package包/類
private void messageManager() {
Random randomGenerator = new Random();
List<String> listMessages = getListMessages();
System.out.println(listMessages.size()+" messages loaded");
BukkitScheduler scheduler = getServer().getScheduler();
scheduler.scheduleSyncRepeatingTask(this, new Runnable() {
@Override
public void run() {
if(getConfig().getBoolean("Enable")) {
if(Bukkit.getOnlinePlayers().size() >= getConfig().getInt(MIN_PLAYER_CONFIG)) {
if(!getConfig().getBoolean(RANDOM_CONFIG)) {
MessageManager.messageDisplayer(getPrefix() + " " + listMessages.get(iMessages));
iMessages++;
if (iMessages >= listMessages.size())
iMessages = 0;
} else {
MessageManager.messageDisplayer(getPrefix() + " " + listMessages.get(randomGenerator.nextInt(listMessages.size())));
}
}
}
}
}, 0, this.getConfig().getInt("Time")*60*20);
}
示例9: keepAlive
import org.bukkit.scheduler.BukkitScheduler; //導入方法依賴的package包/類
private void keepAlive() {
BukkitScheduler scheduler = getServer().getScheduler();
scheduler.scheduleSyncRepeatingTask(this, new Runnable() {
@Override
public void run() {
try {
Database.getConnection().prepareStatement("SELECT 1").executeQuery();
} catch (SQLException e) {
e.printStackTrace();
}
}
}, 0l, 1200L);
}
示例10: MobsTimer
import org.bukkit.scheduler.BukkitScheduler; //導入方法依賴的package包/類
public void MobsTimer() {
BukkitScheduler scheduler = Bukkit.getServer().getScheduler();
scheduler.scheduleSyncRepeatingTask(this, new Runnable() {
@Override
public void run() {
MobsTimerHashMap.clear();
}
}, 0L, Integer.valueOf(20 * getConfig().getInt("Config.MobsInSeconds.Secons")));
}
示例11: startMessageCycle
import org.bukkit.scheduler.BukkitScheduler; //導入方法依賴的package包/類
private void startMessageCycle() {
if (messages.size() < 1) return;
BukkitScheduler scheduler = Bukkit.getServer().getScheduler();
scheduler.scheduleSyncRepeatingTask(plugin, new Runnable() {
public void run() {
printMessage();
}
}, 1200L, 6000L);
}
示例12: checkForJumpEnchant
import org.bukkit.scheduler.BukkitScheduler; //導入方法依賴的package包/類
public void checkForJumpEnchant(){
BukkitScheduler scheduler = Bukkit.getServer().getScheduler();
scheduler.scheduleSyncRepeatingTask(plugin, new Runnable() {
@Override
public void run() {
for(Player player : Bukkit.getOnlinePlayers()){
if(player.getInventory().getBoots() != null){
ItemStack item = player.getInventory().getBoots();
if(new ItemType(item).getArmorType().equals(ArmorTypes.FEET)){
Armor detailItem = new Armor(item);
HashMap<Enchantments, Integer> enchantments = detailItem.getEnchantsAndLevel();
if(enchantments.containsKey(Enchantments.JUMP)){
int amp = 0;
int level = enchantments.get(Enchantments.JUMP);
if(level == 1){
amp = 0;
}else if(level == 2){
amp = 1;
}else if(level == 3){
amp = 2;
}
player.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 20, amp));
}
}
}
}
}
}, 0, 1);
}
示例13: checkForSpeedEnchant
import org.bukkit.scheduler.BukkitScheduler; //導入方法依賴的package包/類
public void checkForSpeedEnchant(){
BukkitScheduler scheduler = Bukkit.getServer().getScheduler();
scheduler.scheduleSyncRepeatingTask(plugin, new Runnable() {
@Override
public void run() {
for(Player player : Bukkit.getOnlinePlayers()){
if(player.getInventory().getBoots() != null){
ItemStack item = player.getInventory().getBoots();
if(new ItemType(item).getArmorType().equals(ArmorTypes.FEET)){
Armor detailItem = new Armor(item);
HashMap<Enchantments, Integer> enchantments = detailItem.getEnchantsAndLevel();
if(enchantments.containsKey(Enchantments.SPEED)){
int amp = 0;
int level = enchantments.get(Enchantments.SPEED);
if(level == 1){
amp = 0;
}else if(level == 2){
amp = 1;
}else if(level == 3){
amp = 2;
}
player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 20, amp));
}
}
}
}
}
}, 0, 1);
}
示例14: checkForBatEnchant
import org.bukkit.scheduler.BukkitScheduler; //導入方法依賴的package包/類
public void checkForBatEnchant(){
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.BAT_VISION)){
int amp = 0;
int level = enchantments.get(Enchantments.BAT_VISION);
if(level == 1){
amp = 0;
}
player.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, 20, amp));
}
}
}
}
}
}, 0, 1);
}
示例15: startThread
import org.bukkit.scheduler.BukkitScheduler; //導入方法依賴的package包/類
/**
* Starts the backup thread
*/
public static void startThread() {
if (Config.getBackupDelay() / 60 / 20 != -1) {
MessageUtil.sendConsoleMessage("Starting the backup thread for every " + Config.getBackupDelay() + " ticks.");
BukkitScheduler scheduler = Bukkit.getServer().getScheduler();
scheduler.scheduleSyncRepeatingTask(getInstance(), new UploadThread(), Config.getBackupDelay(), Config.getBackupDelay());
}
}