Skip to content

Commit ac5d4cd

Browse files
committed
Minor Version Update 1.1.0
Changes: - Converted messaging to Kyori Adventure Components - Miscellaneous code tweaks and organization
1 parent 1e4ebd1 commit ac5d4cd

32 files changed

+298
-318
lines changed

build.gradle

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ plugins {
44
}
55

66
version project.properties["pluginVersion"]
7-
targetCompatibility = sourceCompatibility = JavaVersion.VERSION_11
7+
targetCompatibility = sourceCompatibility = JavaVersion.VERSION_17
88

99
repositories {
1010
mavenCentral()
@@ -13,10 +13,7 @@ repositories {
1313
[
1414
"https://jitpack.io",
1515
"https://papermc.io/repo/repository/maven-public/",
16-
"https://oss.sonatype.org/content/groups/public/",
17-
"https://repo.extendedclip.com/content/repositories/placeholderapi/",
18-
"http://repo.comphenix.net/content/repositories/releases/",
19-
"http://repo.comphenix.net/content/repositories/snapshots/"
16+
"https://os1.oss.sonatype.org/content/groups/public/"
2017
].each { s ->
2118
maven {
2219
url s
@@ -27,24 +24,15 @@ repositories {
2724
dependencies {
2825
//provided
2926
[
30-
"com.destroystokyo.paper:paper-api:1.16.4-R0.1-SNAPSHOT",
31-
"net.md-5:bungeecord-api:1.16-R0.4-SNAPSHOT",
32-
"io.github.waterfallmc:waterfall-api:1.16-R0.4-SNAPSHOT",
33-
"me.clip:placeholderapi:2.10.9",
34-
files("libs/spigot-1.16.5.jar"),
35-
files("libs/spigot-1.16.4.jar")
27+
"io.papermc.paper:paper-api:1.18-R0.1-SNAPSHOT",
3628
].each {s ->
3729
compileOnly s
3830
}
3931

40-
compileOnly ("com.github.dmulloy2:ProtocolLib:4.5.1") {
41-
exclude group: "com.comphenix.executors"
42-
}
43-
4432
//compile
4533
[
46-
"org.jetbrains:annotations:20.1.0",
47-
"org.reflections:reflections:0.9.12"
34+
"org.jetbrains:annotations:23.0.0",
35+
"org.reflections:reflections:0.10.2"
4836
].each {s ->
4937
implementation s
5038
}
@@ -63,6 +51,17 @@ shadowJar {
6351
}
6452
}
6553

54+
apply plugin: 'maven-publish'
55+
apply plugin: 'signing'
56+
57+
signing {
58+
sign configurations.archives
59+
}
60+
61+
group = "io.github.simplexdevelopment"
62+
archivesBaseName = "simplex-core"
63+
version = "1.0.0"
64+
6665
processResources {
6766
//update resources when building
6867
doFirst {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5.1-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

src/main/java/io/github/simplexdev/api/IBan.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package io.github.simplexdev.api;
22

33
import io.github.simplexdev.simplexcore.ban.BanType;
4+
import net.kyori.adventure.text.Component;
45

56
import java.util.Date;
67
import java.util.UUID;
@@ -10,7 +11,7 @@ public interface IBan {
1011

1112
String getSender();
1213

13-
String getBanReason();
14+
Component getBanReason();
1415

1516
String getBanId();
1617

src/main/java/io/github/simplexdev/api/IGUI.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package io.github.simplexdev.api;
22

33
import io.github.simplexdev.api.func.ClickAction;
4+
import net.kyori.adventure.text.Component;
45
import org.bukkit.Material;
56
import org.bukkit.entity.Player;
67
import org.bukkit.inventory.Inventory;
@@ -74,10 +75,10 @@ public interface IGUI {
7475
* Creates a new ItemStack instance to place in the inventory provided by the interface instance.
7576
* @param material The item material
7677
* @param name The name of the item
77-
* @param lore Optional item descriptions
78+
* @param lore Optional item descriptions, as components.
7879
* @return The newly created item
7980
*/
80-
ItemStack newItem(@NotNull Material material, @NotNull String name, String... lore);
81+
ItemStack newItem(@NotNull Material material, @NotNull String name, Component... lore);
8182

8283
/**
8384
* Creates a new ItemStack instance to place in the inventory provided by the interface instance.

src/main/java/io/github/simplexdev/api/func/VoidSupplier.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
package io.github.simplexdev.api.func;
22

3+
import org.jetbrains.annotations.NotNull;
4+
35
@FunctionalInterface
46
public interface VoidSupplier {
57
void get();
68

7-
default VoidSupplier after(VoidSupplier supplier) {
9+
default VoidSupplier after(@NotNull VoidSupplier supplier) {
810
supplier.get();
911
return this;
1012
}

src/main/java/io/github/simplexdev/simplexcore/CoreState.java

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,10 @@ public class CoreState {
77
public CoreState(SimplexCorePlugin plugin) {
88
this.plugin = plugin;
99
switch (getState()) {
10-
case ON:
11-
message = "The Core is currently ON";
12-
break;
13-
case SUSPENDED:
14-
message = "The Core is currently SUSPENDED. Please report this to the developer.";
15-
break;
16-
case DEBUG:
17-
message = "The Core is currently in DEBUG mode. Do not use this if you don't know what you're doing.";
18-
break;
19-
case VOLATILE:
20-
message = "The Core state is currently unknown! Please report this to the developer!";
21-
break;
10+
case ON -> message = "The Core is currently ON";
11+
case SUSPENDED -> message = "The Core is currently SUSPENDED. Please report this to the developer.";
12+
case DEBUG -> message = "The Core is currently in DEBUG mode. Do not use this if you don't know what you're doing.";
13+
case VOLATILE -> message = "The Core state is currently unknown! Please report this to the developer!";
2214
}
2315
}
2416

src/main/java/io/github/simplexdev/simplexcore/ban/Ban.java

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import io.github.simplexdev.simplexcore.module.SimplexModule;
1010
import io.github.simplexdev.simplexcore.utils.TickedTime;
1111
import io.github.simplexdev.simplexcore.utils.Utilities;
12+
import net.kyori.adventure.text.Component;
1213
import org.bukkit.command.CommandSender;
1314
import org.bukkit.configuration.ConfigurationSection;
1415
import org.bukkit.entity.Player;
@@ -33,7 +34,7 @@ public abstract class Ban implements IBan {
3334
private final SimplexModule<?> plugin;
3435

3536
private final String banId;
36-
private final String banReason;
37+
private final Component banReason;
3738

3839
/**
3940
* Creates a new Ban Entry.
@@ -79,7 +80,7 @@ public Ban(SimplexModule<?> plugin, Player player, CommandSender sender, BanType
7980
* @param banDate The date when the ban was created.
8081
* @param banDuration How long the ban should last.
8182
*/
82-
public Ban(SimplexModule<?> plugin, Player player, CommandSender sender, BanType type, String banId, String banReason, Date banDate, long banDuration) {
83+
public Ban(SimplexModule<?> plugin, Player player, CommandSender sender, BanType type, String banId, Component banReason, Date banDate, long banDuration) {
8384
this.plugin = plugin;
8485
this.player = player;
8586
this.sender = sender;
@@ -92,18 +93,20 @@ public Ban(SimplexModule<?> plugin, Player player, CommandSender sender, BanType
9293

9394
/**
9495
* Writes the Ban to a file.
95-
* @param separateFiles Whether or not to create individual files for players or store them all in one bans.yml file.
96+
* @param separateFiles Whether to create individual files for players or store
97+
* them all in one bans.yml file.
9698
*/
9799
public void writeToFile(boolean separateFiles) {
98100
File fileLocation = new File(plugin.getParentFolder(), "bans");
99101

102+
Yaml yaml;
100103
if (separateFiles) {
101-
Yaml yaml = new YamlFactory(plugin).from(null, fileLocation, player.getName() + ".yml");
104+
yaml = new YamlFactory(plugin).from(null, fileLocation, player.getName() + ".yml");
102105
ConfigurationSection section = yaml.getConfig().createSection(getOffender().toString());
103106
section.set("name", player.getName());
104107
section.set("ban_id", banId);
105108
section.set("sender", sender.getName());
106-
section.set("reason", banReason);
109+
section.set("reason", banReason.toString());
107110
section.set("duration", banDuration);
108111
section.set("date", banDate.getTime());
109112
section.set("type", type.toString());
@@ -112,14 +115,13 @@ public void writeToFile(boolean separateFiles) {
112115
} catch (IOException e) {
113116
plugin.getLogger().severe(e.getMessage());
114117
}
115-
yaml.reload();
116118
} else {
117-
Yaml yaml = new YamlFactory(plugin).from(null, fileLocation, "bans.yml");
119+
yaml = new YamlFactory(plugin).from(null, fileLocation, "bans.yml");
118120
ConfigurationSection section = yaml.getConfig().createSection(getOffender().toString());
119121
section.set("name", player.getName());
120122
section.set("ban_id", banId);
121123
section.set("sender", sender.getName());
122-
section.set("reason", banReason);
124+
section.set("reason", banReason.toString());
123125
section.set("duration", banDuration);
124126
section.set("date", banDate.getTime());
125127
section.set("type", type.toString());
@@ -128,7 +130,7 @@ public void writeToFile(boolean separateFiles) {
128130
} catch (IOException ex) {
129131
plugin.getLogger().severe(ex.getMessage());
130132
}
131-
yaml.reload();
132133
}
134+
yaml.reload();
133135
}
134136
}

src/main/java/io/github/simplexdev/simplexcore/ban/BanFactory.java

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,15 @@
44
import io.github.simplexdev.api.func.VoidSupplier;
55
import io.github.simplexdev.simplexcore.chat.Messages;
66
import io.github.simplexdev.simplexcore.config.Yaml;
7-
import io.github.simplexdev.simplexcore.config.YamlFactory;
87
import io.github.simplexdev.simplexcore.module.SimplexModule;
98
import io.github.simplexdev.simplexcore.utils.TickedTime;
109
import io.github.simplexdev.simplexcore.utils.Utilities;
10+
import net.kyori.adventure.text.Component;
1111
import org.bukkit.command.CommandSender;
1212
import org.bukkit.entity.Player;
13+
import org.jetbrains.annotations.Contract;
14+
import org.jetbrains.annotations.NotNull;
15+
import org.jetbrains.annotations.Nullable;
1316

1417
import java.io.File;
1518
import java.util.Date;
@@ -24,7 +27,7 @@ public final class BanFactory {
2427
private final Date banDate;
2528
private final BanType type;
2629
private final String banId;
27-
private String banReason;
30+
private Component banReason;
2831
private long banDuration;
2932

3033
public BanFactory(SimplexModule<?> plugin, Player player, CommandSender sender, Date banDate, BanType type) {
@@ -46,13 +49,13 @@ public BanFactory(SimplexModule<?> plugin, Player player, CommandSender sender,
4649
* @param banReason The reason for the ban. By default, this uses Messages#BAN for the message.
4750
* @return The current instance of BanFactory.
4851
*/
49-
public BanFactory defineOptional(long banDuration, String banReason) {
52+
public BanFactory defineOptional(long banDuration, Component banReason) {
5053
this.banDuration = banDuration;
5154
this.banReason = banReason;
5255
return this;
5356
}
5457

55-
public void write(Yaml yaml, IBan ban) {
58+
public void write(@NotNull Yaml yaml, @NotNull IBan ban) {
5659
yaml.set(pathway("offender"), ban.getOffender());
5760
yaml.set(pathway("sender"), ban.getSender());
5861
yaml.set(pathway("duration"), ban.getBanDuration());
@@ -63,7 +66,8 @@ public void write(Yaml yaml, IBan ban) {
6366
yaml.create();
6467
}
6568

66-
public Yaml read(File yamlFile) {
69+
@Contract(pure = true)
70+
public @Nullable Yaml read(File yamlFile) {
6771
return null;
6872
}
6973

@@ -72,7 +76,8 @@ public Yaml read(File yamlFile) {
7276
*
7377
* @return A new ban instance.
7478
*/
75-
public Ban create() {
79+
@Contract(" -> new")
80+
public @NotNull Ban create() {
7681
return new Ban(plugin, player, sender, type, banDuration) {
7782
@Override
7883
public UUID getOffender() {
@@ -85,7 +90,7 @@ public String getSender() {
8590
}
8691

8792
@Override
88-
public String getBanReason() {
93+
public Component getBanReason() {
8994
return banReason;
9095
}
9196

@@ -115,19 +120,23 @@ public void deleteBan(IBan ban) {
115120
// TODO
116121
}
117122

118-
public IBan getBan(String banId) {
123+
@Contract(pure = true)
124+
public @Nullable IBan getBan(String banId) {
119125
return null;
120126
}
121127

122-
public IBan getBan(Player player) {
128+
@Contract(pure = true)
129+
public @Nullable IBan getBan(Player player) {
123130
return null;
124131
}
125132

126-
public IBan getBan(UUID offenderUUID) {
133+
@Contract(pure = true)
134+
public @Nullable IBan getBan(UUID offenderUUID) {
127135
return null;
128136
}
129137

130-
private VoidSupplier assignBanDuration(Long... time) {
138+
@Contract(pure = true)
139+
private @NotNull VoidSupplier assignBanDuration(Long... time) {
131140
return () -> {
132141
if (type.equals(BanType.PERMANENT)) {
133142
banDuration = TickedTime.YEAR * 99;
@@ -145,7 +154,7 @@ private VoidSupplier assignBanDuration(Long... time) {
145154
};
146155
}
147156

148-
private String createBanId() {
157+
private @NotNull String createBanId() {
149158
return Utilities.generateBanId(type);
150159
}
151160
}

src/main/java/io/github/simplexdev/simplexcore/ban/BanManager.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import org.bukkit.OfflinePlayer;
88
import org.bukkit.event.EventHandler;
99
import org.bukkit.event.player.AsyncPlayerPreLoginEvent;
10+
import org.jetbrains.annotations.NotNull;
1011
import org.jetbrains.annotations.Nullable;
1112

1213
import java.util.Date;
@@ -19,11 +20,9 @@
1920

2021
public final class BanManager extends SimplexListener {
2122
private final Map<Ban, BanType> banMap = new HashMap<>();
22-
private final SimplexModule<?> plugin;
2323

2424
BanManager(SimplexModule<?> plugin) {
25-
this.plugin = plugin;
26-
register(this, plugin);
25+
super(plugin);
2726
}
2827

2928
public void addBan(Ban ban) {
@@ -47,7 +46,7 @@ public Ban getBan(OfflinePlayer player) {
4746
}
4847

4948
@EventHandler
50-
public void banHandler(AsyncPlayerPreLoginEvent event) {
49+
public void banHandler(@NotNull AsyncPlayerPreLoginEvent event) {
5150
UUID player = event.getUniqueId();
5251
OfflinePlayer op = Bukkit.getOfflinePlayer(player);
5352
Ban ban = getBan(op);

src/main/java/io/github/simplexdev/simplexcore/ban/BanType.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package io.github.simplexdev.simplexcore.ban;
22

3+
import org.jetbrains.annotations.NotNull;
4+
35
public enum BanType {
46
PERMANENT("P-"),
57
TEMPORARY("T-"),
@@ -12,7 +14,7 @@ public enum BanType {
1214
this.prefix = prefix;
1315
}
1416

15-
public static String value(BanType type) {
17+
public static @NotNull String value(@NotNull BanType type) {
1618
if (type.equals(PERMANENT)) {
1719
return "Permanent";
1820
} else if (type.equals(TEMPORARY)) {
@@ -22,7 +24,7 @@ public static String value(BanType type) {
2224
}
2325
}
2426

25-
public static BanType getFromId(String banId) {
27+
public static BanType getFromId(@NotNull String banId) {
2628
if (banId.startsWith("P")) {
2729
return PERMANENT;
2830
} else if (banId.startsWith("T")) {

0 commit comments

Comments
 (0)