Commit Graph

966 Commits

Author SHA1 Message Date
tastybento
24148f30ba
Rank Management (#2220)
* Put ranks in the database. Prework for #1798

* Prevent coop and trust commands from being registered

if those ranks don't exist.

* Add /bbox rank command for ranks management

* Rename RanksObject to Ranks

* Strip / on commands if it exists. Fixes #2221

* Fix test failure
2023-11-10 10:53:28 -08:00
tastybento
4481881b9e Fix tests 2023-11-10 07:34:52 -08:00
tastybento
6d09a5a359 Fixes #2219. Island homes were set incorrectly with a new island. 2023-11-04 10:29:28 -07:00
tastybento
d903e57ad6
Remove the deprecated classes for 2.0 (#2216) 2023-10-28 21:16:04 -07:00
tastybento
5ccaadb2ae Fix tests. 2023-10-21 08:19:46 -07:00
tastybento
8d0dbcdc36 Fix erroneous code that got pasted in... 2023-10-21 08:00:19 -07:00
tastybento
e4836b9cef Remove island number check for owner transfer.
This is not needed anymore (we think).
2023-10-21 07:55:03 -07:00
tastybento
ea5529f077
Enables permissions to set how many islands a play can create. (#2201)
Multiple Island Permissions #2199
2023-10-15 19:01:02 -07:00
tastybento
c8b2e1d801 Changed some tests for ItemParsing.
Potions are no longer extended or upgraded using the deprecated
PotionData. They have explict names, like "long_night_vision" or
similar. So these tests don't work any more.
2023-10-11 22:48:39 -07:00
tastybento
a2f1054bbe PotionTypes have changed and now are explicitly named
For example, extended are now called
2023-10-11 22:46:51 -07:00
tastybento
9f8a6bcded Remove players from the island and cache. 2023-10-11 21:43:30 -07:00
tastybento
2b65543935 Adds InvincibleVisitorFlagDamageRemovalEvent and tests.
Resolves #2196
2023-10-08 08:56:13 -07:00
tastybento
7fbd041be9 Check passengers of jockeys when spawned. #2195 2023-10-07 11:15:23 -07:00
tastybento
2bc82dd3cf
Add checking for enchantment table inventory (#2191)
Fixes #2190
2023-09-19 21:07:28 -07: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
503107a90c Fix test 2023-09-04 14:58:23 -07:00
tastybento
8d3be9c0ff Added island member placeholders
Relates to #2180
2023-09-03 10:50:47 -07:00
tastybento
ba31dd78b4 Ignoring sculk sensor test for now.
It used to work, but now doesn't. I've tried updating various plugins
and trying different things, but it seems that the mocking is not
working correctly. I don't know why.
2023-09-03 08:58:00 -07:00
tastybento
a7b791f4be Fixes #2173. Copies the correct range of blocks. Added test class.
Issue was with negative numbers that (int) rounds towards zero and not
towards negative infinity.
2023-09-02 08:04:34 -07:00
tastybento
aed78038ef Fix issue with NPE when Op does Command Ranks and does not own island
Related to #2170

Added a test class for CommandRankClickListener and reworked the logic.
2023-08-17 20:42:17 -07:00
tastybento
06ccb8a5e0 Fixed issue with demoting or promoting above yourself.
Addresses #2164

Added test class to check command. Added new error text.
2023-08-10 21:57:41 -07:00
tastybento
3e1dc81592 Minor code smell reduction 2023-07-22 16:03:55 -07:00
tastybento
62a3a8d6fa Fixed NPE when getting UUID for unknown name.
Added test methods for PlayersManager
2023-07-22 12:00:10 -07:00
tastybento
1a0a314ece Added ClosestSafeSpotTeleport class
Removed code from the main class that was not being used. e.g.,
failureRunnable.
2023-07-20 15:09:14 -07:00
tastybento
2512a892fd Added clearInline Mocks just in case. 2023-07-20 00:38:58 -07:00
tastybento
8ce78c8fe0 Added DefaultPasteUtil test class 2023-07-15 17:55:48 -07:00
tastybento
2dfd136591 Added test class 2023-07-15 16:55:59 -07:00
tastybento
357a8fdc5f Added test class for BlueprintEntity 2023-07-15 16:45:51 -07:00
tastybento
a6bb78c80f Refactor to reduce complexity 2023-07-10 22:25:30 -07:00
tastybento
170c31fcec Judge location of damage by location of entity not user 2023-07-09 15:07:37 -07:00
tastybento
4ef974fbde Better error for unknown icon material, and test class 2023-07-08 08:52:20 -07:00
tastybento
2c8db2a797 Use any() which now is a varArg tester. Remove deprecation 2023-07-08 08:37:10 -07:00
tastybento
9334858675 Added IslandDeletehomeCommand test class 2023-07-03 16:11:37 -07:00
tastybento
7d25aff28f Added test class for DefaultPlayerCommand 2023-07-02 15:52:20 -07:00
tastybento
f47e87af82 Added test class for PanelItem 2023-07-02 15:10:23 -07:00
tastybento
9bd0104a3d Put island deletion under one class manager
The goal is to make BentoBox less of a monster class and have fewer
dependent classes.
2023-07-01 12:49:18 -07:00
tastybento
e846d26fab Fix test
Test doesn't do anything though...
2023-06-28 21:02:39 -07:00
tastybento
0038c3f2b7 Remove boolean return for listener. Check event cancelation instead. 2023-06-24 15:22:23 -07:00
tastybento
66d27e7070
Merge pull request #2148 from BentoBoxWorld/sculk_cal
Adds calibrated sculk sensor to protection
2023-06-24 12:55:36 -07:00
tastybento
1a416d9a23 Fixes #2137 adds calibrated sculk sensor and test class 2023-06-24 12:11:08 -07:00
tastybento
89a9b13d81 Hidden commands can be seen by console, but are hidden from players 2023-06-24 10:40:44 -07:00
tastybento
a7ffb79f1d
Merge branch 'develop' into bbox_perms_command 2023-06-24 10:15:34 -07:00
tastybento
0856d48470 Proactively clear Users before tests just in case. 2023-06-24 10:13:11 -07:00
tastybento
4d295068cf Fix onlyConsole usage and added test class 2023-06-24 09:45:40 -07:00
tastybento
bcb4ed28b8
Fixes #2142 (#2144)
Fixes the logic and adds a bunch of tests to prove the logic works.
2023-06-21 08:15:53 +03:00
tastybento
a90a00b09b Fix new permission tests 2023-06-19 09:36:45 -07:00
tastybento
5a52978803 Add perms test for admin teleport command 2023-06-18 13:35:16 -07:00
tastybento
2672ee5d1b Handle Boats and other Materials for 1.20. Uses Tags a lot.
May break compatibility with older server versions.
2023-06-10 21:31:39 -07:00
tastybento
e4a3891590 Add new IslandNameEvent and test class for command 2023-06-06 20:38:59 -07:00
tastybento
8f954090e7 Fixes VisitorKeepInventory to disregard coops and trusted
#2126
Also fixes some tests.
2023-05-13 09:20:47 -07:00
tastybento
b4737f104c Implements HARVEST and CROP_PLANTING protection flags
Requested by #2113
2023-04-07 20:51:59 +01:00
tastybento
073f3a49d5
Adds API to enable translations to be set and specific API for flags (#2109)
This was a request on Discord so that plugins can set flags and set the
name and lore for them too.
2023-03-26 10:06:38 -07:00
tastybento
6894695024 Clean up test classes; use latest API 2023-03-23 11:02:08 -07:00
tastybento
ca604f893c
Relates to #2104. Adds user.displayName() as a placeholder option (#2108)
* Relates to #2104. Adds user.displayName() as a placeholder option

* Fix test
2023-03-18 10:27:50 -07:00
tastybento
3285ef1ad2 Fix and enhancement for #2105 2023-03-17 20:45:15 -07:00
tastybento
70f044265a Fix test - 54 flags 2023-03-13 20:42:26 -07:00
tastybento
2940d2e492 Add cheat flag to prevent Endermen from teleporting
Fixes #2105
2023-03-13 20:17:03 -07:00
tastybento
2c283ae3a9
Javadoc and other cleanup from code analysis (#2099) 2023-02-26 17:48:37 -08:00
tastybento
1b81e74f4c Evaluates banned commands with spaces
Addresses #2092
2023-02-20 09:59:26 -08:00
tastybento
8276406f9f Fix runCommands method
Note to future self, don't remove Util methods because someone might be
using them!
2023-02-12 08:22:22 -08:00
tastybento
5eaf54e905 Added AdminBlueprintLoadCommand test class 2023-02-11 15:47:52 -08:00
tastybento
04545e676f AdminBlueprintDeleteCommand test class. 2023-02-11 14:57:42 -08:00
tastybento
08a1ad8126 Added AdminBlueprintCopyCommand test class 2023-02-11 14:46:34 -08:00
tastybento
79d56a5cef Added test class for AdminBlueprintSaveCommand 2023-02-11 12:03:16 -08:00
tastybento
f93c49184f Added AddonDescription test class 2023-02-11 10:11:51 -08:00
tastybento
6c1bcdec05 Added test class for IslandChunkDeletionManager 2023-02-08 20:23:19 -08:00
tastybento
a793a33758 Minimal test class for BlueprintPaster 2023-02-08 19:53:16 -08:00
tastybento
a703499817 Added test class. 2023-02-08 19:16:32 -08:00
tastybento
c6fc42846a Remove unused imports 2023-02-05 10:15:34 -08:00
tastybento
0c29d0b5dd
Uses seed worlds for deletion purposes (#2084)
* Uses seed worlds for deletion purposes

* Use Flat type

* Implement the superflat saver

* Fix nullable issue

* Fix tests.

* Fix code smells
2023-02-04 18:37:06 -08:00
tastybento
7040047fcb Fix broken test for IslandRespawnListener 2023-02-04 10:37:02 -08:00
tastybento
a604d5cf82
Add [owner] in command placeholders #2080 (#2081) 2023-01-31 07:13:01 -08:00
tastybento
bbb8207cf0 Teleportation was processed for entities even if it was switched off
Addresses #2078

Added test class to cover some of the logic in the teleportation class.
More tests can be written to cover the various outcomes.
2023-01-28 16:04:52 -08:00
tastybento
8e40bf9dcf Added more validation for addon.yml and test class 2023-01-02 09:31:16 -08:00
tastybento
f545a4576e Remove unused comment 2023-01-01 00:19:10 -08:00
tastybento
ab434b63fa Completed tests for User class 2023-01-01 00:17:30 -08:00
tastybento
0bffe3806a Fix tests 2022-12-31 18:19:32 -08: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
36ae34da5d
2049 trees growing outside range (#2050)
* Fixes #2046. Handles null players for placeholders.

* Remove unused import

* Fixes #2049 for adjacent island spaces

This also deletes blocks in the event rather than setting them to AIR as
was done previously.
2022-12-30 09:37:18 -08:00
tastybento
18983e5570
Code cleanup (#2065)
* Cast operands to (double)

* Code clean up from static analysis

* Revert the GitHubAPI version change because it didn't work.
2022-12-29 10:01:25 -08:00
tastybento
e2b5545f3f Expand remove mobs world setting to include respawning protection
Addresses #2058

We already have a option to protect against hostile mobs when logging in
or teleporting, but not respawn. This adds protection to that. Admin can
turn off the option if they want it more hard core.
2022-12-04 21:06:14 -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
7aa1e2da89 Fix to handle kelp and bamboo spread.
Addresses #2053. This is actually due to a server bug
https://hub.spigotmc.org/jira/browse/SPIGOT-5312. This change uses the
BlockSpreadEvent to trap kelp and bamboo and bamboo sapling.
2022-11-26 17:36:19 -08:00
tastybento
d50208c0e1
Add and fix tests for end gateway and portal. (#2044) 2022-10-31 17:59:04 -07:00
BONNe
369001d368
Rework SQL database implementation. (#1993)
This change switches from plain JDBC driver implementation to a HikariCP Pool implementation.

Pool Implementation is complete for PostgreSQL and SQLite, while MariaDB and MySQL implementation still uses JDBC drivers, however with HikariCP pools.

Also, I added extra properties for SQL databases, where users could specify their own datasource properties.
2022-10-04 12:31:51 +03:00
BONNe
173808b787
Adds glow berries protection. (#2027)
Uuups... someone forgot to add them.

Fixes #2020
2022-09-29 18:58:53 +03:00
BONNe
35ce1a7d81
Rework blueprint and blueprint bundle names. (#2026)
* Fixes issue when blueprint clipboard was stuck after saving.

The issue was that Map#putIfAbsent still creates a new task, even if object is already in map. The usage requires to use Map#computeIfAbsent.

* Rework blueprint and blueprint bundle names.

There was an issue with using non-english characters in blueprint names. It was not possible, as all chars for names were converted to lower cased english letters. It included display names.

I reworked it a bit and now it should be possible to set non-english names for bundles and blueprints.

Fixes #1954
2022-09-29 18:44:07 +03:00
BONNe
9088ea4b80 Fix failing unit-test 2022-08-26 12:43:05 +03:00
BONNe
50bc236bbc Fix failing unit-test 2022-08-26 12:27:11 +03:00
BONNe
64b4c43742 Revert 6e734fc343
The commit was wrong. Protection range should not be decreased, as that would mean that max X and Z blocks are not included in island protection bounding box.
This change is the same as 3c65194dfb but was missed when it was fixed.

Relate to #473
2022-07-25 00:16:16 +03:00
BONNe
db323390cf
Implements adding unknown default island flag values in settings. (#2001)
* Implements option to define non-existing flags in WorldSettings.

This change adds 2 new methods in WorldSettings:
* WorldSettings#getDefaultIslandFlagNames
* WorldSettings#getDefaultIslandSettingNames

These methods replace getDefaultIslandFlags and getDefaultIslandSettings methods.
Default implementation just reads values from replaced methods.

Fixes #1830

* Implement conversion from flag id to actual flag object.

Replaces flag assignment to new island based on flag id's.

Fixes #1830

* Switch from Flag object to String object in Island class.

This switch allows to keep flags that are not present in current BentoBox installation. Otherwise, unknown flags may cause an issues.

Fixes #1830

* Implement FlagBooleanSerializer.

This serializer converts input map of String, Boolean to map of String, Integer.

This map is used to read island setting flags, and integer value is not classic boolean values. (0 for true and -1 for false).

Fixes #1830
2022-07-06 20:20:08 +03:00
BONNe
1991dc7236
Fixes failing test
Increase flag listener counter.
2022-06-14 09:09:06 +03:00
BONNe
85b52f4bfb
Implement new 1.19 materials and entities (#1990)
* Update to Spigot and Paper API 1.19 and Java 17

* Set minimal version to 1.18.

* Add breeding protection for Axolotl and Goats (1.18)
Add breeding protection for Frog and Allay (1.19)

* Clean up switch statement in BlockInteractionListener

* Add chest boat support to BreakBlocksListener.

Part of #1987

* Add powdered snow pickup with bucket protection.

* Add glow ink sac protection on signs.
Switch to SheepDyeWoolEvent as it now contains player variable.

* Clean up Hurting Listener

* Mark 1.16.5, 1.17 and 1.17.1 as incompatible.
Mark 1.18, 1.18.1 and 1.18.2 as supported.

Add 1.19 as compatible.
Part of 1987

* Add ChestBoat inventory protection.
Part of #1987

* Clean up LockAndBanListener

* Add MANGROVE_PRESSURE_PLATE protection.
Part of #1987

* Add Glow Item Frame protection to player interact event.

* Clean up MobSpawnListener

* Clean up ChestDamageListener

* Change from custom method to Tag.PRESSURE_PLATES to detect pressure plates.
Part of #1987

* Implement proper chest boat protection.
Part of #1987

* Move to 1.19 R1 world regenerator.
Part of #1987

* Add allay to the animal entity list.
Part of #1987

* Add axolotl and other fish scooping protection.
Part of #1987

* Fixes Bucket and Glass Bottle filling.

Buckets and bottles were not working since cauldron splitting by type. This change fixes that.

It also protects from filling bottles with water from water sources or waterlogged blocks.

* Remove 1.17.1 compatibility check for biome adapter.
Add cheezee 1.19.1 compatibility version.

* Fixes chest boat interactions.

Part of #1987

* Implement Allay protection.
New flag ALLAY is required to interact with allays.

Part of #1987

* Prevent visitors for being targeted by entities if ENTITY_ATTACK is enabled.

* Implement Sculk Sensor and Shrieker activation protection setting.

Part of #1987

* Add music discs to the LangUtilsHook
Part of #1987

* Fixes failing unit-tests.
2022-06-14 00:38:53 +03:00
BONNe
6f2a9929c0
Fixes Glowing Item frames protection (#1985)
* Fixes glowing item frame protection.
Glowing item frames were not protected.

Fixes #475

* Fixes check-style.
2022-06-05 21:52:37 +03:00
BONNe
3ab7ac8484
Implement ability to create ItemStacks with Custom Model Data. (#1981) 2022-05-23 20:46:02 +03:00
BONNe
b3e55a7b55
Fixes failures in obsidian cooping listener. (#1965)
Failures happened after implementing #1964
2022-04-11 08:23:13 +03:00
BONNe
ad0931ffcb
Fixes kick command (#1960)
PR #1957 broke kick command and noone could kick players from teams.
This should fix it.
2022-04-03 08:12:41 +03:00
tastybento
4e8ca6d22c Fix for kicking offline players
https://github.com/BentoBoxWorld/BentoBox/issues/1950
2022-03-18 13:59:41 +00:00
tastybento
546cf2c9b9 Fix for random test failures. 2022-03-12 19:12:13 -08:00
tastybento
945bfa66ee Adjusted test to try to avoid errors 2022-03-12 12:20:27 -08:00