Merge remote-tracking branch 'origin/master'

This commit is contained in:
MineTec committed 2026-10-15 23:40:25 +02:00
commit 3882f64289
2 files changed
+11 -9

No files matched your search

@@ -14,7 +14,7 @@ import org.jetbrains.annotations.NotNull;
import java.util.List; import java.util.List;
public class QuarzRecipe extends Appliance { public class QuarzRecipe extends Appliance {
private NamespacedKey recipeKey; protected NamespacedKey recipeKey;
@Override @Override
public void onEnable() { public void onEnable() {
this.recipeKey = new NamespacedKey(Main.instance(), "quarz_block_to_quarz"); this.recipeKey = new NamespacedKey(Main.instance(), "quarz_block_to_quarz");
@@ -26,11 +26,6 @@ public class QuarzRecipe extends Appliance {
Bukkit.getOnlinePlayers().forEach(this::unlock); Bukkit.getOnlinePlayers().forEach(this::unlock);
} }
@Override
public void onDisable() {
Bukkit.removeRecipe(this.recipeKey);
}
public void unlock(Player player) { public void unlock(Player player) {
player.discoverRecipe(this.recipeKey); player.discoverRecipe(this.recipeKey);
} }
@@ -1,12 +1,19 @@
package eu.mhsl.craftattack.spawn.craftattack.appliances.gameplay.quarzRecipe; package eu.mhsl.craftattack.spawn.craftattack.appliances.gameplay.quarzRecipe;
import eu.mhsl.craftattack.spawn.core.appliance.ApplianceListener; import eu.mhsl.craftattack.spawn.core.appliance.ApplianceListener;
import io.papermc.paper.event.player.PlayerInventorySlotChangeEvent;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.inventory.ItemStack;
class QuarzRecipeListener extends ApplianceListener<QuarzRecipe> { class QuarzRecipeListener extends ApplianceListener<QuarzRecipe> {
@EventHandler @EventHandler
public void onPlayerJoin(PlayerJoinEvent event) { public void shouldDiscover(PlayerInventorySlotChangeEvent event) {
this.getAppliance().unlock(event.getPlayer()); ItemStack clickedItem = event.getNewItemStack();
Player player = event.getPlayer();
if(clickedItem.getType() != Material.QUARTZ_BLOCK) return;
if(player.hasDiscoveredRecipe(this.getAppliance().recipeKey)) return;
this.getAppliance().unlock(player);
} }
} }