Examples of FileConfiguration


Examples of org.bukkit.configuration.file.FileConfiguration

  public static String cmdPrefix;
  public static final CommanderCommandSender ccs = new CommanderCommandSender();
  public static Integer lastMessageStamp = Utils.getUnixTimestamp(0L);

  public XMPPer() {
    FileConfiguration cnf = CommandsEX.getConf();
    if (cnf.getBoolean("xmppEnabled")) {
      LogHelper.logInfo("[CommandsEX] " + _("xmppConnecting", ""));
      cmdPrefix = cnf.getString("xmppCommandPrefix", "#");
      participantNicks = new HashMap<String, String>();
      xmppConnection = new XMPPConnection(cnf.getString("xmppHost", "localhost"));
      try {
        xmppConnection.connect();
        if (cnf.getString("xmppUser", "").equals("")) {
          LogHelper.logInfo(_("xmppAnonymousLogin", ""));
          xmppConnection.loginAnonymously();
        } else {
          xmppConnection.login(cnf.getString("xmppUser"), cnf.getString("xmppPassword", ""));
        }
        // Only do this if the connection didn't fail
        DiscussionHistory history = new DiscussionHistory();
        history.setMaxStanzas(0);
        chatRoom = new MultiUserChat(xmppConnection, cnf.getString("xmppRoom.name"));
        chatRoom.addMessageListener(this);
        chatRoom.addParticipantStatusListener(this);
        chatRoom.addSubjectUpdatedListener(this);
        chatRoom.addUserStatusListener(this);
        try {
          chatRoom.join(cnf.getString("xmppBotNick", "CommandsEX"), cnf.getString("xmppRoom.password", ""), history, SmackConfiguration.getPacketReplyTimeout());
          for (Occupant occupant : chatRoom.getParticipants()) {
            participantNicks.put(occupant.getJid(), occupant.getNick());
          }
        } catch(XMPPException e) {
          LogHelper.logSevere("[CommandsEX] " + _("xmppUnableToJoinRoom", ""));
View Full Code Here

Examples of org.bukkit.configuration.file.FileConfiguration

   * The actual delayed task to check for timed promotions and promote as needed.
   * Used in 2 places - delayed task and Quit event.
   */
  public static void checkTimedPromotions(Player...players) {
    // load up settings from config file
    FileConfiguration f = CommandsEX.getConf();
    ConfigurationSection configGroups = f.getConfigurationSection("timedPromote");
    boolean promoteSet = CommandsEX.getConf().getBoolean("promoteSet");
   
    // no groups defined
    if (configGroups == null) {
      return;
    }
   
    Map<String, Integer> settings = new HashMap<String, Integer>();
    List<?> exclusions = CommandsEX.getConf().getList("timedPromoteExclude", new ArrayList<String>());
    Set<String> keys = configGroups.getKeys(true);
   
    if (keys.size() > 0) {
      for (String s : keys) {
        // ignore default group with time 0, since that one is an example record
        if (s.equals("default") && (f.getInt("timedPromote." + s) == 0)) continue;
        settings.put(s, f.getInt("timedPromote." + s));
      }
    }
   
    // run through all online players and check their playtime
    Iterator<Entry<String, Integer>> it = CommandsEX.playTimes.entrySet().iterator();
View Full Code Here

Examples of org.bukkit.configuration.file.FileConfiguration

   * The actual delayed task to check for economy-based promotions and promote as needed.
   * Used in 2 places - delayed task and Quit event.
   */
  public static void checkEcoPromotions(Player...players) {
    // load up settings from config file
    FileConfiguration f = CommandsEX.getConf();
    ConfigurationSection configGroups = f.getConfigurationSection("ecoPromote");
    boolean promoteSet = CommandsEX.getConf().getBoolean("promoteSet");
   
    // no groups defined
    if (configGroups == null) {
      return;
    }
   
    Map<String, Double> settings = new HashMap<String, Double>();
    List<?> exclusions = CommandsEX.getConf().getList("ecoPromoteExclude", new ArrayList<String>());
    Boolean checkDemotions = f.getBoolean("ecoPromoteAutoDemote");
    Set<String> keys = configGroups.getKeys(true);
   
    if (keys.size() > 0) {
      for (String s : configGroups.getKeys(true)) {
        // ignore default group with wealth of 0, since that one is an example record
        if (s.equals("default") && (f.getInt("ecoPromote." + s) == 0)) continue;
        settings.put(s, f.getDouble("ecoPromote." + s));
      }
    }
   
    // run through all online players and check their wealth
    for(Player p : Bukkit.getServer().getOnlinePlayers()) {
View Full Code Here

Examples of org.bukkit.configuration.file.FileConfiguration

      LogHelper.logDebug("[CommandsEX] time2rank could not be invoked because Vault or at least 1 permission plugin is not present");
      return true;
    }
   
    // load up settings from config file
    FileConfiguration f = CommandsEX.getConf();
    ConfigurationSection configGroups = f.getConfigurationSection("timedPromote");
    Player p = (Player)sender;
    Long currentGroupTime = f.getLong("timedPromote." + Vault.perms.getPrimaryGroup(p));
    Long nextGroupTime = 9223372036854775807L; // maximum value of LONG in Java
    String nextRankName = "?";
    for (String s : configGroups.getKeys(true)) {
      // ignore default group with time 0, since that one is an example record
      Long t = f.getLong("timedPromote." + s);
      if (s.equals("default") && (t == 0)) continue;
     
      // check if this group has more time set than current one and set it as the next group's time
      if (t > currentGroupTime) {
        // if our current time for next group is higher than the one we found now, use the one we found,
View Full Code Here

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

Examples of org.bukkit.configuration.file.FileConfiguration

  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

Examples of org.bukkit.configuration.file.FileConfiguration

    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

Examples of org.bukkit.configuration.file.FileConfiguration

  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

Examples of org.bukkit.configuration.file.FileConfiguration

  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

Examples of org.bukkit.configuration.file.FileConfiguration

* @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
TOP
Copyright © 2018 www.massapi.com. 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.