The big refactoring #238
47
FightSystem_10/src/de/steamwar/fightsystem/fight/FightWorld_10.java
Normale Datei
47
FightSystem_10/src/de/steamwar/fightsystem/fight/FightWorld_10.java
Normale Datei
@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
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.fight;
|
||||||
|
|
||||||
|
import de.steamwar.core.events.ChunkListener;
|
||||||
|
import net.minecraft.server.v1_10_R1.Chunk;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.craftbukkit.v1_10_R1.CraftWorld;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
class FightWorld_10 {
|
||||||
|
private FightWorld_10(){}
|
||||||
|
|
||||||
|
static void resetChunk(World world, World backup, int x, int z){
|
||||||
|
net.minecraft.server.v1_10_R1.World w = ((CraftWorld) world).getHandle();
|
||||||
|
Chunk chunk = w.getChunkAt(x, z);
|
||||||
|
Chunk backupChunk = ((CraftWorld) backup).getHandle().getChunkAt(x, z);
|
||||||
|
|
||||||
|
System.arraycopy(backupChunk.getSections(), 0, chunk.getSections(), 0, chunk.getSections().length);
|
||||||
|
System.arraycopy(backupChunk.heightMap, 0, chunk.heightMap, 0, chunk.heightMap.length);
|
||||||
|
w.tileEntityListTick.removeAll(chunk.tileEntities.values());
|
||||||
|
w.tileEntityList.removeAll(chunk.tileEntities.values());
|
||||||
|
chunk.tileEntities.clear();
|
||||||
|
chunk.tileEntities.putAll(backupChunk.tileEntities);
|
||||||
|
for(Player p : Bukkit.getOnlinePlayers()){
|
||||||
|
ChunkListener.sendChunk(p, x, z);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -25,9 +25,9 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
class PersonalKitCreator_10 {
|
public class PersonalKitCreator_10 {
|
||||||
|
|
||||||
static boolean hasItems(ItemStack stack){
|
public static boolean hasItems(ItemStack stack){
|
||||||
Set<String> keys = new HashSet<>(CraftItemStack.asNMSCopy(stack).getTag().c());
|
Set<String> keys = new HashSet<>(CraftItemStack.asNMSCopy(stack).getTag().c());
|
||||||
keys.remove("Enchantments");
|
keys.remove("Enchantments");
|
||||||
keys.remove("Damage");
|
keys.remove("Damage");
|
||||||
|
@ -24,7 +24,7 @@ import com.sk89q.worldedit.MaxChangedBlocksException;
|
|||||||
import com.sk89q.worldedit.Vector;
|
import com.sk89q.worldedit.Vector;
|
||||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||||
import de.steamwar.fightsystem.Config;
|
import de.steamwar.fightsystem.utils.Region;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.DyeColor;
|
import org.bukkit.DyeColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -54,10 +54,9 @@ class FightTeam_12 {
|
|||||||
|
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
static void replaceTeamColor(EditSession e, DyeColor c, int cornerX, int cornerY, int cornerZ){
|
static void replaceTeamColor(EditSession e, DyeColor c, Region r){
|
||||||
FightTeam_8.replaceTeamColor(e, c, cornerX, cornerY, cornerZ);
|
FightTeam_8.replaceTeamColor(e, c, r);
|
||||||
Vector corner = new Vector(cornerX, cornerY, cornerZ);
|
CuboidRegion region = new CuboidRegion(new Vector(r.getMinX(), r.getMinY(), r.getMinZ()), new Vector(r.getMaxX(), r.getMaxY(), r.getMaxZ()));
|
||||||
CuboidRegion region = new CuboidRegion(corner, corner.add(Config.SchemsizeX, Config.SchemsizeY, Config.SchemsizeZ));
|
|
||||||
try {
|
try {
|
||||||
e.replaceBlocks(region, CONCRETE_SET, new BaseBlock(CONCRETE.getId(), c.getWoolData()));
|
e.replaceBlocks(region, CONCRETE_SET, new BaseBlock(CONCRETE.getId(), c.getWoolData()));
|
||||||
e.replaceBlocks(region, CONCRETE_POWDER_SET, new BaseBlock(CONCRETE_POWDER.getId(), c.getWoolData()));
|
e.replaceBlocks(region, CONCRETE_POWDER_SET, new BaseBlock(CONCRETE_POWDER.getId(), c.getWoolData()));
|
||||||
|
47
FightSystem_12/src/de/steamwar/fightsystem/fight/FightWorld_12.java
Normale Datei
47
FightSystem_12/src/de/steamwar/fightsystem/fight/FightWorld_12.java
Normale Datei
@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
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.fight;
|
||||||
|
|
||||||
|
import de.steamwar.core.events.ChunkListener;
|
||||||
|
import net.minecraft.server.v1_12_R1.Chunk;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.craftbukkit.v1_12_R1.CraftWorld;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
class FightWorld_12 {
|
||||||
|
private FightWorld_12(){}
|
||||||
|
|
||||||
|
static void resetChunk(World world, World backup, int x, int z){
|
||||||
|
net.minecraft.server.v1_12_R1.World w = ((CraftWorld) world).getHandle();
|
||||||
|
Chunk chunk = w.getChunkAt(x, z);
|
||||||
|
Chunk backupChunk = ((CraftWorld) backup).getHandle().getChunkAt(x, z);
|
||||||
|
|
||||||
|
System.arraycopy(backupChunk.getSections(), 0, chunk.getSections(), 0, chunk.getSections().length);
|
||||||
|
System.arraycopy(backupChunk.heightMap, 0, chunk.heightMap, 0, chunk.heightMap.length);
|
||||||
|
w.tileEntityListTick.removeAll(chunk.tileEntities.values());
|
||||||
|
w.tileEntityList.removeAll(chunk.tileEntities.values());
|
||||||
|
chunk.tileEntities.clear();
|
||||||
|
chunk.tileEntities.putAll(backupChunk.tileEntities);
|
||||||
|
for(Player p : Bukkit.getOnlinePlayers()){
|
||||||
|
ChunkListener.sendChunk(p, x, z);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -25,9 +25,9 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
class PersonalKitCreator_12 {
|
public class PersonalKitCreator_12 {
|
||||||
|
|
||||||
static boolean hasItems(ItemStack stack){
|
public static boolean hasItems(ItemStack stack){
|
||||||
Set<String> keys = new HashSet<>(CraftItemStack.asNMSCopy(stack).getTag().c());
|
Set<String> keys = new HashSet<>(CraftItemStack.asNMSCopy(stack).getTag().c());
|
||||||
keys.remove("Enchantments");
|
keys.remove("Enchantments");
|
||||||
keys.remove("Damage");
|
keys.remove("Damage");
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
package de.steamwar.fightsystem.utils;
|
package de.steamwar.fightsystem.utils;
|
||||||
|
|
||||||
import com.comphenix.protocol.PacketType;
|
import com.comphenix.protocol.PacketType;
|
||||||
import com.comphenix.protocol.ProtocolLibrary;
|
|
||||||
import com.comphenix.protocol.events.PacketAdapter;
|
import com.comphenix.protocol.events.PacketAdapter;
|
||||||
import com.comphenix.protocol.events.PacketContainer;
|
import com.comphenix.protocol.events.PacketContainer;
|
||||||
import com.comphenix.protocol.events.PacketEvent;
|
import com.comphenix.protocol.events.PacketEvent;
|
||||||
@ -35,6 +34,7 @@ import org.bukkit.Bukkit;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
import static de.steamwar.fightsystem.utils.ITechHider.bypass;
|
import static de.steamwar.fightsystem.utils.ITechHider.bypass;
|
||||||
@ -42,14 +42,8 @@ import static de.steamwar.fightsystem.utils.ITechHider.bypass;
|
|||||||
class TechHider_12 {
|
class TechHider_12 {
|
||||||
private TechHider_12(){}
|
private TechHider_12(){}
|
||||||
|
|
||||||
private static final short obfuscateShift4 = (short)(Config.ObfuscateWith << 4);
|
static PacketAdapter chunkHider(Set<Integer> hiddenBlockIds, int obfuscateWith){
|
||||||
|
return new PacketAdapter(IFightSystem.getPlugin(), PacketType.Play.Server.MAP_CHUNK) {
|
||||||
static void start(){
|
|
||||||
chunkHider();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void chunkHider(){
|
|
||||||
ProtocolLibrary.getProtocolManager().getAsynchronousManager().registerAsyncHandler(new PacketAdapter(IFightSystem.getPlugin(), PacketType.Play.Server.MAP_CHUNK) {
|
|
||||||
@Override
|
@Override
|
||||||
public void onPacketSending(PacketEvent e) {
|
public void onPacketSending(PacketEvent e) {
|
||||||
PacketContainer packet = e.getPacket();
|
PacketContainer packet = e.getPacket();
|
||||||
@ -96,8 +90,8 @@ class TechHider_12 {
|
|||||||
int entry = ITechHider.readVarInt(data, i);
|
int entry = ITechHider.readVarInt(data, i);
|
||||||
i += ITechHider.readVarIntLength(data, i);
|
i += ITechHider.readVarIntLength(data, i);
|
||||||
|
|
||||||
if(Config.HiddenBlocks.contains(entry >> 4)){
|
if(hiddenBlockIds.contains(entry)){
|
||||||
entry = obfuscateShift4;
|
entry = obfuscateWith;
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
buffer.writeBytes(ITechHider.writeVarInt(entry));
|
buffer.writeBytes(ITechHider.writeVarInt(entry));
|
||||||
@ -123,6 +117,6 @@ class TechHider_12 {
|
|||||||
byteArray.write(0, data);
|
byteArray.write(0, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).start(ITechHider.threadMultiplier * 4);
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,8 +22,13 @@ package de.steamwar.fightsystem.fight;
|
|||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.bukkit.BukkitWorld;
|
import com.sk89q.worldedit.bukkit.BukkitWorld;
|
||||||
|
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
|
||||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||||
|
import com.sk89q.worldedit.extent.clipboard.io.BuiltInClipboardFormat;
|
||||||
|
import com.sk89q.worldedit.extent.clipboard.io.ClipboardWriter;
|
||||||
|
import com.sk89q.worldedit.function.operation.ForwardExtentCopy;
|
||||||
import com.sk89q.worldedit.function.operation.Operations;
|
import com.sk89q.worldedit.function.operation.Operations;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.math.transform.AffineTransform;
|
import com.sk89q.worldedit.math.transform.AffineTransform;
|
||||||
@ -33,19 +38,23 @@ import com.sk89q.worldedit.world.World;
|
|||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
import de.steamwar.fightsystem.Config;
|
import de.steamwar.fightsystem.Config;
|
||||||
|
import de.steamwar.fightsystem.utils.Region;
|
||||||
import de.steamwar.sql.NoClipboardException;
|
import de.steamwar.sql.NoClipboardException;
|
||||||
import de.steamwar.sql.Schematic;
|
import de.steamwar.sql.Schematic;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.DyeColor;
|
import org.bukkit.DyeColor;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.scoreboard.Team;
|
import org.bukkit.scoreboard.Team;
|
||||||
|
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
class FightTeam_14 {
|
public class FightTeam_14 {
|
||||||
private FightTeam_14(){}
|
private FightTeam_14(){}
|
||||||
|
|
||||||
private static final Set<BaseBlock> WOOL_SET = Collections.singleton(Objects.requireNonNull(BlockTypes.PINK_WOOL).getDefaultState().toBaseBlock());
|
private static final Set<BaseBlock> WOOL_SET = Collections.singleton(Objects.requireNonNull(BlockTypes.PINK_WOOL).getDefaultState().toBaseBlock());
|
||||||
@ -61,10 +70,8 @@ class FightTeam_14 {
|
|||||||
team.setOption(Team.Option.NAME_TAG_VISIBILITY, Team.OptionStatus.FOR_OWN_TEAM);
|
team.setOption(Team.Option.NAME_TAG_VISIBILITY, Team.OptionStatus.FOR_OWN_TEAM);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void replaceTeamColor(EditSession e, DyeColor c, int cornerX, int cornerY, int cornerZ){
|
static void replaceTeamColor(EditSession e, DyeColor c, Region r){
|
||||||
BlockVector3 corner3 = BlockVector3.at(cornerX, cornerY, cornerZ);
|
CuboidRegion region = new CuboidRegion(BlockVector3.at(r.getMinX(), r.getMinY(), r.getMinZ()), BlockVector3.at(r.getMaxX(), r.getMaxY(), r.getMaxZ()));
|
||||||
BlockVector3 schemsize3 = BlockVector3.at(Config.SchemsizeX, Config.SchemsizeY, Config.SchemsizeZ);
|
|
||||||
CuboidRegion region = new CuboidRegion(corner3, corner3.add(schemsize3));
|
|
||||||
try {
|
try {
|
||||||
e.replaceBlocks(region, WOOL_SET, Objects.requireNonNull(BlockTypes.get(c.name().toLowerCase() + "_wool")).getDefaultState().toBaseBlock());
|
e.replaceBlocks(region, WOOL_SET, Objects.requireNonNull(BlockTypes.get(c.name().toLowerCase() + "_wool")).getDefaultState().toBaseBlock());
|
||||||
e.replaceBlocks(region, CARPET_SET, Objects.requireNonNull(BlockTypes.get(c.name().toLowerCase() + "_carpet")).getDefaultState().toBaseBlock());
|
e.replaceBlocks(region, CARPET_SET, Objects.requireNonNull(BlockTypes.get(c.name().toLowerCase() + "_carpet")).getDefaultState().toBaseBlock());
|
||||||
@ -79,9 +86,8 @@ class FightTeam_14 {
|
|||||||
e.flushSession();
|
e.flushSession();
|
||||||
}
|
}
|
||||||
|
|
||||||
static EditSession pasteSchematic(Schematic schematic, int pX, int pY, int pZ, boolean rotate) throws Schematic.WrongVersionException, IOException, NoClipboardException {
|
static EditSession pasteSchematic(Clipboard clipboard, Region region, boolean rotate) throws Schematic.WrongVersionException, IOException, NoClipboardException {
|
||||||
BlockVector3 paste = BlockVector3.at(pX, pY, pZ);
|
BlockVector3 paste = BlockVector3.at(region.centerX(), region.getMinY(), region.centerZ());
|
||||||
Clipboard clipboard = schematic.load();
|
|
||||||
|
|
||||||
World w = new BukkitWorld(Bukkit.getWorlds().get(0));
|
World w = new BukkitWorld(Bukkit.getWorlds().get(0));
|
||||||
BlockVector3 dimensions = clipboard.getDimensions();
|
BlockVector3 dimensions = clipboard.getDimensions();
|
||||||
@ -95,7 +101,7 @@ class FightTeam_14 {
|
|||||||
v = paste.subtract(dimensions.getX()/2, 0, dimensions.getZ()/2).subtract(offset);
|
v = paste.subtract(dimensions.getX()/2, 0, dimensions.getZ()/2).subtract(offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Config.AlignWater){
|
if(Config.WaterDepth != 0){
|
||||||
BlockVector3 it = clipboard.getMinimumPoint();
|
BlockVector3 it = clipboard.getMinimumPoint();
|
||||||
int depth = 0;
|
int depth = 0;
|
||||||
while(!clipboard.getBlock(it).getBlockType().getMaterial().isAir()){
|
while(!clipboard.getBlock(it).getBlockType().getMaterial().isAir()){
|
||||||
@ -112,4 +118,35 @@ class FightTeam_14 {
|
|||||||
e.flushSession();
|
e.flushSession();
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean checkPistonMoving(Block block){
|
||||||
|
return block.getType() == Material.MOVING_PISTON;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void saveSchem(Schematic schem, Region region) {
|
||||||
|
World w = new BukkitWorld(Bukkit.getWorlds().get(0));
|
||||||
|
BlockVector3 min = BlockVector3.at(region.getMinX(), region.getMinY(), region.getMinZ());
|
||||||
|
CuboidRegion cuboidRegion = new CuboidRegion(w, min, BlockVector3.at(region.getMaxX(), region.getMaxY(), region.getMaxZ()));
|
||||||
|
BlockArrayClipboard clipboard = new BlockArrayClipboard(cuboidRegion);
|
||||||
|
EditSession editSession = WorldEdit.getInstance().getEditSessionFactory().getEditSession(w, -1);
|
||||||
|
|
||||||
|
ForwardExtentCopy forwardExtentCopy = new ForwardExtentCopy(editSession, cuboidRegion, clipboard, min);
|
||||||
|
forwardExtentCopy.setCopyingEntities(false);
|
||||||
|
try{
|
||||||
|
Operations.complete(forwardExtentCopy);
|
||||||
|
}catch(WorldEditException e){
|
||||||
|
throw new IllegalStateException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||||
|
try {
|
||||||
|
ClipboardWriter writer = BuiltInClipboardFormat.SPONGE_SCHEMATIC.getWriter(outputStream);
|
||||||
|
writer.write(clipboard);
|
||||||
|
writer.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new IllegalStateException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
schem.saveFromBytes(outputStream.toByteArray(), true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
48
FightSystem_14/src/de/steamwar/fightsystem/fight/FightWorld_14.java
Normale Datei
48
FightSystem_14/src/de/steamwar/fightsystem/fight/FightWorld_14.java
Normale Datei
@ -0,0 +1,48 @@
|
|||||||
|
/*
|
||||||
|
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.fight;
|
||||||
|
|
||||||
|
import de.steamwar.core.events.ChunkListener;
|
||||||
|
import net.minecraft.server.v1_14_R1.Chunk;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.craftbukkit.v1_14_R1.CraftWorld;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
class FightWorld_14 {
|
||||||
|
private FightWorld_14(){}
|
||||||
|
|
||||||
|
static void resetChunk(World world, World backup, int x, int z){
|
||||||
|
net.minecraft.server.v1_14_R1.World w = ((CraftWorld) world).getHandle();
|
||||||
|
Chunk chunk = w.getChunkAt(x, z);
|
||||||
|
Chunk backupChunk = ((CraftWorld) backup).getHandle().getChunkAt(x, z);
|
||||||
|
|
||||||
|
System.arraycopy(backupChunk.getSections(), 0, chunk.getSections(), 0, chunk.getSections().length);
|
||||||
|
w.tileEntityListTick.removeAll(chunk.tileEntities.values());
|
||||||
|
w.tileEntityList.removeAll(chunk.tileEntities.values());
|
||||||
|
chunk.tileEntities.clear();
|
||||||
|
chunk.tileEntities.putAll(backupChunk.tileEntities);
|
||||||
|
chunk.heightMap.clear();
|
||||||
|
chunk.heightMap.putAll(backupChunk.heightMap);
|
||||||
|
for(Player p : Bukkit.getOnlinePlayers()){
|
||||||
|
ChunkListener.sendChunk(p, x, z);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -26,14 +26,14 @@ import java.util.HashSet;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
class PersonalKitCreator_14 {
|
public class PersonalKitCreator_14 {
|
||||||
private PersonalKitCreator_14(){}
|
private PersonalKitCreator_14(){}
|
||||||
|
|
||||||
static boolean hasAttributeModifier(ItemStack stack){
|
public static boolean hasAttributeModifier(ItemStack stack){
|
||||||
return stack.hasItemMeta() && Objects.requireNonNull(stack.getItemMeta()).hasAttributeModifiers();
|
return stack.hasItemMeta() && Objects.requireNonNull(stack.getItemMeta()).hasAttributeModifiers();
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean hasItems(ItemStack stack){
|
public static boolean hasItems(ItemStack stack){
|
||||||
Set<String> keys = new HashSet<>(CraftItemStack.asNMSCopy(stack).getTag().getKeys());
|
Set<String> keys = new HashSet<>(CraftItemStack.asNMSCopy(stack).getTag().getKeys());
|
||||||
keys.remove("Enchantments");
|
keys.remove("Enchantments");
|
||||||
keys.remove("Damage");
|
keys.remove("Damage");
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.steamwar.fightsystem.utils;
|
package de.steamwar.fightsystem.listener;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
@ -20,7 +20,6 @@
|
|||||||
package de.steamwar.fightsystem.utils;
|
package de.steamwar.fightsystem.utils;
|
||||||
|
|
||||||
import com.comphenix.protocol.PacketType;
|
import com.comphenix.protocol.PacketType;
|
||||||
import com.comphenix.protocol.ProtocolLibrary;
|
|
||||||
import com.comphenix.protocol.events.PacketAdapter;
|
import com.comphenix.protocol.events.PacketAdapter;
|
||||||
import com.comphenix.protocol.events.PacketContainer;
|
import com.comphenix.protocol.events.PacketContainer;
|
||||||
import com.comphenix.protocol.events.PacketEvent;
|
import com.comphenix.protocol.events.PacketEvent;
|
||||||
@ -31,21 +30,49 @@ import de.steamwar.fightsystem.Config;
|
|||||||
import de.steamwar.fightsystem.IFightSystem;
|
import de.steamwar.fightsystem.IFightSystem;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import io.netty.buffer.UnpooledByteBufAllocator;
|
import io.netty.buffer.UnpooledByteBufAllocator;
|
||||||
|
import net.minecraft.server.v1_14_R1.*;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.nio.ByteBuffer;
|
||||||
|
import java.nio.LongBuffer;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import static de.steamwar.fightsystem.utils.ITechHider.bypass;
|
import static de.steamwar.fightsystem.utils.ITechHider.bypass;
|
||||||
|
|
||||||
public class TechHider_14 {
|
public class TechHider_14 {
|
||||||
private TechHider_14(){}
|
private TechHider_14(){}
|
||||||
|
|
||||||
static void start(){
|
static Set<Integer> getHiddenBlockIds() {
|
||||||
chunkHider();
|
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));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Config.HiddenBlocks.contains("water")){
|
||||||
|
Fluid water = FluidTypes.WATER.a(false);
|
||||||
|
for(IBlockData data : Block.REGISTRY_ID){
|
||||||
|
if(data.p() == water){
|
||||||
|
hiddenBlockIds.add(Block.getCombinedId(data));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return hiddenBlockIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void chunkHider(){
|
static int getObfuscateWith() {
|
||||||
ProtocolLibrary.getProtocolManager().getAsynchronousManager().registerAsyncHandler(new PacketAdapter(IFightSystem.getPlugin(), PacketType.Play.Server.MAP_CHUNK) {
|
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
|
@Override
|
||||||
public void onPacketSending(PacketEvent e) {
|
public void onPacketSending(PacketEvent e) {
|
||||||
PacketContainer packet = e.getPacket();
|
PacketContainer packet = e.getPacket();
|
||||||
@ -57,16 +84,9 @@ public class TechHider_14 {
|
|||||||
if(bypass(p, chunkX, chunkZ))
|
if(bypass(p, chunkX, chunkZ))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
PacketContainer cached = ITechHider.packetCache.get(packet);
|
packet = packet.shallowClone();
|
||||||
if(cached != null){
|
e.setPacket(packet);
|
||||||
e.setPacket(cached);
|
StructureModifier<List<NbtBase<?>>> list = packet.getListNbtModifier();
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
cached = packet.deepClone();
|
|
||||||
ITechHider.packetCache.put(packet, cached);
|
|
||||||
e.setPacket(cached);
|
|
||||||
StructureModifier<List<NbtBase<?>>> list = cached.getListNbtModifier();
|
|
||||||
List<NbtBase<?>> nmsTags = list.read(0);
|
List<NbtBase<?>> nmsTags = list.read(0);
|
||||||
boolean changed = false;
|
boolean changed = false;
|
||||||
for(int i = nmsTags.size() - 1; i >= 0; i--){
|
for(int i = nmsTags.size() - 1; i >= 0; i--){
|
||||||
@ -83,30 +103,25 @@ public class TechHider_14 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
changed = false;
|
changed = false;
|
||||||
StructureModifier<byte[]> byteArray = cached.getByteArrays();
|
StructureModifier<byte[]> byteArray = packet.getByteArrays();
|
||||||
int primaryBitMask = ints.read(2);
|
int primaryBitMask = ints.read(2);
|
||||||
int numChunkSections = 0;
|
byte[] data = byteArray.read(0);
|
||||||
while(primaryBitMask != 0){
|
|
||||||
numChunkSections += primaryBitMask & 1;
|
|
||||||
primaryBitMask >>= 1;
|
|
||||||
}
|
|
||||||
byte [] data = byteArray.read(0);
|
|
||||||
ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.directBuffer(data.length + 100);
|
ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.directBuffer(data.length + 100);
|
||||||
int i = 0;
|
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
|
buffer.writeBytes(data, i, 2); // Block count
|
||||||
i += 2;
|
i += 2;
|
||||||
byte bitsPerBlock = data[i++];
|
byte bitsPerBlock = data[i++];
|
||||||
buffer.writeByte(bitsPerBlock);
|
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 paletteLength = ITechHider.readVarInt(data, i);
|
||||||
int paletteLengthLength = ITechHider.readVarIntLength(data, i);
|
int paletteLengthLength = ITechHider.readVarIntLength(data, i);
|
||||||
buffer.writeBytes(data, i, paletteLengthLength);
|
buffer.writeBytes(data, i, paletteLengthLength);
|
||||||
@ -115,30 +130,48 @@ public class TechHider_14 {
|
|||||||
int blockId = ITechHider.readVarInt(data, i);
|
int blockId = ITechHider.readVarInt(data, i);
|
||||||
int actPaletteLength = ITechHider.readVarIntLength(data, i);
|
int actPaletteLength = ITechHider.readVarIntLength(data, i);
|
||||||
|
|
||||||
if(Config.HiddenBlocks.contains(blockId)){
|
if(hiddenBlockIds.contains(blockId)){
|
||||||
byte[] a = ITechHider.writeVarInt(Config.ObfuscateWith);
|
buffer.writeBytes(ITechHider.writeVarInt(obfuscateWith));
|
||||||
buffer.writeBytes(a);
|
|
||||||
changed = true;
|
changed = true;
|
||||||
}else{
|
}else{
|
||||||
buffer.writeBytes(data, i, actPaletteLength);
|
buffer.writeBytes(data, i, actPaletteLength);
|
||||||
}
|
}
|
||||||
i += actPaletteLength;
|
i += actPaletteLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//We modify only the chunk palette for performance reasons
|
||||||
int dataArrayLength = ITechHider.readVarInt(data, i);
|
int dataArrayLength = ITechHider.readVarInt(data, i);
|
||||||
int dataArrayLengthLength = ITechHider.readVarIntLength(data, i);
|
int dataArrayLengthLength = ITechHider.readVarIntLength(data, i);
|
||||||
buffer.writeBytes(data, i, dataArrayLength * 8 + dataArrayLengthLength);
|
buffer.writeBytes(data, i, dataArrayLength * 8 + dataArrayLengthLength);
|
||||||
i += dataArrayLengthLength;
|
i += dataArrayLengthLength;
|
||||||
i += dataArrayLength * 8;
|
i += dataArrayLength * 8;
|
||||||
}else{
|
}else{
|
||||||
|
//Full Chunk/no palette, so the chunk has to be crawled through
|
||||||
int dataArrayLength = ITechHider.readVarInt(data, i);
|
int dataArrayLength = ITechHider.readVarInt(data, i);
|
||||||
int dataArrayLengthLength = ITechHider.readVarIntLength(data, i);
|
int dataArrayLengthLength = ITechHider.readVarIntLength(data, i);
|
||||||
buffer.writeBytes(data, i, dataArrayLength*8 + dataArrayLengthLength);
|
buffer.writeBytes(data, i, dataArrayLengthLength);
|
||||||
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;
|
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){
|
if(changed){
|
||||||
data = new byte[buffer.readableBytes()];
|
data = new byte[buffer.readableBytes()];
|
||||||
@ -146,6 +179,48 @@ public class TechHider_14 {
|
|||||||
byteArray.write(0, data);
|
byteArray.write(0, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).start(ITechHider.threadMultiplier * 4);
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
48
FightSystem_15/src/de/steamwar/fightsystem/fight/FightWorld_15.java
Normale Datei
48
FightSystem_15/src/de/steamwar/fightsystem/fight/FightWorld_15.java
Normale Datei
@ -0,0 +1,48 @@
|
|||||||
|
/*
|
||||||
|
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.fight;
|
||||||
|
|
||||||
|
import de.steamwar.core.events.ChunkListener;
|
||||||
|
import net.minecraft.server.v1_15_R1.Chunk;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.craftbukkit.v1_15_R1.CraftWorld;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
class FightWorld_15 {
|
||||||
|
private FightWorld_15(){}
|
||||||
|
|
||||||
|
static void resetChunk(World world, World backup, int x, int z){
|
||||||
|
net.minecraft.server.v1_15_R1.World w = ((CraftWorld) world).getHandle();
|
||||||
|
Chunk chunk = w.getChunkAt(x, z);
|
||||||
|
Chunk backupChunk = ((CraftWorld) backup).getHandle().getChunkAt(x, z);
|
||||||
|
|
||||||
|
System.arraycopy(backupChunk.getSections(), 0, chunk.getSections(), 0, chunk.getSections().length);
|
||||||
|
w.tileEntityListTick.removeAll(chunk.tileEntities.values());
|
||||||
|
w.tileEntityList.removeAll(chunk.tileEntities.values());
|
||||||
|
chunk.tileEntities.clear();
|
||||||
|
chunk.tileEntities.putAll(backupChunk.tileEntities);
|
||||||
|
chunk.heightMap.clear();
|
||||||
|
chunk.heightMap.putAll(backupChunk.heightMap);
|
||||||
|
for(Player p : Bukkit.getOnlinePlayers()){
|
||||||
|
ChunkListener.sendChunk(p, x, z);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -25,9 +25,9 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
class PersonalKitCreator_15 {
|
public class PersonalKitCreator_15 {
|
||||||
|
|
||||||
static boolean hasItems(ItemStack stack){
|
public static boolean hasItems(ItemStack stack){
|
||||||
Set<String> keys = new HashSet<>(CraftItemStack.asNMSCopy(stack).getTag().getKeys());
|
Set<String> keys = new HashSet<>(CraftItemStack.asNMSCopy(stack).getTag().getKeys());
|
||||||
keys.remove("Enchantments");
|
keys.remove("Enchantments");
|
||||||
keys.remove("Damage");
|
keys.remove("Damage");
|
||||||
|
@ -19,187 +19,36 @@
|
|||||||
|
|
||||||
package de.steamwar.fightsystem.utils;
|
package de.steamwar.fightsystem.utils;
|
||||||
|
|
||||||
import com.comphenix.protocol.PacketType;
|
|
||||||
import com.comphenix.protocol.ProtocolLibrary;
|
|
||||||
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.Config;
|
||||||
import de.steamwar.fightsystem.IFightSystem;
|
import net.minecraft.server.v1_15_R1.*;
|
||||||
import io.netty.buffer.ByteBuf;
|
|
||||||
import io.netty.buffer.UnpooledByteBufAllocator;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
import java.util.HashSet;
|
||||||
import java.nio.LongBuffer;
|
import java.util.Set;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import static de.steamwar.fightsystem.utils.ITechHider.bypass;
|
class TechHider_15 {
|
||||||
|
|
||||||
public class TechHider_15 {
|
|
||||||
private TechHider_15(){}
|
private TechHider_15(){}
|
||||||
|
|
||||||
static void start(){
|
static Set<Integer> getHiddenBlockIds() {
|
||||||
chunkHider();
|
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));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Config.HiddenBlocks.contains("water")){
|
||||||
|
Fluid water = FluidTypes.WATER.a(false);
|
||||||
|
for(IBlockData data : Block.REGISTRY_ID){
|
||||||
|
if(data.getFluid() == water){
|
||||||
|
hiddenBlockIds.add(Block.getCombinedId(data));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return hiddenBlockIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void chunkHider(){
|
static int getObfuscateWith() {
|
||||||
/*
|
return Block.getCombinedId(IRegistry.BLOCK.get(new MinecraftKey(Config.ObfuscateWith)).getBlockData());
|
||||||
* Bevor editing this function read and understand: https://wiki.vg/Chunk_Format
|
|
||||||
* */
|
|
||||||
ProtocolLibrary.getProtocolManager().getAsynchronousManager().registerAsyncHandler(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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}).start(ITechHider.threadMultiplier * 4);
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,32 +19,36 @@
|
|||||||
|
|
||||||
package de.steamwar.fightsystem.fight;
|
package de.steamwar.fightsystem.fight;
|
||||||
|
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.*;
|
||||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
|
||||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||||
import com.sk89q.worldedit.bukkit.BukkitWorld;
|
import com.sk89q.worldedit.bukkit.BukkitWorld;
|
||||||
|
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
|
||||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||||
|
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat;
|
||||||
|
import com.sk89q.worldedit.extent.clipboard.io.ClipboardWriter;
|
||||||
|
import com.sk89q.worldedit.function.operation.ForwardExtentCopy;
|
||||||
import com.sk89q.worldedit.function.operation.Operations;
|
import com.sk89q.worldedit.function.operation.Operations;
|
||||||
import com.sk89q.worldedit.math.transform.AffineTransform;
|
import com.sk89q.worldedit.math.transform.AffineTransform;
|
||||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||||
import com.sk89q.worldedit.session.ClipboardHolder;
|
import com.sk89q.worldedit.session.ClipboardHolder;
|
||||||
import com.sk89q.worldedit.world.World;
|
import com.sk89q.worldedit.world.World;
|
||||||
import de.steamwar.fightsystem.Config;
|
import de.steamwar.fightsystem.Config;
|
||||||
|
import de.steamwar.fightsystem.utils.Region;
|
||||||
import de.steamwar.sql.NoClipboardException;
|
import de.steamwar.sql.NoClipboardException;
|
||||||
import de.steamwar.sql.Schematic;
|
import de.steamwar.sql.Schematic;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.DyeColor;
|
import org.bukkit.DyeColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.scoreboard.Team;
|
import org.bukkit.scoreboard.Team;
|
||||||
|
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
class FightTeam_8 {
|
public class FightTeam_8 {
|
||||||
private FightTeam_8(){}
|
private FightTeam_8(){}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
@ -72,9 +76,8 @@ class FightTeam_8 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
static void replaceTeamColor(EditSession e, DyeColor c, int cornerX, int cornerY, int cornerZ){
|
static void replaceTeamColor(EditSession e, DyeColor c, Region r){
|
||||||
Vector corner = new Vector(cornerX, cornerY, cornerZ);
|
CuboidRegion region = new CuboidRegion(new Vector(r.getMinX(), r.getMinY(), r.getMinZ()), new Vector(r.getMaxX(), r.getMaxY(), r.getMaxZ()));
|
||||||
CuboidRegion region = new CuboidRegion(corner, corner.add(Config.SchemsizeX, Config.SchemsizeY, Config.SchemsizeZ));
|
|
||||||
try {
|
try {
|
||||||
e.replaceBlocks(region, WOOL_SET, new BaseBlock(WOOL.getId(), c.getWoolData()));
|
e.replaceBlocks(region, WOOL_SET, new BaseBlock(WOOL.getId(), c.getWoolData()));
|
||||||
e.replaceBlocks(region, CLAY_SET, new BaseBlock(CLAY.getId(), c.getWoolData()));
|
e.replaceBlocks(region, CLAY_SET, new BaseBlock(CLAY.getId(), c.getWoolData()));
|
||||||
@ -87,12 +90,10 @@ class FightTeam_8 {
|
|||||||
e.flushQueue();
|
e.flushQueue();
|
||||||
}
|
}
|
||||||
|
|
||||||
static EditSession pasteSchematic(Schematic schematic, int pasteX, int pasteY, int pasteZ, boolean rotate) throws Schematic.WrongVersionException, IOException, NoClipboardException {
|
static EditSession pasteSchematic(Clipboard clipboard, Region paste, boolean rotate) throws Schematic.WrongVersionException, IOException, NoClipboardException {
|
||||||
Clipboard clipboard = schematic.load();
|
|
||||||
|
|
||||||
World w = new BukkitWorld(Bukkit.getWorlds().get(0));
|
World w = new BukkitWorld(Bukkit.getWorlds().get(0));
|
||||||
Vector dimensions = clipboard.getDimensions();
|
Vector dimensions = clipboard.getDimensions();
|
||||||
Vector v = new Vector(pasteX, pasteY, pasteZ);
|
Vector v = new Vector(paste.centerX(), paste.getMinY(), paste.centerZ());
|
||||||
Vector offset = clipboard.getMinimumPoint().subtract(clipboard.getOrigin());
|
Vector offset = clipboard.getMinimumPoint().subtract(clipboard.getOrigin());
|
||||||
AffineTransform aT = new AffineTransform();
|
AffineTransform aT = new AffineTransform();
|
||||||
if(rotate){
|
if(rotate){
|
||||||
@ -102,7 +103,7 @@ class FightTeam_8 {
|
|||||||
v = v.subtract(dimensions.getX()/2 - dimensions.getX()%2, 0, dimensions.getZ()/2 - dimensions.getZ()%2).subtract(offset);
|
v = v.subtract(dimensions.getX()/2 - dimensions.getX()%2, 0, dimensions.getZ()/2 - dimensions.getZ()%2).subtract(offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Config.AlignWater){
|
if(Config.WaterDepth != 0){
|
||||||
Vector it = clipboard.getMinimumPoint();
|
Vector it = clipboard.getMinimumPoint();
|
||||||
int depth = 0;
|
int depth = 0;
|
||||||
while(!clipboard.getBlock(it).isAir()){
|
while(!clipboard.getBlock(it).isAir()){
|
||||||
@ -119,4 +120,35 @@ class FightTeam_8 {
|
|||||||
e.flushQueue();
|
e.flushQueue();
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean checkPistonMoving(Block block){
|
||||||
|
return block.getType() == Material.PISTON_MOVING_PIECE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void saveSchem(Schematic schem, Region region) {
|
||||||
|
World w = new BukkitWorld(Bukkit.getWorlds().get(0));
|
||||||
|
Vector min = new Vector(region.getMinX(), region.getMinY(), region.getMinZ());
|
||||||
|
CuboidRegion cuboidRegion = new CuboidRegion(w, min, new Vector(region.getMaxX(), region.getMaxY(), region.getMaxZ()));
|
||||||
|
BlockArrayClipboard clipboard = new BlockArrayClipboard(cuboidRegion);
|
||||||
|
EditSession editSession = WorldEdit.getInstance().getEditSessionFactory().getEditSession(w, -1);
|
||||||
|
|
||||||
|
ForwardExtentCopy forwardExtentCopy = new ForwardExtentCopy(editSession, cuboidRegion, clipboard, min);
|
||||||
|
forwardExtentCopy.setCopyingEntities(false);
|
||||||
|
try{
|
||||||
|
Operations.complete(forwardExtentCopy);
|
||||||
|
}catch(WorldEditException e){
|
||||||
|
throw new IllegalStateException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||||
|
try {
|
||||||
|
ClipboardWriter writer = ClipboardFormat.SCHEMATIC.getWriter(outputStream);
|
||||||
|
writer.write(clipboard, w.getWorldData());
|
||||||
|
writer.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new IllegalStateException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
schem.saveFromBytes(outputStream.toByteArray(), false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
47
FightSystem_8/src/de/steamwar/fightsystem/fight/FightWorld_8.java
Normale Datei
47
FightSystem_8/src/de/steamwar/fightsystem/fight/FightWorld_8.java
Normale Datei
@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
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.fight;
|
||||||
|
|
||||||
|
import de.steamwar.core.events.ChunkListener;
|
||||||
|
import net.minecraft.server.v1_8_R3.Chunk;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
class FightWorld_8 {
|
||||||
|
private FightWorld_8(){}
|
||||||
|
|
||||||
|
static void resetChunk(World world, World backup, int x, int z){
|
||||||
|
net.minecraft.server.v1_8_R3.World w = ((CraftWorld) world).getHandle();
|
||||||
|
Chunk chunk = w.getChunkAt(x, z);
|
||||||
|
Chunk backupChunk = ((CraftWorld) backup).getHandle().getChunkAt(x, z);
|
||||||
|
|
||||||
|
System.arraycopy(backupChunk.getSections(), 0, chunk.getSections(), 0, chunk.getSections().length);
|
||||||
|
System.arraycopy(backupChunk.heightMap, 0, chunk.heightMap, 0, chunk.heightMap.length);
|
||||||
|
w.h.removeAll(chunk.tileEntities.values());
|
||||||
|
w.tileEntityList.removeAll(chunk.tileEntities.values());
|
||||||
|
chunk.tileEntities.clear();
|
||||||
|
chunk.tileEntities.putAll(backupChunk.tileEntities);
|
||||||
|
for(Player p : Bukkit.getOnlinePlayers()){
|
||||||
|
ChunkListener.sendChunk(p, x, z);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -25,9 +25,9 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
class PersonalKitCreator_8 {
|
public class PersonalKitCreator_8 {
|
||||||
|
|
||||||
static boolean hasItems(ItemStack stack){
|
public static boolean hasItems(ItemStack stack){
|
||||||
Set<String> keys = new HashSet<>(CraftItemStack.asNMSCopy(stack).getTag().c());
|
Set<String> keys = new HashSet<>(CraftItemStack.asNMSCopy(stack).getTag().c());
|
||||||
keys.remove("Enchantments");
|
keys.remove("Enchantments");
|
||||||
keys.remove("Damage");
|
keys.remove("Damage");
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.steamwar.fightsystem.utils;
|
package de.steamwar.fightsystem.listener;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
42
FightSystem_8/src/de/steamwar/fightsystem/utils/TechHider_8.java
Normale Datei
42
FightSystem_8/src/de/steamwar/fightsystem/utils/TechHider_8.java
Normale Datei
@ -0,0 +1,42 @@
|
|||||||
|
/*
|
||||||
|
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.utils;
|
||||||
|
|
||||||
|
import de.steamwar.fightsystem.Config;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
class TechHider_8 {
|
||||||
|
private TechHider_8(){}
|
||||||
|
|
||||||
|
static Set<Integer> getHiddenBlockIds() {
|
||||||
|
Set<Integer> hiddenBlockIds = new HashSet<>();
|
||||||
|
for(String tag : Config.HiddenBlocks){
|
||||||
|
hiddenBlockIds.add(Material.matchMaterial(tag).getId() << 4);
|
||||||
|
}
|
||||||
|
return hiddenBlockIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int getObfuscateWith() {
|
||||||
|
return Material.matchMaterial(Config.ObfuscateWith).getId() << 4;
|
||||||
|
}
|
||||||
|
}
|
47
FightSystem_9/src/de/steamwar/fightsystem/fight/FightWorld_9.java
Normale Datei
47
FightSystem_9/src/de/steamwar/fightsystem/fight/FightWorld_9.java
Normale Datei
@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
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.fight;
|
||||||
|
|
||||||
|
import de.steamwar.core.events.ChunkListener;
|
||||||
|
import net.minecraft.server.v1_9_R2.Chunk;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.craftbukkit.v1_9_R2.CraftWorld;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
class FightWorld_9 {
|
||||||
|
private FightWorld_9(){}
|
||||||
|
|
||||||
|
static void resetChunk(World world, World backup, int x, int z){
|
||||||
|
net.minecraft.server.v1_9_R2.World w = ((CraftWorld) world).getHandle();
|
||||||
|
Chunk chunk = w.getChunkAt(x, z);
|
||||||
|
Chunk backupChunk = ((CraftWorld) backup).getHandle().getChunkAt(x, z);
|
||||||
|
|
||||||
|
System.arraycopy(backupChunk.getSections(), 0, chunk.getSections(), 0, chunk.getSections().length);
|
||||||
|
System.arraycopy(backupChunk.heightMap, 0, chunk.heightMap, 0, chunk.heightMap.length);
|
||||||
|
w.tileEntityListTick.removeAll(chunk.tileEntities.values());
|
||||||
|
w.tileEntityList.removeAll(chunk.tileEntities.values());
|
||||||
|
chunk.tileEntities.clear();
|
||||||
|
chunk.tileEntities.putAll(backupChunk.tileEntities);
|
||||||
|
for(Player p : Bukkit.getOnlinePlayers()){
|
||||||
|
ChunkListener.sendChunk(p, x, z);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -25,9 +25,9 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
class PersonalKitCreator_9 {
|
public class PersonalKitCreator_9 {
|
||||||
|
|
||||||
static boolean hasItems(ItemStack stack){
|
public static boolean hasItems(ItemStack stack){
|
||||||
Set<String> keys = new HashSet<>(CraftItemStack.asNMSCopy(stack).getTag().c());
|
Set<String> keys = new HashSet<>(CraftItemStack.asNMSCopy(stack).getTag().c());
|
||||||
keys.remove("Enchantments");
|
keys.remove("Enchantments");
|
||||||
keys.remove("Damage");
|
keys.remove("Damage");
|
||||||
|
49
FightSystem_API/src/de/steamwar/fightsystem/ArenaMode.java
Normale Datei
49
FightSystem_API/src/de/steamwar/fightsystem/ArenaMode.java
Normale Datei
@ -0,0 +1,49 @@
|
|||||||
|
/*
|
||||||
|
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;
|
||||||
|
|
||||||
|
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> AntiEvent = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(EVENT)));
|
||||||
|
public static final Set<ArenaMode> AntiPrepare = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(PREPARE)));
|
||||||
|
public static final Set<ArenaMode> VariableTeams = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(RANKED, EVENT)));
|
||||||
|
public static final Set<ArenaMode> RankedEvent = Collections.unmodifiableSet(EnumSet.of(RANKED, EVENT));
|
||||||
|
public static final Set<ArenaMode> Restartable = Collections.unmodifiableSet(EnumSet.of(NORMAL, RANKED));
|
||||||
|
}
|
@ -19,13 +19,14 @@
|
|||||||
|
|
||||||
package de.steamwar.fightsystem;
|
package de.steamwar.fightsystem;
|
||||||
|
|
||||||
|
import de.steamwar.fightsystem.utils.Region;
|
||||||
|
import de.steamwar.fightsystem.winconditions.Winconditions;
|
||||||
import de.steamwar.sql.Event;
|
import de.steamwar.sql.Event;
|
||||||
import de.steamwar.sql.EventFight;
|
import de.steamwar.sql.EventFight;
|
||||||
import de.steamwar.sql.Team;
|
import de.steamwar.sql.Team;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
@ -33,6 +34,7 @@ import org.bukkit.util.Vector;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class Config {
|
public class Config {
|
||||||
|
|
||||||
@ -49,36 +51,22 @@ public class Config {
|
|||||||
public static final List<Integer> EnterStages;
|
public static final List<Integer> EnterStages;
|
||||||
|
|
||||||
//arena parameter
|
//arena parameter
|
||||||
public static final int SchemsizeX;
|
public static final Region BluePasteRegion;
|
||||||
public static final int SchemsizeY;
|
public static final Region RedPasteRegion;
|
||||||
public static final int SchemsizeZ;
|
public static final Region BlueExtendRegion;
|
||||||
public static final int TeamBlueCornerX;
|
public static final Region RedExtendRegion;
|
||||||
public static final int TeamBlueCornerY;
|
public static final Region ArenaRegion;
|
||||||
public static final int TeamBlueCornerZ;
|
|
||||||
private static final int TeamBluePasteX;
|
|
||||||
private static final int TeamBluePasteZ;
|
|
||||||
public static final Location TeamBlueSpawn;
|
public static final Location TeamBlueSpawn;
|
||||||
public static final int TeamRedCornerX;
|
|
||||||
public static final int TeamRedCornerY;
|
|
||||||
public static final int TeamRedCornerZ;
|
|
||||||
private static final int TeamRedPasteX;
|
|
||||||
private static final int TeamRedPasteZ;
|
|
||||||
public static final Location TeamRedSpawn;
|
public static final Location TeamRedSpawn;
|
||||||
private static final int TeamBluetoReddistanceX;
|
|
||||||
private static final int TeamBluetoReddistanceY;
|
|
||||||
public static final int TeamBluetoReddistanceZ;
|
|
||||||
public static final Location SpecSpawn;
|
public static final Location SpecSpawn;
|
||||||
public static final int underArenaBorder;
|
|
||||||
public static final int BorderFromSchematic;
|
private static final int BlueToRedX;
|
||||||
public static final int upperArenaBorder;
|
private static final int BlueToRedY;
|
||||||
public static final boolean AlignWater;
|
public static final int BlueToRedZ;
|
||||||
|
|
||||||
|
public static final int PreperationArea;
|
||||||
public static final int WaterDepth;
|
public static final int WaterDepth;
|
||||||
private static final int Schem2BorderX;
|
|
||||||
private static final int Schem2BorderZ;
|
|
||||||
public static final int ArenaMinX;
|
|
||||||
public static final int ArenaMinZ;
|
|
||||||
public static final int ArenaMaxX;
|
|
||||||
public static final int ArenaMaxZ;
|
|
||||||
public static final boolean GroundWalkable;
|
public static final boolean GroundWalkable;
|
||||||
|
|
||||||
//schematic parameter
|
//schematic parameter
|
||||||
@ -86,10 +74,10 @@ public class Config {
|
|||||||
public static final boolean OnlyPublicSchematics;
|
public static final boolean OnlyPublicSchematics;
|
||||||
public static final boolean IgnorePublicOnly;
|
public static final boolean IgnorePublicOnly;
|
||||||
public static final de.steamwar.sql.SchematicType SchematicType;
|
public static final de.steamwar.sql.SchematicType SchematicType;
|
||||||
public static final boolean TeamRedRotate;
|
public static final boolean RedRotate;
|
||||||
public static final boolean TeamBlueRotate;
|
public static final boolean BlueRotate;
|
||||||
public static final boolean ReplaceObsidian;
|
public static final boolean PasteAligned;
|
||||||
public static final boolean ReplaceBedrock;
|
public static final boolean ReplaceObsidianBedrock;
|
||||||
public static final boolean ReplaceWithBlockupdates;
|
public static final boolean ReplaceWithBlockupdates;
|
||||||
|
|
||||||
//team parameter
|
//team parameter
|
||||||
@ -104,16 +92,7 @@ public class Config {
|
|||||||
public static final boolean Ranked;
|
public static final boolean Ranked;
|
||||||
|
|
||||||
//Active win conditions
|
//Active win conditions
|
||||||
public static final boolean Timeout;
|
public static final Set<Winconditions> ActiveWinconditions;
|
||||||
public static final boolean HeartRatioTimeout;
|
|
||||||
public static final boolean AllDead;
|
|
||||||
public static final boolean CaptainDead;
|
|
||||||
public static final boolean PercentSystem;
|
|
||||||
public static final boolean RelativePercent;
|
|
||||||
public static final boolean Points;
|
|
||||||
public static final boolean TechKO;
|
|
||||||
public static final boolean WaterTechKO;
|
|
||||||
public static final boolean PumpkinTechKO;
|
|
||||||
|
|
||||||
//win condition parameters
|
//win condition parameters
|
||||||
public static final int TimeoutTime;
|
public static final int TimeoutTime;
|
||||||
@ -129,11 +108,9 @@ public class Config {
|
|||||||
|
|
||||||
//tech hider parameter
|
//tech hider parameter
|
||||||
public static final boolean TechhiderActive;
|
public static final boolean TechhiderActive;
|
||||||
public static final Set<Integer> HiddenBlocks;
|
public static final Set<String> HiddenBlocks;
|
||||||
public static final Set<String> HiddenBlockTags;
|
|
||||||
public static final Set<String> HiddenBlockEntities;
|
public static final Set<String> HiddenBlockEntities;
|
||||||
public static final int ObfuscateWith;
|
public static final String ObfuscateWith;
|
||||||
public static final String ObfuscateWithTag;
|
|
||||||
|
|
||||||
//event parameter
|
//event parameter
|
||||||
private static final int EventKampfID;
|
private static final int EventKampfID;
|
||||||
@ -145,6 +122,9 @@ public class Config {
|
|||||||
|
|
||||||
//check parameter
|
//check parameter
|
||||||
public static final int CheckSchemID;
|
public static final int CheckSchemID;
|
||||||
|
public static final int PrepareSchemID;
|
||||||
|
|
||||||
|
public static final ArenaMode mode;
|
||||||
|
|
||||||
//live recorder parameter
|
//live recorder parameter
|
||||||
public static final String spectateIP = "127.0.0.1";
|
public static final String spectateIP = "127.0.0.1";
|
||||||
@ -154,14 +134,14 @@ public class Config {
|
|||||||
if(!new File(IFightSystem.getPlugin().getDataFolder(), System.getProperty("config", "config.yml")).exists()) {
|
if(!new File(IFightSystem.getPlugin().getDataFolder(), System.getProperty("config", "config.yml")).exists()) {
|
||||||
IFightSystem.getPlugin().saveDefaultConfig();
|
IFightSystem.getPlugin().saveDefaultConfig();
|
||||||
Bukkit.getLogger().log(Level.SEVERE, "Arenaconfig fehlt!");
|
Bukkit.getLogger().log(Level.SEVERE, "Arenaconfig fehlt!");
|
||||||
IFightSystem.shutdown(null);
|
Bukkit.shutdown();
|
||||||
}
|
}
|
||||||
FileConfiguration config = IFightSystem.getPlugin().getConfig();
|
FileConfiguration config = IFightSystem.getPlugin().getConfig();
|
||||||
|
|
||||||
File worldConfigFile = new File(Bukkit.getWorlds().get(0).getWorldFolder(), config.getString("Arenaconfig", "config.yml"));
|
File worldConfigFile = new File(Bukkit.getWorlds().get(0).getWorldFolder(), config.getString("Arenaconfig", "config.yml"));
|
||||||
if(!worldConfigFile.exists()) {
|
if(!worldConfigFile.exists()) {
|
||||||
Bukkit.getLogger().log(Level.SEVERE, "Weltconfig fehlt!");
|
Bukkit.getLogger().log(Level.SEVERE, "Weltconfig fehlt!");
|
||||||
IFightSystem.shutdown(null);
|
Bukkit.shutdown();
|
||||||
}
|
}
|
||||||
FileConfiguration worldconfig = YamlConfiguration.loadConfiguration(worldConfigFile);
|
FileConfiguration worldconfig = YamlConfiguration.loadConfiguration(worldConfigFile);
|
||||||
|
|
||||||
@ -171,47 +151,38 @@ public class Config {
|
|||||||
PreFightDuration = config.getInt("Times.PreFightDuration");
|
PreFightDuration = config.getInt("Times.PreFightDuration");
|
||||||
SpectatorDuration = config.getInt("Times.SpectatorDuration");
|
SpectatorDuration = config.getInt("Times.SpectatorDuration");
|
||||||
|
|
||||||
int schemsizeX = worldconfig.getInt("Arena.Schemsize.x");
|
int underBorder = worldconfig.getInt("UnderBorder");
|
||||||
int schemsizeY = worldconfig.getInt("Arena.Schemsize.y");
|
int blueCornerX = worldconfig.getInt("BlueCorner.x");
|
||||||
int schemsizeZ = worldconfig.getInt("Arena.Schemsize.z");
|
int blueCornerY = worldconfig.getInt("BlueCorner.y");
|
||||||
int teamBlueCornerX = worldconfig.getInt("Arena.TeamBlueCorner.x");
|
int blueCornerZ = worldconfig.getInt("BlueCorner.z");
|
||||||
int teamBlueCornerY = worldconfig.getInt("Arena.TeamBlueCorner.y");
|
BlueToRedX = worldconfig.getInt("BlueToRed.x");
|
||||||
int teamBlueCornerZ = worldconfig.getInt("Arena.TeamBlueCorner.z");
|
BlueToRedY = worldconfig.getInt("BlueToRed.y");
|
||||||
TeamBluetoReddistanceX = worldconfig.getInt("Arena.TeamBluetoReddistance.x");
|
BlueToRedZ = worldconfig.getInt("BlueToRed.z");
|
||||||
TeamBluetoReddistanceY = worldconfig.getInt("Arena.TeamBluetoReddistance.y");
|
double teamBlueSpawnOffsetX = worldconfig.getDouble("SpawnOffset.x");
|
||||||
TeamBluetoReddistanceZ = worldconfig.getInt("Arena.TeamBluetoReddistance.z");
|
double teamBlueSpawnOffsetY = worldconfig.getDouble("SpawnOffset.y");
|
||||||
Schem2BorderX = worldconfig.getInt("Arena.Schem2Border.x");
|
double teamBlueSpawnOffsetZ = worldconfig.getDouble("SpawnOffset.z");
|
||||||
Schem2BorderZ = worldconfig.getInt("Arena.Schem2Border.z");
|
|
||||||
underArenaBorder = worldconfig.getInt("Arena.underArenaBorder");
|
WaterDepth = config.getInt("Arena.WaterDepth");
|
||||||
BorderFromSchematic = worldconfig.getInt("Arena.BorderFromSchematic");
|
int schemsizeX = config.getInt("Arena.Schemsize.x");
|
||||||
AlignWater = worldconfig.getBoolean("Arena.AlignWater");
|
int schemsizeY = config.getInt("Arena.Schemsize.y");
|
||||||
WaterDepth = worldconfig.getInt("Arena.WaterDepth");
|
int schemsizeZ = config.getInt("Arena.Schemsize.z");
|
||||||
|
int schem2BorderX = config.getInt("Arena.Schem2Border.x");
|
||||||
|
int schem2BorderZ = config.getInt("Arena.Schem2Border.z");
|
||||||
|
PreperationArea = config.getInt("Arena.BorderFromSchematic");
|
||||||
GroundWalkable = config.getBoolean("Arena.GroundWalkable");
|
GroundWalkable = config.getBoolean("Arena.GroundWalkable");
|
||||||
double teamBlueSpawnOffsetX = worldconfig.getDouble("Arena.SpawnOffset.x");
|
|
||||||
double teamBlueSpawnOffsetY = worldconfig.getDouble("Arena.SpawnOffset.y");
|
|
||||||
double teamBlueSpawnOffsetZ = worldconfig.getDouble("Arena.SpawnOffset.z");
|
|
||||||
|
|
||||||
RanksEnabled = config.getBoolean("Schematic.RanksEnabled");
|
RanksEnabled = config.getBoolean("Schematic.RanksEnabled");
|
||||||
SchematicType = de.steamwar.sql.SchematicType.fromDB(config.getString("Schematic.SchematicType"));
|
SchematicType = de.steamwar.sql.SchematicType.fromDB(config.getString("Schematic.SchematicType"));
|
||||||
IgnorePublicOnly = config.getBoolean("Schematic.IgnorePublicOnly");
|
IgnorePublicOnly = config.getBoolean("Schematic.IgnorePublicOnly");
|
||||||
boolean rotate = config.getBoolean("Schematic.Rotate");
|
boolean rotate = config.getBoolean("Schematic.Rotate");
|
||||||
ReplaceObsidian = config.getBoolean("Schematic.ReplaceObsidian");
|
PasteAligned = config.getBoolean("Schematic.PasteAligned");
|
||||||
ReplaceBedrock = config.getBoolean("Schematic.ReplaceBedrock");
|
ReplaceObsidianBedrock = config.getBoolean("Schematic.ReplaceObsidianBedrock");
|
||||||
ReplaceWithBlockupdates = config.getBoolean("Schematic.ReplaceWithBlockupdates");
|
ReplaceWithBlockupdates = config.getBoolean("Schematic.ReplaceWithBlockupdates");
|
||||||
|
|
||||||
GameName = config.getString("Output.GameName");
|
GameName = config.getString("Output.GameName");
|
||||||
TeamChatDetection = config.getString("Output.TeamChatDetection");
|
TeamChatDetection = config.getString("Output.TeamChatDetection");
|
||||||
|
|
||||||
Timeout = config.getBoolean("WinConditions.Timeout");
|
ActiveWinconditions = Collections.unmodifiableSet(config.getStringList("WinConditions").stream().map(Winconditions::valueOf).collect(Collectors.toSet()));
|
||||||
HeartRatioTimeout = config.getBoolean("WinConditions.HeartRatioTimeout");
|
|
||||||
AllDead = config.getBoolean("WinConditions.AllDead");
|
|
||||||
CaptainDead = config.getBoolean("WinConditions.CaptainDead");
|
|
||||||
PercentSystem = config.getBoolean("WinConditions.PercentSystem");
|
|
||||||
RelativePercent = config.getBoolean("WinConditions.RelativePercent");
|
|
||||||
Points = config.getBoolean("WinConditions.Points");
|
|
||||||
TechKO = config.getBoolean("WinConditions.TechKO");
|
|
||||||
WaterTechKO = config.getBoolean("WinConditions.WaterTechKO");
|
|
||||||
PumpkinTechKO = config.getBoolean("WinConditions.PumpkinTechKO");
|
|
||||||
|
|
||||||
TimeoutTime = config.getInt("WinConditionParams.TimeoutTime");
|
TimeoutTime = config.getInt("WinConditionParams.TimeoutTime");
|
||||||
PercentWin = config.getDouble("WinConditionParams.PercentWin");
|
PercentWin = config.getDouble("WinConditionParams.PercentWin");
|
||||||
@ -223,113 +194,90 @@ public class Config {
|
|||||||
MemberDefault = config.getString("Kits.MemberDefault");
|
MemberDefault = config.getString("Kits.MemberDefault");
|
||||||
LeaderDefault = config.getString("Kits.LeaderDefault");
|
LeaderDefault = config.getString("Kits.LeaderDefault");
|
||||||
PersonalKits = config.getBoolean("Kits.PersonalKits");
|
PersonalKits = config.getBoolean("Kits.PersonalKits");
|
||||||
ForbiddenItems = config.getStringList("Kits.ForbiddenItems");
|
ForbiddenItems = Collections.unmodifiableList(config.getStringList("Kits.ForbiddenItems"));
|
||||||
|
|
||||||
ConfigurationSection techhiderConfig = config.getConfigurationSection("Techhider.HiddenBlocks");
|
HiddenBlocks = Collections.unmodifiableSet(new HashSet<>(config.getStringList("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);
|
|
||||||
HiddenBlockEntities = Collections.unmodifiableSet(new HashSet<>(config.getStringList("Techhider.HiddenBlockEntities")));
|
HiddenBlockEntities = Collections.unmodifiableSet(new HashSet<>(config.getStringList("Techhider.HiddenBlockEntities")));
|
||||||
ObfuscateWith = config.getInt("Techhider.ObfuscateWith");
|
ObfuscateWith = config.getString("Techhider.ObfuscateWith");
|
||||||
ObfuscateWithTag = config.getString("Techhider.ObfuscateWithTag");
|
|
||||||
TechhiderActive = config.getBoolean("Techhider.Active");
|
TechhiderActive = config.getBoolean("Techhider.Active");
|
||||||
|
|
||||||
if(schemsizeX < 0){
|
if(schemsizeX < 0){
|
||||||
SchemsizeX = -schemsizeX;
|
schemsizeX = -schemsizeX;
|
||||||
TeamBlueCornerX = teamBlueCornerX - SchemsizeX;
|
blueCornerX = blueCornerX - schemsizeX;
|
||||||
}else{
|
|
||||||
SchemsizeX = schemsizeX;
|
|
||||||
TeamBlueCornerX = teamBlueCornerX;
|
|
||||||
}
|
}
|
||||||
if(schemsizeY < 0){
|
if(schemsizeY < 0){
|
||||||
SchemsizeY = -schemsizeY;
|
schemsizeY = -schemsizeY;
|
||||||
TeamBlueCornerY = teamBlueCornerY - SchemsizeY;
|
blueCornerY = blueCornerY - schemsizeY;
|
||||||
}else{
|
|
||||||
SchemsizeY = schemsizeY;
|
|
||||||
TeamBlueCornerY = teamBlueCornerY;
|
|
||||||
}
|
}
|
||||||
if(schemsizeZ < 0){
|
if(schemsizeZ < 0){
|
||||||
SchemsizeZ = -schemsizeZ;
|
schemsizeZ = -schemsizeZ;
|
||||||
TeamBlueCornerZ = teamBlueCornerZ - SchemsizeZ;
|
blueCornerZ = blueCornerZ - schemsizeZ;
|
||||||
}else{
|
|
||||||
SchemsizeZ = schemsizeZ;
|
|
||||||
TeamBlueCornerZ = teamBlueCornerZ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
upperArenaBorder = TeamBlueCornerY + SchemsizeY + BorderFromSchematic;
|
|
||||||
|
|
||||||
TeamRedCornerX = TeamBluetoReddistanceX + TeamBlueCornerX;
|
int teamRedCornerX = BlueToRedX + blueCornerX;
|
||||||
TeamRedCornerY = TeamBluetoReddistanceY + TeamBlueCornerY;
|
int teamRedCornerY = BlueToRedY + blueCornerY;
|
||||||
TeamRedCornerZ = TeamBluetoReddistanceZ + TeamBlueCornerZ;
|
int teamRedCornerZ = BlueToRedZ + blueCornerZ;
|
||||||
|
|
||||||
TeamBluePasteX = TeamBlueCornerX + SchemsizeX / 2;
|
int teamBluePasteX = blueCornerX + schemsizeX / 2;
|
||||||
TeamBluePasteZ = TeamBlueCornerZ + SchemsizeZ / 2;
|
int teamBluePasteZ = blueCornerZ + schemsizeZ / 2;
|
||||||
TeamRedPasteX = TeamBluePasteX + TeamBluetoReddistanceX;
|
int teamRedPasteX = teamBluePasteX + BlueToRedX;
|
||||||
TeamRedPasteZ = TeamBluePasteZ + TeamBluetoReddistanceZ;
|
int teamRedPasteZ = teamBluePasteZ + BlueToRedZ;
|
||||||
|
|
||||||
World world = Bukkit.getWorlds().get(0);
|
World world = Bukkit.getWorlds().get(0);
|
||||||
|
|
||||||
TeamBlueSpawn = new Location(world,
|
TeamBlueSpawn = new Location(world,
|
||||||
TeamBluePasteX + 0.5 + teamBlueSpawnOffsetX,
|
teamBluePasteX + 0.5 + teamBlueSpawnOffsetX,
|
||||||
TeamBlueCornerY + 0.5 + teamBlueSpawnOffsetY,
|
blueCornerY + 0.5 + teamBlueSpawnOffsetY,
|
||||||
TeamBluePasteZ + 0.5 + teamBlueSpawnOffsetZ);
|
teamBluePasteZ + 0.5 + teamBlueSpawnOffsetZ);
|
||||||
|
|
||||||
TeamRedSpawn = new Location(world,
|
TeamRedSpawn = new Location(world,
|
||||||
TeamRedPasteX + 0.5 - teamBlueSpawnOffsetX,
|
teamRedPasteX + 0.5 - teamBlueSpawnOffsetX,
|
||||||
TeamRedCornerY + 0.5 + teamBlueSpawnOffsetY,
|
teamRedCornerY + 0.5 + teamBlueSpawnOffsetY,
|
||||||
TeamRedPasteZ + 0.5 - teamBlueSpawnOffsetZ);
|
teamRedPasteZ + 0.5 - teamBlueSpawnOffsetZ);
|
||||||
|
|
||||||
|
SpecSpawn = new Location(world,
|
||||||
|
teamBluePasteX + BlueToRedX /2.0,
|
||||||
|
blueCornerY + BlueToRedY /2.0 + schemsizeY/2.0,
|
||||||
|
teamBluePasteZ + BlueToRedZ /2.0);
|
||||||
|
|
||||||
Vector v1 = TeamBlueSpawn.toVector().subtract(TeamRedSpawn.toVector());
|
Vector v1 = TeamBlueSpawn.toVector().subtract(TeamRedSpawn.toVector());
|
||||||
double pitch = Math.toDegrees(v1.angle(v1.clone().setY(0)));
|
double pitch = Math.toDegrees(v1.angle(v1.clone().setY(0)));
|
||||||
double yaw = Math.toDegrees(v1.clone().setY(0).angle(new Vector(0, 0, 1)));
|
double yaw = Math.toDegrees(v1.clone().setY(0).angle(new Vector(0, 0, 1)));
|
||||||
double pitchInverted = pitch * -1;
|
|
||||||
double yawInverted = yaw + 180;
|
|
||||||
|
|
||||||
TeamBlueSpawn.setYaw((float) yawInverted);
|
TeamBlueSpawn.setYaw((float) yaw + 180);
|
||||||
TeamBlueSpawn.setPitch((float) pitch);
|
TeamBlueSpawn.setPitch((float) pitch);
|
||||||
|
|
||||||
TeamRedSpawn.setYaw((float) yaw);
|
TeamRedSpawn.setYaw((float) yaw);
|
||||||
TeamRedSpawn.setPitch((float) pitchInverted);
|
TeamRedSpawn.setPitch((float) pitch * -1);
|
||||||
|
|
||||||
SpecSpawn = new Location(world,
|
|
||||||
TeamBluePasteX + TeamBluetoReddistanceX/2.0,
|
|
||||||
TeamBlueCornerY + TeamBluetoReddistanceY/2.0 + SchemsizeY/2.0,
|
|
||||||
TeamBluePasteZ + TeamBluetoReddistanceZ/2.0);
|
|
||||||
|
|
||||||
boolean teamRedRotate;
|
boolean teamRedRotate;
|
||||||
boolean teamBlueRotate;
|
boolean teamBlueRotate;
|
||||||
if(TeamBluetoReddistanceX > 0){
|
int arenaMinX;
|
||||||
ArenaMinX = TeamBlueCornerX - Schem2BorderX;
|
int arenaMaxX;
|
||||||
ArenaMaxX = TeamRedCornerX + SchemsizeX + Schem2BorderX;
|
int arenaMinZ;
|
||||||
|
int arenaMaxZ;
|
||||||
|
if(BlueToRedX > 0){
|
||||||
|
arenaMinX = blueCornerX - schem2BorderX;
|
||||||
|
arenaMaxX = teamRedCornerX + schemsizeX + schem2BorderX;
|
||||||
teamRedRotate = true;
|
teamRedRotate = true;
|
||||||
teamBlueRotate = false;
|
teamBlueRotate = false;
|
||||||
}else{
|
}else{
|
||||||
ArenaMinX = TeamRedCornerX - Schem2BorderX;
|
arenaMinX = teamRedCornerX - schem2BorderX;
|
||||||
ArenaMaxX = TeamBlueCornerX + SchemsizeX + Schem2BorderX;
|
arenaMaxX = blueCornerX + schemsizeX + schem2BorderX;
|
||||||
teamRedRotate = false;
|
teamRedRotate = false;
|
||||||
teamBlueRotate = true;
|
teamBlueRotate = true;
|
||||||
}
|
}
|
||||||
if(TeamBluetoReddistanceZ > 0){
|
if(BlueToRedZ > 0){
|
||||||
ArenaMinZ = TeamBlueCornerZ - Schem2BorderZ;
|
arenaMinZ = blueCornerZ - schem2BorderZ;
|
||||||
ArenaMaxZ = TeamRedCornerZ + SchemsizeZ + Schem2BorderZ;
|
arenaMaxZ = teamRedCornerZ + schemsizeZ + schem2BorderZ;
|
||||||
teamRedRotate = true;
|
teamRedRotate = true;
|
||||||
teamBlueRotate = false;
|
teamBlueRotate = false;
|
||||||
}else{
|
}else{
|
||||||
ArenaMinZ = TeamRedCornerZ - Schem2BorderZ;
|
arenaMinZ = teamRedCornerZ - schem2BorderZ;
|
||||||
ArenaMaxZ = TeamBlueCornerZ + SchemsizeZ + Schem2BorderZ;
|
arenaMaxZ = blueCornerZ + schemsizeZ + schem2BorderZ;
|
||||||
if(TeamBluetoReddistanceZ != 0){
|
if(BlueToRedZ != 0){
|
||||||
teamRedRotate = false;
|
teamRedRotate = false;
|
||||||
teamBlueRotate = true;
|
teamBlueRotate = true;
|
||||||
}
|
}
|
||||||
@ -338,15 +286,24 @@ public class Config {
|
|||||||
teamRedRotate = false;
|
teamRedRotate = false;
|
||||||
teamBlueRotate = false;
|
teamBlueRotate = false;
|
||||||
}
|
}
|
||||||
TeamRedRotate = teamRedRotate;
|
RedRotate = teamRedRotate;
|
||||||
TeamBlueRotate = teamBlueRotate;
|
BlueRotate = teamBlueRotate;
|
||||||
|
|
||||||
|
int arenaYSize = blueCornerY - underBorder + schemsizeY + PreperationArea;
|
||||||
|
|
||||||
|
RedPasteRegion = new Region(teamRedCornerX, teamRedCornerY, teamRedCornerZ, schemsizeX, schemsizeY, schemsizeZ);
|
||||||
|
BluePasteRegion = new Region(blueCornerX, blueCornerY, blueCornerZ, schemsizeX, schemsizeY, schemsizeZ);
|
||||||
|
|
||||||
|
RedExtendRegion = new Region(teamRedCornerX, underBorder, teamRedCornerZ, schemsizeX, arenaYSize, schemsizeZ, PreperationArea, PreperationArea);
|
||||||
|
BlueExtendRegion = new Region(blueCornerX, underBorder, blueCornerZ, schemsizeX, arenaYSize, schemsizeZ, PreperationArea, PreperationArea);
|
||||||
|
ArenaRegion = new Region(arenaMinX, underBorder, arenaMinZ, arenaMaxX - arenaMinX, arenaYSize, arenaMaxZ - arenaMinZ);
|
||||||
|
|
||||||
EventKampfID = Integer.parseInt(System.getProperty("fightID", "0"));
|
EventKampfID = Integer.parseInt(System.getProperty("fightID", "0"));
|
||||||
if(event()){
|
if(EventKampfID >= 1){
|
||||||
EventFight eventFight = EventFight.get(EventKampfID);
|
EventFight eventFight = EventFight.get(EventKampfID);
|
||||||
if(eventFight == null){
|
if(eventFight == null){
|
||||||
Bukkit.getLogger().log(Level.SEVERE, "Failed to load EventFight");
|
Bukkit.getLogger().log(Level.SEVERE, "Failed to load EventFight");
|
||||||
IFightSystem.shutdown(null);
|
Bukkit.shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
assert eventFight != null;
|
assert eventFight != null;
|
||||||
@ -355,7 +312,7 @@ public class Config {
|
|||||||
|
|
||||||
if(team1 == null || team2 == null){
|
if(team1 == null || team2 == null){
|
||||||
Bukkit.getLogger().log(Level.SEVERE, "Failed to load Team");
|
Bukkit.getLogger().log(Level.SEVERE, "Failed to load Team");
|
||||||
IFightSystem.shutdown(null);
|
Bukkit.shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
assert team1 != null;
|
assert team1 != null;
|
||||||
@ -405,19 +362,28 @@ public class Config {
|
|||||||
RedLeader = null;
|
RedLeader = null;
|
||||||
|
|
||||||
CheckSchemID = Integer.parseInt(System.getProperty("checkSchemID", "0"));
|
CheckSchemID = Integer.parseInt(System.getProperty("checkSchemID", "0"));
|
||||||
|
PrepareSchemID = Integer.parseInt(System.getProperty("prepareSchemID", "0"));
|
||||||
Ranked = Boolean.parseBoolean(System.getProperty("ranked", "false"));
|
Ranked = Boolean.parseBoolean(System.getProperty("ranked", "false"));
|
||||||
|
|
||||||
|
if(Ranked){
|
||||||
|
mode = ArenaMode.RANKED;
|
||||||
|
}else if(CheckSchemID != 0){
|
||||||
|
mode = ArenaMode.CHECK;
|
||||||
|
}else if(PrepareSchemID != 0){
|
||||||
|
mode = ArenaMode.PREPARE;
|
||||||
|
}else if(EventKampfID >= 1){
|
||||||
|
mode = ArenaMode.EVENT;
|
||||||
|
}else if(EventKampfID == -1){
|
||||||
|
mode = ArenaMode.TEST;
|
||||||
|
}else{
|
||||||
|
mode = ArenaMode.NORMAL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean event(){
|
|
||||||
return EventKampfID >= 1;
|
|
||||||
}
|
|
||||||
public static boolean test(){
|
public static boolean test(){
|
||||||
return EventKampfID == -1;
|
return ArenaMode.Test.contains(mode);
|
||||||
}
|
|
||||||
public static boolean check(){
|
|
||||||
return CheckSchemID != 0;
|
|
||||||
}
|
}
|
||||||
public static boolean recording(){
|
public static boolean recording(){
|
||||||
return event();
|
return mode == ArenaMode.EVENT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
package de.steamwar.fightsystem;
|
package de.steamwar.fightsystem;
|
||||||
|
|
||||||
import de.steamwar.sql.EventFight;
|
import de.steamwar.sql.EventFight;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
@ -50,21 +49,4 @@ public class IFightSystem {
|
|||||||
public static Player getEventLeiter(){
|
public static Player getEventLeiter(){
|
||||||
return eventLeiter;
|
return eventLeiter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void shutdown(String reason){
|
|
||||||
if(reason != null)
|
|
||||||
Bukkit.broadcastMessage(reason);
|
|
||||||
//Staggered kick to prevent lobby overloading
|
|
||||||
kickNext();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void kickNext(){
|
|
||||||
if(Bukkit.getOnlinePlayers().isEmpty()){
|
|
||||||
Bukkit.shutdown();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Bukkit.getOnlinePlayers().iterator().next().kickPlayer(null);
|
|
||||||
Bukkit.getScheduler().runTaskLater(plugin, IFightSystem::kickNext, 10);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -19,92 +19,34 @@
|
|||||||
|
|
||||||
package de.steamwar.fightsystem.utils;
|
package de.steamwar.fightsystem.utils;
|
||||||
|
|
||||||
import com.comphenix.protocol.events.PacketContainer;
|
|
||||||
import com.google.common.primitives.Bytes;
|
import com.google.common.primitives.Bytes;
|
||||||
import de.steamwar.fightsystem.Config;
|
import de.steamwar.fightsystem.Config;
|
||||||
import de.steamwar.fightsystem.IFightSystem;
|
import de.steamwar.fightsystem.IFightSystem;
|
||||||
import de.steamwar.fightsystem.fight.IFight;
|
import de.steamwar.fightsystem.fight.IFight;
|
||||||
import de.steamwar.fightsystem.fight.IFightTeam;
|
import de.steamwar.fightsystem.fight.IFightTeam;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class ITechHider {
|
public class ITechHider {
|
||||||
private ITechHider (){}
|
private ITechHider (){}
|
||||||
|
|
||||||
static final Map<PacketContainer, PacketContainer> packetCache = new HashMap<>();
|
|
||||||
static final Material obfuscateMaterial;
|
|
||||||
static final int threadMultiplier;
|
|
||||||
static final int arenaMinX;
|
|
||||||
static final int arenaMaxX;
|
|
||||||
static final int arenaMinZ;
|
|
||||||
static final int arenaMaxZ;
|
|
||||||
|
|
||||||
private static final int blueMinX;
|
|
||||||
private static final int blueMaxX;
|
|
||||||
private static final int blueMinZ;
|
|
||||||
private static final int blueMaxZ;
|
|
||||||
private static final int redMinX;
|
|
||||||
private static final int redMaxX;
|
|
||||||
private static final int redMinZ;
|
|
||||||
private static final int redMaxZ;
|
|
||||||
|
|
||||||
static{
|
|
||||||
int areaExtension = Config.EnterStages.isEmpty() ? Config.BorderFromSchematic : 0;
|
|
||||||
blueMinX = ITechHider.posToChunk(Config.TeamBlueCornerX - areaExtension);
|
|
||||||
blueMaxX = ITechHider.posToChunk(Config.TeamBlueCornerX + Config.SchemsizeX + areaExtension) + 1;
|
|
||||||
blueMinZ = ITechHider.posToChunk(Config.TeamBlueCornerZ - areaExtension);
|
|
||||||
blueMaxZ = ITechHider.posToChunk(Config.TeamBlueCornerZ + Config.SchemsizeZ + areaExtension) + 1;
|
|
||||||
redMinX = ITechHider.posToChunk(Config.TeamRedCornerX - areaExtension);
|
|
||||||
redMaxX = ITechHider.posToChunk(Config.TeamRedCornerX + Config.SchemsizeX + areaExtension) + 1;
|
|
||||||
redMinZ = ITechHider.posToChunk(Config.TeamRedCornerZ - areaExtension);
|
|
||||||
redMaxZ = ITechHider.posToChunk(Config.TeamRedCornerZ + Config.SchemsizeZ + areaExtension) + 1;
|
|
||||||
arenaMinX = ITechHider.posToChunk(Config.ArenaMinX);
|
|
||||||
arenaMaxX = ITechHider.posToChunk(Config.ArenaMaxX) + 1;
|
|
||||||
arenaMinZ = ITechHider.posToChunk(Config.ArenaMinZ);
|
|
||||||
arenaMaxZ = ITechHider.posToChunk(Config.ArenaMaxZ) + 1;
|
|
||||||
|
|
||||||
obfuscateMaterial = Material.getMaterial(Config.ObfuscateWithTag);
|
|
||||||
Bukkit.getScheduler().runTaskTimer(IFightSystem.getPlugin(), packetCache::clear, 1, 1);
|
|
||||||
|
|
||||||
if(Config.event())
|
|
||||||
threadMultiplier = 4;
|
|
||||||
else
|
|
||||||
threadMultiplier = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static boolean bypass(Player p, int chunkX, int chunkZ){
|
static boolean bypass(Player p, int chunkX, int chunkZ){
|
||||||
if(p == IFightSystem.getEventLeiter())
|
if(p == IFightSystem.getEventLeiter())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
IFightTeam ft = IFight.getPlayerTeam(p);
|
IFightTeam ft = IFight.getPlayerTeam(p);
|
||||||
if(ft == null){
|
if(ft == null){
|
||||||
//Außerhalb der Arena
|
return Config.ArenaRegion.chunkOutside(chunkX, chunkZ);
|
||||||
return arenaMinX > chunkX ||
|
|
||||||
chunkX > arenaMaxX ||
|
|
||||||
arenaMinZ > chunkZ ||
|
|
||||||
chunkZ > arenaMaxZ;
|
|
||||||
}else if(ft.isBlue()){
|
}else if(ft.isBlue()){
|
||||||
return ft.canPlayerEntern(p) ||
|
return ft.canPlayerEntern(p) || Config.RedExtendRegion.chunkOutside(chunkX, chunkZ);
|
||||||
redMinX > chunkX ||
|
|
||||||
chunkX > redMaxX ||
|
|
||||||
redMinZ > chunkZ ||
|
|
||||||
chunkZ > redMaxZ;
|
|
||||||
}else{
|
}else{
|
||||||
return ft.canPlayerEntern(p) ||
|
return ft.canPlayerEntern(p) || Config.BlueExtendRegion.chunkOutside(chunkX, chunkZ);
|
||||||
blueMinX > chunkX ||
|
|
||||||
chunkX > blueMaxX ||
|
|
||||||
blueMinZ > chunkZ ||
|
|
||||||
chunkZ > blueMaxZ;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int posToChunk(int c){
|
public static int posToChunk(int c){
|
||||||
int chunk = c / 16;
|
int chunk = c / 16;
|
||||||
if(c<0)
|
if(c<0)
|
||||||
chunk--;
|
chunk--;
|
||||||
|
153
FightSystem_API/src/de/steamwar/fightsystem/utils/Region.java
Normale Datei
153
FightSystem_API/src/de/steamwar/fightsystem/utils/Region.java
Normale Datei
@ -0,0 +1,153 @@
|
|||||||
|
/*
|
||||||
|
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.utils;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
|
||||||
|
import java.util.function.ObjIntConsumer;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
public class Region {
|
||||||
|
|
||||||
|
private final int minX;
|
||||||
|
private final int minY;
|
||||||
|
private final int minZ;
|
||||||
|
private final int maxX;
|
||||||
|
private final int maxY;
|
||||||
|
private final int maxZ;
|
||||||
|
|
||||||
|
public Region(int minX, int minY, int minZ, int sizeX, int sizeY, int sizeZ, int extendX, int extendZ) {
|
||||||
|
this(minX - extendX, minY, minZ - extendZ,
|
||||||
|
sizeX + extendX * 2, sizeY, sizeZ + extendZ * 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Region(int minX, int minY, int minZ, int sizeX, int sizeY, int sizeZ) {
|
||||||
|
Bukkit.getLogger().log(Level.INFO, minX + " " + minY + " " + minZ + " " + sizeX + " " + sizeY + " " + sizeZ);
|
||||||
|
this.minX = minX;
|
||||||
|
this.minY = minY;
|
||||||
|
this.minZ = minZ;
|
||||||
|
this.maxX = minX + sizeX;
|
||||||
|
this.maxY = minY + sizeY;
|
||||||
|
this.maxZ = minZ + sizeZ;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMinX() {
|
||||||
|
return minX;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMinY() {
|
||||||
|
return minY;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMinZ() {
|
||||||
|
return minZ;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMaxX() {
|
||||||
|
return maxX;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMaxY() {
|
||||||
|
return maxY;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMaxZ() {
|
||||||
|
return maxZ;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double posToChunk(int pos){
|
||||||
|
return pos / 16.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getMinChunkX(){
|
||||||
|
return (int) Math.floor(posToChunk(minX));
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getMaxChunkX(){
|
||||||
|
return (int) Math.ceil(posToChunk(maxX));
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getMinChunkZ(){
|
||||||
|
return (int) Math.floor(posToChunk(minZ));
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getMaxChunkZ(){
|
||||||
|
return (int) Math.ceil(posToChunk(maxZ));
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean chunkOutside(int cX, int cZ) {
|
||||||
|
return getMinChunkX() > cX || cX > getMaxChunkX() ||
|
||||||
|
getMinChunkZ() > cZ || cZ > getMaxChunkZ();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void forEachChunk(ObjIntConsumer<Integer> executor) {
|
||||||
|
for(int x = getMinChunkX(); x <= getMaxChunkX(); x++)
|
||||||
|
for(int z = getMinChunkZ(); z <= getMaxChunkZ(); z++)
|
||||||
|
executor.accept(x, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void forEach(TriConsumer<Integer, Integer, Integer> executor) {
|
||||||
|
for(int x = minX; x < maxX; x++) {
|
||||||
|
for(int y = minY; y < maxY; y++) {
|
||||||
|
for (int z = minZ; z <= maxZ; z++) {
|
||||||
|
executor.accept(x, y, z);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int volume(){
|
||||||
|
return (maxX - minX) * (maxY - minY) * (maxZ - minZ);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int centerX() {
|
||||||
|
return (maxX - minX) / 2 + minX;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int centerZ() {
|
||||||
|
return (maxZ - minZ) / 2 + minZ;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean in2dRegion(Location location){
|
||||||
|
return minX <= location.getX() && location.getX() < maxX && minZ <= location.getZ() && location.getZ() <= maxZ;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean inRegion(Location location){
|
||||||
|
return in2dRegion(location) && minY < location.getY() && location.getY() < maxY;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean playerInRegion(Location location){
|
||||||
|
return in2dRegion(location) && minY <= location.getY() && location.getY() + 1.8 < maxY;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean in2dRegion(Block block){
|
||||||
|
return minX <= block.getX() && block.getX() < maxX && minZ <= block.getZ() && block.getZ() <= maxZ;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean inRegion(Block block){
|
||||||
|
return in2dRegion(block) && minY <= block.getY() && block.getY() < maxY;
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface TriConsumer<T, V, U>{
|
||||||
|
void accept(T x, V y, U z);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,34 @@
|
|||||||
|
/*
|
||||||
|
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;
|
||||||
|
|
||||||
|
public enum Winconditions {
|
||||||
|
TIMEOUT,
|
||||||
|
HEART_RATIO_TIMEOUT,
|
||||||
|
PERCENT_TIMEOUT,
|
||||||
|
ALL_DEAD,
|
||||||
|
CAPTAIN_DEAD,
|
||||||
|
PERCENT_SYSTEM,
|
||||||
|
RELATIVE_PERCENT,
|
||||||
|
POINTS,
|
||||||
|
TIME_TECH_KO,
|
||||||
|
WATER_TECH_KO,
|
||||||
|
PUMPKIN_TECH_KO
|
||||||
|
}
|
@ -1,90 +1,150 @@
|
|||||||
Times:
|
Times:
|
||||||
NoPlayersOnlineDuration: 300
|
# Time in seconds the server stops after starting if nobody joins
|
||||||
|
NoPlayersOnlineDuration: 30
|
||||||
|
# Time in seconds the team leaders have to choose their schematic
|
||||||
PreSchemPasteDuration: 120
|
PreSchemPasteDuration: 120
|
||||||
|
# Time in seconds for preparing
|
||||||
SetupDuration: 300
|
SetupDuration: 300
|
||||||
|
# Time in seconds the final countdown is long
|
||||||
PreFightDuration: 30
|
PreFightDuration: 30
|
||||||
|
# Time in seconds to spectate the arena after the fight
|
||||||
SpectatorDuration: 30
|
SpectatorDuration: 30
|
||||||
|
|
||||||
|
Arena:
|
||||||
|
# The amount of blocks the schematics should be pasted under the surface
|
||||||
|
WaterDepth: 0
|
||||||
|
# The size of the schematics
|
||||||
|
Schemsize:
|
||||||
|
x: 0
|
||||||
|
y: 0
|
||||||
|
z: 0
|
||||||
|
# The outer border of the arena, measured in blocks around the schematic areas
|
||||||
|
Schem2Border:
|
||||||
|
x: 0
|
||||||
|
z: 0
|
||||||
|
# The size of the team areas are expanded around the schematics
|
||||||
|
BorderFromSchematic: 0
|
||||||
|
# If ground walkable, teams can walk below the lower arena border during setup
|
||||||
|
GroundWalkable: true
|
||||||
|
|
||||||
Schematic:
|
Schematic:
|
||||||
OnlyPublicSchematics: false
|
# If the rank system for the schematics should be enabled
|
||||||
|
RanksEnabled: false
|
||||||
|
# The schematic type that can be chosen in this arena
|
||||||
SchematicType: normal
|
SchematicType: normal
|
||||||
|
# If the schematics should be rotated during pasting
|
||||||
Rotate: true
|
Rotate: true
|
||||||
ReplaceObsidian: false
|
# If only public schematics are allowed
|
||||||
ReplaceBedrock: false
|
OnlyPublicSchematics: false
|
||||||
|
# If the public only force should be completly disabled
|
||||||
|
IgnorePublicOnly: false
|
||||||
|
# If obsidian and bedrock should be replaced during PRE_RUNNING
|
||||||
|
ReplaceObsidianBedrock: false
|
||||||
|
# If the replacement should happen with blockupdates
|
||||||
|
ReplaceWithBlockupdates: false
|
||||||
|
|
||||||
Output:
|
Output:
|
||||||
|
# Name of the "Red" team
|
||||||
TeamRedName: Rot
|
TeamRedName: Rot
|
||||||
|
# Color prefix of the "Red" team
|
||||||
TeamRedPrefix: '§c'
|
TeamRedPrefix: '§c'
|
||||||
|
# Name of the "Blue" team
|
||||||
TeamBlueName: Blau
|
TeamBlueName: Blau
|
||||||
|
# Color of the "Blue" team
|
||||||
TeamBluePrefix: '§3'
|
TeamBluePrefix: '§3'
|
||||||
GameName: War*
|
# The name of the gamemode presented to the players
|
||||||
|
GameName: NoGear
|
||||||
|
# The prefix used for team chats
|
||||||
TeamChatDetection: +
|
TeamChatDetection: +
|
||||||
|
|
||||||
|
# The list of active winconditions
|
||||||
WinConditions:
|
WinConditions:
|
||||||
Timeout: true
|
- TIMEOUT
|
||||||
AllDead: true
|
# - HEART_RATIO_TIMEOUT
|
||||||
CaptainDead: false
|
# - PERCENT_TIMEOUT
|
||||||
PercentSystem: false
|
|
||||||
RelativePercent: false
|
- ALL_DEAD
|
||||||
Points: false
|
# - CAPTAIN_DEAD
|
||||||
Entern: false
|
|
||||||
TechKO: false
|
# - PERCENT_SYSTEM
|
||||||
WaterTechKO: false
|
# - RELATIVE_PERCENT
|
||||||
HeartRatioTimeout: false
|
# - POINTS
|
||||||
PumpkinTechKO: false
|
|
||||||
|
- WATER_TECH_KO
|
||||||
|
# - TIME_TECH_KO
|
||||||
|
# - PUMPKIN_TECH_KO
|
||||||
|
|
||||||
WinConditionParams:
|
WinConditionParams:
|
||||||
|
# The time of any of the timeout winconditions in seconds
|
||||||
TimeoutTime: 1200
|
TimeoutTime: 1200
|
||||||
EnterPhaseBegin: 600
|
# The percentage when any of the percent winconditions limits or triggers a win
|
||||||
PercentWin: 5.0
|
PercentWin: 5.0
|
||||||
|
# Blocks ignored by the percent winconditions
|
||||||
IgnoredBlocks:
|
IgnoredBlocks:
|
||||||
- AIR
|
- AIR
|
||||||
- WATER
|
- WATER
|
||||||
- TNT
|
- TNT
|
||||||
- OBSIDIAN
|
- OBSIDIAN
|
||||||
|
|
||||||
Kits:
|
Kits:
|
||||||
|
# The kit file for this configuration
|
||||||
|
File: kits.yml
|
||||||
|
# The default kit for team members
|
||||||
MemberDefault: default
|
MemberDefault: default
|
||||||
|
# The default kit for team leaders
|
||||||
LeaderDefault: default
|
LeaderDefault: default
|
||||||
|
# If the personal kit system is active
|
||||||
PersonalKits: false
|
PersonalKits: false
|
||||||
|
# Items that are not allowed in the personal kit
|
||||||
ForbiddenItems: []
|
ForbiddenItems: []
|
||||||
|
|
||||||
|
# A list of integers containing the waiting time of this enter stage in the fight
|
||||||
|
EnterStages: []
|
||||||
|
|
||||||
Techhider:
|
Techhider:
|
||||||
ObfuscateWith: 121
|
# if the techhider is active
|
||||||
ObfuscateWithTag: ENDER_STONE
|
Active: true
|
||||||
|
# Which block the techhider replaces to.
|
||||||
|
ObfuscateWith: end_stone
|
||||||
|
# A list of all hidden blocks. "water" results in the hiding of all waterlogged blocks as well.
|
||||||
HiddenBlocks:
|
HiddenBlocks:
|
||||||
BEDROCK: 7
|
- water
|
||||||
WATER: 8
|
- note_block
|
||||||
STATIONARY_WATER: 9
|
- powered_rail
|
||||||
NOTE_BLOCK: 25
|
- detector_rail
|
||||||
DETECTOR_RAIL: 28
|
- piston
|
||||||
PISTON_BASE: 33
|
- piston_head
|
||||||
PISTON_EXTENSION: 34
|
- sticky_piston
|
||||||
PISTON_STICKY_BASE: 29
|
- tnt
|
||||||
POWERED_RAIL: 27
|
- chest
|
||||||
TNT: 46
|
- trapped_chest
|
||||||
OBSIDIAN: 49
|
- redstone_wire
|
||||||
CHEST: 54
|
- stone_pressure_plate
|
||||||
REDSTONE_WIRE: 55
|
- iron_door
|
||||||
STONE_PLATE: 70
|
- oak_pressure_plate
|
||||||
IRON_DOOR_BLOCK: 71
|
- spruce_pressure_plate
|
||||||
WOOD_PLATE: 72
|
- birch_pressure_plate
|
||||||
REDSTONE_TORCH_OFF: 75
|
- jungle_pressure_plate
|
||||||
REDSTONE_TORCH_ON: 76
|
- acacia_pressure_plate
|
||||||
STONE_BUTTON: 77
|
- dark_oak_pressure_plate
|
||||||
DIODE_BLOCK_OFF: 93
|
- redstone_torch
|
||||||
DIODE_BLOCK_ON: 94
|
- redstone_wall_torch
|
||||||
BREWING_STAND: 117
|
- repeater
|
||||||
TRIPWIRE_HOOK: 131
|
- brewing_stand
|
||||||
TRIPWIRE: 132
|
- tripwire_hook
|
||||||
WOOD_BUTTON: 143
|
- tripwire
|
||||||
TRAPPED_CHEST: 146
|
- heavy_weighted_pressure_plate
|
||||||
GOLD_PLATE: 147
|
- light_weighted_pressure_plate
|
||||||
IRON_PLATE: 148
|
- comparator
|
||||||
REDSTONE_COMPARATOR_OFF: 149
|
- redstone_block
|
||||||
REDSTONE_COMPARATOR_ON: 150
|
- hopper
|
||||||
REDSTONE_BLOCK: 152
|
- activator_rail
|
||||||
HOPPER: 154
|
- dropper
|
||||||
ACTIVATOR_RAIL: 157
|
- slime_block
|
||||||
DROPPER: 158
|
- observer
|
||||||
SLIME_BLOCK: 165
|
- honey_block
|
||||||
IRON_TRAPDOOR: 167
|
- lever
|
||||||
OBSERVER: 218
|
# The block entities that are hidden (contents of blocks)
|
||||||
LEVER: 69
|
|
||||||
HiddenBlockEntites:
|
HiddenBlockEntites:
|
||||||
- minecraft:sign
|
- minecraft:sign
|
||||||
- minecraft:dispenser
|
- minecraft:dispenser
|
||||||
@ -98,22 +158,22 @@ Techhider:
|
|||||||
- minecraft:jukebox
|
- minecraft:jukebox
|
||||||
- minecraft:comparator
|
- minecraft:comparator
|
||||||
|
|
||||||
# Muss in config.yml des Weltordners gesetzt werden
|
# The following configuration must be in the Worldforlder/config.yml
|
||||||
Arena:
|
#
|
||||||
Schemsize:
|
# # The lower arena border under which players get damage
|
||||||
x: 0
|
# UnderBorder:
|
||||||
y: 0
|
# # The lowest corner in all axis of the blue team schematic area
|
||||||
z: 0
|
# BlueCorner:
|
||||||
TeamBlueCorner:
|
# x: 0
|
||||||
x: 0
|
# y: 0
|
||||||
y: 0
|
# z: 0
|
||||||
z: 0
|
# # The offset between the lowest corner of the blue area and the lowest corner of the red area
|
||||||
TeamBluetoReddistance:
|
# BlueToRed:
|
||||||
x: 0
|
# x: 0
|
||||||
y: 0
|
# y: 0
|
||||||
z: 0
|
# z: 0
|
||||||
Schem2Border:
|
# # The offset the teams spawn relative to the center of their area
|
||||||
x: 0
|
# SpawnOffset:
|
||||||
z: 0
|
# x: 0
|
||||||
underArenaBorder: 0
|
# y: 0
|
||||||
BorderFromSchematic: 0
|
# z: 0
|
@ -24,26 +24,24 @@ import de.steamwar.core.Core;
|
|||||||
import de.steamwar.fightsystem.commands.*;
|
import de.steamwar.fightsystem.commands.*;
|
||||||
import de.steamwar.fightsystem.countdown.*;
|
import de.steamwar.fightsystem.countdown.*;
|
||||||
import de.steamwar.fightsystem.fight.Fight;
|
import de.steamwar.fightsystem.fight.Fight;
|
||||||
import de.steamwar.fightsystem.fight.FightPlayer;
|
|
||||||
import de.steamwar.fightsystem.fight.FightTeam;
|
import de.steamwar.fightsystem.fight.FightTeam;
|
||||||
import de.steamwar.fightsystem.kit.KitManager;
|
import de.steamwar.fightsystem.fight.FightWorld;
|
||||||
|
import de.steamwar.fightsystem.listener.Shutdown;
|
||||||
import de.steamwar.fightsystem.listener.*;
|
import de.steamwar.fightsystem.listener.*;
|
||||||
import de.steamwar.fightsystem.record.RecordSystem;
|
import de.steamwar.fightsystem.record.RecordSystem;
|
||||||
import de.steamwar.fightsystem.record.Recorder;
|
import de.steamwar.fightsystem.record.Recorder;
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.states.StateDependent;
|
import de.steamwar.fightsystem.states.OneShotStateDependent;
|
||||||
import de.steamwar.fightsystem.utils.*;
|
import de.steamwar.fightsystem.utils.EnterHandler;
|
||||||
|
import de.steamwar.fightsystem.utils.FightStatistics;
|
||||||
|
import de.steamwar.fightsystem.utils.TechHider;
|
||||||
import de.steamwar.fightsystem.winconditions.*;
|
import de.steamwar.fightsystem.winconditions.*;
|
||||||
import de.steamwar.sql.EventFight;
|
import de.steamwar.sql.EventFight;
|
||||||
import de.steamwar.sql.Schematic;
|
import de.steamwar.sql.Schematic;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.GameMode;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class FightSystem extends JavaPlugin {
|
public class FightSystem extends JavaPlugin {
|
||||||
@ -51,60 +49,47 @@ public class FightSystem extends JavaPlugin {
|
|||||||
public static final String PREFIX = "§eArena§8» ";
|
public static final String PREFIX = "§eArena§8» ";
|
||||||
private static FightSystem plugin;
|
private static FightSystem plugin;
|
||||||
|
|
||||||
private static FightState fightState = FightState.PRE_LEADER_SETUP;
|
|
||||||
private static Map<StateDependent, Boolean> stateDependentFeatures = new HashMap<>();
|
|
||||||
private static int fightTime = 0;
|
|
||||||
private static Countdown mainCountdown;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLoad() {
|
public void onLoad() {
|
||||||
setPlugin(this);
|
plugin = this;
|
||||||
IFightSystem.init(this);
|
IFightSystem.init(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
Fight.init();
|
Fight.init();
|
||||||
KitManager.loadAllKits();
|
|
||||||
TechHider.init();
|
|
||||||
FightScoreboard.init();
|
|
||||||
RecordSystem.init();
|
RecordSystem.init();
|
||||||
|
|
||||||
try {
|
new EntityDamage();
|
||||||
CommandRemover.removeAll("gamemode");
|
new WaterRemover();
|
||||||
CommandInjector.injectCommand(new GamemodeCommand());
|
new Permanent();
|
||||||
} catch (Exception e) {
|
|
||||||
getLogger().log(Level.SEVERE, "Failed to replace commands", e);
|
|
||||||
Bukkit.shutdown();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
new EntityDamageListener();
|
|
||||||
new EntityExplodeListener();
|
|
||||||
new FoodLevelChangeListener();
|
|
||||||
new PistonListener();
|
new PistonListener();
|
||||||
new PlayerChatListener();
|
new Chat();
|
||||||
new HotbarGUIListener();
|
new HotbarGUI();
|
||||||
new PlayerMoveListener();
|
new ArenaBorder();
|
||||||
new PlayerStateListener();
|
new TeamArea();
|
||||||
new ProjectileLaunchListener();
|
new IngameDeath();
|
||||||
new InFightDamageListener();
|
new InFightDamage();
|
||||||
new InFightInventoryListener();
|
new InFightInventory();
|
||||||
new FreezeWorldStateListener();
|
new DenyWorldInteraction();
|
||||||
new EventJoinListener();
|
new EventJoin();
|
||||||
new EventRecordListener();
|
new Recording();
|
||||||
new CheckListener();
|
new Check();
|
||||||
new TestListener();
|
new Shutdown();
|
||||||
new NormalJoinListener();
|
new SetupQuit();
|
||||||
new RankedJoinListener();
|
new PrepareSchem();
|
||||||
new GameplayListener();
|
new TestJoin();
|
||||||
|
new NormalJoin();
|
||||||
|
new RankedJoin();
|
||||||
new PersonalKitCreator();
|
new PersonalKitCreator();
|
||||||
new ScoreboardListener();
|
new FightScoreboard();
|
||||||
new ArrowStopper();
|
new ArrowStopper();
|
||||||
if(Core.getVersion() > 8)
|
if(Core.getVersion() > 8)
|
||||||
new VersionDependentListener();
|
new ArrowPickup();
|
||||||
|
|
||||||
new EnterHandler();
|
new EnterHandler();
|
||||||
|
new TechHider();
|
||||||
|
new FightWorld();
|
||||||
|
|
||||||
new WinconditionAllDead();
|
new WinconditionAllDead();
|
||||||
new WinconditionCaptainDead();
|
new WinconditionCaptainDead();
|
||||||
@ -115,41 +100,49 @@ public class FightSystem extends JavaPlugin {
|
|||||||
new WinconditionPoints();
|
new WinconditionPoints();
|
||||||
new WinconditionTimeout();
|
new WinconditionTimeout();
|
||||||
new WinconditionHeartRatioTimeout();
|
new WinconditionHeartRatioTimeout();
|
||||||
new WinconditionTechKO();
|
new WinconditionTimeTechKO();
|
||||||
|
new EventTeamOffWincondition();
|
||||||
|
new RankedPlayerLeftWincondition();
|
||||||
|
new WinconditionPercentTimeout();
|
||||||
|
|
||||||
Objects.requireNonNull(getCommand("leave")).setExecutor(new LeaveCommand());
|
new NoPlayersOnlineCountdown();
|
||||||
Objects.requireNonNull(getCommand("kit")).setExecutor(new KitCommand());
|
new PreSchemCountdown();
|
||||||
Objects.requireNonNull(getCommand("remove")).setExecutor(new RemoveCommand());
|
new PostSchemCountdown();
|
||||||
Objects.requireNonNull(getCommand("accept")).setExecutor(new AcceptCommand());
|
new PreRunningCountdown();
|
||||||
Objects.requireNonNull(getCommand("decline")).setExecutor(new DeclineCommand());
|
new SpectateOverCountdown();
|
||||||
Objects.requireNonNull(getCommand("invite")).setExecutor(new InviteCommand());
|
new EventSpectateCountdown();
|
||||||
Objects.requireNonNull(getCommand("ready")).setExecutor(new ReadyCommand());
|
|
||||||
Objects.requireNonNull(getCommand("ak")).setExecutor(new AkCommand());
|
|
||||||
Objects.requireNonNull(getCommand("leader")).setExecutor(new LeaderCommand());
|
|
||||||
Objects.requireNonNull(getCommand("lockschem")).setExecutor(new LockschemCommand());
|
|
||||||
|
|
||||||
mainCountdown = new NoPlayersOnlineCountdown();
|
new LeaveCommand();
|
||||||
fightTime = Config.TimeoutTime;
|
new KitCommand();
|
||||||
|
new RemoveCommand();
|
||||||
|
new AcceptCommand();
|
||||||
|
new DeclineCommand();
|
||||||
|
new InviteCommand();
|
||||||
|
new ReadyCommand();
|
||||||
|
new AkCommand();
|
||||||
|
new LeaderCommand();
|
||||||
|
new LockschemCommand();
|
||||||
|
new StateCommand();
|
||||||
|
new SkipCommand();
|
||||||
|
|
||||||
if(Config.event() || Config.Ranked) {
|
new OneShotStateDependent(ArenaMode.All, FightState.PreRunning, () -> Bukkit.broadcastMessage(PREFIX + "§aDer Kampf beginnt!"));
|
||||||
Objects.requireNonNull(getCommand("invite")).setExecutor(new EventDummyCommand());
|
new OneShotStateDependent(ArenaMode.All, FightState.Running, () -> Bukkit.broadcastMessage(PREFIX + "§aArena freigegeben!"));
|
||||||
Objects.requireNonNull(getCommand("ready")).setExecutor(new EventDummyCommand());
|
new OneShotStateDependent(ArenaMode.AntiTest, FightState.Running, FightStatistics::start);
|
||||||
Objects.requireNonNull(getCommand("ak")).setExecutor(new EventDummyCommand());
|
|
||||||
Objects.requireNonNull(getCommand("leader")).setExecutor(new EventDummyCommand());
|
|
||||||
|
|
||||||
setPreSchemState();
|
try {
|
||||||
}else if(Config.test()){
|
CommandRemover.removeAll("gamemode");
|
||||||
if(Config.check()){
|
CommandInjector.injectCommand(new GamemodeCommand());
|
||||||
Bukkit.getScheduler().runTaskLater(this, () -> Fight.getBlueTeam().setSchematic(Schematic.getSchemFromDB(Config.CheckSchemID)), 0);
|
} catch (Exception e) {
|
||||||
}else{
|
getLogger().log(Level.SEVERE, "Failed to replace commands", e);
|
||||||
Bukkit.getScheduler().runTaskLater(this, Fight.getBlueTeam()::pasteDummy, 0);
|
|
||||||
}
|
|
||||||
Bukkit.getScheduler().runTaskLater(this, Fight.getRedTeam()::pasteDummy, 0);
|
|
||||||
|
|
||||||
setPreSchemState();
|
|
||||||
setPostSchemState();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(Config.mode == ArenaMode.EVENT) {
|
||||||
|
setPreSchemState();
|
||||||
|
}else if(Config.mode == ArenaMode.CHECK){
|
||||||
|
Fight.getBlueTeam().setSchem(Schematic.getSchemFromDB(Config.CheckSchemID));
|
||||||
|
}else if(Config.mode == ArenaMode.PREPARE) {
|
||||||
|
Fight.getBlueTeam().setSchem(Schematic.getSchemFromDB(Config.PrepareSchemID));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -157,71 +150,31 @@ public class FightSystem extends JavaPlugin {
|
|||||||
Recorder.closeAll();
|
Recorder.closeAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setPreSchemState() {
|
public static void setPreLeaderState() {
|
||||||
if(fightState != FightState.PRE_LEADER_SETUP)
|
FightState.setFightState(FightState.PRE_LEADER_SETUP);
|
||||||
throw new SecurityException(fightState.name());
|
|
||||||
setFightState(FightState.PRE_SCHEM_SETUP);
|
|
||||||
|
|
||||||
Fight.calcAvailibleSchemTypes();
|
Fight.getBlueTeam().reset();
|
||||||
mainCountdown = new PreSchemPasteCountdown();
|
Fight.getRedTeam().reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setPreSchemState() {
|
||||||
|
FightState.setFightState(FightState.PRE_SCHEM_SETUP);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setPostSchemState() {
|
public static void setPostSchemState() {
|
||||||
if(fightState != FightState.PRE_SCHEM_SETUP)
|
FightState.setFightState(FightState.POST_SCHEM_SETUP);
|
||||||
throw new SecurityException(fightState.name());
|
|
||||||
setFightState(FightState.POST_SCHEM_SETUP);
|
|
||||||
|
|
||||||
TechHider.start();
|
|
||||||
if(!Config.test()){
|
|
||||||
Fight.getBlueTeam().pasteSchematic();
|
|
||||||
Fight.getRedTeam().pasteSchematic();
|
|
||||||
}
|
|
||||||
|
|
||||||
if(Config.test())
|
|
||||||
mainCountdown = null;
|
|
||||||
else
|
|
||||||
mainCountdown = new SetupOverCountdown();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setPreRunningState() {
|
public static void setPreRunningState() {
|
||||||
if(fightState != FightState.POST_SCHEM_SETUP)
|
FightState.setFightState(FightState.PRE_RUNNING);
|
||||||
throw new SecurityException(fightState.name());
|
|
||||||
setFightState(FightState.PRE_RUNNING);
|
|
||||||
|
|
||||||
Fight.getBlueTeam().loadKits();
|
|
||||||
Fight.getRedTeam().loadKits();
|
|
||||||
setAllPlayersGM(GameMode.SURVIVAL);
|
|
||||||
Bukkit.broadcastMessage(PREFIX + "§aDer Kampf beginnt!");
|
|
||||||
|
|
||||||
mainCountdown = new PreRunningCountdown();
|
|
||||||
|
|
||||||
Fight.replaceSync();
|
|
||||||
|
|
||||||
if(Config.event())
|
|
||||||
new EventTeamOffWincondition();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setRunningState() {
|
public static void setRunningState() {
|
||||||
if(fightState != FightState.PRE_RUNNING)
|
FightState.setFightState(FightState.RUNNING);
|
||||||
throw new SecurityException(fightState.name());
|
|
||||||
setFightState(FightState.RUNNING);
|
|
||||||
setAllPlayersGM(GameMode.SURVIVAL);
|
|
||||||
|
|
||||||
FightStatistics.start();
|
|
||||||
Bukkit.broadcastMessage(PREFIX + "§aArena freigegeben!");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setSpectateState(FightTeam winFightTeam, String windescription) {
|
public static void setSpectateState(FightTeam winFightTeam, String windescription) {
|
||||||
if(fightState == FightState.SPECTATE)
|
FightState.setFightState(FightState.SPECTATE);
|
||||||
return;
|
|
||||||
setFightState(FightState.SPECTATE);
|
|
||||||
|
|
||||||
setAllPlayersGM(GameMode.SPECTATOR);
|
|
||||||
Fight.getBlueTeam().teleportToSpawn();
|
|
||||||
Fight.getRedTeam().teleportToSpawn();
|
|
||||||
Bukkit.getOnlinePlayers().forEach(player -> player.getInventory().clear());
|
|
||||||
|
|
||||||
Bukkit.broadcastMessage(" ");
|
|
||||||
|
|
||||||
if(winFightTeam != null) {
|
if(winFightTeam != null) {
|
||||||
Bukkit.broadcastMessage(PREFIX + "§aDas Team " + winFightTeam.getColoredName() + " §ahat gewonnen!");
|
Bukkit.broadcastMessage(PREFIX + "§aDas Team " + winFightTeam.getColoredName() + " §ahat gewonnen!");
|
||||||
@ -229,7 +182,7 @@ public class FightSystem extends JavaPlugin {
|
|||||||
Bukkit.broadcastMessage(PREFIX + "§aKein Team hat gewonnen!");
|
Bukkit.broadcastMessage(PREFIX + "§aKein Team hat gewonnen!");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Config.event()) {
|
if(Config.mode == ArenaMode.EVENT) {
|
||||||
if (winFightTeam == null)
|
if (winFightTeam == null)
|
||||||
getEventFight().setErgebnis(0);
|
getEventFight().setErgebnis(0);
|
||||||
else if (winFightTeam.isBlue())
|
else if (winFightTeam.isBlue())
|
||||||
@ -239,15 +192,10 @@ public class FightSystem extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!Config.test()){
|
if(!Config.test()){
|
||||||
new SpectateOverCountdown();
|
|
||||||
FightStatistics.saveStats(winFightTeam, windescription);
|
FightStatistics.saveStats(winFightTeam, windescription);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setFightTime(int fightTime) {
|
|
||||||
FightSystem.fightTime = fightTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setEventLeiter(Player el){
|
public static void setEventLeiter(Player el){
|
||||||
IFightSystem.setEventLeiter(el);
|
IFightSystem.setEventLeiter(el);
|
||||||
}
|
}
|
||||||
@ -260,70 +208,24 @@ public class FightSystem extends JavaPlugin {
|
|||||||
return IFightSystem.getEventFight();
|
return IFightSystem.getEventFight();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void setPlugin(FightSystem pl){
|
|
||||||
plugin = pl;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static FightSystem getPlugin() {
|
public static FightSystem getPlugin() {
|
||||||
return plugin;
|
return plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static FightState getFightState() {
|
|
||||||
return fightState;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getFightTime() {
|
|
||||||
return fightTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void shutdown(String reason){
|
public static void shutdown(String reason){
|
||||||
IFightSystem.shutdown(reason);
|
if(reason != null)
|
||||||
|
Bukkit.broadcastMessage(reason);
|
||||||
|
//Staggered kick to prevent lobby overloading
|
||||||
|
kickNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void registerStateDependent(StateDependent stateDependent){
|
private static void kickNext(){
|
||||||
if(stateDependent.enabled().isEmpty())
|
if(Bukkit.getOnlinePlayers().isEmpty()){
|
||||||
|
Bukkit.shutdown();
|
||||||
return;
|
return;
|
||||||
boolean enabled = stateDependent.enabled().contains(fightState);
|
|
||||||
stateDependentFeatures.put(stateDependent, enabled);
|
|
||||||
if(enabled)
|
|
||||||
stateDependent.enable();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void setAllPlayersGM(GameMode gm) {
|
|
||||||
for(FightPlayer fightPlayer: Fight.getBlueTeam().getPlayers()){
|
|
||||||
Fight.setPlayerGamemode(fightPlayer.getPlayer(), gm);
|
|
||||||
}
|
}
|
||||||
for(FightPlayer fightPlayer: Fight.getRedTeam().getPlayers()){
|
|
||||||
Fight.setPlayerGamemode(fightPlayer.getPlayer(), gm);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void setFightState(FightState state){
|
Bukkit.getOnlinePlayers().iterator().next().kickPlayer(null);
|
||||||
fightState = state;
|
Bukkit.getScheduler().runTaskLater(plugin, FightSystem::kickNext, 10);
|
||||||
if(mainCountdown != null){
|
|
||||||
mainCountdown.disable();
|
|
||||||
mainCountdown = null;
|
|
||||||
}
|
|
||||||
postStateChange();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void postStateChange(){
|
|
||||||
for(Map.Entry<StateDependent, Boolean> feature : stateDependentFeatures.entrySet()){
|
|
||||||
//Enable feature if should be enabled and currently disabled
|
|
||||||
if(feature.getKey().enabled().contains(fightState)){
|
|
||||||
if(!feature.getValue()){
|
|
||||||
feature.getKey().enable();
|
|
||||||
feature.setValue(true);
|
|
||||||
}
|
|
||||||
feature.getKey().stateChange(fightState);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//Disable feature if should be disabled and currently enabled
|
|
||||||
if(!feature.getKey().enabled().contains(fightState) && feature.getValue()){
|
|
||||||
feature.getKey().disable();
|
|
||||||
feature.setValue(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,12 +19,20 @@
|
|||||||
|
|
||||||
package de.steamwar.fightsystem.commands;
|
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.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class AcceptCommand implements CommandExecutor {
|
public class AcceptCommand implements CommandExecutor {
|
||||||
|
|
||||||
|
public AcceptCommand() {
|
||||||
|
new StateDependentCommand(ArenaMode.VariableTeams, FightState.Setup, "accept", this);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
if(!(sender instanceof Player)) {
|
if(!(sender instanceof Player)) {
|
||||||
|
@ -19,211 +19,36 @@
|
|||||||
|
|
||||||
package de.steamwar.fightsystem.commands;
|
package de.steamwar.fightsystem.commands;
|
||||||
|
|
||||||
import de.steamwar.fightsystem.FightSystem;
|
import de.steamwar.fightsystem.ArenaMode;
|
||||||
import de.steamwar.fightsystem.fight.Fight;
|
import de.steamwar.fightsystem.fight.Kit;
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.fight.FightTeam;
|
import de.steamwar.fightsystem.states.StateDependentCommand;
|
||||||
import de.steamwar.fightsystem.kit.KitManager;
|
|
||||||
import de.steamwar.fightsystem.Config;
|
|
||||||
import de.steamwar.sql.Schematic;
|
|
||||||
import de.steamwar.sql.SchematicType;
|
|
||||||
import de.steamwar.sql.SteamwarUser;
|
import de.steamwar.sql.SteamwarUser;
|
||||||
import de.steamwar.sql.UserGroup;
|
import de.steamwar.sql.UserGroup;
|
||||||
import net.md_5.bungee.api.ChatColor;
|
|
||||||
import net.md_5.bungee.api.chat.ClickEvent;
|
|
||||||
import net.md_5.bungee.api.chat.ComponentBuilder;
|
|
||||||
import net.md_5.bungee.api.chat.HoverEvent;
|
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class AkCommand implements CommandExecutor {
|
public class AkCommand implements CommandExecutor {
|
||||||
|
|
||||||
private static final String SCHEMLIST_COMMAND = "/ak schemlist ";
|
public AkCommand() {
|
||||||
private static final int FILES_PER_PAGE = 15;
|
new StateDependentCommand(ArenaMode.Test, FightState.All, "ak", this);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
|
||||||
if(!(sender instanceof Player)) {
|
if(!(sender instanceof Player)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
|
|
||||||
switch(args.length){
|
if(SteamwarUser.get(player.getUniqueId()).getUserGroup() != UserGroup.Developer){
|
||||||
case 1:
|
Commands.sendHelp(player);
|
||||||
if(args[0].equalsIgnoreCase("schem") || args[0].equalsIgnoreCase("schemlist")){
|
return false;
|
||||||
|
|
||||||
//TEXT COMPONENTS
|
|
||||||
TextComponent publicList = new TextComponent("PUBLIC");
|
|
||||||
publicList.setColor(ChatColor.YELLOW);
|
|
||||||
publicList.setBold(true);
|
|
||||||
publicList.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§ePublic Liste...").create()));
|
|
||||||
publicList.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/ak schemlist public"));
|
|
||||||
|
|
||||||
TextComponent privateList = new TextComponent("PRIVATE");
|
|
||||||
privateList.setColor(ChatColor.YELLOW);
|
|
||||||
privateList.setBold(true);
|
|
||||||
privateList.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§ePrivate Liste...").create()));
|
|
||||||
privateList.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/ak schemlist 0"));
|
|
||||||
//TEXT COMPONENTS
|
|
||||||
|
|
||||||
player.spigot().sendMessage(publicList);
|
|
||||||
player.spigot().sendMessage(privateList);
|
|
||||||
}else
|
|
||||||
Commands.sendHelp(player);
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
if(args[0].equalsIgnoreCase("addkit")){
|
|
||||||
if(SteamwarUser.get(player.getUniqueId()).getUserGroup() != UserGroup.Developer){
|
|
||||||
Commands.sendHelp(player);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
KitManager.saveInventory(args[1], player);
|
|
||||||
} else if(args[0].equalsIgnoreCase("schemlist") && FightSystem.getFightState() == FightState.PRE_SCHEM_SETUP) {
|
|
||||||
try {
|
|
||||||
FightTeam fightTeam = Fight.getPlayerTeam(player);
|
|
||||||
if(fightTeam != null && fightTeam.getFightPlayer(player).isLeader()) {
|
|
||||||
if(args[1].equalsIgnoreCase("public")) {
|
|
||||||
sendPlayerSchematicList(true, 0, player, Config.SchematicType);
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
int page;
|
|
||||||
page = Integer.parseInt(args[1]);
|
|
||||||
sendPlayerSchematicList(false, page, player, Config.SchematicType);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (NumberFormatException ex) {
|
|
||||||
player.sendMessage(FightSystem.PREFIX + "§cDu musst eine Seitenzahl angeben!");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
Commands.sendHelp(player);
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
if(args[0].equalsIgnoreCase("schem")) {
|
|
||||||
FightTeam fightTeam = Fight.getPlayerTeam(player);
|
|
||||||
if(fightTeam == null) {
|
|
||||||
player.sendMessage(FightSystem.PREFIX + "§cDu bist in keinem Team!");
|
|
||||||
return false;
|
|
||||||
}else if(fightTeam.hasSchematic()) {
|
|
||||||
player.sendMessage(FightSystem.PREFIX + "§cDie Schematic ist bereits gewählt!");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Schematic schem;
|
|
||||||
if(args[2].equalsIgnoreCase("public")) {
|
|
||||||
schem = Schematic.getSchemFromDB(args[1], SteamwarUser.get(0).getUUID());
|
|
||||||
} else if(args[2].equalsIgnoreCase("private")) {
|
|
||||||
schem = Schematic.getSchemFromDB(args[1], player.getUniqueId());
|
|
||||||
} else
|
|
||||||
return false;
|
|
||||||
|
|
||||||
|
|
||||||
if(schem == null) {
|
|
||||||
schem = Schematic.getSchemFromDB(args[1], 0);
|
|
||||||
if(schem == null){
|
|
||||||
player.sendMessage(FightSystem.PREFIX + "§cDiese Schematic gibt es nicht!");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(schem.getSchemType() != Config.SchematicType) {
|
|
||||||
player.sendMessage(FightSystem.PREFIX + "§cDiese Schematic ist kein " + Config.GameName);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
fightTeam.setSchematic(schem);
|
|
||||||
}else
|
|
||||||
Commands.sendHelp(player);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
Commands.sendHelp(player);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Kit.createKit(args[0], player);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendPlayerSchematicList(boolean publicSchematics, int currentPage, Player player, SchematicType schematicType) {
|
|
||||||
List<Schematic> preSchematicList;
|
|
||||||
List<Schematic> schematicList = new ArrayList<>();
|
|
||||||
if(publicSchematics) {
|
|
||||||
preSchematicList = Schematic.getSchemsAccessibleByUser(0);
|
|
||||||
} else {
|
|
||||||
preSchematicList = Schematic.getSchemsAccessibleByUser(player.getUniqueId());
|
|
||||||
}
|
|
||||||
|
|
||||||
for(Schematic s : preSchematicList) {
|
|
||||||
if(s.getSchemType() == schematicType)
|
|
||||||
schematicList.add(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(schematicList.isEmpty()) {
|
|
||||||
player.sendMessage(FightSystem.PREFIX + "§cDu hast noch keine Schematic(s)!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
int pages;
|
|
||||||
|
|
||||||
double doublePages = (double) schematicList.size() / (double) FILES_PER_PAGE;
|
|
||||||
int intPages = schematicList.size() / FILES_PER_PAGE;
|
|
||||||
|
|
||||||
if(schematicList.size() <= FILES_PER_PAGE) {
|
|
||||||
pages = 1;
|
|
||||||
} else if(doublePages > intPages) {
|
|
||||||
pages = (intPages + 1);
|
|
||||||
} else
|
|
||||||
pages = intPages;
|
|
||||||
|
|
||||||
if(currentPage >= pages) return;
|
|
||||||
|
|
||||||
player.sendMessage("§5======§8[§dSeite " + (currentPage + 1) + " §7/ §d" + pages + " §7| §d" + schematicList.size() + " Schematic(s)§8]§5======");
|
|
||||||
|
|
||||||
for(int i = currentPage * FILES_PER_PAGE; i < (currentPage * FILES_PER_PAGE) + FILES_PER_PAGE; i++) {
|
|
||||||
if(schematicList.size() <= i) break;
|
|
||||||
|
|
||||||
Schematic schem = schematicList.get(i);
|
|
||||||
|
|
||||||
TextComponent schematics = new TextComponent("§b" + schem.getSchemName());
|
|
||||||
schematics.setBold(true);
|
|
||||||
|
|
||||||
schematics.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Schematic benutzen...").create()));
|
|
||||||
schematics.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/ak schem " + schem.getSchemName() + (publicSchematics ? " public" : " private")));
|
|
||||||
|
|
||||||
player.spigot().sendMessage(schematics);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(pages <= 1) return;
|
|
||||||
|
|
||||||
if(currentPage == 0) {
|
|
||||||
TextComponent nextPage = new TextComponent("Nächste Seite >>");
|
|
||||||
nextPage.setColor(ChatColor.RED);
|
|
||||||
nextPage.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§6Nächste Seite...").create()));
|
|
||||||
nextPage.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, SCHEMLIST_COMMAND + "1"));
|
|
||||||
player.spigot().sendMessage(nextPage);
|
|
||||||
} else if((currentPage + 1) == pages) {
|
|
||||||
TextComponent beforePage = new TextComponent("<< Vorherige Seite");
|
|
||||||
beforePage.setColor(ChatColor.RED);
|
|
||||||
beforePage.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§6Vorherige Seite...").create()));
|
|
||||||
beforePage.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, SCHEMLIST_COMMAND + (currentPage - 1)));
|
|
||||||
player.spigot().sendMessage(beforePage);
|
|
||||||
} else {
|
|
||||||
TextComponent beforePage = new TextComponent("<< Seite ");
|
|
||||||
beforePage.setColor(ChatColor.RED);
|
|
||||||
beforePage.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§6Vorherige Seite...").create()));
|
|
||||||
beforePage.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, SCHEMLIST_COMMAND + (currentPage - 1)));
|
|
||||||
|
|
||||||
TextComponent nextPage = new TextComponent(">>");
|
|
||||||
nextPage.setColor(ChatColor.RED);
|
|
||||||
nextPage.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§6Nächste Seite...").create()));
|
|
||||||
nextPage.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, SCHEMLIST_COMMAND + (currentPage + 1)));
|
|
||||||
|
|
||||||
beforePage.addExtra(nextPage);
|
|
||||||
player.spigot().sendMessage(beforePage);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -19,12 +19,15 @@
|
|||||||
|
|
||||||
package de.steamwar.fightsystem.commands;
|
package de.steamwar.fightsystem.commands;
|
||||||
|
|
||||||
|
import de.steamwar.fightsystem.Config;
|
||||||
import de.steamwar.fightsystem.FightSystem;
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
import de.steamwar.fightsystem.fight.Fight;
|
import de.steamwar.fightsystem.fight.Fight;
|
||||||
import de.steamwar.fightsystem.fight.FightPlayer;
|
import de.steamwar.fightsystem.fight.FightPlayer;
|
||||||
import de.steamwar.fightsystem.fight.FightTeam;
|
import de.steamwar.fightsystem.fight.FightTeam;
|
||||||
import de.steamwar.fightsystem.kit.Kit;
|
import de.steamwar.fightsystem.fight.Kit;
|
||||||
import de.steamwar.fightsystem.kit.KitManager;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
|
import de.steamwar.sql.PersonalKit;
|
||||||
|
import de.steamwar.sql.SteamwarUser;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@ -36,7 +39,7 @@ public class Commands {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static boolean checkSetup(Player p){
|
static boolean checkSetup(Player p){
|
||||||
if(!FightSystem.getFightState().setup()){
|
if(!FightState.setup()){
|
||||||
p.sendMessage(FightSystem.PREFIX + "§cDer Kampf hat bereits begonnen!");
|
p.sendMessage(FightSystem.PREFIX + "§cDer Kampf hat bereits begonnen!");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -85,9 +88,6 @@ public class Commands {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void toggleReady(Player p){
|
static void toggleReady(Player p){
|
||||||
if(checkSetup(p))
|
|
||||||
return;
|
|
||||||
|
|
||||||
FightTeam fightTeam = checkGetTeam(p);
|
FightTeam fightTeam = checkGetTeam(p);
|
||||||
if(fightTeam == null || checkGetLeader(p) == null)
|
if(fightTeam == null || checkGetLeader(p) == null)
|
||||||
return;
|
return;
|
||||||
@ -95,6 +95,14 @@ public class Commands {
|
|||||||
fightTeam.setReady(!fightTeam.isReady());
|
fightTeam.setReady(!fightTeam.isReady());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void toggleSkip(Player p){
|
||||||
|
FightTeam fightTeam = checkGetTeam(p);
|
||||||
|
if(fightTeam == null || checkGetLeader(p) == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
fightTeam.skip();
|
||||||
|
}
|
||||||
|
|
||||||
static void acceptInvitation(Player p){
|
static void acceptInvitation(Player p){
|
||||||
if(checkSetup(p))
|
if(checkSetup(p))
|
||||||
return;
|
return;
|
||||||
@ -103,9 +111,8 @@ public class Commands {
|
|||||||
if(team == null)
|
if(team == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
FightPlayer leader = team.getLeader();
|
|
||||||
p.sendMessage(FightSystem.PREFIX + "§aDu bist Team " + team.getColoredName() + " §abeigetreten!");
|
p.sendMessage(FightSystem.PREFIX + "§aDu bist Team " + team.getColoredName() + " §abeigetreten!");
|
||||||
leader.sendMessage(FightSystem.PREFIX + "§aDer Spieler §e" + p.getName() + " §aist deinem Team beigetreten!");
|
team.broadcast(FightSystem.PREFIX + "§aDer Spieler §e" + p.getName() + " §aist dem Team beigetreten!");
|
||||||
team.addMember(p);
|
team.addMember(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,9 +124,8 @@ public class Commands {
|
|||||||
if(team == null)
|
if(team == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
FightPlayer leader = team.getLeader();
|
|
||||||
p.sendMessage(FightSystem.PREFIX + "§aDu hast die Einladung von " + team.getColoredName() + " §aabgelehnt!");
|
p.sendMessage(FightSystem.PREFIX + "§aDu hast die Einladung von " + team.getColoredName() + " §aabgelehnt!");
|
||||||
leader.sendMessage(FightSystem.PREFIX + "§cDer Spieler §e" + p.getName() + " §chat deine Einladung abgelehnt!");
|
team.broadcast(FightSystem.PREFIX + "§cDer Spieler §e" + p.getName() + " §chat die Einladung abgelehnt!");
|
||||||
team.getInvited().remove(p);
|
team.getInvited().remove(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -201,14 +207,23 @@ public class Commands {
|
|||||||
if(fightPlayer == null)
|
if(fightPlayer == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Kit k = KitManager.getKitByName(kitName);
|
Kit k = null;
|
||||||
|
if(Config.PersonalKits){
|
||||||
|
PersonalKit kit = PersonalKit.get(SteamwarUser.get(p.getUniqueId()).getId(), Config.SchematicType.toDB(), kitName);
|
||||||
|
if(kit != null){
|
||||||
|
kit.setInUse();
|
||||||
|
k = new Kit(kit);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
k = Kit.getKitByName(kitName);
|
||||||
|
}
|
||||||
|
|
||||||
if(k == null){
|
if(k == null){
|
||||||
p.sendMessage(FightSystem.PREFIX + "§cDieses Kit gibt es nicht!");
|
p.sendMessage(FightSystem.PREFIX + "§cDieses Kit gibt es nicht!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((fightPlayer.isLeader() && !k.isLeaderAllowed()) ||
|
if(!k.canUseKit(fightPlayer.isLeader())){
|
||||||
(!fightPlayer.isLeader() && !k.isMemberAllowed())){
|
|
||||||
p.sendMessage(FightSystem.PREFIX + "§cDu darfst dieses Kit nicht verwenden!");
|
p.sendMessage(FightSystem.PREFIX + "§cDu darfst dieses Kit nicht verwenden!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -227,7 +242,6 @@ public class Commands {
|
|||||||
p.sendMessage("§8/§eleader §8- §7Werde der Leader eines Teams");
|
p.sendMessage("§8/§eleader §8- §7Werde der Leader eines Teams");
|
||||||
}else{
|
}else{
|
||||||
if(fightPlayer.isLeader()){
|
if(fightPlayer.isLeader()){
|
||||||
p.sendMessage("§8/§eak schem §8<§eSchematic§8> - §7Setze deine Schematic");
|
|
||||||
p.sendMessage("§8/§eready §8- §7Setzt das eigene Team auf bereit");
|
p.sendMessage("§8/§eready §8- §7Setzt das eigene Team auf bereit");
|
||||||
p.sendMessage("§8/§einvite §8<§eSpieler§8> - §7Lade einen Spieler in dein Team ein");
|
p.sendMessage("§8/§einvite §8<§eSpieler§8> - §7Lade einen Spieler in dein Team ein");
|
||||||
p.sendMessage("§8/§eremove §8<§eSpieler§8> - §7Wirft einen Spieler aus dem Team");
|
p.sendMessage("§8/§eremove §8<§eSpieler§8> - §7Wirft einen Spieler aus dem Team");
|
||||||
|
@ -19,12 +19,20 @@
|
|||||||
|
|
||||||
package de.steamwar.fightsystem.commands;
|
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.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class DeclineCommand implements CommandExecutor {
|
public class DeclineCommand implements CommandExecutor {
|
||||||
|
|
||||||
|
public DeclineCommand() {
|
||||||
|
new StateDependentCommand(ArenaMode.VariableTeams, FightState.Setup, "decline", this);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
if(!(sender instanceof Player)) {
|
if(!(sender instanceof Player)) {
|
||||||
|
@ -24,13 +24,14 @@ import de.steamwar.fightsystem.FightSystem;
|
|||||||
import de.steamwar.fightsystem.fight.Fight;
|
import de.steamwar.fightsystem.fight.Fight;
|
||||||
import de.steamwar.fightsystem.fight.FightPlayer;
|
import de.steamwar.fightsystem.fight.FightPlayer;
|
||||||
import de.steamwar.fightsystem.fight.FightTeam;
|
import de.steamwar.fightsystem.fight.FightTeam;
|
||||||
import de.steamwar.fightsystem.kit.Kit;
|
import de.steamwar.fightsystem.fight.Kit;
|
||||||
import de.steamwar.fightsystem.kit.KitManager;
|
|
||||||
import de.steamwar.fightsystem.listener.PersonalKitCreator;
|
import de.steamwar.fightsystem.listener.PersonalKitCreator;
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
|
import de.steamwar.inventory.SWAnvilInv;
|
||||||
import de.steamwar.inventory.SWInventory;
|
import de.steamwar.inventory.SWInventory;
|
||||||
import de.steamwar.inventory.SWItem;
|
import de.steamwar.inventory.SWItem;
|
||||||
import de.steamwar.inventory.SWListInv;
|
import de.steamwar.inventory.SWListInv;
|
||||||
|
import de.steamwar.sql.PersonalKit;
|
||||||
import de.steamwar.sql.Schematic;
|
import de.steamwar.sql.Schematic;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
import de.steamwar.sql.SteamwarUser;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -66,6 +67,20 @@ public class GUI {
|
|||||||
inv.open();
|
inv.open();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void state(Player p){
|
||||||
|
SWInventory inv = new SWInventory(p, 9, "Kampfstatus");
|
||||||
|
inv.setItem(0, Material.GLASS, "§7PRE_LEADER_SETUP", (ClickType click) -> FightSystem.setPreLeaderState());
|
||||||
|
inv.setItem(1, Material.GLASS, "§7PRE_SCHEM_SETUP", (ClickType click) -> FightSystem.setPreSchemState());
|
||||||
|
inv.setItem(2, Material.GLASS, "§7POST_SCHEM_SETUP", (ClickType click) -> FightSystem.setPostSchemState());
|
||||||
|
inv.setItem(3, Material.GLASS, "§ePRE_RUNNING", (ClickType click) -> FightSystem.setPreRunningState());
|
||||||
|
inv.setItem(4, Material.GLASS, "§eRUNNING", (ClickType click) -> FightSystem.setRunningState());
|
||||||
|
inv.setItem(5, Material.GLASS, "§7SPECTATE Blue", (ClickType click) -> FightSystem.setSpectateState(Fight.getBlueTeam(), "operator"));
|
||||||
|
inv.setItem(6, Material.GLASS, "§7SPECTATE Red", (ClickType click) -> FightSystem.setSpectateState(Fight.getRedTeam(), "operator"));
|
||||||
|
inv.setItem(7, Material.GLASS, "§7SPECTATE Tie", (ClickType click) -> FightSystem.setSpectateState(null, "operator"));
|
||||||
|
inv.setCallback(-999, (ClickType click) -> p.closeInventory());
|
||||||
|
inv.open();
|
||||||
|
}
|
||||||
|
|
||||||
public static void chooseInvitation(Player p){
|
public static void chooseInvitation(Player p){
|
||||||
List<SWListInv.SWListEntry<UUID>> players = SWListInv.createPlayerList(p.getUniqueId());
|
List<SWListInv.SWListEntry<UUID>> players = SWListInv.createPlayerList(p.getUniqueId());
|
||||||
players.removeIf(swItemUUIDPair -> Fight.getFightPlayer(Bukkit.getPlayer(swItemUUIDPair.getObject())) != null);
|
players.removeIf(swItemUUIDPair -> Fight.getFightPlayer(Bukkit.getPlayer(swItemUUIDPair.getObject())) != null);
|
||||||
@ -91,30 +106,59 @@ public class GUI {
|
|||||||
inv.open();
|
inv.open();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void kitSelection(Player p){
|
public static void kitSelection(Player p, String query){
|
||||||
FightPlayer fightPlayer = Fight.getFightPlayer(p);
|
FightPlayer fightPlayer = Fight.getFightPlayer(p);
|
||||||
if(fightPlayer == null)
|
if(fightPlayer == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
List<SWListInv.SWListEntry<Kit>> entries = new ArrayList<>();
|
||||||
|
|
||||||
if(Config.PersonalKits){
|
if(Config.PersonalKits){
|
||||||
PersonalKitCreator.openKitSelector(p, "");
|
List<PersonalKit> kits = PersonalKit.get(SteamwarUser.get(p.getUniqueId()).getId(), Config.SchematicType.toDB());
|
||||||
return;
|
kits.forEach(kit -> entries.add(new SWListInv.SWListEntry<>(new SWItem(Material.LEATHER_CHESTPLATE, "§e" + kit.getName(), new ArrayList<>(), kit.isInUse(), clickType -> {}), new Kit(kit))));
|
||||||
|
}else{
|
||||||
|
List<Kit> kitList = Kit.getAvailableKits(fightPlayer.isLeader());
|
||||||
|
for(Kit k : kitList){
|
||||||
|
entries.add(new SWListInv.SWListEntry<>(new SWItem(Material.LEATHER_CHESTPLATE, k.getName(), null, k.leaderExclusive(), null), k));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
List<SWListInv.SWListEntry<Kit>> iconList = new ArrayList<>();
|
entries.removeIf(entry -> !entry.getObject().getName().toLowerCase().contains(query.toLowerCase()));
|
||||||
|
|
||||||
List<Kit> kitList = KitManager.getKits(fightPlayer.isLeader());
|
SWListInv<Kit> inv = new SWListInv<>(p, "Kitauswahl", false, entries, (clickType, kit) -> kit.preview(p));
|
||||||
for(Kit k : kitList){
|
|
||||||
iconList.add(new SWListInv.SWListEntry<>(new SWItem(Material.LEATHER_CHESTPLATE, k.getName(), null, !k.isMemberAllowed(), null), k));
|
|
||||||
}
|
|
||||||
|
|
||||||
SWListInv<Kit> inv = new SWListInv<>(p, "Kitauswahl", iconList, (ClickType click, Kit k) -> k.preview(p));
|
|
||||||
inv.setCallback(-999, (ClickType click) -> p.closeInventory());
|
inv.setCallback(-999, (ClickType click) -> p.closeInventory());
|
||||||
|
if(entries.isEmpty()) {
|
||||||
|
inv.setItem(22, new SWItem(Material.BARRIER, "§cKeine Kits gefunden"));
|
||||||
|
}
|
||||||
|
if(Config.PersonalKits){
|
||||||
|
inv.setItem(48, Material.NETHER_STAR, "§eNeues Kit", clickType -> {
|
||||||
|
SWAnvilInv anvilInv = new SWAnvilInv(p, "Kitname eingeben");
|
||||||
|
anvilInv.setItem(Material.LEATHER_CHESTPLATE);
|
||||||
|
anvilInv.setCallback(s -> {
|
||||||
|
SteamwarUser user = SteamwarUser.get(p.getUniqueId());
|
||||||
|
if(PersonalKit.nameInUse(user.getId(), Config.SchematicType.toDB(), s)) {
|
||||||
|
p.sendMessage(FightSystem.PREFIX + "§cDieser Kitname wird bereits genutzt!");
|
||||||
|
p.closeInventory();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Kit prototype = Kit.getAvailableKits(Fight.getFightPlayer(p).isLeader()).get(0);
|
||||||
|
PersonalKit kit = PersonalKit.create(user.getId(), Config.SchematicType.toDB(), s, prototype.getInventory(), prototype.getArmor());
|
||||||
|
PersonalKitCreator.openKitCreator(p, kit);
|
||||||
|
});
|
||||||
|
anvilInv.open();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
inv.setItem(50, Material.NAME_TAG, "§eSuchen", clickType -> {
|
||||||
|
SWAnvilInv anvilInv = new SWAnvilInv(p, "§eNach Kit suchen");
|
||||||
|
anvilInv.setItem(Material.PAPER);
|
||||||
|
anvilInv.setCallback(s -> kitSelection(p, s));
|
||||||
|
anvilInv.open();
|
||||||
|
});
|
||||||
inv.open();
|
inv.open();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void preSchemDialog(Player p){
|
public static void preSchemDialog(Player p){
|
||||||
if(!Config.test() && FightSystem.getFightState() != FightState.PRE_SCHEM_SETUP){
|
if(!Config.test() && FightState.getFightState() != FightState.PRE_SCHEM_SETUP){
|
||||||
p.sendMessage(FightSystem.PREFIX + "§cDu kannst ohne Gegner keine Schematic wählen");
|
p.sendMessage(FightSystem.PREFIX + "§cDu kannst ohne Gegner keine Schematic wählen");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -153,8 +197,8 @@ public class GUI {
|
|||||||
FightTeam fightTeam = Fight.getPlayerTeam(p);
|
FightTeam fightTeam = Fight.getPlayerTeam(p);
|
||||||
if(fightTeam == null)
|
if(fightTeam == null)
|
||||||
return;
|
return;
|
||||||
if(Config.test() || FightSystem.getFightState() != FightState.POST_SCHEM_SETUP)
|
if(Config.test() || FightState.getFightState() != FightState.POST_SCHEM_SETUP)
|
||||||
fightTeam.setSchematic(s);
|
fightTeam.pasteSchem(s);
|
||||||
p.closeInventory();
|
p.closeInventory();
|
||||||
});
|
});
|
||||||
inv.setCallback(-999, (ClickType click) -> p.closeInventory());
|
inv.setCallback(-999, (ClickType click) -> p.closeInventory());
|
||||||
|
@ -19,12 +19,20 @@
|
|||||||
|
|
||||||
package de.steamwar.fightsystem.commands;
|
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.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class InviteCommand implements CommandExecutor {
|
public class InviteCommand implements CommandExecutor {
|
||||||
|
|
||||||
|
public InviteCommand() {
|
||||||
|
new StateDependentCommand(ArenaMode.VariableTeams, FightState.Setup, "invite", this);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
if(!(sender instanceof Player)) {
|
if(!(sender instanceof Player)) {
|
||||||
|
@ -19,12 +19,20 @@
|
|||||||
|
|
||||||
package de.steamwar.fightsystem.commands;
|
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.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class KitCommand implements CommandExecutor {
|
public class KitCommand implements CommandExecutor {
|
||||||
|
|
||||||
|
public KitCommand() {
|
||||||
|
new StateDependentCommand(ArenaMode.All, FightState.Setup, "kit", this);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
if(!(sender instanceof Player)) {
|
if(!(sender instanceof Player)) {
|
||||||
@ -33,7 +41,7 @@ public class KitCommand implements CommandExecutor {
|
|||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
|
|
||||||
if(args.length != 1)
|
if(args.length != 1)
|
||||||
GUI.kitSelection(player);
|
GUI.kitSelection(player, "");
|
||||||
else{
|
else{
|
||||||
Commands.kit(player, args[0]);
|
Commands.kit(player, args[0]);
|
||||||
}
|
}
|
||||||
|
@ -19,29 +19,34 @@
|
|||||||
|
|
||||||
package de.steamwar.fightsystem.commands;
|
package de.steamwar.fightsystem.commands;
|
||||||
|
|
||||||
|
import de.steamwar.fightsystem.ArenaMode;
|
||||||
import de.steamwar.fightsystem.FightSystem;
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
import de.steamwar.fightsystem.fight.Fight;
|
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.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class LeaderCommand implements CommandExecutor {
|
public class LeaderCommand implements CommandExecutor {
|
||||||
|
|
||||||
|
public LeaderCommand() {
|
||||||
|
new StateDependentCommand(ArenaMode.VariableTeams, FightState.Setup, "leader", this);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
if(!(sender instanceof Player))
|
if(!(sender instanceof Player))
|
||||||
return false;
|
return false;
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
|
|
||||||
if(Commands.checkSetup(player))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if(args.length == 0){
|
if(args.length == 0){
|
||||||
if(Fight.getFightPlayer(player) == null){
|
if(Fight.getFightPlayer(player) == null){
|
||||||
if(!Fight.getBlueTeam().hasTeamLeader())
|
if(Fight.getBlueTeam().isLeaderless())
|
||||||
Fight.getBlueTeam().setLeader(Fight.getBlueTeam().addMember(player));
|
Fight.getBlueTeam().addMember(player);
|
||||||
else if(!Fight.getRedTeam().hasTeamLeader())
|
else if(Fight.getRedTeam().isLeaderless())
|
||||||
Fight.getRedTeam().setLeader(Fight.getRedTeam().addMember(player));
|
Fight.getRedTeam().addMember(player);
|
||||||
else
|
else
|
||||||
player.sendMessage(FightSystem.PREFIX + "§cEs sind bereits 2 Teamleader vorhanden");
|
player.sendMessage(FightSystem.PREFIX + "§cEs sind bereits 2 Teamleader vorhanden");
|
||||||
}else
|
}else
|
||||||
|
@ -19,12 +19,20 @@
|
|||||||
|
|
||||||
package de.steamwar.fightsystem.commands;
|
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.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class LeaveCommand implements CommandExecutor {
|
public class LeaveCommand implements CommandExecutor {
|
||||||
|
|
||||||
|
public LeaveCommand() {
|
||||||
|
new StateDependentCommand(ArenaMode.All, FightState.Setup, "leave", this);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
if(!(sender instanceof Player)) {
|
if(!(sender instanceof Player)) {
|
||||||
|
@ -19,9 +19,12 @@
|
|||||||
|
|
||||||
package de.steamwar.fightsystem.commands;
|
package de.steamwar.fightsystem.commands;
|
||||||
|
|
||||||
|
import de.steamwar.fightsystem.ArenaMode;
|
||||||
import de.steamwar.fightsystem.FightSystem;
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
import de.steamwar.fightsystem.fight.Fight;
|
import de.steamwar.fightsystem.fight.Fight;
|
||||||
import de.steamwar.fightsystem.fight.FightTeam;
|
import de.steamwar.fightsystem.fight.FightTeam;
|
||||||
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
|
import de.steamwar.fightsystem.states.StateDependentCommand;
|
||||||
import de.steamwar.sql.Schematic;
|
import de.steamwar.sql.Schematic;
|
||||||
import de.steamwar.sql.SchematicType;
|
import de.steamwar.sql.SchematicType;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
import de.steamwar.sql.SteamwarUser;
|
||||||
@ -32,6 +35,11 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class LockschemCommand implements CommandExecutor {
|
public class LockschemCommand implements CommandExecutor {
|
||||||
|
|
||||||
|
public LockschemCommand() {
|
||||||
|
new StateDependentCommand(ArenaMode.All, FightState.All, "lockschem", this);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
if(!(sender instanceof Player))
|
if(!(sender instanceof Player))
|
||||||
@ -62,6 +70,7 @@ public class LockschemCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
Schematic.getSchemFromDB(fightTeam.getSchematic()).setSchemType(SchematicType.Normal);
|
Schematic.getSchemFromDB(fightTeam.getSchematic()).setSchemType(SchematicType.Normal);
|
||||||
player.sendMessage(FightSystem.PREFIX + "Schematic von " + fightTeam.getColoredName() + " §cgesperrt!");
|
player.sendMessage(FightSystem.PREFIX + "Schematic von " + fightTeam.getColoredName() + " §cgesperrt!");
|
||||||
|
fightTeam.broadcast(FightSystem.PREFIX + "§cDie Schematic wurde von " + player.getName() + " gesperrt!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,12 +19,20 @@
|
|||||||
|
|
||||||
package de.steamwar.fightsystem.commands;
|
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.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class ReadyCommand implements CommandExecutor {
|
public class ReadyCommand implements CommandExecutor {
|
||||||
|
|
||||||
|
public ReadyCommand() {
|
||||||
|
new StateDependentCommand(ArenaMode.AntiPrepare, FightState.PostSchemSetup, "ready", this);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
if(!(sender instanceof Player)) {
|
if(!(sender instanceof Player)) {
|
||||||
|
@ -19,12 +19,20 @@
|
|||||||
|
|
||||||
package de.steamwar.fightsystem.commands;
|
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.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class RemoveCommand implements CommandExecutor {
|
public class RemoveCommand implements CommandExecutor {
|
||||||
|
|
||||||
|
public RemoveCommand() {
|
||||||
|
new StateDependentCommand(ArenaMode.VariableTeams, FightState.Setup, "remove", this);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
if(!(sender instanceof Player)) {
|
if(!(sender instanceof Player)) {
|
||||||
|
@ -0,0 +1,46 @@
|
|||||||
|
/*
|
||||||
|
This file is a part of the SteamWar software.
|
||||||
|
|
||||||
|
Copyright (C) 2020 SteamWar.de-Serverteam
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.steamwar.fightsystem.commands;
|
||||||
|
|
||||||
|
import 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 SkipCommand implements CommandExecutor {
|
||||||
|
|
||||||
|
public SkipCommand() {
|
||||||
|
new StateDependentCommand(ArenaMode.AntiPrepare, FightState.Running, "skip", this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
if(!(sender instanceof Player)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Player player = (Player) sender;
|
||||||
|
|
||||||
|
Commands.toggleSkip(player);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
@ -19,15 +19,27 @@
|
|||||||
|
|
||||||
package de.steamwar.fightsystem.commands;
|
package de.steamwar.fightsystem.commands;
|
||||||
|
|
||||||
import de.steamwar.fightsystem.FightSystem;
|
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.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class StateCommand implements CommandExecutor {
|
||||||
|
|
||||||
|
public StateCommand() {
|
||||||
|
new StateDependentCommand(ArenaMode.Test, FightState.All, "state", this);
|
||||||
|
}
|
||||||
|
|
||||||
public class EventDummyCommand implements CommandExecutor {
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
sender.sendMessage(FightSystem.PREFIX + "§cWährend des Events ist der Befehl nicht verfügbar.");
|
if(!(sender instanceof Player)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
GUI.state((Player) sender);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -20,7 +20,6 @@
|
|||||||
package de.steamwar.fightsystem.countdown;
|
package de.steamwar.fightsystem.countdown;
|
||||||
|
|
||||||
import de.steamwar.core.Core;
|
import de.steamwar.core.Core;
|
||||||
import de.steamwar.fightsystem.Config;
|
|
||||||
import de.steamwar.fightsystem.FightSystem;
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
import de.steamwar.fightsystem.fight.Fight;
|
import de.steamwar.fightsystem.fight.Fight;
|
||||||
import de.steamwar.fightsystem.listener.BasicListener;
|
import de.steamwar.fightsystem.listener.BasicListener;
|
||||||
@ -32,22 +31,28 @@ import org.bukkit.Sound;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public abstract class Countdown {
|
public abstract class Countdown {
|
||||||
|
|
||||||
private int time;
|
private static final List<Countdown> currentCountdowns = new ArrayList<>();
|
||||||
private final BukkitTask task;
|
|
||||||
|
private final int totalTime;
|
||||||
private final Sound sound;
|
private final Sound sound;
|
||||||
private final boolean level;
|
private final boolean level;
|
||||||
|
|
||||||
abstract String countdownCounting();
|
protected int time;
|
||||||
abstract void countdownFinished();
|
private BukkitTask task = null;
|
||||||
|
|
||||||
Countdown(int time, SWSound sound, boolean level) {
|
public abstract String countdownCounting();
|
||||||
|
public abstract void countdownFinished();
|
||||||
|
|
||||||
|
public Countdown(int time, SWSound sound, boolean level) {
|
||||||
|
this.totalTime = time;
|
||||||
this.time = time;
|
this.time = time;
|
||||||
this.sound = getSound(sound);
|
this.sound = getSound(sound);
|
||||||
this.level = level;
|
this.level = level;
|
||||||
|
|
||||||
task = Bukkit.getScheduler().runTaskTimer(FightSystem.getPlugin(), this::count, 0, 20);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Sound getSound(SWSound sound){
|
public static Sound getSound(SWSound sound){
|
||||||
@ -68,19 +73,52 @@ public abstract class Countdown {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void enable() {
|
||||||
|
time = totalTime;
|
||||||
|
task = Bukkit.getScheduler().runTaskTimer(FightSystem.getPlugin(), this::count, 20, 20);
|
||||||
|
currentCountdowns.add(this);
|
||||||
|
}
|
||||||
|
|
||||||
public void disable() {
|
public void disable() {
|
||||||
task.cancel();
|
if(task != null){
|
||||||
|
task.cancel();
|
||||||
|
currentCountdowns.remove(this);
|
||||||
|
task = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void skip(){
|
||||||
|
if(currentCountdowns.isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
int smallestTime = currentCountdowns.get(0).time;
|
||||||
|
for(Countdown countdown : currentCountdowns){
|
||||||
|
if(countdown.time < smallestTime)
|
||||||
|
smallestTime = countdown.time;
|
||||||
|
}
|
||||||
|
|
||||||
|
smallestTime--;
|
||||||
|
for(Countdown countdown : currentCountdowns){
|
||||||
|
countdown.time -= smallestTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
Bukkit.broadcastMessage(FightSystem.PREFIX + "§aBeide Teams waren damit einverstanden, zum nächsten Event zu beschleunigen!");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void broadcast(String message){
|
private void broadcast(String message){
|
||||||
if(Config.recording())
|
RecordSystem.actionBar(message);
|
||||||
RecordSystem.actionBar(message);
|
|
||||||
BaseComponent[] msg = TextComponent.fromLegacyText(message);
|
BaseComponent[] msg = TextComponent.fromLegacyText(message);
|
||||||
for(Player p : Bukkit.getOnlinePlayers())
|
for(Player p : Bukkit.getOnlinePlayers())
|
||||||
BasicListener.toActionbar(p, msg);
|
BasicListener.toActionbar(p, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getTimeLeft(){
|
||||||
|
return time;
|
||||||
|
}
|
||||||
|
|
||||||
void count(){
|
void count(){
|
||||||
|
time--;
|
||||||
|
|
||||||
switch (time) {
|
switch (time) {
|
||||||
case 900: case 600: case 300: case 180: case 120:
|
case 900: case 600: case 300: case 180: case 120:
|
||||||
broadcast("§rNoch §a" + time / 60 + " §rMinuten " + countdownCounting());
|
broadcast("§rNoch §a" + time / 60 + " §rMinuten " + countdownCounting());
|
||||||
@ -106,14 +144,8 @@ public abstract class Countdown {
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this.level)
|
if(this.level)
|
||||||
Fight.setLevel(time);
|
Bukkit.getServer().getOnlinePlayers().forEach(player -> player.setLevel(time));
|
||||||
|
|
||||||
time--;
|
|
||||||
onTime(time);
|
|
||||||
}
|
|
||||||
|
|
||||||
void onTime(int time){
|
|
||||||
//Implemented in some countdowns
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,8 +35,9 @@ public class EnternCountdown extends Countdown {
|
|||||||
private List<TechHider.ChunkPos> chunkPos;
|
private List<TechHider.ChunkPos> chunkPos;
|
||||||
|
|
||||||
public EnternCountdown(FightPlayer fp) {
|
public EnternCountdown(FightPlayer fp) {
|
||||||
super(fp.getKit().getEnterStage(), SWSound.BLOCK_NOTE_PLING, false);
|
super(Config.EnterStages.get(fp.getKit().getEnterStage()), SWSound.BLOCK_NOTE_PLING, false);
|
||||||
fightPlayer = fp;
|
fightPlayer = fp;
|
||||||
|
enable();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -52,13 +53,9 @@ public class EnternCountdown extends Countdown {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
void count(){
|
void count(){
|
||||||
if(!fightPlayer.isLiving()){
|
time--;
|
||||||
disable();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Player player = fightPlayer.getPlayer();
|
Player player = fightPlayer.getPlayer();
|
||||||
int time = FightSystem.getFightTime() - Config.EnterStages.get(fightPlayer.getKit().getEnterStage());
|
|
||||||
switch (time) {
|
switch (time) {
|
||||||
case 900: case 600: case 300: case 180: case 120:
|
case 900: case 600: case 300: case 180: case 120:
|
||||||
BasicListener.toActionbar(player, TextComponent.fromLegacyText("§rNoch §a" + time / 60 + " §rMinuten " + countdownCounting()));
|
BasicListener.toActionbar(player, TextComponent.fromLegacyText("§rNoch §a" + time / 60 + " §rMinuten " + countdownCounting()));
|
||||||
|
@ -17,36 +17,28 @@
|
|||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.steamwar.fightsystem.winconditions;
|
package de.steamwar.fightsystem.countdown;
|
||||||
|
|
||||||
|
import de.steamwar.fightsystem.ArenaMode;
|
||||||
|
import de.steamwar.fightsystem.Config;
|
||||||
import de.steamwar.fightsystem.FightSystem;
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import org.bukkit.Bukkit;
|
import de.steamwar.fightsystem.states.StateDependentCountdown;
|
||||||
import org.bukkit.event.HandlerList;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
|
|
||||||
import java.util.Set;
|
public class EventSpectateCountdown extends Countdown {
|
||||||
|
|
||||||
abstract class ListenerWincondition extends Wincondition implements Listener {
|
public EventSpectateCountdown() {
|
||||||
|
super(Config.SpectatorDuration, SWSound.BLOCK_NOTE_PLING, false);
|
||||||
ListenerWincondition(boolean condition, Set<FightState> enabled){
|
new StateDependentCountdown(ArenaMode.Event, FightState.Spectate, this);
|
||||||
//If the condition is not met, never enable
|
|
||||||
super(condition, enabled);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Enables the state dependent object
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void enable(){
|
public String countdownCounting() {
|
||||||
Bukkit.getPluginManager().registerEvents(this, FightSystem.getPlugin());
|
return "bis der Server gestoppt wird!";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Disables the state dependent object
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void disable(){
|
public void countdownFinished() {
|
||||||
HandlerList.unregisterAll(this);
|
FightSystem.shutdown(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -19,13 +19,29 @@
|
|||||||
|
|
||||||
package de.steamwar.fightsystem.countdown;
|
package de.steamwar.fightsystem.countdown;
|
||||||
|
|
||||||
|
import de.steamwar.fightsystem.ArenaMode;
|
||||||
import de.steamwar.fightsystem.Config;
|
import de.steamwar.fightsystem.Config;
|
||||||
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
|
import de.steamwar.fightsystem.states.StateDependentCountdown;
|
||||||
|
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
|
|
||||||
public class NoPlayersOnlineCountdown extends Countdown {
|
public class NoPlayersOnlineCountdown extends Countdown implements Listener {
|
||||||
|
|
||||||
public NoPlayersOnlineCountdown() {
|
public NoPlayersOnlineCountdown() {
|
||||||
super(Config.NoPlayerOnlineDuration, null, false);
|
super(Config.NoPlayerOnlineDuration, null, false);
|
||||||
|
|
||||||
|
new StateDependentListener(ArenaMode.All, FightState.PreLeaderSetup, this);
|
||||||
|
new StateDependentCountdown(ArenaMode.All, FightState.PreLeaderSetup, this){
|
||||||
|
@Override
|
||||||
|
public void enable() {
|
||||||
|
if(Bukkit.getOnlinePlayers().isEmpty())
|
||||||
|
super.enable();
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -33,6 +49,11 @@ public class NoPlayersOnlineCountdown extends Countdown {
|
|||||||
return "bis der Server gestoppt wird!";
|
return "bis der Server gestoppt wird!";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void handlePlayerJoin(PlayerJoinEvent event) {
|
||||||
|
disable();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void countdownFinished() {
|
public void countdownFinished() {
|
||||||
Bukkit.getServer().shutdown();
|
Bukkit.getServer().shutdown();
|
||||||
|
@ -19,17 +19,21 @@
|
|||||||
|
|
||||||
package de.steamwar.fightsystem.countdown;
|
package de.steamwar.fightsystem.countdown;
|
||||||
|
|
||||||
|
import de.steamwar.fightsystem.ArenaMode;
|
||||||
import de.steamwar.fightsystem.Config;
|
import de.steamwar.fightsystem.Config;
|
||||||
import de.steamwar.fightsystem.FightSystem;
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
|
import de.steamwar.fightsystem.states.StateDependentCountdown;
|
||||||
|
|
||||||
public class SetupOverCountdown extends Countdown {
|
public class PostSchemCountdown extends Countdown {
|
||||||
|
|
||||||
public SetupOverCountdown() {
|
public PostSchemCountdown() {
|
||||||
super(Config.SetupDuration, null, false);
|
super(Config.SetupDuration, null, false);
|
||||||
|
new StateDependentCountdown(ArenaMode.AntiTest, FightState.PostSchemSetup, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
String countdownCounting() {
|
public String countdownCounting() {
|
||||||
return "bis die Kits verteilt werden!";
|
return "bis die Kits verteilt werden!";
|
||||||
}
|
}
|
||||||
|
|
@ -19,13 +19,17 @@
|
|||||||
|
|
||||||
package de.steamwar.fightsystem.countdown;
|
package de.steamwar.fightsystem.countdown;
|
||||||
|
|
||||||
import de.steamwar.fightsystem.FightSystem;
|
import de.steamwar.fightsystem.ArenaMode;
|
||||||
import de.steamwar.fightsystem.Config;
|
import de.steamwar.fightsystem.Config;
|
||||||
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
|
import de.steamwar.fightsystem.states.StateDependentCountdown;
|
||||||
|
|
||||||
public class PreRunningCountdown extends Countdown {
|
public class PreRunningCountdown extends Countdown {
|
||||||
|
|
||||||
public PreRunningCountdown() {
|
public PreRunningCountdown() {
|
||||||
super(Config.PreFightDuration, SWSound.BLOCK_NOTE_PLING, true);
|
super(Config.PreFightDuration, SWSound.BLOCK_NOTE_PLING, true);
|
||||||
|
new StateDependentCountdown(ArenaMode.All, FightState.PreRunning, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -19,31 +19,26 @@
|
|||||||
|
|
||||||
package de.steamwar.fightsystem.countdown;
|
package de.steamwar.fightsystem.countdown;
|
||||||
|
|
||||||
|
import de.steamwar.fightsystem.ArenaMode;
|
||||||
import de.steamwar.fightsystem.Config;
|
import de.steamwar.fightsystem.Config;
|
||||||
import de.steamwar.fightsystem.FightSystem;
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
import de.steamwar.fightsystem.fight.Fight;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.fight.FightTeam;
|
import de.steamwar.fightsystem.states.StateDependentCountdown;
|
||||||
|
|
||||||
public class PreSchemPasteCountdown extends Countdown {
|
public class PreSchemCountdown extends Countdown {
|
||||||
|
|
||||||
public PreSchemPasteCountdown() {
|
public PreSchemCountdown() {
|
||||||
super(Config.PreSchemPasteDuration, SWSound.BLOCK_NOTE_PLING, false);
|
super(Config.PreSchemPasteDuration, SWSound.BLOCK_NOTE_PLING, false);
|
||||||
|
new StateDependentCountdown(ArenaMode.All, FightState.PreSchemSetup, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
String countdownCounting() {
|
public String countdownCounting() {
|
||||||
return "bis eine Public-Schematic gewählt wird!";
|
return "bis eine Public-Schematic gewählt wird!";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void countdownFinished() {
|
public void countdownFinished() {
|
||||||
checkTeam(Fight.getBlueTeam());
|
|
||||||
checkTeam(Fight.getRedTeam());
|
|
||||||
FightSystem.setPostSchemState();
|
FightSystem.setPostSchemState();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkTeam(FightTeam team){
|
|
||||||
if(!team.hasSchematic())
|
|
||||||
team.pasteDummy();
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -19,22 +19,26 @@
|
|||||||
|
|
||||||
package de.steamwar.fightsystem.countdown;
|
package de.steamwar.fightsystem.countdown;
|
||||||
|
|
||||||
import de.steamwar.fightsystem.FightSystem;
|
import de.steamwar.fightsystem.ArenaMode;
|
||||||
import de.steamwar.fightsystem.Config;
|
import de.steamwar.fightsystem.Config;
|
||||||
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
|
import de.steamwar.fightsystem.states.StateDependentCountdown;
|
||||||
|
|
||||||
public class SpectateOverCountdown extends Countdown {
|
public class SpectateOverCountdown extends Countdown {
|
||||||
|
|
||||||
public SpectateOverCountdown() {
|
public SpectateOverCountdown() {
|
||||||
super(Config.SpectatorDuration, SWSound.BLOCK_NOTE_PLING, false);
|
super(Config.SpectatorDuration, SWSound.BLOCK_NOTE_PLING, false);
|
||||||
|
new StateDependentCountdown(ArenaMode.Restartable, FightState.Spectate, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String countdownCounting() {
|
public String countdownCounting() {
|
||||||
return "bis der Server gestoppt wird!";
|
return "bis die Arena zurückgesetzt wird!";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void countdownFinished() {
|
public void countdownFinished() {
|
||||||
FightSystem.shutdown(null);
|
FightSystem.setPreLeaderState();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,46 +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;
|
|
||||||
}
|
|
||||||
|
|
||||||
@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");
|
|
||||||
}
|
|
||||||
}
|
|
@ -42,9 +42,4 @@ public class TimeOverCountdown extends Countdown {
|
|||||||
Bukkit.broadcastMessage(FightSystem.PREFIX +"§aZeit abgelaufen!");
|
Bukkit.broadcastMessage(FightSystem.PREFIX +"§aZeit abgelaufen!");
|
||||||
timeOver.run();
|
timeOver.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
void onTime(int time) {
|
|
||||||
FightSystem.setFightTime(time);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,7 @@ import com.comphenix.protocol.wrappers.EnumWrappers;
|
|||||||
import com.comphenix.protocol.wrappers.PlayerInfoData;
|
import com.comphenix.protocol.wrappers.PlayerInfoData;
|
||||||
import com.comphenix.protocol.wrappers.WrappedChatComponent;
|
import com.comphenix.protocol.wrappers.WrappedChatComponent;
|
||||||
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
||||||
|
import de.steamwar.fightsystem.ArenaMode;
|
||||||
import de.steamwar.fightsystem.Config;
|
import de.steamwar.fightsystem.Config;
|
||||||
import de.steamwar.fightsystem.record.RecordSystem;
|
import de.steamwar.fightsystem.record.RecordSystem;
|
||||||
import de.steamwar.fightsystem.FightSystem;
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
@ -41,9 +42,8 @@ import java.util.logging.Level;
|
|||||||
public class Fight {
|
public class Fight {
|
||||||
private Fight(){}
|
private Fight(){}
|
||||||
|
|
||||||
public static final FightTeam redTeam = new FightTeam(Config.TeamRedName, Config.TeamRedColor, Config.TeamRedSpawn, Config.TeamRedCornerX, Config.TeamRedCornerY, Config.TeamRedCornerZ, Config.TeamRedRotate, false, Config.RedLeader);
|
private static final FightTeam redTeam = new FightTeam(Config.TeamRedName, Config.TeamRedColor, Config.TeamRedSpawn, Config.RedPasteRegion, Config.RedExtendRegion, Config.RedRotate, false, Config.RedLeader);
|
||||||
public static final FightTeam blueTeam = new FightTeam(Config.TeamBlueName, Config.TeamBlueColor, Config.TeamBlueSpawn, Config.TeamBlueCornerX, Config.TeamBlueCornerY, Config.TeamBlueCornerZ, Config.TeamBlueRotate, true, Config.BlueLeader);
|
private static final FightTeam blueTeam = new FightTeam(Config.TeamBlueName, Config.TeamBlueColor, Config.TeamBlueSpawn, Config.BluePasteRegion, Config.BlueExtendRegion, Config.BlueRotate, true, Config.BlueLeader);
|
||||||
private static int schemRank;
|
|
||||||
|
|
||||||
public static void init(){
|
public static void init(){
|
||||||
IFight.init(redTeam, blueTeam);
|
IFight.init(redTeam, blueTeam);
|
||||||
@ -58,14 +58,12 @@ public class Fight {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static FightTeam getOpposite(FightTeam fightTeam) {
|
public static FightTeam getOpposite(FightTeam fightTeam) {
|
||||||
if(fightTeam == null){
|
|
||||||
throw new IllegalArgumentException();
|
|
||||||
}
|
|
||||||
|
|
||||||
if(fightTeam == redTeam)
|
if(fightTeam == redTeam)
|
||||||
return blueTeam;
|
return blueTeam;
|
||||||
else
|
else if(fightTeam == blueTeam)
|
||||||
return redTeam;
|
return redTeam;
|
||||||
|
|
||||||
|
throw new IllegalArgumentException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static FightTeam getInvitedTeam(Player player){
|
public static FightTeam getInvitedTeam(Player player){
|
||||||
@ -93,16 +91,11 @@ public class Fight {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void playSound(Sound sound, float volume, float pitch) {
|
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
|
//volume: max. 100, pitch: max. 2
|
||||||
Bukkit.getServer().getOnlinePlayers().forEach(player -> player.playSound(player.getLocation(), sound, volume, pitch));
|
Bukkit.getServer().getOnlinePlayers().forEach(player -> player.playSound(player.getLocation(), sound, volume, pitch));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setLevel(int level) {
|
|
||||||
Bukkit.getServer().getOnlinePlayers().forEach(player -> player.setLevel(level));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static FightTeam getTeamByName(String name) {
|
public static FightTeam getTeamByName(String name) {
|
||||||
if(redTeam.getName().equalsIgnoreCase(name))
|
if(redTeam.getName().equalsIgnoreCase(name))
|
||||||
return redTeam;
|
return redTeam;
|
||||||
@ -111,14 +104,6 @@ public class Fight {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void replaceSync() {
|
|
||||||
Fight.getRedTeam().replaceSync(Config.ReplaceObsidian, Material.OBSIDIAN, Material.TNT);
|
|
||||||
Fight.getBlueTeam().replaceSync(Config.ReplaceObsidian, Material.OBSIDIAN, Material.TNT);
|
|
||||||
|
|
||||||
Fight.getRedTeam().replaceSync(Config.ReplaceBedrock, Material.BEDROCK, Material.SLIME_BLOCK);
|
|
||||||
Fight.getBlueTeam().replaceSync(Config.ReplaceBedrock, Material.BEDROCK, Material.SLIME_BLOCK);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setPlayerGamemode(Player player, GameMode gameMode) {
|
public static void setPlayerGamemode(Player player, GameMode gameMode) {
|
||||||
player.setGameMode(gameMode);
|
player.setGameMode(gameMode);
|
||||||
|
|
||||||
@ -159,33 +144,26 @@ public class Fight {
|
|||||||
|
|
||||||
public static int getMaxRank(){
|
public static int getMaxRank(){
|
||||||
/* MaxRank of 0 is Pubonly*/
|
/* MaxRank of 0 is Pubonly*/
|
||||||
return schemRank;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void calcAvailibleSchemTypes() {
|
|
||||||
if(Config.OnlyPublicSchematics){
|
if(Config.OnlyPublicSchematics){
|
||||||
schemRank = 0;
|
return 0;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Config.IgnorePublicOnly || Config.event() || Config.Ranked){
|
if(Config.IgnorePublicOnly || ArenaMode.RankedEvent.contains(Config.mode)){
|
||||||
schemRank = 1000;
|
return 1000;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(redTeam.getLeader() == null || redTeam.getLeader().getPlayer() == null ||
|
|
||||||
blueTeam.getLeader() == null || blueTeam.getLeader().getPlayer() == null){
|
if(redTeam.getLeader() == null || blueTeam.getLeader() == null){
|
||||||
schemRank = 1000;
|
return 1000;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Config.RanksEnabled)
|
if(Config.RanksEnabled)
|
||||||
schemRank = Math.min(schemRank(redTeam.getLeader()), schemRank(blueTeam.getLeader()));
|
return Math.min(schemRank(redTeam.getLeader()), schemRank(blueTeam.getLeader()));
|
||||||
else if(Schematic.getSchemsOfType(redTeam.getLeader().getPlayer().getUniqueId(), Config.SchematicType).isEmpty() ||
|
else if(Schematic.getSchemsOfType(redTeam.getLeader().getPlayer().getUniqueId(), Config.SchematicType).isEmpty() ||
|
||||||
Schematic.getSchemsOfType(blueTeam.getLeader().getPlayer().getUniqueId(), Config.SchematicType).isEmpty())
|
Schematic.getSchemsOfType(blueTeam.getLeader().getPlayer().getUniqueId(), Config.SchematicType).isEmpty())
|
||||||
schemRank = 0;
|
return 0;
|
||||||
else
|
else
|
||||||
schemRank = 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int schemRank(FightPlayer fightPlayer){
|
private static int schemRank(FightPlayer fightPlayer){
|
||||||
|
@ -19,10 +19,10 @@
|
|||||||
|
|
||||||
package de.steamwar.fightsystem.fight;
|
package de.steamwar.fightsystem.fight;
|
||||||
|
|
||||||
import de.steamwar.fightsystem.FightSystem;
|
|
||||||
import de.steamwar.fightsystem.kit.KitManager;
|
|
||||||
import de.steamwar.fightsystem.Config;
|
import de.steamwar.fightsystem.Config;
|
||||||
import de.steamwar.fightsystem.kit.Kit;
|
import de.steamwar.fightsystem.countdown.EnternCountdown;
|
||||||
|
import de.steamwar.sql.PersonalKit;
|
||||||
|
import de.steamwar.sql.SteamwarUser;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class FightPlayer {
|
public class FightPlayer {
|
||||||
@ -32,22 +32,39 @@ public class FightPlayer {
|
|||||||
private boolean isOut;
|
private boolean isOut;
|
||||||
private Kit kit;
|
private Kit kit;
|
||||||
private int kills;
|
private int kills;
|
||||||
|
private EnternCountdown enternCountdown = null;
|
||||||
|
|
||||||
public void sendMessage(String message) {
|
public void sendMessage(String message) {
|
||||||
if (this.player != null && this.player.isOnline())
|
this.player.sendMessage(message);
|
||||||
this.player.sendMessage(message);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FightPlayer(Player player, FightTeam team) {
|
FightPlayer(Player player, FightTeam team) {
|
||||||
this.player = player;
|
this.player = player;
|
||||||
this.team = team;
|
this.team = team;
|
||||||
this.isOut = false;
|
this.isOut = false;
|
||||||
kit = KitManager.getKitByName(Config.MemberDefault);
|
kit = Kit.getKitByName(Config.MemberDefault);
|
||||||
|
if(Config.PersonalKits){
|
||||||
|
PersonalKit personalKit = PersonalKit.getKitInUse(SteamwarUser.get(player.getUniqueId()).getId(), Config.SchematicType.toDB());
|
||||||
|
if(personalKit != null){
|
||||||
|
kit = new Kit(personalKit);
|
||||||
|
}
|
||||||
|
}
|
||||||
kills = 0;
|
kills = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setOut() {
|
public void setOut() {
|
||||||
isOut = true;
|
isOut = true;
|
||||||
|
stopEnternCountdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEnternCountdown(EnternCountdown countdown){
|
||||||
|
enternCountdown = countdown;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void stopEnternCountdown(){
|
||||||
|
if(enternCountdown != null){
|
||||||
|
enternCountdown.disable();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Player getPlayer() {
|
public Player getPlayer() {
|
||||||
@ -84,8 +101,8 @@ public class FightPlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean canEntern(){
|
public boolean canEntern(){
|
||||||
if(Config.EnterStages.size() <= kit.getEnterStage() || kit.getEnterStage() < 0)
|
if(enternCountdown == null)
|
||||||
return false;
|
return false;
|
||||||
return Config.EnterStages.get(kit.getEnterStage()) >= FightSystem.getFightTime();
|
return enternCountdown.getTimeLeft() == 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
218
FightSystem_Main/src/de/steamwar/fightsystem/fight/FightSchematic.java
Normale Datei
218
FightSystem_Main/src/de/steamwar/fightsystem/fight/FightSchematic.java
Normale Datei
@ -0,0 +1,218 @@
|
|||||||
|
/*
|
||||||
|
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.fight;
|
||||||
|
|
||||||
|
import com.sk89q.worldedit.EditSession;
|
||||||
|
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||||
|
import de.steamwar.core.VersionedRunnable;
|
||||||
|
import de.steamwar.fightsystem.ArenaMode;
|
||||||
|
import de.steamwar.fightsystem.Config;
|
||||||
|
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.utils.ColorConverter;
|
||||||
|
import de.steamwar.fightsystem.utils.Region;
|
||||||
|
import de.steamwar.sql.NoClipboardException;
|
||||||
|
import de.steamwar.sql.Schematic;
|
||||||
|
import org.bukkit.*;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.block.*;
|
||||||
|
import org.bukkit.event.inventory.InventoryMoveItemEvent;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Random;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
public class FightSchematic extends StateDependent {
|
||||||
|
|
||||||
|
private final FightTeam team;
|
||||||
|
private final Region region;
|
||||||
|
private final boolean rotate;
|
||||||
|
|
||||||
|
private Clipboard clipboard = null;
|
||||||
|
private int schematic = 0;
|
||||||
|
|
||||||
|
public FightSchematic(FightTeam team, boolean rotate) {
|
||||||
|
super(ArenaMode.All, FightState.PostSchemSetup);
|
||||||
|
this.team = team;
|
||||||
|
this.region = team.getSchemRegion();
|
||||||
|
this.rotate = rotate;
|
||||||
|
register();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasSchematic(){
|
||||||
|
return clipboard != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getId(){
|
||||||
|
return schematic;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSchematic(Schematic schem) {
|
||||||
|
schematic = schem.getSchemID();
|
||||||
|
try {
|
||||||
|
clipboard = schem.load();
|
||||||
|
} catch (IOException e) {
|
||||||
|
team.broadcast(FightSystem.PREFIX + "§cKonnte die Schematic nicht laden!");
|
||||||
|
Bukkit.getLogger().log(Level.SEVERE, "Couldn't load Schematic " + schem.getSchemName(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void reset(){
|
||||||
|
schematic = 0;
|
||||||
|
clipboard = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void enable() {
|
||||||
|
if(FightState.getFightState() == FightState.SPECTATE)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(clipboard == null){
|
||||||
|
List<Schematic> publics = Schematic.getSchemsOfType(0, Config.SchematicType);
|
||||||
|
if(publics.isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
setSchematic(publics.get(new Random().nextInt(publics.size())));
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!ArenaMode.Test.contains(Config.mode)){
|
||||||
|
FightPlayer leader = team.getLeader();
|
||||||
|
if(leader != null)
|
||||||
|
leader.getPlayer().getInventory().clear(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(team.isBlue())
|
||||||
|
RecordSystem.blueSchem(schematic);
|
||||||
|
else
|
||||||
|
RecordSystem.redSchem(schematic);
|
||||||
|
|
||||||
|
Bukkit.getScheduler().runTask(FightSystem.getPlugin(), this::paste);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void paste(){
|
||||||
|
FreezeWorld freezer = new FreezeWorld();
|
||||||
|
DyeColor c = ColorConverter.chat2dye(team.getColor());
|
||||||
|
|
||||||
|
try {
|
||||||
|
VersionedRunnable.call(new VersionedRunnable(() -> {
|
||||||
|
try {
|
||||||
|
EditSession e = FightTeam_8.pasteSchematic(clipboard, region, rotate);
|
||||||
|
FightTeam_8.replaceTeamColor(e, c, region);
|
||||||
|
} catch (Schematic.WrongVersionException | IOException | NoClipboardException ex) {
|
||||||
|
throw new SecurityException("Error pasting arena in schematic", ex);
|
||||||
|
}
|
||||||
|
}, 8), new VersionedRunnable(() -> {
|
||||||
|
try {
|
||||||
|
EditSession e = FightTeam_8.pasteSchematic(clipboard, region, rotate);
|
||||||
|
FightTeam_12.replaceTeamColor(e, c, region);
|
||||||
|
} catch (Schematic.WrongVersionException | IOException | NoClipboardException ex) {
|
||||||
|
throw new SecurityException("Error pasting arena in schematic", ex);
|
||||||
|
}
|
||||||
|
}, 12), new VersionedRunnable(() -> {
|
||||||
|
try {
|
||||||
|
EditSession e = FightTeam_14.pasteSchematic(clipboard, region, rotate);
|
||||||
|
FightTeam_14.replaceTeamColor(e, c, region);
|
||||||
|
} catch (Schematic.WrongVersionException | IOException | NoClipboardException ex) {
|
||||||
|
throw new SecurityException("Error pasting arena in schematic", ex);
|
||||||
|
}
|
||||||
|
}, 14));
|
||||||
|
} catch (SecurityException securityException) {
|
||||||
|
team.broadcast(FightSystem.PREFIX + "§cFehler beim Pasten der Schematic");
|
||||||
|
throw securityException;
|
||||||
|
}
|
||||||
|
|
||||||
|
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> HandlerList.unregisterAll(freezer), 3);
|
||||||
|
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), team::teleportToSpawn, 40);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void disable() {
|
||||||
|
if(!Config.ReplaceObsidianBedrock)
|
||||||
|
return;
|
||||||
|
|
||||||
|
FreezeWorld freezer = null;
|
||||||
|
if(!Config.ReplaceWithBlockupdates)
|
||||||
|
freezer = new FreezeWorld();
|
||||||
|
|
||||||
|
replaceSync(Material.OBSIDIAN, Material.TNT);
|
||||||
|
replaceSync(Material.BEDROCK, Material.SLIME_BLOCK);
|
||||||
|
|
||||||
|
if(!Config.ReplaceWithBlockupdates)
|
||||||
|
HandlerList.unregisterAll(freezer);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void replaceSync(Material target, Material replacement){
|
||||||
|
World world = Bukkit.getWorlds().get(0);
|
||||||
|
|
||||||
|
region.forEach((x, y, z) -> {
|
||||||
|
Block block = world.getBlockAt(x, y, z);
|
||||||
|
if(block.getType() == target)
|
||||||
|
block.setType(replacement);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class FreezeWorld implements Listener {
|
||||||
|
private FreezeWorld(){
|
||||||
|
Bukkit.getPluginManager().registerEvents(this, IFightSystem.getPlugin());
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onBlockPhysicsEvent(BlockPhysicsEvent e){
|
||||||
|
e.setCancelled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPistonExtend(BlockPistonExtendEvent e){
|
||||||
|
e.setCancelled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPistonRetract(BlockPistonRetractEvent e){
|
||||||
|
e.setCancelled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onBlockGrow(BlockGrowEvent e){
|
||||||
|
e.setCancelled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onRedstoneEvent(BlockRedstoneEvent e){
|
||||||
|
e.setNewCurrent(e.getOldCurrent());
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onBlockDispense(BlockDispenseEvent e){
|
||||||
|
e.setCancelled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onInventoryMoveEvent(InventoryMoveItemEvent e){
|
||||||
|
e.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -19,82 +19,70 @@
|
|||||||
|
|
||||||
package de.steamwar.fightsystem.fight;
|
package de.steamwar.fightsystem.fight;
|
||||||
|
|
||||||
import com.sk89q.worldedit.EditSession;
|
|
||||||
import de.steamwar.comms.packets.TablistNamePacket;
|
import de.steamwar.comms.packets.TablistNamePacket;
|
||||||
import de.steamwar.core.VersionedRunnable;
|
import de.steamwar.core.VersionedRunnable;
|
||||||
|
import de.steamwar.fightsystem.ArenaMode;
|
||||||
import de.steamwar.fightsystem.Config;
|
import de.steamwar.fightsystem.Config;
|
||||||
import de.steamwar.fightsystem.FightSystem;
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
import de.steamwar.fightsystem.IFightSystem;
|
import de.steamwar.fightsystem.countdown.Countdown;
|
||||||
import de.steamwar.fightsystem.kit.KitManager;
|
import de.steamwar.fightsystem.listener.BasicListener;
|
||||||
import de.steamwar.fightsystem.listener.PersonalKitCreator;
|
import de.steamwar.fightsystem.listener.PersonalKitCreator;
|
||||||
import de.steamwar.fightsystem.record.RecordSystem;
|
import de.steamwar.fightsystem.record.RecordSystem;
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.utils.ColorConverter;
|
import de.steamwar.fightsystem.listener.FightScoreboard;
|
||||||
import de.steamwar.fightsystem.utils.FightScoreboard;
|
import de.steamwar.fightsystem.states.StateDependent;
|
||||||
import de.steamwar.fightsystem.utils.ItemBuilder;
|
import de.steamwar.fightsystem.utils.ItemBuilder;
|
||||||
|
import de.steamwar.fightsystem.utils.Region;
|
||||||
import de.steamwar.fightsystem.utils.TechHider;
|
import de.steamwar.fightsystem.utils.TechHider;
|
||||||
import de.steamwar.fightsystem.winconditions.RankedPlayerLeftWincondition;
|
|
||||||
import de.steamwar.inventory.SWItem;
|
import de.steamwar.inventory.SWItem;
|
||||||
import de.steamwar.sql.NoClipboardException;
|
|
||||||
import de.steamwar.sql.PersonalKit;
|
|
||||||
import de.steamwar.sql.Schematic;
|
import de.steamwar.sql.Schematic;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
import de.steamwar.sql.SteamwarUser;
|
||||||
import org.bukkit.*;
|
import org.bukkit.*;
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.HandlerList;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.event.block.*;
|
|
||||||
import org.bukkit.event.inventory.InventoryMoveItemEvent;
|
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
import org.bukkit.inventory.PlayerInventory;
|
|
||||||
import org.bukkit.scoreboard.NameTagVisibility;
|
import org.bukkit.scoreboard.NameTagVisibility;
|
||||||
import org.bukkit.scoreboard.Team;
|
import org.bukkit.scoreboard.Team;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
|
||||||
public class FightTeam implements IFightTeam{
|
public class FightTeam implements IFightTeam{
|
||||||
|
|
||||||
|
private UUID designatedLeader;
|
||||||
private FightPlayer leader;
|
private FightPlayer leader;
|
||||||
private final UUID designatedLeader;
|
|
||||||
private final Map<Player, FightPlayer> players = new HashMap<>();
|
private final Map<Player, FightPlayer> players = new HashMap<>();
|
||||||
private boolean ready;
|
|
||||||
private final Set<Player> invited = new HashSet<>();
|
private final Set<Player> invited = new HashSet<>();
|
||||||
|
|
||||||
private final String name;
|
private final String name;
|
||||||
private final String prefix;
|
private final String prefix;
|
||||||
private final ChatColor color;
|
private final ChatColor color;
|
||||||
private int schematic = 0;
|
private final FightSchematic schematic;
|
||||||
private final Team team;
|
private final Team team;
|
||||||
private final boolean blue;
|
private final boolean blue;
|
||||||
|
|
||||||
private final Location spawn;
|
private boolean ready;
|
||||||
private final int pasteX;
|
private boolean skip;
|
||||||
private final int pasteY;
|
|
||||||
private final int pasteZ;
|
|
||||||
private final int cornerX;
|
|
||||||
private final int cornerY;
|
|
||||||
private final int cornerZ;
|
|
||||||
private final boolean rotate;
|
|
||||||
|
|
||||||
public FightTeam(String name, String prefix, Location spawn, int cornerX, int cornerY, int cornerZ, boolean rotate, boolean blue, UUID designatedLeader) {
|
private final Location spawn;
|
||||||
|
private final Region schemRegion;
|
||||||
|
private final Region extendRegion;
|
||||||
|
|
||||||
|
public FightTeam(String name, String prefix, Location spawn, Region schemRegion, Region extendRegion, boolean rotate, boolean blue, UUID designatedLeader) {
|
||||||
this.spawn = spawn;
|
this.spawn = spawn;
|
||||||
this.pasteX = cornerX + Config.SchemsizeX/2;
|
this.schemRegion = schemRegion;
|
||||||
this.pasteY = cornerY;
|
this.extendRegion = extendRegion;
|
||||||
this.pasteZ = cornerZ + Config.SchemsizeZ/2;
|
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.prefix = prefix;
|
this.prefix = prefix;
|
||||||
this.ready = false;
|
this.ready = false;
|
||||||
this.rotate = rotate;
|
this.skip = false;
|
||||||
this.cornerX = cornerX;
|
|
||||||
this.cornerY = cornerY;
|
|
||||||
this.cornerZ = cornerZ;
|
|
||||||
this.blue = blue;
|
this.blue = blue;
|
||||||
this.designatedLeader = designatedLeader;
|
this.designatedLeader = designatedLeader;
|
||||||
color = ChatColor.getByChar(ChatColor.getLastColors(prefix).replace("§", ""));
|
this.color = ChatColor.getByChar(ChatColor.getLastColors(prefix).replace("§", ""));
|
||||||
|
this.schematic = new FightSchematic(this, rotate);
|
||||||
|
new KitLoader();
|
||||||
|
new SpectateHandler();
|
||||||
|
|
||||||
if(FightScoreboard.getScoreboard().getTeam(name) == null)
|
if(FightScoreboard.getScoreboard().getTeam(name) == null)
|
||||||
team = FightScoreboard.getScoreboard().registerNewTeam(name);
|
team = FightScoreboard.getScoreboard().registerNewTeam(name);
|
||||||
else
|
else
|
||||||
@ -106,20 +94,16 @@ public class FightTeam implements IFightTeam{
|
|||||||
team.setAllowFriendlyFire(false);
|
team.setAllowFriendlyFire(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final int getCornerX() {
|
public Region getSchemRegion() {
|
||||||
return cornerX;
|
return schemRegion;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final int getCornerY() {
|
public Region getExtendRegion() {
|
||||||
return cornerY;
|
return extendRegion;
|
||||||
}
|
|
||||||
|
|
||||||
public final int getCornerZ() {
|
|
||||||
return cornerZ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canbeLeader(Player p){
|
public boolean canbeLeader(Player p){
|
||||||
return !hasTeamLeader() && (designatedLeader == null || designatedLeader.equals(p.getUniqueId()));
|
return isLeaderless() && (designatedLeader == null || designatedLeader.equals(p.getUniqueId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void teleportToSpawn(){
|
public void teleportToSpawn(){
|
||||||
@ -155,11 +139,44 @@ public class FightTeam implements IFightTeam{
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void reset(){
|
||||||
|
skip = false;
|
||||||
|
ready = false;
|
||||||
|
schematic.reset();
|
||||||
|
invited.clear();
|
||||||
|
|
||||||
|
Set<Player> playerSet = new HashSet<>(players.keySet());
|
||||||
|
for(Player player : playerSet){
|
||||||
|
if(!Bukkit.getOnlinePlayers().contains(player))
|
||||||
|
removePlayer(player);
|
||||||
|
}
|
||||||
|
FightPlayer leaderBackup = leader;
|
||||||
|
playerSet.removeIf(player -> !Bukkit.getOnlinePlayers().contains(player));
|
||||||
|
players.clear();
|
||||||
|
leader = null;
|
||||||
|
|
||||||
|
if(leaderBackup != null){
|
||||||
|
playerSet.remove(leaderBackup.getPlayer());
|
||||||
|
addMember(leaderBackup.getPlayer());
|
||||||
|
}
|
||||||
|
|
||||||
|
playerSet.forEach(this::addMember);
|
||||||
|
|
||||||
|
if(isLeaderless()){
|
||||||
|
for(Player player : Bukkit.getOnlinePlayers()){
|
||||||
|
if(Fight.getPlayerTeam(player) == null && canbeLeader(player)){
|
||||||
|
addMember(player);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void broadcast(String message) {
|
public void broadcast(String message) {
|
||||||
players.forEach((player, fp) -> player.sendMessage(message));
|
players.forEach((player, fp) -> player.sendMessage(message));
|
||||||
}
|
}
|
||||||
|
|
||||||
public FightPlayer addMember(Player player) {
|
public void addMember(Player player) {
|
||||||
final List<TechHider.ChunkPos> chunksToReload = TechHider.prepareChunkReload(player);
|
final List<TechHider.ChunkPos> chunksToReload = TechHider.prepareChunkReload(player);
|
||||||
FightPlayer fightPlayer = new FightPlayer(player, this);
|
FightPlayer fightPlayer = new FightPlayer(player, this);
|
||||||
players.put(player, fightPlayer);
|
players.put(player, fightPlayer);
|
||||||
@ -167,40 +184,47 @@ public class FightTeam implements IFightTeam{
|
|||||||
team.addEntry(player.getName());
|
team.addEntry(player.getName());
|
||||||
|
|
||||||
Fight.setPlayerGamemode(player, GameMode.SURVIVAL);
|
Fight.setPlayerGamemode(player, GameMode.SURVIVAL);
|
||||||
|
player.setHealth(20);
|
||||||
|
player.setFoodLevel(20);
|
||||||
|
player.getInventory().clear();
|
||||||
|
BasicListener.setAttackSpeed(player);
|
||||||
player.teleport(spawn);
|
player.teleport(spawn);
|
||||||
if(KitManager.getKits(false).size() > 1 || Config.PersonalKits)
|
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(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());
|
player.getInventory().setItem(7, new ItemBuilder(Material.BEACON).removeAllAttributs().setDisplayName("§eRespawn").build());
|
||||||
if(!Config.test())
|
if(!Config.test())
|
||||||
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> new TablistNamePacket(SteamwarUser.get(player.getUniqueId()).getId(), prefix + player.getName()).send(player), 5);
|
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);
|
TechHider.reloadChunks(player, chunksToReload);
|
||||||
return fightPlayer;
|
|
||||||
|
if(isLeaderless())
|
||||||
|
setLeader(fightPlayer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removePlayer(Player player) {
|
public void removePlayer(Player player) {
|
||||||
FightPlayer fightPlayer = getFightPlayer(player);
|
FightPlayer fightPlayer = getFightPlayer(player);
|
||||||
|
|
||||||
final List<TechHider.ChunkPos> chunksToReload = TechHider.prepareChunkReload(player);
|
List<TechHider.ChunkPos> chunksToReload = TechHider.prepareChunkReload(player);
|
||||||
players.remove(player);
|
players.remove(player);
|
||||||
team.removeEntry(player.getName());
|
team.removeEntry(player.getName());
|
||||||
fightPlayer.getPlayer().getInventory().clear();
|
|
||||||
|
|
||||||
if(fightPlayer.equals(leader) && FightSystem.getFightState().setup())
|
if(fightPlayer.equals(leader))
|
||||||
setLeader(null);
|
setLeader(null);
|
||||||
|
|
||||||
|
RecordSystem.entityDespawns(player);
|
||||||
Fight.setPlayerGamemode(player, GameMode.SPECTATOR);
|
Fight.setPlayerGamemode(player, GameMode.SPECTATOR);
|
||||||
player.teleport(Config.SpecSpawn);
|
player.teleport(Config.SpecSpawn);
|
||||||
if(!Config.test())
|
player.getInventory().clear();
|
||||||
new TablistNamePacket(SteamwarUser.get(player.getUniqueId()).getId(), "§7" + player.getName()).send(player);
|
|
||||||
if(Config.recording())
|
if(player.isOnline()){
|
||||||
RecordSystem.entityDespawns(player);
|
if(!ArenaMode.Test.contains(Config.mode))
|
||||||
TechHider.reloadChunks(player, chunksToReload);
|
new TablistNamePacket(SteamwarUser.get(player.getUniqueId()).getId(), "§7" + player.getName()).send(player);
|
||||||
|
TechHider.reloadChunks(player, chunksToReload);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasTeamLeader() {
|
public boolean isLeaderless() {
|
||||||
return leader != null;
|
return leader == null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -212,43 +236,48 @@ public class FightTeam implements IFightTeam{
|
|||||||
return leader;
|
return leader;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLeader(FightPlayer leader) {
|
private void setLeader(FightPlayer leader) {
|
||||||
if (leader == null){
|
if (leader == null) {
|
||||||
|
this.leader = null;
|
||||||
if(!players.isEmpty()) {
|
if(!players.isEmpty()) {
|
||||||
setLeader(players.values().iterator().next());
|
setLeader(players.values().iterator().next());
|
||||||
Bukkit.broadcastMessage(FightSystem.PREFIX + "§aDer Spieler §e" + this.leader.getPlayer().getName() + " §aist nun Leader von Team " + getColoredName() + "§a!");
|
Bukkit.broadcastMessage(FightSystem.PREFIX + "§aDer Spieler §e" + this.leader.getPlayer().getName() + " §aist nun Leader von Team " + getColoredName() + "§a!");
|
||||||
}else if(Config.Ranked){
|
}else if(FightState.getFightState() != FightState.PRE_LEADER_SETUP && !ArenaMode.RankedEvent.contains(Config.mode)){
|
||||||
RankedPlayerLeftWincondition.leaderQuit(this);
|
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), FightSystem::setPreLeaderState, 1);
|
||||||
}else if(!Config.event()){
|
|
||||||
FightSystem.shutdown(FightSystem.PREFIX + "§cTeam " + getColoredName() + " §chat keine Spieler mehr.\n Arena schließt...");
|
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!PersonalKitCreator.notInKitCreator(leader.getPlayer()))
|
PersonalKitCreator.closeIfInKitCreator(leader.getPlayer());
|
||||||
leader.getPlayer().closeInventory();
|
|
||||||
|
|
||||||
this.leader = leader;
|
this.leader = leader;
|
||||||
|
designatedLeader = null;
|
||||||
if(ready)
|
if(ready)
|
||||||
setReady(false);
|
setReady(false);
|
||||||
|
|
||||||
leader.setKit(KitManager.getKitByName(Config.LeaderDefault));
|
if(!Config.PersonalKits)
|
||||||
|
leader.setKit(Kit.getKitByName(Config.LeaderDefault));
|
||||||
|
|
||||||
Inventory inventory = leader.getPlayer().getInventory();
|
Inventory inventory = leader.getPlayer().getInventory();
|
||||||
if (KitManager.getKits(true).size() > 1)
|
if (Kit.getAvailableKits(true).size() > 1)
|
||||||
inventory.setItem(1, new ItemBuilder(Material.LEATHER_CHESTPLATE).removeAllAttributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName("§eKit wählen").build());
|
inventory.setItem(1, new ItemBuilder(Material.LEATHER_CHESTPLATE).removeAllAttributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName("§eKit wählen").build());
|
||||||
else if(Config.PersonalKits)
|
else if(Config.PersonalKits)
|
||||||
inventory.setItem(1, new ItemBuilder(Material.LEATHER_CHESTPLATE).removeAllAttributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName("§eKit bearbeiten").build());
|
inventory.setItem(1, new ItemBuilder(Material.LEATHER_CHESTPLATE).removeAllAttributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName("§eKit bearbeiten").build());
|
||||||
else
|
else
|
||||||
inventory.setItem(1, new ItemBuilder(Material.AIR).build());
|
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(2, new ItemBuilder(Material.PAPER).removeAllAttributs().setDisplayName("§eSpieler einladen").build());
|
||||||
inventory.setItem(3, new ItemBuilder(SWItem.getMaterial("FIREWORK_CHARGE")).removeAllAttributs().setDisplayName("§cSpieler rauswerfen").build());
|
inventory.setItem(3, new ItemBuilder(SWItem.getMaterial("FIREWORK_CHARGE")).removeAllAttributs().setDisplayName("§cSpieler rauswerfen").build());
|
||||||
}
|
}
|
||||||
|
|
||||||
inventory.setItem(4, new ItemBuilder(SWItem.getDye(10), (short) 10).removeAllAttributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName("§cNicht bereit").build());
|
inventory.setItem(4, new ItemBuilder(SWItem.getDye(10), (short) 10).removeAllAttributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName("§cNicht bereit").build());
|
||||||
|
|
||||||
if(Config.test() || FightSystem.getFightState() != FightState.POST_SCHEM_SETUP)
|
if(Config.test() || FightState.getFightState() != FightState.POST_SCHEM_SETUP)
|
||||||
inventory.setItem(0, new ItemBuilder(SWItem.getMaterial("CAULDRON_ITEM")).removeAllAttributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName("§e" + Config.GameName + " wählen").build());
|
inventory.setItem(0, new ItemBuilder(SWItem.getMaterial("CAULDRON_ITEM")).removeAllAttributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName("§e" + Config.GameName + " wählen").build());
|
||||||
|
|
||||||
|
if(FightState.getFightState() == FightState.PRE_LEADER_SETUP && !Fight.getOpposite(this).isLeaderless()){
|
||||||
|
FightSystem.setPreSchemState();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Collection<FightPlayer> getPlayers() {
|
public Collection<FightPlayer> getPlayers() {
|
||||||
@ -259,89 +288,29 @@ public class FightTeam implements IFightTeam{
|
|||||||
return ready;
|
return ready;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void pasteSchematic(){
|
public void pasteSchem(Schematic schematic){
|
||||||
if(Config.recording()){
|
setSchem(schematic);
|
||||||
if(blue)
|
|
||||||
RecordSystem.blueSchem(schematic);
|
|
||||||
else
|
|
||||||
RecordSystem.redSchem(schematic);
|
|
||||||
}
|
|
||||||
|
|
||||||
FreezeWorld freezer = new FreezeWorld();
|
|
||||||
DyeColor c = ColorConverter.chat2dye(color);
|
|
||||||
Schematic schem;
|
|
||||||
try{
|
|
||||||
schem = Schematic.getSchemFromDB(this.schematic);
|
|
||||||
}catch(SecurityException e){
|
|
||||||
pasteDummy();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
VersionedRunnable.call(new VersionedRunnable(() -> {
|
|
||||||
try {
|
|
||||||
EditSession e = FightTeam_8.pasteSchematic(schem, pasteX, pasteY, pasteZ, rotate);
|
|
||||||
FightTeam_8.replaceTeamColor(e, c, cornerX, cornerY, cornerZ);
|
|
||||||
} catch (Schematic.WrongVersionException | IOException | NoClipboardException ex) {
|
|
||||||
throw new SecurityException("Error pasting arena in schematic", ex);
|
|
||||||
}
|
|
||||||
}, 8), new VersionedRunnable(() -> {
|
|
||||||
try {
|
|
||||||
EditSession e = FightTeam_8.pasteSchematic(schem, pasteX, pasteY, pasteZ, rotate);
|
|
||||||
FightTeam_12.replaceTeamColor(e, c, cornerX, cornerY, cornerZ);
|
|
||||||
} catch (Schematic.WrongVersionException | IOException | NoClipboardException ex) {
|
|
||||||
throw new SecurityException("Error pasting arena in schematic", ex);
|
|
||||||
}
|
|
||||||
}, 12), new VersionedRunnable(() -> {
|
|
||||||
try {
|
|
||||||
EditSession e = FightTeam_14.pasteSchematic(schem, pasteX, pasteY, pasteZ, rotate);
|
|
||||||
FightTeam_14.replaceTeamColor(e, c, cornerX, cornerY, cornerZ);
|
|
||||||
} catch (Schematic.WrongVersionException | IOException | NoClipboardException ex) {
|
|
||||||
throw new SecurityException("Error pasting arena in schematic", ex);
|
|
||||||
}
|
|
||||||
}, 14));
|
|
||||||
} catch (SecurityException securityException) {
|
|
||||||
broadcast(FightSystem.PREFIX + "§cFehler beim Pasten der Schematic");
|
|
||||||
throw securityException;
|
|
||||||
}
|
|
||||||
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> HandlerList.unregisterAll(freezer), 3);
|
|
||||||
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), this::teleportToSpawn,40);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void pasteDummy(){
|
|
||||||
List<Schematic> publics = Schematic.getSchemsOfType(0, Config.SchematicType);
|
|
||||||
if(publics.isEmpty())
|
|
||||||
return;
|
|
||||||
|
|
||||||
schematic = publics.get(new Random().nextInt(publics.size())).getSchemID();
|
|
||||||
pasteSchematic();
|
|
||||||
|
|
||||||
if(!Config.test() && leader != null)
|
|
||||||
leader.getPlayer().getInventory().clear(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSchematic(Schematic schematic){
|
|
||||||
this.schematic = schematic.getSchemID();
|
|
||||||
broadcast(FightSystem.PREFIX + "§7Das §e" + Config.GameName + " " + schematic.getSchemName() + " §7wird für den Kampf verwendet!");
|
|
||||||
|
|
||||||
if(!Config.test())
|
|
||||||
leader.getPlayer().getInventory().clear(0);
|
|
||||||
|
|
||||||
if(Config.test())
|
if(Config.test())
|
||||||
pasteSchematic();
|
this.schematic.enable();
|
||||||
else if(Fight.getOpposite(this).hasSchematic()){
|
else if(Fight.getOpposite(this).hasSchematic()){
|
||||||
FightSystem.setPostSchemState();
|
FightSystem.setPostSchemState();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setSchem(Schematic schematic){
|
||||||
|
this.schematic.setSchematic(schematic);
|
||||||
|
broadcast(FightSystem.PREFIX + "§7Das §e" + Config.GameName + " " + schematic.getSchemName() + " §7wird für den Kampf verwendet!");
|
||||||
|
}
|
||||||
|
|
||||||
public boolean hasSchematic(){
|
public boolean hasSchematic(){
|
||||||
return schematic != 0;
|
return schematic.hasSchematic();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setReady(boolean ready) {
|
public void setReady(boolean ready) {
|
||||||
Player l = leader.getPlayer();
|
Player l = leader.getPlayer();
|
||||||
|
|
||||||
if(schematic == 0){
|
if(!schematic.hasSchematic()){
|
||||||
l.sendMessage(FightSystem.PREFIX + "§cZuerst muss eine Schematic gewählt sein!");
|
l.sendMessage(FightSystem.PREFIX + "§cZuerst muss eine Schematic gewählt sein!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -358,6 +327,18 @@ public class FightTeam implements IFightTeam{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void skip(){
|
||||||
|
this.skip = !skip;
|
||||||
|
if(skip){
|
||||||
|
broadcast(FightSystem.PREFIX + "§aEuer Team ist nun bereit, zum nächsten Event zu beschleunigen!");
|
||||||
|
if(Fight.getOpposite(this).skip || Config.test()){
|
||||||
|
Countdown.skip();
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
broadcast(FightSystem.PREFIX + "§cEuer Team ist nicht mehr bereit, zum nächsten Event zu beschleunigen!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public Set<Player> getInvited() {
|
public Set<Player> getInvited() {
|
||||||
return invited;
|
return invited;
|
||||||
}
|
}
|
||||||
@ -375,7 +356,7 @@ public class FightTeam implements IFightTeam{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int getSchematic() {
|
public int getSchematic() {
|
||||||
return schematic;
|
return schematic.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Location getSpawn() {
|
public Location getSpawn() {
|
||||||
@ -397,51 +378,6 @@ public class FightTeam implements IFightTeam{
|
|||||||
return currentHearts / maximumHearts;
|
return currentHearts / maximumHearts;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadKits(){
|
|
||||||
for(FightPlayer fightPlayer : players.values()) {
|
|
||||||
if(fightPlayer.getPlayer() == null)
|
|
||||||
continue;
|
|
||||||
fightPlayer.getPlayer().getInventory().clear();
|
|
||||||
|
|
||||||
PersonalKit personalKit = null;
|
|
||||||
if(Config.PersonalKits)
|
|
||||||
personalKit = PersonalKit.getKitInUse(SteamwarUser.get(fightPlayer.getPlayer().getUniqueId()).getId(), Config.SchematicType.toDB());
|
|
||||||
|
|
||||||
if(personalKit != null){
|
|
||||||
PlayerInventory inventory = fightPlayer.getPlayer().getInventory();
|
|
||||||
inventory.setContents(personalKit.getInventory());
|
|
||||||
inventory.setArmorContents(personalKit.getArmor());
|
|
||||||
}else if(fightPlayer.getKit() != null)
|
|
||||||
fightPlayer.getKit().loadToPlayer(fightPlayer.getPlayer());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void replaceSync(boolean replace, Material target, Material replacement) {
|
|
||||||
if(!replace)
|
|
||||||
return;
|
|
||||||
|
|
||||||
World world = Bukkit.getWorlds().get(0);
|
|
||||||
Location minPoint = new Location(world, cornerX, cornerY, cornerZ);
|
|
||||||
Location maxPoint = new Location(world, (cornerX + Config.SchemsizeX), (cornerY + Config.SchemsizeY), (cornerZ + Config.SchemsizeZ));
|
|
||||||
|
|
||||||
FreezeWorld freezer = null;
|
|
||||||
if(!Config.ReplaceWithBlockupdates)
|
|
||||||
freezer = new FreezeWorld();
|
|
||||||
|
|
||||||
for(int x = minPoint.getBlockX(); x <= maxPoint.getBlockX(); x++) {
|
|
||||||
for(int z = minPoint.getBlockZ(); z <= maxPoint.getBlockZ(); z++) {
|
|
||||||
for(int y = minPoint.getBlockY(); y <= maxPoint.getBlockY(); y++) {
|
|
||||||
Block block = world.getBlockAt(x, y, z);
|
|
||||||
if(block.getType() == target)
|
|
||||||
block.setType(replacement);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!Config.ReplaceWithBlockupdates)
|
|
||||||
HandlerList.unregisterAll(freezer);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setTeamColor(Team team, ChatColor color){
|
private void setTeamColor(Team team, ChatColor color){
|
||||||
VersionedRunnable.call(new VersionedRunnable(() -> FightTeam_8.setTeamColor(team, color), 8),
|
VersionedRunnable.call(new VersionedRunnable(() -> FightTeam_8.setTeamColor(team, color), 8),
|
||||||
new VersionedRunnable(() -> FightTeam_9.setTeamColor(team, color), 9),
|
new VersionedRunnable(() -> FightTeam_9.setTeamColor(team, color), 9),
|
||||||
@ -449,44 +385,48 @@ public class FightTeam implements IFightTeam{
|
|||||||
new VersionedRunnable(() -> FightTeam_14.setTeamColor(team, color), 14));
|
new VersionedRunnable(() -> FightTeam_14.setTeamColor(team, color), 14));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class FreezeWorld implements Listener {
|
public ChatColor getColor() {
|
||||||
private FreezeWorld(){
|
return color;
|
||||||
Bukkit.getPluginManager().registerEvents(this, IFightSystem.getPlugin());
|
}
|
||||||
|
|
||||||
|
private class KitLoader extends StateDependent {
|
||||||
|
private KitLoader() {
|
||||||
|
super(ArenaMode.All, FightState.Ingame);
|
||||||
|
register();
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@Override
|
||||||
public void onBlockPhysicsEvent(BlockPhysicsEvent e){
|
public void enable() {
|
||||||
e.setCancelled(true);
|
for(FightPlayer fightPlayer : players.values()) {
|
||||||
|
Player player = fightPlayer.getPlayer();
|
||||||
|
PersonalKitCreator.closeIfInKitCreator(player);
|
||||||
|
|
||||||
|
player.getInventory().clear();
|
||||||
|
Fight.setPlayerGamemode(player, GameMode.SURVIVAL);
|
||||||
|
fightPlayer.getKit().loadToPlayer(player);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@Override
|
||||||
public void onPistonExtend(BlockPistonExtendEvent e){
|
public void disable() {
|
||||||
e.setCancelled(true);
|
players.values().forEach(fightPlayer -> fightPlayer.getPlayer().getInventory().clear());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class SpectateHandler extends StateDependent {
|
||||||
|
private SpectateHandler() {
|
||||||
|
super(ArenaMode.All, FightState.Spectate);
|
||||||
|
register();
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@Override
|
||||||
public void onPistonRetract(BlockPistonRetractEvent e){
|
public void enable() {
|
||||||
e.setCancelled(true);
|
players.values().forEach(fightPlayer -> Fight.setPlayerGamemode(fightPlayer.getPlayer(), GameMode.SPECTATOR));
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@Override
|
||||||
public void onBlockGrow(BlockGrowEvent e){
|
public void disable() {
|
||||||
e.setCancelled(true);
|
players.values().forEach(fightPlayer -> Fight.setPlayerGamemode(fightPlayer.getPlayer(), GameMode.SURVIVAL));
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onRedstoneEvent(BlockRedstoneEvent e){
|
|
||||||
e.setNewCurrent(e.getOldCurrent());
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onBlockDispense(BlockDispenseEvent e){
|
|
||||||
e.setCancelled(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onInventoryMoveEvent(InventoryMoveItemEvent e){
|
|
||||||
e.setCancelled(true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
62
FightSystem_Main/src/de/steamwar/fightsystem/fight/FightWorld.java
Normale Datei
62
FightSystem_Main/src/de/steamwar/fightsystem/fight/FightWorld.java
Normale Datei
@ -0,0 +1,62 @@
|
|||||||
|
/*
|
||||||
|
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.fight;
|
||||||
|
|
||||||
|
import de.steamwar.core.VersionedRunnable;
|
||||||
|
import de.steamwar.fightsystem.ArenaMode;
|
||||||
|
import de.steamwar.fightsystem.Config;
|
||||||
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
|
import de.steamwar.fightsystem.states.StateDependent;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.WorldCreator;
|
||||||
|
|
||||||
|
public class FightWorld extends StateDependent {
|
||||||
|
|
||||||
|
private final World world = Bukkit.getWorlds().get(0);
|
||||||
|
|
||||||
|
public FightWorld() {
|
||||||
|
super(ArenaMode.Restartable, FightState.Schem);
|
||||||
|
register();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void enable() {
|
||||||
|
//unused
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void disable() {
|
||||||
|
World backup = new WorldCreator(world.getName() + "/backup").createWorld();
|
||||||
|
assert backup != null;
|
||||||
|
Config.ArenaRegion.forEachChunk((x, z) -> resetChunk(backup, x, z));
|
||||||
|
Bukkit.unloadWorld(backup, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void resetChunk(World backup, int x, int z){
|
||||||
|
VersionedRunnable.call(
|
||||||
|
new VersionedRunnable(() -> FightWorld_8.resetChunk(world, backup, x, z), 8),
|
||||||
|
new VersionedRunnable(() -> FightWorld_9.resetChunk(world, backup, x, z), 9),
|
||||||
|
new VersionedRunnable(() -> FightWorld_10.resetChunk(world, backup, x, z), 10),
|
||||||
|
new VersionedRunnable(() -> FightWorld_12.resetChunk(world, backup, x, z), 12),
|
||||||
|
new VersionedRunnable(() -> FightWorld_14.resetChunk(world, backup, x, z), 14),
|
||||||
|
new VersionedRunnable(() -> FightWorld_15.resetChunk(world, backup, x, z), 15));
|
||||||
|
}
|
||||||
|
}
|
349
FightSystem_Main/src/de/steamwar/fightsystem/fight/Kit.java
Normale Datei
349
FightSystem_Main/src/de/steamwar/fightsystem/fight/Kit.java
Normale Datei
@ -0,0 +1,349 @@
|
|||||||
|
/*
|
||||||
|
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.fight;
|
||||||
|
|
||||||
|
import de.steamwar.core.Core;
|
||||||
|
import de.steamwar.core.VersionedCallable;
|
||||||
|
import de.steamwar.fightsystem.Config;
|
||||||
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
|
import de.steamwar.fightsystem.commands.Commands;
|
||||||
|
import de.steamwar.fightsystem.commands.GUI;
|
||||||
|
import de.steamwar.fightsystem.listener.*;
|
||||||
|
import de.steamwar.inventory.SWInventory;
|
||||||
|
import de.steamwar.inventory.SWItem;
|
||||||
|
import de.steamwar.sql.PersonalKit;
|
||||||
|
import de.steamwar.sql.SteamwarUser;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
import org.bukkit.enchantments.Enchantment;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.BlockDataMeta;
|
||||||
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
import org.bukkit.potion.PotionEffect;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
public class Kit {
|
||||||
|
private static final File kits = new File(FightSystem.getPlugin().getDataFolder(), Config.KitFile);
|
||||||
|
private static final ArrayList<Kit> loadedKits = new ArrayList<>();
|
||||||
|
|
||||||
|
static {
|
||||||
|
if(!kits.exists()) {
|
||||||
|
Bukkit.getLogger().log(Level.SEVERE, "Kitconfig fehlend!");
|
||||||
|
}
|
||||||
|
|
||||||
|
FileConfiguration kitData = YamlConfiguration.loadConfiguration(kits);
|
||||||
|
ConfigurationSection kitSection = kitData.getConfigurationSection("Kits");
|
||||||
|
|
||||||
|
for(String key : Objects.requireNonNull(kitSection).getKeys(false)) {
|
||||||
|
loadedKits.add(new Kit(Objects.requireNonNull(kitSection.getConfigurationSection(key))));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private final String name;
|
||||||
|
private final ItemStack[] inventory;
|
||||||
|
private final ItemStack[] armor;
|
||||||
|
private final Collection<PotionEffect> effects;
|
||||||
|
private final int enterStage;
|
||||||
|
private final boolean tnt;
|
||||||
|
private final boolean leaderAllowed;
|
||||||
|
private final boolean memberAllowed;
|
||||||
|
|
||||||
|
public Kit(String name, Player player) {
|
||||||
|
this.name = name;
|
||||||
|
this.inventory = player.getInventory().getContents();
|
||||||
|
this.armor = player.getInventory().getArmorContents();
|
||||||
|
this.effects = player.getActivePotionEffects();
|
||||||
|
this.leaderAllowed = true;
|
||||||
|
this.memberAllowed = true;
|
||||||
|
this.enterStage = 0;
|
||||||
|
this.tnt = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Kit(ConfigurationSection kit){
|
||||||
|
name = kit.getName();
|
||||||
|
inventory = Objects.requireNonNull(kit.getList("Items")).toArray(new ItemStack[0]);
|
||||||
|
if(kit.isList("Armor"))
|
||||||
|
armor = Objects.requireNonNull(kit.getList("Armor")).toArray(new ItemStack[0]);
|
||||||
|
else
|
||||||
|
armor = null;
|
||||||
|
leaderAllowed = kit.getBoolean("LeaderAllowed");
|
||||||
|
memberAllowed = kit.getBoolean("MemberAllowed");
|
||||||
|
if(kit.isList("Effects"))
|
||||||
|
effects = (List<PotionEffect>) kit.getList("Effects");
|
||||||
|
else
|
||||||
|
effects = null;
|
||||||
|
enterStage = kit.getInt("EnterStage", 0);
|
||||||
|
tnt = kit.getBoolean("TNT", true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Kit(PersonalKit kit){
|
||||||
|
this.name = kit.getName();
|
||||||
|
this.inventory = kit.getInventory();
|
||||||
|
this.armor = kit.getArmor();
|
||||||
|
this.effects = Collections.emptyList();
|
||||||
|
this.leaderAllowed = true;
|
||||||
|
this.memberAllowed = true;
|
||||||
|
this.enterStage = 0;
|
||||||
|
this.tnt = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Kit getKitByName(String kitName) {
|
||||||
|
for(Kit kit : loadedKits) {
|
||||||
|
if(kit.getName().equalsIgnoreCase(kitName))
|
||||||
|
return kit;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<Kit> getAvailableKits(boolean leader){
|
||||||
|
List<Kit> kits = new ArrayList<>();
|
||||||
|
for (Kit k : loadedKits) {
|
||||||
|
if (k.canUseKit(leader)){
|
||||||
|
kits.add(k);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return kits;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canUseKit(boolean leader){
|
||||||
|
if (leader) {
|
||||||
|
return leaderAllowed;
|
||||||
|
} else {
|
||||||
|
return memberAllowed;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean leaderExclusive() {
|
||||||
|
return !memberAllowed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemStack[] getInventory() {
|
||||||
|
return inventory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemStack[] getArmor() {
|
||||||
|
return armor;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Is this kit allowed to set/handle tnt? */
|
||||||
|
public boolean isTnt(){
|
||||||
|
return tnt;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* In which stage is entern allowed? */
|
||||||
|
public int getEnterStage() {
|
||||||
|
return enterStage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void toPersonalKit(PersonalKit kit) {
|
||||||
|
kit.setContainer(inventory, armor);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeBadItems(){
|
||||||
|
Kit normal = Kit.getKitByName(Config.MemberDefault);
|
||||||
|
assert normal != null;
|
||||||
|
|
||||||
|
for(int i = 0; i < inventory.length; i++){
|
||||||
|
if(isBadItem(inventory[i]))
|
||||||
|
inventory[i] = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isBadItem(ItemStack stack){
|
||||||
|
if(stack == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
//Check for forbidden item
|
||||||
|
if(Config.ForbiddenItems.contains(stack.getType().name()))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
//Check for attribute modifiers
|
||||||
|
if(Core.getVersion() >= 14 && PersonalKitCreator_14.hasAttributeModifier(stack)){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(stack.hasItemMeta()){
|
||||||
|
ItemMeta meta = stack.getItemMeta();
|
||||||
|
if(meta instanceof BlockDataMeta && ((BlockDataMeta)meta).hasBlockData())
|
||||||
|
return true; //Blocks always upwards slabs etc.
|
||||||
|
|
||||||
|
if(VersionedCallable.call(new VersionedCallable<>(() -> PersonalKitCreator_8.hasItems(stack), 8),
|
||||||
|
new VersionedCallable<>(() -> PersonalKitCreator_9.hasItems(stack), 9),
|
||||||
|
new VersionedCallable<>(() -> PersonalKitCreator_10.hasItems(stack), 10),
|
||||||
|
new VersionedCallable<>(() -> PersonalKitCreator_12.hasItems(stack), 12),
|
||||||
|
new VersionedCallable<>(() -> PersonalKitCreator_14.hasItems(stack), 14),
|
||||||
|
new VersionedCallable<>(() -> PersonalKitCreator_15.hasItems(stack), 15)))
|
||||||
|
return true; //Blocks prefilled inventories
|
||||||
|
}
|
||||||
|
|
||||||
|
Kit normal = Kit.getKitByName(Config.MemberDefault);
|
||||||
|
assert normal != null;
|
||||||
|
return !normal.isEnchantmentInKit(stack) && !stack.getEnchantments().isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isEnchantmentInKit(ItemStack stack){
|
||||||
|
for(ItemStack is : inventory){
|
||||||
|
if(similar(stack, is))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if(armor != null){
|
||||||
|
for(ItemStack is : armor){
|
||||||
|
if(similar(stack, is))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean similar(ItemStack stack, ItemStack stack2){
|
||||||
|
if(stack == null || stack2 == null)
|
||||||
|
return false;
|
||||||
|
if(stack.getType() != stack2.getType())
|
||||||
|
return false;
|
||||||
|
if(stack.hasItemMeta() != stack2.hasItemMeta())
|
||||||
|
return false;
|
||||||
|
if(stack.getItemMeta() == null || stack2.getItemMeta() == null)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
//Enchantment Map comparison used for default similarity check does not work
|
||||||
|
Map<Enchantment, Integer> en = stack.getItemMeta().getEnchants();
|
||||||
|
Map<Enchantment, Integer> en2 = new HashMap<>(stack.getItemMeta().getEnchants());
|
||||||
|
|
||||||
|
for(Map.Entry<Enchantment, Integer> e : en.entrySet()){
|
||||||
|
if(!en2.remove(e.getKey(), e.getValue()))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return en2.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void loadToPlayer(Player player) {
|
||||||
|
player.getInventory().setContents(inventory);
|
||||||
|
if(armor != null)
|
||||||
|
player.getInventory().setArmorContents(armor);
|
||||||
|
player.updateInventory();
|
||||||
|
if(effects != null)
|
||||||
|
player.addPotionEffects(effects);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Opens a kit preview with the options to go back to kit selection or to select the kit.
|
||||||
|
*/
|
||||||
|
public void preview(Player player){
|
||||||
|
SWInventory inv = new SWInventory(player, 54, name);
|
||||||
|
|
||||||
|
//36 = Inventargröße
|
||||||
|
for(int i = 0; i < 36; i++){
|
||||||
|
if(inventory[i] == null)
|
||||||
|
continue;
|
||||||
|
SWItem item = new SWItem();
|
||||||
|
item.setItemStack(inventory[i]);
|
||||||
|
inv.setItem(i, item);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(armor != null){
|
||||||
|
for(int i = 0; i < 4; i++){
|
||||||
|
if(armor[i] == null)
|
||||||
|
continue;
|
||||||
|
SWItem item = new SWItem();
|
||||||
|
item.setItemStack(armor[i]);
|
||||||
|
inv.setItem(36 + i, item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(effects != null){
|
||||||
|
Iterator<PotionEffect> it = effects.iterator();
|
||||||
|
int pos = 44;
|
||||||
|
while(it.hasNext()){
|
||||||
|
PotionEffect effect = it.next();
|
||||||
|
SWItem item = new SWItem(SWItem.getMaterial("POTION"), effect.getType().getName());
|
||||||
|
inv.setItem(pos, item);
|
||||||
|
pos--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inv.setCallback(-999, click -> player.closeInventory());
|
||||||
|
if(Config.PersonalKits){
|
||||||
|
inv.setItem(49, SWItem.getMaterial("WOOD_AXE"), "§7Kit bearbeiten", clickType -> PersonalKitCreator.openKitCreator(player, PersonalKit.get(SteamwarUser.get(player.getUniqueId()).getId(), Config.SchematicType.toDB(), name)));
|
||||||
|
inv.setItem(53, Material.BARRIER, "§cKit löschen", clickType -> {
|
||||||
|
player.closeInventory();
|
||||||
|
SWInventory conf = new SWInventory(player, 9, "Kit wirklich löchen?");
|
||||||
|
conf.setItem(8, SWItem.getDye(1), "§cAbbrechen", click -> player.closeInventory());
|
||||||
|
conf.setItem(0, SWItem.getDye(10), "§aLöschen", click -> {
|
||||||
|
player.closeInventory();
|
||||||
|
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||||
|
PersonalKit kit = PersonalKit.get(user.getId(), Config.SchematicType.toDB(), name);
|
||||||
|
if(kit.isInUse()) {
|
||||||
|
List<PersonalKit> kits = PersonalKit.get(user.getId(), Config.SchematicType.toDB());
|
||||||
|
if(!kits.isEmpty()){
|
||||||
|
PersonalKit kit1 = kits.get(0);
|
||||||
|
kit1.setInUse();
|
||||||
|
FightPlayer fightPlayer = Fight.getFightPlayer(player);
|
||||||
|
assert fightPlayer != null;
|
||||||
|
fightPlayer.setKit(new Kit(kit1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
kit.delete();
|
||||||
|
});
|
||||||
|
conf.open();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
inv.setItem(45, SWItem.getDye(10), (byte)10, "§aKit wählen", click -> {
|
||||||
|
Commands.kit(player, name);
|
||||||
|
player.closeInventory();
|
||||||
|
});
|
||||||
|
inv.setItem(53, SWItem.getDye(1), (byte)1, "§cZurück", click -> GUI.kitSelection(player, ""));
|
||||||
|
inv.open();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void createKit(String kitName, Player player){
|
||||||
|
loadedKits.add(new Kit(kitName, player));
|
||||||
|
YamlConfiguration yamlConfiguration = new YamlConfiguration();
|
||||||
|
for(Kit k : loadedKits){
|
||||||
|
ConfigurationSection section = yamlConfiguration.createSection("Kits." + k.getName());
|
||||||
|
section.set("Items", k.inventory);
|
||||||
|
if(k.armor != null)
|
||||||
|
section.set("Armor", k.armor);
|
||||||
|
section.set("LeaderAllowed", k.leaderAllowed);
|
||||||
|
section.set("MemberAllowed", k.memberAllowed);
|
||||||
|
section.set("Effects", k.effects);
|
||||||
|
section.set("EnterStage", k.enterStage);
|
||||||
|
section.set("TNT", k.tnt);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
yamlConfiguration.save(kits);
|
||||||
|
}catch(IOException e){
|
||||||
|
throw new SecurityException("Failed to save kits.data", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,207 +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.kit;
|
|
||||||
|
|
||||||
import de.steamwar.fightsystem.commands.Commands;
|
|
||||||
import de.steamwar.fightsystem.commands.GUI;
|
|
||||||
import de.steamwar.inventory.SWInventory;
|
|
||||||
import de.steamwar.inventory.SWItem;
|
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
|
||||||
import org.bukkit.enchantments.Enchantment;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
import org.bukkit.potion.PotionEffect;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
public class Kit {
|
|
||||||
|
|
||||||
private final String name;
|
|
||||||
private final boolean leaderAllowed;
|
|
||||||
private final boolean memberAllowed;
|
|
||||||
private final ItemStack[] inventory;
|
|
||||||
private final ItemStack[] armor;
|
|
||||||
private final Collection<PotionEffect> effects;
|
|
||||||
private final int enterStage;
|
|
||||||
private final boolean tnt;
|
|
||||||
|
|
||||||
Kit(String name, Player player) {
|
|
||||||
this.name = name;
|
|
||||||
this.leaderAllowed = true;
|
|
||||||
this.memberAllowed = true;
|
|
||||||
this.inventory = player.getInventory().getContents();
|
|
||||||
this.armor = player.getInventory().getArmorContents();
|
|
||||||
this.effects = player.getActivePotionEffects();
|
|
||||||
this.enterStage = 0;
|
|
||||||
this.tnt = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
Kit(ConfigurationSection kit){
|
|
||||||
name = kit.getName();
|
|
||||||
inventory = Objects.requireNonNull(kit.getList("Items")).toArray(new ItemStack[0]);
|
|
||||||
if(kit.isList("Armor"))
|
|
||||||
armor = Objects.requireNonNull(kit.getList("Armor")).toArray(new ItemStack[0]);
|
|
||||||
else
|
|
||||||
armor = null;
|
|
||||||
leaderAllowed = kit.getBoolean("LeaderAllowed");
|
|
||||||
memberAllowed = kit.getBoolean("MemberAllowed");
|
|
||||||
if(kit.isList("Effects"))
|
|
||||||
effects = (Collection<PotionEffect>) kit.getList("Effects");
|
|
||||||
else
|
|
||||||
effects = null;
|
|
||||||
enterStage = kit.getInt("EnterStage", 0);
|
|
||||||
tnt = kit.getBoolean("TNT", true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isLeaderAllowed() {
|
|
||||||
return leaderAllowed;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isMemberAllowed() {
|
|
||||||
return memberAllowed;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ItemStack[] getInventory() {
|
|
||||||
return inventory;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ItemStack[] getArmor() {
|
|
||||||
return armor;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Is this kit allowed to set/handle tnt? */
|
|
||||||
public boolean isTnt(){
|
|
||||||
return tnt;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* In which stage is entern allowed? */
|
|
||||||
public int getEnterStage() {
|
|
||||||
return enterStage;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isEnchantmentInKit(ItemStack stack){
|
|
||||||
for(ItemStack is : inventory){
|
|
||||||
if(similar(stack, is))
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if(armor != null){
|
|
||||||
for(ItemStack is : armor){
|
|
||||||
if(similar(stack, is))
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean similar(ItemStack stack, ItemStack stack2){
|
|
||||||
if(stack == null || stack2 == null)
|
|
||||||
return false;
|
|
||||||
if(stack.getType() != stack2.getType())
|
|
||||||
return false;
|
|
||||||
if(stack.hasItemMeta() != stack2.hasItemMeta())
|
|
||||||
return false;
|
|
||||||
if(stack.getItemMeta() == null || stack2.getItemMeta() == null)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
//Enchantment Map comparison used for default similarity check does not work
|
|
||||||
Map<Enchantment, Integer> en = stack.getItemMeta().getEnchants();
|
|
||||||
Map<Enchantment, Integer> en2 = new HashMap<>(stack.getItemMeta().getEnchants());
|
|
||||||
|
|
||||||
for(Map.Entry<Enchantment, Integer> e : en.entrySet()){
|
|
||||||
if(!en2.remove(e.getKey(), e.getValue()))
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return en2.isEmpty();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void loadToPlayer(Player player) {
|
|
||||||
player.getInventory().setContents(inventory);
|
|
||||||
if(armor != null)
|
|
||||||
player.getInventory().setArmorContents(armor);
|
|
||||||
player.updateInventory();
|
|
||||||
if(effects != null)
|
|
||||||
player.addPotionEffects(effects);
|
|
||||||
}
|
|
||||||
|
|
||||||
void saveKit(ConfigurationSection section){
|
|
||||||
section.set("Items", inventory);
|
|
||||||
if(armor != null)
|
|
||||||
section.set("Armor", armor);
|
|
||||||
section.set("LeaderAllowed", leaderAllowed);
|
|
||||||
section.set("MemberAllowed", memberAllowed);
|
|
||||||
section.set("Effects", effects);
|
|
||||||
section.set("EnterStage", enterStage);
|
|
||||||
section.set("TNT", tnt);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Opens a kit preview with the options to go back to kit selection or to select the kit.
|
|
||||||
* @param player
|
|
||||||
*/
|
|
||||||
public void preview(Player player){
|
|
||||||
SWInventory inv = new SWInventory(player, 54, name);
|
|
||||||
|
|
||||||
preview(inv, inventory, armor, effects);
|
|
||||||
|
|
||||||
inv.setCallback(-999, (click) -> player.closeInventory());
|
|
||||||
inv.setItem(45, SWItem.getDye(10), (byte)10, "§aKit wählen", (click) -> {
|
|
||||||
Commands.kit(player, name);
|
|
||||||
player.closeInventory();
|
|
||||||
});
|
|
||||||
inv.setItem(53, SWItem.getDye(1), (byte)1, "§cZurück", (click) -> GUI.kitSelection(player));
|
|
||||||
inv.open();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void preview(SWInventory inv, ItemStack[] inventory, ItemStack[] armor, Collection<PotionEffect> effects) {
|
|
||||||
//36 = Inventargröße
|
|
||||||
for(int i = 0; i < 36; i++){
|
|
||||||
if(inventory[i] == null)
|
|
||||||
continue;
|
|
||||||
SWItem item = new SWItem();
|
|
||||||
item.setItemStack(inventory[i]);
|
|
||||||
inv.setItem(i, item);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(armor != null){
|
|
||||||
for(int i = 0; i < 4; i++){
|
|
||||||
if(armor[i] == null)
|
|
||||||
continue;
|
|
||||||
SWItem item = new SWItem();
|
|
||||||
item.setItemStack(armor[i]);
|
|
||||||
inv.setItem(36 + i, item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(effects != null){
|
|
||||||
Iterator<PotionEffect> it = effects.iterator();
|
|
||||||
int pos = 44;
|
|
||||||
while(it.hasNext()){
|
|
||||||
PotionEffect effect = it.next();
|
|
||||||
SWItem item = new SWItem(SWItem.getMaterial("POTION"), effect.getType().getName());
|
|
||||||
inv.setItem(pos, item);
|
|
||||||
pos--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,97 +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.kit;
|
|
||||||
|
|
||||||
import de.steamwar.fightsystem.Config;
|
|
||||||
import de.steamwar.fightsystem.FightSystem;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
|
|
||||||
public class KitManager {
|
|
||||||
private KitManager(){}
|
|
||||||
|
|
||||||
private static final File kits = new File(FightSystem.getPlugin().getDataFolder(), Config.KitFile);
|
|
||||||
private static final FileConfiguration kitData = YamlConfiguration.loadConfiguration(kits);
|
|
||||||
|
|
||||||
private static final ArrayList<Kit> loadedKits = new ArrayList<>();
|
|
||||||
|
|
||||||
public static void saveInventory(String kitName, Player player){
|
|
||||||
loadedKits.add(new Kit(kitName, player));
|
|
||||||
saveAllKits();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Kit getKitByName(String kitName) {
|
|
||||||
for(Kit kit : loadedKits) {
|
|
||||||
if(kit.getName().equalsIgnoreCase(kitName))
|
|
||||||
return kit;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<Kit> getKits(boolean leader){
|
|
||||||
List<Kit> kits = new ArrayList<>();
|
|
||||||
if(leader){
|
|
||||||
for (Kit k : loadedKits)
|
|
||||||
if (k.isLeaderAllowed())
|
|
||||||
kits.add(k);
|
|
||||||
}else{
|
|
||||||
for (Kit k : loadedKits)
|
|
||||||
if (k.isMemberAllowed())
|
|
||||||
kits.add(k);
|
|
||||||
}
|
|
||||||
return kits;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void loadAllKits() {
|
|
||||||
if(!kits.exists()) {
|
|
||||||
saveAllKits();
|
|
||||||
Bukkit.getLogger().log(Level.SEVERE, "kit config fehlend!");
|
|
||||||
FightSystem.shutdown(null);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(kitData.getConfigurationSection("Kits") != null) {
|
|
||||||
for(String key : kitData.getConfigurationSection("Kits").getKeys(false)) {
|
|
||||||
loadedKits.add(new Kit(kitData.getConfigurationSection("Kits." + key)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void saveAllKits(){
|
|
||||||
YamlConfiguration yamlConfiguration = new YamlConfiguration();
|
|
||||||
for(Kit k : loadedKits)
|
|
||||||
k.saveKit(yamlConfiguration.createSection("Kits." + k.getName()));
|
|
||||||
|
|
||||||
try {
|
|
||||||
yamlConfiguration.save(kits);
|
|
||||||
}catch(IOException e){
|
|
||||||
throw new SecurityException("Failed to save kits.data", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -0,0 +1,72 @@
|
|||||||
|
/*
|
||||||
|
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.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;
|
||||||
|
|
||||||
|
public class ArenaBorder implements Listener {
|
||||||
|
|
||||||
|
public ArenaBorder() {
|
||||||
|
new StateDependentListener(ArenaMode.All, FightState.All, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void arenaBorder(PlayerMoveEvent event){
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
Location to = event.getTo();
|
||||||
|
assert to != null;
|
||||||
|
|
||||||
|
if(!Config.ArenaRegion.in2dRegion(to)){
|
||||||
|
reset(event);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
FightTeam team = Fight.getPlayerTeam(player);
|
||||||
|
if(team == null || player.getGameMode() == GameMode.SPECTATOR)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(to.getY() <= Config.ArenaRegion.getMinY()) {
|
||||||
|
if(FightState.infight())
|
||||||
|
player.damage(2);
|
||||||
|
else if(!Config.GroundWalkable)
|
||||||
|
player.teleport(team.getSpawn());
|
||||||
|
}else if(to.getY() + 1.8 > Config.ArenaRegion.getMaxY()){
|
||||||
|
reset(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void reset(PlayerMoveEvent event){
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
player.teleport(event.getFrom());
|
||||||
|
BasicListener.toActionbar(player, TextComponent.fromLegacyText("§cDu darfst die Arena nicht verlassen"));
|
||||||
|
}
|
||||||
|
}
|
@ -19,22 +19,16 @@
|
|||||||
|
|
||||||
package de.steamwar.fightsystem.listener;
|
package de.steamwar.fightsystem.listener;
|
||||||
|
|
||||||
|
import de.steamwar.core.Core;
|
||||||
|
import de.steamwar.fightsystem.ArenaMode;
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.utils.WaterRemover;
|
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
|
||||||
|
|
||||||
import java.util.EnumSet;
|
public class ArrowPickup {
|
||||||
|
|
||||||
public class EntityExplodeListener extends BasicListener {
|
public ArrowPickup() {
|
||||||
|
if(Core.getVersion() > 8){
|
||||||
public EntityExplodeListener() {
|
new StateDependentListener(ArenaMode.All, FightState.All, new PickupArrowListener_9());
|
||||||
super(EnumSet.of(FightState.RUNNING));
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void handleEntityExplode(EntityExplodeEvent event) {
|
|
||||||
event.setYield(0); //No drops (additionally to world config)
|
|
||||||
WaterRemover.add(event.blockList());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -20,27 +20,27 @@
|
|||||||
package de.steamwar.fightsystem.listener;
|
package de.steamwar.fightsystem.listener;
|
||||||
|
|
||||||
import de.steamwar.fightsystem.Config;
|
import de.steamwar.fightsystem.Config;
|
||||||
import de.steamwar.fightsystem.FightSystem;
|
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
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.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.entity.Arrow;
|
import org.bukkit.entity.Arrow;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.projectiles.ProjectileSource;
|
import org.bukkit.projectiles.ProjectileSource;
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
|
||||||
import org.bukkit.util.Vector;
|
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 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};
|
private static final BlockFace[] BLOCK_FACES = {BlockFace.UP, BlockFace.DOWN, BlockFace.EAST, BlockFace.WEST, BlockFace.NORTH, BlockFace.SOUTH};
|
||||||
|
|
||||||
public ArrowStopper() {
|
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() {
|
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) {
|
private boolean checkBlocks(Block start, Block end) {
|
||||||
Block cursor = start;
|
Block cursor = start;
|
||||||
|
|
||||||
@ -97,7 +85,7 @@ public class ArrowStopper extends BasicListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean checkBlock(Block block) {
|
private boolean checkBlock(Block block) {
|
||||||
return Config.HiddenBlockTags.contains(block.getType().name());
|
return Config.HiddenBlocks.contains(block.getType().name());
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean invalidEntity(Arrow entity) {
|
private boolean invalidEntity(Arrow entity) {
|
||||||
|
@ -20,28 +20,14 @@
|
|||||||
package de.steamwar.fightsystem.listener;
|
package de.steamwar.fightsystem.listener;
|
||||||
|
|
||||||
import de.steamwar.core.VersionedRunnable;
|
import de.steamwar.core.VersionedRunnable;
|
||||||
import de.steamwar.fightsystem.FightSystem;
|
|
||||||
import de.steamwar.fightsystem.fight.Fight;
|
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 net.md_5.bungee.api.chat.BaseComponent;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.entity.Player;
|
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 {
|
public static boolean notFighting(Player p){
|
||||||
|
|
||||||
private final Set<FightState> enabled;
|
|
||||||
|
|
||||||
BasicListener(Set<FightState> enabled){
|
|
||||||
this.enabled = enabled;
|
|
||||||
FightSystem.registerStateDependent(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean notFighting(Player p){
|
|
||||||
return Fight.getFightPlayer(p) == null;
|
return Fight.getFightPlayer(p) == null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,22 +41,7 @@ public abstract class BasicListener implements Listener, StateDependent {
|
|||||||
new VersionedRunnable(() -> BasicListener_9.toChat(player, components), 9));
|
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));
|
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;
|
package de.steamwar.fightsystem.listener;
|
||||||
|
|
||||||
|
import de.steamwar.fightsystem.ArenaMode;
|
||||||
import de.steamwar.fightsystem.Config;
|
import de.steamwar.fightsystem.Config;
|
||||||
import de.steamwar.fightsystem.FightSystem;
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
import de.steamwar.fightsystem.fight.Fight;
|
import de.steamwar.fightsystem.fight.Fight;
|
||||||
import de.steamwar.fightsystem.fight.FightTeam;
|
import de.steamwar.fightsystem.fight.FightTeam;
|
||||||
import de.steamwar.fightsystem.record.RecordSystem;
|
import de.steamwar.fightsystem.record.RecordSystem;
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
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.BaseComponent;
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||||
|
|
||||||
import java.util.EnumSet;
|
public class Chat implements Listener {
|
||||||
|
|
||||||
public class PlayerChatListener extends BasicListener {
|
public Chat(){
|
||||||
|
new StateDependentListener(ArenaMode.All, FightState.All, this);
|
||||||
public PlayerChatListener(){
|
|
||||||
super(EnumSet.allOf(FightState.class));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@ -63,10 +64,9 @@ public class PlayerChatListener extends BasicListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void broadcastChat(String message) {
|
private void broadcastChat(String message) {
|
||||||
if (Config.recording())
|
RecordSystem.chat(message);
|
||||||
RecordSystem.chat(message);
|
|
||||||
BaseComponent[] msg = TextComponent.fromLegacyText(message);
|
BaseComponent[] msg = TextComponent.fromLegacyText(message);
|
||||||
for(Player p : Bukkit.getOnlinePlayers())
|
for(Player p : Bukkit.getOnlinePlayers())
|
||||||
toChat(p, msg);
|
BasicListener.toChat(p, msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -19,24 +19,26 @@
|
|||||||
|
|
||||||
package de.steamwar.fightsystem.listener;
|
package de.steamwar.fightsystem.listener;
|
||||||
|
|
||||||
|
import de.steamwar.fightsystem.ArenaMode;
|
||||||
import de.steamwar.fightsystem.Config;
|
import de.steamwar.fightsystem.Config;
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
|
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||||
import de.steamwar.sql.Schematic;
|
import de.steamwar.sql.Schematic;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
import de.steamwar.sql.SteamwarUser;
|
||||||
import de.steamwar.sql.UserGroup;
|
import de.steamwar.sql.UserGroup;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
|
|
||||||
import java.util.EnumSet;
|
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class CheckListener extends BasicListener {
|
public class Check implements Listener {
|
||||||
|
|
||||||
public CheckListener() {
|
public Check() {
|
||||||
super(Config.check() ? EnumSet.allOf(FightState.class) : EnumSet.noneOf(FightState.class));
|
new StateDependentListener(ArenaMode.Check, FightState.All, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@ -66,7 +68,7 @@ public class CheckListener extends BasicListener {
|
|||||||
Bukkit.getLogger().log(Level.SEVERE, player.getName() + " tried to use a copy command!");
|
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 ||
|
return user.getUserGroup() == UserGroup.Supporter ||
|
||||||
user.getUserGroup() == UserGroup.Developer ||
|
user.getUserGroup() == UserGroup.Developer ||
|
||||||
user.getUserGroup() == UserGroup.Moderator ||
|
user.getUserGroup() == UserGroup.Moderator ||
|
@ -19,40 +19,40 @@
|
|||||||
|
|
||||||
package de.steamwar.fightsystem.listener;
|
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.FightState;
|
||||||
|
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.block.BlockBreakEvent;
|
import org.bukkit.event.block.BlockBreakEvent;
|
||||||
import org.bukkit.event.block.BlockPlaceEvent;
|
import org.bukkit.event.block.BlockPlaceEvent;
|
||||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||||
|
import org.bukkit.event.entity.ProjectileLaunchEvent;
|
||||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
import org.bukkit.event.inventory.InventoryDragEvent;
|
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 org.bukkit.event.player.PlayerKickEvent;
|
||||||
|
|
||||||
import java.util.EnumSet;
|
public class DenyWorldInteraction implements Listener {
|
||||||
|
|
||||||
public class FreezeWorldStateListener extends BasicListener {
|
public DenyWorldInteraction() {
|
||||||
|
new StateDependentListener(ArenaMode.Test, FightState.PreRunning, this);
|
||||||
public FreezeWorldStateListener() {
|
new StateDependentListener(ArenaMode.AntiTest, FightState.AntiRunning, this);
|
||||||
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));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void handleBlockBreak(BlockBreakEvent event) {
|
public void handleBlockBreak(BlockBreakEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
event.setCancelled(true);
|
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
|
@EventHandler
|
||||||
public void handleBlockPlace(BlockPlaceEvent event) {
|
public void handleBlockPlace(BlockPlaceEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
event.setCancelled(true);
|
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
|
@EventHandler
|
||||||
@ -60,18 +60,18 @@ public class FreezeWorldStateListener extends BasicListener {
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onInventoryClick(InventoryClickEvent event) {
|
|
||||||
if(PersonalKitCreator.notInKitCreator(event.getWhoClicked()))
|
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void handlePlayerKickEvent(PlayerKickEvent e){
|
public void handlePlayerKickEvent(PlayerKickEvent e){
|
||||||
if(e.getReason().contains("Flying is not enabled"))
|
if(e.getReason().contains("Flying is not enabled"))
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onInventoryClick(InventoryClickEvent event) {
|
||||||
|
if(PersonalKitCreator.notInKitCreator(event.getWhoClicked()))
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onInventoryDrag(InventoryDragEvent event) {
|
public void onInventoryDrag(InventoryDragEvent event) {
|
||||||
if(PersonalKitCreator.notInKitCreator(event.getWhoClicked()))
|
if(PersonalKitCreator.notInKitCreator(event.getWhoClicked()))
|
||||||
@ -79,12 +79,11 @@ public class FreezeWorldStateListener extends BasicListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onDropPickup(InventoryPickupItemEvent e){
|
public void handleProjectileLaunch(ProjectileLaunchEvent event) {
|
||||||
e.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
if(event.getEntity().getShooter() instanceof Player){
|
||||||
|
Player player = (Player) event.getEntity().getShooter();
|
||||||
@EventHandler
|
BasicListener.toActionbar(player, TextComponent.fromLegacyText("§cDu darfst den Bogen erst nach Kampfbeginn nutzen!"));
|
||||||
public void onDropping(PlayerDropItemEvent e){
|
}
|
||||||
e.setCancelled(true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -19,17 +19,18 @@
|
|||||||
|
|
||||||
package de.steamwar.fightsystem.listener;
|
package de.steamwar.fightsystem.listener;
|
||||||
|
|
||||||
|
import de.steamwar.fightsystem.ArenaMode;
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
|
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||||
import org.bukkit.event.entity.EntityDamageEvent;
|
import org.bukkit.event.entity.EntityDamageEvent;
|
||||||
|
|
||||||
import java.util.EnumSet;
|
public class EntityDamage implements Listener {
|
||||||
|
|
||||||
public class EntityDamageListener extends BasicListener {
|
public EntityDamage() {
|
||||||
|
new StateDependentListener(ArenaMode.All, FightState.AntiRunning, this);
|
||||||
public EntityDamageListener() {
|
|
||||||
super(EnumSet.of(FightState.PRE_LEADER_SETUP, FightState.PRE_SCHEM_SETUP, FightState.POST_SCHEM_SETUP, FightState.PRE_RUNNING, FightState.SPECTATE));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
@ -19,25 +19,25 @@
|
|||||||
|
|
||||||
package de.steamwar.fightsystem.listener;
|
package de.steamwar.fightsystem.listener;
|
||||||
|
|
||||||
|
import de.steamwar.fightsystem.ArenaMode;
|
||||||
import de.steamwar.fightsystem.Config;
|
import de.steamwar.fightsystem.Config;
|
||||||
import de.steamwar.fightsystem.FightSystem;
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
import de.steamwar.fightsystem.fight.Fight;
|
import de.steamwar.fightsystem.fight.Fight;
|
||||||
import de.steamwar.fightsystem.fight.FightPlayer;
|
|
||||||
import de.steamwar.fightsystem.fight.FightTeam;
|
import de.steamwar.fightsystem.fight.FightTeam;
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
|
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
import de.steamwar.sql.SteamwarUser;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
import org.bukkit.event.player.PlayerLoginEvent;
|
import org.bukkit.event.player.PlayerLoginEvent;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
|
||||||
import java.util.EnumSet;
|
public class EventJoin implements Listener {
|
||||||
|
|
||||||
public class EventJoinListener extends BasicListener {
|
public EventJoin() {
|
||||||
|
new StateDependentListener(ArenaMode.Event, FightState.All, this);
|
||||||
public EventJoinListener() {
|
|
||||||
super(Config.event() ? EnumSet.of(FightState.PRE_LEADER_SETUP, FightState.PRE_SCHEM_SETUP, FightState.POST_SCHEM_SETUP) : EnumSet.noneOf(FightState.class));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@ -60,29 +60,29 @@ public class EventJoinListener extends BasicListener {
|
|||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||||
|
|
||||||
FightTeam team = null;
|
if(FightState.Setup.contains(FightState.getFightState())){
|
||||||
if(user.getTeam() == Config.EventTeamBlueID)
|
FightTeam team = null;
|
||||||
team = Fight.getBlueTeam();
|
if(user.getTeam() == Config.EventTeamBlueID)
|
||||||
else if(user.getTeam() == Config.EventTeamRedID)
|
|
||||||
team = Fight.getRedTeam();
|
|
||||||
|
|
||||||
if(Config.BothTeamsPublic){
|
|
||||||
if(Fight.getRedTeam().getPlayers().size() < Fight.getBlueTeam().getPlayers().size())
|
|
||||||
team = Fight.getRedTeam();
|
|
||||||
else
|
|
||||||
team = Fight.getBlueTeam();
|
team = Fight.getBlueTeam();
|
||||||
}else if(team == null){
|
else if(user.getTeam() == Config.EventTeamRedID)
|
||||||
if(Config.EventTeamRedID == 0)
|
|
||||||
team = Fight.getRedTeam();
|
team = Fight.getRedTeam();
|
||||||
else if(Config.EventTeamBlueID == 0)
|
|
||||||
team = Fight.getBlueTeam();
|
|
||||||
}
|
|
||||||
|
|
||||||
if(team != null && team.getPlayers().size() < Config.MaximumTeamMembers){
|
if(Config.BothTeamsPublic){
|
||||||
FightPlayer fp = team.addMember(player);
|
if(Fight.getRedTeam().getPlayers().size() < Fight.getBlueTeam().getPlayers().size())
|
||||||
if(!team.hasTeamLeader())
|
team = Fight.getRedTeam();
|
||||||
team.setLeader(fp);
|
else
|
||||||
return;
|
team = Fight.getBlueTeam();
|
||||||
|
}else if(team == null){
|
||||||
|
if(Config.EventTeamRedID == 0)
|
||||||
|
team = Fight.getRedTeam();
|
||||||
|
else if(Config.EventTeamBlueID == 0)
|
||||||
|
team = Fight.getBlueTeam();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(team != null && team.getPlayers().size() < Config.MaximumTeamMembers){
|
||||||
|
team.addMember(player);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(user.getId() == FightSystem.getEventFight().getKampfleiter()){
|
if(user.getId() == FightSystem.getEventFight().getKampfleiter()){
|
@ -0,0 +1,142 @@
|
|||||||
|
/*
|
||||||
|
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.core.TPSWatcher;
|
||||||
|
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.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.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 implements Listener {
|
||||||
|
|
||||||
|
private static final Set<FightState> fullScoreboard = EnumSet.of(FightState.RUNNING, FightState.SPECTATE);
|
||||||
|
|
||||||
|
private int index = 0;
|
||||||
|
private String title = "";
|
||||||
|
private final HashMap<String, Integer> scores = new HashMap<>();
|
||||||
|
|
||||||
|
public static Scoreboard getScoreboard() {
|
||||||
|
return Objects.requireNonNull(Bukkit.getScoreboardManager()).getMainScoreboard();
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getTitle() {
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||||
|
SWScoreboard.removeScoreboard(event.getPlayer());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void teamScoreboard(FightTeam fightTeam){
|
||||||
|
setTitle(fightTeam.getColoredName());
|
||||||
|
fightTeam.getPlayers().forEach(fp -> {
|
||||||
|
if(fp.isLiving())
|
||||||
|
addScore(fightTeam.getPrefix() + fp.getPlayer().getName(), (int) Math.ceil(fp.getPlayer().getHealth()));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void generalScoreboard(){
|
||||||
|
setTitle("§eKampf");
|
||||||
|
List<String> scoreList = new ArrayList<>();
|
||||||
|
|
||||||
|
Countdown timeOverCountdown = Wincondition.getTimeOverCountdown();
|
||||||
|
if(timeOverCountdown != null){
|
||||||
|
int fightTime = timeOverCountdown.getTimeLeft();
|
||||||
|
if (fightTime >= 60)
|
||||||
|
scoreList.add("§7Zeit: §a" + fightTime / 60 + "m " + fightTime % 60 + "s");
|
||||||
|
else
|
||||||
|
scoreList.add("§7Zeit: §a" + fightTime + "s");
|
||||||
|
}
|
||||||
|
|
||||||
|
scoreList.add("§7TPS: §e" + TPSWatcher.getTPS());
|
||||||
|
|
||||||
|
if(fullScoreboard.contains(FightState.getFightState())){
|
||||||
|
for(PrintableWincondition wincondition : Wincondition.getPrintableWinconditions()){
|
||||||
|
scoreList.add(wincondition.getDisplay(Fight.getRedTeam()));
|
||||||
|
scoreList.add(wincondition.getDisplay(Fight.getBlueTeam()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int value = scoreList.size();
|
||||||
|
for(String score : scoreList){
|
||||||
|
addScore(score, value--);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void nextIndexDisplay() {
|
||||||
|
index++;
|
||||||
|
if(index > 2)
|
||||||
|
index = 0;
|
||||||
|
FightTeam team = null;
|
||||||
|
if(index == 1)
|
||||||
|
team = Fight.getRedTeam();
|
||||||
|
if(index == 2)
|
||||||
|
team = Fight.getBlueTeam();
|
||||||
|
scores.clear();
|
||||||
|
if(team != null)
|
||||||
|
teamScoreboard(team);
|
||||||
|
else
|
||||||
|
generalScoreboard();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setTitle(String t) {
|
||||||
|
title = t;
|
||||||
|
RecordSystem.scoreboardTitle(t);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addScore(String string, int i) {
|
||||||
|
scores.put(string, i);
|
||||||
|
RecordSystem.scoreboardData(string, i);
|
||||||
|
}
|
||||||
|
}
|
@ -19,22 +19,23 @@
|
|||||||
|
|
||||||
package de.steamwar.fightsystem.listener;
|
package de.steamwar.fightsystem.listener;
|
||||||
|
|
||||||
|
import de.steamwar.fightsystem.ArenaMode;
|
||||||
import de.steamwar.fightsystem.Config;
|
import de.steamwar.fightsystem.Config;
|
||||||
import de.steamwar.fightsystem.commands.GUI;
|
import de.steamwar.fightsystem.commands.GUI;
|
||||||
import de.steamwar.fightsystem.fight.Fight;
|
import de.steamwar.fightsystem.fight.Fight;
|
||||||
import de.steamwar.fightsystem.fight.FightTeam;
|
import de.steamwar.fightsystem.fight.FightTeam;
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
|
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
import java.util.EnumSet;
|
public class HotbarGUI implements Listener {
|
||||||
|
|
||||||
public class HotbarGUIListener extends BasicListener {
|
public HotbarGUI() {
|
||||||
|
new StateDependentListener(ArenaMode.All, FightState.Setup, this);
|
||||||
public HotbarGUIListener() {
|
|
||||||
super(EnumSet.of(FightState.PRE_LEADER_SETUP, FightState.PRE_SCHEM_SETUP, FightState.POST_SCHEM_SETUP));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@ -78,7 +79,7 @@ public class HotbarGUIListener extends BasicListener {
|
|||||||
break;
|
break;
|
||||||
case "§eKit bearbeiten":
|
case "§eKit bearbeiten":
|
||||||
case "§eKit wählen":
|
case "§eKit wählen":
|
||||||
GUI.kitSelection(player);
|
GUI.kitSelection(player, "");
|
||||||
break;
|
break;
|
||||||
case "§eRespawn":
|
case "§eRespawn":
|
||||||
player.teleport(fightTeam.getSpawn());
|
player.teleport(fightTeam.getSpawn());
|
@ -19,22 +19,24 @@
|
|||||||
|
|
||||||
package de.steamwar.fightsystem.listener;
|
package de.steamwar.fightsystem.listener;
|
||||||
|
|
||||||
|
import de.steamwar.fightsystem.ArenaMode;
|
||||||
import de.steamwar.fightsystem.fight.Fight;
|
import de.steamwar.fightsystem.fight.Fight;
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
|
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
import org.bukkit.entity.Arrow;
|
import org.bukkit.entity.Arrow;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||||
import org.bukkit.event.entity.EntityDamageEvent;
|
import org.bukkit.event.entity.EntityDamageEvent;
|
||||||
|
|
||||||
import java.util.EnumSet;
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
public class InFightDamageListener extends BasicListener {
|
public class InFightDamage implements Listener {
|
||||||
|
|
||||||
public InFightDamageListener() {
|
public InFightDamage() {
|
||||||
super(EnumSet.of(FightState.RUNNING));
|
new StateDependentListener(ArenaMode.All, FightState.Running, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@ -42,7 +44,7 @@ public class InFightDamageListener extends BasicListener {
|
|||||||
if(!(event.getEntity() instanceof Player))
|
if(!(event.getEntity() instanceof Player))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(notFighting((Player)event.getEntity()))
|
if(BasicListener.notFighting((Player)event.getEntity()))
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,7 +71,7 @@ public class InFightDamageListener extends BasicListener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(notFighting(damager)){
|
if(BasicListener.notFighting(damager)){
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
//Damager is not fighting
|
//Damager is not fighting
|
||||||
return;
|
return;
|
||||||
@ -81,7 +83,7 @@ public class InFightDamageListener extends BasicListener {
|
|||||||
event.getDamager().setFireTicks(0);
|
event.getDamager().setFireTicks(0);
|
||||||
player.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){
|
if(player.getHealth() - event.getFinalDamage() <= 0){
|
@ -19,28 +19,27 @@
|
|||||||
|
|
||||||
package de.steamwar.fightsystem.listener;
|
package de.steamwar.fightsystem.listener;
|
||||||
|
|
||||||
|
import de.steamwar.fightsystem.ArenaMode;
|
||||||
import de.steamwar.fightsystem.fight.Fight;
|
import de.steamwar.fightsystem.fight.Fight;
|
||||||
import de.steamwar.fightsystem.fight.FightPlayer;
|
import de.steamwar.fightsystem.fight.FightPlayer;
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
|
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.block.BlockBreakEvent;
|
import org.bukkit.event.block.BlockBreakEvent;
|
||||||
import org.bukkit.event.block.BlockPlaceEvent;
|
import org.bukkit.event.block.BlockPlaceEvent;
|
||||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
import org.bukkit.event.inventory.InventoryDragEvent;
|
import org.bukkit.event.inventory.InventoryDragEvent;
|
||||||
import org.bukkit.event.inventory.InventoryPickupItemEvent;
|
|
||||||
import org.bukkit.event.inventory.InventoryType;
|
import org.bukkit.event.inventory.InventoryType;
|
||||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import java.util.EnumSet;
|
public class InFightInventory implements Listener {
|
||||||
|
|
||||||
public class InFightInventoryListener extends BasicListener {
|
public InFightInventory() {
|
||||||
|
new StateDependentListener(ArenaMode.All, FightState.Running, this);
|
||||||
public InFightInventoryListener() {
|
|
||||||
super(EnumSet.of(FightState.RUNNING));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@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
|
@EventHandler
|
||||||
public void onBlockBreak(BlockBreakEvent event) {
|
public void onBlockBreak(BlockBreakEvent event) {
|
||||||
Inventory inventory = event.getPlayer().getInventory();
|
Inventory inventory = event.getPlayer().getInventory();
|
@ -0,0 +1,77 @@
|
|||||||
|
/*
|
||||||
|
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.countdown.Countdown;
|
||||||
|
import de.steamwar.fightsystem.countdown.SWSound;
|
||||||
|
import de.steamwar.fightsystem.fight.Fight;
|
||||||
|
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.Bukkit;
|
||||||
|
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.PlayerQuitEvent;
|
||||||
|
|
||||||
|
public class IngameDeath implements Listener {
|
||||||
|
|
||||||
|
public IngameDeath() {
|
||||||
|
new StateDependentListener(ArenaMode.All, FightState.Ingame, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
public void handlePlayerDeath(PlayerDeathEvent event) {
|
||||||
|
event.setDeathMessage(null);
|
||||||
|
|
||||||
|
Player player = event.getEntity();
|
||||||
|
FightTeam team = Fight.getPlayerTeam(player);
|
||||||
|
|
||||||
|
if(team == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer Spieler " + team.getPrefix() + player.getName() + " §cist gestorben!");
|
||||||
|
Fight.playSound(Countdown.getSound(SWSound.ENTITY_WITHER_DEATH), 100.0F, 1.0F);
|
||||||
|
team.getFightPlayer(player).setOut();
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
public void handlePlayerQuit(PlayerQuitEvent event) {
|
||||||
|
event.setQuitMessage(null);
|
||||||
|
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
FightTeam team = Fight.getPlayerTeam(player);
|
||||||
|
if(team == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
FightPlayer fightPlayer = team.getFightPlayer(player);
|
||||||
|
if(fightPlayer.isLiving()) {
|
||||||
|
Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer Spieler " + team.getPrefix() + player.getName() + " §chat den Kampf verlassen!");
|
||||||
|
team.getFightPlayer(player).setOut();
|
||||||
|
RecordSystem.entityDespawns(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -19,20 +19,21 @@
|
|||||||
|
|
||||||
package de.steamwar.fightsystem.listener;
|
package de.steamwar.fightsystem.listener;
|
||||||
|
|
||||||
|
import de.steamwar.fightsystem.ArenaMode;
|
||||||
import de.steamwar.fightsystem.Config;
|
import de.steamwar.fightsystem.Config;
|
||||||
import de.steamwar.fightsystem.fight.Fight;
|
import de.steamwar.fightsystem.fight.Fight;
|
||||||
import de.steamwar.fightsystem.fight.FightTeam;
|
import de.steamwar.fightsystem.fight.FightTeam;
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
|
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
|
|
||||||
import java.util.EnumSet;
|
public class NormalJoin implements Listener {
|
||||||
|
|
||||||
public class RankedJoinListener extends BasicListener {
|
public NormalJoin() {
|
||||||
|
new StateDependentListener(ArenaMode.Normal, FightState.PreLeaderSetup, this);
|
||||||
public RankedJoinListener() {
|
|
||||||
super(!Config.event() && Config.Ranked ? EnumSet.of(FightState.PRE_SCHEM_SETUP) : EnumSet.noneOf(FightState.class));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@ -42,9 +43,9 @@ public class RankedJoinListener extends BasicListener {
|
|||||||
|
|
||||||
if (fightTeam == null) {
|
if (fightTeam == null) {
|
||||||
if(!player.getUniqueId().equals(Config.RedLeader) && Fight.getBlueTeam().canbeLeader(player)) {
|
if(!player.getUniqueId().equals(Config.RedLeader) && Fight.getBlueTeam().canbeLeader(player)) {
|
||||||
Fight.getBlueTeam().setLeader(Fight.getBlueTeam().addMember(player));
|
Fight.getBlueTeam().addMember(player);
|
||||||
}else if(Fight.getRedTeam().canbeLeader(player)) {
|
}else if(Fight.getRedTeam().canbeLeader(player)) {
|
||||||
Fight.getRedTeam().setLeader(Fight.getRedTeam().addMember(player));
|
Fight.getRedTeam().addMember(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
130
FightSystem_Main/src/de/steamwar/fightsystem/listener/Permanent.java
Normale Datei
130
FightSystem_Main/src/de/steamwar/fightsystem/listener/Permanent.java
Normale Datei
@ -0,0 +1,130 @@
|
|||||||
|
/*
|
||||||
|
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.comms.packets.TablistNamePacket;
|
||||||
|
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.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.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.*;
|
||||||
|
import org.bukkit.event.weather.WeatherChangeEvent;
|
||||||
|
import org.bukkit.event.world.WorldLoadEvent;
|
||||||
|
|
||||||
|
public class Permanent implements Listener {
|
||||||
|
|
||||||
|
public Permanent() {
|
||||||
|
new StateDependentListener(ArenaMode.All, FightState.All, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void handlePlayerRespawn(PlayerRespawnEvent event){
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
Fight.setPlayerGamemode(player, GameMode.SPECTATOR);
|
||||||
|
|
||||||
|
FightTeam team = Fight.getPlayerTeam(player);
|
||||||
|
event.setRespawnLocation(team == null ? Config.SpecSpawn : 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!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
public void handlePlayerJoin(PlayerJoinEvent event) {
|
||||||
|
event.setJoinMessage(null);
|
||||||
|
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
FightTeam fightTeam = Fight.getPlayerTeam(player);
|
||||||
|
|
||||||
|
if (fightTeam == null) {
|
||||||
|
Fight.setPlayerGamemode(player, GameMode.SPECTATOR);
|
||||||
|
player.teleport(Config.SpecSpawn);
|
||||||
|
if(!ArenaMode.Test.contains(Config.mode))
|
||||||
|
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> new TablistNamePacket(SteamwarUser.get(player.getUniqueId()).getId(), "§7" + player.getName()).send(player), 5);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@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 onWorldLoad(WorldLoadEvent e) {
|
||||||
|
e.getWorld().setAutoSave(false);
|
||||||
|
}
|
||||||
|
}
|
@ -19,143 +19,58 @@
|
|||||||
|
|
||||||
package de.steamwar.fightsystem.listener;
|
package de.steamwar.fightsystem.listener;
|
||||||
|
|
||||||
import de.steamwar.core.Core;
|
|
||||||
import de.steamwar.core.VersionedCallable;
|
|
||||||
import de.steamwar.fightsystem.Config;
|
import de.steamwar.fightsystem.Config;
|
||||||
import de.steamwar.fightsystem.FightSystem;
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
import de.steamwar.fightsystem.fight.Fight;
|
import de.steamwar.fightsystem.fight.Fight;
|
||||||
import de.steamwar.fightsystem.fight.FightPlayer;
|
import de.steamwar.fightsystem.fight.FightPlayer;
|
||||||
import de.steamwar.fightsystem.kit.Kit;
|
import de.steamwar.fightsystem.fight.Kit;
|
||||||
import de.steamwar.fightsystem.kit.KitManager;
|
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.inventory.SWAnvilInv;
|
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||||
import de.steamwar.inventory.SWInventory;
|
|
||||||
import de.steamwar.inventory.SWItem;
|
|
||||||
import de.steamwar.inventory.SWListInv;
|
|
||||||
import de.steamwar.sql.PersonalKit;
|
import de.steamwar.sql.PersonalKit;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.entity.HumanEntity;
|
import org.bukkit.entity.HumanEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.inventory.InventoryAction;
|
import org.bukkit.event.inventory.InventoryAction;
|
||||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||||
import org.bukkit.event.player.PlayerMoveEvent;
|
import org.bukkit.event.player.PlayerMoveEvent;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.PlayerInventory;
|
|
||||||
import org.bukkit.inventory.meta.BlockDataMeta;
|
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.HashMap;
|
||||||
import java.util.logging.Level;
|
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 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(){
|
public PersonalKitCreator(){
|
||||||
super(enabled);
|
new StateDependentListener(Config.PersonalKits, FightState.Setup, this);
|
||||||
}
|
|
||||||
|
|
||||||
public static void openKitSelector(Player player, String qry) {
|
|
||||||
List<PersonalKit> kits = PersonalKit.get(SteamwarUser.get(player.getUniqueId()).getId(), Config.SchematicType.toDB());
|
|
||||||
kits.removeIf(kit -> !kit.getName().toLowerCase().contains(qry.toLowerCase()));
|
|
||||||
List<SWListInv.SWListEntry<PersonalKit>> entries = new ArrayList<>(kits.size());
|
|
||||||
kits.forEach(kit -> entries.add(new SWListInv.SWListEntry<>(new SWItem(Material.LEATHER_CHESTPLATE, "§e" + kit.getName(), new ArrayList<>(), kit.isInUse(), clickType -> {}), kit)));
|
|
||||||
SWListInv<PersonalKit> inv = new SWListInv<>(player, "§eKit wählen", false, entries, (clickType, kit) -> preview(player, kit));
|
|
||||||
if(entries.isEmpty())
|
|
||||||
inv.setItem(22, new SWItem(Material.BARRIER, "§cKeine Kits gefunden"));
|
|
||||||
inv.setItem(48, Material.NETHER_STAR, "§eNeues Kit", clickType -> {
|
|
||||||
SWAnvilInv anvilInv = new SWAnvilInv(player, "Kitname eingeben");
|
|
||||||
anvilInv.setItem(Material.LEATHER_CHESTPLATE);
|
|
||||||
anvilInv.setCallback(s -> {
|
|
||||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
|
||||||
if(PersonalKit.nameInUse(user.getId(), Config.SchematicType.toDB(), s)) {
|
|
||||||
player.sendMessage(FightSystem.PREFIX + "§cDieser Kitname wird bereits genutzt!");
|
|
||||||
player.closeInventory();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Kit prototype = KitManager.getKits(Fight.getFightPlayer(player).isLeader()).get(0);
|
|
||||||
PersonalKit kit = PersonalKit.create(user.getId(), Config.SchematicType.toDB(), s, prototype.getInventory(), prototype.getArmor());
|
|
||||||
openKitCreator(player, kit);
|
|
||||||
});
|
|
||||||
anvilInv.open();
|
|
||||||
});
|
|
||||||
inv.setItem(50, Material.NAME_TAG, "§eSuchen", clickType -> {
|
|
||||||
SWAnvilInv anvilInv = new SWAnvilInv(player, "§eNach Kit suchen");
|
|
||||||
anvilInv.setItem(Material.PAPER);
|
|
||||||
anvilInv.setCallback(s -> openKitSelector(player, s));
|
|
||||||
anvilInv.open();
|
|
||||||
});
|
|
||||||
inv.open();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void preview(Player player, PersonalKit kit){
|
|
||||||
SWInventory inv = new SWInventory(player, 54, kit.getName());
|
|
||||||
|
|
||||||
Kit.preview(inv, kit.getInventory(), kit.getArmor(), null);
|
|
||||||
|
|
||||||
inv.setItem(45, Material.LEATHER_CHESTPLATE, "§aKit benutzen", clickType -> useKit(player, kit));
|
|
||||||
inv.setItem(49, SWItem.getMaterial("WOOD_AXE"), "§7Kit bearbeiten", clickType -> openKitCreator(player, kit));
|
|
||||||
inv.setItem(53, Material.BARRIER, "§cKit löschen", clickType -> {
|
|
||||||
player.closeInventory();
|
|
||||||
SWInventory conf = new SWInventory(player, 9, "Kit wirklich löchen?");
|
|
||||||
conf.setItem(8, SWItem.getDye(1), "§cAbbrechen", click -> player.closeInventory());
|
|
||||||
conf.setItem(0, SWItem.getDye(10), "§aLöschen", click -> {
|
|
||||||
player.closeInventory();
|
|
||||||
if(kit.isInUse()) {
|
|
||||||
useKit(player, PersonalKit.get(SteamwarUser.get(player.getUniqueId()).getId(), Config.SchematicType.toDB()).get(0));
|
|
||||||
}
|
|
||||||
kit.delete();
|
|
||||||
});
|
|
||||||
conf.open();
|
|
||||||
});
|
|
||||||
inv.open();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void useKit(Player player, PersonalKit kit) {
|
|
||||||
kit.setInUse();
|
|
||||||
player.closeInventory();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void openKitCreator(Player player, PersonalKit kit){
|
public static void openKitCreator(Player player, PersonalKit kit){
|
||||||
if(!enabled.contains(FightSystem.getFightState()))
|
|
||||||
return;
|
|
||||||
|
|
||||||
player.closeInventory();
|
player.closeInventory();
|
||||||
new InventoryBackup(player, kit);
|
new InventoryBackup(player, kit);
|
||||||
|
new Kit(kit).loadToPlayer(player);
|
||||||
FightPlayer fightPlayer = Fight.getFightPlayer(player);
|
|
||||||
assert fightPlayer != null;
|
|
||||||
|
|
||||||
if(kit == null){
|
|
||||||
fightPlayer.getKit().loadToPlayer(player);
|
|
||||||
}else{
|
|
||||||
player.getInventory().setContents(kit.getInventory());
|
|
||||||
player.getInventory().setArmorContents(kit.getArmor());
|
|
||||||
}
|
|
||||||
|
|
||||||
player.updateInventory();
|
|
||||||
player.setGameMode(GameMode.CREATIVE);
|
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){
|
public static boolean notInKitCreator(HumanEntity player){
|
||||||
return !openKitCreators.containsKey(player);
|
return !openKitCreators.containsKey(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public static void closeIfInKitCreator(HumanEntity player){
|
||||||
public void disable(){
|
InventoryBackup backup = openKitCreators.get(player);
|
||||||
while(!openKitCreators.isEmpty()){
|
if(backup == null)
|
||||||
openKitCreators.values().iterator().next().close();
|
return;
|
||||||
}
|
|
||||||
super.disable();
|
backup.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@ -165,10 +80,23 @@ public class PersonalKitCreator extends BasicListener {
|
|||||||
|
|
||||||
Player player = (Player) e.getWhoClicked();
|
Player player = (Player) e.getWhoClicked();
|
||||||
//Deny bad items
|
//Deny bad items
|
||||||
if(isBadItem(e.getCursor(), player))
|
if(Kit.isBadItem(e.getCursor()))
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
|
|
||||||
checkForClear(e, player);
|
/* Should the inventory reset? */
|
||||||
|
if(e.getAction() != InventoryAction.PLACE_ALL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
ItemStack[] items = e.getWhoClicked().getInventory().getContents();
|
||||||
|
for(int i = 0; i < items.length; i++){
|
||||||
|
ItemStack stack = items[i];
|
||||||
|
if(stack != null && i != e.getSlot())
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
FightPlayer fightPlayer = Fight.getFightPlayer(player);
|
||||||
|
assert fightPlayer != null;
|
||||||
|
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> fightPlayer.getKit().loadToPlayer(player), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@ -198,97 +126,28 @@ public class PersonalKitCreator extends BasicListener {
|
|||||||
backup.close();
|
backup.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkForClear(InventoryClickEvent e, Player player){
|
|
||||||
if(e.getAction() != InventoryAction.PLACE_ALL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
ItemStack[] items = e.getWhoClicked().getInventory().getContents();
|
|
||||||
for(int i = 0; i < items.length; i++){
|
|
||||||
ItemStack stack = items[i];
|
|
||||||
if(stack != null && i != e.getSlot())
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
FightPlayer fightPlayer = Fight.getFightPlayer(player);
|
|
||||||
assert fightPlayer != null;
|
|
||||||
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> fightPlayer.getKit().loadToPlayer(player), 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean isBadItem(ItemStack stack, Player player){
|
|
||||||
if(stack == null)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
//Check for forbidden item
|
|
||||||
if(Config.ForbiddenItems.contains(stack.getType().name()))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
//Check for attribute modifiers
|
|
||||||
if(Core.getVersion() >= 14 && PersonalKitCreator_14.hasAttributeModifier(stack)){
|
|
||||||
Bukkit.getLogger().log(Level.SEVERE, "Spieler " + player.getName() + " hat versucht ein Item mit einem Attribute-Modifier zu bekommen.");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(stack.hasItemMeta()){
|
|
||||||
ItemMeta meta = stack.getItemMeta();
|
|
||||||
if(meta instanceof BlockDataMeta && ((BlockDataMeta)meta).hasBlockData())
|
|
||||||
return true; //Blocks always upwards slabs etc.
|
|
||||||
|
|
||||||
if(hasItems(stack))
|
|
||||||
return true; //Blocks prefilled inventories
|
|
||||||
}
|
|
||||||
|
|
||||||
Kit normal = KitManager.getKitByName(Config.MemberDefault);
|
|
||||||
assert normal != null;
|
|
||||||
return !normal.isEnchantmentInKit(stack) && !stack.getEnchantments().isEmpty();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean hasItems(ItemStack stack){
|
|
||||||
return VersionedCallable.call(new VersionedCallable<>(() -> PersonalKitCreator_8.hasItems(stack), 8),
|
|
||||||
new VersionedCallable<>(() -> PersonalKitCreator_9.hasItems(stack), 9),
|
|
||||||
new VersionedCallable<>(() -> PersonalKitCreator_10.hasItems(stack), 10),
|
|
||||||
new VersionedCallable<>(() -> PersonalKitCreator_12.hasItems(stack), 12),
|
|
||||||
new VersionedCallable<>(() -> PersonalKitCreator_14.hasItems(stack), 14),
|
|
||||||
new VersionedCallable<>(() -> PersonalKitCreator_15.hasItems(stack), 15));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class InventoryBackup{
|
private static class InventoryBackup{
|
||||||
private final Player player;
|
private final Player player;
|
||||||
private final ItemStack[] contents;
|
|
||||||
private final ItemStack[] armor;
|
|
||||||
private final PersonalKit kit;
|
private final PersonalKit kit;
|
||||||
|
private final Kit backup;
|
||||||
|
|
||||||
private InventoryBackup(Player player, PersonalKit kit){
|
private InventoryBackup(Player player, PersonalKit kit){
|
||||||
openKitCreators.put(player, this);
|
openKitCreators.put(player, this);
|
||||||
this.player = player;
|
this.player = player;
|
||||||
this.contents = player.getInventory().getContents();
|
this.backup = new Kit("backup", player);
|
||||||
this.armor = player.getInventory().getArmorContents();
|
|
||||||
this.kit = kit;
|
this.kit = kit;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadBackup(){
|
|
||||||
PlayerInventory inventory = player.getInventory();
|
|
||||||
inventory.setContents(contents);
|
|
||||||
inventory.setArmorContents(armor);
|
|
||||||
player.updateInventory();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void close(){
|
private void close(){
|
||||||
openKitCreators.remove(player);
|
openKitCreators.remove(player);
|
||||||
kit.setContainer(removeBadItems(player.getInventory().getContents()), removeBadItems(player.getInventory().getArmorContents()));
|
Kit kit1 = new Kit(kit.getName(), player);
|
||||||
loadBackup();
|
kit1.removeBadItems();
|
||||||
|
kit1.toPersonalKit(kit);
|
||||||
|
backup.loadToPlayer(player);
|
||||||
player.setGameMode(GameMode.SURVIVAL);
|
player.setGameMode(GameMode.SURVIVAL);
|
||||||
useKit(player, kit);
|
kit.setInUse();
|
||||||
}
|
player.closeInventory();
|
||||||
|
Objects.requireNonNull(Fight.getFightPlayer(player)).setKit(new Kit(kit));
|
||||||
private ItemStack[] removeBadItems(ItemStack[] inventory){
|
|
||||||
Kit normal = KitManager.getKitByName(Config.MemberDefault);
|
|
||||||
assert normal != null;
|
|
||||||
|
|
||||||
for(int i = 0; i < inventory.length; i++){
|
|
||||||
if(isBadItem(inventory[i], player))
|
|
||||||
inventory[i] = null;
|
|
||||||
}
|
|
||||||
return inventory;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,33 +21,27 @@ package de.steamwar.fightsystem.listener;
|
|||||||
|
|
||||||
import de.steamwar.fightsystem.Config;
|
import de.steamwar.fightsystem.Config;
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.utils.Region;
|
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.block.BlockPistonExtendEvent;
|
import org.bukkit.event.block.BlockPistonExtendEvent;
|
||||||
import org.bukkit.event.block.BlockPistonRetractEvent;
|
import org.bukkit.event.block.BlockPistonRetractEvent;
|
||||||
|
|
||||||
import java.util.EnumSet;
|
public class PistonListener implements Listener {
|
||||||
|
|
||||||
public class PistonListener extends BasicListener {
|
|
||||||
|
|
||||||
public PistonListener() {
|
public PistonListener() {
|
||||||
//Wenn Entern aktiv ist, sollen Raketen etc. entern können
|
//Wenn Entern aktiv ist, sollen Raketen etc. entern können
|
||||||
super(Config.EnterStages.isEmpty()
|
new StateDependentListener(Config.EnterStages.isEmpty(), FightState.All, this);
|
||||||
? EnumSet.allOf(FightState.class)
|
new StateDependentListener(!Config.EnterStages.isEmpty(), FightState.Setup, this);
|
||||||
: EnumSet.of(FightState.PRE_LEADER_SETUP, FightState.PRE_SCHEM_SETUP, FightState.POST_SCHEM_SETUP));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void handlePistonExtend(BlockPistonExtendEvent e){
|
public void handlePistonExtend(BlockPistonExtendEvent e){
|
||||||
BlockFace b = e.getDirection();
|
BlockFace b = e.getDirection().getOppositeFace();
|
||||||
for(Block block : e.getBlocks()){
|
for(Block block : e.getBlocks()){
|
||||||
if(
|
if(Config.BlueExtendRegion.inRegion(block.getRelative(b)) && Config.RedExtendRegion.inRegion(block.getRelative(b))){
|
||||||
block.getY() > Config.upperArenaBorder ||
|
|
||||||
(!Region.isIn2DRange(block.getLocation(), Config.TeamBlueCornerX + b.getModX(), Config.TeamBlueCornerZ + b.getModZ(), Config.SchemsizeX, Config.SchemsizeZ, Config.BorderFromSchematic) &&
|
|
||||||
!Region.isIn2DRange(block.getLocation(), Config.TeamRedCornerX + b.getModX(), Config.TeamRedCornerZ + b.getModZ(), Config.SchemsizeX, Config.SchemsizeZ, Config.BorderFromSchematic))
|
|
||||||
){
|
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -56,13 +50,9 @@ public class PistonListener extends BasicListener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void handlePistonRetract(BlockPistonRetractEvent e){
|
public void handlePistonRetract(BlockPistonRetractEvent e){
|
||||||
BlockFace b = e.getDirection();
|
BlockFace b = e.getDirection().getOppositeFace();
|
||||||
for(Block block : e.getBlocks()){
|
for(Block block : e.getBlocks()){
|
||||||
if(
|
if(Config.BlueExtendRegion.inRegion(block.getRelative(b)) && Config.RedExtendRegion.inRegion(block.getRelative(b))) {
|
||||||
block.getY() > Config.upperArenaBorder ||
|
|
||||||
(!Region.isIn2DRange(block.getLocation(), Config.TeamBlueCornerX + b.getModX(), Config.TeamBlueCornerZ + b.getModZ(), Config.SchemsizeX, Config.SchemsizeZ, Config.BorderFromSchematic) &&
|
|
||||||
!Region.isIn2DRange(block.getLocation(), Config.TeamRedCornerX + b.getModX(), Config.TeamRedCornerZ + b.getModZ(), Config.SchemsizeX, Config.SchemsizeZ, Config.BorderFromSchematic))
|
|
||||||
){
|
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1,125 +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.fight.Fight;
|
|
||||||
import de.steamwar.fightsystem.fight.FightTeam;
|
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
|
||||||
import de.steamwar.fightsystem.utils.Region;
|
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.GameMode;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.player.PlayerMoveEvent;
|
|
||||||
|
|
||||||
import java.util.EnumSet;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
|
|
||||||
public class PlayerMoveListener extends BasicListener {
|
|
||||||
|
|
||||||
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));
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void teamAreas(PlayerMoveEvent event) {
|
|
||||||
Player player = event.getPlayer();
|
|
||||||
if(player == FightSystem.getEventLeiter() || Config.test())
|
|
||||||
return;
|
|
||||||
|
|
||||||
Location to = event.getTo();
|
|
||||||
FightTeam fightTeam = Fight.getPlayerTeam(player);
|
|
||||||
|
|
||||||
assert to != null;
|
|
||||||
boolean inArenaY = to.getY() + 1.8 <= Config.upperArenaBorder;
|
|
||||||
|
|
||||||
boolean inBlueArea = inArenaY && Region.isIn2DRange(to, Config.TeamBlueCornerX, Config.TeamBlueCornerZ, Config.SchemsizeX, Config.SchemsizeZ, Config.BorderFromSchematic);
|
|
||||||
boolean inRedArea = inArenaY && Region.isIn2DRange(to, Config.TeamRedCornerX, Config.TeamRedCornerZ, Config.SchemsizeX, Config.SchemsizeZ, Config.BorderFromSchematic);
|
|
||||||
|
|
||||||
if(inBlueArea){
|
|
||||||
if(fightTeam == null)
|
|
||||||
reset(event, DENY_TEAM);
|
|
||||||
else if(fightTeam == Fight.getRedTeam() && (player.getGameMode() == GameMode.SPECTATOR || !fightTeam.canPlayerEntern(player)))
|
|
||||||
reset(event, DENY_ENTERN);
|
|
||||||
else
|
|
||||||
return; // Is allowed in area
|
|
||||||
checkInInnerArea(event.getPlayer(), to, Config.TeamBlueCornerX, Config.TeamBlueCornerZ);
|
|
||||||
}else if(inRedArea){
|
|
||||||
if(fightTeam == null)
|
|
||||||
reset(event, DENY_TEAM);
|
|
||||||
else if(fightTeam == Fight.getBlueTeam() && (player.getGameMode() == GameMode.SPECTATOR || !fightTeam.canPlayerEntern(player)))
|
|
||||||
reset(event, DENY_ENTERN);
|
|
||||||
else
|
|
||||||
return; // Is allowed in area
|
|
||||||
checkInInnerArea(event.getPlayer(), to, Config.TeamRedCornerX, Config.TeamRedCornerZ);
|
|
||||||
}else if(fightTeam != null && player.getGameMode() != GameMode.SPECTATOR && !fightTeam.canPlayerEntern(player))
|
|
||||||
reset(event, DENY_ENTERN);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void checkInInnerArea(Player player, Location to, int teamCornerX, int teamCornerZ){
|
|
||||||
boolean inArenaY = to.getY() + 1.8 <= Config.TeamBlueCornerY + Config.SchemsizeY;
|
|
||||||
boolean inArea = inArenaY && Region.isIn2DRange(to, teamCornerX, teamCornerZ, Config.SchemsizeX, Config.SchemsizeZ, 0);
|
|
||||||
if(inArea && Config.BorderFromSchematic >= 5){ // Preventing false positives due to small extension
|
|
||||||
player.kickPlayer(null);
|
|
||||||
Bukkit.getLogger().log(Level.SEVERE, player.getName() + " ist in einen Teambereich eingedrungen.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void arenaBorder(PlayerMoveEvent event){
|
|
||||||
Player player = event.getPlayer();
|
|
||||||
Location to = event.getTo();
|
|
||||||
|
|
||||||
//Check in Arena
|
|
||||||
assert to != null;
|
|
||||||
if(!Region.isIn2DRegion(to, Config.ArenaMinX, Config.ArenaMinZ, Config.ArenaMaxX, Config.ArenaMaxZ)){
|
|
||||||
reset(event, DENY_ARENA);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
FightTeam team = Fight.getPlayerTeam(player);
|
|
||||||
boolean inArenaY = to.getY() + 1.8 <= Config.upperArenaBorder;
|
|
||||||
|
|
||||||
if(to.getY() <= Config.underArenaBorder) {
|
|
||||||
if(player.getGameMode() == GameMode.SPECTATOR || team == null)
|
|
||||||
reset(event, DENY_ARENA);
|
|
||||||
else if(FightSystem.getFightState().infight())
|
|
||||||
player.damage(2);
|
|
||||||
else if(!Config.GroundWalkable)
|
|
||||||
player.teleport(team.getSpawn());
|
|
||||||
}else if(team != null && !inArenaY){
|
|
||||||
reset(event, DENY_ARENA);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void reset(PlayerMoveEvent event, String message){
|
|
||||||
Player player = event.getPlayer();
|
|
||||||
player.teleport(event.getFrom());
|
|
||||||
toActionbar(player, TextComponent.fromLegacyText(message));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,146 +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.comms.packets.TablistNamePacket;
|
|
||||||
import de.steamwar.fightsystem.Config;
|
|
||||||
import de.steamwar.fightsystem.FightSystem;
|
|
||||||
import de.steamwar.fightsystem.countdown.Countdown;
|
|
||||||
import de.steamwar.fightsystem.countdown.SWSound;
|
|
||||||
import de.steamwar.fightsystem.fight.Fight;
|
|
||||||
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.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.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 PlayerStateListener extends BasicListener{
|
|
||||||
|
|
||||||
public PlayerStateListener() {
|
|
||||||
super(EnumSet.allOf(FightState.class));
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
|
||||||
public void handlePlayerJoin(PlayerJoinEvent event) {
|
|
||||||
event.setJoinMessage(null);
|
|
||||||
|
|
||||||
Player player = event.getPlayer();
|
|
||||||
player.setHealth(20);
|
|
||||||
player.setFoodLevel(20);
|
|
||||||
setAttackSpeed(player);
|
|
||||||
|
|
||||||
FightTeam fightTeam = Fight.getPlayerTeam(player);
|
|
||||||
|
|
||||||
if (fightTeam == null) {
|
|
||||||
Fight.setPlayerGamemode(player, GameMode.SPECTATOR);
|
|
||||||
player.teleport(Config.SpecSpawn);
|
|
||||||
if(!Config.test())
|
|
||||||
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> new TablistNamePacket(SteamwarUser.get(player.getUniqueId()).getId(), "§7" + player.getName()).send(player), 5);
|
|
||||||
} else {
|
|
||||||
player.teleport(fightTeam.getSpawn());
|
|
||||||
if(FightSystem.getFightState().setup())
|
|
||||||
Fight.setPlayerGamemode(player, GameMode.SURVIVAL);
|
|
||||||
else
|
|
||||||
Fight.setPlayerGamemode(player, GameMode.SPECTATOR);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
|
||||||
public void handlePlayerDeath(PlayerDeathEvent event) {
|
|
||||||
Player player = event.getEntity().getPlayer();
|
|
||||||
FightTeam fightTeam = Fight.getPlayerTeam(player);
|
|
||||||
|
|
||||||
if(fightTeam == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
|
||||||
public void handlePlayerQuit(PlayerQuitEvent event) {
|
|
||||||
event.setQuitMessage(null);
|
|
||||||
|
|
||||||
Player player = event.getPlayer();
|
|
||||||
FightTeam fightTeam = Fight.getPlayerTeam(player);
|
|
||||||
if(fightTeam == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
FightState fightState = FightSystem.getFightState();
|
|
||||||
if(fightState.setup()){
|
|
||||||
fightTeam.removePlayer(player);
|
|
||||||
|
|
||||||
if(Config.recording())
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//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))))
|
|
||||||
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!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
102
FightSystem_Main/src/de/steamwar/fightsystem/listener/PrepareSchem.java
Normale Datei
102
FightSystem_Main/src/de/steamwar/fightsystem/listener/PrepareSchem.java
Normale Datei
@ -0,0 +1,102 @@
|
|||||||
|
/*
|
||||||
|
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.core.VersionedCallable;
|
||||||
|
import de.steamwar.core.VersionedRunnable;
|
||||||
|
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.fight.FightTeam_14;
|
||||||
|
import de.steamwar.fightsystem.fight.FightTeam_8;
|
||||||
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
|
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||||
|
import de.steamwar.fightsystem.utils.Region;
|
||||||
|
import de.steamwar.sql.Schematic;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
|
|
||||||
|
public class PrepareSchem implements Listener {
|
||||||
|
|
||||||
|
public PrepareSchem() {
|
||||||
|
new StateDependentListener(ArenaMode.Prepare, FightState.Setup, this){
|
||||||
|
@Override
|
||||||
|
public void disable() {
|
||||||
|
super.disable();
|
||||||
|
Region region = Fight.getBlueTeam().getExtendRegion();
|
||||||
|
World world = Bukkit.getWorlds().get(0);
|
||||||
|
|
||||||
|
Schematic schem;
|
||||||
|
try{
|
||||||
|
schem = Schematic.getSchemFromDB(Config.PrepareSchemID);
|
||||||
|
}catch(SecurityException e){
|
||||||
|
FightSystem.shutdown(FightSystem.PREFIX + "§cAnscheinend wurde die auszufahrende Schematic gelöscht, Einsenden wird abgebrochen.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try{
|
||||||
|
region.forEach((x, y, z) -> {
|
||||||
|
if(VersionedCallable.call(
|
||||||
|
new VersionedCallable<>(() -> FightTeam_8.checkPistonMoving(world.getBlockAt(x, y, z)), 8),
|
||||||
|
new VersionedCallable<>(() -> FightTeam_14.checkPistonMoving(world.getBlockAt(x, y, z)), 14))){
|
||||||
|
FightSystem.shutdown(FightSystem.PREFIX + "§cIm Teambereich wurden sich noch bewegende Pistons gefunden, Einsenden wird abgebrochen.");
|
||||||
|
throw new IllegalStateException();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}catch (IllegalStateException e){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try{
|
||||||
|
VersionedRunnable.call(
|
||||||
|
new VersionedRunnable(() -> FightTeam_8.saveSchem(schem, region), 8),
|
||||||
|
new VersionedRunnable(() -> FightTeam_14.saveSchem(schem, region), 14));
|
||||||
|
}catch(IllegalStateException e){
|
||||||
|
FightSystem.shutdown(FightSystem.PREFIX + "§cDie Schematic konnte nicht gespeichert werden, Einsenden wird abgebrochen.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
schem.setSchemType(Config.SchematicType.checkType());
|
||||||
|
FightSystem.shutdown(FightSystem.PREFIX + "§aDie Schematic wird nun zeitnah von einem Teammitglied überprüft");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,44 +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 net.md_5.bungee.api.chat.TextComponent;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.entity.ProjectileLaunchEvent;
|
|
||||||
|
|
||||||
import java.util.EnumSet;
|
|
||||||
|
|
||||||
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));
|
|
||||||
}
|
|
||||||
|
|
||||||
@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!"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -19,21 +19,21 @@
|
|||||||
|
|
||||||
package de.steamwar.fightsystem.listener;
|
package de.steamwar.fightsystem.listener;
|
||||||
|
|
||||||
|
import de.steamwar.fightsystem.ArenaMode;
|
||||||
import de.steamwar.fightsystem.Config;
|
import de.steamwar.fightsystem.Config;
|
||||||
import de.steamwar.fightsystem.FightSystem;
|
|
||||||
import de.steamwar.fightsystem.fight.Fight;
|
import de.steamwar.fightsystem.fight.Fight;
|
||||||
import de.steamwar.fightsystem.fight.FightTeam;
|
import de.steamwar.fightsystem.fight.FightTeam;
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
|
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
|
|
||||||
import java.util.EnumSet;
|
public class RankedJoin implements Listener {
|
||||||
|
|
||||||
public class NormalJoinListener extends BasicListener {
|
public RankedJoin() {
|
||||||
|
new StateDependentListener(ArenaMode.Ranked, FightState.PreLeaderSetup, this);
|
||||||
public NormalJoinListener() {
|
|
||||||
super(Config.event() || Config.test() || Config.Ranked ? EnumSet.noneOf(FightState.class) : EnumSet.of(FightState.PRE_LEADER_SETUP));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@ -43,15 +43,10 @@ public class NormalJoinListener extends BasicListener {
|
|||||||
|
|
||||||
if (fightTeam == null) {
|
if (fightTeam == null) {
|
||||||
if(!player.getUniqueId().equals(Config.RedLeader) && Fight.getBlueTeam().canbeLeader(player)) {
|
if(!player.getUniqueId().equals(Config.RedLeader) && Fight.getBlueTeam().canbeLeader(player)) {
|
||||||
Fight.getBlueTeam().setLeader(Fight.getBlueTeam().addMember(player));
|
Fight.getBlueTeam().addMember(player);
|
||||||
}else if(Fight.getRedTeam().canbeLeader(player)) {
|
}else if(Fight.getRedTeam().canbeLeader(player)) {
|
||||||
Fight.getRedTeam().setLeader(Fight.getRedTeam().addMember(player));
|
Fight.getRedTeam().addMember(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Fight.getRedTeam().hasTeamLeader() && Fight.getBlueTeam().hasTeamLeader()
|
|
||||||
&& (Fight.getRedTeam().getLeader().getPlayer() == player || Fight.getBlueTeam().getLeader().getPlayer() == player)) {
|
|
||||||
FightSystem.setPreSchemState();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -26,12 +26,15 @@ import de.steamwar.fightsystem.fight.FightPlayer;
|
|||||||
import de.steamwar.fightsystem.fight.FightTeam;
|
import de.steamwar.fightsystem.fight.FightTeam;
|
||||||
import de.steamwar.fightsystem.record.RecordSystem;
|
import de.steamwar.fightsystem.record.RecordSystem;
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
|
import de.steamwar.fightsystem.states.StateDependent;
|
||||||
|
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||||
import org.bukkit.*;
|
import org.bukkit.*;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.entity.TNTPrimed;
|
import org.bukkit.entity.TNTPrimed;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.block.BlockPhysicsEvent;
|
import org.bukkit.event.block.BlockPhysicsEvent;
|
||||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||||
import org.bukkit.event.entity.EntitySpawnEvent;
|
import org.bukkit.event.entity.EntitySpawnEvent;
|
||||||
@ -43,16 +46,31 @@ import org.bukkit.event.player.*;
|
|||||||
import org.bukkit.event.server.BroadcastMessageEvent;
|
import org.bukkit.event.server.BroadcastMessageEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import java.util.EnumSet;
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
public class EventRecordListener extends BasicListener {
|
public class Recording implements Listener {
|
||||||
|
|
||||||
private static final int AIR = 0;
|
private static final int AIR = 0;
|
||||||
private static final Random random = new Random();
|
private static final Random random = new Random();
|
||||||
|
|
||||||
public EventRecordListener() {
|
public Recording() {
|
||||||
super(Config.recording() ? EnumSet.allOf(FightState.class) : EnumSet.noneOf(FightState.class));
|
new StateDependentListener(Config.recording(), FightState.All, this);
|
||||||
|
new StateDependent(Config.recording(), FightState.Ingame){
|
||||||
|
@Override
|
||||||
|
public void enable() {
|
||||||
|
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> {
|
||||||
|
setKitItems(Fight.getBlueTeam());
|
||||||
|
setKitItems(Fight.getRedTeam());
|
||||||
|
}, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void disable() {
|
||||||
|
despawnTeam(Fight.getRedTeam());
|
||||||
|
despawnTeam(Fight.getBlueTeam());
|
||||||
|
despawnTNT();
|
||||||
|
}
|
||||||
|
}.register();
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
@ -170,22 +188,8 @@ 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){
|
private void setKitItems(FightTeam team){
|
||||||
if(FightSystem.getFightState() != FightState.PRE_RUNNING)
|
if(FightState.getFightState() != FightState.PRE_RUNNING)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for(FightPlayer fp : team.getPlayers()){
|
for(FightPlayer fp : team.getPlayers()){
|
||||||
@ -222,6 +226,6 @@ public class EventRecordListener extends BasicListener {
|
|||||||
|
|
||||||
private boolean isNotSent(Player p){
|
private boolean isNotSent(Player p){
|
||||||
FightPlayer fp = Fight.getFightPlayer(p);
|
FightPlayer fp = Fight.getFightPlayer(p);
|
||||||
return fp == null || !fp.isLiving() || FightSystem.getFightState() == FightState.SPECTATE;
|
return fp == null || !fp.isLiving() || FightState.getFightState() == FightState.SPECTATE;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -0,0 +1,35 @@
|
|||||||
|
package de.steamwar.fightsystem.listener;
|
||||||
|
|
||||||
|
import de.steamwar.fightsystem.ArenaMode;
|
||||||
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
|
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 org.bukkit.event.player.PlayerResourcePackStatusEvent;
|
||||||
|
|
||||||
|
public class ResourcePack implements Listener {
|
||||||
|
|
||||||
|
public ResourcePack(){
|
||||||
|
new StateDependentListener(ArenaMode.Event, FightState.All, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void handlePlayerJoin(PlayerJoinEvent event) {
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
player.setResourcePack("https://steamwar.de/antixray.zip");
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onResourcepack(PlayerResourcePackStatusEvent e){
|
||||||
|
if(e.getStatus() == PlayerResourcePackStatusEvent.Status.ACCEPTED || e.getStatus() == PlayerResourcePackStatusEvent.Status.SUCCESSFULLY_LOADED)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Player player = e.getPlayer();
|
||||||
|
player.sendMessage(FightSystem.PREFIX + "§cAuf Eventserver kann nur mit dem SteamWar-Resourcepack beigetreten werden");
|
||||||
|
player.sendMessage(FightSystem.PREFIX + "§cDa du abgelehnt hast, musst du nun in der Serverliste erstmal wieder Ressourcenpakete von SteamWar aktivieren.");
|
||||||
|
player.kickPlayer(null);
|
||||||
|
}
|
||||||
|
}
|
@ -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());
|
|
||||||
}
|
|
||||||
}
|
|
@ -19,32 +19,31 @@
|
|||||||
|
|
||||||
package de.steamwar.fightsystem.listener;
|
package de.steamwar.fightsystem.listener;
|
||||||
|
|
||||||
|
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.FightState;
|
||||||
|
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.entity.SpawnerSpawnEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
import org.bukkit.event.weather.WeatherChangeEvent;
|
|
||||||
|
|
||||||
import java.util.EnumSet;
|
public class SetupQuit implements Listener {
|
||||||
|
|
||||||
public class FoodLevelChangeListener extends BasicListener {
|
public SetupQuit(){
|
||||||
|
new StateDependentListener(ArenaMode.All, FightState.Setup, this);
|
||||||
public FoodLevelChangeListener() {
|
|
||||||
super(EnumSet.allOf(FightState.class));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void handleFoodLevelChange(FoodLevelChangeEvent event) {
|
public void handlePlayerQuit(PlayerQuitEvent event) {
|
||||||
event.setCancelled(true);
|
event.setQuitMessage(null);
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
Player player = event.getPlayer();
|
||||||
public void onWeatherChange(WeatherChangeEvent event){
|
FightTeam team = Fight.getPlayerTeam(player);
|
||||||
event.setCancelled(true);
|
if(team == null)
|
||||||
}
|
return;
|
||||||
|
|
||||||
@EventHandler
|
team.removePlayer(player);
|
||||||
public void onSpawnerSpawn(SpawnerSpawnEvent e){
|
|
||||||
e.setCancelled(true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -19,32 +19,25 @@
|
|||||||
|
|
||||||
package de.steamwar.fightsystem.listener;
|
package de.steamwar.fightsystem.listener;
|
||||||
|
|
||||||
|
import de.steamwar.fightsystem.ArenaMode;
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
|
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.inventory.CraftItemEvent;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.inventory.FurnaceSmeltEvent;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.PlayerBedEnterEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
|
||||||
import java.util.EnumSet;
|
public class Shutdown implements Listener {
|
||||||
|
|
||||||
public class GameplayListener extends BasicListener{
|
public Shutdown(){
|
||||||
|
new StateDependentListener(ArenaMode.AntiEvent, FightState.All, this);
|
||||||
public GameplayListener() {
|
|
||||||
super(EnumSet.allOf(FightState.class));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
public void onSleep(PlayerBedEnterEvent e) {
|
public void handlePlayerQuit(PlayerQuitEvent event) {
|
||||||
e.setCancelled(true);
|
//Shutdown server if nobody online and its not an event server
|
||||||
}
|
if(Bukkit.getOnlinePlayers().isEmpty() || (Bukkit.getOnlinePlayers().size() == 1 && Bukkit.getOnlinePlayers().contains(event.getPlayer())))
|
||||||
|
Bukkit.shutdown();
|
||||||
@EventHandler
|
|
||||||
public void onCrafting(CraftItemEvent e){
|
|
||||||
e.setCancelled(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onFurnace(FurnaceSmeltEvent e){
|
|
||||||
e.setCancelled(true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
92
FightSystem_Main/src/de/steamwar/fightsystem/listener/TeamArea.java
Normale Datei
92
FightSystem_Main/src/de/steamwar/fightsystem/listener/TeamArea.java
Normale Datei
@ -0,0 +1,92 @@
|
|||||||
|
/*
|
||||||
|
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.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 net.md_5.bungee.api.chat.TextComponent;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
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.logging.Level;
|
||||||
|
|
||||||
|
public class TeamArea implements Listener {
|
||||||
|
|
||||||
|
private static final String DENY_TEAM = "§cDu darfst nicht zu den Teams";
|
||||||
|
private static final String DENY_ENTERN = "§cDu darfst nicht entern";
|
||||||
|
|
||||||
|
public TeamArea() {
|
||||||
|
new StateDependentListener(ArenaMode.AntiTest, FightState.All, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void teamAreas(PlayerMoveEvent event) {
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
if(player == FightSystem.getEventLeiter())
|
||||||
|
return;
|
||||||
|
|
||||||
|
Location to = event.getTo();
|
||||||
|
assert to != null;
|
||||||
|
|
||||||
|
FightTeam team = Fight.getPlayerTeam(player);
|
||||||
|
|
||||||
|
if(Config.BlueExtendRegion.playerInRegion(to)){
|
||||||
|
if(team == null)
|
||||||
|
reset(event, DENY_TEAM);
|
||||||
|
else if(team == Fight.getRedTeam() && (player.getGameMode() == GameMode.SPECTATOR || !team.canPlayerEntern(player)))
|
||||||
|
reset(event, DENY_ENTERN);
|
||||||
|
else
|
||||||
|
return; // Is allowed in area
|
||||||
|
checkInInnerArea(event.getPlayer(), to, Fight.getBlueTeam());
|
||||||
|
}else if(Config.RedExtendRegion.playerInRegion(to)){
|
||||||
|
if(team == null)
|
||||||
|
reset(event, DENY_TEAM);
|
||||||
|
else if(team == Fight.getBlueTeam() && (player.getGameMode() == GameMode.SPECTATOR || !team.canPlayerEntern(player)))
|
||||||
|
reset(event, DENY_ENTERN);
|
||||||
|
else
|
||||||
|
return; // Is allowed in area
|
||||||
|
checkInInnerArea(event.getPlayer(), to, Fight.getRedTeam());
|
||||||
|
}else if(team != null && player.getGameMode() != GameMode.SPECTATOR && !team.canPlayerEntern(player))
|
||||||
|
reset(event, DENY_ENTERN);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkInInnerArea(Player player, Location to, FightTeam team){
|
||||||
|
if(team.getSchemRegion().playerInRegion(to) && Config.PreperationArea >= 5){ // Preventing false positives due to small extension
|
||||||
|
player.kickPlayer(null);
|
||||||
|
Bukkit.getLogger().log(Level.SEVERE, player.getName() + " ist in einen Teambereich eingedrungen.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void reset(PlayerMoveEvent event, String message){
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
player.teleport(event.getFrom());
|
||||||
|
BasicListener.toActionbar(player, TextComponent.fromLegacyText(message));
|
||||||
|
}
|
||||||
|
}
|
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().isLeaderless() || Fight.getBlueTeam().isLeaderless())) {
|
||||||
|
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);*/
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,55 +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.core.Core;
|
|
||||||
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;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
public class VersionDependentListener extends BasicListener {
|
|
||||||
|
|
||||||
private static final List<Listener> listeners = new ArrayList<>();
|
|
||||||
|
|
||||||
static {
|
|
||||||
if(Core.getVersion() > 8)
|
|
||||||
listeners.add(new PickupArrowListener_9());
|
|
||||||
}
|
|
||||||
|
|
||||||
public VersionDependentListener() {
|
|
||||||
super(EnumSet.allOf(FightState.class));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void enable() {
|
|
||||||
for(Listener listener : listeners)
|
|
||||||
Bukkit.getPluginManager().registerEvents(listener, FightSystem.getPlugin());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void disable() {
|
|
||||||
for(Listener listener : listeners)
|
|
||||||
HandlerList.unregisterAll(listener);
|
|
||||||
}
|
|
||||||
}
|
|
@ -17,22 +17,32 @@
|
|||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
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.VersionedCallable;
|
import de.steamwar.core.VersionedCallable;
|
||||||
|
import de.steamwar.fightsystem.ArenaMode;
|
||||||
import de.steamwar.fightsystem.Config;
|
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.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||||
|
|
||||||
import java.util.List;
|
public class WaterRemover implements Listener {
|
||||||
|
|
||||||
public class WaterRemover {
|
private static final int MIN_Y = Config.BluePasteRegion.getMinY() + Config.WaterDepth;
|
||||||
private WaterRemover(){}
|
|
||||||
|
|
||||||
private static final int MIN_Y = Config.AlignWater ? Config.TeamBlueCornerY + Config.WaterDepth : Config.TeamBlueCornerY;
|
public WaterRemover() {
|
||||||
|
new StateDependentListener(ArenaMode.All, FightState.Running, this);
|
||||||
|
}
|
||||||
|
|
||||||
public static void add(List<Block> l) {
|
@EventHandler
|
||||||
for(Block b : l){
|
public void handleEntityExplode(EntityExplodeEvent event) {
|
||||||
|
event.setYield(0); //No drops (additionally to world config)
|
||||||
|
|
||||||
|
for(Block b : event.blockList()){
|
||||||
//b cannot be water or air due to current explosion
|
//b cannot be water or air due to current explosion
|
||||||
|
|
||||||
checkBlock(b.getRelative(BlockFace.UP));
|
checkBlock(b.getRelative(BlockFace.UP));
|
||||||
@ -43,8 +53,11 @@ public class WaterRemover {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void checkBlock(Block b) {
|
private void checkBlock(Block b) {
|
||||||
if(!removeWater(b))
|
//checks for water and removes it, if present
|
||||||
|
if(!VersionedCallable.call(
|
||||||
|
new VersionedCallable<>(() -> WaterRemover_8.removeWater(b), 8),
|
||||||
|
new VersionedCallable<>(() -> WaterRemover_14.removeWater(b), 14)))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(b.getY() < MIN_Y)
|
if(b.getY() < MIN_Y)
|
||||||
@ -58,13 +71,8 @@ public class WaterRemover {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isWater(Block block){
|
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));
|
new VersionedCallable<>(() -> WaterRemover_14.isWater(block), 14));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean removeWater(Block block){
|
|
||||||
//checks for water and removes it, if present
|
|
||||||
return VersionedCallable.call(new VersionedCallable<>(() -> WaterRemover_8.removeWater(block), 8),
|
|
||||||
new VersionedCallable<>(() -> WaterRemover_14.removeWater(block), 14));
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -20,6 +20,7 @@
|
|||||||
package de.steamwar.fightsystem.record;
|
package de.steamwar.fightsystem.record;
|
||||||
|
|
||||||
import de.steamwar.core.VersionedCallable;
|
import de.steamwar.core.VersionedCallable;
|
||||||
|
import de.steamwar.fightsystem.ArenaMode;
|
||||||
import de.steamwar.fightsystem.Config;
|
import de.steamwar.fightsystem.Config;
|
||||||
import de.steamwar.fightsystem.FightSystem;
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
@ -48,7 +49,7 @@ public class RecordSystem {
|
|||||||
if (Config.SpectateSystem)
|
if (Config.SpectateSystem)
|
||||||
new SpectateConnection();
|
new SpectateConnection();
|
||||||
new FileRecorder();
|
new FileRecorder();
|
||||||
if(Config.event())
|
if(Config.mode == ArenaMode.EVENT)
|
||||||
teamIds(Config.EventTeamBlueID, Config.EventTeamRedID);
|
teamIds(Config.EventTeamBlueID, Config.EventTeamRedID);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,8 +168,8 @@ public class RecordSystem {
|
|||||||
public static synchronized void blockChange(Block block){
|
public static synchronized void blockChange(Block block){
|
||||||
int blockState = blockToId(block);
|
int blockState = blockToId(block);
|
||||||
|
|
||||||
int shortX = block.getX() - Config.ArenaMinX;
|
int shortX = block.getX() - Config.ArenaRegion.getMinX();
|
||||||
int shortZ = block.getZ() - Config.ArenaMinZ;
|
int shortZ = block.getZ() - Config.ArenaRegion.getMinZ();
|
||||||
if((short)blockState == blockState && shortX > 0 && shortX < 256 && shortZ > 0 && shortZ < 256){
|
if((short)blockState == blockState && shortX > 0 && shortX < 256 && shortZ > 0 && shortZ < 256){
|
||||||
//Short block packet
|
//Short block packet
|
||||||
Recorder.rByte(0x33);
|
Recorder.rByte(0x33);
|
||||||
@ -274,7 +275,7 @@ public class RecordSystem {
|
|||||||
private static void checkWorldState(){
|
private static void checkWorldState(){
|
||||||
tick();
|
tick();
|
||||||
|
|
||||||
if(FightSystem.getFightState() == FightState.SPECTATE)
|
if(FightState.getFightState() == FightState.SPECTATE)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for(TNTPrimed tnt : WORLD.getEntitiesByClass(TNTPrimed.class)){
|
for(TNTPrimed tnt : WORLD.getEntitiesByClass(TNTPrimed.class)){
|
||||||
|
@ -19,39 +19,73 @@
|
|||||||
|
|
||||||
package de.steamwar.fightsystem.states;
|
package de.steamwar.fightsystem.states;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
public enum FightState {
|
public enum FightState {
|
||||||
PRE_LEADER_SETUP(true, true, false, false),
|
PRE_LEADER_SETUP,
|
||||||
PRE_SCHEM_SETUP(true, true, false, false),
|
PRE_SCHEM_SETUP,
|
||||||
POST_SCHEM_SETUP(true, true, false, false),
|
POST_SCHEM_SETUP,
|
||||||
PRE_RUNNING(false, false, true, false),
|
PRE_RUNNING,
|
||||||
RUNNING(false, false, true, true),
|
RUNNING,
|
||||||
SPECTATE(false, true, false, false);
|
SPECTATE;
|
||||||
|
|
||||||
private final boolean setup; //PRE_LEADER_SETUP, PRE_SCHEM_SETUP, POST_SCHEM_SETUP
|
public static final Set<FightState> All = Collections.unmodifiableSet(EnumSet.allOf(FightState.class));
|
||||||
private final boolean outgame; //PRE_LEADER_SETUP, PRE_SCHEM_SETUP, POST_SCHEM_SETUP, SPECTATE
|
|
||||||
private final boolean ingame; //PRE_RUNNING, RUNNING
|
|
||||||
private final boolean infight; //RUNNING
|
|
||||||
|
|
||||||
FightState(boolean setup, boolean outgame, boolean ingame, boolean infight){
|
public static final Set<FightState> PreLeaderSetup = Collections.unmodifiableSet(EnumSet.of(PRE_LEADER_SETUP));
|
||||||
this.setup = setup;
|
public static final Set<FightState> PreSchemSetup = Collections.unmodifiableSet(EnumSet.of(PRE_SCHEM_SETUP));
|
||||||
this.outgame = outgame;
|
public static final Set<FightState> PostSchemSetup = Collections.unmodifiableSet(EnumSet.of(POST_SCHEM_SETUP));
|
||||||
this.ingame = ingame;
|
public static final Set<FightState> PreRunning = Collections.unmodifiableSet(EnumSet.of(PRE_RUNNING));
|
||||||
this.infight = infight;
|
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 boolean setup(){
|
public static void registerStateDependent(IStateDependent stateDependent){
|
||||||
return setup;
|
if(stateDependent.enabled().isEmpty())
|
||||||
|
return;
|
||||||
|
boolean enabled = stateDependent.enabled().contains(fightState);
|
||||||
|
stateDependentFeatures.put(stateDependent, enabled);
|
||||||
|
if(enabled)
|
||||||
|
stateDependent.enable();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean outgame(){
|
public static void setFightState(FightState state){
|
||||||
return outgame;
|
fightState = state;
|
||||||
|
|
||||||
|
for(Map.Entry<IStateDependent, Boolean> feature : stateDependentFeatures.entrySet()){
|
||||||
|
//Enable feature if should be enabled and currently disabled
|
||||||
|
if(feature.getKey().enabled().contains(fightState) && !feature.getValue()){
|
||||||
|
feature.getKey().enable();
|
||||||
|
feature.setValue(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Disable feature if should be disabled and currently enabled
|
||||||
|
if(!feature.getKey().enabled().contains(fightState) && feature.getValue()){
|
||||||
|
feature.getKey().disable();
|
||||||
|
feature.setValue(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean ingame(){
|
public static boolean setup(){
|
||||||
return ingame;
|
return Setup.contains(fightState);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean infight(){
|
public static boolean ingame(){
|
||||||
return infight;
|
return Ingame.contains(fightState);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean infight(){
|
||||||
|
return fightState == RUNNING;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,40 @@
|
|||||||
|
/*
|
||||||
|
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 java.util.Set;
|
||||||
|
|
||||||
|
public interface IStateDependent {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return returns a set containing
|
||||||
|
*/
|
||||||
|
Set<FightState> enabled();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enables the state dependent object
|
||||||
|
*/
|
||||||
|
void enable();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disables the state dependent object
|
||||||
|
*/
|
||||||
|
void disable();
|
||||||
|
}
|
@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
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 java.util.Set;
|
||||||
|
|
||||||
|
public class OneShotStateDependent extends StateDependent{
|
||||||
|
|
||||||
|
private final Runnable runnable;
|
||||||
|
|
||||||
|
public OneShotStateDependent(Set<ArenaMode> mode, Set<FightState> states, Runnable runnable) {
|
||||||
|
super(mode, states);
|
||||||
|
this.runnable = runnable;
|
||||||
|
register();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void enable() {
|
||||||
|
runnable.run();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void disable() {
|
||||||
|
//Do nothing, oneshot
|
||||||
|
}
|
||||||
|
}
|
@ -19,27 +19,37 @@
|
|||||||
|
|
||||||
package de.steamwar.fightsystem.states;
|
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;
|
import java.util.Set;
|
||||||
|
|
||||||
public interface StateDependent {
|
public abstract class StateDependent implements IStateDependent {
|
||||||
|
|
||||||
/**
|
private final Set<FightState> enabled;
|
||||||
* @return returns a set containing
|
private final boolean register;
|
||||||
*/
|
|
||||||
Set<FightState> enabled();
|
|
||||||
|
|
||||||
/**
|
protected StateDependent(Winconditions wincondition, Set<FightState> states){
|
||||||
* Enables the state dependent object
|
this(Config.ActiveWinconditions.contains(wincondition), states);
|
||||||
*/
|
}
|
||||||
void enable();
|
|
||||||
|
|
||||||
/**
|
protected StateDependent(Set<ArenaMode> mode, Set<FightState> states){
|
||||||
* Disables the state dependent object
|
this(mode.contains(Config.mode), states);
|
||||||
*/
|
}
|
||||||
void disable();
|
|
||||||
|
|
||||||
/**
|
protected StateDependent(boolean enabled, Set<FightState> states){
|
||||||
* On state change when enabled
|
this.enabled = states;
|
||||||
*/
|
this.register = enabled;
|
||||||
default void stateChange(FightState state){}
|
}
|
||||||
|
|
||||||
|
public void register(){
|
||||||
|
if(register)
|
||||||
|
FightState.registerStateDependent(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<FightState> enabled() {
|
||||||
|
return enabled;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,57 @@
|
|||||||
|
/*
|
||||||
|
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 unavailable = (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();
|
||||||
|
register();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void enable() {
|
||||||
|
command.setExecutor(executor);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void disable() {
|
||||||
|
command.setExecutor(unavailable);
|
||||||
|
}
|
||||||
|
}
|
Einige Dateien werden nicht angezeigt, da zu viele Dateien in diesem Diff geändert wurden Mehr anzeigen
In neuem Issue referenzieren
Einen Benutzer sperren