Package com.comphenix.protocol.utility

Examples of com.comphenix.protocol.utility.MinecraftVersion


  /**
   * Reset the version string to the default state.
   */
  protected void resetVersion() {
    ProtocolManager manager = ProtocolLibrary.getProtocolManager();
    MinecraftVersion minecraftVersion = LAST_VERSION;
   
    // Fetch the latest known version
    if (manager != null) {
      minecraftVersion = manager.getMinecraftVersion();
    }
    version = VERSION_CONSTRUCTOR.invoke(minecraftVersion.toString(), VERSION_NUMBERS.get(minecraftVersion));
    VERSION.set(handle, version);
  }
View Full Code Here


      if (splitTitle.length == 2) {
        // Get the newest file's version number
                final String remoteVersion = splitTitle[1].split("-")[0];
               
                // Parse the version
                MinecraftVersion parsedRemote = new MinecraftVersion(remoteVersion);
                MinecraftVersion parsedCurrent = new MinecraftVersion(plugin.getDescription().getVersion());

                // The remote version has to be greater
                if (this.hasTag(version) || parsedRemote.compareTo(parsedCurrent) <= 0) {
                    // We already have the latest version, or this build is tagged for no-update
                    this.result = Updater.UpdateResult.NO_UPDATE;
View Full Code Here

    try {
      // Check for other versions
      checkConflictingVersions();
     
      // Handle unexpected Minecraft versions
      MinecraftVersion version = verifyMinecraftVersion();
     
      // Set updater - this will not perform any update automatically
      updater = new Updater(this, BUKKIT_DEV_ID, getFile(), UpdateType.NO_DOWNLOAD, true);
     
      unhookTask = new DelayedSingleTask(this);
View Full Code Here

    }
  }
 
  // Used to check Minecraft version
  private MinecraftVersion verifyMinecraftVersion() {
    MinecraftVersion minimum = new MinecraftVersion(MINIMUM_MINECRAFT_VERSION);
    MinecraftVersion maximum = new MinecraftVersion(MAXIMUM_MINECRAFT_VERSION);
   
    try {
      MinecraftVersion current = new MinecraftVersion(getServer());

      // Skip certain versions
      if (!config.getIgnoreVersionCheck().equals(current.getVersion())) {
        // We'll just warn the user for now
        if (current.compareTo(minimum) < 0)
          logger.warning("Version " + current + " is lower than the minimum " + minimum);
        if (current.compareTo(maximum) > 0)
          logger.warning("Version " + current + " has not yet been tested! Proceed with caution.");
       }
      return current;

    } catch (Exception e) {
View Full Code Here

    }
  }

  private void checkConflictingVersions() {
    Pattern ourPlugin = Pattern.compile("ProtocolLib-(.*)\\.jar");
    MinecraftVersion currentVersion = new MinecraftVersion(this.getDescription().getVersion());
    MinecraftVersion newestVersion = null;

    // Skip the file that contains this current instance however
    File loadedFile = getFile();
   
    try {
      // Scan the plugin folder for newer versions of ProtocolLib
      File pluginFolder = new File("plugins/");
     
      for (File candidate : pluginFolder.listFiles()) {
        if (candidate.isFile() && !candidate.equals(loadedFile)) {
          Matcher match = ourPlugin.matcher(candidate.getName());
         
          if (match.matches()) {
            MinecraftVersion version = new MinecraftVersion(match.group(1));

            if (candidate.length() == 0) {
              // Delete and inform the user
              logger.info((candidate.delete() ? "Deleted " : "Could not delete ") + candidate);
            } else if (newestVersion == null || newestVersion.compareTo(version) < 0) {
View Full Code Here

import com.comphenix.protocol.utility.SnapshotVersion;

public class MinecraftVersionTest {
  @Test
  public void testComparision() {
    MinecraftVersion within = new MinecraftVersion(1, 2, 5);
    MinecraftVersion outside = new MinecraftVersion(1, 7, 0);
   
    MinecraftVersion lower = new MinecraftVersion(1, 0, 0);
    MinecraftVersion highest = new MinecraftVersion(1, 4, 5);
   
    // Make sure this is valid
    assertTrue(lower.compareTo(within) < 0 && within.compareTo(highest) < 0);
    assertFalse(outside.compareTo(within) < 0 && outside.compareTo(highest) < 0);
  }
View Full Code Here

    assertFalse(outside.compareTo(within) < 0 && outside.compareTo(highest) < 0);
  }
 
  @Test
  public void testSnapshotVersion() {
    MinecraftVersion version = MinecraftVersion.fromServerVersion("git-Spigot-1119 (MC: 13w39b)");
    assertEquals(version.getSnapshot(), new SnapshotVersion("13w39b"));
  }
View Full Code Here

TOP

Related Classes of com.comphenix.protocol.utility.MinecraftVersion

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.