Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ This is the core concept and touches almost everything:

This is why first boot is extremely slow and RAM-hungry (see `README.md` warnings): the entire seed region is force-loaded up front. Any change to world generation, structure handling, or world naming must respect both worlds and the copy step in `Boxed.copyChunks()` / `createOverWorld()` / `createNether()`. The `generatorMaps` / `generatorMap` fields in `Boxed.java` route world names → generators for `getDefaultWorldGenerator` (used by Multiverse and similar world-management plugins) and for the hook in `allLoaded()` that calls `WorldManagementHook.registerWorld`.

`isUsesNewChunkGeneration()` returns `true`, which tells BentoBox this addon uses the modern chunk-generation API.

### Advancements drive box size

`AdvancementsManager` is the other key subsystem. Box growth is data-driven from `advancements.yml`: each advancement key maps to an integer "box growth" increment. `AdvancementListener` watches for player advancement events and asks the manager to update the island's protection-range. Per-island state lives in `objects/IslandAdvancements.java` (a BentoBox `DataObject` persisted via its database layer). `AdvancementsManager.save()` is called in `onDisable()` — any new cached state it holds should be flushed there too.
Expand Down
12 changes: 0 additions & 12 deletions src/main/java/world/bentobox/boxed/AdvancementsManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,6 @@ public AdvancementsManager(Boxed addon) {
addon.logError("advancements.yml cannot be found! " + e.getLocalizedMessage());
}
}
/*
// DEBUG - lists all advancements to console
int scoreTotal = 0;
Iterator<Advancement> ad = Bukkit.getServer().advancementIterator();
while (ad.hasNext()) {
Advancement a = ad.next();
int score = getScore(a);
BentoBox.getInstance().logDebug(" 'minecraft:" + a.getKey().getKey() + "': " + score);
scoreTotal += score;
}
BentoBox.getInstance().logDebug("Sum total = " + scoreTotal);
*/
}

/**
Expand Down
11 changes: 1 addition & 10 deletions src/main/java/world/bentobox/boxed/Boxed.java
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,7 @@ public void createWorlds() {
if (settings.isNetherGenerate()) {
createNether(worldName);
}
/*
// Make the end if it does not exist
if (settings.isEndGenerate()) {
//TODO
*/
// The End is not supported yet
}

