Package ch.njol.skript.util

Examples of ch.njol.skript.util.Version


   * @param p
   */
  SkriptAddon(final JavaPlugin p) {
    plugin = p;
    name = "" + p.getName();
    Version v;
    try {
      v = new Version("" + p.getDescription().getVersion());
    } catch (final IllegalArgumentException e) {
      final Matcher m = Pattern.compile("(\\d+)(?:\\.(\\d+)(?:\\.(\\d+))?)?").matcher(p.getDescription().getVersion());
      if (!m.find())
        throw new IllegalArgumentException("The version of the plugin " + p.getName() + " does not contain any numbers: " + p.getDescription().getVersion());
      v = new Version(Utils.parseInt("" + m.group(1)), m.group(2) == null ? 0 : Utils.parseInt("" + m.group(2)), m.group(3) == null ? 0 : Utils.parseInt("" + m.group(3)));
      Skript.warning("The plugin " + p.getName() + " uses a non-standard version syntax: '" + p.getDescription().getVersion() + "'. Skript will use " + v + " instead.");
    }
    version = v;
  }
View Full Code Here


                  continue;
                final Object url = ((JSONObject) o).get("downloadUrl");
                if (!(url instanceof String))
                  continue;
               
                final Version version = new Version(((String) name).contains(" ") ? "" + ((String) name).substring(0, ((String) name).indexOf(' ')) : ((String) name));
                if (version.compareTo(Skript.getVersion()) > 0) {
                  infos.add(new VersionInfo((String) name, version, (String) url));
                }
              }
            }
          } finally {
View Full Code Here

      } catch (final IOException e) {}
    }
    final String v = en.get("version");
    if (v == null)
      Skript.warning("Missing version in english.lang");
    langVersion.put(addon.plugin, v == null ? Skript.getVersion() : new Version(v));
    en.remove("version");
    english.putAll(en);
    for (final LanguageChangeListener l : listeners)
      l.onLanguageChange();
  }
View Full Code Here

      return false;
    if (!l.containsKey("version")) {
      Skript.error(addon + "'s language file " + name + ".lang does not provide a version number!");
    } else {
      try {
        final Version v = new Version("" + l.get("version"));
        final Version lv = langVersion.get(addon.plugin);
        assert lv != null; // set in loadDefault()
        if (v.isSmallerThan(lv))
          Skript.warning(addon + "'s language file " + name + ".lang is outdated, some messages will be english.");
      } catch (final IllegalArgumentException e) {
        Skript.error("Illegal version syntax in " + addon + "'s language file " + name + ".lang: " + e.getLocalizedMessage());
View Full Code Here

 
  @Nullable
  private static Version version = null;
 
  public static Version getVersion() {
    final Version v = version;
    if (v == null)
      throw new IllegalStateException();
    return v;
  }
View Full Code Here

   
    Language.loadDefault(getAddonInstance());
   
    Workarounds.init();
   
    version = new Version("" + getDescription().getVersion());
    runningCraftBukkit = Bukkit.getServer().getClass().getName().equals("org.bukkit.craftbukkit.CraftServer");
    final String bukkitV = Bukkit.getBukkitVersion();
    final Matcher m = Pattern.compile("\\d+\\.\\d+(\\.\\d+)?").matcher(bukkitV);
    if (!m.find()) {
      Skript.error("The Bukkit version '" + bukkitV + "' does not contain a version number which is required for Skript to enable or disable certain features. " +
          "Skript will still work, but you might get random errors if you use features that are not available in your version of Bukkit.");
      minecraftVersion = new Version(666, 0, 0);
    } else {
      minecraftVersion = new Version("" + m.group());
    }
   
    if (!getDataFolder().isDirectory())
      getDataFolder().mkdirs();
   
View Full Code Here

   
    IOException ioEx = null;
    int unsuccessful = 0;
    final StringBuilder invalid = new StringBuilder();
   
    Version varVersion = Skript.getVersion(); // will be set later
   
    final Version v2_0_beta3 = new Version(2, 0, "beta 3");
    boolean update2_0_beta3 = false;
    final Version v2_1 = new Version(2, 1);
    boolean update2_1 = false;
   
    BufferedReader r = null;
    try {
      r = new BufferedReader(new InputStreamReader(new FileInputStream(file), UTF_8));
      String line = null;
      int lineNum = 0;
      while ((line = r.readLine()) != null) {
        lineNum++;
        line = line.trim();
        if (line.isEmpty() || line.startsWith("#")) {
          if (line.startsWith("# version:")) {
            try {
              varVersion = new Version("" + line.substring("# version:".length()).trim());
              update2_0_beta3 = varVersion.isSmallerThan(v2_0_beta3);
              update2_1 = varVersion.isSmallerThan(v2_1);
            } catch (final IllegalArgumentException e) {}
          }
          continue;
View Full Code Here

TOP

Related Classes of ch.njol.skript.util.Version

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.