Skip to content

Commit

Permalink
Merge pull request #2069 from BentoBoxWorld/develop
Browse files Browse the repository at this point in the history
New version
  • Loading branch information
tastybento authored Feb 12, 2023
2 parents 065f4ba + 45f2dca commit fe888a8
Show file tree
Hide file tree
Showing 194 changed files with 7,082 additions and 2,593 deletions.
49 changes: 37 additions & 12 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,23 +66,29 @@
<java.version>17</java.version>
<!-- Non-minecraft related dependencies -->
<powermock.version>2.0.9</powermock.version>
<!-- Database related dependencies -->
<mongodb.version>3.12.8</mongodb.version>
<mariadb.version>3.0.5</mariadb.version>
<mysql.version>8.0.27</mysql.version>
<postgresql.version>42.2.18</postgresql.version>
<hikaricp.version>5.0.1</hikaricp.version>
<!-- More visible way to change dependency versions -->
<spigot.version>1.19.2-R0.1-SNAPSHOT</spigot.version>
<spigot.version>1.19.3-R0.1-SNAPSHOT</spigot.version>
<!-- Might differ from the last Spigot release for short periods
of time -->
<paper.version>1.19-R0.1-SNAPSHOT</paper.version>
<bstats.version>2.2.1</bstats.version>
<vault.version>1.7</vault.version>
<bstats.version>3.0.0</bstats.version>
<vault.version>1.7.1</vault.version>
<placeholderapi.version>2.10.9</placeholderapi.version>
<githubapi.version>d5f5e0bbd8</githubapi.version>
<dynmap.version>3.0-SNAPSHOT</dynmap.version>
<myworlds.version>1.19.3-v1</myworlds.version>
<!-- Revision variable removes warning about dynamic version -->
<revision>${build.version}-SNAPSHOT</revision>
<!-- Do not change unless you want different name for local builds. -->
<build.number>-LOCAL</build.number>
<!-- This allows to change between versions. -->
<build.version>1.21.1</build.version>
<build.version>1.22.0</build.version>
<sonar.organization>bentobox-world</sonar.organization>
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
</properties>
Expand Down Expand Up @@ -176,6 +182,11 @@
<id>nms-repo</id>
<url>https://repo.codemc.io/repository/nms/</url>
</repository>
<!-- Used for MyWorlds hook -->
<repository>
<id>MG-Dev Jenkins CI Maven Repository</id>
<url>https://ci.mg-dev.eu/plugin/repository/everything</url>
</repository>
</repositories>

