Commit Graph

155 Commits

Author SHA1 Message Date
Florian CUNY
62480d7249 Fixed NPE in User when doing #getTranslation(reference, ...variables)
it was due to the null value possibly returned by the LocalesManager#get(user, reference) method when nothing has been found, leading the variables replacement to cause a NPE.

User#getTranslation(reference, ...variables) now does the check and return the reference if the translation found equals null BEFORE trying to replace variables.
User#getTranslationOrNothing(reference, ...variables) works the same as before, it just checks if the returned translation is the same than the reference (therefore it returns the blank String), otherwise it sends the translation.
2018-01-03 21:41:30 +01:00
Florian CUNY
7acc8d5401 Minor changes in CompositeCommand
Notably improved the #isPlayer(user) condition
2018-01-03 21:15:01 +01:00
Florian CUNY
b8dcc98a0c Removed useless accessibility keywords in BSBCommand interface 2018-01-03 21:14:11 +01:00
Florian CUNY
34f291b17f Minor changes in User and IslandBuilder
Mainly spacing but also optimized the User#hasPermission() condition
2018-01-03 21:06:28 +01:00
Tastybento
7e9a287143 Added help text top and bottom
Fixed top-level-command weirdness. / is required in getUsage().
2018-01-03 08:21:49 -08:00
Tastybento
d86c763716 Fixed island multihome to match new syntax.
Renamed island multihome to start with "Custom" to make it clearer. This
class is as much an example as anything of how to override the default
help.

Renamed my author tag to be tastybento. :-)
2018-01-03 07:56:10 -08:00
Florian CUNY
44742d8946 Made use of "commands.help.syntax" for help
This is a more flexible and natural way to provide the display for the help, especially for the colors.

I had to remove the "/" from the usage though. If you think it should be there, re-add it but remove it from the locale then.
2018-01-03 16:11:45 +01:00
Florian CUNY
6536ff58cc Fixed user#getTranslation() not replacing variables 2018-01-03 16:09:54 +01:00
Tastybento
5aa3594f42 The color update!
Added colors to help text.
2018-01-02 19:36:53 -08:00
Tastybento
30fb087777 Implemented locales that include addons.
This is a first working version and can probably be improved.

Firstly, the plugin will save any BSkyBlock language files to the locale
folder from the BSkyBlock jar if and only if the locale folder does not
exist. It will then do the same for any addons as they are loaded. Addon
language files are prefixed with their addon name to keep them separate
and recongnizable.

Then the plugin loads the language files and merges common languages
together into a YAMLConfiguration that is held in memory. The combined
config is never saved out to the file system.

If a request is made for a particular reference to a language that does
not exist or if the reference does not exist, then the default language
is tried.
2018-01-01 18:32:59 -08:00
Tastybento
037bf04836 Added methods to allow shared classes across multiple addons.
The original code did not allow addons to talk to each other in any way.
After trying loads of things with class path I studied the bukkit code
and saw that they override the findClass method in URLClassLoader. This
enables addons to find classes in other addons. All that was then needed
was a map in the AddonsManager of classes that this manager knows about
and a getter and setter method for them. After all that (3 hours) it
works.
2018-01-01 11:40:25 -08:00
Florian CUNY
df5434930c Renamed SettingChangeEvent to FlagChangeEvent and removed references to SettingsFlag 2018-01-01 01:53:03 +01:00
Florian CUNY
ae0dc7c538 Implemented basic Flags API
Removed Island's SettingsFlags
Fixed Island#toggleFlag()
2018-01-01 01:41:19 +01:00
Tastybento
bfcbd44478 Minor changes around Optional. 2017-12-31 16:12:53 -08:00
Florian CUNY
131a8affca PanelsAPI - Fixed ambiguous logic with the cancellation of the clickevent 2018-01-01 00:55:53 +01:00
Florian CUNY
5ea46aea29 Removed useless accessibility keywords in Interfaces 2018-01-01 00:43:32 +01:00
Tastybento
002c54ef21 Fixed issues while implementing the warps addon. 2017-12-31 14:08:15 -08:00
Tastybento
109c0edca3 Panel additions or changes.
By working on the Warp addon I made changes to the Panel API.
2017-12-30 21:14:58 -08:00
Tastybento
06dec42029 Moved a method to use User instead of Player. 2017-12-30 17:28:25 -08:00
Tastybento
1f92c2b60e Added more around the Panel API. 2017-12-30 17:13:20 -08:00
Tastybento
1f57e1eb0b Fixed return type of getBSkyBlock() 2017-12-29 11:02:38 -08:00
Tastybento
4289a24c56 Improved the panel API.
I'm working on addons and realized it would be a better approach to be
able to register the listener for a panel explicitly for each panel.
This is optional. Also, added the ability to open the panel immediately
for a player.
2017-12-29 09:11:14 -08:00
Tastybento
452311fb69 Boom! NMS is gone! (Again) Will it come back?
Used reflection to get the command map from the server instead of using
the NMS call.

