Skip to content

Commit fcb0dcf

Browse files
author
TheProgramSrc
committed
Change Log:
• Changed way to close dialogs • Added Plugin Data Storage • Added Notifications • Bug Fixes
1 parent 41b5238 commit fcb0dcf

23 files changed

+366
-179
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,7 @@ Create the best plugins with better code, control and more!
4343
* [Patreon](https://go.theprogramsrc.xyz/patreon)
4444
* [Free Minecraft Hosting](https://go.theprogramsrc.xyz/aternos)
4545
* [Best Minecraft Hosting, VPS Hosting, Dedicated Hosting and more!](https://go.theprogramsrc.xyz/elixirnode)
46-
* [The one stop marketplace for all the Minecraft plugins you will ever need.](https://go.theprogramsrc.xyz/songoda)
46+
* [The one stop marketplace for all the Minecraft plugins you will ever need.](https://go.theprogramsrc.xyz/songoda)
47+
48+
<br>
49+
If you think there is a feature that shouldn't be here remember that this API is for TheProgramSrc's and PluginsSrc Projects.

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.5.0</version>
1010
<packaging>jar</packaging>
1111

1212
<name>SuperCoreAPI</name>

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

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import org.apache.logging.log4j.LogManager;
44
import org.apache.logging.log4j.core.Logger;
55
import xyz.theprogramsrc.supercoreapi.global.LogsFilter;
6+
import xyz.theprogramsrc.supercoreapi.global.data.PluginDataStorage;
67
import xyz.theprogramsrc.supercoreapi.global.dependencies.DependencyManager;
78
import xyz.theprogramsrc.supercoreapi.global.translations.TranslationManager;
89
import xyz.theprogramsrc.supercoreapi.global.translations.TranslationPack;
@@ -143,14 +144,6 @@ default void addDisableHook(Runnable runnable){
143144
*/
144145
PLUGIN getPlugin();
145146

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-
154147
/**
155148
* Gets the dependency manager
156149
* @return Dependency Manager
@@ -170,4 +163,10 @@ default void registerLogFilter(LogsFilter logsFilter){
170163
Logger consoleLogger = (Logger) LogManager.getRootLogger();
171164
consoleLogger.addFilter(logsFilter);
172165
}
166+
167+
/**
168+
* Gets the plugin data storage
169+
* @return
170+
*/
171+
PluginDataStorage getPluginDataStorage();
173172
}

src/main/java/xyz/theprogramsrc/supercoreapi/bungee/BungeePlugin.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import xyz.theprogramsrc.supercoreapi.bungee.events.BungeeEventManager;
99
import xyz.theprogramsrc.supercoreapi.bungee.storage.Settings;
1010
import xyz.theprogramsrc.supercoreapi.bungee.utils.BungeeUtils;
11+
import xyz.theprogramsrc.supercoreapi.global.data.PluginDataStorage;
1112
import xyz.theprogramsrc.supercoreapi.global.dependencies.Dependencies;
1213
import xyz.theprogramsrc.supercoreapi.global.dependencies.DependencyManager;
1314
import xyz.theprogramsrc.supercoreapi.global.dependencies.classloader.PluginClassLoader;
@@ -31,6 +32,8 @@ public abstract class BungeePlugin extends Plugin implements SuperPlugin<Plugin>
3132
private TranslationManager translationManager;
3233
private DependencyManager dependencyManager;
3334

35+
private PluginDataStorage pluginDataStorage;
36+
3437
@Override
3538
public void onLoad() {
3639
long start = System.currentTimeMillis();
@@ -40,6 +43,7 @@ public void onLoad() {
4043
this.disableHooks = new ArrayList<>();
4144
this.firstStart = !this.getDataFolder().exists();
4245
Utils.folder(this.getDataFolder());
46+
this.pluginDataStorage = new PluginDataStorage(this);
4347
this.onPluginLoad();
4448
if(this.emergencyStop) return;
4549
this.log("Loaded plugin in " + (System.currentTimeMillis() - start) + "ms");
@@ -159,7 +163,7 @@ public Settings getSettings() {
159163

160164
@Override
161165
public DependencyManager getDependencyManager() {
162-
return dependencyManager;
166+
return this.dependencyManager;
163167
}
164168

165169
/**
@@ -172,4 +176,13 @@ public void emergencyStop() {
172176
this.getProxy().getPluginManager().unregisterCommands(this);
173177
this.getProxy().getPluginManager().unregisterListeners(this);
174178
}
179+
180+
public boolean isEmergencyStop() {
181+
return this.emergencyStop;
182+
}
183+
184+
@Override
185+
public PluginDataStorage getPluginDataStorage() {
186+
return this.pluginDataStorage;
187+
}
175188
}

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: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package xyz.theprogramsrc.supercoreapi.global.data;
2+
3+
import com.google.gson.JsonArray;
4+
import com.google.gson.JsonObject;
5+
import xyz.theprogramsrc.supercoreapi.SuperPlugin;
6+
import xyz.theprogramsrc.supercoreapi.global.files.JsonConfig;
7+
import xyz.theprogramsrc.supercoreapi.global.notifications.Notification;
8+
import xyz.theprogramsrc.supercoreapi.global.notifications.NotificationCollection;
9+
10+
import java.util.ArrayList;
11+
import java.util.Arrays;
12+
import java.util.List;
13+
14+
public class PluginDataStorage extends JsonConfig {
15+
16+
public PluginDataStorage(SuperPlugin<?> plugin){
17+
super(plugin.getPluginFolder(), "PluginData.json");
18+
}
19+
20+
public void saveNotification(Notification notification){
21+
JsonArray data = this.getOrCreateArray("notifications");
22+
data.add(notification.toString());
23+
this.set("notifications", data);
24+
}
25+
26+
public void saveNotifications(Notification... notifications){
27+
Arrays.stream(notifications).forEach(this::saveNotification);
28+
}
29+
30+
public NotificationCollection getNotifications(){
31+
JsonArray data = this.getOrCreateArray("notifications");
32+
List<Notification> list = new ArrayList<>();
33+
data.forEach(j->{
34+
JsonObject json = j.getAsJsonObject();
35+
Notification not = Notification.builder()
36+
.setTitle(json.get("title").getAsString())
37+
.setContent(json.get("content").getAsString())
38+
.setCreatedAt(json.get("created_at").getAsLong())
39+
.build();
40+
list.add(not);
41+
});
42+
return new NotificationCollection(list);
43+
}
44+
45+
public Notification[] getNotificationsArray(){
46+
return this.getNotifications().get();
47+
}
48+
}

0 commit comments

Comments
 (0)