changed way to unlock Quarz Recipe
This commit is contained in:
1 parent
d08fd927dc
commit
d03a21d460
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;
|
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);
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-3
@@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user