Package org.bukkit.configuration.file

Examples of org.bukkit.configuration.file.FileConfiguration


          if (loadedClasses.contains("Init_Kits")){
            featureGraph.addPlotter(new Metrics.Plotter("Kits Set") {
            @Override
            public int getValue() {
              int count = 0;
              FileConfiguration f = CommandsEX.getConf();
              ConfigurationSection configGroups = f.getConfigurationSection("kits");
              if (configGroups != null){
                Set<String> kitGroups = configGroups.getKeys(false);

                for (String group : kitGroups) {
                  ConfigurationSection kits = f.getConfigurationSection("kits." + group);
                  Set<String> kitNames = kits.getKeys(false);
                  count = count + kitNames.size();
                }
              }
             
View Full Code Here


  public static void displayMOTD(CommandSender p) {
    // check if we can use Vault to determine player's group
    // check we aren't using SuperPerms, SuperPerms no like groups!
    if (Vault.permsEnabled() && !Vault.perms.getName().equals("SuperPerms") && (p instanceof Player)) {
      // check if we have extra MOTD for this group set up
      FileConfiguration conf = CommandsEX.getConf();
      Boolean privateMOTDsent = false;
      for (String s : Vault.perms.getPlayerGroups((Player) p)) {
        if (!conf.getString("motd_" + s, "").equals("")) {
          privateMOTDsent = true;
          String[] msg = CommandsEX.getConf().getString("motd_" + s).replace("{playername}", Nicknames.getNick(p.getName())).split("\\{newline\\}");
          for (String s1 : msg) {
            p.sendMessage(Utils.replaceChatColors(s1));
          }
View Full Code Here

    CommandsEX.plugin.getServer().getPluginManager().registerEvents(this, CommandsEX.plugin);
  }
 
  @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
  public void onPlayerDeath(PlayerDeathEvent e){
    FileConfiguration config = CommandsEX.getConf();
    Player victim = e.getEntity();
    EntityDamageEvent damev = victim.getLastDamageCause();
    DamageCause cause;
    if (damev != null){
      cause = damev.getCause();
    } else {
      // unknown
      e.setDeathMessage(replacements(config.getString("deathUnknown"), victim));
      return;
    }
    Entity killer = null;
    // put this in a try catch incase we get an NPE here
    try {
      killer = (((EntityDamageByEntityEvent) damev).getDamager());
    } catch (Exception ex){
      // no killer
    }
    String message = null;
   
    // check if player died via pvp
    if (killer instanceof Player){
      message = replacements(config.getString("deathPvP"), victim).replaceAll("%killer%", Nicknames.getNick(((Player) killer).getName()));
    }
   
    // check if drowned
    if (cause == DamageCause.DROWNING){
      message = replacements(config.getString("deathDrown"), victim);
    }
   
    // check if they fell
    if (cause == DamageCause.FALL){
      message = replacements(config.getString("deathFall"), victim);
    }
   
    // check if fire
    if (cause == DamageCause.FIRE || cause == DamageCause.FIRE_TICK){
      message = replacements(config.getString("deathFire"), victim);
    }
   
    // check if lava
    if (cause == DamageCause.LAVA){
      message = replacements(config.getString("deathLava"), victim);
    }
   
    // check if magic
    if (cause == DamageCause.MAGIC){
      message = replacements(config.getString("deathMagic"), victim);
    }
   
    // check if starved
    if (cause == DamageCause.STARVATION){
      message = replacements(config.getString("deathStarvation"), victim);
    }
   
    // check if struck by lightning
    if (cause == DamageCause.LIGHTNING){
      message = replacements(config.getString("deathLightning"), victim);
    }
   
    // check if poisoned
    if (cause == DamageCause.POISON){
      message = replacements(config.getString("deathPoison"), victim);
    }
   
    // check if suffocated
    if (cause == DamageCause.SUFFOCATION){
      message = replacements(config.getString("deathSuffocate"), victim);
    }
   
    // check if suicide
    if (cause == DamageCause.SUICIDE){
      message = replacements(config.getString("deathSuicide"), victim);
    }
   
    // check if void
    if (cause == DamageCause.VOID){
      message = replacements(config.getString("deathVoid"), victim);
    }

    if ((cause == DamageCause.CONTACT || cause == DamageCause.ENTITY_ATTACK) && !(killer instanceof Player)){
      //System.out.println(killer.getType().getName());
      message = replacements(config.getString("death" + killer.getType().getName()), victim);
    }

    // check if explosion
    if (cause == DamageCause.BLOCK_EXPLOSION || cause == DamageCause.ENTITY_EXPLOSION){
      if (killer != null){
        // check if tnt
        if (killer.getType() == EntityType.PRIMED_TNT){
          message = replacements(config.getString("deathTNT"), victim);
        } else if (killer.getType() == EntityType.CREEPER){
          message = replacements(config.getString("deathCreeper"), victim);
        }
      } else {
        message = replacements(config.getString("deathOtherExplosion"), victim);
      }
    }

    // check if projectile
    if (cause == DamageCause.PROJECTILE){
      // check if arrow
      if (killer instanceof Arrow){
        Arrow arrow = (Arrow) killer;
        if (arrow.getShooter() instanceof Player){
          // player shot the arrow
          message = replacements(config.getString("deathShotByPlayer"), victim).replaceAll("%killer%", Nicknames.getNick(((Player) arrow.getShooter()).getName()));
        } else if (arrow.getShooter() instanceof Skeleton) {
          // skeleton shot the arrow
          message = replacements(config.getString("deathShotBySkeleton"), victim).replaceAll("%killer%", Utils.userFriendlyNames(arrow.getShooter().getType().getName()));
        } else {
          // something else shot the arrow, e.g. dispenser
          message = replacements(config.getString("deathShotByOther"), victim);
        }
      }
    }
   
    // small fireball
    if (killer instanceof SmallFireball){
      SmallFireball fireball = (SmallFireball) killer;
      // check if ghast
      if (fireball.getShooter() instanceof Ghast){
        message = replacements(config.getString("deathGhast"), victim);
      }
     
      // check if blaze
      if (fireball.getShooter() instanceof Blaze){
        message = replacements(config.getString("deathBlaze"), victim);
      }
    }
   
    // normal fireball
    if (killer instanceof Fireball){
      Fireball fireball = (Fireball) killer;
      // check if ghast
      if (fireball.getShooter() instanceof Ghast){
        message = replacements(config.getString("deathGhast"), victim);
      }
     
      // check if blaze
      if (fireball.getShooter() instanceof Blaze){
        message = replacements(config.getString("deathBlaze"), victim);
      }
    }
   
    if (message != null){
      // send custom death message
View Full Code Here

  public void passChat(PlayerDeathEvent e) {
    // load groups information from config and check if our player belongs to any of them, then change his group
    Player p = (Player) e.getEntity();
    if (Permissions.checkPermEx(p, "cex.deathgroup.ignore")) return;
   
    FileConfiguration f = CommandsEX.getConf();
    ConfigurationSection configGroups = f.getConfigurationSection("deathGroupChanges");
    if (configGroups == null){ return; }
    Set<String> groups = configGroups.getKeys(false);
    String pName = p.getName();
    String toGroup = null;
    String command = null;
    List<String> removedGroups = new ArrayList<String>();
    final CommanderCommandSender ccs = new CommanderCommandSender();
   
    LogHelper.logDebug("groups: " + Utils.implode(Vault.perms.getPlayerGroups(p), ", "));
    for (String group : groups) {
      LogHelper.logDebug("testing against " + group);
      if (Vault.perms.playerInGroup(p, group)) {
        LogHelper.logDebug("test ok");
        // make sure that these are not null and don't cause problems
        if (f.getString("deathGroupChanges." + group + ".toGroup", "") != null && f.getString("deathGroupChanges." + group + ".command", "") != null){
          toGroup = f.getString("deathGroupChanges." + group + ".toGroup", "");
          command = f.getString("deathGroupChanges." + group + ".command", "");
         
          // change player's group based on config
          if (!toGroup.equals("")) {
            removedGroups.add(group + "##" + toGroup);
            Vault.perms.playerRemoveGroup(p, group);
View Full Code Here

  public void addUser(Player sender, String user)
      throws IOException {

    Chat chat = new Chat();
    FileConfiguration userName = getConfig();
    File configFile = new File("plugins" + File.pathSeparator + "EMC"
        + "users.yml");
    boolean configExists = configFile.exists() && configFile.canRead()
        && configFile.canWrite();
    boolean userIsNotAdded = userName.getString("EMC.Users", user) == null;

    if (userIsNotAdded && sender.hasPermission("ECM.adduser")
        || sender.hasPermission("ECM.*")) {
      if (configExists) {
        userName.set("EMC.Users", user);
        userName.save("plugins" + File.pathSeparator + "ECM"
            + File.pathSeparator + "users.yml");
        chat.finishMessage(sender, "You have let " + user.toLowerCase()
            + " use ECM correctly!");
      } else {
        FileWriter outFile = new FileWriter(configFile, true);
        PrintWriter out = new PrintWriter(outFile);
        out.println("#Users For ECM go in here! Do not touch this! Use the ingame command!");
        out.close();
        userName.set("EMC.Users", user);
        userName.save("plugins" + File.pathSeparator + "ECM"
            + File.pathSeparator + "users.yml");
        chat.finishMessage(
            sender,
            "You have let "
                + user.toLowerCase()
View Full Code Here

* @author Joshua D. Katz
*/
public class Commanddeluser extends JavaPlugin {
  public void addUser(Player sender, String user, Player realUser)
      throws IOException {
    FileConfiguration userName = getConfig();
    File configFile = new File("plugins" + File.pathSeparator + "EMC"
        + "users.yml");
    boolean configExists = configFile.exists() && configFile.canRead()
        && configFile.canWrite();
    boolean userIsAdded = userName.getString("EMC.Users", user) != null;

    if (configExists && userIsAdded && sender.hasPermission("EMC.deluser")
        || sender.hasPermission("EMC.*")) {
      userName.set("EMC.deluser." + user, null);
    }

  }
View Full Code Here

  /**
   * Clears and then populates the plugin's tier list
   */
  public void build() {
    plugin.tiers.clear();
    FileConfiguration cs = new YamlConfiguration();
    File f = new File(plugin.getDataFolder(), "tier.yml");
    if (f.exists())
      try {
        cs.load(f);
      } catch (Exception e) {
        if (plugin.getDebug())
          plugin.log.warning(e.getMessage());
      }
    for (String name : cs.getKeys(false)) {
      int amt = cs.getInt(name + ".Enchantments.Amt");
      int lvl = cs.getInt(name + ".Enchantments.Levels");
      double chance = cs.getDouble(name + ".Chance");
      String color = cs.getString(name + ".Color");
      List<Material> l = new ArrayList<Material>();
      for (String s : cs.getStringList(name + ".Materials")) {
        Material mat = Material.getMaterial(s.toUpperCase());
        if (mat != null)
          l.add(mat);
      }
      for (String s : cs.getStringList(name + ".Material")) {
        Material mat = Material.getMaterial(s.toUpperCase());
        if (mat != null)
          l.add(mat);
      }
      List<String> lore = new ArrayList<String>();
      for (String s : cs.getStringList(name + ".Lore"))
        if (s != null)
          lore.add(ChatColor.translateAlternateColorCodes('&', s));
      plugin.tiers.add(new Tier(name, ChatColor.valueOf(color
          .toUpperCase()), Math.abs(amt), Math.abs(lvl), Math
          .abs((int) (chance * 100)), l, lore, cs.getString(name
          + ".DisplayName", name), ((float) cs.getDouble(name
          + ".DropChance", 100)) / 100));
    }
  }
View Full Code Here

  /**
   * Clears and then populates the plugin's custom items list
   */
  public void build() {
    FileConfiguration fc = new YamlConfiguration();
    File f = new File(plugin.getDataFolder(), "custom.yml");
    if (f.exists()) {
      try {
        fc.load(f);
      } catch (Exception e) {
        if (plugin.getDebug())
          plugin.log.warning(e.getMessage());
      }
    }
    for (String name : fc.getKeys(false)) {
      ConfigurationSection cs = fc.getConfigurationSection(name);
      Material mat = Material.matchMaterial(cs.getString("Material"));
      ChatColor color = ChatColor.valueOf(cs.getString("Color")
          .toUpperCase());
      List<String> lore = cs.getStringList("Lore");
      ItemStack tool = new ItemStack(mat);
View Full Code Here

    nameLoader.writeDefault("set.yml", false);
    nameLoader.writeDefault("prefix.txt", false);
    nameLoader.writeDefault("suffix.txt", false);
    nameLoader.writeDefault("defenselore.txt", false);
    nameLoader.writeDefault("offenselore.txt", false);
    FileConfiguration config = getConfig();
    settings = new Settings(config);
    if (config.getBoolean("Display.ItemMaterialExtras", false)) {
      File loc = new File(getDataFolder(), "/NamesPrefix/");
      if (!loc.exists()) {
        loc.mkdir();
      }
      for (File f : loc.listFiles())
        if (f.getName().endsWith(".txt")) {
          getLogger().info("Loading Prefix File:" + f.getName());
          nameLoader.loadMaterialFile(hmprefix,
              new File(loc, f.getName()));
        }
      File sloc = new File(getDataFolder(), "/NamesSuffix/");
      if (!sloc.exists()) {
        sloc.mkdir();
      }
      for (File f : sloc.listFiles())
        if (f.getName().endsWith(".txt")) {
          getLogger().info("Loading Suffix File:" + f.getName());
          nameLoader.loadMaterialFile(hmsuffix,
              new File(sloc, f.getName()));
        }
    }

    nameLoader.loadFile(prefix, "prefix.txt");
    nameLoader.loadFile(suffix, "suffix.txt");

    nameLoader.loadFile(defenselore, "defenselore.txt");
    nameLoader.loadFile(offenselore, "offenselore.txt");
    custom = new ArrayList<ItemStack>();
    drop = new ItemAPI();
    new CustomBuilder(this).build();
    new SocketBuilder(this).build();
    new TierBuilder(this).build();
    new ArmorSetBuilder(this).build();
    dropsAPI = new DropsAPI(this);
    setsAPI = new SetsAPI(this);
    if (config.getBoolean("Worlds.Enabled", false)) {
      for (String s : config.getStringList("Worlds.Allowed")) {
        worlds.add(s.toLowerCase());
      }
    }
    debug = config.getBoolean("Plugin.Debug", false);

    PluginManager pm = getServer().getPluginManager();
    pm.registerEvents(new MobListener(this), this);
    pm.registerEvents(new TomeListener(this), this);
    pm.registerEvents(new SocketListener(this), this);
    pm.registerEvents(new EffectsListener(this), this);
    pm.registerEvents(new SetListener(this), this);

    getCommand("diablodrops").setExecutor(new DiabloDropCommand(this));

    ShapelessRecipe re = new ShapelessRecipe(new IdentifyTome());
    re.addIngredient(3, Material.BOOK);
    re.addIngredient(Material.EYE_OF_ENDER);
    this.getServer().addRecipe(re);

    if (config.getBoolean("Plugin.AutoUpdate", true)) {
      getServer().getScheduler().runTask(this, new Runnable() {
        @Override
        public void run() {
          Updater up = new Updater(getInstance(), 46631, getFile(),
              UpdateType.DEFAULT, true);
View Full Code Here

  /**
   * Clears and then populates the plugin's ArmorSet list
   */
  public void build() {
    plugin.armorSets.clear();
    FileConfiguration cs = new YamlConfiguration();
    File f = new File(plugin.getDataFolder(), "set.yml");
    if (f.exists()) {
      try {
        cs.load(f);
      } catch (Exception e) {
        if (plugin.getDebug())
          plugin.log.warning(e.getMessage());
      }
    }
    for (String name : cs.getKeys(false)) {
      List<String> bonuses = cs.getStringList(name + ".Bonuses");
      if (bonuses == null)
        bonuses = new ArrayList<String>();
      plugin.armorSets.add(new ArmorSet(name, bonuses));
    }
  }
View Full Code Here

TOP

Related Classes of org.bukkit.configuration.file.FileConfiguration

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.