RecordSystem (Beta) #199
@ -9,6 +9,7 @@ import de.steamwar.fightsystem.fight.FightPlayer;
|
|||||||
import de.steamwar.fightsystem.fight.FightTeam;
|
import de.steamwar.fightsystem.fight.FightTeam;
|
||||||
import de.steamwar.fightsystem.kit.KitManager;
|
import de.steamwar.fightsystem.kit.KitManager;
|
||||||
import de.steamwar.fightsystem.listener.*;
|
import de.steamwar.fightsystem.listener.*;
|
||||||
|
import de.steamwar.fightsystem.record.RecordSystem;
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.states.StateDependent;
|
import de.steamwar.fightsystem.states.StateDependent;
|
||||||
import de.steamwar.fightsystem.utils.*;
|
import de.steamwar.fightsystem.utils.*;
|
||||||
@ -107,6 +108,7 @@ public class FightSystem extends JavaPlugin {
|
|||||||
Objects.requireNonNull(getCommand("ready")).setExecutor(new EventDummyCommand());
|
Objects.requireNonNull(getCommand("ready")).setExecutor(new EventDummyCommand());
|
||||||
Objects.requireNonNull(getCommand("ak")).setExecutor(new EventDummyCommand());
|
Objects.requireNonNull(getCommand("ak")).setExecutor(new EventDummyCommand());
|
||||||
Objects.requireNonNull(getCommand("leader")).setExecutor(new EventDummyCommand());
|
Objects.requireNonNull(getCommand("leader")).setExecutor(new EventDummyCommand());
|
||||||
|
RecordSystem.init();
|
||||||
|
|
||||||
setPreSchemState();
|
setPreSchemState();
|
||||||
}else if(Config.test()){
|
}else if(Config.test()){
|
||||||
|
@ -3,10 +3,12 @@ package de.steamwar.fightsystem.listener;
|
|||||||
import de.steamwar.fightsystem.Config;
|
import de.steamwar.fightsystem.Config;
|
||||||
import de.steamwar.fightsystem.fight.Fight;
|
import de.steamwar.fightsystem.fight.Fight;
|
||||||
import de.steamwar.fightsystem.fight.FightPlayer;
|
import de.steamwar.fightsystem.fight.FightPlayer;
|
||||||
|
import de.steamwar.fightsystem.record.RecordSystem;
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
|
import org.bukkit.event.player.PlayerMoveEvent;
|
||||||
|
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
|
|
||||||
@ -22,6 +24,15 @@ public class EventRecordListener extends BasicListener {
|
|||||||
if(fp == null || !fp.isLiving())
|
if(fp == null || !fp.isLiving())
|
||||||
return;
|
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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,78 @@
|
|||||||
package de.steamwar.fightsystem.record;
|
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 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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren