Skip to content

Commit 93259ab

Browse files
author
Francisco Solis
committed
Performance Improvements and Fixes
* Removed Update Checker for the API * Fixed SuperCoreAPICommand#executePasteCommand * Added test execution to the maven workflow
1 parent 1ee0893 commit 93259ab

8 files changed

Lines changed: 28 additions & 55 deletions

File tree

.github/workflows/maven.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
with:
1111
java-version: 1.8
1212
- name: Build with Maven
13-
run: mvn -B package --file pom.xml
13+
run: mvn -B package test --file pom.xml
1414
- run: mkdir -p ./artifacts
1515
- run: cp target/SuperCoreAPI.jar ./artifacts/
1616
- uses: actions/upload-artifact@v2

SuperCoreAPI.iml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@
3131
<orderEntry type="library" scope="PROVIDED" name="Maven: net.md-5:bungeecord-event:1.16-R0.5-SNAPSHOT" level="project" />
3232
<orderEntry type="library" scope="PROVIDED" name="Maven: net.md-5:bungeecord-protocol:1.16-R0.5-SNAPSHOT" level="project" />
3333
<orderEntry type="library" scope="PROVIDED" name="Maven: net.md-5:brigadier:1.0.16-SNAPSHOT" level="project" />
34-
<orderEntry type="library" scope="PROVIDED" name="Maven: io.netty:netty-codec:4.1.58.Final" level="project" />
34+
<orderEntry type="library" scope="PROVIDED" name="Maven: io.netty:netty-codec:4.1.63.Final" level="project" />
3535
<orderEntry type="library" scope="PROVIDED" name="Maven: net.sf.trove4j:core:3.1.0" level="project" />
3636
<orderEntry type="library" scope="PROVIDED" name="Maven: se.llbit:jo-nbt:1.3.0" level="project" />
37-
<orderEntry type="library" scope="PROVIDED" name="Maven: io.netty:netty-transport-native-unix-common:4.1.58.Final" level="project" />
38-
<orderEntry type="library" scope="PROVIDED" name="Maven: io.netty:netty-common:4.1.58.Final" level="project" />
39-
<orderEntry type="library" scope="PROVIDED" name="Maven: io.netty:netty-buffer:4.1.58.Final" level="project" />
40-
<orderEntry type="library" scope="PROVIDED" name="Maven: io.netty:netty-transport:4.1.58.Final" level="project" />
41-
<orderEntry type="library" scope="PROVIDED" name="Maven: io.netty:netty-resolver:4.1.58.Final" level="project" />
37+
<orderEntry type="library" scope="PROVIDED" name="Maven: io.netty:netty-transport-native-unix-common:4.1.63.Final" level="project" />
38+
<orderEntry type="library" scope="PROVIDED" name="Maven: io.netty:netty-common:4.1.63.Final" level="project" />
39+
<orderEntry type="library" scope="PROVIDED" name="Maven: io.netty:netty-buffer:4.1.63.Final" level="project" />
40+
<orderEntry type="library" scope="PROVIDED" name="Maven: io.netty:netty-transport:4.1.63.Final" level="project" />
41+
<orderEntry type="library" scope="PROVIDED" name="Maven: io.netty:netty-resolver:4.1.63.Final" level="project" />
4242
<orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot:1.16.5-R0.1-SNAPSHOT" level="project" />
4343
<orderEntry type="library" scope="PROVIDED" name="Maven: org.slf4j:slf4j-nop:1.7.30" level="project" />
4444
<orderEntry type="library" scope="PROVIDED" name="Maven: org.slf4j:slf4j-api:1.7.25" level="project" />

dependency-reduced-pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<groupId>xyz.theprogramsrc</groupId>
55
<artifactId>SuperCoreAPI</artifactId>
66
<name>SuperCoreAPI</name>
7-
<version>4.12.0_BETA1</version>
7+
<version>4.13.0</version>
88
<build>
99
<sourceDirectory>src/main/java</sourceDirectory>
1010
<testSourceDirectory>src/test/java</testSourceDirectory>
@@ -155,7 +155,7 @@
155155
<dependency>
156156
<groupId>org.spigotmc</groupId>
157157
<artifactId>spigot</artifactId>
158-
<version>1.16.5-R0.1-20210308.215741-8</version>
158+
<version>1.16.5-R0.1-SNAPSHOT</version>
159159
<scope>provided</scope>
160160
</dependency>
161161
<dependency>

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.12.5</version>
9+
<version>4.13.0</version>
1010
<packaging>jar</packaging>
1111

1212
<name>SuperCoreAPI</name>
Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
package xyz.theprogramsrc.supercoreapi;
22

33

4-
import xyz.theprogramsrc.supercoreapi.global.updater.SongodaUpdateChecker;
5-
import xyz.theprogramsrc.supercoreapi.global.utils.VersioningUtil;
6-
74
/**
85
* This is a set of utils that need to be loaded before everything
96
*/
@@ -13,27 +10,6 @@ public class Base {
1310

1411
public Base(SuperPlugin<?> plugin){
1512
this.plugin = plugin;
16-
this.updateChecker();
1713
}
1814

19-
public void updateChecker(){
20-
new SongodaUpdateChecker("supercoreapi-the-best-way-to-create-a-plugin"){
21-
@Override
22-
public void onFailCheck() {
23-
Base.this.plugin.log("&cError while checking &4SuperCoreAPI &cupdates.");
24-
}
25-
26-
@Override
27-
public void onSuccessCheck(String lastVersion) {
28-
int check = VersioningUtil.checkVersions(Base.this.plugin.SUPER_CORE_API_VERSION, lastVersion);
29-
if(check == 1){
30-
Base.this.plugin.log("&cNew update available for &3SuperCoreAPI &7("+lastVersion+")");
31-
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.");
32-
}else if(check == 2){
33-
Base.this.plugin.log("&cIt seems like you're running a non-release version of &3SuperCoreAPI");
34-
Base.this.plugin.log("&cUnless you're the developer, you must use the version &7" + lastVersion);
35-
}
36-
}
37-
}.checkUpdates();
38-
}
3915
}

