Code cleanup, Utilize Lombok #414
FightSystem_10/src/de/steamwar/fightsystem/utils
FightSystem_12/src/de/steamwar/fightsystem/utils
FightSystem_14/src/de/steamwar/fightsystem/utils
FightSystem_15/src/de/steamwar/fightsystem/utils
FightSystem_9/src/de/steamwar/fightsystem/utils
FightSystem_Core/src/de/steamwar/fightsystem
@ -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();
|
||||||
|
@ -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();
|
||||||
|
@ -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();
|
||||||
|
@ -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();
|
||||||
|
@ -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();
|
||||||
|
@ -39,15 +39,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;
|
||||||
@ -97,7 +100,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();
|
||||||
@ -194,15 +197,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;
|
||||||
}
|
}
|
||||||
|
@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
@ -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);
|
||||||
|
@ -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
|
||||||
|
@ -27,6 +27,7 @@ import de.steamwar.fightsystem.ArenaMode;
|
|||||||
import de.steamwar.fightsystem.Config;
|
import de.steamwar.fightsystem.Config;
|
||||||
import de.steamwar.fightsystem.FightSystem;
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
import de.steamwar.fightsystem.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;
|
||||||
@ -39,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 {
|
||||||
@ -76,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;
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,8 @@ import de.steamwar.fightsystem.countdown.EnternCountdown;
|
|||||||
import de.steamwar.fightsystem.events.TeamDeathEvent;
|
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;
|
||||||
@ -36,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;
|
||||||
|
|
||||||
@ -113,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++;
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,6 @@ import de.steamwar.techhider.ProtocolUtils;
|
|||||||
import lombok.Getter;
|
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;
|
||||||
@ -58,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);
|
||||||
}
|
}
|
||||||
@ -66,30 +65,30 @@ 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
|
@Getter
|
||||||
|
@ -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);
|
||||||
|
@ -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;
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
|
@ -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());
|
|
||||||
}
|
|
||||||
}
|
|
@ -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();
|
||||||
|
@ -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;
|
||||||
|
@ -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() {
|
||||||
|
@ -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);
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -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());
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren