示例#1
0
  /**
   * Gets the set damage for the given damage type, as defined in config.yml.
   *
   * @param player The player to check damage for.
   * @param dCause The cause of the incurred damage.
   * @param defaultDamage The default value to return if no option is set for the given damage type.
   * @return The damage to deal to the player.
   */
  public int getDamage(String player, DamageCause dCause, int defaultDamage) {
    String job = getJob(player);
    List<String> damages = config.getKeys("config.all.damages");
    int damage = defaultDamage;

    if (damages != null) {
      for (String item : damages) {
        if (item.equalsIgnoreCase(dCause.name())) {
          damage = config.getInt("config.all.damages." + item, defaultDamage);
          break;
        }
      }
    }

    damages = config.getKeys("config.jobs." + job + ".damages");

    if (damages != null) {
      for (String item : damages) {
        if (item.equalsIgnoreCase(dCause.name())) {
          damage = config.getInt("config.jobs." + job + ".damages." + item, defaultDamage);
          break;
        }
      }
    }

    return damage;
  }
示例#2
0
  public void readLangFile(String language) {
    String filename = getLangFolder() + File.separator + language + ".yml";

    try {
      Configuration config = new Configuration(new File(filename));

      config.load();

      List<String> keys = config.getKeys();

      if (!langDb.containsKey(language)) {
        langDb.put(language, new HashMap<String, String>());
      }

      Map<String, String> langMap = langDb.get(language);

      for (Iterator<String> it = keys.iterator(); it.hasNext(); ) {
        String key = it.next();

        Log.v("Adding " + language + "." + key + ";");
        langMap.put(key, config.getString(key));
      }

      Log.d("Done parsing localization file '" + filename + "' for language '" + language + "'");
    } catch (Exception ex) {
      Log.e("Could not load localizaion file '" + filename + "'");
    }
  }
  private boolean migratePortals(String name, File oldFolder, File newFolder) {
    Configuration newConfig = new Configuration(new File(newFolder, "portals.yml"));
    MultiversePortals.staticLog(Level.INFO, "Trying to migrate Portals.yml...");
    Configuration oldConfig = new Configuration(new File(oldFolder, "Portals.yml"));
    oldConfig.load();
    List<String> keys = oldConfig.getKeys("portals");
    if (keys == null) {
      MultiversePortals.staticLog(Level.SEVERE, "Migration FAILURE!");
      MultiversePortals.staticLog(Level.SEVERE, "Old Folder Location: " + oldFolder);
      MultiversePortals.staticLog(Level.SEVERE, "New Folder Location: " + newFolder);
      MultiversePortals.staticLog(Level.SEVERE, "Old Config Dump: " + oldConfig.getAll());
      return false;
    }
    for (String key : keys) {
      // Since portal names are lowercase, no reason not to do that here.
      String lowerkey = key.toLowerCase();
      if (newConfig.getProperty(lowerkey) != null) {
        MultiversePortals.staticLog(Level.SEVERE, "Portals are now case-insensitive!");
        MultiversePortals.staticLog(Level.SEVERE, "Found at least 2 portals named: " + lowerkey);
        continue;
      }

      newConfig.setProperty(
          "portals." + lowerkey + ".entryfee.amount",
          oldConfig.getDouble("portals." + key + ".price", 0.0));
      newConfig.setProperty("portals." + lowerkey + ".entryfee.amount", -1);
      newConfig.setProperty(
          "portals." + lowerkey + ".destination",
          transformDestination(
              oldConfig.getString("portals." + key + ".destlocation", "i:Invalid")));
      newConfig.setProperty(
          "portals." + lowerkey + ".world", oldConfig.getProperty("portals." + key + ".world"));
      newConfig.setProperty(
          "portals." + lowerkey + ".location",
          oldConfig.getProperty("portals." + key + ".location"));
      newConfig.setProperty(
          "portals." + lowerkey + ".owner", oldConfig.getProperty("portals." + key + ".owner"));
    }
    newConfig.save();
    MultiversePortals.staticLog(Level.INFO, "Migration SUCCESS!");
    return true;
  }