src/main/java/xyz/theprogramsrc/supercoreapi/SuperPlugin.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@
1616
*/
1717
public interface SuperPlugin<PLUGIN> {
1818

19-
/*
20-
* This need to be updated on every new release
21-
*/
22-
String SUPER_CORE_API_VERSION = "4.12.5";
23-
2419
/**
2520
* Gets if this plugin is paid, By default is set to true, but is recommended to change it if your plugin is free.
2621
* @return Whether the plugin is paid or not

src/main/java/xyz/theprogramsrc/supercoreapi/spigot/commands/precreated/SuperCoreAPICommand.java

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,14 @@ protected void executeInfoCommand(CommandSender sender){
2727
}
2828

2929

30-
String coreVersion = this.plugin.SUPER_CORE_API_VERSION,
31-
serverVersion = Bukkit.getVersion(),
30+
String serverVersion = Bukkit.getVersion(),
3231
nmsVersion = ReflectionUtils.VERSION,
3332
os = System.getProperty("os.name"),
3433
ram = format.format(Runtime.getRuntime().maxMemory() / (1024 * 1024)) + "Mb",
3534
currentPlayers = Bukkit.getOnlinePlayers().size()+"",
3635
bungee = this.plugin.isBungeeInstance()+"",
3736
lastErrors = this.plugin.getLastErrors().size()+"";
3837
this.getSuperUtils().sendMessage(sender, "&bServer information:");
39-
this.getSuperUtils().sendMessage(sender, "&7SuperCoreAPI Version: &9" + coreVersion);
4038
this.getSuperUtils().sendMessage(sender, String.format("&7%s Version: &9%s", this.plugin.getPluginName(), this.plugin.getPluginVersion()));
4139
this.getSuperUtils().sendMessage(sender, "&7Server Version: &9" + serverVersion);
4240
this.getSuperUtils().sendMessage(sender, "&7NMS Version: &9" + nmsVersion);
@@ -61,20 +59,24 @@ protected void executeInfoCommand(CommandSender sender){
6159
}
6260

6361
protected void executePasteCommand(CommandSender sender){
64-
StringBuilder builder = new StringBuilder();
65-
builder.append(Utils.exceptionToString(this.plugin.getLastError())).append("\n\n");
66-
builder.append("Server ID: ").append(this.plugin.getPluginDataStorage().getString("stats_id"));
67-
try{
68-
String key = Utils.uploadPaste(builder.toString());
69-
if(key == null){
62+
if(!this.plugin.getLastErrors().isEmpty()){
63+
StringBuilder builder = new StringBuilder();
64+
builder.append(Utils.exceptionToString(this.plugin.getLastError())).append("\n\n");
65+
builder.append("Server ID: ").append(this.plugin.getPluginDataStorage().getString("stats_id"));
66+
try{
67+
String key = Utils.uploadPaste(builder.toString());
68+
if(key == null){
69+
this.getSuperUtils().sendMessage(sender, "&cUnable to upload paste to https://paste.theprogramsrc.xyz/");
70+
}else{
71+
this.getSuperUtils().sendMessage(sender, "&aPaste successfully uploaded to&c https://paste.theprogramsrc.xyz/" + key);
72+
this.plugin.removeError(this.plugin.getLastErrors().size()-1);
73+
}
74+
}catch (IOException e){
7075
this.getSuperUtils().sendMessage(sender, "&cUnable to upload paste to https://paste.theprogramsrc.xyz/");
71-
}else{
72-
this.getSuperUtils().sendMessage(sender, "&aPaste successfully uploaded to&c https://paste.theprogramsrc.xyz/" + key);
73-
this.plugin.removeError(this.plugin.getLastErrors().size()-1);
76+
e.printStackTrace();
7477
}
75-
}catch (IOException e){
76-
this.getSuperUtils().sendMessage(sender, "&cUnable to upload paste to https://paste.theprogramsrc.xyz/");
77-
e.printStackTrace();
78+
}else{
79+
this.getSuperUtils().sendMessage(sender, "&cNo previous errors found. Try again later.");
7880
}
7981
}
8082
}

src/main/java/xyz/theprogramsrc/supercoreapi/spigot/dialog/Dialog.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public void openDialog(){
5252
this.debug("Opening dialog with title '" + this.getTitle() + "&r'");
5353

5454
if(this.task == null){
55-
this.task = this.getSpigotTasks().runRepeatingTask(1L, 1L, this::sendTitleAndActionbar);
55+
this.task = this.getSpigotTasks().runAsyncRepeatingTask(1L, 1L, this::sendTitleAndActionbar);
5656
}else{
5757
this.task.start();
5858
}

0 commit comments

Comments
 (0)