Commit Graph

42 Commits

Author SHA1 Message Date
tastybento 0e0c502e1d
Team gui (#2251)
* WIP - add GUI for teams.

* WIP teams GUI

* Moe WIP on team GUI

* Modified file to avoid an NPE.

* Minor refactor to prevent int to Integer warning.

* Use latest dependencies for tests to pass.

* Move to singleton pattern for RanksManager,

* Team GUI WIP

* Added support for kick, setowner, and leave.

* Added support for accepting and rejecting an invite.

* Fixed bugs with text and operations.

* WIP for team invites.

* Adds inviting to the GUI.

* Fix tests

* Fixed minor bugs reported by SonarCloud

* Up Minecraft version and paper to 1.20.4 in POM

* Added features based on Discord feedback.

1. added some lore to the invite button to explain the players shown are
from the game world
2. removed the team state in chat
3. added a search to the invite panel

* Added back button.

Refactored some code and templates.

* Fixed bugs with teams and uncoop untrust etc of Ops.

* Return to name search GUI if name not found.

* Added return to GUI for player search

* Use Path.of
2024-01-08 20:50:26 +09: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 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 b5d9d2e52e API: Require getWorldSettings to be a game mode world 2021-10-03 20:33:50 -07:00
tastybento 938940199d Prevents console errors for missing icons in locale files. 2021-09-04 17:21:45 -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
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
BONNe c635647f85
Fix @since for subflags. (#1831) 2021-08-19 12:10:44 -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
Justin 0f7866a00b
Parent/sub-flag support, split up and designate CONTAINER flag as parent flag (#1784)
* Split CONTAINER flag into multiple flags

CONTAINER split into
- CONTAINER (Chest/Minecart Chest)
- BARREL (Barrel)
- COMPOSTER (Composter)
- FLOWER_POT (Flower Pot)
- SHULKER_BOX (Shulker Box)
- TRAPPED_CHEST (Trapped Chest)

Fixes #1777

* Add subflag support

* Create container parent flag, chest subflag

* Remove extra string from when CHEST was CONTAINER

* Fix incorrect flag specified on fired event in IslandToggleClick

* Add missing world subflag event firing

* Remove extra import
2021-07-06 13:41:23 -07:00
tastybento bdbfd33a34
Fixed code smells (#1444)
* Code smell changes

* Fixes issues raised in reviews.
2020-07-09 09:03:01 +02:00
Florian CUNY 31de515b3e Changed the Setting Flags category's icon to COMPARATOR 2020-05-02 14:45:20 +02:00
tastybento 22cd2379d3 Javadoc fixes 2019-12-01 09:03:22 -08:00
tastybento bbbe2565eb Fixed two security issues from sonar 2019-08-29 15:41:56 -07:00
Florian CUNY 267c9c73d8 Fixed NPE when opening the Settings Panel with some flags being hidden
The NPE could only occur if a non-op player was trying to open the Settings Panel or change tab or change mode, leading to the call of a null PanelItem.

I added some nullability annotations to make it 100% clear that Flag#toPanelItem(...) returns null if the player is not op and the flag is invisible.
2019-08-13 15:04:31 +02:00
tastybento 2f78957d31 Implements Basic/Advanced/Expert settings panels (#888)
* Implements Basic/Advanced/Expert settings panels

Better alternative to https://github.com/BentoBoxWorld/BentoBox/pull/887

* Remove StatusIcon class - not used.

* Fixes glow of active tab.

* Moved FlagMode to Flag.Mode

* Display the LOCK flag no matter what the tab is

* Made the "mode" being saved for the player instead of per-tab
This means that a player will have its "mode" saved when he comes back later in the Settings Panel while also making the navigation more fluent - he won't need to set PROTECTION and SETTING to the same mode everytime.

Also renamed Flag.Mode#getNextFlag() to #getNext()
Added PlayersManager#setFlagsDisplayMode(UUID, Flag.Mode), #getFlagsDisplayMode(UUID)

* Play a sound when click on the mode button

* Added a description to the "mode" item

* Modified the mode for some flags
2019-08-12 23:54:05 +02:00
tastybento 13ee55a173
Tab panels (#857)
TabbedPanel extends Panel so that when an icon is
clicked, the context can be gathered by the click listener via the
getActiveTab method. In this case, the CycleClick and IslandToggleClick
classes cast the tab to the SettingsTab so they can retrieve the island
that the panel is referring too. This is required in the case where an
admin is setting a user's island settings. Previously the context of a
panel was only every about the user who opened the panel.

* Adds a tabbed panel API

* Added permission for tab

* Adds default world protection settings GUI

This switches the settings panel to use the new TabbedPanel API.

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

* Adds admin command to change a player's settings.

Requires addon to add the admin settings command.

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

* Locale for AdminSettingsCommand
2019-08-03 16:45:41 -07:00
tastybento 38248bad29 Provided better documentation around when flags should be declared.
Protects against null worlds.

Related to https://github.com/BentoBoxWorld/AcidIsland/issues/53
2019-07-18 18:45:59 -07:00
tastybento 5fe4cccf7b Corrects wrong branch commit for world protection flags.
https://github.com/BentoBoxWorld/BentoBox/issues/840
The previous commit was a different approach. This is the correct one.
Does not break API.
2019-07-13 19:31:20 -07:00
tastybento 574fbc182f Added world protection settings to config
https://github.com/BentoBoxWorld/BentoBox/issues/840

This adds (or fixes) the ability for admins to set the default setting
of a protection flag. The flags go in the world flags section of a game
mode's config.yml.
2019-07-13 15:25:10 -07:00
tastybento 3f3ac57f1e Cleans up code smells. 2019-07-11 13:55:17 -07:00
tastybento abd88c0826 Adds a cooldown API for flags. (#821)
* Adds a cooldown API for flags.

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

Added 60 second cooldown to PVP flags

* Added cooldowns to database.

This way, if a cooldown is a long one it will be remembered even if the
server restarts.

* Update src/main/java/world/bentobox/bentobox/database/objects/adapters/FlagSerializer3.java
2019-07-07 08:08:16 +02:00
tastybento b1f66eb31b Fixes bugs and code smells from Sonarcloud. 2019-07-04 16:54:05 -07:00
tastybento fc2de2501c Added assertions to tests per SonarCloud 2019-06-08 19:14:25 -07:00
Florian CUNY b4fe70da0c Fixed indent and javadoc from previous commit 2019-05-11 14:28:57 +02:00
tastybento 8ce47772c2 Addon reloading: adds parameter to register flag
Addons need to declare themseves when they register a flag so that the
flag listener can be reset. Note that this is not mandatory unless the
flag declares a listener
2019-05-10 15:18:13 -07:00
Florian CUNY 5073d9cf5c Fixed code smells 2019-03-24 15:47:25 +01:00
tastybento 7a7ca42383 Refactored toPanelItem to make it easier to understand 2019-03-23 18:59:30 -07:00
tastybento 23491d0c4a
Flag visibility (#617)
* Saves world settings to config.yml when they are changed mid-game.

* Fixes and adds to tests

* WIP: Added visibility settings for flags.

Tests still need to be fixed and requires saving to config.yml.

* Fixes tests

* Completed changes.

* Renames method to be hidden flags instead of visible settings

GameModeAddons will need to adjust WorldSettings API based classes.
2019-03-23 15:38:06 -07:00
tastybento 2cdbc25f6a Rewrote Flag test class for better coverage 2019-03-09 20:55:54 -08:00
tastybento 58253eb7d7 Implements gamemode-specific flags API (#541)
* Implements gamemode flags API

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

* New and improved
2019-02-13 07:58:33 +01:00
Florian CUNY f5f345a1ab Documented Flag.Type 2019-01-23 19:58:31 +01:00
tastybento b48cc89f73 Added flag default setting for specific world. 2019-01-15 11:45:49 -08:00
Florian CUNY daa2992ba4 Made Flag.Builder#defaultSetting default to 'false'
And therefore, I've removed all calls of #defaultSetting(false) from the Flags. That makes the code a bit nicer :slight_smile:
2018-12-27 11:24:53 +01:00
tastybento 68d6b008f4 Fixed tests by fixing the default rank value.
Flag was marked as deprecated, which may be okay, but because it caused
a lot of warnings in the tests because they bypass the builder I removed
the deprecation but kept the warning in the JavaDoc.
2018-12-23 22:15:37 -08:00
Florian CUNY 2e5cdc7453 Fixed Flag.Builder#usePanel(boolean) to be public 2018-12-23 16:39:31 +01:00
Florian CUNY 168f9ae8f1 Added Flag.Builder 2018-12-23 16:33:10 +01:00
Florian CUNY 63e004415b Fixed Flag.Type.WORLD_SETTING to use GRASS_BLOCK instead of GRASS 2018-08-31 21:04:24 +02:00
Florian CUNY 3212b7180d Changed a few locale references for consistency
Removed `general.errors.you-need` to put the [permission] variable in the `general.errors.no-permission`.
Renamed all confirmation-related references to `commands.confirmation.xxx`.
Renamed `protection.panel.flag-item.xxx_rank` to use a dash instead of an underscore.
2018-08-12 18:47:31 +02:00
Florian CUNY b600dacbdd Continued 1.13 support 2018-08-01 10:18:37 +02:00
Florian CUNY 3473fb48e6 Renamed 'world.bentobox.bbox' to 'world.bentobox.bentobox' 2018-07-31 18:03:32 +02:00