Skip to content

Commit 6872717

Browse files
author
TheProgramSrc
committed
Change log:
• Removed Messaging Service due to multiple bugs • Added SongodaUpdateChecker and SpigotUpdateChecker • Added Extra Requirements for Logs Filter
1 parent 41b5238 commit 6872717

File tree

13 files changed

+98
-148
lines changed

13 files changed

+98
-148
lines changed

SuperCoreAPI.iml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,14 @@
4949
<orderEntry type="library" scope="PROVIDED" name="Maven: org.xerial:sqlite-jdbc:3.25.2" level="project" />
5050
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.logging.log4j:log4j-core:2.5" level="project" />
5151
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.logging.log4j:log4j-api:2.5" level="project" />
52+
<orderEntry type="module-library">
53+
<library>
54+
<CLASSES>
55+
<root url="jar://$USER_HOME$/Desktop/Plugins/Spigot/Premium/UltraPermissions.jar!/" />
56+
</CLASSES>
57+
<JAVADOC />
58+
<SOURCES />
59+
</library>
60+
</orderEntry>
5261
</component>
5362
</module>

dependency-reduced-pom.xml

Lines changed: 14 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>3.1.0</version>
7+
<version>3.4.0</version>
88
<build>
99
<sourceDirectory>src/main/java</sourceDirectory>
1010
<defaultGoal>clean package</defaultGoal>
@@ -124,7 +124,7 @@
124124
<dependency>
125125
<groupId>org.spigotmc</groupId>
126126
<artifactId>spigot</artifactId>
127-
<version>1.15.2-R0.1-20200509.094844-17</version>
127+
<version>1.15.2-R0.1-20200625.172449-18</version>
128128
<scope>provided</scope>
129129
</dependency>
130130
<dependency>
@@ -139,6 +139,18 @@
139139
<version>3.25.2</version>
140140
<scope>provided</scope>
141141
</dependency>
142+
<dependency>
143+
<groupId>org.apache.logging.log4j</groupId>
144+
<artifactId>log4j-core</artifactId>
145+
<version>2.5</version>
146+
<scope>provided</scope>
147+
<exclusions>
148+
<exclusion>
149+
<artifactId>log4j-api</artifactId>
150+
<groupId>org.apache.logging.log4j</groupId>
151+
</exclusion>
152+
</exclusions>
153+
</dependency>
142154
</dependencies>
143155
<distributionManagement>
144156
<repository>

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>3.3.2</version>
9+
<version>3.4.0</version>
1010
<packaging>jar</packaging>
1111

1212
<name>SuperCoreAPI</name>

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

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -143,14 +143,6 @@ default void addDisableHook(Runnable runnable){
143143
*/
144144
PLUGIN getPlugin();
145145

146-
/**
147-
* Returns the plugin messaging channel name
148-
* @return Plugin messaging channel name
149-
*/
150-
default String getPluginMessagingChannelName(){
151-
return this.getPluginName().toLowerCase().replaceAll(" ", "") + ":messagingchannel";
152-
}
153-
154146
/**
155147
* Gets the dependency manager
156148
* @return Dependency Manager

src/main/java/xyz/theprogramsrc/supercoreapi/bungee/events/BungeeEventManager.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ public class BungeeEventManager extends BungeeModule {
1010

1111
public BungeeEventManager(BungeePlugin plugin) {
1212
super(plugin);
13-
getProxy().registerChannel(this.getPlugin().getPluginMessagingChannelName());
1413
}
1514

1615
}

src/main/java/xyz/theprogramsrc/supercoreapi/bungee/events/messagingService/BungeeMessageReceiver.java

Lines changed: 0 additions & 29 deletions
This file was deleted.

src/main/java/xyz/theprogramsrc/supercoreapi/bungee/events/messagingService/BungeeMessageSender.java

Lines changed: 0 additions & 47 deletions
This file was deleted.

src/main/java/xyz/theprogramsrc/supercoreapi/global/LogsFilter.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public LogsFilter(FilterResult result, String... filteredStrings){
2727
private Result process(String message){
2828
if(message != null){
2929
String msg = message.toLowerCase();
30-
if(Arrays.stream(this.filteredStrings).anyMatch(s-> msg.contains(s.toLowerCase()))){
30+
if(Arrays.stream(this.filteredStrings).anyMatch(s-> msg.contains(s.toLowerCase()) && Arrays.stream(this.getExtraRequirements()).anyMatch(s1-> msg.contains(s1.toLowerCase())))){
3131
return Result.toResult(this.result.name(), Result.NEUTRAL);
3232
}
3333
}
@@ -55,6 +55,14 @@ public Result filter(Logger logger, Level level, Marker marker, String msg, Obje
5555
return this.process(msg);
5656
}
5757

58+
/**
59+
* An array of strings that will be checked if a message contains one of those to filter the message
60+
* @return the strings
61+
*/
62+
public String[] getExtraRequirements(){
63+
return new String[0];
64+
}
65+
5866
public static enum FilterResult{
5967
DENY,
6068
NEUTRAL,
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package xyz.theprogramsrc.supercoreapi.global.updater;
2+
3+
import com.google.gson.JsonObject;
4+
import com.google.gson.JsonParser;
5+
import xyz.theprogramsrc.supercoreapi.global.utils.Utils;
6+
7+
public abstract class SongodaUpdateChecker {
8+
9+
private final String apiEndpoint;
10+
11+
public SongodaUpdateChecker(String product){
12+
this.apiEndpoint = "https://songoda.com/api/v2/products/" + product;
13+
}
14+
15+
public void checkUpdates(){
16+
try{
17+
String content = Utils.readWithInputStream(this.apiEndpoint);
18+
if(content == null){
19+
this.onFailCheck();
20+
}else{
21+
JsonObject data = new JsonParser().parse(content).getAsJsonObject();
22+
JsonObject json = data.get("versions").getAsJsonArray().get(0).getAsJsonObject();
23+
String version = json.get("version").getAsString();
24+
this.onSuccessCheck(version);
25+
}
26+
}catch (Exception ex){
27+
ex.printStackTrace();
28+
this.onFailCheck();
29+
}
30+
}
31+
32+
public abstract void onFailCheck();
33+
34+
public abstract void onSuccessCheck(String lastVersion);
35+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package xyz.theprogramsrc.supercoreapi.global.updater;
2+
3+
import xyz.theprogramsrc.supercoreapi.global.utils.Utils;
4+
5+
public abstract class SpigotUpdateChecker {
6+
7+
private final String apiEndpoint;
8+
9+
public SpigotUpdateChecker(String pluginId){
10+
this.apiEndpoint = "https://api.spigotmc.org/legacy/update.php?resource=" + pluginId;
11+
}
12+
13+
public void check(){
14+
try{
15+
String content = Utils.readWithInputStream(this.apiEndpoint);
16+
if(content == null){
17+
this.onCheckFail();
18+
}else{
19+
this.onCheckSuccess(content);
20+
}
21+
}catch (Exception ex){
22+
ex.printStackTrace();
23+
this.onCheckFail();
24+
}
25+
}
26+
27+
public abstract void onCheckSuccess(String lastVersion);
28+
29+
public abstract void onCheckFail();
30+
}

0 commit comments

Comments
 (0)