Commit Graph

131 Commits

Author SHA1 Message Date
tastybento f049fc6941 Added SafeSpotTepeortTest 2021-12-20 09:46:04 -08:00
Huynh Tien 333c9a8272 load chunks passively 2021-12-20 19:37:50 +07:00
Huynh Tien 168de622ea limit how far the y-coordinate will be expanded 2021-12-19 20:40:01 +07:00
Huynh Tien f91ed4705a this should be better 2021-12-16 17:18:09 +07:00
Huynh Tien 6f01310f92 better safe spot finder 2021-12-16 08:58:41 +07:00
tastybento 7616f6aa2a Address potential NPE's 2021-11-12 13:19:19 -08:00
tastybento 930433b64b Clear the going home flag for edge cases
There were a few potential times when the flag may not have been
cleared. These were mostly teleport failure scenarios. Hopefully, this
is all of them.

https://github.com/BentoBoxWorld/BentoBox/issues/1864
2021-10-16 20:44:18 -07:00
tastybento b5fd992fa7 Fix mis-statement of island protection coordinates in info command. 2021-10-03 15:29:57 -07:00
tastybento 53f02ae686
Npe squashing (#1857)
* Fix hanging [uuid] in info.

* NPE checking

* Make getProtectionCenter nonNull

* More NPE fixes.

* Fix test

* Make getPlayer() and getOfflinePlayer() nonNull returns

This requires addons to not use null checks and instead us the isPlayer
or isOfflinePlayer methods.

* NPE blockers

* Deprecate CompositeCommand isPlayer method.

* Fix test
2021-09-18 17:59:32 -07:00
tastybento 8eb45e817c Code smell reduction 2021-09-18 08:15:15 -07:00
tastybento b24c1fdc86 Use final vars for lambdas to avoid them changing async
The processes could run async, especially when chunk loading took a
while, so using fields that could change would result in blocks being
missed, especially in the nether or end. Switching to final vars avoids
this.

Fixes https://github.com/BentoBoxWorld/BentoBox/issues/1840
2021-09-08 21:08:15 -07:00
tastybento 6bff4c8132 Merge branch 'develop' of https://github.com/BentoBoxWorld/BentoBox.git into develop 2021-09-08 20:26:56 -07:00
BONNe 6bf3264ab5
Fixes a bug when Potion metadata was not applied (#1849)
There was missing potion meta data applying after creating an item. 
This affects both: Potions and Tipped arrows.
2021-09-08 19:57:27 -07:00
tastybento 3650863fa1 Clear code - set worlds once on construction. 2021-09-08 19:50:23 -07:00
tastybento 0f7ca6ac60 Slimmer trimmer island info for players.
https://github.com/BentoBoxWorld/BentoBox/issues/1501
2021-09-04 10:02:37 -07:00
tastybento 547c266975 Extracted island info from the Island object.
This is in preparation to have a different info for players than admins.

https://github.com/BentoBoxWorld/BentoBox/issues/1501
2021-09-04 09:46:28 -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 a9a7673ce8 Fix German flag banner description.
Added more debug around error reporting.
2021-08-29 15:04:20 -07:00
BONNe fa41abc062
Implement Flag icon changing via Locales file. (#1829)
This commit contains 2 changes:
- An option for Flag to use icon that is defined in locales after "icon" string.
- An option for ItemParser to parse icon or return given value, if parsing was not successful.

The flag option is not ideal, but it is simpler and easier to maintain then adding new config section where icons can be changed, as the locales file already contains a lot of info about each flag.
2021-08-29 13:30:45 -07:00
tastybento 0341515fc8
Package info files for better JavaDocs (#1839)
* Added package info files for better JavaDocs
2021-08-29 13:28:16 -07:00
tastybento b906f5561a
Hex pr 1820 (#1822) 2021-08-19 12:09:23 -07:00
tastybento cc974c795f Added deprecation suppression. 2021-08-08 18:41:43 -07:00
BONNe 56a1fdb55a
Improve ItemParser code. (#1821)
* Improve ItemParser code.

Add ability to parse text if Material is just a single string.
Add ability to parse player heads.

Add comments to the code.

* Fixes failing test.
2021-08-08 10:05:14 -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 044a0c5c0d Fix JavaDoc 2021-05-31 16:01:21 -07:00
tastybento 609322d582 Remove debug. 2021-03-27 17:05:13 -07:00
tastybento 4b9b6774ea Teleport based on protection center and world height. 2021-03-27 16:57:15 -07:00
tastybento 9e0fdbd210 Add Util method to enable multi-lingual broadcasts. 2021-03-21 09:04:30 -07:00
tastybento a03aa51fb4 Fix NPE with admin teleport command. 2021-03-06 08:14:31 -08: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 04be4cf7de Fixed long standing bug in unused Util method getClosestIsland
Changed AdminRegisterCommand to use the method to remove code
duplication.
2021-02-17 18:36:57 -08:00
BONNe 79c3804603
Implements ability to use faster player head gatherer (relates to #1646). (#1679)
Adds 3 new BentoBox options:
- use-cache-server: option which allows to use mc-heads.net API for gathering player heads. It is a bit faster than Mojang API.
- heads-per-call: option which allows to specify how many heads will be requested at once per each API call.
- ticks-between-calls: option which allows to specify how many ticks should be waited until next API call.

All these options will allow much more faster player head gatherer.

Changes includes optimization for Mojang API too. For servers in online mode, HeadGetter will use Player UUID, instead of asking for UUID from API.
2021-02-16 15:57:04 -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 0372d6766f Fixed bug where End not being deleted. 2021-01-30 10:35:26 -08:00
tastybento 2c7f54fe10 Use orElseGet instead of orElse
orElse is a trap because it evaluates even if the Optional is empty.
orElseGet is the correct way.
2021-01-08 20:05:23 -08:00
tastybento 999d196e8e
Event fix with deprecation (#1623)
* Break out events and add individual handlers

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

* Corrected AddonEvents to have proper static handlers

* Made constructors protected.

Abstract classes should not have public constructors. Constructors of
abstract classes can only be called in constructors of their subclasses.
So there is no point in making them public. The protected modifier
should be enough.
2020-12-27 10:35:49 -08:00
tastybento 98697b1686
Delete experiment (#1589)
* Try loading adjacent chunks, but too slow.

* NMS void delete

* Revert the extra chunk in IslandDeletion.

That was for another deletion approach.

* Added NMS abstraction.

* Debug

* Clearer code.

* Clarify exceptions
2020-12-19 10:29:26 -08:00
tastybento caed56f16e Load initial tp location async
Fixes https://github.com/BentoBoxWorld/BentoBox/issues/1584
2020-11-26 17:25:17 -08:00
tastybento 79f6600fd2 Fixed tests and other small code smells 2020-11-08 16:48:08 -08:00
BONNe 3581537537
Fixes some errors with HeadGetter (#1569)
* Add getKey and getValue for Pair calls for nicer access.

* Fixes ConcurrentModificationException in HeadGetter.
Fixes an issue when elements with the same name were overwritten by HeadGetter.
2020-11-08 11:23:24 -08:00
tastybento ba903bdaca
Stops async db saving on shutdown. Adds JSON backup. (#1558)
* Stops async db saving on shutdown. Adds JSON backup.

* Fixes test failures and added Util class tests.
2020-11-01 13:58:29 -08:00
tastybento b024d0cc8b Switch to use Util method to reset player health.
Reduces duplicate code.
2020-10-11 09:18:53 -07:00
BONNe 6cd9339652
Fixes a bug with cache. (#1533)
It was not possible to set it to unlimited time due to my poor programming and logic skills. 
It also was contradicting to config comments.
2020-10-08 17:47:17 -07:00
tastybento 54bc554763 Code smell reduction 2020-09-12 16:55:54 -07:00
tastybento c05f2a3c15 Fixes default biome setting on island delete.
Fixes https://github.com/BentoBoxWorld/BentoBox/issues/1513
2020-08-31 18:40:30 -07:00
Florian CUNY 41c3d554f5 Added javadoc since tags in HeadGetter.java 2020-07-13 22:37:08 +02:00
BONNe fa259611fe
Rework PlayerHead Getter. (#1446)
* Rework PlayerHead Getter.

Generate player head based on WebAPI (as it is faster) and GameProfile texture (require NMS).
Cache is suitable for storing into file format.
Add ability to add custom HeadCache object into local cache.
Add ability to modify cache keeping length.
Add ability to keep all, or just a single element into cache until server restart.

* Address issues/improvements suggested from review.

- config will store time in minutes.
- default value will be 1h.
2020-07-11 14:13:32 +02:00
tastybento bdbfd33a34
Fixed code smells (#1444)
* Code smell changes

* Fixes issues raised in reviews.
2020-07-09 09:03:01 +02:00
tastybento 23fecdea54 Improves HeadGetter and Panel
Will replace more than one head in a panel if found.
2020-06-28 09:15:42 -07:00