-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master'
- Loading branch information
Showing
12 changed files
with
439 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package myessentials.curse; | ||
|
||
import com.google.gson.Gson; | ||
|
||
import java.io.BufferedReader; | ||
import java.io.IOException; | ||
import java.io.InputStreamReader; | ||
import java.net.MalformedURLException; | ||
import java.net.URL; | ||
|
||
public final class Curse { | ||
private Curse() { | ||
} | ||
|
||
/** | ||
* Gets CurseModInfo using the mcf widget api. http://widget.mcf.li/ | ||
* @param projectid The CurseForge project ID | ||
* @return The CurseModInfo object | ||
* @throws IOException | ||
*/ | ||
public static CurseModInfo getModInfo(String projectid) throws IOException { | ||
URL url = new URL("http://widget.mcf.li/mc-mods/minecraft/" + projectid + ".json"); | ||
BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream())); | ||
return (new Gson()).fromJson(reader, CurseModInfo.class); | ||
} | ||
|
||
/** | ||
* Returns a direct download link of the file for the modid | ||
* @param projectid The CurseForge | ||
* @param downloadid The download id | ||
* @return The download URL | ||
* @throws MalformedURLException | ||
*/ | ||
public static URL getDownloadURL(String projectid, String downloadid) throws MalformedURLException { | ||
return new URL("http://minecraft.curseforge.com/mc-mods/" + projectid + "/files/" + downloadid + "/download"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
package myessentials.curse; | ||
|
||
import java.util.Map; | ||
|
||
public class CurseModInfo { | ||
private String title; | ||
private String game; | ||
private String category; | ||
private String url; | ||
private String thumbnail; | ||
private String[] authors; | ||
// TODO Downloads Counters | ||
private int favorites; | ||
private int likes; | ||
private String updated_at; | ||
private String created_at; | ||
private String project_url; | ||
private String release_type; | ||
private String license; | ||
private VersionInfo download; | ||
private Map<String, VersionInfo[]> versions; | ||
|
||
public VersionInfo[] getVersions(String mcVersion) { | ||
return versions.get(mcVersion); | ||
} | ||
|
||
public VersionInfo getNewestVersion(String mcVersion) { | ||
VersionInfo newest = null; | ||
for (VersionInfo versionInfo : getVersions(mcVersion)) { | ||
if (newest == null || versionInfo.getId() > newest.getId()) { | ||
newest = versionInfo; | ||
} | ||
} | ||
return newest; | ||
} | ||
|
||
public String getTitle() { | ||
return title; | ||
} | ||
|
||
public String getGame() { | ||
return game; | ||
} | ||
|
||
public String getCategory() { | ||
return category; | ||
} | ||
|
||
public String getUrl() { | ||
return url; | ||
} | ||
|
||
public String getThumbnail() { | ||
return thumbnail; | ||
} | ||
|
||
public String[] getAuthors() { | ||
return authors; | ||
} | ||
|
||
public int getFavorites() { | ||
return favorites; | ||
} | ||
|
||
public int getLikes() { | ||
return likes; | ||
} | ||
|
||
public String getUpdated_at() { | ||
return updated_at; | ||
} | ||
|
||
public String getCreated_at() { | ||
return created_at; | ||
} | ||
|
||
public String getProject_url() { | ||
return project_url; | ||
} | ||
|
||
public String getRelease_type() { | ||
return release_type; | ||
} | ||
|
||
public String getLicense() { | ||
return license; | ||
} | ||
|
||
public VersionInfo getDownload() { | ||
return download; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package myessentials.curse; | ||
|
||
public class VersionInfo { | ||
private int id; | ||
private String url; | ||
private String name; | ||
private String type; | ||
private String version; | ||
private int downloads; | ||
private String created_at; | ||
|
||
public int getId() { | ||
return id; | ||
} | ||
|
||
public String getUrl() { | ||
return url; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public String getType() { | ||
return type; | ||
} | ||
|
||
public String getVersion() { | ||
return version; | ||
} | ||
|
||
public int getDownloads() { | ||
return downloads; | ||
} | ||
|
||
public String getCreated_at() { | ||
return created_at; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
package myessentials.new_config; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
/** | ||
* Marks a class as a Config. | ||
* | ||
* Not currently used, but there are plans! | ||
*/ | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target(ElementType.TYPE) | ||
public @interface Config { | ||
/** | ||
* The filename of the config class | ||
* @return | ||
*/ | ||
String value() default ""; | ||
|
||
/** | ||
* The configuration backend to load (forge or json) | ||
* @return | ||
*/ | ||
String backend() default "forge"; | ||
|
||
/** | ||
* Marks a field to hold the ConfigData | ||
*/ | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target(ElementType.FIELD) | ||
@interface Instance { | ||
} | ||
|
||
/** | ||
* Marks a class as a config group | ||
*/ | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target(ElementType.TYPE) | ||
@interface Group { | ||
/** | ||
* Returns the name of the category. | ||
* If set to empty string or null, name will be name of the class its attached to. | ||
* | ||
* @return | ||
*/ | ||
String name() default ""; | ||
|
||
/** | ||
* Returns the comment of the category. | ||
* | ||
* @return Comment of the category | ||
*/ | ||
String comment() default ""; | ||
|
||
Class<?>[] classes() default {}; | ||
} | ||
|
||
/** | ||
* Marks a field as a config property | ||
*/ | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target(ElementType.FIELD) | ||
@interface Property { | ||
/** | ||
* Returns the name of the property. | ||
* If set to empty string or null, name will be name of the field its attached to. | ||
* | ||
* @return Name of property | ||
*/ | ||
String name() default ""; | ||
|
||
/** | ||
* Returns the comment of the property. | ||
* | ||
* @return Comment of the property | ||
*/ | ||
String comment() default ""; | ||
|
||
/** | ||
* Returns if this property can be changed by commands. | ||
* | ||
* @return Can be changed by commands | ||
*/ | ||
boolean command() default true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 0 additions & 27 deletions
27
src/main/java/myessentials/new_config/annotations/ConfigGroup.java
This file was deleted.
Oops, something went wrong.
32 changes: 0 additions & 32 deletions
32
src/main/java/myessentials/new_config/annotations/ConfigProperty.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.