Refactoring for Multiversion-API
Dieser Commit ist enthalten in:
Ursprung
065dc58f98
Commit
595e7a0ea4
@ -32,6 +32,11 @@
|
||||
<artifactId>FightSystem_8</artifactId>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>steamwar</groupId>
|
||||
<artifactId>FightSystem_API</artifactId>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>steamwar</groupId>
|
||||
<artifactId>FAWE</artifactId>
|
||||
|
@ -33,5 +33,10 @@
|
||||
<version>1.8</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>steamwar</groupId>
|
||||
<artifactId>FightSystem_API</artifactId>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
37
FightSystem_API/pom.xml
Normale Datei
37
FightSystem_API/pom.xml
Normale Datei
@ -0,0 +1,37 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>steamwar</groupId>
|
||||
<artifactId>FightSystem</artifactId>
|
||||
<version>1.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>FightSystem_API</artifactId>
|
||||
<version>1.0</version>
|
||||
|
||||
<build>
|
||||
<sourceDirectory>src</sourceDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src</directory>
|
||||
<excludes>
|
||||
<exclude>**/*.java</exclude>
|
||||
<exclude>**/*.kt</exclude>
|
||||
</excludes>
|
||||
</resource>
|
||||
</resources>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>steamwar</groupId>
|
||||
<artifactId>Spigot</artifactId>
|
||||
<version>1.12</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
314
FightSystem_API/src/de/steamwar/fightsystem/Config.java
Normale Datei
314
FightSystem_API/src/de/steamwar/fightsystem/Config.java
Normale Datei
@ -0,0 +1,314 @@
|
||||
package de.steamwar.fightsystem;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import de.steamwar.sql.Event;
|
||||
import de.steamwar.sql.EventFight;
|
||||
import de.steamwar.sql.Team;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class Config {
|
||||
|
||||
private Config(){}
|
||||
|
||||
//Fight sequence durations
|
||||
public static final int NoPlayerOnlineDuration;
|
||||
public static final int SetupDuration;
|
||||
public static final int PreFightDuration;
|
||||
public static final int SpectatorDuration;
|
||||
|
||||
//arena parameter
|
||||
public static final int SchemsizeX;
|
||||
public static final int SchemsizeY;
|
||||
public static final int SchemsizeZ;
|
||||
public static final Vector Schemsize;
|
||||
public static final int TeamBlueCornerX;
|
||||
public static final int TeamBlueCornerY;
|
||||
public static final int TeamBlueCornerZ;
|
||||
public static final Vector TeamBlueCorner;
|
||||
public static final Location TeamBlueSpawn;
|
||||
public static final Vector TeamBluePaste;
|
||||
public static final int TeamRedCornerX;
|
||||
public static final int TeamRedCornerY;
|
||||
public static final int TeamRedCornerZ;
|
||||
public static final Vector TeamRedCorner;
|
||||
public static final Location TeamRedSpawn;
|
||||
public static final Vector TeamRedPaste;
|
||||
private static final int TeamBluetoReddistanceX;
|
||||
private static final int TeamBluetoReddistanceY;
|
||||
public static final int TeamBluetoReddistanceZ;
|
||||
public static final Location SpecSpawn;
|
||||
public static final int underArenaBorder;
|
||||
public static final int BorderFromSchematic;
|
||||
public static final int upperArenaBorder;
|
||||
public static final boolean AlignWater;
|
||||
public static final int WaterDepth;
|
||||
private static final int Schem2BorderX;
|
||||
private static final int Schem2BorderZ;
|
||||
public static final int ArenaMinX;
|
||||
public static final int ArenaMinZ;
|
||||
public static final int ArenaMaxX;
|
||||
public static final int ArenaMaxZ;
|
||||
|
||||
//schematic parameter
|
||||
public static final boolean OnlyPublicSchematics;
|
||||
public static final String SchematicDirectory;
|
||||
public static final de.steamwar.sql.SchematicType SchematicType;
|
||||
public static final boolean TeamRedRotate;
|
||||
public static final boolean TeamBlueRotate;
|
||||
|
||||
//team parameter
|
||||
public static final String TeamRedName;
|
||||
public static final String TeamBlueName;
|
||||
public static final String TeamRedPrefix;
|
||||
public static final String TeamBluePrefix;
|
||||
public static final String GameName;
|
||||
public static final String TeamChatDetection;
|
||||
public static final UUID BlueLeader;
|
||||
public static final UUID RedLeader;
|
||||
|
||||
//Active win conditions
|
||||
public static final boolean Timeout;
|
||||
public static final boolean AllDead;
|
||||
public static final boolean CaptainDead;
|
||||
public static final boolean PercentSystem;
|
||||
public static final boolean Entern;
|
||||
public static final boolean TechKO;
|
||||
public static final boolean WaterTechKO;
|
||||
|
||||
//win condition parameters
|
||||
public static final int TimeoutTime;
|
||||
public static final int EnterPhaseBegin;
|
||||
public static final double PercentWin;
|
||||
|
||||
//default kits
|
||||
public static final String MemberDefault;
|
||||
public static final String LeaderDefault;
|
||||
|
||||
//tech hider parameter
|
||||
public static final List<Integer> HiddenBlocks;
|
||||
public static final List<String> HiddenBlockEntities;
|
||||
public static final int ObfuscateWith;
|
||||
|
||||
//event parameter
|
||||
private static final int EventKampfID;
|
||||
public static final int EventTeamBlueID;
|
||||
public static final int EventTeamRedID;
|
||||
public static final boolean BothTeamsPublic;
|
||||
public static final int MaximumTeamMembers;
|
||||
|
||||
static{
|
||||
File worldConfigFile = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "config.yml");
|
||||
if(!worldConfigFile.exists()) {
|
||||
Bukkit.getLogger().log(Level.SEVERE, "Weltconfig fehlt!");
|
||||
IFightSystem.shutdown(null);
|
||||
}
|
||||
if(!new File(IFightSystem.getPlugin().getDataFolder(), "config.yml").exists()) {
|
||||
IFightSystem.getPlugin().saveDefaultConfig();
|
||||
Bukkit.getLogger().log(Level.SEVERE, "Arenaconfig fehlt!");
|
||||
IFightSystem.shutdown(null);
|
||||
}
|
||||
FileConfiguration config = IFightSystem.getPlugin().getConfig();
|
||||
FileConfiguration worldconfig = YamlConfiguration.loadConfiguration(worldConfigFile);
|
||||
|
||||
NoPlayerOnlineDuration = config.getInt("Times.NoPlayersOnlineDuration");
|
||||
SetupDuration = config.getInt("Times.SetupDuration");
|
||||
PreFightDuration = config.getInt("Times.PreFightDuration");
|
||||
SpectatorDuration = config.getInt("Times.SpectatorDuration");
|
||||
|
||||
int schemsizeX = worldconfig.getInt("Arena.Schemsize.x");
|
||||
int schemsizeY = worldconfig.getInt("Arena.Schemsize.y");
|
||||
int schemsizeZ = worldconfig.getInt("Arena.Schemsize.z");
|
||||
int teamBlueCornerX = worldconfig.getInt("Arena.TeamBlueCorner.x");
|
||||
int teamBlueCornerY = worldconfig.getInt("Arena.TeamBlueCorner.y");
|
||||
int teamBlueCornerZ = worldconfig.getInt("Arena.TeamBlueCorner.z");
|
||||
TeamBluetoReddistanceX = worldconfig.getInt("Arena.TeamBluetoReddistance.x");
|
||||
TeamBluetoReddistanceY = worldconfig.getInt("Arena.TeamBluetoReddistance.y");
|
||||
TeamBluetoReddistanceZ = worldconfig.getInt("Arena.TeamBluetoReddistance.z");
|
||||
Schem2BorderX = worldconfig.getInt("Arena.Schem2Border.x");
|
||||
Schem2BorderZ = worldconfig.getInt("Arena.Schem2Border.z");
|
||||
underArenaBorder = worldconfig.getInt("Arena.underArenaBorder");
|
||||
BorderFromSchematic = worldconfig.getInt("Arena.BorderFromSchematic");
|
||||
AlignWater = worldconfig.getBoolean("Arena.AlignWater");
|
||||
WaterDepth = worldconfig.getInt("Arena.WaterDepth");
|
||||
|
||||
SchematicDirectory = config.getString("Schematic.Directory");
|
||||
SchematicType = de.steamwar.sql.SchematicType.fromDB(config.getString("Schematic.SchematicType"));
|
||||
boolean rotate = config.getBoolean("Schematic.Rotate");
|
||||
|
||||
TeamRedPrefix = config.getString("Output.TeamRedPrefix");
|
||||
TeamBluePrefix = config.getString("Output.TeamBluePrefix");
|
||||
GameName = config.getString("Output.GameName");
|
||||
TeamChatDetection = config.getString("Output.TeamChatDetection");
|
||||
|
||||
Timeout = config.getBoolean("WinConditions.Timeout");
|
||||
AllDead = config.getBoolean("WinConditions.AllDead");
|
||||
CaptainDead = config.getBoolean("WinConditions.CaptainDead");
|
||||
PercentSystem = config.getBoolean("WinConditions.PercentSystem");
|
||||
Entern = config.getBoolean("WinConditions.Entern");
|
||||
TechKO = config.getBoolean("WinConditions.TechKO");
|
||||
WaterTechKO = config.getBoolean("WinConditions.WaterTechKO");
|
||||
|
||||
TimeoutTime = config.getInt("WinConditionParams.TimeoutTime");
|
||||
EnterPhaseBegin = config.getInt("WinConditionParams.EnterPhaseBegin");
|
||||
PercentWin = config.getDouble("WinConditionParams.PercentWin");
|
||||
|
||||
MemberDefault = config.getString("Kits.MemberDefault");
|
||||
LeaderDefault = config.getString("Kits.LeaderDefault");
|
||||
|
||||
HiddenBlocks = Collections.unmodifiableList(config.getIntegerList("Techhider.HiddenBlocks"));
|
||||
HiddenBlockEntities = Collections.unmodifiableList(config.getStringList("Techhider.HiddenBlockEntities"));
|
||||
ObfuscateWith = config.getInt("Techhider.ObfuscateWith");
|
||||
|
||||
if(schemsizeX < 0){
|
||||
SchemsizeX = -schemsizeX;
|
||||
TeamBlueCornerX = teamBlueCornerX - SchemsizeX;
|
||||
}else{
|
||||
SchemsizeX = schemsizeX;
|
||||
TeamBlueCornerX = teamBlueCornerX;
|
||||
}
|
||||
if(schemsizeY < 0){
|
||||
SchemsizeY = -schemsizeY;
|
||||
TeamBlueCornerY = teamBlueCornerY - SchemsizeY;
|
||||
}else{
|
||||
SchemsizeY = schemsizeY;
|
||||
TeamBlueCornerY = teamBlueCornerY;
|
||||
}
|
||||
if(schemsizeZ < 0){
|
||||
SchemsizeZ = -schemsizeZ;
|
||||
TeamBlueCornerZ = teamBlueCornerZ - SchemsizeZ;
|
||||
}else{
|
||||
SchemsizeZ = schemsizeZ;
|
||||
TeamBlueCornerZ = teamBlueCornerZ;
|
||||
}
|
||||
|
||||
upperArenaBorder = TeamBlueCornerY + SchemsizeY + BorderFromSchematic;
|
||||
|
||||
TeamRedCornerX = TeamBluetoReddistanceX + TeamBlueCornerX;
|
||||
TeamRedCornerY = TeamBluetoReddistanceY + TeamBlueCornerY;
|
||||
TeamRedCornerZ = TeamBluetoReddistanceZ + TeamBlueCornerZ;
|
||||
|
||||
int teamBluePasteX = TeamBlueCornerX + SchemsizeX / 2;
|
||||
int teamBluePasteZ = TeamBlueCornerZ + SchemsizeZ / 2;
|
||||
int teamRedPasteX = teamBluePasteX + TeamBluetoReddistanceX;
|
||||
int teamRedPasteZ = teamBluePasteZ + TeamBluetoReddistanceZ;
|
||||
|
||||
TeamBluePaste = new Vector(teamBluePasteX, TeamBlueCornerY, teamBluePasteZ);
|
||||
TeamRedPaste = new Vector(teamRedPasteX, TeamRedCornerY, teamRedPasteZ);
|
||||
Schemsize = new Vector(SchemsizeX, SchemsizeY, SchemsizeZ);
|
||||
TeamBlueCorner = new Vector(TeamBlueCornerX, TeamBlueCornerY, TeamBlueCornerZ);
|
||||
TeamRedCorner = new Vector(TeamRedCornerX, TeamRedCornerY, TeamRedCornerZ);
|
||||
|
||||
World world = Bukkit.getWorlds().get(0);
|
||||
TeamBlueSpawn = new Location(world, teamBluePasteX + 0.5, TeamBlueCornerY + (double)SchemsizeY, teamBluePasteZ + 0.5);
|
||||
TeamRedSpawn = new Location(world, teamRedPasteX + 0.5, TeamRedCornerY + (double)SchemsizeY, teamRedPasteZ + 0.5);
|
||||
SpecSpawn = new Location(world,
|
||||
teamBluePasteX + TeamBluetoReddistanceX/2.0,
|
||||
TeamBlueCornerY + TeamBluetoReddistanceY/2.0 + SchemsizeY/2.0,
|
||||
teamBluePasteZ + TeamBluetoReddistanceZ/2.0);
|
||||
|
||||
boolean teamRedRotate;
|
||||
boolean teamBlueRotate;
|
||||
if(TeamBluetoReddistanceX > 0){
|
||||
ArenaMinX = TeamBlueCornerX - Schem2BorderX;
|
||||
ArenaMaxX = TeamRedCornerX + SchemsizeX + Schem2BorderX;
|
||||
teamRedRotate = true;
|
||||
teamBlueRotate = false;
|
||||
}else{
|
||||
ArenaMinX = TeamRedCornerX - Schem2BorderX;
|
||||
ArenaMaxX = TeamBlueCornerX + SchemsizeX + Schem2BorderX;
|
||||
teamRedRotate = false;
|
||||
teamBlueRotate = true;
|
||||
}
|
||||
if(TeamBluetoReddistanceZ > 0){
|
||||
ArenaMinZ = TeamBlueCornerZ - Schem2BorderZ;
|
||||
ArenaMaxZ = TeamRedCornerZ + SchemsizeZ + Schem2BorderZ;
|
||||
teamRedRotate = true;
|
||||
teamBlueRotate = false;
|
||||
}else{
|
||||
ArenaMinZ = TeamRedCornerZ - Schem2BorderZ;
|
||||
ArenaMaxZ = TeamBlueCornerZ + SchemsizeZ + Schem2BorderZ;
|
||||
if(TeamBluetoReddistanceZ != 0){
|
||||
teamRedRotate = false;
|
||||
teamBlueRotate = true;
|
||||
}
|
||||
}
|
||||
if(!rotate){
|
||||
teamRedRotate = false;
|
||||
teamBlueRotate = false;
|
||||
}
|
||||
TeamRedRotate = teamRedRotate;
|
||||
TeamBlueRotate = teamBlueRotate;
|
||||
|
||||
EventKampfID = Integer.parseInt(System.getProperty("fightID", "0"));
|
||||
if(event()){
|
||||
EventFight eventFight = EventFight.get(EventKampfID);
|
||||
if(eventFight == null){
|
||||
Bukkit.getLogger().log(Level.SEVERE, "Failed to load EventFight");
|
||||
IFightSystem.shutdown(null);
|
||||
}
|
||||
|
||||
assert eventFight != null;
|
||||
Team team1 = Team.get(eventFight.getTeamBlue());
|
||||
Team team2 = Team.get(eventFight.getTeamRed());
|
||||
|
||||
if(team1 == null || team2 == null){
|
||||
Bukkit.getLogger().log(Level.SEVERE, "Failed to load Team");
|
||||
IFightSystem.shutdown(null);
|
||||
}
|
||||
|
||||
assert team1 != null;
|
||||
assert team2 != null;
|
||||
TeamBlueName = team1.getTeamKuerzel();
|
||||
TeamRedName = team2.getTeamKuerzel();
|
||||
EventTeamBlueID = team1.getTeamId();
|
||||
EventTeamRedID = team2.getTeamId();
|
||||
BothTeamsPublic = EventTeamRedID == 0 && EventTeamBlueID == 0;
|
||||
|
||||
IFightSystem.setEventFight(eventFight);
|
||||
|
||||
Event event = Event.get(eventFight.getEventID());
|
||||
MaximumTeamMembers = event.getMaximumTeamMembers();
|
||||
if(BothTeamsPublic)
|
||||
OnlyPublicSchematics = true;
|
||||
else
|
||||
OnlyPublicSchematics = event.publicSchemsOnly();
|
||||
}else{
|
||||
//No event
|
||||
TeamRedName = config.getString("Output.TeamRedName");
|
||||
TeamBlueName = config.getString("Output.TeamBlueName");
|
||||
OnlyPublicSchematics = config.getBoolean("Schematic.OnlyPublicSchematics");
|
||||
EventTeamBlueID = 0;
|
||||
EventTeamRedID = 0;
|
||||
BothTeamsPublic = true;
|
||||
MaximumTeamMembers = Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
String blueLeader = System.getProperty("blueLeader", null);
|
||||
String redLeader = System.getProperty("redLeader", null);
|
||||
if(blueLeader != null)
|
||||
BlueLeader = UUID.fromString(blueLeader);
|
||||
else
|
||||
BlueLeader = null;
|
||||
if(redLeader != null)
|
||||
RedLeader = UUID.fromString(redLeader);
|
||||
else
|
||||
RedLeader = null;
|
||||
}
|
||||
|
||||
public static boolean event(){
|
||||
return EventKampfID >= 1;
|
||||
}
|
||||
public static boolean test(){
|
||||
return EventKampfID == -1;
|
||||
}
|
||||
}
|
52
FightSystem_API/src/de/steamwar/fightsystem/IFightSystem.java
Normale Datei
52
FightSystem_API/src/de/steamwar/fightsystem/IFightSystem.java
Normale Datei
@ -0,0 +1,52 @@
|
||||
package de.steamwar.fightsystem;
|
||||
|
||||
import de.steamwar.sql.EventFight;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class IFightSystem {
|
||||
private IFightSystem(){}
|
||||
|
||||
private static Plugin plugin;
|
||||
private static String prefix;
|
||||
private static EventFight eventFight;
|
||||
private static boolean entern = false;
|
||||
private static Player eventLeiter;
|
||||
|
||||
public static void init(Plugin plugin, String prefix){
|
||||
IFightSystem.plugin = plugin;
|
||||
IFightSystem.prefix = prefix;
|
||||
}
|
||||
static void setEventFight(EventFight ef){
|
||||
eventFight = ef;
|
||||
}
|
||||
static void setEntern(boolean entern){
|
||||
IFightSystem.entern = entern;
|
||||
}
|
||||
static void setEventLeiter(Player el){
|
||||
eventLeiter = el;
|
||||
}
|
||||
|
||||
public static Plugin getPlugin(){
|
||||
return plugin;
|
||||
}
|
||||
public static String getPrefix(){
|
||||
return prefix;
|
||||
}
|
||||
public static EventFight getEventFight(){
|
||||
return eventFight;
|
||||
}
|
||||
public static boolean isEntern(){
|
||||
return entern;
|
||||
}
|
||||
public static Player getEventLeiter(){
|
||||
return eventLeiter;
|
||||
}
|
||||
public static void shutdown(String reason){
|
||||
if(reason != null)
|
||||
Bukkit.broadcastMessage(reason);
|
||||
Bukkit.getOnlinePlayers().forEach(player -> player.kickPlayer(null));
|
||||
Bukkit.shutdown();
|
||||
}
|
||||
}
|
23
FightSystem_API/src/de/steamwar/fightsystem/fight/IFight.java
Normale Datei
23
FightSystem_API/src/de/steamwar/fightsystem/fight/IFight.java
Normale Datei
@ -0,0 +1,23 @@
|
||||
package de.steamwar.fightsystem.fight;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class IFight {
|
||||
private IFight(){}
|
||||
|
||||
private static IFightTeam redTeam;
|
||||
private static IFightTeam blueTeam;
|
||||
|
||||
static void init(IFightTeam redTeam, IFightTeam blueTeam){
|
||||
IFight.redTeam = redTeam;
|
||||
IFight.blueTeam = blueTeam;
|
||||
}
|
||||
|
||||
public static IFightTeam getPlayerTeam(Player player) {
|
||||
if(redTeam.isPlayerInTeam(player))
|
||||
return redTeam;
|
||||
if(blueTeam.isPlayerInTeam(player))
|
||||
return blueTeam;
|
||||
return null;
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package de.steamwar.fightsystem.fight;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public interface IFightTeam {
|
||||
|
||||
boolean isBlue();
|
||||
boolean isPlayerInTeam(Player player);
|
||||
}
|
122
FightSystem_API/src/de/steamwar/fightsystem/utils/ITechHider.java
Normale Datei
122
FightSystem_API/src/de/steamwar/fightsystem/utils/ITechHider.java
Normale Datei
@ -0,0 +1,122 @@
|
||||
package de.steamwar.fightsystem.utils;
|
||||
|
||||
import com.google.common.primitives.Bytes;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.IFightSystem;
|
||||
import de.steamwar.fightsystem.fight.IFight;
|
||||
import de.steamwar.fightsystem.fight.IFightTeam;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ITechHider {
|
||||
private ITechHider (){}
|
||||
|
||||
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;
|
||||
private static int arenaMinX;
|
||||
private static int arenaMaxX;
|
||||
private static int arenaMinZ;
|
||||
private static int arenaMaxZ;
|
||||
|
||||
static{
|
||||
blueMinX = ITechHider.posToChunk(Config.TeamBlueCornerX);
|
||||
blueMaxX = ITechHider.posToChunk(Config.TeamBlueCornerX + Config.SchemsizeX) + 1;
|
||||
blueMinZ = ITechHider.posToChunk(Config.TeamBlueCornerZ);
|
||||
blueMaxZ = ITechHider.posToChunk(Config.TeamBlueCornerZ + Config.SchemsizeZ) + 1;
|
||||
redMinX = ITechHider.posToChunk(Config.TeamRedCornerX);
|
||||
redMaxX = ITechHider.posToChunk(Config.TeamRedCornerX + Config.SchemsizeX) + 1;
|
||||
redMinZ = ITechHider.posToChunk(Config.TeamRedCornerZ);
|
||||
redMaxZ = ITechHider.posToChunk(Config.TeamRedCornerZ + Config.SchemsizeZ) + 1;
|
||||
arenaMinX = ITechHider.posToChunk(Config.ArenaMinX);
|
||||
arenaMaxX = ITechHider.posToChunk(Config.ArenaMaxX) + 1;
|
||||
arenaMinZ = ITechHider.posToChunk(Config.ArenaMinZ);
|
||||
arenaMaxZ = ITechHider.posToChunk(Config.ArenaMaxZ) + 1;
|
||||
}
|
||||
|
||||
static boolean bypass(Player p, int chunkX, int chunkZ){
|
||||
if(p == IFightSystem.getEventLeiter())
|
||||
return true;
|
||||
|
||||
IFightTeam ft = IFight.getPlayerTeam(p);
|
||||
if(ft == null){
|
||||
//Außerhalb der Arena
|
||||
return arenaMinX > chunkX ||
|
||||
chunkX > arenaMaxX ||
|
||||
arenaMinZ > chunkZ ||
|
||||
chunkZ > arenaMaxZ;
|
||||
}else if(ft.isBlue()){
|
||||
return IFightSystem.isEntern() ||
|
||||
redMinX > chunkX ||
|
||||
chunkX > redMaxX ||
|
||||
redMinZ > chunkZ ||
|
||||
chunkZ > redMaxZ;
|
||||
}else{
|
||||
return IFightSystem.isEntern() ||
|
||||
blueMinX > chunkX ||
|
||||
chunkX > blueMaxX ||
|
||||
blueMinZ > chunkZ ||
|
||||
chunkZ > blueMaxZ;
|
||||
}
|
||||
}
|
||||
|
||||
static int posToChunk(int c){
|
||||
int chunk = c / 16;
|
||||
if(c<0)
|
||||
chunk--;
|
||||
return chunk;
|
||||
}
|
||||
|
||||
static int readVarInt(byte[] array, int startPos) {
|
||||
int numRead = 0;
|
||||
int result = 0;
|
||||
byte read;
|
||||
do {
|
||||
read = array[startPos + numRead];
|
||||
int value = (read & 0b01111111);
|
||||
result |= (value << (7 * numRead));
|
||||
|
||||
numRead++;
|
||||
if (numRead > 5) {
|
||||
break;
|
||||
}
|
||||
} while ((read & 0b10000000) != 0);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static int readVarIntLength(byte[] array, int startPos) {
|
||||
int numRead = 0;
|
||||
byte read;
|
||||
do {
|
||||
read = array[startPos + numRead];
|
||||
numRead++;
|
||||
if (numRead > 5) {
|
||||
break;
|
||||
}
|
||||
} while ((read & 0b10000000) != 0);
|
||||
|
||||
return numRead;
|
||||
}
|
||||
|
||||
static byte[] writeVarInt(int value) {
|
||||
List<Byte> buffer = new ArrayList<>(5);
|
||||
do {
|
||||
byte temp = (byte)(value & 0b01111111);
|
||||
// Note: >>> means that the sign bit is shifted with the rest of the number rather than being left alone
|
||||
value >>>= 7;
|
||||
if (value != 0) {
|
||||
temp |= 0b10000000;
|
||||
}
|
||||
buffer.add(temp);
|
||||
} while (value != 0);
|
||||
return Bytes.toArray(buffer);
|
||||
}
|
||||
}
|
@ -63,5 +63,11 @@
|
||||
<version>1.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>steamwar</groupId>
|
||||
<artifactId>FightSystem_API</artifactId>
|
||||
<version>1.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
@ -8,7 +8,6 @@ import de.steamwar.fightsystem.fight.FightState;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.kit.KitManager;
|
||||
import de.steamwar.fightsystem.listener.*;
|
||||
import de.steamwar.fightsystem.utils.Config;
|
||||
import de.steamwar.fightsystem.utils.FightScoreboard;
|
||||
import de.steamwar.fightsystem.utils.TechHider;
|
||||
import de.steamwar.fightsystem.utils.WaterRemover;
|
||||
@ -29,15 +28,16 @@ public class FightSystem extends JavaPlugin {
|
||||
|
||||
private static FightState fightState = FightState.SETUP;
|
||||
private static int fightTime = 0;
|
||||
private static boolean entern = false;
|
||||
|
||||
private static EventFight eventFight;
|
||||
private static Player eventLeiter;
|
||||
@Override
|
||||
public void onLoad() {
|
||||
setPlugin(this);
|
||||
IFightSystem.init(this, PREFIX);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
setPlugin(this);
|
||||
Config.load();
|
||||
Fight.init();
|
||||
KitManager.loadAllKits();
|
||||
|
||||
new EntityDamageListener();
|
||||
@ -155,11 +155,11 @@ public class FightSystem extends JavaPlugin {
|
||||
|
||||
if(Config.event()){
|
||||
if(winFightTeam == null)
|
||||
eventFight.setErgebnis(0);
|
||||
getEventFight().setErgebnis(0);
|
||||
else if(winFightTeam.isBlue())
|
||||
eventFight.setErgebnis(1);
|
||||
getEventFight().setErgebnis(1);
|
||||
else
|
||||
eventFight.setErgebnis(2);
|
||||
getEventFight().setErgebnis(2);
|
||||
}
|
||||
|
||||
if(!Config.test())
|
||||
@ -173,7 +173,7 @@ public class FightSystem extends JavaPlugin {
|
||||
public static void setEntern(boolean entern) {
|
||||
final List<Pair<Integer, Integer>> chunksBlue = TechHider.prepareChunkReload(Fight.getBlueTeam().getPlayers().iterator().next().getPlayer());
|
||||
final List<Pair<Integer, Integer>> chunksRed = TechHider.prepareChunkReload(Fight.getRedTeam().getPlayers().iterator().next().getPlayer());
|
||||
FightSystem.entern = entern;
|
||||
IFightSystem.setEntern(entern);
|
||||
for(FightPlayer player : Fight.getBlueTeam().getPlayers()){
|
||||
TechHider.reloadChunks(player.getPlayer(), chunksBlue);
|
||||
}
|
||||
@ -207,20 +207,16 @@ public class FightSystem extends JavaPlugin {
|
||||
BasicListener.fightStateChange(state);
|
||||
}
|
||||
|
||||
public static void setEventFight(EventFight ef){
|
||||
eventFight = ef;
|
||||
}
|
||||
|
||||
public static void setEventLeiter(Player el){
|
||||
eventLeiter = el;
|
||||
IFightSystem.setEventLeiter(el);
|
||||
}
|
||||
|
||||
public static Player getEventLeiter(){
|
||||
return eventLeiter;
|
||||
return IFightSystem.getEventLeiter();
|
||||
}
|
||||
|
||||
public static EventFight getEventFight(){
|
||||
return eventFight;
|
||||
return IFightSystem.getEventFight();
|
||||
}
|
||||
|
||||
private static void setPlugin(FightSystem pl){
|
||||
@ -240,13 +236,10 @@ public class FightSystem extends JavaPlugin {
|
||||
}
|
||||
|
||||
public static boolean isEntern() {
|
||||
return entern;
|
||||
return IFightSystem.isEntern();
|
||||
}
|
||||
|
||||
public static void shutdown(String reason){
|
||||
if(reason != null)
|
||||
Bukkit.broadcastMessage(reason);
|
||||
Bukkit.getOnlinePlayers().forEach(player -> player.kickPlayer(null));
|
||||
Bukkit.shutdown();
|
||||
IFightSystem.shutdown(reason);
|
||||
}
|
||||
}
|
@ -5,7 +5,7 @@ import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightState;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.kit.KitManager;
|
||||
import de.steamwar.fightsystem.utils.Config;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.sql.Schematic;
|
||||
import de.steamwar.sql.SchematicType;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
|
@ -6,7 +6,7 @@ import de.steamwar.fightsystem.fight.FightPlayer;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.kit.Kit;
|
||||
import de.steamwar.fightsystem.kit.KitManager;
|
||||
import de.steamwar.fightsystem.utils.Config;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.inventory.SWInventory;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import de.steamwar.inventory.SWListInv;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package de.steamwar.fightsystem.countdown;
|
||||
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.utils.Config;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
public class EnternCountdown extends Countdown {
|
||||
|
@ -1,7 +1,7 @@
|
||||
package de.steamwar.fightsystem.countdown;
|
||||
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.utils.Config;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
|
||||
public class EventStartCountdown extends Countdown {
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
package de.steamwar.fightsystem.countdown;
|
||||
|
||||
import de.steamwar.fightsystem.utils.Config;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
public class NoPlayersOnlineCountdown extends Countdown {
|
||||
|
@ -1,7 +1,7 @@
|
||||
package de.steamwar.fightsystem.countdown;
|
||||
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.utils.Config;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
|
||||
public class PreRunningCountdown extends Countdown {
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package de.steamwar.fightsystem.countdown;
|
||||
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.utils.Config;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
public class SetupOverCountdown extends Countdown {
|
||||
|
@ -1,7 +1,7 @@
|
||||
package de.steamwar.fightsystem.countdown;
|
||||
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.utils.Config;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
|
||||
public class SpectateOverCountdown extends Countdown {
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package de.steamwar.fightsystem.countdown;
|
||||
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.utils.Config;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
public class TimeOverCountdown extends Countdown {
|
||||
|
@ -1,17 +1,20 @@
|
||||
package de.steamwar.fightsystem.fight;
|
||||
|
||||
import de.steamwar.fightsystem.utils.Config;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class Fight {
|
||||
|
||||
private Fight(){}
|
||||
|
||||
public static final FightTeam redTeam = new FightTeam(Config.TeamRedName, Config.TeamRedPrefix, Config.TeamRedSpawn, Config.TeamRedPaste, Config.TeamRedCorner, Config.TeamRedRotate, false, Config.RedLeader);
|
||||
public static final FightTeam blueTeam = new FightTeam(Config.TeamBlueName, Config.TeamBluePrefix, Config.TeamBlueSpawn, Config.TeamBluePaste, Config.TeamBlueCorner, Config.TeamBlueRotate, true, Config.BlueLeader);
|
||||
|
||||
public static void init(){
|
||||
IFight.init(redTeam, blueTeam);
|
||||
}
|
||||
|
||||
public static FightTeam getPlayerTeam(Player player) {
|
||||
if(redTeam.isPlayerInTeam(player))
|
||||
return redTeam;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package de.steamwar.fightsystem.fight;
|
||||
|
||||
import de.steamwar.fightsystem.kit.KitManager;
|
||||
import de.steamwar.fightsystem.utils.Config;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.kit.Kit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
@ -4,6 +4,7 @@ import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import de.steamwar.core.Core;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.kit.KitManager;
|
||||
import de.steamwar.fightsystem.utils.*;
|
||||
@ -23,7 +24,7 @@ import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
|
||||
public class FightTeam {
|
||||
public class FightTeam implements IFightTeam{
|
||||
|
||||
private FightPlayer leader;
|
||||
private final UUID designatedLeader;
|
||||
@ -97,6 +98,7 @@ public class FightTeam {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlayerInTeam(Player player) {
|
||||
for(FightPlayer fightPlayer : players) {
|
||||
if(fightPlayer.getPlayer().equals(player))
|
||||
@ -128,8 +130,8 @@ public class FightTeam {
|
||||
player.setGameMode(GameMode.SURVIVAL);
|
||||
player.teleport(spawn);
|
||||
if(KitManager.getKits(false).size() > 1)
|
||||
player.getInventory().setItem(1, new ItemBuilder(Material.LEATHER_CHESTPLATE).removeAllAtributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName("§eKit wählen").build());
|
||||
player.getInventory().setItem(7, new ItemBuilder(Material.BEACON).removeAllAtributs().setDisplayName("§eRespawn").build());
|
||||
player.getInventory().setItem(1, new ItemBuilder(Material.LEATHER_CHESTPLATE).removeAllAttributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName("§eKit wählen").build());
|
||||
player.getInventory().setItem(7, new ItemBuilder(Material.BEACON).removeAllAttributs().setDisplayName("§eRespawn").build());
|
||||
TechHider.reloadChunks(player, chunksToReload);
|
||||
return fightPlayer;
|
||||
}
|
||||
@ -164,6 +166,7 @@ public class FightTeam {
|
||||
return leader != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBlue(){
|
||||
return blue;
|
||||
}
|
||||
@ -180,15 +183,15 @@ public class FightTeam {
|
||||
leader.setKit(KitManager.getKitByName(Config.LeaderDefault));
|
||||
Inventory inventory = leader.getPlayer().getInventory();
|
||||
if (KitManager.getKits(true).size() > 1)
|
||||
inventory.setItem(1, new ItemBuilder(Material.LEATHER_CHESTPLATE).removeAllAtributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName("§eKit wählen").build());
|
||||
inventory.setItem(1, new ItemBuilder(Material.LEATHER_CHESTPLATE).removeAllAttributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName("§eKit wählen").build());
|
||||
else
|
||||
inventory.setItem(1, new ItemBuilder(Material.AIR).build());
|
||||
if(!Config.event()){
|
||||
inventory.setItem(2, new ItemBuilder(Material.PAPER).removeAllAtributs().setDisplayName("§eSpieler einladen").build());
|
||||
inventory.setItem(3, new ItemBuilder(Material.FIREWORK_CHARGE).removeAllAtributs().setDisplayName("§cSpieler rauswerfen").build());
|
||||
inventory.setItem(4, new ItemBuilder(Material.INK_SACK, (short) 10).removeAllAtributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName("§cNicht bereit").build());
|
||||
inventory.setItem(2, new ItemBuilder(Material.PAPER).removeAllAttributs().setDisplayName("§eSpieler einladen").build());
|
||||
inventory.setItem(3, new ItemBuilder(Material.FIREWORK_CHARGE).removeAllAttributs().setDisplayName("§cSpieler rauswerfen").build());
|
||||
inventory.setItem(4, new ItemBuilder(Material.INK_SACK, (short) 10).removeAllAttributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName("§cNicht bereit").build());
|
||||
}
|
||||
inventory.setItem(0, new ItemBuilder(Material.CAULDRON_ITEM).removeAllAtributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName("§e" + Config.GameName + " wählen").build());
|
||||
inventory.setItem(0, new ItemBuilder(Material.CAULDRON_ITEM).removeAllAttributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName("§e" + Config.GameName + " wählen").build());
|
||||
}
|
||||
|
||||
public Set<FightPlayer> getPlayers() {
|
||||
@ -267,13 +270,13 @@ public class FightTeam {
|
||||
|
||||
this.ready = ready;
|
||||
if(ready) {
|
||||
l.getInventory().setItem(4, new ItemBuilder(Material.INK_SACK, (short) 8).removeAllAtributs().addEnchantment(Enchantment.DURABILITY,1 ).setDisplayName("§aBereit").build());
|
||||
l.getInventory().setItem(4, new ItemBuilder(Material.INK_SACK, (short) 8).removeAllAttributs().addEnchantment(Enchantment.DURABILITY,1 ).setDisplayName("§aBereit").build());
|
||||
broadcast(FightSystem.PREFIX + "§aEuer Team ist nun bereit!");
|
||||
if(Fight.getOpposite(this).isReady() || Config.test()) {
|
||||
FightSystem.setPreRunningState();
|
||||
}
|
||||
} else {
|
||||
l.getInventory().setItem(4, new ItemBuilder(Material.INK_SACK, (short) 10).removeAllAtributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName("§cNicht bereit").build());
|
||||
l.getInventory().setItem(4, new ItemBuilder(Material.INK_SACK, (short) 10).removeAllAttributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName("§cNicht bereit").build());
|
||||
broadcast(FightSystem.PREFIX + "§cEuer Team ist nicht mehr bereit!");
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightPlayer;
|
||||
import de.steamwar.fightsystem.fight.FightState;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.utils.Config;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -25,6 +25,18 @@ public class EventJoinListener extends BasicListener {
|
||||
else if(user.getTeam() == Config.EventTeamRedID)
|
||||
team = Fight.getRedTeam();
|
||||
|
||||
if(Config.BothTeamsPublic){
|
||||
if(Fight.getRedTeam().getPlayers().size() < Fight.getBlueTeam().getPlayers().size())
|
||||
team = Fight.getRedTeam();
|
||||
else
|
||||
team = Fight.getBlueTeam();
|
||||
}else if(team == null){
|
||||
if(Config.EventTeamRedID == 0)
|
||||
team = Fight.getRedTeam();
|
||||
else if(Config.EventTeamBlueID == 0)
|
||||
team = Fight.getBlueTeam();
|
||||
}
|
||||
|
||||
if(team != null && team.getPlayers().size() < Config.MaximumTeamMembers){
|
||||
FightPlayer fp = team.addMember(player);
|
||||
if(!team.hasTeamLeader())
|
||||
|
@ -4,7 +4,7 @@ import de.steamwar.fightsystem.commands.GUI;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightState;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.utils.Config;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
@ -15,6 +15,8 @@ public class HotbarGUIListener extends BasicListener {
|
||||
@EventHandler
|
||||
public void handlePlayerInteract(PlayerInteractEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
event.setCancelled(true);
|
||||
|
||||
if(event.getItem() != null) {
|
||||
FightTeam fightTeam = Fight.getPlayerTeam(player);
|
||||
if(fightTeam == null)
|
||||
@ -26,8 +28,6 @@ public class HotbarGUIListener extends BasicListener {
|
||||
if(displayName == null)
|
||||
return;
|
||||
|
||||
event.setCancelled(true);
|
||||
|
||||
if(displayName.equals("§e" + Config.GameName + " wählen")){
|
||||
GUI.preSchemDialog(player);
|
||||
return;
|
||||
|
@ -2,7 +2,7 @@ package de.steamwar.fightsystem.listener;
|
||||
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.fight.FightState;
|
||||
import de.steamwar.fightsystem.utils.Config;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.utils.Region;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
|
@ -3,7 +3,7 @@ package de.steamwar.fightsystem.listener;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.utils.Config;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
@ -5,7 +5,7 @@ import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightPlayer;
|
||||
import de.steamwar.fightsystem.fight.FightState;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.utils.Config;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -4,7 +4,7 @@ import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightState;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.utils.Config;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.utils.Region;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import org.bukkit.GameMode;
|
||||
|
@ -2,7 +2,7 @@ package de.steamwar.fightsystem.listener;
|
||||
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.utils.Config;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
|
@ -1,289 +0,0 @@
|
||||
package de.steamwar.fightsystem.utils;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.sql.Event;
|
||||
import de.steamwar.sql.EventFight;
|
||||
import de.steamwar.sql.Team;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class Config {
|
||||
|
||||
private Config(){}
|
||||
|
||||
public static int NoPlayerOnlineDuration;
|
||||
public static int SetupDuration;
|
||||
public static int PreFightDuration;
|
||||
public static int SpectatorDuration;
|
||||
|
||||
public static int SchemsizeX;
|
||||
public static int SchemsizeY;
|
||||
public static int SchemsizeZ;
|
||||
public static int TeamBlueCornerX;
|
||||
public static int TeamBlueCornerY;
|
||||
public static int TeamBlueCornerZ;
|
||||
public static int TeamBluetoReddistanceX;
|
||||
public static int TeamBluetoReddistanceY;
|
||||
public static int TeamBluetoReddistanceZ;
|
||||
public static int Schem2BorderX;
|
||||
public static int Schem2BorderZ;
|
||||
public static int underArenaBorder;
|
||||
public static int BorderFromSchematic;
|
||||
public static int upperArenaBorder;
|
||||
public static boolean AlignWater;
|
||||
public static int WaterDepth;
|
||||
|
||||
public static boolean OnlyPublicSchematics;
|
||||
public static String SchematicDirectory;
|
||||
public static de.steamwar.sql.SchematicType SchematicType;
|
||||
public static boolean TeamRedRotate;
|
||||
public static boolean TeamBlueRotate;
|
||||
|
||||
public static String TeamRedName;
|
||||
public static String TeamRedPrefix;
|
||||
public static String TeamBlueName;
|
||||
public static String TeamBluePrefix;
|
||||
public static String GameName;
|
||||
public static String TeamChatDetection;
|
||||
|
||||
public static boolean Timeout;
|
||||
public static boolean AllDead;
|
||||
public static boolean CaptainDead;
|
||||
public static boolean PercentSystem;
|
||||
public static boolean Entern;
|
||||
public static boolean TechKO;
|
||||
public static boolean WaterTechKO;
|
||||
|
||||
public static int TimeoutTime;
|
||||
public static int EnterPhaseBegin;
|
||||
public static double PercentWin;
|
||||
|
||||
public static int MoneyWin;
|
||||
public static int MoneyLose;
|
||||
public static int MoneyDraw;
|
||||
|
||||
public static String MemberDefault;
|
||||
public static String LeaderDefault;
|
||||
|
||||
public static int TeamRedCornerX;
|
||||
public static int TeamRedCornerY;
|
||||
public static int TeamRedCornerZ;
|
||||
|
||||
public static Location TeamBlueSpawn;
|
||||
public static Location TeamRedSpawn;
|
||||
public static Location SpecSpawn;
|
||||
|
||||
public static Vector TeamBluePaste;
|
||||
public static Vector TeamRedPaste;
|
||||
public static Vector TeamBlueCorner;
|
||||
public static Vector TeamRedCorner;
|
||||
public static Vector Schemsize;
|
||||
|
||||
public static int ArenaMinX;
|
||||
public static int ArenaMinZ;
|
||||
public static int ArenaMaxX;
|
||||
public static int ArenaMaxZ;
|
||||
|
||||
public static List<Integer> HiddenBlocks;
|
||||
public static List<String> HiddenBlockEntities;
|
||||
public static int ObfuscateWith;
|
||||
|
||||
public static int EventKampfID;
|
||||
public static int EventTeamBlueID;
|
||||
public static int EventTeamRedID;
|
||||
public static int MaximumTeamMembers = Integer.MAX_VALUE;
|
||||
|
||||
public static UUID BlueLeader;
|
||||
public static UUID RedLeader;
|
||||
|
||||
public static void load(){
|
||||
if(!new File(Bukkit.getWorldContainer().getPath() + '/' + Bukkit.getWorlds().get(0).getName() + "/config.yml").exists()) {
|
||||
FightSystem.getPlugin().saveDefaultConfig();
|
||||
System.out.println(FightSystem.PREFIX + "config.yml erstellt und geladen!");
|
||||
FightSystem.shutdown(null);
|
||||
}
|
||||
if(!new File("plugins/" + FightSystem.getPlugin().getName() + "/config.yml").exists()) {
|
||||
System.out.println(FightSystem.PREFIX + "config.yml fehlt!");
|
||||
FightSystem.shutdown(null);
|
||||
}
|
||||
FileConfiguration config = FightSystem.getPlugin().getConfig();
|
||||
YamlConfiguration worldconfig = YamlConfiguration.loadConfiguration(new File(Bukkit.getWorldContainer().getPath() + '/' + Bukkit.getWorlds().get(0).getName() + "/config.yml"));
|
||||
|
||||
NoPlayerOnlineDuration = config.getInt("Times.NoPlayersOnlineDuration");
|
||||
SetupDuration = config.getInt("Times.SetupDuration");
|
||||
PreFightDuration = config.getInt("Times.PreFightDuration");
|
||||
SpectatorDuration = config.getInt("Times.SpectatorDuration");
|
||||
|
||||
SchemsizeX = worldconfig.getInt("Arena.Schemsize.x");
|
||||
SchemsizeY = worldconfig.getInt("Arena.Schemsize.y");
|
||||
SchemsizeZ = worldconfig.getInt("Arena.Schemsize.z");
|
||||
TeamBlueCornerX = worldconfig.getInt("Arena.TeamBlueCorner.x");
|
||||
TeamBlueCornerY = worldconfig.getInt("Arena.TeamBlueCorner.y");
|
||||
TeamBlueCornerZ = worldconfig.getInt("Arena.TeamBlueCorner.z");
|
||||
TeamBluetoReddistanceX = worldconfig.getInt("Arena.TeamBluetoReddistance.x");
|
||||
TeamBluetoReddistanceY = worldconfig.getInt("Arena.TeamBluetoReddistance.y");
|
||||
TeamBluetoReddistanceZ = worldconfig.getInt("Arena.TeamBluetoReddistance.z");
|
||||
Schem2BorderX = worldconfig.getInt("Arena.Schem2Border.x");
|
||||
Schem2BorderZ = worldconfig.getInt("Arena.Schem2Border.z");
|
||||
underArenaBorder = worldconfig.getInt("Arena.underArenaBorder");
|
||||
BorderFromSchematic = worldconfig.getInt("Arena.BorderFromSchematic");
|
||||
AlignWater = worldconfig.getBoolean("Arena.AlignWater");
|
||||
WaterDepth = worldconfig.getInt("Arena.WaterDepth");
|
||||
|
||||
OnlyPublicSchematics = config.getBoolean("Schematic.OnlyPublicSchematics");
|
||||
SchematicDirectory = config.getString("Schematic.Directory");
|
||||
SchematicType = de.steamwar.sql.SchematicType.fromDB(config.getString("Schematic.SchematicType"));
|
||||
boolean Rotate = config.getBoolean("Schematic.Rotate");
|
||||
|
||||
TeamRedName = config.getString("Output.TeamRedName");
|
||||
TeamRedPrefix = config.getString("Output.TeamRedPrefix");
|
||||
TeamBlueName = config.getString("Output.TeamBlueName");
|
||||
TeamBluePrefix = config.getString("Output.TeamBluePrefix");
|
||||
GameName = config.getString("Output.GameName");
|
||||
TeamChatDetection = config.getString("Output.TeamChatDetection");
|
||||
|
||||
Timeout = config.getBoolean("WinConditions.Timeout");
|
||||
AllDead = config.getBoolean("WinConditions.AllDead");
|
||||
CaptainDead = config.getBoolean("WinConditions.CaptainDead");
|
||||
PercentSystem = config.getBoolean("WinConditions.PercentSystem");
|
||||
Entern = config.getBoolean("WinConditions.Entern");
|
||||
TechKO = config.getBoolean("WinConditions.TechKO");
|
||||
WaterTechKO = config.getBoolean("WinConditions.WaterTechKO");
|
||||
|
||||
TimeoutTime = config.getInt("WinConditionParams.TimeoutTime");
|
||||
EnterPhaseBegin = config.getInt("WinConditionParams.EnterPhaseBegin");
|
||||
PercentWin = config.getDouble("WinConditionParams.PercentWin");
|
||||
|
||||
MoneyWin = config.getInt("Money.Win");
|
||||
MoneyLose = config.getInt("Money.Lose");
|
||||
MoneyDraw = config.getInt("Money.Draw");
|
||||
|
||||
MemberDefault = config.getString("Kits.MemberDefault");
|
||||
LeaderDefault = config.getString("Kits.LeaderDefault");
|
||||
|
||||
HiddenBlocks = config.getIntegerList("Techhider.HiddenBlocks");
|
||||
HiddenBlockEntities = config.getStringList("Techhider.HiddenBlockEntities");
|
||||
ObfuscateWith = config.getInt("Techhider.ObfuscateWith");
|
||||
|
||||
if(SchemsizeX < 0){
|
||||
SchemsizeX = -SchemsizeX;
|
||||
TeamBlueCornerX -= SchemsizeX;
|
||||
}
|
||||
if(SchemsizeY < 0){
|
||||
SchemsizeY = -SchemsizeY;
|
||||
TeamBlueCornerY -= SchemsizeY;
|
||||
}
|
||||
if(SchemsizeZ < 0){
|
||||
SchemsizeZ = -SchemsizeZ;
|
||||
TeamBlueCornerZ -= SchemsizeZ;
|
||||
}
|
||||
|
||||
upperArenaBorder = TeamBlueCornerY + SchemsizeY + BorderFromSchematic;
|
||||
|
||||
TeamRedCornerX = TeamBluetoReddistanceX + TeamBlueCornerX;
|
||||
TeamRedCornerY = TeamBluetoReddistanceY + TeamBlueCornerY;
|
||||
TeamRedCornerZ = TeamBluetoReddistanceZ + TeamBlueCornerZ;
|
||||
|
||||
int teamBluePasteX = TeamBlueCornerX + SchemsizeX / 2;
|
||||
int teamBluePasteZ = TeamBlueCornerZ + SchemsizeZ / 2;
|
||||
int teamRedPasteX = teamBluePasteX + TeamBluetoReddistanceX;
|
||||
int teamRedPasteZ = teamBluePasteZ + TeamBluetoReddistanceZ;
|
||||
|
||||
TeamBluePaste = new Vector(teamBluePasteX, TeamBlueCornerY, teamBluePasteZ);
|
||||
TeamRedPaste = new Vector(teamRedPasteX, TeamRedCornerY, teamRedPasteZ);
|
||||
Schemsize = new Vector(SchemsizeX, SchemsizeY, SchemsizeZ);
|
||||
TeamBlueCorner = new Vector(TeamBlueCornerX, TeamBlueCornerY, TeamBlueCornerZ);
|
||||
TeamRedCorner = new Vector(TeamRedCornerX, TeamRedCornerY, TeamRedCornerZ);
|
||||
|
||||
World world = Bukkit.getWorlds().get(0);
|
||||
TeamBlueSpawn = new Location(world, teamBluePasteX + 0.5, TeamBlueCornerY + SchemsizeY, teamBluePasteZ + 0.5);
|
||||
TeamRedSpawn = new Location(world, teamRedPasteX + 0.5, TeamRedCornerY + SchemsizeY, teamRedPasteZ + 0.5);
|
||||
SpecSpawn = new Location(world,
|
||||
teamBluePasteX + TeamBluetoReddistanceX/2.0,
|
||||
TeamBlueCornerY + TeamBluetoReddistanceY/2.0 + SchemsizeY/2.0,
|
||||
teamBluePasteZ + TeamBluetoReddistanceZ/2.0);
|
||||
|
||||
if(TeamBluetoReddistanceX > 0){
|
||||
ArenaMinX = TeamBlueCornerX - Schem2BorderX;
|
||||
ArenaMaxX = TeamRedCornerX + SchemsizeX + Schem2BorderX;
|
||||
TeamRedRotate = true;
|
||||
TeamBlueRotate = false;
|
||||
}else{
|
||||
ArenaMinX = TeamRedCornerX - Schem2BorderX;
|
||||
ArenaMaxX = TeamBlueCornerX + SchemsizeX + Schem2BorderX;
|
||||
TeamRedRotate = false;
|
||||
TeamBlueRotate = true;
|
||||
}
|
||||
if(TeamBluetoReddistanceZ > 0){
|
||||
ArenaMinZ = TeamBlueCornerZ - Schem2BorderZ;
|
||||
ArenaMaxZ = TeamRedCornerZ + SchemsizeZ + Schem2BorderZ;
|
||||
TeamRedRotate = true;
|
||||
TeamBlueRotate = false;
|
||||
}else{
|
||||
ArenaMinZ = TeamRedCornerZ - Schem2BorderZ;
|
||||
ArenaMaxZ = TeamBlueCornerZ + SchemsizeZ + Schem2BorderZ;
|
||||
if(TeamBluetoReddistanceZ != 0){
|
||||
TeamRedRotate = false;
|
||||
TeamBlueRotate = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(!Rotate){
|
||||
TeamRedRotate = false;
|
||||
TeamBlueRotate = false;
|
||||
}
|
||||
|
||||
EventKampfID = Integer.parseInt(System.getProperty("fightID", "0"));
|
||||
if(event()){
|
||||
EventFight eventFight = EventFight.get(EventKampfID);
|
||||
if(eventFight == null){
|
||||
Bukkit.getLogger().log(Level.SEVERE, "Failed to load EventFight");
|
||||
FightSystem.shutdown(null);
|
||||
return;
|
||||
}
|
||||
|
||||
Team team1 = Team.get(eventFight.getTeamBlue());
|
||||
Team team2 = Team.get(eventFight.getTeamRed());
|
||||
|
||||
if(team1 == null || team2 == null){
|
||||
Bukkit.getLogger().log(Level.SEVERE, "Failed to load Team");
|
||||
FightSystem.shutdown(null);
|
||||
return;
|
||||
}
|
||||
|
||||
TeamBlueName = team1.getTeamKuerzel();
|
||||
TeamRedName = team2.getTeamKuerzel();
|
||||
EventTeamBlueID = team1.getTeamId();
|
||||
EventTeamRedID = team2.getTeamId();
|
||||
|
||||
FightSystem.setEventFight(eventFight);
|
||||
|
||||
Event event = Event.get(eventFight.getEventID());
|
||||
MaximumTeamMembers = event.getMaximumTeamMembers();
|
||||
OnlyPublicSchematics = event.publicSchemsOnly();
|
||||
}
|
||||
|
||||
String blueLeader = System.getProperty("blueLeader", null);
|
||||
String redLeader = System.getProperty("redLeader", null);
|
||||
if(blueLeader != null)
|
||||
BlueLeader = UUID.fromString(blueLeader);
|
||||
if(redLeader != null)
|
||||
RedLeader = UUID.fromString(redLeader);
|
||||
}
|
||||
|
||||
public static boolean event(){
|
||||
return EventKampfID >= 1;
|
||||
}
|
||||
public static boolean test(){
|
||||
return EventKampfID == -1;
|
||||
}
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package de.steamwar.fightsystem.utils;
|
||||
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
|
@ -18,7 +18,6 @@ public class ItemBuilder {
|
||||
meta = item.getItemMeta();
|
||||
}
|
||||
|
||||
|
||||
public ItemBuilder(Material matrial, int amount) {
|
||||
item = new ItemStack(matrial, amount);
|
||||
meta = item.getItemMeta();
|
||||
@ -28,7 +27,7 @@ public class ItemBuilder {
|
||||
meta = item.getItemMeta();
|
||||
}
|
||||
|
||||
public ItemBuilder removeAllAtributs() {
|
||||
public ItemBuilder removeAllAttributs() {
|
||||
meta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
|
||||
meta.addItemFlags(ItemFlag.HIDE_DESTROYS);
|
||||
meta.addItemFlags(ItemFlag.HIDE_UNBREAKABLE);
|
||||
|
@ -12,11 +12,9 @@ import com.comphenix.protocol.wrappers.MultiBlockChangeInfo;
|
||||
import com.comphenix.protocol.wrappers.WrappedBlockData;
|
||||
import com.comphenix.protocol.wrappers.nbt.NbtCompound;
|
||||
import com.comphenix.protocol.wrappers.nbt.NbtFactory;
|
||||
import com.google.common.primitives.Bytes;
|
||||
import de.steamwar.core.Core;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.UnpooledByteBufAllocator;
|
||||
import javafx.util.Pair;
|
||||
@ -27,6 +25,8 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static de.steamwar.fightsystem.utils.ITechHider.bypass;
|
||||
|
||||
public class TechHider {
|
||||
private TechHider(){}
|
||||
|
||||
@ -36,16 +36,7 @@ public class TechHider {
|
||||
private static int arenaMaxX;
|
||||
private static int arenaMinZ;
|
||||
private static int arenaMaxZ;
|
||||
private static int blueMinX;
|
||||
private static int blueMaxX;
|
||||
private static int blueMinZ;
|
||||
private static int blueMaxZ;
|
||||
private static int redMinX;
|
||||
private static int redMaxX;
|
||||
private static int redMinZ;
|
||||
private static int redMaxZ;
|
||||
private static short obfuscateShift4;
|
||||
//private static final short BITMASK = 0x1FF;
|
||||
private static Material obfuscateMaterial;
|
||||
private static boolean running = false;
|
||||
private static int threadMultiplier = 1;
|
||||
@ -54,19 +45,10 @@ public class TechHider {
|
||||
if(disabled())
|
||||
return;
|
||||
|
||||
arenaMinX = posToChunk(Config.ArenaMinX);
|
||||
arenaMinZ = posToChunk(Config.ArenaMinZ);
|
||||
blueMinX = posToChunk(Config.TeamBlueCornerX);
|
||||
blueMinZ = posToChunk(Config.TeamBlueCornerZ);
|
||||
redMinX = posToChunk(Config.TeamRedCornerX);
|
||||
redMinZ = posToChunk(Config.TeamRedCornerZ);
|
||||
|
||||
arenaMaxX = posToChunk(Config.ArenaMaxX) + 1;
|
||||
arenaMaxZ = posToChunk(Config.ArenaMaxZ) + 1;
|
||||
blueMaxX = posToChunk(Config.TeamBlueCornerX + Config.SchemsizeX) + 1;
|
||||
blueMaxZ = posToChunk(Config.TeamBlueCornerZ + Config.SchemsizeZ) + 1;
|
||||
redMaxX = posToChunk(Config.TeamRedCornerX + Config.SchemsizeX) + 1;
|
||||
redMaxZ = posToChunk(Config.TeamRedCornerZ + Config.SchemsizeZ) + 1;
|
||||
arenaMinX = ITechHider.posToChunk(Config.ArenaMinX);
|
||||
arenaMinZ = ITechHider.posToChunk(Config.ArenaMinZ);
|
||||
arenaMaxX = ITechHider.posToChunk(Config.ArenaMaxX) + 1;
|
||||
arenaMaxZ = ITechHider.posToChunk(Config.ArenaMaxZ) + 1;
|
||||
|
||||
obfuscateShift4 = (short)(Config.ObfuscateWith << 4);
|
||||
//noinspection deprecation
|
||||
@ -120,32 +102,6 @@ public class TechHider {
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean bypass(Player p, int chunkX, int chunkZ){
|
||||
if(p == FightSystem.getEventLeiter())
|
||||
return true;
|
||||
|
||||
FightTeam ft = Fight.getPlayerTeam(p);
|
||||
if(ft == null){
|
||||
//Außerhalb der Arena
|
||||
return arenaMinX > chunkX ||
|
||||
chunkX > arenaMaxX ||
|
||||
arenaMinZ > chunkZ ||
|
||||
chunkZ > arenaMaxZ;
|
||||
}else if(ft.isBlue()){
|
||||
return FightSystem.isEntern() ||
|
||||
redMinX > chunkX ||
|
||||
chunkX > redMaxX ||
|
||||
redMinZ > chunkZ ||
|
||||
chunkZ > redMaxZ;
|
||||
}else{
|
||||
return FightSystem.isEntern() ||
|
||||
blueMinX > chunkX ||
|
||||
chunkX > blueMaxX ||
|
||||
blueMinZ > chunkZ ||
|
||||
chunkZ > blueMaxZ;
|
||||
}
|
||||
}
|
||||
|
||||
private static void chunkHider(){
|
||||
ProtocolLibrary.getProtocolManager().getAsynchronousManager().registerAsyncHandler(new PacketAdapter(FightSystem.getPlugin(), PacketType.Play.Server.MAP_CHUNK) {
|
||||
@Override
|
||||
@ -199,17 +155,17 @@ public class TechHider {
|
||||
}
|
||||
|
||||
if(bitsPerBlock != 13){
|
||||
int paletteLength = readVarInt(data, i);
|
||||
int paletteLengthLength = readVarIntLength(data, i);
|
||||
int paletteLength = ITechHider.readVarInt(data, i);
|
||||
int paletteLengthLength = ITechHider.readVarIntLength(data, i);
|
||||
buffer.writeBytes(data, i, paletteLengthLength);
|
||||
i += paletteLengthLength;
|
||||
for(int actPaletteId = 0; actPaletteId < paletteLength; actPaletteId++){
|
||||
int actPalette = readVarInt(data, i);
|
||||
int actPaletteLength = readVarIntLength(data, i);
|
||||
int actPalette = ITechHider.readVarInt(data, i);
|
||||
int actPaletteLength = ITechHider.readVarIntLength(data, i);
|
||||
|
||||
int blockId = actPalette >> 4;
|
||||
if(Config.HiddenBlocks.contains(blockId)){
|
||||
byte[] a = writeVarInt(obfuscateShift4);
|
||||
byte[] a = ITechHider.writeVarInt(obfuscateShift4);
|
||||
buffer.writeBytes(a);
|
||||
changed = true;
|
||||
}else{
|
||||
@ -217,34 +173,16 @@ public class TechHider {
|
||||
}
|
||||
i += actPaletteLength;
|
||||
}
|
||||
int dataArrayLength = readVarInt(data, i);
|
||||
int dataArrayLengthLength = readVarIntLength(data, i);
|
||||
int dataArrayLength = ITechHider.readVarInt(data, i);
|
||||
int dataArrayLengthLength = ITechHider.readVarIntLength(data, i);
|
||||
buffer.writeBytes(data, i, dataArrayLength * 8 + dataArrayLengthLength);
|
||||
i += dataArrayLengthLength;
|
||||
i += dataArrayLength * 8;
|
||||
}else{
|
||||
int dataArrayLength = readVarInt(data, i);
|
||||
int dataArrayLengthLength = readVarIntLength(data, i);
|
||||
int dataArrayLength = ITechHider.readVarInt(data, i);
|
||||
int dataArrayLengthLength = ITechHider.readVarIntLength(data, i);
|
||||
buffer.writeBytes(data, i, dataArrayLength*8 + dataArrayLengthLength);
|
||||
i += dataArrayLengthLength;
|
||||
/*int arrayEnd = dataArrayLength * 8 + i;
|
||||
int bitsOver = 8; //9 bits (id) + 4 bits (metadata)
|
||||
while(i < arrayEnd){
|
||||
int blockId = (newData.get(i++) & (BITMASK >> 9 - bitsOver)) << 9-bitsOver;
|
||||
blockId += newData.get(i) >> bitsOver-1;
|
||||
if(Config.HiddenBlocks.contains(blockId)){
|
||||
final short debug = 44;
|
||||
newData.set(i-1, (byte)(newData.get(i-1) & -(BITMASK >> 9-bitsOver) | debug >> 9-bitsOver));
|
||||
newData.set(i, (byte)(newData.get(i) & -(BITMASK << bitsOver-1) | debug << bitsOver-1));
|
||||
System.out.println(blockId + " replaced at " + chunkX + " " + chunkZ + " i:" + i + " " + String.format("%8s", Integer.toBinaryString(newData.get(i-1) & 0xFF)).replace(' ', '0') + String.format("%8s", Integer.toBinaryString(newData.get(i) & 0xFF)).replace(' ', '0') + " " + bitsOver);
|
||||
changed = true;
|
||||
}
|
||||
bitsOver -= 5; // 13-8
|
||||
if(bitsOver < 1){
|
||||
i++;
|
||||
bitsOver += 8;
|
||||
}
|
||||
}*/
|
||||
i += dataArrayLength * 8;
|
||||
}
|
||||
|
||||
@ -309,7 +247,7 @@ public class TechHider {
|
||||
BlockPosition pos = packet.getBlockPositionModifier().read(0);
|
||||
|
||||
Player p = e.getPlayer();
|
||||
if(bypass(p, posToChunk(pos.getX()), posToChunk(pos.getZ())))
|
||||
if(bypass(p, ITechHider.posToChunk(pos.getX()), ITechHider.posToChunk(pos.getZ())))
|
||||
return;
|
||||
|
||||
PacketContainer cached = packetCache.get(packet);
|
||||
@ -340,7 +278,7 @@ public class TechHider {
|
||||
BlockPosition pos = packet.getBlockPositionModifier().read(0);
|
||||
|
||||
Player p = e.getPlayer();
|
||||
if(bypass(p, posToChunk(pos.getX()), posToChunk(pos.getZ())))
|
||||
if(bypass(p, ITechHider.posToChunk(pos.getX()), ITechHider.posToChunk(pos.getZ())))
|
||||
return;
|
||||
|
||||
e.setCancelled(true);
|
||||
@ -381,59 +319,6 @@ public class TechHider {
|
||||
}
|
||||
|
||||
private static boolean disabled(){
|
||||
return Config.event() && Config.OnlyPublicSchematics;
|
||||
}
|
||||
|
||||
private static int posToChunk(int c){
|
||||
int chunk = c / 16;
|
||||
if(c<0)
|
||||
chunk--;
|
||||
return chunk;
|
||||
}
|
||||
|
||||
private static int readVarInt(byte[] array, int startPos) {
|
||||
int numRead = 0;
|
||||
int result = 0;
|
||||
byte read;
|
||||
do {
|
||||
read = array[startPos + numRead];
|
||||
int value = (read & 0b01111111);
|
||||
result |= (value << (7 * numRead));
|
||||
|
||||
numRead++;
|
||||
if (numRead > 5) {
|
||||
break;
|
||||
}
|
||||
} while ((read & 0b10000000) != 0);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private static int readVarIntLength(byte[] array, int startPos) {
|
||||
int numRead = 0;
|
||||
byte read;
|
||||
do {
|
||||
read = array[startPos + numRead];
|
||||
numRead++;
|
||||
if (numRead > 5) {
|
||||
break;
|
||||
}
|
||||
} while ((read & 0b10000000) != 0);
|
||||
|
||||
return numRead;
|
||||
}
|
||||
|
||||
private static byte[] writeVarInt(int value) {
|
||||
List<Byte> buffer = new ArrayList<>(5);
|
||||
do {
|
||||
byte temp = (byte)(value & 0b01111111);
|
||||
// Note: >>> means that the sign bit is shifted with the rest of the number rather than being left alone
|
||||
value >>>= 7;
|
||||
if (value != 0) {
|
||||
temp |= 0b10000000;
|
||||
}
|
||||
buffer.add(temp);
|
||||
} while (value != 0);
|
||||
return Bytes.toArray(buffer);
|
||||
return Config.OnlyPublicSchematics;
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ package de.steamwar.fightsystem.winconditions;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.utils.Config;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
@ -3,7 +3,7 @@ package de.steamwar.fightsystem.winconditions;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.utils.Config;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package de.steamwar.fightsystem.winconditions;
|
||||
|
||||
import de.steamwar.fightsystem.countdown.EnternCountdown;
|
||||
import de.steamwar.fightsystem.utils.Config;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
|
||||
public class WinconditionEntern {
|
||||
public WinconditionEntern() {
|
||||
|
@ -3,7 +3,7 @@ package de.steamwar.fightsystem.winconditions;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightState;
|
||||
import de.steamwar.fightsystem.utils.Config;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.utils.Region;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
@ -4,7 +4,7 @@ import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.countdown.TechKOCountdown;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.utils.Config;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package de.steamwar.fightsystem.winconditions;
|
||||
|
||||
import de.steamwar.fightsystem.countdown.TimeOverCountdown;
|
||||
import de.steamwar.fightsystem.utils.Config;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
|
||||
public class WinconditionTimeout {
|
||||
public WinconditionTimeout() {
|
||||
|
@ -4,7 +4,7 @@ import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightState;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.utils.Config;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
|
1
pom.xml
1
pom.xml
@ -36,6 +36,7 @@
|
||||
</build>
|
||||
|
||||
<modules>
|
||||
<module>FightSystem_API</module>
|
||||
<module>FightSystem_8</module>
|
||||
<module>FightSystem_12</module>
|
||||
<module>FightSystem_Main</module>
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren