Fixing computation + various other things (blue bug still there)
Dieser Commit ist enthalten in:
Ursprung
24f5958444
Commit
89484f6e5d
@ -5,8 +5,8 @@ import org.bukkit.entity.Player;
|
||||
|
||||
public class Fight {
|
||||
|
||||
public static final FightTeam redTeam = new FightTeam(Config.TeamRedName, Config.TeamRedPrefix, Config.TeamRedSpawn, Config.TeamRedPaste, Config.TeamRedRotate);
|
||||
public static final FightTeam blueTeam = new FightTeam(Config.TeamBlueName, Config.TeamBluePrefix, Config.TeamBlueSpawn, Config.TeamBluePaste, Config.TeamBlueRotate);
|
||||
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, true);
|
||||
|
||||
|
||||
public static FightTeam getPlayerTeam(Player player) {
|
||||
|
@ -42,18 +42,20 @@ public class FightTeam {
|
||||
private final String name;
|
||||
private final String prefix;
|
||||
private Schematic schematic;
|
||||
private final boolean blue;
|
||||
|
||||
private final Location spawn;
|
||||
private final Vector paste;
|
||||
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;
|
||||
paste = Paste;
|
||||
name = Name;
|
||||
prefix = Prefix;
|
||||
ready = false;
|
||||
rotate = Rotate;
|
||||
blue = Blue;
|
||||
}
|
||||
|
||||
public void teleportToSpawn(){
|
||||
@ -140,6 +142,13 @@ public class FightTeam {
|
||||
return leader != null;
|
||||
}
|
||||
|
||||
public boolean isBlue(){
|
||||
return blue;
|
||||
}
|
||||
public boolean isRed(){
|
||||
return !blue;
|
||||
}
|
||||
|
||||
public FightPlayer getLeader() {
|
||||
return leader;
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ public class PlayerMoveListener implements Listener {
|
||||
player.teleport(from);
|
||||
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.sendMessage(FightSystem.PREFIX + "§cDu darfst nicht zu " + Fight.getOpposite(fightTeam).getName() + "§c!");
|
||||
}
|
||||
|
@ -49,24 +49,21 @@ public class TechHider {
|
||||
private static Material obfuscateMaterial;
|
||||
|
||||
public static void init(){
|
||||
arenaMinX = Config.ArenaMinX / 16 - (Config.ArenaMinX % 16 < 0 ? 1 : 0);
|
||||
arenaMinZ = Config.ArenaMinZ / 16 - (Config.ArenaMinZ % 16 < 0 ? 1 : 0);
|
||||
arenaMaxX = Config.ArenaMaxX / 16 + (Config.ArenaMaxX % 16 > 0 ? 1 : 0);
|
||||
arenaMaxZ = Config.ArenaMaxZ / 16 + (Config.ArenaMaxZ % 16 > 0 ? 1 : 0);
|
||||
blueMinX = Config.TeamBlueCornerX / 16 - (Config.TeamBlueCornerX % 16 < 0 ? 1 : 0);
|
||||
blueMinZ = Config.TeamBlueCornerZ / 16 - (Config.TeamBlueCornerZ % 16 < 0 ? 1 : 0);
|
||||
int max = Config.TeamBlueCornerX + Config.SchemsizeX;
|
||||
blueMaxX = max / 16 + (max % 16 > 0 ? 1 : 0);
|
||||
max = Config.TeamBlueCornerZ + Config.SchemsizeZ;
|
||||
blueMaxZ = max / 16 + (max % 16 > 0 ? 1 : 0);
|
||||
redMinX = Config.TeamRedCornerX / 16 - (Config.TeamRedCornerX % 16 < 0 ? 1 : 0);
|
||||
redMinZ = Config.TeamRedCornerZ / 16 - (Config.TeamRedCornerZ % 16 < 0 ? 1 : 0);
|
||||
max = Config.TeamRedCornerX + Config.SchemsizeX;
|
||||
redMaxX = max / 16 + (max % 16 > 0 ? 1 : 0);
|
||||
max = Config.TeamRedCornerZ + Config.SchemsizeZ;
|
||||
redMaxZ = max / 16 + (max % 16 > 0 ? 1 : 0);
|
||||
arenaMinX = posToChunk(Config.ArenaMinX);
|
||||
arenaMinZ = posToChunk(Config.ArenaMinZ);
|
||||
blueMinX = posToChunk(Config.TeamBlueCornerX);
|
||||
blueMinZ = posToChunk(Config.TeamBlueCornerZ);
|
||||
redMinX = posToChunk(Config.TeamRedCornerX);
|
||||
redMinZ = posToChunk(Config.TeamRedCornerZ);
|
||||
|
||||
arenaMaxX = posToChunk(Config.ArenaMaxX) + 1;
|
||||
arenaMaxZ = posToChunk(Config.ArenaMaxZ) + 1;
|
||||
blueMaxX = posToChunk(Config.TeamBlueCornerX + Config.SchemsizeX) + 1;
|
||||
blueMaxZ = posToChunk(Config.TeamBlueCornerZ + Config.SchemsizeZ) + 1;
|
||||
redMaxX = posToChunk(Config.TeamRedCornerX + Config.SchemsizeX) + 1;
|
||||
redMaxZ = posToChunk(Config.TeamRedCornerZ + Config.SchemsizeZ) + 1;
|
||||
|
||||
obfuscateShift4 = (short)(Config.ObfuscateWith << 4);
|
||||
//noinspection deprecation
|
||||
obfuscateMaterial = Material.getMaterial(Config.ObfuscateWith);
|
||||
|
||||
System.out.println("Arena: " + arenaMinX + "->" + arenaMaxX + " " + arenaMinZ + "->" + arenaMaxZ);
|
||||
@ -180,7 +177,7 @@ public class TechHider {
|
||||
BlockPosition pos = packet.getBlockPositionModifier().read(0);
|
||||
|
||||
Player p = e.getPlayer();
|
||||
if(bypass(p, pos.getX() / 16, pos.getZ() / 16))
|
||||
if(bypass(p, posToChunk(pos.getX()), posToChunk(pos.getZ())))
|
||||
return;
|
||||
|
||||
WrappedBlockData block = blockStructure.read(0);
|
||||
@ -222,8 +219,9 @@ public class TechHider {
|
||||
public void onPacketSending(PacketEvent e) {
|
||||
PacketContainer packet = e.getPacket();
|
||||
BlockPosition pos = packet.getBlockPositionModifier().read(0);
|
||||
|
||||
Player p = e.getPlayer();
|
||||
if(bypass(p, pos.getX() / 16, pos.getZ() / 16))
|
||||
if(bypass(p, posToChunk(pos.getX()), posToChunk(pos.getZ())))
|
||||
return;
|
||||
|
||||
e.setCancelled(true);
|
||||
@ -265,7 +263,7 @@ public class TechHider {
|
||||
FightTeam ft = Fight.getPlayerTeam(p);
|
||||
if(ft == null){
|
||||
return false;
|
||||
}else if(ft.equals(Fight.getBlueTeam())){
|
||||
}else if(ft.isBlue()){
|
||||
return FightSystem.isEntern() ||
|
||||
redMinX > chunkX ||
|
||||
chunkX > redMaxX ||
|
||||
@ -291,11 +289,20 @@ public class TechHider {
|
||||
|
||||
public static void reloadChunks(Player p, List<Pair<Integer, Integer>> chunksToReload){
|
||||
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> {
|
||||
for(Pair<Integer, Integer> chunk : chunksToReload)
|
||||
for(Pair<Integer, Integer> chunk : chunksToReload){
|
||||
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);
|
||||
}
|
||||
|
||||
private static int posToChunk(int c){
|
||||
int chunk = c / 16;
|
||||
if(c<0)
|
||||
chunk--;
|
||||
return chunk;
|
||||
}
|
||||
|
||||
private static int readVarInt(byte[] array, int startPos) {
|
||||
int numRead = 0;
|
||||
int result = 0;
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren