SteamWar/FightSystem
Archiviert
13
1

Techhiding (bugged, with invitation fix)

Dieser Commit ist enthalten in:
Lixfel 2019-06-08 12:57:58 +02:00
Ursprung 9377db47e5
Commit a05e377fa7
3 geänderte Dateien mit 46 neuen und 12 gelöschten Zeilen

Datei anzeigen

@ -1,6 +1,7 @@
package me.yaruma.fightsystem;
import de.warking.hunjy.CoinSystem.CoinSystem;
import javafx.util.Pair;
import me.yaruma.fightsystem.commands.*;
import me.yaruma.fightsystem.fight.*;
import me.yaruma.fightsystem.kit.KitManager;
@ -23,6 +24,7 @@ import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
import java.io.File;
import java.util.List;
public class FightSystem extends JavaPlugin {
@ -249,6 +251,14 @@ public class FightSystem extends JavaPlugin {
}
public static void setEntern(boolean entern) {
final List<Pair<Integer, Integer>> chunksBlue = TechHider.prepareChunkReload(Fight.getBlueTeam().getPlayers().get(0).getPlayer());
final List<Pair<Integer, Integer>> chunksRed = TechHider.prepareChunkReload(Fight.getRedTeam().getPlayers().get(0).getPlayer());
FightSystem.entern = entern;
for(FightPlayer player : Fight.getBlueTeam().getPlayers()){
TechHider.reloadChunks(player.getPlayer(), chunksBlue);
}
for(FightPlayer player : Fight.getRedTeam().getPlayers()){
TechHider.reloadChunks(player.getPlayer(), chunksRed);
}
}
}

Datei anzeigen

