changed old gamerules to new and added quarz recipe

This commit is contained in:
jannis committed 2026-10-13 21:41:00 +02:00
1 parent 7d0a28b015
commit cf3fd2f38f
3 files changed
+63 -10

No files matched your search

@@ -0,0 +1,42 @@
package eu.mhsl.craftattack.spawn.craftattack.appliances.gameplay.quarzRecipe;
import eu.mhsl.craftattack.spawn.core.Main;
import eu.mhsl.craftattack.spawn.core.appliance.Appliance;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.ShapelessRecipe;
import org.jetbrains.annotations.NotNull;
import java.util.List;
public class QuarzRecipe extends Appliance {
private NamespacedKey recipeKey;
@Override
public void onEnable() {
this.recipeKey = new NamespacedKey(Main.instance(), "quarz_block_to_quarz");
ShapelessRecipe recipe = new ShapelessRecipe(this.recipeKey, new ItemStack(Material.QUARTZ, 4));
recipe.addIngredient(Material.QUARTZ_BLOCK);
Bukkit.addRecipe(recipe);
Bukkit.getOnlinePlayers().forEach(this::unlock);
}
@Override
public void onDisable() {
Bukkit.removeRecipe(this.recipeKey);
}
public void unlock(Player player) {
player.discoverRecipe(this.recipeKey);
}
@Override
protected @NotNull List<Listener> listeners() {
return List.of(new QuarzRecipeListener());
}
}
@@ -0,0 +1,12 @@
package eu.mhsl.craftattack.spawn.craftattack.appliances.gameplay.quarzRecipe;
import eu.mhsl.craftattack.spawn.core.appliance.ApplianceListener;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerJoinEvent;
public class QuarzRecipeListener extends ApplianceListener<QuarzRecipe> {
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
this.getAppliance().unlock(event.getPlayer());
}
}
@@ -58,16 +58,15 @@ public class ProjectStart extends Appliance {
); );
private final Map<GameRule<Boolean>, Boolean> gameRulesAfterStart = Map.ofEntries( private final Map<GameRule<Boolean>, Boolean> gameRulesAfterStart = Map.ofEntries(
entry(GameRule.DO_DAYLIGHT_CYCLE, true), entry(GameRules.ADVANCE_TIME, true),
entry(GameRule.DO_INSOMNIA, true), entry(GameRules.SPAWN_PHANTOMS, true),
entry(GameRule.DISABLE_RAIDS, false), entry(GameRules.RAIDS, true),
entry(GameRule.DO_FIRE_TICK, true), entry(GameRules.ENTITY_DROPS, true),
entry(GameRule.DO_ENTITY_DROPS, true), entry(GameRules.SPAWN_PATROLS, true),
entry(GameRule.DO_PATROL_SPAWNING, true), entry(GameRules.SPAWN_WANDERING_TRADERS, true),
entry(GameRule.DO_TRADER_SPAWNING, true), entry(GameRules.ADVANCE_WEATHER, true),
entry(GameRule.DO_WEATHER_CYCLE, true), entry(GameRules.FALL_DAMAGE, true),
entry(GameRule.FALL_DAMAGE, true), entry(GameRules.FIRE_DAMAGE, true)
entry(GameRule.FIRE_DAMAGE, true)
); );
public ProjectStart() { public ProjectStart() {