Also, more importantly, this commit enables CompositeCommands to
auto-register their top-level command in the constructor. No need to
separately obtain the command manager object. Yes, easy API. :-)
2017-12-28 20:36:04 -08:00
Tastybento
9b0992c30d Removed perm checks for console. 2017-12-28 17:20:33 -08:00
Tastybento
4d7b5374e5 Bolstered error reporting for malformed addon.yml files. 2017-12-28 17:11:49 -08:00
Tastybento
6e6165a301 Merge branch 'develop' of https://github.com/tastybento/bskyblock.git into develop 2017-12-28 11:56:55 -08:00
Tastybento
a15b1b2371 Added saveResource method to AddOn save to a specific folder. 2017-12-28 11:56:45 -08:00
Florian CUNY
cb2d24c779 Removed useless AddonStates and added MISSING_DEPENDENCY 2017-12-28 20:50:24 +01:00
Tastybento
d3490a6f24 Added comments to Addon. Added save config method. 2017-12-28 09:37:07 -08:00
Florian CUNY
c2271ae229 Removed TeamChatEvent, CoopJoinEvent and CoopLeaveEvent
because their related features won't be implemented in BSB
2017-12-28 15:30:18 +01:00
Florian CUNY
390d58cc8b AddonsAPI & Events changes
Moved PremadeEvent to api/events
Made use of PremadeEvent for all existing events
Renamed TeamReason to Reason in TeamEvent
Made the addon events follow the used builder pattern
Renamed #loadAddons() to #enableAddons() in AddonsManager
Added #disableAddons() in AddonsManager
2017-12-28 15:29:32 +01:00
Florian CUNY
40c59f2f7e AddonsAPI - Polishing the API
Renamed all the classes
2017-12-28 14:50:02 +01:00
Florian CUNY
86ad00acab AddonsAPI - Polishing the API
Temporarily remove api/addons folder to rename files
2017-12-28 14:49:27 +01:00
Tastybento
687a71876d Completed the addons additions.
Everything seems to work okay.
2017-12-27 19:16:13 -08:00
Tastybento
f80a933c34 Merge branch 'develop' into addons 2017-12-27 14:03:52 -08:00
Tastybento
fcaa3514ac Fixed NPE bug when getting plugin. 2017-12-27 14:03:00 -08:00
Tastybento
4fc33cb9f7 Mid-work. 2017-12-27 13:59:27 -08:00
Tastybento
2825f9535e Command API and Help done.
Commands now require a setup to define their permission, player/console
status, description and any parameters they have. This is also where any
subcommands are created if they exist.

Each command automatically has a help subcommand. This is used to
display help. This will also recursively go to any other sub commands
and get help from them. 

Note that getUsage() now *only* shows the command and any sub commands.
It turns out that Bukkit requires this to start with a / because it
actually uses this in its own help system and the server will not start
if it is not in the right format. Therefore I split off parameters into
their own string. This also enables them to be translatable. 

Everything should work at this point. It's just waiting on the locale
system to work to display the strings in the locale files.
2017-12-27 12:09:08 -08:00
Tastybento
f22065fd2c Fixed help and usage descriptions.
Known issue - the help shown when doing a parent help is not using the
child's custom help class for usage/description.
2017-12-26 11:09:00 -08:00
Tastybento
239cf50709 Switched to a getter for getPlugin() in CompositeCommand
Made internal variable protected.
2017-12-26 08:40:28 -08:00
Tastybento
97722b56d5 Switched plugin to bsb to avoid confusion with other plugins. 2017-12-24 10:35:36 -08:00
Tastybento
f5464347c6 rename comments. 2017-12-24 10:27:03 -08:00
Tastybento
866ac2f776 rename - list -> args 2017-12-24 10:26:41 -08:00
Tastybento
a198c1a44a Renamed some classes to BSB... 2017-12-24 09:51:41 -08:00
Florian CUNY
8144f80cfb Updated en_US with all the commands and made some minor changes to the CommandsAPI
Renamed BSBCommand to BSCommand
Renamed some commands
Put invites commands in team
Splited makeleader from promote -> setowner
2017-12-24 16:52:10 +01:00
Tastybento
9b5a7c887c Made parent Optional in CompositeCommand to avoid null checks. 2017-12-23 21:58:32 -08:00
Tastybento
00b71c6090 Added comments. 2017-12-23 21:45:49 -08:00
Tastybento
f8ac04a779 Implemented the auto command help.
The help command is a default subcommand of every command. It will
display the usage info for the command and any subcommands.
2017-12-23 21:35:10 -08:00
Tastybento
eeb4e2a9ee Lots of work done on the command API.
Sub commands work, tab complete works. See the TestIslandCommand.java
test command for how to use the API and unit tests.

