SteamWar/FightSystem
Archiviert
13
1

personalKit #106

Zusammengeführt
Lixfel hat 5 Commits von personalKit nach master 2020-01-27 06:33:09 +01:00 zusammengeführt
28 geänderte Dateien mit 173 neuen und 87 gelöschten Zeilen
Nur Änderungen aus Commit 61ff397458 werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -1,6 +1,5 @@
package de.steamwar.fightsystem.utils; package de.steamwar.fightsystem.utils;
import javafx.util.Pair;
import net.minecraft.server.v1_10_R1.PacketPlayOutMapChunk; import net.minecraft.server.v1_10_R1.PacketPlayOutMapChunk;
import org.bukkit.craftbukkit.v1_10_R1.CraftChunk; import org.bukkit.craftbukkit.v1_10_R1.CraftChunk;
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftPlayer; import org.bukkit.craftbukkit.v1_10_R1.entity.CraftPlayer;
@ -9,7 +8,7 @@ import org.bukkit.entity.Player;
class TechHider_10 { class TechHider_10 {
private TechHider_10(){} private TechHider_10(){}
static void reloadChunk(Player p, Pair<Integer, Integer> chunk){ static void reloadChunk(Player p, ITechHider.ChunkPos chunk){
((CraftPlayer)p).getHandle().playerConnection.sendPacket(new PacketPlayOutMapChunk(((CraftChunk)p.getWorld().getChunkAt(chunk.getKey(), chunk.getValue())).getHandle(), 65535)); ((CraftPlayer)p).getHandle().playerConnection.sendPacket(new PacketPlayOutMapChunk(((CraftChunk)p.getWorld().getChunkAt(chunk.x(), chunk.z())).getHandle(), 65535));
} }
} }

Datei anzeigen

