Skip to content

Commit fe888a8

Browse files
authored
Merge pull request #2069 from BentoBoxWorld/develop
New version
2 parents 065f4ba + 45f2dca commit fe888a8

File tree

194 files changed

+7082
-2593
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

194 files changed

+7082
-2593
lines changed

pom.xml

Lines changed: 37 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -66,23 +66,29 @@
6666
<java.version>17</java.version>
6767
<!-- Non-minecraft related dependencies -->
6868
<powermock.version>2.0.9</powermock.version>
69+
<!-- Database related dependencies -->
6970
<mongodb.version>3.12.8</mongodb.version>
71+
<mariadb.version>3.0.5</mariadb.version>
72+
<mysql.version>8.0.27</mysql.version>
73+
<postgresql.version>42.2.18</postgresql.version>
74+
<hikaricp.version>5.0.1</hikaricp.version>
7075
<!-- More visible way to change dependency versions -->
71-
<spigot.version>1.19.2-R0.1-SNAPSHOT</spigot.version>
76+
<spigot.version>1.19.3-R0.1-SNAPSHOT</spigot.version>
7277
<!-- Might differ from the last Spigot release for short periods
7378
of time -->
7479
<paper.version>1.19-R0.1-SNAPSHOT</paper.version>
75-
<bstats.version>2.2.1</bstats.version>
76-
<vault.version>1.7</vault.version>
80+
<bstats.version>3.0.0</bstats.version>
81+
<vault.version>1.7.1</vault.version>
7782
<placeholderapi.version>2.10.9</placeholderapi.version>
7883
<githubapi.version>d5f5e0bbd8</githubapi.version>
7984
<dynmap.version>3.0-SNAPSHOT</dynmap.version>
85+
<myworlds.version>1.19.3-v1</myworlds.version>
8086
<!-- Revision variable removes warning about dynamic version -->
8187
<revision>${build.version}-SNAPSHOT</revision>
8288
<!-- Do not change unless you want different name for local builds. -->
8389
<build.number>-LOCAL</build.number>
8490
<!-- This allows to change between versions. -->
85-
<build.version>1.21.1</build.version>
91+
<build.version>1.22.0</build.version>
8692
<sonar.organization>bentobox-world</sonar.organization>
8793
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
8894
</properties>
@@ -176,6 +182,11 @@
176182
<id>nms-repo</id>
177183
<url>https://repo.codemc.io/repository/nms/</url>
178184
</repository>
185+
<!-- Used for MyWorlds hook -->
186+
<repository>
187+
<id>MG-Dev Jenkins CI Maven Repository</id>
188+
<url>https://ci.mg-dev.eu/plugin/repository/everything</url>
189+
</repository>
179190
</repositories>
180191

