예제 #1
0
	@Override
	public void shutdown() {
		
		theLogger.info("Stopping the Bukkit API " + version);
		int pollCount = 0;
		while (pollCount < 50 && getScheduler().getActiveWorkers().size() > 0) {
			try {
				Thread.sleep(50);
			} catch (InterruptedException e) {}
			pollCount++;
		}

		List<BukkitWorker> overdueWorkers = getScheduler().getActiveWorkers();
		for (BukkitWorker worker : overdueWorkers) {
			Plugin plugin = worker.getOwner();
			String author = "<NoAuthorGiven>";
			if (plugin.getDescription().getAuthors().size() > 0) {
				author = plugin.getDescription().getAuthors().get(0);
			}
			getLogger().log(Level.SEVERE, String.format(
					"Nag author: '%s' of '%s' about the following: %s",
					author,
					plugin.getDescription().getName(),
					"This plugin is not properly shutting down its async tasks when it is being reloaded.  This may cause conflicts with the newly loaded version of the plugin"
					));
		}
		getPluginManager().disablePlugins();
		//theServer.stopServer();

	}
예제 #2
0
 private void enableSubPlugins() {
   File root = new File(getDataFolder(), Setting.SUBPLUGIN_FOLDER.asString());
   if (!root.exists() || !root.isDirectory()) return;
   File[] files = root.listFiles();
   for (File file : files) {
     Plugin plugin;
     try {
       plugin = Bukkit.getPluginManager().loadPlugin(file);
     } catch (Exception e) {
       continue;
     }
     if (plugin == null) continue;
     // code beneath modified from CraftServer
     try {
       Messaging.logTr(Messages.LOADING_SUB_PLUGIN, plugin.getDescription().getFullName());
       plugin.onLoad();
     } catch (Throwable ex) {
       Messaging.severeTr(
           Messages.ERROR_INITALISING_SUB_PLUGIN,
           ex.getMessage(),
           plugin.getDescription().getFullName());
       ex.printStackTrace();
     }
   }
   ((CraftServer) Bukkit.getServer()).enablePlugins(PluginLoadOrder.POSTWORLD);
 }
예제 #3
0
  @Override
  public void onEnable() {
    pdfFile = this.getDescription();
    logPrefix = "[" + pdfFile.getName() + "] ";
    PluginManager pm = getServer().getPluginManager();
    pm.registerEvents(new TTBlockListener(this), this);

    Plugin spout = pm.getPlugin("Spout");
    if (spout != null && spout.isEnabled()) {
      this.spoutEnabled = true;
      String v = spout.getDescription().getVersion();
      log.info(logPrefix + "Spout detected! Using version " + v);
    }

    Plugin permissionsEx = pm.getPlugin("PermissionsEx");
    Plugin permissions = pm.getPlugin("Permissions");
    if (permissionsEx != null && permissionsEx.isEnabled()) {
      permissionsExHandler = PermissionsEx.getPermissionManager();
      String v = permissionsEx.getDescription().getVersion();
      log.info(logPrefix + "PermissionsEx detected! Using version " + v);
    } else if (permissions != null && permissions.isEnabled()) {
      permissionsHandler = ((Permissions) permissions).getHandler();
      String v = permissions.getDescription().getVersion();
      log.info(logPrefix + "Permissions detected! Using version " + v);
    }

    log.info(logPrefix + "Version " + pdfFile.getVersion() + " is enabled!");
  }
예제 #4
0
  public Permission_Xperms(Plugin plugin) {
    this.plugin = plugin;
    Bukkit.getServer()
        .getPluginManager()
        .registerEvents(new PermissionServerListener(this), plugin);

    if (perms == null) {
      Plugin perms = plugin.getServer().getPluginManager().getPlugin("Xperms");
      if (perms != null) {
        if (perms.isEnabled()) {
          try {
            if (Double.valueOf(perms.getDescription().getVersion()) < 1.1) {
              log.info(
                  String.format(
                      "[%s] [Permission] %s Current version is not compatible with vault! Please Update!",
                      plugin.getDescription().getName(), name));
            }
          } catch (NumberFormatException e) {
            // version is first release, numbered 1.0.0
            log.info(
                String.format(
                    "[%s] [Permission] %s Current version is not compatibe with vault! Please Update!",
                    plugin.getDescription().getName(), name));
          }
        }
        perms = (Xmain) perms;
        log.info(
            String.format("[%s][Permission] %s hooked.", plugin.getDescription().getName(), name));
      }
    }
  }
예제 #5
0
  /** @author CraftCraft */
  public void loadPlugins() {
    pluginManager.registerInterface(JavaPluginLoader.class);

    File pluginFolder = theServer.getFile("plugins");

    if (pluginFolder.exists()) {
      this.theLogger.info("Plugins are being loaded...");
      Plugin[] plugins = pluginManager.loadPlugins(pluginFolder);
      for (Plugin plugin : plugins) {
        try {
          String message = String.format("Loading %s", plugin.getDescription().getFullName());
          plugin.getLogger().info(message);
          plugin.onLoad();
        } catch (Throwable ex) {
          Logger.getLogger(CraftServer.class.getName())
              .log(
                  Level.SEVERE,
                  ex.getMessage()
                      + " initializing "
                      + plugin.getDescription().getFullName()
                      + " (Is it up to date?)",
                  ex);
        }
      }
    } else {
      theLogger.info("Plugin folder doesn't exist: " + pluginFolder.getAbsolutePath());
      pluginFolder.mkdir();
    }
  }
예제 #6
0
  /*
   * @author CraftCraft
   */
  private void loadPlugin(Plugin plugin) {
    try {
      pluginManager.enablePlugin(plugin);

      List<Permission> perms = plugin.getDescription().getPermissions();

      for (Permission perm : perms) {
        try {
          pluginManager.addPermission(perm);
        } catch (IllegalArgumentException ex) {
          getLogger()
              .log(
                  Level.WARNING,
                  "Plugin "
                      + plugin.getDescription().getFullName()
                      + " tried to register permission '"
                      + perm.getName()
                      + "' but it's already registered",
                  ex);
        }
      }
    } catch (Throwable ex) {
      Logger.getLogger(CraftServer.class.getName())
          .log(
              Level.SEVERE,
              ex.getMessage()
                  + " loading "
                  + plugin.getDescription().getFullName()
                  + " (Is it up to date?)",
              ex);
    }
  }
예제 #7
0
 private boolean versionCheck(String title) {
   if (type != UpdateType.NO_VERSION_CHECK) {
     String version = plugin.getDescription().getVersion();
     if (title.split("v").length == 2) {
       String remoteVersion =
           title.split("v")[1].split(" ")[0]; // Get the newest file's version number
       if (hasTag(version) || version.equalsIgnoreCase(remoteVersion)) {
         // We already have the latest version, or this build is tagged for no-update
         result = Updater.UpdateResult.NO_UPDATE;
         return false;
       }
     } else {
       // The file's name did not contain the string 'vVersion'
       plugin
           .getLogger()
           .warning("The author of this plugin has misconfigured their Auto Update system");
       plugin
           .getLogger()
           .warning(
               "Files uploaded to BukkitDev should contain the version number, seperated from the name by a 'v', such as PluginName v1.0");
       plugin
           .getLogger()
           .warning(
               "Please notify the author ("
                   + plugin.getDescription().getAuthors().get(0)
                   + ") of this error.");
       result = Updater.UpdateResult.FAIL_NOVERSION;
       return false;
     }
   }
   return true;
 }
예제 #8
0
  public static void initialize(Server server) {
    Plugin permissionsEx = server.getPluginManager().getPlugin("PermissionsEx");
    Plugin groupManager = server.getPluginManager().getPlugin("GroupManager");
    Plugin permissions = server.getPluginManager().getPlugin("Permissions");

    if (permissionsEx != null) {
      permissionPlugin = permissionsEx;
      handler = PermissionHandler.PERMISSIONSEX;
      String version = permissionsEx.getDescription().getVersion();
      WarpLogger.info("Permissions enabled using: PermissionsEx v" + version);
    } else if (groupManager != null) {
      permissionPlugin = groupManager;
      handler = PermissionHandler.GROUPMANAGER;
      String version = groupManager.getDescription().getVersion();
      WarpLogger.info("Permissions enabled using: GroupManager v" + version);
    } else if (permissions != null) {
      permissionPlugin = permissions;
      String version = permissions.getDescription().getVersion();
      if (version.contains("3.")) {
        handler = PermissionHandler.PERMISSIONS3;
      } else {
        handler = PermissionHandler.PERMISSIONS;
      }
      WarpLogger.info("Permissions enabled using: Permissions v" + version);
    } else if (server.getPluginManager().getPermissions() != null) {
      handler = PermissionHandler.SUPERPERMS;
      WarpLogger.info("Permissions enabled using: SuperPerms");
    } else {
      handler = PermissionHandler.NONE;
      WarpLogger.warning("A permission plugin isn't loaded.");
    }
  }
