예제 #1
0
  @Override
  public void startEvent() {
    super.startEvent();
    Server server = Bukkit.getServer();

    int osize = teams.size();
    nrounds = getNRounds(osize);
    int nteams = (int) Math.pow(2, nrounds);
    server.broadcastMessage(
        Log.colorChat(
            eventParams.getPrefix()
                + "&e The "
                + eventParams.toPrettyString()
                + oParms.getName()
                + " tournament is starting!"));

    preliminary_round = teams.size() != nteams;
    if (preliminary_round) nrounds++;

    TreeMap<Double, Team> sortTeams = new TreeMap<Double, Team>(Collections.reverseOrder());
    BTInterface bti = new BTInterface(eventParams);
    //		System.out.println("startEvent:: bti=" + bti);
    for (Team t : teams) {
      Double elo = Defaults.DEFAULT_ELO;
      if (bti.isValid()) {
        elo = (double) bti.getElo(t);
      }
      while (sortTeams.containsKey(elo)) {
        elo += 0.0001;
      }
      sortTeams.put(elo, t);
    }
    competingTeams.addAll(teams);
    teams.clear();
    aliveTeams.clear();
    ArrayList<Team> ts = new ArrayList<Team>(sortTeams.values());
    for (Team t : ts) {
      teams.add(t);
      aliveTeams.add(t);
    }
    server.broadcastMessage(
        Log.colorChat(
            eventParams.getPrefix()
                + "&6 "
                + teams.size()
                + " &e"
                + MessageUtil.getTeamsOrPlayers(teams.size())
                + " will compete in a &6"
                + nrounds
                + "&e round tournament"));
    if (preliminary_round) {
      makePreliminaryRound();
    } else {
      makeNextRound();
    }
    startRound();
  }
예제 #2
0
  public void startGame() {
    state = State.IN_GAME;

    for (Tribute t : ServerGames.tributes) {
      t.player.setHealth(20);
      t.player.setFoodLevel(20);
      clearItems(t.player);
      if (!t.player.isOnline()) {
        ServerGames.tributes.remove(t);
      }
    }

    loaded.clear();
    Chests.resetChests();

    bets.clear();

    clearAll();
    load();

    for (Player p : getCorn().getWorld().getPlayers()) {
      p.setCompassTarget(getCorn());
    }

    server.broadcastMessage(GOLD + "[ServerGames]" + GREEN + " Let the game begin!");

    game = new Game(this);

    startTimer();
  }
예제 #3
0
  public void startLobby() {
    server.broadcastMessage(GOLD + "[ServerGames]" + GREEN + " Countdown started.");

    clearAll();

    bets.clear();
    this.clearEnt();
    load();
    tpAll(waiting);
    ServerGames.current = worlds.get(new Random().nextInt(ServerGames.worlds.size()));

    for (Player p : server.getOnlinePlayers()) {
      showAllFor(p);
      showPlayer(p);

      if (isTribute(p) || isSpectator(p)) clearItems(p);
    }

    loaded.clear();

    this.resetPlayers();

    state = State.LOBBY;
    game = new Lobby(this);

    startTimer();
  }
예제 #4
0
  @Override
  public final boolean onCommand(
      final CommandSender commandSender,
      final Command command,
      final String label,
      final String[] args) {
    final String senderName = commandSender.getName();
    final Server server = Bukkit.getServer();
    final Player sender = server.getPlayer(senderName);

    if (sender.hasPermission("udsplugin.lockdown")) {
      if (args.length == 0) {
        if (!UDSPlugin.getServerInLockdown()) {
          UDSPlugin.setServerInLockdown(true);
          UDSPlugin.getPlayers().get(senderName).setLockdownPass(true);
          server.broadcastMessage(Color.BROADCAST + "Server is now in lockdown.");
        } else {
          UDSPlugin.setServerInLockdown(false);
          server.broadcastMessage(Color.BROADCAST + "Server is no longer in lockdown.");
          for (Map.Entry<String, UDSPlayer> i : UDSPlugin.getPlayers().entrySet()) {
            i.getValue().setLockdownPass(false);
          }
        }
      } else if (args.length == 1) {
        final UDSPlayer serverPlayer = PlayerUtils.matchUDS(args[0]);
        if (serverPlayer != null) {

          final String targetName = serverPlayer.getNick();
          if (serverPlayer.hasLockdownPass()) {
            serverPlayer.setLockdownPass(false);
            sender.sendMessage(Color.MESSAGE + targetName + "'s lockdown pass has been removed.");
          } else {
            serverPlayer.setLockdownPass(true);
            sender.sendMessage(
                Color.MESSAGE + targetName + " has been issued with a lockdown pass.");
          }
        } else {
          sender.sendMessage(UDSMessage.NO_PLAYER);
        }
      } else {
        sender.sendMessage(UDSMessage.BAD_ARGS);
      }
    } else {
      sender.sendMessage(UDSMessage.NO_PERM);
    }
    return true;
  }
