From cd8603a6d854f83956f570c5e7abacebec984d17 Mon Sep 17 00:00:00 2001 From: uiytt Date: Mon, 12 Oct 2020 22:12:37 +0200 Subject: [PATCH] Formatting fix --- .../api/events/PreCanUnlockResearchEvent.java | 63 ++++++++----------- .../guide/BookSlimefunGuide.java | 6 +- .../guide/ChestSlimefunGuide.java | 6 +- 3 files changed, 33 insertions(+), 42 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/PreCanUnlockResearchEvent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/PreCanUnlockResearchEvent.java index 8ad65c629..f2d7e4447 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/PreCanUnlockResearchEvent.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/PreCanUnlockResearchEvent.java @@ -13,64 +13,55 @@ import org.bukkit.event.Event; import org.bukkit.event.HandlerList; import javax.annotation.Nonnull; +import javax.annotation.ParametersAreNonnullByDefault; +/** + * This {@link Event} is called whenever a {@link Player} click to unlock a research. + * This is called called before {@link Research#canUnlock(Player)} + * The event is not called for the cheat sheet + * + * @author uiytt + * + * @see ChestSlimefunGuide + * @see BookSlimefunGuide + * + */ public class PreCanUnlockResearchEvent extends Event implements Cancellable { private static final HandlerList handlers = new HandlerList(); - private boolean cancelled = false; private final Player player; private final Research research; - private final PlayerProfile profile; private final SlimefunItem slimefunItem; - private final Category category; - /** - * This {@link Event} is called whenever a {@link Player} click to unlock a research. - * This is called called before {@link Research#canUnlock(Player)} - * The event is not called for the cheat sheet - * - * @author uiytt - * - * @see ChestSlimefunGuide - * @see BookSlimefunGuide - * - */ - public PreCanUnlockResearchEvent(@Nonnull Player p, @Nonnull Research research, @Nonnull PlayerProfile profile, @Nonnull SlimefunItem slimefunItem, @Nonnull Category category) { + private boolean cancelled; + + + @ParametersAreNonnullByDefault + public PreCanUnlockResearchEvent(Player p, Research research, SlimefunItem slimefunItem) { Validate.notNull(p, "The Player cannot be null"); Validate.notNull(research, "Research cannot be null"); - Validate.notNull(profile, "PlayerProfile cannot be null"); Validate.notNull(slimefunItem, "SlimefunItem cannot be null"); - Validate.notNull(category, "Category cannot be null"); this.player = p; this.research = research; - this.profile = profile; this.slimefunItem = slimefunItem; - this.category = category; } @Nonnull public Player getPlayer() { - return this.player; - } - @Nonnull - public Research getResearch() { - return this.research; - } - @Nonnull - public PlayerProfile getProfile() { - return this.profile; - } - @Nonnull - public SlimefunItem getSlimefunItem() { - return this.slimefunItem; - } - @Nonnull - public Category getCategory() { - return this.category; + return player; } + @Nonnull + public Research getResearch() { + return research; + } + + @Nonnull + public SlimefunItem getSlimefunItem() { + return slimefunItem; + } @Nonnull public static HandlerList getHandlerList() { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/BookSlimefunGuide.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/BookSlimefunGuide.java index 9b4aeed6a..b1b19529f 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/BookSlimefunGuide.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/BookSlimefunGuide.java @@ -242,9 +242,10 @@ public class BookSlimefunGuide implements SlimefunGuideImplementation { if (profile.hasUnlocked(research)) { openCategory(profile, category, page); } else { - PreCanUnlockResearchEvent event = new PreCanUnlockResearchEvent(p,research,profile,item,category); + PreCanUnlockResearchEvent event = new PreCanUnlockResearchEvent(p, research, item); Bukkit.getPluginManager().callEvent(event); - if(!event.isCancelled()) { + + if (!event.isCancelled()) { if (research.canUnlock(p)) { unlockItem(p, item, pl -> openCategory(profile, category, page)); } else { @@ -252,7 +253,6 @@ public class BookSlimefunGuide implements SlimefunGuideImplementation { } } } - } }); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/ChestSlimefunGuide.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/ChestSlimefunGuide.java index 6d6bdb936..16ad24646 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/ChestSlimefunGuide.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/ChestSlimefunGuide.java @@ -289,9 +289,10 @@ public class ChestSlimefunGuide implements SlimefunGuideImplementation { if (profile.hasUnlocked(research)) { openCategory(profile, category, page); } else { - PreCanUnlockResearchEvent event = new PreCanUnlockResearchEvent(p,research,profile,sfitem,category); + PreCanUnlockResearchEvent event = new PreCanUnlockResearchEvent(p, research, sfitem); Bukkit.getPluginManager().callEvent(event); - if(!event.isCancelled()) { + + if (!event.isCancelled()) { if (research.canUnlock(pl)) { unlockItem(pl, sfitem, player -> openCategory(profile, category, page)); } else { @@ -301,7 +302,6 @@ public class ChestSlimefunGuide implements SlimefunGuideImplementation { } } - return false; }); } else {