예제 #9
0
  public void start() throws Exception {
    if (!plugin.isEnabled()) return;
    if (!enabled) return;
    BottomLine.debug("Searching for update...");

    HttpURLConnection c =
        (HttpURLConnection) new URL("http://www.spigotmc.org/api/general.php").openConnection();
    c.setDoOutput(true);
    c.setRequestMethod("POST");
    c.getOutputStream()
        .write(
            ("key=98BE0FE67F88AB82B4C197FAF1DC3B69206EFDCC4D3B80FC83A00037510B99B4&resource=" + id)
                .getBytes("UTF-8"));

    String current = plugin.getDescription().getVersion();
    String vers =
        new BufferedReader(new InputStreamReader(c.getInputStream()))
            .readLine()
            .replaceAll("[a-zA-Z ]", "");
    if (compareVersions(vers, current) == 1) {
      BottomLine.debug("Found new version, " + vers + "! (Currently running " + current + ")");
      BottomLine.debug("Download at: http://www.spigotmc.org/resources/bottomline." + id);

      BottomLine.update = true;

      newvers = vers;
      oldvers = plugin.getDescription().getVersion();
    } else {
      BottomLine.debug("No new update found to download!");
    }
  }
예제 #10
0
  /**
   * Enable all plugins of the given load order type.
   *
   * @param type The type of plugin to enable.
   */
  public void enablePlugins(PluginLoadOrder type) {
    Plugin[] plugins = pluginManager.getPlugins();
    for (Plugin plugin : plugins) {
      if (!plugin.isEnabled() && plugin.getDescription().getLoad() == type) {
        List<Permission> perms = plugin.getDescription().getPermissions();
        for (Permission perm : perms) {
          try {
            pluginManager.addPermission(perm);
          } catch (IllegalArgumentException ex) {
            getLogger()
                .log(
                    Level.WARNING,
                    "Plugin "
                        + plugin.getDescription().getFullName()
                        + " tried to register permission '"
                        + perm.getName()
                        + "' but it's already registered",
                    ex);
          }
        }

        try {
          pluginManager.enablePlugin(plugin);
        } catch (Throwable ex) {
          logger.log(Level.SEVERE, "Error loading {0}", plugin.getDescription().getFullName());
          ex.printStackTrace();
        }
      }
    }
  }
  public static void initialize(Server server) {
    Plugin permissionsEx = server.getPluginManager().getPlugin("PermissionsEx");
    Plugin groupManager = server.getPluginManager().getPlugin("GroupManager");
    Plugin permissions = server.getPluginManager().getPlugin("Permissions");

    if (permissionsEx != null) {
      permissionPlugin = permissionsEx;
      handler = PermissionHandler.PERMISSIONSEX;
      String version = permissionsEx.getDescription().getVersion();
      ButtonControlLogger.info("Permissions enabled using: PermissionsEx v" + version);
    } else if (groupManager != null) {
      permissionPlugin = groupManager;
      handler = PermissionHandler.GROUPMANAGER;
      String version = groupManager.getDescription().getVersion();
      ButtonControlLogger.info("Permissions enabled using: GroupManager v" + version);
    } else if (permissions != null) {
      permissionPlugin = permissions;
      handler = PermissionHandler.PERMISSIONS;
      String version = permissions.getDescription().getVersion();
      ButtonControlLogger.info("Permissions enabled using: Permissions v" + version);
    } else {
      handler = PermissionHandler.NONE;
      ButtonControlLogger.warning("A permission plugin isn't loaded.");
    }
  }