Still need to do the auto-help.
2017-12-23 19:14:35 -08:00
Tastybento
c5262e8faa Commands API implemented. Still a WIP.
Commands work and tab complete works somewhat. 
Help still needs to be done. Added in NotSetup And PluginConfig to just
make the plugin work. It's fine to remove them when there is a working
alternative.
2017-12-22 17:26:05 -08:00
Florian CUNY
a3db6e9b5d AddonsAPI - Made overriden BSModule methods final, so they cannot be over-overriden 2017-12-22 13:39:00 +01:00
Florian CUNY
1c3b3a2c56 AddonsAPI - Added #getFolder() in BSModule 2017-12-22 13:37:28 +01:00
Florian CUNY
6178b768bb L10nAPI - Fixed compilation errors by...
...
- Removing NetherPortals listener
- Adding a #getTranslation(reference, ...variables) in User
2017-12-22 13:31:27 +01:00
Florian CUNY
29dfc313fc L10nAPI - Reworking API - WIP
Removed the old localization system
Started implementation of the new one

For build reasons, removed protection listeners - they were requiring too much work to update them, and they need to be reworked due to the boilerplate code.
2017-12-22 13:22:33 +01:00
Tastybento
b3e4eeebc2 Fixed main command setup.
Added comments.
2017-12-21 23:16:43 -08:00
Tastybento
c2e37ad2ae Fixed permission check. 2017-12-21 23:13:22 -08:00
Tastybento
f28936948a Reworked command API
Implemented a recursive composite command that can be extended with
subcommands to infinity (and beyond!).

Composite command also tries to create help text and a list of help
commands. These are not current used and need more work.

This has not been tested yet completely.
2017-12-21 23:03:39 -08:00
Tastybento
18ad604b7b Changed TeamEvent to fire off class-specific events. 2017-12-17 12:38:52 -08:00
Florian CUNY
ed6899c989 CommandsAPI - command now asks if the sender is a player (option) and if it has the right permission (option)
Added some methods in User class
CommandsAPI is still WIP
2017-12-17 11:02:49 +01:00
Florian CUNY
cd40405c30
Implemented User class
And also made use of it in commands
2017-12-17 10:26:25 +01:00
Tastybento
90f88b4425 Fully removed Vault
Added commands for /island.
2017-12-16 09:33:24 -08:00
Tastybento
c6e885a8de Added abstract class to handle the invite map. 2017-12-13 23:31:14 -08:00
Tastybento
4b9762fb81 Added a number of Island commands.
Note that the team invite/uninvite are not linked yet.
2017-12-13 18:35:39 -08:00
Florian CUNY
ca17cd1080 AddonsAPI - Documented AddonState & added ERROR state 2017-12-12 14:42:04 +01:00
Florian CUNY
40b56843e7 AddonsAPI - Added #isAddon() in BSModule 2017-12-12 14:14:38 +01:00
Florian CUNY
df35492de5 AddonsAPI - Added RELOADING state & #reload() method 2017-12-11 22:05:32 +01:00
Florian CUNY
b8a5b0151f Made use of BSModule and CommandsManager in BSAddon and BSkyBlock main class 2017-12-11 21:55:42 +01:00
Florian CUNY
2c8a36ed54 CommandsAPI - Implemented CommandsManager to manage registering of commands by both BSB and its addons 2017-12-11 21:55:05 +01:00
Florian CUNY
7effb541ba AddonsAPI - Created interface BSModule to allow easier identification 2017-12-11 21:52:10 +01:00
Florian CUNY
d278ac317f Moved AddonManager to the managers package 2017-12-11 21:02:36 +01:00
Florian CUNY
3196b0b962 Addons API - Added AddonState 2017-12-11 21:01:49 +01:00
Florian CUNY
d776f6a90b Addons API - Introducing foundations of this API. WIP 2017-12-10 21:42:04 +01:00
Florian CUNY
71bbde1687 Commands API - Removed old API 2017-12-10 17:38:27 +01:00
Florian CUNY
65999aa550 Commands API - execution is working. WIP 2017-12-10 17:35:15 +01:00
Florian CUNY
46910dd851 Introducing the new Commands API - WIP 2017-12-10 11:46:59 +01:00
Tastybento
01baad3eba Update to fix bugs. Still WIP. 2017-12-09 11:43:35 -08:00
Florian CUNY
1e4dd979ae Revert "New Locale system - it breaks everything"
This reverts commit 9a3c900ac5.
2017-12-03 17:34:31 +01:00
Florian CUNY
9a3c900ac5 New Locale system - it breaks everything
The locales are not being loaded
Needs a few more methods to have a convenient way of using it
Needs to be fixed
2017-12-03 17:19:22 +01:00
Tastybento
b21e6dbcb0 Small change to panel builder
Enables items to be added without a slot to the end of the inventory.
Also enables slots to be queried.
2017-12-02 10:09:45 -08:00
Florian CUNY
dd40faa3b6 Implemented Panels API - still need some work, but it is functionnal 2017-11-29 16:54:24 +01:00
Tastybento
01b7b04dfc Made database classes available to add-ons. 2017-11-24 13:04:13 -08:00
Tastybento
792d1f8ec3 Fixed a lot of bugs
Changed events to be builder types.

