Skip to content

Commit ce5cd5f

Browse files
authored
Merge pull request #24 from tomkeuper/development
Release V1.0
2 parents 6aa223f + e0b72d2 commit ce5cd5f

File tree

17 files changed

+355
-10
lines changed

17 files changed

+355
-10
lines changed

.github/workflows/compile.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ on:
44
push:
55
branches-ignore:
66
- production
7-
- development
87
pull_request:
98
types:
109
- opened

.github/workflows/deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ jobs:
4949
with:
5050
target_commitish: production
5151
tag_name: ${{ env.RELEASE_VERSION }}
52-
release_name: Release ${{ env.RELEASE_VERSION }}
52+
name: Release ${{ env.RELEASE_VERSION }}
5353
generate_release_notes: true
5454
files: "target/proxy-*"
5555
deploy-package:

pom.xml

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

77
<groupId>com.tomkeuper.bedwars</groupId>
88
<artifactId>proxy</artifactId>
9-
<version>1.0-SNAPSHOT</version>
9+
<version>1.0</version>
1010
<modules>
1111
<module>proxy-api</module>
1212
<module>proxy-plugin</module>

proxy-api/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>proxy</artifactId>
77
<groupId>com.tomkeuper.bedwars</groupId>
8-
<version>1.0-SNAPSHOT</version>
8+
<version>1.0</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

proxy-api/src/main/java/com/tomkeuper/bedwars/proxy/api/BedWars.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.tomkeuper.bedwars.proxy.api;
22

