Adding crazy world reset
Dieser Commit ist enthalten in:
Ursprung
aef57c490e
Commit
8956c5523e
@ -37,7 +37,7 @@ public class BlockTextCreator {
|
||||
|
||||
private static BlockArrayClipboard[] createText(String text){
|
||||
List<BlockArrayClipboard> result = new ArrayList<>();
|
||||
for(char c : text.toCharArray()){
|
||||
for(char c : text.toUpperCase().toCharArray()){
|
||||
try {
|
||||
result.add((BlockArrayClipboard) new SpongeSchematicReader(new NBTInputStream(new GZIPInputStream(new FileInputStream(new File(SpectateSystem.get().getDataFolder(), "text/" + c + ".schem"))))).read());
|
||||
} catch (FileNotFoundException e) {
|
||||
@ -96,7 +96,7 @@ public class BlockTextCreator {
|
||||
Paster.replaceTeamColor(
|
||||
WorldEdit.getInstance().getEditSessionFactory().getEditSession(WORLD, -1),
|
||||
c,
|
||||
x, y, z, length, 6, 0);
|
||||
x - length / 2, y, z, length, 6, 0);
|
||||
}
|
||||
|
||||
private static void pasteForTeam(int teamId, int x, int z, boolean rotate, String color){
|
||||
|
@ -19,10 +19,20 @@
|
||||
|
||||
package de.steamwar.spectatesystem.util;
|
||||
|
||||
import de.steamwar.spectatesystem.Config;
|
||||
import de.steamwar.spectatesystem.SpectateSystem;
|
||||
import de.steamwar.spectatesystem.elements.REntity;
|
||||
import net.minecraft.server.v1_15_R1.Block;
|
||||
import net.minecraft.server.v1_15_R1.BlockPosition;
|
||||
import net.minecraft.server.v1_15_R1.IBlockData;
|
||||
import net.minecraft.server.v1_15_R1.WorldServer;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.WorldCreator;
|
||||
import org.bukkit.craftbukkit.v1_15_R1.CraftChunk;
|
||||
import org.bukkit.craftbukkit.v1_15_R1.CraftWorld;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class WorldLoader {
|
||||
private WorldLoader(){}
|
||||
@ -32,17 +42,35 @@ public class WorldLoader {
|
||||
public static void reloadWorld(){
|
||||
Bukkit.getScheduler().runTask(SpectateSystem.get(), () -> {
|
||||
REntity.removeAll();
|
||||
/*
|
||||
Chunk[] chunks = world.getLoadedChunks();
|
||||
PlayerChunkMap playerChunkMap = ((CraftWorld)world).getHandle().getChunkProvider().playerChunkMap;
|
||||
for(long l : playerChunkMap.updatingChunks.keySet())
|
||||
playerChunkMap.unloadQueue.add(l);
|
||||
System.out.println(world.getLoadedChunks().length);
|
||||
for(Chunk chunk: chunks){
|
||||
//world.getChunkAt(chunk.getX(), chunk.getZ());
|
||||
for(Player player : Bukkit.getOnlinePlayers())
|
||||
((CraftPlayer)player).getHandle().playerConnection.sendPacket(new PacketPlayOutMapChunk(((CraftChunk)chunk).getHandle(), 65535));
|
||||
}*/
|
||||
|
||||
WorldServer cworld = ((CraftWorld)world).getHandle();
|
||||
WorldServer backup = ((CraftWorld) Objects.requireNonNull(new WorldCreator(world.getName() + "-backup").createWorld())).getHandle();
|
||||
|
||||
for(int cX = Config.ArenaMinX / 16; cX <= Config.ArenaMaxX / 16; cX++){
|
||||
for(int cZ = Config.ArenaMinZ / 16; cZ <= Config.ArenaMaxZ / 16; cZ++){
|
||||
long start = System.currentTimeMillis();
|
||||
int changedBlocks = 0;
|
||||
net.minecraft.server.v1_15_R1.Chunk cchunk = ((CraftChunk) world.getChunkAt(cX, cZ)).getHandle();
|
||||
for(int y = 255; y >= 0; y--){ // y top down to reduce lightning calculations
|
||||
for(int x = cX * 16; x < (cX + 1) * 16; x++){
|
||||
for(int z = cZ; z < (cZ + 1) * 16; z++){
|
||||
BlockPosition blockPos = new BlockPosition(x, y, z);
|
||||
IBlockData backupBlock = backup.getType(blockPos);
|
||||
if(Block.REGISTRY_ID.getId(backupBlock) == Block.REGISTRY_ID.getId(cchunk.getType(blockPos)))
|
||||
continue;
|
||||
|
||||
changedBlocks++;
|
||||
cchunk.removeTileEntity(blockPos);
|
||||
cworld.setTypeAndData(blockPos, backupBlock, 1042);
|
||||
cworld.getChunkProvider().flagDirty(blockPos);
|
||||
}
|
||||
}
|
||||
}
|
||||
System.out.println("Resetted " + changedBlocks + " in " + (System.currentTimeMillis() - start) + "ms");
|
||||
}
|
||||
}
|
||||
|
||||
Bukkit.unloadWorld(world.getName() + "-backup", false);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren