mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-25 22:56:45 +01:00
Merged
This commit is contained in:
commit
95c9fd01dd
@ -97,6 +97,7 @@ import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
import org.bukkit.event.vehicle.VehicleCreateEvent;
|
||||
import org.bukkit.event.vehicle.VehicleDestroyEvent;
|
||||
@ -109,6 +110,16 @@ import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.projectiles.BlockProjectileSource;
|
||||
import org.bukkit.projectiles.ProjectileSource;
|
||||
import org.bukkit.util.Vector;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@ -463,6 +474,13 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
}, 20);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void playerRespawn(PlayerRespawnEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
final PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||
EventUtil.manager.doDeathTask(pp);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void playerMove(PlayerMoveEvent event) {
|
||||
org.bukkit.Location from = event.getFrom();
|
||||
@ -616,11 +634,14 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
}
|
||||
Plot plot = area.getPlotAbs(loc);
|
||||
if (plot != null) {
|
||||
PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||
if (event.getBlock().getY() == 0) {
|
||||
if (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_DESTROY_GROUNDLEVEL)) {
|
||||
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_DESTROY_GROUNDLEVEL);
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||
}
|
||||
if (!plot.hasOwner()) {
|
||||
if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_DESTROY_UNOWNED)) {
|
||||
return;
|
||||
@ -727,7 +748,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
plotExit(pp, plot);
|
||||
}
|
||||
|
||||
if (BukkitMain.worldEdit != null) {
|
||||
if (BukkitMain.worldEdit != null && PS.get().worldedit != null) {
|
||||
if (!Permissions.hasPermission(pp, C.PERMISSION_WORLDEDIT_BYPASS)) {
|
||||
if (pp.getAttribute("worldedit")) {
|
||||
pp.removeAttribute("worldedit");
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -13,6 +13,7 @@ import com.intellectualcrafters.plot.util.ReflectionUtils.RefMethod.RefExecutor;
|
||||
import com.intellectualcrafters.plot.util.SetQueue;
|
||||
import com.intellectualcrafters.plot.util.SetQueue.ChunkWrapper;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.plotsquared.bukkit.util.BukkitUtil;
|
||||
import com.plotsquared.bukkit.util.SendChunk;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
@ -37,6 +38,7 @@ public class FastQueue_1_8_3 extends SlowQueue {
|
||||
private final SendChunk sendChunk;
|
||||
private final HashMap<ChunkWrapper, Chunk> toUpdate = new HashMap<>();
|
||||
private final RefMethod methodGetHandleChunk;
|
||||
private final RefMethod methodGetHandleWorld;
|
||||
private final RefMethod methodInitLighting;
|
||||
private final RefConstructor classBlockPositionConstructor;
|
||||
private final RefConstructor classChunkSectionConstructor;
|
||||
@ -50,6 +52,7 @@ public class FastQueue_1_8_3 extends SlowQueue {
|
||||
|
||||
public FastQueue_1_8_3() throws RuntimeException {
|
||||
RefClass classCraftChunk = getRefClass("{cb}.CraftChunk");
|
||||
RefClass classCraftWorld = getRefClass("{cb}.CraftWorld");
|
||||
this.methodGetHandleChunk = classCraftChunk.getMethod("getHandle");
|
||||
RefClass classChunk = getRefClass("{nms}.Chunk");
|
||||
this.methodInitLighting = classChunk.getMethod("initLighting");
|
||||
@ -64,6 +67,7 @@ public class FastQueue_1_8_3 extends SlowQueue {
|
||||
this.methodAreNeighborsLoaded = classChunk.getMethod("areNeighborsLoaded", int.class);
|
||||
this.classChunkSectionConstructor = classChunkSection.getConstructor(int.class, boolean.class, char[].class);
|
||||
this.tileEntityListTick = classWorld.getField("tileEntityList");
|
||||
this.methodGetHandleWorld = classCraftWorld.getMethod("getHandle");
|
||||
this.methodGetWorld = classChunk.getMethod("getWorld");
|
||||
this.sendChunk = new SendChunk();
|
||||
TaskManager.runTaskRepeat(new Runnable() {
|
||||
@ -257,6 +261,17 @@ public class FastQueue_1_8_3 extends SlowQueue {
|
||||
return new FastChunk_1_8_3(wrap);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void regenerateChunk(String worldname, ChunkLoc loc) {
|
||||
World world = BukkitUtil.getWorld(worldname);
|
||||
Chunk chunk = world.getChunkAt(loc.x, loc.z);
|
||||
if (chunk.getTileEntities().length > 0) {
|
||||
Object w = methodGetHandleWorld.of(world).call();
|
||||
((Collection) this.tileEntityListTick.of(w).get()).clear();
|
||||
}
|
||||
super.regenerateChunk(worldname, loc);
|
||||
}
|
||||
|
||||
/**
|
||||
* This should be overridden by any specialized queues
|
||||
* @param plotChunk
|
||||
|
@ -80,6 +80,18 @@ public class FastQueue_1_9 extends SlowQueue {
|
||||
MainUtil.initCache();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void regenerateChunk(String worldname, ChunkLoc loc) {
|
||||
World world = BukkitUtil.getWorld(worldname);
|
||||
Chunk chunk = world.getChunkAt(loc.x, loc.z);
|
||||
if (chunk.getTileEntities().length > 0) {
|
||||
Object c = methodGetHandleChunk.of(chunk).call();
|
||||
Object w = methodGetWorld.of(c).call();
|
||||
((Collection) this.tileEntityListTick.of(w).get()).clear();
|
||||
}
|
||||
super.regenerateChunk(worldname, loc);
|
||||
}
|
||||
|
||||
/**
|
||||
* This should be overridden by any specialized queues
|
||||
* @param plotChunk
|
||||
|
@ -8,6 +8,7 @@ import com.intellectualcrafters.plot.util.PlotChunk;
|
||||
import com.intellectualcrafters.plot.util.PlotQueue;
|
||||
import com.intellectualcrafters.plot.util.SetQueue;
|
||||
import com.intellectualcrafters.plot.util.SetQueue.ChunkWrapper;
|
||||
import com.plotsquared.bukkit.util.BukkitUtil;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map.Entry;
|
||||
@ -103,6 +104,11 @@ public class SlowQueue implements PlotQueue<Chunk> {
|
||||
this.blocks.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void regenerateChunk(String world, ChunkLoc loc) {
|
||||
BukkitUtil.getWorld(world).regenerateChunk(loc.x, loc.z);
|
||||
}
|
||||
|
||||
/**
|
||||
* This should be overridden by any specialized queues.
|
||||
* @param plotChunk
|
||||
|
@ -53,7 +53,6 @@ import com.intellectualcrafters.plot.util.WorldUtil;
|
||||
import com.intellectualcrafters.plot.util.area.QuadMap;
|
||||
import com.plotsquared.listener.WESubscriber;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
@ -2030,6 +2029,7 @@ public class PS {
|
||||
|
||||
// Teleportation
|
||||
options.put("teleport.on_login", Settings.TELEPORT_ON_LOGIN);
|
||||
options.put("teleport.on_death", Settings.TELEPORT_ON_DEATH);
|
||||
options.put("teleport.delay", Settings.TELEPORT_DELAY);
|
||||
|
||||
// WorldEdit
|
||||
@ -2140,6 +2140,7 @@ public class PS {
|
||||
// Teleportation
|
||||
Settings.TELEPORT_DELAY = this.config.getInt("teleport.delay");
|
||||
Settings.TELEPORT_ON_LOGIN = this.config.getBoolean("teleport.on_login");
|
||||
Settings.TELEPORT_ON_DEATH = this.config.getBoolean("teleport.on_death");
|
||||
|
||||
// WorldEdit
|
||||
Settings.QUEUE_COMMANDS = this.config.getBoolean("worldedit.queue-commands");
|
||||
|
@ -5,7 +5,6 @@ import com.intellectualcrafters.configuration.file.YamlConfiguration;
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.util.StringMan;
|
||||
import com.plotsquared.general.commands.CommandCaller;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
@ -58,6 +57,7 @@ public enum C {
|
||||
PERMISSION_COMMANDS_CHAT("plots.admin.command.chat", "static.permissions"),
|
||||
PERMISSION_MERGE_OTHER("plots.merge.other", "static.permissions"),
|
||||
PERMISSION_ADMIN_DESTROY_UNOWNED("plots.admin.destroy.unowned", "static.permissions"),
|
||||
PERMISSION_ADMIN_DESTROY_GROUNDLEVEL("plots.admin.destroy.groundlevel", "static.permissions"),
|
||||
PERMISSION_ADMIN_DESTROY_OTHER("plots.admin.destroy.other", "static.permissions"),
|
||||
PERMISSION_ADMIN_DESTROY_ROAD("plots.admin.destroy.road", "static.permissions"),
|
||||
PERMISSION_ADMIN_BUILD_ROAD("plots.admin.build.road", "static.permissions"),
|
||||
|
@ -82,6 +82,10 @@ public class Settings {
|
||||
* Teleport to path on login
|
||||
*/
|
||||
public static boolean TELEPORT_ON_LOGIN = false;
|
||||
/**
|
||||
* Teleport to path on death
|
||||
*/
|
||||
public static boolean TELEPORT_ON_DEATH = false;
|
||||
/**
|
||||
* Display titles
|
||||
*/
|
||||
|
@ -4,6 +4,7 @@ import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||
import com.intellectualcrafters.plot.util.SetQueue.ChunkWrapper;
|
||||
@ -11,7 +12,9 @@ import com.intellectualcrafters.plot.util.SetQueue.ChunkWrapper;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public abstract class ChunkManager {
|
||||
@ -226,7 +229,19 @@ public abstract class ChunkManager {
|
||||
return chunks;
|
||||
}
|
||||
|
||||
public abstract void regenerateChunk(String world, ChunkLoc loc);
|
||||
public void regenerateChunk(String world, ChunkLoc loc) {
|
||||
SetQueue.IMP.regenerateChunk(world, loc);
|
||||
SetQueue.IMP.queue.sendChunk(world, Collections.singletonList(loc));
|
||||
for (Map.Entry<String, PlotPlayer> entry : UUIDHandler.getPlayers().entrySet()) {
|
||||
PlotPlayer pp = entry.getValue();
|
||||
Location pLoc = pp.getLocation();
|
||||
if (!StringMan.isEqual(world, pLoc.getWorld()) || !pLoc.getChunkLoc().equals(loc)) {
|
||||
continue;
|
||||
}
|
||||
pLoc.setY(WorldUtil.IMP.getHighestBlock(world, pLoc.getX(), pLoc.getZ()));
|
||||
pp.teleport(pLoc);
|
||||
}
|
||||
}
|
||||
|
||||
public void deleteRegionFiles(String world, Collection<ChunkLoc> chunks) {
|
||||
deleteRegionFiles(world, chunks, null);
|
||||
|
@ -15,7 +15,6 @@ import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.Rating;
|
||||
import com.plotsquared.listener.PlayerBlockEventType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.UUID;
|
||||
@ -78,6 +77,19 @@ public abstract class EventUtil {
|
||||
}
|
||||
}
|
||||
|
||||
public void doDeathTask(final PlotPlayer pp) {
|
||||
final Plot plot = pp.getCurrentPlot();
|
||||
if (Settings.TELEPORT_ON_DEATH && plot != null) {
|
||||
TaskManager.runTask(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
plot.teleportPlayer(pp);
|
||||
}
|
||||
});
|
||||
MainUtil.sendMessage(pp, C.TELEPORTED_TO_ROAD);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean checkPlayerBlockEvent(PlotPlayer pp, PlayerBlockEventType type, Location loc, LazyBlock block, boolean notifyPerms) {
|
||||
PlotArea area = PS.get().getPlotAreaAbs(loc);
|
||||
Plot plot;
|
||||
|
@ -26,5 +26,7 @@ public interface PlotQueue<T> {
|
||||
PlotChunk<T> next(ChunkWrapper wrap, boolean fixLighting);
|
||||
|
||||
void clear();
|
||||
|
||||
void regenerateChunk(String world, ChunkLoc loc);
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.intellectualcrafters.plot.util;
|
||||
|
||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
@ -149,6 +149,10 @@ public class SetQueue {
|
||||
return this.queue.setBlock(world, x, y, z, (short) id, (byte) 0);
|
||||
}
|
||||
|
||||
public void regenerateChunk(String world, ChunkLoc loc) {
|
||||
queue.regenerateChunk(world, loc);
|
||||
}
|
||||
|
||||
public class ChunkWrapper {
|
||||
|
||||
public final int x;
|
||||
|
@ -1,13 +1,13 @@
|
||||
package com.plotsquared.sponge.util;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import net.minecraft.world.chunk.IChunkProvider;
|
||||
import net.minecraft.world.gen.ChunkProviderServer;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.function.Predicate;
|
||||
import org.spongepowered.api.entity.Entity;
|
||||
import org.spongepowered.api.entity.living.Living;
|
||||
import org.spongepowered.api.entity.living.animal.Animal;
|
||||
@ -15,10 +15,6 @@ import org.spongepowered.api.entity.living.monster.Monster;
|
||||
import org.spongepowered.api.world.Chunk;
|
||||
import org.spongepowered.api.world.World;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public class SpongeChunkManager extends ChunkManager {
|
||||
|
||||
@Override
|
||||
@ -68,55 +64,6 @@ public class SpongeChunkManager extends ChunkManager {
|
||||
return super.getChunkChunks(world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void regenerateChunk(String world, ChunkLoc loc) {
|
||||
World spongeWorld = SpongeUtil.getWorld(world);
|
||||
net.minecraft.world.World nmsWorld = (net.minecraft.world.World) spongeWorld;
|
||||
Optional<Chunk> chunkOpt = spongeWorld.getChunk(loc.x, 0, loc.z);
|
||||
if (chunkOpt.isPresent()) {
|
||||
try {
|
||||
Chunk spongeChunk = chunkOpt.get();
|
||||
IChunkProvider provider = nmsWorld.getChunkProvider();
|
||||
if (!(provider instanceof ChunkProviderServer)) {
|
||||
PS.debug("Not valid world generator for: " + world);
|
||||
return;
|
||||
}
|
||||
/* ChunkProviderServer chunkServer = (ChunkProviderServer) provider;
|
||||
IChunkProvider chunkProvider = chunkServer.serverChunkGenerator;
|
||||
|
||||
long pos = ChunkCoordIntPair.chunkXZ2Int(loc.x, loc.z);
|
||||
net.minecraft.world.chunk.Chunk mcChunk = (net.minecraft.world.chunk.Chunk) spongeChunk;
|
||||
if (chunkServer.chunkExists(loc.x, loc.z)) {
|
||||
mcChunk = chunkServer.loadChunk(loc.x, loc.z);
|
||||
mcChunk.onChunkUnload();
|
||||
}
|
||||
Field fieldDroppedChunksSet;
|
||||
try {
|
||||
fieldDroppedChunksSet = chunkServer.getClass().getField("droppedChunksSet");
|
||||
} catch (Throwable t) {
|
||||
fieldDroppedChunksSet = ReflectionUtils.findField(chunkServer.getClass(), Set.class);
|
||||
}
|
||||
Set<Long> set = (Set<Long>) fieldDroppedChunksSet.get(chunkServer);
|
||||
set.remove(pos);
|
||||
ReflectionUtils.findField(chunkServer.getClass(),)
|
||||
chunkServer.id2ChunkMap.remove(pos);
|
||||
mcChunk = chunkProvider.provideChunk(loc.x, loc.z);
|
||||
chunkServer.id2ChunkMap.add(pos, mcChunk);
|
||||
chunkServer.loadedChunks.add(mcChunk);
|
||||
if (mcChunk != null) {
|
||||
mcChunk.onChunkLoad();
|
||||
mcChunk.populateChunk(chunkProvider, chunkProvider, loc.x, loc.z);
|
||||
SetQueue.IMP.queue.sendChunk(world, Arrays.asList(loc));
|
||||
}
|
||||
else {
|
||||
PS.debug("CHUNK IS NULL!?");
|
||||
}*/
|
||||
} catch (Throwable e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean copyRegion(Location pos1, Location pos2, Location newPos, Runnable whenDone) {
|
||||
// TODO copy a region
|
||||
|
@ -17,6 +17,13 @@ import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.intellectualcrafters.plot.util.WorldUtil;
|
||||
import com.plotsquared.sponge.SpongeMain;
|
||||
import com.plotsquared.sponge.object.SpongePlayer;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Optional;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
import org.apache.commons.lang3.NotImplementedException;
|
||||
@ -42,14 +49,6 @@ import org.spongepowered.api.world.biome.BiomeType;
|
||||
import org.spongepowered.api.world.biome.BiomeTypes;
|
||||
import org.spongepowered.api.world.extent.Extent;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Optional;
|
||||
|
||||
public class SpongeUtil extends WorldUtil {
|
||||
|
||||
public static Cause CAUSE = Cause.of(NamedCause.source("PlotSquared"));
|
||||
|
@ -10,6 +10,9 @@ import com.intellectualcrafters.plot.util.PlotQueue;
|
||||
import com.intellectualcrafters.plot.util.SetQueue;
|
||||
import com.intellectualcrafters.plot.util.SetQueue.ChunkWrapper;
|
||||
import com.plotsquared.sponge.util.SpongeUtil;
|
||||
import java.util.Optional;
|
||||
import net.minecraft.world.chunk.IChunkProvider;
|
||||
import net.minecraft.world.gen.ChunkProviderServer;
|
||||
import org.spongepowered.api.block.BlockState;
|
||||
import org.spongepowered.api.world.Chunk;
|
||||
|
||||
@ -17,6 +20,7 @@ import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import org.spongepowered.api.world.World;
|
||||
|
||||
public class SlowQueue implements PlotQueue<Chunk> {
|
||||
|
||||
@ -101,6 +105,55 @@ public class SlowQueue implements PlotQueue<Chunk> {
|
||||
this.blocks.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void regenerateChunk(String world, ChunkLoc loc) {
|
||||
World spongeWorld = SpongeUtil.getWorld(world);
|
||||
net.minecraft.world.World nmsWorld = (net.minecraft.world.World) spongeWorld;
|
||||
Optional<Chunk> chunkOpt = spongeWorld.getChunk(loc.x, 0, loc.z);
|
||||
if (chunkOpt.isPresent()) {
|
||||
try {
|
||||
Chunk spongeChunk = chunkOpt.get();
|
||||
IChunkProvider provider = nmsWorld.getChunkProvider();
|
||||
if (!(provider instanceof ChunkProviderServer)) {
|
||||
PS.debug("Not valid world generator for: " + world);
|
||||
return;
|
||||
}
|
||||
/* ChunkProviderServer chunkServer = (ChunkProviderServer) provider;
|
||||
IChunkProvider chunkProvider = chunkServer.serverChunkGenerator;
|
||||
|
||||
long pos = ChunkCoordIntPair.chunkXZ2Int(loc.x, loc.z);
|
||||
net.minecraft.world.chunk.Chunk mcChunk = (net.minecraft.world.chunk.Chunk) spongeChunk;
|
||||
if (chunkServer.chunkExists(loc.x, loc.z)) {
|
||||
mcChunk = chunkServer.loadChunk(loc.x, loc.z);
|
||||
mcChunk.onChunkUnload();
|
||||
}
|
||||
Field fieldDroppedChunksSet;
|
||||
try {
|
||||
fieldDroppedChunksSet = chunkServer.getClass().getField("droppedChunksSet");
|
||||
} catch (Throwable t) {
|
||||
fieldDroppedChunksSet = ReflectionUtils.findField(chunkServer.getClass(), Set.class);
|
||||
}
|
||||
Set<Long> set = (Set<Long>) fieldDroppedChunksSet.get(chunkServer);
|
||||
set.remove(pos);
|
||||
ReflectionUtils.findField(chunkServer.getClass(),)
|
||||
chunkServer.id2ChunkMap.remove(pos);
|
||||
mcChunk = chunkProvider.provideChunk(loc.x, loc.z);
|
||||
chunkServer.id2ChunkMap.add(pos, mcChunk);
|
||||
chunkServer.loadedChunks.add(mcChunk);
|
||||
if (mcChunk != null) {
|
||||
mcChunk.onChunkLoad();
|
||||
mcChunk.populateChunk(chunkProvider, chunkProvider, loc.x, loc.z);
|
||||
SetQueue.IMP.queue.sendChunk(world, Arrays.asList(loc));
|
||||
}
|
||||
else {
|
||||
PS.debug("CHUNK IS NULL!?");
|
||||
}*/
|
||||
} catch (Throwable e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This should be overriden by any specialized queues.
|
||||
* @param plotChunk
|
||||
|
Loading…
Reference in New Issue
Block a user