@ -12,7 +12,6 @@ import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.IFightSystem; import de.steamwar.fightsystem.IFightSystem;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import io.netty.buffer.UnpooledByteBufAllocator; import io.netty.buffer.UnpooledByteBufAllocator;
import javafx.util.Pair;
import net.minecraft.server.v1_12_R1.PacketPlayOutMapChunk; import net.minecraft.server.v1_12_R1.PacketPlayOutMapChunk;
import org.bukkit.craftbukkit.v1_12_R1.CraftChunk; import org.bukkit.craftbukkit.v1_12_R1.CraftChunk;
import org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer; import org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer;
@ -27,8 +26,8 @@ class TechHider_12 {
private static final short obfuscateShift4 = (short)(Config.ObfuscateWith << 4); private static final short obfuscateShift4 = (short)(Config.ObfuscateWith << 4);
static void reloadChunk(Player p, Pair<Integer, Integer> chunk){ static void reloadChunk(Player p, ITechHider.ChunkPos chunk){
((CraftPlayer)p).getHandle().playerConnection.sendPacket(new PacketPlayOutMapChunk(((CraftChunk)p.getWorld().getChunkAt(chunk.getKey(), chunk.getValue())).getHandle(), 65535)); ((CraftPlayer)p).getHandle().playerConnection.sendPacket(new PacketPlayOutMapChunk(((CraftChunk)p.getWorld().getChunkAt(chunk.x(), chunk.z())).getHandle(), 65535));
} }
static void start(){ static void start(){

Datei anzeigen

@ -12,7 +12,6 @@ import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.IFightSystem; import de.steamwar.fightsystem.IFightSystem;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import io.netty.buffer.UnpooledByteBufAllocator; import io.netty.buffer.UnpooledByteBufAllocator;
import javafx.util.Pair;
import net.minecraft.server.v1_14_R1.PacketPlayOutMapChunk; import net.minecraft.server.v1_14_R1.PacketPlayOutMapChunk;
import org.bukkit.craftbukkit.v1_14_R1.CraftChunk; import org.bukkit.craftbukkit.v1_14_R1.CraftChunk;
import org.bukkit.craftbukkit.v1_14_R1.entity.CraftPlayer; import org.bukkit.craftbukkit.v1_14_R1.entity.CraftPlayer;
@ -25,8 +24,8 @@ import static de.steamwar.fightsystem.utils.ITechHider.bypass;
public class TechHider_14 { public class TechHider_14 {
private TechHider_14(){} private TechHider_14(){}
static void reloadChunk(Player p, Pair<Integer, Integer> chunk){ static void reloadChunk(Player p, ITechHider.ChunkPos chunk){
((CraftPlayer)p).getHandle().playerConnection.sendPacket(new PacketPlayOutMapChunk(((CraftChunk)p.getWorld().getChunkAt(chunk.getKey(), chunk.getValue())).getHandle(), 65535)); ((CraftPlayer)p).getHandle().playerConnection.sendPacket(new PacketPlayOutMapChunk(((CraftChunk)p.getWorld().getChunkAt(chunk.x(), chunk.z())).getHandle(), 65535));
} }
static void start(){ static void start(){

Datei anzeigen

@ -1,6 +1,5 @@
package de.steamwar.fightsystem.utils; package de.steamwar.fightsystem.utils;
import javafx.util.Pair;
import net.minecraft.server.v1_15_R1.PacketPlayOutMapChunk; import net.minecraft.server.v1_15_R1.PacketPlayOutMapChunk;
import org.bukkit.craftbukkit.v1_15_R1.CraftChunk; import org.bukkit.craftbukkit.v1_15_R1.CraftChunk;
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer; import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer;
@ -9,8 +8,8 @@ import org.bukkit.entity.Player;
public class TechHider_15 { public class TechHider_15 {
private TechHider_15(){} private TechHider_15(){}
static void reloadChunk(Player p, Pair<Integer, Integer> chunk){ static void reloadChunk(Player p, ITechHider.ChunkPos chunk){
((CraftPlayer)p).getHandle().playerConnection.sendPacket(new PacketPlayOutMapChunk(((CraftChunk)p.getWorld().getChunkAt(chunk.getKey(), chunk.getValue())).getHandle(), 65535)); ((CraftPlayer)p).getHandle().playerConnection.sendPacket(new PacketPlayOutMapChunk(((CraftChunk)p.getWorld().getChunkAt(chunk.x(), chunk.z())).getHandle(), 65535));
} }
static void start(){ static void start(){

Datei anzeigen

@ -1,6 +1,5 @@
package de.steamwar.fightsystem.utils; package de.steamwar.fightsystem.utils;
import javafx.util.Pair;
import net.minecraft.server.v1_8_R3.PacketPlayOutMapChunk; import net.minecraft.server.v1_8_R3.PacketPlayOutMapChunk;
import org.bukkit.craftbukkit.v1_8_R3.CraftChunk; import org.bukkit.craftbukkit.v1_8_R3.CraftChunk;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
@ -9,7 +8,7 @@ import org.bukkit.entity.Player;
class TechHider_8 { class TechHider_8 {
private TechHider_8(){} private TechHider_8(){}
static void reloadChunk(Player p, Pair<Integer, Integer> chunk){ static void reloadChunk(Player p, ITechHider.ChunkPos chunk){
((CraftPlayer)p).getHandle().playerConnection.sendPacket(new PacketPlayOutMapChunk(((CraftChunk)p.getWorld().getChunkAt(chunk.getKey(), chunk.getValue())).getHandle(), true, 65535)); ((CraftPlayer)p).getHandle().playerConnection.sendPacket(new PacketPlayOutMapChunk(((CraftChunk)p.getWorld().getChunkAt(chunk.x(), chunk.z())).getHandle(), true, 65535));
} }
} }

Datei anzeigen

@ -1,6 +1,5 @@
package de.steamwar.fightsystem.utils; package de.steamwar.fightsystem.utils;
import javafx.util.Pair;
import net.minecraft.server.v1_9_R2.PacketPlayOutMapChunk; import net.minecraft.server.v1_9_R2.PacketPlayOutMapChunk;
import org.bukkit.craftbukkit.v1_9_R2.CraftChunk; import org.bukkit.craftbukkit.v1_9_R2.CraftChunk;
import org.bukkit.craftbukkit.v1_9_R2.entity.CraftPlayer; import org.bukkit.craftbukkit.v1_9_R2.entity.CraftPlayer;
@ -9,7 +8,7 @@ import org.bukkit.entity.Player;
class TechHider_9 { class TechHider_9 {
private TechHider_9(){} private TechHider_9(){}
static void reloadChunk(Player p, Pair<Integer, Integer> chunk){ static void reloadChunk(Player p, ITechHider.ChunkPos chunk){
((CraftPlayer)p).getHandle().playerConnection.sendPacket(new PacketPlayOutMapChunk(((CraftChunk)p.getWorld().getChunkAt(chunk.getKey(), chunk.getValue())).getHandle(), 65535)); ((CraftPlayer)p).getHandle().playerConnection.sendPacket(new PacketPlayOutMapChunk(((CraftChunk)p.getWorld().getChunkAt(chunk.x(), chunk.z())).getHandle(), 65535));
} }
} }

Datei anzeigen

@ -61,6 +61,7 @@ public class Config {
//schematic parameter //schematic parameter
public static final boolean OnlyPublicSchematics; public static final boolean OnlyPublicSchematics;
public static final boolean IgnorePublicOnly;
public static final de.steamwar.sql.SchematicType SchematicType; public static final de.steamwar.sql.SchematicType SchematicType;
public static final boolean TeamRedRotate; public static final boolean TeamRedRotate;
public static final boolean TeamBlueRotate; public static final boolean TeamBlueRotate;
@ -151,6 +152,7 @@ public class Config {
WaterDepth = worldconfig.getInt("Arena.WaterDepth"); WaterDepth = worldconfig.getInt("Arena.WaterDepth");
SchematicType = de.steamwar.sql.SchematicType.fromDB(config.getString("Schematic.SchematicType")); SchematicType = de.steamwar.sql.SchematicType.fromDB(config.getString("Schematic.SchematicType"));
IgnorePublicOnly = config.getBoolean("Schematic.IgnorePublicOnly");
boolean rotate = config.getBoolean("Schematic.Rotate"); boolean rotate = config.getBoolean("Schematic.Rotate");
ReplaceObsidian = config.getBoolean("Schematic.ReplaceObsidian"); ReplaceObsidian = config.getBoolean("Schematic.ReplaceObsidian");
ReplaceBedrock = config.getBoolean("Schematic.ReplaceBedrock"); ReplaceBedrock = config.getBoolean("Schematic.ReplaceBedrock");

Datei anzeigen

@ -136,4 +136,22 @@ public class ITechHider {
} while (value != 0); } while (value != 0);
return Bytes.toArray(buffer); return Bytes.toArray(buffer);
} }
public static class ChunkPos{
final int x;
final int z;
ChunkPos(int x, int z){
this.x = x;
this.z = z;
}
final int x(){
return x;
}
final int z(){
return z;
}
}
} }

Datei anzeigen

@ -9,13 +9,9 @@ import de.steamwar.fightsystem.kit.KitManager;
import de.steamwar.fightsystem.listener.*; import de.steamwar.fightsystem.listener.*;
import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependent; import de.steamwar.fightsystem.states.StateDependent;
import de.steamwar.fightsystem.utils.FightScoreboard; import de.steamwar.fightsystem.utils.*;
import de.steamwar.fightsystem.utils.PersonalKitCreator;
import de.steamwar.fightsystem.utils.TechHider;
import de.steamwar.fightsystem.utils.WaterRemover;
import de.steamwar.fightsystem.winconditions.*; import de.steamwar.fightsystem.winconditions.*;
import de.steamwar.sql.EventFight; import de.steamwar.sql.EventFight;
import javafx.util.Pair;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -160,6 +156,7 @@ public class FightSystem extends JavaPlugin {
if(Config.Entern) if(Config.Entern)
mainCountdown = new EnternCountdown(); mainCountdown = new EnternCountdown();
FightStatistics.start();
WaterRemover.init(); WaterRemover.init();
Bukkit.broadcastMessage(PREFIX + "§aArena freigegeben!"); Bukkit.broadcastMessage(PREFIX + "§aArena freigegeben!");
} }
@ -169,8 +166,8 @@ public class FightSystem extends JavaPlugin {
throw new SecurityException(fightState.name()); throw new SecurityException(fightState.name());
setFightState(FightState.ENTERN); setFightState(FightState.ENTERN);
final List<Pair<Integer, Integer>> chunksBlue = TechHider.prepareChunkReload(Fight.getBlueTeam().getPlayers().iterator().next().getPlayer()); final List<ITechHider.ChunkPos> chunksBlue = TechHider.prepareChunkReload(Fight.getBlueTeam().getPlayers().iterator().next().getPlayer());
final List<Pair<Integer, Integer>> chunksRed = TechHider.prepareChunkReload(Fight.getRedTeam().getPlayers().iterator().next().getPlayer()); final List<ITechHider.ChunkPos> chunksRed = TechHider.prepareChunkReload(Fight.getRedTeam().getPlayers().iterator().next().getPlayer());
IFightSystem.setEntern(true); IFightSystem.setEntern(true);
for(FightPlayer player : Fight.getBlueTeam().getPlayers()){ for(FightPlayer player : Fight.getBlueTeam().getPlayers()){
TechHider.reloadChunks(player.getPlayer(), chunksBlue); TechHider.reloadChunks(player.getPlayer(), chunksBlue);
@ -180,7 +177,7 @@ public class FightSystem extends JavaPlugin {
} }
} }
public static void setSpectateState(FightTeam winFightTeam) { public static void setSpectateState(FightTeam winFightTeam, String windescription) {
if(!fightState.ingame()) if(!fightState.ingame())
throw new SecurityException(fightState.name()); throw new SecurityException(fightState.name());
setFightState(FightState.SPECTATE); setFightState(FightState.SPECTATE);
@ -207,8 +204,10 @@ public class FightSystem extends JavaPlugin {
getEventFight().setErgebnis(2); getEventFight().setErgebnis(2);
} }
if(!Config.test()) if(!Config.test()){
new SpectateOverCountdown(); new SpectateOverCountdown();
FightStatistics.saveStats(winFightTeam, windescription);
}
} }
public static void setFightTime(int fightTime) { public static void setFightTime(int fightTime) {

Datei anzeigen

@ -14,7 +14,6 @@ import de.steamwar.inventory.SWItem;
import de.steamwar.inventory.SWListInv; import de.steamwar.inventory.SWListInv;
import de.steamwar.sql.Schematic; import de.steamwar.sql.Schematic;
import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.SteamwarUser;
import javafx.util.Pair;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -49,26 +48,26 @@ public class GUI {
} }
public static void chooseInvitation(Player p){ public static void chooseInvitation(Player p){
List<Pair<SWItem, UUID>> players = SWListInv.createPlayerList(p); List<SWListInv.SWListEntry<UUID>> players = SWListInv.createPlayerList(p.getUniqueId());
players.removeIf(swItemUUIDPair -> Fight.getFightPlayer(Bukkit.getPlayer(swItemUUIDPair.getValue())) != null); players.removeIf(swItemUUIDPair -> Fight.getFightPlayer(Bukkit.getPlayer(swItemUUIDPair.getObject())) != null);
SWListInv<UUID> inv = new SWListInv<>(p, "Spieler einladen", (ClickType click, UUID player) -> { SWListInv<UUID> inv = new SWListInv<>(p, "Spieler einladen", players, (ClickType click, UUID player) -> {
Commands.invite(p, SteamwarUser.get(player).getUserName()); Commands.invite(p, SteamwarUser.get(player).getUserName());
p.closeInventory(); p.closeInventory();
}, players); });
inv.setCallback(-999, (ClickType click) -> p.closeInventory()); inv.setCallback(-999, (ClickType click) -> p.closeInventory());
inv.open(); inv.open();
} }
public static void chooseRemove(Player p){ public static void chooseRemove(Player p){
List<Pair<SWItem, UUID>> players = SWListInv.createPlayerList(p); List<SWListInv.SWListEntry<UUID>> players = SWListInv.createPlayerList(p.getUniqueId());
FightTeam team = Fight.getPlayerTeam(p); FightTeam team = Fight.getPlayerTeam(p);
if(team == null) if(team == null)
return; return;
players.removeIf(swItemUUIDPair -> !team.equals(Fight.getPlayerTeam(Bukkit.getPlayer(swItemUUIDPair.getValue())))); players.removeIf(swItemUUIDPair -> !team.equals(Fight.getPlayerTeam(Bukkit.getPlayer(swItemUUIDPair.getObject()))));
SWListInv<UUID> inv = new SWListInv<>(p, "Spieler rauswerfen", (ClickType click, UUID player) -> { SWListInv<UUID> inv = new SWListInv<>(p, "Spieler rauswerfen", players, (ClickType click, UUID player) -> {
Commands.kick(p, SteamwarUser.get(player).getUserName()); Commands.kick(p, SteamwarUser.get(player).getUserName());
p.closeInventory(); p.closeInventory();
}, players); });
inv.setCallback(-999, (ClickType click) -> p.closeInventory()); inv.setCallback(-999, (ClickType click) -> p.closeInventory());
inv.open(); inv.open();
} }
@ -83,14 +82,14 @@ public class GUI {
return; return;
} }
List<Pair<SWItem, Kit>> iconList = new ArrayList<>(); List<SWListInv.SWListEntry<Kit>> iconList = new ArrayList<>();
List<Kit> kitList = KitManager.getKits(fightPlayer.isLeader()); List<Kit> kitList = KitManager.getKits(fightPlayer.isLeader());
for(Kit k : kitList){ for(Kit k : kitList){
iconList.add(new Pair<>(new SWItem(Material.LEATHER_CHESTPLATE, k.getName(), null, !k.isMemberAllowed(), null), k)); iconList.add(new SWListInv.SWListEntry<>(new SWItem(Material.LEATHER_CHESTPLATE, k.getName(), null, !k.isMemberAllowed(), null), k));
} }
SWListInv<Kit> inv = new SWListInv<>(p, "Kitauswahl", (ClickType click, Kit k) -> k.preview(p), iconList); SWListInv<Kit> inv = new SWListInv<>(p, "Kitauswahl", iconList, (ClickType click, Kit k) -> k.preview(p));
inv.setCallback(-999, (ClickType click) -> p.closeInventory()); inv.setCallback(-999, (ClickType click) -> p.closeInventory());
inv.open(); inv.open();
} }
@ -115,20 +114,21 @@ public class GUI {
} }
private static void schemDialog(Player p, boolean publicSchems){ private static void schemDialog(Player p, boolean publicSchems){
List<Pair<SWItem, Schematic>> schems; List<SWListInv.SWListEntry<Schematic>> schems;
if(publicSchems) if(publicSchems)
schems = SWListInv.getSchemList(0, Config.SchematicType); schems = SWListInv.getSchemList(Config.SchematicType, 0);
else if(Config.test()) else if(Config.test())
schems = SWListInv.getSchemList(SteamwarUser.get(p.getUniqueId()).getId(), null); schems = SWListInv.getSchemList(null, SteamwarUser.get(p.getUniqueId()).getId());
else else
schems = SWListInv.getSchemList(SteamwarUser.get(p.getUniqueId()).getId(), Config.SchematicType); schems = SWListInv.getSchemList(Config.SchematicType, SteamwarUser.get(p.getUniqueId()).getId());
SWListInv<Schematic> inv = new SWListInv<>(p, Config.GameName + "-Auswahl", (ClickType click, Schematic s) -> {
SWListInv<Schematic> inv = new SWListInv<>(p, Config.GameName + "-Auswahl", schems, (ClickType click, Schematic s) -> {
FightTeam fightTeam = Fight.getPlayerTeam(p); FightTeam fightTeam = Fight.getPlayerTeam(p);
if(fightTeam == null) if(fightTeam == null)
return; return;
fightTeam.setSchematic(s); fightTeam.setSchematic(s);
p.closeInventory(); p.closeInventory();
}, schems); });
inv.setCallback(-999, (ClickType click) -> p.closeInventory()); inv.setCallback(-999, (ClickType click) -> p.closeInventory());
inv.open(); inv.open();
} }

Datei anzeigen

@ -23,6 +23,6 @@ public class TechKOCountdown extends Countdown {
@Override @Override
void countdownFinished() { void countdownFinished() {
Bukkit.broadcastMessage(FightSystem.PREFIX + team.getColoredName() + "§7 ist §eTech K§8.§eO§8.!"); Bukkit.broadcastMessage(FightSystem.PREFIX + team.getColoredName() + "§7 ist §eTech K§8.§eO§8.!");
FightSystem.setSpectateState(Fight.getOpposite(team)); FightSystem.setSpectateState(Fight.getOpposite(team), "TechKO");
} }
} }

Datei anzeigen

@ -114,6 +114,16 @@ public class Fight {
} }
public static void calcAvailibleSchemTypes() { public static void calcAvailibleSchemTypes() {
if(Config.IgnorePublicOnly){
onlyPublicSchems = false;
return;
}
if(Config.OnlyPublicSchematics){
onlyPublicSchems = true;
return;
}
if(redTeam.getLeader() == null || redTeam.getLeader().getPlayer() == null || if(redTeam.getLeader() == null || redTeam.getLeader().getPlayer() == null ||
blueTeam.getLeader() == null || blueTeam.getLeader().getPlayer() == null){ blueTeam.getLeader() == null || blueTeam.getLeader().getPlayer() == null){
onlyPublicSchems = false; onlyPublicSchems = false;

Datei anzeigen

@ -11,6 +11,7 @@ public class FightPlayer {
private final FightTeam team; private final FightTeam team;
private boolean isOut; private boolean isOut;
private Kit kit; private Kit kit;
private int kills;
public void sendMessage(String message) { public void sendMessage(String message) {
if (this.player != null && this.player.isOnline()) if (this.player != null && this.player.isOnline())
@ -22,6 +23,7 @@ public class FightPlayer {
this.team = team; this.team = team;
this.isOut = false; this.isOut = false;
kit = KitManager.getKitByName(Config.MemberDefault); kit = KitManager.getKitByName(Config.MemberDefault);
kills = 0;
} }
public void setOut() { public void setOut() {
@ -52,4 +54,12 @@ public class FightPlayer {
public FightTeam getTeam(){ public FightTeam getTeam(){
return team; return team;
} }
public int getKills(){
return kills;
}
public void addKill(){
kills++;
}
} }

Datei anzeigen

@ -7,16 +7,12 @@ import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.IFightSystem; import de.steamwar.fightsystem.IFightSystem;
import de.steamwar.fightsystem.kit.KitManager; import de.steamwar.fightsystem.kit.KitManager;
import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.utils.ColorConverter; import de.steamwar.fightsystem.utils.*;
import de.steamwar.fightsystem.utils.FightScoreboard;
import de.steamwar.fightsystem.utils.ItemBuilder;
import de.steamwar.fightsystem.utils.TechHider;
import de.steamwar.inventory.SWItem; import de.steamwar.inventory.SWItem;
import de.steamwar.sql.NoClipboardException; import de.steamwar.sql.NoClipboardException;
import de.steamwar.sql.PersonalKit; import de.steamwar.sql.PersonalKit;
import de.steamwar.sql.Schematic; import de.steamwar.sql.Schematic;
import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.SteamwarUser;
import javafx.util.Pair;
import org.bukkit.*; import org.bukkit.*;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.Enchantment;
@ -144,7 +140,7 @@ public class FightTeam implements IFightTeam{
} }
public FightPlayer addMember(Player player) { public FightPlayer addMember(Player player) {
final List<Pair<Integer, Integer>> chunksToReload = TechHider.prepareChunkReload(player); final List<ITechHider.ChunkPos> chunksToReload = TechHider.prepareChunkReload(player);
FightPlayer fightPlayer = new FightPlayer(player, this); FightPlayer fightPlayer = new FightPlayer(player, this);
players.add(fightPlayer); players.add(fightPlayer);
invited.remove(player); invited.remove(player);
@ -162,7 +158,7 @@ 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<Pair<Integer, Integer>> chunksToReload = TechHider.prepareChunkReload(player); final List<ITechHider.ChunkPos> chunksToReload = TechHider.prepareChunkReload(player);
players.remove(fightPlayer); players.remove(fightPlayer);
team.removeEntry(player.getName()); team.removeEntry(player.getName());
fightPlayer.getPlayer().getInventory().clear(); fightPlayer.getPlayer().getInventory().clear();

Datei anzeigen

@ -85,6 +85,8 @@ public class Kit {
//36 = Inventargröße //36 = Inventargröße
for(int i = 0; i < 36; i++){ for(int i = 0; i < 36; i++){
if(inventory[i] == null)
continue;
SWItem item = new SWItem(); SWItem item = new SWItem();
item.setItemStack(inventory[i]); item.setItemStack(inventory[i]);
inv.setItem(i, item); inv.setItem(i, item);
@ -92,6 +94,8 @@ public class Kit {
if(armor != null){ if(armor != null){
for(int i = 0; i < 4; i++){ for(int i = 0; i < 4; i++){
if(armor[i] == null)
continue;
SWItem item = new SWItem(); SWItem item = new SWItem();
item.setItemStack(armor[i]); item.setItemStack(armor[i]);
inv.setItem(36 + i, item); inv.setItem(36 + i, item);

Datei anzeigen

@ -10,6 +10,7 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent;
import java.util.EnumSet; import java.util.EnumSet;
import java.util.Objects;
public class InFightDamageListener extends BasicListener { public class InFightDamageListener extends BasicListener {
@ -61,5 +62,9 @@ public class InFightDamageListener extends BasicListener {
event.setCancelled(true); event.setCancelled(true);
toActionbar(damager, TextComponent.fromLegacyText("§cDu darfst deinen Teamkollegen keinen Schaden zufügen!")); toActionbar(damager, TextComponent.fromLegacyText("§cDu darfst deinen Teamkollegen keinen Schaden zufügen!"));
} }
if(player.getHealth() - event.getFinalDamage() <= 0){
Objects.requireNonNull(Fight.getFightPlayer(damager)).addKill();
}
} }
} }

Datei anzeigen

@ -0,0 +1,46 @@
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.FightPlayer;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.sql.SteamwarUser;
import org.bukkit.Bukkit;
import java.sql.Timestamp;
import java.time.Instant;
import static de.steamwar.sql.Fight.create;
public class FightStatistics {
private FightStatistics(){}
private static Timestamp starttime = Timestamp.from(Instant.now());
public static void start(){
starttime = Timestamp.from(Instant.now());
}
public static void saveStats(FightTeam winner, String windescription){
SteamwarUser blueLeader = SteamwarUser.get(Fight.getBlueTeam().getLeader().getPlayer().getUniqueId());
SteamwarUser redLeader = SteamwarUser.get(Fight.getRedTeam().getLeader().getPlayer().getUniqueId());
int win = 0;
if(winner == Fight.getBlueTeam())
win = 1;
else if(winner == Fight.getRedTeam())
win = 2;
int fightId = create(Config.SchematicType.toDB(), Bukkit.getWorlds().get(0).getName(), starttime, Config.TimeoutTime - FightSystem.getFightTime(),
blueLeader.getId(), redLeader.getId(), Fight.getBlueTeam().getSchematic().getSchemID(), Fight.getRedTeam().getSchematic().getSchemID(), win, windescription);
for(FightPlayer fp : Fight.getBlueTeam().getPlayers())
savePlayerStats(fp, fightId);
for(FightPlayer fp : Fight.getRedTeam().getPlayers())
savePlayerStats(fp, fightId);
}
private static void savePlayerStats(FightPlayer fp, int fightId){
SteamwarUser user = SteamwarUser.get(fp.getPlayer().getUniqueId());
de.steamwar.sql.FightPlayer.create(fightId, user.getId(), fp.getKit().getName(), fp.getKills(), !fp.isLiving());
}
}

Datei anzeigen

@ -14,7 +14,6 @@ import de.steamwar.core.Core;
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 javafx.util.Pair;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -168,29 +167,29 @@ public class TechHider {
}); });
} }
public static List<Pair<Integer, Integer>> prepareChunkReload(Player p){ public static List<ITechHider.ChunkPos> prepareChunkReload(Player p){
if(disabled()) if(disabled())
return Collections.emptyList(); return Collections.emptyList();
List<Pair<Integer, Integer>> chunksToReload = new ArrayList<>(); List<ITechHider.ChunkPos> chunksToReload = new ArrayList<>();
for(int x = ITechHider.arenaMinX; x <= ITechHider.arenaMaxX; x++) for(int x = ITechHider.arenaMinX; x <= ITechHider.arenaMaxX; x++)
for(int z = ITechHider.arenaMinZ; z <= ITechHider.arenaMaxZ; z++) for(int z = ITechHider.arenaMinZ; z <= ITechHider.arenaMaxZ; z++)
if(!bypass(p, x, z)) if(!bypass(p, x, z))
chunksToReload.add(new Pair<>(x, z)); chunksToReload.add(new ITechHider.ChunkPos(x, z));
return chunksToReload; return chunksToReload;
} }
public static void reloadChunks(Player p, List<Pair<Integer, Integer>> chunksToReload){ public static void reloadChunks(Player p, List<ITechHider.ChunkPos> chunksToReload){
if(disabled()) if(disabled())
return; return;
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> { Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> {
for(Pair<Integer, Integer> chunk : chunksToReload){ for(ITechHider.ChunkPos chunk : chunksToReload){
if(bypass(p, chunk.getKey(), chunk.getValue())) if(bypass(p, chunk.x(), chunk.z()))
reloadChunk(p, chunk); reloadChunk(p, chunk);
} }
}, 40); }, 40);
} }
private static void reloadChunk(Player p, Pair<Integer, Integer> chunk){ private static void reloadChunk(Player p, ITechHider.ChunkPos chunk){
switch(Core.getVersion()){ switch(Core.getVersion()){
case 15: case 15:
TechHider_15.reloadChunk(p, chunk); TechHider_15.reloadChunk(p, chunk);

Datei anzeigen

@ -29,7 +29,7 @@ public class EventTeamOffWincondition extends Wincondition {
private void teamOff(FightTeam team){ private void teamOff(FightTeam team){
if(team.allPlayersOut()){ if(team.allPlayersOut()){
Bukkit.broadcastMessage(FightSystem.PREFIX + "§6Das Team " + team.getColoredName() + " §6ist Offline!"); Bukkit.broadcastMessage(FightSystem.PREFIX + "§6Das Team " + team.getColoredName() + " §6ist Offline!");
FightSystem.setSpectateState(Fight.getOpposite(team)); FightSystem.setSpectateState(Fight.getOpposite(team), "TeamOffline");
} }
} }
} }

Datei anzeigen

@ -34,7 +34,7 @@ public class WinconditionAllDead extends PlayerWincondition {
assert fightTeam != null; // Checked with isTarget assert fightTeam != null; // Checked with isTarget
if(fightTeam.allPlayersOut()) { if(fightTeam.allPlayersOut()) {
Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer letzte Spieler aus " + fightTeam.getColoredName() + message); Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer letzte Spieler aus " + fightTeam.getColoredName() + message);
FightSystem.setSpectateState(Fight.getOpposite(fightTeam)); FightSystem.setSpectateState(Fight.getOpposite(fightTeam), "AllDead");
} }
} }
} }

Datei anzeigen

@ -34,7 +34,7 @@ public class WinconditionCaptainDead extends PlayerWincondition {
assert fightTeam != null; // Checked with isTarget assert fightTeam != null; // Checked with isTarget
if(fightTeam.isPlayerLeader(player)) { if(fightTeam.isPlayerLeader(player)) {
Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer Leader von " + fightTeam.getColoredName() + message); Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer Leader von " + fightTeam.getColoredName() + message);
FightSystem.setSpectateState(Fight.getOpposite(fightTeam)); FightSystem.setSpectateState(Fight.getOpposite(fightTeam), "LeaderDead");
} }
} }
} }

Datei anzeigen

@ -23,11 +23,11 @@ public class WinconditionHeartRatioTimeout extends Wincondition {
double redHeartRatio = Fight.getRedTeam().getHeartRatio(); double redHeartRatio = Fight.getRedTeam().getHeartRatio();
if(blueHeartRatio > redHeartRatio) if(blueHeartRatio > redHeartRatio)
FightSystem.setSpectateState(Fight.getBlueTeam()); FightSystem.setSpectateState(Fight.getBlueTeam(), "HeartTimeout");
else if(blueHeartRatio < redHeartRatio) else if(blueHeartRatio < redHeartRatio)
FightSystem.setSpectateState(Fight.getRedTeam()); FightSystem.setSpectateState(Fight.getRedTeam(), "HeartTimeout");
else else
FightSystem.setSpectateState(null); FightSystem.setSpectateState(null, "HeartTimeout");
}); });
} }

