Commit Graph

245 Commits

Author SHA1 Message Date
Tastybento
e881a5bd2b Removal of code smells.
Removed a lot of debug code.

Refactored some loops into lambas.
2018-04-18 19:07:20 -07:00
Tastybento
2e1c055cd7 Made BSBDatabase much easier to use for addons
Now obtaining the database handler is easy and understandable.
2018-04-15 17:30:42 -07:00
Tastybento
a5cc4c20ea Updates due to Challenges development. 2018-04-08 19:54:37 -07:00
Tastybento
a95e869cc9 Now reads addon.yml as a YAML file
Also imports level 1 permissions, i.e., does not handle children.
2018-04-05 18:56:48 -07:00
Tastybento
c49e2b07d3 Fixed issues with panels not scaling in size correctly. 2018-04-02 18:20:54 -07:00
Tastybento
e09cb30cb5 Made head getting async for panels. 2018-03-31 18:34:49 -07:00
Tastybento
b20fbd55a4 Cleaned up imports and unneeded exceptions 2018-03-11 15:59:03 -07:00
tastybento
8e97186caf Fixed merge conflicts. 2018-03-12 05:11:02 +09:00
tastybento
cf792779f9 Now using JSON-based data for MySQL
Large number of changes to improve database functions.
2018-03-12 04:08:19 +09:00
Florian CUNY
f511e54429 Unit testing is working greatly, fixed CompositeCommand 2018-03-01 15:12:31 +01:00
Florian CUNY
e4cedb58d0 Removed useless constructor in CompositeCommand + updated unit tests 2018-03-01 14:43:33 +01:00
Florian CUNY
6ba27eef4e Moved User to its own package + added Notifier to avoid massive "Island protected" spam 2018-03-01 14:25:09 +01:00
Florian CUNY
4a86784535 Fixes bug with nextSlot() not taking care of size if it was set 2018-03-01 11:05:19 +01:00
Florian CUNY
c60f92b7b3 MAJOR changes to Panel API
All methods in PanelBuilder follow the Builder pattern (no more "set...")
nextSlot() now returns the first unoccupied slot
2018-03-01 11:02:11 +01:00
Florian CUNY
f648c936ad Continued working on the SettingsPanel. Did minor fixes in PanelItemBuilder 2018-02-26 20:18:09 +01:00
Tastybento
e598fa7c93 Cleaned up a vunerability and some code smells. 2018-02-25 23:05:21 -08:00
Tastybento
bdca10636e Added Config comment capability.
See the challenges addon for examples.
2018-02-25 22:44:22 -08:00
Tastybento
1315dd990c user or listener can be null, so need to us ofNullable. 2018-02-25 20:46:13 -08:00
Tastybento
9db2602f78 Added FlagsManagerTest class to test the flags manager.
Added some code to the Flag, Flags and FlagManager classes to enable
passing the tests.
Realized that some flags had duplicate icons. This means that the
getFlagByIcon() method doesn't work because there could be more than
one. If we want to allow duplicate icons then we need to change the
manager. Also, do we need to getFlagByIcon method?
2018-02-25 19:48:01 -08:00
Tastybento
97491b1d89 Removed unused imports 2018-02-25 18:21:42 -08:00
Tastybento
7fa038bfce Merge branch 'develop' of https://github.com/tastybento/bskyblock.git into develop 2018-02-25 18:20:01 -08:00
Tastybento
00121e7e37 Added a specific config class to store objects as YAML 2018-02-25 18:19:52 -08:00
Florian CUNY
a885247c85 Implemented basic SettingsPanel + MAJOR changes in Panel/Flag API
It currently just displays a panel with all the flags in it. And throws exception when clicking on an item :P

Flag no longer have a PanelItem but Material instead as the icon.
Added a toPanelItem() method in Flag
Made the Panel(Builder) not using the Optional as fields anymore
2018-02-25 17:09:46 +01:00
Florian CUNY
6edc9555ad Renamed FlagType -> Flag and Flag -> Flags
Don't know when nor why it has been changed. Flag means the object, the flag itself, while Flags means the list of pre-defined Flag(s).
2018-02-25 16:01:30 +01:00
Tastybento
b043e641a1 Added equals to User class
Added null check for FlatFileDB Handler.
2018-02-24 21:29:51 -08:00
Tastybento
5a3a557cf2 Made improvements while writing challenges addon
Improved enum error handling in flat file.
2018-02-24 11:28:21 -08:00
Tastybento
84f10d6790 Removed debug. 2018-02-20 14:16:40 -08:00
Tastybento
b25d17fa78 Renamed flags to Flag because it was confusing.
Had to rename the class to FlagType as a result.