Refactored island cache.

Fixed island deletion.

Made island distance chunk (16 blocks) based.
2017-11-20 16:05:52 -08:00
tastybento
0dfc32a5b9 Improved sub-command registration for add-ins. 2017-10-22 19:08:34 -07:00
tastybento
1e205ac12e Cleaned up command api a lot
Added event that fires when a command is run.
2017-10-21 11:30:22 -07:00
tastybento
7804c4a867 Enabled subcommand addition to BSkyBlock /island command.
This is a bit of a hack. The AbstractCommand class had to be pulled
apart to enable the ArgumentHandler to be imported by another plugin
without the other plugin having to extend AbstractCommand, which is
something it does not want to do because it is not defining a new
command, but just adding arguments. 

There's too much passing of arguments in this implementation, but it
works. I'll see if I can simplify it.
2017-10-09 22:52:57 -07:00
tastybento
3b604058da Rewrote TeamEvent to be a proper builder with final variables.
This follows the proper builder approach, where all variables are
defined in a builder with a final build at the end to make the object.
The variables in the object are final so cannot be changed afterwards.
2017-08-28 22:31:47 -07:00
tastybento
4eaa5a1f5f Added TeamEvents using the Builder pattern.
TeamEvent is used for all team events. Removed the extra classes that
are not needed anymore.

See this for a good summary on builder patterns:
http://minborgsjavapot.blogspot.com/2014/08/creating-objects-using-builder-pattern.html

Plan is to replace the island events with builder pattern too, so that
we only need one class for typical island events.
2017-08-27 21:54:01 -07:00
tastybento
fe6159e87b Fixed MySQL bug for loading individual objects.
The code was not loading the uniqueId object.

Added a lot of debug code in to help debug.
2017-08-26 18:21:42 -07:00
Poslovitch
b22c509f3a Removed hard coded default colors. Gonna add them in locale files instead. 2017-08-18 17:14:50 +02:00
Poslovitch
4943c89c42 Code cleanup. Made use of some Java8 features. Renamed PlayerManager#isAKnownPlayer() to PlayerManager#isKnown() 2017-08-18 16:05:35 +02:00
tastybento
55101f7ff2 Lots of changes to get teams to work.
I had a lot of problems finding a bug so I put a lot of debug in.
2017-08-12 18:51:48 -07:00
tastybento
4c69587d9a WIP: Teams - still testing and debugging, but making progress. 2017-08-12 09:08:09 -07:00
Poslovitch
25d2702632 /is help now basically works... But it needs a full redesign 2017-08-09 15:21:22 +02:00
Poslovitch
bfefea7f6a Implemented basic help. It NEEDS improvements. 2017-08-08 17:13:36 +02:00
Poslovitch
95c80a89f8 Made some changes and fixes to commands
ArgumentHandler#tabComplete(CommandSender, String[]) now returns a
Set<String>
Removed some redundant code
2017-08-06 23:01:01 +02:00
tastybento
5d43a500a4 Completed island leave command.
Fixed bugs with teams.
2017-08-05 20:13:06 -07:00
tastybento
c5d0a09a76 Fixed tabComplete showing messages
Changed the response for canUse to return an error code because the
error could be different depending on the reason. For tabComplete no
error is shown, but for commands, the error can be shown.

Implemented the invite and uninvite commands and filled in the team
command.
2017-08-05 12:45:10 -07:00
tastybento
f515623e26 Implemented command arguments and tabcomplete changes
Args no longer include the sub-command, just the args after the sub
command.

Improved tab complete so that it completes half-written commands

Fixed deprecation issue with visitor guard.
2017-08-05 10:23:45 -07:00
Poslovitch
0c1b5f7197 Tiny adjustements to commands 2017-08-01 14:20:52 +02:00
Poslovitch
614e5d3d5b Commands are now working (still need some work) 2017-07-31 10:58:28 +02:00