13
0

Push current changes

Dieser Commit ist enthalten in:
Lixfel 2020-10-15 18:16:34 +02:00
Ursprung d7e18602d6
Commit 1a63993de1
6 geänderte Dateien mit 82 neuen und 64 gelöschten Zeilen

Datei anzeigen

@ -0,0 +1,15 @@
package de.steamwar.spectatesystem;
import java.io.*;
public class FightfileConnection extends PacketSource {
public FightfileConnection(File fightFile) throws IOException {
super(new DataInputStream(new FileInputStream(fightFile)));
}
@Override
boolean isClosed() {
return false;
}
}

Datei anzeigen

@ -26,61 +26,19 @@ import java.io.IOException;
import java.net.Socket;
import java.util.logging.Level;
public class FightserverConnection implements PacketSource {
public class FightserverConnection extends PacketSource {
private final Socket socket;
private final DataInputStream inputStream;
FightserverConnection(Socket socket) throws IOException{
super(new DataInputStream(socket.getInputStream()));
this.socket = socket;
this.inputStream = new DataInputStream(socket.getInputStream());
new PacketProcessor(this);
}
@Override
public byte rByte() throws IOException {
return inputStream.readByte();
}
@Override
public boolean rBoolean() throws IOException {
return inputStream.readBoolean();
}
@Override
public short rShort() throws IOException {
return inputStream.readShort();
}
@Override
public int rInt() throws IOException {
return inputStream.readInt();
}
@Override
public long rLong() throws IOException {
return inputStream.readLong();
}
@Override
public float rFloat() throws IOException {
return inputStream.readFloat();
}
@Override
public double rDouble() throws IOException {
return inputStream.readDouble();
}
@Override
public String rString() throws IOException {
return inputStream.readUTF();
}
@Override
public void close() {
super.close();
try {
socket.close();
inputStream.close();
} catch (IOException e) {
Bukkit.getLogger().log(Level.SEVERE, "IOException on close", e);
}

Datei anzeigen

@ -19,19 +19,60 @@
package de.steamwar.spectatesystem;
import org.bukkit.Bukkit;
import java.io.DataInputStream;
import java.io.IOException;
import java.util.logging.Level;
public interface PacketSource {
public abstract class PacketSource {
byte rByte() throws IOException;
boolean rBoolean() throws IOException;
short rShort() throws IOException;
int rInt() throws IOException;
long rLong() throws IOException;
float rFloat() throws IOException;
double rDouble() throws IOException;
String rString() throws IOException;
private final DataInputStream inputStream;
void close();
boolean isClosed();
protected PacketSource(DataInputStream inputStream){
this.inputStream = inputStream;
new PacketProcessor(this);
}
public byte rByte() throws IOException {
return inputStream.readByte();
}
public boolean rBoolean() throws IOException {
return inputStream.readBoolean();
}
public short rShort() throws IOException {
return inputStream.readShort();
}
public int rInt() throws IOException {
return inputStream.readInt();
}
public long rLong() throws IOException {
return inputStream.readLong();
}
public float rFloat() throws IOException {
return inputStream.readFloat();
}
public double rDouble() throws IOException {
return inputStream.readDouble();
}
public String rString() throws IOException {
return inputStream.readUTF();
}
public void close(){
try {
inputStream.close();
} catch (IOException e) {
Bukkit.getLogger().log(Level.SEVERE, "IOException on close", e);
}
}
abstract boolean isClosed();
}

Datei anzeigen

@ -29,7 +29,6 @@ import org.bukkit.BanList;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_15_R1.CraftChunk;
import org.bukkit.craftbukkit.v1_15_R1.CraftWorld;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.block.BlockExplodeEvent;
@ -104,7 +103,6 @@ public class ArenaListener extends BasicListener {
@EventHandler
public void onWorldLoad(WorldLoadEvent e){
e.getWorld().setAutoSave(false);
((CraftWorld)e.getWorld()).getHandle().savingDisabled = true;
}
@EventHandler

Datei anzeigen

@ -28,7 +28,7 @@ import java.util.zip.GZIPInputStream;
public class BlockTextCreator {
private BlockTextCreator(){}
private final static int BETWEEN_CHARACTERS_WIDTH = 1;
private static final int BETWEEN_CHARACTERS_WIDTH = 1;
private static final World WORLD = new BukkitWorld(Bukkit.getWorlds().get(0));
@ -70,9 +70,9 @@ public class BlockTextCreator {
return lengthes[lengthes.length - 1] + offsets[offsets.length - 1];
}
private static void pasteChar(BlockArrayClipboard character, int char_offset, int length, int x, int y, int z, AffineTransform transform){
private static void pasteChar(BlockArrayClipboard character, int charOffset, int length, int x, int y, int z, AffineTransform transform){
BlockVector3 offset = character.getRegion().getMinimumPoint().subtract(character.getOrigin());
BlockVector3 v = BlockVector3.ZERO.subtract(char_offset - length / 2, 0, 0).subtract(offset);
BlockVector3 v = BlockVector3.ZERO.subtract(- charOffset - length / 2, 0, 0).subtract(offset);
v = transform.apply(v.toVector3()).toBlockPoint();
v = v.add(x, y, z);

Datei anzeigen

@ -21,10 +21,12 @@ package de.steamwar.spectatesystem.util;
import de.steamwar.spectatesystem.SpectateSystem;
import net.minecraft.server.v1_15_R1.PacketPlayOutMapChunk;
import net.minecraft.server.v1_15_R1.PlayerChunkMap;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.World;
import org.bukkit.craftbukkit.v1_15_R1.CraftChunk;
import org.bukkit.craftbukkit.v1_15_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer;
import org.bukkit.entity.Player;
@ -35,9 +37,13 @@ public class WorldLoader {
public static void reloadWorld(){
Bukkit.getScheduler().runTask(SpectateSystem.get(), () -> {
for(Chunk chunk: world.getLoadedChunks()){
world.unloadChunk(chunk.getX(), chunk.getZ(), false);
world.getChunkAt(chunk.getX(), chunk.getZ());
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));
}