Exemplo n.º 1
0
  @Override
  public void onCommand(Player p, String[] args) {
    if (!p.hasPermission("ugungame.setspawn")) {
      MessageManager.bad(p, "You dont have the permission to do this!");
      return;
    }

    if (args.length < 2) {
      MessageManager.bad(p, usage + "setspawn <arena> <mapid(1|2)>");
      return;
    }

    if (!ArenaManager.getInstance().isExist(args[0])) {
      MessageManager.bad(p, "§cThe arena §6" + args[0] + " §cdoes not exist!");
      return;
    }

    Arena a = ArenaManager.getInstance().getArena(args[0]);

    if (args[1].equalsIgnoreCase("1")) {
      a.getCfg().set("locations.spawns.spawn.map1.world", p.getLocation().getWorld().getName());
      a.getCfg().set("locations.spawns.spawn.map1.x", Double.valueOf(p.getLocation().getX()));
      a.getCfg().set("locations.spawns.spawn.map1.y", Double.valueOf(p.getLocation().getY()));
      a.getCfg().set("locations.spawns.spawn.map1.z", Double.valueOf(p.getLocation().getZ()));
      a.getCfg().set("locations.spawns.spawn.map1.yaw", Float.valueOf(p.getLocation().getYaw()));
      a.getCfg()
          .set("locations.spawns.spawn.map1.pitch", Float.valueOf(p.getLocation().getPitch()));
      try {
        a.getCfg().save(a.getFile());
        MessageManager.good(
            p, "The spawn for arena §6" + a.getName() + " §aand for the map §61 §ahas been set!");
      } catch (IOException e) {
        e.printStackTrace();
      }
    } else if (args[1].equalsIgnoreCase("2")) {
      a.getCfg().set("locations.spawns.spawn.map2.world", p.getLocation().getWorld().getName());
      a.getCfg().set("locations.spawns.spawn.map2.x", Double.valueOf(p.getLocation().getX()));
      a.getCfg().set("locations.spawns.spawn.map2.y", Double.valueOf(p.getLocation().getY()));
      a.getCfg().set("locations.spawns.spawn.map2.z", Double.valueOf(p.getLocation().getZ()));
      a.getCfg().set("locations.spawns.spawn.map2.yaw", Float.valueOf(p.getLocation().getYaw()));
      a.getCfg()
          .set("locations.spawns.spawn.map2.pitch", Float.valueOf(p.getLocation().getPitch()));
      try {
        a.getCfg().save(a.getFile());
        MessageManager.good(
            p, "The spawn for arena §6" + a.getName() + " §aand for the map §62 §ahas been set!");
      } catch (IOException e) {
        e.printStackTrace();
      }
    }
  }
Exemplo n.º 2
0
  @EventHandler(priority = EventPriority.MONITOR)
  public void onDeath(PlayerDeathEvent e) {
    final Player ent = (Player) e.getEntity();
    Player killer = (Player) e.getEntity().getKiller();
    if (ArenaManager.getInstance().getPlayerArena(e.getEntity()) != null) {
      Arena a =
          ArenaManager.getInstance()
              .getArena(ArenaManager.getInstance().getPlayerArena(e.getEntity()));

      e.getDrops().clear();
      e.setDeathMessage(null);
      e.setDroppedExp(0);
      if (a.getArenaState() != ArenaState.STARTED) {
        return;
      }

      a.removeLevel(ent);

      // TODO: Death message.
      e.setDeathMessage(
          UGunGame.getInstance().prefix + "§e" + ent.getName() + " killed by " + killer.getName());

      MessageManager.good(killer, "You got §6" + a.getCfg().getInt("arena.money.add") + " §aUGP!");
      MessageManager.bad(ent, "You lost §6" + a.getCfg().getInt("arena.money.remove") + " §cUGP!");

      ScoreboardStats.addMoney(a, killer);
      ScoreboardStats.removeMoney(a, ent);
      ScoreboardStats.createScoreboard(killer);
      ScoreboardStats.createScoreboard(ent);
    }

    if (killer == null) {
      return;
    }

    if (ArenaManager.getInstance().getPlayerArena(killer) != null) {
      Arena a =
          ArenaManager.getInstance().getArena(ArenaManager.getInstance().getPlayerArena(killer));
      if (a.getArenaState() != ArenaState.STARTED) {
        return;
      }

      killer.getInventory().clear();
      killer.getInventory().setArmorContents(null);
      a.addLevel(killer);
    }
  }
Exemplo n.º 3
0
  @Override
  public void onCommand(Player p, String[] args) {
    if (!p.hasPermission("ugungame.create")) {
      MessageManager.bad(p, "You dont have the permission to do this!");
      return;
    }

    if (args.length < 1) {
      MessageManager.bad(p, usage + "create <arena>");
      return;
    }

    if (ArenaManager.getInstance().isExist(args[0])) {
      MessageManager.bad(p, "The arena §6" + args[0] + " §cdoes already exists!");
      return;
    }

    Arena a = new Arena(args[0]);
    ArenaManager.getInstance().addArena(a);
    MessageManager.good(p, "The arena §6" + a.getName() + " §ahas been created!");
  }