Package com.massivecraft.mcore.ps

Examples of com.massivecraft.mcore.ps.PS


  {
    // Args
    Faction faction = this.arg(0, ARFaction.get(usenderFaction), usenderFaction);
    if (faction == null) return;
   
    PS newHome = PS.valueOf(me.getLocation());
   
    // Validate
    if ( ! UConf.get(faction).homesEnabled)
    {
      usender.msg("<b>Sorry, Faction homes are disabled on this server.");
View Full Code Here


      return false;
    }
   
    // Pre Calculations
    String worldDisplayName = Mixin.getWorldDisplayName(worldId);
    PS current = this.getWorldSpawnPs(worldId);
    String currentFormatted = current.toString(PSFormatDesc.get());
    String goalFormatted = goal.toString(PSFormatDesc.get());
   
    // No change?
    if (MUtil.equals(goal, current))
    {
View Full Code Here

    for (Entry<PS, TerritoryAccess> entry : this.map.entrySet())
    {
      TerritoryAccess territoryAccess = entry.getValue();
      if ( ! territoryAccess.getHostFactionId().equals(factionId)) continue;
     
      PS ps = entry.getKey();
      this.removeAt(ps);
    }
  }
View Full Code Here

    {
      TerritoryAccess territoryAccess = entry.getValue();
      String factionId = territoryAccess.getHostFactionId();
      if (factionColl.containsId(factionId)) continue;
     
      PS ps = entry.getKey();
      this.removeAt(ps);
     
      Factions.get().log("Board cleaner removed "+factionId+" from "+ps);
    }
  }
View Full Code Here

    for (Entry<PS, TerritoryAccess> entry : this.map.entrySet())
    {
      TerritoryAccess ta = entry.getValue();
      if (!ta.getHostFactionId().equals(factionId)) continue;
     
      PS ps = entry.getKey();
      ps = ps.withWorld(this.getId());
      ret.add(ps);
    }
    return ret;
  }
