Example #1
0
 public boolean rename(String landName) {
   if (LandProtection.getDataManager().renameLandFile(this, landName)) {
     this.landName = landName.toLowerCase();
     landFile = LandProtection.getDataManager().getLandFile(this.landName);
     configuration = new Configuration(landFile);
     config = configuration.getConfig();
     this.displayName = landName;
     this.config.set("AreaName", landName);
     this.configuration.saveConfig();
     return true;
   }
   return false;
 }
Example #2
0
  public LandData(String landName) {
    this.landName = landName;
    landFile = LandProtection.getDataManager().getLandFile(landName);
    configuration = new Configuration(landFile);

    config = configuration.getConfig();

    this.displayName = config.getString("AreaName");

    this.highX = config.getInt("Location.HighX");
    this.highY = config.getInt("Location.HighY");
    this.highZ = config.getInt("Location.HighZ");

    this.lowX = config.getInt("Location.LowX");
    this.lowY = config.getInt("Location.LowY");
    this.lowZ = config.getInt("Location.LowZ");

    this.worldName = config.getString("Location.World");

    this.teleportLocation =
        new Location(
            LandProtection.getInstance().getServer().getWorld(this.worldName),
            config.getInt("TPLocation.X"),
            config.getInt("TPLocation.Y"),
            config.getInt("TPLocation.Z"));

    this.creationDate = config.getLong("CreationDate");

    this.owner = UManager.getOfflineUser(UUID.fromString(config.getString("Owner")));

    this.enterMessage = config.getString("EnterMessage");
    this.leaveMessage = config.getString("LeaveMessage");

    this.subzoneList = config.getStringList("Subzones");

    Map<String, Object> arF = config.getConfigurationSection("AreaFlags").getValues(false);
    Map<Flag, Boolean> areaF = new HashMap<Flag, Boolean>();
    for (String flag : arF.keySet()) {
      boolean bool = (boolean) arF.get(flag);
      if (!FlagManager.isFlagExist(flag)) {
        Core.logMessage(
            LandProtection.getInstance(),
            Level.WARNING,
            "&4Chyba! &6Vlajka " + flag + " neexistuje!");
      } else {
        areaF.put(FlagManager.getFlag(flag), bool);
      }
    }
    Flags aFlags = new Flags(areaF);
    Map<UUID, Flags> playerFlags = new HashMap<UUID, Flags>();

    for (String playerUUID : config.getConfigurationSection("PlayersFlags").getKeys(false)) {
      Map<String, Object> plF =
          config.getConfigurationSection("PlayersFlags." + playerUUID).getValues(false);
      Map<Flag, Boolean> playerF = new HashMap<Flag, Boolean>();
      for (String flag : plF.keySet()) {
        boolean bool = (boolean) plF.get(flag);
        playerF.put(FlagManager.getFlag(flag), bool);
      }
      Flags pflags = new Flags(playerF);
      playerFlags.put(UUID.fromString(playerUUID), pflags);
    }

    lsFlags = new LSFlags(playerFlags, aFlags);
  }