Datei anzeigen

@ -37,7 +37,7 @@ public class WinconditionPercentSystem extends ListenerWincondition {
double destroyPercent = doubleBlueDestroyedBlocks * 100 / schematicSize; double destroyPercent = doubleBlueDestroyedBlocks * 100 / schematicSize;
bluePercent = destroyPercent; bluePercent = destroyPercent;
if(destroyPercent >= Config.PercentWin) { if(destroyPercent >= Config.PercentWin) {
FightSystem.setSpectateState(Fight.redTeam); FightSystem.setSpectateState(Fight.redTeam, "Percent");
} }
//Team Red //Team Red
}else if(Region.isInRange(entity.getLocation(), Config.TeamRedCornerX, Config.TeamRedCornerY, Config.TeamRedCornerZ, Config.SchemsizeX, Config.SchemsizeY, Config.SchemsizeZ, Config.BorderFromSchematic)) { }else if(Region.isInRange(entity.getLocation(), Config.TeamRedCornerX, Config.TeamRedCornerY, Config.TeamRedCornerZ, Config.SchemsizeX, Config.SchemsizeY, Config.SchemsizeZ, Config.BorderFromSchematic)) {
@ -46,7 +46,7 @@ public class WinconditionPercentSystem extends ListenerWincondition {
double destroyPercent = doubleRedDestroyedBlocks * 100 / schematicSize; double destroyPercent = doubleRedDestroyedBlocks * 100 / schematicSize;
redPercent = destroyPercent; redPercent = destroyPercent;
if(destroyPercent >= Config.PercentWin) { if(destroyPercent >= Config.PercentWin) {
FightSystem.setSpectateState(Fight.blueTeam); FightSystem.setSpectateState(Fight.blueTeam, "Percent");
} }
} }
} }

