Commit Graph

58 Commits

Author SHA1 Message Date
tastybento 6127cdced1 Reduce complexity. 2024-03-15 18:49:20 -07:00
tastybento 070c1102db Use Bukkit for Admin BP pasting. 2024-02-23 22:05:32 -08:00
tastybento a1d19fae74 WIP - use Bukkit for bp admin pasting. 2024-02-23 21:56:32 -08:00
tastybento af843aeb35 Unregister coded. 2024-02-19 10:55:15 -08:00
tastybento 1783bb7058 Fixes bug where pasting was happening twice 2023-02-08 19:21:50 -08:00
tastybento 1d28979d5c Refactor to reduce complexity 2023-02-04 19:08:09 -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 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
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 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
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
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
Invvk c02e566266
using java 16 syntax (#1958) 2022-04-01 00:12:47 +03: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 db464d5c04 NPE protections 2021-10-09 11:40:15 -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 faf351fd59
Support glowing ink in blueprints (#1842)
Fixes https://github.com/BentoBoxWorld/BentoBox/issues/1837
2021-08-29 14:17:42 -07:00
tastybento b906f5561a
Hex pr 1820 (#1822) 2021-08-19 12:09:23 -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
tastybento b5725e7107 Remove update when pasting chest. 2021-07-25 10:23:03 -07: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 1ec886472d Add biome support to blueprints.
https://github.com/BentoBoxWorld/BentoBox/issues/1571
2020-11-08 12:24:40 -08:00
tastybento bdbfd33a34
Fixed code smells (#1444)
* Code smell changes

* Fixes issues raised in reviews.
2020-07-09 09:03:01 +02:00
tastybento 1ebae9b1a4
Uses completablefutures to paste islands sequentially (#1410)
* Uses completablefutures to paste islands sequentially

* Removes debug
2020-06-22 00:01:30 +02:00
Florian CUNY aa9a4d16f1 Added ability to replace [name] by the island owner's name when pasting an entity from a blueprint 2020-06-17 21:28:00 +02:00
tastybento 6fa89b0b4d
Uses Locale.ENGLISH for toLowerCase and toUpperCase (#1378)
The locale should be explicitly declared otherwise the default locale of
the operating system will be used, which may result in unexpected bugs.
2020-05-30 21:52:05 +02:00
tastybento 41e9bccc67 Load chunks async for every block pasted.
This loads every chunk async based on the block or entity being pasted.
2020-03-17 23:14:43 -07:00
tastybento 295d985024 Removed unused import. 2020-02-14 08:13:20 -08:00
Florian CUNY cc0d981e62 Added javadoc to BlueprintPaster's chunkLoadTime field 2020-02-11 16:02:39 +01:00
Florian CUNY c5eb8ac7e7 Fixed some code smells 2020-02-11 11:28:15 +01:00
tastybento 9f65537ab8 Load chunks before pasting islands. Runs async.
1.15.2 can take a looooong time to load a chunk, sometimes up to 10
seconds.

https://github.com/BentoBoxWorld/BentoBox/issues/1180
2020-02-10 20:14:43 -08:00
tastybento 9ff2eda576 Avoid setting banner pattern if none exist (null)
https://github.com/BentoBoxWorld/BentoBox/issues/1016
2019-10-29 17:44:45 -07:00
Florian CUNY 5ef74bd0f4 Fixed some code smells 2019-10-28 10:04:44 +01:00
Florian CUNY 8692685822 Improved user feedback when pasting (creation/reset) an island
Implements https://github.com/BentoBoxWorld/BentoBox/issues/996
2019-10-21 17:55:35 +02:00
Florian CUNY ba35d7c062 Simplified methods in BlueprintPaster
There wasn't the need for that many parameters in each method.
2019-10-21 15:20:02 +02:00
Florian CUNY 477f60ae03 Added Banner patterns support in Blueprints
Implements https://github.com/BentoBoxWorld/BentoBox/issues/961
2019-09-29 10:26:39 +02:00
tastybento 2f7a4b2528 move entity attribute setting 2019-09-26 08:52:57 -07:00
tastybento 6cd8c70bd4 Pastes default nether or end blueprints if island doesn't exist
Fixes issue where the nether-island or end-island named blueprints were
deleted.

https://github.com/BentoBoxWorld/BentoBox/issues/943
2019-09-15 14:10:52 -07:00
Florian CUNY 115f434a30 Added parsing placeholders in entities' name when pasting blueprints
Implements https://github.com/BentoBoxWorld/BentoBox/issues/898
Also adds a few nullability annotations
2019-09-14 21:51:28 +02:00
tastybento 2f35a6c77c Sets pos1 and pos2 after pasting island and show clipboard. 2019-08-31 16:39:38 -07: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
Florian CUNY 537b854c75 Fixed some code smells
Added TextVariables#NEXT
2019-08-13 10:53:07 +02:00
tastybento b5202c3944 Code smell improvements and null protections 2019-08-10 11:44:29 -07:00
tastybento 3f3ac57f1e Cleans up code smells. 2019-07-11 13:55:17 -07:00
tastybento b1f66eb31b Fixes bugs and code smells from Sonarcloud. 2019-07-04 16:54:05 -07:00
Florian CUNY f5a3fdee82 Another try at fixing NoClassDefFoundError with WorldEdit hook... 2019-07-04 17:11:17 +02:00
Florian CUNY 18f37c4efa Improved the on-the-fly Blueprint conversion
https://github.com/BentoBoxWorld/BentoBox/issues/802

It now avoids sending warnings if the conversion could be achieved seamlessly.
2019-07-02 09:31:51 +02:00
tastybento eeb3e64a97 Uses newer API for signs. 2019-06-08 17:27:24 -07:00
tastybento 390532adbc Fixes an error that can occur with sign pasting 2019-06-02 21:17:16 -07:00
tastybento 0fd25f02cd Fixes pasting of blueprints with crops, etc.
https://github.com/BentoBoxWorld/BentoBox/issues/702

Also fixes pasting of entities in the ground when they are on blocks
like crops that are slightly less than an integer block high.
2019-05-26 16:07:50 -07:00