SteamWar/FightSystem
Archiviert
13
1

Omni-Replay #280

Manuell gemergt
Lixfel hat 15 Commits von spectate2.0 nach master 2021-08-27 22:12:03 +02:00 zusammengeführt
10 geänderte Dateien mit 56 neuen und 90 gelöschten Zeilen
Nur Änderungen aus Commit 7d1c34d31e werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -49,7 +49,7 @@ public enum ArenaMode {
public static final Set<ArenaMode> AntiPrepare = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(PREPARE)));
public static final Set<ArenaMode> VariableTeams = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(RANKED, EVENT, REPLAY)));
public static final Set<ArenaMode> RankedEvent = Collections.unmodifiableSet(EnumSet.of(RANKED, EVENT, REPLAY));
public static final Set<ArenaMode> Restartable = Collections.unmodifiableSet(EnumSet.of(NORMAL, RANKED));
public static final Set<ArenaMode> Restartable = Collections.unmodifiableSet(EnumSet.of(NORMAL, RANKED, REPLAY));
public static final Set<ArenaMode> SoloLeader = Collections.unmodifiableSet(EnumSet.of(TEST, CHECK, PREPARE));
public static final Set<ArenaMode> NotOnBau = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(TEST, CHECK, PREPARE, REPLAY)));
}

Datei anzeigen

@ -30,7 +30,7 @@ import org.bukkit.entity.Player;
public class RemoveCommand implements CommandExecutor {
public RemoveCommand() {
new StateDependentCommand(ArenaMode.VariableTeams, FightState.Setup, "die", this);
new StateDependentCommand(ArenaMode.VariableTeams, FightState.Setup, "remove", this);
}
@Override

Datei anzeigen

@ -60,7 +60,7 @@ public class FightSchematic extends StateDependent {
private int schematic = 0;
public FightSchematic(FightTeam team, boolean rotate) {
super(ArenaMode.AntiReplay, FightState.PostSchemSetup);
super(ArenaMode.All, FightState.PostSchemSetup);
this.team = team;
this.region = team.getSchemRegion();
this.rotate = rotate;

Datei anzeigen

@ -170,7 +170,7 @@ public class FightTeam implements IFightTeam{
playerSet.forEach(this::addMember);
if(isLeaderless()){
if(ArenaMode.VariableTeams.contains(Config.mode) && isLeaderless()){
for(Player player : Bukkit.getOnlinePlayers()){
if(Fight.getPlayerTeam(player) == null && canbeLeader(player)){
addMember(player);

Datei anzeigen

@ -20,6 +20,7 @@
package de.steamwar.fightsystem.listener;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentListener;
import org.bukkit.Bukkit;
@ -36,7 +37,10 @@ public class Shutdown implements Listener {
@EventHandler(priority = EventPriority.HIGH)
public void handlePlayerQuit(PlayerQuitEvent event) {
//Shutdown server if nobody online and its not an event server
if(Config.replayserver())
return;
//Shutdown server if nobody online
if(Bukkit.getOnlinePlayers().isEmpty() || (Bukkit.getOnlinePlayers().size() == 1 && Bukkit.getOnlinePlayers().contains(event.getPlayer())))
Bukkit.shutdown();
}

Datei anzeigen

@ -38,6 +38,7 @@ public class FileRecorder extends StateDependent implements Recorder {
public FileRecorder(){
super(ArenaMode.AntiReplay, FightState.Recording);
register();
}
@Override

Datei anzeigen

@ -20,12 +20,10 @@
package de.steamwar.fightsystem.record;
import de.steamwar.fightsystem.Config;
import org.bukkit.Bukkit;
import java.io.*;
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
import java.util.logging.Level;
import java.util.zip.GZIPInputStream;
public class FileSource extends PacketSource {
@ -56,7 +54,6 @@ public class FileSource extends PacketSource {
try{
return inputStream.available() == 0;
}catch (IOException e){
Bukkit.getLogger().log(Level.WARNING, "On close test exception", e);
return true;
}
}

Datei anzeigen

@ -289,13 +289,13 @@ public class PacketProcessor {
private void endReplay(){
REntity.dieAll();
freezer.disable();
replaying = false;
if(Config.replayserver() || ArenaMode.AntiReplay.contains(Config.mode)) {
FightSystem.setSpectateState(null, "Replay ends");
}else{
Bukkit.broadcastMessage(FightSystem.PREFIX + "§cReplay beendet");
new EventSpectateCountdown().enable();
}
replaying = false;
}
private void bow() throws IOException {

Datei anzeigen

@ -24,6 +24,7 @@ import com.comphenix.protocol.ProtocolLibrary;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.reflect.StructureModifier;
import com.comphenix.protocol.wrappers.*;
import com.mojang.authlib.GameProfile;
import de.steamwar.core.Core;
import de.steamwar.core.VersionedCallable;
import de.steamwar.fightsystem.listener.FightScoreboard;
@ -55,14 +56,7 @@ public class REntity {
if(entity.fireTick > 0) {
entity.fireTick--;
if(entity.fireTick == 0) {
/*DataWatcher dataWatcher = new DataWatcher(null);
DataWatcherObject<Byte> dataWatcherObject = new DataWatcherObject<>(0, DataWatcherRegistry.a);
dataWatcher.register(dataWatcherObject, (byte) 0);
dataWatcher.markDirty(dataWatcherObject);
entity.sendDataWatcher(dataWatcher);*/
WrappedDataWatcher watcher = new WrappedDataWatcher();
watcher.setObject(0, (byte) 0, true);
ProtocolLibrary.getProtocolManager().broadcastServerPacket(entity.getDataWatcherPacket(watcher));
ProtocolLibrary.getProtocolManager().broadcastServerPacket(entity.getDataWatcherPacket(0, (byte)0));
}
}
});
@ -82,28 +76,14 @@ public class REntity {
}
//ProtocolLibrary.getProtocolManager().sendServerPacket(player, entity.getTeleportPacket()); Sollte nicht nötig sein?
if(entity.fireTick != 0) {
WrappedDataWatcher watcher = new WrappedDataWatcher();
watcher.setObject(0, (byte) 1, true);
/*ProtocolLibrary.getProtocolManager().sendServerPacket(player, entity.getDataWatcherPacket(watcher));
DataWatcher dataWatcher = new DataWatcher(null);
DataWatcherObject<Byte> dataWatcherObject = new DataWatcherObject<>(0, DataWatcherRegistry.a);
dataWatcher.register(dataWatcherObject, (byte) 1);
dataWatcher.markDirty(dataWatcherObject);
entity.sendDataWatcher(dataWatcher);*/
ProtocolLibrary.getProtocolManager().sendServerPacket(player, entity.getDataWatcherPacket(0, (byte) 1));
}
if(entity.sneaks) {
WrappedDataWatcher watcher = new WrappedDataWatcher();
if(Core.getVersion() > 12){
watcher.setObject(6, getPose(true), true);
ProtocolLibrary.getProtocolManager().sendServerPacket(player, entity.getDataWatcherPacket(6, getPose(true)));
}else{
watcher.setObject(0, (byte) 2, true);
ProtocolLibrary.getProtocolManager().sendServerPacket(player, entity.getDataWatcherPacket(0, (byte) 2));
}
ProtocolLibrary.getProtocolManager().sendServerPacket(player, entity.getDataWatcherPacket(watcher));
/*DataWatcher dataWatcher = new DataWatcher(null);
DataWatcherObject<EntityPose> dataWatcherObject = new DataWatcherObject<>(6, DataWatcherRegistry.s);
dataWatcher.register(dataWatcherObject, EntityPose.CROUCHING);
dataWatcher.markDirty(dataWatcherObject);
entity.sendDataWatcher(dataWatcher);*/
}
}
}catch(InvocationTargetException e){
@ -153,7 +133,7 @@ public class REntity {
SteamwarUser user = SteamwarUser.get(userId);
this.uuid = user.getUUID();
this.playerInfoData = new PlayerInfoData(WrappedGameProfile.fromOfflinePlayer(Bukkit.getOfflinePlayer(uuid)), 0, EnumWrappers.NativeGameMode.SURVIVAL, WrappedChatComponent.fromText(user.getUserName()));
this.playerInfoData = new PlayerInfoData(WrappedGameProfile.fromHandle(new GameProfile(uuid, user.getUserName())), 0, EnumWrappers.NativeGameMode.SURVIVAL, WrappedChatComponent.fromText(user.getUserName()));
entities.put(internalId, this);
ProtocolLibrary.getProtocolManager().broadcastServerPacket(getPlayerInfoPacket());
@ -211,18 +191,11 @@ public class REntity {
public void sneak(boolean sneaking) {
sneaks = sneaking;
/*DataWatcher dataWatcher = new DataWatcher(null);
DataWatcherObject<EntityPose> dataWatcherObject = new DataWatcherObject<>(6, DataWatcherRegistry.s);
dataWatcher.register(dataWatcherObject, sneaking?EntityPose.CROUCHING:EntityPose.STANDING);
dataWatcher.markDirty(dataWatcherObject);*/
WrappedDataWatcher watcher = new WrappedDataWatcher();
if(Core.getVersion() > 12){
watcher.setObject(6, getPose(sneaking), true);
ProtocolLibrary.getProtocolManager().broadcastServerPacket(getDataWatcherPacket(6, getPose(sneaking)));
}else{
watcher.setObject(0, sneaking ? (byte) 2 : (byte) 0, true);
ProtocolLibrary.getProtocolManager().broadcastServerPacket(getDataWatcherPacket(0, sneaking ? (byte) 2 : (byte) 0));
}
ProtocolLibrary.getProtocolManager().broadcastServerPacket(getDataWatcherPacket(watcher));
}
public void setOnFire(boolean perma) {
@ -232,36 +205,21 @@ public class REntity {
fireTick = -1;
}
/*DataWatcher dataWatcher = new DataWatcher(null);
DataWatcherObject<Byte> dataWatcherObject = new DataWatcherObject<>(0, DataWatcherRegistry.a);
dataWatcher.register(dataWatcherObject, (byte) 1);
dataWatcher.markDirty(dataWatcherObject);*/
WrappedDataWatcher watcher = new WrappedDataWatcher();
watcher.setObject(0, (byte) 1, true);
ProtocolLibrary.getProtocolManager().broadcastServerPacket(getDataWatcherPacket(watcher));
ProtocolLibrary.getProtocolManager().broadcastServerPacket(getDataWatcherPacket(0, (byte) 1));
}
public void setBowDrawn(boolean drawn, boolean offHand) {
/*DataWatcher dataWatcher = new DataWatcher(null);
DataWatcherObject<Byte> dataWatcherObject = new DataWatcherObject<>(7, DataWatcherRegistry.a);
dataWatcher.register(dataWatcherObject, (byte) ((drawn ? 1 : 0) + (offHand ? 2 : 0)));
dataWatcher.markDirty(dataWatcherObject);
*/
WrappedDataWatcher watcher = new WrappedDataWatcher();
if(Core.getVersion() > 8){
watcher.setObject(Core.getVersion() > 12 ? 7 : 6, (byte) ((drawn ? 1 : 0) + (offHand ? 2 : 0)), true);
ProtocolLibrary.getProtocolManager().broadcastServerPacket(getDataWatcherPacket(Core.getVersion() > 12 ? 7 : 6, (byte) ((drawn ? 1 : 0) + (offHand ? 2 : 0))));
}else{
watcher.setObject(0, (byte)0x10, true);
ProtocolLibrary.getProtocolManager().broadcastServerPacket(getDataWatcherPacket(0, (byte)0x10));
}
ProtocolLibrary.getProtocolManager().broadcastServerPacket(getDataWatcherPacket(watcher));
}
public void setItem(String item, boolean enchanted, String slot) {
ItemStack stack = new ItemStack(Material.valueOf(item.replace("minecraft:", "").toUpperCase()), 1);
if(enchanted)
stack.addEnchantment(Enchantment.DURABILITY, 1);
stack.addUnsafeEnchantment(Enchantment.DURABILITY, 1);
itemSlots.put(slot, stack);
ProtocolLibrary.getProtocolManager().broadcastServerPacket(getEquipmentPacket(slot, stack));
@ -310,10 +268,12 @@ public class REntity {
bytes.write(1, pitch);
}
private PacketContainer getDataWatcherPacket(WrappedDataWatcher dataWatcher) {
private PacketContainer getDataWatcherPacket(int index, Object value) {
PacketContainer metadataPacket = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.ENTITY_METADATA);
metadataPacket.getIntegers().write(0, entityId);
metadataPacket.getDataWatcherModifier().write(0, dataWatcher);
WrappedWatchableObject watchable = new WrappedWatchableObject(new WrappedDataWatcher.WrappedDataWatcherObject(index, WrappedDataWatcher.Registry.get(value.getClass())), value);
watchable.setDirtyState(true);
metadataPacket.getWatchableCollectionModifier().write(0, Collections.singletonList(watchable));
return metadataPacket;
}
@ -327,7 +287,7 @@ public class REntity {
private PacketContainer getHeadRotationPacket(){
PacketContainer headRotation = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.ENTITY_HEAD_ROTATION);
headRotation.getIntegers().write(0, entityId);
headRotation.getBytes().write(1, headYaw);
headRotation.getBytes().write(0, headYaw);
return headRotation;
}
@ -366,7 +326,7 @@ public class REntity {
PacketContainer equipmentPacket = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.ENTITY_EQUIPMENT);
StructureModifier<Integer> ints = equipmentPacket.getIntegers();
ints.write(0, entityId);
if(Core.getVersion() > 8){
if(Core.getVersion() == 8){
switch(slot){
case "MAINHAND":
case "OFFHAND":

Datei anzeigen

@ -122,7 +122,7 @@ public interface Recorder {
default void entityMoves(Entity e){
Location location = e.getLocation();
write(0x01, e.getEntityId(), location.getX(), location.getY(), location.getZ(), location.getPitch(), location.getYaw(), (int)(VersionedCallable.call(
write(0x01, e.getEntityId(), location.getX(), location.getY(), location.getZ(), location.getPitch(), location.getYaw(), (byte)(VersionedCallable.call(
new VersionedCallable<>(() -> FightWorld_8.headRotation(e), 8),
new VersionedCallable<>(() -> FightWorld_9.headRotation(e), 9),
new VersionedCallable<>(() -> FightWorld_10.headRotation(e), 10),
@ -141,7 +141,7 @@ public interface Recorder {
}
default void entityAnimation(Entity e, int animation){
write(0x04, e.getEntityId(), animation);
write(0x04, e.getEntityId(), (byte)animation);
}
default void tntSpawn(Entity e){
@ -194,10 +194,10 @@ public interface Recorder {
int shortZ = block.getZ() - Config.ArenaRegion.getMinZ();
if((short)blockState == blockState && shortX > 0 && shortX < 256 && shortZ > 0 && shortZ < 256){
//Short block packet
write(0x33, shortX, block.getY(), shortZ, (short)blockState);
write(0x33, (byte)shortX, (byte)block.getY(), (byte)shortZ, (short)blockState);
}else{
//Block packet
write(0x30, block.getX(), block.getY(), block.getZ(), blockState);
write(0x30, block.getX(), (byte)block.getY(), block.getZ(), blockState);
}
}
@ -252,9 +252,12 @@ public interface Recorder {
default void write(int id, Object... objects){
DataOutputStream stream = getStream();
try {
synchronized (stream) {
stream.writeByte(id);
for(Object o : objects){
if(o instanceof Byte)
if(o instanceof Boolean)
stream.writeBoolean((Boolean)o);
else if(o instanceof Byte)
stream.writeByte((Byte)o);
else if(o instanceof Short)
stream.writeShort((Short)o);
@ -270,6 +273,7 @@ public interface Recorder {
throw new SecurityException("Undefined write for: " + o.getClass().getName());
}
stream.flush();
}
} catch (IOException e) {
Bukkit.getLogger().log(Level.SEVERE, "Could not write", e);
try {