예제 #1
0
  public void PlayerFreezing() {
    BukkitScheduler scheduler = Bukkit.getServer().getScheduler();
    scheduler.scheduleSyncRepeatingTask(
        main,
        new Runnable() {
          @Override
          public void run() {
            Material playerChest = player.getInventory().getChestplate().getType();

            if (freezoMeter > 0) {
              freezoMeter = -1;
            } else if (freezoMeter < 0 && player.getInventory().getArmorContents() == null) {
              player.damage(20);
              freezoMeter = 100;
            } else if (freezoMeter < 0 && playerChest == Material.LEATHER_CHESTPLATE) {
              player.damage(0);
              freezoMeter = 100;
            } else if (freezoMeter < 0 && playerChest == Material.IRON_CHESTPLATE
                || playerChest == Material.GOLD_CHESTPLATE) {
              player.damage(15);
              freezoMeter = 100;
            } else if (freezoMeter < 0 && playerChest == Material.DIAMOND_CHESTPLATE) {
              player.damage(10);
              freezoMeter = 100;
            }
          }
        },
        10L,
        20L * 30);
  }
예제 #2
0
 @EventHandler
 public void WeatherChange(WeatherChangeEvent e) {
   BukkitScheduler scheduler = Bukkit.getServer().getScheduler();
   scheduler.scheduleSyncRepeatingTask(
       main,
       new Runnable() {
         @Override
         public void run() {
           boolean weather = Bukkit.getWorlds().get(0).hasStorm();
           if (weather) {
             PlayerFreezing();
           }
         }
       },
       0L,
       20L);
 }
예제 #3
0
  @Override
  public void onEnable() {
    // Setup Permissions
    setupPermissions();

    // Create new configuration file
    FileConfiguration config = getConfig();
    File VanishNoPickup = new File(getDataFolder(), "config.yml");

    // Load the config if it's there
    try {
      config.load(VanishNoPickup);
    } catch (Exception ex) {
      // Ignore the errors
    }

    // Load our variables from configuration
    RANGE = config.getInt("range", 512);
    RANGE_SQUARED = RANGE * RANGE;
    REFRESH_TIMER = config.getInt("refresh_delay", 20);

    // Save the configuration(especially if it wasn't before)
    try {
      config.save(VanishNoPickup);
    } catch (Exception ex) {
      // Ignore the errors
    }
    PluginManager pm = getServer().getPluginManager();
    pm.registerEvents(entityListener, this);
    pm.registerEvents(playerListener, this);

    log.info("[" + getDescription().getName() + "] " + getDescription().getVersion() + " enabled.");

    scheduler = getServer().getScheduler();

    // Scheduler is set to update all invisible player statuses every 20 seconds?!  That seems like
    // a lot.
    scheduler.scheduleSyncRepeatingTask(
        this, new UpdateInvisibleTimerTask(), 10, 20 * REFRESH_TIMER);
  }