本文整理匯總了Java中org.bukkit.event.weather.WeatherChangeEvent類的典型用法代碼示例。如果您正苦於以下問題:Java WeatherChangeEvent類的具體用法?Java WeatherChangeEvent怎麽用?Java WeatherChangeEvent使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
WeatherChangeEvent類屬於org.bukkit.event.weather包,在下文中一共展示了WeatherChangeEvent類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setStorm
import org.bukkit.event.weather.WeatherChangeEvent; //導入依賴的package包/類
public void setStorm(boolean hasStorm) {
CraftServer server = world.getServer();
WeatherChangeEvent weather = new WeatherChangeEvent(this, hasStorm);
server.getPluginManager().callEvent(weather);
if (!weather.isCancelled()) {
world.worldInfo.setRaining(hasStorm);
// These numbers are from Minecraft
if (hasStorm) {
setWeatherDuration(rand.nextInt(12000) + 12000);
} else {
setWeatherDuration(rand.nextInt(168000) + 12000);
}
}
}
示例2: check
import org.bukkit.event.weather.WeatherChangeEvent; //導入依賴的package包/類
@SuppressWarnings("null")
@Override
public boolean check(final Event e) {
if (types == null)
return true;
if (!(e instanceof WeatherChangeEvent || e instanceof ThunderChangeEvent))
return false;
final boolean rain = e instanceof WeatherChangeEvent ? ((WeatherChangeEvent) e).toWeatherState() : ((ThunderChangeEvent) e).getWorld().hasStorm();
final boolean thunder = e instanceof ThunderChangeEvent ? ((ThunderChangeEvent) e).toThunderState() : ((WeatherChangeEvent) e).getWorld().isThundering();
return types.check(e, new Checker<WeatherType>() {
@Override
public boolean check(final WeatherType t) {
return t.isWeather(rain, thunder);
}
});
}
示例3: onWeatherEvent
import org.bukkit.event.weather.WeatherChangeEvent; //導入依賴的package包/類
@EventHandler
public void onWeatherEvent(WeatherChangeEvent we) {
if (we.isCancelled()) {
return;
}
List<Game> games = BedwarsRel.getInstance().getGameManager().getGamesByWorld(we.getWorld());
if (games.size() == 0) {
return;
}
for (Game game : games) {
if (game.getState() != GameState.STOPPED) {
we.setCancelled(true);
break;
}
}
}
示例4: 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);
}
}
}
}
示例5: setStorm
import org.bukkit.event.weather.WeatherChangeEvent; //導入依賴的package包/類
public void setStorm(boolean hasStorm) {
CraftServer server = world.getServer();
WeatherChangeEvent weather = new WeatherChangeEvent(this, hasStorm);
server.getPluginManager().callEvent(weather);
if (!weather.isCancelled()) {
world.worldData.setStorm(hasStorm);
// These numbers are from Minecraft
if (hasStorm) {
setWeatherDuration(rand.nextInt(12000) + 12000);
} else {
setWeatherDuration(rand.nextInt(168000) + 12000);
}
}
}
示例6: Y
import org.bukkit.event.weather.WeatherChangeEvent; //導入依賴的package包/類
private void Y() {
// CraftBukkit start
WeatherChangeEvent weather = new WeatherChangeEvent(this.getWorld(), false);
this.getServer().getPluginManager().callEvent(weather);
ThunderChangeEvent thunder = new ThunderChangeEvent(this.getWorld(), false);
this.getServer().getPluginManager().callEvent(thunder);
if (!weather.isCancelled()) {
this.worldData.setWeatherDuration(0);
this.worldData.setStorm(false);
}
if (!thunder.isCancelled()) {
this.worldData.setThunderDuration(0);
this.worldData.setThundering(false);
}
// CraftBukkit end
}
示例7: Z
import org.bukkit.event.weather.WeatherChangeEvent; //導入依賴的package包/類
private void Z() {
// CraftBukkit start
WeatherChangeEvent weather = new WeatherChangeEvent(this.getWorld(), false);
this.getServer().getPluginManager().callEvent(weather);
ThunderChangeEvent thunder = new ThunderChangeEvent(this.getWorld(), false);
this.getServer().getPluginManager().callEvent(thunder);
if (!weather.isCancelled()) {
this.worldData.setWeatherDuration(0);
this.worldData.setStorm(false);
}
if (!thunder.isCancelled()) {
this.worldData.setThunderDuration(0);
this.worldData.setThundering(false);
}
// CraftBukkit end
}
示例8: resetRainAndThunder
import org.bukkit.event.weather.WeatherChangeEvent; //導入依賴的package包/類
private void resetRainAndThunder()
{
// CraftBukkit start
WeatherChangeEvent weather = new WeatherChangeEvent(this.getWorld(), false);
this.getServer().getPluginManager().callEvent(weather);
ThunderChangeEvent thunder = new ThunderChangeEvent(this.getWorld(), false);
this.getServer().getPluginManager().callEvent(thunder);
if (!weather.isCancelled())
{
this.worldInfo.setRainTime(0);
this.worldInfo.setRaining(false);
}
if (!thunder.isCancelled())
{
this.worldInfo.setThunderTime(0);
this.worldInfo.setThundering(false);
}
// CraftBukkit end
if (!weather.isCancelled() && !thunder.isCancelled()) provider.resetRainAndThunder(); // Cauldron
}
示例9: 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;
}
}
示例10: onWeatherChangeEvent
import org.bukkit.event.weather.WeatherChangeEvent; //導入依賴的package包/類
@EventHandler
public void onWeatherChangeEvent(final WeatherChangeEvent e) {
if (!Settings.worldName.contains(e.getWorld().getName())) {
return;
}
if (e.toWeatherState()) {
// It's raining
plugin.logger(3,"It's raining!");
startSnow();
} else {
// It's stopped raining!
plugin.logger(3,"Stopped raining!");
if (snow != null)
snow.cancel();
}
}
示例11: X
import org.bukkit.event.weather.WeatherChangeEvent; //導入依賴的package包/類
private void X() {
// CraftBukkit start
WeatherChangeEvent weather = new WeatherChangeEvent(this.getWorld(), false);
this.getServer().getPluginManager().callEvent(weather);
ThunderChangeEvent thunder = new ThunderChangeEvent(this.getWorld(), false);
this.getServer().getPluginManager().callEvent(thunder);
if (!weather.isCancelled()) {
this.worldData.setWeatherDuration(0);
this.worldData.setStorm(false);
}
if (!thunder.isCancelled()) {
this.worldData.setThunderDuration(0);
this.worldData.setThundering(false);
}
// CraftBukkit end
}
示例12: setStorm
import org.bukkit.event.weather.WeatherChangeEvent; //導入依賴的package包/類
public void setStorm(boolean hasStorm) {
CraftServer server = world.getServer();
WeatherChangeEvent weather = new WeatherChangeEvent((org.bukkit.World) this, hasStorm);
server.getPluginManager().callEvent(weather);
if (!weather.isCancelled()) {
world.field_72986_A.func_76084_b(hasStorm);
// These numbers are from Minecraft
if (hasStorm) {
setWeatherDuration(rand.nextInt(12000) + 12000);
} else {
setWeatherDuration(rand.nextInt(168000) + 12000);
}
}
}
示例13: onWeatherChange
import org.bukkit.event.weather.WeatherChangeEvent; //導入依賴的package包/類
@EventHandler(priority=EventPriority.HIGHEST)
public void onWeatherChange(WeatherChangeEvent event) {
if (plugin.getConfig().getString("toggle.noweather").equals(true)) {
boolean rain = event.toWeatherState();
if(rain)
event.setCancelled(true);
}
}
示例14: onWeatherChange
import org.bukkit.event.weather.WeatherChangeEvent; //導入依賴的package包/類
@EventHandler(priority = EventPriority.HIGHEST)
public void onWeatherChange(WeatherChangeEvent event) {
if (plugin.getConfig().getString("toggle.noweather").equals(true)) {
boolean rain = event.toWeatherState();
if (rain)
event.setCancelled(true);
}
}
示例15: onWeatherChange
import org.bukkit.event.weather.WeatherChangeEvent; //導入依賴的package包/類
@EventHandler
public void onWeatherChange(WeatherChangeEvent event) {
event.getWorld().setThunderDuration(0);
event.getWorld().setWeatherDuration(0);
event.getWorld().setThundering(false);
event.setCancelled(true);
}