Beispiel #1
0
 private static void load() {
   if (props == null) props = new Properties();
   else props.clear();
   File[] list = (new File(OS.getWorkDir() + OS.getFileSeparator() + "devices")).listFiles();
   if (list == null) return;
   for (int i = 0; i < list.length; i++) {
     if (list[i].isDirectory()) {
       PropertiesFile p = new PropertiesFile();
       String device =
           list[i].getPath().substring(list[i].getPath().lastIndexOf(OS.getFileSeparator()) + 1);
       try {
         if (!device.toLowerCase().equals("busybox")) {
           p.open(
               "",
               new File(list[i].getPath() + OS.getFileSeparator() + device + ".properties")
                   .getAbsolutePath());
           DeviceEntry entry = new DeviceEntry(p);
           if (device.equals(entry.getId())) props.put(device, entry);
           else MyLogger.getLogger().error(device + " : this bundle is not valid");
         }
       } catch (Exception fne) {
         MyLogger.getLogger().error(device + " : this bundle is not valid");
       }
     }
   }
 }
Beispiel #2
0
 public static DeviceEntry getDevice(String device) {
   try {
     if (props.containsKey(device)) return (DeviceEntry) props.get(device);
     else {
       File f =
           new File(
               OS.getWorkDir() + File.separator + "devices" + File.separator + device + ".ftd");
       if (f.exists()) {
         DeviceEntry ent = null;
         JarFile jar = new JarFile(f);
         Enumeration e = jar.entries();
         while (e.hasMoreElements()) {
           JarEntry file = (JarEntry) e.nextElement();
           if (file.getName().endsWith(device + ".properties")) {
             InputStream is = jar.getInputStream(file); // get the input stream
             PropertiesFile p = new PropertiesFile();
             p.load(is);
             ent = new DeviceEntry(p);
           }
         }
         return ent;
       } else return null;
     }
   } catch (Exception ex) {
     ex.printStackTrace();
     return null;
   }
 }
Beispiel #3
0
 public static void sendInfo(Player p, Item item) {
   String key = item.getItemId() + ":" + item.getDamage();
   p.sendMessage(WShop.PRE + key);
   p.sendMessage(WShop.PRE + "Price (sell): " + PRICES.getDouble(key + "_sell", -1));
   p.sendMessage(WShop.PRE + "Price (buy): " + PRICES.getDouble(key + "_buy", -1));
   p.sendMessage(WShop.PRE + "Amount: " + ITEMS.getInt(key, 0));
 }
Beispiel #4
0
 /**
  * @param p - The player buying an item.
  * @param item - The item the player wants to buy.
  */
 public static void buyItem(Player p, Item item) {
   String key = item.getItemId() + ":" + item.getDamage();
   int amount = ITEMS.getInt(key, 0);
   if (amount == -1) {
     p.sendMessage(WShop.PRE + "The server does not sell that item at this time.");
     return;
   }
   if (amount < item.getAmount()) {
     p.sendMessage(WShop.PRE + "The server does not have that much of " + key);
     return;
   } // end if
   double price = PRICES.getDouble(key + "_buy", -1);
   if (price == -1) {
     p.sendMessage(WShop.PRE + "The server does not sell that item at this time." + key);
     return;
   }
   if (canPay(p, price)) {
     payPlayer(p, -price); // Make sure we charge them here, not pay them. Negate the price.
     p.giveItem(item);
     ITEMS.setInt(key, amount - item.getAmount());
     p.sendMessage(
         WShop.PRE
             + "Bought an item. ID:"
             + item.getItemId()
             + ", Damage:"
             + item.getDamage()
             + ", Amount:"
             + item.getAmount()
             + ", Cost:"
             + price);
   } else {
     p.sendMessage(WShop.PRE + "You do not have enough money to buy " + key);
     return;
   }
 } // end buyItem
