Skip to content

Commit

Permalink
Merge remote-tracking branch 'Slimefun/master'
Browse files Browse the repository at this point in the history
DEV - 1097
  • Loading branch information
xMikux committed Aug 30, 2023
2 parents 35024e6 + 67af02c commit 2a11aa6
Show file tree
Hide file tree
Showing 4 changed files with 275 additions and 273 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Automatically normalize line endings (to LF) for all text-based files.
* text=auto eol=lf
Original file line number Diff line number Diff line change
@@ -1,104 +1,104 @@
package io.github.thebusybiscuit.slimefun4.api.events;

import javax.annotation.Nonnull;

import org.apache.commons.lang.Validate;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.bukkit.inventory.ItemStack;

import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideMode;

/**
* This {@link Event} is called whenever a {@link Player} tries to open the Slimefun Guide book.
*
* @author Linox
*
* @see SlimefunGuideMode
*/
public class SlimefunGuideOpenEvent extends Event implements Cancellable {

private static final HandlerList handlers = new HandlerList();

private final Player player;
private final ItemStack guide;
private SlimefunGuideMode layout;
private boolean cancelled;

public SlimefunGuideOpenEvent(@Nonnull Player p, @Nonnull ItemStack guide, @Nonnull SlimefunGuideMode layout) {
Validate.notNull(p, "The Player cannot be null");
Validate.notNull(guide, "Guide cannot be null");
Validate.notNull(layout, "Layout cannot be null");
this.player = p;
this.guide = guide;
this.layout = layout;
}

/**
* This returns the {@link Player} that tries to open
* the Slimefun Guide.
*
* @return The {@link Player}
*/
@Nonnull
public Player getPlayer() {
return player;
}

/**
* This returns the {@link ItemStack} that {@link Player}
* tries to open the Slimefun Guide with.
*
* @return The {@link ItemStack}
*/
@Nonnull
public ItemStack getGuide() {
return guide;
}

/**
* This returns the {@link SlimefunGuideMode} of the Slimefun Guide
* that {@link Player} tries to open.
*
* @return The {@link SlimefunGuideMode}
*/
@Nonnull
public SlimefunGuideMode getGuideLayout() {
return layout;
}

/**
* Changes the {@link SlimefunGuideMode} that was tried to be opened with.
*
* @param layout
* The new {@link SlimefunGuideMode}
*/
public void setGuideLayout(@Nonnull SlimefunGuideMode layout) {
Validate.notNull(layout, "You must specify a layout that is not-null!");
this.layout = layout;
}

@Override
public boolean isCancelled() {
return cancelled;
}

@Override
public void setCancelled(boolean cancel) {
this.cancelled = cancel;
}

@Nonnull
public static HandlerList getHandlerList() {
return handlers;
}

@Nonnull
@Override
public HandlerList getHandlers() {
return getHandlerList();
}

}
package io.github.thebusybiscuit.slimefun4.api.events;

import javax.annotation.Nonnull;

import org.apache.commons.lang.Validate;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.bukkit.inventory.ItemStack;

import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideMode;

/**
* This {@link Event} is called whenever a {@link Player} tries to open the Slimefun Guide book.
*
* @author Linox
*
* @see SlimefunGuideMode
*/
public class SlimefunGuideOpenEvent extends Event implements Cancellable {

private static final HandlerList handlers = new HandlerList();

private final Player player;
private final ItemStack guide;
private SlimefunGuideMode layout;
private boolean cancelled;

public SlimefunGuideOpenEvent(@Nonnull Player p, @Nonnull ItemStack guide, @Nonnull SlimefunGuideMode layout) {
Validate.notNull(p, "The Player cannot be null");
Validate.notNull(guide, "Guide cannot be null");
Validate.notNull(layout, "Layout cannot be null");
this.player = p;
this.guide = guide;
this.layout = layout;
}

/**
* This returns the {@link Player} that tries to open
* the Slimefun Guide.
*
* @return The {@link Player}
*/
@Nonnull
public Player getPlayer() {
return player;
}

/**
* This returns the {@link ItemStack} that {@link Player}
* tries to open the Slimefun Guide with.
*
* @return The {@link ItemStack}
*/
@Nonnull
public ItemStack getGuide() {
return guide;
}

/**
* This returns the {@link SlimefunGuideMode} of the Slimefun Guide
* that {@link Player} tries to open.
*
* @return The {@link SlimefunGuideMode}
*/
@Nonnull
public SlimefunGuideMode getGuideLayout() {
return layout;
}

/**
* Changes the {@link SlimefunGuideMode} that was tried to be opened with.
*
* @param layout
* The new {@link SlimefunGuideMode}
*/
public void setGuideLayout(@Nonnull SlimefunGuideMode layout) {
Validate.notNull(layout, "You must specify a layout that is not-null!");
this.layout = layout;
}

@Override
public boolean isCancelled() {
return cancelled;
}

@Override
public void setCancelled(boolean cancel) {
this.cancelled = cancel;
}

@Nonnull
public static HandlerList getHandlerList() {
return handlers;
}

@Nonnull
@Override
public HandlerList getHandlers() {
return getHandlerList();
}

}
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
package io.github.thebusybiscuit.slimefun4.core.attributes;

import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDeathEvent;

import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType;
import io.github.thebusybiscuit.slimefun4.implementation.items.misc.BasicCircuitBoard;
import io.github.thebusybiscuit.slimefun4.implementation.listeners.entity.MobDropListener;

/**
* This interface, when attached to a {@link SlimefunItem}, provides an easy method for adding
* a % chance to drop for an {@link SlimefunItem} on {@link EntityDeathEvent}, this chance is 0-100
* and used in conjunction with the {@link RecipeType#MOB_DROP}.
*
* @author dNiym
*
* @see BasicCircuitBoard
* @see MobDropListener
* @see PiglinBarterDrop
*
*/
public interface RandomMobDrop extends ItemAttribute {

/**
* Implement this method to make the object have a variable chance of being
* added to the dropList when {@link EntityType} specified in
* the {@link RecipeType#MOB_DROP} is killed by the {@link Player}.
*
* @return The integer chance (0-100%) {@link SlimefunItem} has to drop.
*/
int getMobDropChance();

}
package io.github.thebusybiscuit.slimefun4.core.attributes;

import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDeathEvent;

import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType;
import io.github.thebusybiscuit.slimefun4.implementation.items.misc.BasicCircuitBoard;
import io.github.thebusybiscuit.slimefun4.implementation.listeners.entity.MobDropListener;

/**
* This interface, when attached to a {@link SlimefunItem}, provides an easy method for adding
* a % chance to drop for an {@link SlimefunItem} on {@link EntityDeathEvent}, this chance is 0-100
* and used in conjunction with the {@link RecipeType#MOB_DROP}.
*
* @author dNiym
*
* @see BasicCircuitBoard
* @see MobDropListener
* @see PiglinBarterDrop
*
*/
public interface RandomMobDrop extends ItemAttribute {

/**
* Implement this method to make the object have a variable chance of being
* added to the dropList when {@link EntityType} specified in
* the {@link RecipeType#MOB_DROP} is killed by the {@link Player}.
*
* @return The integer chance (0-100%) {@link SlimefunItem} has to drop.
*/
int getMobDropChance();

}
Loading

0 comments on commit 2a11aa6

Please sign in to comment.