View Full Code Here

  @Override
  public boolean isBorderPs(PS ps)
  {
    ps = ps.getChunk(true);
   
    PS nearby = null;
    Faction faction = this.getFactionAt(ps);
   
    nearby = ps.withChunkX(ps.getChunkX() +1);
    if (faction != this.getFactionAt(nearby)) return true;
   
View Full Code Here

  @Override
  public boolean isConnectedPs(PS ps, Faction faction)
  {
    ps = ps.getChunk(true);
   
    PS nearby = null;
   
    nearby = ps.withChunkX(ps.getChunkX() +1);
    if (faction == this.getFactionAt(nearby)) return true;
   
    nearby = ps.withChunkX(ps.getChunkX() -1);
View Full Code Here

    ret.add(Txt.titleize("("+centerPs.getChunkX() + "," + centerPs.getChunkZ()+") "+centerFaction.getName(observer)));
   
    int halfWidth = Const.MAP_WIDTH / 2;
    int halfHeight = Const.MAP_HEIGHT / 2;
   
    PS topLeftPs = centerPs.plusChunkCoords(-halfWidth, -halfHeight);
   
    int width = halfWidth * 2 + 1;
    int height = halfHeight * 2 + 1;
   
    // Make room for the list of names
    height--;
   
    Map<Faction, Character> fList = new HashMap<Faction, Character>();
    int chrIdx = 0;
   
    // For each row
    for (int dz = 0; dz < height; dz++)
    {
      // Draw and add that row
      String row = "";
      for (int dx = 0; dx < width; dx++)
      {
        if(dx == halfWidth && dz == halfHeight)
        {
          row += ChatColor.AQUA+"+";
          continue;
        }
     
        PS herePs = topLeftPs.plusChunkCoords(dx, dz);
        Faction hereFaction = this.getFactionAt(herePs);
        if (hereFaction.isNone())
        {
          row += ChatColor.GRAY+"-";
        }
View Full Code Here

    }
  }
 
  public boolean tryClaim(Faction newFaction, PS ps, boolean verbooseChange, boolean verbooseSame)
  {
    PS chunk = ps.getChunk(true);
    Faction oldFaction = BoardColls.get().getFactionAt(chunk);
   
    UConf uconf = UConf.get(newFaction);
    MConf mconf = MConf.get();
   
    // Validate
    if (newFaction == oldFaction)
    {
      msg("%s<i> already owns this land.", newFaction.describeTo(this, true));
      return true;
    }
   
    if (!this.isUsingAdminMode())
    {
      if (newFaction.isNormal())
      {
        if (mconf.worldsNoClaiming.contains(ps.getWorld()))
        {
          msg("<b>Sorry, this world has land claiming disabled.");
          return false;
        }
       
        if (!FPerm.TERRITORY.has(this, newFaction, true))
        {
          return false;
        }
       
        if (newFaction.getUPlayers().size() < uconf.claimsRequireMinFactionMembers)
        {
          msg("Factions must have at least <h>%s<b> members to claim land.", uconf.claimsRequireMinFactionMembers);
          return false;
        }
       
        int ownedLand = newFaction.getLandCount();
       
        if (uconf.claimedLandsMax != 0 && ownedLand >= uconf.claimedLandsMax && ! newFaction.getFlag(FFlag.INFPOWER))
        {
          msg("<b>Limit reached. You can't claim more land.");
          return false;
        }
       
        if (ownedLand >= newFaction.getPowerRounded())
        {
          msg("<b>You can't claim more land. You need more power.");
          return false;
        }
       
        if
        (
          uconf.claimsMustBeConnected
          &&
          newFaction.getLandCountInWorld(ps.getWorld()) > 0
          &&
          !BoardColls.get().isConnectedPs(chunk, newFaction)
          &&
          (!uconf.claimsCanBeUnconnectedIfOwnedByOtherFaction || oldFaction.isNone())
        )
        {
          if (uconf.claimsCanBeUnconnectedIfOwnedByOtherFaction)
          {
            msg("<b>You can only claim additional land which is connected to your first claim or controlled by another faction!");
          }
          else
          {
            msg("<b>You can only claim additional land which is connected to your first claim!");
          }
          return false;
        }
      }
     
      if (oldFaction.isNormal())
      {
        if (!FPerm.TERRITORY.has(this, oldFaction, false))
        {
          if (!uconf.claimingFromOthersAllowed)
          {
            msg("<b>You may not claim land from others.");
            return false;
          }
         
          if (oldFaction.getRelationTo(newFaction).isAtLeast(Rel.TRUCE))
          {
            msg("<b>You can't claim this land due to your relation with the current owner.");
            return false;
          }
         
          if (!oldFaction.hasLandInflation())
          {
            msg("%s<i> owns this land and is strong enough to keep it.", oldFaction.getName(this));
            return false;
          }
         
          if ( ! BoardColls.get().isBorderPs(chunk))
          {
            msg("<b>You must start claiming land at the border of the territory.");
            return false;
          }
        }
      }
    }
   
    // Event
    FactionsEventChunkChange event = new FactionsEventChunkChange(sender, chunk, newFaction);
    event.run();
    if (event.isCancelled()) return false;

    // Apply
    BoardColls.get().setFactionAt(chunk, newFaction);
   
    // Inform
    Set<UPlayer> informees = new HashSet<UPlayer>();
    informees.add(this);
    if (newFaction.isNormal())
    {
      informees.addAll(newFaction.getUPlayers());
    }
    if (oldFaction.isNormal())
    {
      informees.addAll(oldFaction.getUPlayers());
    }
    if (MConf.get().logLandClaims)
    {
      informees.add(UPlayer.get(SenderUtil.getConsole()));
    }
   
    String chunkString = chunk.toString(PSFormatHumanSpace.get());
    String typeString = event.getType().toString().toLowerCase();
    for (UPlayer informee : informees)
    {
      informee.msg("<h>%s<i> did %s %s <i>for <h>%s<i> from <h>%s<i>.", this.describeTo(informee, true), typeString, chunkString, newFaction.describeTo(informee), oldFaction.describeTo(informee));
    }
View Full Code Here

    for (Entry<String, JsonElement> entry : jsonObject.entrySet())
    {
      String[] ChunkCoordParts = entry.getKey().split("[,\\s]+");
      int chunkX = Integer.parseInt(ChunkCoordParts[0]);
      int chunkZ = Integer.parseInt(ChunkCoordParts[1]);
      PS chunk = PS.valueOf(chunkX, chunkZ);
     
      TerritoryAccess territoryAccess = context.deserialize(entry.getValue(), TerritoryAccess.class);
     
      ret.put(chunk, territoryAccess);
    }
View Full Code Here

TOP

Related Classes of com.massivecraft.mcore.ps.PS

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.