mirror of
https://github.com/BentoBoxWorld/Boxed.git
synced 2025-03-02 03:31:10 +01:00
Bug fixes
Added better handling of aquatic elements. Avoid informing players of revoked achievements if the score is zero. Added the mangrove boat recipe to be ignored.
This commit is contained in:
parent
7d66ff19a2
commit
d1df71574a
@ -212,7 +212,12 @@ public class AdvancementsManager {
|
||||
|
||||
}
|
||||
|
||||
private int getScore(String string) {
|
||||
/**
|
||||
* Get the score for this advancement
|
||||
* @param key - advancement key as stored in the config file
|
||||
* @return score of advancement
|
||||
*/
|
||||
public int getScore(String string) {
|
||||
String adv = "advancements." + string;
|
||||
// Check score of advancement
|
||||
return !advConfig.contains(adv) && adv.endsWith("/root") ? advConfig.getInt("settings.default-root-increase") : advConfig.getInt(adv, this.unknownAdvChange);
|
||||
|
@ -188,13 +188,15 @@ public class Boxed extends GameModeAddon {
|
||||
int size = this.getSettings().getIslandDistance();
|
||||
double percent = size * 4 * size;
|
||||
int count = 0;
|
||||
int last = 0;
|
||||
for (int x = -size; x < size; x ++) {
|
||||
for (int z = -size; z < size; z++) {
|
||||
ChunkSnapshot chunk = seedWorld.getChunkAt(x, z).getChunkSnapshot(true, true, false);
|
||||
this.chunkGenerator.setChunk(chunk);
|
||||
count++;
|
||||
int p = (int) (count / percent * 100);
|
||||
if (p % 10 == 0) {
|
||||
if (p % 10 == 0 && p != last) {
|
||||
last = p;
|
||||
this.log("Storing seed chunks. " + p + "% done");
|
||||
}
|
||||
|
||||
|
@ -69,8 +69,8 @@ public class Settings implements WorldSettings {
|
||||
|
||||
@ConfigComment("World seed.")
|
||||
@ConfigComment("If you change this, stop the server and delete the worlds made.")
|
||||
@ConfigEntry(path = "world.seed", needsReset = true)
|
||||
private long seed = 978573758696L;
|
||||
@ConfigEntry(path = "world.generator.seed", needsReset = true)
|
||||
private long seed = 602103456450L;
|
||||
|
||||
@ConfigComment("World difficulty setting - PEACEFUL, EASY, NORMAL, HARD")
|
||||
@ConfigComment("Other plugins may override this setting")
|
||||
@ -78,28 +78,28 @@ public class Settings implements WorldSettings {
|
||||
private Difficulty difficulty = Difficulty.NORMAL;
|
||||
|
||||
@ConfigComment("Generate surface")
|
||||
@ConfigEntry(path = "world.generate-surface", needsRestart = true)
|
||||
@ConfigEntry(path = "world.generator.generate-surface", needsRestart = true)
|
||||
private boolean generateSurface = true;
|
||||
|
||||
@ConfigComment("Generate bedrock")
|
||||
@ConfigEntry(path = "world.generate-bedrock", needsRestart = true)
|
||||
@ConfigEntry(path = "world.generator.generate-bedrock", needsRestart = true)
|
||||
private boolean generateBedrock = true;
|
||||
|
||||
@ConfigComment("Generate caves")
|
||||
@ConfigEntry(path = "world.generate-caves", needsRestart = true)
|
||||
@ConfigEntry(path = "world.generator.generate-caves", needsRestart = true)
|
||||
private boolean generateCaves = true;
|
||||
|
||||
@ConfigComment("Generate Decorations")
|
||||
@ConfigEntry(path = "world.generate-decorations", needsRestart = true)
|
||||
@ConfigEntry(path = "world.generator.generate-decorations", needsRestart = true)
|
||||
private boolean generateDecorations = true;
|
||||
|
||||
@ConfigComment("Generate mobs")
|
||||
@ConfigEntry(path = "world.generate-mobs", needsRestart = true)
|
||||
@ConfigEntry(path = "world.generator.generate-mobs", needsRestart = true)
|
||||
private boolean generateMobs = true;
|
||||
|
||||
@ConfigComment("Allow surface structures - villages, shipwrecks, broken portals, etc.")
|
||||
@ConfigComment("These will be randomly placed, so may not be available for every player.")
|
||||
@ConfigEntry(path = "world.allow-structures", needsRestart = true)
|
||||
@ConfigEntry(path = "world.generator.allow-structures", needsRestart = true)
|
||||
private boolean allowStructures = true;
|
||||
|
||||
|
||||
@ -124,10 +124,14 @@ public class Settings implements WorldSettings {
|
||||
|
||||
@ConfigComment("Radius of player area in chunks. (So distance between player starting spots is twice this)")
|
||||
@ConfigComment("It is the same for every dimension : Overworld, Nether and End.")
|
||||
@ConfigComment("This value cannot be changed mid-game and the plugin will not start if it is different.")
|
||||
@ConfigEntry(path = "world.chunk-radius", needsReset = true)
|
||||
private int islandDistance = 10;
|
||||
|
||||
@ConfigComment("Space around each player area in chunks.")
|
||||
@ConfigComment("It is the same for every dimension : Overworld, Nether and End.")
|
||||
@ConfigEntry(path = "world.chunk-radius", needsReset = true)
|
||||
private int islandGap = 10;
|
||||
|
||||
@ConfigComment("Starting size of boxed spaces. This is a radius so 1 = a 2x2 area.")
|
||||
@ConfigComment("Admins can adjust via the /boxadmin range set <player> <new range> command")
|
||||
@ConfigEntry(path = "world.starting-protection-range")
|
||||
@ -1825,4 +1829,18 @@ public class Settings implements WorldSettings {
|
||||
public void setGenerateMobs(boolean generateMobs) {
|
||||
this.generateMobs = generateMobs;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the islandGap
|
||||
*/
|
||||
public int getIslandGap() {
|
||||
return islandGap;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param islandGap the islandGap to set
|
||||
*/
|
||||
public void setIslandGap(int islandGap) {
|
||||
this.islandGap = islandGap;
|
||||
}
|
||||
}
|
||||
|
@ -7,10 +7,12 @@ import java.util.Random;
|
||||
import org.bukkit.ChunkSnapshot;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.generator.BiomeProvider;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
import org.bukkit.generator.WorldInfo;
|
||||
|
||||
import world.bentobox.bentobox.BentoBox;
|
||||
import world.bentobox.bentobox.util.Pair;
|
||||
import world.bentobox.boxed.Boxed;
|
||||
|
||||
@ -82,27 +84,33 @@ public class BoxedChunkGenerator extends ChunkGenerator {
|
||||
Pair<Integer, Integer> coords = new Pair<>(xx, zz);
|
||||
if (!chunks.containsKey(coords)) {
|
||||
// This should never be needed because islands should abut each other
|
||||
//BentoBox.getInstance().logDebug("Water chunk: " + chunkX + "," + chunkZ);
|
||||
cd.setRegion(0, minY, 0, 16, 0, 16, Material.WATER);
|
||||
return;
|
||||
}
|
||||
//BentoBox.getInstance().logDebug("Copying chunk: " + xx + "," + zz);
|
||||
// Copy the chunk
|
||||
ChunkSnapshot chunk = chunks.get(coords);
|
||||
for (int x = 0; x < 16; x ++) {
|
||||
for (int z = 0; z < 16; z++) {
|
||||
for (int y = minY; y < height; y++) {
|
||||
Material m = chunk.getBlockType(x, y, z);
|
||||
|
||||
switch (m) {
|
||||
case WATER:
|
||||
case LAVA:
|
||||
case NETHERRACK:
|
||||
cd.setBlock(x, y, z, m);
|
||||
break;
|
||||
default:
|
||||
cd.setBlock(x, y, z, isGround(m) ? Material.STONE: Material.AIR);
|
||||
// Handle blocks that occur naturally in water
|
||||
if (isInWater(m)) {
|
||||
cd.setBlock(x, y, z, Material.WATER);
|
||||
} else {
|
||||
// Handle liquids and default blocks
|
||||
switch (m) {
|
||||
case WATER:
|
||||
case LAVA:
|
||||
case NETHERRACK:
|
||||
case STONE:
|
||||
case END_STONE:
|
||||
cd.setBlock(x, y, z, m);
|
||||
break;
|
||||
default:
|
||||
// Most other blocks
|
||||
cd.setBlock(x, y, z, isGround(m) ? Material.STONE: Material.AIR);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -115,6 +123,57 @@ public class BoxedChunkGenerator extends ChunkGenerator {
|
||||
return chunks;
|
||||
}
|
||||
|
||||
private static boolean isInWater(Material m) {
|
||||
switch (m) {
|
||||
// Underwater plants
|
||||
case KELP:
|
||||
case KELP_PLANT:
|
||||
case SEAGRASS:
|
||||
case BUBBLE_COLUMN:
|
||||
case BUBBLE_CORAL:
|
||||
case BUBBLE_CORAL_BLOCK:
|
||||
case BUBBLE_CORAL_FAN:
|
||||
case BUBBLE_CORAL_WALL_FAN:
|
||||
case DEAD_BRAIN_CORAL:
|
||||
case DEAD_BRAIN_CORAL_BLOCK:
|
||||
case DEAD_BRAIN_CORAL_FAN:
|
||||
case DEAD_BRAIN_CORAL_WALL_FAN:
|
||||
case DEAD_BUBBLE_CORAL:
|
||||
case DEAD_BUBBLE_CORAL_BLOCK:
|
||||
case DEAD_BUBBLE_CORAL_FAN:
|
||||
case DEAD_BUBBLE_CORAL_WALL_FAN:
|
||||
case DEAD_BUSH:
|
||||
case DEAD_FIRE_CORAL:
|
||||
case DEAD_FIRE_CORAL_BLOCK:
|
||||
case DEAD_FIRE_CORAL_FAN:
|
||||
case DEAD_FIRE_CORAL_WALL_FAN:
|
||||
case DEAD_HORN_CORAL:
|
||||
case DEAD_HORN_CORAL_BLOCK:
|
||||
case DEAD_HORN_CORAL_FAN:
|
||||
case DEAD_HORN_CORAL_WALL_FAN:
|
||||
case DEAD_TUBE_CORAL:
|
||||
case DEAD_TUBE_CORAL_BLOCK:
|
||||
case DEAD_TUBE_CORAL_FAN:
|
||||
case DEAD_TUBE_CORAL_WALL_FAN:
|
||||
case FIRE_CORAL:
|
||||
case FIRE_CORAL_BLOCK:
|
||||
case FIRE_CORAL_FAN:
|
||||
case FIRE_CORAL_WALL_FAN:
|
||||
case HORN_CORAL:
|
||||
case HORN_CORAL_BLOCK:
|
||||
case HORN_CORAL_FAN:
|
||||
case HORN_CORAL_WALL_FAN:
|
||||
case TUBE_CORAL:
|
||||
case TUBE_CORAL_BLOCK:
|
||||
case TUBE_CORAL_FAN:
|
||||
case TUBE_CORAL_WALL_FAN:
|
||||
case TALL_SEAGRASS:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static boolean isGround(Material m) {
|
||||
if (m.isAir() || m.isBurnable() || !m.isSolid()) return false;
|
||||
@ -266,6 +325,7 @@ public class BoxedChunkGenerator extends ChunkGenerator {
|
||||
case SMOOTH_RED_SANDSTONE:
|
||||
case SMOOTH_SANDSTONE:
|
||||
case SMOOTH_STONE:
|
||||
case TUFF:
|
||||
case WARPED_HYPHAE:
|
||||
case WARPED_NYLIUM:
|
||||
case WHITE_CONCRETE:
|
||||
|
@ -9,6 +9,7 @@ import java.util.Spliterators;
|
||||
import java.util.stream.StreamSupport;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.Server;
|
||||
@ -27,6 +28,7 @@ import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerPortalEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
|
||||
import world.bentobox.bentobox.BentoBox;
|
||||
import world.bentobox.bentobox.api.events.island.IslandNewIslandEvent;
|
||||
import world.bentobox.bentobox.api.events.team.TeamJoinedEvent;
|
||||
import world.bentobox.bentobox.api.events.team.TeamLeaveEvent;
|
||||
@ -71,14 +73,19 @@ public class AdvancementListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onAdvancement(PlayerAdvancementDoneEvent e) {
|
||||
// Ignore if player is not in survival
|
||||
if (!e.getPlayer().getGameMode().equals(GameMode.SURVIVAL)) {
|
||||
return;
|
||||
}
|
||||
if (Util.sameWorld(e.getPlayer().getWorld(), addon.getOverWorld())) {
|
||||
|
||||
// Only allow members or higher to get advancements in a box
|
||||
if (!addon.getIslands().getIslandAt(e.getPlayer().getLocation()).map(i -> i.getMemberSet().contains(e.getPlayer().getUniqueId())).orElse(false)) {
|
||||
// Remove advancement from player
|
||||
e.getAdvancement().getCriteria().forEach(c ->
|
||||
e.getPlayer().getAdvancementProgress(e.getAdvancement()).revokeCriteria(c));
|
||||
User u = User.getInstance(e.getPlayer());
|
||||
if (u != null) {
|
||||
if (u != null && addon.getAdvManager().getScore(e.getAdvancement().getKey().getKey()) > 0) {
|
||||
u.notify("boxed.adv-disallowed", TextVariables.NAME, e.getPlayer().getName(), TextVariables.DESCRIPTION, this.keyToString(u, e.getAdvancement().getKey()));
|
||||
}
|
||||
return;
|
||||
@ -153,7 +160,7 @@ public class AdvancementListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onPortal(PlayerPortalEvent e) {
|
||||
if (!Util.sameWorld(e.getPlayer().getWorld(), addon.getOverWorld())) {
|
||||
if (!Util.sameWorld(e.getPlayer().getWorld(), addon.getOverWorld()) || !e.getPlayer().getGameMode().equals(GameMode.SURVIVAL)) {
|
||||
return;
|
||||
}
|
||||
if (e.getCause().equals(TeleportCause.NETHER_PORTAL)) {
|
||||
|
@ -907,6 +907,7 @@ advancements:
|
||||
'minecraft:recipes/transportation/furnace_minecart': 0
|
||||
'minecraft:recipes/transportation/hopper_minecart': 0
|
||||
'minecraft:recipes/transportation/jungle_boat': 0
|
||||
'minecraft:recipes/transportation/mangrove_boat': 0
|
||||
'minecraft:recipes/transportation/minecart': 0
|
||||
'minecraft:recipes/transportation/oak_boat': 0
|
||||
'minecraft:recipes/transportation/powered_rail': 0
|
||||
|
Loading…
Reference in New Issue
Block a user