Beispiel #5
0
 /**
  * @param p - The player trying to sell.
  * @param item - The item to sell, commonly the players help item.
  */
 public static void sellItem(Player p, Item item) {
   String key = item.getItemId() + ":" + item.getDamage();
   double price = PRICES.getDouble(key + "_sell", -1);
   if (price == -1) {
     p.sendMessage(WShop.PRE + "The server does not buy that item at this time.");
     return;
   }
   int amount = ITEMS.getInt(key, 0);
   p.getInventory().removeItem(item);
   ITEMS.setInt(key, amount + item.getAmount());
   payPlayer(p, price);
   return;
 } // end sellItem
 public void test_of_ioException() {
   assertThrows(
       () ->
           PropertiesFile.of(
               Files.asCharSource(new File("src/test/resources"), StandardCharsets.UTF_8)),
       UncheckedIOException.class);
 }
  public void Save() {
    String numkey = "sign-amount";
    String signprefix = "sign-";
    // clear properties file
    int num = mPropertiesFile.getInt(numkey, 0);
    for (int i = 0; i < num; ++i) {
      mPropertiesFile.removeKey(signprefix + i);
    }

    // save
    num = mSensorList.size();
    mPropertiesFile.setInt(numkey, num);
    for (int i = 0; i < mSensorList.size(); ++i) {
      mPropertiesFile.setString(signprefix + i, mSensorList.get(i).serialize());
    }
  }
Beispiel #8
0
 public HashSet<String> getRecognitionList() {
   String[] result = _entry.getProperty("recognition").split(",");
   HashSet<String> set = new HashSet<String>();
   for (int i = 0; i < result.length; i++) {
     set.add(result[i]);
   }
   return set;
 }
Beispiel #9
0
  public static void loadSettings() {

    if (!new File("/plugins/config/WorldTools/MySQL.properties").exists()) {
      try {
        File f = new File("plugins/config/WorldTools/MySQL.properties");
        BufferedWriter out = new BufferedWriter(new FileWriter(f));
        out.write("############################");
        out.newLine();
        out.write("# THIS IS CURRENTLY UNUSED #");
        out.newLine();
        out.write("############################");
        out.newLine();
        out.write("useCanarySQL=true");
        out.newLine();
        out.newLine();
        out.write("SQLdriver=com.mysql.jdbc.Driver");
        out.newLine();
        out.newLine();
        out.write("SQLuser=root");
        out.newLine();
        out.newLine();
        out.write("SQLpass=root");
        out.newLine();
        out.newLine();
        out.write("SQLdb=jdbc:mysql://localhost:3306/minecraft");
        out.newLine();
        out.newLine();
      } catch (IOException e) {
        log.info("[WorldTools] - Error during creating SQL propertiesfile!");
        e.printStackTrace();
      }
    }
    PropertiesFile properties = new PropertiesFile("/plugins/config/WorldTools/MySQL.properties");
    try {
      SQLdriver = properties.getProperty("SQLdriver");
      SQLusername = properties.getProperty("SQLuser");
      SQLpassword = properties.getProperty("SQLpass");
      SQLdb = properties.getProperty("SQLdb");
      useSql = Boolean.parseBoolean(properties.getProperty("UseCanarySQL"));
    } catch (Exception e) {
      log.log(Level.SEVERE, "Exception while reading from the mysql properties", e);
    }
    getConnection();
  }
Beispiel #10
0
 public String getBusybox(boolean select) {
   String version = "";
   if (!select) version = _entry.getProperty("busyboxhelper");
   else {
     version = WidgetTask.openBusyboxSelector(Display.getCurrent().getActiveShell());
     // BusyBoxSelectGUI sel = new BusyBoxSelectGUI(getId());
     // version = sel.getVersion();
   }
   if (version.length() == 0) return "";
   else return "." + fsep + "devices" + fsep + "busybox" + fsep + version + fsep + "busybox";
 }
