Skip to content

Commit

Permalink
Updated plugin.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
TheBusyBiscuit committed Apr 2, 2017
1 parent 402e3bd commit 976eccf
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 41 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/bin/
/.settings/
.classpath
.project
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package me.mrCookieSlime.CSCoreLibSetup;
package me.mrCookieSlime.ExoticGarden.CSCoreLibSetup;

import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
Expand Down Expand Up @@ -33,27 +34,26 @@ public CSCoreLibLoader(Plugin plugin) {
public boolean load() {
if (plugin.getServer().getPluginManager().isPluginEnabled("CS-CoreLib")) return true;
else {
System.err.println(" ");
System.err.println("#################### - INFO - ####################");
System.err.println(" ");
System.err.println(plugin.getName() + " could not be loaded.");
System.err.println("It appears that you have not installed CS-CoreLib");
System.err.println("Your Server will now try to download and install");
System.err.println("CS-CoreLib for you.");
System.err.println("You will be asked to restart your Server when it's finished.");
System.err.println("If this somehow fails, please download and install CS-CoreLib manually:");
System.err.println("https://dev.bukkit.org/projects/cs-corelib");
System.err.println(" ");
System.err.println("#################### - INFO - ####################");
System.err.println(" ");
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {

@Override
public void run() {
System.err.println(" ");
System.err.println("#################### - FATAL ERROR - ####################");
System.err.println(" ");
System.err.println(plugin.getName() + " could not be properly installed!");
System.err.println("It appears that you have not installed CS-CoreLib");
System.err.println("And because of that, CS-CoreLib is now going to be");
System.err.println("downloaded and installed.");
System.err.println("But for the time being " + plugin.getName() + " will remain disabled");
System.err.println("After the installation process has finished,");
System.out.println("you will be asked to restart your Server.");
System.err.println("- mrCookieSlime");
System.err.println(" ");
System.err.println("#################### - FATAL ERROR - ####################");
System.err.println(" ");
if (connect()) install();
}
}, 0L);
}, 10L);
return false;
}
}
Expand All @@ -67,22 +67,48 @@ private boolean connect() {

final BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
final JSONArray array = (JSONArray) JSONValue.parse(reader.readLine());
download = new URL((String) ((JSONObject) array.get(array.size() - 1)).get("downloadUrl"));
download = traceURL(((String) ((JSONObject) array.get(array.size() - 1)).get("downloadUrl")).replace("https:", "http:"));
file = new File("plugins/" + (String) ((JSONObject) array.get(array.size() - 1)).get("name") + ".jar");

return true;
} catch (IOException e) {
System.err.println(" ");
System.err.println("#################### - FATAL ERROR - ####################");
System.err.println("#################### - WARNING - ####################");
System.err.println(" ");
System.err.println("Could not connect to BukkitDev, is it down?");
System.err.println("Could not connect to BukkitDev.");
System.err.println("Please download & install CS-CoreLib manually:");
System.err.println("https://dev.bukkit.org/projects/cs-corelib");
System.err.println(" ");
System.err.println("#################### - FATAL ERROR - ####################");
System.err.println("#################### - WARNING - ####################");
System.err.println(" ");
return false;
}
}

private URL traceURL(String location) throws IOException {
HttpURLConnection connection = null;

while (true) {
URL url = new URL(location);
connection = (HttpURLConnection) url.openConnection();

connection.setInstanceFollowRedirects(false);
connection.setConnectTimeout(5000);
connection.addRequestProperty("User-Agent", "Auto Updater (by mrCookieSlime)");

switch (connection.getResponseCode()) {
case HttpURLConnection.HTTP_MOVED_PERM:
case HttpURLConnection.HTTP_MOVED_TEMP:
String loc = connection.getHeaderField("Location");
location = new URL(new URL(location), loc).toExternalForm();
continue;
}
break;
}

return new URL(connection.getURL().toString().replaceAll(" ", "%20"));
}

private void install() {
BufferedInputStream input = null;
FileOutputStream output = null;
Expand All @@ -97,23 +123,25 @@ private void install() {
}
} catch (Exception ex) {
System.err.println(" ");
System.err.println("#################### - FATAL ERROR - ####################");
System.err.println("#################### - WARNING - ####################");
System.err.println(" ");
System.err.println("Could not download CS-CoreLib");
System.err.println("Failed to download CS-CoreLib");
System.err.println("Please download & install CS-CoreLib manually:");
System.err.println("https://dev.bukkit.org/projects/cs-corelib");
System.err.println(" ");
System.err.println("#################### - FATAL ERROR - ####################");
System.err.println("#################### - WARNING - ####################");
System.err.println(" ");
} finally {
try {
if (input != null) input.close();
if (output != null) output.close();
System.err.println(" ");
System.err.println("#################### - WARNING - ####################");
System.err.println("#################### - INFO - ####################");
System.err.println(" ");
System.err.println("Please restart your Server to finish the Installation");
System.err.println("of " + plugin.getName() + " and CS-CoreLib");
System.err.println(" ");
System.err.println("#################### - WARNING - ####################");
System.err.println("#################### - INFO - ####################");
System.err.println(" ");
} catch (IOException e) {
e.printStackTrace();
Expand Down
26 changes: 13 additions & 13 deletions src/me/mrCookieSlime/ExoticGarden/ExoticGarden.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,18 @@
import java.util.List;
import java.util.Map;

import org.bukkit.Effect;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.material.MaterialData;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;

import me.mrCookieSlime.CSCoreLibPlugin.CSCoreLib;
import me.mrCookieSlime.CSCoreLibPlugin.PluginUtils;
import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config;
Expand All @@ -20,7 +32,7 @@
import me.mrCookieSlime.CSCoreLibPlugin.general.Player.PlayerInventory;
import me.mrCookieSlime.CSCoreLibPlugin.general.String.StringUtils;
import me.mrCookieSlime.CSCoreLibPlugin.general.World.CustomSkull;
import me.mrCookieSlime.CSCoreLibSetup.CSCoreLibLoader;
import me.mrCookieSlime.ExoticGarden.CSCoreLibSetup.CSCoreLibLoader;
import me.mrCookieSlime.Slimefun.Lists.Categories;
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.Lists.SlimefunItems;
Expand All @@ -33,18 +45,6 @@
import me.mrCookieSlime.Slimefun.Setup.SlimefunManager;
import me.mrCookieSlime.Slimefun.api.BlockStorage;

import org.bukkit.Effect;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.material.MaterialData;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;

public class ExoticGarden extends JavaPlugin {

static List<Berry> berries = new ArrayList<Berry>();
Expand Down
7 changes: 4 additions & 3 deletions src/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
name: ExoticGarden
version: 1.6.1
author: mrCookieSlime
website: http://dev.bukkit.org/profiles/mrCookieSlime/bukkit-plugins/
version: 1.6.2
authors: [mrCookieSlime, Goldentoenail]
description: A Slimefun Addon that adds new Plants and dishes to the game
website: http://TheBusyBiscuit.github.io/

main: me.mrCookieSlime.ExoticGarden.ExoticGarden

Expand Down

0 comments on commit 976eccf

Please sign in to comment.