SteamWar/FightSystem
Archiviert
13
1

Fixing computation + various other things (blue bug still there)

Dieser Commit ist enthalten in:
Travis CI 2019-07-01 18:04:46 +02:00
Ursprung 24f5958444
Commit 89484f6e5d
4 geänderte Dateien mit 42 neuen und 26 gelöschten Zeilen

Datei anzeigen

@ -5,8 +5,8 @@ import org.bukkit.entity.Player;
public class Fight { public class Fight {
public static final FightTeam redTeam = new FightTeam(Config.TeamRedName, Config.TeamRedPrefix, Config.TeamRedSpawn, Config.TeamRedPaste, Config.TeamRedRotate); public static final FightTeam redTeam = new FightTeam(Config.TeamRedName, Config.TeamRedPrefix, Config.TeamRedSpawn, Config.TeamRedPaste, Config.TeamRedRotate, false);
public static final FightTeam blueTeam = new FightTeam(Config.TeamBlueName, Config.TeamBluePrefix, Config.TeamBlueSpawn, Config.TeamBluePaste, Config.TeamBlueRotate); public static final FightTeam blueTeam = new FightTeam(Config.TeamBlueName, Config.TeamBluePrefix, Config.TeamBlueSpawn, Config.TeamBluePaste, Config.TeamBlueRotate, true);
public static FightTeam getPlayerTeam(Player player) { public static FightTeam getPlayerTeam(Player player) {

Datei anzeigen

@ -42,18 +42,20 @@ public class FightTeam {
private final String name; private final String name;
private final String prefix; private final String prefix;
private Schematic schematic; private Schematic schematic;
private final boolean blue;
private final Location spawn; private final Location spawn;
private final Vector paste; private final Vector paste;
private final boolean rotate; private final boolean rotate;
public FightTeam(String Name, String Prefix, Location Spawn, Vector Paste, boolean Rotate) { public FightTeam(String Name, String Prefix, Location Spawn, Vector Paste, boolean Rotate, boolean Blue) {
spawn = Spawn; spawn = Spawn;
paste = Paste; paste = Paste;
name = Name; name = Name;
prefix = Prefix; prefix = Prefix;
ready = false; ready = false;
rotate = Rotate; rotate = Rotate;
blue = Blue;
} }
public void teleportToSpawn(){ public void teleportToSpawn(){
@ -140,6 +142,13 @@ public class FightTeam {
return leader != null; return leader != null;
} }
public boolean isBlue(){
return blue;
}
public boolean isRed(){
return !blue;
}
public FightPlayer getLeader() { public FightPlayer getLeader() {
return leader; return leader;
} }

Datei anzeigen

@ -59,7 +59,7 @@ public class PlayerMoveListener implements Listener {
player.teleport(from); player.teleport(from);
player.sendMessage(FightSystem.PREFIX + "§cDu darfst nicht weiter zu den Kämpfern!"); player.sendMessage(FightSystem.PREFIX + "§cDu darfst nicht weiter zu den Kämpfern!");
} }
}else if(fightTeam != null && !instance.isEntern()){ }else if(fightTeam != null && !instance.isEntern() && !fightTeam.getFightPlayer(player).isOut()){
player.teleport(from); player.teleport(from);
player.sendMessage(FightSystem.PREFIX + "§cDu darfst nicht zu " + Fight.getOpposite(fightTeam).getName() + "§c!"); player.sendMessage(FightSystem.PREFIX + "§cDu darfst nicht zu " + Fight.getOpposite(fightTeam).getName() + "§c!");
} }

Datei anzeigen

@ -49,24 +49,21 @@ public class TechHider {
private static Material obfuscateMaterial; private static Material obfuscateMaterial;
public static void init(){ public static void init(){
arenaMinX = Config.ArenaMinX / 16 - (Config.ArenaMinX % 16 < 0 ? 1 : 0); arenaMinX = posToChunk(Config.ArenaMinX);
arenaMinZ = Config.ArenaMinZ / 16 - (Config.ArenaMinZ % 16 < 0 ? 1 : 0); arenaMinZ = posToChunk(Config.ArenaMinZ);
arenaMaxX = Config.ArenaMaxX / 16 + (Config.ArenaMaxX % 16 > 0 ? 1 : 0); blueMinX = posToChunk(Config.TeamBlueCornerX);
arenaMaxZ = Config.ArenaMaxZ / 16 + (Config.ArenaMaxZ % 16 > 0 ? 1 : 0); blueMinZ = posToChunk(Config.TeamBlueCornerZ);
blueMinX = Config.TeamBlueCornerX / 16 - (Config.TeamBlueCornerX % 16 < 0 ? 1 : 0); redMinX = posToChunk(Config.TeamRedCornerX);
blueMinZ = Config.TeamBlueCornerZ / 16 - (Config.TeamBlueCornerZ % 16 < 0 ? 1 : 0); redMinZ = posToChunk(Config.TeamRedCornerZ);
int max = Config.TeamBlueCornerX + Config.SchemsizeX;
blueMaxX = max / 16 + (max % 16 > 0 ? 1 : 0); arenaMaxX = posToChunk(Config.ArenaMaxX) + 1;
max = Config.TeamBlueCornerZ + Config.SchemsizeZ; arenaMaxZ = posToChunk(Config.ArenaMaxZ) + 1;
blueMaxZ = max / 16 + (max % 16 > 0 ? 1 : 0); blueMaxX = posToChunk(Config.TeamBlueCornerX + Config.SchemsizeX) + 1;
redMinX = Config.TeamRedCornerX / 16 - (Config.TeamRedCornerX % 16 < 0 ? 1 : 0); blueMaxZ = posToChunk(Config.TeamBlueCornerZ + Config.SchemsizeZ) + 1;
redMinZ = Config.TeamRedCornerZ / 16 - (Config.TeamRedCornerZ % 16 < 0 ? 1 : 0); redMaxX = posToChunk(Config.TeamRedCornerX + Config.SchemsizeX) + 1;
max = Config.TeamRedCornerX + Config.SchemsizeX; redMaxZ = posToChunk(Config.TeamRedCornerZ + Config.SchemsizeZ) + 1;
redMaxX = max / 16 + (max % 16 > 0 ? 1 : 0);
max = Config.TeamRedCornerZ + Config.SchemsizeZ;
redMaxZ = max / 16 + (max % 16 > 0 ? 1 : 0);
obfuscateShift4 = (short)(Config.ObfuscateWith << 4); obfuscateShift4 = (short)(Config.ObfuscateWith << 4);
//noinspection deprecation
obfuscateMaterial = Material.getMaterial(Config.ObfuscateWith); obfuscateMaterial = Material.getMaterial(Config.ObfuscateWith);
System.out.println("Arena: " + arenaMinX + "->" + arenaMaxX + " " + arenaMinZ + "->" + arenaMaxZ); System.out.println("Arena: " + arenaMinX + "->" + arenaMaxX + " " + arenaMinZ + "->" + arenaMaxZ);
@ -180,7 +177,7 @@ public class TechHider {
BlockPosition pos = packet.getBlockPositionModifier().read(0); BlockPosition pos = packet.getBlockPositionModifier().read(0);
Player p = e.getPlayer(); Player p = e.getPlayer();
if(bypass(p, pos.getX() / 16, pos.getZ() / 16)) if(bypass(p, posToChunk(pos.getX()), posToChunk(pos.getZ())))
return; return;
WrappedBlockData block = blockStructure.read(0); WrappedBlockData block = blockStructure.read(0);
@ -222,8 +219,9 @@ public class TechHider {
public void onPacketSending(PacketEvent e) { public void onPacketSending(PacketEvent e) {
PacketContainer packet = e.getPacket(); PacketContainer packet = e.getPacket();
BlockPosition pos = packet.getBlockPositionModifier().read(0); BlockPosition pos = packet.getBlockPositionModifier().read(0);
Player p = e.getPlayer(); Player p = e.getPlayer();
if(bypass(p, pos.getX() / 16, pos.getZ() / 16)) if(bypass(p, posToChunk(pos.getX()), posToChunk(pos.getZ())))
return; return;
e.setCancelled(true); e.setCancelled(true);
@ -265,7 +263,7 @@ public class TechHider {
FightTeam ft = Fight.getPlayerTeam(p); FightTeam ft = Fight.getPlayerTeam(p);
if(ft == null){ if(ft == null){
return false; return false;
}else if(ft.equals(Fight.getBlueTeam())){ }else if(ft.isBlue()){
return FightSystem.isEntern() || return FightSystem.isEntern() ||
redMinX > chunkX || redMinX > chunkX ||
chunkX > redMaxX || chunkX > redMaxX ||
@ -291,11 +289,20 @@ public class TechHider {
public static void reloadChunks(Player p, List<Pair<Integer, Integer>> chunksToReload){ public static void reloadChunks(Player p, List<Pair<Integer, Integer>> chunksToReload){
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> { Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> {
for(Pair<Integer, Integer> chunk : chunksToReload) for(Pair<Integer, Integer> chunk : chunksToReload){
((CraftPlayer)p).getHandle().playerConnection.sendPacket(new PacketPlayOutMapChunk(((CraftChunk)p.getWorld().getChunkAt(chunk.getKey(), chunk.getValue())).getHandle(), 65535)); if(bypass(p, chunk.getKey(), chunk.getValue()))
((CraftPlayer)p).getHandle().playerConnection.sendPacket(new PacketPlayOutMapChunk(((CraftChunk)p.getWorld().getChunkAt(chunk.getKey(), chunk.getValue())).getHandle(), 65535));
}
}, 40); }, 40);
} }
private static int posToChunk(int c){
int chunk = c / 16;
if(c<0)
chunk--;
return chunk;
}
private static int readVarInt(byte[] array, int startPos) { private static int readVarInt(byte[] array, int startPos) {
int numRead = 0; int numRead = 0;
int result = 0; int result = 0;