1
mirror of https://github.com/StarWishsama/Slimefun4.git synced 2024-09-20 03:35:51 +00:00

Formatting fix

This commit is contained in:
uiytt 2020-10-12 22:12:37 +02:00
parent 9ded6d1ac4
commit cd8603a6d8
3 changed files with 33 additions and 42 deletions

View File

@ -13,17 +13,7 @@ import org.bukkit.event.Event;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
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 {@link Event} is called whenever a {@link Player} click to unlock a research.
@ -36,41 +26,42 @@ public class PreCanUnlockResearchEvent extends Event implements Cancellable {
* @see BookSlimefunGuide * @see BookSlimefunGuide
* *
*/ */
public PreCanUnlockResearchEvent(@Nonnull Player p, @Nonnull Research research, @Nonnull PlayerProfile profile, @Nonnull SlimefunItem slimefunItem, @Nonnull Category category) { public class PreCanUnlockResearchEvent extends Event implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private final Player player;
private final Research research;
private final SlimefunItem slimefunItem;
private boolean cancelled;
@ParametersAreNonnullByDefault
public PreCanUnlockResearchEvent(Player p, Research research, SlimefunItem slimefunItem) {
Validate.notNull(p, "The Player cannot be null"); Validate.notNull(p, "The Player cannot be null");
Validate.notNull(research, "Research 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(slimefunItem, "SlimefunItem cannot be null");
Validate.notNull(category, "Category cannot be null");
this.player = p; this.player = p;
this.research = research; this.research = research;
this.profile = profile;
this.slimefunItem = slimefunItem; this.slimefunItem = slimefunItem;
this.category = category;
} }
@Nonnull @Nonnull
public Player getPlayer() { public Player getPlayer() {
return this.player; return 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;
} }
@Nonnull
public Research getResearch() {
return research;
}
@Nonnull
public SlimefunItem getSlimefunItem() {
return slimefunItem;
}
@Nonnull @Nonnull
public static HandlerList getHandlerList() { public static HandlerList getHandlerList() {

View File

@ -242,8 +242,9 @@ public class BookSlimefunGuide implements SlimefunGuideImplementation {
if (profile.hasUnlocked(research)) { if (profile.hasUnlocked(research)) {
openCategory(profile, category, page); openCategory(profile, category, page);
} else { } else {
PreCanUnlockResearchEvent event = new PreCanUnlockResearchEvent(p,research,profile,item,category); PreCanUnlockResearchEvent event = new PreCanUnlockResearchEvent(p, research, item);
Bukkit.getPluginManager().callEvent(event); Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) { if (!event.isCancelled()) {
if (research.canUnlock(p)) { if (research.canUnlock(p)) {
unlockItem(p, item, pl -> openCategory(profile, category, page)); unlockItem(p, item, pl -> openCategory(profile, category, page));
@ -252,7 +253,6 @@ public class BookSlimefunGuide implements SlimefunGuideImplementation {
} }
} }
} }
} }
}); });
} }

View File

@ -289,8 +289,9 @@ public class ChestSlimefunGuide implements SlimefunGuideImplementation {
if (profile.hasUnlocked(research)) { if (profile.hasUnlocked(research)) {
openCategory(profile, category, page); openCategory(profile, category, page);
} else { } else {
PreCanUnlockResearchEvent event = new PreCanUnlockResearchEvent(p,research,profile,sfitem,category); PreCanUnlockResearchEvent event = new PreCanUnlockResearchEvent(p, research, sfitem);
Bukkit.getPluginManager().callEvent(event); Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) { if (!event.isCancelled()) {
if (research.canUnlock(pl)) { if (research.canUnlock(pl)) {
unlockItem(pl, sfitem, player -> openCategory(profile, category, page)); unlockItem(pl, sfitem, player -> openCategory(profile, category, page));
@ -301,7 +302,6 @@ public class ChestSlimefunGuide implements SlimefunGuideImplementation {
} }
} }
return false; return false;
}); });
} else { } else {