181192
<dependencies>
@@ -197,7 +208,7 @@
197208
<dependency>
198209
<groupId>com.mojang</groupId>
199210
<artifactId>authlib</artifactId>
200-
<version>3.2.38</version>
211+
<version>3.16.29</version>
201212
<scope>provided</scope>
202213
</dependency>
203214
<!-- Metrics -->
@@ -232,10 +243,11 @@
232243
<version>${mongodb.version}</version>
233244
<scope>provided</scope>
234245
</dependency>
246+
<!-- HikariCP database handler -->
235247
<dependency>
236-
<groupId>postgresql</groupId>
237-
<artifactId>postgresql</artifactId>
238-
<version>9.1-901-1.jdbc4</version>
248+
<groupId>com.zaxxer</groupId>
249+
<artifactId>HikariCP</artifactId>
250+
<version>${hikaricp.version}</version>
239251
<scope>provided</scope>
240252
</dependency>
241253
<!-- Vault: as their maven repo is down, we need to get it from jitpack -->
@@ -260,6 +272,12 @@
260272
<version>${dynmap.version}</version>
261273
<scope>provided</scope>
262274
</dependency>
275+
<dependency>
276+
<groupId>com.bergerkiller.bukkit</groupId>
277+
<artifactId>MyWorlds</artifactId>
278+
<version>${myworlds.version}</version>
279+
<scope>provided</scope>
280+
</dependency>
263281
<!-- Shaded APIs -->
264282
<dependency>
265283
<groupId>com.github.TheBusyBiscuit</groupId>
@@ -269,7 +287,7 @@
269287
<dependency>
270288
<groupId>com.github.Marcono1234</groupId>
271289
<artifactId>gson-record-type-adapter-factory</artifactId>
272-
<version>0.1.0</version>
290+
<version>0.3.0</version>
273291
</dependency>
274292
<!-- Static analysis -->
275293
<!-- We are using Eclipse's annotations. If you're using IDEA, update
@@ -352,6 +370,7 @@
352370
<version>3.0.0-M5</version>
353371
<configuration>
354372
<argLine>
373+
${argLine}
355374
--add-opens java.base/java.lang=ALL-UNNAMED
356375
--add-opens java.base/java.math=ALL-UNNAMED
357376
--add-opens java.base/java.io=ALL-UNNAMED
@@ -390,10 +409,11 @@
390409
<plugin>
391410
<groupId>org.apache.maven.plugins</groupId>
392411
<artifactId>maven-javadoc-plugin</artifactId>
393-
<version>3.3.0</version>
412+
<version>3.4.1</version>
394413
<configuration>
395414
<source>${java.version}</source>
396415
<show>private</show>
416+
<quiet>true</quiet>
397417
<failOnError>false</failOnError>
398418
<additionalJOption>-Xdoclint:none</additionalJOption>
399419
<!-- To compile with Java 11, this tag may be required -->
@@ -495,16 +515,21 @@
495515
</configuration>
496516
<executions>
497517
<execution>
498-
<id>pre-unit-test</id>
518+
<id>prepare-agent</id>
499519
<goals>
500520
<goal>prepare-agent</goal>
501521
</goals>
502522
</execution>
503523
<execution>
504-
<id>post-unit-test</id>
524+
<id>report</id>
505525
<goals>
506526
<goal>report</goal>
507527
</goals>
528+
<configuration>
529+
<formats>
530+
<format>XML</format>
531+
</formats>
532+
</configuration>
508533
</execution>
509534
</executions>
510535
</plugin>