Datei anzeigen

@ -80,11 +80,11 @@ public class WinconditionPoints extends PlayerWincondition {
private void fightEnds(){ private void fightEnds(){
if(red.getPoints() > blue.getPoints()) if(red.getPoints() > blue.getPoints())
FightSystem.setSpectateState(blue.enemy); FightSystem.setSpectateState(blue.enemy, "Points");
else if(red.getPoints() < blue.getPoints()) else if(red.getPoints() < blue.getPoints())
FightSystem.setSpectateState(red.enemy); FightSystem.setSpectateState(red.enemy, "Points");
else else
FightSystem.setSpectateState(null); FightSystem.setSpectateState(null, "Points");
} }
private TeamPoints getEnemyByTeam(FightTeam team){ private TeamPoints getEnemyByTeam(FightTeam team){
@ -97,7 +97,7 @@ public class WinconditionPoints extends PlayerWincondition {
public static class TeamPoints { public static class TeamPoints {
private final FightTeam enemy; private final FightTeam enemy;
private final WinconditionRelativePercent.TeamPercent enemyPercent; private final WinconditionRelativePercent.TeamPercent enemyPercent;
private final double factor; private double factor;
private static final int maxPoints = 2000; private static final int maxPoints = 2000;
private int points; private int points;
@ -107,6 +107,8 @@ public class WinconditionPoints extends PlayerWincondition {
this.enemyPercent = enemyPercent; this.enemyPercent = enemyPercent;
points = 0; points = 0;
//Prevent NPE
Bukkit.getScheduler().runTask(FightSystem.getPlugin(), () ->{
if(enemyPercent.getBlockCount() < ownPercent.getBlockCount()) if(enemyPercent.getBlockCount() < ownPercent.getBlockCount())
this.factor = 10000; //Original mit 20 (20% = 0.2 ergeben 2000 Punkte this.factor = 10000; //Original mit 20 (20% = 0.2 ergeben 2000 Punkte
else{ else{
@ -119,6 +121,7 @@ public class WinconditionPoints extends PlayerWincondition {
this.factor = f; this.factor = f;
} }
});
} }
public int getPoints(){ public int getPoints(){

Datei anzeigen

@ -76,7 +76,7 @@ public class WinconditionPumpkinTechKO extends Wincondition {
private static void checkKO(FightTeam team, int pumpkins){ private static void checkKO(FightTeam team, int pumpkins){
if(pumpkins == 0){ if(pumpkins == 0){
Bukkit.broadcastMessage(FightSystem.PREFIX + "§eDas Team " + team.getColoredName() + " §eist Tech K.O.!"); Bukkit.broadcastMessage(FightSystem.PREFIX + "§eDas Team " + team.getColoredName() + " §eist Tech K.O.!");
Bukkit.getScheduler().runTask(FightSystem.getPlugin(), () -> FightSystem.setSpectateState(Fight.getOpposite(team))); Bukkit.getScheduler().runTask(FightSystem.getPlugin(), () -> FightSystem.setSpectateState(Fight.getOpposite(team), "PumpkinTechKO"));
} }
} }
} }

Datei anzeigen

@ -105,7 +105,7 @@ public class WinconditionRelativePercent extends Wincondition{
return; return;
if(getPercent() * 100 >= Config.PercentWin){ if(getPercent() * 100 >= Config.PercentWin){
Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer Schiff von " + team.getColoredName() + " §cwurde zu stark beschädigt!"); Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer Schiff von " + team.getColoredName() + " §cwurde zu stark beschädigt!");
FightSystem.setSpectateState(Fight.getOpposite(team)); FightSystem.setSpectateState(Fight.getOpposite(team), "RelativePercent");
} }
} }
} }

Datei anzeigen

@ -17,7 +17,7 @@ public class WinconditionTimeout extends Wincondition {
@Override @Override
public void enable() { public void enable() {
countdown = new TimeOverCountdown(() -> FightSystem.setSpectateState(null)); countdown = new TimeOverCountdown(() -> FightSystem.setSpectateState(null, "Timeout"));
} }
@Override @Override

Datei anzeigen

@ -63,7 +63,7 @@ public class WinconditionWaterTechKO extends Wincondition {
private void checkEmpty(FightTeam team, Set<Location> teamWater){ private void checkEmpty(FightTeam team, Set<Location> teamWater){
if(teamWater.isEmpty()){ if(teamWater.isEmpty()){
Bukkit.broadcastMessage(FightSystem.PREFIX + "§eDas Team " + team.getColoredName() + " §eist Tech K.O.!"); Bukkit.broadcastMessage(FightSystem.PREFIX + "§eDas Team " + team.getColoredName() + " §eist Tech K.O.!");
Bukkit.getScheduler().runTask(FightSystem.getPlugin(), () -> FightSystem.setSpectateState(Fight.getOpposite(team))); Bukkit.getScheduler().runTask(FightSystem.getPlugin(), () -> FightSystem.setSpectateState(Fight.getOpposite(team), "WaterTechKO"));
} }
} }