Commit Graph

54 Commits

Author SHA1 Message Date
tastybento aaa1504dc6 WIP multipaper 2024-04-07 17:05:21 -07:00
tastybento 81f765df36 Fix invites and accepts. 2024-03-30 20:57:20 -07:00
tastybento 2b19d43c85 Remove restrictions on having multiple islands for team members.
Added API to enable checking for teams on islands easier.
2024-03-29 19:38:44 -07:00
tastybento 12bf37d2c2
No tabs (#2243)
* Remove all tabs from source and replace with 4 spaces.
2023-12-04 20:55:40 -08:00
tastybento 63d092db93
Multi island api update (#2224)
* Fixes bug with island team joining and deletion. Include debug.

* Remove ambiguous API with mutli-island.

* Add back deprecated methods so developers can be wartned not to use them

* Added back in deprecated methods.

* Fix bugs and NPEs.

* Fix some code smells

* Remove debug logging.
2023-11-12 12:22:12 -08:00
tastybento a4bef159be
2 0 0 multi island (#2185)
* Multi world WIP - stashing

* Initial work on supporting multiple islands per player

The default allowed number is 5 for now, but will be set to 1 by
default.

Lots more work to do on this!

* More work on multi island. Fixed tests so clean compile.

* Remove unused imports

* Updated island go and homes command to multi island

Updated tests.

* Do not reload addons anymore.

* Add island name when entering or leaving own island

* Remove unused import

* Adds island names to /island go command.

* Enables more homes to be set if player has more than one island

* Switch to using a set for islands and explicit primary boolean in Island

* WIP

* Fix bugs with the go command.

* Be able to delete multiple islands, e.g. when joining a team

This is not fully tested.

* Do not remove all islands when a player does reset.

Players can reset just the island they are on.

* More fixes for go command

* Fix tests

* Fix @NonNull annotation

* Fix home syntax listing reference for IslandDeleteHome

* Fixed deletehome for multiple islands.

* Fix /island command teleport to current island default home.

* Remove deprecated code.

* Fix tag for concurrent island setting in config.yml

* Improve error when trying to make additional islands over limit

* Update config.yml

* Correctly assign invites for islands.

* Switch to canExecute API in prep for multi-island handling

* Prevent players from obtaining more concurrent islands by owner transfer

* Handle leaving and disbanding of teams

* Fix tests

* Fix minor bugs or code smells.

* Restore the quarantine code from deprecation.

This code can stay. It checks if islands can load, and if not puts them
in a trash. It does no harm.

* Remove unneeded eq()'s

* Fix tests
2023-09-16 15:55:52 -07:00
tastybento 056cff4b6f
Code clean up from Sonar Cloud analysis (#2068)
* Code clean up from Sonar Cloud analysis

* Fix tests

* Remove code smell

* Rename "island" which hides the field declared at line 25.

* Removed code smells.

* Rename variable record to rec

Renamed "record" variable to not match a restricted identifier.
Restricted Identifiers should not be used as identifiers. "record" is
using in Java 16.

* Added private constructor to prevent instantiation of static class

Changed variable name to rec instead of restricted "record".

* Remove Blueprint code smells.

* Use a record for database settings constructor

Code smell: Methods should not have too many parameters. I'm not sure
what methods are using this class though.

* Update MyWorlds version

The POM for MyWorlds is invalid and causes a warning, but this still
persists with this version.

* Extracted nested try block into a separate method.

Makes it clear when reading the code what might be caught

* Extracted nested try block into a separate method.

* Fixed JavaDoc /** instead of just /*

* Extracted nested try block into a separate method.

* Refactored to not assign loop counter from within the loop body.

* Better delete option. With results.

That said, this is legacy code to handle an issue that occurred a long
time ago and this whole set of code can probably be removed.

* Catch Exceptions not Throwable

* Log error with BentoBox logError

* Use computeIfAbsent

Using these instead leads to cleaner and more readable code.

* User can no longer be null

* Added the missing @Deprecated annotation and @since ref

* Added @since reference

* Merge if statements

* Use BentoBox error logging.

* Added JavaDoc @since

* Remove deprecated class and move used class

* Remove deprecated WoodType and use Type.

* Remove unused import

* Extracted nested try block into a separate method.

* Comment empty default statement

* Clean up logic; avoid switch

* Use Java instead of Guava

* private constructor to hide the implicit public one.

* Private constructor to hide the implicit public one.

Merged if statement.

* Add comment

* if merge

* Make variable constant

* Remove unused imports

* Remove deprecated and unused method

* Remove unused import

* Typo

* Remove instanceof and cast

* Remove superfluous null check

* Put constant at bottom of file because @BONNe likes it there.

* Simplify particle validation code
2022-12-31 16:41:17 -08:00
tastybento 69fa951907 Handles null player world better on joining server
In theory, this should not be required, but it seems that a player's
world might be null in some edge cases. Alternatively, the Util.getWorld
function can return a null if the player was in a nether or end but that
does not have a corresponding overworld.
Addresses #2057
2022-12-04 20:36:41 -08:00
tastybento 7b94aa0ea2
Adds bonus range elements to Island object. (#1921)
* Adds bonus range elements to Island object.

Admin commands still need to be adjusted or added to support management
of the bonus ranges.

* Changed to mutable class

Fixed bugs.
2022-01-28 18:35:55 -08:00
tastybento 3dd9e973fb 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.

https://github.com/BentoBoxWorld/BentoBox/issues/1851
2021-09-11 16:50:43 -07:00
tastybento 23857501f5
Static code analysis (#1844)
* StringBuffer (Java 5) may be declared as StringBuilder

* Replace map with flatMap

* Use instanceof naming

* No need to specify paramter types.

* Remove verbose code

* Fix JavaDoc issues

* Make internal class a record.

* Remove unused import.

* Make internal class a record.

* Made internal class a record.

* Removed unused import

* Fix typos

* Fix typo in test.
2021-08-29 18:17:38 -07:00
tastybento 9dc4ebc2d1
Make variables final if they can be. (#1843)
* Make variables final if they can be.

* Do not use final so that test can pass.

For testing, we use a trick to set this variable, but it won't work if
it is final. Right now, I'd like to keep the test.
2021-08-29 18:17:21 -07:00
tastybento acfc001cd6
Java upgrade (#1814)
* Version 1.17.3

* Use Map.of and List.of instead of Immutable collections

* Replace explicit type argument.

* Replace lamba with method reference

* Replace condition with Objects.requireNonNullElseGet

* Use String.repeat

* Use new switch expressions

* Use instanceof patten variables which are more compact

* Fuse toUnmodifiableList into stream and return it.

* Remove unnecessary toString() calls.

* Remove unnecessary public

* Extracted common part from if

* Simplify conditional expressions

* Remove unused IOExceptions

* Cast to long

* Use Map.putAll

* Use primitives

* Clarify what is null or not

* Addedd @Serial annotation introduced with Java 14.

* Use Optional.isEmpty instead of !isPresent

* Use flatMap then ifPresent

* Just use Arrays.stream

* Swap map and filter for null with Objects::nonNull

* Use expression lambda
2021-07-31 08:48:26 -07:00
BONNe 3a1ec0a570
Implements better online player counter. (#1791)
Current one is based on online player count when bStats sends data to the server.
This one will send data about amount of players who logged in the server.
2021-07-06 15:22:44 +02:00
tastybento b6a69d0c90
Switch to island homes from player homes. (#1689)
* Switch to island homes from player homes.

Stores home locations and max homes in the Island object. Adds commands
required to manage home names, specifically rename and delete. I did not
add list as there is tab complete on island go, but it may be required.
2021-03-01 10:42:08 -08:00
tastybento f4ff1bb412 Filter out null islands in worlds where players have none in world. 2021-02-28 11:55:43 -08:00
tastybento dfd4df4e05
Adds maxMembers to the Island object for persistent storage (#1691)
* Adds maxMembers to the Island object for persistent storage

https://github.com/BentoBoxWorld/BentoBox/issues/1690

* Expanded approach to include coop and trusted ranks.

* Checks for max members/coops/trusts on accept based on island setting.

* Write island max member/coop/trusted if owner joins server

This updates the island's settings based on the owner's permissions.
2021-02-27 11:19:02 -08:00
tastybento 1d9ce7241e
Decouple island location from island center. (#1659)
* Decouple island location from island center.

This enables the protection area to move anywhere within the island
boundaries

* Paste island at island location.

* Move visitors to the island location

* Added island location placeholders

* Use island location instead of island center

* Fix tests

* Allow radius 1 islands.

* Correct admin range set limit

* Debug in progress

* Fix island deletion.

The speed option was doing nothing except causing repeated actions on
the same chunks.

* Soft depend for WorldGeneratorApi for Boxed game mode

* Changed to "protectionCenter".

Added logic to expand the deletion area based on moving the island
protection location and range instead of just deleting everything. This
will keep deletion time to a minimum for BSkyBlock, etc.

* Fix tests.
2021-02-13 10:19:53 -08:00
tastybento 2c004ce504 Clear user cache on login.
Fixes https://github.com/BentoBoxWorld/BentoBox/issues/1341

Server calls PlayerTeleportEvent if player is mounted on quit, which
inserts player back into cache. By clearing the cache on login, the
stale player object will be cleared.
2020-05-05 16:26:51 -07:00
tastybento 4a3c9ad8ae Added null checking for world when changing worlds
https://github.com/BentoBoxWorld/BentoBox/issues/1336
2020-05-02 18:54:06 -07:00
tastybento f0564b7c78 Puts a null check on player UUID
It's possible for fake players to have null UUIDs apparently. So this
check avoids an NPE.
2020-05-01 20:48:04 -07:00
tastybento 0a86ddd0ab Fixes island creation on joining.
Fixes https://github.com/BentoBoxWorld/BentoBox/issues/1221

The original code could actually never work because the check for
whether a player had played before or not was occuring immediately after
addPlayer, which added the player to the server. Also, the code to run
was running in a thread and not on the main thread, so if it had run
could have caused errors.
2020-03-10 18:30:50 -07:00
BONNe 2192e3fa4e Add new IslandEvent: IslandProtectionRangeChange (#1109)
* Add new IslandEvent: IslandProtectionRangeChange.

This event is fired when island protection range is updated. It contains new and old protection range values.
Event implements cancellable as other IslandEvent, but cancelling (or changing event values) is not implemented.

* Fix extended class.
IslandProtectionRangeChangeEvent should extend IslandBaseEvent.
2020-01-17 13:42:53 +01:00
tastybento 7737456309 Fixes issue with island protection range and permissions.
Permissions could set the island protection range greater than the
island distance.

This commit also fixes the User method that calculates the max value
from a permission. The default value was being used as the starting
point rather than 0, so it was not possible to set perms to go less than
the default value.

Added test clases around all these items.

https://github.com/BentoBoxWorld/BentoBox/issues/1047
2019-11-28 21:48:07 -08:00
tastybento d7b428fc58 Remove unused imports 2019-11-11 07:51:29 -08:00
Florian CUNY a1b7df19c7 Added WorldSettings options to create island on first login
Implements https://github.com/BentoBoxWorld/BentoBox/issues/889
2019-11-09 17:50:27 +01:00
Florian CUNY e5646c72cd Removed unneeded #isKnown() check in onJoin listener
Since the player is added to the player cache right before the check, the code is always executed.
2019-11-09 11:41:48 +01:00
tastybento 87168a5ea9 Compile against Spigot 1.14.4 (#919)
Fixes #914.

* Shifts to compile with 1.14.4 API.

Note that this will make some events incompatible with 1.13.2 because of
a class not found error.

* WIP

* Fixed deprecated APIs and ItemStackAdapter test case

* Fixes enderchest test bug.

* Updated server version compatibilities in ServerCompatibility
2019-08-29 21:18:45 +02:00
tastybento e99f84f7c7 Prevents named mobs from being cleared on teleport.
Adds a setting in BentoBox config to set the clear radius.
Adds defensive code to avoid clearing mobs in non game worlds.

https://github.com/BentoBoxWorld/BentoBox/issues/847
https://github.com/BentoBoxWorld/BentoBox/issues/819
2019-07-18 21:58:16 -07:00
tastybento 3f3ac57f1e Cleans up code smells. 2019-07-11 13:55:17 -07:00
tastybento 1f341f4929 Remove code smells due to nonNull Spigot settings
Let's see if the nonNull's are really true!
2019-03-23 16:34:04 -07:00
tastybento cb09ec2e3a Switched from plugin.getServer() to Bukkit.getServer() to enable tests
plugin.getServer() cannot be mocked because it is final.
2019-03-11 22:58:30 -07:00
tastybento 15f97927de Fixes range resetting if player does not have a range permission.
If a player's island range is set using the range set admin command, the
range was being reset when the player logged in if they had no range
permission.

https://github.com/BentoBoxWorld/BentoBox/issues/484
2019-03-03 19:23:15 -08:00
Florian CUNY 587e400287 Fixed code smells 2019-02-22 10:40:05 +01:00
BONNe 54811c5dbd Fix issue with offline players that kept inventory (#564)
Fixes #521 


* Fix issue with offline players that kept inventory, after being kicked out of team. (#521)

* Update src/main/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamKickCommand.java

Co-Authored-By: BONNe <bonne@bonne.id.lv>

* Update IslandTeamKickCommand.java

* Change QuarantinedWorld to PendingKicks.

Increase PlayerChangedWorldEvent event priority.
2019-02-21 16:55:09 +01:00
tastybento bce17ce467 Added admin trash command to handle damaged island db (#546)
* WIP - adds admin commands to handle damaged island db

Trash, purge, etc.

DO NOT MERGE YET

https://github.com/BentoBoxWorld/BentoBox/issues/505

* Prefixes the island uniqueId with the game mode name.

This enables manual removal of old game mode island files from the
database by admins if required.

* Adds Admin trash and empty trash commands

* Adds various commands for trash management

* Remove unused imports

* Forgot the javadoc in IslandsManager
2019-02-17 13:32:05 +01:00
Florian CUNY 9803a02471 Added NonNull to all listeners constructors 2019-02-16 10:58:25 +01:00
Florian CUNY 0d7836ff12 Revert "Made each "basic" listeners register themselves on instanciation"
This reverts commit 53137b526d.
2019-02-16 10:48:39 +01:00
Florian CUNY 53137b526d Made each "basic" listeners register themselves on instanciation 2019-02-14 11:24:58 +01:00
Florian CUNY 457b296372 Fixed code smells 2019-01-12 18:29:20 +01:00
tastybento d13ae470d5 Removed unused imports. 2019-01-03 10:25:03 -08:00
Florian CUNY 9f676636e0 Fixed some code smells 2019-01-03 17:09:27 +01:00
Florian CUNY 396425a52d Started implementing automated island ownership transfer
#167
2019-01-02 23:02:52 +01:00
tastybento ca844f1727 Fixes some code smells. 2018-12-13 08:10:33 +09:00
tastybento 9c9490908e Fixes message to players about losing coop. 2018-12-10 15:44:29 -08:00
tastybento 1a1fe14775 Merge branch 'develop' of https://github.com/BentoBoxWorld/bentobox.git into develop 2018-12-09 22:54:44 -08:00
tastybento 3dd7126ca9 Added coop removal when all island members log out.
Needs to be tested.
2018-12-09 22:54:37 -08:00
Florian CUNY a04a0cb3d0 Replace code referencing "teamleader" to "owner"
This will improve the consistency of the code, as well as the Javadocs.

Locales (and some other files) still need to be updated to remove these references to team leader.
2018-12-09 11:28:31 +01:00
tastybento ffd1af5867 Removes coop on logout of cooped player or server shutdown.
https://github.com/BentoBoxWorld/bentobox/issues/335
2018-11-20 12:52:12 -08:00
Florian CUNY a071f97538 Fixed island protection range not being updated after a login
Fixes #256.
2018-10-27 16:47:55 +02:00