Skip to content

Commit df2b445

Browse files
tastybentoBONNeFredthedoggyjstnfgecko10000
authored
Release 1.18.0 (#1876)
## 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>
1 parent a6d70d6 commit df2b445

File tree

168 files changed

+2502
-1632
lines changed

Some content is hidden

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

168 files changed

+2502
-1632
lines changed

.github/workflows/build.yml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,18 @@ jobs:
2424
path: ~/.sonar/cache
2525
key: ${{ runner.os }}-sonar
2626
restore-keys: ${{ runner.os }}-sonar
27-
- name: Cache local Maven repository
27+
- name: Cache Maven packages
2828
uses: actions/cache@v2
2929
with:
30-
path: ~/.m2/repository
31-
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
32-
restore-keys: |
33-
${{ runner.os }}-maven-
34-
- name: Build
35-
run: mvn --batch-mode clean org.jacoco:jacoco-maven-plugin:prepare-agent install
30+
path: ~/.m2
31+
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
32+
restore-keys: ${{ runner.os }}-m2
33+
- name: Build and analyze
34+
env:
35+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
36+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
37+
run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=BentoBoxWorld_BentoBox
38+
- run: mvn --batch-mode clean org.jacoco:jacoco-maven-plugin:prepare-agent install
3639
- run: mkdir staging && cp target/*.jar staging
3740
- name: Save artifacts
3841
uses: actions/upload-artifact@v2

pom.xml

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,9 @@
8383
<!-- Do not change unless you want different name for local builds. -->
8484
<build.number>-LOCAL</build.number>
8585
<!-- This allows to change between versions. -->
86-
<build.version>1.17.3</build.version>
86+
<build.version>1.18.0</build.version>
87+
<sonar.organization>bentobox-world</sonar.organization>
88+
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
8789
</properties>
8890

8991
<!-- Profiles will allow to automatically change build version. -->
@@ -339,7 +341,33 @@
339341
<version>3.0.0-M5</version>
340342
<configuration>
341343
<argLine>
342-
--illegal-access=permit
344+
--add-opens java.base/java.lang=ALL-UNNAMED
345+
--add-opens java.base/java.math=ALL-UNNAMED
346+
--add-opens java.base/java.io=ALL-UNNAMED
347+
--add-opens java.base/java.util=ALL-UNNAMED
348+
--add-opens
349+
java.base/java.util.stream=ALL-UNNAMED
350+
--add-opens java.base/java.text=ALL-UNNAMED
351+
--add-opens
352+
java.base/java.util.regex=ALL-UNNAMED
353+
--add-opens
354+
java.base/java.nio.channels.spi=ALL-UNNAMED
355+
--add-opens java.base/sun.nio.ch=ALL-UNNAMED
356+
--add-opens java.base/java.net=ALL-UNNAMED
357+
--add-opens
358+
java.base/java.util.concurrent=ALL-UNNAMED
359+
--add-opens java.base/sun.nio.fs=ALL-UNNAMED
360+
--add-opens java.base/sun.nio.cs=ALL-UNNAMED
361+
--add-opens java.base/java.nio.file=ALL-UNNAMED
362+
--add-opens
363+
java.base/java.nio.charset=ALL-UNNAMED
364+
--add-opens
365+
java.base/java.lang.reflect=ALL-UNNAMED
366+
--add-opens
367+
java.logging/java.util.logging=ALL-UNNAMED
368+
--add-opens java.base/java.lang.ref=ALL-UNNAMED
369+
--add-opens java.base/java.util.jar=ALL-UNNAMED
370+
--add-opens java.base/java.util.zip=ALL-UNNAMED
343371
</argLine>
344372
</configuration>
345373
</plugin>
@@ -358,12 +386,12 @@
358386
<failOnError>false</failOnError>
359387
<additionalJOption>-Xdoclint:none</additionalJOption>
360388
<!-- To compile with Java 11, this tag may be required -->
361-
<!-- <javadocExecutable>${java.home}/bin/javadoc</javadocExecutable> -->
389+
<javadocExecutable>${java.home}/bin/javadoc</javadocExecutable>
362390
</configuration>
363391
<executions>
364392
<execution>
365393
<id>attach-javadocs</id>
366-
<phase>install</phase>
394+
<phase>package</phase>
367395
<goals>
368396
<goal>jar</goal>
369397
</goals>

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import java.util.List;
44
import java.util.Optional;
5-
import java.util.stream.Collectors;
65

76
import org.apache.commons.lang.exception.ExceptionUtils;
87
import org.bukkit.Bukkit;
@@ -23,7 +22,6 @@
2322
import world.bentobox.bentobox.hooks.DynmapHook;
2423
import world.bentobox.bentobox.hooks.MultiverseCoreHook;
2524
import world.bentobox.bentobox.hooks.VaultHook;
26-
import world.bentobox.bentobox.hooks.WorldEditHook;
2725
import world.bentobox.bentobox.hooks.placeholders.PlaceholderAPIHook;
2826
import world.bentobox.bentobox.listeners.BannedCommands;
2927
import world.bentobox.bentobox.listeners.BlockEndDragon;
@@ -103,7 +101,7 @@ public void onEnable(){
103101
logWarning("BentoBox is tested only on the following Spigot versions:");
104102

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

108106
logWarning(String.join(", ", versions));
109107
logWarning("**************************************");
@@ -172,6 +170,7 @@ public void onEnable(){
172170
completeSetup(loadTime);
173171
} catch (Exception e) {
174172
fireCriticalError(e.getMessage(), "");
173+
e.printStackTrace();
175174
}
176175
});
177176
}
@@ -227,7 +226,6 @@ private void completeSetup(long loadTime) {
227226

228227
// Register additional hooks
229228
hooksManager.registerHook(new DynmapHook());
230-
hooksManager.registerHook(new WorldEditHook());
231229
// TODO: re-enable after rework
232230
//hooksManager.registerHook(new LangUtilsHook());
233231

@@ -333,7 +331,7 @@ public PlayersManager getPlayers() {
333331
* @since 1.16.0
334332
*/
335333
public PlayersManager getPlayersManager() {
336-
return playersManager;
334+
return getPlayers();
337335
}
338336

339337
/**
@@ -352,7 +350,7 @@ public IslandsManager getIslands() {
352350
* @since 1.16.0
353351
*/
354352
public IslandsManager getIslandsManager() {
355-
return islandsManager;
353+
return getIslands();
356354
}
357355

358356
private static void setInstance(BentoBox plugin) {

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ public AddonClassLoader(AddonsManager addonsManager, YamlConfiguration data, Fil
7979
*/
8080
@NonNull
8181
public static AddonDescription asDescription(YamlConfiguration data) throws InvalidAddonDescriptionException {
82-
AddonDescription.Builder builder = new AddonDescription.Builder(data.getString("main"), data.getString("name"), data.getString("version"))
83-
.authors(data.getString("authors"))
82+
AddonDescription.Builder builder = new AddonDescription.Builder(Objects.requireNonNull(data.getString("main")), Objects.requireNonNull(data.getString("name")), Objects.requireNonNull(data.getString("version")))
83+
.authors(Objects.requireNonNull(data.getString("authors")))
8484
.metrics(data.getBoolean("metrics", true))
8585
.repository(data.getString("repository", ""));
8686

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

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

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

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -158,26 +158,35 @@ public String getApiVersion() {
158158
* @return the permissions
159159
* @since 1.13.0
160160
*/
161+
@Nullable
161162
public ConfigurationSection getPermissions() {
162163
return permissions;
163164
}
164165

165166
public static class Builder {
166-
private @NonNull
167-
final String main;
168-
private @NonNull
169-
final String name;
170-
private @NonNull
171-
final String version;
172-
private @NonNull String description = "";
173-
private @NonNull List<String> authors = new ArrayList<>();
174-
private @NonNull List<String> dependencies = new ArrayList<>();
175-
private @NonNull List<String> softDependencies = new ArrayList<>();
167+
@NonNull
168+
private final String main;
169+
@NonNull
170+
private final String name;
171+
@NonNull
172+
private final String version;
173+
@NonNull
174+
private String description = "";
175+
@NonNull
176+
private List<String> authors = new ArrayList<>();
177+
@NonNull
178+
private List<String> dependencies = new ArrayList<>();
179+
@NonNull
180+
private List<String> softDependencies = new ArrayList<>();
176181
private boolean metrics = true;
177-
private @NonNull String repository = "";
178-
private @NonNull Material icon = Material.PAPER;
179-
private @NonNull String apiVersion = "1";
180-
private @Nullable ConfigurationSection permissions;
182+
@NonNull
183+
private String repository = "";
184+
@NonNull
185+
private Material icon = Material.PAPER;
186+
@NonNull
187+
private String apiVersion = "1";
188+
@Nullable
189+
private ConfigurationSection permissions;
181190

182191
/**
183192
* @since 1.1
@@ -279,6 +288,6 @@ public Builder permissions(ConfigurationSection permissions) {
279288
@Override
280289
public String toString() {
281290
return "AddonDescription [" + (name != null ? "name=" + name + ", " : "")
282-
+ (version != null ? "version=" + version : "") + "]";
291+
+ "version=" + version + "]";
283292
}
284293
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ public abstract class GameModeAddon extends Addon {
5252
public abstract WorldSettings getWorldSettings();
5353

5454
/**
55-
* Checks if a player is in any of the island worlds
56-
* @param loc - player to check
57-
* @return true if in a world or false if not
55+
* Checks if location is governed by this game mode
56+
* @param loc - location to check
57+
* @return true if location in covered by this addon or false if not
5858
*/
5959
public boolean inWorld(Location loc) {
6060
return Util.sameWorld(loc.getWorld(), islandWorld);
@@ -63,7 +63,7 @@ public boolean inWorld(Location loc) {
6363
/**
6464
* Checks if world is governed by this game mode
6565
* @param world - world to check
66-
* @return true if in a world or false if not
66+
* @return true if world in covered by this addon or false if not
6767
* @since 1.2.0
6868
*/
6969
public boolean inWorld(World world) {

src/main/java/world/bentobox/bentobox/api/commands/CompositeCommand.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ protected CompositeCommand(Addon addon, CompositeCommand parent, String label, S
218218
* subcommands until it finds the right object and then runs execute on it.
219219
*/
220220
@Override
221-
public boolean execute(CommandSender sender, String label, String[] args) {
221+
public boolean execute(@NonNull CommandSender sender, @NonNull String label, String[] args) {
222222
// Get the User instance for this sender
223223
User user = User.getInstance(sender);
224224
// Fire an event to see if this command should be cancelled
@@ -352,7 +352,7 @@ protected PlayersManager getPlayers() {
352352
}
353353

354354
@Override
355-
public BentoBox getPlugin() {
355+
public @NonNull BentoBox getPlugin() {
356356
return plugin;
357357
}
358358

@@ -422,7 +422,7 @@ protected UUID getOwner(@NonNull World world, @NonNull User user) {
422422
}
423423

424424
@Override
425-
public String getUsage() {
425+
public @NonNull String getUsage() {
426426
return "/" + usage;
427427
}
428428

@@ -476,9 +476,12 @@ public boolean isOnlyPlayer() {
476476
* Convenience method to check if a user is a player
477477
* @param user - the User
478478
* @return true if sender is a player
479+
* @deprecated use {@link User#isPlayer()}
480+
* @forRemove 1.18.0
479481
*/
482+
@Deprecated
480483
protected boolean isPlayer(User user) {
481-
return user.getPlayer() != null;
484+
return user.isPlayer();
482485
}
483486

484487
/**
@@ -521,7 +524,7 @@ public void setOnlyPlayer(boolean onlyPlayer) {
521524
* @return The instance of this {@link Command}.
522525
*/
523526
@Override
524-
public Command setDescription(String description) {
527+
public @NonNull Command setDescription(@NonNull String description) {
525528
super.setDescription(description);
526529
return this;
527530
}
@@ -575,7 +578,7 @@ public void inheritPermission() {
575578
* This creates the full linking chain of commands
576579
*/
577580
@Override
578-
public Command setUsage(String usage) {
581+
public @NonNull Command setUsage(@NonNull String usage) {
579582
// Go up the chain
580583
CompositeCommand parentCommand = getParent();
581584
StringBuilder u = new StringBuilder().append(getLabel()).append(" ").append(usage);
@@ -590,7 +593,7 @@ public Command setUsage(String usage) {
590593

591594
@Override
592595
@NonNull
593-
public List<String> tabComplete(final CommandSender sender, final String alias, final String[] args) {
596+
public List<String> tabComplete(final @NonNull CommandSender sender, final @NonNull String alias, final String[] args) {
594597
List<String> options = new ArrayList<>();
595598
// Get command object based on args entered so far
596599
CompositeCommand command = getCommandFromArgs(args);

0 commit comments

Comments
 (0)