mirror of
https://github.com/Auxilor/EcoMobs.git
synced 2025-12-21 16:09:24 +00:00
Added discover-recipes
This commit is contained in:
@@ -9,6 +9,7 @@ import com.willfp.ecobosses.bosses.listeners.PassiveListeners;
|
||||
import com.willfp.ecobosses.bosses.listeners.SpawnListeners;
|
||||
import com.willfp.ecobosses.bosses.util.BossUtils;
|
||||
import com.willfp.ecobosses.commands.CommandEcobosses;
|
||||
import com.willfp.ecobosses.util.DiscoverRecipeListener;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
@@ -54,6 +55,7 @@ public class EcoBossesPlugin extends EcoPlugin {
|
||||
new AttackListeners(this),
|
||||
new DeathListeners(this),
|
||||
new SpawnListeners(this),
|
||||
new DiscoverRecipeListener(this),
|
||||
new PassiveListeners(this)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.willfp.ecobosses.util;
|
||||
|
||||
import com.willfp.eco.core.EcoPlugin;
|
||||
import com.willfp.eco.core.PluginDependent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.inventory.ShapedRecipe;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class DiscoverRecipeListener extends PluginDependent<EcoPlugin> implements Listener {
|
||||
/**
|
||||
* Register listener.
|
||||
*
|
||||
* @param plugin Talismans.
|
||||
*/
|
||||
public DiscoverRecipeListener(@NotNull final EcoPlugin plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unlock all recipes on player join.
|
||||
*
|
||||
* @param event The event to listen for.
|
||||
*/
|
||||
@EventHandler
|
||||
public void onJoin(@NotNull final PlayerJoinEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (this.getPlugin().getConfigYml().getBool("discover-recipes")) {
|
||||
Bukkit.getServer().recipeIterator().forEachRemaining(recipe -> {
|
||||
if (recipe instanceof ShapedRecipe) {
|
||||
NamespacedKey key = ((ShapedRecipe) recipe).getKey();
|
||||
if (key.getNamespace().equals("ecobosses")) {
|
||||
if (!key.getKey().contains("displayed")) {
|
||||
player.discoverRecipe(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,5 +4,6 @@
|
||||
#
|
||||
|
||||
bossbar-radius: 50 # How far away players should be able to see the boss bar for bosses.
|
||||
discover-recipes: true
|
||||
|
||||
# Read the wiki! https://ecobosses.willfp.com/
|
||||
Reference in New Issue
Block a user