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
4 geänderte Dateien mit 155 neuen und 28 gelöschten Zeilen
Nur Änderungen aus Commit 6ed7ae0180 werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -6,6 +6,7 @@ import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.IFightSystem; import de.steamwar.fightsystem.IFightSystem;
import de.steamwar.fightsystem.kit.KitManager; import de.steamwar.fightsystem.kit.KitManager;
import de.steamwar.fightsystem.record.RecordSystem;
import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.utils.*; import de.steamwar.fightsystem.utils.*;
import de.steamwar.fightsystem.winconditions.RankedPlayerLeftWincondition; import de.steamwar.fightsystem.winconditions.RankedPlayerLeftWincondition;
@ -236,6 +237,13 @@ public class FightTeam implements IFightTeam{
} }
public void pasteSchematic(){ public void pasteSchematic(){
if(Config.recording()){
if(blue)
RecordSystem.blueSchem(schematic.getSchemID());
else
RecordSystem.redSchem(schematic.getSchemID());
}
FreezeWorld freezer = new FreezeWorld(); FreezeWorld freezer = new FreezeWorld();
DyeColor c = ColorConverter.chat2dye(color); DyeColor c = ColorConverter.chat2dye(color);
EditSession e; EditSession e;

Datei anzeigen

@ -7,10 +7,7 @@ import de.steamwar.fightsystem.fight.FightPlayer;
import de.steamwar.fightsystem.fight.FightTeam; import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.record.RecordSystem; import de.steamwar.fightsystem.record.RecordSystem;
import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.FightState;
import org.bukkit.Location; import org.bukkit.*;
import org.bukkit.Particle;
import org.bukkit.Sound;
import org.bukkit.SoundCategory;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
@ -19,8 +16,11 @@ import org.bukkit.event.block.BlockPhysicsEvent;
import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.entity.EntitySpawnEvent; import org.bukkit.event.entity.EntitySpawnEvent;
import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.event.player.*; import org.bukkit.event.player.*;
import org.bukkit.event.server.BroadcastMessageEvent; import org.bukkit.event.server.BroadcastMessageEvent;
import org.bukkit.inventory.ItemStack;
import java.util.EnumSet; import java.util.EnumSet;
@ -103,14 +103,86 @@ public class EventRecordListener extends BasicListener {
RecordSystem.sound(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), Sound.ENTITY_GENERIC_EXPLODE.name(), SoundCategory.BLOCKS.name(), 255.0f, 1.0f); RecordSystem.sound(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), Sound.ENTITY_GENERIC_EXPLODE.name(), SoundCategory.BLOCKS.name(), 255.0f, 1.0f);
} }
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onItem(PlayerItemHeldEvent e){
if(isNotSent(e.getPlayer()))
return;
RecordSystem.item(e.getPlayer(), disarmNull(e.getPlayer().getInventory().getItem(e.getNewSlot())), "MAINHAND");
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onItemSwap(PlayerSwapHandItemsEvent e){
if(isNotSent(e.getPlayer()))
return;
Player player = e.getPlayer();
RecordSystem.item(player, disarmNull(e.getMainHandItem()), "MAINHAND");
RecordSystem.item(player, disarmNull(e.getOffHandItem()), "OFFHAND");
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onInventoryClick(InventoryClickEvent e){
Player player = (Player) e.getWhoClicked();
if(isNotSent(player))
return;
if(e.getSlotType() != InventoryType.SlotType.ARMOR)
return;
switch(e.getSlot()){
case 103:
RecordSystem.item(player, disarmNull(e.getCurrentItem()), "HEAD");
break;
case 102:
RecordSystem.item(player, disarmNull(e.getCurrentItem()), "CHEST");
break;
case 101:
RecordSystem.item(player, disarmNull(e.getCurrentItem()), "LEGS");
break;
case 100:
default:
RecordSystem.item(player, disarmNull(e.getCurrentItem()), "FEET");
}
}
@Override @Override
public void stateChange(FightState state) { public void stateChange(FightState state) {
if(state == FightState.SPECTATE){ if(state == FightState.PRE_RUNNING) {
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> {
setKitItems(Fight.getBlueTeam());
setKitItems(Fight.getRedTeam());
}, 1);
}else if(state == FightState.SPECTATE){
despawnTeam(Fight.getRedTeam()); despawnTeam(Fight.getRedTeam());
despawnTeam(Fight.getBlueTeam()); despawnTeam(Fight.getBlueTeam());
} }
} }
private void setKitItems(FightTeam team){
if(FightSystem.getFightState() != FightState.PRE_RUNNING)
return;
for(FightPlayer fp : team.getPlayers()){
if(!fp.isLiving())
continue;
Player player = fp.getPlayer();
RecordSystem.item(player, disarmNull(player.getInventory().getItemInMainHand()), "MAINHAND");
RecordSystem.item(player, disarmNull(player.getInventory().getItemInOffHand()), "OFFHAND");
RecordSystem.item(player, disarmNull(player.getInventory().getHelmet()), "HEAD");
RecordSystem.item(player, disarmNull(player.getInventory().getChestplate()), "CHEST");
RecordSystem.item(player, disarmNull(player.getInventory().getLeggings()), "LEGS");
RecordSystem.item(player, disarmNull(player.getInventory().getBoots()), "FEET");
}
}
private ItemStack disarmNull(ItemStack stack){
if(stack == null)
return new ItemStack(Material.AIR);
return stack;
}
private void despawnTeam(FightTeam team){ private void despawnTeam(FightTeam team){
for(FightPlayer player : team.getPlayers()){ for(FightPlayer player : team.getPlayers()){
if(player.isLiving()) if(player.isLiving())

Datei anzeigen

@ -13,6 +13,7 @@ import org.bukkit.craftbukkit.v1_15_R1.entity.CraftEntity;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.entity.TNTPrimed; import org.bukkit.entity.TNTPrimed;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
public class RecordSystem { public class RecordSystem {
@ -37,9 +38,7 @@ public class RecordSystem {
* EntityAnimationPacket (0x04) + int EntityId + byte animation * EntityAnimationPacket (0x04) + int EntityId + byte animation
* TNTSpawnPacket (0x05) + int EntityId * TNTSpawnPacket (0x05) + int EntityId
* EntitySpeedPacket (0x06) + int EntityId + double dx, dy, dz * EntitySpeedPacket (0x06) + int EntityId + double dx, dy, dz
* * PlayerItemPacket (0x07) + int EntityId + String item + boolean enchanted + String slot
* TODO (Player-Oriented):
* ItemInHandPacket (0x03) + int EntityId
* TODO Bow spanning * TODO Bow spanning
* *
* *
@ -49,9 +48,13 @@ public class RecordSystem {
* SoundPacket (0x32) + int x, y, z + string soundType + string soundType + float volume, pitch * SoundPacket (0x32) + int x, y, z + string soundType + string soundType + float volume, pitch
* *
* *
* ChatPacket (0xa0) + String message * ChatPacket (0xA0) + String message
* ActionBarPacket (0xa1) + String message * ActionBarPacket (0xA1) + String message
* SystemPacket (0xa2) + String message * SystemPacket (0xA2) + String message
* BlueSchemPacket (0xB0) + int blueSchemId
* RedSchemPacket (0xB1) + int redSchemId
* ScoreboardTitlePacket (0xC0) + String scoreboardTitle
* ScoreboardDataPacket (0xC1) + String key + int value
* *
* TickPacket (0xff) * TickPacket (0xff)
* */ * */
@ -116,6 +119,14 @@ public class RecordSystem {
Recorder.flush(); Recorder.flush();
} }
public static synchronized void item(Player p, ItemStack item, String slot){
Recorder.rByte(p.getEntityId());
Recorder.rString(item.getType().getKey().toString());
Recorder.rBoolean(!item.getEnchantments().isEmpty());
Recorder.rString(slot);
Recorder.flush();
}
public static synchronized void blockChange(BlockPosition pos, int blockState){ public static synchronized void blockChange(BlockPosition pos, int blockState){
Recorder.rByte(0x30); Recorder.rByte(0x30);
Recorder.rInt(pos.getX()); Recorder.rInt(pos.getX());
@ -147,23 +158,48 @@ public class RecordSystem {
} }
public static synchronized void chat(String s) { public static synchronized void chat(String s) {
Recorder.rByte(0xa0); Recorder.rByte(0xA0);
Recorder.rString(s); Recorder.rString(s);
Recorder.flush(); Recorder.flush();
} }
public static synchronized void actionBar(String s) { public static synchronized void actionBar(String s) {
Recorder.rByte(0xa1); Recorder.rByte(0xA1);
Recorder.rString(s); Recorder.rString(s);
Recorder.flush(); Recorder.flush();
} }
public static synchronized void systemChat(String s) { public static synchronized void systemChat(String s) {
Recorder.rByte(0xa2); Recorder.rByte(0xA2);
Recorder.rString(s); Recorder.rString(s);
Recorder.flush(); Recorder.flush();
} }
public static synchronized void blueSchem(int schemId) {
Recorder.rByte(0xB0);
Recorder.rInt(schemId);
Recorder.flush();
}
public static synchronized void redSchem(int schemId) {
Recorder.rByte(0xB1);
Recorder.rInt(schemId);
Recorder.flush();
}
public static synchronized void scoreboardTitle(String title){
Recorder.rByte(0xC0);
Recorder.rString(title);
Recorder.flush();
}
public static synchronized void scoreboardData(String key, int value){
Recorder.rByte(0xC1);
Recorder.rString(key);
Recorder.rInt(value);
Recorder.flush();
}
public static synchronized void tick(){ public static synchronized void tick(){
Recorder.rByte(0xff); Recorder.rByte(0xff);
Recorder.flush(); Recorder.flush();

Datei anzeigen

@ -4,6 +4,7 @@ import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.Fight; import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightTeam; import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.record.RecordSystem;
import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.winconditions.*; import de.steamwar.fightsystem.winconditions.*;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -55,42 +56,52 @@ public class FightScoreboard {
private static void teamScoreboard(FightTeam fightTeam){ private static void teamScoreboard(FightTeam fightTeam){
objective.setDisplayName(fightTeam.getColoredName()); objective.setDisplayName(fightTeam.getColoredName());
if(Config.recording())
RecordSystem.scoreboardTitle(fightTeam.getColoredName());
fightTeam.getPlayers().forEach(fp -> { fightTeam.getPlayers().forEach(fp -> {
if(fp.isLiving()) if(fp.isLiving())
objective.getScore(fightTeam.getPrefix() + fp.getPlayer().getName()).setScore((int) fp.getPlayer().getHealth()); setScore(fightTeam.getPrefix() + fp.getPlayer().getName(), (int) fp.getPlayer().getHealth());
}); });
} }
private static void generalScoreboard(){ private static void generalScoreboard(){
objective.setDisplayName("§6Kampf"); objective.setDisplayName("§eKampf");
if(Config.recording())
RecordSystem.scoreboardTitle("§eKampf");
if (Config.Timeout || Config.Points || Config.HeartRatioTimeout) { if (Config.Timeout || Config.Points || Config.HeartRatioTimeout) {
int fightTime = FightSystem.getFightTime(); int fightTime = FightSystem.getFightTime();
if (fightTime >= 60) if (fightTime >= 60)
objective.getScore("§7Zeit: §a" + fightTime / 60 + "m " + fightTime % 60 + "s").setScore(3); setScore("§7Zeit: §a" + fightTime / 60 + "m " + fightTime % 60 + "s", 3);
else else
objective.getScore("§7Zeit: §a" + fightTime + "s").setScore(3); setScore("§7Zeit: §a" + fightTime + "s", 3);
} }
if(fullScoreboard.contains(FightSystem.getFightState())){ if(fullScoreboard.contains(FightSystem.getFightState())){
if (Config.PercentSystem){ if (Config.PercentSystem){
objective.getScore(Fight.getRedTeam().getPrefix() + "Schaden: " + (Math.round(100.0 * WinconditionPercentSystem.getRedPercent()) / 100.0) + "%").setScore(1); setScore(Fight.getRedTeam().getPrefix() + "Schaden: " + (Math.round(100.0 * WinconditionPercentSystem.getRedPercent()) / 100.0) + "%", 1);
objective.getScore(Fight.getBlueTeam().getPrefix() + "Schaden: " + (Math.round(100.0 * WinconditionPercentSystem.getBluePercent()) / 100.0) + "%").setScore(0); setScore(Fight.getBlueTeam().getPrefix() + "Schaden: " + (Math.round(100.0 * WinconditionPercentSystem.getBluePercent()) / 100.0) + "%", 0);
}else if(Config.WaterTechKO){ }else if(Config.WaterTechKO){
objective.getScore(Fight.getRedTeam().getPrefix() + "Wasser: " + WinconditionWaterTechKO.getTeamRedWater()).setScore(1); setScore(Fight.getRedTeam().getPrefix() + "Wasser: " + WinconditionWaterTechKO.getTeamRedWater(),1);
objective.getScore(Fight.getBlueTeam().getPrefix() + "Wasser: " + WinconditionWaterTechKO.getTeamBlueWater()).setScore(0); setScore(Fight.getBlueTeam().getPrefix() + "Wasser: " + WinconditionWaterTechKO.getTeamBlueWater(), 0);
}else if(Config.RelativePercent){ }else if(Config.RelativePercent){
objective.getScore(Fight.getRedTeam().getPrefix() + "Schaden: " + WinconditionRelativePercent.getRed().getPrintablePercent() + "%").setScore(1); setScore(Fight.getRedTeam().getPrefix() + "Schaden: " + WinconditionRelativePercent.getRed().getPrintablePercent() + "%", 1);
objective.getScore(Fight.getBlueTeam().getPrefix() + "Schaden: " + WinconditionRelativePercent.getBlue().getPrintablePercent() + "%").setScore(0); setScore(Fight.getBlueTeam().getPrefix() + "Schaden: " + WinconditionRelativePercent.getBlue().getPrintablePercent() + "%", 0);
}else if(Config.Points){ }else if(Config.Points){
objective.getScore(Fight.getRedTeam().getPrefix() + "Punkte: " + WinconditionPoints.getRed().getPoints()).setScore(1); setScore(Fight.getRedTeam().getPrefix() + "Punkte: " + WinconditionPoints.getRed().getPoints(), 1);
objective.getScore(Fight.getBlueTeam().getPrefix() + "Punkte: " + WinconditionPoints.getBlue().getPoints()).setScore(0); setScore(Fight.getBlueTeam().getPrefix() + "Punkte: " + WinconditionPoints.getBlue().getPoints(), 0);
}else if(Config.PumpkinTechKO){ }else if(Config.PumpkinTechKO){
objective.getScore(Fight.getRedTeam().getPrefix() + "Kanonen: " + WinconditionPumpkinTechKO.getTeamRedPumpkins()).setScore(1); setScore(Fight.getRedTeam().getPrefix() + "Kanonen: " + WinconditionPumpkinTechKO.getTeamRedPumpkins(), 1);
objective.getScore(Fight.getBlueTeam().getPrefix() + "Kanonen: " + WinconditionPumpkinTechKO.getTeamBluePumpkins()).setScore(0); setScore(Fight.getBlueTeam().getPrefix() + "Kanonen: " + WinconditionPumpkinTechKO.getTeamBluePumpkins(), 0);
} }
} }
} }
private static void setScore(String key, int value){
objective.getScore(key).setScore(value);
if(Config.recording())
RecordSystem.scoreboardData(key, value);
}
private static FightTeam getIndexDisplay() { private static FightTeam getIndexDisplay() {
index++; index++;
if(index == 1) if(index == 1)