private void createNether(String worldName) {
Expand Down Expand Up @@ -400,9 +396,4 @@ public void allLoaded() {
public AdvancementsManager getAdvManager() {
return advManager;
}

@Override
public boolean isUsesNewChunkGeneration() {
return true;
}
}
7 changes: 3 additions & 4 deletions src/main/java/world/bentobox/boxed/PlaceholdersManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,11 @@ public String getCount(User user) {
* @return string of advancement count
*/
public String getCountByLocation(User user) {
if (user != null && user.getUniqueId() != null && user.getLocation() != null) {
return addon.getIslands().getIslandAt(user.getLocation())
.map(i -> String.valueOf(addon.getAdvManager().getIsland(i).getAdvancements().size())).orElse("");
} else {
if (user == null || user.getUniqueId() == null) {
return "";
}
return addon.getIslands().getIslandAt(user.getLocation())
.map(i -> String.valueOf(addon.getAdvManager().getIsland(i).getAdvancements().size())).orElse("");
}


Expand Down
2 changes: 2 additions & 0 deletions src/main/java/world/bentobox/boxed/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -1777,6 +1777,7 @@ public void setIgnoreAdvancements(boolean ignoreAdvancements) {
/**
* @return the concurrentIslands
*/
@Override
public int getConcurrentIslands() {
if (concurrentIslands <= 0) {
return BentoBox.getInstance().getSettings().getIslandNumber();
Expand All @@ -1794,6 +1795,7 @@ public void setConcurrentIslands(int concurrentIslands) {
/**
* @return the disallowTeamMemberIslands
*/
@Override
public boolean isDisallowTeamMemberIslands() {
return disallowTeamMemberIslands;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.block.BlockState;
import org.bukkit.block.data.BlockData;
import org.bukkit.block.structure.Mirror;
import org.bukkit.block.structure.StructureRotation;
Expand Down Expand Up @@ -119,9 +118,7 @@ public boolean canExecute(User user, String label, List<String> args) {
}

// Next come the coordinates - there must be at least 3 of them
if ((!args.get(1).equals("~") && !Util.isInteger(args.get(1), true))
|| (!args.get(2).equals("~") && !Util.isInteger(args.get(2), true))
|| (!args.get(3).equals("~") && !Util.isInteger(args.get(3), true))) {
if (!isCoordinate(args.get(1)) || !isCoordinate(args.get(2)) || !isCoordinate(args.get(3))) {
user.sendMessage("boxed.commands.boxadmin.place.use-integers");
return false;
}
Expand All @@ -132,10 +129,7 @@ public boolean canExecute(User user, String label, List<String> args) {
}

// Handle rotation
sr = Enums.getIfPresent(StructureRotation.class, args.get(4).toUpperCase(Locale.ENGLISH)).orNull();
if (sr == null) {
user.sendMessage("boxed.commands.boxadmin.place.unknown-rotation");
Arrays.stream(StructureRotation.values()).map(StructureRotation::name).forEach(user::sendRawMessage);
if (!parseRotation(user, args.get(4))) {
return false;
}

Expand All @@ -144,24 +138,67 @@ public boolean canExecute(User user, String label, List<String> args) {
}

// Handle mirror
mirror = Enums.getIfPresent(Mirror.class, args.get(5).toUpperCase(Locale.ENGLISH)).orNull();
if (!parseMirror(user, args.get(5))) {
return false;
}

// Handle NO_MOBS
return args.size() < 7 || parseNoMobs(user, args.get(6));
}

/**
* @param arg command argument
* @return true if the argument is a relative marker (~) or an integer
*/
private static boolean isCoordinate(String arg) {
return arg.equals("~") || Util.isInteger(arg, true);
}

/**
* Parses the rotation argument into {@link #sr}
* @param user user to inform if the rotation is unknown
* @param arg rotation argument
* @return true if the rotation is valid
*/
private boolean parseRotation(User user, String arg) {
sr = Enums.getIfPresent(StructureRotation.class, arg.toUpperCase(Locale.ENGLISH)).orNull();
if (sr == null) {
user.sendMessage("boxed.commands.boxadmin.place.unknown-rotation");
Arrays.stream(StructureRotation.values()).map(StructureRotation::name).forEach(user::sendRawMessage);
return false;
}
return true;
}

/**
* Parses the mirror argument into {@link #mirror}
* @param user user to inform if the mirror is unknown
* @param arg mirror argument
* @return true if the mirror is valid
*/
private boolean parseMirror(User user, String arg) {
mirror = Enums.getIfPresent(Mirror.class, arg.toUpperCase(Locale.ENGLISH)).orNull();
if (mirror == null) {
user.sendMessage("boxed.commands.boxadmin.place.unknown-mirror");
Arrays.stream(Mirror.values()).map(Mirror::name).forEach(user::sendRawMessage);
return false;
}
return true;
}

if (args.size() == 7) {
if (args.get(6).toUpperCase(Locale.ENGLISH).equals("NO_MOBS")) {
noMobs = true;
} else {
user.sendMessage("boxed.commands.boxadmin.place.unknown", TextVariables.LABEL, args.get(6).toUpperCase(Locale.ENGLISH));
return false;
}
/**
* Parses the NO_MOBS argument into {@link #noMobs}
* @param user user to inform if the argument is unknown
* @param arg argument
* @return true if the argument is valid
*/
private boolean parseNoMobs(User user, String arg) {
if (arg.toUpperCase(Locale.ENGLISH).equals("NO_MOBS")) {
noMobs = true;
return true;
}

// Syntax is okay
return true;
user.sendMessage("boxed.commands.boxadmin.place.unknown", TextVariables.LABEL, arg.toUpperCase(Locale.ENGLISH));
return false;
}

@Override
Expand Down Expand Up @@ -193,7 +230,7 @@ public boolean execute(User user, String label, List<String> args) {
.removeJigsaw(new StructureRecord(tag.getKey(), tag.getKey(), spot, sr, mirror, noMobs, removedBlocks));
placedStructures.push(new StructureRecord(tag.getKey(), tag.getKey(), spot, sr, mirror, noMobs, removedBlocks)); // Track the placement

boolean result = saveStructure(spot, tag, user, sr, mirror);
boolean result = saveStructure(spot, tag, sr, mirror);
if (result) {
user.sendMessage("boxed.commands.boxadmin.place.saved");
} else {
Expand All @@ -202,7 +239,7 @@ public boolean execute(User user, String label, List<String> args) {
return result;
}

private boolean saveStructure(Location spot, NamespacedKey tag, User user, StructureRotation sr2, Mirror mirror2) {
private boolean saveStructure(Location spot, NamespacedKey tag, StructureRotation sr2, Mirror mirror2) {
return getAddon().getIslands().getIslandAt(spot).map(i -> {
int xx = spot.getBlockX() - i.getCenter().getBlockX();
int zz = spot.getBlockZ() - i.getCenter().getBlockZ();
Expand All @@ -218,8 +255,7 @@ private boolean saveStructure(Location spot, NamespacedKey tag, User user, Struc
config.set(spot.getWorld().getEnvironment().name().toLowerCase(Locale.ENGLISH) + "." + xx + "," + spot.getBlockY() + "," + zz, v.toString());
config.save(structures);
} catch (IOException | InvalidConfigurationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
getAddon().logError("Could not save structure to " + STRUCTURE_FILE + ": " + e.getMessage());
return false;
}
return true;
Expand Down Expand Up @@ -261,13 +297,13 @@ private boolean undoLastPlacement(User user) {
Collections.emptyList() // No entity transformers
);
lastRecord.removedBlocks().clear();
removeStructure(lastRecord.location(), tag, user); // Remove from config
removeStructure(lastRecord.location()); // Remove from config

user.sendMessage("boxed.commands.boxadmin.place.undo-success");
return true;
}

private boolean removeStructure(Location spot, NamespacedKey tag, User user) {
private boolean removeStructure(Location spot) {
return getAddon().getIslands().getIslandAt(spot).map(i -> {
int xx = spot.getBlockX() - i.getCenter().getBlockX();
int zz = spot.getBlockZ() - i.getCenter().getBlockZ();
Expand All @@ -282,7 +318,7 @@ private boolean removeStructure(Location spot, NamespacedKey tag, User user) {
return true;
}
} catch (IOException | InvalidConfigurationException e) {
e.printStackTrace();
getAddon().logError("Could not remove structure from " + STRUCTURE_FILE + ": " + e.getMessage());
}
return false;
}).orElse(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

import java.util.List;

import org.bukkit.Registry;
import org.bukkit.World.Environment;
import org.bukkit.block.Biome;
import org.bukkit.generator.BiomeProvider;
import org.bukkit.generator.WorldInfo;
import org.bukkit.util.Vector;
import org.eclipse.jdt.annotation.Nullable;

import io.papermc.paper.registry.RegistryAccess;
import io.papermc.paper.registry.RegistryKey;
import world.bentobox.bentobox.BentoBox;
import world.bentobox.boxed.Boxed;
import world.bentobox.boxed.generators.chunks.AbstractBoxedChunkGenerator;
Expand All @@ -27,19 +27,18 @@ public abstract class AbstractCopyBiomeProvider extends BiomeProvider {

protected final int dist;

protected AbstractCopyBiomeProvider(Boxed boxed, Environment env, Biome defaultBiome) {
protected AbstractCopyBiomeProvider(Boxed boxed, Biome defaultBiome) {
this.addon = boxed;
this.defaultBiome = defaultBiome;
dist = addon.getSettings().getIslandDistance();
}

@Override
public Biome getBiome(WorldInfo worldInfo, int x, int y, int z) {
int chunkX = x >> 4;
int chunkZ = z >> 4;
chunkX = AbstractBoxedChunkGenerator.repeatCalc(chunkX);
chunkZ = AbstractBoxedChunkGenerator.repeatCalc(chunkZ);
@Nullable ChunkStore c = addon.getChunkGenerator(worldInfo.getEnvironment()).getChunk(chunkX, chunkZ);
AbstractBoxedChunkGenerator gen = addon.getChunkGenerator(worldInfo.getEnvironment());
int chunkX = gen.repeatCalc(x >> 4);
int chunkZ = gen.repeatCalc(z >> 4);
@Nullable ChunkStore c = gen.getChunk(chunkX, chunkZ);

if (c != null) {
int xx = Math.floorMod(x, 16);
Expand All @@ -54,7 +53,7 @@ public Biome getBiome(WorldInfo worldInfo, int x, int y, int z) {
@Override
public List<Biome> getBiomes(WorldInfo worldInfo) {
// Return all of them for now!
return Registry.BIOME.stream().filter(b -> !b.equals(Biome.CUSTOM)).toList();
return RegistryAccess.registryAccess().getRegistry(RegistryKey.BIOME).stream().toList();
}

}
Loading
Loading