12
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.ProtocolLibrary;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.reflect.StructureModifier;
import com.comphenix.protocol.wrappers.EnumWrappers;
import com.comphenix.protocol.wrappers.PlayerInfoData;
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);
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(){
IFight.init(redTeam, blueTeam);
}
@ -138,8 +125,8 @@ public class Fight {
if(gameMode == GameMode.SPECTATOR) {
for(Player currentPlayer : Bukkit.getServer().getOnlinePlayers()) {
if(currentPlayer.getUniqueId() != player.getUniqueId() && currentPlayer.getGameMode() == GameMode.SPECTATOR) {
currentPlayer.hidePlayer(player);
player.hidePlayer(currentPlayer);
currentPlayer.hidePlayer(FightSystem.getPlugin(), player);
player.hidePlayer(FightSystem.getPlugin(), currentPlayer);
}
}
@ -147,14 +134,13 @@ public class Fight {
return;
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> {
PacketContainer gm_1_packet = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.PLAYER_INFO);
gm_1_packet.getPlayerInfoAction().write(0, EnumWrappers.PlayerInfoAction.UPDATE_GAME_MODE);
PacketContainer gm1packet = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.PLAYER_INFO);
gm1packet.getPlayerInfoAction().write(0, EnumWrappers.PlayerInfoAction.UPDATE_GAME_MODE);
List<PlayerInfoData> playerInfoActions = new ArrayList<>();
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 {
ProtocolLibrary.getProtocolManager().sendServerPacket(player, gm_1_packet);
ProtocolLibrary.getProtocolManager().sendServerPacket(player, flying_packet);
ProtocolLibrary.getProtocolManager().sendServerPacket(player, gm1packet);
} catch (InvocationTargetException e) {
Bukkit.getLogger().log(Level.SEVERE, "Invocation target exception", e);
}
@ -162,8 +148,8 @@ public class Fight {
}else if(gameMode == GameMode.SURVIVAL) {
for(Player currentPlayer : Bukkit.getServer().getOnlinePlayers()) {
if(currentPlayer.getUniqueId() != player.getUniqueId() && currentPlayer.getGameMode() == GameMode.SPECTATOR) {
currentPlayer.showPlayer(player);
player.showPlayer(currentPlayer);
currentPlayer.showPlayer(FightSystem.getPlugin(), player);
player.showPlayer(FightSystem.getPlugin(), currentPlayer);
}
}
}