Beispiel #11
0
  /** Constructor. */
  public PTAModelChecker(Prism prism, ModulesFile modulesFile, PropertiesFile propertiesFile)
      throws PrismException {
    this.prism = prism;
    mainLog = prism.getMainLog();
    this.modulesFile = modulesFile;
    this.propertiesFile = propertiesFile;

    // Get combined constant values from model/properties
    constantValues = new Values();
    constantValues.addValues(modulesFile.getConstantValues());
    if (propertiesFile != null) constantValues.addValues(propertiesFile.getConstantValues());

    // Build a combined label list and expand any constants
    // (note labels in model are ignored (removed) during PTA translation so need to store here)
    labelList = new LabelList();
    for (int i = 0; i < modulesFile.getLabelList().size(); i++) {
      labelList.addLabel(
          modulesFile.getLabelList().getLabelNameIdent(i),
          modulesFile.getLabelList().getLabel(i).deepCopy());
    }
    for (int i = 0; i < propertiesFile.getLabelList().size(); i++) {
      labelList.addLabel(
          propertiesFile.getLabelList().getLabelNameIdent(i),
          propertiesFile.getLabelList().getLabel(i).deepCopy());
    }
    labelList = (LabelList) labelList.replaceConstants(constantValues);

    // Build mapping from all (original model) variables to non-clocks only
    int numVars = modulesFile.getNumVars();
    nonClockVarMap = new int[numVars];
    int count = 0;
    for (int i = 0; i < numVars; i++) {
      if (modulesFile.getVarType(i) instanceof TypeClock) {
        nonClockVarMap[i] = -1;
      } else {
        nonClockVarMap[i] = count++;
      }
    }
  }
  public void Load() {
    String numkey = "sign-amount";
    String signprefix = "sign-";
    // clear list
    mSensorList.clear();

    // save
    int num = mPropertiesFile.getInt(numkey, 0);
    for (int i = 0; i < num; ++i) {
      SensorBlock s = SensorBlock.deserialize(mPropertiesFile.getString(signprefix + i, ""));
      if (s != null) {
        mSensorList.add(s);
      } else {
        Logger.getLogger("Minecraft")
            .warning(
                "[TOWNDEFENSE] Sensor at line "
                    + i
                    + " could not be deserialized or is invalid. Deleting.");
      }
    }
    TownDefense.Broadcast("Loaded " + mSensorList.size() + " of " + num + " Sensors.");
  }
Beispiel #13
0
 public DeviceEntry(String Id) {
   _entry = new PropertiesFile();
   try {
     String path =
         OS.getWorkDir()
             + File.separator
             + "devices"
             + File.separator
             + Id
             + File.separator
             + Id
             + ".properties";
     _entry.open("", path);
   } catch (Exception e) {
   }
 }
  public DestroySpell(MagicSpellsListener listener, PropertiesFile properties) {
    super(listener, properties);

    // register spell
    listener.registerSpellName(
        properties.getString("destroy-spellname", "destroy"),
        this,
        properties.getString("destroy-desc", "Destroys target blocks"));

    // get properties
    REDSTONE_COST = properties.getInt("destroy-redstone-cost", 10);
    OTHER_COST = properties.getInt("destroy-other-cost-type", 289);
    OTHER_COST_NAME = properties.getString("destroy-other-cost-name", "gunpowder");
    OTHER_COST_AMT = properties.getInt("destroy-other-cost-amt", 1);

    BLAST_RADIUS = properties.getInt("destroy-blast-radius", 2);

    STR_CAST = properties.getString("destroy-cast-str", "Boom!");
    STR_CAST_OTHERS = properties.getString("destroy-cast-others-str", "Boom!");

    // setup reagents
    reagents = new int[][] {{REDSTONE_DUST, REDSTONE_COST}, {OTHER_COST, OTHER_COST_AMT}};
  }
 @Test(expectedExceptions = IllegalArgumentException.class)
 public void test_of_invalid_emptyKey() {
   String invalid = "= y\n";
   PropertiesFile.of(CharSource.wrap(invalid));
 }
 public void test_of_list() {
   PropertiesFile test = PropertiesFile.of(CharSource.wrap(FILE2));
   Multimap<String, String> keyValues = ImmutableListMultimap.of("a", "x", "a", "y");
   assertEquals(test.getProperties(), PropertySet.of(keyValues));
   assertEquals(test.toString(), "{a=[x, y]}");
 }
Beispiel #17
0
  public static void initialize(File dataFolder) {
    if (!dataFolder.exists()) {
      dataFolder.mkdirs();
    }

    File configFile = new File(dataFolder, settingsFile);
    PropertiesFile file = new PropertiesFile(configFile);
    dataDir = dataFolder;

    maxPublic = file.getInt("maxPublic", 5, "Maximum number of public warps any player can make");
    maxPrivate =
        file.getInt("maxPrivate", 10, "Maximum number of private warps any player can make");
    adminsObeyLimits =
        file.getBoolean("adminsObeyLimits", false, "Whether or not admins can disobey warp limits");
    adminPrivateWarps =
        file.getBoolean(
            "adminPrivateWarps", true, "Whether or not admins can see private warps in their list");
    loadChunks =
        file.getBoolean(
            "loadChunks",
            false,
            "Force sending of the chunk which people teleport to - default: false");

    usemySQL =
        file.getBoolean(
            "usemySQL", false, "MySQL usage --  true = use MySQL database / false = use SQLite");
    mySQLconn =
        file.getString(
            "mySQLconn",
            "jdbc:mysql://localhost:3306/minecraft",
            "MySQL Connection (only if using MySQL)");
    mySQLuname = file.getString("mySQLuname", "root", "MySQL Username (only if using MySQL)");
    mySQLpass = file.getString("mySQLpass", "password", "MySQL Password (only if using MySQL)");

    file.save();
  }
