mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-23 01:37:37 +00:00
Fix some adapter issues
regen 1.13, tile get npe, null block type values
This commit is contained in:
parent
4a4f5bcc74
commit
39faa740a2
@ -24,7 +24,6 @@ import com.boydti.fawe.bukkit.util.ItemUtil;
|
|||||||
import com.boydti.fawe.bukkit.util.VaultUtil;
|
import com.boydti.fawe.bukkit.util.VaultUtil;
|
||||||
import com.boydti.fawe.bukkit.util.image.BukkitImageViewer;
|
import com.boydti.fawe.bukkit.util.image.BukkitImageViewer;
|
||||||
import com.boydti.fawe.config.Settings;
|
import com.boydti.fawe.config.Settings;
|
||||||
import com.boydti.fawe.object.FaweCommand;
|
|
||||||
import com.boydti.fawe.regions.FaweMaskManager;
|
import com.boydti.fawe.regions.FaweMaskManager;
|
||||||
import com.boydti.fawe.util.Jars;
|
import com.boydti.fawe.util.Jars;
|
||||||
import com.boydti.fawe.util.TaskManager;
|
import com.boydti.fawe.util.TaskManager;
|
||||||
|
@ -82,6 +82,9 @@ public class BukkitGetBlocks_1_15 extends CharGetBlocks {
|
|||||||
@Override
|
@Override
|
||||||
public CompoundTag getTile(int x, int y, int z) {
|
public CompoundTag getTile(int x, int y, int z) {
|
||||||
TileEntity tileEntity = getChunk().getTileEntity(new BlockPosition((x & 15) + (X << 4), y, (z & 15) + (Z << 4)));
|
TileEntity tileEntity = getChunk().getTileEntity(new BlockPosition((x & 15) + (X << 4), y, (z & 15) + (Z << 4)));
|
||||||
|
if (tileEntity == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
return new LazyCompoundTag_1_15(Suppliers.memoize(() -> tileEntity.save(new NBTTagCompound())));
|
return new LazyCompoundTag_1_15(Suppliers.memoize(() -> tileEntity.save(new NBTTagCompound())));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -231,6 +231,17 @@ public interface BukkitImplAdapter<T> extends IBukkitAdapter {
|
|||||||
throw new UnsupportedOperationException("Cannot send fake chunks");
|
throw new UnsupportedOperationException("Cannot send fake chunks");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Regenerate a region in the given world, so it appears "as new".
|
||||||
|
* @param world the world to regen in
|
||||||
|
* @param region the region to regen
|
||||||
|
* @param session the session to use for setting blocks
|
||||||
|
* @return true on success, false on failure
|
||||||
|
*/
|
||||||
|
default boolean regenerate(org.bukkit.World world, Region region, EditSession session) {
|
||||||
|
return regenerate(world, region, null, null, session);
|
||||||
|
}
|
||||||
|
|
||||||
default boolean regenerate(org.bukkit.World world, Region region, @Nullable Long seed, @Nullable BiomeType biome, EditSession editSession) {
|
default boolean regenerate(org.bukkit.World world, Region region, @Nullable Long seed, @Nullable BiomeType biome, EditSession editSession) {
|
||||||
return editSession.regenerate(region);
|
return editSession.regenerate(region);
|
||||||
}
|
}
|
||||||
|
@ -71,13 +71,16 @@ import net.minecraft.server.v1_13_R2.IDataManager;
|
|||||||
import net.minecraft.server.v1_13_R2.IRegistry;
|
import net.minecraft.server.v1_13_R2.IRegistry;
|
||||||
import net.minecraft.server.v1_13_R2.ItemStack;
|
import net.minecraft.server.v1_13_R2.ItemStack;
|
||||||
import net.minecraft.server.v1_13_R2.MinecraftKey;
|
import net.minecraft.server.v1_13_R2.MinecraftKey;
|
||||||
|
import net.minecraft.server.v1_13_R2.MinecraftServer;
|
||||||
import net.minecraft.server.v1_13_R2.NBTBase;
|
import net.minecraft.server.v1_13_R2.NBTBase;
|
||||||
import net.minecraft.server.v1_13_R2.NBTTagCompound;
|
import net.minecraft.server.v1_13_R2.NBTTagCompound;
|
||||||
import net.minecraft.server.v1_13_R2.NBTTagInt;
|
import net.minecraft.server.v1_13_R2.NBTTagInt;
|
||||||
import net.minecraft.server.v1_13_R2.PacketPlayOutMapChunk;
|
import net.minecraft.server.v1_13_R2.PacketPlayOutMapChunk;
|
||||||
import net.minecraft.server.v1_13_R2.PlayerChunk;
|
import net.minecraft.server.v1_13_R2.PlayerChunk;
|
||||||
|
import net.minecraft.server.v1_13_R2.ServerNBTManager;
|
||||||
import net.minecraft.server.v1_13_R2.TileEntity;
|
import net.minecraft.server.v1_13_R2.TileEntity;
|
||||||
import net.minecraft.server.v1_13_R2.World;
|
import net.minecraft.server.v1_13_R2.World;
|
||||||
|
import net.minecraft.server.v1_13_R2.WorldData;
|
||||||
import net.minecraft.server.v1_13_R2.WorldNBTStorage;
|
import net.minecraft.server.v1_13_R2.WorldNBTStorage;
|
||||||
import net.minecraft.server.v1_13_R2.WorldServer;
|
import net.minecraft.server.v1_13_R2.WorldServer;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -102,6 +105,7 @@ import java.lang.reflect.Method;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.OptionalInt;
|
import java.util.OptionalInt;
|
||||||
|
import java.util.UUID;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.Future;
|
import java.util.concurrent.Future;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
@ -397,9 +401,13 @@ public final class FAWE_Spigot_v1_13_R2 extends CachedBukkitAdapter implements I
|
|||||||
// normally it should be deleted at the end of this method
|
// normally it should be deleted at the end of this method
|
||||||
saveFolder.deleteOnExit();
|
saveFolder.deleteOnExit();
|
||||||
try {
|
try {
|
||||||
CraftServer server = originalWorld.getServer();
|
MinecraftServer server = originalWorld.getServer().getServer();
|
||||||
IDataManager originalDataManager = originalWorld.getDataManager();
|
IDataManager originalDataManager = originalWorld.getDataManager();
|
||||||
WorldNBTStorage saveHandler = new WorldNBTStorage(saveFolder, originalDataManager.getDirectory().getName(), server.getServer(), originalDataManager.i());
|
ServerNBTManager saveHandler = new ServerNBTManager(saveFolder,
|
||||||
|
originalWorld.getDataManager().getDirectory().getName(), server, server.dataConverterManager);
|
||||||
|
WorldData newWorldData = new WorldData(originalWorld.worldData.a((NBTTagCompound) null),
|
||||||
|
server.dataConverterManager, getDataVersion(), null);
|
||||||
|
newWorldData.checkName(UUID.randomUUID().toString());
|
||||||
|
|
||||||
ChunkGenerator generator = world.getGenerator();
|
ChunkGenerator generator = world.getGenerator();
|
||||||
org.bukkit.World.Environment environment = world.getEnvironment();
|
org.bukkit.World.Environment environment = world.getEnvironment();
|
||||||
@ -413,10 +421,10 @@ public final class FAWE_Spigot_v1_13_R2 extends CachedBukkitAdapter implements I
|
|||||||
}
|
}
|
||||||
generator = null;
|
generator = null;
|
||||||
}
|
}
|
||||||
try (WorldServer freshWorld = new WorldServer(server.getServer(),
|
try (WorldServer freshWorld = new WorldServer(server,
|
||||||
saveHandler,
|
saveHandler,
|
||||||
originalWorld.worldMaps,
|
originalWorld.worldMaps,
|
||||||
originalWorld.worldData,
|
newWorldData,
|
||||||
originalWorld.worldProvider.getDimensionManager(),
|
originalWorld.worldProvider.getDimensionManager(),
|
||||||
originalWorld.methodProfiler,
|
originalWorld.methodProfiler,
|
||||||
environment,
|
environment,
|
||||||
|
@ -85,6 +85,7 @@ import net.minecraft.server.v1_14_R1.PacketPlayOutMapChunk;
|
|||||||
import net.minecraft.server.v1_14_R1.PlayerChunk;
|
import net.minecraft.server.v1_14_R1.PlayerChunk;
|
||||||
import net.minecraft.server.v1_14_R1.TileEntity;
|
import net.minecraft.server.v1_14_R1.TileEntity;
|
||||||
import net.minecraft.server.v1_14_R1.World;
|
import net.minecraft.server.v1_14_R1.World;
|
||||||
|
import net.minecraft.server.v1_14_R1.WorldData;
|
||||||
import net.minecraft.server.v1_14_R1.WorldNBTStorage;
|
import net.minecraft.server.v1_14_R1.WorldNBTStorage;
|
||||||
import net.minecraft.server.v1_14_R1.WorldServer;
|
import net.minecraft.server.v1_14_R1.WorldServer;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -400,10 +401,11 @@ public final class FAWE_Spigot_v1_14_R4 extends CachedBukkitAdapter implements I
|
|||||||
// normally it should be deleted at the end of this method
|
// normally it should be deleted at the end of this method
|
||||||
saveFolder.deleteOnExit();
|
saveFolder.deleteOnExit();
|
||||||
try {
|
try {
|
||||||
CraftServer server = originalWorld.getServer();
|
MinecraftServer server = originalWorld.getServer().getServer();
|
||||||
WorldNBTStorage originalDataManager = originalWorld.getDataManager();
|
WorldNBTStorage originalDataManager = originalWorld.getDataManager();
|
||||||
WorldNBTStorage saveHandler = new WorldNBTStorage(saveFolder, originalDataManager.getDirectory().getName(), server.getServer(), originalDataManager.getDataFixer());
|
WorldNBTStorage saveHandler = new WorldNBTStorage(saveFolder, originalDataManager.getDirectory().getName(), server, originalDataManager.getDataFixer());
|
||||||
ChunkGenerator originalGen = world.getGenerator();
|
WorldData newWorldData = new WorldData(originalWorld.worldData.a((NBTTagCompound) null),
|
||||||
|
server.dataConverterManager, getDataVersion(), null);
|
||||||
|
|
||||||
ChunkGenerator generator = world.getGenerator();
|
ChunkGenerator generator = world.getGenerator();
|
||||||
org.bukkit.World.Environment environment = world.getEnvironment();
|
org.bukkit.World.Environment environment = world.getEnvironment();
|
||||||
@ -417,12 +419,12 @@ public final class FAWE_Spigot_v1_14_R4 extends CachedBukkitAdapter implements I
|
|||||||
}
|
}
|
||||||
generator = null;
|
generator = null;
|
||||||
}
|
}
|
||||||
try (WorldServer freshWorld = new WorldServer(server.getServer(),
|
try (WorldServer freshWorld = new WorldServer(server,
|
||||||
server.getServer().executorService, saveHandler,
|
server.executorService, saveHandler,
|
||||||
originalWorld.worldData,
|
newWorldData,
|
||||||
originalWorld.worldProvider.getDimensionManager(),
|
originalWorld.worldProvider.getDimensionManager(),
|
||||||
originalWorld.getMethodProfiler(),
|
originalWorld.getMethodProfiler(),
|
||||||
server.getServer().worldLoadListenerFactory.create(11),
|
server.worldLoadListenerFactory.create(11),
|
||||||
environment,
|
environment,
|
||||||
generator)) {
|
generator)) {
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@ package com.sk89q.worldedit.bukkit.adapter.impl;
|
|||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import com.bekvon.bukkit.residence.commands.server;
|
||||||
import com.boydti.fawe.Fawe;
|
import com.boydti.fawe.Fawe;
|
||||||
import com.boydti.fawe.FaweCache;
|
import com.boydti.fawe.FaweCache;
|
||||||
import com.boydti.fawe.beta.IChunkGet;
|
import com.boydti.fawe.beta.IChunkGet;
|
||||||
@ -61,6 +62,7 @@ import java.io.File;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.OptionalInt;
|
import java.util.OptionalInt;
|
||||||
|
import java.util.UUID;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.Future;
|
import java.util.concurrent.Future;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
@ -80,6 +82,7 @@ import net.minecraft.server.v1_15_R1.IBlockData;
|
|||||||
import net.minecraft.server.v1_15_R1.IRegistry;
|
import net.minecraft.server.v1_15_R1.IRegistry;
|
||||||
import net.minecraft.server.v1_15_R1.ItemStack;
|
import net.minecraft.server.v1_15_R1.ItemStack;
|
||||||
import net.minecraft.server.v1_15_R1.MinecraftKey;
|
import net.minecraft.server.v1_15_R1.MinecraftKey;
|
||||||
|
import net.minecraft.server.v1_15_R1.MinecraftServer;
|
||||||
import net.minecraft.server.v1_15_R1.NBTBase;
|
import net.minecraft.server.v1_15_R1.NBTBase;
|
||||||
import net.minecraft.server.v1_15_R1.NBTTagCompound;
|
import net.minecraft.server.v1_15_R1.NBTTagCompound;
|
||||||
import net.minecraft.server.v1_15_R1.NBTTagInt;
|
import net.minecraft.server.v1_15_R1.NBTTagInt;
|
||||||
@ -87,6 +90,7 @@ import net.minecraft.server.v1_15_R1.PacketPlayOutMapChunk;
|
|||||||
import net.minecraft.server.v1_15_R1.PlayerChunk;
|
import net.minecraft.server.v1_15_R1.PlayerChunk;
|
||||||
import net.minecraft.server.v1_15_R1.TileEntity;
|
import net.minecraft.server.v1_15_R1.TileEntity;
|
||||||
import net.minecraft.server.v1_15_R1.World;
|
import net.minecraft.server.v1_15_R1.World;
|
||||||
|
import net.minecraft.server.v1_15_R1.WorldData;
|
||||||
import net.minecraft.server.v1_15_R1.WorldNBTStorage;
|
import net.minecraft.server.v1_15_R1.WorldNBTStorage;
|
||||||
import net.minecraft.server.v1_15_R1.WorldServer;
|
import net.minecraft.server.v1_15_R1.WorldServer;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -391,10 +395,12 @@ public final class FAWE_Spigot_v1_15_R1 extends CachedBukkitAdapter implements I
|
|||||||
// normally it should be deleted at the end of this method
|
// normally it should be deleted at the end of this method
|
||||||
saveFolder.deleteOnExit();
|
saveFolder.deleteOnExit();
|
||||||
try {
|
try {
|
||||||
CraftServer server = originalWorld.getServer();
|
MinecraftServer server = originalWorld.getServer().getServer();
|
||||||
WorldNBTStorage originalDataManager = originalWorld.getDataManager();
|
WorldNBTStorage originalDataManager = originalWorld.getDataManager();
|
||||||
WorldNBTStorage saveHandler = new WorldNBTStorage(saveFolder, originalDataManager.getDirectory().getName(), server.getServer(), originalDataManager.getDataFixer());
|
WorldNBTStorage saveHandler = new WorldNBTStorage(saveFolder, originalDataManager.getDirectory().getName(), server, originalDataManager.getDataFixer());
|
||||||
ChunkGenerator originalGen = world.getGenerator();
|
WorldData newWorldData = new WorldData(originalWorld.worldData.a((NBTTagCompound) null),
|
||||||
|
server.dataConverterManager, getDataVersion(), null);
|
||||||
|
newWorldData.setName(UUID.randomUUID().toString());
|
||||||
|
|
||||||
ChunkGenerator generator = world.getGenerator();
|
ChunkGenerator generator = world.getGenerator();
|
||||||
org.bukkit.World.Environment environment = world.getEnvironment();
|
org.bukkit.World.Environment environment = world.getEnvironment();
|
||||||
@ -408,12 +414,12 @@ public final class FAWE_Spigot_v1_15_R1 extends CachedBukkitAdapter implements I
|
|||||||
}
|
}
|
||||||
generator = null;
|
generator = null;
|
||||||
}
|
}
|
||||||
try (WorldServer freshWorld = new WorldServer(server.getServer(),
|
try (WorldServer freshWorld = new WorldServer(server,
|
||||||
server.getServer().executorService, saveHandler,
|
server.executorService, saveHandler,
|
||||||
originalWorld.worldData,
|
newWorldData,
|
||||||
originalWorld.worldProvider.getDimensionManager(),
|
originalWorld.worldProvider.getDimensionManager(),
|
||||||
originalWorld.getMethodProfiler(),
|
originalWorld.getMethodProfiler(),
|
||||||
server.getServer().worldLoadListenerFactory.create(11),
|
server.worldLoadListenerFactory.create(11),
|
||||||
environment,
|
environment,
|
||||||
generator)) {
|
generator)) {
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@ package com.boydti.fawe;
|
|||||||
|
|
||||||
import com.boydti.fawe.beta.implementation.queue.QueueHandler;
|
import com.boydti.fawe.beta.implementation.queue.QueueHandler;
|
||||||
import com.boydti.fawe.beta.implementation.cache.preloader.Preloader;
|
import com.boydti.fawe.beta.implementation.cache.preloader.Preloader;
|
||||||
import com.boydti.fawe.object.FaweCommand;
|
|
||||||
import com.boydti.fawe.regions.FaweMaskManager;
|
import com.boydti.fawe.regions.FaweMaskManager;
|
||||||
import com.boydti.fawe.util.TaskManager;
|
import com.boydti.fawe.util.TaskManager;
|
||||||
import com.boydti.fawe.util.image.ImageViewer;
|
import com.boydti.fawe.util.image.ImageViewer;
|
||||||
|
@ -1,45 +0,0 @@
|
|||||||
package com.boydti.fawe.object;
|
|
||||||
|
|
||||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
|
||||||
import com.boydti.fawe.util.TaskManager;
|
|
||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
|
||||||
|
|
||||||
public abstract class FaweCommand<T> {
|
|
||||||
public final String perm;
|
|
||||||
public final boolean safe;
|
|
||||||
|
|
||||||
public FaweCommand(String perm) {
|
|
||||||
this(perm, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public FaweCommand(String perm, boolean safe) {
|
|
||||||
this.perm = perm;
|
|
||||||
this.safe = safe;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPerm() {
|
|
||||||
return this.perm;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean executeSafe(Actor player, String... args) {
|
|
||||||
try {
|
|
||||||
if (!safe) {
|
|
||||||
execute(player, args);
|
|
||||||
return true;
|
|
||||||
} else if (player == null) {
|
|
||||||
TaskManager.IMP.async(() -> execute(player, args));
|
|
||||||
} else {
|
|
||||||
if (!player.runAction(() -> execute(player, args), true, true)) {
|
|
||||||
player.printError(TranslatableComponent.of("fawe.info.worldedit.command.limit"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
} catch (Throwable e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract boolean execute(Actor actor, String... args);
|
|
||||||
}
|
|
@ -28,6 +28,7 @@ import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
|
|||||||
import com.sk89q.worldedit.command.util.annotation.Confirm;
|
import com.sk89q.worldedit.command.util.annotation.Confirm;
|
||||||
import com.sk89q.worldedit.entity.Player;
|
import com.sk89q.worldedit.entity.Player;
|
||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
|
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
||||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||||
import org.enginehub.piston.annotation.Command;
|
import org.enginehub.piston.annotation.Command;
|
||||||
@ -60,7 +61,7 @@ public class HistoryCommands {
|
|||||||
desc = "Undoes the last action (from history)"
|
desc = "Undoes the last action (from history)"
|
||||||
)
|
)
|
||||||
@CommandPermissions({"worldedit.history.undo", "worldedit.history.undo.self"})
|
@CommandPermissions({"worldedit.history.undo", "worldedit.history.undo.self"})
|
||||||
public void undo(Player player, LocalSession session,
|
public void undo(Actor actor, LocalSession session,
|
||||||
@Confirm(Confirm.Processor.LIMIT) @Arg(desc = "Number of undoes to perform", def = "1")
|
@Confirm(Confirm.Processor.LIMIT) @Arg(desc = "Number of undoes to perform", def = "1")
|
||||||
int times,
|
int times,
|
||||||
@Arg(name = "player", desc = "Undo this player's operations", def = "")
|
@Arg(name = "player", desc = "Undo this player's operations", def = "")
|
||||||
@ -68,31 +69,32 @@ public class HistoryCommands {
|
|||||||
times = Math.max(1, times);
|
times = Math.max(1, times);
|
||||||
LocalSession undoSession = session;
|
LocalSession undoSession = session;
|
||||||
if (session.hasFastMode()) {
|
if (session.hasFastMode()) {
|
||||||
player.print(TranslatableComponent.of("fawe.worldedit.history.command.undo.disabled"));
|
actor.print(TranslatableComponent.of("fawe.worldedit.history.command.undo.disabled"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (playerName != null) {
|
if (playerName != null) {
|
||||||
player.checkPermission("worldedit.history.undo.other");
|
actor.checkPermission("worldedit.history.undo.other");
|
||||||
undoSession = worldEdit.getSessionManager().findByName(playerName);
|
undoSession = worldEdit.getSessionManager().findByName(playerName);
|
||||||
if (undoSession == null) {
|
if (undoSession == null) {
|
||||||
player.printError(TranslatableComponent.of("worldedit.session.cant-find-session", TextComponent.of(playerName)));
|
actor.printError(TranslatableComponent.of("worldedit.session.cant-find-session", TextComponent.of(playerName)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int timesUndone = 0;
|
int timesUndone = 0;
|
||||||
for (int i = 0; i < times; ++i) {
|
for (int i = 0; i < times; ++i) {
|
||||||
EditSession undone = undoSession.undo(undoSession.getBlockBag(player), player);
|
BlockBag bag = actor instanceof Player ? undoSession.getBlockBag((Player) actor) : null;
|
||||||
|
EditSession undone = undoSession.undo(bag, actor);
|
||||||
if (undone != null) {
|
if (undone != null) {
|
||||||
timesUndone++;
|
timesUndone++;
|
||||||
worldEdit.flushBlockBag(player, undone);
|
worldEdit.flushBlockBag(actor, undone);
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (timesUndone > 0) {
|
if (timesUndone > 0) {
|
||||||
player.printInfo(TranslatableComponent.of("worldedit.undo.undone", TextComponent.of(timesUndone)));
|
actor.printInfo(TranslatableComponent.of("worldedit.undo.undone", TextComponent.of(timesUndone)));
|
||||||
} else {
|
} else {
|
||||||
player.printError(TranslatableComponent.of("worldedit.undo.none"));
|
actor.printError(TranslatableComponent.of("worldedit.undo.none"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,7 +104,7 @@ public class HistoryCommands {
|
|||||||
desc = "Redoes the last action (from history)"
|
desc = "Redoes the last action (from history)"
|
||||||
)
|
)
|
||||||
@CommandPermissions({"worldedit.history.redo", "worldedit.history.redo.self"})
|
@CommandPermissions({"worldedit.history.redo", "worldedit.history.redo.self"})
|
||||||
public void redo(Player player, LocalSession session,
|
public void redo(Actor actor, LocalSession session,
|
||||||
@Confirm(Confirm.Processor.LIMIT) @Arg(desc = "Number of redoes to perform", def = "1")
|
@Confirm(Confirm.Processor.LIMIT) @Arg(desc = "Number of redoes to perform", def = "1")
|
||||||
int times,
|
int times,
|
||||||
@Arg(name = "player", desc = "Redo this player's operations", def = "")
|
@Arg(name = "player", desc = "Redo this player's operations", def = "")
|
||||||
@ -110,27 +112,28 @@ public class HistoryCommands {
|
|||||||
times = Math.max(1, times);
|
times = Math.max(1, times);
|
||||||
LocalSession redoSession = session;
|
LocalSession redoSession = session;
|
||||||
if (playerName != null) {
|
if (playerName != null) {
|
||||||
player.checkPermission("worldedit.history.redo.other");
|
actor.checkPermission("worldedit.history.redo.other");
|
||||||
redoSession = worldEdit.getSessionManager().findByName(playerName);
|
redoSession = worldEdit.getSessionManager().findByName(playerName);
|
||||||
if (redoSession == null) {
|
if (redoSession == null) {
|
||||||
player.printError(TranslatableComponent.of("worldedit.session.cant-find-session", TextComponent.of(playerName)));
|
actor.printError(TranslatableComponent.of("worldedit.session.cant-find-session", TextComponent.of(playerName)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int timesRedone = 0;
|
int timesRedone = 0;
|
||||||
for (int i = 0; i < times; ++i) {
|
for (int i = 0; i < times; ++i) {
|
||||||
EditSession redone = redoSession.redo(redoSession.getBlockBag(player), player);
|
BlockBag bag = actor instanceof Player ? redoSession.getBlockBag((Player) actor) : null;
|
||||||
|
EditSession redone = redoSession.redo(bag, actor);
|
||||||
if (redone != null) {
|
if (redone != null) {
|
||||||
timesRedone++;
|
timesRedone++;
|
||||||
worldEdit.flushBlockBag(player, redone);
|
worldEdit.flushBlockBag(actor, redone);
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (timesRedone > 0) {
|
if (timesRedone > 0) {
|
||||||
player.printInfo(TranslatableComponent.of("worldedit.redo.undone", TextComponent.of(timesRedone)));
|
actor.printInfo(TranslatableComponent.of("worldedit.redo.undone", TextComponent.of(timesRedone)));
|
||||||
} else {
|
} else {
|
||||||
player.printError(TranslatableComponent.of("worldedit.redo.none"));
|
actor.printError(TranslatableComponent.of("worldedit.redo.none"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -218,6 +218,9 @@ public class BlockTypesCache {
|
|||||||
values[internalId] = type;
|
values[internalId] = type;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for (int i = 0; i < values.length; i++) {
|
||||||
|
if (values[i] == null) values[i] = values[0];
|
||||||
|
}
|
||||||
|
|
||||||
states = stateList.toArray(new BlockState[stateList.size()]);
|
states = stateList.toArray(new BlockState[stateList.size()]);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user