예제 #12
0
  /** Generic method that posts a plugin to the metrics website */
  private void postPlugin(boolean isPing) throws IOException {
    // The plugin's description file containg all of the plugin data such as name, version, author,
    // etc
    final PluginDescriptionFile description = plugin.getDescription();

    // Construct the post data
    final StringBuilder data = new StringBuilder();
    data.append(encode("guid")).append('=').append(encode(guid));
    encodeDataPair(data, "version", description.getVersion());
    encodeDataPair(data, "server", Bukkit.getVersion());
    encodeDataPair(data, "players", Integer.toString(Bukkit.getServer().getOnlinePlayers().length));
    encodeDataPair(data, "revision", String.valueOf(REVISION));

    // If we're pinging, append it
    if (isPing) {
      encodeDataPair(data, "ping", "true");
    }

    // Create the url
    URL url =
        new URL(BASE_URL + String.format(REPORT_URL, encode(plugin.getDescription().getName())));

    // Connect to the website
    URLConnection connection;

    // Mineshafter creates a socks proxy, so we can safely bypass it
    // It does not reroute POST requests so we need to go around it
    if (isMineshafterPresent()) {
      connection = url.openConnection(Proxy.NO_PROXY);
    } else {
      connection = url.openConnection();
    }

    connection.setDoOutput(true);

    // Write the data
    final OutputStreamWriter writer = new OutputStreamWriter(connection.getOutputStream());
    writer.write(data.toString());
    writer.flush();

    // Now read the response
    final BufferedReader reader =
        new BufferedReader(new InputStreamReader(connection.getInputStream()));
    final String response = reader.readLine();

    // close resources
    writer.close();
    reader.close();

    if (response == null || response.startsWith("ERR")) {
      throw new IOException(response); // Throw the exception
    }
    // if (response.startsWith("OK")) - We should get "OK" followed by an optional description if
    // everything goes right
  }
예제 #13
0
  /**
   * Obtains all the plugins currently enabled on the server.
   *
   * @return A <code>List</code> of <code>Map</code>s of plugins with their name and version.
   */
  private static List<Map<String, String>> getPluginList() {
    Plugin[] plugins = minequery.getServer().getPluginManager().getPlugins();
    List<Map<String, String>> pluginList = new ArrayList<Map<String, String>>();

    for (Plugin plugin : plugins) {
      Map<String, String> pluginMap = new HashMap<String, String>();
      pluginMap.put("name", plugin.getDescription().getName());
      pluginMap.put("version", plugin.getDescription().getVersion());
      pluginList.add(pluginMap);
    }

    return pluginList;
  }
예제 #14
0
 public GenericCustomItem(Plugin plugin, String name) {
   super(
       name,
       318,
       mm.registerCustomItemName(plugin, plugin.getDescription().getName() + "." + name));
   this.fullName = plugin.getDescription().getName() + "." + name;
   this.customId = mm.registerCustomItemName(plugin, fullName);
   this.plugin = plugin;
   this.setName(name);
   MaterialData.addCustomItem(this);
   for (SpoutPlayer player : Spout.getServer().getOnlinePlayers()) {
     player.sendPacket(this);
   }
 }
 public static void onEnable(Plugin plugin) {
   String pluginName = plugin.getDescription().getName();
   if (pluginName.equals("LWC") && lwc == null) {
     lwc = ((LWCPlugin) plugin).getLWC();
     if (!TSettings.LowDetailMode) {
       TLogger.info("LWC version " + plugin.getDescription().getVersion() + " loaded.");
     }
   }
   if (pluginName.equals("Lockette") && lockette == null) {
     lockette = (Lockette) plugin;
     if (!TSettings.LowDetailMode) {
       TLogger.info("Lockette version " + plugin.getDescription().getVersion() + " loaded.");
     }
   }
 }
예제 #16
0
  /** Loads all plugins, calling onLoad, &c. */
  private void loadPlugins() {
    // clear the map
    commandMap.clearCommands();
    commandMap.register("glowstone", new ColorCommand("colors"));
    commandMap.register("glowstone", new TellrawCommand());

    File folder = new File(config.getString(ServerConfig.Key.PLUGIN_FOLDER));
    if (!folder.isDirectory() && !folder.mkdirs()) {
      logger.log(Level.SEVERE, "Could not create plugins directory: " + folder);
    }

    // clear plugins and prepare to load
    pluginManager.clearPlugins();
    pluginManager.registerInterface(JavaPluginLoader.class);
    Plugin[] plugins = pluginManager.loadPlugins(folder);

    // call onLoad methods
    for (Plugin plugin : plugins) {
      try {
        plugin.onLoad();
      } catch (Exception ex) {
        logger.log(Level.SEVERE, "Error loading " + plugin.getDescription().getFullName(), ex);
      }
    }
  }
