Skip to content

Commit 1cafa31

Browse files
author
TheProgramSrc
committed
v4.2.2 Changelog:
+ Added API Update Checker + Now the API can be added as jar file to the plugins folder * Fixes with Songoda Update Checker
1 parent 833209a commit 1cafa31

File tree

9 files changed

+101
-6
lines changed

9 files changed

+101
-6
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## v4.2.2 Changelog:
2+
```
3+
+ Added API Update Checker
4+
+ Now the API can be added as jar file to the plugins folder
5+
* Fixes with Songoda Update Checker
6+
```
7+
18
## v4.2.1 Changelog:
29
```
310
+ Now the API check if the MojangAPI (https://sessionserver.mojang.com) is down.

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>xyz.theprogramsrc</groupId>
88
<artifactId>SuperCoreAPI</artifactId>
9-
<version>4.2.1</version>
9+
<version>4.2.2</version>
1010
<packaging>jar</packaging>
1111

1212
<name>SuperCoreAPI</name>
Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,42 @@
11
package xyz.theprogramsrc;
22

33

4+
import xyz.theprogramsrc.supercoreapi.SuperPlugin;
5+
import xyz.theprogramsrc.supercoreapi.global.updater.SpigotUpdateChecker;
6+
47
/**
58
* This is a set of utils that need to be loaded
6-
*
7-
* TODO
89
*/
910
public class Base {
1011

11-
public Base(){
12+
private final SuperPlugin<?> plugin;
13+
14+
public Base(SuperPlugin<?> plugin){
15+
this.plugin = plugin;
16+
this.loadUpdateChecker();
17+
}
18+
19+
private void loadUpdateChecker(){
20+
new SpigotUpdateChecker("77096"){
21+
22+
@Override
23+
public void onCheckFail() {
24+
Base.this.plugin.log("&cError while checking &4SuperCoreAPI &cupdates.");
25+
}
1226

27+
@Override
28+
public void onCheckSuccess(String lastVersion) {
29+
String currentVersion = "4.2.2";
30+
int latest = Integer.parseInt(lastVersion.split(" ")[0].replaceAll("\\.", ""));
31+
int current = Integer.parseInt(currentVersion.split(" ")[0].replaceAll("\\.", ""));
32+
if(latest > current){
33+
Base.this.plugin.log("&cNew update available for &3SuperCoreAPI &7("+lastVersion+")");
34+
Base.this.plugin.log("&cIf you're the developer of the plugin update the API, if you're a customer of a plugin using &3SuperCoreAPI&c please notify to the Developer.");
35+
}else if(latest < current){
36+
Base.this.plugin.log("&cIt seems like you're running a non-release version of &3SuperCoreAPI");
37+
Base.this.plugin.log("&cUnless you're the developer, you must use the version &7" + lastVersion);
38+
}
39+
}
40+
}.check();
1341
}
1442
}

src/main/java/xyz/theprogramsrc/supercoreapi/global/updater/SongodaUpdateChecker.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public void checkUpdates(){
1818
if(content == null){
1919
this.onFailCheck();
2020
}else{
21-
JsonObject data = new JsonParser().parse(content).getAsJsonObject();
21+
JsonObject data = new JsonParser().parse(content).getAsJsonObject().get("data").getAsJsonObject();
2222
JsonObject json = data.get("versions").getAsJsonArray().get(0).getAsJsonObject();
2323
String version = json.get("version").getAsString();
2424
this.onSuccessCheck(version);
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package xyz.theprogramsrc.supercoreapi.plugin;
2+
3+
import net.md_5.bungee.api.ChatColor;
4+
import net.md_5.bungee.api.chat.TextComponent;
5+
import net.md_5.bungee.api.plugin.Plugin;
6+
7+
public class BungeePlugin extends Plugin {
8+
9+
@Override
10+
public void onEnable() {
11+
this.log("&3SuperCoreAPI &awas loaded as .jar file");
12+
}
13+
14+
@Override
15+
public void onDisable() {
16+
this.log("&3SuperCoreAPI &awas disabled");
17+
}
18+
19+
private void log(String s){
20+
this.getProxy().getConsole().sendMessage(new TextComponent(c(s)));
21+
}
22+
23+
private String c(String s){
24+
return ChatColor.translateAlternateColorCodes('&', s);
25+
}
26+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package xyz.theprogramsrc.supercoreapi.plugin;
2+
3+
import org.bukkit.Bukkit;
4+
import org.bukkit.ChatColor;
5+
import org.bukkit.plugin.java.JavaPlugin;
6+
7+
public class SpigotPlugin extends JavaPlugin {
8+
9+
@Override
10+
public void onEnable() {
11+
this.log("&3SuperCoreAPI &awas loaded as .jar file");
12+
}
13+
14+
@Override
15+
public void onDisable() {
16+
this.log("&3SuperCoreAPI &awas disabled");
17+
}
18+
19+
private void log(String s){
20+
Bukkit.getConsoleSender().sendMessage(c(s));
21+
}
22+
23+
private String c(String s){
24+
return ChatColor.translateAlternateColorCodes('&', s);
25+
}
26+
}

src/main/java/xyz/theprogramsrc/supercoreapi/spigot/SpigotPlugin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public void onLoad() {
5555
long current = System.currentTimeMillis();
5656
i = this;
5757
this.emergencyStop = false;
58-
new xyz.theprogramsrc.Base();
58+
new xyz.theprogramsrc.Base(this);
5959
this.disableHooks = new ArrayList<>();
6060
this.serverFolder = Utils.folder(new File("."));
6161
this.firstStart = !this.getDataFolder().exists();

src/main/resources/bungee.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
name: SuperCoreAPI
2+
version: ${project.version}
3+
main: xyz.theprogramsrc.supercoreapi.plugin.BungeePlugin
4+
author: TheProgramSrc

src/main/resources/plugin.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
name: SuperCoreAPI
2+
version: ${project.version}
3+
main: xyz.theprogramsrc.supercoreapi.plugin.SpigotPlugin
4+
author: TheProgramSrc

0 commit comments

Comments
 (0)