Refactoring + Arena reset
Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Ursprung
7b085d8ee6
Commit
9098a26aa9
@ -22,7 +22,9 @@ public enum ArenaMode {
|
|||||||
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> 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> VariableTeams = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(RANKED, 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)));
|
||||||
public static final Set<ArenaMode> RankedEvent = Collections.unmodifiableSet(EnumSet.of(RANKED, EVENT));
|
public static final Set<ArenaMode> RankedEvent = Collections.unmodifiableSet(EnumSet.of(RANKED, EVENT));
|
||||||
|
public static final Set<ArenaMode> Restartable = Collections.unmodifiableSet(EnumSet.of(NORMAL, RANKED));
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
package de.steamwar.fightsystem;
|
package de.steamwar.fightsystem;
|
||||||
|
|
||||||
|
import de.steamwar.fightsystem.utils.Region;
|
||||||
import de.steamwar.fightsystem.winconditions.Winconditions;
|
import de.steamwar.fightsystem.winconditions.Winconditions;
|
||||||
import de.steamwar.sql.Event;
|
import de.steamwar.sql.Event;
|
||||||
import de.steamwar.sql.EventFight;
|
import de.steamwar.sql.EventFight;
|
||||||
@ -50,6 +51,12 @@ public class Config {
|
|||||||
public static final List<Integer> EnterStages;
|
public static final List<Integer> EnterStages;
|
||||||
|
|
||||||
//arena parameter
|
//arena parameter
|
||||||
|
public static final Region BluePasteRegion;
|
||||||
|
public static final Region RedPasteRegion;
|
||||||
|
public static final Region BlueExtendRegion;
|
||||||
|
public static final Region RedExetendRegion;
|
||||||
|
public static final Region ArenaRegion;
|
||||||
|
|
||||||
public static final int SchemsizeX;
|
public static final int SchemsizeX;
|
||||||
public static final int SchemsizeY;
|
public static final int SchemsizeY;
|
||||||
public static final int SchemsizeZ;
|
public static final int SchemsizeZ;
|
||||||
@ -309,6 +316,12 @@ public class Config {
|
|||||||
TeamRedRotate = teamRedRotate;
|
TeamRedRotate = teamRedRotate;
|
||||||
TeamBlueRotate = teamBlueRotate;
|
TeamBlueRotate = teamBlueRotate;
|
||||||
|
|
||||||
|
RedPasteRegion = new Region(TeamRedCornerX, TeamRedCornerY, TeamRedCornerZ, SchemsizeX, SchemsizeY, SchemsizeZ);
|
||||||
|
BluePasteRegion = new Region(TeamBlueCornerX, TeamBlueCornerY, TeamBlueCornerZ, SchemsizeX, SchemsizeY, SchemsizeZ);
|
||||||
|
RedExetendRegion = new Region(TeamRedCornerX, underArenaBorder, TeamRedCornerZ, SchemsizeX, upperArenaBorder, SchemsizeZ, BorderFromSchematic, BorderFromSchematic);
|
||||||
|
BlueExtendRegion = new Region(TeamBlueCornerX, underArenaBorder, TeamBlueCornerZ, SchemsizeX, upperArenaBorder, SchemsizeZ, BorderFromSchematic, BorderFromSchematic);
|
||||||
|
ArenaRegion = new Region(ArenaMinX, underArenaBorder, ArenaMinZ, ArenaMaxX - ArenaMinX, upperArenaBorder - underArenaBorder, ArenaMaxZ - ArenaMinZ);
|
||||||
|
|
||||||
EventKampfID = Integer.parseInt(System.getProperty("fightID", "0"));
|
EventKampfID = Integer.parseInt(System.getProperty("fightID", "0"));
|
||||||
if(EventKampfID >= 1){
|
if(EventKampfID >= 1){
|
||||||
EventFight eventFight = EventFight.get(EventKampfID);
|
EventFight eventFight = EventFight.get(EventKampfID);
|
||||||
|
@ -41,35 +41,8 @@ public class ITechHider {
|
|||||||
static final Map<PacketContainer, PacketContainer> packetCache = new HashMap<>();
|
static final Map<PacketContainer, PacketContainer> packetCache = new HashMap<>();
|
||||||
static final Material obfuscateMaterial;
|
static final Material obfuscateMaterial;
|
||||||
static final int threadMultiplier;
|
static final int threadMultiplier;
|
||||||
static final int arenaMinX;
|
|
||||||
static final int arenaMaxX;
|
|
||||||
static final int arenaMinZ;
|
|
||||||
static final int arenaMaxZ;
|
|
||||||
|
|
||||||
private static final int blueMinX;
|
|
||||||
private static final int blueMaxX;
|
|
||||||
private static final int blueMinZ;
|
|
||||||
private static final int blueMaxZ;
|
|
||||||
private static final int redMinX;
|
|
||||||
private static final int redMaxX;
|
|
||||||
private static final int redMinZ;
|
|
||||||
private static final int redMaxZ;
|
|
||||||
|
|
||||||
static{
|
static{
|
||||||
int areaExtension = Config.EnterStages.isEmpty() ? Config.BorderFromSchematic : 0;
|
|
||||||
blueMinX = ITechHider.posToChunk(Config.TeamBlueCornerX - areaExtension);
|
|
||||||
blueMaxX = ITechHider.posToChunk(Config.TeamBlueCornerX + Config.SchemsizeX + areaExtension) + 1;
|
|
||||||
blueMinZ = ITechHider.posToChunk(Config.TeamBlueCornerZ - areaExtension);
|
|
||||||
blueMaxZ = ITechHider.posToChunk(Config.TeamBlueCornerZ + Config.SchemsizeZ + areaExtension) + 1;
|
|
||||||
redMinX = ITechHider.posToChunk(Config.TeamRedCornerX - areaExtension);
|
|
||||||
redMaxX = ITechHider.posToChunk(Config.TeamRedCornerX + Config.SchemsizeX + areaExtension) + 1;
|
|
||||||
redMinZ = ITechHider.posToChunk(Config.TeamRedCornerZ - areaExtension);
|
|
||||||
redMaxZ = ITechHider.posToChunk(Config.TeamRedCornerZ + Config.SchemsizeZ + areaExtension) + 1;
|
|
||||||
arenaMinX = ITechHider.posToChunk(Config.ArenaMinX);
|
|
||||||
arenaMaxX = ITechHider.posToChunk(Config.ArenaMaxX) + 1;
|
|
||||||
arenaMinZ = ITechHider.posToChunk(Config.ArenaMinZ);
|
|
||||||
arenaMaxZ = ITechHider.posToChunk(Config.ArenaMaxZ) + 1;
|
|
||||||
|
|
||||||
obfuscateMaterial = Material.getMaterial(Config.ObfuscateWith);
|
obfuscateMaterial = Material.getMaterial(Config.ObfuscateWith);
|
||||||
Bukkit.getScheduler().runTaskTimer(IFightSystem.getPlugin(), packetCache::clear, 1, 1);
|
Bukkit.getScheduler().runTaskTimer(IFightSystem.getPlugin(), packetCache::clear, 1, 1);
|
||||||
|
|
||||||
@ -85,27 +58,15 @@ public class ITechHider {
|
|||||||
|
|
||||||
IFightTeam ft = IFight.getPlayerTeam(p);
|
IFightTeam ft = IFight.getPlayerTeam(p);
|
||||||
if(ft == null){
|
if(ft == null){
|
||||||
//Außerhalb der Arena
|
return Config.ArenaRegion.chunkOutside(chunkX, chunkZ);
|
||||||
return arenaMinX > chunkX ||
|
|
||||||
chunkX > arenaMaxX ||
|
|
||||||
arenaMinZ > chunkZ ||
|
|
||||||
chunkZ > arenaMaxZ;
|
|
||||||
}else if(ft.isBlue()){
|
}else if(ft.isBlue()){
|
||||||
return ft.canPlayerEntern(p) ||
|
return ft.canPlayerEntern(p) || Config.BlueExtendRegion.chunkOutside(chunkX, chunkZ);
|
||||||
redMinX > chunkX ||
|
|
||||||
chunkX > redMaxX ||
|
|
||||||
redMinZ > chunkZ ||
|
|
||||||
chunkZ > redMaxZ;
|
|
||||||
}else{
|
}else{
|
||||||
return ft.canPlayerEntern(p) ||
|
return ft.canPlayerEntern(p) || Config.RedExetendRegion.chunkOutside(chunkX, chunkZ);
|
||||||
blueMinX > chunkX ||
|
|
||||||
chunkX > blueMaxX ||
|
|
||||||
blueMinZ > chunkZ ||
|
|
||||||
chunkZ > blueMaxZ;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int posToChunk(int c){
|
public static int posToChunk(int c){
|
||||||
int chunk = c / 16;
|
int chunk = c / 16;
|
||||||
if(c<0)
|
if(c<0)
|
||||||
chunk--;
|
chunk--;
|
||||||
|
101
FightSystem_API/src/de/steamwar/fightsystem/utils/Region.java
Normale Datei
101
FightSystem_API/src/de/steamwar/fightsystem/utils/Region.java
Normale Datei
@ -0,0 +1,101 @@
|
|||||||
|
package de.steamwar.fightsystem.utils;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
|
||||||
|
import java.util.function.ObjIntConsumer;
|
||||||
|
|
||||||
|
public class Region {
|
||||||
|
|
||||||
|
private final int minX;
|
||||||
|
private final int minY;
|
||||||
|
private final int minZ;
|
||||||
|
private final int maxX;
|
||||||
|
private final int maxY;
|
||||||
|
private final int maxZ;
|
||||||
|
|
||||||
|
public Region(int minX, int minY, int minZ, int sizeX, int maxY, int sizeZ, int extendX, int extendZ) {
|
||||||
|
this(minX - extendX, minY, minZ - extendZ,
|
||||||
|
minX + sizeX + extendX, maxY, minZ + sizeZ + extendZ);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Region(int minX, int minY, int minZ, int sizeX, int sizeY, int sizeZ) {
|
||||||
|
this.minX = minX;
|
||||||
|
this.minY = minY;
|
||||||
|
this.minZ = minZ;
|
||||||
|
this.maxX = minX + sizeX;
|
||||||
|
this.maxY = minY + sizeY;
|
||||||
|
this.maxZ = minZ + sizeZ;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMinX() {
|
||||||
|
return minX;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMinY() {
|
||||||
|
return minY;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMinZ() {
|
||||||
|
return minZ;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMaxX() {
|
||||||
|
return maxX;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMaxY() {
|
||||||
|
return maxY;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMaxZ() {
|
||||||
|
return maxZ;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMinChunkX(){
|
||||||
|
return ITechHider.posToChunk(minX);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMaxChunkX(){
|
||||||
|
return ITechHider.posToChunk(maxX);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMinChunkZ(){
|
||||||
|
return ITechHider.posToChunk(minZ);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMaxChunkZ(){
|
||||||
|
return ITechHider.posToChunk(maxZ);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean chunkOutside(int cX, int cZ) {
|
||||||
|
return getMinChunkX() > cX || cX > getMaxChunkX() ||
|
||||||
|
getMinChunkZ() > cZ || cZ > getMaxChunkZ();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void forEachChunk(ObjIntConsumer<Integer> executor) {
|
||||||
|
for(int x = getMinChunkX(); x <= getMaxChunkX(); x++)
|
||||||
|
for(int z = getMinChunkZ(); z <= getMaxChunkZ(); z++)
|
||||||
|
executor.accept(x, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean in2dRegion(Location location){
|
||||||
|
return minX <= location.getX() && location.getX() < maxX && minZ <= location.getZ() && location.getZ() <= maxZ;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean inRegion(Location location){
|
||||||
|
return in2dRegion(location) && minY < location.getY() && location.getY() < maxY;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean playerInRegion(Location location){
|
||||||
|
return in2dRegion(location) && minY < location.getY() && location.getY() + 1.8 < maxY;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean in2dRegion(Block block){
|
||||||
|
return minX <= block.getX() && block.getX() < maxX && minZ <= block.getZ() && block.getZ() <= maxZ;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean inRegion(Block block){
|
||||||
|
return in2dRegion(block) && minY <= block.getY() && block.getY() < maxY;
|
||||||
|
}
|
||||||
|
}
|
@ -26,6 +26,7 @@ import de.steamwar.fightsystem.countdown.*;
|
|||||||
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.fight.FightWorld;
|
||||||
import de.steamwar.fightsystem.listener.*;
|
import de.steamwar.fightsystem.listener.*;
|
||||||
import de.steamwar.fightsystem.record.RecordSystem;
|
import de.steamwar.fightsystem.record.RecordSystem;
|
||||||
import de.steamwar.fightsystem.record.Recorder;
|
import de.steamwar.fightsystem.record.Recorder;
|
||||||
@ -65,15 +66,18 @@ public class FightSystem extends JavaPlugin {
|
|||||||
new PistonListener();
|
new PistonListener();
|
||||||
new Chat();
|
new Chat();
|
||||||
new HotbarGUI();
|
new HotbarGUI();
|
||||||
new Move();
|
new ArenaBorder();
|
||||||
new ConnectionListener();
|
new TeamArea();
|
||||||
|
new IngameDeath();
|
||||||
new InFightDamage();
|
new InFightDamage();
|
||||||
new InFightInventory();
|
new InFightInventory();
|
||||||
new DenyWorldInteraction();
|
new DenyWorldInteraction();
|
||||||
new EventJoin();
|
new EventJoin();
|
||||||
new Recording();
|
new Recording();
|
||||||
new Check();
|
new Check();
|
||||||
new PrepareJoin();
|
new Shutdown();
|
||||||
|
new SetupQuit();
|
||||||
|
new PrepareSchem();
|
||||||
new TestJoin();
|
new TestJoin();
|
||||||
new NormalJoin();
|
new NormalJoin();
|
||||||
new RankedJoin();
|
new RankedJoin();
|
||||||
@ -85,6 +89,7 @@ public class FightSystem extends JavaPlugin {
|
|||||||
|
|
||||||
new EnterHandler();
|
new EnterHandler();
|
||||||
new TechHider();
|
new TechHider();
|
||||||
|
new FightWorld();
|
||||||
|
|
||||||
new WinconditionAllDead();
|
new WinconditionAllDead();
|
||||||
new WinconditionCaptainDead();
|
new WinconditionCaptainDead();
|
||||||
@ -101,10 +106,11 @@ public class FightSystem extends JavaPlugin {
|
|||||||
new WinconditionPercentTimeout();
|
new WinconditionPercentTimeout();
|
||||||
|
|
||||||
new NoPlayersOnlineCountdown();
|
new NoPlayersOnlineCountdown();
|
||||||
new PreSchemPasteCountdown();
|
new PreSchemCountdown();
|
||||||
new SetupOverCountdown();
|
new PostSchemCountdown();
|
||||||
new PreRunningCountdown();
|
new PreRunningCountdown();
|
||||||
new SpectateOverCountdown();
|
new SpectateOverCountdown();
|
||||||
|
new EventSpectateCountdown();
|
||||||
|
|
||||||
new LeaveCommand();
|
new LeaveCommand();
|
||||||
new KitCommand();
|
new KitCommand();
|
||||||
@ -122,16 +128,14 @@ public class FightSystem extends JavaPlugin {
|
|||||||
CommandInjector.injectCommand(new GamemodeCommand());
|
CommandInjector.injectCommand(new GamemodeCommand());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
getLogger().log(Level.SEVERE, "Failed to replace commands", e);
|
getLogger().log(Level.SEVERE, "Failed to replace commands", e);
|
||||||
Bukkit.shutdown();
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Config.mode == ArenaMode.EVENT) {
|
if(Config.mode == ArenaMode.EVENT) {
|
||||||
setPreSchemState();
|
setPreSchemState();
|
||||||
}else if(Config.mode == ArenaMode.CHECK){
|
}else if(Config.mode == ArenaMode.CHECK){
|
||||||
Fight.getBlueTeam().setNotPastingSchem(Schematic.getSchemFromDB(Config.CheckSchemID));
|
Fight.getBlueTeam().setSchem(Schematic.getSchemFromDB(Config.CheckSchemID));
|
||||||
}else if(Config.mode == ArenaMode.PREPARE) {
|
}else if(Config.mode == ArenaMode.PREPARE) {
|
||||||
Fight.getBlueTeam().setNotPastingSchem(Schematic.getSchemFromDB(Config.PrepareSchemID));
|
Fight.getBlueTeam().setSchem(Schematic.getSchemFromDB(Config.PrepareSchemID));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -140,15 +144,18 @@ public class FightSystem extends JavaPlugin {
|
|||||||
Recorder.closeAll();
|
Recorder.closeAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public static void setPreLeaderState() {
|
||||||
|
FightState.setFightState(FightState.PRE_LEADER_SETUP);
|
||||||
|
}
|
||||||
|
|
||||||
public static void setPreSchemState() {
|
public static void setPreSchemState() {
|
||||||
FightState.setFightState(FightState.PRE_SCHEM_SETUP);
|
FightState.setFightState(FightState.PRE_SCHEM_SETUP);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setPostSchemState() {
|
public static void setPostSchemState() {
|
||||||
FightState.setFightState(FightState.POST_SCHEM_SETUP);
|
FightState.setFightState(FightState.POST_SCHEM_SETUP);
|
||||||
|
|
||||||
Fight.getBlueTeam().pasteSchematic();
|
|
||||||
Fight.getRedTeam().pasteSchematic();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setPreRunningState() {
|
public static void setPreRunningState() {
|
||||||
@ -177,8 +184,6 @@ public class FightSystem extends JavaPlugin {
|
|||||||
Fight.getRedTeam().teleportToSpawn();
|
Fight.getRedTeam().teleportToSpawn();
|
||||||
Bukkit.getOnlinePlayers().forEach(player -> player.getInventory().clear());
|
Bukkit.getOnlinePlayers().forEach(player -> player.getInventory().clear());
|
||||||
|
|
||||||
Bukkit.broadcastMessage(" ");
|
|
||||||
|
|
||||||
if(winFightTeam != null) {
|
if(winFightTeam != null) {
|
||||||
Bukkit.broadcastMessage(PREFIX + "§aDas Team " + winFightTeam.getColoredName() + " §ahat gewonnen!");
|
Bukkit.broadcastMessage(PREFIX + "§aDas Team " + winFightTeam.getColoredName() + " §ahat gewonnen!");
|
||||||
} else {
|
} else {
|
||||||
|
@ -106,9 +106,8 @@ public class Commands {
|
|||||||
if(team == null)
|
if(team == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
FightPlayer leader = team.getLeader();
|
|
||||||
p.sendMessage(FightSystem.PREFIX + "§aDu bist Team " + team.getColoredName() + " §abeigetreten!");
|
p.sendMessage(FightSystem.PREFIX + "§aDu bist Team " + team.getColoredName() + " §abeigetreten!");
|
||||||
leader.sendMessage(FightSystem.PREFIX + "§aDer Spieler §e" + p.getName() + " §aist deinem Team beigetreten!");
|
team.broadcast(FightSystem.PREFIX + "§aDer Spieler §e" + p.getName() + " §aist dem Team beigetreten!");
|
||||||
team.addMember(p);
|
team.addMember(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,9 +119,8 @@ public class Commands {
|
|||||||
if(team == null)
|
if(team == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
FightPlayer leader = team.getLeader();
|
|
||||||
p.sendMessage(FightSystem.PREFIX + "§aDu hast die Einladung von " + team.getColoredName() + " §aabgelehnt!");
|
p.sendMessage(FightSystem.PREFIX + "§aDu hast die Einladung von " + team.getColoredName() + " §aabgelehnt!");
|
||||||
leader.sendMessage(FightSystem.PREFIX + "§cDer Spieler §e" + p.getName() + " §chat deine Einladung abgelehnt!");
|
team.broadcast(FightSystem.PREFIX + "§cDer Spieler §e" + p.getName() + " §chat die Einladung abgelehnt!");
|
||||||
team.getInvited().remove(p);
|
team.getInvited().remove(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -184,7 +184,7 @@ public class GUI {
|
|||||||
if(fightTeam == null)
|
if(fightTeam == null)
|
||||||
return;
|
return;
|
||||||
if(Config.test() || FightState.getFightState() != FightState.POST_SCHEM_SETUP)
|
if(Config.test() || FightState.getFightState() != FightState.POST_SCHEM_SETUP)
|
||||||
fightTeam.setSchematic(s);
|
fightTeam.pasteSchem(s);
|
||||||
p.closeInventory();
|
p.closeInventory();
|
||||||
});
|
});
|
||||||
inv.setCallback(-999, (ClickType click) -> p.closeInventory());
|
inv.setCallback(-999, (ClickType click) -> p.closeInventory());
|
||||||
|
@ -43,9 +43,9 @@ public class LeaderCommand implements CommandExecutor {
|
|||||||
|
|
||||||
if(args.length == 0){
|
if(args.length == 0){
|
||||||
if(Fight.getFightPlayer(player) == null){
|
if(Fight.getFightPlayer(player) == null){
|
||||||
if(!Fight.getBlueTeam().hasTeamLeader())
|
if(Fight.getBlueTeam().isLeaderless())
|
||||||
Fight.getBlueTeam().setLeader(Fight.getBlueTeam().addMember(player));
|
Fight.getBlueTeam().setLeader(Fight.getBlueTeam().addMember(player));
|
||||||
else if(!Fight.getRedTeam().hasTeamLeader())
|
else if(Fight.getRedTeam().isLeaderless())
|
||||||
Fight.getRedTeam().setLeader(Fight.getRedTeam().addMember(player));
|
Fight.getRedTeam().setLeader(Fight.getRedTeam().addMember(player));
|
||||||
else
|
else
|
||||||
player.sendMessage(FightSystem.PREFIX + "§cEs sind bereits 2 Teamleader vorhanden");
|
player.sendMessage(FightSystem.PREFIX + "§cEs sind bereits 2 Teamleader vorhanden");
|
||||||
|
@ -22,7 +22,6 @@ package de.steamwar.fightsystem.commands;
|
|||||||
import de.steamwar.fightsystem.ArenaMode;
|
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.FightTeam;
|
import de.steamwar.fightsystem.fight.FightTeam;
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.states.StateDependentCommand;
|
import de.steamwar.fightsystem.states.StateDependentCommand;
|
||||||
@ -71,10 +70,7 @@ public class LockschemCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
Schematic.getSchemFromDB(fightTeam.getSchematic()).setSchemType(SchematicType.Normal);
|
Schematic.getSchemFromDB(fightTeam.getSchematic()).setSchemType(SchematicType.Normal);
|
||||||
player.sendMessage(FightSystem.PREFIX + "Schematic von " + fightTeam.getColoredName() + " §cgesperrt!");
|
player.sendMessage(FightSystem.PREFIX + "Schematic von " + fightTeam.getColoredName() + " §cgesperrt!");
|
||||||
FightPlayer leader = fightTeam.getLeader();
|
fightTeam.broadcast(FightSystem.PREFIX + "§cDie Schematic wurde von " + player.getName() + " gesperrt!");
|
||||||
if(leader != null){
|
|
||||||
leader.sendMessage(FightSystem.PREFIX + "§cDeine Schematic wurde von " + player.getName() + " gesperrt!");
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
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.countdown;
|
||||||
|
|
||||||
|
import de.steamwar.fightsystem.ArenaMode;
|
||||||
|
import de.steamwar.fightsystem.Config;
|
||||||
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
|
import de.steamwar.fightsystem.states.StateDependentCountdown;
|
||||||
|
|
||||||
|
public class EventSpectateCountdown extends Countdown {
|
||||||
|
|
||||||
|
public EventSpectateCountdown() {
|
||||||
|
super(Config.SpectatorDuration, SWSound.BLOCK_NOTE_PLING, false);
|
||||||
|
new StateDependentCountdown(ArenaMode.Event, FightState.Spectate, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String countdownCounting() {
|
||||||
|
return "bis der Server gestoppt wird!";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void countdownFinished() {
|
||||||
|
FightSystem.shutdown(null);
|
||||||
|
}
|
||||||
|
}
|
@ -25,9 +25,9 @@ import de.steamwar.fightsystem.FightSystem;
|
|||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.states.StateDependentCountdown;
|
import de.steamwar.fightsystem.states.StateDependentCountdown;
|
||||||
|
|
||||||
public class SetupOverCountdown extends Countdown {
|
public class PostSchemCountdown extends Countdown {
|
||||||
|
|
||||||
public SetupOverCountdown() {
|
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);
|
||||||
}
|
}
|
@ -25,9 +25,9 @@ import de.steamwar.fightsystem.FightSystem;
|
|||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.states.StateDependentCountdown;
|
import de.steamwar.fightsystem.states.StateDependentCountdown;
|
||||||
|
|
||||||
public class PreSchemPasteCountdown extends Countdown {
|
public class PreSchemCountdown extends Countdown {
|
||||||
|
|
||||||
public PreSchemPasteCountdown() {
|
public PreSchemCountdown() {
|
||||||
super(Config.PreSchemPasteDuration, SWSound.BLOCK_NOTE_PLING, false);
|
super(Config.PreSchemPasteDuration, SWSound.BLOCK_NOTE_PLING, false);
|
||||||
new StateDependentCountdown(ArenaMode.All, FightState.PreSchemSetup, this);
|
new StateDependentCountdown(ArenaMode.All, FightState.PreSchemSetup, this);
|
||||||
}
|
}
|
@ -29,16 +29,16 @@ public class SpectateOverCountdown extends Countdown {
|
|||||||
|
|
||||||
public SpectateOverCountdown() {
|
public SpectateOverCountdown() {
|
||||||
super(Config.SpectatorDuration, SWSound.BLOCK_NOTE_PLING, false);
|
super(Config.SpectatorDuration, SWSound.BLOCK_NOTE_PLING, false);
|
||||||
new StateDependentCountdown(ArenaMode.AntiTest, FightState.Spectate, this);
|
new StateDependentCountdown(ArenaMode.Restartable, FightState.Spectate, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String countdownCounting() {
|
public String countdownCounting() {
|
||||||
return "bis der Server gestoppt wird!";
|
return "bis die Arena zurückgesetzt wird!";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void countdownFinished() {
|
public void countdownFinished() {
|
||||||
FightSystem.shutdown(null);
|
FightSystem.setPreLeaderState();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,8 +42,8 @@ import java.util.logging.Level;
|
|||||||
public class Fight {
|
public class Fight {
|
||||||
private Fight(){}
|
private Fight(){}
|
||||||
|
|
||||||
private static final FightTeam redTeam = new FightTeam(Config.TeamRedName, Config.TeamRedColor, Config.TeamRedSpawn, Config.TeamRedCornerX, Config.TeamRedCornerY, Config.TeamRedCornerZ, Config.TeamRedRotate, false, Config.RedLeader);
|
private static final FightTeam redTeam = new FightTeam(Config.TeamRedName, Config.TeamRedColor, Config.TeamRedSpawn, Config.RedPasteRegion, Config.RedExetendRegion, Config.TeamRedRotate, false, Config.RedLeader);
|
||||||
private static final FightTeam blueTeam = new FightTeam(Config.TeamBlueName, Config.TeamBlueColor, Config.TeamBlueSpawn, Config.TeamBlueCornerX, Config.TeamBlueCornerY, Config.TeamBlueCornerZ, Config.TeamBlueRotate, true, Config.BlueLeader);
|
private static final FightTeam blueTeam = new FightTeam(Config.TeamBlueName, Config.TeamBlueColor, Config.TeamBlueSpawn, Config.BluePasteRegion, Config.BlueExtendRegion, Config.TeamBlueRotate, true, Config.BlueLeader);
|
||||||
|
|
||||||
public static void init(){
|
public static void init(){
|
||||||
IFight.init(redTeam, blueTeam);
|
IFight.init(redTeam, blueTeam);
|
||||||
@ -159,8 +159,8 @@ public class Fight {
|
|||||||
return 1000;
|
return 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(redTeam.getLeader() == null || redTeam.getLeader().getPlayer() == null ||
|
|
||||||
blueTeam.getLeader() == null || blueTeam.getLeader().getPlayer() == null){
|
if(redTeam.getLeader() == null || blueTeam.getLeader() == null){
|
||||||
return 1000;
|
return 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,12 +22,13 @@ package de.steamwar.fightsystem.fight;
|
|||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||||
import de.steamwar.core.VersionedRunnable;
|
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.IFightSystem;
|
import de.steamwar.fightsystem.IFightSystem;
|
||||||
import de.steamwar.fightsystem.record.RecordSystem;
|
import de.steamwar.fightsystem.record.RecordSystem;
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.states.IStateDependent;
|
import de.steamwar.fightsystem.states.StateDependent;
|
||||||
import de.steamwar.fightsystem.utils.ColorConverter;
|
import de.steamwar.fightsystem.utils.ColorConverter;
|
||||||
import de.steamwar.sql.NoClipboardException;
|
import de.steamwar.sql.NoClipboardException;
|
||||||
import de.steamwar.sql.Schematic;
|
import de.steamwar.sql.Schematic;
|
||||||
@ -42,10 +43,9 @@ import org.bukkit.event.inventory.InventoryMoveItemEvent;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.Set;
|
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class FightSchematic implements IStateDependent {
|
public class FightSchematic extends StateDependent {
|
||||||
|
|
||||||
private final FightTeam team;
|
private final FightTeam team;
|
||||||
private final int pasteX;
|
private final int pasteX;
|
||||||
@ -60,6 +60,7 @@ public class FightSchematic implements IStateDependent {
|
|||||||
private int schematic = 0;
|
private int schematic = 0;
|
||||||
|
|
||||||
public FightSchematic(FightTeam team, int pasteX, int pasteY, int pasteZ, int cornerX, int cornerY, int cornerZ, boolean rotate) {
|
public FightSchematic(FightTeam team, int pasteX, int pasteY, int pasteZ, int cornerX, int cornerY, int cornerZ, boolean rotate) {
|
||||||
|
super(ArenaMode.All, FightState.Schem);
|
||||||
this.team = team;
|
this.team = team;
|
||||||
this.pasteX = pasteX;
|
this.pasteX = pasteX;
|
||||||
this.pasteY = pasteY;
|
this.pasteY = pasteY;
|
||||||
@ -68,7 +69,6 @@ public class FightSchematic implements IStateDependent {
|
|||||||
this.cornerY = cornerY;
|
this.cornerY = cornerY;
|
||||||
this.cornerZ = cornerZ;
|
this.cornerZ = cornerZ;
|
||||||
this.rotate = rotate;
|
this.rotate = rotate;
|
||||||
FightState.registerStateDependent(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasSchematic(){
|
public boolean hasSchematic(){
|
||||||
@ -89,11 +89,6 @@ public class FightSchematic implements IStateDependent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Set<FightState> enabled() {
|
|
||||||
return FightState.Schem;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void enable() {
|
public void enable() {
|
||||||
if(FightState.getFightState() == FightState.SPECTATE)
|
if(FightState.getFightState() == FightState.SPECTATE)
|
||||||
@ -107,6 +102,12 @@ public class FightSchematic implements IStateDependent {
|
|||||||
setSchematic(publics.get(new Random().nextInt(publics.size())));
|
setSchematic(publics.get(new Random().nextInt(publics.size())));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!ArenaMode.Test.contains(Config.mode)){
|
||||||
|
FightPlayer leader = team.getLeader();
|
||||||
|
if(leader != null)
|
||||||
|
leader.getPlayer().getInventory().clear(0);
|
||||||
|
}
|
||||||
|
|
||||||
if(team.isBlue())
|
if(team.isBlue())
|
||||||
RecordSystem.blueSchem(schematic);
|
RecordSystem.blueSchem(schematic);
|
||||||
else
|
else
|
||||||
@ -175,7 +176,7 @@ public class FightSchematic implements IStateDependent {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void disable() {
|
public void disable() {
|
||||||
//TODO: Reset team area
|
team.teleportToSpawn();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class FreezeWorld implements Listener {
|
private static class FreezeWorld implements Listener {
|
||||||
|
@ -30,6 +30,7 @@ import de.steamwar.fightsystem.record.RecordSystem;
|
|||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.listener.FightScoreboard;
|
import de.steamwar.fightsystem.listener.FightScoreboard;
|
||||||
import de.steamwar.fightsystem.utils.ItemBuilder;
|
import de.steamwar.fightsystem.utils.ItemBuilder;
|
||||||
|
import de.steamwar.fightsystem.utils.Region;
|
||||||
import de.steamwar.fightsystem.utils.TechHider;
|
import de.steamwar.fightsystem.utils.TechHider;
|
||||||
import de.steamwar.inventory.SWItem;
|
import de.steamwar.inventory.SWItem;
|
||||||
import de.steamwar.sql.Schematic;
|
import de.steamwar.sql.Schematic;
|
||||||
@ -59,27 +60,20 @@ public class FightTeam implements IFightTeam{
|
|||||||
private final boolean blue;
|
private final boolean blue;
|
||||||
|
|
||||||
private final Location spawn;
|
private final Location spawn;
|
||||||
private final int pasteX;
|
private final Region schemRegion;
|
||||||
private final int pasteY;
|
private final Region extendRegion;
|
||||||
private final int pasteZ;
|
|
||||||
private final int cornerX;
|
|
||||||
private final int cornerY;
|
|
||||||
private final int cornerZ;
|
|
||||||
private final boolean rotate;
|
|
||||||
|
|
||||||
public FightTeam(String name, String prefix, Location spawn, int cornerX, int cornerY, int cornerZ, boolean rotate, boolean blue, UUID designatedLeader) {
|
public FightTeam(String name, String prefix, Location spawn, Region schemRegion, Region extendRegion, boolean rotate, boolean blue, UUID designatedLeader) {
|
||||||
this.spawn = spawn;
|
this.spawn = spawn;
|
||||||
this.pasteX = cornerX + Config.SchemsizeX/2;
|
this.schemRegion = schemRegion;
|
||||||
this.pasteY = cornerY;
|
this.extendRegion = extendRegion;
|
||||||
this.pasteZ = cornerZ + Config.SchemsizeZ/2;
|
int pasteX = schemRegion.getMinX() + Config.SchemsizeX / 2;
|
||||||
|
int pasteY = schemRegion.getMinY();
|
||||||
|
int pasteZ = schemRegion.getMinZ() + Config.SchemsizeZ / 2;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.prefix = prefix;
|
this.prefix = prefix;
|
||||||
this.ready = false;
|
this.ready = false;
|
||||||
this.rotate = rotate;
|
this.schematic = new FightSchematic(this, pasteX, pasteY, pasteZ, schemRegion.getMinX(), schemRegion.getMinY(), schemRegion.getMinZ(), rotate);
|
||||||
this.cornerX = cornerX;
|
|
||||||
this.cornerY = cornerY;
|
|
||||||
this.cornerZ = cornerZ;
|
|
||||||
this.schematic = new FightSchematic(this, pasteX, pasteY, pasteZ, cornerX, cornerY, cornerZ, rotate);
|
|
||||||
this.blue = blue;
|
this.blue = blue;
|
||||||
this.designatedLeader = designatedLeader;
|
this.designatedLeader = designatedLeader;
|
||||||
color = ChatColor.getByChar(ChatColor.getLastColors(prefix).replace("§", ""));
|
color = ChatColor.getByChar(ChatColor.getLastColors(prefix).replace("§", ""));
|
||||||
@ -94,20 +88,28 @@ public class FightTeam implements IFightTeam{
|
|||||||
team.setAllowFriendlyFire(false);
|
team.setAllowFriendlyFire(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Region getSchemRegion() {
|
||||||
|
return schemRegion;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Region getExtendRegion() {
|
||||||
|
return extendRegion;
|
||||||
|
}
|
||||||
|
|
||||||
public final int getCornerX() {
|
public final int getCornerX() {
|
||||||
return cornerX;
|
return schemRegion.getMinX();
|
||||||
}
|
}
|
||||||
|
|
||||||
public final int getCornerY() {
|
public final int getCornerY() {
|
||||||
return cornerY;
|
return schemRegion.getMinY();
|
||||||
}
|
}
|
||||||
|
|
||||||
public final int getCornerZ() {
|
public final int getCornerZ() {
|
||||||
return cornerZ;
|
return schemRegion.getMinZ();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canbeLeader(Player p){
|
public boolean canbeLeader(Player p){
|
||||||
return !hasTeamLeader() && (designatedLeader == null || designatedLeader.equals(p.getUniqueId()));
|
return isLeaderless() && (designatedLeader == null || designatedLeader.equals(p.getUniqueId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void teleportToSpawn(){
|
public void teleportToSpawn(){
|
||||||
@ -172,24 +174,24 @@ public class FightTeam implements IFightTeam{
|
|||||||
public void removePlayer(Player player) {
|
public void removePlayer(Player player) {
|
||||||
FightPlayer fightPlayer = getFightPlayer(player);
|
FightPlayer fightPlayer = getFightPlayer(player);
|
||||||
|
|
||||||
final List<TechHider.ChunkPos> chunksToReload = TechHider.prepareChunkReload(player);
|
List<TechHider.ChunkPos> chunksToReload = TechHider.prepareChunkReload(player);
|
||||||
players.remove(player);
|
players.remove(player);
|
||||||
team.removeEntry(player.getName());
|
team.removeEntry(player.getName());
|
||||||
fightPlayer.getPlayer().getInventory().clear();
|
|
||||||
|
|
||||||
if(fightPlayer.equals(leader) && FightState.setup())
|
if(fightPlayer.equals(leader))
|
||||||
setLeader(null);
|
setLeader(null);
|
||||||
|
|
||||||
Fight.setPlayerGamemode(player, GameMode.SPECTATOR);
|
Fight.setPlayerGamemode(player, GameMode.SPECTATOR);
|
||||||
player.teleport(Config.SpecSpawn);
|
player.teleport(Config.SpecSpawn);
|
||||||
if(!Config.test())
|
player.getInventory().clear();
|
||||||
|
if(!ArenaMode.Test.contains(Config.mode))
|
||||||
new TablistNamePacket(SteamwarUser.get(player.getUniqueId()).getId(), "§7" + player.getName()).send(player);
|
new TablistNamePacket(SteamwarUser.get(player.getUniqueId()).getId(), "§7" + player.getName()).send(player);
|
||||||
RecordSystem.entityDespawns(player);
|
RecordSystem.entityDespawns(player);
|
||||||
TechHider.reloadChunks(player, chunksToReload);
|
TechHider.reloadChunks(player, chunksToReload);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasTeamLeader() {
|
public boolean isLeaderless() {
|
||||||
return leader != null;
|
return leader == null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -207,7 +209,7 @@ public class FightTeam implements IFightTeam{
|
|||||||
setLeader(players.values().iterator().next());
|
setLeader(players.values().iterator().next());
|
||||||
Bukkit.broadcastMessage(FightSystem.PREFIX + "§aDer Spieler §e" + this.leader.getPlayer().getName() + " §aist nun Leader von Team " + getColoredName() + "§a!");
|
Bukkit.broadcastMessage(FightSystem.PREFIX + "§aDer Spieler §e" + this.leader.getPlayer().getName() + " §aist nun Leader von Team " + getColoredName() + "§a!");
|
||||||
}else if(!ArenaMode.RankedEvent.contains(Config.mode)){
|
}else if(!ArenaMode.RankedEvent.contains(Config.mode)){
|
||||||
FightSystem.shutdown(FightSystem.PREFIX + "§cTeam " + getColoredName() + " §chat keine Spieler mehr.\n Arena schließt...");
|
FightSystem.setPreLeaderState();
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -248,27 +250,19 @@ public class FightTeam implements IFightTeam{
|
|||||||
return ready;
|
return ready;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void pasteSchematic(){
|
public void pasteSchem(Schematic schematic){
|
||||||
if(!Config.test() && leader != null)
|
setSchem(schematic);
|
||||||
leader.getPlayer().getInventory().clear(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSchematic(Schematic schematic){
|
if(ArenaMode.Test.contains(Config.mode))
|
||||||
setNotPastingSchem(schematic);
|
this.schematic.enable();
|
||||||
broadcast(FightSystem.PREFIX + "§7Das §e" + Config.GameName + " " + schematic.getSchemName() + " §7wird für den Kampf verwendet!");
|
|
||||||
|
|
||||||
if(!Config.test())
|
|
||||||
leader.getPlayer().getInventory().clear(0);
|
|
||||||
|
|
||||||
if(Config.test())
|
|
||||||
pasteSchematic();
|
|
||||||
else if(Fight.getOpposite(this).hasSchematic()){
|
else if(Fight.getOpposite(this).hasSchematic()){
|
||||||
FightSystem.setPostSchemState();
|
FightSystem.setPostSchemState();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setNotPastingSchem(Schematic schematic){
|
public void setSchem(Schematic schematic){
|
||||||
this.schematic.setSchematic(schematic);
|
this.schematic.setSchematic(schematic);
|
||||||
|
broadcast(FightSystem.PREFIX + "§7Das §e" + Config.GameName + " " + schematic.getSchemName() + " §7wird für den Kampf verwendet!");
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasSchematic(){
|
public boolean hasSchematic(){
|
||||||
|
49
FightSystem_Main/src/de/steamwar/fightsystem/fight/FightWorld.java
Normale Datei
49
FightSystem_Main/src/de/steamwar/fightsystem/fight/FightWorld.java
Normale Datei
@ -0,0 +1,49 @@
|
|||||||
|
package de.steamwar.fightsystem.fight;
|
||||||
|
|
||||||
|
import de.steamwar.core.events.ChunkListener;
|
||||||
|
import de.steamwar.fightsystem.ArenaMode;
|
||||||
|
import de.steamwar.fightsystem.Config;
|
||||||
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
|
import de.steamwar.fightsystem.states.StateDependent;
|
||||||
|
import net.minecraft.server.v1_15_R1.Chunk;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.WorldCreator;
|
||||||
|
import org.bukkit.craftbukkit.v1_15_R1.CraftWorld;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class FightWorld extends StateDependent {
|
||||||
|
|
||||||
|
private final World world = Bukkit.getWorlds().get(0);
|
||||||
|
|
||||||
|
public FightWorld() {
|
||||||
|
super(ArenaMode.Restartable, FightState.Schem);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void enable() {
|
||||||
|
//unused
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void disable() {
|
||||||
|
World backup = new WorldCreator(world.getName() + "/backup").createWorld();
|
||||||
|
assert backup != null;
|
||||||
|
Config.ArenaRegion.forEachChunk((x, z) -> resetChunk(backup, x, z));
|
||||||
|
Bukkit.unloadWorld(backup, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void resetChunk(World backup, int x, int z){
|
||||||
|
Chunk chunk = ((CraftWorld) world).getHandle().getChunkAt(x, z);
|
||||||
|
Chunk backupChunk = ((CraftWorld) backup).getHandle().getChunkAt(x, z);
|
||||||
|
|
||||||
|
System.arraycopy(backupChunk.getSections(), 0, chunk.getSections(), 0, chunk.getSections().length);
|
||||||
|
chunk.tileEntities.clear();
|
||||||
|
chunk.tileEntities.putAll(backupChunk.tileEntities);
|
||||||
|
chunk.heightMap.clear();
|
||||||
|
chunk.heightMap.putAll(backupChunk.heightMap);
|
||||||
|
for(Player p : Bukkit.getOnlinePlayers()){
|
||||||
|
ChunkListener.sendChunk(p, x, z);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,72 @@
|
|||||||
|
/*
|
||||||
|
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.Config;
|
||||||
|
import de.steamwar.fightsystem.fight.Fight;
|
||||||
|
import de.steamwar.fightsystem.fight.FightTeam;
|
||||||
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
|
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||||
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
|
import org.bukkit.GameMode;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.player.PlayerMoveEvent;
|
||||||
|
|
||||||
|
public class ArenaBorder implements Listener {
|
||||||
|
|
||||||
|
public ArenaBorder() {
|
||||||
|
new StateDependentListener(ArenaMode.All, FightState.All, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void arenaBorder(PlayerMoveEvent event){
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
Location to = event.getTo();
|
||||||
|
assert to != null;
|
||||||
|
|
||||||
|
if(!Config.ArenaRegion.in2dRegion(to)){
|
||||||
|
reset(event);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
FightTeam team = Fight.getPlayerTeam(player);
|
||||||
|
if(team == null || player.getGameMode() == GameMode.SPECTATOR)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(to.getY() <= Config.underArenaBorder) {
|
||||||
|
if(FightState.infight())
|
||||||
|
player.damage(2);
|
||||||
|
else if(!Config.GroundWalkable)
|
||||||
|
player.teleport(team.getSpawn());
|
||||||
|
}else if(to.getY() + 1.8 <= Config.upperArenaBorder){
|
||||||
|
reset(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void reset(PlayerMoveEvent event){
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
player.teleport(event.getFrom());
|
||||||
|
BasicListener.toActionbar(player, TextComponent.fromLegacyText("§cDu darfst die Arena nicht verlassen"));
|
||||||
|
}
|
||||||
|
}
|
@ -1,118 +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.comms.packets.TablistNamePacket;
|
|
||||||
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.countdown.SWSound;
|
|
||||||
import de.steamwar.fightsystem.fight.Fight;
|
|
||||||
import de.steamwar.fightsystem.fight.FightPlayer;
|
|
||||||
import de.steamwar.fightsystem.fight.FightTeam;
|
|
||||||
import de.steamwar.fightsystem.record.RecordSystem;
|
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
|
||||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
|
||||||
import de.steamwar.sql.SteamwarUser;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.GameMode;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.EventPriority;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
|
||||||
|
|
||||||
public class ConnectionListener implements Listener {
|
|
||||||
|
|
||||||
public ConnectionListener() {
|
|
||||||
new StateDependentListener(ArenaMode.All, FightState.All, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
|
||||||
public void handlePlayerJoin(PlayerJoinEvent event) {
|
|
||||||
event.setJoinMessage(null);
|
|
||||||
|
|
||||||
Player player = event.getPlayer();
|
|
||||||
FightTeam fightTeam = Fight.getPlayerTeam(player);
|
|
||||||
|
|
||||||
if (fightTeam == null) {
|
|
||||||
Fight.setPlayerGamemode(player, GameMode.SPECTATOR);
|
|
||||||
player.teleport(Config.SpecSpawn);
|
|
||||||
if(!Config.test())
|
|
||||||
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> new TablistNamePacket(SteamwarUser.get(player.getUniqueId()).getId(), "§7" + player.getName()).send(player), 5);
|
|
||||||
} else {
|
|
||||||
player.teleport(fightTeam.getSpawn());
|
|
||||||
if(FightState.setup())
|
|
||||||
Fight.setPlayerGamemode(player, GameMode.SURVIVAL);
|
|
||||||
else
|
|
||||||
Fight.setPlayerGamemode(player, GameMode.SPECTATOR);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
|
||||||
public void handlePlayerDeath(PlayerDeathEvent event) {
|
|
||||||
event.setDeathMessage(null);
|
|
||||||
|
|
||||||
Player player = event.getEntity().getPlayer();
|
|
||||||
FightTeam fightTeam = Fight.getPlayerTeam(player);
|
|
||||||
|
|
||||||
if(fightTeam == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
assert player != null;
|
|
||||||
Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer Spieler " + fightTeam.getPrefix() + player.getName() + " §cist gestorben!");
|
|
||||||
fightTeam.getFightPlayer(player).setOut();
|
|
||||||
Fight.setPlayerGamemode(player, GameMode.SPECTATOR);
|
|
||||||
player.teleport(fightTeam.getSpawn());
|
|
||||||
Fight.playSound(Countdown.getSound(SWSound.ENTITY_WITHER_DEATH), 100.0F, 1.0F);
|
|
||||||
RecordSystem.entityDespawns(player);
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
|
||||||
public void handlePlayerQuit(PlayerQuitEvent event) {
|
|
||||||
event.setQuitMessage(null);
|
|
||||||
|
|
||||||
Player player = event.getPlayer();
|
|
||||||
FightTeam fightTeam = Fight.getPlayerTeam(player);
|
|
||||||
if(fightTeam == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if(FightState.setup()){
|
|
||||||
fightTeam.removePlayer(player);
|
|
||||||
|
|
||||||
RecordSystem.entityDespawns(player);
|
|
||||||
}else if(FightState.ingame()){
|
|
||||||
FightPlayer fightPlayer = fightTeam.getFightPlayer(player);
|
|
||||||
if(fightPlayer.isLiving()) {
|
|
||||||
Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer Spieler " + fightTeam.getPrefix() + player.getName() + " §chat den Kampf verlassen!");
|
|
||||||
fightTeam.getFightPlayer(player).setOut();
|
|
||||||
|
|
||||||
RecordSystem.entityDespawns(player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//Shutdown server if nobody online and its not an event server
|
|
||||||
if(Config.mode != ArenaMode.EVENT && (Bukkit.getOnlinePlayers().isEmpty() || (Bukkit.getOnlinePlayers().size() == 1 && Bukkit.getOnlinePlayers().contains(player))))
|
|
||||||
FightSystem.shutdown(null);
|
|
||||||
}
|
|
||||||
}
|
|
@ -81,7 +81,7 @@ public class EventJoin implements Listener {
|
|||||||
|
|
||||||
if(team != null && team.getPlayers().size() < Config.MaximumTeamMembers){
|
if(team != null && team.getPlayers().size() < Config.MaximumTeamMembers){
|
||||||
FightPlayer fp = team.addMember(player);
|
FightPlayer fp = team.addMember(player);
|
||||||
if(!team.hasTeamLeader())
|
if(team.isLeaderless())
|
||||||
team.setLeader(fp);
|
team.setLeader(fp);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,77 @@
|
|||||||
|
/*
|
||||||
|
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.FightSystem;
|
||||||
|
import de.steamwar.fightsystem.countdown.Countdown;
|
||||||
|
import de.steamwar.fightsystem.countdown.SWSound;
|
||||||
|
import de.steamwar.fightsystem.fight.Fight;
|
||||||
|
import de.steamwar.fightsystem.fight.FightPlayer;
|
||||||
|
import de.steamwar.fightsystem.fight.FightTeam;
|
||||||
|
import de.steamwar.fightsystem.record.RecordSystem;
|
||||||
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
|
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||||
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
|
||||||
|
public class IngameDeath implements Listener {
|
||||||
|
|
||||||
|
public IngameDeath() {
|
||||||
|
new StateDependentListener(ArenaMode.All, FightState.Ingame, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
public void handlePlayerDeath(PlayerDeathEvent event) {
|
||||||
|
event.setDeathMessage(null);
|
||||||
|
|
||||||
|
Player player = event.getEntity();
|
||||||
|
FightTeam team = Fight.getPlayerTeam(player);
|
||||||
|
|
||||||
|
if(team == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer Spieler " + team.getPrefix() + player.getName() + " §cist gestorben!");
|
||||||
|
Fight.playSound(Countdown.getSound(SWSound.ENTITY_WITHER_DEATH), 100.0F, 1.0F);
|
||||||
|
team.getFightPlayer(player).setOut();
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
public void handlePlayerQuit(PlayerQuitEvent event) {
|
||||||
|
event.setQuitMessage(null);
|
||||||
|
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
FightTeam team = Fight.getPlayerTeam(player);
|
||||||
|
if(team == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
FightPlayer fightPlayer = team.getFightPlayer(player);
|
||||||
|
if(fightPlayer.isLiving()) {
|
||||||
|
Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer Spieler " + team.getPrefix() + player.getName() + " §chat den Kampf verlassen!");
|
||||||
|
team.getFightPlayer(player).setOut();
|
||||||
|
RecordSystem.entityDespawns(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,127 +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.Config;
|
|
||||||
import de.steamwar.fightsystem.FightSystem;
|
|
||||||
import de.steamwar.fightsystem.fight.Fight;
|
|
||||||
import de.steamwar.fightsystem.fight.FightTeam;
|
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
|
||||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
|
||||||
import de.steamwar.fightsystem.utils.Region;
|
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.GameMode;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.event.player.PlayerMoveEvent;
|
|
||||||
|
|
||||||
import java.util.logging.Level;
|
|
||||||
|
|
||||||
public class Move implements Listener {
|
|
||||||
|
|
||||||
private static final String DENY_ARENA = "§cDu darfst die Arena nicht verlassen";
|
|
||||||
private static final String DENY_TEAM = "§cDu darfst nicht zu den Teams";
|
|
||||||
private static final String DENY_ENTERN = "§cDu darfst nicht entern";
|
|
||||||
|
|
||||||
public Move() {
|
|
||||||
new StateDependentListener(ArenaMode.All, FightState.All, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void teamAreas(PlayerMoveEvent event) {
|
|
||||||
Player player = event.getPlayer();
|
|
||||||
if(player == FightSystem.getEventLeiter() || Config.test())
|
|
||||||
return;
|
|
||||||
|
|
||||||
Location to = event.getTo();
|
|
||||||
FightTeam fightTeam = Fight.getPlayerTeam(player);
|
|
||||||
|
|
||||||
assert to != null;
|
|
||||||
boolean inArenaY = to.getY() + 1.8 <= Config.upperArenaBorder;
|
|
||||||
|
|
||||||
boolean inBlueArea = inArenaY && Region.isIn2DRange(to, Config.TeamBlueCornerX, Config.TeamBlueCornerZ, Config.SchemsizeX, Config.SchemsizeZ, Config.BorderFromSchematic);
|
|
||||||
boolean inRedArea = inArenaY && Region.isIn2DRange(to, Config.TeamRedCornerX, Config.TeamRedCornerZ, Config.SchemsizeX, Config.SchemsizeZ, Config.BorderFromSchematic);
|
|
||||||
|
|
||||||
if(inBlueArea){
|
|
||||||
if(fightTeam == null)
|
|
||||||
reset(event, DENY_TEAM);
|
|
||||||
else if(fightTeam == Fight.getRedTeam() && (player.getGameMode() == GameMode.SPECTATOR || !fightTeam.canPlayerEntern(player)))
|
|
||||||
reset(event, DENY_ENTERN);
|
|
||||||
else
|
|
||||||
return; // Is allowed in area
|
|
||||||
checkInInnerArea(event.getPlayer(), to, Config.TeamBlueCornerX, Config.TeamBlueCornerZ);
|
|
||||||
}else if(inRedArea){
|
|
||||||
if(fightTeam == null)
|
|
||||||
reset(event, DENY_TEAM);
|
|
||||||
else if(fightTeam == Fight.getBlueTeam() && (player.getGameMode() == GameMode.SPECTATOR || !fightTeam.canPlayerEntern(player)))
|
|
||||||
reset(event, DENY_ENTERN);
|
|
||||||
else
|
|
||||||
return; // Is allowed in area
|
|
||||||
checkInInnerArea(event.getPlayer(), to, Config.TeamRedCornerX, Config.TeamRedCornerZ);
|
|
||||||
}else if(fightTeam != null && player.getGameMode() != GameMode.SPECTATOR && !fightTeam.canPlayerEntern(player))
|
|
||||||
reset(event, DENY_ENTERN);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void checkInInnerArea(Player player, Location to, int teamCornerX, int teamCornerZ){
|
|
||||||
boolean inArenaY = to.getY() + 1.8 <= Config.TeamBlueCornerY + Config.SchemsizeY;
|
|
||||||
boolean inArea = inArenaY && Region.isIn2DRange(to, teamCornerX, teamCornerZ, Config.SchemsizeX, Config.SchemsizeZ, 0);
|
|
||||||
if(inArea && Config.BorderFromSchematic >= 5){ // Preventing false positives due to small extension
|
|
||||||
player.kickPlayer(null);
|
|
||||||
Bukkit.getLogger().log(Level.SEVERE, player.getName() + " ist in einen Teambereich eingedrungen.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void arenaBorder(PlayerMoveEvent event){
|
|
||||||
Player player = event.getPlayer();
|
|
||||||
Location to = event.getTo();
|
|
||||||
|
|
||||||
//Check in Arena
|
|
||||||
assert to != null;
|
|
||||||
if(!Region.isIn2DRegion(to, Config.ArenaMinX, Config.ArenaMinZ, Config.ArenaMaxX, Config.ArenaMaxZ)){
|
|
||||||
reset(event, DENY_ARENA);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
FightTeam team = Fight.getPlayerTeam(player);
|
|
||||||
boolean inArenaY = to.getY() + 1.8 <= Config.upperArenaBorder;
|
|
||||||
|
|
||||||
if(to.getY() <= Config.underArenaBorder) {
|
|
||||||
if(player.getGameMode() == GameMode.SPECTATOR || team == null)
|
|
||||||
reset(event, DENY_ARENA);
|
|
||||||
else if(FightState.infight())
|
|
||||||
player.damage(2);
|
|
||||||
else if(!Config.GroundWalkable)
|
|
||||||
player.teleport(team.getSpawn());
|
|
||||||
}else if(team != null && !inArenaY){
|
|
||||||
reset(event, DENY_ARENA);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void reset(PlayerMoveEvent event, String message){
|
|
||||||
Player player = event.getPlayer();
|
|
||||||
player.teleport(event.getFrom());
|
|
||||||
BasicListener.toActionbar(player, TextComponent.fromLegacyText(message));
|
|
||||||
}
|
|
||||||
}
|
|
@ -23,6 +23,7 @@ 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.fight.Fight;
|
import de.steamwar.fightsystem.fight.Fight;
|
||||||
|
import de.steamwar.fightsystem.fight.FightPlayer;
|
||||||
import de.steamwar.fightsystem.fight.FightTeam;
|
import de.steamwar.fightsystem.fight.FightTeam;
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||||
@ -50,8 +51,9 @@ public class NormalJoin implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Fight.getRedTeam().hasTeamLeader() && Fight.getBlueTeam().hasTeamLeader()
|
FightPlayer redLeader = Fight.getRedTeam().getLeader();
|
||||||
&& (Fight.getRedTeam().getLeader().getPlayer() == player || Fight.getBlueTeam().getLeader().getPlayer() == player)) {
|
FightPlayer blueLeader = Fight.getBlueTeam().getLeader();
|
||||||
|
if(redLeader != null && blueLeader != null && (Fight.getRedTeam().getLeader().getPlayer() == player || Fight.getBlueTeam().getLeader().getPlayer() == player)) {
|
||||||
FightSystem.setPreSchemState();
|
FightSystem.setPreSchemState();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,26 +19,30 @@
|
|||||||
|
|
||||||
package de.steamwar.fightsystem.listener;
|
package de.steamwar.fightsystem.listener;
|
||||||
|
|
||||||
|
import de.steamwar.comms.packets.TablistNamePacket;
|
||||||
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.fight.Fight;
|
import de.steamwar.fightsystem.fight.Fight;
|
||||||
import de.steamwar.fightsystem.fight.FightTeam;
|
import de.steamwar.fightsystem.fight.FightTeam;
|
||||||
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 net.md_5.bungee.api.chat.TextComponent;
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
||||||
import org.bukkit.event.entity.SpawnerSpawnEvent;
|
import org.bukkit.event.entity.SpawnerSpawnEvent;
|
||||||
import org.bukkit.event.inventory.CraftItemEvent;
|
import org.bukkit.event.inventory.CraftItemEvent;
|
||||||
import org.bukkit.event.inventory.FurnaceSmeltEvent;
|
import org.bukkit.event.inventory.FurnaceSmeltEvent;
|
||||||
import org.bukkit.event.inventory.InventoryPickupItemEvent;
|
import org.bukkit.event.inventory.InventoryPickupItemEvent;
|
||||||
import org.bukkit.event.player.PlayerBedEnterEvent;
|
import org.bukkit.event.player.*;
|
||||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
|
||||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
|
||||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
|
||||||
import org.bukkit.event.weather.WeatherChangeEvent;
|
import org.bukkit.event.weather.WeatherChangeEvent;
|
||||||
|
import org.bukkit.event.world.WorldLoadEvent;
|
||||||
|
|
||||||
public class Permanent implements Listener {
|
public class Permanent implements Listener {
|
||||||
|
|
||||||
@ -46,6 +50,39 @@ public class Permanent implements Listener {
|
|||||||
new StateDependentListener(ArenaMode.All, FightState.All, this);
|
new StateDependentListener(ArenaMode.All, FightState.All, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void handlePlayerRespawn(PlayerRespawnEvent event){
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
Fight.setPlayerGamemode(player, GameMode.SPECTATOR);
|
||||||
|
|
||||||
|
FightTeam team = Fight.getPlayerTeam(player);
|
||||||
|
event.setRespawnLocation(team == null ? Config.SpecSpawn : team.getSpawn());
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onTpGM3(PlayerTeleportEvent e) {
|
||||||
|
if (e.getCause() == PlayerTeleportEvent.TeleportCause.SPECTATE) {
|
||||||
|
e.setCancelled(true);
|
||||||
|
BasicListener.toActionbar(e.getPlayer(), TextComponent.fromLegacyText("§cDu darfst diese Teleportfunktion nicht benutzen!"));
|
||||||
|
e.getPlayer().kickPlayer("§cDu darfst diese Teleportfunktion nicht benutzen!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
public void handlePlayerJoin(PlayerJoinEvent event) {
|
||||||
|
event.setJoinMessage(null);
|
||||||
|
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
FightTeam fightTeam = Fight.getPlayerTeam(player);
|
||||||
|
|
||||||
|
if (fightTeam == null) {
|
||||||
|
Fight.setPlayerGamemode(player, GameMode.SPECTATOR);
|
||||||
|
player.teleport(Config.SpecSpawn);
|
||||||
|
if(!ArenaMode.Test.contains(Config.mode))
|
||||||
|
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> new TablistNamePacket(SteamwarUser.get(player.getUniqueId()).getId(), "§7" + player.getName()).send(player), 5);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void handleFoodLevelChange(FoodLevelChangeEvent event) {
|
public void handleFoodLevelChange(FoodLevelChangeEvent event) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
@ -87,21 +124,7 @@ public class Permanent implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void handlePlayerRespawn(PlayerRespawnEvent event) {
|
public void onWorldLoad(WorldLoadEvent e) {
|
||||||
Player player = event.getPlayer();
|
e.getWorld().setAutoSave(false);
|
||||||
FightTeam team = Fight.getPlayerTeam(player);
|
|
||||||
if(team == null)
|
|
||||||
event.setRespawnLocation(Config.SpecSpawn);
|
|
||||||
else
|
|
||||||
event.setRespawnLocation(team.getSpawn());
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onTpGM3(PlayerTeleportEvent e) {
|
|
||||||
if (e.getCause() == PlayerTeleportEvent.TeleportCause.SPECTATE) {
|
|
||||||
e.setCancelled(true);
|
|
||||||
BasicListener.toActionbar(e.getPlayer(), TextComponent.fromLegacyText("§cDu darfst diese Teleportfunktion nicht benutzen!"));
|
|
||||||
e.getPlayer().kickPlayer("§cDu darfst diese Teleportfunktion nicht benutzen!");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,6 @@ package de.steamwar.fightsystem.listener;
|
|||||||
import de.steamwar.fightsystem.Config;
|
import de.steamwar.fightsystem.Config;
|
||||||
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.utils.Region;
|
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
@ -40,13 +39,9 @@ public class PistonListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void handlePistonExtend(BlockPistonExtendEvent e){
|
public void handlePistonExtend(BlockPistonExtendEvent e){
|
||||||
BlockFace b = e.getDirection();
|
BlockFace b = e.getDirection().getOppositeFace();
|
||||||
for(Block block : e.getBlocks()){
|
for(Block block : e.getBlocks()){
|
||||||
if(
|
if(Config.BlueExtendRegion.inRegion(block.getRelative(b)) && Config.RedExetendRegion.inRegion(block.getRelative(b))){
|
||||||
block.getY() > Config.upperArenaBorder ||
|
|
||||||
(!Region.isIn2DRange(block.getLocation(), Config.TeamBlueCornerX + b.getModX(), Config.TeamBlueCornerZ + b.getModZ(), Config.SchemsizeX, Config.SchemsizeZ, Config.BorderFromSchematic) &&
|
|
||||||
!Region.isIn2DRange(block.getLocation(), Config.TeamRedCornerX + b.getModX(), Config.TeamRedCornerZ + b.getModZ(), Config.SchemsizeX, Config.SchemsizeZ, Config.BorderFromSchematic))
|
|
||||||
){
|
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -55,13 +50,9 @@ public class PistonListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void handlePistonRetract(BlockPistonRetractEvent e){
|
public void handlePistonRetract(BlockPistonRetractEvent e){
|
||||||
BlockFace b = e.getDirection();
|
BlockFace b = e.getDirection().getOppositeFace();
|
||||||
for(Block block : e.getBlocks()){
|
for(Block block : e.getBlocks()){
|
||||||
if(
|
if(Config.BlueExtendRegion.inRegion(block.getRelative(b)) && Config.RedExetendRegion.inRegion(block.getRelative(b))) {
|
||||||
block.getY() > Config.upperArenaBorder ||
|
|
||||||
(!Region.isIn2DRange(block.getLocation(), Config.TeamBlueCornerX + b.getModX(), Config.TeamBlueCornerZ + b.getModZ(), Config.SchemsizeX, Config.SchemsizeZ, Config.BorderFromSchematic) &&
|
|
||||||
!Region.isIn2DRange(block.getLocation(), Config.TeamRedCornerX + b.getModX(), Config.TeamRedCornerZ + b.getModZ(), Config.SchemsizeX, Config.SchemsizeZ, Config.BorderFromSchematic))
|
|
||||||
){
|
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -30,10 +30,16 @@ import org.bukkit.event.EventHandler;
|
|||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
|
|
||||||
public class PrepareJoin implements Listener {
|
public class PrepareSchem implements Listener {
|
||||||
|
|
||||||
public PrepareJoin() {
|
public PrepareSchem() {
|
||||||
new StateDependentListener(ArenaMode.Prepare, FightState.All, this);
|
new StateDependentListener(ArenaMode.Prepare, FightState.Setup, this){
|
||||||
|
@Override
|
||||||
|
public void disable() {
|
||||||
|
super.disable();
|
||||||
|
//TODO
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
@ -26,6 +26,7 @@ import de.steamwar.fightsystem.fight.FightPlayer;
|
|||||||
import de.steamwar.fightsystem.fight.FightTeam;
|
import de.steamwar.fightsystem.fight.FightTeam;
|
||||||
import de.steamwar.fightsystem.record.RecordSystem;
|
import de.steamwar.fightsystem.record.RecordSystem;
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
|
import de.steamwar.fightsystem.states.StateDependent;
|
||||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||||
import org.bukkit.*;
|
import org.bukkit.*;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
@ -53,19 +54,21 @@ public class Recording implements Listener {
|
|||||||
private static final Random random = new Random();
|
private static final Random random = new Random();
|
||||||
|
|
||||||
public Recording() {
|
public Recording() {
|
||||||
new StateDependentListener(Config.recording(), FightState.All, this){
|
new StateDependentListener(Config.recording(), FightState.All, this);
|
||||||
|
new StateDependent(Config.recording(), FightState.Ingame){
|
||||||
@Override
|
@Override
|
||||||
public void stateChange(FightState state) {
|
public void enable() {
|
||||||
if(state == FightState.PRE_RUNNING) {
|
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> {
|
||||||
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> {
|
setKitItems(Fight.getBlueTeam());
|
||||||
setKitItems(Fight.getBlueTeam());
|
setKitItems(Fight.getRedTeam());
|
||||||
setKitItems(Fight.getRedTeam());
|
}, 1);
|
||||||
}, 1);
|
}
|
||||||
}else if(state == FightState.SPECTATE){
|
|
||||||
despawnTeam(Fight.getRedTeam());
|
@Override
|
||||||
despawnTeam(Fight.getBlueTeam());
|
public void disable() {
|
||||||
despawnTNT();
|
despawnTeam(Fight.getRedTeam());
|
||||||
}
|
despawnTeam(Fight.getBlueTeam());
|
||||||
|
despawnTNT();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
50
FightSystem_Main/src/de/steamwar/fightsystem/listener/SetupQuit.java
Normale Datei
50
FightSystem_Main/src/de/steamwar/fightsystem/listener/SetupQuit.java
Normale Datei
@ -0,0 +1,50 @@
|
|||||||
|
/*
|
||||||
|
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.fight.Fight;
|
||||||
|
import de.steamwar.fightsystem.fight.FightTeam;
|
||||||
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
|
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
|
||||||
|
public class SetupQuit implements Listener {
|
||||||
|
|
||||||
|
public SetupQuit(){
|
||||||
|
new StateDependentListener(ArenaMode.All, FightState.Setup, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
public void handlePlayerQuit(PlayerQuitEvent event) {
|
||||||
|
event.setQuitMessage(null);
|
||||||
|
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
FightTeam team = Fight.getPlayerTeam(player);
|
||||||
|
if(team == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
team.removePlayer(player);
|
||||||
|
}
|
||||||
|
}
|
43
FightSystem_Main/src/de/steamwar/fightsystem/listener/Shutdown.java
Normale Datei
43
FightSystem_Main/src/de/steamwar/fightsystem/listener/Shutdown.java
Normale Datei
@ -0,0 +1,43 @@
|
|||||||
|
/*
|
||||||
|
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 org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
|
||||||
|
public class Shutdown implements Listener {
|
||||||
|
|
||||||
|
public Shutdown(){
|
||||||
|
new StateDependentListener(ArenaMode.AntiEvent, FightState.All, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
public void handlePlayerQuit(PlayerQuitEvent event) {
|
||||||
|
//Shutdown server if nobody online and its not an event server
|
||||||
|
if(Bukkit.getOnlinePlayers().isEmpty() || (Bukkit.getOnlinePlayers().size() == 1 && Bukkit.getOnlinePlayers().contains(event.getPlayer())))
|
||||||
|
Bukkit.shutdown();
|
||||||
|
}
|
||||||
|
}
|
73
FightSystem_Main/src/de/steamwar/fightsystem/listener/TeamArea.java
Normale Datei
73
FightSystem_Main/src/de/steamwar/fightsystem/listener/TeamArea.java
Normale Datei
@ -0,0 +1,73 @@
|
|||||||
|
package de.steamwar.fightsystem.listener;
|
||||||
|
|
||||||
|
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.states.FightState;
|
||||||
|
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||||
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.GameMode;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.player.PlayerMoveEvent;
|
||||||
|
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
public class TeamArea implements Listener {
|
||||||
|
|
||||||
|
private static final String DENY_TEAM = "§cDu darfst nicht zu den Teams";
|
||||||
|
private static final String DENY_ENTERN = "§cDu darfst nicht entern";
|
||||||
|
|
||||||
|
public TeamArea() {
|
||||||
|
new StateDependentListener(ArenaMode.AntiTest, FightState.All, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void teamAreas(PlayerMoveEvent event) {
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
if(player == FightSystem.getEventLeiter())
|
||||||
|
return;
|
||||||
|
|
||||||
|
Location to = event.getTo();
|
||||||
|
assert to != null;
|
||||||
|
|
||||||
|
FightTeam team = Fight.getPlayerTeam(player);
|
||||||
|
|
||||||
|
if(Config.BlueExtendRegion.playerInRegion(to)){
|
||||||
|
if(team == null)
|
||||||
|
reset(event, DENY_TEAM);
|
||||||
|
else if(team == Fight.getRedTeam() && (player.getGameMode() == GameMode.SPECTATOR || !team.canPlayerEntern(player)))
|
||||||
|
reset(event, DENY_ENTERN);
|
||||||
|
else
|
||||||
|
return; // Is allowed in area
|
||||||
|
checkInInnerArea(event.getPlayer(), to, Fight.getBlueTeam());
|
||||||
|
}else if(Config.RedExetendRegion.playerInRegion(to)){
|
||||||
|
if(team == null)
|
||||||
|
reset(event, DENY_TEAM);
|
||||||
|
else if(team == Fight.getBlueTeam() && (player.getGameMode() == GameMode.SPECTATOR || !team.canPlayerEntern(player)))
|
||||||
|
reset(event, DENY_ENTERN);
|
||||||
|
else
|
||||||
|
return; // Is allowed in area
|
||||||
|
checkInInnerArea(event.getPlayer(), to, Fight.getRedTeam());
|
||||||
|
}else if(team != null && player.getGameMode() != GameMode.SPECTATOR && !team.canPlayerEntern(player))
|
||||||
|
reset(event, DENY_ENTERN);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkInInnerArea(Player player, Location to, FightTeam team){
|
||||||
|
if(team.getSchemRegion().playerInRegion(to) && Config.BorderFromSchematic >= 5){ // Preventing false positives due to small extension
|
||||||
|
player.kickPlayer(null);
|
||||||
|
Bukkit.getLogger().log(Level.SEVERE, player.getName() + " ist in einen Teambereich eingedrungen.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void reset(PlayerMoveEvent event, String message){
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
player.teleport(event.getFrom());
|
||||||
|
BasicListener.toActionbar(player, TextComponent.fromLegacyText(message));
|
||||||
|
}
|
||||||
|
}
|
@ -41,7 +41,7 @@ public class TestJoin implements Listener {
|
|||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
FightTeam fightTeam = Fight.getPlayerTeam(player);
|
FightTeam fightTeam = Fight.getPlayerTeam(player);
|
||||||
|
|
||||||
if (fightTeam == null && (!Fight.getRedTeam().hasTeamLeader() || !Fight.getBlueTeam().hasTeamLeader())) {
|
if (fightTeam == null && (Fight.getRedTeam().isLeaderless() || Fight.getBlueTeam().isLeaderless())) {
|
||||||
player.sendMessage(FightSystem.PREFIX + "§7Werde zum Teamleader mit §8/§eleader");
|
player.sendMessage(FightSystem.PREFIX + "§7Werde zum Teamleader mit §8/§eleader");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,12 +64,9 @@ public enum FightState {
|
|||||||
|
|
||||||
for(Map.Entry<IStateDependent, Boolean> feature : stateDependentFeatures.entrySet()){
|
for(Map.Entry<IStateDependent, Boolean> feature : stateDependentFeatures.entrySet()){
|
||||||
//Enable feature if should be enabled and currently disabled
|
//Enable feature if should be enabled and currently disabled
|
||||||
if(feature.getKey().enabled().contains(fightState)){
|
if(feature.getKey().enabled().contains(fightState) && !feature.getValue()){
|
||||||
if(!feature.getValue()){
|
feature.getKey().enable();
|
||||||
feature.getKey().enable();
|
feature.setValue(true);
|
||||||
feature.setValue(true);
|
|
||||||
}
|
|
||||||
feature.getKey().stateChange(fightState);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Disable feature if should be disabled and currently enabled
|
//Disable feature if should be disabled and currently enabled
|
||||||
|
@ -37,9 +37,4 @@ public interface IStateDependent {
|
|||||||
* Disables the state dependent object
|
* Disables the state dependent object
|
||||||
*/
|
*/
|
||||||
void disable();
|
void disable();
|
||||||
|
|
||||||
/**
|
|
||||||
* On state change when enabled
|
|
||||||
*/
|
|
||||||
default void stateChange(FightState state){}
|
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,7 @@ public class FightStatistics {
|
|||||||
private FightStatistics(){}
|
private FightStatistics(){}
|
||||||
|
|
||||||
private static Timestamp starttime = Timestamp.from(Instant.now());
|
private static Timestamp starttime = Timestamp.from(Instant.now());
|
||||||
private static int K = 20;
|
private static final int K = 20;
|
||||||
|
|
||||||
public static void start(){
|
public static void start(){
|
||||||
starttime = Timestamp.from(Instant.now());
|
starttime = Timestamp.from(Instant.now());
|
||||||
@ -49,10 +49,14 @@ public class FightStatistics {
|
|||||||
|
|
||||||
public static void saveStats(FightTeam winner, String windescription){
|
public static void saveStats(FightTeam winner, String windescription){
|
||||||
String gameMode = Config.SchematicType.toDB();
|
String gameMode = Config.SchematicType.toDB();
|
||||||
if(!Fight.getBlueTeam().hasTeamLeader() || !Fight.getRedTeam().hasTeamLeader())
|
|
||||||
return;
|
int blueLeader = 0;
|
||||||
SteamwarUser blueLeader = SteamwarUser.get(Fight.getBlueTeam().getLeader().getPlayer().getUniqueId());
|
int redLeader = 0;
|
||||||
SteamwarUser redLeader = SteamwarUser.get(Fight.getRedTeam().getLeader().getPlayer().getUniqueId());
|
if(Fight.getBlueTeam().getLeader() != null)
|
||||||
|
blueLeader = SteamwarUser.get(Fight.getBlueTeam().getLeader().getPlayer().getUniqueId()).getId();
|
||||||
|
if(Fight.getRedTeam().getLeader() != null)
|
||||||
|
redLeader = SteamwarUser.get(Fight.getRedTeam().getLeader().getPlayer().getUniqueId()).getId();
|
||||||
|
|
||||||
int win = 0;
|
int win = 0;
|
||||||
double blueResult;
|
double blueResult;
|
||||||
if(winner == Fight.getBlueTeam()) {
|
if(winner == Fight.getBlueTeam()) {
|
||||||
@ -65,7 +69,8 @@ public class FightStatistics {
|
|||||||
blueResult = 0.5;
|
blueResult = 0.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
Integer blueSchem, redSchem;
|
Integer blueSchem;
|
||||||
|
Integer redSchem;
|
||||||
try{
|
try{
|
||||||
blueSchem = Schematic.getSchemFromDB(Fight.getBlueTeam().getSchematic()).getSchemID();
|
blueSchem = Schematic.getSchemFromDB(Fight.getBlueTeam().getSchematic()).getSchemID();
|
||||||
}catch(SecurityException e){
|
}catch(SecurityException e){
|
||||||
@ -85,7 +90,7 @@ public class FightStatistics {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
int fightId = create(gameMode, Bukkit.getWorlds().get(0).getName(), starttime, remainingTime,
|
int fightId = create(gameMode, Bukkit.getWorlds().get(0).getName(), starttime, remainingTime,
|
||||||
blueLeader.getId(), redLeader.getId(), blueSchem, redSchem, win, windescription);
|
blueLeader, redLeader, blueSchem, redSchem, win, windescription);
|
||||||
|
|
||||||
for (FightPlayer fp : Fight.getBlueTeam().getPlayers())
|
for (FightPlayer fp : Fight.getBlueTeam().getPlayers())
|
||||||
savePlayerStats(fp, fightId);
|
savePlayerStats(fp, fightId);
|
||||||
@ -96,16 +101,16 @@ public class FightStatistics {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(Config.Ranked){
|
if(Config.Ranked){
|
||||||
int blueElo = Elo.getElo(blueLeader.getId(), gameMode);
|
int blueElo = Elo.getElo(blueLeader, gameMode);
|
||||||
int redElo = Elo.getElo(redLeader.getId(), gameMode);
|
int redElo = Elo.getElo(redLeader, gameMode);
|
||||||
double redWinExpectation = 1 / (1 + Math.pow(10, (blueElo - redElo) / 400f));
|
double redWinExpectation = 1 / (1 + Math.pow(10, (blueElo - redElo) / 400f));
|
||||||
double blueWinExpectation = 1 / (1 + Math.pow(10, (redElo - blueElo) / 400f));
|
double blueWinExpectation = 1 / (1 + Math.pow(10, (redElo - blueElo) / 400f));
|
||||||
int newBlueElo = (int) Math.round(blueElo + K * (blueResult - blueWinExpectation));
|
int newBlueElo = (int) Math.round(blueElo + K * (blueResult - blueWinExpectation));
|
||||||
int newRedElo = (int) Math.round(redElo + K * (1 - blueResult - redWinExpectation));
|
int newRedElo = (int) Math.round(redElo + K * (1 - blueResult - redWinExpectation));
|
||||||
Elo.setElo(blueLeader.getId(), gameMode, newBlueElo);
|
Elo.setElo(blueLeader, gameMode, newBlueElo);
|
||||||
Elo.setElo(redLeader.getId(), gameMode, newRedElo);
|
Elo.setElo(redLeader, gameMode, newRedElo);
|
||||||
Bukkit.broadcastMessage(FightSystem.PREFIX + "§7ELO von " + Fight.getBlueTeam().getPrefix() + blueLeader.getUserName() + "§8: §7" + blueElo + "§8»§e" + newBlueElo);
|
Bukkit.broadcastMessage(FightSystem.PREFIX + "§7ELO von " + Fight.getBlueTeam().getPrefix() + Fight.getBlueTeam().getLeader().getPlayer().getName() + "§8: §7" + blueElo + "§8»§e" + newBlueElo);
|
||||||
Bukkit.broadcastMessage(FightSystem.PREFIX + "§7ELO von " + Fight.getRedTeam().getPrefix() + redLeader.getUserName() + "§8: §7" + redElo + "§8»§e" + newRedElo);
|
Bukkit.broadcastMessage(FightSystem.PREFIX + "§7ELO von " + Fight.getRedTeam().getPrefix() + Fight.getRedTeam().getLeader().getPlayer().getName() + "§8: §7" + redElo + "§8»§e" + newRedElo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,55 +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.utils;
|
|
||||||
|
|
||||||
import org.bukkit.Location;
|
|
||||||
|
|
||||||
public class Region {
|
|
||||||
|
|
||||||
private Region(){}
|
|
||||||
|
|
||||||
public static boolean isInRange(Location location, int minX, int minY, int minZ, int xRange, int yRange, int zRange, int margin) {
|
|
||||||
return isInRegion(location, minX, minY, minZ, minX + xRange, minY + yRange, minZ + zRange, margin);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isInRegion(Location location, int minX, int minY, int minZ, int maxX, int maxY, int maxZ, int margin) {
|
|
||||||
return isIn2DRegion(location, minX, minZ, maxX, maxZ, margin) && inRange(location.getBlockY(), minY, maxY, margin);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isIn2DRange(Location location, int minX, int minZ, int xRange, int zRange, int margin){
|
|
||||||
return isIn2DRegion(location, minX, minZ, minX + xRange, minZ + zRange, margin);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean isIn2DRegion(Location location, int minX, int minZ, int maxX, int maxZ, int margin){
|
|
||||||
return inRange(location.getBlockX(), minX, maxX, margin) && inRange(location.getBlockZ(), minZ, maxZ, margin);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isIn2DRegion(Location location, int minX, int minZ, int maxX, int maxZ){
|
|
||||||
return inRange(location.getBlockX(), minX, maxX) && inRange(location.getBlockZ(), minZ, maxZ);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean inRange(double value, int min, int max, int margin){
|
|
||||||
return inRange(value, min-margin, max+margin);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean inRange(double value, int min, int max){
|
|
||||||
return min <= value && value <= max;
|
|
||||||
}
|
|
||||||
}
|
|
@ -232,10 +232,10 @@ public class TechHider implements IStateDependent {
|
|||||||
if(DISABLED)
|
if(DISABLED)
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
List<ChunkPos> chunksToReload = new ArrayList<>();
|
List<ChunkPos> chunksToReload = new ArrayList<>();
|
||||||
for(int x = ITechHider.arenaMinX; x <= ITechHider.arenaMaxX; x++)
|
Config.ArenaRegion.forEachChunk((x, z) -> {
|
||||||
for(int z = ITechHider.arenaMinZ; z <= ITechHider.arenaMaxZ; z++)
|
if(!bypass(p, x, z))
|
||||||
if(!bypass(p, x, z))
|
chunksToReload.add(new ChunkPos(x, z));
|
||||||
chunksToReload.add(new ChunkPos(x, z));
|
});
|
||||||
return chunksToReload;
|
return chunksToReload;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +24,6 @@ import de.steamwar.fightsystem.fight.Fight;
|
|||||||
import de.steamwar.fightsystem.fight.FightTeam;
|
import de.steamwar.fightsystem.fight.FightTeam;
|
||||||
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.utils.Region;
|
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||||
@ -74,7 +73,7 @@ public class WinconditionPercentSystem extends Wincondition implements Listener,
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void check(EntityExplodeEvent event) {
|
private void check(EntityExplodeEvent event) {
|
||||||
if(!Region.isInRange(event.getEntity().getLocation(), team.getCornerX(), team.getCornerY(), team.getCornerZ(), Config.SchemsizeX, Config.SchemsizeY, Config.SchemsizeZ, Config.BorderFromSchematic)){
|
if(!team.getExtendRegion().inRegion(event.getEntity().getLocation())){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren