SteamWar/FightSystem
Archiviert
13
1

Adding skip, techhider improvements...

Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Lixfel 2021-03-23 16:42:45 +01:00
Ursprung 9b65277c66
Commit ce5cbf9969
23 geänderte Dateien mit 442 neuen und 123 gelöschten Zeilen

Datei anzeigen

@ -22,8 +22,13 @@ package de.steamwar.fightsystem.fight;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.bukkit.BukkitWorld;
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.extent.clipboard.io.BuiltInClipboardFormat;
import com.sk89q.worldedit.extent.clipboard.io.ClipboardWriter;
import com.sk89q.worldedit.function.operation.ForwardExtentCopy;
import com.sk89q.worldedit.function.operation.Operations;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.transform.AffineTransform;
@ -39,14 +44,17 @@ import de.steamwar.sql.Schematic;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.DyeColor;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.scoreboard.Team;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Collections;
import java.util.Objects;
import java.util.Set;
class FightTeam_14 {
public class FightTeam_14 {
private FightTeam_14(){}
private static final Set<BaseBlock> WOOL_SET = Collections.singleton(Objects.requireNonNull(BlockTypes.PINK_WOOL).getDefaultState().toBaseBlock());
@ -78,8 +86,8 @@ class FightTeam_14 {
e.flushSession();
}
static EditSession pasteSchematic(Clipboard clipboard, int pX, int pY, int pZ, boolean rotate) throws Schematic.WrongVersionException, IOException, NoClipboardException {
BlockVector3 paste = BlockVector3.at(pX, pY, pZ);
static EditSession pasteSchematic(Clipboard clipboard, Region region, boolean rotate) throws Schematic.WrongVersionException, IOException, NoClipboardException {
BlockVector3 paste = BlockVector3.at(region.centerX(), region.getMinY(), region.centerZ());
World w = new BukkitWorld(Bukkit.getWorlds().get(0));
BlockVector3 dimensions = clipboard.getDimensions();
@ -93,7 +101,7 @@ class FightTeam_14 {
v = paste.subtract(dimensions.getX()/2, 0, dimensions.getZ()/2).subtract(offset);
}
if(Config.AlignWater){
if(Config.WaterDepth != 0){
BlockVector3 it = clipboard.getMinimumPoint();
int depth = 0;
while(!clipboard.getBlock(it).getBlockType().getMaterial().isAir()){
@ -110,4 +118,35 @@ class FightTeam_14 {
e.flushSession();
return e;
}
public static boolean checkPistonMoving(Block block){
return block.getType() == Material.MOVING_PISTON;
}
public static void saveSchem(Schematic schem, Region region) {
World w = new BukkitWorld(Bukkit.getWorlds().get(0));
BlockVector3 min = BlockVector3.at(region.getMinX(), region.getMinY(), region.getMinZ());
CuboidRegion cuboidRegion = new CuboidRegion(w, min, BlockVector3.at(region.getMaxX(), region.getMaxY(), region.getMaxZ()));
BlockArrayClipboard clipboard = new BlockArrayClipboard(cuboidRegion);
EditSession editSession = WorldEdit.getInstance().getEditSessionFactory().getEditSession(w, -1);
ForwardExtentCopy forwardExtentCopy = new ForwardExtentCopy(editSession, cuboidRegion, clipboard, min);
forwardExtentCopy.setCopyingEntities(false);
try{
Operations.complete(forwardExtentCopy);
}catch(WorldEditException e){
throw new IllegalStateException(e);
}
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
try {
ClipboardWriter writer = BuiltInClipboardFormat.SPONGE_SCHEMATIC.getWriter(outputStream);
writer.write(clipboard);
writer.close();
} catch (IOException e) {
throw new IllegalStateException(e);
}
schem.saveFromBytes(outputStream.toByteArray(), true);
}
}

Datei anzeigen

@ -30,10 +30,7 @@ import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.IFightSystem;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.UnpooledByteBufAllocator;
import net.minecraft.server.v1_14_R1.Block;
import net.minecraft.server.v1_14_R1.IBlockData;
import net.minecraft.server.v1_14_R1.IRegistry;
import net.minecraft.server.v1_14_R1.MinecraftKey;
import net.minecraft.server.v1_14_R1.*;
import org.bukkit.entity.Player;
import java.nio.ByteBuffer;
@ -54,6 +51,16 @@ public class TechHider_14 {
hiddenBlockIds.add(Block.getCombinedId(data));
}
}
if(Config.HiddenBlocks.contains("water")){
Fluid water = FluidTypes.WATER.a(false);
for(IBlockData data : Block.REGISTRY_ID){
if(data.p() == water){
hiddenBlockIds.add(Block.getCombinedId(data));
}
}
}
return hiddenBlockIds;
}

Datei anzeigen

@ -20,10 +20,7 @@
package de.steamwar.fightsystem.utils;
import de.steamwar.fightsystem.Config;
import net.minecraft.server.v1_15_R1.Block;
import net.minecraft.server.v1_15_R1.IBlockData;
import net.minecraft.server.v1_15_R1.IRegistry;
import net.minecraft.server.v1_15_R1.MinecraftKey;
import net.minecraft.server.v1_15_R1.*;
import java.util.HashSet;
import java.util.Set;
@ -38,6 +35,16 @@ class TechHider_15 {
hiddenBlockIds.add(Block.getCombinedId(data));
}
}
if(Config.HiddenBlocks.contains("water")){
Fluid water = FluidTypes.WATER.a(false);
for(IBlockData data : Block.REGISTRY_ID){
if(data.getFluid() == water){
hiddenBlockIds.add(Block.getCombinedId(data));
}
}
}
return hiddenBlockIds;
}

Datei anzeigen

@ -19,13 +19,14 @@
package de.steamwar.fightsystem.fight;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.*;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.bukkit.BukkitWorld;
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat;
import com.sk89q.worldedit.extent.clipboard.io.ClipboardWriter;
import com.sk89q.worldedit.function.operation.ForwardExtentCopy;
import com.sk89q.worldedit.function.operation.Operations;
import com.sk89q.worldedit.math.transform.AffineTransform;
import com.sk89q.worldedit.regions.CuboidRegion;
@ -39,13 +40,15 @@ import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.DyeColor;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.scoreboard.Team;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Collections;
import java.util.Set;
class FightTeam_8 {
public class FightTeam_8 {
private FightTeam_8(){}
@SuppressWarnings("deprecation")
@ -87,10 +90,10 @@ class FightTeam_8 {
e.flushQueue();
}
static EditSession pasteSchematic(Clipboard clipboard, int pasteX, int pasteY, int pasteZ, boolean rotate) throws Schematic.WrongVersionException, IOException, NoClipboardException {
static EditSession pasteSchematic(Clipboard clipboard, Region paste, boolean rotate) throws Schematic.WrongVersionException, IOException, NoClipboardException {
World w = new BukkitWorld(Bukkit.getWorlds().get(0));
Vector dimensions = clipboard.getDimensions();
Vector v = new Vector(pasteX, pasteY, pasteZ);
Vector v = new Vector(paste.centerX(), paste.getMinY(), paste.centerZ());
Vector offset = clipboard.getMinimumPoint().subtract(clipboard.getOrigin());
AffineTransform aT = new AffineTransform();
if(rotate){
@ -100,7 +103,7 @@ class FightTeam_8 {
v = v.subtract(dimensions.getX()/2 - dimensions.getX()%2, 0, dimensions.getZ()/2 - dimensions.getZ()%2).subtract(offset);
}
if(Config.AlignWater){
if(Config.WaterDepth != 0){
Vector it = clipboard.getMinimumPoint();
int depth = 0;
while(!clipboard.getBlock(it).isAir()){
@ -117,4 +120,35 @@ class FightTeam_8 {
e.flushQueue();
return e;
}
public static boolean checkPistonMoving(Block block){
return block.getType() == Material.PISTON_MOVING_PIECE;
}
public static void saveSchem(Schematic schem, Region region) {
World w = new BukkitWorld(Bukkit.getWorlds().get(0));
Vector min = new Vector(region.getMinX(), region.getMinY(), region.getMinZ());
CuboidRegion cuboidRegion = new CuboidRegion(w, min, new Vector(region.getMaxX(), region.getMaxY(), region.getMaxZ()));
BlockArrayClipboard clipboard = new BlockArrayClipboard(cuboidRegion);
EditSession editSession = WorldEdit.getInstance().getEditSessionFactory().getEditSession(w, -1);
ForwardExtentCopy forwardExtentCopy = new ForwardExtentCopy(editSession, cuboidRegion, clipboard, min);
forwardExtentCopy.setCopyingEntities(false);
try{
Operations.complete(forwardExtentCopy);
}catch(WorldEditException e){
throw new IllegalStateException(e);
}
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
try {
ClipboardWriter writer = ClipboardFormat.SCHEMATIC.getWriter(outputStream);
writer.write(clipboard, w.getWorldData());
writer.close();
} catch (IOException e) {
throw new IllegalStateException(e);
}
schem.saveFromBytes(outputStream.toByteArray(), false);
}
}

Datei anzeigen

@ -61,12 +61,11 @@ public class Config {
public static final Location TeamRedSpawn;
public static final Location SpecSpawn;
private static final int TeamBluetoReddistanceX;
private static final int TeamBluetoReddistanceY;
public static final int TeamBluetoReddistanceZ;
private static final int BlueToRedX;
private static final int BlueToRedY;
public static final int BlueToRedZ;
public static final int BorderFromSchematic;
public static final boolean AlignWater;
public static final int PreperationArea;
public static final int WaterDepth;
public static final boolean GroundWalkable;
@ -77,6 +76,7 @@ public class Config {
public static final de.steamwar.sql.SchematicType SchematicType;
public static final boolean RedRotate;
public static final boolean BlueRotate;
public static final boolean PasteAligned;
public static final boolean ReplaceObsidianBedrock;
public static final boolean ReplaceWithBlockupdates;
@ -134,14 +134,14 @@ public class Config {
if(!new File(IFightSystem.getPlugin().getDataFolder(), System.getProperty("config", "config.yml")).exists()) {
IFightSystem.getPlugin().saveDefaultConfig();
Bukkit.getLogger().log(Level.SEVERE, "Arenaconfig fehlt!");
IFightSystem.shutdown(null);
Bukkit.shutdown();
}
FileConfiguration config = IFightSystem.getPlugin().getConfig();
File worldConfigFile = new File(Bukkit.getWorlds().get(0).getWorldFolder(), config.getString("Arenaconfig", "config.yml"));
if(!worldConfigFile.exists()) {
Bukkit.getLogger().log(Level.SEVERE, "Weltconfig fehlt!");
IFightSystem.shutdown(null);
Bukkit.shutdown();
}
FileConfiguration worldconfig = YamlConfiguration.loadConfiguration(worldConfigFile);
@ -151,30 +151,30 @@ public class Config {
PreFightDuration = config.getInt("Times.PreFightDuration");
SpectatorDuration = config.getInt("Times.SpectatorDuration");
int underBorder = worldconfig.getInt("UnderBorder");
int blueCornerX = worldconfig.getInt("BlueCorner.x");
int blueCornerY = worldconfig.getInt("BlueCorner.y");
int blueCornerZ = worldconfig.getInt("BlueCorner.z");
BlueToRedX = worldconfig.getInt("BlueToRed.x");
BlueToRedY = worldconfig.getInt("BlueToRed.y");
BlueToRedZ = worldconfig.getInt("BlueToRed.z");
double teamBlueSpawnOffsetX = worldconfig.getDouble("SpawnOffset.x");
double teamBlueSpawnOffsetY = worldconfig.getDouble("SpawnOffset.y");
double teamBlueSpawnOffsetZ = worldconfig.getDouble("SpawnOffset.z");
WaterDepth = config.getInt("Arena.WaterDepth");
int schemsizeX = config.getInt("Arena.Schemsize.x");
int schemsizeY = config.getInt("Arena.Schemsize.y");
int schemsizeZ = config.getInt("Arena.Schemsize.z");
int teamBlueCornerX = worldconfig.getInt("Arena.TeamBlueCorner.x");
int teamBlueCornerY = worldconfig.getInt("Arena.TeamBlueCorner.y");
int teamBlueCornerZ = worldconfig.getInt("Arena.TeamBlueCorner.z");
TeamBluetoReddistanceX = worldconfig.getInt("Arena.TeamBluetoReddistance.x");
TeamBluetoReddistanceY = worldconfig.getInt("Arena.TeamBluetoReddistance.y");
TeamBluetoReddistanceZ = worldconfig.getInt("Arena.TeamBluetoReddistance.z");
int schem2BorderX = config.getInt("Arena.Schem2Border.x");
int schem2BorderZ = config.getInt("Arena.Schem2Border.z");
int underArenaBorder = worldconfig.getInt("Arena.underArenaBorder");
BorderFromSchematic = config.getInt("Arena.BorderFromSchematic");
AlignWater = worldconfig.getBoolean("Arena.AlignWater");
WaterDepth = worldconfig.getInt("Arena.WaterDepth");
PreperationArea = config.getInt("Arena.BorderFromSchematic");
GroundWalkable = config.getBoolean("Arena.GroundWalkable");
double teamBlueSpawnOffsetX = worldconfig.getDouble("Arena.SpawnOffset.x");
double teamBlueSpawnOffsetY = worldconfig.getDouble("Arena.SpawnOffset.y");
double teamBlueSpawnOffsetZ = worldconfig.getDouble("Arena.SpawnOffset.z");
RanksEnabled = config.getBoolean("Schematic.RanksEnabled");
SchematicType = de.steamwar.sql.SchematicType.fromDB(config.getString("Schematic.SchematicType"));
IgnorePublicOnly = config.getBoolean("Schematic.IgnorePublicOnly");
boolean rotate = config.getBoolean("Schematic.Rotate");
PasteAligned = config.getBoolean("Schematic.PasteAligned");
ReplaceObsidianBedrock = config.getBoolean("Schematic.ReplaceObsidianBedrock");
ReplaceWithBlockupdates = config.getBoolean("Schematic.ReplaceWithBlockupdates");
@ -202,32 +202,32 @@ public class Config {
if(schemsizeX < 0){
schemsizeX = -schemsizeX;
teamBlueCornerX = teamBlueCornerX - schemsizeX;
blueCornerX = blueCornerX - schemsizeX;
}
if(schemsizeY < 0){
schemsizeY = -schemsizeY;
teamBlueCornerY = teamBlueCornerY - schemsizeY;
blueCornerY = blueCornerY - schemsizeY;
}
if(schemsizeZ < 0){
schemsizeZ = -schemsizeZ;
teamBlueCornerZ = teamBlueCornerZ - schemsizeZ;
blueCornerZ = blueCornerZ - schemsizeZ;
}
int teamRedCornerX = TeamBluetoReddistanceX + teamBlueCornerX;
int teamRedCornerY = TeamBluetoReddistanceY + teamBlueCornerY;
int teamRedCornerZ = TeamBluetoReddistanceZ + teamBlueCornerZ;
int teamRedCornerX = BlueToRedX + blueCornerX;
int teamRedCornerY = BlueToRedY + blueCornerY;
int teamRedCornerZ = BlueToRedZ + blueCornerZ;
int teamBluePasteX = teamBlueCornerX + schemsizeX / 2;
int teamBluePasteZ = teamBlueCornerZ + schemsizeZ / 2;
int teamRedPasteX = teamBluePasteX + TeamBluetoReddistanceX;
int teamRedPasteZ = teamBluePasteZ + TeamBluetoReddistanceZ;
int teamBluePasteX = blueCornerX + schemsizeX / 2;
int teamBluePasteZ = blueCornerZ + schemsizeZ / 2;
int teamRedPasteX = teamBluePasteX + BlueToRedX;
int teamRedPasteZ = teamBluePasteZ + BlueToRedZ;
World world = Bukkit.getWorlds().get(0);
TeamBlueSpawn = new Location(world,
teamBluePasteX + 0.5 + teamBlueSpawnOffsetX,
teamBlueCornerY + 0.5 + teamBlueSpawnOffsetY,
blueCornerY + 0.5 + teamBlueSpawnOffsetY,
teamBluePasteZ + 0.5 + teamBlueSpawnOffsetZ);
TeamRedSpawn = new Location(world,
@ -236,9 +236,9 @@ public class Config {
teamRedPasteZ + 0.5 - teamBlueSpawnOffsetZ);
SpecSpawn = new Location(world,
teamBluePasteX + TeamBluetoReddistanceX/2.0,
teamBlueCornerY + TeamBluetoReddistanceY/2.0 + schemsizeY/2.0,
teamBluePasteZ + TeamBluetoReddistanceZ/2.0);
teamBluePasteX + BlueToRedX /2.0,
blueCornerY + BlueToRedY /2.0 + schemsizeY/2.0,
teamBluePasteZ + BlueToRedZ /2.0);
Vector v1 = TeamBlueSpawn.toVector().subtract(TeamRedSpawn.toVector());
double pitch = Math.toDegrees(v1.angle(v1.clone().setY(0)));
@ -257,26 +257,26 @@ public class Config {
int arenaMaxX;
int arenaMinZ;
int arenaMaxZ;
if(TeamBluetoReddistanceX > 0){
arenaMinX = teamBlueCornerX - schem2BorderX;
if(BlueToRedX > 0){
arenaMinX = blueCornerX - schem2BorderX;
arenaMaxX = teamRedCornerX + schemsizeX + schem2BorderX;
teamRedRotate = true;
teamBlueRotate = false;
}else{
arenaMinX = teamRedCornerX - schem2BorderX;
arenaMaxX = teamBlueCornerX + schemsizeX + schem2BorderX;
arenaMaxX = blueCornerX + schemsizeX + schem2BorderX;
teamRedRotate = false;
teamBlueRotate = true;
}
if(TeamBluetoReddistanceZ > 0){
arenaMinZ = teamBlueCornerZ - schem2BorderZ;
if(BlueToRedZ > 0){
arenaMinZ = blueCornerZ - schem2BorderZ;
arenaMaxZ = teamRedCornerZ + schemsizeZ + schem2BorderZ;
teamRedRotate = true;
teamBlueRotate = false;
}else{
arenaMinZ = teamRedCornerZ - schem2BorderZ;
arenaMaxZ = teamBlueCornerZ + schemsizeZ + schem2BorderZ;
if(TeamBluetoReddistanceZ != 0){
arenaMaxZ = blueCornerZ + schemsizeZ + schem2BorderZ;
if(BlueToRedZ != 0){
teamRedRotate = false;
teamBlueRotate = true;
}
@ -289,19 +289,19 @@ public class Config {
BlueRotate = teamBlueRotate;
RedPasteRegion = new Region(teamRedCornerX, teamRedCornerY, teamRedCornerZ, schemsizeX, schemsizeY, schemsizeZ);
BluePasteRegion = new Region(teamBlueCornerX, teamBlueCornerY, teamBlueCornerZ, schemsizeX, schemsizeY, schemsizeZ);
BluePasteRegion = new Region(blueCornerX, blueCornerY, blueCornerZ, schemsizeX, schemsizeY, schemsizeZ);
RedExtendRegion = new Region(teamRedCornerX, underArenaBorder, teamRedCornerZ, schemsizeX, schemsizeY, schemsizeZ, BorderFromSchematic, BorderFromSchematic);
BlueExtendRegion = new Region(teamBlueCornerX, underArenaBorder, teamBlueCornerZ, schemsizeX, schemsizeY, schemsizeZ, BorderFromSchematic, BorderFromSchematic);
int upperArenaBorder = teamBlueCornerY + schemsizeY + BorderFromSchematic;
ArenaRegion = new Region(arenaMinX, underArenaBorder, arenaMinZ, arenaMaxX - arenaMinX, upperArenaBorder - underArenaBorder, arenaMaxZ - arenaMinZ);
RedExtendRegion = new Region(teamRedCornerX, underBorder, teamRedCornerZ, schemsizeX, schemsizeY, schemsizeZ, PreperationArea, PreperationArea);
BlueExtendRegion = new Region(blueCornerX, underBorder, blueCornerZ, schemsizeX, schemsizeY, schemsizeZ, PreperationArea, PreperationArea);
int upperArenaBorder = blueCornerY + schemsizeY + PreperationArea;
ArenaRegion = new Region(arenaMinX, underBorder, arenaMinZ, arenaMaxX - arenaMinX, upperArenaBorder - underBorder, arenaMaxZ - arenaMinZ);
EventKampfID = Integer.parseInt(System.getProperty("fightID", "0"));
if(EventKampfID >= 1){
EventFight eventFight = EventFight.get(EventKampfID);
if(eventFight == null){
Bukkit.getLogger().log(Level.SEVERE, "Failed to load EventFight");
IFightSystem.shutdown(null);
Bukkit.shutdown();
}
assert eventFight != null;
@ -310,7 +310,7 @@ public class Config {
if(team1 == null || team2 == null){
Bukkit.getLogger().log(Level.SEVERE, "Failed to load Team");
IFightSystem.shutdown(null);
Bukkit.shutdown();
}
assert team1 != null;
@ -379,7 +379,7 @@ public class Config {
}
public static boolean test(){
return EventKampfID == -1;
return ArenaMode.Test.contains(ArenaMode.TEST);
}
public static boolean recording(){
return mode == ArenaMode.EVENT;

Datei anzeigen

@ -20,7 +20,6 @@
package de.steamwar.fightsystem;
import de.steamwar.sql.EventFight;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
@ -50,21 +49,4 @@ public class IFightSystem {
public static Player getEventLeiter(){
return eventLeiter;
}
public static void shutdown(String reason){
if(reason != null)
Bukkit.broadcastMessage(reason);
//Staggered kick to prevent lobby overloading
kickNext();
}
private static void kickNext(){
if(Bukkit.getOnlinePlayers().isEmpty()){
Bukkit.shutdown();
return;
}
Bukkit.getOnlinePlayers().iterator().next().kickPlayer(null);
Bukkit.getScheduler().runTaskLater(plugin, IFightSystem::kickNext, 10);
}
}

Datei anzeigen

@ -1,6 +1,5 @@
package de.steamwar.fightsystem.utils;
import org.apache.logging.log4j.util.TriConsumer;
import org.bukkit.Location;
import org.bukkit.block.Block;
@ -121,4 +120,8 @@ public class Region {
public boolean inRegion(Block block){
return in2dRegion(block) && minY <= block.getY() && block.getY() < maxY;
}
public interface TriConsumer<T, V, U>{
void accept(T x, V y, U z);
}
}

Datei anzeigen

@ -31,6 +31,7 @@ import de.steamwar.fightsystem.listener.*;
import de.steamwar.fightsystem.record.RecordSystem;
import de.steamwar.fightsystem.record.Recorder;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.OneShotStateDependent;
import de.steamwar.fightsystem.utils.EnterHandler;
import de.steamwar.fightsystem.utils.FightStatistics;
import de.steamwar.fightsystem.utils.TechHider;
@ -121,6 +122,12 @@ public class FightSystem extends JavaPlugin {
new AkCommand();
new LeaderCommand();
new LockschemCommand();
new StateCommand();
new SkipCommand();
new OneShotStateDependent(ArenaMode.All, FightState.PreRunning, () -> Bukkit.broadcastMessage(PREFIX + "§aDer Kampf beginnt!"));
new OneShotStateDependent(ArenaMode.All, FightState.Running, () -> Bukkit.broadcastMessage(PREFIX + "§aArena freigegeben!"));
new OneShotStateDependent(ArenaMode.AntiTest, FightState.Running, FightStatistics::start);
try {
CommandRemover.removeAll("gamemode");
@ -160,15 +167,10 @@ public class FightSystem extends JavaPlugin {
public static void setPreRunningState() {
FightState.setFightState(FightState.PRE_RUNNING);
Bukkit.broadcastMessage(PREFIX + "§aDer Kampf beginnt!");
}
public static void setRunningState() {
FightState.setFightState(FightState.RUNNING);
FightStatistics.start();
Bukkit.broadcastMessage(PREFIX + "§aArena freigegeben!");
}
public static void setSpectateState(FightTeam winFightTeam, String windescription) {
@ -211,6 +213,19 @@ public class FightSystem extends JavaPlugin {
}
public static void shutdown(String reason){
IFightSystem.shutdown(reason);
if(reason != null)
Bukkit.broadcastMessage(reason);
//Staggered kick to prevent lobby overloading
kickNext();
}
private static void kickNext(){
if(Bukkit.getOnlinePlayers().isEmpty()){
Bukkit.shutdown();
return;
}
Bukkit.getOnlinePlayers().iterator().next().kickPlayer(null);
Bukkit.getScheduler().runTaskLater(plugin, FightSystem::kickNext, 10);
}
}

Datei anzeigen

@ -88,6 +88,14 @@ public class Commands {
}
static void toggleReady(Player p){
FightTeam fightTeam = checkGetTeam(p);
if(fightTeam == null || checkGetLeader(p) == null)
return;
fightTeam.skip();
}
static void toggleSkip(Player p){
if(checkSetup(p))
return;

Datei anzeigen

@ -67,6 +67,20 @@ public class GUI {
inv.open();
}
public static void state(Player p){
SWInventory inv = new SWInventory(p, 9, "Kampfstatus");
inv.setItem(0, Material.GLASS, "§7PRE_LEADER_SETUP", (ClickType click) -> FightSystem.setPreLeaderState());
inv.setItem(1, Material.GLASS, "§7PRE_SCHEM_SETUP", (ClickType click) -> FightSystem.setPreSchemState());
inv.setItem(2, Material.GLASS, "§7POST_SCHEM_SETUP", (ClickType click) -> FightSystem.setPostSchemState());
inv.setItem(3, Material.GLASS, "§ePRE_RUNNING", (ClickType click) -> FightSystem.setPreRunningState());
inv.setItem(4, Material.GLASS, "§eRUNNING", (ClickType click) -> FightSystem.setRunningState());
inv.setItem(5, Material.GLASS, "§7SPECTATE Blue", (ClickType click) -> FightSystem.setSpectateState(Fight.getBlueTeam(), "operator"));
inv.setItem(6, Material.GLASS, "§7SPECTATE Red", (ClickType click) -> FightSystem.setSpectateState(Fight.getRedTeam(), "operator"));
inv.setItem(7, Material.GLASS, "§7SPECTATE Tie", (ClickType click) -> FightSystem.setSpectateState(null, "operator"));
inv.setCallback(-999, (ClickType click) -> p.closeInventory());
inv.open();
}
public static void chooseInvitation(Player p){
List<SWListInv.SWListEntry<UUID>> players = SWListInv.createPlayerList(p.getUniqueId());
players.removeIf(swItemUUIDPair -> Fight.getFightPlayer(Bukkit.getPlayer(swItemUUIDPair.getObject())) != null);

Datei anzeigen

@ -0,0 +1,27 @@
package de.steamwar.fightsystem.commands;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentCommand;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class SkipCommand implements CommandExecutor {
public SkipCommand() {
new StateDependentCommand(ArenaMode.AntiPrepare, FightState.Running, "skip", this);
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if(!(sender instanceof Player)) {
return false;
}
Player player = (Player) sender;
Commands.toggleSkip(player);
return false;
}
}

Datei anzeigen

@ -0,0 +1,26 @@
package de.steamwar.fightsystem.commands;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentCommand;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class StateCommand implements CommandExecutor {
public StateCommand() {
new StateDependentCommand(ArenaMode.Test, FightState.All, "state", this);
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if(!(sender instanceof Player)) {
return false;
}
GUI.state((Player) sender);
return false;
}
}

Datei anzeigen

@ -31,8 +31,13 @@ import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitTask;
import java.util.ArrayList;
import java.util.List;
public abstract class Countdown {
private static final List<Countdown> currentCountdowns = new ArrayList<>();
private final int totalTime;
private final Sound sound;
private final boolean level;
@ -71,15 +76,35 @@ public abstract class Countdown {
public void enable() {
time = totalTime;
task = Bukkit.getScheduler().runTaskTimer(FightSystem.getPlugin(), this::count, 20, 20);
currentCountdowns.add(this);
}
public void disable() {
if(task != null){
task.cancel();
currentCountdowns.remove(this);
task = null;
}
}
public static void skip(){
if(currentCountdowns.isEmpty())
return;
int smallestTime = currentCountdowns.get(0).time;
for(Countdown countdown : currentCountdowns){
if(countdown.time < smallestTime)
smallestTime = countdown.time;
}
smallestTime--;
for(Countdown countdown : currentCountdowns){
countdown.time -= smallestTime;
}
Bukkit.broadcastMessage(FightSystem.PREFIX + "§aBeide Teams waren damit einverstanden, zum nächsten Event zu beschleunigen!");
}
private void broadcast(String message){
RecordSystem.actionBar(message);
BaseComponent[] msg = TextComponent.fromLegacyText(message);

Datei anzeigen

@ -115,21 +115,21 @@ public class FightSchematic extends StateDependent {
try {
VersionedRunnable.call(new VersionedRunnable(() -> {
try {
EditSession e = FightTeam_8.pasteSchematic(clipboard, region.centerX(), region.getMinY(), region.centerZ(), rotate);
EditSession e = FightTeam_8.pasteSchematic(clipboard, region, rotate);
FightTeam_8.replaceTeamColor(e, c, region);
} catch (Schematic.WrongVersionException | IOException | NoClipboardException ex) {
throw new SecurityException("Error pasting arena in schematic", ex);
}
}, 8), new VersionedRunnable(() -> {
try {
EditSession e = FightTeam_8.pasteSchematic(clipboard, region.centerX(), region.getMinY(), region.centerZ(), rotate);
EditSession e = FightTeam_8.pasteSchematic(clipboard, region, rotate);
FightTeam_12.replaceTeamColor(e, c, region);
} catch (Schematic.WrongVersionException | IOException | NoClipboardException ex) {
throw new SecurityException("Error pasting arena in schematic", ex);
}
}, 12), new VersionedRunnable(() -> {
try {
EditSession e = FightTeam_14.pasteSchematic(clipboard, region.centerX(), region.getMinY(), region.centerZ(), rotate);
EditSession e = FightTeam_14.pasteSchematic(clipboard, region, rotate);
FightTeam_14.replaceTeamColor(e, c, region);
} catch (Schematic.WrongVersionException | IOException | NoClipboardException ex) {
throw new SecurityException("Error pasting arena in schematic", ex);

Datei anzeigen

@ -24,6 +24,7 @@ import de.steamwar.core.VersionedRunnable;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.countdown.Countdown;
import de.steamwar.fightsystem.listener.BasicListener;
import de.steamwar.fightsystem.listener.PersonalKitCreator;
import de.steamwar.fightsystem.record.RecordSystem;
@ -48,11 +49,11 @@ import java.util.*;
public class FightTeam implements IFightTeam{
private FightPlayer leader;
private UUID designatedLeader;
private FightPlayer leader;
private final Map<Player, FightPlayer> players = new HashMap<>();
private boolean ready;
private final Set<Player> invited = new HashSet<>();
private final String name;
private final String prefix;
private final ChatColor color;
@ -60,6 +61,9 @@ public class FightTeam implements IFightTeam{
private final Team team;
private final boolean blue;
private boolean ready;
private boolean skip;
private final Location spawn;
private final Region schemRegion;
private final Region extendRegion;
@ -71,6 +75,7 @@ public class FightTeam implements IFightTeam{
this.name = name;
this.prefix = prefix;
this.ready = false;
this.skip = false;
this.blue = blue;
this.designatedLeader = designatedLeader;
this.color = ChatColor.getByChar(ChatColor.getLastColors(prefix).replace("§", ""));
@ -315,6 +320,18 @@ public class FightTeam implements IFightTeam{
}
}
public void skip(){
this.skip = !skip;
if(skip){
broadcast(FightSystem.PREFIX + "§aEuer Team ist nun bereit, zum nächsten Event zu beschleunigen!");
if(Fight.getOpposite(this).skip || Config.test()){
Countdown.skip();
}
}else{
broadcast(FightSystem.PREFIX + "§cEuer Team ist nicht mehr bereit, zum nächsten Event zu beschleunigen!");
}
}
public Set<Player> getInvited() {
return invited;
}

Datei anzeigen

@ -37,7 +37,7 @@ import org.bukkit.event.player.PlayerQuitEvent;
public class EventJoin implements Listener {
public EventJoin() {
new StateDependentListener(ArenaMode.Event, FightState.Setup, this);
new StateDependentListener(ArenaMode.Event, FightState.All, this);
}
@EventHandler
@ -58,8 +58,10 @@ public class EventJoin implements Listener {
@EventHandler
public void handlePlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
//player.setResourcePack("https://steamwar.de/antixray.zip");
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
if(FightState.Setup.contains(FightState.getFightState())){
FightTeam team = null;
if(user.getTeam() == Config.EventTeamBlueID)
team = Fight.getBlueTeam();
@ -82,6 +84,7 @@ public class EventJoin implements Listener {
team.addMember(player);
return;
}
}
if(user.getId() == FightSystem.getEventFight().getKampfleiter()){
FightSystem.setEventLeiter(player);
@ -98,4 +101,14 @@ public class EventJoin implements Listener {
if(player == FightSystem.getEventLeiter())
FightSystem.setEventLeiter(null);
}
/*@EventHandler
public void onResourcepack(PlayerResourcePackStatusEvent e){
if(e.getStatus() == PlayerResourcePackStatusEvent.Status.ACCEPTED || e.getStatus() == PlayerResourcePackStatusEvent.Status.SUCCESSFULLY_LOADED)
return;
Player player = e.getPlayer();
player.sendMessage(FightSystem.PREFIX + "§cAuf Eventserver kann nur mit dem SteamWar-Resourcepack beigetreten werden");
player.kickPlayer(null);
}*/
}

Datei anzeigen

@ -19,12 +19,21 @@
package de.steamwar.fightsystem.listener;
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.Fight;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.fight.FightTeam_14;
import de.steamwar.fightsystem.fight.FightTeam_8;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentListener;
import de.steamwar.fightsystem.utils.Region;
import de.steamwar.sql.Schematic;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
@ -37,7 +46,38 @@ public class PrepareSchem implements Listener {
@Override
public void disable() {
super.disable();
//TODO
Region region = Fight.getBlueTeam().getExtendRegion();
World world = Bukkit.getWorlds().get(0);
Schematic schem;
try{
schem = Schematic.getSchemFromDB(Config.PrepareSchemID);
}catch(SecurityException e){
FightSystem.shutdown(FightSystem.PREFIX + "§cAnscheinend wurde die auszufahrende Schematic gelöscht, Einsenden wird abgebrochen.");
return;
}
try{
region.forEach((x, y, z) -> {
if(VersionedCallable.call(
new VersionedCallable<>(() -> FightTeam_8.checkPistonMoving(world.getBlockAt(x, y, z)), 8),
new VersionedCallable<>(() -> FightTeam_14.checkPistonMoving(world.getBlockAt(x, y, z)), 14))){
FightSystem.shutdown(FightSystem.PREFIX + "§cIm Teambereich wurden sich noch bewegende Pistons gefunden, Einsenden wird abgebrochen.");
throw new IllegalStateException();
}
});
}catch (IllegalStateException e){
return;
}
try{
VersionedRunnable.call(
new VersionedRunnable(() -> FightTeam_8.saveSchem(schem, region), 8),
new VersionedRunnable(() -> FightTeam_14.saveSchem(schem, region), 14));
}catch(IllegalStateException e){
FightSystem.shutdown(FightSystem.PREFIX + "§cDie Schematic konnte nicht gespeichert werden, Einsenden wird abgebrochen.");
return;
}
}
};
}

Datei anzeigen

@ -59,7 +59,7 @@ public class TeamArea implements Listener {
}
private void checkInInnerArea(Player player, Location to, FightTeam team){
if(team.getSchemRegion().playerInRegion(to) && Config.BorderFromSchematic >= 5){ // Preventing false positives due to small extension
if(team.getSchemRegion().playerInRegion(to) && Config.PreperationArea >= 5){ // Preventing false positives due to small extension
player.kickPlayer(null);
Bukkit.getLogger().log(Level.SEVERE, player.getName() + " ist in einen Teambereich eingedrungen.");
}

Datei anzeigen

@ -32,7 +32,7 @@ import org.bukkit.event.entity.EntityExplodeEvent;
public class WaterRemover implements Listener {
private static final int MIN_Y = Config.BluePasteRegion.getMinY() + (Config.AlignWater ? Config.WaterDepth : 0);
private static final int MIN_Y = Config.BluePasteRegion.getMinY() + Config.WaterDepth;
public WaterRemover() {
new StateDependentListener(ArenaMode.All, FightState.Running, this);

Datei anzeigen

@ -0,0 +1,25 @@
package de.steamwar.fightsystem.states;
import de.steamwar.fightsystem.ArenaMode;
import java.util.Set;
public class OneShotStateDependent extends StateDependent{
private final Runnable runnable;
public OneShotStateDependent(Set<ArenaMode> mode, Set<FightState> states, Runnable runnable) {
super(mode, states);
this.runnable = runnable;
}
@Override
public void enable() {
runnable.run();
}
@Override
public void disable() {
//Do nothing, oneshot
}
}

Datei anzeigen

@ -126,6 +126,9 @@ public class TechHider implements IStateDependent {
if(Core.getVersion() > 8) {
protocolManager.addPacketListener(updateBlockEntity);
}
if(Core.getVersion() > 12) {
protocolManager.addPacketListener(blockBreakHider);
}
if(chunkHider != null) {
protocolManager.getAsynchronousManager().registerAsyncHandler(chunkHider).start(threadMultiplier * 4);
}
@ -139,6 +142,9 @@ public class TechHider implements IStateDependent {
if(Core.getVersion() > 8) {
protocolManager.removePacketListener(updateBlockEntity);
}
if(Core.getVersion() > 12) {
protocolManager.removePacketListener(blockBreakHider);
}
if(chunkHider != null) {
protocolManager.getAsynchronousManager().unregisterAsyncHandler(chunkHider);
}
@ -223,6 +229,35 @@ public class TechHider implements IStateDependent {
}
};
private final PacketAdapter blockBreakHider = new PacketAdapter(IFightSystem.getPlugin(), PacketType.Play.Server.BLOCK_BREAK) {
@Override
public void onPacketSending(PacketEvent e) {
PacketContainer packet = e.getPacket();
BlockPosition pos = packet.getBlockPositionModifier().read(0);
Player p = e.getPlayer();
if(bypass(p, ITechHider.posToChunk(pos.getX()), ITechHider.posToChunk(pos.getZ())))
return;
PacketContainer cached = packetCache.get(packet);
if(cached != null){
e.setPacket(cached);
return;
}
cached = packet.deepClone();
packetCache.put(packet, cached);
e.setPacket(cached);
StructureModifier<WrappedBlockData> blockStructure = cached.getBlockData();
WrappedBlockData block = blockStructure.read(0);
if(Config.HiddenBlocks.contains(block.getType().name())){
block.setType(obfuscateMaterial);
blockStructure.write(0, block);
}
}
};
private final PacketAdapter updateBlockEntity = new PacketAdapter(FightSystem.getPlugin(), PacketType.Play.Server.TILE_ENTITY_DATA) {
@Override
public void onPacketSending(PacketEvent event) {

Datei anzeigen

@ -51,7 +51,7 @@ public class WinconditionTimeTechKO extends Wincondition {
public WinconditionTimeTechKO(){
super("TechKO", "", " §chat den Gegner Tech K.O. gesetzt!");
if(Config.TeamBluetoReddistanceZ > 0) {
if(Config.BlueToRedZ > 0) {
smallerZteam = Fight.getBlueTeam();
biggerZteam = Fight.getRedTeam();
}else{

Datei anzeigen

@ -18,3 +18,5 @@ commands:
remove:
leader:
lockschem:
state:
skip: