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


Java WeatherChangeEvent.getWorld方法代碼示例

本文整理匯總了Java中org.bukkit.event.weather.WeatherChangeEvent.getWorld方法的典型用法代碼示例。如果您正苦於以下問題:Java WeatherChangeEvent.getWorld方法的具體用法?Java WeatherChangeEvent.getWorld怎麽用?Java WeatherChangeEvent.getWorld使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.bukkit.event.weather.WeatherChangeEvent的用法示例。


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

示例1: onWeatherChange

import org.bukkit.event.weather.WeatherChangeEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.NORMAL)
public void onWeatherChange(WeatherChangeEvent e) {    
	World w = e.getWorld();
	int trys = RPConfig.getGlobalFlagInt(w.getName()+".rain.trys-before-rain");
	if (e.toWeatherState()){
		if (!rainCounter.containsKey(w)){
			rainCounter.put(w, trys);
			e.setCancelled(true);
		} else {
			int acTry = rainCounter.get(w);
			if (acTry-1 <= 0){    
				Bukkit.getScheduler().runTaskLater(RedProtect.get(), () -> w.setWeatherDuration(RPConfig.getGlobalFlagInt(w.getName()+".rain.duration")*20), 40);
				rainCounter.put(w, trys);
			} else {
				rainCounter.put(w, acTry-1);
    			e.setCancelled(true);
			}
		}    		
	}
}
 
開發者ID:FabioZumbi12,項目名稱:RedProtect,代碼行數:21,代碼來源:RPWorldListener.java

示例2: onWeatherChange

import org.bukkit.event.weather.WeatherChangeEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.HIGH)
public void onWeatherChange(WeatherChangeEvent event)
{
    try
    {
        if (event.getWorld() == TFM_AdminWorld.getInstance().getWorld() && TFM_AdminWorld.getInstance().getWeatherMode() != TFM_AdminWorld.WeatherMode.OFF)
        {
            return;
        }
    }
    catch (Exception ex)
    {
    }

    if (event.toWeatherState() && TFM_ConfigEntry.DISABLE_WEATHER.getBoolean())
    {
        event.setCancelled(true);
        return;
    }
}
 
開發者ID:Yoshi41023,項目名稱:TatsuCraftMod,代碼行數:21,代碼來源:TFM_WeatherListener.java

示例3: onWeatherChange

import org.bukkit.event.weather.WeatherChangeEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onWeatherChange(WeatherChangeEvent event) {
    World world = event.getWorld();

    if (plugin.isActive(world) && plugin.isFeatureEnabled(world, Feature.WEATHER)) {
        event.setCancelled(true);
    }
}
 
開發者ID:Samistine,項目名稱:BloodMoon,代碼行數:9,代碼來源:WeatherListener.java

示例4: onWeatherChange

import org.bukkit.event.weather.WeatherChangeEvent; //導入方法依賴的package包/類
@EventHandler
public void onWeatherChange(WeatherChangeEvent e) {
	if(e.toWeatherState()) {
		e.setCancelled(true);
		World world = e.getWorld();
		world.setStorm(false);
		world.setThundering(false);
		world.setWeatherDuration(100000);
	}
}
 
開發者ID:kyriog,項目名稱:rftd,代碼行數:11,代碼來源:WeatherListener.java

示例5: onWeatherChange

import org.bukkit.event.weather.WeatherChangeEvent; //導入方法依賴的package包/類
@EventHandler
public void onWeatherChange(WeatherChangeEvent event) {

    notifyAboutUpdate();

    Random r = new Random();
    Boolean voteInProgress = false;

    //Check if the world is enabled
    if (getFileConfig().getStringList("Worlds").contains(event.getWorld().getName())) {
        //Check if it's going to rain
        if (event.toWeatherState()) {


            if (getFileConfig().getInt("RainTime.longest") == 0) {
                event.setCancelled(true);

                LogDebug("Rain event cancelled.");

                return;
            }


            //Check if there is a vote in progress in that world. Abort if so.
            for (VoteManager vote : voteManagers) {
                if (vote.getVoteWorld().getName().equals(event.getWorld().getName())) {
                    voteInProgress = true;
                    continue;
                }
            }

            LogDebug("Is vote in progress: " + voteInProgress + " " + event.getWorld().getName());

            if (voteInProgress) {
                return;
            }

            if (r.nextInt(100) >= getFileConfig().getInt("FailChance")) {


                VoteManager vm = new VoteManager(this, event.getWorld(), new WeatherInformation(event.getWorld(), event.toWeatherState(), event.toWeatherState(), event.getWorld().isThundering(), event.getWorld().getWeatherDuration(), event.getWorld().getThunderDuration()));

                vm.startVote(getFileConfig().getInt("TimeToVote"));
                voteManagers.add(vm);
                event.setCancelled(true);
            } else {
                messageAllPlayers(locale.getMessage("storm_too_strong"), event.getWorld());
            }
        } else {
            if (getFileConfig().getInt("SunTime.longest") == 0) {
                event.setCancelled(true);

                LogDebug("Sun event cancelled.");
                return;
            }
            Integer duration;

            duration = r.nextInt((getFileConfig().getInt("SunTime.longest") - getFileConfig().getInt("SunTime.shortest")) + 1) + getFileConfig().getInt("SunTime.shortest");

            event.getWorld().setWeatherDuration(duration * 20);

            LogDebug("The sun will shine in " + event.getWorld().getName() + " for " + duration + " seconds.");
        }

    }
}
 
開發者ID:igwb,項目名稱:WeatherVote,代碼行數:67,代碼來源:WeatherVote.java


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