Javadoc
This commit is contained in:
@@ -158,6 +158,7 @@ public class TalismansPlugin extends AbstractEcoPlugin {
|
||||
return Arrays.asList(
|
||||
TalismansConfigs.class,
|
||||
TalismanChecks.class,
|
||||
TalismanChecks.class,
|
||||
Talismans.class
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,25 +1,53 @@
|
||||
package com.willfp.talismans.talismans.meta;
|
||||
|
||||
import com.willfp.eco.util.config.Configs;
|
||||
import com.willfp.eco.util.config.updating.annotations.ConfigUpdater;
|
||||
import lombok.Getter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public enum TalismanStrength {
|
||||
/**
|
||||
* Weakest.
|
||||
*/
|
||||
TALISMAN(() -> Configs.CONFIG.getString("strengths.talisman.color")),
|
||||
|
||||
/**
|
||||
* Middle.
|
||||
*/
|
||||
RING(() -> Configs.CONFIG.getString("strengths.ring.color")),
|
||||
|
||||
/**
|
||||
* Strongest.
|
||||
*/
|
||||
RELIC(() -> Configs.CONFIG.getString("strengths.relic.color"));
|
||||
|
||||
/**
|
||||
* The color.
|
||||
*/
|
||||
@Getter
|
||||
private String color;
|
||||
|
||||
/**
|
||||
* Supplier to get the color.
|
||||
*/
|
||||
private final Supplier<String> colorSupplier;
|
||||
|
||||
/**
|
||||
* Create a new strength.
|
||||
*
|
||||
* @param colorSupplier The color supplier.
|
||||
*/
|
||||
TalismanStrength(@NotNull final Supplier<String> colorSupplier) {
|
||||
this.colorSupplier = colorSupplier;
|
||||
this.color = colorSupplier.get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Update values.
|
||||
*/
|
||||
@ConfigUpdater
|
||||
public static void update() {
|
||||
for (TalismanStrength strength : TalismanStrength.values()) {
|
||||
strength.color = strength.colorSupplier.get();
|
||||
|
||||
@@ -6,6 +6,10 @@ import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class BlockPlaceListener implements Listener {
|
||||
/**
|
||||
* Called on block place.
|
||||
* @param event The event to listen for.
|
||||
*/
|
||||
@EventHandler
|
||||
public void onAttemptTalismanPlace(@NotNull final BlockPlaceEvent event) {
|
||||
if (TalismanChecks.getTalismanOnItem(event.getItemInHand()) != null) {
|
||||
|
||||
@@ -32,9 +32,24 @@ import java.util.UUID;
|
||||
|
||||
@UtilityClass
|
||||
public class TalismanChecks {
|
||||
/**
|
||||
* Cached talismans.
|
||||
*/
|
||||
public static final Map<UUID, Set<Talisman>> CACHED_TALISMANS = Collections.synchronizedMap(new HashMap<>());
|
||||
|
||||
/**
|
||||
* If ender chests should be checked.
|
||||
*/
|
||||
private static boolean readEnderChest = true;
|
||||
|
||||
/**
|
||||
* If shulker boxes should be read.
|
||||
*/
|
||||
private static boolean readShulkerBoxes = true;
|
||||
|
||||
/**
|
||||
* The associated plugin instance.
|
||||
*/
|
||||
private static final AbstractEcoPlugin PLUGIN = AbstractEcoPlugin.getInstance();
|
||||
|
||||
/**
|
||||
|
||||
@@ -15,6 +15,10 @@ import org.jetbrains.annotations.NotNull;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class TalismanCraftListener implements Listener {
|
||||
/**
|
||||
* Called on item craft.
|
||||
* @param event The event to listen for.
|
||||
*/
|
||||
@EventHandler
|
||||
public void onCraft(@NotNull final PrepareItemCraftEvent event) {
|
||||
if (!(event.getRecipe() instanceof ShapedRecipe)) {
|
||||
@@ -40,6 +44,10 @@ public class TalismanCraftListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called on item craft.
|
||||
* @param event The event to listen for.
|
||||
*/
|
||||
@EventHandler
|
||||
public void onCraft(@NotNull final CraftItemEvent event) {
|
||||
if (!(event.getRecipe() instanceof ShapedRecipe)) {
|
||||
@@ -66,6 +74,10 @@ public class TalismanCraftListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called on item craft.
|
||||
* @param event The event to listen for.
|
||||
*/
|
||||
@EventHandler
|
||||
public void prepareCraftTalismanListener(@NotNull final PrepareItemCraftEvent event) {
|
||||
if (!(event.getRecipe() instanceof ShapedRecipe)) {
|
||||
@@ -126,6 +138,10 @@ public class TalismanCraftListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called on item craft.
|
||||
* @param event The event to listen for.
|
||||
*/
|
||||
@EventHandler
|
||||
public void prepareCraftTalismanListener(@NotNull final CraftItemEvent event) {
|
||||
if (!(event.getRecipe() instanceof ShapedRecipe)) {
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
package com.willfp.talismans.talismans.util.equipevent;
|
||||
|
||||
public enum EquipType {
|
||||
/**
|
||||
* When a player equips a talisman.
|
||||
*/
|
||||
EQUIP,
|
||||
/**
|
||||
* When a player unequips a talisman.
|
||||
*/
|
||||
UNEQUIP
|
||||
}
|
||||
|
||||
@@ -8,6 +8,9 @@ import org.bukkit.event.player.PlayerEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class TalismanEquipEvent extends PlayerEvent {
|
||||
/**
|
||||
* Handler list.
|
||||
*/
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
/**
|
||||
|
||||
@@ -21,10 +21,20 @@ import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class TalismanEquipEventListeners extends PluginDependent implements Listener {
|
||||
/**
|
||||
* Initialize new listeners and link them to a plugin.
|
||||
*
|
||||
* @param plugin The plugin to link to.
|
||||
*/
|
||||
public TalismanEquipEventListeners(@NotNull final AbstractEcoPlugin plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called on item pickup.
|
||||
*
|
||||
* @param event The event to listen for.
|
||||
*/
|
||||
@EventHandler
|
||||
public void onItemPickup(@NotNull final EntityPickupItemEvent event) {
|
||||
if (!(event.getEntity() instanceof Player)) {
|
||||
@@ -38,16 +48,31 @@ public class TalismanEquipEventListeners extends PluginDependent implements List
|
||||
refreshPlayer((Player) event.getEntity());
|
||||
}
|
||||
|
||||
/**
|
||||
* Called on player join.
|
||||
*
|
||||
* @param event The event to listen for.
|
||||
*/
|
||||
@EventHandler
|
||||
public void onPlayerJoin(@NotNull final PlayerJoinEvent event) {
|
||||
refresh();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called on player leave.
|
||||
*
|
||||
* @param event The event to listen for.
|
||||
*/
|
||||
@EventHandler
|
||||
public void onPlayerLeave(@NotNull final PlayerQuitEvent event) {
|
||||
refresh();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called on item drop.
|
||||
*
|
||||
* @param event The event to listen for.
|
||||
*/
|
||||
@EventHandler
|
||||
public void onInventoryDrop(@NotNull final EntityDropItemEvent event) {
|
||||
if (!(event.getEntity() instanceof Player)) {
|
||||
@@ -61,6 +86,11 @@ public class TalismanEquipEventListeners extends PluginDependent implements List
|
||||
refreshPlayer((Player) event.getEntity());
|
||||
}
|
||||
|
||||
/**
|
||||
* Called on inventory click.
|
||||
*
|
||||
* @param event The event to listen for.
|
||||
*/
|
||||
@EventHandler
|
||||
public void onInventoryClick(@NotNull final InventoryClickEvent event) {
|
||||
if (!(event.getWhoClicked() instanceof Player)) {
|
||||
|
||||
Reference in New Issue
Block a user