SteamWar/FightSystem
Archiviert
13
1

Removing pair from fight system

Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Lixfel 2020-01-19 07:38:54 +01:00
Ursprung 11da798b4e
Commit 03e5cf62a2
11 geänderte Dateien mit 61 neuen und 54 gelöschten Zeilen

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

@ -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

@ -10,11 +10,11 @@ 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.FightScoreboard;
import de.steamwar.fightsystem.utils.ITechHider;
import de.steamwar.fightsystem.utils.TechHider; import de.steamwar.fightsystem.utils.TechHider;
import de.steamwar.fightsystem.utils.WaterRemover; 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;
@ -167,8 +167,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);

Datei anzeigen

@ -13,7 +13,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;
@ -48,26 +47,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();
} }
@ -77,14 +76,14 @@ public class GUI {
if(fightPlayer == null) if(fightPlayer == null)
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();
} }
@ -109,20 +108,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

@ -7,14 +7,10 @@ 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.Schematic; import de.steamwar.sql.Schematic;
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;
@ -141,7 +137,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);
@ -159,7 +155,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

@ -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);