Omni-Replay #280
@ -30,7 +30,7 @@ public enum ArenaMode {
|
|||||||
TEST,
|
TEST,
|
||||||
CHECK,
|
CHECK,
|
||||||
PREPARE,
|
PREPARE,
|
||||||
SPECTATE;
|
REPLAY;
|
||||||
|
|
||||||
public static final Set<ArenaMode> All = Collections.unmodifiableSet(EnumSet.allOf(ArenaMode.class));
|
public static final Set<ArenaMode> All = Collections.unmodifiableSet(EnumSet.allOf(ArenaMode.class));
|
||||||
|
|
||||||
@ -40,15 +40,16 @@ public enum ArenaMode {
|
|||||||
public static final Set<ArenaMode> Test = Collections.unmodifiableSet(EnumSet.of(TEST, CHECK));
|
public static final Set<ArenaMode> Test = Collections.unmodifiableSet(EnumSet.of(TEST, CHECK));
|
||||||
public static final Set<ArenaMode> Ranked = Collections.unmodifiableSet(EnumSet.of(RANKED));
|
public static final Set<ArenaMode> Ranked = Collections.unmodifiableSet(EnumSet.of(RANKED));
|
||||||
public static final Set<ArenaMode> Prepare = Collections.unmodifiableSet(EnumSet.of(PREPARE));
|
public static final Set<ArenaMode> Prepare = Collections.unmodifiableSet(EnumSet.of(PREPARE));
|
||||||
public static final Set<ArenaMode> Spectate = Collections.unmodifiableSet(EnumSet.of(SPECTATE));
|
public static final Set<ArenaMode> Replay = Collections.unmodifiableSet(EnumSet.of(REPLAY));
|
||||||
|
|
||||||
public static final Set<ArenaMode> AntiSpectate = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(SPECTATE)));
|
public static final Set<ArenaMode> AntiReplay = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(REPLAY)));
|
||||||
|
public static final Set<ArenaMode> Replayable = Collections.unmodifiableSet(EnumSet.of(REPLAY, TEST));
|
||||||
public static final Set<ArenaMode> AntiTest = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(TEST, CHECK)));
|
public static final Set<ArenaMode> AntiTest = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(TEST, CHECK)));
|
||||||
public static final Set<ArenaMode> AntiEvent = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(EVENT)));
|
public static final Set<ArenaMode> AntiEvent = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(EVENT)));
|
||||||
public static final Set<ArenaMode> AntiPrepare = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(PREPARE)));
|
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, SPECTATE)));
|
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));
|
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));
|
||||||
public static final Set<ArenaMode> SoloLeader = Collections.unmodifiableSet(EnumSet.of(TEST, CHECK, PREPARE));
|
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)));
|
public static final Set<ArenaMode> NotOnBau = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(TEST, CHECK, PREPARE, REPLAY)));
|
||||||
}
|
}
|
||||||
|
@ -118,7 +118,7 @@ public class Config {
|
|||||||
public static final int EventTeamRedID;
|
public static final int EventTeamRedID;
|
||||||
public static final boolean BothTeamsPublic;
|
public static final boolean BothTeamsPublic;
|
||||||
public static final int MaximumTeamMembers;
|
public static final int MaximumTeamMembers;
|
||||||
public static final boolean SpectateSystem;
|
public static final boolean LiveReplay;
|
||||||
|
|
||||||
//check parameter
|
//check parameter
|
||||||
public static final int CheckSchemID;
|
public static final int CheckSchemID;
|
||||||
@ -126,9 +126,10 @@ public class Config {
|
|||||||
|
|
||||||
public static final ArenaMode mode;
|
public static final ArenaMode mode;
|
||||||
|
|
||||||
//live recorder parameter
|
//replay system parameter
|
||||||
public static final String spectateIP = "127.0.0.1";
|
public static final String spectateIP = "127.0.0.1";
|
||||||
public static final int spectatePort = 2222;
|
public static final int spectatePort = 2222;
|
||||||
|
public static final int ReplayID;
|
||||||
|
|
||||||
static{
|
static{
|
||||||
if(!new File(IFightSystem.getPlugin().getDataFolder(), System.getProperty("config", "config.yml")).exists()) {
|
if(!new File(IFightSystem.getPlugin().getDataFolder(), System.getProperty("config", "config.yml")).exists()) {
|
||||||
@ -335,7 +336,7 @@ public class Config {
|
|||||||
OnlyPublicSchematics = event.publicSchemsOnly();
|
OnlyPublicSchematics = event.publicSchemsOnly();
|
||||||
MaximumTeamMembers = event.getMaximumTeamMembers();
|
MaximumTeamMembers = event.getMaximumTeamMembers();
|
||||||
}
|
}
|
||||||
SpectateSystem = event.spectateSystem();
|
LiveReplay = event.spectateSystem();
|
||||||
}else{
|
}else{
|
||||||
//No event
|
//No event
|
||||||
TeamRedColor = config.getString("Output.TeamRedPrefix");
|
TeamRedColor = config.getString("Output.TeamRedPrefix");
|
||||||
@ -347,7 +348,7 @@ public class Config {
|
|||||||
EventTeamRedID = 0;
|
EventTeamRedID = 0;
|
||||||
BothTeamsPublic = true;
|
BothTeamsPublic = true;
|
||||||
MaximumTeamMembers = Integer.MAX_VALUE;
|
MaximumTeamMembers = Integer.MAX_VALUE;
|
||||||
SpectateSystem = false;
|
LiveReplay = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
String blueLeader = System.getProperty("blueLeader", null);
|
String blueLeader = System.getProperty("blueLeader", null);
|
||||||
@ -364,6 +365,7 @@ public class Config {
|
|||||||
CheckSchemID = Integer.parseInt(System.getProperty("checkSchemID", "0"));
|
CheckSchemID = Integer.parseInt(System.getProperty("checkSchemID", "0"));
|
||||||
PrepareSchemID = Integer.parseInt(System.getProperty("prepareSchemID", "0"));
|
PrepareSchemID = Integer.parseInt(System.getProperty("prepareSchemID", "0"));
|
||||||
Ranked = Boolean.parseBoolean(System.getProperty("ranked", "false"));
|
Ranked = Boolean.parseBoolean(System.getProperty("ranked", "false"));
|
||||||
|
ReplayID = Integer.parseInt(System.getProperty("replay", "0"));
|
||||||
|
|
||||||
if(Ranked){
|
if(Ranked){
|
||||||
mode = ArenaMode.RANKED;
|
mode = ArenaMode.RANKED;
|
||||||
@ -375,6 +377,8 @@ public class Config {
|
|||||||
mode = ArenaMode.EVENT;
|
mode = ArenaMode.EVENT;
|
||||||
}else if(EventKampfID == -1){
|
}else if(EventKampfID == -1){
|
||||||
mode = ArenaMode.TEST;
|
mode = ArenaMode.TEST;
|
||||||
|
}else if(ReplayID != 0){
|
||||||
|
mode = ArenaMode.REPLAY;
|
||||||
}else{
|
}else{
|
||||||
mode = ArenaMode.NORMAL;
|
mode = ArenaMode.NORMAL;
|
||||||
}
|
}
|
||||||
@ -383,7 +387,7 @@ public class Config {
|
|||||||
public static boolean test(){
|
public static boolean test(){
|
||||||
return ArenaMode.Test.contains(mode);
|
return ArenaMode.Test.contains(mode);
|
||||||
}
|
}
|
||||||
public static boolean recording(){
|
public static boolean replayserver(){
|
||||||
return mode == ArenaMode.EVENT;
|
return ReplayID == -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ public class IFight {
|
|||||||
private static IFightTeam redTeam;
|
private static IFightTeam redTeam;
|
||||||
private static IFightTeam blueTeam;
|
private static IFightTeam blueTeam;
|
||||||
|
|
||||||
static void init(IFightTeam redTeam, IFightTeam blueTeam){
|
public static void init(IFightTeam redTeam, IFightTeam blueTeam){
|
||||||
IFight.redTeam = redTeam;
|
IFight.redTeam = redTeam;
|
||||||
IFight.blueTeam = blueTeam;
|
IFight.blueTeam = blueTeam;
|
||||||
}
|
}
|
||||||
|
@ -26,10 +26,12 @@ import de.steamwar.fightsystem.countdown.*;
|
|||||||
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.fight.FightWorld;
|
import de.steamwar.fightsystem.fight.FightWorld;
|
||||||
|
import de.steamwar.fightsystem.fight.IFight;
|
||||||
import de.steamwar.fightsystem.listener.Shutdown;
|
import de.steamwar.fightsystem.listener.Shutdown;
|
||||||
import de.steamwar.fightsystem.listener.*;
|
import de.steamwar.fightsystem.listener.*;
|
||||||
import de.steamwar.fightsystem.record.RecordSystem;
|
import de.steamwar.fightsystem.record.FileRecorder;
|
||||||
import de.steamwar.fightsystem.record.Recorder;
|
import de.steamwar.fightsystem.record.LiveRecorder;
|
||||||
|
import de.steamwar.fightsystem.record.PacketProcessor;
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.states.OneShotStateDependent;
|
import de.steamwar.fightsystem.states.OneShotStateDependent;
|
||||||
import de.steamwar.fightsystem.utils.EnterHandler;
|
import de.steamwar.fightsystem.utils.EnterHandler;
|
||||||
@ -57,8 +59,7 @@ public class FightSystem extends JavaPlugin {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
Fight.init();
|
IFight.init(Fight.getRedTeam(), Fight.getBlueTeam());
|
||||||
RecordSystem.init();
|
|
||||||
|
|
||||||
new EntityDamage();
|
new EntityDamage();
|
||||||
new WaterRemover();
|
new WaterRemover();
|
||||||
@ -123,12 +124,16 @@ public class FightSystem extends JavaPlugin {
|
|||||||
new AkCommand();
|
new AkCommand();
|
||||||
new LeaderCommand();
|
new LeaderCommand();
|
||||||
new LockschemCommand();
|
new LockschemCommand();
|
||||||
|
new ReplayCommand();
|
||||||
new StateCommand();
|
new StateCommand();
|
||||||
new SkipCommand();
|
new SkipCommand();
|
||||||
new WinCommand();
|
new WinCommand();
|
||||||
|
|
||||||
new OneShotStateDependent(ArenaMode.AntiSpectate, FightState.PreRunning, () -> Bukkit.broadcastMessage(PREFIX + "§aDer Kampf beginnt!"));
|
new LiveRecorder();
|
||||||
new OneShotStateDependent(ArenaMode.AntiSpectate, FightState.Running, () -> Bukkit.broadcastMessage(PREFIX + "§aArena freigegeben!"));
|
new FileRecorder();
|
||||||
|
|
||||||
|
new OneShotStateDependent(ArenaMode.AntiReplay, FightState.PreRunning, () -> Bukkit.broadcastMessage(PREFIX + "§aDer Kampf beginnt!"));
|
||||||
|
new OneShotStateDependent(ArenaMode.AntiReplay, FightState.Running, () -> Bukkit.broadcastMessage(PREFIX + "§aArena freigegeben!"));
|
||||||
new OneShotStateDependent(ArenaMode.AntiTest, FightState.Running, FightStatistics::start);
|
new OneShotStateDependent(ArenaMode.AntiTest, FightState.Running, FightStatistics::start);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -148,14 +153,11 @@ public class FightSystem extends JavaPlugin {
|
|||||||
}else{
|
}else{
|
||||||
Fight.getBlueTeam().setSchem(Schematic.getSchemFromDB(Config.PrepareSchemID));
|
Fight.getBlueTeam().setSchem(Schematic.getSchemFromDB(Config.PrepareSchemID));
|
||||||
}
|
}
|
||||||
|
}else if(Config.mode == ArenaMode.REPLAY) {
|
||||||
|
FightWorld.forceLoad();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDisable() {
|
|
||||||
Recorder.closeAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setPreLeaderState() {
|
public static void setPreLeaderState() {
|
||||||
FightState.setFightState(FightState.PRE_LEADER_SETUP);
|
FightState.setFightState(FightState.PRE_LEADER_SETUP);
|
||||||
|
|
||||||
@ -181,6 +183,8 @@ public class FightSystem extends JavaPlugin {
|
|||||||
|
|
||||||
public static void setSpectateState(FightTeam winFightTeam, String windescription) {
|
public static void setSpectateState(FightTeam winFightTeam, String windescription) {
|
||||||
FightState.setFightState(FightState.SPECTATE);
|
FightState.setFightState(FightState.SPECTATE);
|
||||||
|
if(PacketProcessor.isReplaying())
|
||||||
|
return;
|
||||||
|
|
||||||
if(winFightTeam != null) {
|
if(winFightTeam != null) {
|
||||||
Bukkit.broadcastMessage(PREFIX + "§aDas Team " + winFightTeam.getColoredName() + " §ahat gewonnen!");
|
Bukkit.broadcastMessage(PREFIX + "§aDas Team " + winFightTeam.getColoredName() + " §ahat gewonnen!");
|
||||||
|
@ -30,7 +30,7 @@ import org.bukkit.entity.Player;
|
|||||||
public class KitCommand implements CommandExecutor {
|
public class KitCommand implements CommandExecutor {
|
||||||
|
|
||||||
public KitCommand() {
|
public KitCommand() {
|
||||||
new StateDependentCommand(ArenaMode.AntiSpectate, FightState.Setup, "kit", this);
|
new StateDependentCommand(ArenaMode.AntiReplay, FightState.Setup, "kit", this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -30,7 +30,7 @@ import org.bukkit.entity.Player;
|
|||||||
public class LeaveCommand implements CommandExecutor {
|
public class LeaveCommand implements CommandExecutor {
|
||||||
|
|
||||||
public LeaveCommand() {
|
public LeaveCommand() {
|
||||||
new StateDependentCommand(ArenaMode.AntiSpectate, FightState.Setup, "leave", this);
|
new StateDependentCommand(ArenaMode.AntiReplay, FightState.Setup, "leave", this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -37,7 +37,7 @@ import org.bukkit.entity.Player;
|
|||||||
public class LockschemCommand implements CommandExecutor {
|
public class LockschemCommand implements CommandExecutor {
|
||||||
|
|
||||||
public LockschemCommand() {
|
public LockschemCommand() {
|
||||||
new StateDependentCommand(ArenaMode.AntiSpectate, FightState.All, "lockschem", this);
|
new StateDependentCommand(ArenaMode.AntiReplay, FightState.All, "lockschem", this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -0,0 +1,70 @@
|
|||||||
|
/*
|
||||||
|
This file is a part of the SteamWar software.
|
||||||
|
|
||||||
|
Copyright (C) 2020 SteamWar.de-Serverteam
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.steamwar.fightsystem.commands;
|
||||||
|
|
||||||
|
import de.steamwar.fightsystem.ArenaMode;
|
||||||
|
import de.steamwar.fightsystem.Config;
|
||||||
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
|
import de.steamwar.fightsystem.record.FileRecorder;
|
||||||
|
import de.steamwar.fightsystem.record.FileSource;
|
||||||
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
|
import de.steamwar.fightsystem.states.StateDependentCommand;
|
||||||
|
import de.steamwar.sql.SteamwarUser;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public class ReplayCommand implements CommandExecutor {
|
||||||
|
|
||||||
|
public ReplayCommand() {
|
||||||
|
new StateDependentCommand(ArenaMode.Replayable, FightState.All, "replay", this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
if(!(sender instanceof Player)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Player player = (Player) sender;
|
||||||
|
|
||||||
|
if(!Config.test()){
|
||||||
|
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||||
|
if(!user.getUserGroup().isTeamGroup()){
|
||||||
|
sender.sendMessage(FightSystem.PREFIX + "§cDieser Befehl ist zu diesem Kampfzeitpunkt nicht verfügbar.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!FileRecorder.getFile().exists()){
|
||||||
|
sender.sendMessage(FightSystem.PREFIX + "§cKein Replay vorhanden.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
new FileSource(FileRecorder.getFile());
|
||||||
|
} catch (IOException e) {
|
||||||
|
sender.sendMessage(FightSystem.PREFIX + "§cDas Replay konnte nicht gestartet werden.");
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
@ -23,7 +23,7 @@ import de.steamwar.core.Core;
|
|||||||
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.listener.BasicListener;
|
import de.steamwar.fightsystem.listener.BasicListener;
|
||||||
import de.steamwar.fightsystem.record.RecordSystem;
|
import de.steamwar.fightsystem.record.GlobalRecorder;
|
||||||
import net.md_5.bungee.api.chat.BaseComponent;
|
import net.md_5.bungee.api.chat.BaseComponent;
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -108,7 +108,7 @@ public abstract class Countdown {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void broadcast(String message){
|
private void broadcast(String message){
|
||||||
RecordSystem.actionBar(message);
|
GlobalRecorder.getInstance().actionBar(message);
|
||||||
BaseComponent[] msg = TextComponent.fromLegacyText(message);
|
BaseComponent[] msg = TextComponent.fromLegacyText(message);
|
||||||
for(Player p : Bukkit.getOnlinePlayers())
|
for(Player p : Bukkit.getOnlinePlayers())
|
||||||
BasicListener.toActionbar(p, msg);
|
BasicListener.toActionbar(p, msg);
|
||||||
|
@ -34,8 +34,8 @@ public class NoPlayersOnlineCountdown extends Countdown implements Listener {
|
|||||||
public NoPlayersOnlineCountdown() {
|
public NoPlayersOnlineCountdown() {
|
||||||
super(Config.NoPlayerOnlineDuration, null, false);
|
super(Config.NoPlayerOnlineDuration, null, false);
|
||||||
|
|
||||||
new StateDependentListener(ArenaMode.AntiSpectate, FightState.PreLeaderSetup, this);
|
new StateDependentListener(ArenaMode.AntiReplay, FightState.PreLeaderSetup, this);
|
||||||
new StateDependentCountdown(ArenaMode.AntiSpectate, FightState.PreLeaderSetup, this){
|
new StateDependentCountdown(ArenaMode.AntiReplay, FightState.PreLeaderSetup, this){
|
||||||
@Override
|
@Override
|
||||||
public void enable() {
|
public void enable() {
|
||||||
if(Bukkit.getOnlinePlayers().isEmpty())
|
if(Bukkit.getOnlinePlayers().isEmpty())
|
||||||
|
@ -30,6 +30,7 @@ public class PostSchemCountdown extends Countdown {
|
|||||||
public PostSchemCountdown() {
|
public PostSchemCountdown() {
|
||||||
super(Config.SetupDuration, null, false);
|
super(Config.SetupDuration, null, false);
|
||||||
new StateDependentCountdown(ArenaMode.AntiTest, FightState.PostSchemSetup, this);
|
new StateDependentCountdown(ArenaMode.AntiTest, FightState.PostSchemSetup, this);
|
||||||
|
//TODO: Replaying?
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -29,7 +29,7 @@ public class PreRunningCountdown extends Countdown {
|
|||||||
|
|
||||||
public PreRunningCountdown() {
|
public PreRunningCountdown() {
|
||||||
super(Config.PreFightDuration, SWSound.BLOCK_NOTE_PLING, true);
|
super(Config.PreFightDuration, SWSound.BLOCK_NOTE_PLING, true);
|
||||||
new StateDependentCountdown(ArenaMode.AntiSpectate, FightState.PreRunning, this);
|
new StateDependentCountdown(ArenaMode.AntiReplay, FightState.PreRunning, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -29,7 +29,7 @@ public class PreSchemCountdown extends Countdown {
|
|||||||
|
|
||||||
public PreSchemCountdown() {
|
public PreSchemCountdown() {
|
||||||
super(Config.PreSchemPasteDuration, SWSound.BLOCK_NOTE_PLING, false);
|
super(Config.PreSchemPasteDuration, SWSound.BLOCK_NOTE_PLING, false);
|
||||||
new StateDependentCountdown(ArenaMode.AntiSpectate, FightState.PreSchemSetup, this);
|
new StateDependentCountdown(ArenaMode.AntiReplay, FightState.PreSchemSetup, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -28,10 +28,12 @@ import com.comphenix.protocol.wrappers.WrappedChatComponent;
|
|||||||
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
||||||
import de.steamwar.fightsystem.ArenaMode;
|
import de.steamwar.fightsystem.ArenaMode;
|
||||||
import de.steamwar.fightsystem.Config;
|
import de.steamwar.fightsystem.Config;
|
||||||
import de.steamwar.fightsystem.record.RecordSystem;
|
|
||||||
import de.steamwar.fightsystem.FightSystem;
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
|
import de.steamwar.fightsystem.record.GlobalRecorder;
|
||||||
import de.steamwar.sql.Schematic;
|
import de.steamwar.sql.Schematic;
|
||||||
import org.bukkit.*;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.GameMode;
|
||||||
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
@ -45,10 +47,6 @@ public class Fight {
|
|||||||
private static final FightTeam redTeam = new FightTeam(Config.TeamRedName, Config.TeamRedColor, Config.TeamRedSpawn, Config.RedPasteRegion, Config.RedExtendRegion, Config.RedRotate, false, Config.RedLeader);
|
private static final FightTeam redTeam = new FightTeam(Config.TeamRedName, Config.TeamRedColor, Config.TeamRedSpawn, Config.RedPasteRegion, Config.RedExtendRegion, Config.RedRotate, false, Config.RedLeader);
|
||||||
private static final FightTeam blueTeam = new FightTeam(Config.TeamBlueName, Config.TeamBlueColor, Config.TeamBlueSpawn, Config.BluePasteRegion, Config.BlueExtendRegion, Config.BlueRotate, true, Config.BlueLeader);
|
private static final FightTeam blueTeam = new FightTeam(Config.TeamBlueName, Config.TeamBlueColor, Config.TeamBlueSpawn, Config.BluePasteRegion, Config.BlueExtendRegion, Config.BlueRotate, true, Config.BlueLeader);
|
||||||
|
|
||||||
public static void init(){
|
|
||||||
IFight.init(redTeam, blueTeam);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static FightTeam getPlayerTeam(Player player) {
|
public static FightTeam getPlayerTeam(Player player) {
|
||||||
if(redTeam.isPlayerInTeam(player))
|
if(redTeam.isPlayerInTeam(player))
|
||||||
return redTeam;
|
return redTeam;
|
||||||
@ -91,7 +89,7 @@ public class Fight {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void playSound(Sound sound, float volume, float pitch) {
|
public static void playSound(Sound sound, float volume, float pitch) {
|
||||||
RecordSystem.soundAtPlayer(sound.name(), volume, pitch);
|
GlobalRecorder.getInstance().soundAtPlayer(sound.name(), volume, pitch);
|
||||||
//volume: max. 100, pitch: max. 2
|
//volume: max. 100, pitch: max. 2
|
||||||
Bukkit.getServer().getOnlinePlayers().forEach(player -> player.playSound(player.getLocation(), sound, volume, pitch));
|
Bukkit.getServer().getOnlinePlayers().forEach(player -> player.playSound(player.getLocation(), sound, volume, pitch));
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ import de.steamwar.core.VersionedRunnable;
|
|||||||
import de.steamwar.fightsystem.ArenaMode;
|
import de.steamwar.fightsystem.ArenaMode;
|
||||||
import de.steamwar.fightsystem.Config;
|
import de.steamwar.fightsystem.Config;
|
||||||
import de.steamwar.fightsystem.FightSystem;
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
import de.steamwar.fightsystem.record.RecordSystem;
|
import de.steamwar.fightsystem.record.GlobalRecorder;
|
||||||
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.ColorConverter;
|
import de.steamwar.fightsystem.utils.ColorConverter;
|
||||||
@ -60,7 +60,7 @@ public class FightSchematic extends StateDependent {
|
|||||||
private int schematic = 0;
|
private int schematic = 0;
|
||||||
|
|
||||||
public FightSchematic(FightTeam team, boolean rotate) {
|
public FightSchematic(FightTeam team, boolean rotate) {
|
||||||
super(ArenaMode.AntiSpectate, FightState.PostSchemSetup);
|
super(ArenaMode.AntiReplay, FightState.PostSchemSetup);
|
||||||
this.team = team;
|
this.team = team;
|
||||||
this.region = team.getSchemRegion();
|
this.region = team.getSchemRegion();
|
||||||
this.rotate = rotate;
|
this.rotate = rotate;
|
||||||
@ -110,9 +110,9 @@ public class FightSchematic extends StateDependent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(team.isBlue())
|
if(team.isBlue())
|
||||||
RecordSystem.blueSchem(schematic);
|
GlobalRecorder.getInstance().blueSchem(schematic);
|
||||||
else
|
else
|
||||||
RecordSystem.redSchem(schematic);
|
GlobalRecorder.getInstance().redSchem(schematic);
|
||||||
|
|
||||||
Bukkit.getScheduler().runTask(FightSystem.getPlugin(), this::paste);
|
Bukkit.getScheduler().runTask(FightSystem.getPlugin(), this::paste);
|
||||||
}
|
}
|
||||||
|
@ -26,10 +26,10 @@ import de.steamwar.fightsystem.Config;
|
|||||||
import de.steamwar.fightsystem.FightSystem;
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
import de.steamwar.fightsystem.countdown.Countdown;
|
import de.steamwar.fightsystem.countdown.Countdown;
|
||||||
import de.steamwar.fightsystem.listener.BasicListener;
|
import de.steamwar.fightsystem.listener.BasicListener;
|
||||||
import de.steamwar.fightsystem.listener.PersonalKitCreator;
|
|
||||||
import de.steamwar.fightsystem.record.RecordSystem;
|
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
|
||||||
import de.steamwar.fightsystem.listener.FightScoreboard;
|
import de.steamwar.fightsystem.listener.FightScoreboard;
|
||||||
|
import de.steamwar.fightsystem.listener.PersonalKitCreator;
|
||||||
|
import de.steamwar.fightsystem.record.GlobalRecorder;
|
||||||
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.states.StateDependent;
|
import de.steamwar.fightsystem.states.StateDependent;
|
||||||
import de.steamwar.fightsystem.utils.ItemBuilder;
|
import de.steamwar.fightsystem.utils.ItemBuilder;
|
||||||
import de.steamwar.fightsystem.utils.Region;
|
import de.steamwar.fightsystem.utils.Region;
|
||||||
@ -202,7 +202,7 @@ public class FightTeam implements IFightTeam{
|
|||||||
player.getInventory().setItem(7, new ItemBuilder(Material.BEACON).removeAllAttributs().setDisplayName("§eRespawn").build());
|
player.getInventory().setItem(7, new ItemBuilder(Material.BEACON).removeAllAttributs().setDisplayName("§eRespawn").build());
|
||||||
if(ArenaMode.NotOnBau.contains(Config.mode))
|
if(ArenaMode.NotOnBau.contains(Config.mode))
|
||||||
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> new TablistNamePacket(SteamwarUser.get(player.getUniqueId()).getId(), prefix + player.getName()).send(player), 5);
|
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> new TablistNamePacket(SteamwarUser.get(player.getUniqueId()).getId(), prefix + player.getName()).send(player), 5);
|
||||||
RecordSystem.playerJoins(player);
|
GlobalRecorder.getInstance().playerJoins(player);
|
||||||
TechHider.reloadChunks(player, chunksToReload, false);
|
TechHider.reloadChunks(player, chunksToReload, false);
|
||||||
|
|
||||||
if(isLeaderless())
|
if(isLeaderless())
|
||||||
@ -220,7 +220,7 @@ public class FightTeam implements IFightTeam{
|
|||||||
if(fightPlayer.equals(leader))
|
if(fightPlayer.equals(leader))
|
||||||
setLeader(null);
|
setLeader(null);
|
||||||
|
|
||||||
RecordSystem.entityDespawns(player);
|
GlobalRecorder.getInstance().entityDespawns(player);
|
||||||
Fight.setPlayerGamemode(player, GameMode.SPECTATOR);
|
Fight.setPlayerGamemode(player, GameMode.SPECTATOR);
|
||||||
player.teleport(Config.SpecSpawn);
|
player.teleport(Config.SpecSpawn);
|
||||||
player.getInventory().clear();
|
player.getInventory().clear();
|
||||||
@ -300,7 +300,7 @@ public class FightTeam implements IFightTeam{
|
|||||||
public void pasteSchem(Schematic schematic){
|
public void pasteSchem(Schematic schematic){
|
||||||
setSchem(schematic);
|
setSchem(schematic);
|
||||||
|
|
||||||
if(Config.test() || RecordSystem.isReplaying())
|
if(Config.test())
|
||||||
this.schematic.enable();
|
this.schematic.enable();
|
||||||
else if(Fight.getOpposite(this).hasSchematic()){
|
else if(Fight.getOpposite(this).hasSchematic()){
|
||||||
FightSystem.setPostSchemState();
|
FightSystem.setPostSchemState();
|
||||||
@ -406,7 +406,7 @@ public class FightTeam implements IFightTeam{
|
|||||||
|
|
||||||
private class KitLoader extends StateDependent {
|
private class KitLoader extends StateDependent {
|
||||||
private KitLoader() {
|
private KitLoader() {
|
||||||
super(ArenaMode.AntiSpectate, FightState.Ingame);
|
super(ArenaMode.AntiReplay, FightState.Ingame);
|
||||||
register();
|
register();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -431,7 +431,7 @@ public class FightTeam implements IFightTeam{
|
|||||||
|
|
||||||
private class SpectateHandler extends StateDependent {
|
private class SpectateHandler extends StateDependent {
|
||||||
private SpectateHandler() {
|
private SpectateHandler() {
|
||||||
super(ArenaMode.AntiSpectate, FightState.Spectate);
|
super(ArenaMode.AntiReplay, FightState.Spectate);
|
||||||
register();
|
register();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,10 +22,13 @@ package de.steamwar.fightsystem.fight;
|
|||||||
import de.steamwar.fightsystem.IFightSystem;
|
import de.steamwar.fightsystem.IFightSystem;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.block.*;
|
import org.bukkit.event.block.*;
|
||||||
import org.bukkit.event.inventory.InventoryMoveItemEvent;
|
import org.bukkit.event.inventory.InventoryMoveItemEvent;
|
||||||
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
|
import org.bukkit.event.player.PlayerSwapHandItemsEvent;
|
||||||
|
|
||||||
public class FreezeWorld implements Listener {
|
public class FreezeWorld implements Listener {
|
||||||
public FreezeWorld(){
|
public FreezeWorld(){
|
||||||
@ -70,4 +73,19 @@ public class FreezeWorld implements Listener {
|
|||||||
public void onInventoryMoveEvent(InventoryMoveItemEvent e){
|
public void onInventoryMoveEvent(InventoryMoveItemEvent e){
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onBlockExplosion(BlockExplodeEvent e){
|
||||||
|
e.setCancelled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void handlePlayerSwapHandItemsEvent(PlayerSwapHandItemsEvent event) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.LOW)
|
||||||
|
public void handlePlayerInteract(PlayerInteractEvent event) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,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.record.GlobalRecorder;
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||||
import net.md_5.bungee.api.chat.BaseComponent;
|
import net.md_5.bungee.api.chat.BaseComponent;
|
||||||
@ -64,7 +64,7 @@ public class Chat implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void broadcastChat(String message) {
|
private void broadcastChat(String message) {
|
||||||
RecordSystem.chat(message);
|
GlobalRecorder.getInstance().chat(message);
|
||||||
BaseComponent[] msg = TextComponent.fromLegacyText(message);
|
BaseComponent[] msg = TextComponent.fromLegacyText(message);
|
||||||
for(Player p : Bukkit.getOnlinePlayers())
|
for(Player p : Bukkit.getOnlinePlayers())
|
||||||
BasicListener.toChat(p, msg);
|
BasicListener.toChat(p, msg);
|
||||||
|
@ -42,7 +42,7 @@ public class EventJoin implements Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void playerLogin(PlayerLoginEvent event) {
|
public void playerLogin(PlayerLoginEvent event) {
|
||||||
if(!Config.SpectateSystem)
|
if(!Config.LiveReplay)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
@ -89,7 +89,7 @@ public class EventJoin implements Listener {
|
|||||||
FightSystem.setEventLeiter(player);
|
FightSystem.setEventLeiter(player);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(Config.SpectateSystem)
|
if(Config.LiveReplay)
|
||||||
player.kickPlayer("§cDu bist kein Kampfteilnehmer");
|
player.kickPlayer("§cDu bist kein Kampfteilnehmer");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +24,8 @@ import de.steamwar.fightsystem.ArenaMode;
|
|||||||
import de.steamwar.fightsystem.countdown.Countdown;
|
import de.steamwar.fightsystem.countdown.Countdown;
|
||||||
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.record.GlobalRecorder;
|
||||||
|
import de.steamwar.fightsystem.record.PacketProcessor;
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||||
import de.steamwar.fightsystem.states.StateDependentTask;
|
import de.steamwar.fightsystem.states.StateDependentTask;
|
||||||
@ -61,8 +62,8 @@ public class FightScoreboard implements Listener, ScoreboardCallback {
|
|||||||
|
|
||||||
|
|
||||||
public FightScoreboard(){
|
public FightScoreboard(){
|
||||||
new StateDependentListener(ArenaMode.AntiSpectate, FightState.All, this);
|
new StateDependentListener(ArenaMode.AntiReplay, FightState.All, this);
|
||||||
new StateDependentTask(ArenaMode.AntiSpectate, FightState.All, this::updateScoreboard, 0, 20);
|
new StateDependentTask(ArenaMode.AntiReplay, FightState.All, this::updateScoreboard, 0, 20);
|
||||||
scoreboard = this;
|
scoreboard = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,7 +113,7 @@ public class FightScoreboard implements Listener, ScoreboardCallback {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateScoreboard() {
|
private void updateScoreboard() {
|
||||||
if(RecordSystem.isReplaying())
|
if(PacketProcessor.isReplaying())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ((index++ / 5) % 2 == 0) {
|
if ((index++ / 5) % 2 == 0) {
|
||||||
@ -127,12 +128,12 @@ public class FightScoreboard implements Listener, ScoreboardCallback {
|
|||||||
public void setTitle(String t) {
|
public void setTitle(String t) {
|
||||||
scores.clear();
|
scores.clear();
|
||||||
title = t;
|
title = t;
|
||||||
RecordSystem.scoreboardTitle(t);
|
GlobalRecorder.getInstance().scoreboardTitle(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addScore(String string, int i) {
|
public void addScore(String string, int i) {
|
||||||
scores.put(string, i);
|
scores.put(string, i);
|
||||||
RecordSystem.scoreboardData(string, i);
|
GlobalRecorder.getInstance().scoreboardData(string, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -35,7 +35,7 @@ import org.bukkit.inventory.meta.ItemMeta;
|
|||||||
public class HotbarGUI implements Listener {
|
public class HotbarGUI implements Listener {
|
||||||
|
|
||||||
public HotbarGUI() {
|
public HotbarGUI() {
|
||||||
new StateDependentListener(ArenaMode.AntiSpectate, FightState.Setup, this);
|
new StateDependentListener(ArenaMode.AntiReplay, FightState.Setup, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
|
@ -36,7 +36,7 @@ import java.util.Objects;
|
|||||||
public class InFightDamage implements Listener {
|
public class InFightDamage implements Listener {
|
||||||
|
|
||||||
public InFightDamage() {
|
public InFightDamage() {
|
||||||
new StateDependentListener(ArenaMode.AntiSpectate, FightState.Running, this);
|
new StateDependentListener(ArenaMode.AntiReplay, FightState.Running, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
|
@ -40,7 +40,7 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
public class InFightInventory implements Listener {
|
public class InFightInventory implements Listener {
|
||||||
|
|
||||||
public InFightInventory() {
|
public InFightInventory() {
|
||||||
new StateDependentListener(ArenaMode.AntiSpectate, FightState.Running, this);
|
new StateDependentListener(ArenaMode.AntiReplay, FightState.Running, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
|
@ -26,7 +26,7 @@ import de.steamwar.fightsystem.countdown.SWSound;
|
|||||||
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.fight.FightTeam;
|
import de.steamwar.fightsystem.fight.FightTeam;
|
||||||
import de.steamwar.fightsystem.record.RecordSystem;
|
import de.steamwar.fightsystem.record.GlobalRecorder;
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -40,7 +40,7 @@ import org.bukkit.event.player.PlayerQuitEvent;
|
|||||||
public class IngameDeath implements Listener {
|
public class IngameDeath implements Listener {
|
||||||
|
|
||||||
public IngameDeath() {
|
public IngameDeath() {
|
||||||
new StateDependentListener(ArenaMode.AntiSpectate, FightState.Ingame, this);
|
new StateDependentListener(ArenaMode.AntiReplay, FightState.Ingame, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
@ -71,7 +71,7 @@ public class IngameDeath implements Listener {
|
|||||||
if(fightPlayer.isLiving()) {
|
if(fightPlayer.isLiving()) {
|
||||||
Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer Spieler " + team.getPrefix() + player.getName() + " §chat den Kampf verlassen!");
|
Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer Spieler " + team.getPrefix() + player.getName() + " §chat den Kampf verlassen!");
|
||||||
team.getFightPlayer(player).setOut();
|
team.getFightPlayer(player).setOut();
|
||||||
RecordSystem.entityDespawns(player);
|
GlobalRecorder.getInstance().entityDespawns(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,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.REntity;
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
import de.steamwar.sql.SteamwarUser;
|
||||||
@ -81,6 +82,8 @@ public class Permanent implements Listener {
|
|||||||
if(ArenaMode.NotOnBau.contains(Config.mode))
|
if(ArenaMode.NotOnBau.contains(Config.mode))
|
||||||
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> new TablistNamePacket(SteamwarUser.get(player.getUniqueId()).getId(), "§7" + player.getName()).send(player), 5);
|
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> new TablistNamePacket(SteamwarUser.get(player.getUniqueId()).getId(), "§7" + player.getName()).send(player), 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
REntity.playerJoins(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
|
@ -25,15 +25,16 @@ import com.comphenix.protocol.events.PacketAdapter;
|
|||||||
import com.comphenix.protocol.events.PacketContainer;
|
import com.comphenix.protocol.events.PacketContainer;
|
||||||
import com.comphenix.protocol.events.PacketEvent;
|
import com.comphenix.protocol.events.PacketEvent;
|
||||||
import com.comphenix.protocol.wrappers.EnumWrappers;
|
import com.comphenix.protocol.wrappers.EnumWrappers;
|
||||||
import de.steamwar.fightsystem.Config;
|
import de.steamwar.fightsystem.ArenaMode;
|
||||||
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.FightPlayer;
|
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.GlobalRecorder;
|
||||||
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.states.StateDependentListener;
|
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||||
|
import de.steamwar.fightsystem.states.StateDependentTask;
|
||||||
import org.bukkit.*;
|
import org.bukkit.*;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -55,6 +56,7 @@ public class Recording implements Listener {
|
|||||||
|
|
||||||
private static final int AIR = 0;
|
private static final int AIR = 0;
|
||||||
private static final Random random = new Random();
|
private static final Random random = new Random();
|
||||||
|
private static final World world = Bukkit.getWorlds().get(0);
|
||||||
private static final PacketAdapter BOW_PACKET_PROCESSOR = new PacketAdapter(FightSystem.getPlugin(), PacketType.Play.Client.BLOCK_PLACE) {
|
private static final PacketAdapter BOW_PACKET_PROCESSOR = new PacketAdapter(FightSystem.getPlugin(), PacketType.Play.Client.BLOCK_PLACE) {
|
||||||
@Override
|
@Override
|
||||||
public void onPacketReceiving(PacketEvent event) {
|
public void onPacketReceiving(PacketEvent event) {
|
||||||
@ -66,23 +68,22 @@ public class Recording implements Listener {
|
|||||||
(hand == EnumWrappers.Hand.OFF_HAND && p.getInventory().getItemInOffHand().getType() == Material.BOW)))
|
(hand == EnumWrappers.Hand.OFF_HAND && p.getInventory().getItemInOffHand().getType() == Material.BOW)))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
RecordSystem.bowSpan(p, true, hand != EnumWrappers.Hand.MAIN_HAND);
|
GlobalRecorder.getInstance().bowSpan(p, true, hand != EnumWrappers.Hand.MAIN_HAND);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private static final PacketAdapter BOW_PACKET_DEDRAW_PROCESSOR = new PacketAdapter(FightSystem.getPlugin(), PacketType.Play.Client.BLOCK_DIG) {
|
private static final PacketAdapter BOW_PACKET_DEDRAW_PROCESSOR = new PacketAdapter(FightSystem.getPlugin(), PacketType.Play.Client.BLOCK_DIG) {
|
||||||
@Override
|
@Override
|
||||||
public void onPacketReceiving(PacketEvent e) {
|
public void onPacketReceiving(PacketEvent e) {
|
||||||
PacketContainer packetDig = e.getPacket();
|
PacketContainer packetDig = e.getPacket();
|
||||||
if(packetDig.getPlayerDigTypes().read(0) == EnumWrappers.PlayerDigType.RELEASE_USE_ITEM) {
|
if(packetDig.getPlayerDigTypes().read(0) == EnumWrappers.PlayerDigType.RELEASE_USE_ITEM) {
|
||||||
RecordSystem.bowSpan(e.getPlayer(), false, false);
|
GlobalRecorder.getInstance().bowSpan(e.getPlayer(), false, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public Recording() {
|
public Recording() {
|
||||||
new StateDependentListener(Config.recording(), FightState.All, this);
|
new StateDependentListener(ArenaMode.AntiReplay, FightState.All, this);
|
||||||
new StateDependent(Config.recording(), FightState.Ingame){
|
new StateDependent(ArenaMode.AntiReplay, FightState.Ingame){
|
||||||
@Override
|
@Override
|
||||||
public void enable() {
|
public void enable() {
|
||||||
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> {
|
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> {
|
||||||
@ -98,7 +99,7 @@ public class Recording implements Listener {
|
|||||||
despawnTNT();
|
despawnTNT();
|
||||||
}
|
}
|
||||||
}.register();
|
}.register();
|
||||||
new StateDependent(Config.recording(), FightState.Ingame) {
|
new StateDependent(ArenaMode.AntiReplay, FightState.Ingame) {
|
||||||
@Override
|
@Override
|
||||||
public void enable() {
|
public void enable() {
|
||||||
ProtocolLibrary.getProtocolManager().addPacketListener(BOW_PACKET_PROCESSOR);
|
ProtocolLibrary.getProtocolManager().addPacketListener(BOW_PACKET_PROCESSOR);
|
||||||
@ -111,6 +112,17 @@ public class Recording implements Listener {
|
|||||||
ProtocolLibrary.getProtocolManager().removePacketListener(BOW_PACKET_DEDRAW_PROCESSOR);
|
ProtocolLibrary.getProtocolManager().removePacketListener(BOW_PACKET_DEDRAW_PROCESSOR);
|
||||||
}
|
}
|
||||||
}.register();
|
}.register();
|
||||||
|
new StateDependentTask(ArenaMode.AntiReplay, FightState.All, () -> {
|
||||||
|
GlobalRecorder.getInstance().tick();
|
||||||
|
|
||||||
|
if(FightState.getFightState() == FightState.SPECTATE || !GlobalRecorder.getInstance().recording())
|
||||||
|
return;
|
||||||
|
|
||||||
|
for(TNTPrimed tnt : world.getEntitiesByClass(TNTPrimed.class)){
|
||||||
|
GlobalRecorder.getInstance().entityMoves(tnt);
|
||||||
|
GlobalRecorder.getInstance().entitySpeed(tnt);
|
||||||
|
}
|
||||||
|
}, 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
@ -118,7 +130,7 @@ public class Recording implements Listener {
|
|||||||
if(isNotSent(e.getPlayer()))
|
if(isNotSent(e.getPlayer()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
RecordSystem.entityMoves(e.getPlayer());
|
GlobalRecorder.getInstance().entityMoves(e.getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||||
@ -126,12 +138,12 @@ public class Recording implements Listener {
|
|||||||
if(isNotSent(e.getEntity()))
|
if(isNotSent(e.getEntity()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
RecordSystem.entityDespawns(e.getEntity());
|
GlobalRecorder.getInstance().entityDespawns(e.getEntity());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void onBroadcast(BroadcastMessageEvent e){
|
public void onBroadcast(BroadcastMessageEvent e){
|
||||||
RecordSystem.systemChat(e.getMessage());
|
GlobalRecorder.getInstance().systemChat(e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
@ -139,7 +151,7 @@ public class Recording implements Listener {
|
|||||||
if(isNotSent(e.getPlayer()))
|
if(isNotSent(e.getPlayer()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
RecordSystem.playerSneak(e.getPlayer(), e.isSneaking());
|
GlobalRecorder.getInstance().playerSneak(e.getPlayer(), e.isSneaking());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
@ -148,7 +160,7 @@ public class Recording implements Listener {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if(e.getAnimationType() == PlayerAnimationType.ARM_SWING)
|
if(e.getAnimationType() == PlayerAnimationType.ARM_SWING)
|
||||||
RecordSystem.entityAnimation(e.getPlayer(), AIR);
|
GlobalRecorder.getInstance().entityAnimation(e.getPlayer(), AIR);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
@ -160,10 +172,10 @@ public class Recording implements Listener {
|
|||||||
if(isNotSent(p))
|
if(isNotSent(p))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
RecordSystem.damageAnimation(p);
|
GlobalRecorder.getInstance().damageAnimation(p);
|
||||||
|
|
||||||
if(e.getCause() == EntityDamageEvent.DamageCause.FIRE_TICK || e.getCause() == EntityDamageEvent.DamageCause.FIRE)
|
if(e.getCause() == EntityDamageEvent.DamageCause.FIRE_TICK || e.getCause() == EntityDamageEvent.DamageCause.FIRE)
|
||||||
RecordSystem.setOnFire(p, false);
|
GlobalRecorder.getInstance().setOnFire(p, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
@ -175,22 +187,21 @@ public class Recording implements Listener {
|
|||||||
if(isNotSent(p))
|
if(isNotSent(p))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
RecordSystem.setOnFire(p, false);
|
GlobalRecorder.getInstance().setOnFire(p, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void onTNTSpawn(EntitySpawnEvent e){
|
public void onTNTSpawn(EntitySpawnEvent e){
|
||||||
//TODO: Falling block
|
|
||||||
if(e.getEntityType() != EntityType.PRIMED_TNT)
|
if(e.getEntityType() != EntityType.PRIMED_TNT)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
RecordSystem.tntSpawn(e.getEntity());
|
GlobalRecorder.getInstance().tntSpawn(e.getEntity());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void onBlockPhysics(BlockPhysicsEvent e){
|
public void onBlockPhysics(BlockPhysicsEvent e){
|
||||||
if(e.getBlock() == e.getSourceBlock() || e.getChangedType() == Material.AIR)
|
if(e.getBlock() == e.getSourceBlock() || e.getChangedType() == Material.AIR)
|
||||||
RecordSystem.blockChange(e.getBlock());
|
GlobalRecorder.getInstance().blockChange(e.getBlock());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
@ -199,9 +210,9 @@ public class Recording implements Listener {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
Location loc = e.getLocation();
|
Location loc = e.getLocation();
|
||||||
RecordSystem.entityDespawns(e.getEntity());
|
GlobalRecorder.getInstance().entityDespawns(e.getEntity());
|
||||||
RecordSystem.particle(loc.getX(), loc.getY(), loc.getZ(), Particle.EXPLOSION_HUGE.name());
|
GlobalRecorder.getInstance().particle(loc.getX(), loc.getY(), loc.getZ(), Particle.EXPLOSION_HUGE.name());
|
||||||
RecordSystem.sound(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), Sound.ENTITY_GENERIC_EXPLODE.name(), SoundCategory.BLOCKS.name(), 4.0F, (1.0F + (random.nextFloat() - random.nextFloat()) * 0.2F) * 0.7F);
|
GlobalRecorder.getInstance().sound(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), Sound.ENTITY_GENERIC_EXPLODE.name(), SoundCategory.BLOCKS.name(), 4.0F, (1.0F + (random.nextFloat() - random.nextFloat()) * 0.2F) * 0.7F);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
@ -209,7 +220,7 @@ public class Recording implements Listener {
|
|||||||
if(isNotSent(e.getPlayer()))
|
if(isNotSent(e.getPlayer()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
RecordSystem.item(e.getPlayer(), disarmNull(e.getPlayer().getInventory().getItem(e.getNewSlot())), "MAINHAND");
|
GlobalRecorder.getInstance().item(e.getPlayer(), disarmNull(e.getPlayer().getInventory().getItem(e.getNewSlot())), "MAINHAND");
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
@ -218,16 +229,16 @@ public class Recording implements Listener {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
Player player = e.getPlayer();
|
Player player = e.getPlayer();
|
||||||
RecordSystem.item(player, disarmNull(e.getMainHandItem()), "MAINHAND");
|
GlobalRecorder.getInstance().item(player, disarmNull(e.getMainHandItem()), "MAINHAND");
|
||||||
RecordSystem.item(player, disarmNull(e.getOffHandItem()), "OFFHAND");
|
GlobalRecorder.getInstance().item(player, disarmNull(e.getOffHandItem()), "OFFHAND");
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void onProjectileSpawn(ProjectileLaunchEvent e){
|
public void onProjectileSpawn(ProjectileLaunchEvent e){
|
||||||
if(e.getEntityType() == EntityType.FIREBALL)
|
if(e.getEntityType() == EntityType.FIREBALL)
|
||||||
RecordSystem.fireballSpawn(e.getEntity());
|
GlobalRecorder.getInstance().fireballSpawn(e.getEntity());
|
||||||
else if(e.getEntityType() == EntityType.ARROW)
|
else if(e.getEntityType() == EntityType.ARROW)
|
||||||
RecordSystem.arrowSpawn(e.getEntity());
|
GlobalRecorder.getInstance().arrowSpawn(e.getEntity());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
@ -241,17 +252,17 @@ public class Recording implements Listener {
|
|||||||
|
|
||||||
switch(e.getSlot()){
|
switch(e.getSlot()){
|
||||||
case 103:
|
case 103:
|
||||||
RecordSystem.item(player, disarmNull(e.getCurrentItem()), "HEAD");
|
GlobalRecorder.getInstance().item(player, disarmNull(e.getCurrentItem()), "HEAD");
|
||||||
break;
|
break;
|
||||||
case 102:
|
case 102:
|
||||||
RecordSystem.item(player, disarmNull(e.getCurrentItem()), "CHEST");
|
GlobalRecorder.getInstance().item(player, disarmNull(e.getCurrentItem()), "CHEST");
|
||||||
break;
|
break;
|
||||||
case 101:
|
case 101:
|
||||||
RecordSystem.item(player, disarmNull(e.getCurrentItem()), "LEGS");
|
GlobalRecorder.getInstance().item(player, disarmNull(e.getCurrentItem()), "LEGS");
|
||||||
break;
|
break;
|
||||||
case 100:
|
case 100:
|
||||||
default:
|
default:
|
||||||
RecordSystem.item(player, disarmNull(e.getCurrentItem()), "FEET");
|
GlobalRecorder.getInstance().item(player, disarmNull(e.getCurrentItem()), "FEET");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -264,12 +275,12 @@ public class Recording implements Listener {
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
Player player = fp.getPlayer();
|
Player player = fp.getPlayer();
|
||||||
RecordSystem.item(player, disarmNull(player.getInventory().getItemInMainHand()), "MAINHAND");
|
GlobalRecorder.getInstance().item(player, disarmNull(player.getInventory().getItemInMainHand()), "MAINHAND");
|
||||||
RecordSystem.item(player, disarmNull(player.getInventory().getItemInOffHand()), "OFFHAND");
|
GlobalRecorder.getInstance().item(player, disarmNull(player.getInventory().getItemInOffHand()), "OFFHAND");
|
||||||
RecordSystem.item(player, disarmNull(player.getInventory().getHelmet()), "HEAD");
|
GlobalRecorder.getInstance().item(player, disarmNull(player.getInventory().getHelmet()), "HEAD");
|
||||||
RecordSystem.item(player, disarmNull(player.getInventory().getChestplate()), "CHEST");
|
GlobalRecorder.getInstance().item(player, disarmNull(player.getInventory().getChestplate()), "CHEST");
|
||||||
RecordSystem.item(player, disarmNull(player.getInventory().getLeggings()), "LEGS");
|
GlobalRecorder.getInstance().item(player, disarmNull(player.getInventory().getLeggings()), "LEGS");
|
||||||
RecordSystem.item(player, disarmNull(player.getInventory().getBoots()), "FEET");
|
GlobalRecorder.getInstance().item(player, disarmNull(player.getInventory().getBoots()), "FEET");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -282,13 +293,13 @@ public class Recording implements Listener {
|
|||||||
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())
|
||||||
RecordSystem.entityDespawns(player.getPlayer());
|
GlobalRecorder.getInstance().entityDespawns(player.getPlayer());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void despawnTNT(){
|
private void despawnTNT(){
|
||||||
for(TNTPrimed tnt : Bukkit.getWorlds().get(0).getEntitiesByClass(TNTPrimed.class))
|
for(TNTPrimed tnt : Bukkit.getWorlds().get(0).getEntitiesByClass(TNTPrimed.class))
|
||||||
RecordSystem.entityDespawns(tnt);
|
GlobalRecorder.getInstance().entityDespawns(tnt);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isNotSent(Player p){
|
private boolean isNotSent(Player p){
|
||||||
|
@ -32,7 +32,7 @@ import org.bukkit.event.player.PlayerQuitEvent;
|
|||||||
public class SetupQuit implements Listener {
|
public class SetupQuit implements Listener {
|
||||||
|
|
||||||
public SetupQuit(){
|
public SetupQuit(){
|
||||||
new StateDependentListener(ArenaMode.AntiSpectate, FightState.Setup, this);
|
new StateDependentListener(ArenaMode.AntiReplay, FightState.Setup, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
|
@ -1,73 +0,0 @@
|
|||||||
/*
|
|
||||||
This file is a part of the SteamWar software.
|
|
||||||
|
|
||||||
Copyright (C) 2020 SteamWar.de-Serverteam
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU Affero General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU Affero General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Affero General Public License
|
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package de.steamwar.fightsystem.listener;
|
|
||||||
|
|
||||||
import de.steamwar.fightsystem.ArenaMode;
|
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
|
||||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
|
||||||
import de.steamwar.sql.SteamwarUser;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.EventPriority;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.event.block.BlockExplodeEvent;
|
|
||||||
import org.bukkit.event.block.BlockPhysicsEvent;
|
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
|
||||||
import org.bukkit.event.player.PlayerLoginEvent;
|
|
||||||
import org.bukkit.event.player.PlayerSwapHandItemsEvent;
|
|
||||||
|
|
||||||
public class Spectate implements Listener {
|
|
||||||
|
|
||||||
public Spectate(){
|
|
||||||
new StateDependentListener(ArenaMode.Spectate, FightState.All, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onLogin(PlayerLoginEvent e){
|
|
||||||
Player player = e.getPlayer();
|
|
||||||
|
|
||||||
if(InspectCommand.inspecting){
|
|
||||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
|
||||||
if(!SpectateSystem.allowedGroups.contains(user.getUserGroup())){
|
|
||||||
e.disallow(PlayerLoginEvent.Result.KICK_WHITELIST, "§eSteam§8War» §cDerzeit ist das Zuschauen nicht gestattet.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onPhysics(BlockPhysicsEvent event) {
|
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onBlockExplosion(BlockExplodeEvent e){
|
|
||||||
e.setCancelled(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void handlePlayerSwapHandItemsEvent(PlayerSwapHandItemsEvent event) {
|
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOW)
|
|
||||||
public void handlePlayerInteract(PlayerInteractEvent event) {
|
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
|
||||||
}
|
|
@ -35,7 +35,7 @@ public class WaterRemover implements Listener {
|
|||||||
private static final int MIN_Y = Config.BluePasteRegion.getMinY() + Config.WaterDepth;
|
private static final int MIN_Y = Config.BluePasteRegion.getMinY() + Config.WaterDepth;
|
||||||
|
|
||||||
public WaterRemover() {
|
public WaterRemover() {
|
||||||
new StateDependentListener(ArenaMode.AntiSpectate, FightState.Running, this);
|
new StateDependentListener(ArenaMode.AntiReplay, FightState.Running, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
|
@ -19,120 +19,59 @@
|
|||||||
|
|
||||||
package de.steamwar.fightsystem.record;
|
package de.steamwar.fightsystem.record;
|
||||||
|
|
||||||
|
import de.steamwar.fightsystem.ArenaMode;
|
||||||
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
|
import de.steamwar.fightsystem.states.StateDependent;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.zip.GZIPOutputStream;
|
import java.util.zip.GZIPOutputStream;
|
||||||
|
|
||||||
public class FileRecorder extends Recorder {
|
public class FileRecorder extends StateDependent implements Recorder {
|
||||||
|
|
||||||
private final DataOutputStream outputStream;
|
private static final File file = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "recording.recording");
|
||||||
|
private DataOutputStream outputStream;
|
||||||
|
|
||||||
|
public static File getFile() {
|
||||||
|
return file;
|
||||||
|
}
|
||||||
|
|
||||||
public FileRecorder(){
|
public FileRecorder(){
|
||||||
super();
|
super(ArenaMode.AntiReplay, FightState.Schem);
|
||||||
World world = Bukkit.getWorlds().get(0);
|
}
|
||||||
File file = new File(world.getWorldFolder(), world.getName() + ".recording");
|
|
||||||
|
@Override
|
||||||
|
public DataOutputStream getStream() {
|
||||||
|
return outputStream;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void enable() {
|
||||||
try{
|
try{
|
||||||
file.createNewFile();
|
outputStream = new DataOutputStream(new BufferedOutputStream(new GZIPOutputStream(new FileOutputStream(file), 4096)){
|
||||||
outputStream = new DataOutputStream(new BufferedOutputStream(new GZIPOutputStream(new FileOutputStream(file), 4096)));
|
@Override
|
||||||
|
public synchronized void flush() {
|
||||||
|
//Don't flush explicitly (performance)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void close() throws IOException {
|
||||||
|
try{
|
||||||
|
super.flush();
|
||||||
|
}catch(IOException e){
|
||||||
|
//do nothing
|
||||||
|
}
|
||||||
|
super.close();
|
||||||
|
}
|
||||||
|
});
|
||||||
}catch(IOException e){
|
}catch(IOException e){
|
||||||
throw new SecurityException("Could not open file", e);
|
throw new SecurityException("Could not open file", e);
|
||||||
}
|
}
|
||||||
|
Recorder.super.enable();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void writeBoolean(boolean b) {
|
public void disable() {
|
||||||
try {
|
Recorder.super.disable();
|
||||||
outputStream.writeBoolean(b);
|
|
||||||
} catch (IOException e) {
|
|
||||||
Bukkit.getLogger().log(Level.SEVERE, "Could not write", e);
|
|
||||||
close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void writeByte(int b) {
|
|
||||||
try {
|
|
||||||
outputStream.writeByte(b);
|
|
||||||
} catch (IOException e) {
|
|
||||||
Bukkit.getLogger().log(Level.SEVERE, "Could not write", e);
|
|
||||||
close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void writeShort(short s) {
|
|
||||||
try {
|
|
||||||
outputStream.writeShort(s);
|
|
||||||
} catch (IOException e) {
|
|
||||||
Bukkit.getLogger().log(Level.SEVERE, "Could not write", e);
|
|
||||||
close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void writeInt(int i) {
|
|
||||||
try {
|
|
||||||
outputStream.writeInt(i);
|
|
||||||
} catch (IOException e) {
|
|
||||||
Bukkit.getLogger().log(Level.SEVERE, "Could not write", e);
|
|
||||||
close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void writeLong(long l) {
|
|
||||||
try {
|
|
||||||
outputStream.writeLong(l);
|
|
||||||
} catch (IOException e) {
|
|
||||||
Bukkit.getLogger().log(Level.SEVERE, "Could not write", e);
|
|
||||||
close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void writeFloat(float f) {
|
|
||||||
try {
|
|
||||||
outputStream.writeFloat(f);
|
|
||||||
} catch (IOException e) {
|
|
||||||
Bukkit.getLogger().log(Level.SEVERE, "Could not write", e);
|
|
||||||
close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void writeDouble(double d) {
|
|
||||||
try {
|
|
||||||
outputStream.writeDouble(d);
|
|
||||||
} catch (IOException e) {
|
|
||||||
Bukkit.getLogger().log(Level.SEVERE, "Could not write", e);
|
|
||||||
close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void writeString(String s) {
|
|
||||||
try {
|
|
||||||
outputStream.writeUTF(s);
|
|
||||||
} catch (IOException e) {
|
|
||||||
Bukkit.getLogger().log(Level.SEVERE, "Could not write", e);
|
|
||||||
close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void doFlush() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void closeRecorder() {
|
|
||||||
try {
|
|
||||||
outputStream.close();
|
|
||||||
} catch (IOException e) {
|
|
||||||
Bukkit.getLogger().log(Level.SEVERE, "Could not close OutputStream", e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
51
FightSystem_Main/src/de/steamwar/fightsystem/record/FileSource.java
Normale Datei
51
FightSystem_Main/src/de/steamwar/fightsystem/record/FileSource.java
Normale Datei
@ -0,0 +1,51 @@
|
|||||||
|
/*
|
||||||
|
This file is a part of the SteamWar software.
|
||||||
|
|
||||||
|
Copyright (C) 2020 SteamWar.de-Serverteam
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.steamwar.fightsystem.record;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
|
import java.io.DataInputStream;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.zip.GZIPInputStream;
|
||||||
|
|
||||||
|
public class FileSource extends PacketSource {
|
||||||
|
|
||||||
|
public FileSource(File fightFile) throws IOException {
|
||||||
|
super(new DataInputStream(new GZIPInputStream(new FileInputStream(fightFile))));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
boolean isClosed() {
|
||||||
|
try{
|
||||||
|
return inputStream.available() == 0;
|
||||||
|
}catch (IOException e){
|
||||||
|
Bukkit.getLogger().log(Level.WARNING, "On close test exception", e);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
boolean async() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
107
FightSystem_Main/src/de/steamwar/fightsystem/record/GlobalRecorder.java
Normale Datei
107
FightSystem_Main/src/de/steamwar/fightsystem/record/GlobalRecorder.java
Normale Datei
@ -0,0 +1,107 @@
|
|||||||
|
/*
|
||||||
|
This file is a part of the SteamWar software.
|
||||||
|
|
||||||
|
Copyright (C) 2020 SteamWar.de-Serverteam
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.steamwar.fightsystem.record;
|
||||||
|
|
||||||
|
import java.io.DataOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class GlobalRecorder extends OutputStream implements Recorder {
|
||||||
|
|
||||||
|
private static final GlobalRecorder recorder = new GlobalRecorder();
|
||||||
|
|
||||||
|
public static GlobalRecorder getInstance(){
|
||||||
|
return recorder;
|
||||||
|
}
|
||||||
|
|
||||||
|
private final List<OutputStream> streams = new ArrayList<>();
|
||||||
|
private final DataOutputStream outputStream = new DataOutputStream(this);
|
||||||
|
|
||||||
|
public void add(OutputStream stream){
|
||||||
|
streams.add(stream);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void remove(OutputStream stream){
|
||||||
|
streams.remove(stream);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean recording(){
|
||||||
|
return !streams.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DataOutputStream getStream() {
|
||||||
|
return outputStream;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void write(int i) throws IOException {
|
||||||
|
foreach(stream -> stream.write(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void write(byte[] bytes, int i, int i1) throws IOException {
|
||||||
|
foreach(stream -> stream.write(bytes, i, i1));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void flush() throws IOException {
|
||||||
|
foreach(OutputStream::flush);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void close() throws IOException {
|
||||||
|
foreach(OutputStream::close);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void foreach(IOThrower thrower) throws IOException {
|
||||||
|
//Custom iterator to allow removal of current element during iteration in underlying list
|
||||||
|
Iterator<OutputStream> it = new Iterator<OutputStream>() {
|
||||||
|
|
||||||
|
private int pos = 0;
|
||||||
|
private int size = streams.size();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasNext() {
|
||||||
|
return pos < streams.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public OutputStream next() {
|
||||||
|
if(size > streams.size()){
|
||||||
|
pos--;
|
||||||
|
size--;
|
||||||
|
}
|
||||||
|
return streams.get(pos++);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
while(it.hasNext()) {
|
||||||
|
thrower.run(it.next());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
interface IOThrower{
|
||||||
|
void run(OutputStream stream) throws IOException;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,70 @@
|
|||||||
|
/*
|
||||||
|
This file is a part of the SteamWar software.
|
||||||
|
|
||||||
|
Copyright (C) 2020 SteamWar.de-Serverteam
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.steamwar.fightsystem.record;
|
||||||
|
|
||||||
|
import de.steamwar.fightsystem.Config;
|
||||||
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
|
import de.steamwar.fightsystem.states.StateDependent;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
|
import java.net.Socket;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
public class LiveRecorder extends StateDependent implements Recorder {
|
||||||
|
|
||||||
|
private DataOutputStream outputStream;
|
||||||
|
private Socket socket;
|
||||||
|
|
||||||
|
public LiveRecorder(){
|
||||||
|
super(Config.LiveReplay, FightState.All);
|
||||||
|
register();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void enable() {
|
||||||
|
try {
|
||||||
|
socket = new Socket(Config.spectateIP, Config.spectatePort);
|
||||||
|
socket.setSoTimeout(1); // Wait a maximum of 1ms on a blocking operation (flush)
|
||||||
|
socket.setSoLinger(true, 1); // Wait a maximum of 1ms on disable
|
||||||
|
socket.setTcpNoDelay(true); // Don't wait on ack
|
||||||
|
outputStream = new DataOutputStream(new BufferedOutputStream(socket.getOutputStream(), 1024));
|
||||||
|
} catch (IOException e) {
|
||||||
|
Bukkit.getLogger().log(Level.WARNING, "Could not init connection to spectate server", e);
|
||||||
|
disable();
|
||||||
|
}
|
||||||
|
Recorder.super.enable();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void disable() {
|
||||||
|
try {
|
||||||
|
socket.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
Bukkit.getLogger().log(Level.WARNING, "IOException on socket close", e);
|
||||||
|
}
|
||||||
|
Recorder.super.disable();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DataOutputStream getStream() {
|
||||||
|
return outputStream;
|
||||||
|
}
|
||||||
|
}
|
62
FightSystem_Main/src/de/steamwar/fightsystem/record/LiveServer.java
Normale Datei
62
FightSystem_Main/src/de/steamwar/fightsystem/record/LiveServer.java
Normale Datei
@ -0,0 +1,62 @@
|
|||||||
|
/*
|
||||||
|
This file is a part of the SteamWar software.
|
||||||
|
|
||||||
|
Copyright (C) 2020 SteamWar.de-Serverteam
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.steamwar.fightsystem.record;
|
||||||
|
|
||||||
|
import de.steamwar.fightsystem.Config;
|
||||||
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.ServerSocket;
|
||||||
|
import java.net.Socket;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
public class LiveServer {
|
||||||
|
|
||||||
|
private final ServerSocket socket;
|
||||||
|
|
||||||
|
public LiveServer() throws IOException {
|
||||||
|
socket = new ServerSocket(Config.spectatePort);
|
||||||
|
Bukkit.getScheduler().runTaskAsynchronously(FightSystem.getPlugin(), this::acceptConnections);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void close(){
|
||||||
|
try {
|
||||||
|
socket.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
Bukkit.getLogger().log(Level.SEVERE, "Could not close socket", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void acceptConnections(){
|
||||||
|
try {
|
||||||
|
while(!socket.isClosed()){
|
||||||
|
Socket s = socket.accept();
|
||||||
|
if(PacketProcessor.isReplaying()){
|
||||||
|
s.close();
|
||||||
|
}else{
|
||||||
|
new LiveSource(s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
Bukkit.getLogger().log(Level.INFO, "Stopping accepting connections", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
56
FightSystem_Main/src/de/steamwar/fightsystem/record/LiveSource.java
Normale Datei
56
FightSystem_Main/src/de/steamwar/fightsystem/record/LiveSource.java
Normale Datei
@ -0,0 +1,56 @@
|
|||||||
|
/*
|
||||||
|
This file is a part of the SteamWar software.
|
||||||
|
|
||||||
|
Copyright (C) 2020 SteamWar.de-Serverteam
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.steamwar.fightsystem.record;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
|
import java.io.DataInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.Socket;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
public class LiveSource extends PacketSource {
|
||||||
|
private final Socket socket;
|
||||||
|
|
||||||
|
protected LiveSource(Socket socket) throws IOException {
|
||||||
|
super(new DataInputStream(socket.getInputStream()));
|
||||||
|
this.socket = socket;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void close() {
|
||||||
|
super.close();
|
||||||
|
try {
|
||||||
|
socket.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
Bukkit.getLogger().log(Level.SEVERE, "IOException on close", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
boolean isClosed() {
|
||||||
|
return socket.isClosed();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
boolean async() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -19,11 +19,13 @@
|
|||||||
|
|
||||||
package de.steamwar.fightsystem.record;
|
package de.steamwar.fightsystem.record;
|
||||||
|
|
||||||
|
import de.steamwar.core.VersionedRunnable;
|
||||||
|
import de.steamwar.fightsystem.ArenaMode;
|
||||||
import de.steamwar.fightsystem.Config;
|
import de.steamwar.fightsystem.Config;
|
||||||
import de.steamwar.fightsystem.FightSystem;
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
|
import de.steamwar.fightsystem.countdown.EventSpectateCountdown;
|
||||||
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.fight.FightWorld;
|
|
||||||
import de.steamwar.fightsystem.fight.FreezeWorld;
|
import de.steamwar.fightsystem.fight.FreezeWorld;
|
||||||
import de.steamwar.fightsystem.listener.FightScoreboard;
|
import de.steamwar.fightsystem.listener.FightScoreboard;
|
||||||
import de.steamwar.fightsystem.utils.TechHider;
|
import de.steamwar.fightsystem.utils.TechHider;
|
||||||
@ -43,7 +45,13 @@ import java.util.LinkedList;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
class PacketProcessor {
|
public class PacketProcessor {
|
||||||
|
|
||||||
|
static boolean replaying = false;
|
||||||
|
|
||||||
|
public static boolean isReplaying(){
|
||||||
|
return replaying;
|
||||||
|
}
|
||||||
|
|
||||||
private static final World world = Bukkit.getWorlds().get(0);
|
private static final World world = Bukkit.getWorlds().get(0);
|
||||||
|
|
||||||
@ -57,7 +65,7 @@ class PacketProcessor {
|
|||||||
|
|
||||||
public PacketProcessor(PacketSource source){
|
public PacketProcessor(PacketSource source){
|
||||||
this.source = source;
|
this.source = source;
|
||||||
RecordSystem.setReplaying(true);
|
replaying = true;
|
||||||
if(source.async()) {
|
if(source.async()) {
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(FightSystem.getPlugin(), this::process);
|
Bukkit.getScheduler().runTaskAsynchronously(FightSystem.getPlugin(), this::process);
|
||||||
task = Bukkit.getScheduler().runTaskTimer(FightSystem.getPlugin(), this::runSync, 1, 1);
|
task = Bukkit.getScheduler().runTaskTimer(FightSystem.getPlugin(), this::runSync, 1, 1);
|
||||||
@ -198,7 +206,7 @@ class PacketProcessor {
|
|||||||
if(!Config.ArenaRegion.in2dRegion(x, z))
|
if(!Config.ArenaRegion.in2dRegion(x, z))
|
||||||
return; //Outside of the arena
|
return; //Outside of the arena
|
||||||
|
|
||||||
execSync(() -> RecordSystem.setBlock(x, y, z, TechHider.ENABLED && hiddenBlockIds.contains(blockState) ? obfuscateWith : blockState));
|
execSync(() -> setBlockInternal(x, y, z, TechHider.ENABLED && hiddenBlockIds.contains(blockState) ? obfuscateWith : blockState));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void particle() throws IOException {
|
private void particle() throws IOException {
|
||||||
@ -281,9 +289,13 @@ class PacketProcessor {
|
|||||||
private void endReplay(){
|
private void endReplay(){
|
||||||
REntity.dieAll();
|
REntity.dieAll();
|
||||||
freezer.disable();
|
freezer.disable();
|
||||||
//TODO: Stop server if singular replay
|
replaying = false;
|
||||||
FightWorld.resetWorld();
|
if(Config.replayserver() || ArenaMode.AntiReplay.contains(Config.mode)) {
|
||||||
RecordSystem.setReplaying(false);
|
FightSystem.setSpectateState(null, "Replay ends");
|
||||||
|
}else{
|
||||||
|
Bukkit.broadcastMessage(FightSystem.PREFIX + "§cReplay beendet");
|
||||||
|
new EventSpectateCountdown().enable();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void bow() throws IOException {
|
private void bow() throws IOException {
|
||||||
@ -419,4 +431,10 @@ class PacketProcessor {
|
|||||||
task.cancel();
|
task.cancel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void setBlockInternal(int x, int y, int z, int blockState){
|
||||||
|
VersionedRunnable.call(new VersionedRunnable(() -> RecordSystem_8.setBlock(world, x, y, z, blockState), 8),
|
||||||
|
new VersionedRunnable(() -> RecordSystem_14.setBlock(world, x, y, z, blockState), 14),
|
||||||
|
new VersionedRunnable(() -> RecordSystem_15.setBlock(world, x, y, z, blockState), 15));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,7 @@ public abstract class PacketSource {
|
|||||||
try {
|
try {
|
||||||
inputStream.close();
|
inputStream.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Bukkit.getLogger().log(Level.SEVERE, "IOException on close", e);
|
Bukkit.getLogger().log(Level.SEVERE, "IOException on disable", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ import com.comphenix.protocol.events.PacketContainer;
|
|||||||
import com.comphenix.protocol.reflect.StructureModifier;
|
import com.comphenix.protocol.reflect.StructureModifier;
|
||||||
import com.comphenix.protocol.wrappers.*;
|
import com.comphenix.protocol.wrappers.*;
|
||||||
import de.steamwar.core.Core;
|
import de.steamwar.core.Core;
|
||||||
|
import de.steamwar.core.VersionedCallable;
|
||||||
import de.steamwar.fightsystem.listener.FightScoreboard;
|
import de.steamwar.fightsystem.listener.FightScoreboard;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
import de.steamwar.sql.SteamwarUser;
|
||||||
import net.royawesome.jlibnoise.MathHelper;
|
import net.royawesome.jlibnoise.MathHelper;
|
||||||
@ -20,6 +21,7 @@ import org.bukkit.scoreboard.Team;
|
|||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class REntity {
|
public class REntity {
|
||||||
|
|
||||||
@ -47,7 +49,8 @@ public class REntity {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void playerJoins(Player player) throws InvocationTargetException {
|
public static void playerJoins(Player player) {
|
||||||
|
try{
|
||||||
for(REntity entity : entities.values()){
|
for(REntity entity : entities.values()){
|
||||||
if(entity.entityType == EntityType.PLAYER){
|
if(entity.entityType == EntityType.PLAYER){
|
||||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, entity.getPlayerInfoPacket());
|
ProtocolLibrary.getProtocolManager().sendServerPacket(player, entity.getPlayerInfoPacket());
|
||||||
@ -71,7 +74,11 @@ public class REntity {
|
|||||||
}
|
}
|
||||||
if(entity.sneaks) {
|
if(entity.sneaks) {
|
||||||
WrappedDataWatcher watcher = new WrappedDataWatcher();
|
WrappedDataWatcher watcher = new WrappedDataWatcher();
|
||||||
watcher.setObject(6, RecordSystem.getPose(true), true);
|
if(Core.getVersion() > 12){
|
||||||
|
watcher.setObject(6, getPose(true), true);
|
||||||
|
}else{
|
||||||
|
watcher.setObject(0, (byte) 2, true);
|
||||||
|
}
|
||||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, entity.getDataWatcherPacket(watcher));
|
ProtocolLibrary.getProtocolManager().sendServerPacket(player, entity.getDataWatcherPacket(watcher));
|
||||||
/*DataWatcher dataWatcher = new DataWatcher(null);
|
/*DataWatcher dataWatcher = new DataWatcher(null);
|
||||||
DataWatcherObject<EntityPose> dataWatcherObject = new DataWatcherObject<>(6, DataWatcherRegistry.s);
|
DataWatcherObject<EntityPose> dataWatcherObject = new DataWatcherObject<>(6, DataWatcherRegistry.s);
|
||||||
@ -80,6 +87,9 @@ public class REntity {
|
|||||||
entity.sendDataWatcher(dataWatcher);*/
|
entity.sendDataWatcher(dataWatcher);*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}catch(InvocationTargetException e){
|
||||||
|
Bukkit.getLogger().log(Level.SEVERE, "Could not sync player", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void dieAll(){
|
public static void dieAll(){
|
||||||
@ -189,7 +199,7 @@ public class REntity {
|
|||||||
|
|
||||||
WrappedDataWatcher watcher = new WrappedDataWatcher();
|
WrappedDataWatcher watcher = new WrappedDataWatcher();
|
||||||
if(Core.getVersion() > 12){
|
if(Core.getVersion() > 12){
|
||||||
watcher.setObject(6, RecordSystem.getPose(sneaking), true);
|
watcher.setObject(6, getPose(sneaking), true);
|
||||||
}else{
|
}else{
|
||||||
watcher.setObject(0, sneaking ? (byte) 2 : (byte) 0, true);
|
watcher.setObject(0, sneaking ? (byte) 2 : (byte) 0, true);
|
||||||
}
|
}
|
||||||
@ -381,4 +391,9 @@ public class REntity {
|
|||||||
}
|
}
|
||||||
return namedSpawnPacket;
|
return namedSpawnPacket;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static Object getPose(boolean sneaking){
|
||||||
|
return VersionedCallable.call(new VersionedCallable<>(() -> RecordSystem_14.getPose(sneaking), 14),
|
||||||
|
new VersionedCallable<>(() -> RecordSystem_15.getPose(sneaking), 15));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,351 +0,0 @@
|
|||||||
/*
|
|
||||||
This file is a part of the SteamWar software.
|
|
||||||
|
|
||||||
Copyright (C) 2020 SteamWar.de-Serverteam
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU Affero General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU Affero General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Affero General Public License
|
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package de.steamwar.fightsystem.record;
|
|
||||||
|
|
||||||
import de.steamwar.core.VersionedCallable;
|
|
||||||
import de.steamwar.core.VersionedRunnable;
|
|
||||||
import de.steamwar.fightsystem.ArenaMode;
|
|
||||||
import de.steamwar.fightsystem.Config;
|
|
||||||
import de.steamwar.fightsystem.FightSystem;
|
|
||||||
import de.steamwar.fightsystem.fight.*;
|
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
|
||||||
import de.steamwar.sql.SteamwarUser;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.entity.Entity;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.entity.TNTPrimed;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
import org.bukkit.util.Vector;
|
|
||||||
|
|
||||||
public class RecordSystem {
|
|
||||||
private RecordSystem(){}
|
|
||||||
|
|
||||||
private static boolean replaying = false;
|
|
||||||
|
|
||||||
public static boolean isReplaying(){
|
|
||||||
return replaying;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setReplaying(boolean replaying){
|
|
||||||
RecordSystem.replaying = replaying;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final World WORLD = Bukkit.getWorlds().get(0);
|
|
||||||
|
|
||||||
public static void init(){
|
|
||||||
if(!Config.recording())
|
|
||||||
return;
|
|
||||||
|
|
||||||
Bukkit.getScheduler().runTaskTimer(FightSystem.getPlugin(), RecordSystem::checkWorldState, 1, 1);
|
|
||||||
if (Config.SpectateSystem)
|
|
||||||
new SpectateConnection();
|
|
||||||
new FileRecorder();
|
|
||||||
if(Config.mode == ArenaMode.EVENT)
|
|
||||||
teamIds(Config.EventTeamBlueID, Config.EventTeamRedID);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* PlayerJoinPacket (0x00) + int EntityId + int SWUserId
|
|
||||||
* EntityMovePacket (0x01) + int EntityId + double x, y, z + float pitch, yaw + byte headyaw
|
|
||||||
* EntityDespawnsPacket (0x02) + int EntityId
|
|
||||||
* PlayerSneakPacket (0x03) + int EntityId + boolean sneaks
|
|
||||||
* EntityAnimationPacket (0x04) + int EntityId + byte animation
|
|
||||||
* TNTSpawnPacket (0x05) + int EntityId
|
|
||||||
* EntitySpeedPacket (0x06) + int EntityId + double dx, dy, dz
|
|
||||||
* PlayerItemPacket (0x07) + int EntityId + String item + boolean enchanted + String slot
|
|
||||||
* ArrowSpawnPacket (0x08) + int EntityId
|
|
||||||
* FireballSpawnPacket (0x09) + int EntityId
|
|
||||||
* BowSpanPacket (0x0A) + int EntityId + boolean start + hand
|
|
||||||
* PlayerDamagePacket (0x0B) + int EntityId
|
|
||||||
* SetOnFire (0x0C) + int EntityId + boolean perma
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* BlockPacket (0x30) + pos int, byte, int + int BlockState
|
|
||||||
* ParticlePacket (0x31) + double x, y, z + string particleType
|
|
||||||
* SoundPacket (0x32) + int x, y, z + string soundType + string soundCategory + float volume, pitch
|
|
||||||
* ShortBlockPacket (0x33) + pos relative to ArenaMinX,ArenaMinZ byte, byte, byte + short BlockState
|
|
||||||
* SoundAtPlayerPacket (0x34) + string (soundType, soundCategory) + float volume, pitch
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* ChatPacket (0xA0) + String message
|
|
||||||
* ActionBarPacket (0xA1) + String message
|
|
||||||
* SystemPacket (0xA2) + String message
|
|
||||||
* BlueSchemPacket (0xB0) + int blueSchemId
|
|
||||||
* RedSchemPacket (0xB1) + int redSchemId
|
|
||||||
* TeamIDPacket (0xB2) + int blueTeamId, redTeamId
|
|
||||||
* ScoreboardTitlePacket (0xC0) + String scoreboardTitle
|
|
||||||
* ScoreboardDataPacket (0xC1) + String key + int value
|
|
||||||
*
|
|
||||||
* CommentPacket (0xfe) + String comment
|
|
||||||
* TickPacket (0xff)
|
|
||||||
* */
|
|
||||||
|
|
||||||
public static synchronized void playerJoins(Player p){
|
|
||||||
SteamwarUser user = SteamwarUser.get(p.getUniqueId());
|
|
||||||
|
|
||||||
Recorder.rByte(0x00);
|
|
||||||
Recorder.rInt(p.getEntityId());
|
|
||||||
Recorder.rInt(user.getId());
|
|
||||||
entityMoves(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static synchronized void entityMoves(Entity e){
|
|
||||||
Location location = e.getLocation();
|
|
||||||
|
|
||||||
Recorder.rByte(0x01);
|
|
||||||
Recorder.rInt(e.getEntityId());
|
|
||||||
Recorder.rDouble(location.getX());
|
|
||||||
Recorder.rDouble(location.getY());
|
|
||||||
Recorder.rDouble(location.getZ());
|
|
||||||
Recorder.rFloat(location.getPitch());
|
|
||||||
Recorder.rFloat(location.getYaw());
|
|
||||||
Recorder.rByte((int)(VersionedCallable.call(
|
|
||||||
new VersionedCallable<>(() -> FightWorld_8.headRotation(e), 8),
|
|
||||||
new VersionedCallable<>(() -> FightWorld_9.headRotation(e), 9),
|
|
||||||
new VersionedCallable<>(() -> FightWorld_10.headRotation(e), 10),
|
|
||||||
new VersionedCallable<>(() -> FightWorld_12.headRotation(e), 12),
|
|
||||||
new VersionedCallable<>(() -> FightWorld_14.headRotation(e), 14),
|
|
||||||
new VersionedCallable<>(() -> FightWorld_15.headRotation(e), 15)
|
|
||||||
) * 256 / 360));
|
|
||||||
Recorder.flush();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static synchronized void entityDespawns(Entity e){
|
|
||||||
Recorder.rByte(0x02);
|
|
||||||
Recorder.rInt(e.getEntityId());
|
|
||||||
Recorder.flush();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static synchronized void playerSneak(Player p, boolean sneaks){
|
|
||||||
Recorder.rByte(0x03);
|
|
||||||
Recorder.rInt(p.getEntityId());
|
|
||||||
Recorder.rBoolean(sneaks);
|
|
||||||
Recorder.flush();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static synchronized void entityAnimation(Entity e, int animation){
|
|
||||||
Recorder.rByte(0x04);
|
|
||||||
Recorder.rInt(e.getEntityId());
|
|
||||||
Recorder.rByte(animation);
|
|
||||||
Recorder.flush();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static synchronized void tntSpawn(Entity e){
|
|
||||||
Recorder.rByte(0x05);
|
|
||||||
spawnEntity(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static synchronized void entitySpeed(Entity e){
|
|
||||||
Vector velocity = e.getVelocity();
|
|
||||||
Recorder.rByte(0x06);
|
|
||||||
Recorder.rInt(e.getEntityId());
|
|
||||||
Recorder.rDouble(velocity.getX());
|
|
||||||
Recorder.rDouble(velocity.getY());
|
|
||||||
Recorder.rDouble(velocity.getZ());
|
|
||||||
Recorder.flush();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static synchronized void item(Player p, ItemStack item, String slot){
|
|
||||||
Recorder.rByte(0x07);
|
|
||||||
Recorder.rInt(p.getEntityId());
|
|
||||||
Recorder.rString("minecraft:" + item.getType().name().toLowerCase());
|
|
||||||
Recorder.rBoolean(!item.getEnchantments().isEmpty());
|
|
||||||
Recorder.rString(slot);
|
|
||||||
Recorder.flush();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static synchronized void arrowSpawn(Entity e){
|
|
||||||
Recorder.rByte(0x08);
|
|
||||||
spawnEntity(e);
|
|
||||||
if(e.getFireTicks() > 0)
|
|
||||||
setOnFire(e, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static synchronized void fireballSpawn(Entity e){
|
|
||||||
Recorder.rByte(0x09);
|
|
||||||
spawnEntity(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static synchronized void bowSpan(Entity e, boolean start, boolean offHand) {
|
|
||||||
Recorder.rByte(0x0A);
|
|
||||||
Recorder.rInt(e.getEntityId());
|
|
||||||
Recorder.rBoolean(start);
|
|
||||||
Recorder.rBoolean(offHand);
|
|
||||||
Recorder.flush();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static synchronized void damageAnimation(Player p) {
|
|
||||||
Recorder.rByte(0x0B);
|
|
||||||
Recorder.rInt(p.getEntityId());
|
|
||||||
Recorder.flush();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static synchronized void setOnFire(Entity e, boolean perma) {
|
|
||||||
Recorder.rByte(0x0C);
|
|
||||||
Recorder.rInt(e.getEntityId());
|
|
||||||
Recorder.rBoolean(perma);
|
|
||||||
Recorder.flush();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static synchronized void blockChange(Block block){
|
|
||||||
int blockState = blockToId(block);
|
|
||||||
|
|
||||||
int shortX = block.getX() - Config.ArenaRegion.getMinX();
|
|
||||||
int shortZ = block.getZ() - Config.ArenaRegion.getMinZ();
|
|
||||||
if((short)blockState == blockState && shortX > 0 && shortX < 256 && shortZ > 0 && shortZ < 256){
|
|
||||||
//Short block packet
|
|
||||||
Recorder.rByte(0x33);
|
|
||||||
Recorder.rByte(shortX);
|
|
||||||
Recorder.rByte(block.getY());
|
|
||||||
Recorder.rByte(shortZ);
|
|
||||||
Recorder.rShort((short)blockState);
|
|
||||||
}else{
|
|
||||||
//Block packet
|
|
||||||
Recorder.rByte(0x30);
|
|
||||||
Recorder.rInt(block.getX());
|
|
||||||
Recorder.rByte(block.getY());
|
|
||||||
Recorder.rInt(block.getZ());
|
|
||||||
Recorder.rInt(blockState);
|
|
||||||
}
|
|
||||||
Recorder.flush();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static synchronized void particle(double x, double y, double z, String particleType){
|
|
||||||
Recorder.rByte(0x31);
|
|
||||||
Recorder.rDouble(x);
|
|
||||||
Recorder.rDouble(y);
|
|
||||||
Recorder.rDouble(z);
|
|
||||||
Recorder.rString(particleType);
|
|
||||||
Recorder.flush();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static synchronized void sound(int x, int y, int z, String soundType, String soundCategory, float volume, float pitch){
|
|
||||||
Recorder.rByte(0x32);
|
|
||||||
Recorder.rInt(x);
|
|
||||||
Recorder.rInt(y);
|
|
||||||
Recorder.rInt(z);
|
|
||||||
Recorder.rString(soundType);
|
|
||||||
Recorder.rString(soundCategory);
|
|
||||||
Recorder.rFloat(volume);
|
|
||||||
Recorder.rFloat(pitch);
|
|
||||||
Recorder.flush();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static synchronized void soundAtPlayer(String soundType, float volume, float pitch){
|
|
||||||
Recorder.rByte(0x34);
|
|
||||||
Recorder.rString(soundType);
|
|
||||||
Recorder.rFloat(volume);
|
|
||||||
Recorder.rFloat(pitch);
|
|
||||||
Recorder.flush();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static synchronized void chat(String s) {
|
|
||||||
Recorder.rByte(0xA0);
|
|
||||||
Recorder.rString(s);
|
|
||||||
Recorder.flush();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static synchronized void actionBar(String s) {
|
|
||||||
Recorder.rByte(0xA1);
|
|
||||||
Recorder.rString(s);
|
|
||||||
Recorder.flush();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static synchronized void systemChat(String s) {
|
|
||||||
Recorder.rByte(0xA2);
|
|
||||||
Recorder.rString(s);
|
|
||||||
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 teamIds(int blueTeamId, int redTeamId) {
|
|
||||||
Recorder.rByte(0xB2);
|
|
||||||
Recorder.rInt(blueTeamId);
|
|
||||||
Recorder.rInt(redTeamId);
|
|
||||||
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(){
|
|
||||||
Recorder.rByte(0xff);
|
|
||||||
Recorder.flush();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void checkWorldState(){
|
|
||||||
tick();
|
|
||||||
|
|
||||||
if(FightState.getFightState() == FightState.SPECTATE)
|
|
||||||
return;
|
|
||||||
|
|
||||||
for(TNTPrimed tnt : WORLD.getEntitiesByClass(TNTPrimed.class)){
|
|
||||||
entityMoves(tnt);
|
|
||||||
entitySpeed(tnt);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void spawnEntity(Entity e){
|
|
||||||
Recorder.rInt(e.getEntityId());
|
|
||||||
entityMoves(e);
|
|
||||||
entitySpeed(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static int blockToId(Block block){
|
|
||||||
return VersionedCallable.call(new VersionedCallable<>(() -> RecordSystem_8.blockToId(block), 8),
|
|
||||||
new VersionedCallable<>(() -> RecordSystem_14.blockToId(block), 14),
|
|
||||||
new VersionedCallable<>(() -> RecordSystem_15.blockToId(block), 15));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Object getPose(boolean sneaking){
|
|
||||||
return VersionedCallable.call(new VersionedCallable<>(() -> RecordSystem_14.getPose(sneaking), 14),
|
|
||||||
new VersionedCallable<>(() -> RecordSystem_15.getPose(sneaking), 15));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setBlock(int x, int y, int z, int blockState){
|
|
||||||
VersionedRunnable.call(new VersionedRunnable(() -> RecordSystem_8.setBlock(WORLD, x, y, z, blockState), 8),
|
|
||||||
new VersionedRunnable(() -> RecordSystem_14.setBlock(WORLD, x, y, z, blockState), 14),
|
|
||||||
new VersionedRunnable(() -> RecordSystem_15.setBlock(WORLD, x, y, z, blockState), 15));
|
|
||||||
}
|
|
||||||
}
|
|
@ -19,72 +19,264 @@
|
|||||||
|
|
||||||
package de.steamwar.fightsystem.record;
|
package de.steamwar.fightsystem.record;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import de.steamwar.core.VersionedCallable;
|
||||||
import java.util.List;
|
import de.steamwar.fightsystem.ArenaMode;
|
||||||
|
import de.steamwar.fightsystem.Config;
|
||||||
|
import de.steamwar.fightsystem.fight.*;
|
||||||
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
|
import de.steamwar.sql.SteamwarUser;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
public abstract class Recorder {
|
import java.io.DataOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
private static final List<Recorder> recorders = new ArrayList<>();
|
public interface Recorder {
|
||||||
|
DataOutputStream getStream();
|
||||||
|
|
||||||
public static void rBoolean(boolean b){
|
default void enable() {
|
||||||
recorders.forEach((recorder) -> recorder.writeBoolean(b));
|
GlobalRecorder.getInstance().add(getStream());
|
||||||
|
|
||||||
|
if(ArenaMode.Event.contains(Config.mode)){
|
||||||
|
teamIds(Config.EventTeamBlueID, Config.EventTeamRedID);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void rByte(int b){
|
enableTeam(Fight.getBlueTeam());
|
||||||
recorders.forEach((recorder) -> recorder.writeByte(b));
|
enableTeam(Fight.getRedTeam());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void rShort(short s){
|
default void enableTeam(FightTeam team){
|
||||||
recorders.forEach((recorder) -> recorder.writeShort(s));
|
if(FightState.Schem.contains(FightState.getFightState())){
|
||||||
|
if(team.isBlue())
|
||||||
|
blueSchem(team.getSchematic());
|
||||||
|
else
|
||||||
|
redSchem(team.getSchematic());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void rInt(int i){
|
if(FightState.AntiSpectate.contains(FightState.getFightState())){
|
||||||
recorders.forEach((recorder) -> recorder.writeInt(i));
|
for(FightPlayer player : team.getPlayers()){
|
||||||
|
if(player.isLiving()){
|
||||||
|
playerJoins(player.getPlayer());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void rLong(long l){
|
default void disable() {
|
||||||
recorders.forEach((recorder) -> recorder.writeLong(l));
|
GlobalRecorder.getInstance().remove(getStream());
|
||||||
|
try {
|
||||||
|
getStream().close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
Bukkit.getLogger().log(Level.SEVERE, "Could not close OutputStream", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void rFloat(float f){
|
/*
|
||||||
recorders.forEach((recorder) -> recorder.writeFloat(f));
|
* PlayerJoinPacket (0x00) + int EntityId + int SWUserId
|
||||||
|
* EntityMovePacket (0x01) + int EntityId + double x, y, z + float pitch, yaw + byte headyaw
|
||||||
|
* EntityDespawnsPacket (0x02) + int EntityId
|
||||||
|
* PlayerSneakPacket (0x03) + int EntityId + boolean sneaks
|
||||||
|
* EntityAnimationPacket (0x04) + int EntityId + byte animation
|
||||||
|
* TNTSpawnPacket (0x05) + int EntityId
|
||||||
|
* EntitySpeedPacket (0x06) + int EntityId + double dx, dy, dz
|
||||||
|
* PlayerItemPacket (0x07) + int EntityId + String item + boolean enchanted + String slot
|
||||||
|
* ArrowSpawnPacket (0x08) + int EntityId
|
||||||
|
* FireballSpawnPacket (0x09) + int EntityId
|
||||||
|
* BowSpanPacket (0x0A) + int EntityId + boolean start + hand
|
||||||
|
* PlayerDamagePacket (0x0B) + int EntityId
|
||||||
|
* SetOnFire (0x0C) + int EntityId + boolean perma
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* BlockPacket (0x30) + pos int, byte, int + int BlockState
|
||||||
|
* ParticlePacket (0x31) + double x, y, z + string particleType
|
||||||
|
* SoundPacket (0x32) + int x, y, z + string soundType + string soundCategory + float volume, pitch
|
||||||
|
* ShortBlockPacket (0x33) + pos relative to ArenaMinX,ArenaMinZ byte, byte, byte + short BlockState
|
||||||
|
* SoundAtPlayerPacket (0x34) + string (soundType, soundCategory) + float volume, pitch
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* ChatPacket (0xA0) + String message
|
||||||
|
* ActionBarPacket (0xA1) + String message
|
||||||
|
* SystemPacket (0xA2) + String message
|
||||||
|
* BlueSchemPacket (0xB0) + int blueSchemId
|
||||||
|
* RedSchemPacket (0xB1) + int redSchemId
|
||||||
|
* TeamIDPacket (0xB2) + int blueTeamId, redTeamId
|
||||||
|
* ScoreboardTitlePacket (0xC0) + String scoreboardTitle
|
||||||
|
* ScoreboardDataPacket (0xC1) + String key + int value
|
||||||
|
*
|
||||||
|
* CommentPacket (0xfe) + String comment
|
||||||
|
* TickPacket (0xff)
|
||||||
|
* */
|
||||||
|
|
||||||
|
default void playerJoins(Player p){
|
||||||
|
SteamwarUser user = SteamwarUser.get(p.getUniqueId());
|
||||||
|
|
||||||
|
write(0x00, p.getEntityId(), user.getId());
|
||||||
|
entityMoves(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void rDouble(double d){
|
default void entityMoves(Entity e){
|
||||||
recorders.forEach((recorder) -> recorder.writeDouble(d));
|
Location location = e.getLocation();
|
||||||
|
write(0x01, e.getEntityId(), location.getX(), location.getY(), location.getZ(), location.getPitch(), location.getYaw(), (int)(VersionedCallable.call(
|
||||||
|
new VersionedCallable<>(() -> FightWorld_8.headRotation(e), 8),
|
||||||
|
new VersionedCallable<>(() -> FightWorld_9.headRotation(e), 9),
|
||||||
|
new VersionedCallable<>(() -> FightWorld_10.headRotation(e), 10),
|
||||||
|
new VersionedCallable<>(() -> FightWorld_12.headRotation(e), 12),
|
||||||
|
new VersionedCallable<>(() -> FightWorld_14.headRotation(e), 14),
|
||||||
|
new VersionedCallable<>(() -> FightWorld_15.headRotation(e), 15)
|
||||||
|
) * 256 / 360));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void rString(String s){
|
default void entityDespawns(Entity e){
|
||||||
recorders.forEach((recorder) -> recorder.writeString(s));
|
write(0x02, e.getEntityId());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void flush(){
|
default void playerSneak(Player p, boolean sneaks){
|
||||||
recorders.forEach(Recorder::doFlush);
|
write(0x03, p.getEntityId(), sneaks);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void closeAll(){
|
default void entityAnimation(Entity e, int animation){
|
||||||
while(!recorders.isEmpty())
|
write(0x04, e.getEntityId(), animation);
|
||||||
recorders.get(0).close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Recorder(){
|
default void tntSpawn(Entity e){
|
||||||
recorders.add(this);
|
write(0x05, e.getEntityId());
|
||||||
|
entityMoves(e);
|
||||||
|
entitySpeed(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void close(){
|
default void entitySpeed(Entity e){
|
||||||
closeRecorder();
|
Vector velocity = e.getVelocity();
|
||||||
recorders.remove(this);
|
write(0x06, e.getEntityId(), velocity.getX(), velocity.getY(), velocity.getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract void writeBoolean(boolean b);
|
default void item(Player p, ItemStack item, String slot){
|
||||||
protected abstract void writeByte(int b);
|
write(0x07, p.getEntityId(), "minecraft:" + item.getType().name().toLowerCase(), !item.getEnchantments().isEmpty(), slot);
|
||||||
protected abstract void writeShort(short s);
|
}
|
||||||
protected abstract void writeInt(int i);
|
|
||||||
protected abstract void writeLong(long l);
|
default void arrowSpawn(Entity e){
|
||||||
protected abstract void writeFloat(float f);
|
write(0x08, e.getEntityId());
|
||||||
protected abstract void writeDouble(double d);
|
entityMoves(e);
|
||||||
protected abstract void writeString(String s);
|
entitySpeed(e);
|
||||||
protected abstract void doFlush();
|
if(e.getFireTicks() > 0)
|
||||||
|
setOnFire(e, true);
|
||||||
protected abstract void closeRecorder();
|
}
|
||||||
|
|
||||||
|
default void fireballSpawn(Entity e){
|
||||||
|
write(0x09, e.getEntityId());
|
||||||
|
entityMoves(e);
|
||||||
|
entitySpeed(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
default void bowSpan(Entity e, boolean start, boolean offHand) {
|
||||||
|
write(0x0a, e.getEntityId(), start, offHand);
|
||||||
|
}
|
||||||
|
|
||||||
|
default void damageAnimation(Player p) {
|
||||||
|
write(0x0b, p.getEntityId());
|
||||||
|
}
|
||||||
|
|
||||||
|
default void setOnFire(Entity e, boolean perma) {
|
||||||
|
write(0x0c, e.getEntityId(), perma);
|
||||||
|
}
|
||||||
|
|
||||||
|
default void blockChange(Block block){
|
||||||
|
int blockState = VersionedCallable.call(new VersionedCallable<>(() -> RecordSystem_8.blockToId(block), 8),
|
||||||
|
new VersionedCallable<>(() -> RecordSystem_14.blockToId(block), 14),
|
||||||
|
new VersionedCallable<>(() -> RecordSystem_15.blockToId(block), 15));
|
||||||
|
|
||||||
|
int shortX = block.getX() - Config.ArenaRegion.getMinX();
|
||||||
|
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);
|
||||||
|
}else{
|
||||||
|
//Block packet
|
||||||
|
write(0x30, block.getX(), block.getY(), block.getZ(), blockState);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
default void particle(double x, double y, double z, String particleType){
|
||||||
|
write(0x31, x, y, z, particleType);
|
||||||
|
}
|
||||||
|
|
||||||
|
default void sound(int x, int y, int z, String soundType, String soundCategory, float volume, float pitch){
|
||||||
|
write(0x32, x, y, z, soundType, soundCategory, volume, pitch);
|
||||||
|
}
|
||||||
|
|
||||||
|
default void soundAtPlayer(String soundType, float volume, float pitch){
|
||||||
|
write(0x34, soundType, volume, pitch);
|
||||||
|
}
|
||||||
|
|
||||||
|
default void chat(String s) {
|
||||||
|
write(0xa0, s);
|
||||||
|
}
|
||||||
|
|
||||||
|
default void actionBar(String s) {
|
||||||
|
write(0xa1, s);
|
||||||
|
}
|
||||||
|
|
||||||
|
default void systemChat(String s) {
|
||||||
|
write(0xa2, s);
|
||||||
|
}
|
||||||
|
|
||||||
|
default void blueSchem(int schemId) {
|
||||||
|
write(0xb0, schemId);
|
||||||
|
}
|
||||||
|
|
||||||
|
default void redSchem(int schemId) {
|
||||||
|
write(0xb1, schemId);
|
||||||
|
}
|
||||||
|
|
||||||
|
default void teamIds(int blueTeamId, int redTeamId) {
|
||||||
|
write(0xb2, blueTeamId, redTeamId);
|
||||||
|
}
|
||||||
|
|
||||||
|
default void scoreboardTitle(String title){
|
||||||
|
write(0xc0, title);
|
||||||
|
}
|
||||||
|
|
||||||
|
default void scoreboardData(String key, int value){
|
||||||
|
write(0xc1, key, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
default void tick(){
|
||||||
|
write(0xff);
|
||||||
|
}
|
||||||
|
|
||||||
|
default void write(int id, Object... objects){
|
||||||
|
DataOutputStream stream = getStream();
|
||||||
|
try {
|
||||||
|
stream.writeByte(id);
|
||||||
|
for(Object o : objects){
|
||||||
|
if(o instanceof Byte)
|
||||||
|
stream.writeByte((Byte)o);
|
||||||
|
else if(o instanceof Short)
|
||||||
|
stream.writeShort((Short)o);
|
||||||
|
else if(o instanceof Integer)
|
||||||
|
stream.writeInt((Integer)o);
|
||||||
|
else if(o instanceof Float)
|
||||||
|
stream.writeFloat((Float)o);
|
||||||
|
else if(o instanceof Double)
|
||||||
|
stream.writeDouble((Double)o);
|
||||||
|
else if(o instanceof String)
|
||||||
|
stream.writeUTF((String)o);
|
||||||
|
else
|
||||||
|
throw new SecurityException("Undefined write for: " + o.getClass().getName());
|
||||||
|
}
|
||||||
|
stream.flush();
|
||||||
|
} catch (IOException e) {
|
||||||
|
Bukkit.getLogger().log(Level.SEVERE, "Could not write", e);
|
||||||
|
try {
|
||||||
|
stream.close();
|
||||||
|
} catch (IOException ioException) {
|
||||||
|
Bukkit.getLogger().log(Level.SEVERE, "Could not close", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,147 +0,0 @@
|
|||||||
/*
|
|
||||||
This file is a part of the SteamWar software.
|
|
||||||
|
|
||||||
Copyright (C) 2020 SteamWar.de-Serverteam
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU Affero General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU Affero General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Affero General Public License
|
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package de.steamwar.fightsystem.record;
|
|
||||||
|
|
||||||
import de.steamwar.fightsystem.Config;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
|
|
||||||
import java.io.*;
|
|
||||||
import java.net.Socket;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
|
|
||||||
public class SpectateConnection extends Recorder{
|
|
||||||
|
|
||||||
private Socket socket;
|
|
||||||
private DataOutputStream outputStream;
|
|
||||||
|
|
||||||
SpectateConnection(){
|
|
||||||
super();
|
|
||||||
try {
|
|
||||||
this.socket = new Socket(Config.spectateIP, Config.spectatePort);
|
|
||||||
socket.setSoTimeout(1); // Wait a maximum of 1ms on a blocking operation (flush)
|
|
||||||
socket.setSoLinger(true, 1); // Wait a maximum of 1ms on close
|
|
||||||
socket.setTcpNoDelay(true); // Don't wait always on ack
|
|
||||||
this.outputStream = new DataOutputStream(new BufferedOutputStream(socket.getOutputStream()));
|
|
||||||
} catch (IOException e) {
|
|
||||||
Bukkit.getLogger().log(Level.WARNING, "Could not init connection to spectate server", e);
|
|
||||||
close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void writeBoolean(boolean b) {
|
|
||||||
try{
|
|
||||||
outputStream.writeBoolean(b);
|
|
||||||
} catch (IOException e) {
|
|
||||||
close();
|
|
||||||
Bukkit.getLogger().log(Level.SEVERE, "Could not send", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void writeByte(int b) {
|
|
||||||
try{
|
|
||||||
outputStream.writeByte(b);
|
|
||||||
} catch (IOException e) {
|
|
||||||
close();
|
|
||||||
Bukkit.getLogger().log(Level.SEVERE, "Could not send", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void writeShort(short s) {
|
|
||||||
try{
|
|
||||||
outputStream.writeShort(s);
|
|
||||||
} catch (IOException e) {
|
|
||||||
close();
|
|
||||||
Bukkit.getLogger().log(Level.SEVERE, "Could not send", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void writeInt(int i) {
|
|
||||||
try{
|
|
||||||
outputStream.writeInt(i);
|
|
||||||
} catch (IOException e) {
|
|
||||||
close();
|
|
||||||
Bukkit.getLogger().log(Level.SEVERE, "Could not send", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void writeLong(long l) {
|
|
||||||
try{
|
|
||||||
outputStream.writeLong(l);
|
|
||||||
} catch (IOException e) {
|
|
||||||
close();
|
|
||||||
Bukkit.getLogger().log(Level.SEVERE, "Could not send", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void writeFloat(float f) {
|
|
||||||
try{
|
|
||||||
outputStream.writeFloat(f);
|
|
||||||
} catch (IOException e) {
|
|
||||||
close();
|
|
||||||
Bukkit.getLogger().log(Level.SEVERE, "Could not send", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void writeDouble(double d) {
|
|
||||||
try{
|
|
||||||
outputStream.writeDouble(d);
|
|
||||||
} catch (IOException e) {
|
|
||||||
close();
|
|
||||||
Bukkit.getLogger().log(Level.SEVERE, "Could not send", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void writeString(String s) {
|
|
||||||
try{
|
|
||||||
outputStream.writeUTF(s);
|
|
||||||
} catch (IOException e) {
|
|
||||||
close();
|
|
||||||
Bukkit.getLogger().log(Level.SEVERE, "Could not send", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void doFlush() {
|
|
||||||
try{
|
|
||||||
outputStream.flush();
|
|
||||||
} catch (IOException e) {
|
|
||||||
close();
|
|
||||||
Bukkit.getLogger().log(Level.SEVERE, "Could not flush", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void closeRecorder() {
|
|
||||||
try {
|
|
||||||
socket.close();
|
|
||||||
outputStream.close();
|
|
||||||
} catch (IOException e) {
|
|
||||||
Bukkit.getLogger().log(Level.WARNING, "IOException on socket close", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -43,6 +43,7 @@ public enum FightState {
|
|||||||
public static final Set<FightState> TeamFix = Collections.unmodifiableSet(EnumSet.of(PRE_RUNNING, RUNNING, SPECTATE));
|
public static final Set<FightState> TeamFix = Collections.unmodifiableSet(EnumSet.of(PRE_RUNNING, RUNNING, SPECTATE));
|
||||||
public static final Set<FightState> Schem = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(PRE_LEADER_SETUP, PRE_SCHEM_SETUP)));
|
public static final Set<FightState> Schem = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(PRE_LEADER_SETUP, PRE_SCHEM_SETUP)));
|
||||||
public static final Set<FightState> AntiRunning = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(RUNNING)));
|
public static final Set<FightState> AntiRunning = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(RUNNING)));
|
||||||
|
public static final Set<FightState> AntiSpectate = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(SPECTATE)));
|
||||||
|
|
||||||
private static final Map<IStateDependent, Boolean> stateDependentFeatures = new HashMap<>();
|
private static final Map<IStateDependent, Boolean> stateDependentFeatures = new HashMap<>();
|
||||||
private static FightState fightState = PRE_LEADER_SETUP;
|
private static FightState fightState = PRE_LEADER_SETUP;
|
||||||
|
@ -18,6 +18,7 @@ commands:
|
|||||||
remove:
|
remove:
|
||||||
leader:
|
leader:
|
||||||
lockschem:
|
lockschem:
|
||||||
|
replay:
|
||||||
state:
|
state:
|
||||||
skip:
|
skip:
|
||||||
win:
|
win:
|
In neuem Issue referenzieren
Einen Benutzer sperren