Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
3882f64289
2 files changed
+11
-9
No files matched your search
+1
-6
@@ -14,7 +14,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
public class QuarzRecipe extends Appliance {
|
||||
private NamespacedKey recipeKey;
|
||||
protected NamespacedKey recipeKey;
|
||||
@Override
|
||||
public void onEnable() {
|
||||
this.recipeKey = new NamespacedKey(Main.instance(), "quarz_block_to_quarz");
|
||||
@@ -26,11 +26,6 @@ public class QuarzRecipe extends Appliance {
|
||||
Bukkit.getOnlinePlayers().forEach(this::unlock);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
Bukkit.removeRecipe(this.recipeKey);
|
||||
}
|
||||
|
||||
public void unlock(Player player) {
|
||||
player.discoverRecipe(this.recipeKey);
|
||||
}
|
||||
|
||||
+10
-3
@@ -1,12 +1,19 @@
|
||||
package eu.mhsl.craftattack.spawn.craftattack.appliances.gameplay.quarzRecipe;
|
||||
|
||||
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.player.PlayerJoinEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
class QuarzRecipeListener extends ApplianceListener<QuarzRecipe> {
|
||||
@EventHandler
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
this.getAppliance().unlock(event.getPlayer());
|
||||
public void shouldDiscover(PlayerInventorySlotChangeEvent event) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user