<dependencies>
Expand All @@ -197,7 +208,7 @@
<dependency>
<groupId>com.mojang</groupId>
<artifactId>authlib</artifactId>
<version>3.2.38</version>
<version>3.16.29</version>
<scope>provided</scope>
</dependency>
<!-- Metrics -->
Expand Down Expand Up @@ -232,10 +243,11 @@
<version>${mongodb.version}</version>
<scope>provided</scope>
</dependency>
<!-- HikariCP database handler -->
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.1-901-1.jdbc4</version>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId>
<version>${hikaricp.version}</version>
<scope>provided</scope>
</dependency>
<!-- Vault: as their maven repo is down, we need to get it from jitpack -->
Expand All @@ -260,6 +272,12 @@
<version>${dynmap.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.bergerkiller.bukkit</groupId>
<artifactId>MyWorlds</artifactId>
<version>${myworlds.version}</version>
<scope>provided</scope>
</dependency>
<!-- Shaded APIs -->
<dependency>
<groupId>com.github.TheBusyBiscuit</groupId>
Expand All @@ -269,7 +287,7 @@
<dependency>
<groupId>com.github.Marcono1234</groupId>
<artifactId>gson-record-type-adapter-factory</artifactId>
<version>0.1.0</version>
<version>0.3.0</version>
</dependency>
<!-- Static analysis -->
<!-- We are using Eclipse's annotations. If you're using IDEA, update
Expand Down Expand Up @@ -352,6 +370,7 @@
<version>3.0.0-M5</version>
<configuration>
<argLine>
${argLine}
--add-opens java.base/java.lang=ALL-UNNAMED
--add-opens java.base/java.math=ALL-UNNAMED
--add-opens java.base/java.io=ALL-UNNAMED
Expand Down Expand Up @@ -390,10 +409,11 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.3.0</version>
<version>3.4.1</version>
<configuration>
<source>${java.version}</source>
<show>private</show>
<quiet>true</quiet>
<failOnError>false</failOnError>
<additionalJOption>-Xdoclint:none</additionalJOption>
<!-- To compile with Java 11, this tag may be required -->
Expand Down Expand Up @@ -495,16 +515,21 @@
</configuration>
<executions>
<execution>
<id>pre-unit-test</id>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>post-unit-test</id>
<id>report</id>
<goals>
<goal>report</goal>
</goals>
<configuration>
<formats>
<format>XML</format>
</formats>
</configuration>
</execution>
</executions>
</plugin>
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/world/bentobox/bentobox/BentoBox.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,17 @@
import world.bentobox.bentobox.commands.BentoBoxCommand;
import world.bentobox.bentobox.database.DatabaseSetup;
import world.bentobox.bentobox.hooks.MultiverseCoreHook;
import world.bentobox.bentobox.hooks.MyWorldsHook;
import world.bentobox.bentobox.hooks.VaultHook;
import world.bentobox.bentobox.hooks.placeholders.PlaceholderAPIHook;
import world.bentobox.bentobox.listeners.BannedCommands;
import world.bentobox.bentobox.listeners.BlockEndDragon;
import world.bentobox.bentobox.listeners.DeathListener;
import world.bentobox.bentobox.listeners.JoinLeaveListener;
import world.bentobox.bentobox.listeners.PanelListenerManager;
import world.bentobox.bentobox.listeners.StandardSpawnProtectionListener;
import world.bentobox.bentobox.listeners.teleports.EntityTeleportListener;
import world.bentobox.bentobox.listeners.teleports.PlayerTeleportListener;
import world.bentobox.bentobox.listeners.StandardSpawnProtectionListener;
import world.bentobox.bentobox.managers.AddonsManager;
import world.bentobox.bentobox.managers.BlueprintsManager;
import world.bentobox.bentobox.managers.CommandsManager;
Expand Down Expand Up @@ -225,6 +226,7 @@ private void completeSetup(long loadTime) {
// Register Multiverse hook - MV loads AFTER BentoBox
// Make sure all worlds are already registered to Multiverse.
hooksManager.registerHook(new MultiverseCoreHook());
hooksManager.registerHook(new MyWorldsHook());
islandWorldManager.registerWorldsToMultiverse();

// TODO: re-enable after implementation
Expand Down
64 changes: 64 additions & 0 deletions src/main/java/world/bentobox/bentobox/Settings.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package world.bentobox.bentobox;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

import org.bukkit.Material;
Expand All @@ -11,8 +13,10 @@
import world.bentobox.bentobox.api.configuration.StoreAt;
import world.bentobox.bentobox.database.DatabaseSetup.DatabaseType;


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

@ConfigComment("Number of active connections to the SQL database at the same time.")
@ConfigComment("Default 10.")
@ConfigEntry(path = "general.database.max-pool-size", since = "1.21.0")
private int maximumPoolSize = 10;

@ConfigComment("Enable SSL connection to MongoDB, MariaDB, MySQL and PostgreSQL databases.")
@ConfigEntry(path = "general.database.use-ssl", since = "1.12.0")
private boolean useSSL = false;
Expand All @@ -118,6 +128,16 @@ public class Settings implements ConfigObject {
@ConfigEntry(path = "general.database.prefix-character", since = "1.13.0")
private String databasePrefix = "";

@ConfigComment("Custom connection datasource properties that will be applied to connection pool.")
@ConfigComment("Check available values to your SQL driver implementation.")
@ConfigComment("Example: ")
@ConfigComment(" custom-properties: ")
@ConfigComment(" cachePrepStmts: 'true'")
@ConfigComment(" prepStmtCacheSize: '250'")
@ConfigComment(" prepStmtCacheSqlLimit: '2048'")
@ConfigEntry(path = "general.database.custom-properties", since = "1.21.0")
private Map<String, String> customPoolProperties = new HashMap<>();

@ConfigComment("MongoDB client connection URI to override default connection options.")
@ConfigComment("See: https://docs.mongodb.com/manual/reference/connection-string/")
@ConfigEntry(path = "general.database.mongodb-connection-uri", since = "1.14.0")
Expand Down Expand Up @@ -954,6 +974,17 @@ public void setSlowDeletion(boolean slowDeletion) {
}


/**
* Gets maximum pool size.
*
* @return the maximum pool size
*/
public int getMaximumPoolSize()
{
return maximumPoolSize;
}


/**
* Gets safe spot search range.
*
Expand All @@ -965,6 +996,39 @@ public int getSafeSpotSearchRange()
}


/**
* Sets maximum pool size.
*
* @param maximumPoolSize the maximum pool size
*/
public void setMaximumPoolSize(int maximumPoolSize)
{
this.maximumPoolSize = maximumPoolSize;
}


/**
* Gets custom pool properties.
*
* @return the custom pool properties
*/
public Map<String, String> getCustomPoolProperties()
{
return customPoolProperties;
}


/**
* Sets custom pool properties.
*
* @param customPoolProperties the custom pool properties
*/
public void setCustomPoolProperties(Map<String, String> customPoolProperties)
{
this.customPoolProperties = customPoolProperties;
}


/**
* Sets safe spot search range.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.net.URLClassLoader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
Expand All @@ -33,6 +34,19 @@ public class AddonClassLoader extends URLClassLoader {
private final Addon addon;
private final AddonsManager loader;

/**
* For testing only
* @param addon addon
* @param loader Addons Manager
* @param jarFile Jar File
* @throws MalformedURLException exception
*/
protected AddonClassLoader(Addon addon, AddonsManager loader, File jarFile) throws MalformedURLException {
super(new URL[]{jarFile.toURI().toURL()});
this.addon = addon;
this.loader = loader;
}

public AddonClassLoader(AddonsManager addonsManager, YamlConfiguration data, File jarFile, ClassLoader parent)
throws InvalidAddonInheritException,
MalformedURLException,
Expand Down Expand Up @@ -79,8 +93,27 @@ public AddonClassLoader(AddonsManager addonsManager, YamlConfiguration data, Fil
*/
@NonNull
public static AddonDescription asDescription(YamlConfiguration data) throws InvalidAddonDescriptionException {
AddonDescription.Builder builder = new AddonDescription.Builder(Objects.requireNonNull(data.getString("main")), Objects.requireNonNull(data.getString("name")), Objects.requireNonNull(data.getString("version")))
// Validate addon.yml
if (!data.contains("main")) {
throw new InvalidAddonDescriptionException("Missing 'main' tag. A main class must be listed in addon.yml");
}
if (!data.contains("name")) {
throw new InvalidAddonDescriptionException("Missing 'name' tag. An addon name must be listed in addon.yml");
}
if (!data.contains("version")) {
throw new InvalidAddonDescriptionException("Missing 'version' tag. A version must be listed in addon.yml");
}
if (!data.contains("authors")) {
throw new InvalidAddonDescriptionException("Missing 'authors' tag. At least one author must be listed in addon.yml");
}

AddonDescription.Builder builder = new AddonDescription.Builder(
// Mandatory elements
Objects.requireNonNull(data.getString("main")),
Objects.requireNonNull(data.getString("name")),
Objects.requireNonNull(data.getString("version")))
.authors(Objects.requireNonNull(data.getString("authors")))
// Optional elements
.metrics(data.getBoolean("metrics", true))
.repository(data.getString("repository", ""));

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

String apiVersion = data.getString("api-version");
if (apiVersion != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ public Builder permissions(ConfigurationSection permissions) {
*/
@Override
public String toString() {
return "AddonDescription [" + (name != null ? "name=" + name + ", " : "")
return "AddonDescription [" + "name=" + name + ", "
+ "version=" + version + "]";
}
}
Loading

0 comments on commit fe888a8

Please sign in to comment.