コード例 #1
0
  /** Pickup * */
  @EventHandler
  public void onPickup(PlayerPickupItemEvent e) {
    /** Lobby * */
    if (Main.getState() == GameState.LOBBY) e.setCancelled(true);

    /** Spectator * */
    if (Game.spectators.contains(e.getPlayer().getName())) e.setCancelled(true);

    /** Remove dropped item in arrayList * */
    if (IngameState.dropped_items.containsValue(e.getItem())) {
      IngameState.dropped_items.remove(e.getItem());
    }
  }
コード例 #2
0
  /** Constructor * */
  public LobbyState() {
    /** Set state * */
    Main.setState(GameState.LOBBY);

    /** Team selection * */
    TeamSelection.setup();

    /** Location * */
    location = GameConfiguration.getLocation(Main.getPlugin().getConfig(), "lobby.position");

    /** Time * */
    time = Main.getPlugin().getConfig().getInt("lobby.time");

    /** Minimal players * */
    minimalplayers = Main.getPlugin().getConfig().getInt("lobby.minimal-players");

    /** Current time * */
    currenttime = time;

    /** Scheduler * */
    new BukkitRunnable() {
      public void run() {
        /** Set level and EXP * */
        for (Player p : Bukkit.getOnlinePlayers()) {
          /** Set exp * */
          p.setExp((1f / time) * currenttime);

          /** Set level * */
          p.setLevel(currenttime);
        }

        /** Sound * */
        if (currenttime % 15 == 0 || currenttime <= 5) {
          /** Broadcast * */
          if (currenttime != 0)
            Bukkit.broadcastMessage(
                Main.prefix + "Das Spiel beginnt in §e" + currenttime + " Sekunden§7.");

          for (Player p : Bukkit.getOnlinePlayers()) {
            /** Play sound * */
            p.playSound(p.getLocation(), Sound.NOTE_PLING, 1, 3);
          }
        }

        /** Check time * */
        if (currenttime == 0) {
          if (Bukkit.getOnlinePlayers().size() >= minimalplayers) {
            /** Ingame state * */
            new IngameState();

            /** Cancel * */
            cancel();
          } else {
            /** Set time * */
            currenttime = time - 1;

            /** Broadcast * */
            Bukkit.broadcastMessage(
                Main.prefix
                    + "Es fehlen noch §e"
                    + (minimalplayers - Bukkit.getOnlinePlayers().size())
                    + " §7Spieler!");

            /** Set level and exp * */
            for (Player p : Bukkit.getOnlinePlayers()) {
              /** Play sound * */
              p.playSound(p.getLocation(), Sound.NOTE_PLING, 1, 0);
            }
          }
        }

        /** Subtract time * */
        currenttime--;
      }
    }.runTaskTimer(Main.getPlugin(), 0L, 20L);
  }