SteamWar/FightSystem
Archiviert
13
1

Merge branch 'master' into betterTimeTechKO
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Dieser Commit ist enthalten in:
Lixfel 2022-04-09 21:40:42 +02:00
Commit a45a124da2
3 geänderte Dateien mit 10 neuen und 33 gelöschten Zeilen

Datei anzeigen

@ -26,12 +26,12 @@ import io.netty.buffer.UnpooledByteBufAllocator;
import net.minecraft.core.IRegistry; import net.minecraft.core.IRegistry;
import net.minecraft.network.protocol.game.ClientboundLevelChunkPacketData; import net.minecraft.network.protocol.game.ClientboundLevelChunkPacketData;
import net.minecraft.network.protocol.game.ClientboundLevelChunkWithLightPacket; import net.minecraft.network.protocol.game.ClientboundLevelChunkWithLightPacket;
import net.minecraft.util.SimpleBitStorage;
import net.minecraft.world.level.block.entity.TileEntityTypes; import net.minecraft.world.level.block.entity.TileEntityTypes;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.nio.LongBuffer;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.function.IntFunction; import java.util.function.IntFunction;
@ -93,15 +93,17 @@ public class TechHider18 implements TechHider.ChunkHider {
buffer.writeBytes(data, curI, dataArrayLength * 8); buffer.writeBytes(data, curI, dataArrayLength * 8);
} else { } else {
ByteBuffer source = ByteBuffer.wrap(data, curI, dataArrayLength * 8); ByteBuffer source = ByteBuffer.wrap(data, curI, dataArrayLength * 8);
VariableValueArray values = new VariableValueArray(bitsPerBlock, dataArrayLength, source.asLongBuffer()); long[] array = new long[dataArrayLength];
source.asLongBuffer().get(array);
SimpleBitStorage values = new SimpleBitStorage(bitsPerBlock, 4096, array);
for (int pos = 0; pos < 4096; pos++) { for (int pos = 0; pos < 4096; pos++) {
if (hiddenBlockIds.contains(values.get(pos))) { if (hiddenBlockIds.contains(values.a(pos))) {
values.set(pos, obfuscateWith); values.b(pos, obfuscateWith);
} }
} }
for (long l : values.backing) for (long l : values.a())
buffer.writeLong(l); buffer.writeLong(l);
} }
}); });
@ -145,30 +147,4 @@ public class TechHider18 implements TechHider.ChunkHider {
return i; return i;
} }
private static final class VariableValueArray {
private final long[] backing;
private final int bitsPerValue;
private final long valueMask;
private final int valuesPerLong;
public VariableValueArray(int bitsPerEntry, int dataArrayLength, LongBuffer buffer) {
this.bitsPerValue = bitsPerEntry;
this.backing = new long[dataArrayLength];
buffer.get(backing);
this.valueMask = (1L << this.bitsPerValue) - 1;
this.valuesPerLong = 64 / bitsPerEntry;
}
public int get(int index) {
return (int)((backing[index / valuesPerLong] >> ((index % valuesPerLong) * bitsPerValue)) & valueMask);
}
public void set(int index, int value) {
int i0 = index / valuesPerLong;
int i1 = index % valuesPerLong;
backing[i0] = backing[i0] & ~(this.valueMask << i1) | (value & valueMask) << i1;
}
}
} }

Datei anzeigen

@ -21,6 +21,7 @@ package de.steamwar.fightsystem.commands;
import de.steamwar.fightsystem.ArenaMode; import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.record.PacketProcessor; import de.steamwar.fightsystem.record.PacketProcessor;
import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentCommand; import de.steamwar.fightsystem.states.StateDependentCommand;
@ -42,7 +43,7 @@ public class SkipCommand implements CommandExecutor {
} }
Player player = (Player) sender; Player player = (Player) sender;
if(PacketProcessor.isReplaying()) { if(PacketProcessor.isReplaying() && Fight.getBlueTeam().getDesignatedLeader() == player.getUniqueId()) {
PacketProcessor.currentReplay().skipToSubtitle(); PacketProcessor.currentReplay().skipToSubtitle();
} else { } else {
Commands.toggleSkip(player); Commands.toggleSkip(player);

Datei anzeigen

@ -232,7 +232,7 @@ public class FightUI {
} }
Message message = queue.poll(); Message message = queue.poll();
Bukkit.getOnlinePlayers().forEach(p -> WorldOfColorWrapper.impl.sendTitle(p, "", FightSystem.getMessage().parse(message.getMsg(), p, message.getParams()), 5, 40, 5)); Bukkit.getOnlinePlayers().forEach(p -> WorldOfColorWrapper.impl.sendTitle(p, " ", FightSystem.getMessage().parse(message.getMsg(), p, message.getParams()), 5, 40, 5));
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), FightUI::printSubtitle, 50); Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), FightUI::printSubtitle, 50);
subtitleScheduled = true; subtitleScheduled = true;
} }