예제 #5
0
  @MatchEventHandler
  public void matchCompleted(MatchCompletedEvent event) {
    Match am = event.getMatch();
    MatchResult r = am.getResult();
    Matchup m = null;
    if (r.getVictors() != null && !r.getVictors().isEmpty()) {
      m = getMatchup(r.getVictors().iterator().next(), round);
    } else if (r.getLosers() != null && !r.getLosers().isEmpty()) {
      m = getMatchup(r.getLosers().iterator().next(), round);
    } else if (r.getDrawers() != null && !r.getDrawers().isEmpty()) {
      m = getMatchup(r.getDrawers().iterator().next(), round);
    }
    if (m == null) { // / This match wasnt in our tournament
      return;
    }
    if (am.getState() == MatchState.ONCANCEL) {
      endEvent();
      return;
    }
    Team victor = null;
    if (r.isDraw()) { // / match was a draw, pick a random lucky winner
      victor = pickRandomWinner(r, r.getDrawers());
    } else if (r.hasVictor() && r.getVictors().size() != 1) {
      victor = pickRandomWinner(r, r.getVictors());
    } else if (r.hasVictor()) {
      victor = r.getVictors().iterator().next(); // / single winner
    }
    m.setResult(r);
    for (Team t : r.getLosers()) {
      super.removeTeam(t);
    }
    aliveTeams.removeAll(r.getLosers());

    if (roundFinished()) {
      TimeUtil.testClock();
      if (Defaults.DEBUG) System.out.println("ROUND FINISHED !!!!!   " + aliveTeams);

      if (round + 1 == nrounds || isFinished()) {
        Server server = Bukkit.getServer();
        Team t = aliveTeams.get(0);
        server.broadcastMessage(
            Log.colorChat(
                eventParams.getPrefix()
                    + "&e Congratulations to &6"
                    + t.getDisplayName()
                    + "&e for winning!"));
        HashSet<Team> losers = new HashSet<Team>(competingTeams);
        losers.remove(victor);
        Set<Team> victors = new HashSet<Team>(Arrays.asList(victor));
        eventVictory(victors, losers);
        PerformTransition.transition(am, MatchState.FIRSTPLACE, t, false);
        PerformTransition.transition(am, MatchState.PARTICIPANTS, losers, false);
        eventCompleted();
      } else {
        makeNextRound();
        startRound();
      }
    }
  }
예제 #6
0
  @Override
  public boolean handleOther(Server server, String[] args) {
    String msg = argsToMessage(args);

    server.broadcastMessage("<" + BLUE + "GOD" + WHITE + "> " + LIGHT_PURPLE + msg);
    LOGGER.info("CONSOLE: <GOD> " + msg);

    return true;
  }
예제 #7
0
 public void onPlayerQuit_removePlayerOffTeam(ArenaPlayer arenaPlayer, PlayerQuitEvent event) {
   Server server = arenaPlayer.getPlayer().getServer();
   if (arenaGame.isOnRedTeam(arenaPlayer)) {
     arenaGame.getRedTeam().remove(arenaPlayer);
     server.broadcastMessage(
         ChatColor.RED
             + "Player "
             + arenaPlayer.getPlayer().getName()
             + " has been removed from RED team");
   } else {
     arenaGame.getBlueTeam().remove(arenaPlayer);
     server.broadcastMessage(
         ChatColor.BLUE
             + "Player "
             + arenaPlayer.getPlayer().getName()
             + " has been removed from BLUE team");
   }
 }
예제 #8
0
  @Override
  public boolean handlePlayer(TregminePlayer player, String[] args) {
    Server server = player.getServer();
    String msg = argsToMessage(args);

    server.broadcastMessage("<" + RED + "GOD" + WHITE + "> " + LIGHT_PURPLE + msg);

    LOGGER.info(player.getName() + ": <GOD> " + msg);

    Player[] players = server.getOnlinePlayers();
    for (Player p : players) {
      TregminePlayer current = tregmine.getPlayer((p.getName()));
      if (current.isAdmin()) {
        current.sendMessage(DARK_AQUA + "/say used by: " + player.getChatName());
      }
    }

    return true;
  }
예제 #9
0
  public void startDeath() {
    server.broadcastMessage(GOLD + "[ServerGames] " + RED + "Do not run from the deathmatch.");
    for (Tribute t : ServerGames.tributes) {
      if (!t.player.isDead()) {
        t.player.teleport(toCenter(t.start));
        tell(t.player, GOLD + "[ServerGames] " + GREEN + "You have made it to the deathmatch.");
      }
    }

    for (Spectator s : ServerGames.spectators) {
      if (!s.player.isDead()) s.player.teleport(ServerGames.getCorn());
    }

    clearAll();
    load();

    state = State.DEATHMATCH;
    game = new Deathmatch(this);

    startTimer();
  }
예제 #10
0
 @Override
 public int broadcastMessage(String message) {
   return server.broadcastMessage(message);
 }
예제 #11
0
 public int broadcastMessage(String message) {
   JSONAPI.instance.jsonServer.logChat("", message);
   return Server.broadcastMessage(message);
 }
예제 #12
0
  public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    if (plugin.getConfig().getBoolean("ENABLE_VOTE") == false) {
      sender.sendMessage(CraftEssence.premessage + "Voting is currently disabled.");
      return true;
    }

    if (!plugin.hasPerm(sender, "vote", false)) {
      sender.sendMessage(ChatColor.YELLOW + "You do not have permission to use /" + label);
      return true;
    }

    if (args.length == 0) {
      sender.sendMessage("-" + ChatColor.AQUA + "Vote Help" + ChatColor.WHITE + "-");
      sender.sendMessage("/vote day - 'Start a vote to change time to day.'");
      sender.sendMessage("/vote night - Start a vote to change time to night.");
      sender.sendMessage("/vote kick - 'Start a vote to kick a player.'");
      sender.sendMessage("/vote yes - 'To vote yes to a current vote in progress");
      sender.sendMessage("/vote no - 'To vote no to a current vote in progress");
      return true;
    }
    Player player = (Player) sender;
    World world = player.getWorld();
    Server srv = plugin.getServer();
    if (args[0].equalsIgnoreCase("kick")) {
      if (!plugin.hasPerm(sender, "vote.kick", false)) {
        sender.sendMessage(
            ChatColor.YELLOW + "You to dont have proper permissions for that command.");
        return true;
      }

      if (plugin.vote != null) {
        sender.sendMessage("A vote has already been started.");
        return true;
      }

      plugin.vote = args[0] + ":" + args[1];
      plugin.vuser.put(player.getName(), "yes");
      srv.broadcastMessage(
          CraftEssence.premessage
              + "A vote has started to kick "
              + args[1]
              + ", to vote type '/vote yes' or '/vote no'");
      plugin.startVoteTimer();
      return true;
    } else if (args[0].equalsIgnoreCase("day")) {
      if (!plugin.hasPerm(sender, "vote.day", false)) {
        sender.sendMessage(
            ChatColor.YELLOW + "You to dont have proper permissions for that command.");
        return true;
      }
      if (plugin.vote != null) {
        sender.sendMessage(CraftEssence.premessage + "A vote has already been started.");
        return true;
      }
      String wn = world.getName();
      plugin.vote = args[0] + ":" + wn;
      plugin.vuser.put(player.getName(), "yes");
      srv.broadcastMessage(
          CraftEssence.premessage
              + "A vote has started to make it day on "
              + wn
              + ", to vote type '/vote yes' or '/vote no'");
      plugin.startVoteTimer();
      return true;
    } else if (args[0].equalsIgnoreCase("night")) {
      if (!plugin.hasPerm(sender, "vote.night", false)) {
        sender.sendMessage(
            ChatColor.YELLOW + "You to dont have proper permissions for that command.");
        return true;
      }
      if (plugin.vote != null) {
        sender.sendMessage(CraftEssence.premessage + "A vote has already been started.");
        return true;
      }
      String wn = world.getName();
      plugin.vote = args[0] + ":" + wn;
      plugin.vuser.put(player.getName(), "yes");
      plugin.startVoteTimer();
      srv.broadcastMessage(
          CraftEssence.premessage
              + "A vote has started to make it night on "
              + wn
              + ", to vote type '/vote yes' or '/vote no'");
      return true;
    } else if (args[0].equalsIgnoreCase("yes")) {
      if (plugin.vote == null) {
        sender.sendMessage(CraftEssence.premessage + "There is nothing to vote on.");
        return true;
      }
      if (plugin.vuser.containsKey(player.getName())) {
        sender.sendMessage(CraftEssence.premessage + "You have already voted.");
        return true;
      }
      plugin.vuser.put(player.getName(), "yes");
      // Get total votes
      int yesno = plugin.vuser.values().size();
      srv.broadcastMessage(CraftEssence.premessage + "There are " + yesno + " votes so far.");

      return true;
    } else if (args[0].equalsIgnoreCase("no")) {
      if (plugin.vote == null) {
        sender.sendMessage(CraftEssence.premessage + "There is nothing to vote on.");
        return true;
      }
      return true;
    } else if (args[0].equalsIgnoreCase("clear")) {
      if (!plugin.hasPerm(sender, "vote.clear", false)) {
        sender.sendMessage(
            ChatColor.YELLOW + "You to dont have proper permissions for that command.");
        return true;
      }
      plugin.vote = null;
      plugin.vuser.clear();
      plugin
          .getServer()
          .broadcastMessage(CraftEssence.premessage + "Current vote timer has been stoped.");
      return true;
    } else {
      if (plugin.vote != null) {
        sender.sendMessage(CraftEssence.premessage + "A vote has already been started.");
        return true;
      } else {
        sender.sendMessage(CraftEssence.premessage + "The option you want to vote on is invalid.");
        return true;
      }
    }
  }
예제 #13
0
  @EventHandler
  public void matchCompleted(MatchCompletedEvent event) {
    if (!isRunning()) return;
    Match am = event.getMatch();
    Team victor = am.getVictor();
    Matchup m;
    if (victor == null) m = getMatchup(am.getResult().getLosers().iterator().next(), round);
    else m = getMatchup(victor, round);
    //		System.out.println("victor ===" + victor + "  am= " +am + " losers=" + am.getLosers() +"   m
    // = " + m +"   am.result="+am.getResult());
    if (m == null) { // / This match wasnt in our tournament
      return;
    }
    if (am.getState() == MatchState.ONCANCEL) {
      endEvent();
      return;
    }
    MatchResult r = am.getResult();
    if (victor == null) { // / match was a draw, pick a random lucky winner
      List<Team> ls = new ArrayList<Team>(am.getResult().getLosers());
      if (ls.isEmpty()) {
        Log.err("[BattleArena] Tournament found a match with no players, cancelling tournament");
        this.cancelEvent();
        return;
      }
      victor = ls.get(rand.nextInt(ls.size()));
      victor.sendMessage("&2You drew your match but have been randomly selected as the winner!");
      r.setVictor(victor);
      Set<Team> losers = new HashSet<Team>(ls);
      losers.remove(victor);
      r.setLosers(losers);
      for (Team l : losers) {
        l.sendMessage(
            "&cYou drew your match but someone else has been randomly selected as the winner!");
      }
    }
    m.setResult(r);
    for (Team t : r.getLosers()) {
      super.removeTeam(t);
    }
    aliveTeams.removeAll(r.getLosers());

    if (roundFinished()) {
      TimeUtil.testClock();
      if (Defaults.DEBUG) System.out.println("ROUND FINISHED !!!!!   " + aliveTeams);

      if (round + 1 == nrounds || isFinished()) {
        Server server = Bukkit.getServer();
        Team t = aliveTeams.get(0);
        server.broadcastMessage(
            Log.colorChat(
                eventParams.getPrefix()
                    + "&e Congratulations to &6"
                    + t.getDisplayName()
                    + "&e for winning!"));
        HashSet<Team> losers = new HashSet<Team>(competingTeams);
        losers.remove(victor);
        eventVictory(victor, losers);
        PerformTransition.transition(am, MatchState.FIRSTPLACE, t, false);
        PerformTransition.transition(am, MatchState.PARTICIPANTS, losers, false);
        eventCompleted();
      } else {
        makeNextRound();
        startRound();
      }
    }
  }
예제 #14
0
  public void startSetup() {
    clearAll();

    int i = 0;

    for (Player p : server.getOnlinePlayers()) {
      if (!isSpectator(p) && !isTribute(p)) {
        hidePlayer(p);
      }

      if (isTribute(p)) {
        if (i >= getTubes().size()) i = 0;

        Location to = getTubes().get(i);
        p.setHealth(20);
        p.setFoodLevel(20);
        p.setSprinting(false);
        p.setSneaking(false);
        p.setPassenger(null);
        p.setGameMode(GameMode.SURVIVAL);
        p.setFireTicks(0);
        clearItems(p);
        getTribute(p).start = to;
        p.teleport(toCenter(to));

        i++;
      }
    }

    for (String s : ServerGames.worlds) {
      World w = ServerGames.server.getWorld(s);
      w.getEntities().clear();
      w.setThundering(false);
      w.setTime(0);
      w.setWeatherDuration(0);
      w.setStorm(false);
    }

    // ----- WORLD RESETTING -----
    LogBlock logblock = (LogBlock) getServer().getPluginManager().getPlugin("LogBlock");
    QueryParams params = new QueryParams(logblock);

    params.world = getCorn().getWorld();
    params.silent = false;

    try {
      logblock.getCommandsHandler()
      .new CommandRollback(this.getServer().getConsoleSender(), params, false);
    } catch (Exception e) {
    }

    clearEnt();

    // ----- WORLD RESETTING -----

    server.broadcastMessage(DARK_AQUA + "This plugin was created by Brenhien and NerdsWBNerds.");
    server.broadcastMessage(
        DARK_AQUA
            + "Email [email protected] or tweet us (@NerdsWBNerds) with ideas or bugs you have found.");

    load();

    state = State.SET_UP;
    game = new Setup(this);

    startTimer();
  }