Rewrote FireListener to be simpler.

Wrote test case for fire listener.
2018-02-20 14:06:09 -08:00
Tastybento
44ed33bb26 Tweaks due to work on Challenges addon.
Enabled the overall panel listener to work.
2018-02-19 19:49:21 -08:00
Tastybento
023a68546c Changes made due to addon development.
Added a method to easily get named addons from other addons.

Fixed bugs with addonclassloader.

Added ignores to some unavoidable line items

Added auto-cancel to panels so that items cannot be taken from them by
default.
2018-02-19 13:05:36 -08:00
Tastybento
49764c151d Reverted f3d7bf2af3
It breaks the addon class loading and using lamda functions doesn't end
up being neater because it must be able to throw a
ClassNotFoundExcepetion to the Bukkit code.
2018-02-19 12:05:59 -08:00
Tastybento
25b4f674bb Fixes infinite error with commit f14676f.
The lambdas were missing the input argument to the execute method so
were calling the parent's execute method.
2018-02-19 11:01:48 -08:00
Tastybento
382f195015 Added tests to PanelItemBuilder and fixed bugs.
Cleared up the description settings methods. Using these will add to the
description of the item.

Temporarily removed JavaDoc and Source jar creation from the POM to save
time when compiling. Will put it back when we need it.

Also, I worked out how to run the Bukkit server setup for tests. See the
setUp method in the tests. This works (at last).
2018-02-19 09:57:19 -08:00
Tastybento
7f0d71e25c Added support for player heads in PanelItemBuilder API 2018-02-19 07:55:57 -08:00
Tastybento
f64dc0aaea Javadoc cleanup. 2018-02-17 17:01:25 -08:00
Tastybento
9715811303 Removed @throws javadoc tag as it is not needed. 2018-02-17 14:54:36 -08:00
Tastybento
54dd9e87d4 Reduced the complexity of these commands.
By splitting up the methods, it makes it easier to understand and spot
bugs.
2018-02-11 15:22:03 -08:00
Tastybento
c07b649488 Completed nether portals
Also fixed some issues around admin commands and the teleport admin
commands in particular.
2018-02-11 11:12:56 -08:00
Tastybento
921d25c2d5 Added private constructor because all methods are static. 2018-02-10 14:39:57 -08:00
Tastybento
180517cef3 Code smells cleanup 2018-02-10 14:00:40 -08:00
Tastybento
84e3ae3e8b Removed imports
Fixed vulnerability issue with Pair

Fixed database connection issue with MySQLDatabaseHandler
2018-02-10 13:51:11 -08:00
Florian CUNY
b04602302b Internal Placeholders are now working
It works, but it is more like a DIY patch thing. It has a few problems with the current implementation :
1. It doesn't suit our "code style" : it uses an Handler instead of a Manager, eg.
2. It is a bit laggy (I've got the feeling that it could be improved)
3. It doesn't hook to other Placeholder APIs for now
And a few other things.

I think this is more like a Proof of Concept : it will have to be improved in the next weeks.
2018-02-10 13:54:27 +01:00
Florian CUNY
65245a99f5 Fixes bug where the help could be seen even though not having the perms 2018-02-10 11:00:19 +01:00
tastybento
f8da3fbc61 Fixed bugs with MySQLDatabaseHandler
Code clean up, fixed bugs. Added automated tests.
2018-02-09 17:06:32 -08:00
Tastybento
f3d7bf2af3 Refactored code to make it better to maintain and read. 2018-02-08 21:17:16 -08:00
Tastybento
c916bbf827 Automated code cleanup.
Removes spaces, adds {} to if statements, etc.
2018-02-08 20:08:46 -08:00
Tastybento
2be005acb1 Removed vulnerabilities
Mainly leftover raw stacktrace prints in exceptions instead of propper
logging statements.
2018-02-07 21:11:23 -08:00
Tastybento
08b2e2579b Reverted to using an explicit throw of all exceptions 2018-02-07 19:28:29 -08:00
Tastybento
e4fbc6fab1 Simplified code, no need for internal variable. 2018-02-07 19:16:05 -08:00
Tastybento
3f35afc76a Close is handled automatically. 2018-02-07 19:13:40 -08:00
Tastybento
e5a87ccf7a Code cleanup and bug fixing.
This just cleans up a lot of code that could cause confusion or was
actually wrong.
2018-02-06 23:04:09 -08:00
Tastybento
1db21c10da Fixed bug with help that I introduced.
Added specific convenience showHelp() method to Composite command.
2018-02-06 22:45:21 -08:00
Tastybento
219d1e66ab Fixed brackets. 2018-02-06 21:43:31 -08:00
Tastybento
fdc7a62990 Fixed issue where Optional was not being explicitly checked before get. 2018-02-06 21:31:59 -08:00
tastybento
aac17990bc Made description private. 2018-02-06 16:09:49 -08:00
tastybento
04a4394752 Make addon non-public and provide getter to address minor vulnerability. 2018-02-06 16:04:22 -08:00
tastybento
7e2f8052da Improved exception handling error messages. 2018-02-06 15:59:42 -08:00
tastybento
1e920825ef Added context to raw stack trace dump after exception. 2018-02-06 15:55:31 -08:00
tastybento
1ddf706c68 Bug fixes to avoid NPE's and Optional gets without isPresent 2018-02-06 13:21:08 -08:00
Tastybento
ace6294e23 Came full circle - kept Flags as final statics
This approach simulates an enum, but one that can be extended by others
to add custom flags. I added a handy values() method that uses
reflection to provide a list of all the flags in the class.

See TestBSkyBlock.java test classes for the tests of the default flag
registration and the custom flag registration.
2018-02-05 23:53:07 -08:00
tastybento
be5404e9c2 Added Setting type to flags.
Flags can be Protection type or Setting Type.

Still needs testing for PVP.
2018-02-05 17:39:04 -08:00
tastybento
645b4eb610 Implements flags as enum so flags are protected. 2018-02-05 14:51:03 -08:00
tastybento
ffbf938a32 WIP trying out moving flags into flag manager. 2018-02-05 14:30:35 -08:00
tastybento
812594783e Made Adapter its own annotation. 2018-02-05 11:35:50 -08:00
Tastybento
fa1ccd0c99 Fixed bugs with MySQL saving and loading.
Added the adapter annotation to MySQL and fixed issues with empty
hashmaps causing null errors.

Added a flag serializer adapter for the protection flags so that flags
are saved and loaded correctly.

Renamed the Adapter notation class to be clearer about what it is doing.
2018-02-04 12:53:17 -08:00
Tastybento
83d0848429 Fixed bugs with protection.
Added serializer adapter for the Flags hashmap in Island.

Teams don't work. Need to work out why.
PVP doesn't work correctly. It allows members to hit visitors anytime,
but visitors can only hit others if PVP is off. This isn't how it is
supposed to work!
2018-02-03 20:42:12 -08:00
Tastybento
c648409858 Reworked code so it can be tested using automated unit tests.
See TestBSkyBlock.java class for protection tests.

More to come!
2018-02-03 15:26:13 -08:00
Tastybento
df0ecca217 Added dependency injection (DI) for flag listeners for plugin.
This is required for automated testing (can't use static getInstance). I
really need automated testing of the protection classes, so even though
this adds a parameter to the classes, it's important to have it right
now.
2018-02-03 11:54:33 -08:00
Tastybento
0d645600fc Fixed bugs with start up and flag registration.
Protection does not work yet. Still need more debugging.
2018-02-02 08:18:56 -08:00
Tastybento
72c99656cc Added the protection listeners. Took all day!
Generally these are very easy to understand. They use an abstract class
for common code.

I have not tested these in-game. I would like to see if I can create
some test classes but it may not be possible because of the static
BSkyBlock calls.
2018-02-01 20:30:57 -08:00
tastybento
4fe94bee3b Finished up the place and break block listeners.
There's a lot more that needs to be checked in these listeners! I moved
some common methods into the abstract class because they will be used
again and again by other listeners.

Added an anvil listener.

Added the flags. They were from ASkyBlock so may have name changes.
2018-01-31 15:46:38 -08:00
tastybento
177023f314 Added code to support protection flag listeners.
Made getIslandsAt() Optional to enable better code structures in the
listeners.

Created an abstract class to simplify flag protection listeners.

Added default setting for flags that will be able to be set by config.
This default is used for any space in the worlds not occupied by an
island.
2018-01-30 16:59:10 -08:00
Tastybento
f7b6898559 Added protection methods. 2018-01-28 20:44:57 -08:00
Tastybento
f1072e5984 Fixed flag optional aspect. 2018-01-28 09:47:51 -08:00
Florian CUNY
1d5b0ab8dd API Improvements on PanelItem and Flags
Their respective builders now have default values
Flags get automatically registered once built
Added some convenience methods
2018-01-28 13:31:07 +01:00
Tastybento
2b434bf93a Added ability for panel description to be just a string. 2018-01-27 15:58:15 -08:00
Florian CUNY
72c862c0d5 Starting to implement some Flags to test the API 2018-01-27 17:04:08 +01:00
Florian CUNY
6c08763cbb Made PanelItemBuilder methods' name suit the Builder style 2018-01-27 17:03:30 +01:00
Tastybento
475f9b1416 Made changes to fix events and support the FAWE addon. 2018-01-25 22:19:33 -08:00
Tastybento
f6ca7f7866 Fixed subcommand aliases. Added admin tp command.
While writing the admin tp command, I realized that subcommand aliases
were not working. Also, it was not possible to tell what alias had been
used for a command. I added that capability. i.e., if the alias is used,
then the label of that command is set to the alias.
2018-01-21 12:58:35 -08:00
Tastybento
09b9d4dd49 Now uses the official config.yml in the BSkyBlock data folder.
Saves a backup of the config after validation in the database so it can
be checked.

To Be Done: Validation of the config when it is loaded against the
database version.
2018-01-07 14:43:37 -08:00
Tastybento
16bcb90127 Added saveSettings and loadSettings methods.
These methods are used specifically for loading and saving settings
classes (those use the ISettings interface). The saving saves a copy of
any settings class in the database for future reference. The loading
loads a copy from the database if it exists and checks if any fields are
different from the config file. If they are different and some action
needs to be taken, the action is taken. This is still be to be coded.

In other news, the saving of arrays is unsupported and currently should
be avoided. Use Lists or Sets instead.
2018-01-07 11:56:43 -08:00
Tastybento
2765e5f3ab Fixed code according to comments on last commit.
Reworked locales so they use a nice and pretty folder structure.

Added the ability to define adapters to serialize certain data
structures. Added the PotionType list adapter.

Saving and loading of configs basically works. Known issues:

1. The config.yml is saved and loaded to/from the database folder
2. More error handling is required for the config loading. e.g., a list
value with only one value in it is not read as a list. This could get
tricky.
3. Comments are not saved (yet)
2018-01-06 19:40:25 -08:00
Tastybento
92af75e602 Converted to using the Settings loaded by the database handler.
Removed a lot of static references.

Constants have their own class.
2018-01-06 15:23:01 -08:00
Tastybento
2d447afa88 Added annotation handling to the flatfile database handler.
Currently it handles the @ConfigEntry path and specificTo fields.

Experimental: There is a class called Setting2.java. It has an
annotation that defines its filename as config.yml. Currently, it is
using the database folder as its location, but it could be the plugin's
datafolder in the future. By placing the config.yml file in the database
folder, it will be read. See the code in BSkyBlock onEnable() for how
that is done.

The main differences between Settings2.java and Settings.java are that
all fields are NOT static and therefore it is an object and uses getters
and setters. This is because it is a JavaBean. In other code, settings
should be queried using this config object.
2018-01-05 19:58:08 -08:00
Tastybento
478968dac7 Extended the config api annotations.
Added the concept of an adapter class that would convert the YAML input
to the setting type and value.
I included an example adapter class for Enum.

I fixed a number of the settings to match the config/yml or the other
way around.

After compiling and running, do /bsb reload to see the result.

This is a WIP and obviously not finished.
2018-01-04 19:58:04 -08:00
Florian CUNY
1430eda5ce ConfigAPI - Implementing the basic functionnalities
a lot of unused/useless Settings has been removed
Settings class has been moved to the main package, because the config package would then only contain it

I need feedback about it
2018-01-04 16:57:12 +01:00
Florian CUNY
b7f1d68bcf Store the locale files in their own "parent" folder, so it looks nicer, instead of having a prefix
also renamed BSBLocale#add() to BSBLocale#merge()
and renamed the locale files as well
2018-01-04 14:14:18 +01:00
Tastybento
4aaab9f69f Added a depth limit to the help command. 2018-01-03 21:37:37 -08:00
Florian CUNY
afa292986d Removed the cache from BSBLocale
because YAMLConfiguration is a cache itself.
2018-01-03 21:57:32 +01:00
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