diff --git a/pom.xml b/pom.xml index bff5025c0..3f19184e5 100644 --- a/pom.xml +++ b/pom.xml @@ -73,10 +73,10 @@ 42.2.18 5.0.1 - 1.20.5-R0.1-SNAPSHOT + 1.20.6-R0.1-SNAPSHOT - 1.20.4-R0.1-SNAPSHOT + 1.20.6-R0.1-SNAPSHOT 3.0.0 1.7.1 2.10.9 diff --git a/src/main/java/world/bentobox/bentobox/BentoBox.java b/src/main/java/world/bentobox/bentobox/BentoBox.java index 21b7d9628..c4ce1ddb9 100644 --- a/src/main/java/world/bentobox/bentobox/BentoBox.java +++ b/src/main/java/world/bentobox/bentobox/BentoBox.java @@ -38,6 +38,7 @@ import world.bentobox.bentobox.listeners.DeathListener; import world.bentobox.bentobox.listeners.JoinLeaveListener; import world.bentobox.bentobox.listeners.PanelListenerManager; import world.bentobox.bentobox.listeners.PrimaryIslandListener; +import world.bentobox.bentobox.listeners.SeedWorldMakerListener; import world.bentobox.bentobox.listeners.StandardSpawnProtectionListener; import world.bentobox.bentobox.listeners.teleports.EntityTeleportListener; import world.bentobox.bentobox.listeners.teleports.PlayerTeleportListener; @@ -313,6 +314,8 @@ public class BentoBox extends JavaPlugin implements Listener { manager.registerEvents(islandDeletionManager, this); // Primary Island Listener manager.registerEvents(new PrimaryIslandListener(this), this); + // Seed world chunk generator + manager.registerEvents(new SeedWorldMakerListener(this), this); } @Override diff --git a/src/main/java/world/bentobox/bentobox/api/panels/PanelItem.java b/src/main/java/world/bentobox/bentobox/api/panels/PanelItem.java index 41d5bab66..589e936d2 100644 --- a/src/main/java/world/bentobox/bentobox/api/panels/PanelItem.java +++ b/src/main/java/world/bentobox/bentobox/api/panels/PanelItem.java @@ -133,9 +133,9 @@ public class PanelItem { } if (meta != null) { if (glow) { - meta.addEnchant(Enchantment.POWER, 0, glow); + meta.addEnchant(Enchantment.LURE, 0, glow); } else { - meta.removeEnchant(Enchantment.POWER); + meta.removeEnchant(Enchantment.LURE); } icon.setItemMeta(meta); diff --git a/src/main/java/world/bentobox/bentobox/api/user/User.java b/src/main/java/world/bentobox/bentobox/api/user/User.java index 41e9601ea..60d9ac37c 100644 --- a/src/main/java/world/bentobox/bentobox/api/user/User.java +++ b/src/main/java/world/bentobox/bentobox/api/user/User.java @@ -67,17 +67,21 @@ public class User implements MetaDataAble { Map> v = new EnumMap<>(Particle.class); v.put(Enums.getIfPresent(Particle.class, "DUST") .or(Enums.getIfPresent(Particle.class, "REDSTONE").or(Particle.FLAME)), Particle.DustOptions.class); - v.put(Particle.ITEM, ItemStack.class); - v.put(Particle.ITEM_COBWEB, ItemStack.class); + if (Enums.getIfPresent(Particle.class, "ITEM").isPresent()) { + // 1.20.6 Particles + v.put(Particle.ITEM, ItemStack.class); + v.put(Particle.ITEM_COBWEB, ItemStack.class); + v.put(Particle.BLOCK, BlockData.class); + v.put(Particle.DUST_PILLAR, BlockData.class); + v.put(Particle.ENTITY_EFFECT, Color.class); + } v.put(Particle.FALLING_DUST, BlockData.class); - v.put(Particle.BLOCK, BlockData.class); v.put(Particle.BLOCK_MARKER, BlockData.class); v.put(Particle.DUST_COLOR_TRANSITION, DustTransition.class); - v.put(Particle.DUST_PILLAR, BlockData.class); v.put(Particle.VIBRATION, Vibration.class); v.put(Particle.SCULK_CHARGE, Float.class); v.put(Particle.SHRIEK, Integer.class); - v.put(Particle.ENTITY_EFFECT, Color.class); + VALIDATION_CHECK = Collections.unmodifiableMap(v); } @@ -732,7 +736,8 @@ public class User implements MetaDataAble { // Check if this particle is beyond the viewing distance of the server if (this.player != null && this.player.getLocation().toVector().distanceSquared(new Vector(x, y, z)) < (Bukkit.getServer().getViewDistance() * 256 * Bukkit.getServer().getViewDistance())) { - if (particle.equals(Particle.DUST)) { + if (particle.equals(Enums.getIfPresent(Particle.class, "DUST") + .or(Enums.getIfPresent(Particle.class, "REDSTONE").or(Particle.FLAME)))) { player.spawnParticle(particle, x, y, z, 1, 0, 0, 0, 1, dustOptions); } else if (dustOptions != null) { player.spawnParticle(particle, x, y, z, 1, dustOptions); diff --git a/src/main/java/world/bentobox/bentobox/hooks/LangUtilsHook.java b/src/main/java/world/bentobox/bentobox/hooks/LangUtilsHook.java index d1161d574..a4cde55e5 100644 --- a/src/main/java/world/bentobox/bentobox/hooks/LangUtilsHook.java +++ b/src/main/java/world/bentobox/bentobox/hooks/LangUtilsHook.java @@ -24,6 +24,7 @@ import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionType; import org.jetbrains.annotations.Nullable; +import com.google.common.base.Enums; import com.meowj.langutils.lang.LanguageHelper; import world.bentobox.bentobox.BentoBox; @@ -286,10 +287,6 @@ public class LangUtilsHook extends Hook { case LUCK -> "Potion of Luck"; case TURTLE_MASTER -> "Potion of the Turtle Master"; case SLOW_FALLING -> "Potion of Slow Falling"; - case HARMING -> "Potion of Harming"; - case HEALING -> "Potion of Healing"; - case INFESTED -> "Infested Potion"; - case LEAPING -> "Potion of Leaping"; case LONG_FIRE_RESISTANCE -> "Potion of Long Fire Resistance"; case LONG_INVISIBILITY -> "Potion of Long Invisibility"; case LONG_NIGHT_VISION -> "Potion of Long Night Vision"; @@ -302,8 +299,6 @@ public class LangUtilsHook extends Hook { case LONG_TURTLE_MASTER -> "Potion of Long Turtle Master"; case LONG_WATER_BREATHING -> "Potion of Long Water Breathing"; case LONG_WEAKNESS -> "Potion of Long Weakness"; - case OOZING -> "Potion of Oozing"; - case REGENERATION -> "Potion of Regeneration"; case STRONG_HARMING -> "Potion of Strong Harming"; case STRONG_HEALING -> "Potion of Strong Healing"; case STRONG_LEAPING -> "Potion of Strong Leaping"; @@ -313,10 +308,7 @@ public class LangUtilsHook extends Hook { case STRONG_STRENGTH -> "Potion of Strong Strength"; case STRONG_SWIFTNESS -> "Potion of Swiftness"; case STRONG_TURTLE_MASTER -> "Potion of Strong Turtle Master"; - case SWIFTNESS -> "Potion of Swiftness"; - case WEAVING -> "Potion of Weaving"; - case WIND_CHARGED -> "Potion of Wind Charged"; - default -> "Potion (Unknown)"; + default -> "Potion of " + Util.prettifyText(potionType.name()); }; } diff --git a/src/main/java/world/bentobox/bentobox/listeners/SeedWorldMakerListener.java b/src/main/java/world/bentobox/bentobox/listeners/SeedWorldMakerListener.java new file mode 100644 index 000000000..72e42adae --- /dev/null +++ b/src/main/java/world/bentobox/bentobox/listeners/SeedWorldMakerListener.java @@ -0,0 +1,59 @@ +package world.bentobox.bentobox.listeners; + +import org.bukkit.Bukkit; +import org.bukkit.World; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.world.ChunkLoadEvent; + +import world.bentobox.bentobox.BentoBox; +import world.bentobox.bentobox.api.addons.GameModeAddon; +import world.bentobox.bentobox.api.events.BentoBoxReadyEvent; +import world.bentobox.bentobox.util.Util; + +/** + * Updates chunks in seed worlds if they have been generated in the main world + * @author tastybento + */ +public class SeedWorldMakerListener implements Listener { + + private final BentoBox plugin; + + /** + * Whether BentoBox is ready or not. + * This helps to avoid hanging out the server on startup as a lot of {@link ChunkLoadEvent} are called at this time. + * @since 1.1 + */ + private boolean ready; + + + public SeedWorldMakerListener(BentoBox bentoBox) { + this.plugin = bentoBox; + } + + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) + public void onBentoBoxReady(BentoBoxReadyEvent e) { + ready = true; + } + + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) + public void onChunkLoad(ChunkLoadEvent e) { + if (!ready || !e.getChunk().isGenerated()) { + return; + } + World world = e.getWorld(); + plugin.getIWM().getAddon(world).filter(GameModeAddon::isUsesNewChunkGeneration).ifPresent(gma -> { + World seed = Bukkit.getWorld(world.getName() + "/bentobox"); + int x = e.getChunk().getX(); + int z = e.getChunk().getZ(); + if (seed != null && !seed.getChunkAt(x, z, false).isGenerated()) { + Util.getChunkAtAsync(seed, x, z, true); + } + }); + + } + + + +} diff --git a/src/main/java/world/bentobox/bentobox/nms/CopyWorldRegenerator.java b/src/main/java/world/bentobox/bentobox/nms/CopyWorldRegenerator.java index 458d0d087..9fb49d34b 100644 --- a/src/main/java/world/bentobox/bentobox/nms/CopyWorldRegenerator.java +++ b/src/main/java/world/bentobox/bentobox/nms/CopyWorldRegenerator.java @@ -46,6 +46,7 @@ import world.bentobox.bentobox.database.objects.IslandDeletion; import world.bentobox.bentobox.hooks.ItemsAdderHook; import world.bentobox.bentobox.hooks.SlimefunHook; import world.bentobox.bentobox.util.MyBiomeGrid; +import world.bentobox.bentobox.util.Util; /** * Regenerates by using a seed world. The seed world is created using the same generator as the game @@ -101,7 +102,10 @@ public abstract class CopyWorldRegenerator implements WorldRegenerator { } final int x = chunkX; final int z = chunkZ; - newTasks.add(regenerateChunk(di, world, x, z)); + // Only add chunks that are generated + if (world.getChunkAt(x, z, false).isGenerated()) { + newTasks.add(regenerateChunk(di, world, x, z)); + } chunkZ++; if (chunkZ > di.getMaxZChunk()) { chunkZ = di.getMinZChunk(); @@ -126,6 +130,11 @@ public abstract class CopyWorldRegenerator implements WorldRegenerator { private CompletableFuture regenerateChunk(@Nullable IslandDeletion di, @NonNull World world, int chunkX, int chunkZ) { + // Check if chunk has been generated + if (!world.getChunkAt(chunkX, chunkZ, false).isGenerated()) { + return CompletableFuture.completedFuture(null); + } + CompletableFuture seedWorldFuture = getSeedWorldChunk(world, chunkX, chunkZ); // Set up a future to get the chunk requests using Paper's Lib. If Paper is used, this should be done async diff --git a/src/main/java/world/bentobox/bentobox/util/ItemParser.java b/src/main/java/world/bentobox/bentobox/util/ItemParser.java index f294e829e..74d46638d 100644 --- a/src/main/java/world/bentobox/bentobox/util/ItemParser.java +++ b/src/main/java/world/bentobox/bentobox/util/ItemParser.java @@ -344,7 +344,8 @@ public class ItemParser { PatternType pt = Enums.getIfPresent(PatternType.class, part[i]).orNull(); if (pt == null) { // Try to convert old to new - if (part[i].trim().equals("STRIPE_SMALL")) { + if (part[i].trim().equals("STRIPE_SMALL") + && Enums.getIfPresent(PatternType.class, "SMALL_STRIPES").isPresent()) { pt = PatternType.SMALL_STRIPES; } } diff --git a/src/main/java/world/bentobox/bentobox/util/Util.java b/src/main/java/world/bentobox/bentobox/util/Util.java index 74f253bed..96632f666 100644 --- a/src/main/java/world/bentobox/bentobox/util/Util.java +++ b/src/main/java/world/bentobox/bentobox/util/Util.java @@ -748,6 +748,7 @@ public class Util { String serverPackageName = Bukkit.getServer().getClass().getPackage().getName(); String pluginPackageName = plugin.getClass().getPackage().getName(); String version = serverPackageName.substring(serverPackageName.lastIndexOf('.') + 1); + BentoBox.getInstance().log("Optimizing for " + version); PasteHandler handler; try { Class clazz = Class.forName(pluginPackageName + ".nms." + version + ".PasteHandlerImpl");