Beispiel #18
0
 public boolean canFlash() {
   return _entry.getProperty("canflash").equals("true");
 }
Beispiel #19
0
 public boolean canKernel() {
   return (_entry.getProperty("cankernel").equals("true"));
 }
Beispiel #20
0
 public boolean canFastboot() {
   return _entry.getProperty("canfastboot").equals("true");
 }
Beispiel #21
0
 public String getKernelVersion() {
   return _entry.getProperty("kernel.version");
 }
Beispiel #22
0
  public static HashMap<String, Keyword_Format> setupPreprocesses(PropertiesFile propertyfile)
      throws Exception {
    // TODO Auto-generated method stub

    PropertiesFile filelocations = propertyfile;
    // Preprocessing Started
    System.out.println("Preprocessing Started.");

    // Step 1: Read csv file to generate list of documents
    // Read_generateCorpus.readCSV_getCORPUS(filelocations);

    System.out.println("Step: 1 generate corpus done.");

    // Step 2: Append Concepts
    // AppendConcepts.appendConcept(filelocations);
    System.out.println("Step: 2 Appending concepts done.");

    // Step 3: Stem all the Files
    try {
      // Stem_All_Files_under_Dir.stem_all_files_in_directory(filelocations);
    } catch (Throwable e) {
      e.printStackTrace();
    }

    System.out.println("Step: 3 Stemming done.");

    // Step 4: Filter into separate question & answers
    // Potential place to store in db
    // FilterStemmed.filter_docs(filelocations);
    System.out.println("Step: 4 Filtering done.");

    // Generate concepts from text

    // Step 5: Create Index Code
    // CallIndexFiles_Code.setupIndex(filelocations);
    System.out.println("Step: 5 Indexing (Code) done.");

    // Step 6: Create Index Text
    // CallIndexFiles_Text.setupIndex(filelocations);
    System.out.println("Step: 6 Indexing (Text) done.");

    // Pre-calculate document Norm: Code

    IndexReader t =
        IndexReader.open(
            FSDirectory.open(
                new File(
                    Preprocessing.class
                        .getClassLoader()
                        .getResource(filelocations.getBaseUrl() + filelocations.getIndexC())
                        .toURI())));
    Recommender.precalculate_doc_norm(t, "code");
    System.out.println("Code document norm calculation complete");

    // Pre-calculate Document Norm: Text
    IndexReader s =
        IndexReader.open(
            FSDirectory.open(
                new File(
                    Preprocessing.class
                        .getClassLoader()
                        .getResource(filelocations.getBaseUrl() + filelocations.getIndexT())
                        .toURI())));
    Recommender.precalculate_doc_norm(s, "text");
    System.out.println("Text document norm calculation complete");

    // Generate Keywords for each document
    HashMap<String, Keyword_Format> toController =
        KeywordExtract.GetConceptsForDocuments(filelocations);
    System.out.println("Concepts Extracted from Documents");

    // Preprocessing Completed.
    System.out.println("Preprocessing completed. ");

    return toController;
  }
