Add setting for opening gui with no effects/styles, fix gui pages bug

This commit is contained in:
Esophose 2020-01-21 16:23:47 -07:00
parent b2549bed16
commit 9ebff20618
6 changed files with 8 additions and 5 deletions

View file

@ -27,7 +27,7 @@ dependencies {
shadow 'org.jetbrains:annotations:16.0.2'
shadow 'me.clip:placeholderapi:2.10.4'
shadow 'org.xerial:sqlite-jdbc:3.23.1'
shadow 'org.spigotmc:spigot-api:1.15-R0.1-SNAPSHOT'
shadow 'org.spigotmc:spigot-api:1.15.2-R0.1-SNAPSHOT'
}
shadowJar {

View file

@ -18,7 +18,8 @@ public class DefaultCommandModule implements CommandModule {
List<String> matches = new ArrayList<>();
List<String> commandNames = PlayerParticles.getInstance().getManager(CommandManager.class).getCommandNames();
if (args.length == 0) return commandNames;
if (args.length == 0)
return commandNames;
StringUtil.copyPartialMatches(args[0], commandNames, matches);

View file

@ -35,7 +35,8 @@ public class GUICommandModule implements CommandModule {
return;
}
if (!Setting.GUI_PRESETS_ONLY.getBoolean() && (permissionManager.getEffectsUserHasPermissionFor(pplayer).isEmpty() || permissionManager.getStylesUserHasPermissionFor(pplayer).isEmpty())) {
boolean hasEffectsAndStyles = permissionManager.getEffectsUserHasPermissionFor(pplayer).isEmpty() || permissionManager.getStylesUserHasPermissionFor(pplayer).isEmpty();
if (!Setting.GUI_PRESETS_ONLY.getBoolean() && (Setting.GUI_REQUIRE_EFFECTS_AND_STYLES.getBoolean() && !hasEffectsAndStyles)) {
if (byDefault) {
localeManager.sendMessage(pplayer, "command-error-missing-effects-or-styles");
} else {

View file

@ -27,7 +27,7 @@ public class GuiInventoryEditEffect extends GuiInventory {
List<ParticleEffect> effectsUserHasPermissionFor = PlayerParticles.getInstance().getManager(PermissionManager.class).getEffectsUserHasPermissionFor(pplayer);
int numberOfItems = effectsUserHasPermissionFor.size();
int itemsPerPage = 28;
int maxPages = (int) Math.ceil((double) numberOfItems / itemsPerPage);
int maxPages = (int) Math.max(1, Math.ceil((double) numberOfItems / itemsPerPage));
int slot = 10;
int nextWrap = 17;
int maxSlot = 43;

View file

@ -27,7 +27,7 @@ public class GuiInventoryEditStyle extends GuiInventory {
List<ParticleStyle> stylesUserHasPermissionFor = PlayerParticles.getInstance().getManager(PermissionManager.class).getStylesUserHasPermissionFor(pplayer);
int numberOfItems = stylesUserHasPermissionFor.size();
int itemsPerPage = 28;
int maxPages = (int) Math.ceil((double) numberOfItems / itemsPerPage);
int maxPages = (int) Math.max(1, Math.ceil((double) numberOfItems / itemsPerPage));
int slot = 10;
int nextWrap = 17;
int maxSlot = 43;

View file

@ -37,6 +37,7 @@ public class ConfigurationManager extends Manager {
USE_MESSAGE_PREFIX("use-message-prefix", true, "Whether or not to use the message-prefix field when displaying messages"),
GUI_ENABLED("gui-enabled", true, "If the command /pp gui is enabled", "Disable this if you have your own custom GUI through another plugin"),
GUI_REQUIRE_PERMISSION("gui-require-permission", false, "If the GUI should require the permission playerparticles.gui to open"),
GUI_REQUIRE_EFFECTS_AND_STYLES("gui-require-effects-and-styles", true, "If the GUI should require the player to have permission for at least", "one effect and one style to be able to open the GUI"),
GUI_PRESETS_ONLY("gui-presets-only", false, "If true, only the preset groups will be available in the GUI", "Permissions to open the GUI will change to only open if the user has any preset groups available"),
GUI_CLOSE_AFTER_GROUP_SELECTED("gui-close-after-group-selected", true, "If true, the GUI will close after selecting a group (either saved or preset)"),
GUI_BUTTON_SOUND("gui-button-sound", true, "If clicking a GUI button should make a noise"),