@ -8,10 +8,12 @@ import com.sk89q.worldedit.world.World;
import de.warking.hunjy.MySQL.Schematic;
import de.warking.hunjy.MySQL.SchematicType;
import de.warking.hunjy.MySQL.WarkingUser;
import javafx.util.Pair;
import me.yaruma.fightsystem.FightSystem;
import me.yaruma.fightsystem.kit.KitManager;
import me.yaruma.fightsystem.utils.Config;
import me.yaruma.fightsystem.utils.ItemBuilder;
import me.yaruma.fightsystem.utils.TechHider;
import me.yaruma.fightsystem.winconditions.WinconditionTechKO;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.chat.ClickEvent;
@ -98,6 +100,7 @@ public class FightTeam {
}
public FightPlayer addMember(Player player) {
final List<Pair<Integer, Integer>> chunksToReload = TechHider.prepareChunkReload(player);
FightPlayer fightPlayer = new FightPlayer(player, false);
players.add(fightPlayer);
invited.remove(player);
@ -105,6 +108,7 @@ public class FightTeam {
player.setGameMode(GameMode.ADVENTURE);
player.teleport(spawn);
player.getInventory().setItem(1, new ItemBuilder(Material.LEATHER_CHESTPLATE).removeAllAtributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName("§eKit wählen").build());
TechHider.reloadChunks(player, chunksToReload);
return fightPlayer;
}
@ -113,6 +117,7 @@ public class FightTeam {
if(fightPlayer == null)
return;
final List<Pair<Integer, Integer>> chunksToReload = TechHider.prepareChunkReload(player);
players.remove(fightPlayer);
fightPlayer.getPlayer().getInventory().clear();
if(fightPlayer.equals(leader) && FightSystem.getFightState() == FightState.SETUP){
@ -128,6 +133,7 @@ public class FightTeam {
player.setGameMode(GameMode.SPECTATOR);
player.teleport(Config.SpecSpawn);
TechHider.reloadChunks(player, chunksToReload);
}
public boolean hasTeamLeader() {

Datei anzeigen

@ -13,12 +13,16 @@ import com.comphenix.protocol.wrappers.WrappedBlockData;
import com.comphenix.protocol.wrappers.nbt.NbtCompound;
import com.comphenix.protocol.wrappers.nbt.NbtFactory;
import com.google.common.primitives.Bytes;
import javafx.util.Pair;
import me.yaruma.fightsystem.FightSystem;
import me.yaruma.fightsystem.fight.Fight;
import me.yaruma.fightsystem.fight.FightTeam;
import net.minecraft.server.v1_12_R1.PacketPlayOutMapChunk;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.craftbukkit.v1_12_R1.CraftChunk;
import org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer;
import org.bukkit.entity.Player;
import java.util.ArrayList;
@ -39,7 +43,7 @@ public class TechHider {
private static int redMinZ;
private static int redMaxZ;
private static short obfuscateShift4;
private static final short fullBitmask = 0x1FFF;
private static final short BITMASK = 0x1FF;
private static Material obfuscateMaterial;
public static void init(){
@ -130,25 +134,28 @@ public class TechHider {
i += readVarIntLength(Bytes.toArray(newData), i);
i += dataArrayLength * 8;
}else{
//System.out.println("Full chunk " + chunkX + " " + chunkZ + " " + chunkX*16 + " " + chunkZ*16);
int dataArrayLength = readVarInt(Bytes.toArray(newData), i);
i += readVarIntLength(Bytes.toArray(newData), i);
int arrayEnd = dataArrayLength * 8 + i;
/*int arrayEnd = dataArrayLength * 8 + i;
int bitsOver = 8; //9 bits (id) + 4 bits (metadata)
while(i < arrayEnd){
int blockId = (newData.get(i++) & (0x1FF >> 9 - bitsOver)) << 9-bitsOver;
int blockId = (newData.get(i++) & (BITMASK >> 9 - bitsOver)) << 9-bitsOver;
blockId += newData.get(i) >> bitsOver-1;
if(Config.HiddenBlocks.contains(blockId)){
System.out.println("Hidden Block found!");
int bytei = newData.get(i);
final short debug = 44;
newData.set(i-1, (byte)(newData.get(i-1) & -(BITMASK >> 9-bitsOver) | debug >> 9-bitsOver));
newData.set(i, (byte)(newData.get(i) & -(BITMASK << bitsOver-1) | debug << bitsOver-1));
System.out.println(blockId + " replaced at " + chunkX + " " + chunkZ + " i:" + i + " " + String.format("%8s", Integer.toBinaryString(newData.get(i-1) & 0xFF)).replace(' ', '0') + String.format("%8s", Integer.toBinaryString(newData.get(i) & 0xFF)).replace(' ', '0') + " " + bitsOver);
changed = true;
}
bitsOver -= 5; // 13-8
if(bitsOver < 1){
i++;
bitsOver += 8;
}
}
//i += dataArrayLength * 8;
}*/
i += dataArrayLength * 8;
}
i += 4096; //Skylight (Not in Nether/End!!!) 2048 + Blocklight 2048
@ -250,15 +257,26 @@ public class TechHider {
if(ft == null){
return false;
}else if(ft == Fight.getBlueTeam()){
return Config.Entern || ! (redMinX <= chunkX && chunkX <= redMaxX && redMinZ <= chunkZ && chunkZ <= redMaxZ);
return FightSystem.isEntern() || !(redMinX <= chunkX && chunkX <= redMaxX && redMinZ <= chunkZ && chunkZ <= redMaxZ);
}else{
return Config.Entern || ! (blueMinX <= chunkX && chunkX <= blueMaxX && blueMinZ <= chunkZ && chunkZ <= blueMaxZ);
return FightSystem.isEntern() || !(blueMinX <= chunkX && chunkX <= blueMaxX && blueMinZ <= chunkZ && chunkZ <= blueMaxZ);
}
}
private static void reloadChunks(){
Player p = Bukkit.getPlayer("Lixfel");
public static List<Pair<Integer, Integer>> prepareChunkReload(Player p){
List<Pair<Integer, Integer>> chunksToReload = new ArrayList<>();
for(int x = arenaMinX; x <= arenaMaxX; x++)
for(int z = arenaMinZ; z <= arenaMaxZ; z++)
if(!bypass(p, x, z))
chunksToReload.add(new Pair<>(x, z));
return chunksToReload;
}
public static void reloadChunks(Player p, List<Pair<Integer, Integer>> chunksToReload){
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> {
for(Pair<Integer, Integer> chunk : chunksToReload)
((CraftPlayer)p).getHandle().playerConnection.sendPacket(new PacketPlayOutMapChunk(((CraftChunk)p.getWorld().getChunkAt(chunk.getKey(), chunk.getValue())).getHandle(), 65535));
}, 20);
}
private static int readVarInt(byte[] array, int startPos) {