13
0

Bringing SpectateSystem nearer to production

Dieser Commit ist enthalten in:
Lixfel 2020-10-30 14:59:49 +01:00
Ursprung 724bc117e6
Commit fc15f2c21e
2 geänderte Dateien mit 22 neuen und 32 gelöschten Zeilen

Datei anzeigen

@ -35,6 +35,7 @@
</configuration>
</plugin>
</plugins>
<finalName>spectatesystem</finalName>
</build>
<dependencies>

Datei anzeigen

@ -150,18 +150,22 @@ class PacketProcessor {
Bukkit.getOnlinePlayers().forEach(p -> p.spigot().sendMessage(type, text));
}
private void shortBlock() throws IOException {
int x = Byte.toUnsignedInt(source.rByte()) + Config.ArenaMinX;
int y = Byte.toUnsignedInt(source.rByte());
int z = Byte.toUnsignedInt(source.rByte()) + Config.ArenaMinZ;
int blockState = source.rShort();
setBlock(x, y, z, blockState);
}
private void block() throws IOException {
int x = source.rInt();
int y = Byte.toUnsignedInt(source.rByte());
int z = source.rInt();
int blockState = source.rInt();
if (Config.TechhiderActive && Config.HiddenBlocks.contains(blockState)) {
blockState = Config.ObfuscateWith;
}
CraftBlockData craftBlockData = CraftBlockData.fromData(Objects.requireNonNull(Block.REGISTRY_ID.fromId(blockState)));
Bukkit.getScheduler().runTask(SpectateSystem.get(), () -> world.getBlockAt(x, y, z).setBlockData(craftBlockData));
setBlock(x, y, z, blockState);
}
private void particle() throws IOException {
@ -191,29 +195,6 @@ class PacketProcessor {
Bukkit.getScheduler().runTask(SpectateSystem.get(), () -> world.playSound(new Location(world, x, y, z), sound, sCategory, volume, pitch));
}
private static int debug_block_ignored = 0;
private static int debug_block_unneccesary = 0;
private void shortBlock() throws IOException {
int x = Byte.toUnsignedInt(source.rByte()) + Config.ArenaMinX;
int y = Byte.toUnsignedInt(source.rByte());
int z = Byte.toUnsignedInt(source.rByte()) + Config.ArenaMinZ;
int blockState = source.rShort();
if (Config.TechhiderActive && Config.HiddenBlocks.contains(blockState)) {
blockState = Config.ObfuscateWith;
debug_block_ignored++;
}
CraftBlockData craftBlockData = CraftBlockData.fromData(Objects.requireNonNull(Block.REGISTRY_ID.fromId(blockState)));
Bukkit.getScheduler().runTask(SpectateSystem.get(), () -> {
org.bukkit.block.Block block = world.getBlockAt(x, y, z);
if(block.getBlockData().matches(craftBlockData))
debug_block_unneccesary++;
block.setBlockData(craftBlockData);
});
}
private void soundAtPlayer() throws IOException {
String soundName = source.rString();
@ -264,6 +245,17 @@ class PacketProcessor {
SpectateSystem.getScoreboard().addValue(key, value);
}
private void setBlock(int x, int y, int z, int blockState){
if(Config.ArenaMinX > x || Config.ArenaMaxX < x || Config.ArenaMinZ > z || Config.ArenaMaxZ < z)
return; //Outside of the arena
if (Config.TechhiderActive && Config.HiddenBlocks.contains(blockState)) {
blockState = Config.ObfuscateWith;
}
CraftBlockData craftBlockData = CraftBlockData.fromData(Objects.requireNonNull(Block.REGISTRY_ID.fromId(blockState)));
Bukkit.getScheduler().runTask(SpectateSystem.get(), () -> world.getBlockAt(x, y, z).setBlockData(craftBlockData));
}
private void endSpectating(){
WorldLoader.reloadWorld();
SpectateSystem.getScoreboard().setTitle("§eKein Kampf");
@ -271,11 +263,8 @@ class PacketProcessor {
for(Map.Entry<Byte, Integer> entry : packetCounter.entrySet()){
System.out.println(Integer.toHexString(entry.getKey()) + " " + entry.getValue());
}
System.out.println("Techhiderupdates: " + debug_block_ignored + ", Unneccesary: " + debug_block_unneccesary);
packetCounter.clear();
debug_block_ignored = 0;
debug_block_unneccesary = 0;
}
private void process(){