初始化提交

This commit is contained in:
2022-11-06 18:37:18 +08:00
commit 0a77aef84e
55 changed files with 3550 additions and 0 deletions

View File

@@ -0,0 +1,14 @@
version = '1.0.0'
setArchivesBaseName("HamsterOreRemove")
dependencies {
compileOnly 'org.spigotmc:spigot-api:1.19.2-R0.1-SNAPSHOT'
}
processResources {
inputs.property "version", project.version
filesMatching("plugin.yml") {
expand "version": project.version
}
duplicatesStrategy(DuplicatesStrategy.EXCLUDE)
}

View File

@@ -0,0 +1,121 @@
package cn.hamster3.mc.plugin.ore.remove;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.block.BlockState;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.world.WorldInitEvent;
import org.bukkit.generator.BlockPopulator;
import org.bukkit.generator.LimitedRegion;
import org.bukkit.generator.WorldInfo;
import org.bukkit.plugin.java.JavaPlugin;
import org.jetbrains.annotations.NotNull;
import java.util.Random;
public class OreRemovePlugin extends JavaPlugin implements Listener {
@Override
public void onEnable() {
Bukkit.getPluginManager().registerEvents(this, this);
}
@EventHandler(ignoreCancelled = true)
public void onWorldInit(WorldInitEvent event) {
event.getWorld().getPopulators().add(new BlockPopulator() {
@Override
public void populate(@NotNull WorldInfo worldInfo, @NotNull Random random, int chunkX, int chunkZ, @NotNull LimitedRegion limitedRegion) {
for (int x = 0; x < 16; x++) {
for (int y = -64; y < 255; y++) {
for (int z = 0; z < 16; z++) {
BlockState block = limitedRegion.getBlockState(x, y, z);
//noinspection EnhancedSwitchMigration
switch (block.getType()) {
case GRASS_BLOCK:
case DIRT: {
block.setType(Material.AIR);
break;
}
case COAL_ORE:
case COPPER_ORE:
case IRON_ORE:
case LAPIS_ORE:
case REDSTONE_ORE:
case GOLD_ORE:
case DIAMOND_ORE:
case EMERALD_ORE: {
block.setType(Material.STONE);
break;
}
case DEEPSLATE_COAL_ORE:
case DEEPSLATE_COPPER_ORE:
case DEEPSLATE_DIAMOND_ORE:
case DEEPSLATE_EMERALD_ORE:
case DEEPSLATE_GOLD_ORE:
case DEEPSLATE_IRON_ORE:
case DEEPSLATE_LAPIS_ORE:
case DEEPSLATE_REDSTONE_ORE: {
block.setType(Material.DEEPSLATE);
break;
}
case NETHER_GOLD_ORE:
case NETHER_QUARTZ_ORE: {
block.setType(Material.NETHERRACK);
break;
}
}
}
}
}
}
});
}
/*
@EventHandler(ignoreCancelled = true)
public void onChunkPopulate(ChunkPopulateEvent event) {
Chunk chunk = event.getChunk();
for (int x = 0; x < 16; x++) {
for (int y = -64; y < 255; y++) {
for (int z = 0; z < 16; z++) {
Block block = chunk.getBlock(x, y, z);
//noinspection EnhancedSwitchMigration
switch (block.getType()) {
case GRASS_BLOCK:
case DIRT: {
block.setType(Material.AIR);
break;
}
case COAL_ORE:
case COPPER_ORE:
case IRON_ORE:
case LAPIS_ORE:
case REDSTONE_ORE:
case GOLD_ORE:
case DIAMOND_ORE:
case EMERALD_ORE: {
block.setType(Material.STONE);
break;
}
case DEEPSLATE_COAL_ORE:
case DEEPSLATE_COPPER_ORE:
case DEEPSLATE_DIAMOND_ORE:
case DEEPSLATE_EMERALD_ORE:
case DEEPSLATE_GOLD_ORE:
case DEEPSLATE_IRON_ORE:
case DEEPSLATE_LAPIS_ORE:
case DEEPSLATE_REDSTONE_ORE: {
block.setType(Material.DEEPSLATE);
break;
}
case NETHER_GOLD_ORE:
case NETHER_QUARTZ_ORE: {
block.setType(Material.NETHERRACK);
break;
}
}
}
}
}
}
*/
}

View File

@@ -0,0 +1,4 @@
name: HamsterOreRemove
main: cn.hamster3.mc.plugin.ore.remove.OreRemovePlugin
version: ${version}
api-version: 1.13