Package com.tommytony.war.utility

Examples of com.tommytony.war.utility.LoadoutSelection


    }
   
    boolean isFirstRespawn = false;
    if (!this.getLoadoutSelections().keySet().contains(player.getName())) {
      isFirstRespawn = true;
      this.getLoadoutSelections().put(player.getName(), new LoadoutSelection(true, 0));
    } else if (this.isReinitializing) {
      isFirstRespawn = true;
      this.getLoadoutSelections().get(player.getName()).setStillInSpawn(true);
    } else {
      this.getLoadoutSelections().get(player.getName()).setStillInSpawn(true);
View Full Code Here


    }
    return authors;
  }

  public void equipPlayerLoadoutSelection(Player player, Team playerTeam, boolean isFirstRespawn, boolean isToggle) {
    LoadoutSelection selection = this.getLoadoutSelections().get(player.getName());
    if (selection != null && !this.isRespawning(player) && playerTeam.getPlayers().contains(player)) {
      // Make sure that inventory resets dont occur if player has already tp'ed out (due to game end, or somesuch)
      // - repawn timer + this method is why inventories were getting wiped as players exited the warzone.
      List<Loadout> loadouts = playerTeam.getInventories().resolveNewLoadouts();
      List<String> sortedNames = LoadoutYmlMapper.sortNames(Loadout.toLegacyFormat(loadouts));
      sortedNames.remove("first");
      for (Iterator<String> it = sortedNames.iterator(); it.hasNext();) {
        String loadoutName = it.next();
        Loadout ldt = Loadout.getLoadout(loadouts, loadoutName);
        if (ldt.requiresPermission() && !player.hasPermission(ldt.getPermission())) {
          it.remove();
        }
      }
      if (sortedNames.isEmpty()) {
        // Fix for zones that mistakenly only specify a `first' loadout, but do not add any others.
        this.resetInventory(playerTeam, player, Collections.<Integer, ItemStack>emptyMap());
        War.war.msg(player, "404 No loadouts found");
        return;
      }
      int currentIndex = selection.getSelectedIndex();
      Loadout firstLoadout = Loadout.getLoadout(loadouts, "first");
      int i = 0;
      Iterator<String> it = sortedNames.iterator();
      while (it.hasNext()) {
        String name = (String) it.next();
View Full Code Here

          playerWarzone.respawnPlayer(event, playerTeam, event.getPlayer());
          return;
        }
      }
           
      LoadoutSelection loadoutSelectionState = playerWarzone.getLoadoutSelections().get(player.getName());
      FlagReturn flagReturn = playerTeam.getTeamConfig().resolveFlagReturn();
      if (!playerTeam.isSpawnLocation(playerLoc)) {
        if (!playerWarzone.isEnoughPlayers() && loadoutSelectionState != null && loadoutSelectionState.isStillInSpawn()) {
          // Be sure to keep only players that just respawned locked inside the spawn for minplayer/minteams restrictions - otherwise
          // this will conflict with the can't-renter-spawn bump just a few lines below 
          War.war.badMsg(player, "zone.spawn.minplayers", playerWarzone.getWarzoneConfig().getInt(WarzoneConfig.MINPLAYERS),
              playerWarzone.getWarzoneConfig().getInt(WarzoneConfig.MINTEAMS));
          event.setTo(playerTeam.getRandomSpawn());
          return;
        }
        if (playerWarzone.isRespawning(player)) {
          int rt = playerTeam.getTeamConfig().resolveInt(TeamConfig.RESPAWNTIMER);
          War.war.badMsg(player, "zone.spawn.timer", rt);
          event.setTo(playerTeam.getRandomSpawn());
          return;
        }
        if (playerWarzone.isReinitializing()) {
          // don't let players wander about outside spawns during reset
          // (they could mess up the blocks that have already been reset
          // before the start of the new battle)
          War.war.msg(player, "zone.battle.reset");
          event.setTo(playerTeam.getRandomSpawn());
          return;
        }
      } else if (loadoutSelectionState != null && !loadoutSelectionState.isStillInSpawn()
          && !playerWarzone.isCakeThief(player.getName())
          && (flagReturn.equals(FlagReturn.BOTH) || flagReturn.equals(FlagReturn.SPAWN))
          && !playerWarzone.isFlagThief(player.getName())) {
       
        // player is in spawn, but has left already: he should NOT be let back in - kick him out gently
View Full Code Here

      Warzone playerWarzone = Warzone.getZoneByLocation(event.getPlayer());
      Team playerTeam = Team.getTeamByPlayerName(event.getPlayer().getName());
      if (playerWarzone != null && playerTeam != null && playerTeam.getInventories().resolveLoadouts().keySet().size() > 1 && playerTeam.isSpawnLocation(event.getPlayer().getLocation())) {
        if (playerWarzone.getLoadoutSelections().keySet().contains(event.getPlayer().getName())
            && playerWarzone.getLoadoutSelections().get(event.getPlayer().getName()).isStillInSpawn()) {
          LoadoutSelection selection = playerWarzone.getLoadoutSelections().get(event.getPlayer().getName());
          List<Loadout> loadouts = new ArrayList<Loadout>(playerTeam.getInventories().resolveNewLoadouts());
          for (Iterator<Loadout> it = loadouts.iterator(); it.hasNext();) {
            Loadout ldt = it.next();
            if (ldt.getName().equals("first") ||
                (ldt.requiresPermission() && !event.getPlayer().hasPermission(ldt.getPermission()))) {
              it.remove();
            }
          }
          int currentIndex = (selection.getSelectedIndex() + 1) % loadouts.size();
          selection.setSelectedIndex(currentIndex);

          playerWarzone.equipPlayerLoadoutSelection(event.getPlayer(), playerTeam, false, true);
        } else {
          War.war.badMsg(event.getPlayer(), "zone.loadout.reenter");
        }
View Full Code Here

      Team defenderTeam = Team.getTeamByPlayerName(d.getName());
     
      if ((attackerTeam != null && defenderTeam != null && attackerTeam != defenderTeam && attackerWarzone == defenderWarzone)
          || (attackerTeam != null && defenderTeam != null && attacker.getEntityId() == defender.getEntityId())) {
       
        LoadoutSelection defenderLoadoutState = defenderWarzone.getLoadoutSelections().get(d.getName());
        if (defenderLoadoutState != null && defenderLoadoutState.isStillInSpawn()) {
          War.war.badMsg(a, "pvp.target.spawn");
          event.setCancelled(true);
          return;
        }
       
        LoadoutSelection attackerLoadoutState = attackerWarzone.getLoadoutSelections().get(a.getName());
        if (attackerLoadoutState != null && attackerLoadoutState.isStillInSpawn()) {
          War.war.badMsg(a, "pvp.self.spawn");
          event.setCancelled(true);
          return;
        }
       
        // Make sure none of them are locked in by respawn timer
        if (defenderWarzone.isRespawning(d)) {
          War.war.badMsg(a, "pvp.target.respawn");
          event.setCancelled(true);
          return;
        } else if (attackerWarzone.isRespawning(a)) {
          War.war.badMsg(a, "pvp.self.respawn");
          event.setCancelled(true);
          return;
        }
       
        if (!attackerWarzone.getWarzoneConfig().getBoolean(WarzoneConfig.PVPINZONE)) {
          // spleef-like, non-pvp, zone
          event.setCancelled(true);
          return;
        }

        // Detect death, prevent it and respawn the player
        if (event.getDamage() >= d.getHealth()) {
          if (defenderWarzone.getReallyDeadFighters().contains(d.getName())) {
            // don't re-kill a dead person       
            return;
          }
          WarPlayerDeathEvent event1 = new WarPlayerDeathEvent(defenderWarzone, d, a, event.getCause());
          War.war.getServer().getPluginManager().callEvent(event1);
          if (!defenderWarzone.getWarzoneConfig().getBoolean(WarzoneConfig.REALDEATHS)) {
            // fast respawn, don't really die
            event.setCancelled(true);
          }
          if (d == a) {
            defenderWarzone.handleSuicide(d);
          } else {
            defenderWarzone.handleKill(a, d, event.getDamager());
          }
        } else if (defenderWarzone.isBombThief(d.getName()) && d.getLocation().distance(a.getLocation()) < 2) {
          // Close combat, close enough to detonate         
          Bomb bomb = defenderWarzone.getBombForThief(d.getName());
                   
          // Kill the bomber
          WarPlayerDeathEvent event1 = new WarPlayerDeathEvent(defenderWarzone, d, null, event.getCause());
          War.war.getServer().getPluginManager().callEvent(event1);
          defenderWarzone.handleDeath(d);
         
          if (defenderWarzone.getWarzoneConfig().getBoolean(WarzoneConfig.REALDEATHS)) {
            // and respawn him and remove from deadmen (cause realdeath + handleDeath means no respawn and getting queued up for onPlayerRespawn)
            defenderWarzone.getReallyDeadFighters().remove(d.getName());
            defenderWarzone.respawnPlayer(defenderTeam, d);
          }
         
          // Blow up bomb
          if (!defenderWarzone.getWarzoneConfig().getBoolean(WarzoneConfig.UNBREAKABLE)) {
            defenderWarzone.getWorld().createExplosion(a.getLocation(), 2F);
          }

          // bring back tnt
          bomb.getVolume().resetBlocks();
          bomb.addBombBlocks();
         
          // Notify everyone
          for (Team t : defenderWarzone.getTeams()) {
            t.sendAchievement(attackerTeam.getKind().getColor() + a.getName() + ChatColor.YELLOW + " made ",
                defenderTeam.getKind().getColor() + d.getName() + ChatColor.YELLOW + " blow up!", new ItemStack(Material.TNT), 10000);
            t.teamcast("pvp.kill.bomb", attackerTeam.getKind().getColor() + a.getName() + ChatColor.WHITE,
                defenderTeam.getKind().getColor() + d.getName() + ChatColor.WHITE);
          }
        }
      } else if (attackerTeam != null && defenderTeam != null && attackerTeam == defenderTeam && attackerWarzone == defenderWarzone && attacker.getEntityId() != defender.getEntityId()) {
        // same team, but not same person
        if (attackerWarzone.getWarzoneConfig().getBoolean(WarzoneConfig.FRIENDLYFIRE)) {
          War.war.badMsg(a, "pvp.ff.enabled"); // if ff is on, let the attack go through
        } else {
          War.war.badMsg(a, "pvp.ff.disabled");
          event.setCancelled(true); // ff is off
        }
      } else if (attackerTeam == null && defenderTeam == null && War.war.canPvpOutsideZones(a)) {
        // let normal PVP through is its not turned off or if you have perms
      } else if (attackerTeam == null && defenderTeam == null && !War.war.canPvpOutsideZones(a)) {
        if (!War.war.getWarConfig().getBoolean(WarConfig.DISABLEPVPMESSAGE)) {
          War.war.badMsg(a, "pvp.outside.permission");
        }
       
        event.setCancelled(true); // global pvp is off
      } else {
        if (attackerTeam == null) {
          War.war.badMsg(a, "pvp.self.notplaying");
        } else if (defenderTeam == null) {
          War.war.badMsg(a, "pvp.target.notplaying");
        } else if (attacker != null && defender != null && attacker.getEntityId() == defender.getEntityId()) {
          // You just hit yourself, probably with a bouncing arrow
        } else if (attackerTeam == defenderTeam) {
          War.war.badMsg(a, "pvp.ff.disabled");
        } else if (attackerWarzone != defenderWarzone) {
          War.war.badMsg(a, "pvp.target.otherzone");
        }

        event.setCancelled(true); // can't attack someone inside a warzone if you're not in a team
      }
    } else if (defender instanceof Player) {
      // attacked by dispenser arrow most probably
      // Detect death, prevent it and respawn the player
      Player d = (Player) defender;
      Warzone defenderWarzone = Warzone.getZoneByPlayerName(d.getName());
      if (d != null && defenderWarzone != null && event.getDamage() >= d.getHealth()) {
        LoadoutSelection defenderLoadoutState = defenderWarzone.getLoadoutSelections().get(d.getName());
        if (defenderLoadoutState != null && defenderLoadoutState.isStillInSpawn()) {
          event.setCancelled(true);
          return;
        }
        if (defenderWarzone.getReallyDeadFighters().contains(d.getName())) {
          // don't re-kill a dead person
View Full Code Here

      this.handlerAttackDefend((EntityDamageByEntityEvent) event);
    } else  {
      Team team = Team.getTeamByPlayerName(player.getName());
     
      if (zone != null && team != null) {
        LoadoutSelection playerLoadoutState = zone.getLoadoutSelections().get(player.getName());
        if (team.isSpawnLocation(player.getLocation())
            && playerLoadoutState != null && playerLoadoutState.isStillInSpawn()) {
          // don't let a player still in spawn get damaged
          event.setCancelled(true);
        } else if (event.getDamage() >= player.getHealth()) {
          if (zone.getReallyDeadFighters().contains(player.getName())) {
            // don't re-count the death points of an already dead person
View Full Code Here

TOP

Related Classes of com.tommytony.war.utility.LoadoutSelection

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.