Commit Graph

2823 Commits

Author SHA1 Message Date
tastybento
f29e78557a Change location of seed world data.
Fixes #2087
2023-02-05 14:11:59 -08:00
tastybento
2d8b3074a9 Minor refactor to remove continue from for loop 2023-02-05 10:39:10 -08:00
tastybento
ad2541963e Minor instanceof casting change 2023-02-05 10:38:09 -08:00
tastybento
2c1a018071 Clarify nonnull on Location 2023-02-05 10:37:43 -08:00
tastybento
c6fc42846a Remove unused imports 2023-02-05 10:15:34 -08:00
tastybento
0e253f3ba5 Clarify that parameter is non-null 2023-02-05 10:10:25 -08:00
tastybento
a68436fde1 Remove Optional from parameter. 2023-02-05 10:05:57 -08:00
tastybento
1d28979d5c Refactor to reduce complexity 2023-02-04 19:08:09 -08:00
tastybento
187132bc1d Refactor to reduce complixty. Added comments. 2023-02-04 19:00:18 -08:00
tastybento
3331ffac4e Refactor to reduce complexity. 2023-02-04 18:49:13 -08:00
tastybento
f9e57898ab Refactor to reduce complexity. 2023-02-04 18:45:05 -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
BONNe
ea6ca3d26b
Add variable parsing on reference text (#2073)
This solves the issue in customizable GUI's where variables are defined directly into the panel button name and description instead of providing the link to the locale. 

Not all users want to specify all text into a locale, and they would not get parsed variables just because of that.
This change fixes it and it does not give any bad situations even if the reference is just missing text in the locale, as there will be nothing for parsing.
2023-01-31 18:03:37 +02: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
BONNe
e89970b49b
Remove 1.18.2 from supported version list. (#2074)
* Remove 1.18.2 from supported version list.

1.18.2 support was removed with changes in commit 056cff4b6f

Also, mark 1.19, 1.19.1 and 1.19.2 as incompatible. It happens because of GSon library changes that prevents bentobox compiled with Spigot 1.19.3 to run on older versions.

* Fixes GSON crashes introduced by migrating to 1.19.3 api.
2023-01-06 18:29:37 +02:00
tastybento
0de2c3a7b6 Update JavaDoc to indicate return value is immutable 2023-01-05 21:30:19 -08:00
tastybento
0f89de6c2a Make list mutable. 2023-01-05 21:16:50 -08:00
tastybento
8e40bf9dcf Added more validation for addon.yml and test class 2023-01-02 09:31:16 -08:00
tastybento
10a73e66b4 Added explicit @since annotation 2023-01-01 09:25:09 -08:00
tastybento
3746349e22 The protected modifier for constructor should be enough.
Constructors of abstract classes can only be called in constructors of
their subclasses. So there is no point in making them public.
2023-01-01 09:22:41 -08:00
tastybento
1262a08a22 Removed deprecated method isPlayer(User) 2023-01-01 08:43:31 -08:00
tastybento
6b88d31762 Bug fix for particle validation 2023-01-01 00:02:59 -08:00
tastybento
93ca9fb0e6 Correct nullable tags 2022-12-31 18:33:49 -08:00
tastybento
872940011a Loads of minor code smell fixes
Mostly replacing instanceof check and cast with e.g. 'instanceof Player
player'
Replaced some "switch" statements by "if" statements to increase
readability.
Used the primitive boolean check to avoid potential NPEs.
Reordered field modifiers to comply with the Java Language
Specification. Mainly @NonNull position.
2022-12-31 18:19:25 -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
bde294e0e6 Updated some dependency versions
https://github.com/BentoBoxWorld/BentoBox/issues/2064
2022-12-28 12:37:33 -08:00
tastybento
e7f1269443
Support for 1.19.3 (#2060) 2022-12-11 17:51:52 -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
2629e940c7
2046 null player placeholder support (#2048)
* Fixes #2046. Handles null players for placeholders.

* Remove unused import
2022-11-13 08:49:22 +02:00
tastybento
1c4fb76828
Fixes #2045. Hides invisible team members from the count. (#2047) 2022-11-12 02:28:09 +02:00
BONNe
acb984ee90
Fixes super-flat clearing
Superflat was not working properly. It was always clearing just 1 (first) chunk because it referenced the chunk from the first event that created the clearing task.
The issue should be fixed.
2022-11-01 23:04:59 +02:00
BONNe
d9ad9f158b
Fixes a mistake in clean super flat listener
There was a logical mistake in checking if a clean super flat should work.
2022-11-01 20:10:45 +02:00
BONNe
87a6799cd1
Fixes clean super-flat issue from 1.19 worlds
In 1.19 worlds it was fixed that super-flat worlds are generated at min-height, instead at 0.
This change keeps the previous super-flat chunk generation until 1.18 is dropped.
2022-11-01 18:25:39 +02:00
BONNe
a22ce33175
Mark end portals and gateways as unsafe location. (#2042)
The end portals and gateways teleports players to a different dimension upon player touches it. So teleportation should consider these positions as unsafe, otherwise player will be teleported to the different dimension instantly.

Fixes #2040
2022-10-19 11:41:00 +03:00
Irmo van den Berge
ac4922534e
Register BentoBox World Generator option with MyWorlds (#2039)
Signed-off-by: Irmo van den Berge <irmo.vandenberge@ziggo.nl>
2022-10-19 11:27:12 +03:00
BONNe
b48a5a73b8 Merge remote-tracking branch 'origin/master' into develop-fix
# Conflicts:
#	pom.xml
2022-10-11 09:55:16 +03:00
BONNe
065f4ba4bd Spigot does not support parallel stream processing for placing blocks and entities in the world.
This is a hot-fix release.
2022-10-11 09:37:59 +03:00
BONNe
e47890c16e Merge remote-tracking branch 'origin/develop' into develop 2022-10-04 15:54:34 +03:00
BONNe
866dff6244 Fixes missing FLAG check on clicking minecart entities
Players could open minecart entities, even without flag requirement.

Fixes #2031
2022-10-04 15:54:18 +03: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
1a59ca7785 Merge remote-tracking branch 'origin/develop' into master
# Conflicts:
#	pom.xml
#	src/main/java/world/bentobox/bentobox/blueprints/BlueprintPaster.java
#	src/main/java/world/bentobox/bentobox/database/objects/Island.java
#	src/main/java/world/bentobox/bentobox/versions/ServerCompatibility.java
2022-10-04 11:56:32 +03:00
BONNe
b263c92c13
Use Spigot only events. (#2029)
I missed that EntityMoveEvent is only Paper. Interesting why Spigot does not have such...

Fixes #2028
2022-10-01 01:50:32 +03:00
BONNe
52bca66149 Add better config description for safe-spot-search-range. 2022-09-30 21:46:01 +03:00
BONNe
f01e5540c7 Deprecate old player teleportation code. 2022-09-30 21:41:02 +03:00
BONNe
bf87cca754 Implement proper entity teleportation between dimension.
Teleportation via portals for entities was in a mixed state. It was not fully implemented and not fully prevented. Especially when portal linking was enabled.

Now I implemented world settings flag: ENTITY_PORTAL_TELEPORT.
Enabling this flag will allow entities to use portals to switch dimensions.

Fixes #2023 and #966
2022-09-30 21:33:17 +03:00
BONNe
682d835961 Add all dimension checks for methods. 2022-09-30 14:34:28 +03:00
BONNe
4458d16274 Fixes incorrect condition for missing island check. 2022-09-30 14:34:12 +03:00
BONNe
d197ce8bea Add class description. 2022-09-30 02:34:46 +03:00
BONNe
aa7abe02bf Teleport island-less player to the spawn if he exits nether 2022-09-30 02:33:07 +03:00
BONNe
97c4cf883f Implement proper end exit portal handling.
When players will exit the end-gate, they will be teleported to proper island, instead of world spawn point.

The only way how players can be teleported to the spawn is if they do not have islands.
2022-09-30 02:25:44 +03:00
BONNe
eb5147e710 Change to direct PlayerTeleportListener#portalProcess method call. 2022-09-30 01:31:05 +03:00
BONNe
755aeb866e Rework player teleportation.
I reworked the classes and some teleportation operations. Now teleportation should find the closest available spot, instead of always being the highest block at original Y location. Part of #1994.
Also, I fixed an issue that portals stopped working if some conflicting options were enabled. Now portals will not work only if nether is disabled in config.
2022-09-30 01:26:31 +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
Huynh Tien
12926f9ee7
setBlock & setEntity as CompletableFuture (#2019)
* setBlock & setEntity as CompletableFuture

* use collectingAndThen toArray
2022-09-05 09:28:16 +03:00
BONNe
c7b48b3d2a
Update Spigot 1.19.2. (#2017)
Add 1.19.2 compatibility.
2022-08-26 12:17:19 +03:00
BONNe
6f791420e7
Proper dimension processing (#2015)
* Adds ProtectionBoundingBox for environment

Since minecraft introduced different island heights for different dimensions, protection bounding box were returned wrong area for nether and end dimensions.
This change adds a new method that allows to get proper protection bounding box for requested dimension.
Due to the fact, that nether and end islands can be disabled, then this method may return null.

Fixes #2014

* Adds BoundingBox for environment

Since minecraft introduced different island heights for different dimensions, bounding box were returned wrong area for nether and end dimensions.
This change adds a new method that allows to get proper bounding box for requested dimension.
Due to the fact, that nether and end islands can be disabled, then this method may return null.

Part of #2014

* Fixes Island#onIsland check for non-island worlds

Island#onIsland method was missing checks if island mode is enabled for requested dimension. It returned false positive situations in cases when island generation were disabled in nether or the end worlds.

* Fixes Island#inIslandSpace check for non-island worlds

Island#inIslandSpace method was missing checks if island mode is enabled for requested dimension. It returned false positive situations in cases when island generation were disabled in nether or the end worlds.

* Adds some helper methods in Island object.

- Island#getNetherWorld - returns the nether world or null
- Island#getEndWorld - returns the end world or null
- Island#getWorld(Environment) - returns world of requested environment or null
- Island#isNetherIslandEnabled - returns if nether is generated and nether islands are enabled.
- Island#isEndIslandEnabled - returns if end is generated and end islands are enabled.
2022-08-26 11:32:03 +03:00
BONNe
6c1399c2b4
Fixes wrong admin permission.
Default Amin command should have `admin` instead of admin.*
2022-08-14 20:12:15 +03:00
BONNe
44201afa1f Fixes an issue with missing parent permission check before command execution.
Implement a new method that recursively checks if player has access permission to all commands in whole hierarchy.

Fixes #2010
2022-08-03 19:00:42 +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
a59697c14e Fixes particle spawning for older API usage.
Border addon used still older BentoBox API. This change fixes it, and fixes API compatibility with older addons/plugins.
2022-07-14 11:29:46 +03:00
BONNe
5a527d4119 Add parent for admin team's commands.
This is a parity change with player command.
2022-07-13 12:35:20 +03:00
BONNe
927fcba15a Disables biome copying by default in blueprints.
Biome will be copied only if it is required by copy command parameter.

Fixes #1862
2022-07-07 00:08:15 +03:00
BONNe
9ec8730359 Prevents liquids from being placed from dispenser outside island area.
Fixes #1869
2022-07-06 23:55:17 +03:00
BONNe
9643f617b6 Implement a command that allows to reset island name.
Fixes #1879
2022-07-06 23:30:51 +03:00
BONNe
3784aa48d7 Disables podzol and coarse dirt from becoming path.
This protection reuses Flags.COARSE_DIRT_TILLING.

Fixes #1878
2022-07-06 23:00:20 +03:00
BONNe
2f244c0606 Fixes an issue when portals did not operate under 0.
Fixes #1977
2022-07-06 22:12:47 +03:00
BONNe
f969f2721f Disable DynmapHook as it is not implemented.
Fixes #1995
2022-07-06 20:39:15 +03:00
Galić Mijo
cbd063c9e8
Check if unique name contains chars not supported in regex expression (#1998)
* Check if unique name contains chars not supported in regex expression
Cannot start, contain, or end with special char, cannot contain any numbers.
Can only contain - for word separation

* Negation fix
2022-07-06 20:21:36 +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
d8fa029ac9
Fixes an issue where Blueprint Pasting did not send or include nether and the end blueprints times. (#1979) 2022-06-16 22:44:38 +03:00
BONNe
c54358441d
Raid abuse fix (#1991)
* Implements new VISITOR_TRIGGER_RAID flag.

This world settings flag allows toggling if visitors can or cannot start a raid on an island they are visiting.

Relates to #1976

* Fixes abuse of Raid Mechanism and Mob Natural Spawn Rules.

Fixes to #1976

* Simplify raid abuse detection.
2022-06-14 02:42:48 +03:00
BONNe
e41f5ac24f
Fixes a bug that prevented mobs to attack
Commit 85b52f4b introduced a bug that prevented entities to target any island member. This should fix it.
2022-06-14 02:33:35 +03:00
BONNe
d984955af3 Fixes Range Display command crashes.
Spigot in 1.18 introduce new way how block particles should be displayed. However, BentoBox never fully implemented it.
To avoid such issues in-future, I added checks for each particle type that requires extra data object.

Fixes #1989
2022-06-14 01:18:52 +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
345b9e2564
Fixes an incorrect <Material>:CMD-<number> parsing
The issue was that it used an incorrect value for parsing Material. Instead of stripped part[0] it used whole text with CMD in it.
2022-05-23 23:23:22 +03:00
BONNe
3ab7ac8484
Implement ability to create ItemStacks with Custom Model Data. (#1981) 2022-05-23 20:46:02 +03:00
Huynh Tien
0f815d8175
More abstract on Blueprint Paster (#1970)
* more abstract on Paster

* comment and stuff

* How about Impl

* ok, PasteHandler

* PasteUtil

* don't check other BlockState if there is one matched

* world as an argument

* forgot the impl

* createBlockData from BlueprintBlock

* fix remaining conflicts

Co-authored-by: tastybento <tastybento@users.noreply.github.com>
2022-05-03 18:39:27 +01:00
evlad
4ab579f2cd
Feat: Filtering spectators from visitors (#1974)
* support 1.18 negative y

* feat: visitor gamemode spectator check
2022-05-03 08:03:49 +03:00
Huynh Tien
6fba4bfbea
More abstract on World Regenerator (#1969)
* more abstract on delete chunks

* update NMS to 1.18.2

* at most abstract, requires only the island and the world

* it's weird that we can't use whenComplete

* rename to WorldRegenerator
2022-05-02 15:23:31 -07:00
evlad
d07c1b5a8c
support 1.18 negative y (#1973)
Fixes an issue where blueprint starting block could not be placed in negative area.
2022-05-01 08:44:42 +03:00
Huynh Tien
3e0368fbab
fix null on invitedPlayer (#1972) 2022-04-28 15:39:39 +03:00
BONNe
c4c51d00e2
Fixes wrong protection bounding box (#1971)
#1966 fixed a bounding box size for the whole island, while the protection bounding box was still wrong.

Fixes https://github.com/BentoBoxWorld/BSkyBlock/issues/473
2022-04-26 12:06:50 +03:00
tastybento
928f1eb1eb
Version 1.20.1 (#1966)
* Version 1.20.1

* Added name of the addon causing the issue.

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

* Use world min-height for island bounding box.

* Fixes a bug when fallback could not use reusable

There was an issue in PanelItemTemplate that prevented fallback buttons to be "reusable" things.
The issue was that reusable items were not passed to the panel item reader.

* Adjusted test to try to avoid errors

* Fix for random test failures.

* Added 1.18.2 support

* Address unnecessary PVP reports on each teleport (#1948)

If a player is teleporting on the same island in the same dimension, it keeps spamming that PVP is enabled in dimension. 
It should be enough with sending messages when the player teleports to the island.

Fixes #1885

* Fixes bug with Safe Spot Teleport (#1951)

There was a bug that prevented finding a safe spot if all valid blocks were in height with the `startY` location.

Reported via discord.

* Fix Exception error reported by IDE

I am not sure why Eclipse is saying this is an error.

* Fix for kicking offline players

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

* Add an option in SafeSpotTeleport to cancel if fail (#1952)

There was no option to cancel teleportation if SafeSpotTeleport could not find a valid spot. This option could be used to avoid creating "backup" blocks in situations when teleportation is avoidable, f.e. visiting an island.

* Replace peplaceAll with replace

It does the same thing if the first argument is not a regex.

* Use constants for common strings

* Use constants for common strings

* Go back to replaceAll

This is required.

* Clearer paster (#1953)

* WIP - make easier to understand.

* Small refactor of paster to make it easier to understand

* Fix tabs to spaces. Sorry - new editor!

* Fix tabs to spaces

* Fix tab to spaces

* Improve team kick command (#1957)

The kick command has an unnecessary owner check. As command should be configurable by island owners, then limiting it to an owner is wrong.
Add a code that allows kicking only lower-ranked players.

Add message that shows who kicked from the island.
Add message that shows that rank does not allow to kick.

* Solve crashes with Addon#allLoaded call (#1959)

If some addon has code in Addon#allLoaded that crashes the call, then it did not disable addon as well as did not call allLoaded for every other addon that was left in the list.

This should be solved by adding an extra try-catch.

* using java 16 syntax (#1958)

* Fixes kick command (#1960)

PR #1957 broke kick command and noone could kick players from teams.
This should fix it.

* Fixes a bug with blueprint height (#1961)

Blueprint clipboard was preventing setting Y below 0 or above 255. 

The code was not adjusted to 1.18 changes.
Reported via discord.

* Fixes Lava Duplication Glitch (#1964)

Due to the fact, that Obsidian Scooping uses one tick delay to remove obsidian, a player with a bucket in hand and offhand duplicated lava. 
To avoid that, added an extra check that ignores the interact event if a player holds a bucket in both hands, and interacted hand is offhand.

Fixes #1963

* Fixes failures in obsidian cooping listener. (#1965)

Failures happened after implementing #1964

Co-authored-by: BONNe <bonne@bonne.id.lv>
Co-authored-by: Invvk <70810073+Invvk@users.noreply.github.com>
2022-04-17 09:04:37 -07:00
BONNe
9f163f0572
Fixes Lava Duplication Glitch (#1964)
Due to the fact, that Obsidian Scooping uses one tick delay to remove obsidian, a player with a bucket in hand and offhand duplicated lava. 
To avoid that, added an extra check that ignores the interact event if a player holds a bucket in both hands, and interacted hand is offhand.

Fixes #1963
2022-04-11 08:13:12 +03:00
BONNe
4341c28aca
Fixes a bug with blueprint height (#1961)
Blueprint clipboard was preventing setting Y below 0 or above 255. 

The code was not adjusted to 1.18 changes.
Reported via discord.
2022-04-03 21:36:51 +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
Invvk
c02e566266
using java 16 syntax (#1958) 2022-04-01 00:12:47 +03:00
BONNe
36751d5573
Solve crashes with Addon#allLoaded call (#1959)
If some addon has code in Addon#allLoaded that crashes the call, then it did not disable addon as well as did not call allLoaded for every other addon that was left in the list.

This should be solved by adding an extra try-catch.
2022-04-01 00:12:27 +03:00
BONNe
9f21314818
Improve team kick command (#1957)
The kick command has an unnecessary owner check. As command should be configurable by island owners, then limiting it to an owner is wrong.
Add a code that allows kicking only lower-ranked players.

Add message that shows who kicked from the island.
Add message that shows that rank does not allow to kick.
2022-03-25 23:29:14 +02:00
tastybento
6796fceee8
Clearer paster (#1953)
* WIP - make easier to understand.

* Small refactor of paster to make it easier to understand

* Fix tabs to spaces. Sorry - new editor!

* Fix tabs to spaces

* Fix tab to spaces
2022-03-19 16:19:31 +00:00
tastybento
51dbca0f99 Go back to replaceAll
This is required.
2022-03-19 15:12:04 +00:00
tastybento
b0f1417166 Use constants for common strings 2022-03-19 14:45:44 +00:00
tastybento
0b3ef8df6d Use constants for common strings 2022-03-19 14:43:52 +00:00
tastybento
bda56763a8 Replace peplaceAll with replace
It does the same thing if the first argument is not a regex.
2022-03-19 14:29:54 +00:00
BONNe
3ba6620e73
Add an option in SafeSpotTeleport to cancel if fail (#1952)
There was no option to cancel teleportation if SafeSpotTeleport could not find a valid spot. This option could be used to avoid creating "backup" blocks in situations when teleportation is avoidable, f.e. visiting an island.
2022-03-19 14:22:03 +00:00
tastybento
4e8ca6d22c Fix for kicking offline players
https://github.com/BentoBoxWorld/BentoBox/issues/1950
2022-03-18 13:59:41 +00:00
tastybento
fd44e03b7b Fix Exception error reported by IDE
I am not sure why Eclipse is saying this is an error.
2022-03-18 13:59:29 +00:00
BONNe
6d59e79e78
Fixes bug with Safe Spot Teleport (#1951)
There was a bug that prevented finding a safe spot if all valid blocks were in height with the `startY` location.

Reported via discord.
2022-03-18 15:06:31 +02:00
BONNe
0cf1d43a29
Address unnecessary PVP reports on each teleport (#1948)
If a player is teleporting on the same island in the same dimension, it keeps spamming that PVP is enabled in dimension. 
It should be enough with sending messages when the player teleports to the island.

Fixes #1885
2022-03-16 09:51:22 +02:00
tastybento
e7599ec805 Added 1.18.2 support 2022-03-12 19:20:53 -08:00
BONNe
50b677f4c5
Fixes a bug when fallback could not use reusable
There was an issue in PanelItemTemplate that prevented fallback buttons to be "reusable" things.
The issue was that reusable items were not passed to the panel item reader.
2022-03-12 12:15:10 +02:00
tastybento
6a009946f5 Use world min-height for island bounding box. 2022-02-26 10:22:41 -08:00
tastybento
6c7d77f093 Added name of the addon causing the issue.
https://github.com/BentoBoxWorld/BentoBox/issues/1944
2022-02-24 08:02:20 -08:00
tastybento
4e3079b623
Merge branch 'master' into develop 2022-02-19 09:57:05 -08:00
BONNe
d492539c51
Implement ACTION defining by ACTION TYPE (#1938)
This change implements a new way how to define actions via a custom panel template.

Previously there were 2 options how to define an action:
- by click-type
- as an array list

This adds the third type: by action type. It means that now developers could code that action is the main key for defining what happens when button is clicked:
```
    actions:
       visit:
          click-type: LEFT
          tooltip: Tooltip text for left click action
```
2022-02-11 18:07:14 -08:00
BONNe
fa68f8f01c
Add missing templated panel builder method (#1935)
#1932 implemented a feature that allows reading multiple panels from a single file, however, there was a missing builder in TemplatedPanelBuilder class that would allow to use it.

This fixes it and adds the missing builder method.
2022-02-11 18:06:56 -08:00
tastybento
937e8bf614 Fix island test and max ever range bug 2022-01-28 21:33:39 -08:00
BONNe
09ab327551
Implement a flag that rules all flags. (#1927)
Add new Protection Flag: CHANGE_SETTINGS. This flag allows set which rank can change island settings. By default, it is set to OWNER rank and minimal value is MEMBER rank.

Fixes #1493
2022-01-28 18:45:50 -08:00
BONNe
90ebe103c4
Templated Panel Title Parameters (#1934)
* Implement parameter adding to the templated panel title.

There was an issue when templated panels were always static, and api did not have a way how to change it. This will allow passing parameters to the tile, and allow adding dynamic texts.

* Implement parameter adding to the templated panel title.

There was an issue when templated panels were always static, and api did not have a way how to change it. This will allow passing parameters to the tile, and allow adding dynamic texts.
2022-01-28 18:43:14 -08:00
Huynh Tien
178529adb1
Fix null in reject invite (#1933)
* remove debug

* fix null in reject invite
2022-01-28 18:42:56 -08:00
BONNe
52cc2a8593
Implement multiple panels in single file (#1932)
The existing template file reader could read a single configuration section from a file, and the section was required to start with the same name as the file.
This changes it and allows to read any configuration section from the panel.

This change is backward compatible and does not influence existing panels.
2022-01-28 18:42:23 -08:00
BONNe
3ecdda65b5
Fixed bug with running onLeave commands (#1929)
In discord, it was reported that running the admin delete command produces a null-pointer if `[player]` placeholder is used.

With fast checking I found out the issue: incorrect user was passed to the command.
Also, I moved runCommands below all resets, so commands could be used to give items, or xp or other stuff that is removed.
2022-01-28 18:42:02 -08:00
BONNe
da98bbcf38
Extend ranked commands (#1928)
* Add CompositeCommand#defaultCommandRank variable.

This variable stores default rank for a command. This adds more flexibility to the Island#commandRanks object. This change allows specifying default rank for each command.

* Add more commands for users to configure on their islands.

Owners now can specify who can use:
- sethome command
- renamehome command
- deletehome command
- setname command
- resetname command
2022-01-28 18:41:20 -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
BONNe
54869a400a
Implement duplicated actions click type (#1919)
Some addons may want to introduce two different actions with the same click type.
This change will allow to do it, as now actions may be defined as lists instead of configuration sections.

To use it, action must be defined a bit differently:
```
      actions:
        - click-type: <value of enum ClickType>  # required
          type: <value of String> # not required
          content: <value of String>  # not required
          tooltip: <value of String>  # not required
        - click-type: <value of enum ClickType>  # required
          type: <value of String> # not required
          content: <value of String>  # not required
          tooltip: <value of String>  # not required
```

Co-authored-by: tastybento <tastybento@users.noreply.github.com>
2022-01-28 18:35:27 -08:00
BONNe
56c9f5c28e
Fixes a bug with on-join commands not working when players join the team. #1925 (#1926) 2022-01-23 15:25:27 -08:00
tastybento
2f0869fd6e More voiding of event listeners
https://github.com/BentoBoxWorld/BentoBox/issues/1918
2022-01-22 18:04:00 -08:00
tastybento
d14ad977ab Clean up imports. 2022-01-22 13:14:57 -08:00
tastybento
9062aab34b Change behavior of teleporting to default nether
If create-and-link-portals is true, then teleporting to the nether will
not go to a central portal point and instead create a portal in the
nether at the same coordinates as the portal in the overworld.
Teleporting back will not be affected.

https://github.com/BentoBoxWorld/BSkyBlock/issues/464
2022-01-22 13:14:34 -08:00
tastybento
94b982f644 Fix tests
Fixes https://github.com/BentoBoxWorld/BentoBox/issues/1918
2022-01-22 12:16:27 -08:00
tastybento
5573e9f329 Fix TNTListener tests 2022-01-22 11:57:11 -08:00
tastybento
823bc5ceed Fix Fire tests 2022-01-22 11:54:00 -08:00
tastybento
f25e54f3c8 Return void for event listeners
https://github.com/BentoBoxWorld/BentoBox/issues/1918
2022-01-21 18:47:31 -08:00
tastybento
046c4fff35 Fix for double chest protection.
Double chests could be viewed but not accessed even if chest access or
trapped chest access was allowed.

Fixes https://github.com/BentoBoxWorld/BentoBox/issues/1912
2022-01-09 20:53:47 -08:00
tastybento
bea9f0e394 List must be mutable. Remove debug. 2022-01-09 20:41:20 -08:00
tastybento
721f0271aa Dynamically grab flags
https://github.com/BentoBoxWorld/BentoBox/issues/1915
2022-01-09 19:44:44 -08:00
tastybento
00e174258e Hook into Vault after other plugins have loaded.
https://github.com/BentoBoxWorld/BentoBox/issues/1913
2022-01-07 19:08:15 -08:00
BONNe
eaf2236f7f
Fixes a bug that increased all button count by 1 (#1911)
This will fix an issue when the next button was not displayed when it was necessary.
2022-01-07 18:48:25 -08:00
BONNe
d1eb175e88
Change AbsolutePath to CanonicalPath (#1901)
I am not 100% sure if this would fix https://github.com/BentoBoxWorld/BSkyBlock/issues/451

However, searching google I found that others had a similar issue with the absolute path and they changed it to canonical. 

As I was not able to reproduce the main reported issue, I do not know if this fixes it.
2022-01-01 17:45:05 -08:00
Huynh Tien
7088a2736f
Flags for Block Explode (#1899)
* add Block Explosion support for TNT_DAMAGE flag

* prevent block explosion from damaging entities

* seperated flags for block explode

* invert and cancel

* pattern instanceof
2022-01-01 17:42:46 -08:00
Huynh Tien
dffe8a811e
fix an exception when cleaning an offline player (#1898) 2022-01-01 17:39:25 -08:00
Huynh Tien
ce1d8e5117
Rework the chunk deletion (#1897)
* delete island one by one

* register before IslandDeletionManager

* optimize imports

* setting

* just some indents

* config

* run synchronously

* a bit reformat before recoding

* proper delete chunks

* comment

* combine the task call

* expose the NMS Handler

* don't have to try-catch this

* we know that this is final

* expose copy chunk data so that it can be overridden

* Don't have to use Vector

* set block from minimum height

* remove NMS and use fallback if not set

* only get the height once

* fix test
2022-01-01 17:38:27 -08:00
Huynh Tien
c9c9ea0389
Fix Biome compatibility on 1.17 (#1895)
* Fix Biome compatibility on 1.17

* check if it's not 1.17.1
2022-01-01 17:34:51 -08:00
tastybento
17ac4f688a Add an admin delete homes command
https://github.com/BentoBoxWorld/BentoBox/issues/1900

This admin command removes all homes from a specified island.
2021-12-31 10:51:16 -08:00
tastybento
acba363523 Added why to VisitorKeepInventory and test class
why reports can now be made by subclasses of FlagListener
2021-12-21 10:12:20 -08:00
tastybento
7fbae58bb2 Make check an NPE check and failure 2021-12-20 15:30:29 -08:00
tastybento
3ece0d049a Added test for SafeSpotTeleport and removed old test 2021-12-20 09:50:45 -08:00
tastybento
f049fc6941 Added SafeSpotTepeortTest 2021-12-20 09:46:04 -08:00
Huynh Tien
e3b99195ca
Optimize safe location searching with configurable range limit (#1892)
* better safe spot finder

* this should be better

* limit how far the y-coordinate will be expanded

* load chunks passively
2021-12-20 09:44:34 -08:00
Huynh Tien
333c9a8272 load chunks passively 2021-12-20 19:37:50 +07:00
BONNe
ed50765b98
Addres Biome's changes in Minecraft 1.18. (#1893)
Since Minecraft 1.18 renamed and removed a lot of biomes, some addons that stored them in the database may require migration.

This Adapter will fix that as now BentoBox itself will do migration for all Biome.class objects.
2021-12-19 08:49:29 -08:00
Huynh Tien
168de622ea limit how far the y-coordinate will be expanded 2021-12-19 20:40:01 +07:00