Beispiel #23
0
  public static Warzone load(String name, boolean createNewVolume) {
    // war.getLogger().info("Loading warzone " + name + " config and blocks...");
    PropertiesFile warzoneConfig =
        new PropertiesFile(War.war.getDataFolder().getPath() + "/warzone-" + name + ".txt");
    try {
      warzoneConfig.load();
    } catch (IOException e) {
      War.war.getLogger().info("Failed to load warzone-" + name + ".txt file.");
      e.printStackTrace();
    }

    // world
    String worldStr = warzoneConfig.getProperty("world");
    World world = null;
    if (worldStr == null || worldStr.equals("")) {
      world = War.war.getServer().getWorlds().get(0); // default to first world
    } else {
      world = War.war.getServer().getWorld(worldStr);
    }

    if (world == null) {
      War.war.log(
          "Failed to restore warzone "
              + name
              + ". The specified world (name: "
              + worldStr
              + ") does not exist!",
          Level.WARNING);
    } else {
      // Create the zone
      Warzone warzone = new Warzone(world, name);

      // Create file if needed
      if (!warzoneConfig.containsKey("name")) {
        WarzoneTxtMapper.save(warzone, false);
        War.war.getLogger().info("Warzone " + name + " config file created.");
        try {
          warzoneConfig.load();
        } catch (IOException e) {
          // war.getLogger().info("Failed to reload warzone-" + name + ".txt file after creating
          // it.");
          e.printStackTrace();
        }
      }

      // teleport
      String teleportStr = warzoneConfig.getString("teleport");
      if (teleportStr != null && !teleportStr.equals("")) {
        String[] teleportSplit = teleportStr.split(",");
        int teleX = Integer.parseInt(teleportSplit[0]);
        int teleY = Integer.parseInt(teleportSplit[1]);
        int teleZ = Integer.parseInt(teleportSplit[2]);
        int yaw = Integer.parseInt(teleportSplit[3]);
        warzone.setTeleport(new Location(world, teleX, teleY, teleZ, yaw, 0));
      }

      // ff
      if (warzoneConfig.containsKey("friendlyFire")) {
        warzone
            .getWarzoneConfig()
            .put(WarzoneConfig.FRIENDLYFIRE, warzoneConfig.getBoolean("friendlyFire"));
      }

      // loadout
      warzone.getDefaultInventories().getLoadouts().clear();

      String loadoutStr = warzoneConfig.getString("loadout");
      if (loadoutStr != null && !loadoutStr.equals("")) {
        warzone
            .getDefaultInventories()
            .getLoadouts()
            .put("default", new HashMap<Integer, ItemStack>());
        LoadoutTxtMapper.fromStringToLoadout(
            loadoutStr, warzone.getDefaultInventories().getLoadouts().get("default"));
      }

      // extraLoadouts
      String extraLoadoutStr = warzoneConfig.getString("extraLoadouts");
      String[] extraLoadoutsSplit = extraLoadoutStr.split(",");

      for (String nameStr : extraLoadoutsSplit) {
        if (nameStr != null && !nameStr.equals("")) {
          warzone
              .getDefaultInventories()
              .getLoadouts()
              .put(nameStr, new HashMap<Integer, ItemStack>());
        }
      }

      for (String extraName : extraLoadoutsSplit) {
        if (extraName != null && !extraName.equals("")) {
          String loadoutString = warzoneConfig.getString(extraName + "Loadout");
          HashMap<Integer, ItemStack> loadout =
              warzone.getDefaultInventories().getLoadouts().get(extraName);
          LoadoutTxtMapper.fromStringToLoadout(loadoutString, loadout);
        }
      }

      // authors
      if (warzoneConfig.containsKey("author") && !warzoneConfig.getString("author").equals("")) {
        for (String authorStr : warzoneConfig.getString("author").split(",")) {
          if (!authorStr.equals("")) {
            warzone.addAuthor(authorStr);
          }
        }
      }

      // life pool (always set after teams, so the teams' remaining lives get initialized properly
      // by this setter)
      if (warzoneConfig.containsKey("lifePool")) {
        warzone.getTeamDefaultConfig().put(TeamConfig.LIFEPOOL, warzoneConfig.getInt("lifePool"));
      }

      // monument heal
      if (warzoneConfig.containsKey("monumentHeal")) {
        warzone
            .getWarzoneConfig()
            .put(WarzoneConfig.MONUMENTHEAL, warzoneConfig.getInt("monumentHeal"));
      }

      // autoAssignOnly
      if (warzoneConfig.containsKey("autoAssignOnly")) {
        warzone
            .getWarzoneConfig()
            .put(WarzoneConfig.AUTOASSIGN, warzoneConfig.getBoolean("autoAssignOnly"));
      }

      // flagPointsOnly
      if (warzoneConfig.containsKey("flagPointsOnly")) {
        warzone
            .getTeamDefaultConfig()
            .put(TeamConfig.FLAGPOINTSONLY, warzoneConfig.getBoolean("flagPointsOnly"));
      }

      // flagMustBeHome
      if (warzoneConfig.containsKey("flagMustBeHome")) {
        warzone
            .getTeamDefaultConfig()
            .put(TeamConfig.FLAGMUSTBEHOME, warzoneConfig.getBoolean("flagMustBeHome"));
      }

      // team cap
      if (warzoneConfig.containsKey("teamCap")) {
        warzone.getTeamDefaultConfig().put(TeamConfig.TEAMSIZE, warzoneConfig.getInt("teamCap"));
      }

      // score cap
      if (warzoneConfig.containsKey("scoreCap")) {
        warzone.getTeamDefaultConfig().put(TeamConfig.MAXSCORE, warzoneConfig.getInt("scoreCap"));
      }

      // respawn timer
      if (warzoneConfig.containsKey("respawnTimer")) {
        warzone
            .getTeamDefaultConfig()
            .put(TeamConfig.RESPAWNTIMER, warzoneConfig.getInt("respawnTimer"));
      }

      // blockHeads
      if (warzoneConfig.containsKey("blockHeads")) {
        warzone
            .getWarzoneConfig()
            .put(WarzoneConfig.BLOCKHEADS, warzoneConfig.getBoolean("blockHeads"));
      }

      // spawnStyle
      String spawnStyle = warzoneConfig.getString("spawnStyle");
      if (spawnStyle != null && !spawnStyle.equals("")) {
        warzone
            .getTeamDefaultConfig()
            .put(TeamConfig.SPAWNSTYLE, TeamSpawnStyle.getStyleFromString(spawnStyle));
      }

      // flagReturn
      String flagReturn = warzoneConfig.getString("flagReturn");
      if (flagReturn != null && !flagReturn.equals("")) {
        warzone
            .getTeamDefaultConfig()
            .put(TeamConfig.FLAGRETURN, FlagReturn.getFromString(flagReturn));
      }

      // reward
      String rewardStr = warzoneConfig.getString("reward");
      if (rewardStr != null && !rewardStr.equals("")) {
        HashMap<Integer, ItemStack> reward = new HashMap<Integer, ItemStack>();
        LoadoutTxtMapper.fromStringToLoadout(rewardStr, reward);
        warzone.getDefaultInventories().setReward(reward);
      }

      // unbreakableZoneBlocks
      if (warzoneConfig.containsKey("unbreakableZoneBlocks")) {
        warzone
            .getWarzoneConfig()
            .put(WarzoneConfig.UNBREAKABLE, warzoneConfig.getBoolean("unbreakableZoneBlocks"));
      }

      // disabled
      if (warzoneConfig.containsKey("disabled")) {
        warzone
            .getWarzoneConfig()
            .put(WarzoneConfig.DISABLED, warzoneConfig.getBoolean("disabled"));
      }

      // noCreatures
      if (warzoneConfig.containsKey("noCreatures")) {
        warzone
            .getWarzoneConfig()
            .put(WarzoneConfig.NOCREATURES, warzoneConfig.getBoolean("noCreatures"));
      }

      // glassWalls
      if (warzoneConfig.containsKey("glassWalls")) {
        warzone
            .getWarzoneConfig()
            .put(WarzoneConfig.GLASSWALLS, warzoneConfig.getBoolean("glassWalls"));
      }

      // pvpInZone
      if (warzoneConfig.containsKey("pvpInZone")) {
        warzone
            .getWarzoneConfig()
            .put(WarzoneConfig.PVPINZONE, warzoneConfig.getBoolean("pvpInZone"));
      }

      // instaBreak
      if (warzoneConfig.containsKey("instaBreak")) {
        warzone
            .getWarzoneConfig()
            .put(WarzoneConfig.INSTABREAK, warzoneConfig.getBoolean("instaBreak"));
      }

      // noDrops
      if (warzoneConfig.containsKey("noDrops")) {
        warzone.getWarzoneConfig().put(WarzoneConfig.NODROPS, warzoneConfig.getBoolean("noDrops"));
      }

      // noHunger
      if (warzoneConfig.containsKey("noHunger")) {
        warzone
            .getTeamDefaultConfig()
            .put(TeamConfig.NOHUNGER, warzoneConfig.getBoolean("noHunger"));
      }

      // saturation
      if (warzoneConfig.containsKey("saturation")) {
        warzone
            .getTeamDefaultConfig()
            .put(TeamConfig.SATURATION, warzoneConfig.getInt("saturation"));
      }

      // minPlayers
      if (warzoneConfig.containsKey("minPlayers")) {
        warzone
            .getWarzoneConfig()
            .put(WarzoneConfig.MINPLAYERS, warzoneConfig.getInt("minPlayers"));
      }

      // minTeams
      if (warzoneConfig.containsKey("minTeams")) {
        warzone.getWarzoneConfig().put(WarzoneConfig.MINTEAMS, warzoneConfig.getInt("minTeams"));
      }

      // resetOnEmpty
      if (warzoneConfig.containsKey("resetOnEmpty")) {
        warzone
            .getWarzoneConfig()
            .put(WarzoneConfig.RESETONEMPTY, warzoneConfig.getBoolean("resetOnEmpty"));
      }

      // resetOnLoad
      if (warzoneConfig.containsKey("resetOnLoad")) {
        warzone
            .getWarzoneConfig()
            .put(WarzoneConfig.RESETONLOAD, warzoneConfig.getBoolean("resetOnLoad"));
      }

      // resetOnUnload
      if (warzoneConfig.containsKey("resetOnUnload")) {
        warzone
            .getWarzoneConfig()
            .put(WarzoneConfig.RESETONUNLOAD, warzoneConfig.getBoolean("resetOnUnload"));
      }

      // rallyPoint
      String rallyPointStr = warzoneConfig.getString("rallyPoint");
      if (rallyPointStr != null && !rallyPointStr.equals("")) {
        String[] rallyPointStrSplit = rallyPointStr.split(",");

        int rpX = Integer.parseInt(rallyPointStrSplit[0]);
        int rpY = Integer.parseInt(rallyPointStrSplit[1]);
        int rpZ = Integer.parseInt(rallyPointStrSplit[2]);
        Location rallyPoint = new Location(world, rpX, rpY, rpZ);
        warzone.setRallyPoint(rallyPoint);
      }

      // monuments
      String monumentsStr = warzoneConfig.getString("monuments");
      if (monumentsStr != null && !monumentsStr.equals("")) {
        String[] monumentsSplit = monumentsStr.split(";");
        warzone.getMonuments().clear();
        for (String monumentStr : monumentsSplit) {
          if (monumentStr != null && !monumentStr.equals("")) {
            String[] monumentStrSplit = monumentStr.split(",");
            int monumentX = Integer.parseInt(monumentStrSplit[1]);
            int monumentY = Integer.parseInt(monumentStrSplit[2]);
            int monumentZ = Integer.parseInt(monumentStrSplit[3]);
            Monument monument =
                new Monument(
                    monumentStrSplit[0],
                    warzone,
                    new Location(world, monumentX, monumentY, monumentZ));
            warzone.getMonuments().add(monument);
          }
        }
      }

      // teams
      String teamsStr = warzoneConfig.getString("teams");
      if (teamsStr != null && !teamsStr.equals("")) {
        String[] teamsSplit = teamsStr.split(";");
        warzone.getTeams().clear();
        for (String teamStr : teamsSplit) {
          if (teamStr != null && !teamStr.equals("")) {
            String[] teamStrSplit = teamStr.split(",");
            int teamX = Integer.parseInt(teamStrSplit[1]);
            int teamY = Integer.parseInt(teamStrSplit[2]);
            int teamZ = Integer.parseInt(teamStrSplit[3]);
            Location teamLocation = new Location(world, teamX, teamY, teamZ);
            if (teamStrSplit.length > 4) {
              int yaw = Integer.parseInt(teamStrSplit[4]);
              teamLocation.setYaw(yaw);
            }
            Team team =
                new Team(
                    teamStrSplit[0],
                    TeamKind.teamKindFromString(teamStrSplit[0]),
                    teamLocation,
                    warzone);
            team.setRemainingLives(warzone.getTeamDefaultConfig().resolveInt(TeamConfig.LIFEPOOL));
            warzone.getTeams().add(team);
          }
        }
      }

      // teamFlags
      String teamFlagsStr = warzoneConfig.getString("teamFlags");
      if (teamFlagsStr != null && !teamFlagsStr.equals("")) {
        String[] teamFlagsSplit = teamFlagsStr.split(";");
        for (String teamFlagStr : teamFlagsSplit) {
          if (teamFlagStr != null && !teamFlagStr.equals("")) {
            String[] teamFlagStrSplit = teamFlagStr.split(",");
            Team team = warzone.getTeamByKind(TeamKind.teamKindFromString(teamFlagStrSplit[0]));
            if (team != null) {
              int teamFlagX = Integer.parseInt(teamFlagStrSplit[1]);
              int teamFlagY = Integer.parseInt(teamFlagStrSplit[2]);
              int teamFlagZ = Integer.parseInt(teamFlagStrSplit[3]);
              Location teamFlagLocation = new Location(world, teamFlagX, teamFlagY, teamFlagZ);
              if (teamFlagStrSplit.length > 4) {
                int yaw = Integer.parseInt(teamFlagStrSplit[4]);
                teamFlagLocation.setYaw(yaw);
              }
              team.setTeamFlag(teamFlagLocation); // this may screw things up
            }
          }
        }
      }

      // lobby
      String lobbyStr = warzoneConfig.getString("lobby");

      warzoneConfig.close();

      if (createNewVolume) {
        ZoneVolume zoneVolume =
            new ZoneVolume(
                warzone.getName(),
                world,
                warzone); // VolumeMapper.loadZoneVolume(warzone.getName(), warzone.getName(), war,
                          // warzone.getWorld(), warzone);
        warzone.setVolume(zoneVolume);
      }

      // monument blocks
      for (Monument monument : warzone.getMonuments()) {
        monument.setVolume(VolumeMapper.loadVolume(monument.getName(), warzone.getName(), world));
      }

      // team spawn blocks
      for (Team team : warzone.getTeams()) {
        team.setSpawnVolume(VolumeMapper.loadVolume(team.getName(), warzone.getName(), world));
        if (team.getTeamFlag() != null) {
          team.setFlagVolume(
              VolumeMapper.loadVolume(team.getName() + "flag", warzone.getName(), world));
        }
      }

      // lobby
      BlockFace lobbyFace = null;
      if (lobbyStr != null && !lobbyStr.equals("")) {
        String[] lobbyStrSplit = lobbyStr.split(",");
        if (lobbyStrSplit.length > 0) {
          // lobby orientation
          if (lobbyStrSplit[0].equals("south")) {
            lobbyFace = Direction.SOUTH();
          } else if (lobbyStrSplit[0].equals("east")) {
            lobbyFace = Direction.EAST();
          } else if (lobbyStrSplit[0].equals("north")) {
            lobbyFace = Direction.NORTH();
          } else if (lobbyStrSplit[0].equals("west")) {
            lobbyFace = Direction.WEST();
          }

          // lobby world
          World lobbyWorld = world; // by default, warzone world
          if (lobbyStrSplit.length > 1) {
            World strWorld = War.war.getServer().getWorld(lobbyStrSplit[1]);
            if (strWorld != null) {
              lobbyWorld = strWorld;
            }
          }

          // create the lobby
          Volume lobbyVolume = VolumeMapper.loadVolume("lobby", warzone.getName(), lobbyWorld);
          ZoneLobby lobby = new ZoneLobby(warzone, lobbyFace, lobbyVolume);
          warzone.setLobby(lobby);
        }
      }

      return warzone;
    }
    return null;
  }
Beispiel #24
0
 public String getOptimize() {
   return "./devices/" + _entry.getProperty("internalname") + "/optimize.tar";
 }
Beispiel #25
0
 public String getBuildMerge() {
   return "./devices/" + _entry.getProperty("internalname") + "/build.prop";
 }
Beispiel #26
0
 public String getCharger() {
   return "./devices/" + _entry.getProperty("internalname") + "/charger";
 }
Beispiel #27
0
 public String getBuildId() {
   return _entry.getProperty("android.build");
 }
 public void setProperty(String name, PropertiesFile propFile) {
   if (propFile != null && propFile.getFile() != null) {
     mProperties.put(name, propFile.getFile().getAbsolutePath());
   }
 }
  // -------------------------------------------------------------------------
  public void test_equalsHashCode() {
    PropertiesFile a1 = PropertiesFile.of(CharSource.wrap(FILE1));
    PropertiesFile a2 = PropertiesFile.of(CharSource.wrap(FILE1));
    PropertiesFile b = PropertiesFile.of(CharSource.wrap(FILE2));

    assertEquals(a1.equals(a1), true);
    assertEquals(a1.equals(a2), true);
    assertEquals(a1.equals(b), false);
    assertEquals(a1.equals(null), false);
    assertEquals(a1.equals(""), false);
    assertEquals(a1.hashCode(), a2.hashCode());
  }
Beispiel #30
0
 private void setKernelVersion() {
   _entry.setProperty("kernel.version", AdbUtility.getKernelVersion(isBusyboxInstalled(false)));
 }