SteamWar/FightSystem
Archiviert
13
1

GameMode 1 Spectator #190

Manuell gemergt
Lixfel hat 6 Commits von gm1Spectator nach master 2020-10-29 19:57:48 +01:00 zusammengeführt
Nur Änderungen aus Commit 192602625b werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -22,7 +22,6 @@ package de.steamwar.fightsystem.fight;
import com.comphenix.protocol.PacketType; import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.ProtocolLibrary; import com.comphenix.protocol.ProtocolLibrary;
import com.comphenix.protocol.events.PacketContainer; import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.reflect.StructureModifier;
import com.comphenix.protocol.wrappers.EnumWrappers; import com.comphenix.protocol.wrappers.EnumWrappers;
import com.comphenix.protocol.wrappers.PlayerInfoData; import com.comphenix.protocol.wrappers.PlayerInfoData;
import com.comphenix.protocol.wrappers.WrappedChatComponent; import com.comphenix.protocol.wrappers.WrappedChatComponent;
@ -48,18 +47,6 @@ public class Fight {
public static final FightTeam blueTeam = new FightTeam(Config.TeamBlueName, Config.TeamBluePrefix, Config.TeamBlueSpawn, Config.TeamBlueCornerX, Config.TeamBlueCornerY, Config.TeamBlueCornerZ, Config.TeamBlueRotate, true, Config.BlueLeader); public static final FightTeam blueTeam = new FightTeam(Config.TeamBlueName, Config.TeamBluePrefix, Config.TeamBlueSpawn, Config.TeamBlueCornerX, Config.TeamBlueCornerY, Config.TeamBlueCornerZ, Config.TeamBlueRotate, true, Config.BlueLeader);
private static int schemRank; private static int schemRank;
private static final PacketContainer flying_packet = new PacketContainer(PacketType.Play.Server.ABILITIES);
static {
flying_packet.getBytes().write(0, (byte)0x06);
StructureModifier<Boolean> booleans = flying_packet.getBooleans();
booleans.write(0, false);
booleans.write(1, true);
booleans.write(2, true);
booleans.write(3, false);
flying_packet.getFloat().writeDefaults();
}
public static void init(){ public static void init(){
IFight.init(redTeam, blueTeam); IFight.init(redTeam, blueTeam);
} }
@ -138,8 +125,8 @@ public class Fight {
if(gameMode == GameMode.SPECTATOR) { if(gameMode == GameMode.SPECTATOR) {
for(Player currentPlayer : Bukkit.getServer().getOnlinePlayers()) { for(Player currentPlayer : Bukkit.getServer().getOnlinePlayers()) {
if(currentPlayer.getUniqueId() != player.getUniqueId() && currentPlayer.getGameMode() == GameMode.SPECTATOR) { if(currentPlayer.getUniqueId() != player.getUniqueId() && currentPlayer.getGameMode() == GameMode.SPECTATOR) {
currentPlayer.hidePlayer(player); currentPlayer.hidePlayer(FightSystem.getPlugin(), player);
player.hidePlayer(currentPlayer); player.hidePlayer(FightSystem.getPlugin(), currentPlayer);
} }
} }
@ -147,14 +134,13 @@ public class Fight {
return; return;
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> { Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> {
PacketContainer gm_1_packet = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.PLAYER_INFO); PacketContainer gm1packet = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.PLAYER_INFO);
gm_1_packet.getPlayerInfoAction().write(0, EnumWrappers.PlayerInfoAction.UPDATE_GAME_MODE); gm1packet.getPlayerInfoAction().write(0, EnumWrappers.PlayerInfoAction.UPDATE_GAME_MODE);
List<PlayerInfoData> playerInfoActions = new ArrayList<>(); List<PlayerInfoData> playerInfoActions = new ArrayList<>();
playerInfoActions.add(new PlayerInfoData(WrappedGameProfile.fromPlayer(player), 1, EnumWrappers.NativeGameMode.CREATIVE, WrappedChatComponent.fromText(player.getDisplayName()))); playerInfoActions.add(new PlayerInfoData(WrappedGameProfile.fromPlayer(player), 1, EnumWrappers.NativeGameMode.CREATIVE, WrappedChatComponent.fromText(player.getDisplayName())));
gm_1_packet.getPlayerInfoDataLists().write(0, playerInfoActions); gm1packet.getPlayerInfoDataLists().write(0, playerInfoActions);
try { try {
ProtocolLibrary.getProtocolManager().sendServerPacket(player, gm_1_packet); ProtocolLibrary.getProtocolManager().sendServerPacket(player, gm1packet);
ProtocolLibrary.getProtocolManager().sendServerPacket(player, flying_packet);
} catch (InvocationTargetException e) { } catch (InvocationTargetException e) {
Bukkit.getLogger().log(Level.SEVERE, "Invocation target exception", e); Bukkit.getLogger().log(Level.SEVERE, "Invocation target exception", e);
} }
@ -162,8 +148,8 @@ public class Fight {
}else if(gameMode == GameMode.SURVIVAL) { }else if(gameMode == GameMode.SURVIVAL) {
for(Player currentPlayer : Bukkit.getServer().getOnlinePlayers()) { for(Player currentPlayer : Bukkit.getServer().getOnlinePlayers()) {
if(currentPlayer.getUniqueId() != player.getUniqueId() && currentPlayer.getGameMode() == GameMode.SPECTATOR) { if(currentPlayer.getUniqueId() != player.getUniqueId() && currentPlayer.getGameMode() == GameMode.SPECTATOR) {
currentPlayer.showPlayer(player); currentPlayer.showPlayer(FightSystem.getPlugin(), player);
player.showPlayer(currentPlayer); player.showPlayer(FightSystem.getPlugin(), currentPlayer);
} }
} }
} }