Пример #1
0
 public void addComments(Configuration config) {
   String comments = "";
   comments += "# Word Replace Version 8.0\n";
   comments += "# Changing Word1 -> Word2 since 2011 (Not that long)\n";
   comments += "\n";
   comments += "# Supported colors are: (case insensitive)\n";
   comments += "# - Black(&0)             Dark_Gray(&8)\n";
   comments += "# - Dark_Blue(&1)         Blue(&9)\n";
   comments += "# - Dark_Green(&2)        Green(&a)\n";
   comments += "# - Dark_Aqua(&3)         Aqua(&b)\n";
   comments += "# - Dark_Red(&4)          Red(&c)\n";
   comments += "# - Dark_Purple(&5)       Light_Purple(&d)\n";
   comments += "# - Gold(&6)              Yellow(&e)\n";
   comments += "# - Gray(&7)              White(&f)\n";
   comments += "# - You can also use Pink for Light_Purple and RAND for Random Colors\n";
   comments += "# This defaults to WHITE if it finds an error\n";
   comments += "\n";
   comments += "# the replace-user-names node is if you want it so that when a user FULLY\n";
   comments += "# types in the name of another user, it is colored. Set to false to disable,\n";
   comments += "# set to true for random colors, currently cannot set the color.\n";
   comments += "\n";
   comments += "# An Example is \"AQUA,Admin,dcsiira:dc:siira\"\n";
   comments +=
       "# Which replaces the words \"dc\",\"dcsiira\",\"siira\",\"Admin\" with \"Admin\", Colored in AQUA\n";
   config.setHeader(comments);
 }
Пример #2
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.");
  }
Пример #3
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.");
  }