Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Poslovitch committed Jan 26, 2020
2 parents 69248fd + 9cc95c4 commit fb19c1f
Show file tree
Hide file tree
Showing 91 changed files with 4,063 additions and 696 deletions.
7 changes: 1 addition & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,7 @@ addons:

jdk:
- openjdk8
- openjdk11

matrix:
allow_failures:
- jdk: openjdk11


script:
#- sonar-scanner
- mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent install sonar:sonar -Dsonar.projectKey=BentoBoxWorld_BentoBox
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ There are also plenty of other official or community-made Addons you can try and
## Downloads

### Webtool
A [webtool](https://bentobox-tool.herokuapp.com/) is currently being developed to allow you to easily setup BentoBox and Addons on your server.
A [webtool](https://download.bentobox.world/) is currently being developed to allow you to easily setup BentoBox and Addons on your server.

### Direct links
* [Download](https://github.com/BentoBoxWorld/BentoBox/releases)
Expand Down
37 changes: 35 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
<!-- 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.10.0</build.version>
<build.version>1.11.0</build.version>
</properties>

<!-- Profiles will allow to automatically change build version. -->
Expand Down Expand Up @@ -221,6 +221,11 @@
<artifactId>mongodb-driver</artifactId>
<version>${mongodb.version}</version>
</dependency>
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.1-901-1.jdbc4</version>
</dependency>
<!-- Vault: as their maven repo is down, we need to get it from jitpack -->
<!-- See https://github.com/MilkBowl/VaultAPI/issues/69 -->
<dependency>
Expand Down Expand Up @@ -338,21 +343,39 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.1.0</version>
<version>3.1.1</version>
<configuration>
<source>8</source>
<show>private</show>
<failOnError>false</failOnError>
<additionalJOption>-Xdoclint:none</additionalJOption>
<!-- To compile with Java 11, this tag may be required -->
<!-- <javadocExecutable>${java.home}/bin/javadoc</javadocExecutable> -->
</configuration>
<executions>
<execution>
<id>attach-javadocs</id>
<phase>install</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.0.1</version>
<executions>
<execution>
<id>attach-sources</id>
<phase>install</phase>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
Expand All @@ -375,6 +398,7 @@
</relocations>
<artifactSet>
<excludes>
<exclude>com.google:*</exclude>
<exclude>org.mongodb:*</exclude>
<exclude>org.eclipse.jdt:*</exclude>
</excludes>
Expand All @@ -398,6 +422,15 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
<executions>
<execution>
<id>default-deploy</id>
<phase>deploy</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
Expand Down
10 changes: 8 additions & 2 deletions src/main/java/world/bentobox/bentobox/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,24 @@ public class Settings implements ConfigObject {
@ConfigEntry(path = "general.default-language")
private String defaultLanguage = "en-US";

@ConfigComment("Use economy or not. If true, an economy plugin is required. If false, no money is used or give.")
@ConfigComment("Use economy or not. If true, an economy plugin is required. If false, no money is used or given.")
@ConfigComment("If there is no economy plugin present anyway, money will be automatically disabled.")
@ConfigEntry(path = "general.use-economy")
private boolean useEconomy = true;

// Database
@ConfigComment("JSON, MYSQL, MARIADB (10.2.3+), MONGODB, SQLITE, POSTGRESQL and YAML(deprecated).")
@ConfigComment("JSON, MYSQL, MARIADB, MONGODB, SQLITE, POSTGRESQL and YAML(deprecated).")
@ConfigComment("Transition database options are:")
@ConfigComment(" YAML2JSON, YAML2MARIADB, YAML2MYSQL, YAML2MONGODB, YAML2SQLITE")
@ConfigComment(" JSON2MARIADB, JSON2MYSQL, JSON2MONGODB, JSON2SQLITE, JSON2POSTGRESQL")
@ConfigComment(" MYSQL2JSON, MARIADB2JSON, MONGODB2JSON, SQLITE2JSON, POSTGRESQL2JSON")
@ConfigComment("If you need others, please make a feature request.")
@ConfigComment("Minimum required versions:")
@ConfigComment(" MySQL versions 5.7 or later")
@ConfigComment(" MariaDB versions 10.2.3 or later")
@ConfigComment(" MongoDB versions 3.6 or later")
@ConfigComment(" SQLite versions 3.28 or later")
@ConfigComment(" PostgreSQL versions 9.4 or later")
@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).")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;

import world.bentobox.bentobox.api.addons.exceptions.InvalidAddonDescriptionException;
import world.bentobox.bentobox.api.addons.exceptions.InvalidAddonFormatException;
import world.bentobox.bentobox.api.addons.exceptions.InvalidAddonInheritException;
import world.bentobox.bentobox.managers.AddonsManager;
Expand All @@ -39,6 +40,7 @@ public AddonClassLoader(AddonsManager addonsManager, YamlConfiguration data, Fil
throws InvalidAddonInheritException,
MalformedURLException,
InvalidDescriptionException,
InvalidAddonDescriptionException,
InstantiationException,
IllegalAccessException, InvocationTargetException, NoSuchMethodException {
super(new URL[]{path.toURI().toURL()}, parent);
Expand Down Expand Up @@ -94,7 +96,7 @@ private void registerPermission(ConfigurationSection perms, String perm) {
}

@NonNull
private AddonDescription asDescription(YamlConfiguration data) {
private AddonDescription asDescription(YamlConfiguration data) throws InvalidAddonDescriptionException {
AddonDescription.Builder builder = new AddonDescription.Builder(data.getString("main"), data.getString("name"), data.getString("version"))
.authors(data.getString("authors"))
.metrics(data.getBoolean("metrics", true))
Expand All @@ -110,6 +112,14 @@ private AddonDescription asDescription(YamlConfiguration data) {
}
builder.icon(Material.getMaterial(data.getString("icon", "PAPER")));

String apiVersion = data.getString("api-version");
if (apiVersion != null) {
if (!apiVersion.matches("^(\\d+\\.)?(\\d+\\.)?(\\*|\\d+)$")) {
throw new InvalidAddonDescriptionException("Provided API version '" + apiVersion + "' is not valid. It must only contain digits and dots and not end with a dot.");
}
builder.apiVersion(apiVersion);
}

return builder.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ public final class AddonDescription {
* @since 1.5.0
*/
private final @NonNull Material icon;
/**
* Minimum BentoBox version this addon requires in order to work properly.
* Defaults to {@code "1"}.
* @since 1.11.0
*/
private final @NonNull String apiVersion;

private AddonDescription(@NonNull Builder builder) {
this.main = builder.main;
Expand All @@ -47,6 +53,7 @@ private AddonDescription(@NonNull Builder builder) {
this.metrics = builder.metrics;
this.repository = builder.repository;
this.icon = builder.icon;
this.apiVersion = builder.apiVersion;
}

@NonNull
Expand Down Expand Up @@ -120,6 +127,29 @@ public Material getIcon() {
return icon;
}

/**
* Returns the minimum BentoBox version this addon requires in order to work properly.
* <br/>
* Examples:
* <ul>
* <li>{@code "1"} means that the addon relies on BentoBox {@code 1.0.0} or higher.</li>
* <li>Similarly, {@code "2"} sets the requirement to BentoBox {@code 2.0.0} or higher.</li>
* <li>
* More specific versions can be provided:
* <ul>
* <li>{@code "1.10"} -> BentoBox {@code 1.10.0} or higher.</li>
* <li>{@code "1.9.2"} -> BentoBox {@code 1.9.2} or higher.</li>
* </ul>
* </li>
* </ul>
* Defaults to {@code "1"}.
* @return the minimum BentoBox version this addon requires in order to work properly.
*/
@NonNull
public String getApiVersion() {
return apiVersion;
}

public static class Builder {
private @NonNull String main;
private @NonNull String name;
Expand All @@ -131,6 +161,7 @@ public static class Builder {
private boolean metrics = true;
private @NonNull String repository = "";
private @NonNull Material icon = Material.PAPER;
private @NonNull String apiVersion = "1";

/**
* @since 1.1
Expand Down Expand Up @@ -196,6 +227,18 @@ public Builder icon(@NonNull Material icon) {
return this;
}

/**
* Sets the minimum BentoBox version this addon requires in order to work properly.
* @param apiVersion the minimum BentoBox version this addon requires in order to work properly.
* @since 1.11.0
* @see AddonDescription#getApiVersion()
*/
@NonNull
public Builder apiVersion(@NonNull String apiVersion) {
this.apiVersion = apiVersion;
return this;
}

@NonNull
public AddonDescription build() {
return new AddonDescription(this);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package world.bentobox.bentobox.api.addons.exceptions;

/**
* @since 1.11.0
*/
public class InvalidAddonDescriptionException extends AddonException {

/**
*
*/
private static final long serialVersionUID = 7741502900847049986L;

public InvalidAddonDescriptionException(String errorMessage) {
super(errorMessage);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class AdminGetrankCommand extends CompositeCommand {

private Island island;
private @Nullable UUID targetUUID;
private @Nullable UUID ownerUUID;

public AdminGetrankCommand(CompositeCommand adminCommand) {
super(adminCommand, "getrank");
Expand All @@ -39,7 +40,7 @@ public void setup() {

@Override
public boolean canExecute(User user, String label, List<String> args) {
if (args.size() != 1) {
if (args.size() != 1 && args.size() != 2) {
// Show help
showHelp(this, user);
return false;
Expand All @@ -50,11 +51,33 @@ public boolean canExecute(User user, String label, List<String> args) {
user.sendMessage("general.errors.unknown-player", TextVariables.NAME, args.get(0));
return false;
}
island = getIslands().getIsland(getWorld(), targetUUID);
if (island == null) {
user.sendMessage("general.errors.player-has-no-island");
return false;

if (args.size() == 1) {
// We want to get the rank of the player on the island he is part of.
// So we have to make sure that this player has an island
if (!getIslands().hasIsland(getWorld(), targetUUID) && !getIslands().inTeam(getWorld(), targetUUID)) {
user.sendMessage("general.errors.player-has-no-island");
return false;
}

island = getIslands().getIsland(getWorld(), targetUUID);
} else {
// We want to get the rank of the player on the island of the owner we specify.
// So we have to make sure that the island owner actually owns an island
ownerUUID = getPlayers().getUUID(args.get(1));
if (ownerUUID == null) {
user.sendMessage("general.errors.unknown-player", TextVariables.NAME, args.get(1));
return false;
}

if (!getPlugin().getIslands().hasIsland(getWorld(), ownerUUID)) {
user.sendMessage("general.errors.player-is-not-owner", TextVariables.NAME, args.get(1));
return false;
}

island = getIslands().getIsland(getWorld(), ownerUUID);
}

return true;
}

Expand All @@ -64,9 +87,9 @@ public boolean execute(User user, String label, List<String> args) {
RanksManager rm = getPlugin().getRanksManager();
User target = User.getInstance(targetUUID);
int currentRank = island.getRank(target);
user.sendMessage("commands.admin.getrank.rank-is", TextVariables.RANK, user.getTranslation(rm.getRank(currentRank)));
user.sendMessage("commands.admin.getrank.rank-is", TextVariables.RANK, user.getTranslation(rm.getRank(currentRank)),
TextVariables.NAME, getPlayers().getName(island.getOwner()));
return true;

}

@Override
Expand All @@ -75,7 +98,7 @@ public Optional<List<String>> tabComplete(User user, String alias, List<String>
// Don't show every player on the server. Require at least the first letter
return Optional.empty();
}
String lastArg = !args.isEmpty() ? args.get(args.size()-1) : "";
String lastArg = args.get(args.size() - 1);
List<String> options = Bukkit.getOnlinePlayers().stream().map(Player::getName).collect(Collectors.toList());
return Optional.of(Util.tabLimit(options, lastArg));
}
Expand Down
Loading

0 comments on commit fb19c1f

Please sign in to comment.