예제 #17
0
  private void registerPluginIds() {
    if (pluginIds.isEmpty()) {
      for (Plugin plugin : Bukkit.getServer().getPluginManager().getPlugins()) {
        if (pluginIds.containsKey(plugin)) {
          VoxelGuest.log(
              "Attempted to register multiple IDs for plugin \""
                  + plugin.getDescription().getName()
                  + "\"",
              1);
          continue;
        }

        String sample = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890";
        char[] key = new char[16];
        Random rand = new Random();

        for (int i = 0; i < 16; i++) {
          key[i] = sample.charAt(rand.nextInt(sample.length()));
        }

        String id = new String(key);
        pluginIds.put(plugin, id);
      }
    }
  }
예제 #18
0
  public void enablePlugin(final Plugin plugin) {
    if (!(plugin instanceof JavaPlugin)) {
      throw new IllegalArgumentException("Plugin is not associated with this PluginLoader");
    }

    if (!plugin.isEnabled()) {
      JavaPlugin jPlugin = (JavaPlugin) plugin;

      String pluginName = jPlugin.getDescription().getName();

      if (!loaders.containsKey(pluginName)) {
        loaders.put(pluginName, (PluginClassLoader) jPlugin.getClassLoader());
      }

      try {
        jPlugin.setEnabled(true);
      } catch (Throwable ex) {
        server
            .getLogger()
            .log(
                Level.SEVERE,
                "Error occurred while enabling "
                    + plugin.getDescription().getFullName()
                    + " (Is it up to date?): "
                    + ex.getMessage(),
                ex);
      }

      // Perhaps abort here, rather than continue going, but as it stands,
      // an abort is not possible the way it's currently written
      server.getPluginManager().callEvent(new PluginEnableEvent(plugin));
    }
  }
예제 #19
0
 /**
  * Initialize the updater
  *
  * @param plugin The plugin that is checking for an update.
  * @param slug The dev.bukkit.org slug of the project
  *     (http://dev.bukkit.org/server-mods/SLUG_IS_HERE)
  * @param file The file that the plugin is running from, get this by doing this.getFile() from
  *     within your main class.
  * @param type Specify the type of update this will be. See {@link UpdateType}
  * @param announce True if the program should announce the progress of new updates in console
  */
 public Updater(Plugin plugin, String slug, File file, UpdateType type, boolean announce) {
   this.plugin = plugin;
   this.type = type;
   this.announce = announce;
   this.file = file;
   try {
     // Obtain the results of the project's file feed
     url = new URL(DBOUrl + slug + "/files.rss");
   } catch (MalformedURLException ex) {
     // Invalid slug
     plugin
         .getLogger()
         .warning(
             "The author of this plugin ("
                 + plugin.getDescription().getAuthors().get(0)
                 + ") has misconfigured their Auto Update system");
     plugin
         .getLogger()
         .warning(
             "The project slug given ('"
                 + slug
                 + "') is invalid. Please nag the author about this.");
     result = Updater.UpdateResult.FAIL_BADSLUG; // Bad slug! Bad!
   }
   thread = new Thread(new UpdateRunnable());
   thread.start();
 }
 public static AWEAdaptor getAWEAdaptor() {
   if (adaptor == null) {
     Plugin awe = getAWE();
     if (awe != null) {
       VersionUtil.Version version = VersionUtil.getVersion(awe.getDescription().getVersion());
       String className = null;
       if (version.isLT("3.0")) {
         className = "us.talabrek.ultimateskyblock.handler.asyncworldedit.AWE211Adaptor";
       } else if (version.isLT("3.2.0")) {
         className = "us.talabrek.ultimateskyblock.handler.asyncworldedit.AWE311Adaptor";
       } else {
         className = "us.talabrek.ultimateskyblock.handler.asyncworldedit.AWE321Adaptor";
       }
       try {
         adaptor = (AWEAdaptor) Class.forName(className).<AWEAdaptor>newInstance();
       } catch (InstantiationException
           | IllegalAccessException
           | ClassNotFoundException
           | NoClassDefFoundError e) {
         log.log(Level.WARNING, "Unable to locate AWE adaptor for version " + version + ": " + e);
         adaptor = NULL_ADAPTOR;
       }
     } else {
       adaptor = NULL_ADAPTOR;
     }
   }
   return adaptor;
 }
예제 #21
0
  public int registerCustomItemName(Plugin plugin, String key) {
    int id = UniqueItemStringMap.getId(key);

    itemPlugin.put(id, plugin.getDescription().getName());

    return id;
  }
예제 #22
0
파일: General.java 프로젝트: cjc343/General
 private void setupOtherPlugins() {
   // setup permissions and iconomy
   Plugin plugin = this.getServer().getPluginManager().getPlugin("Permissions");
   if (General.Permissions == null) {
     if (plugin != null) {
       General.Permissions = (Permissions) plugin;
       System.out.println("[" + General.name + "] hooked into Permissions.");
     }
   }
   Plugin p2 = this.getServer().getPluginManager().getPlugin("iConomy");
   if (General.iConomy == null) {
     if (p2 != null) {
       General.iConomy = (iConomy) p2;
       System.out.println("[" + General.name + "] hooked into iConomy.");
     }
   }
   // set up command registry
   for (Plugin p : getServer().getPluginManager().getPlugins()) {
     if (p.isEnabled()) {
       if (p != null && !p.getDescription().getName().equalsIgnoreCase(General.name)) {
         iListen.checkPluginCommands(p);
       }
     }
   }
 }
예제 #23
0
  private void printVersion(CommandSender sender) {
    PluginDescriptionFile desc = plugin.getDescription();

    sender.sendMessage(
        ChatColor.GREEN
            + desc.getName()
            + ChatColor.WHITE
            + " v"
            + ChatColor.GREEN
            + desc.getVersion());
    sender.sendMessage(
        ChatColor.WHITE
            + "Authors: "
            + ChatColor.GREEN
            + "dmulloy2"
            + ChatColor.WHITE
            + " and "
            + ChatColor.GREEN
            + "Comphenix");
    sender.sendMessage(
        ChatColor.WHITE
            + "Issues: "
            + ChatColor.GREEN
            + "https://github.com/dmulloy2/ProtocolLib/issues");
  }
예제 #24
0
 public GenericBlockDesign(
     float lowXBound,
     float lowYBound,
     float lowZBound,
     float highXBound,
     float highYBound,
     float highZBound,
     String textureURL,
     Plugin texturePlugin,
     float[][] xPos,
     float[][] yPos,
     float[][] zPos,
     float[][] textXPos,
     float[][] textYPos,
     int renderPass) {
   this.lowXBound = lowXBound;
   this.lowYBound = lowYBound;
   this.lowZBound = lowZBound;
   this.highXBound = highXBound;
   this.highYBound = highYBound;
   this.highZBound = highZBound;
   this.textureURL = textureURL;
   this.texturePlugin = texturePlugin.getDescription().getName();
   this.xPos = xPos;
   this.yPos = yPos;
   this.zPos = zPos;
   this.textXPos = textXPos;
   this.textYPos = textYPos;
   this.renderPass = renderPass;
 }
예제 #25
0
  /** Loads all plugins, calling onLoad, &c. */
  private void loadPlugins() {
    // clear the map
    commandMap.removeAllOfType(PluginCommand.class);

    File folder = new File(config.getString("server.folders.plugins", "plugins"));
    folder.mkdirs();

    // clear plugins and prepare to load
    pluginManager.clearPlugins();
    pluginManager.registerInterface(JavaPluginLoader.class);
    Plugin[] plugins = pluginManager.loadPlugins(folder);

    // call onLoad methods
    for (Plugin plugin : plugins) {
      try {
        plugin.onLoad();
      } catch (Exception ex) {
        logger.log(
            Level.SEVERE,
            "Error loading {0}: {1}",
            new Object[] {plugin.getDescription().getName(), ex.getMessage()});
        ex.printStackTrace();
      }
    }
  }
예제 #26
0
 public static void hasUpdate(Player player) {
   try {
     HttpURLConnection c =
         (HttpURLConnection) new URL("http://www.spigotmc.org/api/general.php").openConnection();
     c.setDoOutput(true);
     c.setRequestMethod("POST");
     c.getOutputStream()
         .write(
             ("key=98BE0FE67F88AB82B4C197FAF1DC3B69206EFDCC4D3B80FC83A00037510B99B4&resource=17599")
                 .getBytes("UTF-8"));
     String oldVersion = plugin.getDescription().getVersion();
     String newVersion =
         new BufferedReader(new InputStreamReader(c.getInputStream()))
             .readLine()
             .replaceAll("[a-zA-Z ]", "");
     if (!newVersion.equals(oldVersion)) {
       player.sendMessage(
           getPrefix()
               + color(
                   "&cYour server is running &7v"
                       + oldVersion
                       + "&c and the newest is &7v"
                       + newVersion
                       + "&c."));
     }
   } catch (Exception e) {
     return;
   }
 }
예제 #27
0
 private void setupSpout(PluginManager pm) {
   Plugin spout = pm.getPlugin("Spout");
   if (spout != null && spout.isEnabled()) {
     spoutEnabled = true;
     MiscUtil.log(Level.INFO, "Loaded Spout v" + spout.getDescription().getVersion());
   }
 }
예제 #28
0
  /**
   * Generic method that posts a plugin to the metrics website
   *
   * @param plugin
   */
  private void postPlugin(Plugin plugin, boolean isPing) throws IOException {
    // Construct the post data
    String response = "ERR No response";
    String data =
        encode("guid")
            + '='
            + encode(guid)
            + gField("version", plugin.getDescription().getVersion())
            + gField("server", Bukkit.getVersion())
            + gField("players", String.valueOf(Bukkit.getServer().getOnlinePlayers().length))
            + gField("revision", String.valueOf(REVISION));

    // If we're pinging, append it
    if (isPing) {
      data += gField("ping", "true");
    }

    // Add any custom data (if applicable)
    Set<Plotter> plotters = customData.get(plugin);

    if (plotters != null) {
      for (Plotter plotter : plotters) {
        data += gField("Custom" + plotter.getColumnName(), Integer.toString(plotter.getValue()));
      }
    }

    // Create the url
    URL url = new URL(BASE_URL + String.format(REPORT_URL, plugin.getDescription().getName()));

    // Connect to the website
    URLConnection connection = url.openConnection();
    connection.setDoOutput(true);

    // Write the data
    OutputStreamWriter writer = new OutputStreamWriter(connection.getOutputStream());
    writer.write(data);
    writer.flush();

    // Now read the response
    BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
    response = reader.readLine();

    // close resources
    writer.close();
    reader.close();
    if (response.startsWith("ERR")) throw new IOException(response);
  }
	public final void addPlugin(final Plugin plugin)
	{
		if (plugin.getDescription().getMain().contains("com.earth2me.essentials"))
		{
			return;
		}
		final List<Command> commands = PluginCommandYamlParser.parse(plugin);
		final String pluginName = plugin.getDescription().getName().toLowerCase(Locale.ENGLISH);

		for (Command command : commands)
		{
			final PluginCommand pc = (PluginCommand)command;
			final List<String> labels = new ArrayList<String>(pc.getAliases());
			labels.add(pc.getName());

			PluginCommand reg = ess.getServer().getPluginCommand(pluginName + ":" + pc.getName().toLowerCase(Locale.ENGLISH));
			if (reg == null)
			{
				reg = ess.getServer().getPluginCommand(pc.getName().toLowerCase(Locale.ENGLISH));
			}
			if (reg == null || !reg.getPlugin().equals(plugin))
			{
				continue;
			}
			for (String label : labels)
			{
				List<PluginCommand> plugincommands = altcommands.get(label.toLowerCase(Locale.ENGLISH));
				if (plugincommands == null)
				{
					plugincommands = new ArrayList<PluginCommand>();
					altcommands.put(label.toLowerCase(Locale.ENGLISH), plugincommands);
				}
				boolean found = false;
				for (PluginCommand pc2 : plugincommands)
				{
					if (pc2.getPlugin().equals(plugin))
					{
						found = true;
					}
				}
				if (!found)
				{
					plugincommands.add(reg);
				}
			}
		}
	}
예제 #30
0
 @EventHandler
 public void command(PlayerCommandPreprocessEvent event) {
   Player p = event.getPlayer();
   String command = event.getMessage().replaceFirst("/", "");
   if (command.equalsIgnoreCase("versionchecker")) {
     p.sendMessage("Running VersionChecker in " + plugin.getDescription().getFullName());
   }
 }