gpt4 book ai didi

org.bukkit.event.weather.WeatherChangeEvent.isCancelled()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-24 23:45:05 27 4
gpt4 key购买 nike

本文整理了Java中org.bukkit.event.weather.WeatherChangeEvent.isCancelled()方法的一些代码示例,展示了WeatherChangeEvent.isCancelled()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WeatherChangeEvent.isCancelled()方法的具体详情如下:
包路径:org.bukkit.event.weather.WeatherChangeEvent
类名称:WeatherChangeEvent
方法名:isCancelled

WeatherChangeEvent.isCancelled介绍

暂无

代码示例

代码示例来源:origin: GlowstoneMC/Glowstone

@Override
public void setStorm(boolean hasStorm) {
  // call event
  WeatherChangeEvent event = new WeatherChangeEvent(this, hasStorm);
  if (EventFactory.getInstance().callEvent(event).isCancelled()) {
    return;
  }
  // change weather
  boolean previouslyRaining = currentlyRaining;
  currentlyRaining = hasStorm;
  // Numbers borrowed from CraftBukkit.
  if (currentlyRaining) {
    setWeatherDuration(ThreadLocalRandom.current().nextInt(TickUtil.TICKS_PER_HALF_DAY)
        + TickUtil.TICKS_PER_HALF_DAY);
  } else {
    setWeatherDuration(ThreadLocalRandom.current().nextInt(TickUtil.TICKS_PER_WEEK)
        + TickUtil.TICKS_PER_HALF_DAY);
  }
  // update players
  if (previouslyRaining != currentlyRaining) {
    getRawPlayers().forEach(GlowPlayer::sendWeather);
  }
}

代码示例来源:origin: io.github.bedwarsrel/BedwarsRel-Common

@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;
  }
 }
}

代码示例来源:origin: BedwarsRel/BedwarsRel

@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;
  }
 }
}

代码示例来源:origin: Multiverse/Multiverse-Core

/**
 * This method is called when the weather changes.
 * @param event The Event that was fired.
 */
@EventHandler
public void weatherChange(WeatherChangeEvent event) {
  if (event.isCancelled()) {
    return;
  }
  MultiverseWorld world = this.plugin.getMVWorldManager().getMVWorld(event.getWorld().getName());
  if (world != null) {
    // If it's going to start raining and we have weather disabled
    event.setCancelled((event.toWeatherState() && !world.isWeatherEnabled()));
  }
}

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com