mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-12-23 01:27:46 +01:00
2356 better deletion (#2364)
* Fix 1.20.4 backwards compatibility * Improve deletion speed and memory usage
This commit is contained in:
parent
83698c267f
commit
d288528a17
4
pom.xml
4
pom.xml
@ -73,10 +73,10 @@
|
||||
<postgresql.version>42.2.18</postgresql.version>
|
||||
<hikaricp.version>5.0.1</hikaricp.version>
|
||||
<!-- More visible way to change dependency versions -->
|
||||
<spigot.version>1.20.5-R0.1-SNAPSHOT</spigot.version>
|
||||
<spigot.version>1.20.6-R0.1-SNAPSHOT</spigot.version>
|
||||
<!-- Might differ from the last Spigot release for short periods
|
||||
of time -->
|
||||
<paper.version>1.20.4-R0.1-SNAPSHOT</paper.version>
|
||||
<paper.version>1.20.6-R0.1-SNAPSHOT</paper.version>
|
||||
<bstats.version>3.0.0</bstats.version>
|
||||
<vault.version>1.7.1</vault.version>
|
||||
<placeholderapi.version>2.10.9</placeholderapi.version>
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
||||
|
@ -67,17 +67,21 @@ public class User implements MetaDataAble {
|
||||
Map<Particle, Class<?>> 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);
|
||||
|
@ -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());
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -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<Void> 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<Chunk> 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
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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");
|
||||
|
Loading…
Reference in New Issue
Block a user