SteamWar/FightSystem
Archiviert
13
1

RecordSystem (Beta) #199

Manuell gemergt
Lixfel hat 40 Commits von recordSystem nach master 2020-11-01 20:11:45 +01:00 zusammengeführt
3 geänderte Dateien mit 88 neuen und 1 gelöschten Zeilen
Nur Änderungen aus Commit 7af46a1f13 werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -9,6 +9,7 @@ import de.steamwar.fightsystem.fight.FightPlayer;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.kit.KitManager;
import de.steamwar.fightsystem.listener.*;
import de.steamwar.fightsystem.record.RecordSystem;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependent;
import de.steamwar.fightsystem.utils.*;
@ -107,6 +108,7 @@ public class FightSystem extends JavaPlugin {
Objects.requireNonNull(getCommand("ready")).setExecutor(new EventDummyCommand());
Objects.requireNonNull(getCommand("ak")).setExecutor(new EventDummyCommand());
Objects.requireNonNull(getCommand("leader")).setExecutor(new EventDummyCommand());
RecordSystem.init();
setPreSchemState();
}else if(Config.test()){

Datei anzeigen

@ -3,10 +3,12 @@ package de.steamwar.fightsystem.listener;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightPlayer;
import de.steamwar.fightsystem.record.RecordSystem;
import de.steamwar.fightsystem.states.FightState;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import java.util.EnumSet;
@ -22,6 +24,15 @@ public class EventRecordListener extends BasicListener {
if(fp == null || !fp.isLiving())
return;
//TODO: Send Change
RecordSystem.playerJoins(e.getPlayer());
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPlayerMove(PlayerMoveEvent e){
FightPlayer fp = Fight.getFightPlayer(e.getPlayer());
if(fp == null || !fp.isLiving())
return;
RecordSystem.entityMoves(e.getPlayer());
}
}

Datei anzeigen

@ -1,4 +1,78 @@
package de.steamwar.fightsystem.record;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.sql.SteamwarUser;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufAllocator;
import io.netty.buffer.UnpooledUnsafeDirectByteBuf;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
public class RecordSystem {
public static void init(){
if(!Config.event())
return;
Bukkit.getScheduler().runTaskTimer(FightSystem.getPlugin(), RecordSystem::checkWorldState, 1, 1);
}
/*
* PlayerJoinPacket (0x00) + int SWUserId + int EntityId
* EntityMovePacket (0x01) + int EntityId + double x, y, z + float pitch, yaw
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
* */
public static void playerJoins(Player p){
SteamwarUser user = SteamwarUser.get(p.getUniqueId());
ByteBuf buf = new UnpooledUnsafeDirectByteBuf(ByteBufAllocator.DEFAULT, 8, 8); //TODO size
buf.writeByte(0x00);
buf.writeInt(user.getId());
buf.writeInt(p.getEntityId());
send(buf);
entityMoves(p);
}
public static void entityMoves(Entity e){
Location location = e.getLocation();
ByteBuf buf = new UnpooledUnsafeDirectByteBuf(ByteBufAllocator.DEFAULT, 8, 8); //TODO size
buf.writeByte(0x01);
buf.writeInt(e.getEntityId());
buf.writeDouble(location.getX());
buf.writeDouble(location.getY());
buf.writeDouble(location.getZ());
buf.writeFloat(location.getPitch());
buf.writeFloat(location.getYaw());
send(buf);
}
private static void send(ByteBuf buf){
}
private static void checkWorldState(){
//TODO: TNT Entity position check
}
}