The big refactoring #238
@ -31,9 +31,12 @@ import de.steamwar.fightsystem.IFightSystem;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.UnpooledByteBufAllocator;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import static de.steamwar.fightsystem.utils.ITechHider.bypass;
|
||||
@ -41,9 +44,19 @@ import static de.steamwar.fightsystem.utils.ITechHider.bypass;
|
||||
class TechHider_12 {
|
||||
private TechHider_12(){}
|
||||
|
||||
private static final short obfuscateShift4 = (short)(Config.ObfuscateWith << 4);
|
||||
static Set<Integer> getHiddenBlockIds() {
|
||||
Set<Integer> hiddenBlockIds = new HashSet<>();
|
||||
for(String tag : Config.HiddenBlocks){
|
||||
hiddenBlockIds.add(Material.matchMaterial(tag).getId() << 4);
|
||||
}
|
||||
return hiddenBlockIds;
|
||||
}
|
||||
|
||||
static PacketAdapter chunkHider(){
|
||||
static int getObfuscateWith() {
|
||||
return Material.matchMaterial(Config.ObfuscateWith).getId() << 4;
|
||||
}
|
||||
|
||||
static PacketAdapter chunkHider(Set<Integer> hiddenBlockIds, int obfuscateWith){
|
||||
return new PacketAdapter(IFightSystem.getPlugin(), PacketType.Play.Server.MAP_CHUNK) {
|
||||
@Override
|
||||
public void onPacketSending(PacketEvent e) {
|
||||
@ -91,8 +104,8 @@ class TechHider_12 {
|
||||
int entry = ITechHider.readVarInt(data, i);
|
||||
i += ITechHider.readVarIntLength(data, i);
|
||||
|
||||
if(Config.HiddenBlocks.contains(entry >> 4)){
|
||||
entry = obfuscateShift4;
|
||||
if(hiddenBlockIds.contains(entry)){
|
||||
entry = obfuscateWith;
|
||||
changed = true;
|
||||
}
|
||||
buffer.writeBytes(ITechHider.writeVarInt(entry));
|
||||
|
@ -30,16 +30,41 @@ import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.IFightSystem;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.UnpooledByteBufAllocator;
|
||||
import net.minecraft.server.v1_14_R1.Block;
|
||||
import net.minecraft.server.v1_14_R1.IBlockData;
|
||||
import net.minecraft.server.v1_14_R1.IRegistry;
|
||||
import net.minecraft.server.v1_14_R1.MinecraftKey;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.LongBuffer;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static de.steamwar.fightsystem.utils.ITechHider.bypass;
|
||||
|
||||
public class TechHider_14 {
|
||||
private TechHider_14(){}
|
||||
|
||||
static PacketAdapter chunkHider(){
|
||||
static Set<Integer> getHiddenBlockIds() {
|
||||
Set<Integer> hiddenBlockIds = new HashSet<>();
|
||||
for(String tag : Config.HiddenBlocks){
|
||||
for(IBlockData data : IRegistry.BLOCK.get(new MinecraftKey(tag)).getStates().a()){
|
||||
hiddenBlockIds.add(Block.getCombinedId(data));
|
||||
}
|
||||
}
|
||||
return hiddenBlockIds;
|
||||
}
|
||||
|
||||
static int getObfuscateWith() {
|
||||
return Block.getCombinedId(IRegistry.BLOCK.get(new MinecraftKey(Config.ObfuscateWith)).getBlockData());
|
||||
}
|
||||
|
||||
static PacketAdapter chunkHider(Set<Integer> hiddenBlockIds, int obfuscateWith){
|
||||
/*
|
||||
* Bevor editing this function read and understand: https://wiki.vg/Chunk_Format
|
||||
* */
|
||||
return new PacketAdapter(IFightSystem.getPlugin(), PacketType.Play.Server.MAP_CHUNK) {
|
||||
@Override
|
||||
public void onPacketSending(PacketEvent e) {
|
||||
@ -52,16 +77,9 @@ public class TechHider_14 {
|
||||
if(bypass(p, chunkX, chunkZ))
|
||||
return;
|
||||
|
||||
PacketContainer cached = ITechHider.packetCache.get(packet);
|
||||
if(cached != null){
|
||||
e.setPacket(cached);
|
||||
return;
|
||||
}
|
||||
|
||||
cached = packet.deepClone();
|
||||
ITechHider.packetCache.put(packet, cached);
|
||||
e.setPacket(cached);
|
||||
StructureModifier<List<NbtBase<?>>> list = cached.getListNbtModifier();
|
||||
packet = packet.shallowClone();
|
||||
e.setPacket(packet);
|
||||
StructureModifier<List<NbtBase<?>>> list = packet.getListNbtModifier();
|
||||
List<NbtBase<?>> nmsTags = list.read(0);
|
||||
boolean changed = false;
|
||||
for(int i = nmsTags.size() - 1; i >= 0; i--){
|
||||
@ -78,30 +96,25 @@ public class TechHider_14 {
|
||||
}
|
||||
|
||||
changed = false;
|
||||
StructureModifier<byte[]> byteArray = cached.getByteArrays();
|
||||
StructureModifier<byte[]> byteArray = packet.getByteArrays();
|
||||
int primaryBitMask = ints.read(2);
|
||||
int numChunkSections = 0;
|
||||
while(primaryBitMask != 0){
|
||||
numChunkSections += primaryBitMask & 1;
|
||||
primaryBitMask >>= 1;
|
||||
}
|
||||
byte [] data = byteArray.read(0);
|
||||
byte[] data = byteArray.read(0);
|
||||
ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.directBuffer(data.length + 100);
|
||||
int i = 0;
|
||||
|
||||
while(numChunkSections > 0){
|
||||
int chunkY = 0;
|
||||
while(primaryBitMask != 0){
|
||||
while((primaryBitMask & 1) == 0){
|
||||
primaryBitMask >>= 1;
|
||||
chunkY++;
|
||||
}
|
||||
|
||||
buffer.writeBytes(data, i, 2); // Block count
|
||||
i += 2;
|
||||
byte bitsPerBlock = data[i++];
|
||||
buffer.writeByte(bitsPerBlock);
|
||||
if(bitsPerBlock < 4)
|
||||
bitsPerBlock = 4;
|
||||
else if(bitsPerBlock > 8){
|
||||
bitsPerBlock = 14;
|
||||
buffer.writeByte(data[++i]);
|
||||
}
|
||||
|
||||
if(bitsPerBlock != 14){
|
||||
if(bitsPerBlock < 9){
|
||||
int paletteLength = ITechHider.readVarInt(data, i);
|
||||
int paletteLengthLength = ITechHider.readVarIntLength(data, i);
|
||||
buffer.writeBytes(data, i, paletteLengthLength);
|
||||
@ -110,30 +123,48 @@ public class TechHider_14 {
|
||||
int blockId = ITechHider.readVarInt(data, i);
|
||||
int actPaletteLength = ITechHider.readVarIntLength(data, i);
|
||||
|
||||
if(Config.HiddenBlocks.contains(blockId)){
|
||||
byte[] a = ITechHider.writeVarInt(Config.ObfuscateWith);
|
||||
buffer.writeBytes(a);
|
||||
if(hiddenBlockIds.contains(blockId)){
|
||||
buffer.writeBytes(ITechHider.writeVarInt(obfuscateWith));
|
||||
changed = true;
|
||||
}else{
|
||||
buffer.writeBytes(data, i, actPaletteLength);
|
||||
}
|
||||
i += actPaletteLength;
|
||||
}
|
||||
|
||||
//We modify only the chunk palette for performance reasons
|
||||
int dataArrayLength = ITechHider.readVarInt(data, i);
|
||||
int dataArrayLengthLength = ITechHider.readVarIntLength(data, i);
|
||||
buffer.writeBytes(data, i, dataArrayLength * 8 + dataArrayLengthLength);
|
||||
i += dataArrayLengthLength;
|
||||
i += dataArrayLength * 8;
|
||||
}else{
|
||||
//Full Chunk/no palette, so the chunk has to be crawled through
|
||||
int dataArrayLength = ITechHider.readVarInt(data, i);
|
||||
int dataArrayLengthLength = ITechHider.readVarIntLength(data, i);
|
||||
buffer.writeBytes(data, i, dataArrayLength*8 + dataArrayLengthLength);
|
||||
buffer.writeBytes(data, i, dataArrayLengthLength);
|
||||
i += dataArrayLengthLength;
|
||||
|
||||
ByteBuffer source = ByteBuffer.wrap(data, i, dataArrayLength * 8);
|
||||
VariableValueArray values = new VariableValueArray(bitsPerBlock, dataArrayLength, source.asLongBuffer());
|
||||
|
||||
for(int pos = 0; pos < 4096; pos++){
|
||||
if(hiddenBlockIds.contains(values.get(pos))){
|
||||
changed = true;
|
||||
values.set(pos, obfuscateWith);
|
||||
}
|
||||
}
|
||||
|
||||
for(long l : values.backing)
|
||||
buffer.writeLong(l);
|
||||
|
||||
i += dataArrayLength * 8;
|
||||
}
|
||||
numChunkSections--;
|
||||
|
||||
primaryBitMask >>= 1;
|
||||
chunkY++;
|
||||
}
|
||||
buffer.writeBytes(data, i, data.length - i);
|
||||
buffer.writeBytes(data, i, data.length - i); // MC appends a 0 byte at the end if there is a full chunk, idk why
|
||||
|
||||
if(changed){
|
||||
data = new byte[buffer.readableBytes()];
|
||||
@ -143,4 +174,46 @@ public class TechHider_14 {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private static final class VariableValueArray {
|
||||
private final long[] backing;
|
||||
private final int bitsPerValue;
|
||||
private final long valueMask;
|
||||
|
||||
public VariableValueArray(int bitsPerEntry, int dataArrayLength, LongBuffer buffer) {
|
||||
this.bitsPerValue = bitsPerEntry;
|
||||
this.backing = new long[dataArrayLength];
|
||||
buffer.get(backing);
|
||||
this.valueMask = (1L << this.bitsPerValue) - 1;
|
||||
}
|
||||
|
||||
public int get(int index) {
|
||||
index *= bitsPerValue;
|
||||
int i0 = index >> 6;
|
||||
int i1 = index & 0x3f;
|
||||
|
||||
long value = backing[i0] >>> i1;
|
||||
|
||||
// The value is divided over two long values
|
||||
if (i1 + bitsPerValue > 64) {
|
||||
value |= backing[++i0] << 64 - i1;
|
||||
}
|
||||
|
||||
return (int) (value & valueMask);
|
||||
}
|
||||
|
||||
public void set(int index, int value) {
|
||||
index *= bitsPerValue;
|
||||
int i0 = index >> 6;
|
||||
int i1 = index & 0x3f;
|
||||
|
||||
backing[i0] = this.backing[i0] & ~(this.valueMask << i1) | (value & valueMask) << i1;
|
||||
int i2 = i1 + bitsPerValue;
|
||||
// The value is divided over two long values
|
||||
if (i2 > 64) {
|
||||
i0++;
|
||||
backing[i0] = backing[i0] & -(1L << i2 - 64) | value >> 64 - i1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
/*
|
||||
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
|
||||
@ -19,182 +19,29 @@
|
||||
|
||||
package de.steamwar.fightsystem.utils;
|
||||
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.events.PacketAdapter;
|
||||
import com.comphenix.protocol.events.PacketContainer;
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import com.comphenix.protocol.reflect.StructureModifier;
|
||||
import com.comphenix.protocol.wrappers.nbt.NbtBase;
|
||||
import com.comphenix.protocol.wrappers.nbt.NbtCompound;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.IFightSystem;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.UnpooledByteBufAllocator;
|
||||
import org.bukkit.entity.Player;
|
||||
import net.minecraft.server.v1_15_R1.Block;
|
||||
import net.minecraft.server.v1_15_R1.IBlockData;
|
||||
import net.minecraft.server.v1_15_R1.IRegistry;
|
||||
import net.minecraft.server.v1_15_R1.MinecraftKey;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.LongBuffer;
|
||||
import java.util.List;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import static de.steamwar.fightsystem.utils.ITechHider.bypass;
|
||||
|
||||
public class TechHider_15 {
|
||||
class TechHider_15 {
|
||||
private TechHider_15(){}
|
||||
|
||||
static PacketAdapter chunkHider(){
|
||||
/*
|
||||
* Bevor editing this function read and understand: https://wiki.vg/Chunk_Format
|
||||
* */
|
||||
return new PacketAdapter(IFightSystem.getPlugin(), PacketType.Play.Server.MAP_CHUNK) {
|
||||
@Override
|
||||
public void onPacketSending(PacketEvent e) {
|
||||
PacketContainer packet = e.getPacket();
|
||||
StructureModifier<Integer> ints = packet.getIntegers();
|
||||
|
||||
int chunkX = ints.read(0);
|
||||
int chunkZ = ints.read(1);
|
||||
Player p = e.getPlayer();
|
||||
if(bypass(p, chunkX, chunkZ))
|
||||
return;
|
||||
|
||||
packet = packet.shallowClone();
|
||||
e.setPacket(packet);
|
||||
StructureModifier<List<NbtBase<?>>> list = packet.getListNbtModifier();
|
||||
List<NbtBase<?>> nmsTags = list.read(0);
|
||||
boolean changed = false;
|
||||
for(int i = nmsTags.size() - 1; i >= 0; i--){
|
||||
NbtBase<?> nbtBase = nmsTags.get(i);
|
||||
assert nbtBase instanceof NbtCompound;
|
||||
NbtCompound nbt = (NbtCompound) nbtBase;
|
||||
if(Config.HiddenBlockEntities.contains(nbt.getString("id"))){
|
||||
nmsTags.remove(i);
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
if(changed){
|
||||
list.write(0, nmsTags);
|
||||
}
|
||||
|
||||
changed = false;
|
||||
StructureModifier<byte[]> byteArray = packet.getByteArrays();
|
||||
int primaryBitMask = ints.read(2);
|
||||
byte[] data = byteArray.read(0);
|
||||
ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.directBuffer(data.length + 100);
|
||||
int i = 0;
|
||||
|
||||
int chunkY = 0;
|
||||
while(primaryBitMask != 0){
|
||||
while((primaryBitMask & 1) == 0){
|
||||
primaryBitMask >>= 1;
|
||||
chunkY++;
|
||||
}
|
||||
|
||||
buffer.writeBytes(data, i, 2); // Block count
|
||||
i += 2;
|
||||
byte bitsPerBlock = data[i++];
|
||||
buffer.writeByte(bitsPerBlock);
|
||||
|
||||
if(bitsPerBlock < 9){
|
||||
int paletteLength = ITechHider.readVarInt(data, i);
|
||||
int paletteLengthLength = ITechHider.readVarIntLength(data, i);
|
||||
buffer.writeBytes(data, i, paletteLengthLength);
|
||||
i += paletteLengthLength;
|
||||
for(int actPaletteId = 0; actPaletteId < paletteLength; actPaletteId++){
|
||||
int blockId = ITechHider.readVarInt(data, i);
|
||||
int actPaletteLength = ITechHider.readVarIntLength(data, i);
|
||||
|
||||
if(Config.HiddenBlocks.contains(blockId)){
|
||||
byte[] a = ITechHider.writeVarInt(Config.ObfuscateWith);
|
||||
buffer.writeBytes(a);
|
||||
changed = true;
|
||||
}else{
|
||||
buffer.writeBytes(data, i, actPaletteLength);
|
||||
}
|
||||
i += actPaletteLength;
|
||||
}
|
||||
|
||||
//We modify only the chunk palette for performance reasons
|
||||
int dataArrayLength = ITechHider.readVarInt(data, i);
|
||||
int dataArrayLengthLength = ITechHider.readVarIntLength(data, i);
|
||||
buffer.writeBytes(data, i, dataArrayLength * 8 + dataArrayLengthLength);
|
||||
i += dataArrayLengthLength;
|
||||
i += dataArrayLength * 8;
|
||||
}else{
|
||||
//Full Chunk/no palette, so the chunk has to be crawled through
|
||||
int dataArrayLength = ITechHider.readVarInt(data, i);
|
||||
int dataArrayLengthLength = ITechHider.readVarIntLength(data, i);
|
||||
buffer.writeBytes(data, i, dataArrayLengthLength);
|
||||
i += dataArrayLengthLength;
|
||||
|
||||
ByteBuffer source = ByteBuffer.wrap(data, i, dataArrayLength * 8);
|
||||
VariableValueArray values = new VariableValueArray(bitsPerBlock, dataArrayLength, source.asLongBuffer());
|
||||
|
||||
for(int pos = 0; pos < 4096; pos++){
|
||||
if(Config.HiddenBlocks.contains(values.get(pos))){
|
||||
changed = true;
|
||||
values.set(pos, Config.ObfuscateWith);
|
||||
}
|
||||
}
|
||||
|
||||
for(long l : values.backing)
|
||||
buffer.writeLong(l);
|
||||
|
||||
i += dataArrayLength * 8;
|
||||
}
|
||||
|
||||
primaryBitMask >>= 1;
|
||||
chunkY++;
|
||||
}
|
||||
buffer.writeBytes(data, i, data.length - i); // MC appends a 0 byte at the end if there is a full chunk, idk why
|
||||
|
||||
if(changed){
|
||||
data = new byte[buffer.readableBytes()];
|
||||
buffer.readBytes(data);
|
||||
byteArray.write(0, data);
|
||||
}
|
||||
static Set<Integer> getHiddenBlockIds() {
|
||||
Set<Integer> hiddenBlockIds = new HashSet<>();
|
||||
for(String tag : Config.HiddenBlocks){
|
||||
for(IBlockData data : IRegistry.BLOCK.get(new MinecraftKey(tag)).getStates().a()){
|
||||
hiddenBlockIds.add(Block.getCombinedId(data));
|
||||
}
|
||||
};
|
||||
}
|
||||
return hiddenBlockIds;
|
||||
}
|
||||
|
||||
private static final class VariableValueArray {
|
||||
private final long[] backing;
|
||||
private final int bitsPerValue;
|
||||
private final long valueMask;
|
||||
|
||||
public VariableValueArray(int bitsPerEntry, int dataArrayLength, LongBuffer buffer) {
|
||||
this.bitsPerValue = bitsPerEntry;
|
||||
this.backing = new long[dataArrayLength];
|
||||
buffer.get(backing);
|
||||
this.valueMask = (1L << this.bitsPerValue) - 1;
|
||||
}
|
||||
|
||||
public int get(int index) {
|
||||
index *= bitsPerValue;
|
||||
int i0 = index >> 6;
|
||||
int i1 = index & 0x3f;
|
||||
|
||||
long value = backing[i0] >>> i1;
|
||||
|
||||
// The value is divided over two long values
|
||||
if (i1 + bitsPerValue > 64) {
|
||||
value |= backing[++i0] << 64 - i1;
|
||||
}
|
||||
|
||||
return (int) (value & valueMask);
|
||||
}
|
||||
|
||||
public void set(int index, int value) {
|
||||
index *= bitsPerValue;
|
||||
int i0 = index >> 6;
|
||||
int i1 = index & 0x3f;
|
||||
|
||||
backing[i0] = this.backing[i0] & ~(this.valueMask << i1) | (value & valueMask) << i1;
|
||||
int i2 = i1 + bitsPerValue;
|
||||
// The value is divided over two long values
|
||||
if (i2 > 64) {
|
||||
i0++;
|
||||
backing[i0] = backing[i0] & -(1L << i2 - 64) | value >> 64 - i1;
|
||||
}
|
||||
}
|
||||
static int getObfuscateWith() {
|
||||
return Block.getCombinedId(IRegistry.BLOCK.get(new MinecraftKey(Config.ObfuscateWith)).getBlockData());
|
||||
}
|
||||
}
|
||||
|
28
FightSystem_API/src/de/steamwar/fightsystem/ArenaMode.java
Normale Datei
28
FightSystem_API/src/de/steamwar/fightsystem/ArenaMode.java
Normale Datei
@ -0,0 +1,28 @@
|
||||
package de.steamwar.fightsystem;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.Set;
|
||||
|
||||
public enum ArenaMode {
|
||||
NORMAL,
|
||||
RANKED,
|
||||
EVENT,
|
||||
TEST,
|
||||
CHECK,
|
||||
PREPARE;
|
||||
|
||||
public static final Set<ArenaMode> All = Collections.unmodifiableSet(EnumSet.allOf(ArenaMode.class));
|
||||
|
||||
public static final Set<ArenaMode> Normal = Collections.unmodifiableSet(EnumSet.of(NORMAL));
|
||||
public static final Set<ArenaMode> Check = Collections.unmodifiableSet(EnumSet.of(CHECK));
|
||||
public static final Set<ArenaMode> Event = Collections.unmodifiableSet(EnumSet.of(EVENT));
|
||||
public static final Set<ArenaMode> Test = Collections.unmodifiableSet(EnumSet.of(TEST, CHECK));
|
||||
public static final Set<ArenaMode> Ranked = Collections.unmodifiableSet(EnumSet.of(RANKED));
|
||||
public static final Set<ArenaMode> Prepare = Collections.unmodifiableSet(EnumSet.of(PREPARE));
|
||||
|
||||
public static final Set<ArenaMode> AntiTest = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(TEST, CHECK)));
|
||||
public static final Set<ArenaMode> VariableTeams = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(RANKED, EVENT)));
|
||||
public static final Set<ArenaMode> AntiPrepare = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(PREPARE)));
|
||||
public static final Set<ArenaMode> RankedEvent = Collections.unmodifiableSet(EnumSet.of(RANKED, EVENT));
|
||||
}
|
@ -26,7 +26,6 @@ import de.steamwar.sql.Team;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.util.Vector;
|
||||
@ -122,11 +121,9 @@ public class Config {
|
||||
|
||||
//tech hider parameter
|
||||
public static final boolean TechhiderActive;
|
||||
public static final Set<Integer> HiddenBlocks;
|
||||
public static final Set<String> HiddenBlockTags;
|
||||
public static final Set<String> HiddenBlocks;
|
||||
public static final Set<String> HiddenBlockEntities;
|
||||
public static final int ObfuscateWith;
|
||||
public static final String ObfuscateWithTag;
|
||||
public static final String ObfuscateWith;
|
||||
|
||||
//event parameter
|
||||
private static final int EventKampfID;
|
||||
@ -138,6 +135,9 @@ public class Config {
|
||||
|
||||
//check parameter
|
||||
public static final int CheckSchemID;
|
||||
public static final int PrepareSchemID;
|
||||
|
||||
public static final ArenaMode mode;
|
||||
|
||||
//live recorder parameter
|
||||
public static final String spectateIP = "127.0.0.1";
|
||||
@ -209,25 +209,9 @@ public class Config {
|
||||
PersonalKits = config.getBoolean("Kits.PersonalKits");
|
||||
ForbiddenItems = config.getStringList("Kits.ForbiddenItems");
|
||||
|
||||
ConfigurationSection techhiderConfig = config.getConfigurationSection("Techhider.HiddenBlocks");
|
||||
Set<Integer> blocks = new HashSet<>();
|
||||
Set<String> blockTags = new HashSet<>();
|
||||
for(String key : techhiderConfig.getKeys(false)){
|
||||
blockTags.add(key);
|
||||
if(techhiderConfig.isInt(key))
|
||||
blocks.add(techhiderConfig.getInt(key));
|
||||
else{
|
||||
List<Integer> minmax = techhiderConfig.getIntegerList(key); // Entry 0: Minimum, Entry 1: Maximum
|
||||
for(int i = minmax.get(0); i <= minmax.get(1); i++)
|
||||
blocks.add(i);
|
||||
}
|
||||
|
||||
}
|
||||
HiddenBlocks = Collections.unmodifiableSet(blocks);
|
||||
HiddenBlockTags = Collections.unmodifiableSet(blockTags);
|
||||
HiddenBlocks = Collections.unmodifiableSet(new HashSet<>(config.getStringList("Techhider.HiddenBlocks")));
|
||||
HiddenBlockEntities = Collections.unmodifiableSet(new HashSet<>(config.getStringList("Techhider.HiddenBlockEntities")));
|
||||
ObfuscateWith = config.getInt("Techhider.ObfuscateWith");
|
||||
ObfuscateWithTag = config.getString("Techhider.ObfuscateWithTag");
|
||||
ObfuscateWith = config.getString("Techhider.ObfuscateWithTag");
|
||||
TechhiderActive = config.getBoolean("Techhider.Active");
|
||||
|
||||
if(schemsizeX < 0){
|
||||
@ -326,7 +310,7 @@ public class Config {
|
||||
TeamBlueRotate = teamBlueRotate;
|
||||
|
||||
EventKampfID = Integer.parseInt(System.getProperty("fightID", "0"));
|
||||
if(event()){
|
||||
if(EventKampfID >= 1){
|
||||
EventFight eventFight = EventFight.get(EventKampfID);
|
||||
if(eventFight == null){
|
||||
Bukkit.getLogger().log(Level.SEVERE, "Failed to load EventFight");
|
||||
@ -389,22 +373,28 @@ public class Config {
|
||||
RedLeader = null;
|
||||
|
||||
CheckSchemID = Integer.parseInt(System.getProperty("checkSchemID", "0"));
|
||||
PrepareSchemID = Integer.parseInt(System.getProperty("prepareSchemID", "0"));
|
||||
Ranked = Boolean.parseBoolean(System.getProperty("ranked", "false"));
|
||||
|
||||
if(Ranked){
|
||||
mode = ArenaMode.RANKED;
|
||||
}else if(CheckSchemID != 0){
|
||||
mode = ArenaMode.CHECK;
|
||||
}else if(EventKampfID >= 1){
|
||||
mode = ArenaMode.EVENT;
|
||||
}else if(EventKampfID == -1){
|
||||
mode = ArenaMode.TEST;
|
||||
}else if(PrepareSchemID != 0){
|
||||
mode = ArenaMode.PREPARE;
|
||||
}else{
|
||||
mode = ArenaMode.NORMAL;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean event(){
|
||||
return EventKampfID >= 1;
|
||||
}
|
||||
public static boolean test(){
|
||||
return EventKampfID == -1;
|
||||
}
|
||||
public static boolean check(){
|
||||
return CheckSchemID != 0;
|
||||
}
|
||||
public static boolean fixedTeams(){
|
||||
return event() || Ranked;
|
||||
}
|
||||
public static boolean recording(){
|
||||
return event();
|
||||
return mode == ArenaMode.EVENT;
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ package de.steamwar.fightsystem.utils;
|
||||
|
||||
import com.comphenix.protocol.events.PacketContainer;
|
||||
import com.google.common.primitives.Bytes;
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.IFightSystem;
|
||||
import de.steamwar.fightsystem.fight.IFight;
|
||||
@ -69,10 +70,10 @@ public class ITechHider {
|
||||
arenaMinZ = ITechHider.posToChunk(Config.ArenaMinZ);
|
||||
arenaMaxZ = ITechHider.posToChunk(Config.ArenaMaxZ) + 1;
|
||||
|
||||
obfuscateMaterial = Material.getMaterial(Config.ObfuscateWithTag);
|
||||
obfuscateMaterial = Material.getMaterial(Config.ObfuscateWith);
|
||||
Bukkit.getScheduler().runTaskTimer(IFightSystem.getPlugin(), packetCache::clear, 1, 1);
|
||||
|
||||
if(Config.event())
|
||||
if(Config.mode == ArenaMode.EVENT)
|
||||
threadMultiplier = 4;
|
||||
else
|
||||
threadMultiplier = 1;
|
||||
|
@ -59,30 +59,29 @@ public class FightSystem extends JavaPlugin {
|
||||
Fight.init();
|
||||
RecordSystem.init();
|
||||
|
||||
new EntityDamageListener();
|
||||
new EntityDamage();
|
||||
new WaterRemover();
|
||||
new FoodLevelChangeListener();
|
||||
new Permanent();
|
||||
new PistonListener();
|
||||
new PlayerChatListener();
|
||||
new HotbarGUIListener();
|
||||
new PlayerMoveListener();
|
||||
new PlayerStateListener();
|
||||
new ProjectileLaunchListener();
|
||||
new InFightDamageListener();
|
||||
new InFightInventoryListener();
|
||||
new FreezeWorldStateListener();
|
||||
new EventJoinListener();
|
||||
new EventRecordListener();
|
||||
new CheckListener();
|
||||
new TestListener();
|
||||
new NormalJoinListener();
|
||||
new RankedJoinListener();
|
||||
new GameplayListener();
|
||||
new Chat();
|
||||
new HotbarGUI();
|
||||
new Move();
|
||||
new ConnectionListener();
|
||||
new InFightDamage();
|
||||
new InFightInventory();
|
||||
new DenyWorldInteraction();
|
||||
new EventJoin();
|
||||
new Recording();
|
||||
new Check();
|
||||
new PrepareJoin();
|
||||
new TestJoin();
|
||||
new NormalJoin();
|
||||
new RankedJoin();
|
||||
new PersonalKitCreator();
|
||||
new ScoreboardListener();
|
||||
new FightScoreboard();
|
||||
new ArrowStopper();
|
||||
if(Core.getVersion() > 8)
|
||||
new VersionDependentListener();
|
||||
new ArrowPickup();
|
||||
|
||||
new EnterHandler();
|
||||
new TechHider();
|
||||
@ -127,15 +126,12 @@ public class FightSystem extends JavaPlugin {
|
||||
return;
|
||||
}
|
||||
|
||||
if(Config.event() || Config.Ranked) {
|
||||
if(Config.mode == ArenaMode.EVENT) {
|
||||
setPreSchemState();
|
||||
}else if(Config.test()){
|
||||
if(Config.check()){
|
||||
Fight.getBlueTeam().setNotPastingSchem(Schematic.getSchemFromDB(Config.CheckSchemID));
|
||||
}
|
||||
|
||||
setPreSchemState();
|
||||
Bukkit.getScheduler().runTaskLater(this, FightSystem::setPostSchemState, 0);
|
||||
}else if(Config.mode == ArenaMode.CHECK){
|
||||
Fight.getBlueTeam().setNotPastingSchem(Schematic.getSchemFromDB(Config.CheckSchemID));
|
||||
}else if(Config.mode == ArenaMode.PREPARE) {
|
||||
Fight.getBlueTeam().setNotPastingSchem(Schematic.getSchemFromDB(Config.PrepareSchemID));
|
||||
}
|
||||
}
|
||||
|
||||
@ -189,7 +185,7 @@ public class FightSystem extends JavaPlugin {
|
||||
Bukkit.broadcastMessage(PREFIX + "§aKein Team hat gewonnen!");
|
||||
}
|
||||
|
||||
if(Config.event()) {
|
||||
if(Config.mode == ArenaMode.EVENT) {
|
||||
if (winFightTeam == null)
|
||||
getEventFight().setErgebnis(0);
|
||||
else if (winFightTeam.isBlue())
|
||||
|
@ -19,16 +19,18 @@
|
||||
|
||||
package de.steamwar.fightsystem.commands;
|
||||
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentCommand;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class AcceptCommand extends BasicCommand {
|
||||
public class AcceptCommand implements CommandExecutor {
|
||||
|
||||
public AcceptCommand() {
|
||||
super(!Config.fixedTeams(), FightState.SETUP, "accept");
|
||||
new StateDependentCommand(ArenaMode.VariableTeams, FightState.Setup, "accept", this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -19,19 +19,21 @@
|
||||
|
||||
package de.steamwar.fightsystem.commands;
|
||||
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.fight.Kit;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentCommand;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.sql.UserGroup;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class AkCommand extends BasicCommand {
|
||||
public class AkCommand implements CommandExecutor {
|
||||
|
||||
public AkCommand() {
|
||||
super(Config.test(), FightState.ALL, "ak");
|
||||
new StateDependentCommand(ArenaMode.Test, FightState.All, "ak", this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,40 +0,0 @@
|
||||
package de.steamwar.fightsystem.commands;
|
||||
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependent;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public abstract class BasicCommand implements CommandExecutor, StateDependent {
|
||||
|
||||
private final Set<FightState> enabled;
|
||||
private final PluginCommand command;
|
||||
|
||||
protected BasicCommand(boolean condition, Set<FightState> enabled, String name){
|
||||
this.enabled = enabled;
|
||||
this.command = FightSystem.getPlugin().getCommand(name);
|
||||
assert command != null;
|
||||
disable();
|
||||
|
||||
if(condition)
|
||||
FightState.registerStateDependent(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<FightState> enabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enable() {
|
||||
command.setExecutor(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable() {
|
||||
command.setExecutor(new UnavailableCommand());
|
||||
}
|
||||
}
|
@ -19,16 +19,18 @@
|
||||
|
||||
package de.steamwar.fightsystem.commands;
|
||||
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentCommand;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class DeclineCommand extends BasicCommand {
|
||||
public class DeclineCommand implements CommandExecutor {
|
||||
|
||||
public DeclineCommand() {
|
||||
super(!Config.fixedTeams(), FightState.SETUP, "decline");
|
||||
new StateDependentCommand(ArenaMode.VariableTeams, FightState.Setup, "decline", this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -19,16 +19,18 @@
|
||||
|
||||
package de.steamwar.fightsystem.commands;
|
||||
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentCommand;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class InviteCommand extends BasicCommand {
|
||||
public class InviteCommand implements CommandExecutor {
|
||||
|
||||
public InviteCommand() {
|
||||
super(!Config.fixedTeams(), FightState.SETUP, "invite");
|
||||
new StateDependentCommand(ArenaMode.VariableTeams, FightState.Setup, "invite", this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -19,15 +19,18 @@
|
||||
|
||||
package de.steamwar.fightsystem.commands;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentCommand;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class KitCommand extends BasicCommand {
|
||||
public class KitCommand implements CommandExecutor {
|
||||
|
||||
public KitCommand() {
|
||||
super(true, FightState.SETUP, "kit");
|
||||
new StateDependentCommand(ArenaMode.All, FightState.Setup, "kit", this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -19,20 +19,20 @@
|
||||
|
||||
package de.steamwar.fightsystem.commands;
|
||||
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentCommand;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
public class LeaderCommand extends BasicCommand {
|
||||
public class LeaderCommand implements CommandExecutor {
|
||||
|
||||
public LeaderCommand() {
|
||||
super(!Config.fixedTeams(), Config.test() ? FightState.ALL : EnumSet.of(FightState.PRE_LEADER_SETUP), "leader");
|
||||
new StateDependentCommand(ArenaMode.VariableTeams, FightState.Setup, "leader", this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -19,15 +19,18 @@
|
||||
|
||||
package de.steamwar.fightsystem.commands;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentCommand;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class LeaveCommand extends BasicCommand {
|
||||
public class LeaveCommand implements CommandExecutor {
|
||||
|
||||
public LeaveCommand() {
|
||||
super(true, FightState.SETUP, "leave");
|
||||
new StateDependentCommand(ArenaMode.All, FightState.Setup, "leave", this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -19,22 +19,26 @@
|
||||
|
||||
package de.steamwar.fightsystem.commands;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightPlayer;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentCommand;
|
||||
import de.steamwar.sql.Schematic;
|
||||
import de.steamwar.sql.SchematicType;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.sql.UserGroup;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class LockschemCommand extends BasicCommand {
|
||||
public class LockschemCommand implements CommandExecutor {
|
||||
|
||||
public LockschemCommand() {
|
||||
super(true, FightState.ALL, "lockschem");
|
||||
new StateDependentCommand(ArenaMode.All, FightState.All, "lockschem", this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -67,6 +71,10 @@ public class LockschemCommand extends BasicCommand {
|
||||
}
|
||||
Schematic.getSchemFromDB(fightTeam.getSchematic()).setSchemType(SchematicType.Normal);
|
||||
player.sendMessage(FightSystem.PREFIX + "Schematic von " + fightTeam.getColoredName() + " §cgesperrt!");
|
||||
FightPlayer leader = fightTeam.getLeader();
|
||||
if(leader != null){
|
||||
leader.sendMessage(FightSystem.PREFIX + "§cDeine Schematic wurde von " + player.getName() + " gesperrt!");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -19,15 +19,18 @@
|
||||
|
||||
package de.steamwar.fightsystem.commands;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentCommand;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class ReadyCommand extends BasicCommand {
|
||||
public class ReadyCommand implements CommandExecutor {
|
||||
|
||||
public ReadyCommand() {
|
||||
super(true, FightState.SETUP, "ready");
|
||||
new StateDependentCommand(ArenaMode.AntiPrepare, FightState.PostSchemSetup, "ready", this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -19,16 +19,18 @@
|
||||
|
||||
package de.steamwar.fightsystem.commands;
|
||||
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentCommand;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class RemoveCommand extends BasicCommand {
|
||||
public class RemoveCommand implements CommandExecutor {
|
||||
|
||||
public RemoveCommand() {
|
||||
super(!Config.fixedTeams(), FightState.SETUP, "remove");
|
||||
new StateDependentCommand(ArenaMode.VariableTeams, FightState.Setup, "remove", this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -20,7 +20,6 @@
|
||||
package de.steamwar.fightsystem.countdown;
|
||||
|
||||
import de.steamwar.core.Core;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.listener.BasicListener;
|
||||
@ -34,16 +33,18 @@ import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
public abstract class Countdown {
|
||||
|
||||
protected int time;
|
||||
private final int totalTime;
|
||||
private final Sound sound;
|
||||
private final boolean level;
|
||||
|
||||
protected int time;
|
||||
private BukkitTask task = null;
|
||||
|
||||
abstract String countdownCounting();
|
||||
abstract void countdownFinished();
|
||||
public abstract String countdownCounting();
|
||||
public abstract void countdownFinished();
|
||||
|
||||
Countdown(int time, SWSound sound, boolean level) {
|
||||
public Countdown(int time, SWSound sound, boolean level) {
|
||||
this.totalTime = time;
|
||||
this.time = time;
|
||||
this.sound = getSound(sound);
|
||||
this.level = level;
|
||||
@ -68,6 +69,7 @@ public abstract class Countdown {
|
||||
}
|
||||
|
||||
public void enable() {
|
||||
time = totalTime;
|
||||
task = Bukkit.getScheduler().runTaskTimer(FightSystem.getPlugin(), this::count, 20, 20);
|
||||
}
|
||||
|
||||
@ -79,8 +81,7 @@ public abstract class Countdown {
|
||||
}
|
||||
|
||||
private void broadcast(String message){
|
||||
if(Config.recording())
|
||||
RecordSystem.actionBar(message);
|
||||
RecordSystem.actionBar(message);
|
||||
BaseComponent[] msg = TextComponent.fromLegacyText(message);
|
||||
for(Player p : Bukkit.getOnlinePlayers())
|
||||
BasicListener.toActionbar(p, msg);
|
||||
|
@ -19,20 +19,17 @@
|
||||
|
||||
package de.steamwar.fightsystem.countdown;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependent;
|
||||
import de.steamwar.fightsystem.states.StateDependentCountdown;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class NoPlayersOnlineCountdown extends Countdown implements StateDependent {
|
||||
private static final Set<FightState> enabled = EnumSet.of(FightState.PRE_LEADER_SETUP);
|
||||
public class NoPlayersOnlineCountdown extends Countdown {
|
||||
|
||||
public NoPlayersOnlineCountdown() {
|
||||
super(Config.NoPlayerOnlineDuration, null, false);
|
||||
FightState.registerStateDependent(this);
|
||||
new StateDependentCountdown(ArenaMode.All, FightState.PreLeaderSetup, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -44,9 +41,4 @@ public class NoPlayersOnlineCountdown extends Countdown implements StateDependen
|
||||
public void countdownFinished() {
|
||||
Bukkit.getServer().shutdown();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<FightState> enabled() {
|
||||
return enabled;
|
||||
}
|
||||
}
|
||||
|
@ -19,20 +19,17 @@
|
||||
|
||||
package de.steamwar.fightsystem.countdown;
|
||||
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
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.StateDependent;
|
||||
import de.steamwar.fightsystem.states.StateDependentCountdown;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class PreRunningCountdown extends Countdown implements StateDependent {
|
||||
private static final Set<FightState> enabled = EnumSet.of(FightState.PRE_RUNNING);
|
||||
public class PreRunningCountdown extends Countdown {
|
||||
|
||||
public PreRunningCountdown() {
|
||||
super(Config.PreFightDuration, SWSound.BLOCK_NOTE_PLING, true);
|
||||
FightState.registerStateDependent(this);
|
||||
new StateDependentCountdown(ArenaMode.All, FightState.PreRunning, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -44,9 +41,4 @@ public class PreRunningCountdown extends Countdown implements StateDependent {
|
||||
public void countdownFinished() {
|
||||
FightSystem.setRunningState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<FightState> enabled() {
|
||||
return enabled;
|
||||
}
|
||||
}
|
||||
|
@ -19,34 +19,26 @@
|
||||
|
||||
package de.steamwar.fightsystem.countdown;
|
||||
|
||||
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.StateDependent;
|
||||
import de.steamwar.fightsystem.states.StateDependentCountdown;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class PreSchemPasteCountdown extends Countdown implements StateDependent {
|
||||
private static final Set<FightState> enabled = EnumSet.of(FightState.PRE_SCHEM_SETUP);
|
||||
public class PreSchemPasteCountdown extends Countdown {
|
||||
|
||||
public PreSchemPasteCountdown() {
|
||||
super(Config.PreSchemPasteDuration, SWSound.BLOCK_NOTE_PLING, false);
|
||||
FightState.registerStateDependent(this);
|
||||
new StateDependentCountdown(ArenaMode.All, FightState.PreSchemSetup, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
String countdownCounting() {
|
||||
public String countdownCounting() {
|
||||
return "bis eine Public-Schematic gewählt wird!";
|
||||
}
|
||||
|
||||
@Override
|
||||
void countdownFinished() {
|
||||
public void countdownFinished() {
|
||||
FightSystem.setPostSchemState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<FightState> enabled() {
|
||||
return enabled;
|
||||
}
|
||||
}
|
||||
|
@ -19,24 +19,21 @@
|
||||
|
||||
package de.steamwar.fightsystem.countdown;
|
||||
|
||||
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.StateDependent;
|
||||
import de.steamwar.fightsystem.states.StateDependentCountdown;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class SetupOverCountdown extends Countdown implements StateDependent {
|
||||
private static final Set<FightState> enabled = Config.test() ? EnumSet.noneOf(FightState.class) : EnumSet.of(FightState.POST_SCHEM_SETUP);
|
||||
public class SetupOverCountdown extends Countdown {
|
||||
|
||||
public SetupOverCountdown() {
|
||||
super(Config.SetupDuration, null, false);
|
||||
FightState.registerStateDependent(this);
|
||||
new StateDependentCountdown(ArenaMode.AntiTest, FightState.PostSchemSetup, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
String countdownCounting() {
|
||||
public String countdownCounting() {
|
||||
return "bis die Kits verteilt werden!";
|
||||
}
|
||||
|
||||
@ -44,9 +41,4 @@ public class SetupOverCountdown extends Countdown implements StateDependent {
|
||||
public void countdownFinished() {
|
||||
FightSystem.setPreRunningState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<FightState> enabled() {
|
||||
return enabled;
|
||||
}
|
||||
}
|
||||
|
@ -19,20 +19,17 @@
|
||||
|
||||
package de.steamwar.fightsystem.countdown;
|
||||
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
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.StateDependent;
|
||||
import de.steamwar.fightsystem.states.StateDependentCountdown;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class SpectateOverCountdown extends Countdown implements StateDependent {
|
||||
private static final Set<FightState> enabled = Config.test() ? EnumSet.noneOf(FightState.class) : EnumSet.of(FightState.SPECTATE);
|
||||
public class SpectateOverCountdown extends Countdown {
|
||||
|
||||
public SpectateOverCountdown() {
|
||||
super(Config.SpectatorDuration, SWSound.BLOCK_NOTE_PLING, false);
|
||||
FightState.registerStateDependent(this);
|
||||
new StateDependentCountdown(ArenaMode.AntiTest, FightState.Spectate, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -44,9 +41,4 @@ public class SpectateOverCountdown extends Countdown implements StateDependent {
|
||||
public void countdownFinished() {
|
||||
FightSystem.shutdown(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<FightState> enabled() {
|
||||
return enabled;
|
||||
}
|
||||
}
|
||||
|
@ -1,47 +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.countdown;
|
||||
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
public class TechKOCountdown extends Countdown {
|
||||
|
||||
private final FightTeam team;
|
||||
|
||||
public TechKOCountdown(FightTeam team, int countdownTime) {
|
||||
super(countdownTime, SWSound.BLOCK_NOTE_PLING, false);
|
||||
this.team = team;
|
||||
enable();
|
||||
}
|
||||
|
||||
@Override
|
||||
final String countdownCounting() {
|
||||
return "bis " + team.getColoredName() + " §feinen Schuss abgegeben haben muss!";
|
||||
}
|
||||
|
||||
@Override
|
||||
void countdownFinished() {
|
||||
Bukkit.broadcastMessage(FightSystem.PREFIX + team.getColoredName() + "§7 ist §eTech K§8.§eO§8.!");
|
||||
FightSystem.setSpectateState(Fight.getOpposite(team), "TechKO");
|
||||
}
|
||||
}
|
@ -30,7 +30,6 @@ public class TimeOverCountdown extends Countdown {
|
||||
public TimeOverCountdown(Runnable timeOver) {
|
||||
super(Config.TimeoutTime, SWSound.BLOCK_NOTE_BASS, false);
|
||||
this.timeOver = timeOver;
|
||||
enable();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -26,6 +26,7 @@ import com.comphenix.protocol.wrappers.EnumWrappers;
|
||||
import com.comphenix.protocol.wrappers.PlayerInfoData;
|
||||
import com.comphenix.protocol.wrappers.WrappedChatComponent;
|
||||
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.record.RecordSystem;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
@ -92,8 +93,7 @@ public class Fight {
|
||||
}
|
||||
|
||||
public static void playSound(Sound sound, float volume, float pitch) {
|
||||
if(Config.recording())
|
||||
RecordSystem.soundAtPlayer(sound.name(), volume, pitch);
|
||||
RecordSystem.soundAtPlayer(sound.name(), volume, pitch);
|
||||
//volume: max. 100, pitch: max. 2
|
||||
Bukkit.getServer().getOnlinePlayers().forEach(player -> player.playSound(player.getLocation(), sound, volume, pitch));
|
||||
}
|
||||
@ -155,7 +155,7 @@ public class Fight {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(Config.IgnorePublicOnly || Config.event() || Config.Ranked){
|
||||
if(Config.IgnorePublicOnly || ArenaMode.RankedEvent.contains(Config.mode)){
|
||||
return 1000;
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,7 @@ import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.IFightSystem;
|
||||
import de.steamwar.fightsystem.record.RecordSystem;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependent;
|
||||
import de.steamwar.fightsystem.states.IStateDependent;
|
||||
import de.steamwar.fightsystem.utils.ColorConverter;
|
||||
import de.steamwar.sql.NoClipboardException;
|
||||
import de.steamwar.sql.Schematic;
|
||||
@ -45,7 +45,7 @@ import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class FightSchematic implements StateDependent {
|
||||
public class FightSchematic implements IStateDependent {
|
||||
|
||||
private final FightTeam team;
|
||||
private final int pasteX;
|
||||
@ -91,11 +91,14 @@ public class FightSchematic implements StateDependent {
|
||||
|
||||
@Override
|
||||
public Set<FightState> enabled() {
|
||||
return FightState.SCHEM;
|
||||
return FightState.Schem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enable() {
|
||||
if(FightState.getFightState() == FightState.SPECTATE)
|
||||
return;
|
||||
|
||||
if(clipboard == null){
|
||||
List<Schematic> publics = Schematic.getSchemsOfType(0, Config.SchematicType);
|
||||
if(publics.isEmpty())
|
||||
@ -104,12 +107,10 @@ public class FightSchematic implements StateDependent {
|
||||
setSchematic(publics.get(new Random().nextInt(publics.size())));
|
||||
}
|
||||
|
||||
if(Config.recording()){
|
||||
if(team.isBlue())
|
||||
RecordSystem.blueSchem(schematic);
|
||||
else
|
||||
RecordSystem.redSchem(schematic);
|
||||
}
|
||||
if(team.isBlue())
|
||||
RecordSystem.blueSchem(schematic);
|
||||
else
|
||||
RecordSystem.redSchem(schematic);
|
||||
|
||||
FreezeWorld freezer = new FreezeWorld();
|
||||
DyeColor c = ColorConverter.chat2dye(team.getColor());
|
||||
|
@ -21,12 +21,14 @@ package de.steamwar.fightsystem.fight;
|
||||
|
||||
import de.steamwar.comms.packets.TablistNamePacket;
|
||||
import de.steamwar.core.VersionedRunnable;
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.listener.BasicListener;
|
||||
import de.steamwar.fightsystem.listener.PersonalKitCreator;
|
||||
import de.steamwar.fightsystem.record.RecordSystem;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.utils.FightScoreboard;
|
||||
import de.steamwar.fightsystem.listener.FightScoreboard;
|
||||
import de.steamwar.fightsystem.utils.ItemBuilder;
|
||||
import de.steamwar.fightsystem.utils.TechHider;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
@ -153,14 +155,16 @@ public class FightTeam implements IFightTeam{
|
||||
team.addEntry(player.getName());
|
||||
|
||||
Fight.setPlayerGamemode(player, GameMode.SURVIVAL);
|
||||
player.setHealth(20);
|
||||
player.setFoodLevel(20);
|
||||
BasicListener.setAttackSpeed(player);
|
||||
player.teleport(spawn);
|
||||
if(Kit.getAvailableKits(false).size() > 1 || Config.PersonalKits)
|
||||
player.getInventory().setItem(1, new ItemBuilder(Material.LEATHER_CHESTPLATE).removeAllAttributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName("§eKit wählen").build());
|
||||
player.getInventory().setItem(7, new ItemBuilder(Material.BEACON).removeAllAttributs().setDisplayName("§eRespawn").build());
|
||||
if(!Config.test())
|
||||
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> new TablistNamePacket(SteamwarUser.get(player.getUniqueId()).getId(), prefix + player.getName()).send(player), 5);
|
||||
if(Config.recording())
|
||||
RecordSystem.playerJoins(player);
|
||||
RecordSystem.playerJoins(player);
|
||||
TechHider.reloadChunks(player, chunksToReload);
|
||||
return fightPlayer;
|
||||
}
|
||||
@ -180,8 +184,7 @@ public class FightTeam implements IFightTeam{
|
||||
player.teleport(Config.SpecSpawn);
|
||||
if(!Config.test())
|
||||
new TablistNamePacket(SteamwarUser.get(player.getUniqueId()).getId(), "§7" + player.getName()).send(player);
|
||||
if(Config.recording())
|
||||
RecordSystem.entityDespawns(player);
|
||||
RecordSystem.entityDespawns(player);
|
||||
TechHider.reloadChunks(player, chunksToReload);
|
||||
}
|
||||
|
||||
@ -203,7 +206,7 @@ public class FightTeam implements IFightTeam{
|
||||
if(!players.isEmpty()) {
|
||||
setLeader(players.values().iterator().next());
|
||||
Bukkit.broadcastMessage(FightSystem.PREFIX + "§aDer Spieler §e" + this.leader.getPlayer().getName() + " §aist nun Leader von Team " + getColoredName() + "§a!");
|
||||
}else if(!Config.event() && !Config.Ranked){
|
||||
}else if(!ArenaMode.RankedEvent.contains(Config.mode)){
|
||||
FightSystem.shutdown(FightSystem.PREFIX + "§cTeam " + getColoredName() + " §chat keine Spieler mehr.\n Arena schließt...");
|
||||
}
|
||||
return;
|
||||
@ -226,7 +229,7 @@ public class FightTeam implements IFightTeam{
|
||||
else
|
||||
inventory.setItem(1, new ItemBuilder(Material.AIR).build());
|
||||
|
||||
if(!Config.event() && !Config.Ranked){
|
||||
if(!ArenaMode.RankedEvent.contains(Config.mode)){
|
||||
inventory.setItem(2, new ItemBuilder(Material.PAPER).removeAllAttributs().setDisplayName("§eSpieler einladen").build());
|
||||
inventory.setItem(3, new ItemBuilder(SWItem.getMaterial("FIREWORK_CHARGE")).removeAllAttributs().setDisplayName("§cSpieler rauswerfen").build());
|
||||
}
|
||||
|
@ -17,17 +17,18 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.fightsystem.commands;
|
||||
package de.steamwar.fightsystem.listener;
|
||||
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import de.steamwar.core.Core;
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||
|
||||
public class UnavailableCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
sender.sendMessage(FightSystem.PREFIX + "§cDieser Befehl ist zu diesem Kampfzeitpunkt nicht verfügbar.");
|
||||
return false;
|
||||
public class ArrowPickup {
|
||||
|
||||
public ArrowPickup() {
|
||||
if(Core.getVersion() > 8){
|
||||
new StateDependentListener(ArenaMode.All, FightState.All, new PickupArrowListener_9());
|
||||
}
|
||||
}
|
||||
}
|
@ -20,27 +20,27 @@
|
||||
package de.steamwar.fightsystem.listener;
|
||||
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||
import de.steamwar.fightsystem.states.StateDependentTask;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.projectiles.ProjectileSource;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.EnumSet;
|
||||
public class ArrowStopper implements Listener {
|
||||
|
||||
public class ArrowStopper extends BasicListener {
|
||||
|
||||
private BukkitTask task;
|
||||
private static final Vector NULL_VECTOR = new Vector(0, 0, 0);
|
||||
private static final BlockFace[] BLOCK_FACES = {BlockFace.UP, BlockFace.DOWN, BlockFace.EAST, BlockFace.WEST, BlockFace.NORTH, BlockFace.SOUTH};
|
||||
|
||||
public ArrowStopper() {
|
||||
super(Config.TechhiderActive ? EnumSet.of(FightState.RUNNING) : EnumSet.noneOf(FightState.class));
|
||||
new StateDependentListener(Config.TechhiderActive, FightState.Running, this);
|
||||
new StateDependentTask(Config.TechhiderActive, FightState.Running, this::run, 1, 1);
|
||||
}
|
||||
|
||||
private void run() {
|
||||
@ -62,18 +62,6 @@ public class ArrowStopper extends BasicListener {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enable() {
|
||||
super.enable();
|
||||
task = Bukkit.getScheduler().runTaskTimer(FightSystem.getPlugin(), this::run, 1, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable() {
|
||||
super.disable();
|
||||
task.cancel();
|
||||
}
|
||||
|
||||
private boolean checkBlocks(Block start, Block end) {
|
||||
Block cursor = start;
|
||||
|
||||
@ -97,7 +85,7 @@ public class ArrowStopper extends BasicListener {
|
||||
}
|
||||
|
||||
private boolean checkBlock(Block block) {
|
||||
return Config.HiddenBlockTags.contains(block.getType().name());
|
||||
return Config.HiddenBlocks.contains(block.getType().name());
|
||||
}
|
||||
|
||||
private boolean invalidEntity(Arrow entity) {
|
||||
|
@ -20,28 +20,14 @@
|
||||
package de.steamwar.fightsystem.listener;
|
||||
|
||||
import de.steamwar.core.VersionedRunnable;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependent;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import java.util.Set;
|
||||
public class BasicListener {
|
||||
private BasicListener(){}
|
||||
|
||||
public abstract class BasicListener implements Listener, StateDependent {
|
||||
|
||||
private final Set<FightState> enabled;
|
||||
|
||||
BasicListener(Set<FightState> enabled){
|
||||
this.enabled = enabled;
|
||||
FightState.registerStateDependent(this);
|
||||
}
|
||||
|
||||
boolean notFighting(Player p){
|
||||
public static boolean notFighting(Player p){
|
||||
return Fight.getFightPlayer(p) == null;
|
||||
}
|
||||
|
||||
@ -55,22 +41,7 @@ public abstract class BasicListener implements Listener, StateDependent {
|
||||
new VersionedRunnable(() -> BasicListener_9.toChat(player, components), 9));
|
||||
}
|
||||
|
||||
void setAttackSpeed(Player player){
|
||||
public static void setAttackSpeed(Player player){
|
||||
VersionedRunnable.call(new VersionedRunnable(() -> BasicListener_9.setAttackSpeed(player), 9));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enable(){
|
||||
Bukkit.getPluginManager().registerEvents(this, FightSystem.getPlugin());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable(){
|
||||
HandlerList.unregisterAll(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<FightState> enabled() {
|
||||
return enabled;
|
||||
}
|
||||
}
|
||||
|
@ -19,25 +19,26 @@
|
||||
|
||||
package de.steamwar.fightsystem.listener;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.record.RecordSystem;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
|
||||
import java.util.EnumSet;
|
||||
public class Chat implements Listener {
|
||||
|
||||
public class PlayerChatListener extends BasicListener {
|
||||
|
||||
public PlayerChatListener(){
|
||||
super(EnumSet.allOf(FightState.class));
|
||||
public Chat(){
|
||||
new StateDependentListener(ArenaMode.All, FightState.All, this);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -63,10 +64,9 @@ public class PlayerChatListener extends BasicListener {
|
||||
}
|
||||
|
||||
private void broadcastChat(String message) {
|
||||
if (Config.recording())
|
||||
RecordSystem.chat(message);
|
||||
RecordSystem.chat(message);
|
||||
BaseComponent[] msg = TextComponent.fromLegacyText(message);
|
||||
for(Player p : Bukkit.getOnlinePlayers())
|
||||
toChat(p, msg);
|
||||
BasicListener.toChat(p, msg);
|
||||
}
|
||||
}
|
@ -19,24 +19,26 @@
|
||||
|
||||
package de.steamwar.fightsystem.listener;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||
import de.steamwar.sql.Schematic;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.sql.UserGroup;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class CheckListener extends BasicListener {
|
||||
public class Check implements Listener {
|
||||
|
||||
public CheckListener() {
|
||||
super(Config.check() ? EnumSet.allOf(FightState.class) : EnumSet.noneOf(FightState.class));
|
||||
public Check() {
|
||||
new StateDependentListener(ArenaMode.Check, FightState.All, this);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -66,7 +68,7 @@ public class CheckListener extends BasicListener {
|
||||
Bukkit.getLogger().log(Level.SEVERE, player.getName() + " tried to use a copy command!");
|
||||
}
|
||||
|
||||
private static boolean allowedToCheck(SteamwarUser user) {
|
||||
private boolean allowedToCheck(SteamwarUser user) {
|
||||
return user.getUserGroup() == UserGroup.Supporter ||
|
||||
user.getUserGroup() == UserGroup.Developer ||
|
||||
user.getUserGroup() == UserGroup.Moderator ||
|
@ -20,6 +20,7 @@
|
||||
package de.steamwar.fightsystem.listener;
|
||||
|
||||
import de.steamwar.comms.packets.TablistNamePacket;
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.countdown.Countdown;
|
||||
@ -29,25 +30,22 @@ import de.steamwar.fightsystem.fight.FightPlayer;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.record.RecordSystem;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
|
||||
import java.util.EnumSet;
|
||||
public class ConnectionListener implements Listener {
|
||||
|
||||
public class PlayerStateListener extends BasicListener{
|
||||
|
||||
public PlayerStateListener() {
|
||||
super(EnumSet.allOf(FightState.class));
|
||||
public ConnectionListener() {
|
||||
new StateDependentListener(ArenaMode.All, FightState.All, this);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
@ -55,10 +53,6 @@ public class PlayerStateListener extends BasicListener{
|
||||
event.setJoinMessage(null);
|
||||
|
||||
Player player = event.getPlayer();
|
||||
player.setHealth(20);
|
||||
player.setFoodLevel(20);
|
||||
setAttackSpeed(player);
|
||||
|
||||
FightTeam fightTeam = Fight.getPlayerTeam(player);
|
||||
|
||||
if (fightTeam == null) {
|
||||
@ -77,6 +71,8 @@ public class PlayerStateListener extends BasicListener{
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void handlePlayerDeath(PlayerDeathEvent event) {
|
||||
event.setDeathMessage(null);
|
||||
|
||||
Player player = event.getEntity().getPlayer();
|
||||
FightTeam fightTeam = Fight.getPlayerTeam(player);
|
||||
|
||||
@ -85,13 +81,11 @@ public class PlayerStateListener extends BasicListener{
|
||||
|
||||
assert player != null;
|
||||
Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer Spieler " + fightTeam.getPrefix() + player.getName() + " §cist gestorben!");
|
||||
event.setDeathMessage(null);
|
||||
fightTeam.getFightPlayer(player).setOut();
|
||||
Fight.setPlayerGamemode(player, GameMode.SPECTATOR);
|
||||
player.teleport(fightTeam.getSpawn());
|
||||
Fight.playSound(Countdown.getSound(SWSound.ENTITY_WITHER_DEATH), 100.0F, 1.0F);
|
||||
if(Config.recording())
|
||||
RecordSystem.entityDespawns(player);
|
||||
RecordSystem.entityDespawns(player);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
@ -106,40 +100,19 @@ public class PlayerStateListener extends BasicListener{
|
||||
if(FightState.setup()){
|
||||
fightTeam.removePlayer(player);
|
||||
|
||||
if(Config.recording())
|
||||
RecordSystem.entityDespawns(player);
|
||||
RecordSystem.entityDespawns(player);
|
||||
}else if(FightState.ingame()){
|
||||
FightPlayer fightPlayer = fightTeam.getFightPlayer(player);
|
||||
if(fightPlayer.isLiving()) {
|
||||
Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer Spieler " + fightTeam.getPrefix() + player.getName() + " §chat den Kampf verlassen!");
|
||||
fightTeam.getFightPlayer(player).setOut();
|
||||
|
||||
if(Config.recording())
|
||||
RecordSystem.entityDespawns(player);
|
||||
RecordSystem.entityDespawns(player);
|
||||
}
|
||||
}
|
||||
|
||||
//Shutdown server if nobody online and its not an event server
|
||||
if(!Config.event() && (Bukkit.getOnlinePlayers().isEmpty() || (Bukkit.getOnlinePlayers().size() == 1 && Bukkit.getOnlinePlayers().contains(player))))
|
||||
if(Config.mode != ArenaMode.EVENT && (Bukkit.getOnlinePlayers().isEmpty() || (Bukkit.getOnlinePlayers().size() == 1 && Bukkit.getOnlinePlayers().contains(player))))
|
||||
FightSystem.shutdown(null);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void handlePlayerRespawn(PlayerRespawnEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
FightTeam team = Fight.getPlayerTeam(player);
|
||||
if(team == null)
|
||||
event.setRespawnLocation(Config.SpecSpawn);
|
||||
else
|
||||
event.setRespawnLocation(team.getSpawn());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onTpGM3(PlayerTeleportEvent e) {
|
||||
if (e.getCause() == PlayerTeleportEvent.TeleportCause.SPECTATE) {
|
||||
e.setCancelled(true);
|
||||
toActionbar(e.getPlayer(), TextComponent.fromLegacyText("§cDu darfst diese Teleportfunktion nicht benutzen!"));
|
||||
e.getPlayer().kickPlayer("§cDu darfst diese Teleportfunktion nicht benutzen!");
|
||||
}
|
||||
}
|
||||
}
|
@ -19,40 +19,40 @@
|
||||
|
||||
package de.steamwar.fightsystem.listener;
|
||||
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.entity.ProjectileLaunchEvent;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryDragEvent;
|
||||
import org.bukkit.event.inventory.InventoryPickupItemEvent;
|
||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||
import org.bukkit.event.player.PlayerKickEvent;
|
||||
|
||||
import java.util.EnumSet;
|
||||
public class DenyWorldInteraction implements Listener {
|
||||
|
||||
public class FreezeWorldStateListener extends BasicListener {
|
||||
|
||||
public FreezeWorldStateListener() {
|
||||
super(Config.test() ? EnumSet.of(FightState.PRE_RUNNING) : EnumSet.of(FightState.PRE_LEADER_SETUP, FightState.PRE_SCHEM_SETUP, FightState.POST_SCHEM_SETUP, FightState.PRE_RUNNING, FightState.SPECTATE));
|
||||
public DenyWorldInteraction() {
|
||||
new StateDependentListener(ArenaMode.Test, FightState.PreRunning, this);
|
||||
new StateDependentListener(ArenaMode.AntiTest, FightState.AntiRunning, this);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void handleBlockBreak(BlockBreakEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
event.setCancelled(true);
|
||||
toActionbar(player, TextComponent.fromLegacyText("§cDu darfst derzeit keine Blöcke abbauen!"));
|
||||
BasicListener.toActionbar(player, TextComponent.fromLegacyText("§cDu darfst derzeit keine Blöcke abbauen!"));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void handleBlockPlace(BlockPlaceEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
event.setCancelled(true);
|
||||
toActionbar(player, TextComponent.fromLegacyText("§cDu darfst derzeit keine Blöcke setzen!"));
|
||||
BasicListener.toActionbar(player, TextComponent.fromLegacyText("§cDu darfst derzeit keine Blöcke setzen!"));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -60,18 +60,18 @@ public class FreezeWorldStateListener extends BasicListener {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInventoryClick(InventoryClickEvent event) {
|
||||
if(PersonalKitCreator.notInKitCreator(event.getWhoClicked()))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void handlePlayerKickEvent(PlayerKickEvent e){
|
||||
if(e.getReason().contains("Flying is not enabled"))
|
||||
e.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInventoryClick(InventoryClickEvent event) {
|
||||
if(PersonalKitCreator.notInKitCreator(event.getWhoClicked()))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInventoryDrag(InventoryDragEvent event) {
|
||||
if(PersonalKitCreator.notInKitCreator(event.getWhoClicked()))
|
||||
@ -79,12 +79,11 @@ public class FreezeWorldStateListener extends BasicListener {
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onDropPickup(InventoryPickupItemEvent e){
|
||||
e.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onDropping(PlayerDropItemEvent e){
|
||||
e.setCancelled(true);
|
||||
public void handleProjectileLaunch(ProjectileLaunchEvent event) {
|
||||
event.setCancelled(true);
|
||||
if(event.getEntity().getShooter() instanceof Player){
|
||||
Player player = (Player) event.getEntity().getShooter();
|
||||
BasicListener.toActionbar(player, TextComponent.fromLegacyText("§cDu darfst den Bogen erst nach Kampfbeginn nutzen!"));
|
||||
}
|
||||
}
|
||||
}
|
@ -19,17 +19,18 @@
|
||||
|
||||
package de.steamwar.fightsystem.listener;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
|
||||
import java.util.EnumSet;
|
||||
public class EntityDamage implements Listener {
|
||||
|
||||
public class EntityDamageListener extends BasicListener {
|
||||
|
||||
public EntityDamageListener() {
|
||||
super(EnumSet.of(FightState.PRE_LEADER_SETUP, FightState.PRE_SCHEM_SETUP, FightState.POST_SCHEM_SETUP, FightState.PRE_RUNNING, FightState.SPECTATE));
|
||||
public EntityDamage() {
|
||||
new StateDependentListener(ArenaMode.All, FightState.AntiRunning, this);
|
||||
}
|
||||
|
||||
@EventHandler
|
@ -19,25 +19,26 @@
|
||||
|
||||
package de.steamwar.fightsystem.listener;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightPlayer;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerLoginEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
import java.util.EnumSet;
|
||||
public class EventJoin implements Listener {
|
||||
|
||||
public class EventJoinListener extends BasicListener {
|
||||
|
||||
public EventJoinListener() {
|
||||
super(Config.event() ? EnumSet.of(FightState.PRE_LEADER_SETUP, FightState.PRE_SCHEM_SETUP, FightState.POST_SCHEM_SETUP) : EnumSet.noneOf(FightState.class));
|
||||
public EventJoin() {
|
||||
new StateDependentListener(ArenaMode.Event, FightState.Setup, this);
|
||||
}
|
||||
|
||||
@EventHandler
|
@ -17,43 +17,50 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.fightsystem.utils;
|
||||
package de.steamwar.fightsystem.listener;
|
||||
|
||||
import de.steamwar.core.TPSWatcher;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.countdown.TimeOverCountdown;
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.countdown.Countdown;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.record.RecordSystem;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.winconditions.*;
|
||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||
import de.steamwar.fightsystem.states.StateDependentTask;
|
||||
import de.steamwar.fightsystem.winconditions.PrintableWincondition;
|
||||
import de.steamwar.fightsystem.winconditions.Wincondition;
|
||||
import de.steamwar.scoreboard.SWScoreboard;
|
||||
import de.steamwar.scoreboard.ScoreboardCallback;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.scoreboard.Scoreboard;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class FightScoreboard {
|
||||
private FightScoreboard(){}
|
||||
public class FightScoreboard implements Listener {
|
||||
|
||||
private static final Set<FightState> fullScoreboard = EnumSet.of(FightState.RUNNING, FightState.SPECTATE);
|
||||
private static int index = 0;
|
||||
private static String title = "";
|
||||
private static final HashMap<String, Integer> scores = new HashMap<>();
|
||||
|
||||
static {
|
||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(FightSystem.getPlugin(), FightScoreboard::nextIndexDisplay, 0, 200);
|
||||
}
|
||||
private int index = 0;
|
||||
private String title = "";
|
||||
private final HashMap<String, Integer> scores = new HashMap<>();
|
||||
|
||||
public static Scoreboard getScoreboard() {
|
||||
return Bukkit.getScoreboardManager().getMainScoreboard();
|
||||
return Objects.requireNonNull(Bukkit.getScoreboardManager()).getMainScoreboard();
|
||||
}
|
||||
|
||||
public static void showScoreboard(Player p) {
|
||||
SWScoreboard.createScoreboard(p, new ScoreboardCallback() {
|
||||
public FightScoreboard(){
|
||||
new StateDependentListener(ArenaMode.All, FightState.All, this);
|
||||
new StateDependentTask(ArenaMode.All, FightState.All, this::nextIndexDisplay, 0, 200);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
SWScoreboard.createScoreboard(event.getPlayer(), new ScoreboardCallback() {
|
||||
@Override
|
||||
public HashMap<String, Integer> getData() {
|
||||
return scores;
|
||||
@ -66,11 +73,12 @@ public class FightScoreboard {
|
||||
});
|
||||
}
|
||||
|
||||
public static void removeScoreboard(Player p) {
|
||||
SWScoreboard.removeScoreboard(p);
|
||||
@EventHandler
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
SWScoreboard.removeScoreboard(event.getPlayer());
|
||||
}
|
||||
|
||||
private static void teamScoreboard(FightTeam fightTeam){
|
||||
private void teamScoreboard(FightTeam fightTeam){
|
||||
setTitle(fightTeam.getColoredName());
|
||||
fightTeam.getPlayers().forEach(fp -> {
|
||||
if(fp.isLiving())
|
||||
@ -78,35 +86,35 @@ public class FightScoreboard {
|
||||
});
|
||||
}
|
||||
|
||||
private static void generalScoreboard(){
|
||||
private void generalScoreboard(){
|
||||
setTitle("§eKampf");
|
||||
List<String> scores = new ArrayList<>();
|
||||
List<String> scoreList = new ArrayList<>();
|
||||
|
||||
TimeOverCountdown timeOverCountdown = TimeoutWincondition.getTimeOverCountdown();
|
||||
Countdown timeOverCountdown = Wincondition.getTimeOverCountdown();
|
||||
if(timeOverCountdown != null){
|
||||
int fightTime = timeOverCountdown.getTimeLeft();
|
||||
if (fightTime >= 60)
|
||||
scores.add("§7Zeit: §a" + fightTime / 60 + "m " + fightTime % 60 + "s");
|
||||
scoreList.add("§7Zeit: §a" + fightTime / 60 + "m " + fightTime % 60 + "s");
|
||||
else
|
||||
scores.add("§7Zeit: §a" + fightTime + "s");
|
||||
scoreList.add("§7Zeit: §a" + fightTime + "s");
|
||||
}
|
||||
|
||||
scores.add("§7TPS: §e" + TPSWatcher.getTPS());
|
||||
scoreList.add("§7TPS: §e" + TPSWatcher.getTPS());
|
||||
|
||||
if(fullScoreboard.contains(FightState.getFightState())){
|
||||
for(PrintableWincondition wincondition : Wincondition.getPrintableWinconditions()){
|
||||
scores.add(wincondition.getDisplay(Fight.getRedTeam()));
|
||||
scores.add(wincondition.getDisplay(Fight.getBlueTeam()));
|
||||
scoreList.add(wincondition.getDisplay(Fight.getRedTeam()));
|
||||
scoreList.add(wincondition.getDisplay(Fight.getBlueTeam()));
|
||||
}
|
||||
}
|
||||
|
||||
int value = scores.size();
|
||||
for(String score : scores){
|
||||
int value = scoreList.size();
|
||||
for(String score : scoreList){
|
||||
addScore(score, value--);
|
||||
}
|
||||
}
|
||||
|
||||
private static void nextIndexDisplay() {
|
||||
private void nextIndexDisplay() {
|
||||
index++;
|
||||
if(index > 2)
|
||||
index = 0;
|
||||
@ -122,15 +130,13 @@ public class FightScoreboard {
|
||||
generalScoreboard();
|
||||
}
|
||||
|
||||
private static void setTitle(String t) {
|
||||
private void setTitle(String t) {
|
||||
title = t;
|
||||
if(Config.recording())
|
||||
RecordSystem.scoreboardTitle(t);
|
||||
RecordSystem.scoreboardTitle(t);
|
||||
}
|
||||
|
||||
private static void addScore(String string, int i) {
|
||||
if(Config.recording())
|
||||
RecordSystem.scoreboardData(string, i);
|
||||
private void addScore(String string, int i) {
|
||||
scores.put(string, i);
|
||||
RecordSystem.scoreboardData(string, i);
|
||||
}
|
||||
}
|
@ -1,50 +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.states.FightState;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
||||
import org.bukkit.event.entity.SpawnerSpawnEvent;
|
||||
import org.bukkit.event.weather.WeatherChangeEvent;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
public class FoodLevelChangeListener extends BasicListener {
|
||||
|
||||
public FoodLevelChangeListener() {
|
||||
super(EnumSet.allOf(FightState.class));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void handleFoodLevelChange(FoodLevelChangeEvent event) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onWeatherChange(WeatherChangeEvent event){
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onSpawnerSpawn(SpawnerSpawnEvent e){
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
@ -1,50 +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.states.FightState;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.inventory.CraftItemEvent;
|
||||
import org.bukkit.event.inventory.FurnaceSmeltEvent;
|
||||
import org.bukkit.event.player.PlayerBedEnterEvent;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
public class GameplayListener extends BasicListener{
|
||||
|
||||
public GameplayListener() {
|
||||
super(EnumSet.allOf(FightState.class));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onSleep(PlayerBedEnterEvent e) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onCrafting(CraftItemEvent e){
|
||||
e.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onFurnace(FurnaceSmeltEvent e){
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
@ -19,22 +19,23 @@
|
||||
|
||||
package de.steamwar.fightsystem.listener;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.commands.GUI;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.EnumSet;
|
||||
public class HotbarGUI implements Listener {
|
||||
|
||||
public class HotbarGUIListener extends BasicListener {
|
||||
|
||||
public HotbarGUIListener() {
|
||||
super(EnumSet.of(FightState.PRE_LEADER_SETUP, FightState.PRE_SCHEM_SETUP, FightState.POST_SCHEM_SETUP));
|
||||
public HotbarGUI() {
|
||||
new StateDependentListener(ArenaMode.All, FightState.Setup, this);
|
||||
}
|
||||
|
||||
@EventHandler
|
@ -19,22 +19,24 @@
|
||||
|
||||
package de.steamwar.fightsystem.listener;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.Objects;
|
||||
|
||||
public class InFightDamageListener extends BasicListener {
|
||||
public class InFightDamage implements Listener {
|
||||
|
||||
public InFightDamageListener() {
|
||||
super(EnumSet.of(FightState.RUNNING));
|
||||
public InFightDamage() {
|
||||
new StateDependentListener(ArenaMode.All, FightState.Running, this);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -42,7 +44,7 @@ public class InFightDamageListener extends BasicListener {
|
||||
if(!(event.getEntity() instanceof Player))
|
||||
return;
|
||||
|
||||
if(notFighting((Player)event.getEntity()))
|
||||
if(BasicListener.notFighting((Player)event.getEntity()))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@ -69,7 +71,7 @@ public class InFightDamageListener extends BasicListener {
|
||||
return;
|
||||
}
|
||||
|
||||
if(notFighting(damager)){
|
||||
if(BasicListener.notFighting(damager)){
|
||||
event.setCancelled(true);
|
||||
//Damager is not fighting
|
||||
return;
|
||||
@ -81,7 +83,7 @@ public class InFightDamageListener extends BasicListener {
|
||||
event.getDamager().setFireTicks(0);
|
||||
player.setFireTicks(0);
|
||||
}
|
||||
toActionbar(damager, TextComponent.fromLegacyText("§cDu darfst deinen Teamkollegen keinen Schaden zufügen!"));
|
||||
BasicListener.toActionbar(damager, TextComponent.fromLegacyText("§cDu darfst deinen Teamkollegen keinen Schaden zufügen!"));
|
||||
}
|
||||
|
||||
if(player.getHealth() - event.getFinalDamage() <= 0){
|
@ -19,28 +19,27 @@
|
||||
|
||||
package de.steamwar.fightsystem.listener;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightPlayer;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryDragEvent;
|
||||
import org.bukkit.event.inventory.InventoryPickupItemEvent;
|
||||
import org.bukkit.event.inventory.InventoryType;
|
||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.EnumSet;
|
||||
public class InFightInventory implements Listener {
|
||||
|
||||
public class InFightInventoryListener extends BasicListener {
|
||||
|
||||
public InFightInventoryListener() {
|
||||
super(EnumSet.of(FightState.RUNNING));
|
||||
public InFightInventory() {
|
||||
new StateDependentListener(ArenaMode.All, FightState.Running, this);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -77,16 +76,6 @@ public class InFightInventoryListener extends BasicListener {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onDropPickup(InventoryPickupItemEvent e){
|
||||
e.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onDropping(PlayerDropItemEvent e){
|
||||
e.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBlockBreak(BlockBreakEvent event) {
|
||||
Inventory inventory = event.getPlayer().getInventory();
|
@ -19,11 +19,13 @@
|
||||
|
||||
package de.steamwar.fightsystem.listener;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||
import de.steamwar.fightsystem.utils.Region;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -31,19 +33,19 @@ import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class PlayerMoveListener extends BasicListener {
|
||||
public class Move implements Listener {
|
||||
|
||||
private static final String DENY_ARENA = "§cDu darfst die Arena nicht verlassen";
|
||||
private static final String DENY_TEAM = "§cDu darfst nicht zu den Teams";
|
||||
private static final String DENY_ENTERN = "§cDu darfst nicht entern";
|
||||
|
||||
public PlayerMoveListener() {
|
||||
super(EnumSet.allOf(FightState.class));
|
||||
public Move() {
|
||||
new StateDependentListener(ArenaMode.All, FightState.All, this);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -108,7 +110,7 @@ public class PlayerMoveListener extends BasicListener {
|
||||
if(to.getY() <= Config.underArenaBorder) {
|
||||
if(player.getGameMode() == GameMode.SPECTATOR || team == null)
|
||||
reset(event, DENY_ARENA);
|
||||
else if(FightState.getFightState().infight())
|
||||
else if(FightState.infight())
|
||||
player.damage(2);
|
||||
else if(!Config.GroundWalkable)
|
||||
player.teleport(team.getSpawn());
|
||||
@ -120,6 +122,6 @@ public class PlayerMoveListener extends BasicListener {
|
||||
private void reset(PlayerMoveEvent event, String message){
|
||||
Player player = event.getPlayer();
|
||||
player.teleport(event.getFrom());
|
||||
toActionbar(player, TextComponent.fromLegacyText(message));
|
||||
BasicListener.toActionbar(player, TextComponent.fromLegacyText(message));
|
||||
}
|
||||
}
|
@ -19,21 +19,22 @@
|
||||
|
||||
package de.steamwar.fightsystem.listener;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
|
||||
import java.util.EnumSet;
|
||||
public class NormalJoin implements Listener {
|
||||
|
||||
public class NormalJoinListener extends BasicListener {
|
||||
|
||||
public NormalJoinListener() {
|
||||
super(Config.event() || Config.test() || Config.Ranked ? EnumSet.noneOf(FightState.class) : EnumSet.of(FightState.PRE_LEADER_SETUP));
|
||||
public NormalJoin() {
|
||||
new StateDependentListener(ArenaMode.Normal, FightState.PreLeaderSetup, this);
|
||||
}
|
||||
|
||||
@EventHandler
|
107
FightSystem_Main/src/de/steamwar/fightsystem/listener/Permanent.java
Normale Datei
107
FightSystem_Main/src/de/steamwar/fightsystem/listener/Permanent.java
Normale Datei
@ -0,0 +1,107 @@
|
||||
/*
|
||||
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.Config;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
||||
import org.bukkit.event.entity.SpawnerSpawnEvent;
|
||||
import org.bukkit.event.inventory.CraftItemEvent;
|
||||
import org.bukkit.event.inventory.FurnaceSmeltEvent;
|
||||
import org.bukkit.event.inventory.InventoryPickupItemEvent;
|
||||
import org.bukkit.event.player.PlayerBedEnterEvent;
|
||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
import org.bukkit.event.weather.WeatherChangeEvent;
|
||||
|
||||
public class Permanent implements Listener {
|
||||
|
||||
public Permanent() {
|
||||
new StateDependentListener(ArenaMode.All, FightState.All, this);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void handleFoodLevelChange(FoodLevelChangeEvent event) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onWeatherChange(WeatherChangeEvent event){
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onSpawnerSpawn(SpawnerSpawnEvent e){
|
||||
e.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onSleep(PlayerBedEnterEvent e) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onCrafting(CraftItemEvent e){
|
||||
e.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onFurnace(FurnaceSmeltEvent e){
|
||||
e.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onDropPickup(InventoryPickupItemEvent e){
|
||||
e.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onDropping(PlayerDropItemEvent e){
|
||||
e.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void handlePlayerRespawn(PlayerRespawnEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
FightTeam team = Fight.getPlayerTeam(player);
|
||||
if(team == null)
|
||||
event.setRespawnLocation(Config.SpecSpawn);
|
||||
else
|
||||
event.setRespawnLocation(team.getSpawn());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onTpGM3(PlayerTeleportEvent e) {
|
||||
if (e.getCause() == PlayerTeleportEvent.TeleportCause.SPECTATE) {
|
||||
e.setCancelled(true);
|
||||
BasicListener.toActionbar(e.getPlayer(), TextComponent.fromLegacyText("§cDu darfst diese Teleportfunktion nicht benutzen!"));
|
||||
e.getPlayer().kickPlayer("§cDu darfst diese Teleportfunktion nicht benutzen!");
|
||||
}
|
||||
}
|
||||
}
|
@ -25,6 +25,7 @@ import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightPlayer;
|
||||
import de.steamwar.fightsystem.fight.Kit;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||
import de.steamwar.sql.PersonalKit;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -32,6 +33,7 @@ import org.bukkit.GameMode;
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.InventoryAction;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
@ -39,18 +41,24 @@ import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
public class PersonalKitCreator extends BasicListener {
|
||||
public class PersonalKitCreator implements Listener {
|
||||
|
||||
private static final Map<HumanEntity, InventoryBackup> openKitCreators = new HashMap<>();
|
||||
private static final EnumSet<FightState> enabled = Config.PersonalKits ? EnumSet.of(FightState.PRE_LEADER_SETUP, FightState.PRE_SCHEM_SETUP, FightState.POST_SCHEM_SETUP) : EnumSet.noneOf(FightState.class);
|
||||
|
||||
public PersonalKitCreator(){
|
||||
super(enabled);
|
||||
new StateDependentListener(Config.PersonalKits, FightState.Setup, this){
|
||||
@Override
|
||||
public void disable(){
|
||||
while(!openKitCreators.isEmpty()){
|
||||
openKitCreators.values().iterator().next().close();
|
||||
}
|
||||
super.disable();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static void openKitCreator(Player player, PersonalKit kit){
|
||||
@ -58,21 +66,13 @@ public class PersonalKitCreator extends BasicListener {
|
||||
new InventoryBackup(player, kit);
|
||||
new Kit(kit).loadToPlayer(player);
|
||||
player.setGameMode(GameMode.CREATIVE);
|
||||
toActionbar(player, TextComponent.fromLegacyText("§eInventar zum Anpassen des Kits öffnen§8!"));
|
||||
BasicListener.toActionbar(player, TextComponent.fromLegacyText("§eInventar zum Anpassen des Kits öffnen§8!"));
|
||||
}
|
||||
|
||||
public static boolean notInKitCreator(HumanEntity player){
|
||||
return !openKitCreators.containsKey(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable(){
|
||||
while(!openKitCreators.isEmpty()){
|
||||
openKitCreators.values().iterator().next().close();
|
||||
}
|
||||
super.disable();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInventoryClick(InventoryClickEvent e){
|
||||
if(!openKitCreators.containsKey(e.getWhoClicked()))
|
||||
|
@ -21,22 +21,21 @@ package de.steamwar.fightsystem.listener;
|
||||
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||
import de.steamwar.fightsystem.utils.Region;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockPistonExtendEvent;
|
||||
import org.bukkit.event.block.BlockPistonRetractEvent;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
public class PistonListener extends BasicListener {
|
||||
public class PistonListener implements Listener {
|
||||
|
||||
public PistonListener() {
|
||||
//Wenn Entern aktiv ist, sollen Raketen etc. entern können
|
||||
super(Config.EnterStages.isEmpty()
|
||||
? EnumSet.allOf(FightState.class)
|
||||
: EnumSet.of(FightState.PRE_LEADER_SETUP, FightState.PRE_SCHEM_SETUP, FightState.POST_SCHEM_SETUP));
|
||||
new StateDependentListener(Config.EnterStages.isEmpty(), FightState.All, this);
|
||||
new StateDependentListener(!Config.EnterStages.isEmpty(), FightState.Setup, this);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
/*
|
||||
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
|
||||
@ -19,26 +19,35 @@
|
||||
|
||||
package de.steamwar.fightsystem.listener;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.ProjectileLaunchEvent;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
|
||||
import java.util.EnumSet;
|
||||
public class PrepareJoin implements Listener {
|
||||
|
||||
public class ProjectileLaunchListener extends BasicListener {
|
||||
|
||||
public ProjectileLaunchListener() {
|
||||
super(EnumSet.of(FightState.PRE_LEADER_SETUP, FightState.PRE_SCHEM_SETUP, FightState.POST_SCHEM_SETUP, FightState.PRE_RUNNING, FightState.SPECTATE));
|
||||
public PrepareJoin() {
|
||||
new StateDependentListener(ArenaMode.Prepare, FightState.All, this);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void handleProjectileLaunch(ProjectileLaunchEvent event) {
|
||||
event.setCancelled(true);
|
||||
if(event.getEntity().getShooter() instanceof Player){
|
||||
Player player = (Player) event.getEntity().getShooter();
|
||||
toActionbar(player, TextComponent.fromLegacyText("§cDu darfst den Bogen erst nach Fightbeginn nutzen!"));
|
||||
public void handlePlayerJoin(PlayerJoinEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
FightTeam team = Fight.getPlayerTeam(player);
|
||||
|
||||
if (team == null) {
|
||||
Fight.getBlueTeam().addMember(player);
|
||||
}
|
||||
|
||||
if(FightState.getFightState() == FightState.PRE_LEADER_SETUP) {
|
||||
FightSystem.setPreSchemState();
|
||||
FightSystem.setPostSchemState();
|
||||
}
|
||||
}
|
||||
}
|
@ -19,20 +19,21 @@
|
||||
|
||||
package de.steamwar.fightsystem.listener;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
|
||||
import java.util.EnumSet;
|
||||
public class RankedJoin implements Listener {
|
||||
|
||||
public class RankedJoinListener extends BasicListener {
|
||||
|
||||
public RankedJoinListener() {
|
||||
super(!Config.event() && Config.Ranked ? EnumSet.of(FightState.PRE_SCHEM_SETUP) : EnumSet.noneOf(FightState.class));
|
||||
public RankedJoin() {
|
||||
new StateDependentListener(ArenaMode.Ranked, FightState.PreLeaderSetup, this);
|
||||
}
|
||||
|
||||
@EventHandler
|
@ -26,12 +26,14 @@ import de.steamwar.fightsystem.fight.FightPlayer;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.record.RecordSystem;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockPhysicsEvent;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.entity.EntitySpawnEvent;
|
||||
@ -43,16 +45,29 @@ import org.bukkit.event.player.*;
|
||||
import org.bukkit.event.server.BroadcastMessageEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.Random;
|
||||
|
||||
public class EventRecordListener extends BasicListener {
|
||||
public class Recording implements Listener {
|
||||
|
||||
private static final int AIR = 0;
|
||||
private static final Random random = new Random();
|
||||
|
||||
public EventRecordListener() {
|
||||
super(Config.recording() ? EnumSet.allOf(FightState.class) : EnumSet.noneOf(FightState.class));
|
||||
public Recording() {
|
||||
new StateDependentListener(Config.recording(), FightState.All, this){
|
||||
@Override
|
||||
public void stateChange(FightState state) {
|
||||
if(state == FightState.PRE_RUNNING) {
|
||||
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> {
|
||||
setKitItems(Fight.getBlueTeam());
|
||||
setKitItems(Fight.getRedTeam());
|
||||
}, 1);
|
||||
}else if(state == FightState.SPECTATE){
|
||||
despawnTeam(Fight.getRedTeam());
|
||||
despawnTeam(Fight.getBlueTeam());
|
||||
despawnTNT();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
@ -170,20 +185,6 @@ public class EventRecordListener extends BasicListener {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stateChange(FightState state) {
|
||||
if(state == FightState.PRE_RUNNING) {
|
||||
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> {
|
||||
setKitItems(Fight.getBlueTeam());
|
||||
setKitItems(Fight.getRedTeam());
|
||||
}, 1);
|
||||
}else if(state == FightState.SPECTATE){
|
||||
despawnTeam(Fight.getRedTeam());
|
||||
despawnTeam(Fight.getBlueTeam());
|
||||
despawnTNT();
|
||||
}
|
||||
}
|
||||
|
||||
private void setKitItems(FightTeam team){
|
||||
if(FightState.getFightState() != FightState.PRE_RUNNING)
|
||||
return;
|
@ -1,26 +0,0 @@
|
||||
package de.steamwar.fightsystem.listener;
|
||||
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.utils.FightScoreboard;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
public class ScoreboardListener extends BasicListener {
|
||||
|
||||
public ScoreboardListener() {
|
||||
super(EnumSet.allOf(FightState.class));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
FightScoreboard.showScoreboard(event.getPlayer());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
FightScoreboard.removeScoreboard(event.getPlayer());
|
||||
}
|
||||
}
|
55
FightSystem_Main/src/de/steamwar/fightsystem/listener/TestJoin.java
Normale Datei
55
FightSystem_Main/src/de/steamwar/fightsystem/listener/TestJoin.java
Normale Datei
@ -0,0 +1,55 @@
|
||||
/*
|
||||
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.FightSystem;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
|
||||
public class TestJoin implements Listener {
|
||||
|
||||
public TestJoin() {
|
||||
new StateDependentListener(ArenaMode.Test, FightState.All, this);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void handlePlayerJoin(PlayerJoinEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
FightTeam fightTeam = Fight.getPlayerTeam(player);
|
||||
|
||||
if (fightTeam == null && (!Fight.getRedTeam().hasTeamLeader() || !Fight.getBlueTeam().hasTeamLeader())) {
|
||||
player.sendMessage(FightSystem.PREFIX + "§7Werde zum Teamleader mit §8/§eleader");
|
||||
}
|
||||
|
||||
player.setOp(true);
|
||||
|
||||
if(FightState.getFightState() == FightState.PRE_LEADER_SETUP){
|
||||
FightSystem.setPreSchemState();
|
||||
FightSystem.setPostSchemState();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,193 +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.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.countdown.NoPlayersOnlineCountdown;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
public class TestListener extends BasicListener {
|
||||
|
||||
private NoPlayersOnlineCountdown countdown;
|
||||
|
||||
public TestListener() {
|
||||
super(Config.test() ? EnumSet.allOf(FightState.class) : EnumSet.noneOf(FightState.class));
|
||||
if(Config.test())
|
||||
countdown = new NoPlayersOnlineCountdown();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void handlePlayerJoin(PlayerJoinEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
FightTeam fightTeam = Fight.getPlayerTeam(player);
|
||||
|
||||
if (fightTeam == null && (!Fight.getRedTeam().hasTeamLeader() || !Fight.getBlueTeam().hasTeamLeader())) {
|
||||
player.sendMessage(FightSystem.PREFIX + "§7Werde zum Teamleader mit §8/§eleader");
|
||||
}
|
||||
|
||||
if(countdown != null){
|
||||
countdown.disable();
|
||||
countdown = null;
|
||||
}
|
||||
|
||||
player.setOp(true);
|
||||
/*PermissionAttachment attachment = player.addAttachment(FightSystem.getPlugin());
|
||||
attachment.setPermission("fawe.permpack.basic", true);
|
||||
attachment.setPermission("minecraft.command.gamemode", true);
|
||||
attachment.setPermission("minecraft.command.tp", true);
|
||||
attachment.setPermission("worldedit.navigation.jumpto.tool", true);
|
||||
attachment.setPermission("worldedit.navigation.thru.tool", true);
|
||||
attachment.setPermission("worldedit.navigation.jumpto.tool", true);
|
||||
attachment.setPermission("worldedit.navigation.thru.tool", true);
|
||||
attachment.setPermission("worldedit.biome.info", true);
|
||||
attachment.setPermission("worldedit.biome.set", true);
|
||||
attachment.setPermission("worldedit.biome.list", true);
|
||||
attachment.setPermission("worldedit.chunkinfo", true);
|
||||
attachment.setPermission("worldedit.listchunks", true);
|
||||
attachment.setPermission("worldedit.clipboard.cut", true);
|
||||
attachment.setPermission("worldedit.clipboard.paste", true);
|
||||
attachment.setPermission("worldedit.schematic.formats", true);
|
||||
attachment.setPermission("worldedit.schematic.load", true);
|
||||
attachment.setPermission("worldedit.schematic.list", true);
|
||||
attachment.setPermission("worldedit.schematic.save", true);
|
||||
attachment.setPermission("worldedit.clipboard.clear", true);
|
||||
attachment.setPermission("worldedit.clipboard.copy", true);
|
||||
attachment.setPermission("worldedit.clipboard.lazycopy", true);
|
||||
attachment.setPermission("worldedit.clipboard.place", true);
|
||||
attachment.setPermission("worldedit.clipboard.download", true);
|
||||
attachment.setPermission("worldedit.clipboard.flip", true);
|
||||
attachment.setPermission("worldedit.clipboard.rotate", true);
|
||||
attachment.setPermission("worldedit.help", true);
|
||||
attachment.setPermission("worldedit.global-mask", true);
|
||||
attachment.setPermission("worldedit.global-transform", true);
|
||||
attachment.setPermission("worldedit.generation.cylinder", true);
|
||||
attachment.setPermission("worldedit.generation.sphere", true);
|
||||
attachment.setPermission("worldedit.generation.forest", true);
|
||||
attachment.setPermission("worldedit.generation.pumpkins", true);
|
||||
attachment.setPermission("worldedit.generation.pyramid", true);
|
||||
attachment.setPermission("worldedit.generation.shape", true);
|
||||
attachment.setPermission("worldedit.biome.set", true);
|
||||
attachment.setPermission("worldedit.history.undo", true);
|
||||
attachment.setPermission("worldedit.history.redo", true);
|
||||
attachment.setPermission("worldedit.history.rollback", true);
|
||||
attachment.setPermission("worldedit.navigation.unstuck", true);
|
||||
attachment.setPermission("worldedit.navigation.ascend", true);
|
||||
attachment.setPermission("worldedit.navigation.descend", true);
|
||||
attachment.setPermission("worldedit.navigation.ceiling", true);
|
||||
attachment.setPermission("worldedit.navigation.thru.command", true);
|
||||
attachment.setPermission("worldedit.navigation.jumpto.command", true);
|
||||
attachment.setPermission("worldedit.navigation.up", true);
|
||||
attachment.setPermission("worldedit.region.hollow", true);
|
||||
attachment.setPermission("worldedit.region.line", true);
|
||||
attachment.setPermission("worldedit.region.curve", true);
|
||||
attachment.setPermission("worldedit.region.overlay", true);
|
||||
attachment.setPermission("worldedit.region.center", true);
|
||||
attachment.setPermission("worldedit.region.naturalize", true);
|
||||
attachment.setPermission("worldedit.region.walls", true);
|
||||
attachment.setPermission("worldedit.region.faces", true);
|
||||
attachment.setPermission("worldedit.region.smooth", true);
|
||||
attachment.setPermission("worldedit.region.move", true);
|
||||
attachment.setPermission("worldedit.region.forest", true);
|
||||
attachment.setPermission("worldedit.region.replace", true);
|
||||
attachment.setPermission("worldedit.region.stack", true);
|
||||
attachment.setPermission("worldedit.region.set", true);
|
||||
attachment.setPermission("worldedit.selection.pos", true);
|
||||
attachment.setPermission("worldedit.selection.chunk", true);
|
||||
attachment.setPermission("worldedit.selection.hpos", true);
|
||||
attachment.setPermission("worldedit.wand", true);
|
||||
attachment.setPermission("worldedit.wand.toggle", true);
|
||||
attachment.setPermission("worldedit.selection.contract", true);
|
||||
attachment.setPermission("worldedit.selection.outset", true);
|
||||
attachment.setPermission("worldedit.selection.inset", true);
|
||||
attachment.setPermission("worldedit.analysis.distr", true);
|
||||
attachment.setPermission("worldedit.analysis.count", true);
|
||||
attachment.setPermission("worldedit.selection.size", true);
|
||||
attachment.setPermission("worldedit.selection.expand", true);
|
||||
attachment.setPermission("worldedit.selection.shift", true);
|
||||
attachment.setPermission("worldedit.snapshots.list", true);
|
||||
attachment.setPermission("worldedit.superpickaxe", true);
|
||||
attachment.setPermission("worldedit.superpickaxe.area", true);
|
||||
attachment.setPermission("worldedit.superpickaxe.recursive", true);
|
||||
attachment.setPermission("worldedit.brush.blendball", true);
|
||||
attachment.setPermission("worldedit.brush.erode", true);
|
||||
attachment.setPermission("worldedit.brush.pull", true);
|
||||
attachment.setPermission("worldedit.brush.circle", true);
|
||||
attachment.setPermission("worldedit.brush.recursive", true);
|
||||
attachment.setPermission("worldedit.brush.line", true);
|
||||
attachment.setPermission("worldedit.brush.spline", true);
|
||||
attachment.setPermission("worldedit.brush.surfacespline", true);
|
||||
attachment.setPermission("worldedit.brush.shatter", true);
|
||||
attachment.setPermission("worldedit.brush.stencil", true);
|
||||
attachment.setPermission("worldedit.brush.height", true);
|
||||
attachment.setPermission("worldedit.brush.layer", true);
|
||||
attachment.setPermission("worldedit.brush.populateschematic", true);
|
||||
attachment.setPermission("worldedit.brush.scatter", true);
|
||||
attachment.setPermission("worldedit.brush.splatter", true);
|
||||
attachment.setPermission("worldedit.brush.scattercommand", true);
|
||||
attachment.setPermission("worldedit.brush.copy", true);
|
||||
attachment.setPermission("worldedit.brush.command", true);
|
||||
attachment.setPermission("worldedit.brush.apply", true);
|
||||
attachment.setPermission("worldedit.brush.sphere", true);
|
||||
attachment.setPermission("worldedit.brush.cylinder", true);
|
||||
attachment.setPermission("worldedit.brush.clipboard", true);
|
||||
attachment.setPermission("worldedit.brush.smooth", true);
|
||||
attachment.setPermission("worldedit.brush.ex", true);
|
||||
attachment.setPermission("worldedit.brush.gravity", true);
|
||||
attachment.setPermission("worldedit.brush.options.range", true);
|
||||
attachment.setPermission("worldedit.brush.options.material", true);
|
||||
attachment.setPermission("worldedit.brush.options.size", true);
|
||||
attachment.setPermission("worldedit.brush.options.mask", true);
|
||||
attachment.setPermission("worldedit.brush.options.smask", true);
|
||||
attachment.setPermission("worldedit.brush.options.transform", true);
|
||||
attachment.setPermission("worldedit.brush.options.scroll", true);
|
||||
attachment.setPermission("worldedit.brush.options.visualize", true);
|
||||
attachment.setPermission("worldedit.tool.deltree", true);
|
||||
attachment.setPermission("worldedit.tool.farwand", true);
|
||||
attachment.setPermission("worldedit.tool.lrbuild", true);
|
||||
attachment.setPermission("worldedit.tool.info", true);
|
||||
attachment.setPermission("worldedit.tool.tree", true);
|
||||
attachment.setPermission("worldedit.tool.replacer", true);
|
||||
attachment.setPermission("worldedit.tool.data-cycler", true);
|
||||
attachment.setPermission("worldedit.tool.flood-fill", true);
|
||||
attachment.setPermission("worldedit.tool.inspect", true);
|
||||
attachment.setPermission("worldedit.fill.recursive", true);
|
||||
attachment.setPermission("worldedit.drain", true);
|
||||
attachment.setPermission("worldedit.fixlava", true);
|
||||
attachment.setPermission("worldedit.fixwater", true);
|
||||
attachment.setPermission("worldedit.removeabove", true);
|
||||
attachment.setPermission("worldedit.removebelow", true);
|
||||
attachment.setPermission("worldedit.removenear", true);
|
||||
attachment.setPermission("worldedit.replacenear", true);
|
||||
attachment.setPermission("worldedit.snow", true);
|
||||
attachment.setPermission("worldedit.thaw", true);
|
||||
attachment.setPermission("worldedit.green", true);
|
||||
attachment.setPermission("worldedit.extinguish", true);
|
||||
attachment.setPermission("worldedit.calc", true);
|
||||
attachment.setPermission("worldedit.fill", true);*/
|
||||
}
|
||||
}
|
@ -20,21 +20,22 @@
|
||||
package de.steamwar.fightsystem.listener;
|
||||
|
||||
import de.steamwar.core.VersionedCallable;
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
public class WaterRemover extends BasicListener {
|
||||
public class WaterRemover implements Listener {
|
||||
|
||||
private static final int MIN_Y = Config.AlignWater ? Config.TeamBlueCornerY + Config.WaterDepth : Config.TeamBlueCornerY;
|
||||
|
||||
public WaterRemover() {
|
||||
super(EnumSet.of(FightState.RUNNING));
|
||||
new StateDependentListener(ArenaMode.All, FightState.Running, this);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -54,7 +55,8 @@ public class WaterRemover extends BasicListener {
|
||||
|
||||
private void checkBlock(Block b) {
|
||||
//checks for water and removes it, if present
|
||||
if(!VersionedCallable.call(new VersionedCallable<>(() -> WaterRemover_8.removeWater(b), 8),
|
||||
if(!VersionedCallable.call(
|
||||
new VersionedCallable<>(() -> WaterRemover_8.removeWater(b), 8),
|
||||
new VersionedCallable<>(() -> WaterRemover_14.removeWater(b), 14)))
|
||||
return;
|
||||
|
||||
@ -69,7 +71,8 @@ public class WaterRemover extends BasicListener {
|
||||
}
|
||||
|
||||
public static boolean isWater(Block block){
|
||||
return VersionedCallable.call(new VersionedCallable<>(() -> WaterRemover_8.isWater(block), 8),
|
||||
return VersionedCallable.call(
|
||||
new VersionedCallable<>(() -> WaterRemover_8.isWater(block), 8),
|
||||
new VersionedCallable<>(() -> WaterRemover_14.isWater(block), 14));
|
||||
}
|
||||
}
|
||||
|
@ -20,6 +20,7 @@
|
||||
package de.steamwar.fightsystem.record;
|
||||
|
||||
import de.steamwar.core.VersionedCallable;
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
@ -48,7 +49,7 @@ public class RecordSystem {
|
||||
if (Config.SpectateSystem)
|
||||
new SpectateConnection();
|
||||
new FileRecorder();
|
||||
if(Config.event())
|
||||
if(Config.mode == ArenaMode.EVENT)
|
||||
teamIds(Config.EventTeamBlueID, Config.EventTeamRedID);
|
||||
}
|
||||
|
||||
|
@ -19,10 +19,7 @@
|
||||
|
||||
package de.steamwar.fightsystem.states;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
|
||||
public enum FightState {
|
||||
PRE_LEADER_SETUP,
|
||||
@ -32,19 +29,28 @@ public enum FightState {
|
||||
RUNNING,
|
||||
SPECTATE;
|
||||
|
||||
public static Set<FightState> SETUP = EnumSet.of(PRE_LEADER_SETUP, PRE_SCHEM_SETUP, POST_SCHEM_SETUP);
|
||||
public static Set<FightState> INGAME = EnumSet.of(PRE_RUNNING, RUNNING);
|
||||
public static Set<FightState> ALL = EnumSet.allOf(FightState.class);
|
||||
public static Set<FightState> SCHEM = EnumSet.complementOf(EnumSet.of(FightState.PRE_LEADER_SETUP, FightState.PRE_SCHEM_SETUP));
|
||||
public static final Set<FightState> All = Collections.unmodifiableSet(EnumSet.allOf(FightState.class));
|
||||
|
||||
private static final Map<StateDependent, Boolean> stateDependentFeatures = new HashMap<>();
|
||||
public static final Set<FightState> PreLeaderSetup = Collections.unmodifiableSet(EnumSet.of(PRE_LEADER_SETUP));
|
||||
public static final Set<FightState> PreSchemSetup = Collections.unmodifiableSet(EnumSet.of(PRE_SCHEM_SETUP));
|
||||
public static final Set<FightState> PostSchemSetup = Collections.unmodifiableSet(EnumSet.of(POST_SCHEM_SETUP));
|
||||
public static final Set<FightState> PreRunning = Collections.unmodifiableSet(EnumSet.of(PRE_RUNNING));
|
||||
public static final Set<FightState> Running = Collections.unmodifiableSet(EnumSet.of(RUNNING));
|
||||
public static final Set<FightState> Spectate = Collections.unmodifiableSet(EnumSet.of(SPECTATE));
|
||||
|
||||
public static final Set<FightState> Setup = Collections.unmodifiableSet(EnumSet.of(PRE_LEADER_SETUP, PRE_SCHEM_SETUP, POST_SCHEM_SETUP));
|
||||
public static final Set<FightState> Ingame = Collections.unmodifiableSet(EnumSet.of(PRE_RUNNING, RUNNING));
|
||||
public static final Set<FightState> Schem = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(PRE_LEADER_SETUP, PRE_SCHEM_SETUP)));
|
||||
public static final Set<FightState> AntiRunning = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(RUNNING)));
|
||||
|
||||
private static final Map<IStateDependent, Boolean> stateDependentFeatures = new HashMap<>();
|
||||
private static FightState fightState = PRE_LEADER_SETUP;
|
||||
|
||||
public static FightState getFightState() {
|
||||
return fightState;
|
||||
}
|
||||
|
||||
public static void registerStateDependent(StateDependent stateDependent){
|
||||
public static void registerStateDependent(IStateDependent stateDependent){
|
||||
if(stateDependent.enabled().isEmpty())
|
||||
return;
|
||||
boolean enabled = stateDependent.enabled().contains(fightState);
|
||||
@ -56,7 +62,7 @@ public enum FightState {
|
||||
public static void setFightState(FightState state){
|
||||
fightState = state;
|
||||
|
||||
for(Map.Entry<StateDependent, Boolean> feature : stateDependentFeatures.entrySet()){
|
||||
for(Map.Entry<IStateDependent, Boolean> feature : stateDependentFeatures.entrySet()){
|
||||
//Enable feature if should be enabled and currently disabled
|
||||
if(feature.getKey().enabled().contains(fightState)){
|
||||
if(!feature.getValue()){
|
||||
@ -75,11 +81,11 @@ public enum FightState {
|
||||
}
|
||||
|
||||
public static boolean setup(){
|
||||
return SETUP.contains(fightState);
|
||||
return Setup.contains(fightState);
|
||||
}
|
||||
|
||||
public static boolean ingame(){
|
||||
return INGAME.contains(fightState);
|
||||
return Ingame.contains(fightState);
|
||||
}
|
||||
|
||||
public static boolean infight(){
|
||||
|
@ -17,39 +17,29 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.fightsystem.winconditions;
|
||||
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
package de.steamwar.fightsystem.states;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
abstract class ListenerWincondition extends Wincondition implements Listener {
|
||||
public interface IStateDependent {
|
||||
|
||||
protected ListenerWincondition(Winconditions condition, Set<FightState> enabled, String windescription){
|
||||
super(condition, enabled, windescription);
|
||||
}
|
||||
|
||||
protected ListenerWincondition(boolean condition, Set<FightState> enabled, String windescription) {
|
||||
super(condition, enabled, windescription);
|
||||
}
|
||||
/**
|
||||
* @return returns a set containing
|
||||
*/
|
||||
Set<FightState> enabled();
|
||||
|
||||
/**
|
||||
* Enables the state dependent object
|
||||
*/
|
||||
@Override
|
||||
public void enable(){
|
||||
Bukkit.getPluginManager().registerEvents(this, FightSystem.getPlugin());
|
||||
}
|
||||
void enable();
|
||||
|
||||
/**
|
||||
* Disables the state dependent object
|
||||
*/
|
||||
@Override
|
||||
public void disable(){
|
||||
HandlerList.unregisterAll(this);
|
||||
}
|
||||
void disable();
|
||||
|
||||
/**
|
||||
* On state change when enabled
|
||||
*/
|
||||
default void stateChange(FightState state){}
|
||||
}
|
@ -1,45 +1,32 @@
|
||||
/*
|
||||
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.states;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.winconditions.Winconditions;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public interface StateDependent {
|
||||
public abstract class StateDependent implements IStateDependent {
|
||||
|
||||
/**
|
||||
* @return returns a set containing
|
||||
*/
|
||||
Set<FightState> enabled();
|
||||
private final Set<FightState> enabled;
|
||||
|
||||
/**
|
||||
* Enables the state dependent object
|
||||
*/
|
||||
void enable();
|
||||
protected StateDependent(Winconditions wincondition, Set<FightState> states){
|
||||
this(Config.ActiveWinconditions.contains(wincondition), states);
|
||||
}
|
||||
|
||||
/**
|
||||
* Disables the state dependent object
|
||||
*/
|
||||
void disable();
|
||||
protected StateDependent(Set<ArenaMode> mode, Set<FightState> states){
|
||||
this(mode.contains(Config.mode), states);
|
||||
}
|
||||
|
||||
/**
|
||||
* On state change when enabled
|
||||
*/
|
||||
default void stateChange(FightState state){}
|
||||
protected StateDependent(boolean enabled, Set<FightState> states){
|
||||
this.enabled = states;
|
||||
|
||||
if(enabled)
|
||||
FightState.registerStateDependent(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<FightState> enabled() {
|
||||
return enabled;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,56 @@
|
||||
/*
|
||||
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.states;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public class StateDependentCommand extends StateDependent {
|
||||
|
||||
private static final CommandExecutor unavailible = (sender, cmd, s, strings) -> {
|
||||
sender.sendMessage(FightSystem.PREFIX + "§cDieser Befehl ist zu diesem Kampfzeitpunkt nicht verfügbar.");
|
||||
return false;
|
||||
};
|
||||
|
||||
private final PluginCommand command;
|
||||
private final CommandExecutor executor;
|
||||
|
||||
public StateDependentCommand(Set<ArenaMode> mode, Set<FightState> states, String name, CommandExecutor executor) {
|
||||
super(mode, states);
|
||||
this.executor = executor;
|
||||
this.command = FightSystem.getPlugin().getCommand(name);
|
||||
assert command != null;
|
||||
disable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enable() {
|
||||
command.setExecutor(executor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable() {
|
||||
command.setExecutor(unavailible);
|
||||
}
|
||||
}
|
@ -17,40 +17,40 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.fightsystem.winconditions;
|
||||
package de.steamwar.fightsystem.states;
|
||||
|
||||
import de.steamwar.fightsystem.countdown.TimeOverCountdown;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.countdown.Countdown;
|
||||
import de.steamwar.fightsystem.winconditions.Winconditions;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.Set;
|
||||
|
||||
public abstract class TimeoutWincondition extends Wincondition {
|
||||
public class StateDependentCountdown extends StateDependent {
|
||||
|
||||
private static TimeOverCountdown timeOverCountdown = null;
|
||||
private final Countdown countdown;
|
||||
|
||||
protected TimeoutWincondition(Winconditions condition, Set<FightState> enabled, String windescription) {
|
||||
super(condition, enabled, windescription);
|
||||
public StateDependentCountdown(Set<ArenaMode> mode, Set<FightState> states, Countdown countdown) {
|
||||
super(mode, states);
|
||||
this.countdown = countdown;
|
||||
}
|
||||
|
||||
protected TimeoutWincondition(Winconditions condition, String windescription) {
|
||||
super(condition, EnumSet.of(FightState.RUNNING), windescription);
|
||||
public StateDependentCountdown(Winconditions wincondition, Set<FightState> states, Countdown countdown) {
|
||||
super(Config.ActiveWinconditions.contains(wincondition), states);
|
||||
this.countdown = countdown;
|
||||
}
|
||||
|
||||
protected abstract void timeOver();
|
||||
public Countdown getCountdown(){
|
||||
return countdown;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enable() {
|
||||
timeOverCountdown = new TimeOverCountdown(this::timeOver);
|
||||
countdown.enable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable() {
|
||||
if(timeOverCountdown != null)
|
||||
timeOverCountdown.disable();
|
||||
}
|
||||
|
||||
public static TimeOverCountdown getTimeOverCountdown(){
|
||||
return timeOverCountdown;
|
||||
countdown.disable();
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
/*
|
||||
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
|
||||
@ -17,39 +17,44 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.fightsystem.listener;
|
||||
package de.steamwar.fightsystem.states;
|
||||
|
||||
import de.steamwar.core.Core;
|
||||
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.winconditions.Winconditions;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Set;
|
||||
|
||||
public class VersionDependentListener extends BasicListener {
|
||||
public class StateDependentListener extends StateDependent{
|
||||
|
||||
private static final List<Listener> listeners = new ArrayList<>();
|
||||
private final Listener listener;
|
||||
|
||||
static {
|
||||
if(Core.getVersion() > 8)
|
||||
listeners.add(new PickupArrowListener_9());
|
||||
public StateDependentListener(Winconditions wincondition, Set<FightState> states, Listener listener){
|
||||
super(Config.ActiveWinconditions.contains(wincondition), states);
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
public VersionDependentListener() {
|
||||
super(EnumSet.allOf(FightState.class));
|
||||
public StateDependentListener(boolean enabled, Set<FightState> states, Listener listener){
|
||||
super(enabled, states);
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
public StateDependentListener(Set<ArenaMode> mode, Set<FightState> states, Listener listener) {
|
||||
super(mode, states);
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enable() {
|
||||
for(Listener listener : listeners)
|
||||
Bukkit.getPluginManager().registerEvents(listener, FightSystem.getPlugin());
|
||||
Bukkit.getPluginManager().registerEvents(listener, FightSystem.getPlugin());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable() {
|
||||
for(Listener listener : listeners)
|
||||
HandlerList.unregisterAll(listener);
|
||||
HandlerList.unregisterAll(listener);
|
||||
}
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
/*
|
||||
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.states;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.winconditions.Winconditions;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public class StateDependentTask extends StateDependent {
|
||||
|
||||
private final Runnable runnable;
|
||||
private final long delay;
|
||||
private final long period;
|
||||
|
||||
private BukkitTask task = null;
|
||||
|
||||
public StateDependentTask(Winconditions wincondition, Set<FightState> states, Runnable runnable, long delay, long period){
|
||||
this(Config.ActiveWinconditions.contains(wincondition), states, runnable, delay, period);
|
||||
}
|
||||
|
||||
public StateDependentTask(boolean enabled, Set<FightState> states, Runnable runnable, long delay, long period){
|
||||
super(enabled, states);
|
||||
this.runnable = runnable;
|
||||
this.delay = delay;
|
||||
this.period = period;
|
||||
}
|
||||
|
||||
public StateDependentTask(Set<ArenaMode> mode, Set<FightState> states, Runnable runnable, long delay, long period) {
|
||||
super(mode, states);
|
||||
this.runnable = runnable;
|
||||
this.delay = delay;
|
||||
this.period = period;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enable() {
|
||||
task = Bukkit.getScheduler().runTaskTimer(FightSystem.getPlugin(), runnable, delay, period);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable() {
|
||||
task.cancel();
|
||||
}
|
||||
|
||||
}
|
@ -25,12 +25,12 @@ import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightPlayer;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependent;
|
||||
import de.steamwar.fightsystem.states.IStateDependent;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class EnterHandler implements StateDependent {
|
||||
public class EnterHandler implements IStateDependent {
|
||||
private static final Set<FightState> enabled = EnumSet.of(FightState.PRE_RUNNING, FightState.RUNNING);
|
||||
|
||||
public EnterHandler(){
|
||||
|
@ -21,11 +21,11 @@ package de.steamwar.fightsystem.utils;
|
||||
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.countdown.TimeOverCountdown;
|
||||
import de.steamwar.fightsystem.countdown.Countdown;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightPlayer;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.winconditions.TimeoutWincondition;
|
||||
import de.steamwar.fightsystem.winconditions.Wincondition;
|
||||
import de.steamwar.sql.Elo;
|
||||
import de.steamwar.sql.Schematic;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
@ -78,7 +78,7 @@ public class FightStatistics {
|
||||
}
|
||||
|
||||
int remainingTime = 0;
|
||||
TimeOverCountdown timeOverCountdown = TimeoutWincondition.getTimeOverCountdown();
|
||||
Countdown timeOverCountdown = Wincondition.getTimeOverCountdown();
|
||||
if(timeOverCountdown != null){
|
||||
remainingTime = timeOverCountdown.getTimeLeft();
|
||||
}
|
||||
@ -95,7 +95,7 @@ public class FightStatistics {
|
||||
Bukkit.getLogger().log(Level.SEVERE, "Failed to save statistics", e);
|
||||
}
|
||||
|
||||
if(Config.Ranked && !Config.event()){
|
||||
if(Config.Ranked){
|
||||
int blueElo = Elo.getElo(blueLeader.getId(), gameMode);
|
||||
int redElo = Elo.getElo(redLeader.getId(), gameMode);
|
||||
double redWinExpectation = 1 / (1 + Math.pow(10, (blueElo - redElo) / 400f));
|
||||
|
@ -37,7 +37,7 @@ import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.IFightSystem;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependent;
|
||||
import de.steamwar.fightsystem.states.IStateDependent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -46,7 +46,7 @@ import java.util.*;
|
||||
|
||||
import static de.steamwar.fightsystem.utils.ITechHider.bypass;
|
||||
|
||||
public class TechHider implements StateDependent {
|
||||
public class TechHider implements IStateDependent {
|
||||
|
||||
private static final boolean DISABLED = !Config.OnlyPublicSchematics && !Config.test() && Config.TechhiderActive;
|
||||
|
||||
@ -59,10 +59,21 @@ public class TechHider implements StateDependent {
|
||||
enabled = DISABLED
|
||||
? EnumSet.noneOf(FightState.class)
|
||||
: EnumSet.complementOf(EnumSet.of(FightState.PRE_LEADER_SETUP, FightState.PRE_SCHEM_SETUP));
|
||||
|
||||
Set<Integer> hiddenBlockIds = VersionedCallable.call(
|
||||
new VersionedCallable<>(Collections::emptySet, 8),
|
||||
new VersionedCallable<>(TechHider_12::getHiddenBlockIds, 12),
|
||||
new VersionedCallable<>(TechHider_14::getHiddenBlockIds, 14),
|
||||
new VersionedCallable<>(TechHider_15::getHiddenBlockIds, 15));
|
||||
int obfuscateWith = VersionedCallable.call(
|
||||
new VersionedCallable<>(() -> 0, 8),
|
||||
new VersionedCallable<>(TechHider_12::getObfuscateWith, 12),
|
||||
new VersionedCallable<>(TechHider_14::getObfuscateWith, 14),
|
||||
new VersionedCallable<>(TechHider_15::getObfuscateWith, 15));
|
||||
|
||||
chunkHider = VersionedCallable.call(new VersionedCallable<>(() -> null, 8),
|
||||
new VersionedCallable<>(TechHider_12::chunkHider, 12),
|
||||
new VersionedCallable<>(TechHider_14::chunkHider, 14),
|
||||
new VersionedCallable<>(TechHider_15::chunkHider, 15));
|
||||
new VersionedCallable<>(() -> TechHider_12.chunkHider(hiddenBlockIds, obfuscateWith), 12),
|
||||
new VersionedCallable<>(() -> TechHider_14.chunkHider(hiddenBlockIds, obfuscateWith), 14));
|
||||
|
||||
if(DISABLED)
|
||||
return;
|
||||
@ -144,7 +155,7 @@ public class TechHider implements StateDependent {
|
||||
boolean changed = false;
|
||||
for(MultiBlockChangeInfo mbci : changes){
|
||||
WrappedBlockData block = mbci.getData();
|
||||
if(Config.HiddenBlockTags.contains(block.getType().name())){
|
||||
if(Config.HiddenBlocks.contains(block.getType().name())){
|
||||
changed = true;
|
||||
block.setType(ITechHider.obfuscateMaterial);
|
||||
mbci.setData(block);
|
||||
@ -178,7 +189,7 @@ public class TechHider implements StateDependent {
|
||||
e.setPacket(cached);
|
||||
StructureModifier<WrappedBlockData> blockStructure = cached.getBlockData();
|
||||
WrappedBlockData block = blockStructure.read(0);
|
||||
if(Config.HiddenBlockTags.contains(block.getType().name())){
|
||||
if(Config.HiddenBlocks.contains(block.getType().name())){
|
||||
block.setType(ITechHider.obfuscateMaterial);
|
||||
blockStructure.write(0, block);
|
||||
}
|
||||
|
@ -19,37 +19,37 @@
|
||||
|
||||
package de.steamwar.fightsystem.winconditions;
|
||||
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependent;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
public class EventTeamOffWincondition extends Wincondition {
|
||||
public class EventTeamOffWincondition extends Wincondition{
|
||||
|
||||
public EventTeamOffWincondition(){
|
||||
super(Config.event(), EnumSet.of(FightState.PRE_RUNNING), "TeamOffline");
|
||||
}
|
||||
super("TeamOffline", "§cDas Team ", " §cist offline!", "§cBeide Teams sind offline!");
|
||||
new StateDependent(ArenaMode.Event, FightState.PreRunning) {
|
||||
@Override
|
||||
public void enable() {
|
||||
if(Fight.getBlueTeam().allPlayersOut() && Fight.getRedTeam().allPlayersOut()){
|
||||
win(null);
|
||||
}else{
|
||||
teamOff(Fight.getBlueTeam());
|
||||
teamOff(Fight.getRedTeam());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enable() {
|
||||
if(Fight.getBlueTeam().allPlayersOut() && Fight.getRedTeam().allPlayersOut()){
|
||||
win(null, null, null, "§cBeide Teams sind offline!");
|
||||
}else{
|
||||
teamOff(Fight.getBlueTeam());
|
||||
teamOff(Fight.getRedTeam());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable() {
|
||||
//Team off is a one time trigger
|
||||
@Override
|
||||
public void disable() {
|
||||
//Team off is a one time trigger
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private void teamOff(FightTeam team){
|
||||
if(team.allPlayersOut()){
|
||||
win(Fight.getOpposite(team), "§cDas Team ", " §cist offline!");
|
||||
win(Fight.getOpposite(team));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,22 @@
|
||||
/*
|
||||
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.winconditions;
|
||||
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
|
@ -19,18 +19,21 @@
|
||||
|
||||
package de.steamwar.fightsystem.winconditions;
|
||||
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
public class RankedPlayerLeftWincondition extends ListenerWincondition{
|
||||
public class RankedPlayerLeftWincondition extends Wincondition implements Listener {
|
||||
|
||||
public RankedPlayerLeftWincondition(){
|
||||
super(Config.Ranked, FightState.INGAME, "LeaderQuit");
|
||||
super("LeaderQuit", "§cDer Leader von ", " §chat den Kampf verlassen!");
|
||||
new StateDependentListener(ArenaMode.Ranked, FightState.Setup, this);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -41,7 +44,7 @@ public class RankedPlayerLeftWincondition extends ListenerWincondition{
|
||||
return;
|
||||
|
||||
if(team.isPlayerLeader(player)) {
|
||||
win(Fight.getOpposite(team), "§cDer Leader von ", " §chat den Kampf verlassen!");
|
||||
win(Fight.getOpposite(team));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,43 +19,53 @@
|
||||
|
||||
package de.steamwar.fightsystem.winconditions;
|
||||
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.countdown.Countdown;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependent;
|
||||
import de.steamwar.fightsystem.states.StateDependentCountdown;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public abstract class Wincondition implements StateDependent {
|
||||
public abstract class Wincondition {
|
||||
|
||||
protected static PercentWincondition percentWincondition = null;
|
||||
protected static StateDependentCountdown timeOverCountdown = null;
|
||||
protected static final List<PrintableWincondition> printableWinconditions = new ArrayList<>();
|
||||
|
||||
private final Set<FightState> enabled;
|
||||
private final String windescription;
|
||||
private final String preteammessage;
|
||||
private final String postteammessage;
|
||||
private final String tiemessage;
|
||||
|
||||
protected Wincondition(Winconditions condition, Set<FightState> enabled, String windescription){
|
||||
this(Config.ActiveWinconditions.contains(condition), enabled, windescription);
|
||||
protected Wincondition(String windescription, String tiemessage) {
|
||||
this(windescription, null, null, tiemessage);
|
||||
}
|
||||
|
||||
protected Wincondition(boolean condition, Set<FightState> enabled, String windescription){
|
||||
this.enabled = enabled;
|
||||
protected Wincondition(String windescription, String preteammessage, String postteammessage) {
|
||||
this(windescription, preteammessage, postteammessage, null);
|
||||
}
|
||||
|
||||
protected Wincondition(String windescription, String preteammessage, String postteammessage, String tiemessage) {
|
||||
this.windescription = windescription;
|
||||
if(condition)
|
||||
FightState.registerStateDependent(this);
|
||||
this.preteammessage = preteammessage;
|
||||
this.tiemessage = tiemessage;
|
||||
this.postteammessage = postteammessage;
|
||||
}
|
||||
|
||||
protected void win(FightTeam team, String preteammessage, String postteammessage){
|
||||
win(team, preteammessage, postteammessage, null);
|
||||
public static Countdown getTimeOverCountdown(){
|
||||
return timeOverCountdown.getCountdown();
|
||||
}
|
||||
|
||||
protected void win(FightTeam team, String preteammessage, String postteammessage, String tiemessage){
|
||||
protected void win(FightTeam team, String postteammessage){
|
||||
Bukkit.broadcastMessage(FightSystem.PREFIX + tiemessage + team.getColoredName() + postteammessage);
|
||||
FightSystem.setSpectateState(team, windescription);
|
||||
}
|
||||
|
||||
protected void win(FightTeam team){
|
||||
if(team != null){
|
||||
Bukkit.broadcastMessage(FightSystem.PREFIX + preteammessage + team.getColoredName() + postteammessage);
|
||||
}else{
|
||||
@ -73,11 +83,6 @@ public abstract class Wincondition implements StateDependent {
|
||||
return fightTeam;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<FightState> enabled(){
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public static List<PrintableWincondition> getPrintableWinconditions(){
|
||||
return printableWinconditions;
|
||||
}
|
||||
|
@ -22,15 +22,18 @@ package de.steamwar.fightsystem.winconditions;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
public class WinconditionAllDead extends ListenerWincondition {
|
||||
public class WinconditionAllDead extends Wincondition implements Listener {
|
||||
|
||||
public WinconditionAllDead(){
|
||||
super(Winconditions.ALL_DEAD, FightState.INGAME, "AllDead");
|
||||
super("AllDead", "§cDer letzte Spieler aus ");
|
||||
new StateDependentListener(Winconditions.ALL_DEAD, FightState.Ingame, this);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -49,7 +52,7 @@ public class WinconditionAllDead extends ListenerWincondition {
|
||||
return;
|
||||
|
||||
if(team.allPlayersOut()) {
|
||||
win(Fight.getOpposite(team), "§cDer letzte Spieler aus ", message);
|
||||
win(Fight.getOpposite(team), message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -22,15 +22,18 @@ package de.steamwar.fightsystem.winconditions;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
public class WinconditionCaptainDead extends ListenerWincondition {
|
||||
public class WinconditionCaptainDead extends Wincondition implements Listener {
|
||||
|
||||
public WinconditionCaptainDead(){
|
||||
super(Winconditions.CAPTAIN_DEAD, FightState.INGAME, "LeaderDead");
|
||||
super("LeaderDead", "§cDer Leader von ");
|
||||
new StateDependentListener(Winconditions.CAPTAIN_DEAD, FightState.Ingame, this);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -49,7 +52,7 @@ public class WinconditionCaptainDead extends ListenerWincondition {
|
||||
return;
|
||||
|
||||
if(team.isPlayerLeader(player)) {
|
||||
win(Fight.getOpposite(team), "§cDer Leader von ", message);
|
||||
win(Fight.getOpposite(team), message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,16 +19,19 @@
|
||||
|
||||
package de.steamwar.fightsystem.winconditions;
|
||||
|
||||
import de.steamwar.fightsystem.countdown.TimeOverCountdown;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentCountdown;
|
||||
|
||||
public class WinconditionHeartRatioTimeout extends TimeoutWincondition {
|
||||
public class WinconditionHeartRatioTimeout extends Wincondition {
|
||||
|
||||
public WinconditionHeartRatioTimeout() {
|
||||
super(Winconditions.HEART_RATIO_TIMEOUT, "HeartTimeout");
|
||||
super("HeartTimeout", "§cDie Zeit ist abgelaufen, und Team ", " §chatte mehr verbleibende Leben!", "§cDie Zeit ist abgelaufen, und beide Teams hatten die gleiche Anzahl an verbleibenden Leben!");
|
||||
timeOverCountdown = new StateDependentCountdown(Winconditions.HEART_RATIO_TIMEOUT, FightState.Running, new TimeOverCountdown(this::timeOver));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void timeOver() {
|
||||
double blueHeartRatio = Fight.getBlueTeam().getHeartRatio();
|
||||
double redHeartRatio = Fight.getRedTeam().getHeartRatio();
|
||||
@ -39,6 +42,6 @@ public class WinconditionHeartRatioTimeout extends TimeoutWincondition {
|
||||
else if(blueHeartRatio < redHeartRatio)
|
||||
team = Fight.getRedTeam();
|
||||
|
||||
win(team, "§cDie Zeit ist abgelaufen, und Team ", " §chatte mehr verbleibende Leben!", "§cDie Zeit ist abgelaufen, und beide Teams hatten die gleiche Anzahl an verbleibenden Leben!");
|
||||
win(team);
|
||||
}
|
||||
}
|
||||
|
@ -23,26 +23,29 @@ import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||
import de.steamwar.fightsystem.utils.Region;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class WinconditionPercentSystem extends ListenerWincondition implements PrintableWincondition, PercentWincondition {
|
||||
public class WinconditionPercentSystem extends Wincondition implements Listener, PrintableWincondition, PercentWincondition {
|
||||
|
||||
private static final int SCHEMATIC_SIZE = Math.abs(Config.SchemsizeX * Config.SchemsizeY * Config.SchemsizeZ);
|
||||
|
||||
private final Map<FightTeam, TeamPercent> teamMap = new HashMap<>();
|
||||
|
||||
public WinconditionPercentSystem() {
|
||||
super(Winconditions.PERCENT_SYSTEM, EnumSet.of(FightState.RUNNING), "Percent");
|
||||
super("Percent", "§cTeam ", " §chat den Gegnern");
|
||||
printableWinconditions.add(this);
|
||||
percentWincondition = this;
|
||||
teamMap.put(Fight.getBlueTeam(), new TeamPercent(Fight.getBlueTeam()));
|
||||
teamMap.put(Fight.getRedTeam(), new TeamPercent(Fight.getRedTeam()));
|
||||
|
||||
new StateDependentListener(Winconditions.PERCENT_SYSTEM, FightState.Running, this);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -78,7 +81,7 @@ public class WinconditionPercentSystem extends ListenerWincondition implements P
|
||||
destroyedBlocks += event.blockList().size();
|
||||
percent = (double)destroyedBlocks * 100 / SCHEMATIC_SIZE;
|
||||
if(percent >= Config.PercentWin) {
|
||||
win(Fight.getOpposite(team), "§cTeam ", " §chat den Gegnern");
|
||||
win(Fight.getOpposite(team));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,16 +19,19 @@
|
||||
|
||||
package de.steamwar.fightsystem.winconditions;
|
||||
|
||||
import de.steamwar.fightsystem.countdown.TimeOverCountdown;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentCountdown;
|
||||
|
||||
public class WinconditionPercentTimeout extends TimeoutWincondition {
|
||||
public class WinconditionPercentTimeout extends Wincondition {
|
||||
|
||||
public WinconditionPercentTimeout() {
|
||||
super(Winconditions.HEART_RATIO_TIMEOUT, "PercentTimeout");
|
||||
super("PercentTimeout", "§cDie Zeit ist abgelaufen, und Team ", " §chatte weniger Schaden erlitten!", "§cDie Zeit ist abgelaufen, und beide Teams hatten gleichen Schaden!");
|
||||
timeOverCountdown = new StateDependentCountdown(Winconditions.PERCENT_TIMEOUT, FightState.Running, new TimeOverCountdown(this::timeOver));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void timeOver() {
|
||||
double bluePercent = Wincondition.percentWincondition.getPercent(Fight.getBlueTeam());
|
||||
double redPercent = Wincondition.percentWincondition.getPercent(Fight.getRedTeam());
|
||||
@ -38,6 +41,6 @@ public class WinconditionPercentTimeout extends TimeoutWincondition {
|
||||
team = Fight.getRedTeam();
|
||||
else if(bluePercent < redPercent)
|
||||
team = Fight.getBlueTeam();
|
||||
win(team, "§cDie Zeit ist abgelaufen, und Team ", " §chatte weniger Schaden erlitten!", "§cDie Zeit ist abgelaufen, und beide Teams hatten gleichen Schaden!");
|
||||
win(team);
|
||||
}
|
||||
}
|
||||
|
@ -20,13 +20,16 @@
|
||||
package de.steamwar.fightsystem.winconditions;
|
||||
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.countdown.TimeOverCountdown;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependent;
|
||||
import de.steamwar.fightsystem.states.StateDependentCountdown;
|
||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
@ -34,23 +37,32 @@ import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class WinconditionPoints extends TimeoutWincondition implements PrintableWincondition, Listener {
|
||||
public class WinconditionPoints extends Wincondition implements PrintableWincondition, Listener {
|
||||
|
||||
private final Map<FightTeam, WinconditionRelativePercent.TeamPercent> percentMap = new HashMap<>();
|
||||
private final Map<FightTeam, TeamPoints> teamMap = new HashMap<>();
|
||||
|
||||
public WinconditionPoints(){
|
||||
super(Winconditions.POINTS, FightState.INGAME, "Points");
|
||||
|
||||
percentMap.put(Fight.getBlueTeam(), new WinconditionRelativePercent.TeamPercent(Fight.getBlueTeam()));
|
||||
percentMap.put(Fight.getRedTeam(), new WinconditionRelativePercent.TeamPercent(Fight.getRedTeam()));
|
||||
super("Points", "§cDas Team ", " §chat mehr Punkte!", "§cBeide Teams haben gleich viele Punkte!");
|
||||
|
||||
teamMap.put(Fight.getBlueTeam(), new TeamPoints(Fight.getBlueTeam()));
|
||||
teamMap.put(Fight.getRedTeam(), new TeamPoints(Fight.getRedTeam()));
|
||||
printableWinconditions.add(this);
|
||||
|
||||
new StateDependentListener(Winconditions.POINTS, FightState.Ingame, this);
|
||||
timeOverCountdown = new StateDependentCountdown(Winconditions.POINTS, FightState.Running, new TimeOverCountdown(this::timeOver));
|
||||
new StateDependent(Winconditions.POINTS, FightState.Ingame){
|
||||
@Override
|
||||
public void enable() {
|
||||
teamMap.values().forEach(TeamPoints::enable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable() {
|
||||
teamMap.values().forEach(TeamPoints::disable);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void timeOver() {
|
||||
int redPoints = teamMap.get(Fight.getRedTeam()).getPoints();
|
||||
int bluePoints = teamMap.get(Fight.getBlueTeam()).getPoints();
|
||||
@ -61,26 +73,7 @@ public class WinconditionPoints extends TimeoutWincondition implements Printable
|
||||
else if(redPoints < bluePoints)
|
||||
team = Fight.getBlueTeam();
|
||||
|
||||
win(team, "§cDas Team ", " §chat mehr Punkte!", "§cBeide Teams haben gleich viele Punkte!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enable() {
|
||||
Bukkit.getPluginManager().registerEvents(this, FightSystem.getPlugin());
|
||||
teamMap.values().forEach(TeamPoints::enable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable() {
|
||||
super.disable();
|
||||
HandlerList.unregisterAll(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stateChange(FightState state){
|
||||
if(state == FightState.RUNNING){
|
||||
super.enable();
|
||||
}
|
||||
win(team);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -119,19 +112,21 @@ public class WinconditionPoints extends TimeoutWincondition implements Printable
|
||||
private static final int MAX_POINTS = 2000;
|
||||
|
||||
private final FightTeam team;
|
||||
private final WinconditionRelativePercent.TeamPercent percent;
|
||||
|
||||
private double factor;
|
||||
private int points;
|
||||
|
||||
TeamPoints(FightTeam team){
|
||||
this.team = team;
|
||||
points = 0;
|
||||
this.percent = new WinconditionRelativePercent.TeamPercent(team);
|
||||
this.points = 0;
|
||||
}
|
||||
|
||||
public void enable() {
|
||||
percentMap.get(team).enable();
|
||||
int ownBlocks = percentMap.get(team).getBlockCount();
|
||||
int enemyBlocks = percentMap.get(Fight.getOpposite(team)).getBlockCount();
|
||||
percent.enable();
|
||||
int ownBlocks = percent.getBlockCount();
|
||||
int enemyBlocks = teamMap.get(Fight.getOpposite(team)).percent.getBlockCount();
|
||||
|
||||
if(enemyBlocks < ownBlocks) {
|
||||
this.factor = 10000; //Original mit 20 (20% = 0.2 ergeben 2000 Punkte
|
||||
@ -147,8 +142,12 @@ public class WinconditionPoints extends TimeoutWincondition implements Printable
|
||||
}
|
||||
}
|
||||
|
||||
public void disable(){
|
||||
percent.disable();
|
||||
}
|
||||
|
||||
public int getPoints(){
|
||||
int damagePoints = (int)(percentMap.get(Fight.getOpposite(team)).getPercent() * factor);
|
||||
int damagePoints = (int)(teamMap.get(Fight.getOpposite(team)).percent.getPercent() * factor);
|
||||
if(damagePoints > MAX_POINTS)
|
||||
damagePoints = MAX_POINTS;
|
||||
return points + damagePoints;
|
||||
|
@ -20,15 +20,14 @@
|
||||
package de.steamwar.fightsystem.winconditions;
|
||||
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentTask;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@ -39,24 +38,14 @@ public class WinconditionPumpkinTechKO extends Wincondition implements Printable
|
||||
private static final Material PUMPKIN_LANTERN = SWItem.getMaterial("JACK_O_LANTERN");
|
||||
|
||||
private final Map<FightTeam, TeamPumpkin> teamMap = new HashMap<>();
|
||||
private BukkitTask task;
|
||||
|
||||
public WinconditionPumpkinTechKO(){
|
||||
super(Winconditions.PUMPKIN_TECH_KO, FightState.INGAME, "PumpkinTechKO");
|
||||
super("PumpkinTechKO", "§cDas Team ", " §cist Tech K.O.!");
|
||||
new StateDependentTask(Winconditions.PUMPKIN_TECH_KO, FightState.Ingame, this::check, 0, 200);
|
||||
teamMap.put(Fight.getRedTeam(), new TeamPumpkin(Fight.getRedTeam()));
|
||||
teamMap.put(Fight.getBlueTeam(), new TeamPumpkin(Fight.getBlueTeam()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enable() {
|
||||
task = Bukkit.getScheduler().runTaskTimer(FightSystem.getPlugin(), this::check, 0, 200);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable() {
|
||||
task.cancel();
|
||||
}
|
||||
|
||||
private void check(){
|
||||
teamMap.values().forEach(TeamPumpkin::check);
|
||||
}
|
||||
@ -87,7 +76,7 @@ public class WinconditionPumpkinTechKO extends Wincondition implements Printable
|
||||
}
|
||||
|
||||
if(pumpkins == 0) {
|
||||
win(Fight.getOpposite(team), "§cDas Team ", " §cist Tech K.O.!");
|
||||
win(Fight.getOpposite(team));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
@ -46,21 +47,22 @@ public class WinconditionRelativePercent extends Wincondition implements Printab
|
||||
private final Map<FightTeam, TeamPercent> teamMap = new HashMap<>();
|
||||
|
||||
public WinconditionRelativePercent(){
|
||||
super(Winconditions.RELATIVE_PERCENT, EnumSet.of(FightState.PRE_RUNNING, FightState.RUNNING), "RelativePercent");
|
||||
super("RelativePercent", null);
|
||||
teamMap.put(Fight.getBlueTeam(), new TeamPercent(Fight.getBlueTeam()));
|
||||
teamMap.put(Fight.getRedTeam(), new TeamPercent(Fight.getRedTeam()));
|
||||
printableWinconditions.add(this);
|
||||
percentWincondition = this;
|
||||
}
|
||||
new StateDependent(Winconditions.RELATIVE_PERCENT, FightState.Running){
|
||||
@Override
|
||||
public void enable() {
|
||||
teamMap.values().forEach(TeamPercent::enable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enable() {
|
||||
teamMap.values().forEach(TeamPercent::enable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable() {
|
||||
teamMap.values().forEach(teamPercent -> teamPercent.task.cancel());
|
||||
@Override
|
||||
public void disable() {
|
||||
teamMap.values().forEach(TeamPercent::disable);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -90,6 +92,10 @@ public class WinconditionRelativePercent extends Wincondition implements Printab
|
||||
task = Bukkit.getScheduler().runTaskTimer(FightSystem.getPlugin(), this::check, 400, 400);
|
||||
}
|
||||
|
||||
public void disable(){
|
||||
task.cancel();
|
||||
}
|
||||
|
||||
private void check(){
|
||||
currentBlocks = currentBlocks();
|
||||
|
||||
@ -114,7 +120,7 @@ public class WinconditionRelativePercent extends Wincondition implements Printab
|
||||
|
||||
private int currentBlocks(){
|
||||
// Entern active
|
||||
if(!Config.EnterStages.isEmpty() && Config.EnterStages.get(0) >= Config.TimeoutTime - TimeoutWincondition.getTimeOverCountdown().getTimeLeft())
|
||||
if(!Config.EnterStages.isEmpty() && Config.EnterStages.get(0) >= Config.TimeoutTime - Wincondition.getTimeOverCountdown().getTimeLeft())
|
||||
return currentBlocks;
|
||||
|
||||
int blocks = 0;
|
||||
|
@ -20,19 +20,17 @@
|
||||
package de.steamwar.fightsystem.winconditions;
|
||||
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.countdown.TechKOCountdown;
|
||||
import de.steamwar.fightsystem.countdown.Countdown;
|
||||
import de.steamwar.fightsystem.countdown.SWSound;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentTask;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
public class WinconditionTimeTechKO extends ListenerWincondition {
|
||||
public class WinconditionTimeTechKO extends Wincondition {
|
||||
|
||||
private static final int TECH_KO_TIME_IN_S = 90;
|
||||
private static final int TECH_KO_HALF_TIME = TECH_KO_TIME_IN_S*10;
|
||||
@ -46,13 +44,12 @@ public class WinconditionTimeTechKO extends ListenerWincondition {
|
||||
private int biggerZtime = TECH_KO_HALF_TIME;
|
||||
private TechKOCountdown smallerZcountdown = null;
|
||||
private TechKOCountdown biggerZcountdown = null;
|
||||
private BukkitTask task;
|
||||
|
||||
/**
|
||||
* Works only for z-Axis fight direction for performance reasons
|
||||
*/
|
||||
public WinconditionTimeTechKO(){
|
||||
super(Winconditions.TIME_TECH_KO, EnumSet.of(FightState.RUNNING), null);
|
||||
super("TechKO", "", " §chat den Gegner Tech K.O. gesetzt!");
|
||||
|
||||
if(Config.TeamBluetoReddistanceZ > 0) {
|
||||
smallerZteam = Fight.getBlueTeam();
|
||||
@ -61,26 +58,21 @@ public class WinconditionTimeTechKO extends ListenerWincondition {
|
||||
smallerZteam = Fight.getRedTeam();
|
||||
biggerZteam = Fight.getBlueTeam();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enable() {
|
||||
super.enable();
|
||||
task = Bukkit.getScheduler().runTaskTimer(FightSystem.getPlugin(), this::run, 1, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable() {
|
||||
super.disable();
|
||||
if(smallerZcountdown != null){
|
||||
smallerZcountdown.disable();
|
||||
smallerZcountdown = null;
|
||||
}
|
||||
if(biggerZcountdown != null){
|
||||
biggerZcountdown.disable();
|
||||
biggerZcountdown = null;
|
||||
}
|
||||
task.cancel();
|
||||
new StateDependentTask(Winconditions.TIME_TECH_KO, FightState.Running, this::run, 1, 1){
|
||||
@Override
|
||||
public void disable() {
|
||||
super.disable();
|
||||
if(smallerZcountdown != null){
|
||||
smallerZcountdown.disable();
|
||||
smallerZcountdown = null;
|
||||
}
|
||||
if(biggerZcountdown != null){
|
||||
biggerZcountdown.disable();
|
||||
biggerZcountdown = null;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private void run(){
|
||||
@ -111,4 +103,24 @@ public class WinconditionTimeTechKO extends ListenerWincondition {
|
||||
smallerZtime--;
|
||||
biggerZtime--;
|
||||
}
|
||||
|
||||
private class TechKOCountdown extends Countdown {
|
||||
private final FightTeam team;
|
||||
|
||||
public TechKOCountdown(FightTeam team, int countdownTime) {
|
||||
super(countdownTime, SWSound.BLOCK_NOTE_PLING, false);
|
||||
this.team = team;
|
||||
super.enable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String countdownCounting() {
|
||||
return "bis " + team.getColoredName() + " §feinen Schuss abgegeben haben muss!";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void countdownFinished() {
|
||||
win(Fight.getOpposite(team));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,14 +19,18 @@
|
||||
|
||||
package de.steamwar.fightsystem.winconditions;
|
||||
|
||||
public class WinconditionTimeout extends TimeoutWincondition {
|
||||
import de.steamwar.fightsystem.countdown.TimeOverCountdown;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentCountdown;
|
||||
|
||||
public class WinconditionTimeout extends Wincondition {
|
||||
|
||||
public WinconditionTimeout() {
|
||||
super(Winconditions.TIMEOUT, "Timeout");
|
||||
super("Timeout", "§cDie Zeit ist abgelaufen!");
|
||||
timeOverCountdown = new StateDependentCountdown(Winconditions.TIMEOUT, FightState.Running, new TimeOverCountdown(this::timeOver));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void timeOver() {
|
||||
win(null, null, null, "§cDie Zeit ist abgelaufen!");
|
||||
win(null);
|
||||
}
|
||||
}
|
||||
|
@ -20,16 +20,14 @@
|
||||
package de.steamwar.fightsystem.winconditions;
|
||||
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.listener.WaterRemover;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentTask;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@ -38,23 +36,14 @@ public class WinconditionWaterTechKO extends Wincondition implements PrintableWi
|
||||
private static final World WORLD = Bukkit.getWorlds().get(0);
|
||||
|
||||
private final Map<FightTeam, TeamWater> teamMap = new HashMap<>();
|
||||
private BukkitTask task;
|
||||
|
||||
public WinconditionWaterTechKO() {
|
||||
super(Winconditions.WATER_TECH_KO, EnumSet.of(FightState.PRE_RUNNING, FightState.RUNNING), "WaterTechKO");
|
||||
super("WaterTechKO", "§cDas Team ", " §cwurde Tech K.O. gesetzt!");
|
||||
teamMap.put(Fight.getBlueTeam(), new TeamWater(Fight.getBlueTeam()));
|
||||
teamMap.put(Fight.getRedTeam(), new TeamWater(Fight.getRedTeam()));
|
||||
printableWinconditions.add(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enable() {
|
||||
task = Bukkit.getScheduler().runTaskTimer(FightSystem.getPlugin(), this::check, 200, 200);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable() {
|
||||
task.cancel();
|
||||
new StateDependentTask(Winconditions.WATER_TECH_KO, FightState.Ingame, this::check, 200, 200);
|
||||
}
|
||||
|
||||
private void check() {
|
||||
@ -86,7 +75,7 @@ public class WinconditionWaterTechKO extends Wincondition implements PrintableWi
|
||||
}
|
||||
|
||||
if(water == 0){
|
||||
win(Fight.getOpposite(team), "§cDas Team ", " §cist Tech K.O.!");
|
||||
win(Fight.getOpposite(team));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren