Ejemplo n.º 1
0
  @ArenaEventHandler
  public void matchComplete(MatchCompletedEvent event) {
    Match match = event.getMatch();
    Matchup matchup = matchups.remove(match);
    if (matchup == null) return;
    Duel d = ongoingDuels.remove(matchup);
    if (d == null) return;
    MatchResult mr = match.getResult();

    Double money = (Double) d.getDuelOptionValue(DuelOption.MONEY);
    if (money != null) {
      if (mr.hasVictor()) {
        Collection<ArenaTeam> winningTeams = mr.getVictors();
        int winningSize = 0;
        for (ArenaTeam winTeam : winningTeams) {
          winningSize += winTeam.size();
        }
        final double split = d.getTotalMoney() / winningSize;
        for (ArenaTeam winTeam : winningTeams) {
          for (ArenaPlayer ap : winTeam.getPlayers()) {
            MessageUtil.sendMessage(
                ap,
                "&4[Duel] &eYou have won &6"
                    + split
                    + " "
                    + Defaults.MONEY_STR
                    + "&e for your victory!");
            MoneyController.add(ap.getName(), split);
          }
        }
      } else {
        refundMoney(money, mr.getDrawers());
      }
    }
  }
Ejemplo n.º 2
0
 private boolean checkWager(Duel d) {
   Double wager = (Double) d.getDuelOptionValue(DuelOption.MONEY);
   if (wager == null) return true;
   HashSet<ArenaPlayer> players = new HashSet<ArenaPlayer>(d.getChallengedPlayers());
   players.addAll(d.getChallengerTeam().getPlayers());
   for (ArenaPlayer ap : players) {
     if (MoneyController.balance(ap.getName()) < wager) {
       MessageUtil.sendMessage(ap, "&4[Duel] &cYou don't have enough money to accept the wager!");
       cancelFormingDuel(
           d, "&4[Duel]&6" + ap.getDisplayName() + " didn't have enough money for the wager");
       return false;
     }
   }
   for (ArenaPlayer ap : players) {
     MessageUtil.sendMessage(
         ap,
         "&4[Duel] &6"
             + wager
             + " "
             + Defaults.MONEY_STR
             + "&e has been subtracted from your account");
     MoneyController.subtract(ap.getName(), wager);
   }
   d.setTotalMoney((wager) * players.size());
   return true;
 }
Ejemplo n.º 3
0
 @ArenaEventHandler
 public void matchCancelled(MatchCancelledEvent event) {
   Match match = event.getMatch();
   Matchup matchup = matchups.remove(match);
   if (matchup == null) return;
   Duel d = ongoingDuels.remove(matchup);
   if (d == null) return;
   Double money = (Double) d.getDuelOptionValue(DuelOption.MONEY);
   if (money != null) {
     refundMoney(money, match.getTeams());
   }
 }