3+
import com.tomkeuper.bedwars.proxy.api.addon.IAddonManager;
34
import com.tomkeuper.bedwars.proxy.api.communication.IRedisClient;
45
import com.tomkeuper.bedwars.proxy.api.database.Database;
56
import com.tomkeuper.bedwars.proxy.api.level.Level;
@@ -24,6 +25,11 @@ public interface BedWars {
2425
*/
2526
Level getLevelsUtil();
2627

28+
/**
29+
* Get addon util
30+
*/
31+
IAddonManager getAddonsUtil();
32+
2733
/**
2834
* Change the level interface.
2935
* @param level custom level class
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package com.tomkeuper.bedwars.proxy.api.addon;
2+
3+
import org.bukkit.plugin.Plugin;
4+
5+
public abstract class Addon {
6+
/**
7+
* Get the author of an addon
8+
*/
9+
public abstract String getAuthor();
10+
11+
/**
12+
* Get the addon plugin
13+
*/
14+
public abstract Plugin getPlugin();
15+
16+
/**
17+
* Get the version of an addon
18+
*/
19+
public abstract String getVersion();
20+
21+
/**
22+
* Get the name of an addon
23+
*/
24+
public abstract String getName();
25+
26+
/**
27+
* Get the identifier of an addon
28+
*/
29+
@SuppressWarnings("unused")
30+
public abstract String getDescription();
31+
32+
/**
33+
* Load everything from the addon
34+
* Listeners, config files, databases,...
35+
*/
36+
public abstract void load();
37+
38+
/**
39+
* Unload everything from the addon
40+
*/
41+
public abstract void unload();
42+
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
package com.tomkeuper.bedwars.proxy.api.addon;
2+
3+
import java.util.List;
4+
5+
/**
6+
* The manager responsible for handling addons.
7+
*/
8+
public interface IAddonManager {
9+
10+
/**
11+
* Get the list of registered addons.
12+
*
13+
* @return The list of registered addons.
14+
*/
15+
List<Addon> getAddons();
16+
17+
/**
18+
* Get the list of loaded addons.
19+
*
20+
* @return The list of loaded addons.
21+
*/
22+
List<Addon> getLoadedAddons();
23+
24+
/**
25+
* Get the list of unloaded addons.
26+
*
27+
* @return The list of unloaded addons.
28+
*/
29+
List<Addon> getUnloadedAddons();
30+
31+
/**
32+
* Get the list of addons created by a specific author.
33+
*
34+
* @param author The author of the addons.
35+
* @return The list of addons created by the specified author.
36+
*/
37+
List<Addon> getAddonsByAuthor(String author);
38+
39+
/**
40+
* Load an addon.
41+
*
42+
* @param addon The addon to load.
43+
*/
44+
void loadAddon(Addon addon);
45+
46+
/**
47+
* Unload an addon.
48+
*
49+
* @param addon The addon to unload.
50+
*/
51+
void unloadAddon(Addon addon);
52+
53+
/**
54+
* Unload every addon
55+
*/
56+
void unloadAddons();
57+
58+
/**
59+
* Load every addon
60+
*/
61+
void loadAddons();
62+
63+
/**
64+
* Register an addon.
65+
*
66+
* @param addon The addon to register.
67+
*/
68+
void registerAddon(Addon addon);
69+
}

proxy-api/src/main/java/com/tomkeuper/bedwars/proxy/api/communication/IRedisClient.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,13 @@
55

66
public interface IRedisClient {
77
void sendMessage(@NotNull JsonObject message, @NotNull String addonIdentifier);
8+
9+
/**
10+
* Retrieve the data associated with a specific identifier from the Redis database.
11+
* Settings can be stored by the BedWars plugin.
12+
*
13+
* @param redisSettingIdentifier the identifier of the setting to be checked.
14+
* @return the data as a string associated with the specified identifier
15+
*/
16+
String retrieveSetting(@NotNull String redisSettingIdentifier);
817
}

proxy-plugin/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>proxy</artifactId>
77
<groupId>com.tomkeuper.bedwars</groupId>
8-
<version>1.0-SNAPSHOT</version>
8+
<version>1.0</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

proxy-plugin/src/main/java/com/tomkeuper/bedwars/proxy/API.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.tomkeuper.bedwars.proxy;
22

33
import com.tomkeuper.bedwars.proxy.api.BedWars;
4+
import com.tomkeuper.bedwars.proxy.api.addon.IAddonManager;
45
import com.tomkeuper.bedwars.proxy.api.communication.IRedisClient;
56
import com.tomkeuper.bedwars.proxy.api.database.Database;
67
import com.tomkeuper.bedwars.proxy.api.level.Level;
@@ -38,6 +39,11 @@ public Level getLevelsUtil() {
3839
return BedWarsProxy.getLevelManager();
3940
}
4041

42+
@Override
43+
public IAddonManager getAddonsUtil() {
44+
return BedWarsProxy.addonManager;
45+
}
46+
4147
/**
4248
* Change the level interface.
4349
* @param level custom level class

proxy-plugin/src/main/java/com/tomkeuper/bedwars/proxy/BedWarsProxy.java

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package com.tomkeuper.bedwars.proxy;
22

3+
import com.tomkeuper.bedwars.proxy.addon.AddonManager;
34
import com.tomkeuper.bedwars.proxy.api.BedWars;
5+
import com.tomkeuper.bedwars.proxy.api.addon.Addon;
6+
import com.tomkeuper.bedwars.proxy.api.addon.IAddonManager;
47
import com.tomkeuper.bedwars.proxy.api.database.Database;
58
import com.tomkeuper.bedwars.proxy.api.party.Party;
69
import com.tomkeuper.bedwars.proxy.arenamanager.ArenaSelectorListener;
@@ -48,6 +51,7 @@
4851
import org.jetbrains.annotations.NotNull;
4952

5053
import java.lang.reflect.Field;
54+
import java.util.StringJoiner;
5155

5256
public class BedWarsProxy extends JavaPlugin {
5357

@@ -64,10 +68,13 @@ public class BedWarsProxy extends JavaPlugin {
6468
private static BlockSupport blockAdapter;
6569
private static ItemStackSupport itemAdapter;
6670

71+
public static IAddonManager addonManager = new AddonManager();
72+
6773
private static Party party;
6874
private static Level levelManager;
6975

7076
public static boolean isPapi = false, debug = true;
77+
public static int defaultRankupCost;
7178

7279
@Override
7380
public void onLoad() {
@@ -102,6 +109,20 @@ public void onEnable() {
102109
return;
103110
}
104111

112+
// Check stored settings
113+
String retrievedValue = redisConnection.retrieveSetting("default_rankup_cost");
114+
if (retrievedValue != null) {
115+
try {
116+
defaultRankupCost = Integer.parseInt(retrievedValue);
117+
} catch (NumberFormatException e) {
118+
getLogger().severe("Stored default rankup cost is not a number! Using default value of 1000.");
119+
defaultRankupCost = 1000;
120+
}
121+
} else {
122+
getLogger().severe("No stored value has been found! Using default value of 1000.");
123+
defaultRankupCost = 1000;
124+
}
125+
105126
registerListeners(new LangListeners(), new ArenaSelectorListener(), new CacheListener());
106127
//noinspection InstantiationOfUtilityClass
107128
new SoundsConfig();
@@ -154,6 +175,32 @@ public void onEnable() {
154175
m.addCustomChart(new SimplePie("party_adapter", () -> getParty().getClass().getSimpleName()));
155176
m.addCustomChart(new SimplePie("level_adapter", () -> getLevelManager().getClass().getSimpleName()));
156177
SignManager.init();
178+
179+
// Initialize the addons
180+
Bukkit.getScheduler().runTaskLater(this, () -> addonManager.loadAddons(), 60L);
181+
182+
// Send startup message, delayed to make sure everything is loaded and registered.
183+
Bukkit.getScheduler().runTaskLater(this, () -> {
184+
this.getLogger().info("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
185+
this.getLogger().info("BWProxy2023 v"+ plugin.getDescription().getVersion()+" has been enabled!");
186+
this.getLogger().info("");
187+
this.getLogger().info("PAPI Support: " + isPapi);
188+
this.getLogger().info("");
189+
this.getLogger().info("Party Adapter: " + getParty().getClass().getSimpleName());
190+
this.getLogger().info("Default Language: " + LanguageManager.get().getDefaultLanguage().getIso());
191+
this.getLogger().info("Level Adapter: " + getLevelManager().getClass().getSimpleName());
192+
this.getLogger().info("");
193+
194+
StringJoiner addonString = new StringJoiner(", ");
195+
addonString.setEmptyValue("None");
196+
for (Addon addon : api.getAddonsUtil().getAddons()){
197+
addonString.add(addon.getName());
198+
}
199+
200+
this.getLogger().info("Addon" + (addonManager.getAddons().isEmpty() || addonManager.getAddons().size() > 1 ? "s" : "") + " (" + addonManager.getAddons().size() + "): " + addonString);
201+
this.getLogger().info("");
202+
this.getLogger().info("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
203+
}, 80L);
157204
}
158205

159206
@Override

0 commit comments

Comments
 (0)