mirror of
https://github.com/Morpheus-nox/NoOre-Plugin.git
synced 2026-02-04 05:10:15 +00:00
Add files via upload
This commit is contained in:
60
NoOreChunkListener.java
Normal file
60
NoOreChunkListener.java
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
package com.morpheus.noore;
|
||||||
|
|
||||||
|
import org.bukkit.Chunk;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.world.ChunkLoadEvent;
|
||||||
|
|
||||||
|
import java.util.EnumSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
public class NoOreChunkListener implements Listener {
|
||||||
|
|
||||||
|
private static final Set<Material> ORES_TO_REMOVE = EnumSet.of(
|
||||||
|
Material.COAL_ORE,
|
||||||
|
Material.IRON_ORE,
|
||||||
|
Material.COPPER_ORE,
|
||||||
|
Material.GOLD_ORE,
|
||||||
|
Material.REDSTONE_ORE,
|
||||||
|
Material.LAPIS_ORE,
|
||||||
|
Material.DIAMOND_ORE,
|
||||||
|
Material.EMERALD_ORE,
|
||||||
|
Material.DEEPSLATE_COAL_ORE,
|
||||||
|
Material.DEEPSLATE_IRON_ORE,
|
||||||
|
Material.DEEPSLATE_COPPER_ORE,
|
||||||
|
Material.DEEPSLATE_GOLD_ORE,
|
||||||
|
Material.DEEPSLATE_REDSTONE_ORE,
|
||||||
|
Material.DEEPSLATE_LAPIS_ORE,
|
||||||
|
Material.DEEPSLATE_DIAMOND_ORE,
|
||||||
|
Material.DEEPSLATE_EMERALD_ORE,
|
||||||
|
Material.NETHER_QUARTZ_ORE,
|
||||||
|
Material.NETHER_GOLD_ORE,
|
||||||
|
Material.ANCIENT_DEBRIS
|
||||||
|
);
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onChunkLoad(ChunkLoadEvent event) {
|
||||||
|
// Só processa chunks recém-gerados
|
||||||
|
if (!event.isNewChunk()) return;
|
||||||
|
|
||||||
|
Chunk chunk = event.getChunk();
|
||||||
|
World world = chunk.getWorld();
|
||||||
|
|
||||||
|
final int minY = world.getMinHeight();
|
||||||
|
final int maxY = world.getMaxHeight();
|
||||||
|
|
||||||
|
for (int x = 0; x < 16; x++) {
|
||||||
|
for (int z = 0; z < 16; z++) {
|
||||||
|
for (int y = minY; y < maxY; y++) {
|
||||||
|
Block block = chunk.getBlock(x, y, z);
|
||||||
|
if (ORES_TO_REMOVE.contains(block.getType())) {
|
||||||
|
block.setType(Material.STONE, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
35
NoOreGenPlugin.java
Normal file
35
NoOreGenPlugin.java
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
package com.morpheus.noore;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
public class NoOreGenPlugin extends JavaPlugin implements Listener {
|
||||||
|
|
||||||
|
private final NoOrePopulator populator = new NoOrePopulator();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onEnable() {
|
||||||
|
// Adiciona o populator aos mundos já carregados
|
||||||
|
for (World world : Bukkit.getWorlds()) {
|
||||||
|
addPopulatorToWorld(world);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Registra eventos (opcional para futuramente lidar com ChunkLoadEvent)
|
||||||
|
Bukkit.getPluginManager().registerEvents(new NoOreChunkListener(), this);
|
||||||
|
|
||||||
|
getLogger().info("§aNoOreGen ativado! Minérios não serão mais gerados em novos chunks.");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addPopulatorToWorld(World world) {
|
||||||
|
if (!world.getPopulators().contains(populator)) {
|
||||||
|
world.getPopulators().add(populator);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDisable() {
|
||||||
|
getLogger().info("§cNoOreGen desativado.");
|
||||||
|
}
|
||||||
|
}
|
||||||
53
NoOrePopulator.java
Normal file
53
NoOrePopulator.java
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
package com.morpheus.noore;
|
||||||
|
|
||||||
|
import org.bukkit.Chunk;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.generator.BlockPopulator;
|
||||||
|
|
||||||
|
import java.util.EnumSet;
|
||||||
|
import java.util.Random;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
public class NoOrePopulator extends BlockPopulator {
|
||||||
|
|
||||||
|
private static final Set<Material> ORES_TO_REMOVE = EnumSet.of(
|
||||||
|
Material.COAL_ORE,
|
||||||
|
Material.IRON_ORE,
|
||||||
|
Material.COPPER_ORE,
|
||||||
|
Material.GOLD_ORE,
|
||||||
|
Material.REDSTONE_ORE,
|
||||||
|
Material.LAPIS_ORE,
|
||||||
|
Material.DIAMOND_ORE,
|
||||||
|
Material.EMERALD_ORE,
|
||||||
|
Material.DEEPSLATE_COAL_ORE,
|
||||||
|
Material.DEEPSLATE_IRON_ORE,
|
||||||
|
Material.DEEPSLATE_COPPER_ORE,
|
||||||
|
Material.DEEPSLATE_GOLD_ORE,
|
||||||
|
Material.DEEPSLATE_REDSTONE_ORE,
|
||||||
|
Material.DEEPSLATE_LAPIS_ORE,
|
||||||
|
Material.DEEPSLATE_DIAMOND_ORE,
|
||||||
|
Material.DEEPSLATE_EMERALD_ORE,
|
||||||
|
Material.NETHER_QUARTZ_ORE,
|
||||||
|
Material.NETHER_GOLD_ORE,
|
||||||
|
Material.ANCIENT_DEBRIS
|
||||||
|
);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void populate(World world, Random random, Chunk chunk) {
|
||||||
|
final int minY = world.getMinHeight();
|
||||||
|
final int maxY = world.getMaxHeight();
|
||||||
|
|
||||||
|
for (int x = 0; x < 16; x++) {
|
||||||
|
for (int z = 0; z < 16; z++) {
|
||||||
|
for (int y = minY; y < maxY; y++) {
|
||||||
|
Block block = chunk.getBlock(x, y, z);
|
||||||
|
if (ORES_TO_REMOVE.contains(block.getType())) {
|
||||||
|
block.setType(Material.STONE, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
6
plugin.yml
Normal file
6
plugin.yml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
name: NoOreGen
|
||||||
|
version: 1.1
|
||||||
|
main: com.morpheus.noore.NoOreGenPlugin
|
||||||
|
api-version: 1.20
|
||||||
|
author: Morpheus
|
||||||
|
description: Remove a geração de minérios em novos chunks.
|
||||||
Reference in New Issue
Block a user