Skip to content

Commit

Permalink
Release 1.18.0 (#1876)
Browse files Browse the repository at this point in the history
## Change Log 

* Island range perms could be 2x island distance

This could allow protection ranges to be much greater than the island
range and therefore overflow into adjacent islands.

#1851

* Ensure maxEverProtectionRange is less than range.

#1851

* Added test class for Island.

* Added access to private fields for JUnit tests

* Added Sonar Properties to POM

* Changes to analyze using sonar.

* Remove zip reference

* Avoid zipSlip vulnerability.

* Removed the unused WorldEdit hook. (#1853)

If someone wants to add it back later they can, but this code does
nothing right now.

* Requires nonNull parameters for User.instanceOf (#1852)

* Requires nonNull parameters for User.instanceOf

The only reason why User.instanceOf was returning a potential null was
if the parameter was null. Further absolutely no null checking was being
done, so the assumption was that User.instanceOf should never return a
null. This corrects the annotations and requires non-Null parameters.

* Remove null player test

* Fix JavaDoc for GameModeAddon inWorld method

* Fix max-range bug

* Remove illegal tag as it's not needed

* Code smell reduction

* Add missing packages so tests can pass.

* Non null user methods (#1856)

* This makes some User methods non-null.

Instead of returning null, some methods will throw an error if they are
called on non-Players. This means code does not have to do null checks.

* Perform null check in method.

* Null check

* Fix test

* Fix test.

* Npe squashing (#1857)

* Fix hanging [uuid] in info.

* NPE checking

* Make getProtectionCenter nonNull

* More NPE fixes.

* Fix test

* Make getPlayer() and getOfflinePlayer() nonNull returns

This requires addons to not use null checks and instead us the isPlayer
or isOfflinePlayer methods.

* NPE blockers

* Deprecate CompositeCommand isPlayer method.

* Fix test

* Use isPlayer instead of null check.

Refactor code to be easier to understand.

* Fix

* Fix some code smells.

* Prevent NPE possibility.

* Fix "ugly" enchant name. (#1858)

Enchant names did not have a touch of Util#prettifyText code.

* Remove deprecated events.

* Fix IslandSethomeCommand test

* Fix tests - just counts of events.

* Added API to get a translation without color conversion

It may be necessary to read the translation without converting colors to
Bukkit colors.

* Fix tests.

* Fix test.

* Version NPE protections.

* 1.18.0 (#1860)

* Mark all home-related methods in PlayersManager as deprecated.

* Fix bug where maxHomes was shown as null

* Version 1.18.0

API changes may break compatibility with Addons.

* Remove usage of deprecated methods except for migration code.

* Prevent NPE. Check isPlayer instead of getWorld() == null

* Fix nullability issue and added to @deprecated annotations

* Added deprecation notices to home methods in Players

* Fix missing color conversion for translations.

* Fix mis-statement of island protection coordinates in info command.

* Fix tests

* Fix missing edge deletion of island.

The bounding box was erroneously being made smaller when it was not
required because the inBounds check does that already.

#1863

* Prevent rare NPE

* Ensure oldIsland is never null.

* Refactored setowner command and added test class

* API: Require getWorldSettings to be a game mode world

* Fix tests and refactor code

* Fix test

IWM inWworld needs to return true

* Fix test

IWM inWorld must return true

* Put default getHandlers back in for backwards compatibility

Without them, too many older addons break. They need updating to have
their own handlers. Once that is done, the default ones can be removed
maybe.

* Refactor code for clarity.

* NPE protections

* Prevent NPE

@Poslovich - you were right!

* Throw an error if player is null

* Prevent NPE

* Prevent NPE

* Do a null check

* World should never be null.

* Require non-null world

* Require owner to be non-null. It should never be null

* Prevent NPEs

* Clear the going home flag for edge cases

There were a few potential times when the flag may not have been
cleared. These were mostly teleport failure scenarios. Hopefully, this
is all of them.

#1864

* Shift priority of EntityPortalEnterEvent to HIGH

#1866

This will allow other plugins running at NORMAL to cancel the event
before BentoBox does something.

* Increase priority of EntityPortalEvent listener

#1866

* Fixes #1868

* Code refactoring around User.getInstance(player)

Co-authored-by: BONNe <bonne@bonne.id.lv>
Co-authored-by: Fredthedoggy <45927799+Fredthedoggy@users.noreply.github.com>
Co-authored-by: Justin <jstnf@users.noreply.github.com>
Co-authored-by: gecko10000 <60494179+levtey@users.noreply.github.com>
  • Loading branch information
5 people committed Nov 9, 2021
1 parent a6d70d6 commit df2b445
Show file tree
Hide file tree
Showing 168 changed files with 2,502 additions and 1,632 deletions.
17 changes: 10 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,18 @@ jobs:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache local Maven repository
- name: Cache Maven packages
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Build
run: mvn --batch-mode clean org.jacoco:jacoco-maven-plugin:prepare-agent install
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: Build and analyze
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=BentoBoxWorld_BentoBox
- run: mvn --batch-mode clean org.jacoco:jacoco-maven-plugin:prepare-agent install
- run: mkdir staging && cp target/*.jar staging
- name: Save artifacts
uses: actions/upload-artifact@v2
Expand Down
36 changes: 32 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@
<!-- 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.17.3</build.version>
<build.version>1.18.0</build.version>
<sonar.organization>bentobox-world</sonar.organization>
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
</properties>

<!-- Profiles will allow to automatically change build version. -->
Expand Down Expand Up @@ -339,7 +341,33 @@
<version>3.0.0-M5</version>
<configuration>
<argLine>
--illegal-access=permit
--add-opens java.base/java.lang=ALL-UNNAMED
--add-opens java.base/java.math=ALL-UNNAMED
--add-opens java.base/java.io=ALL-UNNAMED
--add-opens java.base/java.util=ALL-UNNAMED
--add-opens
java.base/java.util.stream=ALL-UNNAMED
--add-opens java.base/java.text=ALL-UNNAMED
--add-opens
java.base/java.util.regex=ALL-UNNAMED
--add-opens
java.base/java.nio.channels.spi=ALL-UNNAMED
--add-opens java.base/sun.nio.ch=ALL-UNNAMED
--add-opens java.base/java.net=ALL-UNNAMED
--add-opens
java.base/java.util.concurrent=ALL-UNNAMED
--add-opens java.base/sun.nio.fs=ALL-UNNAMED
--add-opens java.base/sun.nio.cs=ALL-UNNAMED
--add-opens java.base/java.nio.file=ALL-UNNAMED
--add-opens
java.base/java.nio.charset=ALL-UNNAMED
--add-opens
java.base/java.lang.reflect=ALL-UNNAMED
--add-opens
java.logging/java.util.logging=ALL-UNNAMED
--add-opens java.base/java.lang.ref=ALL-UNNAMED
--add-opens java.base/java.util.jar=ALL-UNNAMED
--add-opens java.base/java.util.zip=ALL-UNNAMED
</argLine>
</configuration>
</plugin>
Expand All @@ -358,12 +386,12 @@
<failOnError>false</failOnError>
<additionalJOption>-Xdoclint:none</additionalJOption>
<!-- To compile with Java 11, this tag may be required -->
<!-- <javadocExecutable>${java.home}/bin/javadoc</javadocExecutable> -->
<javadocExecutable>${java.home}/bin/javadoc</javadocExecutable>
</configuration>
<executions>
<execution>
<id>attach-javadocs</id>
<phase>install</phase>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
Expand Down
10 changes: 4 additions & 6 deletions src/main/java/world/bentobox/bentobox/BentoBox.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;

import org.apache.commons.lang.exception.ExceptionUtils;
import org.bukkit.Bukkit;
Expand All @@ -23,7 +22,6 @@
import world.bentobox.bentobox.hooks.DynmapHook;
import world.bentobox.bentobox.hooks.MultiverseCoreHook;
import world.bentobox.bentobox.hooks.VaultHook;
import world.bentobox.bentobox.hooks.WorldEditHook;
import world.bentobox.bentobox.hooks.placeholders.PlaceholderAPIHook;
import world.bentobox.bentobox.listeners.BannedCommands;
import world.bentobox.bentobox.listeners.BlockEndDragon;
Expand Down Expand Up @@ -103,7 +101,7 @@ public void onEnable(){
logWarning("BentoBox is tested only on the following Spigot versions:");

List<String> versions = ServerCompatibility.ServerVersion.getVersions(ServerCompatibility.Compatibility.COMPATIBLE, ServerCompatibility.Compatibility.SUPPORTED)
.stream().map(ServerCompatibility.ServerVersion::toString).collect(Collectors.toList());
.stream().map(ServerCompatibility.ServerVersion::toString).toList();

logWarning(String.join(", ", versions));
logWarning("**************************************");
Expand Down Expand Up @@ -172,6 +170,7 @@ public void onEnable(){
completeSetup(loadTime);
} catch (Exception e) {
fireCriticalError(e.getMessage(), "");
e.printStackTrace();
}
});
}
Expand Down Expand Up @@ -227,7 +226,6 @@ private void completeSetup(long loadTime) {

// Register additional hooks
hooksManager.registerHook(new DynmapHook());
hooksManager.registerHook(new WorldEditHook());
// TODO: re-enable after rework
//hooksManager.registerHook(new LangUtilsHook());

Expand Down Expand Up @@ -333,7 +331,7 @@ public PlayersManager getPlayers() {
* @since 1.16.0
*/
public PlayersManager getPlayersManager() {
return playersManager;
return getPlayers();
}

/**
Expand All @@ -352,7 +350,7 @@ public IslandsManager getIslands() {
* @since 1.16.0
*/
public IslandsManager getIslandsManager() {
return islandsManager;
return getIslands();
}

private static void setInstance(BentoBox plugin) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ public AddonClassLoader(AddonsManager addonsManager, YamlConfiguration data, Fil
*/
@NonNull
public static 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"))
AddonDescription.Builder builder = new AddonDescription.Builder(Objects.requireNonNull(data.getString("main")), Objects.requireNonNull(data.getString("name")), Objects.requireNonNull(data.getString("version")))
.authors(Objects.requireNonNull(data.getString("authors")))
.metrics(data.getBoolean("metrics", true))
.repository(data.getString("repository", ""));

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

String apiVersion = data.getString("api-version");
if (apiVersion != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,26 +158,35 @@ public String getApiVersion() {
* @return the permissions
* @since 1.13.0
*/
@Nullable
public ConfigurationSection getPermissions() {
return permissions;
}

public static class Builder {
private @NonNull
final String main;
private @NonNull
final String name;
private @NonNull
final String version;
private @NonNull String description = "";
private @NonNull List<String> authors = new ArrayList<>();
private @NonNull List<String> dependencies = new ArrayList<>();
private @NonNull List<String> softDependencies = new ArrayList<>();
@NonNull
private final String main;
@NonNull
private final String name;
@NonNull
private final String version;
@NonNull
private String description = "";
@NonNull
private List<String> authors = new ArrayList<>();
@NonNull
private List<String> dependencies = new ArrayList<>();
@NonNull
private List<String> softDependencies = new ArrayList<>();
private boolean metrics = true;
private @NonNull String repository = "";
private @NonNull Material icon = Material.PAPER;
private @NonNull String apiVersion = "1";
private @Nullable ConfigurationSection permissions;
@NonNull
private String repository = "";
@NonNull
private Material icon = Material.PAPER;
@NonNull
private String apiVersion = "1";
@Nullable
private ConfigurationSection permissions;

/**
* @since 1.1
Expand Down Expand Up @@ -279,6 +288,6 @@ public Builder permissions(ConfigurationSection permissions) {
@Override
public String toString() {
return "AddonDescription [" + (name != null ? "name=" + name + ", " : "")
+ (version != null ? "version=" + version : "") + "]";
+ "version=" + version + "]";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ public abstract class GameModeAddon extends Addon {
public abstract WorldSettings getWorldSettings();

/**
* Checks if a player is in any of the island worlds
* @param loc - player to check
* @return true if in a world or false if not
* Checks if location is governed by this game mode
* @param loc - location to check
* @return true if location in covered by this addon or false if not
*/
public boolean inWorld(Location loc) {
return Util.sameWorld(loc.getWorld(), islandWorld);
Expand All @@ -63,7 +63,7 @@ public boolean inWorld(Location loc) {
/**
* Checks if world is governed by this game mode
* @param world - world to check
* @return true if in a world or false if not
* @return true if world in covered by this addon or false if not
* @since 1.2.0
*/
public boolean inWorld(World world) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ protected CompositeCommand(Addon addon, CompositeCommand parent, String label, S
* subcommands until it finds the right object and then runs execute on it.
*/
@Override
public boolean execute(CommandSender sender, String label, String[] args) {
public boolean execute(@NonNull CommandSender sender, @NonNull String label, String[] args) {
// Get the User instance for this sender
User user = User.getInstance(sender);
// Fire an event to see if this command should be cancelled
Expand Down Expand Up @@ -352,7 +352,7 @@ protected PlayersManager getPlayers() {
}

@Override
public BentoBox getPlugin() {
public @NonNull BentoBox getPlugin() {
return plugin;
}

Expand Down Expand Up @@ -422,7 +422,7 @@ protected UUID getOwner(@NonNull World world, @NonNull User user) {
}

@Override
public String getUsage() {
public @NonNull String getUsage() {
return "/" + usage;
}

Expand Down Expand Up @@ -476,9 +476,12 @@ public boolean isOnlyPlayer() {
* Convenience method to check if a user is a player
* @param user - the User
* @return true if sender is a player
* @deprecated use {@link User#isPlayer()}
* @forRemove 1.18.0
*/
@Deprecated
protected boolean isPlayer(User user) {
return user.getPlayer() != null;
return user.isPlayer();
}

/**
Expand Down Expand Up @@ -521,7 +524,7 @@ public void setOnlyPlayer(boolean onlyPlayer) {
* @return The instance of this {@link Command}.
*/
@Override
public Command setDescription(String description) {
public @NonNull Command setDescription(@NonNull String description) {
super.setDescription(description);
return this;
}
Expand Down Expand Up @@ -575,7 +578,7 @@ public void inheritPermission() {
* This creates the full linking chain of commands
*/
@Override
public Command setUsage(String usage) {
public @NonNull Command setUsage(@NonNull String usage) {
// Go up the chain
CompositeCommand parentCommand = getParent();
StringBuilder u = new StringBuilder().append(getLabel()).append(" ").append(usage);
Expand All @@ -590,7 +593,7 @@ public Command setUsage(String usage) {

@Override
@NonNull
public List<String> tabComplete(final CommandSender sender, final String alias, final String[] args) {
public List<String> tabComplete(final @NonNull CommandSender sender, final @NonNull String alias, final String[] args) {
List<String> options = new ArrayList<>();
// Get command object based on args entered so far
CompositeCommand command = getCommandFromArgs(args);
Expand Down

0 comments on commit df2b445

Please sign in to comment.