SteamWar/FightSystem
Archiviert
13
1

Merge branch 'master' into lixfel-ai-v1

Dieser Commit ist enthalten in:
Lixfel 2024-01-24 20:09:11 +01:00
Commit db365b161b
46 geänderte Dateien mit 693 neuen und 487 gelöschten Zeilen

Datei anzeigen

@ -39,7 +39,7 @@ public class CraftbukkitWrapper10 implements CraftbukkitWrapper {
System.arraycopy(backupChunk.getSections(), 0, chunk.getSections(), 0, chunk.getSections().length); System.arraycopy(backupChunk.getSections(), 0, chunk.getSections(), 0, chunk.getSections().length);
System.arraycopy(backupChunk.heightMap, 0, chunk.heightMap, 0, chunk.heightMap.length); System.arraycopy(backupChunk.heightMap, 0, chunk.heightMap, 0, chunk.heightMap.length);
w.tileEntityListTick.removeAll(chunk.tileEntities.values()); w.tileEntityListTick.removeAll(chunk.tileEntities.values());
if (!FightWorld.isPaper()) { if (!FightWorld.isPAPER()) {
w.tileEntityList.removeAll(chunk.tileEntities.values()); w.tileEntityList.removeAll(chunk.tileEntities.values());
} }
chunk.tileEntities.clear(); chunk.tileEntities.clear();

Datei anzeigen

@ -39,7 +39,7 @@ public class CraftbukkitWrapper12 implements CraftbukkitWrapper {
System.arraycopy(backupChunk.getSections(), 0, chunk.getSections(), 0, chunk.getSections().length); System.arraycopy(backupChunk.getSections(), 0, chunk.getSections(), 0, chunk.getSections().length);
System.arraycopy(backupChunk.heightMap, 0, chunk.heightMap, 0, chunk.heightMap.length); System.arraycopy(backupChunk.heightMap, 0, chunk.heightMap, 0, chunk.heightMap.length);
w.tileEntityListTick.removeAll(chunk.tileEntities.values()); w.tileEntityListTick.removeAll(chunk.tileEntities.values());
if (!FightWorld.isPaper()) { if (!FightWorld.isPAPER()) {
w.tileEntityList.removeAll(chunk.tileEntities.values()); w.tileEntityList.removeAll(chunk.tileEntities.values());
} }
chunk.tileEntities.clear(); chunk.tileEntities.clear();

Datei anzeigen

@ -38,7 +38,7 @@ public class CraftbukkitWrapper14 implements CraftbukkitWrapper {
System.arraycopy(backupChunk.getSections(), 0, chunk.getSections(), 0, chunk.getSections().length); System.arraycopy(backupChunk.getSections(), 0, chunk.getSections(), 0, chunk.getSections().length);
w.tileEntityListTick.removeAll(chunk.tileEntities.values()); w.tileEntityListTick.removeAll(chunk.tileEntities.values());
if (!FightWorld.isPaper()) { if (!FightWorld.isPAPER()) {
w.tileEntityList.removeAll(chunk.tileEntities.values()); w.tileEntityList.removeAll(chunk.tileEntities.values());
} }
chunk.tileEntities.clear(); chunk.tileEntities.clear();

Datei anzeigen

@ -108,4 +108,9 @@ public class FlatteningWrapper14 implements FlatteningWrapper {
public boolean isCrouching(Player player) { public boolean isCrouching(Player player) {
return player.getPose() == Pose.SWIMMING; return player.getPose() == Pose.SWIMMING;
} }
@Override
public void sendBlockChange(Player player, Block block, Material type) {
player.sendBlockChange(block.getLocation(), type.createBlockData());
}
} }

Datei anzeigen

@ -38,7 +38,7 @@ public class CraftbukkitWrapper15 implements CraftbukkitWrapper {
System.arraycopy(backupChunk.getSections(), 0, chunk.getSections(), 0, chunk.getSections().length); System.arraycopy(backupChunk.getSections(), 0, chunk.getSections(), 0, chunk.getSections().length);
w.tileEntityListTick.removeAll(chunk.tileEntities.values()); w.tileEntityListTick.removeAll(chunk.tileEntities.values());
if (!FightWorld.isPaper()) { if (!FightWorld.isPAPER()) {
w.tileEntityList.removeAll(chunk.tileEntities.values()); w.tileEntityList.removeAll(chunk.tileEntities.values());
} }
chunk.tileEntities.clear(); chunk.tileEntities.clear();

Datei anzeigen

@ -83,4 +83,10 @@ public class FlatteningWrapper8 implements FlatteningWrapper {
public boolean isCrouching(Player player) { public boolean isCrouching(Player player) {
return false; return false;
} }
@Override
@SuppressWarnings("deprecation")
public void sendBlockChange(Player player, Block block, Material type) {
player.sendBlockChange(block.getLocation(), type, (byte)0);
}
} }

Datei anzeigen

@ -39,7 +39,7 @@ public class CraftbukkitWrapper9 implements CraftbukkitWrapper {
System.arraycopy(backupChunk.getSections(), 0, chunk.getSections(), 0, chunk.getSections().length); System.arraycopy(backupChunk.getSections(), 0, chunk.getSections(), 0, chunk.getSections().length);
System.arraycopy(backupChunk.heightMap, 0, chunk.heightMap, 0, chunk.heightMap.length); System.arraycopy(backupChunk.heightMap, 0, chunk.heightMap, 0, chunk.heightMap.length);
w.tileEntityListTick.removeAll(chunk.tileEntities.values()); w.tileEntityListTick.removeAll(chunk.tileEntities.values());
if (!FightWorld.isPaper()) { if (!FightWorld.isPAPER()) {
w.tileEntityList.removeAll(chunk.tileEntities.values()); w.tileEntityList.removeAll(chunk.tileEntities.values());
} }
chunk.tileEntities.clear(); chunk.tileEntities.clear();

Datei anzeigen

@ -47,6 +47,9 @@ dependencies {
compileOnly 'io.netty:netty-all:4.1.68.Final' compileOnly 'io.netty:netty-all:4.1.68.Final'
compileOnly 'com.mojang:authlib:1.5.25' compileOnly 'com.mojang:authlib:1.5.25'
compileOnly 'org.projectlombok:lombok:1.18.30'
annotationProcessor 'org.projectlombok:lombok:1.18.30'
compileOnly swdep("WorldEdit-1.15") compileOnly swdep("WorldEdit-1.15")
compileOnly swdep("SpigotCore") compileOnly swdep("SpigotCore")
} }

Datei anzeigen

@ -309,13 +309,13 @@ public class Config {
RedRotate = teamRedRotate; RedRotate = teamRedRotate;
BlueRotate = teamBlueRotate; BlueRotate = teamBlueRotate;
RedPasteRegion = new Region(teamRedCornerX, teamRedCornerY, teamRedCornerZ, schemsizeX, schemsizeY, schemsizeZ); RedPasteRegion = Region.fromSize(teamRedCornerX, teamRedCornerY, teamRedCornerZ, schemsizeX, schemsizeY, schemsizeZ);
BluePasteRegion = new Region(blueCornerX, blueCornerY, blueCornerZ, schemsizeX, schemsizeY, schemsizeZ); BluePasteRegion = Region.fromSize(blueCornerX, blueCornerY, blueCornerZ, schemsizeX, schemsizeY, schemsizeZ);
RedExtendRegion = new Region(teamRedCornerX, teamRedCornerY, teamRedCornerZ, schemsizeX, schemsizeY, schemsizeZ, PreperationArea, PreperationArea, PreperationArea); RedExtendRegion = Region.withExtension(teamRedCornerX, teamRedCornerY, teamRedCornerZ, schemsizeX, schemsizeY, schemsizeZ, PreperationArea, PreperationArea, PreperationArea);
BlueExtendRegion = new Region(blueCornerX, blueCornerY, blueCornerZ, schemsizeX, schemsizeY, schemsizeZ, PreperationArea, PreperationArea, PreperationArea); BlueExtendRegion = Region.withExtension(blueCornerX, blueCornerY, blueCornerZ, schemsizeX, schemsizeY, schemsizeZ, PreperationArea, PreperationArea, PreperationArea);
ArenaRegion = new Region(arenaMinX, blueCornerY, arenaMinZ, arenaMaxX - arenaMinX, schemsizeY, arenaMaxZ - arenaMinZ, 0, PreperationArea, 0); ArenaRegion = Region.withExtension(arenaMinX, blueCornerY, arenaMinZ, arenaMaxX - arenaMinX, schemsizeY, arenaMaxZ - arenaMinZ, 0, PreperationArea, 0);
PlayerRegion = new Region(arenaMinX, underBorder, arenaMinZ, arenaMaxX - arenaMinX, world.getMaxHeight() - underBorder, arenaMaxZ - arenaMinZ); PlayerRegion = new Region(arenaMinX, underBorder, arenaMinZ, arenaMaxX, world.getMaxHeight(), arenaMaxZ);
EventKampfID = Integer.parseInt(System.getProperty("fightID", "0")); EventKampfID = Integer.parseInt(System.getProperty("fightID", "0"));
if(EventKampfID >= 1){ if(EventKampfID >= 1){

Datei anzeigen

@ -41,15 +41,18 @@ import de.steamwar.fightsystem.record.GlobalRecorder;
import de.steamwar.fightsystem.record.LiveRecorder; import de.steamwar.fightsystem.record.LiveRecorder;
import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.OneShotStateDependent; import de.steamwar.fightsystem.states.OneShotStateDependent;
import de.steamwar.fightsystem.states.StateDependentListener;
import de.steamwar.fightsystem.utils.*; import de.steamwar.fightsystem.utils.*;
import de.steamwar.fightsystem.winconditions.*; import de.steamwar.fightsystem.winconditions.*;
import de.steamwar.message.Message; import de.steamwar.message.Message;
import de.steamwar.sql.SchematicNode; import de.steamwar.sql.SchematicNode;
import lombok.Getter;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
public class FightSystem extends JavaPlugin { public class FightSystem extends JavaPlugin {
@Getter
private static FightSystem plugin; private static FightSystem plugin;
private Message message; private Message message;
@ -83,7 +86,6 @@ public class FightSystem extends JavaPlugin {
}); });
new Chat(); new Chat();
new ArenaBorder(); new ArenaBorder();
new TeamArea();
new IngameDeath(); new IngameDeath();
new InFightDamage(); new InFightDamage();
new InFightInventory(); new InFightInventory();
@ -100,7 +102,7 @@ public class FightSystem extends JavaPlugin {
new RunningWorldInteraction(); new RunningWorldInteraction();
new PersonalKitCreator(); new PersonalKitCreator();
new ArrowStopper(); new ArrowStopper();
new ArrowPickup(); new StateDependentListener(ArenaMode.All, FightState.All, BountifulWrapper.impl.newDenyArrowPickupListener());
new BlockFadeListener(); new BlockFadeListener();
new LeaveableArena(); new LeaveableArena();
new ClickAnalyzer(); new ClickAnalyzer();
@ -205,15 +207,6 @@ public class FightSystem extends JavaPlugin {
FightState.setFightState(FightState.SPECTATE); FightState.setFightState(FightState.SPECTATE);
} }
public static FightSystem getPlugin() {
return plugin;
}
public static void broadcast(String msg, Object... params) {
getMessage().broadcast(msg, params);
GlobalRecorder.getInstance().system(msg, params);
}
public static Message getMessage() { public static Message getMessage() {
return plugin.message; return plugin.message;
} }

Datei anzeigen

@ -1,42 +0,0 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2020 SteamWar.de-Serverteam
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.fightsystem.commands;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.SimpleCommandMap;
import java.lang.reflect.Field;
public class CommandInjector {
private CommandInjector(){}
private static final String PACKAGE_NAME = Bukkit.getServer().getClass().getPackage().getName();
private static final String VERSION = PACKAGE_NAME.substring(PACKAGE_NAME.lastIndexOf('.') + 1);
public static void injectCommand(Command cmd) throws Exception {
Class serverClass = Class.forName("org.bukkit.craftbukkit." + VERSION + ".CraftServer");
Field f1 = serverClass.getDeclaredField("commandMap");
f1.setAccessible(true);
SimpleCommandMap commandMap = (SimpleCommandMap) f1.get(Bukkit.getServer());
commandMap.register("BauSystem", cmd);
}
}

Datei anzeigen

@ -19,6 +19,7 @@
package de.steamwar.fightsystem.commands; package de.steamwar.fightsystem.commands;
import com.comphenix.tinyprotocol.Reflection;
import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.Fight; import de.steamwar.fightsystem.fight.Fight;
@ -28,12 +29,20 @@ import de.steamwar.fightsystem.fight.Kit;
import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.FightState;
import de.steamwar.sql.PersonalKit; import de.steamwar.sql.PersonalKit;
import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.SteamwarUser;
import lombok.experimental.UtilityClass;
import net.md_5.bungee.api.ChatMessageType; import net.md_5.bungee.api.ChatMessageType;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.SimpleCommandMap;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@UtilityClass
public class Commands { public class Commands {
private Commands(){}
private static final Reflection.FieldAccessor<SimpleCommandMap> commandMap = Reflection.getField("{obc}.CraftServer", "commandMap", SimpleCommandMap.class);
public static void injectCommand(Command cmd) {
commandMap.get(Bukkit.getServer()).register("FightSystem", cmd);
}
private static void errNoTeam(Player p){ private static void errNoTeam(Player p){
FightSystem.getMessage().sendPrefixless("NO_TEAM", p, ChatMessageType.ACTION_BAR); FightSystem.getMessage().sendPrefixless("NO_TEAM", p, ChatMessageType.ACTION_BAR);

Datei anzeigen

@ -50,7 +50,8 @@ public class GUI {
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
private static void addTeamRequest(Player p, SWInventory inv, int pos, FightTeam team) { private static void addTeamRequest(Player p, SWInventory inv, int pos, FightTeam team) {
byte colorCode = ColorConverter.chat2dye(team.getColor()).getDyeData(); byte colorCode = ColorConverter.chat2dye(team.getColor()).getDyeData();
inv.setItem(pos, SWItem.getDye(colorCode), colorCode, msg.parse("JOIN_REQUEST_TEAM", p, team.getColoredName()), click -> { String name = team.getLeader() != null ? team.getLeader().getEntity().getName() : team.getName();
inv.setItem(pos, SWItem.getDye(colorCode), colorCode, msg.parse("JOIN_REQUEST_TEAM", p, team.getColor() + name), click -> {
p.closeInventory(); p.closeInventory();
new JoinRequest(p, team); new JoinRequest(p, team);
}); });

Datei anzeigen

@ -47,10 +47,10 @@ public class GamemodeCommand extends BukkitCommand {
try { try {
CommandRemover.removeAll("gamemode"); CommandRemover.removeAll("gamemode");
CommandInjector.injectCommand(this);
} catch (Exception e) { } catch (Exception e) {
FightSystem.getPlugin().getLogger().log(Level.SEVERE, "Failed to replace commands", e); FightSystem.getPlugin().getLogger().log(Level.SEVERE, "Failed to replace commands", e);
} }
Commands.injectCommand(this);
} }
@Override @Override

Datei anzeigen

@ -21,11 +21,13 @@ package de.steamwar.fightsystem.countdown;
import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.events.BoardingEvent;
import de.steamwar.fightsystem.fight.FightPlayer; import de.steamwar.fightsystem.fight.FightPlayer;
import de.steamwar.fightsystem.utils.Message; import de.steamwar.fightsystem.utils.Message;
import de.steamwar.fightsystem.utils.SWSound; import de.steamwar.fightsystem.utils.SWSound;
import de.steamwar.techhider.ProtocolUtils; import de.steamwar.techhider.ProtocolUtils;
import net.md_5.bungee.api.ChatMessageType; import net.md_5.bungee.api.ChatMessageType;
import org.bukkit.Bukkit;
import java.util.List; import java.util.List;
@ -55,6 +57,7 @@ public class EnternCountdown extends Countdown {
@Override @Override
public void countdownFinished() { public void countdownFinished() {
Bukkit.getPluginManager().callEvent(new BoardingEvent(fightPlayer));
FightSystem.getMessage().sendPrefixless("ENTERN_ALLOWED", fightPlayer.getEntity(), ChatMessageType.ACTION_BAR); FightSystem.getMessage().sendPrefixless("ENTERN_ALLOWED", fightPlayer.getEntity(), ChatMessageType.ACTION_BAR);
fightPlayer.ifPlayer(player -> { fightPlayer.ifPlayer(player -> {
FightSystem.getHullHider().updatePlayer(player); FightSystem.getHullHider().updatePlayer(player);

Datei anzeigen

@ -0,0 +1,40 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2024 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.fightsystem.events;
import de.steamwar.fightsystem.fight.FightPlayer;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
@Getter
@AllArgsConstructor
public class BoardingEvent extends Event {
@Getter
private static final HandlerList handlerList = new HandlerList();
private final FightPlayer fightPlayer;
@Override
public HandlerList getHandlers() {
return handlerList;
}
}

Datei anzeigen

@ -0,0 +1,40 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2024 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.fightsystem.events;
import de.steamwar.fightsystem.fight.FightPlayer;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
@Getter
@AllArgsConstructor
public class TeamDeathEvent extends Event {
@Getter
private static final HandlerList handlerList = new HandlerList();
private final FightPlayer fightPlayer;
@Override
public HandlerList getHandlers() {
return handlerList;
}
}

Datei anzeigen

@ -0,0 +1,40 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2024 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.fightsystem.events;
import de.steamwar.fightsystem.fight.FightPlayer;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
@Getter
@AllArgsConstructor
public class TeamLeaveEvent extends Event {
@Getter
private static final HandlerList handlerList = new HandlerList();
private final FightPlayer fightPlayer;
@Override
public HandlerList getHandlers() {
return handlerList;
}
}

Datei anzeigen

@ -0,0 +1,40 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2024 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.fightsystem.events;
import de.steamwar.fightsystem.fight.FightPlayer;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
@Getter
@AllArgsConstructor
public class TeamSpawnEvent extends Event {
@Getter
private static final HandlerList handlerList = new HandlerList();
private final FightPlayer fightPlayer;
@Override
public HandlerList getHandlers() {
return handlerList;
}
}

Datei anzeigen

@ -21,11 +21,13 @@ package de.steamwar.fightsystem.fight;
import com.comphenix.tinyprotocol.TinyProtocol; import com.comphenix.tinyprotocol.TinyProtocol;
import com.mojang.authlib.GameProfile; import com.mojang.authlib.GameProfile;
import de.steamwar.core.Core;
import de.steamwar.core.ProtocolWrapper; import de.steamwar.core.ProtocolWrapper;
import de.steamwar.fightsystem.ArenaMode; import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.record.GlobalRecorder; import de.steamwar.fightsystem.record.GlobalRecorder;
import lombok.Getter;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.Sound; import org.bukkit.Sound;
@ -38,7 +40,9 @@ import java.util.HashSet;
public class Fight { public class Fight {
private Fight(){} private Fight(){}
@Getter
private static final FightTeam redTeam = new FightTeam(Config.TeamRedName, Config.TeamRedColor, Config.TeamRedSpawn, Config.RedPasteRegion, Config.RedExtendRegion, Config.RedRotate, false, Config.RedLeader); private static final FightTeam redTeam = new FightTeam(Config.TeamRedName, Config.TeamRedColor, Config.TeamRedSpawn, Config.RedPasteRegion, Config.RedExtendRegion, Config.RedRotate, false, Config.RedLeader);
@Getter
private static final FightTeam blueTeam = new FightTeam(Config.TeamBlueName, Config.TeamBlueColor, Config.TeamBlueSpawn, Config.BluePasteRegion, Config.BlueExtendRegion, Config.BlueRotate, true, Config.BlueLeader); private static final FightTeam blueTeam = new FightTeam(Config.TeamBlueName, Config.TeamBlueColor, Config.TeamBlueSpawn, Config.BluePasteRegion, Config.BlueExtendRegion, Config.BlueRotate, true, Config.BlueLeader);
private static final Collection<FightTeam> teams = new HashSet<>(); private static final Collection<FightTeam> teams = new HashSet<>();
static { static {
@ -75,14 +79,6 @@ public class Fight {
return getPlayerTeam(player) != null; return getPlayerTeam(player) != null;
} }
public static FightTeam getRedTeam() {
return redTeam;
}
public static FightTeam getBlueTeam() {
return blueTeam;
}
public static Collection<FightTeam> teams() { public static Collection<FightTeam> teams() {
return teams; return teams;
} }
@ -94,7 +90,10 @@ public class Fight {
public static void playSound(Sound sound, float volume, float pitch) { public static void playSound(Sound sound, float volume, float pitch) {
GlobalRecorder.getInstance().soundAtPlayer(sound.name(), volume, pitch); GlobalRecorder.getInstance().soundAtPlayer(sound.name(), volume, pitch);
//volume: max. 100, pitch: max. 2 //volume: max. 100, pitch: max. 2
Bukkit.getServer().getOnlinePlayers().forEach(player -> player.playSound(player.getLocation(), sound, volume, pitch)); if(Core.getVersion() >= 18)
Bukkit.getServer().getOnlinePlayers().forEach(player -> player.playSound(player, sound, volume, pitch));
else
Bukkit.getServer().getOnlinePlayers().forEach(player -> player.playSound(player.getLocation(), sound, volume, pitch));
} }
public static FightTeam getTeamByName(String name) { public static FightTeam getTeamByName(String name) {

Datei anzeigen

@ -23,8 +23,11 @@ import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.ai.AI; import de.steamwar.fightsystem.ai.AI;
import de.steamwar.fightsystem.countdown.Countdown; import de.steamwar.fightsystem.countdown.Countdown;
import de.steamwar.fightsystem.countdown.EnternCountdown; import de.steamwar.fightsystem.countdown.EnternCountdown;
import de.steamwar.fightsystem.events.TeamDeathEvent;
import de.steamwar.sql.PersonalKit; import de.steamwar.sql.PersonalKit;
import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.SteamwarUser;
import lombok.Getter;
import lombok.Setter;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -35,9 +38,13 @@ public class FightPlayer {
private final int id; private final int id;
private LivingEntity entity; private LivingEntity entity;
@Getter
private final FightTeam team; private final FightTeam team;
private boolean isOut; private boolean isOut;
@Setter
@Getter
private Kit kit; private Kit kit;
@Getter
private int kills; private int kills;
private EnternCountdown enternCountdown = null; private EnternCountdown enternCountdown = null;
@ -62,6 +69,7 @@ public class FightPlayer {
public void setOut() { public void setOut() {
isOut = true; isOut = true;
Bukkit.getPluginManager().callEvent(new TeamDeathEvent(this));
stopEnternCountdown(); stopEnternCountdown();
ifAI(AI::stop); ifAI(AI::stop);
} }
@ -111,22 +119,6 @@ public class FightPlayer {
return leader != null && leader.getEntity() == entity; return leader != null && leader.getEntity() == entity;
} }
public Kit getKit() {
return kit;
}
public void setKit(Kit kit) {
this.kit = kit;
}
public FightTeam getTeam(){
return team;
}
public int getKills(){
return kills;
}
public void addKill(){ public void addKill(){
kills++; kills++;
} }

Datei anzeigen

@ -25,10 +25,12 @@ import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.commands.GUI; import de.steamwar.fightsystem.commands.GUI;
import de.steamwar.fightsystem.countdown.Countdown; import de.steamwar.fightsystem.countdown.Countdown;
import de.steamwar.fightsystem.events.TeamLeaveEvent;
import de.steamwar.fightsystem.events.TeamSpawnEvent;
import de.steamwar.fightsystem.listener.FightScoreboard; import de.steamwar.fightsystem.listener.FightScoreboard;
import de.steamwar.fightsystem.listener.Permanent; import de.steamwar.fightsystem.listener.Permanent;
import de.steamwar.fightsystem.listener.PersonalKitCreator; import de.steamwar.fightsystem.listener.PersonalKitCreator;
import de.steamwar.fightsystem.record.GlobalRecorder; import de.steamwar.fightsystem.listener.TeamArea;
import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.OneShotStateDependent; import de.steamwar.fightsystem.states.OneShotStateDependent;
import de.steamwar.fightsystem.states.StateDependent; import de.steamwar.fightsystem.states.StateDependent;
@ -39,9 +41,9 @@ import de.steamwar.inventory.SWItem;
import de.steamwar.sql.SchematicNode; import de.steamwar.sql.SchematicNode;
import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.SteamwarUser;
import de.steamwar.techhider.ProtocolUtils; import de.steamwar.techhider.ProtocolUtils;
import lombok.Getter;
import net.md_5.bungee.api.ChatMessageType; import net.md_5.bungee.api.ChatMessageType;
import org.bukkit.*; import org.bukkit.*;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.scoreboard.NameTagVisibility; import org.bukkit.scoreboard.NameTagVisibility;
@ -55,7 +57,7 @@ public class FightTeam {
private static void setKitButton(HotbarKit kit, boolean leader) { private static void setKitButton(HotbarKit kit, boolean leader) {
if (Kit.getAvailableKits(leader).size() > 1 || Config.PersonalKits) if (Kit.getAvailableKits(leader).size() > 1 || Config.PersonalKits)
kit.setItem(1, "CHOOSE_KIT", new ItemBuilder(Material.LEATHER_CHESTPLATE).removeAllAttributes().addEnchantment(Enchantment.DURABILITY, 1).build(), player -> GUI.kitSelection(player, "")); kit.setItem(1, "CHOOSE_KIT", new ItemBuilder(Material.LEATHER_CHESTPLATE).enchant().build(), player -> GUI.kitSelection(player, ""));
else else
kit.setItem(1, null, null, null); kit.setItem(1, null, null, null);
} }
@ -63,50 +65,61 @@ public class FightTeam {
private static final HotbarKit memberKit = new HotbarKit(); private static final HotbarKit memberKit = new HotbarKit();
static { static {
setKitButton(memberKit, false); setKitButton(memberKit, false);
memberKit.setItem(7, "RESPAWN", new ItemBuilder(Material.BEACON).removeAllAttributes().build(), player -> player.teleport(Objects.requireNonNull(Fight.getPlayerTeam(player)).getSpawn())); memberKit.setItem(7, "RESPAWN", new ItemBuilder(Material.BEACON).build(), player -> player.teleport(Objects.requireNonNull(Fight.getPlayerTeam(player)).getSpawn()));
} }
private static final HotbarKit notReadyKit = new HotbarKit(memberKit); private static final HotbarKit notReadyKit = new HotbarKit(memberKit);
static { static {
setKitButton(notReadyKit, true); setKitButton(notReadyKit, true);
if(!ArenaMode.RankedEvent.contains(Config.mode)){ if(!ArenaMode.RankedEvent.contains(Config.mode)){
notReadyKit.setItem(2, "REQUESTS", new ItemBuilder(Material.PAPER).removeAllAttributes().build(), GUI::chooseJoinRequests); notReadyKit.setItem(2, "REQUESTS", new ItemBuilder(Material.PAPER).build(), GUI::chooseJoinRequests);
notReadyKit.setItem(3, "REMOVE_PLAYERS", new ItemBuilder(SWItem.getMaterial("FIREWORK_CHARGE")).removeAllAttributes().build(), GUI::chooseRemove); notReadyKit.setItem(3, "REMOVE_PLAYERS", new ItemBuilder(SWItem.getMaterial("FIREWORK_CHARGE")).build(), GUI::chooseRemove);
} }
if(Config.test()) if(Config.test())
notReadyKit.setItem(5, "CHOOSE_SCHEMATIC", new ItemBuilder(SWItem.getMaterial("CAULDRON_ITEM")).removeAllAttributes().addEnchantment(Enchantment.DURABILITY, 1).build(), GUI::preSchemDialog); notReadyKit.setItem(5, "CHOOSE_SCHEMATIC", new ItemBuilder(SWItem.getMaterial("CAULDRON_ITEM")).enchant().build(), GUI::preSchemDialog);
notReadyKit.setItem(4, "TEAM_NOT_READY", new ItemBuilder(SWItem.getDye(10), (short) 10).removeAllAttributes().addEnchantment(Enchantment.DURABILITY, 1).build(), player -> Objects.requireNonNull(Fight.getPlayerTeam(player)).setReady(true)); notReadyKit.setItem(4, "TEAM_NOT_READY", new ItemBuilder(SWItem.getDye(10), (short) 10).enchant().build(), player -> Objects.requireNonNull(Fight.getPlayerTeam(player)).setReady(true));
} }
private static final HotbarKit chooseSchemKit = new HotbarKit(notReadyKit); private static final HotbarKit chooseSchemKit = new HotbarKit(notReadyKit);
static { static {
chooseSchemKit.setItem(4, "CHOOSE_SCHEMATIC", new ItemBuilder(SWItem.getMaterial("CAULDRON_ITEM")).removeAllAttributes().addEnchantment(Enchantment.DURABILITY, 1).build(), GUI::preSchemDialog); chooseSchemKit.setItem(4, "CHOOSE_SCHEMATIC", new ItemBuilder(SWItem.getMaterial("CAULDRON_ITEM")).enchant().build(), GUI::preSchemDialog);
} }
private static final HotbarKit readyKit = new HotbarKit(memberKit); private static final HotbarKit readyKit = new HotbarKit(memberKit);
static { static {
readyKit.setItem(1, null, null, null); readyKit.setItem(1, null, null, null);
readyKit.setItem(4, "TEAM_READY", new ItemBuilder(SWItem.getDye(8), (short) 8).removeAllAttributes().addEnchantment(Enchantment.DURABILITY,1 ).build(), player -> Objects.requireNonNull(Fight.getPlayerTeam(player)).setReady(false)); readyKit.setItem(4, "TEAM_READY", new ItemBuilder(SWItem.getDye(8), (short) 8).enchant().build(), player -> Objects.requireNonNull(Fight.getPlayerTeam(player)).setReady(false));
} }
@Getter
private UUID designatedLeader; private UUID designatedLeader;
@Getter
private FightPlayer leader; private FightPlayer leader;
@Getter
private boolean publicsOnly; private boolean publicsOnly;
private final Map<UUID, FightPlayer> players = new HashMap<>(); private final Map<UUID, FightPlayer> players = new HashMap<>();
@Getter
private String name; private String name;
@Getter
private String prefix; private String prefix;
@Getter
private ChatColor color; private ChatColor color;
private final FightSchematic schematic; private final FightSchematic schematic;
private final Team team; private final Team team;
@Getter
private final boolean blue; private final boolean blue;
@Getter
private boolean ready; private boolean ready;
private boolean skip; private boolean skip;
@Getter
private final Location spawn; private final Location spawn;
@Getter
private final Region schemRegion; private final Region schemRegion;
@Getter
private final Region extendRegion; private final Region extendRegion;
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@ -123,6 +136,7 @@ public class FightTeam {
this.schematic = new FightSchematic(this, rotate); this.schematic = new FightSchematic(this, rotate);
new KitLoader(); new KitLoader();
new SpectateHandler(); new SpectateHandler();
new TeamArea(this);
team = FightScoreboard.getBukkitTeam(name); team = FightScoreboard.getBukkitTeam(name);
WorldOfColorWrapper.impl.setTeamColor(team, color); WorldOfColorWrapper.impl.setTeamColor(team, color);
@ -146,26 +160,10 @@ public class FightTeam {
this.color = ChatColor.getByChar(ChatColor.getLastColors(prefix).replace("§", "")); this.color = ChatColor.getByChar(ChatColor.getLastColors(prefix).replace("§", ""));
} }
public UUID getDesignatedLeader(){
return designatedLeader;
}
public Region getSchemRegion() {
return schemRegion;
}
public Region getExtendRegion() {
return extendRegion;
}
public boolean canbeLeader(Player p){ public boolean canbeLeader(Player p){
return isLeaderless() && (designatedLeader == null || designatedLeader.equals(p.getUniqueId())); return isLeaderless() && (designatedLeader == null || designatedLeader.equals(p.getUniqueId()));
} }
public boolean isPublicsOnly() {
return publicsOnly;
}
public void teleportToSpawn(){ public void teleportToSpawn(){
players.forEach((player, fp) -> fp.getEntity().teleport(spawn)); players.forEach((player, fp) -> fp.getEntity().teleport(spawn));
} }
@ -265,6 +263,8 @@ public class FightTeam {
FightPlayer fightPlayer = getFightPlayer(entity) != null ? getFightPlayer(entity) : new FightPlayer(entity, user, this); FightPlayer fightPlayer = getFightPlayer(entity) != null ? getFightPlayer(entity) : new FightPlayer(entity, user, this);
fightPlayer.revive(); fightPlayer.revive();
players.put(entity.getUniqueId(), fightPlayer); players.put(entity.getUniqueId(), fightPlayer);
Bukkit.getPluginManager().callEvent(new TeamSpawnEvent(fightPlayer));
Permanent.getSpectatorTeam().removeEntry(entity.getName()); Permanent.getSpectatorTeam().removeEntry(entity.getName());
team.addEntry(entity.getName()); team.addEntry(entity.getName());
@ -288,7 +288,6 @@ public class FightTeam {
if(FightState.Running.contains(FightState.getFightState())) if(FightState.Running.contains(FightState.getFightState()))
fightPlayer.startEnternCountdown(Wincondition.getTimeOverCountdown()); fightPlayer.startEnternCountdown(Wincondition.getTimeOverCountdown());
GlobalRecorder.getInstance().playerJoins(entity, user);
fightPlayer.ifPlayer(player -> FightSystem.getTechHider().reloadChunks(player, chunksToReload, false)); fightPlayer.ifPlayer(player -> FightSystem.getTechHider().reloadChunks(player, chunksToReload, false));
if(isLeaderless()) if(isLeaderless())
@ -299,6 +298,7 @@ public class FightTeam {
public void removePlayer(LivingEntity entity) { public void removePlayer(LivingEntity entity) {
FightPlayer fightPlayer = getFightPlayer(entity); FightPlayer fightPlayer = getFightPlayer(entity);
Bukkit.getPluginManager().callEvent(new TeamLeaveEvent(fightPlayer));
fightPlayer.ifPlayer(PersonalKitCreator::closeIfInKitCreator); fightPlayer.ifPlayer(PersonalKitCreator::closeIfInKitCreator);
List<ProtocolUtils.ChunkPos> chunksToReload = FightSystem.getTechHider().prepareChunkReload(entity, true); List<ProtocolUtils.ChunkPos> chunksToReload = FightSystem.getTechHider().prepareChunkReload(entity, true);
@ -311,7 +311,6 @@ public class FightTeam {
if(fightPlayer.equals(leader)) if(fightPlayer.equals(leader))
removeLeader(); removeLeader();
GlobalRecorder.getInstance().entityDespawns(entity);
entity.teleport(Config.SpecSpawn); entity.teleport(Config.SpecSpawn);
fightPlayer.ifPlayer(player -> { fightPlayer.ifPlayer(player -> {
@ -332,14 +331,6 @@ public class FightTeam {
return leader == null; return leader == null;
} }
public boolean isBlue(){
return blue;
}
public FightPlayer getLeader() {
return leader;
}
private void removeLeader() { private void removeLeader() {
this.leader = null; this.leader = null;
if(!players.isEmpty()) { if(!players.isEmpty()) {
@ -383,10 +374,6 @@ public class FightTeam {
return players.values(); return players.values();
} }
public boolean isReady() {
return ready;
}
public void pasteSchem() { public void pasteSchem() {
testPasteAction(); testPasteAction();
} }
@ -457,26 +444,14 @@ public class FightTeam {
} }
} }
public String getName() {
return name;
}
public String getColoredName() { public String getColoredName() {
return prefix + name; return prefix + name;
} }
public String getPrefix() {
return prefix;
}
public int getSchematic() { public int getSchematic() {
return schematic.getId(); return schematic.getId();
} }
public Location getSpawn() {
return spawn;
}
public double getCurrentHearts() { public double getCurrentHearts() {
return players.values().stream().filter(FightPlayer::isLiving).mapToDouble(fp -> fp.getEntity().getHealth()).sum(); return players.values().stream().filter(FightPlayer::isLiving).mapToDouble(fp -> fp.getEntity().getHealth()).sum();
} }
@ -494,10 +469,6 @@ public class FightTeam {
return (int) players.values().stream().filter(FightPlayer::isLiving).count(); return (int) players.values().stream().filter(FightPlayer::isLiving).count();
} }
public ChatColor getColor() {
return color;
}
@Override @Override
public String toString() { public String toString() {
return name; return name;

Datei anzeigen

@ -26,6 +26,7 @@ import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependent; import de.steamwar.fightsystem.states.StateDependent;
import de.steamwar.fightsystem.utils.CraftbukkitWrapper; import de.steamwar.fightsystem.utils.CraftbukkitWrapper;
import de.steamwar.fightsystem.utils.FlatteningWrapper; import de.steamwar.fightsystem.utils.FlatteningWrapper;
import lombok.Getter;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.WorldCreator; import org.bukkit.WorldCreator;
@ -39,11 +40,8 @@ import java.util.Objects;
public class FightWorld extends StateDependent { public class FightWorld extends StateDependent {
private static final boolean paper = Bukkit.getVersion().contains("git-Paper"); @Getter
private static final boolean PAPER = Bukkit.getVersion().contains("git-Paper");
public static boolean isPaper(){
return paper;
}
public FightWorld() { public FightWorld() {
super(ArenaMode.Restartable.contains(Config.mode) || Config.replayserver(), FightState.Schem); super(ArenaMode.Restartable.contains(Config.mode) || Config.replayserver(), FightState.Schem);

Datei anzeigen

@ -51,7 +51,7 @@ public class HotbarKit extends Kit {
public static final HotbarKit SPECTATOR_KIT = new HotbarKit(); public static final HotbarKit SPECTATOR_KIT = new HotbarKit();
static { static {
for(int i = 0; i < 9; i++) for(int i = 0; i < 9; i++)
SPECTATOR_KIT.setItem(i, "JOIN_REQUEST", new ItemBuilder(Material.PAPER).removeAllAttributes().build(), GUI::joinRequest); SPECTATOR_KIT.setItem(i, "JOIN_REQUEST", new ItemBuilder(Material.PAPER).build(), GUI::joinRequest);
} }
private static final int HOTBAR_SIZE = 9; private static final int HOTBAR_SIZE = 9;

Datei anzeigen

@ -30,6 +30,7 @@ import de.steamwar.inventory.SWInventory;
import de.steamwar.inventory.SWItem; import de.steamwar.inventory.SWItem;
import de.steamwar.sql.PersonalKit; import de.steamwar.sql.PersonalKit;
import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.SteamwarUser;
import lombok.Getter;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
@ -69,11 +70,19 @@ public class Kit {
} }
} }
@Getter
private final String name; private final String name;
@Getter
private final ItemStack[] inventory; private final ItemStack[] inventory;
@Getter
private final ItemStack[] armor; private final ItemStack[] armor;
@Getter
private final Collection<PotionEffect> effects; private final Collection<PotionEffect> effects;
/* In which stage is entern allowed? */
@Getter
private final int enterStage; private final int enterStage;
/* Is this kit allowed to set/handle tnt? */
@Getter
private final boolean tnt; private final boolean tnt;
private final boolean leaderAllowed; private final boolean leaderAllowed;
private final boolean memberAllowed; private final boolean memberAllowed;
@ -140,10 +149,6 @@ public class Kit {
return kits; return kits;
} }
public String getName() {
return name;
}
public boolean canUseKit(boolean leader){ public boolean canUseKit(boolean leader){
if (leader) { if (leader) {
return leaderAllowed; return leaderAllowed;
@ -156,10 +161,6 @@ public class Kit {
return !memberAllowed; return !memberAllowed;
} }
public ItemStack[] getInventory() {
return inventory;
}
public boolean contains(ItemStack stack) { public boolean contains(ItemStack stack) {
for(ItemStack i : inventory) { for(ItemStack i : inventory) {
if(similar(i, stack)) if(similar(i, stack))
@ -172,24 +173,6 @@ public class Kit {
return false; return false;
} }
public ItemStack[] getArmor() {
return armor;
}
public Collection<PotionEffect> getEffects() {
return effects;
}
/* Is this kit allowed to set/handle tnt? */
public boolean isTnt(){
return tnt;
}
/* In which stage is entern allowed? */
public int getEnterStage() {
return enterStage;
}
public void toPersonalKit(PersonalKit kit) { public void toPersonalKit(PersonalKit kit) {
kit.setContainer(inventory, armor); kit.setContainer(inventory, armor);
} }

Datei anzeigen

@ -21,52 +21,72 @@ package de.steamwar.fightsystem.listener;
import de.steamwar.fightsystem.ArenaMode; import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.events.TeamDeathEvent;
import de.steamwar.fightsystem.events.TeamLeaveEvent;
import de.steamwar.fightsystem.events.TeamSpawnEvent;
import de.steamwar.fightsystem.fight.Fight; import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightPlayer; import de.steamwar.fightsystem.fight.FightPlayer;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentListener; import de.steamwar.fightsystem.states.StateDependentListener;
import de.steamwar.fightsystem.states.StateDependentTask; import de.steamwar.fightsystem.states.StateDependentTask;
import net.md_5.bungee.api.ChatMessageType;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent;
public class ArenaBorder implements Listener { public class ArenaBorder implements Listener {
private final Border spectatorBorder = new Border(Config.PlayerRegion, true, 5, "NO_ARENA_LEAVING");
private final Border playerBorder = new Border(Config.PlayerRegion.to2d(), true, 5, "NO_ARENA_LEAVING");
public ArenaBorder() { public ArenaBorder() {
new StateDependentListener(ArenaMode.All, FightState.All, this); new StateDependentListener(ArenaMode.All, FightState.All, this);
new StateDependentTask(ArenaMode.All, FightState.Running, this::damage, 2, 2); new StateDependentTask(ArenaMode.All, FightState.Running, this::damage, 2, 2);
new StateDependentListener(!Config.GroundWalkable, FightState.AntiIngame, new Listener() {
@EventHandler
public void onMove(PlayerMoveEvent e) {
Player player = e.getPlayer();
if(e.getTo().getY() <= Config.PlayerRegion.getMinY() && playerBorder.contains(player))
player.teleport(Fight.getPlayerTeam(player).getSpawn());
}
});
} }
@EventHandler @EventHandler
public void arenaBorder(PlayerMoveEvent event){ public void onPlayerJoin(PlayerJoinEvent e) {
Player player = event.getPlayer(); addToSpectator(e.getPlayer());
FightTeam team = Fight.getPlayerTeam(player); }
if(Config.ArenaLeaveable && team == null) @EventHandler
return; public void onTeamJoin(TeamSpawnEvent e) {
e.getFightPlayer().ifPlayer(player -> {
spectatorBorder.removePlayer(player);
playerBorder.addPlayer(player);
});
}
Location to = event.getTo(); @EventHandler
assert to != null; public void onTeamDeath(TeamDeathEvent e) {
e.getFightPlayer().ifPlayer(player -> {
playerBorder.removePlayer(player);
addToSpectator(player);
});
}
if(Config.PlayerRegion.inRegion(to)) @EventHandler
return; public void onTeamLeave(TeamLeaveEvent e) {
e.getFightPlayer().ifPlayer(player -> {
playerBorder.removePlayer(player);
addToSpectator(player);
});
}
if(to.getY() <= Config.PlayerRegion.getMinY() && player.getGameMode() != GameMode.SPECTATOR && team != null) { @EventHandler
if(!Config.GroundWalkable && !FightState.infight()) public void onPlayerQuit(PlayerQuitEvent e) {
player.teleport(team.getSpawn()); spectatorBorder.removePlayer(e.getPlayer());
return;
}
player.teleport(event.getFrom());
FightSystem.getMessage().sendPrefixless("NO_ARENA_LEAVING", player, ChatMessageType.ACTION_BAR);
} }
private void damage() { private void damage() {
@ -78,4 +98,11 @@ public class ArenaBorder implements Listener {
} }
}); });
} }
private void addToSpectator(Player player) {
if(Config.ArenaLeaveable || !player.isOnline() || playerBorder.contains(player))
return;
spectatorBorder.addPlayer(player);
}
} }

Datei anzeigen

@ -1,32 +0,0 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2020 SteamWar.de-Serverteam
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.fightsystem.listener;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentListener;
import de.steamwar.fightsystem.utils.BountifulWrapper;
public class ArrowPickup {
public ArrowPickup() {
new StateDependentListener(ArenaMode.All, FightState.All, BountifulWrapper.impl.newDenyArrowPickupListener());
}
}

Datei anzeigen

@ -0,0 +1,131 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2024 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.fightsystem.listener;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentTask;
import de.steamwar.fightsystem.utils.FlatteningWrapper;
import de.steamwar.fightsystem.utils.Region;
import net.md_5.bungee.api.ChatMessageType;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
public class Border {
private final Map<Player, Set<Block>> ghostBarriers = new HashMap<>();
private final Map<Player, Location> lastLocation = new HashMap<>();
private final boolean contain;
private final String resetMessage;
private final Region region;
private final int ghostRange;
private final int ghostSize;
public Border(Region region, boolean contain, int ghostRange, String resetMessage) {
this.contain = contain;
this.resetMessage = resetMessage;
this.region = region;
this.ghostRange = ghostRange;
this.ghostSize = 2*ghostRange + 1;
new StateDependentTask(ArenaMode.All, FightState.All, this::run, 1, 1);
}
public void addPlayer(Player player) {
ghostBarriers.computeIfAbsent(player, uuid -> new HashSet<>());
lastLocation.put(player, player.getLocation());
}
public boolean contains(Player player) {
return ghostBarriers.containsKey(player);
}
public void removePlayer(Player player) {
lastLocation.remove(player);
Set<Block> blocks = ghostBarriers.remove(player);
if(blocks == null || !player.isOnline())
return;
for(Block block : blocks)
sendChange(player, block, Material.AIR);
}
private void run() {
for(Map.Entry<Player, Set<Block>> entry : ghostBarriers.entrySet()) {
Player player = entry.getKey();
Location location = player.getLocation();
if(region.playerInRegion(location) != contain) {
player.teleport(lastLocation.get(player));
FightSystem.getMessage().sendPrefixless(resetMessage, player, ChatMessageType.ACTION_BAR);
return;
}
Set<Block> ghostBlocks = entry.getValue();
Region ghostRegion = Region.fromSize(location.getBlockX() - ghostRange, location.getBlockY() - ghostRange, location.getBlockZ() - ghostRange, ghostSize, ghostSize, ghostSize);
ghostBlocks.removeIf(block -> {
if(!ghostRegion.inRegion(block)) {
sendChange(player, block, Material.AIR);
return true;
}
return false;
});
if(contain) {
borderIteration(player, ghostBlocks, Region.fromSize(region.getMinX()-1, region.getMinY(), region.getMinZ(), 1, region.getSizeY(), region.getSizeZ()).intersection(ghostRegion));
borderIteration(player, ghostBlocks, Region.fromSize(region.getMinX(), region.getMinY()-1, region.getMinZ(), region.getSizeX(), 1, region.getSizeZ()).intersection(ghostRegion));
borderIteration(player, ghostBlocks, Region.fromSize(region.getMinX(), region.getMinY(), region.getMinZ()-1, region.getSizeX(), region.getSizeY(), 1).intersection(ghostRegion));
borderIteration(player, ghostBlocks, Region.fromSize(region.getMaxX(), region.getMinY(), region.getMinZ(), 1, region.getSizeY(), region.getSizeZ()).intersection(ghostRegion));
borderIteration(player, ghostBlocks, Region.fromSize(region.getMinX(), region.getMaxY(), region.getMinZ(), region.getSizeX(), 1, region.getSizeZ()).intersection(ghostRegion));
borderIteration(player, ghostBlocks, Region.fromSize(region.getMinX(), region.getMinY(), region.getMaxZ(), region.getSizeX(), region.getSizeY(), 1).intersection(ghostRegion));
} else {
borderIteration(player, ghostBlocks, Region.fromSize(region.getMinX(), region.getMinY(), region.getMinZ(), 1, region.getSizeY(), region.getSizeZ()).intersection(ghostRegion));
borderIteration(player, ghostBlocks, Region.fromSize(region.getMinX(), region.getMinY(), region.getMinZ(), region.getSizeX(), 1, region.getSizeZ()).intersection(ghostRegion));
borderIteration(player, ghostBlocks, Region.fromSize(region.getMinX(), region.getMinY(), region.getMinZ(), region.getSizeX(), region.getSizeY(), 1).intersection(ghostRegion));
borderIteration(player, ghostBlocks, Region.fromSize(region.getMaxX()-1, region.getMinY(), region.getMinZ(), 1, region.getSizeY(), region.getSizeZ()).intersection(ghostRegion));
borderIteration(player, ghostBlocks, Region.fromSize(region.getMinX(), region.getMaxY()-1, region.getMinZ(), region.getSizeX(), 1, region.getSizeZ()).intersection(ghostRegion));
borderIteration(player, ghostBlocks, Region.fromSize(region.getMinX(), region.getMinY(), region.getMaxZ()-1, region.getSizeX(), region.getSizeY(), 1).intersection(ghostRegion));
}
lastLocation.put(entry.getKey(), location);
}
}
private void borderIteration(Player player, Set<Block> ghostBlocks, Region border) {
border.forEach((x, y, z) -> {
Block block = Config.world.getBlockAt(x, y, z);
if(ghostBlocks.add(block))
sendChange(player, block, Material.BARRIER);
});
}
private void sendChange(Player player, Block block, Material type) {
if(block.getType() == Material.AIR)
FlatteningWrapper.impl.sendBlockChange(player, block, type);
}
}

Datei anzeigen

@ -37,8 +37,10 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockDispenseEvent; import org.bukkit.event.block.BlockDispenseEvent;
import org.bukkit.event.block.BlockFromToEvent; import org.bukkit.event.block.BlockFromToEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.entity.FoodLevelChangeEvent; import org.bukkit.event.entity.FoodLevelChangeEvent;
import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.entity.PlayerDeathEvent;
@ -217,4 +219,25 @@ public class Permanent implements Listener {
if(e.getItem().getType() == Material.TNT || FlatteningWrapper.impl.isFacingWater(block)) if(e.getItem().getType() == Material.TNT || FlatteningWrapper.impl.isFacingWater(block))
e.setCancelled(true); e.setCancelled(true);
} }
@EventHandler
public void blockPlace(BlockPlaceEvent event) {
Player player = event.getPlayer();
Block block = event.getBlock();
if(Fight.teams().stream().anyMatch(team -> team.getExtendRegion().inRegion(block)))
return;
event.setCancelled(true);
FightSystem.getMessage().sendPrefixless("NO_BLOCK_PLACE", player, ChatMessageType.ACTION_BAR);
}
@EventHandler
public void blockBreak(BlockBreakEvent event) {
Block block = event.getBlock();
if(Config.BlueExtendRegion.getMinY() <= block.getY())
return;
event.setCancelled(true);
FightSystem.getMessage().sendPrefixless("NO_BLOCK_BREAK", event.getPlayer(), ChatMessageType.ACTION_BAR);
}
} }

Datei anzeigen

@ -23,6 +23,9 @@ import com.comphenix.tinyprotocol.Reflection;
import com.comphenix.tinyprotocol.TinyProtocol; import com.comphenix.tinyprotocol.TinyProtocol;
import de.steamwar.fightsystem.ArenaMode; import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.events.TeamDeathEvent;
import de.steamwar.fightsystem.events.TeamLeaveEvent;
import de.steamwar.fightsystem.events.TeamSpawnEvent;
import de.steamwar.fightsystem.fight.Fight; import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightPlayer; import de.steamwar.fightsystem.fight.FightPlayer;
import de.steamwar.fightsystem.fight.FightTeam; import de.steamwar.fightsystem.fight.FightTeam;
@ -142,6 +145,11 @@ public class Recording implements Listener {
return packet; return packet;
} }
@EventHandler
public void onPlayerSpawn(TeamSpawnEvent e) {
GlobalRecorder.getInstance().playerJoins(e.getFightPlayer().getEntity(), e.getFightPlayer().getUser());
}
@EventHandler(priority = EventPriority.HIGH) @EventHandler(priority = EventPriority.HIGH)
public void onPlayerMove(PlayerMoveEvent e){ public void onPlayerMove(PlayerMoveEvent e){
if(isNotSent(e.getPlayer())) if(isNotSent(e.getPlayer()))
@ -151,19 +159,13 @@ public class Recording implements Listener {
} }
@EventHandler @EventHandler
public void onPlayerDeath(PlayerDeathEvent e) { public void onPlayerDeath(TeamDeathEvent e) {
if(isNotSent(e.getEntity())) GlobalRecorder.getInstance().entityDespawns(e.getFightPlayer().getEntity());
return;
GlobalRecorder.getInstance().entityDespawns(e.getEntity());
} }
@EventHandler @EventHandler
public void onPlayerQuit(PlayerQuitEvent e){ public void onPlayerLeave(TeamLeaveEvent e) {
if(isNotSent(e.getPlayer())) GlobalRecorder.getInstance().entityDespawns(e.getFightPlayer().getEntity());
return;
GlobalRecorder.getInstance().entityDespawns(e.getPlayer());
} }
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)

Datei anzeigen

@ -21,110 +21,106 @@ package de.steamwar.fightsystem.listener;
import de.steamwar.fightsystem.ArenaMode; import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.events.BoardingEvent;
import de.steamwar.fightsystem.events.TeamDeathEvent;
import de.steamwar.fightsystem.events.TeamSpawnEvent;
import de.steamwar.fightsystem.fight.Fight; import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightPlayer;
import de.steamwar.fightsystem.fight.FightTeam; import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.OneShotStateDependent;
import de.steamwar.fightsystem.states.StateDependentListener; import de.steamwar.fightsystem.states.StateDependentListener;
import de.steamwar.fightsystem.utils.Region; import de.steamwar.fightsystem.states.StateDependentTask;
import net.md_5.bungee.api.ChatMessageType;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.block.Block;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerQuitEvent;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.logging.Level;
public class TeamArea implements Listener { public class TeamArea implements Listener {
private static final Set<Player> realSpectator = new HashSet<>(); private final FightTeam team;
private final Border spectatorBorder;
private final Border bordingBorder;
private final Set<Player> realSpectator = new HashSet<>();
public TeamArea(FightTeam team) {
this.team = team;
this.spectatorBorder = new Border(team.getExtendRegion(), false, 5, "NO_TEAMAREA");
this.bordingBorder = new Border(team.getExtendRegion().to2d(), true, 1, "NO_ENTERN");
public TeamArea() {
new StateDependentListener(ArenaMode.AntiTest, FightState.All, this); new StateDependentListener(ArenaMode.AntiTest, FightState.All, this);
new StateDependentTask(ArenaMode.AntiTest, FightState.TeamFix, this::realSpectatorCheck, 1, 1);
new OneShotStateDependent(ArenaMode.AntiTest, FightState.Spectate, () -> Fight.teams().forEach(t -> t.getPlayers().forEach(this::teamSpectator)));
} }
@EventHandler @EventHandler
public void teamAreas(PlayerMoveEvent event) { public void playerJoin(PlayerJoinEvent e) {
Player player = event.getPlayer(); Player player = e.getPlayer();
if(Config.isReferee(player)) if(Fight.getPlayerTeam(player) != team && !Config.isReferee(player))
return; spectatorBorder.addPlayer(player);
}
FightTeam team = Fight.getPlayerTeam(player); @EventHandler
Fight.teams().forEach(t -> checkInTeamRegion(event, t, player, team)); public void teamJoin(TeamSpawnEvent e) {
FightPlayer fightPlayer = e.getFightPlayer();
if(fightPlayer.getTeam() == team) {
fightPlayer.ifPlayer(player -> {
spectatorBorder.removePlayer(player);
bordingBorder.addPlayer(player);
});
}
}
@EventHandler
public void boarding(BoardingEvent e) {
FightPlayer fightPlayer = e.getFightPlayer();
if(fightPlayer.getTeam() == team) {
fightPlayer.ifPlayer(bordingBorder::removePlayer);
} else {
fightPlayer.ifPlayer(spectatorBorder::removePlayer);
}
}
@EventHandler
public void teamDeath(TeamDeathEvent e) {
teamSpectator(e.getFightPlayer());
}
private void teamSpectator(FightPlayer fightPlayer) {
if(fightPlayer.getTeam() == team) {
fightPlayer.ifPlayer(bordingBorder::removePlayer);
} else {
fightPlayer.ifPlayer(spectatorBorder::addPlayer);
}
} }
@EventHandler @EventHandler
public void playerQuit(PlayerQuitEvent e) { public void playerQuit(PlayerQuitEvent e) {
realSpectator.remove(e.getPlayer()); Player player = e.getPlayer();
spectatorBorder.removePlayer(player);
bordingBorder.removePlayer(player);
realSpectator.remove(player);
} }
@EventHandler private void realSpectatorCheck() {
public void blockPlace(BlockPlaceEvent event) { for(FightPlayer fightPlayer : team.getPlayers()) {
Player player = event.getPlayer(); if(fightPlayer.isLiving())
Block block = event.getBlock(); continue;
if(Config.BlueExtendRegion.inRegion(block) || Config.RedExtendRegion.inRegion(block))
return;
event.setCancelled(true); fightPlayer.ifPlayer(player -> {
FightSystem.getMessage().sendPrefixless("NO_BLOCK_PLACE", player, ChatMessageType.ACTION_BAR); boolean inRegion = team.getExtendRegion().playerInRegion(player.getLocation());
} if(inRegion && !realSpectator.contains(player)) {
Fight.pseudoSpectator(player, false);
@EventHandler realSpectator.add(player);
public void blockBreak(BlockBreakEvent event) { }else if(!inRegion && realSpectator.contains(player)) {
Block block = event.getBlock(); Fight.pseudoSpectator(player, true);
if(Config.BlueExtendRegion.getMinY() <= block.getY()) realSpectator.remove(player);
return; }
});
event.setCancelled(true);
FightSystem.getMessage().sendPrefixless("NO_BLOCK_BREAK", event.getPlayer(), ChatMessageType.ACTION_BAR);
}
private void checkInTeamRegion(PlayerMoveEvent event, FightTeam team, Player player, FightTeam playerTeam) {
boolean spectator = player.getGameMode() == GameMode.SPECTATOR;
if(!spectator && playerTeam != null && playerTeam.canPlayerEntern(player))
return; // Player can entern
Region region = team.getExtendRegion();
boolean inRegion = region.in2dRegion(event.getTo());
if(team == playerTeam) {
if(spectator) {
realSpectator(inRegion, player);
} else if (!playerTeam.canPlayerEntern(player) && !inRegion) {
reset(event, "NO_ENTERN"); // Leaving prior to entern
}
return; // Always allowed in own region
} }
if(region.playerInRegion(event.getTo())) {
reset(event, "NO_TEAMAREA"); // Not allowed in region
if(team.getSchemRegion().playerInRegion(event.getTo()) && Config.PreperationArea >= 5){ // Preventing false positives due to small extension
player.kickPlayer(null);
Bukkit.getLogger().log(Level.INFO, player.getName() + " has entered a team area");
}
}
}
private void realSpectator(boolean inRegion, Player player) {
if(inRegion && !realSpectator.contains(player)) {
Fight.pseudoSpectator(player, false);
realSpectator.add(player);
}else if(!inRegion && realSpectator.contains(player)) {
Fight.pseudoSpectator(player, true);
realSpectator.remove(player);
}
}
private void reset(PlayerMoveEvent event, String message){
Player player = event.getPlayer();
player.teleport(event.getFrom());
FightSystem.getMessage().sendPrefixless(message, player, ChatMessageType.ACTION_BAR);
} }
} }

Datei anzeigen

@ -71,23 +71,26 @@ public class WaterRemover implements Listener {
event.setYield(0); //No drops (additionally to world config) event.setYield(0); //No drops (additionally to world config)
FightTeam spawn = tnt.remove(event.getEntity().getEntityId()); FightTeam spawn = tnt.remove(event.getEntity().getEntityId());
if(spawn != null && event.blockList().isEmpty() && Fight.getOpposite(spawn).getExtendRegion().inRegion(event.getLocation())) { if(spawn != null && !spawn.getExtendRegion().inRegion(event.getLocation())) {
checkBlock(event.getLocation().getBlock()); Block b = event.getLocation().getBlock();
checkBlock(b);
checkNeighbours(b);
} }
for(Block b : event.blockList()){ event.blockList().forEach(this::checkNeighbours);
//b cannot be water or air due to current explosion }
checkBlock(b.getRelative(BlockFace.UP)); private void checkNeighbours(Block b) {
checkBlock(b.getRelative(BlockFace.EAST)); checkBlock(b.getRelative(BlockFace.UP));
checkBlock(b.getRelative(BlockFace.WEST)); checkBlock(b.getRelative(BlockFace.EAST));
checkBlock(b.getRelative(BlockFace.NORTH)); checkBlock(b.getRelative(BlockFace.WEST));
checkBlock(b.getRelative(BlockFace.SOUTH)); checkBlock(b.getRelative(BlockFace.NORTH));
} checkBlock(b.getRelative(BlockFace.SOUTH));
checkBlock(b.getRelative(BlockFace.DOWN));
} }
private void checkBlock(Block b) { private void checkBlock(Block b) {
//do not remove outside teamareas //do not remove outside teamareasevent.getLocation().getBlock()
if(!Config.BlueExtendRegion.inRegion(b) && !Config.RedExtendRegion.inRegion(b)) if(!Config.BlueExtendRegion.inRegion(b) && !Config.RedExtendRegion.inRegion(b))
return; return;
@ -98,10 +101,6 @@ public class WaterRemover implements Listener {
if(b.getY() < MIN_Y) if(b.getY() < MIN_Y)
return; return;
checkBlock(b.getRelative(BlockFace.UP)); checkNeighbours(b);
checkBlock(b.getRelative(BlockFace.EAST));
checkBlock(b.getRelative(BlockFace.WEST));
checkBlock(b.getRelative(BlockFace.NORTH));
checkBlock(b.getRelative(BlockFace.SOUTH));
} }
} }

Datei anzeigen

@ -22,19 +22,17 @@ package de.steamwar.fightsystem.record;
import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependent; import de.steamwar.fightsystem.states.StateDependent;
import lombok.Getter;
import java.io.*; import java.io.*;
import java.util.zip.GZIPOutputStream; import java.util.zip.GZIPOutputStream;
public class FileRecorder extends StateDependent implements Recorder { public class FileRecorder extends StateDependent implements Recorder {
@Getter
private static final File file = new File(Config.world.getWorldFolder(), "recording.recording"); private static final File file = new File(Config.world.getWorldFolder(), "recording.recording");
private DataOutputStream outputStream; private DataOutputStream outputStream;
public static File getFile() {
return file;
}
public FileRecorder(){ public FileRecorder(){
super(Config.ReplayID == 0, FightState.Recording); super(Config.ReplayID == 0, FightState.Recording);
register(); register();

Datei anzeigen

@ -19,6 +19,8 @@
package de.steamwar.fightsystem.states; package de.steamwar.fightsystem.states;
import lombok.Getter;
import java.util.*; import java.util.*;
public enum FightState { public enum FightState {
@ -48,12 +50,9 @@ public enum FightState {
public static final Set<FightState> AntiSpectate = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(SPECTATE))); public static final Set<FightState> AntiSpectate = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(SPECTATE)));
private static final Map<IStateDependent, Boolean> stateDependentFeatures = new HashMap<>(); private static final Map<IStateDependent, Boolean> stateDependentFeatures = new HashMap<>();
@Getter
private static FightState fightState = PRE_LEADER_SETUP; private static FightState fightState = PRE_LEADER_SETUP;
public static FightState getFightState() {
return fightState;
}
public static void registerStateDependent(IStateDependent stateDependent){ public static void registerStateDependent(IStateDependent stateDependent){
if(stateDependent.enabled().isEmpty()) if(stateDependent.enabled().isEmpty())
return; return;

Datei anzeigen

@ -35,6 +35,7 @@ import de.steamwar.network.packets.common.FightEndsPacket;
import de.steamwar.sql.Replay; import de.steamwar.sql.Replay;
import de.steamwar.sql.SchematicNode; import de.steamwar.sql.SchematicNode;
import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.SteamwarUser;
import lombok.Getter;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import java.sql.Timestamp; import java.sql.Timestamp;
@ -46,6 +47,7 @@ import static de.steamwar.sql.Fight.create;
public class FightStatistics { public class FightStatistics {
@Getter
private static boolean unranked = false; private static boolean unranked = false;
public static void unrank() { public static void unrank() {
@ -53,10 +55,6 @@ public class FightStatistics {
FightUI.addSubtitle("UI_UNRANKED"); FightUI.addSubtitle("UI_UNRANKED");
} }
public static boolean isUnranked() {
return unranked;
}
private Timestamp starttime = Timestamp.from(Instant.now()); private Timestamp starttime = Timestamp.from(Instant.now());
public FightStatistics() { public FightStatistics() {

Datei anzeigen

@ -31,6 +31,7 @@ import de.steamwar.fightsystem.states.OneShotStateDependent;
import de.steamwar.fightsystem.states.StateDependentCountdown; import de.steamwar.fightsystem.states.StateDependentCountdown;
import de.steamwar.fightsystem.states.StateDependentTask; import de.steamwar.fightsystem.states.StateDependentTask;
import de.steamwar.fightsystem.winconditions.Wincondition; import de.steamwar.fightsystem.winconditions.Wincondition;
import lombok.Getter;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -43,10 +44,8 @@ import java.util.stream.Collectors;
public class FightUI { public class FightUI {
@Getter
private static FightUI instance; private static FightUI instance;
public static FightUI getInstance() {
return instance;
}
public FightUI() { public FightUI() {
new StateDependentTask(ArenaMode.AntiReplay, FightState.All, this::update, 20, 20); new StateDependentTask(ArenaMode.AntiReplay, FightState.All, this::update, 20, 20);

Datei anzeigen

@ -22,6 +22,7 @@ package de.steamwar.fightsystem.utils;
import de.steamwar.core.VersionDependent; import de.steamwar.core.VersionDependent;
import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.FightSystem;
import org.bukkit.DyeColor; import org.bukkit.DyeColor;
import org.bukkit.Material;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -49,4 +50,5 @@ public interface FlatteningWrapper {
boolean isFacingWater(Block dispenser); boolean isFacingWater(Block dispenser);
boolean isCrouching(Player player); boolean isCrouching(Player player);
void sendBlockChange(Player player, Block block, Material type);
} }

Datei anzeigen

@ -90,6 +90,10 @@ public class Hull {
} }
} }
public boolean isLocationHidden(Player player, Location location) {
return players.contains(player) && region.inRegion(location) && !visibility.get(new IntVector(location).toId(region));
}
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public void addPlayer(Player player) { public void addPlayer(Player player) {
if(players.add(player)) { if(players.add(player)) {
@ -201,7 +205,7 @@ public class Hull {
while(rit.hasNext()) { while(rit.hasNext()) {
REntity entity = rit.next(); REntity entity = rit.next();
if(uncoveredSet.contains(new IntVector(new Location(Config.world, entity.getX(), entity.getY(), entity.getZ())))) { //TODO more precise if(uncoveredSet.contains(new IntVector(new Location(Config.world, entity.getX(), entity.getY(), entity.getZ())))) { //TODO more precise
it.remove(); rit.remove();
entity.hide(false); entity.hide(false);
} }
} }

Datei anzeigen

@ -19,8 +19,11 @@
package de.steamwar.fightsystem.utils; package de.steamwar.fightsystem.utils;
import com.comphenix.tinyprotocol.Reflection;
import com.comphenix.tinyprotocol.TinyProtocol;
import de.steamwar.core.Core; import de.steamwar.core.Core;
import de.steamwar.entity.REntity; import de.steamwar.entity.REntity;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.fight.Fight; import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightPlayer; import de.steamwar.fightsystem.fight.FightPlayer;
import de.steamwar.fightsystem.fight.FightTeam; import de.steamwar.fightsystem.fight.FightTeam;
@ -29,7 +32,9 @@ import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependent; import de.steamwar.fightsystem.states.StateDependent;
import de.steamwar.fightsystem.states.StateDependentListener; import de.steamwar.fightsystem.states.StateDependentListener;
import de.steamwar.fightsystem.states.StateDependentTask; import de.steamwar.fightsystem.states.StateDependentTask;
import de.steamwar.techhider.TechHider;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -43,28 +48,41 @@ import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerQuitEvent;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.function.BiFunction;
import java.util.function.Function;
public class HullHider implements Listener { public class HullHider implements Listener {
private static final boolean ENABLED = TechHiderWrapper.ENABLED && Core.getVersion() >= 18; private static final boolean ENABLED = TechHiderWrapper.ENABLED && Core.getVersion() >= 18;
private final Map<FightTeam, Hull> hulls = new HashMap<>(); private final Map<FightTeam, Hull> hulls = new HashMap<>();
private final Map<Class<?>, BiFunction<Player, Object, Object>> packetHiders = new HashMap<>();
public HullHider() { public HullHider() {
if(ENABLED) if(ENABLED)
Fight.teams().forEach(team -> hulls.put(team, new Hull(team))); Fight.teams().forEach(team -> hulls.put(team, new Hull(team)));
packetHiders.put(packetPlayOutWorldEvent, this::worldEventHider);
packetHiders.put(packetPlayOutExplosion, this::explosionHider);
posHiderGenerator("{nms.network.protocol.game}.PacketPlayOutWorldParticles", Core.getVersion() >= 18 ? double.class : float.class, 1.0);
posHiderGenerator("{nms.network.protocol.game}.PacketPlayOutNamedSoundEffect", int.class, 8.0);
if(Core.getVersion() >= 9 && Core.getVersion() < 18)
posHiderGenerator("{nms.network.protocol.game}.PacketPlayOutCustomSoundEffect", int.class, 8.0);
new StateDependentListener(ENABLED, FightState.Schem, this); new StateDependentListener(ENABLED, FightState.Schem, this);
new StateDependent(ENABLED, FightState.Schem) { new StateDependent(ENABLED, FightState.Schem) {
@Override @Override
public void enable() { public void enable() {
packetHiders.forEach(TinyProtocol.instance::addFilter);
Bukkit.getOnlinePlayers().forEach(HullHider.this::updatePlayer); Bukkit.getOnlinePlayers().forEach(HullHider.this::updatePlayer);
} }
@Override @Override
public void disable() { public void disable() {
Bukkit.getOnlinePlayers().forEach(player -> removePlayer(player, true)); Bukkit.getOnlinePlayers().forEach(player -> removePlayer(player, true));
packetHiders.forEach(TinyProtocol.instance::removeFilter);
} }
}.register(); }.register();
new StateDependentTask(ENABLED, FightState.Schem, this::onTick, 0, 1); new StateDependentTask(ENABLED, FightState.Schem, this::onTick, 0, 1);
@ -144,4 +162,46 @@ public class HullHider implements Listener {
public void despawnREntity(REntity e) { public void despawnREntity(REntity e) {
hulls.values().forEach(hull -> hull.removeREntity(e)); hulls.values().forEach(hull -> hull.removeREntity(e));
} }
private static final Class<?> packetPlayOutWorldEvent = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutWorldEvent");
private static final Reflection.FieldAccessor<?> worldEventPosition = Reflection.getField(packetPlayOutWorldEvent, TechHider.blockPosition, 0);
public static final Reflection.FieldAccessor<Integer> blockPositionY = Reflection.getField("{nms.core}.BaseBlockPosition", int.class, 1);
private Object worldEventHider(Player player, Object packet) {
Object baseBlock = worldEventPosition.get(packet);
return packetHider(player, packet, new Location(Config.world, TechHider.blockPositionX.get(baseBlock), blockPositionY.get(baseBlock), TechHider.blockPositionZ.get(baseBlock)));
}
private static final Class<?> packetPlayOutExplosion = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutExplosion");
private static final Reflection.FieldAccessor<List> explosionBlocks = Reflection.getField(packetPlayOutExplosion, List.class, 0);
private static final Function<Object, Location> explosionLocation = posPacketToLocation(packetPlayOutExplosion, double.class, 1.0);
private Object explosionHider(Player player, Object packet) {
if(explosionBlocks.get(packet).isEmpty())
return packetHider(player, packet, explosionLocation.apply(packet));
return packet;
}
private void posHiderGenerator(String typeName, Class<? extends Number> posType, double factor) {
Class<?> type = Reflection.getClass(typeName);
Function<Object, Location> location = posPacketToLocation(type, posType, factor);
packetHiders.put(type, (player, packet) -> packetHider(player, packet, location.apply(packet)));
}
private static Function<Object, Location> posPacketToLocation(Class<?> type, Class<? extends Number> posType, double factor) {
Reflection.FieldAccessor<? extends Number> x = Reflection.getField(type, posType, 0);
Reflection.FieldAccessor<? extends Number> y = Reflection.getField(type, posType, 1);
Reflection.FieldAccessor<? extends Number> z = Reflection.getField(type, posType, 2);
return packet -> new Location(Config.world, x.get(packet).doubleValue()/factor, y.get(packet).doubleValue()/factor, z.get(packet).doubleValue()/factor);
}
private Object packetHider(Player player, Object packet, Location location) {
for(Hull hull : hulls.values()) {
if(hull.isLocationHidden(player, location))
return null;
}
return packet;
}
} }

Datei anzeigen

@ -25,51 +25,26 @@ import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;
import java.util.List;
public class ItemBuilder { public class ItemBuilder {
private final ItemStack item; private final ItemStack item;
private final ItemMeta meta; private final ItemMeta meta;
public ItemBuilder(Material matrial) { public ItemBuilder(Material material) {
item = new ItemStack(matrial); item = new ItemStack(material);
meta = item.getItemMeta();
}
public ItemBuilder(Material matrial, int amount) {
item = new ItemStack(matrial, amount);
meta = item.getItemMeta(); meta = item.getItemMeta();
meta.addItemFlags(ItemFlag.values());
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public ItemBuilder(Material matrial, short subid) { public ItemBuilder(Material material, short subid) {
item = new ItemStack(matrial, 1, subid); item = new ItemStack(material, 1, subid);
meta = item.getItemMeta(); meta = item.getItemMeta();
meta.addItemFlags(ItemFlag.values());
} }
public ItemBuilder removeAllAttributes() { public ItemBuilder enchant() {
meta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES); meta.addEnchant(Enchantment.DURABILITY, 1, true);
meta.addItemFlags(ItemFlag.HIDE_DESTROYS);
meta.addItemFlags(ItemFlag.HIDE_UNBREAKABLE);
meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
meta.addItemFlags(ItemFlag.HIDE_PLACED_ON);
meta.addItemFlags(ItemFlag.HIDE_POTION_EFFECTS);
return this;
}
public ItemBuilder setDisplayName(String name) {
meta.setDisplayName(name);
return this;
}
public ItemBuilder addLore(List<String> lore) {
meta.setLore(lore);
return this;
}
public ItemBuilder addEnchantment(Enchantment enchantment, int level) {
meta.addEnchant(enchantment, level, true);
return this; return this;
} }
@ -77,5 +52,4 @@ public class ItemBuilder {
item.setItemMeta(meta); item.setItemMeta(meta);
return item; return item;
} }
} }

Datei anzeigen

@ -19,7 +19,11 @@
package de.steamwar.fightsystem.utils; package de.steamwar.fightsystem.utils;
import lombok.Getter;
@Getter
public class Message { public class Message {
private final String msg; private final String msg;
private final Object[] params; private final Object[] params;
@ -27,12 +31,4 @@ public class Message {
this.msg = msg; this.msg = msg;
this.params = params; this.params = params;
} }
public String getMsg() {
return msg;
}
public Object[] getParams() {
return params;
}
} }

Datei anzeigen

@ -20,13 +20,26 @@
package de.steamwar.fightsystem.utils; package de.steamwar.fightsystem.utils;
import de.steamwar.techhider.ProtocolUtils; import de.steamwar.techhider.ProtocolUtils;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import java.util.function.ObjIntConsumer; import java.util.function.ObjIntConsumer;
@Getter
@AllArgsConstructor
public class Region { public class Region {
public static Region withExtension(int minX, int minY, int minZ, int sizeX, int sizeY, int sizeZ, int extendX, int extendY, int extendZ) {
return Region.fromSize(minX - extendX, minY - extendY, minZ - extendZ,
sizeX + extendX * 2, sizeY + extendY * 2, sizeZ + extendZ * 2);
}
public static Region fromSize(int minX, int minY, int minZ, int sizeX, int sizeY, int sizeZ) {
return new Region(minX, minY, minZ, minX+sizeX, minY+sizeY, minZ+sizeZ);
}
private final int minX; private final int minX;
private final int minY; private final int minY;
private final int minZ; private final int minZ;
@ -34,44 +47,6 @@ public class Region {
private final int maxY; private final int maxY;
private final int maxZ; private final int maxZ;
public Region(int minX, int minY, int minZ, int sizeX, int sizeY, int sizeZ, int extendX, int extendY, int extendZ) {
this(minX - extendX, minY - extendY, minZ - extendZ,
sizeX + extendX * 2, sizeY + extendY * 2, sizeZ + extendZ * 2);
}
public Region(int minX, int minY, int minZ, int sizeX, int sizeY, int sizeZ) {
this.minX = minX;
this.minY = minY;
this.minZ = minZ;
this.maxX = minX + sizeX;
this.maxY = minY + sizeY;
this.maxZ = minZ + sizeZ;
}
public int getMinX() {
return minX;
}
public int getMinY() {
return minY;
}
public int getMinZ() {
return minZ;
}
public int getMaxX() {
return maxX;
}
public int getMaxY() {
return maxY;
}
public int getMaxZ() {
return maxZ;
}
public int getSizeX() { public int getSizeX() {
return maxX - minX; return maxX - minX;
} }
@ -161,6 +136,18 @@ public class Region {
return in2dRegion(x, z) && minY <= y && y < maxY; return in2dRegion(x, z) && minY <= y && y < maxY;
} }
public Region intersection(Region other) {
int x = Math.max(minX, other.minX);
int y = Math.max(minY, other.minY);
int z = Math.max(minZ, other.minZ);
return new Region(x, y, z, Math.min(maxX, other.maxX), Math.min(maxY, other.maxY), Math.min(maxZ, other.maxZ));
}
public Region to2d() {
return new Region(minX, Integer.MIN_VALUE/2, minZ, maxX, Integer.MAX_VALUE/2, maxZ);
}
public interface TriConsumer<T, V, U>{ public interface TriConsumer<T, V, U>{
void accept(T x, V y, U z); void accept(T x, V y, U z);
} }

Datei anzeigen

@ -24,6 +24,7 @@ import de.steamwar.fightsystem.countdown.Countdown;
import de.steamwar.fightsystem.fight.Fight; import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightTeam; import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.states.StateDependentCountdown; import de.steamwar.fightsystem.states.StateDependentCountdown;
import lombok.Getter;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
@ -34,8 +35,10 @@ import java.util.stream.Collectors;
public abstract class Wincondition { public abstract class Wincondition {
@Getter
protected static WinconditionPercent percentWincondition = null; protected static WinconditionPercent percentWincondition = null;
protected static StateDependentCountdown timeOverCountdown = null; protected static StateDependentCountdown timeOverCountdown = null;
@Getter
protected static final List<PrintableWincondition> printableWinconditions = new ArrayList<>(); protected static final List<PrintableWincondition> printableWinconditions = new ArrayList<>();
private final String windescription; private final String windescription;
@ -61,14 +64,6 @@ public abstract class Wincondition {
return Fight.getPlayerTeam((LivingEntity) player); return Fight.getPlayerTeam((LivingEntity) player);
} }
public static List<PrintableWincondition> getPrintableWinconditions(){
return printableWinconditions;
}
public static WinconditionPercent getPercentWincondition() {
return percentWincondition;
}
protected void comparisonWin(ToDoubleFunction<FightTeam> evaluate, String winMessage, String tieMessage) { protected void comparisonWin(ToDoubleFunction<FightTeam> evaluate, String winMessage, String tieMessage) {
double max = Fight.teams().stream().mapToDouble(evaluate).max().orElseThrow(() -> new SecurityException("No teams present")); double max = Fight.teams().stream().mapToDouble(evaluate).max().orElseThrow(() -> new SecurityException("No teams present"));
List<FightTeam> teams = Fight.teams().stream().filter(team -> evaluate.applyAsDouble(team) == max).collect(Collectors.toList()); List<FightTeam> teams = Fight.teams().stream().filter(team -> evaluate.applyAsDouble(team) == max).collect(Collectors.toList());

Datei anzeigen

@ -19,16 +19,13 @@
package de.steamwar.fightsystem.winconditions; package de.steamwar.fightsystem.winconditions;
import de.steamwar.fightsystem.events.TeamDeathEvent;
import de.steamwar.fightsystem.fight.Fight; import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightPlayer;
import de.steamwar.fightsystem.fight.FightTeam; import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentListener; import de.steamwar.fightsystem.states.StateDependentListener;
import org.bukkit.entity.Entity;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.player.PlayerQuitEvent;
public class WinconditionAllDead extends Wincondition implements Listener { public class WinconditionAllDead extends Wincondition implements Listener {
@ -38,25 +35,12 @@ public class WinconditionAllDead extends Wincondition implements Listener {
} }
@EventHandler @EventHandler
public void handlePlayerDeath(EntityDeathEvent event) { public void handlePlayerDeath(TeamDeathEvent event) {
handleDeath(event.getEntity()); FightTeam team = event.getFightPlayer().getTeam();
}
@EventHandler if(team.getAlivePlayers() > 0)
public void handlePlayerQuit(PlayerQuitEvent event) {
handleDeath(event.getPlayer());
}
private void handleDeath(Entity player){
FightTeam team = isTarget(player);
if(team == null)
return; return;
for(FightPlayer fp : team.getPlayers()) {
if(fp.isLiving() && fp.getEntity() != player)
return;
}
win(Fight.getOpposite(team), "WIN_ALL_DEAD", team.getPrefix()); win(Fight.getOpposite(team), "WIN_ALL_DEAD", team.getPrefix());
} }
} }

Datei anzeigen

@ -19,16 +19,14 @@
package de.steamwar.fightsystem.winconditions; package de.steamwar.fightsystem.winconditions;
import de.steamwar.fightsystem.events.TeamDeathEvent;
import de.steamwar.fightsystem.fight.Fight; import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightPlayer;
import de.steamwar.fightsystem.fight.FightTeam; import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentListener; import de.steamwar.fightsystem.states.StateDependentListener;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.player.PlayerQuitEvent;
public class WinconditionCaptainDead extends Wincondition implements Listener { public class WinconditionCaptainDead extends Wincondition implements Listener {
@ -38,22 +36,12 @@ public class WinconditionCaptainDead extends Wincondition implements Listener {
} }
@EventHandler @EventHandler
public void handlePlayerDeath(EntityDeathEvent event) { public void handlePlayerDeath(TeamDeathEvent event) {
handleDeath(event.getEntity()); FightPlayer leader = event.getFightPlayer();
} if(!leader.isLeader())
@EventHandler
public void handlePlayerQuit(PlayerQuitEvent event) {
handleDeath(event.getPlayer());
}
private void handleDeath(Entity player){
FightTeam team = isTarget(player);
if(team == null)
return; return;
if(team.isPlayerLeader((LivingEntity) player)) { FightTeam team = leader.getTeam();
win(Fight.getOpposite(team), "WIN_LEADER_DEAD", team.getPrefix() + team.getLeader().getEntity().getName()); win(Fight.getOpposite(team), "WIN_LEADER_DEAD", team.getPrefix() + leader.getEntity().getName());
}
} }
} }

Datei anzeigen

@ -46,11 +46,6 @@ mainClassName = ''
allprojects { allprojects {
repositories { repositories {
mavenCentral() mavenCentral()
jcenter()
maven {
url = uri("https://repo.codemc.io/repository/maven-snapshots/")
}
maven { maven {
url = uri('https://hub.spigotmc.org/nexus/content/repositories/snapshots/') url = uri('https://hub.spigotmc.org/nexus/content/repositories/snapshots/')