示例#4
0
  private static void load() {
    conf.load();

    key = conf.getString("APIkey", null);
    if (key == null) conf.setProperty("APIkey", "");

    servername = conf.getString("servername", null);
    if (servername == null) conf.setProperty("servername", "please change");

    owner = conf.getString("owner", null);
    if (owner == null) conf.setProperty("owner", "please change");

    // options
    banborder = conf.getString("options.banborder", "1000");
    if (banborder == "1000") conf.setProperty("options.banborder", "-40");

    glizer.D = conf.getBoolean("options.debugmode", false);

    // features
    List<String> features = conf.getKeys("features");
    bChat.log(features.toString());
    if (!features.contains("usewhitelist")) conf.setProperty("features.usewhitelist", false);
    if (!features.contains("useglobalbans")) conf.setProperty("features.useglobalbans", true);
    if (!features.contains("usebansystem")) conf.setProperty("features.usebansystem", true);
    if (!features.contains("useprofiles")) conf.setProperty("features.useprofiles", true);
    if (!features.contains("usecomments")) conf.setProperty("features.usecomments", true);
    if (!features.contains("useratings")) conf.setProperty("features.useratings", true);

    usewhitelist = conf.getBoolean("features.usewhitelist", false);
    useglobalbans = conf.getBoolean("features.useglobalbans", false);
    usebansystem = conf.getBoolean("features.usebansystem", false);
    useprofiles = conf.getBoolean("features.useprofiles", false);
    usecomments = conf.getBoolean("features.usecomments", false);
    useratings = conf.getBoolean("features.useratings", false);

    conf.save();
  }
示例#5
0
  /**
   * Attempts to get the zone player is currently standing in.
   *
   * @param player The player whose location is being checked.
   * @return Returns the zone name if the player is in a zone, or null if the player is not in a
   *     zone.
   */
  public String getInZone(String player) {
    List<String> zoneList = zones.getKeys("zones");
    String inZone = null;

    if (zoneList != null) {
      for (String zone : zoneList) {
        ifDebug("Checking inZone for zone '" + inZone + "'.");

        int[] upper = getZoneCoords(zone, "upper");
        int[] lower = getZoneCoords(zone, "lower");
        double[] locat = {
          Math.floor(getPlayer(player).getLocation().getX()),
          Math.floor(getPlayer(player).getLocation().getY()),
          Math.floor(getPlayer(player).getLocation().getZ())
        };

        if (debug) {
          for (int i = 0; i < 3; i++) {
            ifDebug("Upper[" + i + "]: " + upper[i]);
            ifDebug("Lower[" + i + "]: " + lower[i]);
            ifDebug("Locat[" + i + "]: " + locat[i]);
          }
        }

        if ((upper[0] >= locat[0] && lower[0] <= locat[0])
            && (upper[1] >= locat[1] && lower[1] <= locat[1])
            && (upper[2] >= locat[2] && lower[2] <= locat[2])) {

          inZone = zone;
          break;
        }
      }
    }

    return inZone;
  }
 public List<String> readStringList(File readFile, String root) {
   Configuration config = load(readFile);
   return config.getKeys(root);
 }
示例#7
0
  @Override
  public void onEnable() {
    pdf = this.getDescription();
    // Begin config code
    if (!new File(getDataFolder(), "config.yml").exists()) {
      try {
        getDataFolder().mkdir();
        new File(getDataFolder(), "config.yml").createNewFile();
      } catch (Exception e) {
        e.printStackTrace();
        System.out.println(pref + "Error making config.yml?!");
        getServer().getPluginManager().disablePlugin(this); // Cleanup
        return;
      }
    }
    cfg = this.getConfiguration(); // Get config

    if (cfg.getKeys().isEmpty()) { // Config hasn't been made
      System.out.println(pref + "config.yml not found, making with default values");
      cfg.setProperty("RealDrops.enabled", false);
      cfg.setProperty("Permissions.enabled", true);
      cfg.setProperty("MobTarget.enabled", true);
      cfg.setProperty("DisableItemPickup", true);
      for (String mobtype : MobType.types) {
        cfg.setHeader(
            "#Setting a mobtype to false will not allow a player to disguise as that type");
        cfg.setProperty("Blacklist." + mobtype, true); // Just making
      }
      cfg.save();
    }
    if (cfg.getProperty("MobTarget.enabled") == null
        || cfg.getProperty("DisableItemPickup.enabled") == null) {
      cfg.setProperty("MobTarget.enabled", true);
      cfg.setProperty("DisableItemPickup.enabled", true);
      cfg.save();
    }
    if (cfg.getProperty("Blacklist.enderman") == null) {
      cfg.setProperty("Blacklist.enderman", true);
      cfg.setProperty("Blacklist.silverfish", true);
      cfg.setProperty("Blacklist.cavespider", true);
    }

    cfg.save();
    perm = cfg.getBoolean("Permissions.enabled", true);

    PluginManager pm = getServer().getPluginManager();
    this.getCommand("md").setExecutor(new MDCommand(this));

    pm.registerEvents(playerlistener, this);
    pm.registerEvents(entitylistener, this);

    getServer().getScheduler().scheduleSyncRepeatingTask(this, new DisguiseTask(this), 1200, 1200);

    System.out.println(
        "["
            + pdf.getName()
            + "]"
            + " by "
            + pdf.getAuthors().get(0)
            + " version "
            + pdf.getVersion()
            + " enabled.");
  }
 @Override
 public List<String> getAllCachedPlayers() {
   return c.getKeys("players");
 }
 @Override
 public List<String> getAllCachedGroups() {
   return c.getKeys("groups");
 }
示例#10
0
  @Override
  public void onEnable() {
    pdf = this.getDescription();
    // Begin config code
    if (!new File(getDataFolder(), "config.yml").exists()) {
      try {
        getDataFolder().mkdir();
        new File(getDataFolder(), "config.yml").createNewFile();
      } catch (Exception e) {
        e.printStackTrace();
        System.out.println(pref + "Error making config.yml?!");
        getServer().getPluginManager().disablePlugin(this); // Cleanup
        return;
      }
    }
    cfg = this.getConfiguration(); // Get config

    if (cfg.getKeys().isEmpty()) { // Config hasn't been made
      System.out.println(pref + "config.yml not found, making with default values");
      cfg.setProperty("RealDrops.enabled", false);
      cfg.setProperty("Permissions.enabled", true);
      cfg.setProperty("MobTarget.enabled", true);
      cfg.setProperty("DisableItemPickup", true);
      for (String mobtype : MobIdEnum.map.keySet()) {
        cfg.setHeader(
            "#Setting a mobtype to false will not allow a player to disguise as that type");
        cfg.setProperty("Blacklist." + mobtype, true); // Just making
      }
      cfg.save();
    }
    if (cfg.getProperty("MobTarget.enabled") == null
        || cfg.getProperty("DisableItemPickup.enabled") == null) {
      cfg.setProperty("MobTarget.enabled", true);
      cfg.setProperty("DisableItemPickup.enabled", true);
      cfg.save();
    }
    if (cfg.getProperty("Blacklist.enderman") == null) {
      cfg.setProperty("Blacklist.enderman", true);
      cfg.setProperty("Blacklist.silverfish", true);
      cfg.setProperty("Blacklist.cavespider", true);
    }

    cfg.save();
    perm = cfg.getBoolean("Permissions.enabled", true);

    PluginManager pm = getServer().getPluginManager();
    this.getCommand("md").setExecutor(new MDCommand(this));
    pm.registerEvent(Event.Type.PLAYER_JOIN, playerlistener, Priority.Lowest, this);
    pm.registerEvent(Event.Type.PLAYER_QUIT, playerlistener, Priority.Normal, this);
    pm.registerEvent(Event.Type.PLAYER_RESPAWN, playerlistener, Priority.Normal, this);
    pm.registerEvent(Event.Type.PLAYER_TELEPORT, playerlistener, Priority.Monitor, this);
    pm.registerEvent(Event.Type.PLAYER_PICKUP_ITEM, playerlistener, Priority.Monitor, this);
    pm.registerEvent(Event.Type.ENTITY_DEATH, entitylistener, Priority.Normal, this);
    pm.registerEvent(Event.Type.ENTITY_TARGET, entitylistener, Priority.Normal, this);
    pm.registerEvent(Event.Type.PLAYER_ANIMATION, playerlistener, Priority.Normal, this);

    // new MDPlayerListener(this), Priority.Normal, this);
    getServer().getScheduler().scheduleSyncRepeatingTask(this, new DisguiseTask(this), 1200, 1200);
    // Register packet listeners
    // org.getspout.spoutapi.packet.listener.Listeners.addListener(17, packetlistener);
    // org.getspout.spoutapi.packet.listener.Listeners.addListener(18, packetlistener);
    System.out.println(
        "["
            + pdf.getName()
            + "]"
            + " by "
            + pdf.getAuthors().get(0)
            + " version "
            + pdf.getVersion()
            + " enabled.");
  }
示例#11
0
 /**
  * Gets a String List of all currently open tickets.
  *
  * @return A String List of all tickets, as listed in ticket.yml.
  */
 public List<String> getOpenTickets() {
   return (tickets.getKeys("tickets"));
 }
示例#12
0
 /**
  * Get a list of all jobs in config.yml
  *
  * @return Returns a String List containing all jobs available to the players.
  */
 public List<String> getJobList() {
   return (config.getKeys("config.jobs"));
 }
示例#13
0
 public List<String> readStringList(String root) {
   Configuration config = load();
   return config.getKeys(root);
 }