src/main/java/world/bentobox/bentobox/BentoBox.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,17 @@
2020
import world.bentobox.bentobox.commands.BentoBoxCommand;
2121
import world.bentobox.bentobox.database.DatabaseSetup;
2222
import world.bentobox.bentobox.hooks.MultiverseCoreHook;
23+
import world.bentobox.bentobox.hooks.MyWorldsHook;
2324
import world.bentobox.bentobox.hooks.VaultHook;
2425
import world.bentobox.bentobox.hooks.placeholders.PlaceholderAPIHook;
2526
import world.bentobox.bentobox.listeners.BannedCommands;
2627
import world.bentobox.bentobox.listeners.BlockEndDragon;
2728
import world.bentobox.bentobox.listeners.DeathListener;
2829
import world.bentobox.bentobox.listeners.JoinLeaveListener;
2930
import world.bentobox.bentobox.listeners.PanelListenerManager;
31+
import world.bentobox.bentobox.listeners.StandardSpawnProtectionListener;
3032
import world.bentobox.bentobox.listeners.teleports.EntityTeleportListener;
3133
import world.bentobox.bentobox.listeners.teleports.PlayerTeleportListener;
32-
import world.bentobox.bentobox.listeners.StandardSpawnProtectionListener;
3334
import world.bentobox.bentobox.managers.AddonsManager;
3435
import world.bentobox.bentobox.managers.BlueprintsManager;
3536
import world.bentobox.bentobox.managers.CommandsManager;
@@ -225,6 +226,7 @@ private void completeSetup(long loadTime) {
225226
// Register Multiverse hook - MV loads AFTER BentoBox
226227
// Make sure all worlds are already registered to Multiverse.
227228
hooksManager.registerHook(new MultiverseCoreHook());
229+
hooksManager.registerHook(new MyWorldsHook());
228230
islandWorldManager.registerWorldsToMultiverse();
229231

230232
// TODO: re-enable after implementation

src/main/java/world/bentobox/bentobox/Settings.java

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package world.bentobox.bentobox;
22

3+
import java.util.HashMap;
34
import java.util.HashSet;
5+
import java.util.Map;
46
import java.util.Set;
57

68
import org.bukkit.Material;
@@ -11,8 +13,10 @@
1113
import world.bentobox.bentobox.api.configuration.StoreAt;
1214
import world.bentobox.bentobox.database.DatabaseSetup.DatabaseType;
1315

16+
1417
/**
1518
* All the plugin settings are here
19+
*
1620
* @author tastybento
1721
*/
1822
@StoreAt(filename="config.yml") // Explicitly call out what name this should have.
@@ -68,6 +72,7 @@ public class Settings implements ConfigObject {
6872
@ConfigComment("Transition options enable migration from one database type to another. Use /bbox migrate.")
6973
@ConfigComment("YAML and JSON are file-based databases.")
7074
@ConfigComment("MYSQL might not work with all implementations: if available, use a dedicated database type (e.g. MARIADB).")
75+
@ConfigComment("BentoBox uses HikariCP for connecting with SQL databases.")
7176
@ConfigComment("If you use MONGODB, you must also run the BSBMongo plugin (not addon).")
7277
@ConfigComment("See https://github.com/tastybento/bsbMongo/releases/.")
7378
@ConfigEntry(path = "general.database.type", video = "https://youtu.be/FFzCk5-y7-g")
@@ -107,6 +112,11 @@ public class Settings implements ConfigObject {
107112
@ConfigEntry(path = "general.database.max-saved-islands-per-tick")
108113
private int maxSavedIslandsPerTick = 20;
109114

115+
@ConfigComment("Number of active connections to the SQL database at the same time.")
116+
@ConfigComment("Default 10.")
117+
@ConfigEntry(path = "general.database.max-pool-size", since = "1.21.0")
118+
private int maximumPoolSize = 10;
119+
110120
@ConfigComment("Enable SSL connection to MongoDB, MariaDB, MySQL and PostgreSQL databases.")
111121
@ConfigEntry(path = "general.database.use-ssl", since = "1.12.0")
112122
private boolean useSSL = false;
@@ -118,6 +128,16 @@ public class Settings implements ConfigObject {
118128
@ConfigEntry(path = "general.database.prefix-character", since = "1.13.0")
119129
private String databasePrefix = "";
120130

131+
@ConfigComment("Custom connection datasource properties that will be applied to connection pool.")
132+
@ConfigComment("Check available values to your SQL driver implementation.")
133+
@ConfigComment("Example: ")
134+
@ConfigComment(" custom-properties: ")
135+
@ConfigComment(" cachePrepStmts: 'true'")
136+
@ConfigComment(" prepStmtCacheSize: '250'")
137+
@ConfigComment(" prepStmtCacheSqlLimit: '2048'")
138+
@ConfigEntry(path = "general.database.custom-properties", since = "1.21.0")
139+
private Map<String, String> customPoolProperties = new HashMap<>();
140+
121141
@ConfigComment("MongoDB client connection URI to override default connection options.")
122142
@ConfigComment("See: https://docs.mongodb.com/manual/reference/connection-string/")
123143
@ConfigEntry(path = "general.database.mongodb-connection-uri", since = "1.14.0")
@@ -954,6 +974,17 @@ public void setSlowDeletion(boolean slowDeletion) {
954974
}
955975

956976

977+
/**
978+
* Gets maximum pool size.
979+
*
980+
* @return the maximum pool size
981+
*/
982+
public int getMaximumPoolSize()
983+
{
984+
return maximumPoolSize;
985+
}
986+
987+
957988
/**
958989
* Gets safe spot search range.
959990
*
@@ -965,6 +996,39 @@ public int getSafeSpotSearchRange()
965996
}
966997

967998

999+
/**
1000+
* Sets maximum pool size.
1001+
*
1002+
* @param maximumPoolSize the maximum pool size
1003+
*/
1004+
public void setMaximumPoolSize(int maximumPoolSize)
1005+
{
1006+
this.maximumPoolSize = maximumPoolSize;
1007+
}
1008+
1009+
1010+
/**
1011+
* Gets custom pool properties.
1012+
*
1013+
* @return the custom pool properties
1014+
*/
1015+
public Map<String, String> getCustomPoolProperties()
1016+
{
1017+
return customPoolProperties;
1018+
}
1019+
1020+
1021+
/**
1022+
* Sets custom pool properties.
1023+
*
1024+
* @param customPoolProperties the custom pool properties
1025+
*/
1026+
public void setCustomPoolProperties(Map<String, String> customPoolProperties)
1027+
{
1028+
this.customPoolProperties = customPoolProperties;
1029+
}
1030+
1031+
9681032
/**
9691033
* Sets safe spot search range.
9701034
*

src/main/java/world/bentobox/bentobox/api/addons/AddonClassLoader.java

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import java.net.URLClassLoader;
88
import java.util.Arrays;
99
import java.util.HashMap;
10+
import java.util.Locale;
1011
import java.util.Map;
1112
import java.util.Objects;
1213
import java.util.Set;
@@ -33,6 +34,19 @@ public class AddonClassLoader extends URLClassLoader {
3334
private final Addon addon;
3435
private final AddonsManager loader;
3536

37+
/**
38+
* For testing only
39+
* @param addon addon
40+
* @param loader Addons Manager
41+
* @param jarFile Jar File
42+
* @throws MalformedURLException exception
43+
*/
44+
protected AddonClassLoader(Addon addon, AddonsManager loader, File jarFile) throws MalformedURLException {
45+
super(new URL[]{jarFile.toURI().toURL()});
46+
this.addon = addon;
47+
this.loader = loader;
48+
}
49+
3650
public AddonClassLoader(AddonsManager addonsManager, YamlConfiguration data, File jarFile, ClassLoader parent)
3751
throws InvalidAddonInheritException,
3852
MalformedURLException,
@@ -79,8 +93,27 @@ public AddonClassLoader(AddonsManager addonsManager, YamlConfiguration data, Fil
7993
*/
8094
@NonNull
8195
public static AddonDescription asDescription(YamlConfiguration data) throws InvalidAddonDescriptionException {
82-
AddonDescription.Builder builder = new AddonDescription.Builder(Objects.requireNonNull(data.getString("main")), Objects.requireNonNull(data.getString("name")), Objects.requireNonNull(data.getString("version")))
96+
// Validate addon.yml
97+
if (!data.contains("main")) {
98+
throw new InvalidAddonDescriptionException("Missing 'main' tag. A main class must be listed in addon.yml");
99+
}
100+
if (!data.contains("name")) {
101+
throw new InvalidAddonDescriptionException("Missing 'name' tag. An addon name must be listed in addon.yml");
102+
}
103+
if (!data.contains("version")) {
104+
throw new InvalidAddonDescriptionException("Missing 'version' tag. A version must be listed in addon.yml");
105+
}
106+
if (!data.contains("authors")) {
107+
throw new InvalidAddonDescriptionException("Missing 'authors' tag. At least one author must be listed in addon.yml");
108+
}
109+
110+
AddonDescription.Builder builder = new AddonDescription.Builder(
111+
// Mandatory elements
112+
Objects.requireNonNull(data.getString("main")),
113+
Objects.requireNonNull(data.getString("name")),
114+
Objects.requireNonNull(data.getString("version")))
83115
.authors(Objects.requireNonNull(data.getString("authors")))
116+
// Optional elements
84117
.metrics(data.getBoolean("metrics", true))
85118
.repository(data.getString("repository", ""));
86119

@@ -92,7 +125,7 @@ public static AddonDescription asDescription(YamlConfiguration data) throws Inva
92125
if (softDepend != null) {
93126
builder.softDependencies(Arrays.asList(softDepend.split("\\s*,\\s*")));
94127
}
95-
builder.icon(Objects.requireNonNull(Material.getMaterial(data.getString("icon", "PAPER"))));
128+
builder.icon(Objects.requireNonNull(Material.getMaterial(data.getString("icon", "PAPER").toUpperCase(Locale.ENGLISH))));
96129

97130
String apiVersion = data.getString("api-version");
98131
if (apiVersion != null) {

src/main/java/world/bentobox/bentobox/api/addons/AddonDescription.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ public Builder permissions(ConfigurationSection permissions) {
287287
*/
288288
@Override
289289
public String toString() {
290-
return "AddonDescription [" + (name != null ? "name=" + name + ", " : "")
290+
return "AddonDescription [" + "name=" + name + ", "
291291
+ "version=" + version + "]";
292292
}
293293
}

0 commit comments

Comments
 (0)