12
1

New VersionDependent system

Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Lixfel 2021-08-31 10:42:42 +02:00
Ursprung fa66d32852
Commit 96bd358d29
168 geänderte Dateien mit 1554 neuen und 1581 gelöschten Zeilen

Datei anzeigen

@ -17,28 +17,10 @@
<artifactId>FightSystem_10</artifactId>
<version>1.0</version>
<build>
<sourceDirectory>src</sourceDirectory>
<resources>
<resource>
<directory>src</directory>
<excludes>
<exclude>**/*.java</exclude>
<exclude>**/*.kt</exclude>
</excludes>
</resource>
</resources>
</build>
<dependencies>
<dependency>
<groupId>steamwar</groupId>
<artifactId>FightSystem_9</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>FightSystem_API</artifactId>
<artifactId>FightSystem_Core</artifactId>
<version>1.0</version>
</dependency>
<dependency>

Datei anzeigen

@ -1,36 +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 org.bukkit.craftbukkit.v1_10_R1.inventory.CraftItemStack;
import org.bukkit.inventory.ItemStack;
import java.util.HashSet;
import java.util.Set;
public class PersonalKitCreator_10 {
public static boolean hasItems(ItemStack stack){
Set<String> keys = new HashSet<>(CraftItemStack.asNMSCopy(stack).getTag().c());
keys.remove("Enchantments");
keys.remove("Damage");
return !keys.isEmpty();
}
}

Datei anzeigen

@ -1,7 +1,7 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2020 SteamWar.de-Serverteam
Copyright (C) 2021 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
@ -15,24 +15,29 @@
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;
package de.steamwar.fightsystem.utils;
import de.steamwar.core.events.ChunkListener;
import de.steamwar.fightsystem.fight.FightWorld;
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.craftbukkit.v1_10_R1.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_10_R1.inventory.CraftItemStack;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
public class FightWorld_10 {
private FightWorld_10(){}
import java.util.HashSet;
import java.util.Set;
static void resetChunk(World world, World backup, int x, int z, boolean isPaper){
public class CraftbukkitWrapper10 implements CraftbukkitWrapper.ICraftbukkitWrapper {
@Override
public 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);
@ -40,7 +45,7 @@ public class FightWorld_10 {
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());
if (!isPaper) {
if (!FightWorld.isPaper()) {
w.tileEntityList.removeAll(chunk.tileEntities.values());
}
chunk.tileEntities.clear();
@ -50,11 +55,21 @@ public class FightWorld_10 {
}
}
public static void sendResourcePack(Player player, String pack, String sha1){
@Override
public void sendResourcePack(Player player, String pack, String sha1) {
((CraftPlayer)player).getHandle().setResourcePack(pack, sha1);
}
public static float headRotation(Entity e){
@Override
public float headRotation(Entity e) {
return ((CraftEntity)e).getHandle().getHeadRotation();
}
@Override
public boolean hasItems(ItemStack stack) {
Set<String> keys = new HashSet<>(CraftItemStack.asNMSCopy(stack).getTag().c());
keys.remove("Enchantments");
keys.remove("Damage");
return !keys.isEmpty();
}
}

Datei anzeigen

@ -17,28 +17,15 @@
<artifactId>FightSystem_12</artifactId>
<version>1.0</version>
<build>
<sourceDirectory>src</sourceDirectory>
<resources>
<resource>
<directory>src</directory>
<excludes>
<exclude>**/*.java</exclude>
<exclude>**/*.kt</exclude>
</excludes>
</resource>
</resources>
</build>
<dependencies>
<dependency>
<groupId>steamwar</groupId>
<artifactId>FightSystem_10</artifactId>
<artifactId>FightSystem_8</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>FightSystem_API</artifactId>
<artifactId>FightSystem_Core</artifactId>
<version>1.0</version>
</dependency>
<dependency>

Datei anzeigen

@ -22,11 +22,10 @@ package de.steamwar.fightsystem.fight;
import org.bukkit.ChatColor;
import org.bukkit.scoreboard.Team;
class FightTeam_9 {
private FightTeam_9(){}
public class FightTeam12 implements FightTeam.IFightTeam {
static void setTeamColor(Team team, ChatColor color){
FightTeam_8.setTeamColor(team, color);
team.setOption(Team.Option.NAME_TAG_VISIBILITY, Team.OptionStatus.FOR_OWN_TEAM);
@Override
public void setTeamColor(Team team, ChatColor color){
team.setColor(color);
}
}

Datei anzeigen

@ -0,0 +1,30 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2021 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 org.bukkit.entity.Arrow;
public class ArrowStopper12 implements ArrowStopper.IArrowStopper {
@Override
public boolean isInBlock(Arrow e) {
return e.isInBlock();
}
}

Datei anzeigen

@ -1,36 +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 org.bukkit.craftbukkit.v1_12_R1.inventory.CraftItemStack;
import org.bukkit.inventory.ItemStack;
import java.util.HashSet;
import java.util.Set;
public class PersonalKitCreator_12 {
public static boolean hasItems(ItemStack stack){
Set<String> keys = new HashSet<>(CraftItemStack.asNMSCopy(stack).getTag().c());
keys.remove("Enchantments");
keys.remove("Damage");
return !keys.isEmpty();
}
}

Datei anzeigen

@ -1,7 +1,7 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2020 SteamWar.de-Serverteam
Copyright (C) 2021 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
@ -15,24 +15,29 @@
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;
package de.steamwar.fightsystem.utils;
import de.steamwar.core.events.ChunkListener;
import de.steamwar.fightsystem.fight.FightWorld;
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.craftbukkit.v1_12_R1.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_12_R1.inventory.CraftItemStack;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
public class FightWorld_12 {
private FightWorld_12(){}
import java.util.HashSet;
import java.util.Set;
static void resetChunk(World world, World backup, int x, int z, boolean isPaper){
public class CraftbukkitWrapper12 implements CraftbukkitWrapper.ICraftbukkitWrapper {
@Override
public 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);
@ -40,7 +45,7 @@ public class FightWorld_12 {
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());
if (!isPaper) {
if (!FightWorld.isPaper()) {
w.tileEntityList.removeAll(chunk.tileEntities.values());
}
chunk.tileEntities.clear();
@ -50,11 +55,21 @@ public class FightWorld_12 {
}
}
public static void sendResourcePack(Player player, String pack, String sha1){
@Override
public void sendResourcePack(Player player, String pack, String sha1) {
((CraftPlayer)player).getHandle().setResourcePack(pack, sha1);
}
public static float headRotation(Entity e){
@Override
public float headRotation(Entity e) {
return ((CraftEntity)e).getHandle().getHeadRotation();
}
@Override
public boolean hasItems(ItemStack stack) {
Set<String> keys = new HashSet<>(CraftItemStack.asNMSCopy(stack).getTag().c());
keys.remove("Enchantments");
keys.remove("Damage");
return !keys.isEmpty();
}
}

Datei anzeigen

@ -0,0 +1,124 @@
/*
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 com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketAdapter;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.events.PacketEvent;
import com.comphenix.protocol.reflect.StructureModifier;
import com.comphenix.protocol.wrappers.nbt.NbtBase;
import com.comphenix.protocol.wrappers.nbt.NbtCompound;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.UnpooledByteBufAllocator;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import java.util.List;
import java.util.Set;
import java.util.logging.Level;
import static de.steamwar.fightsystem.utils.ITechHider.bypass;
public class TechHider12 extends PacketAdapter {
private final Set<Integer> hiddenBlockIds = BlockIdWrapper.impl.getHiddenBlockIds();
private final int obfuscateWith = BlockIdWrapper.impl.getObfuscateWith();
public TechHider12() {
super(FightSystem.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--){
NbtCompound nbt = (NbtCompound)nmsTags.get(i);
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();
byte [] data = byteArray.read(0);
ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.directBuffer(data.length + 100);
int i = 0;
while(i < data.length){
byte bitsPerBlock = data[i++];
buffer.writeByte(bitsPerBlock);
if(bitsPerBlock != 13){
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 entry = ITechHider.readVarInt(data, i);
i += ITechHider.readVarIntLength(data, i);
if(hiddenBlockIds.contains(entry)){
entry = obfuscateWith;
changed = true;
}
buffer.writeBytes(ITechHider.writeVarInt(entry));
}
}else{
buffer.writeByte(data[++i]); //Empty palette
Bukkit.getLogger().log(Level.SEVERE, "Full chunk occured");
}
int dataArrayLength = ITechHider.readVarInt(data, i);
int dataArrayLengthLength = ITechHider.readVarIntLength(data, i);
buffer.writeBytes(data, i, dataArrayLength*8 + dataArrayLengthLength);
i += dataArrayLengthLength;
i += dataArrayLength * 8;
buffer.writeBytes(data, i, 4096);
i += 4096; //Skylight (Not in Nether/End!!!) 2048 + Blocklight 2048
}
if(changed){
data = new byte[buffer.readableBytes()];
buffer.readBytes(data);
byteArray.write(0, data);
}
}
}

Datei anzeigen

@ -1,122 +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.utils;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketAdapter;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.events.PacketEvent;
import com.comphenix.protocol.reflect.StructureModifier;
import com.comphenix.protocol.wrappers.nbt.NbtBase;
import com.comphenix.protocol.wrappers.nbt.NbtCompound;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.IFightSystem;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.UnpooledByteBufAllocator;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import java.util.List;
import java.util.Set;
import java.util.logging.Level;
import static de.steamwar.fightsystem.utils.ITechHider.bypass;
class TechHider_12 {
private TechHider_12(){}
static PacketAdapter chunkHider(Set<Integer> hiddenBlockIds, int obfuscateWith){
return new PacketAdapter(IFightSystem.getPlugin(), PacketType.Play.Server.MAP_CHUNK) {
@Override
public void onPacketSending(PacketEvent e) {
PacketContainer packet = e.getPacket();
StructureModifier<Integer> ints = packet.getIntegers();
int chunkX = ints.read(0);
int chunkZ = ints.read(1);
Player p = e.getPlayer();
if(bypass(p, chunkX, chunkZ))
return;
packet = packet.shallowClone();
e.setPacket(packet);
StructureModifier<List<NbtBase<?>>> list = packet.getListNbtModifier();
List<NbtBase<?>> nmsTags = list.read(0);
boolean changed = false;
for(int i = nmsTags.size() - 1; i >= 0; i--){
NbtCompound nbt = (NbtCompound)nmsTags.get(i);
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();
byte [] data = byteArray.read(0);
ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.directBuffer(data.length + 100);
int i = 0;
while(i < data.length){
byte bitsPerBlock = data[i++];
buffer.writeByte(bitsPerBlock);
if(bitsPerBlock != 13){
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 entry = ITechHider.readVarInt(data, i);
i += ITechHider.readVarIntLength(data, i);
if(hiddenBlockIds.contains(entry)){
entry = obfuscateWith;
changed = true;
}
buffer.writeBytes(ITechHider.writeVarInt(entry));
}
}else{
buffer.writeByte(data[++i]); //Empty palette
Bukkit.getLogger().log(Level.SEVERE, "Full chunk 1.12 occured");
}
int dataArrayLength = ITechHider.readVarInt(data, i);
int dataArrayLengthLength = ITechHider.readVarIntLength(data, i);
buffer.writeBytes(data, i, dataArrayLength*8 + dataArrayLengthLength);
i += dataArrayLengthLength;
i += dataArrayLength * 8;
buffer.writeBytes(data, i, 4096);
i += 4096; //Skylight (Not in Nether/End!!!) 2048 + Blocklight 2048
}
if(changed){
data = new byte[buffer.readableBytes()];
buffer.readBytes(data);
byteArray.write(0, data);
}
}
};
}
}

Datei anzeigen

@ -1,7 +1,7 @@
/*
/*
This file is a part of the SteamWar software.
Copyright (C) 2020 SteamWar.de-Serverteam
Copyright (C) 2021 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
@ -15,24 +15,18 @@
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;
package de.steamwar.fightsystem.utils;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
import org.bukkit.ChatColor;
import org.bukkit.DyeColor;
import org.bukkit.Material;
import org.bukkit.scoreboard.Team;
import java.util.Collections;
import java.util.Set;
class FightTeam_12 {
private FightTeam_12(){}
public class WorldeditWrapper12 extends WorldeditWrapper8 {
@SuppressWarnings("deprecation")
private static final int COLOR_TO_REPLACE = DyeColor.PINK.getWoolData();
@ -42,16 +36,10 @@ class FightTeam_12 {
@SuppressWarnings("deprecation")
private static final BaseBlock CONCRETE_POWDER = new BaseBlock(Material.CONCRETE_POWDER.getId(), COLOR_TO_REPLACE);
private static final Set<BaseBlock> CONCRETE_SET = Collections.singleton(CONCRETE);
private static final Set<BaseBlock> CONCRETE_POWDER_SET = Collections.singleton(CONCRETE_POWDER);
static void setTeamColor(Team team, ChatColor color){
team.setColor(color);
team.setOption(Team.Option.NAME_TAG_VISIBILITY, Team.OptionStatus.FOR_OWN_TEAM);
}
static void replaceTeamColor(Clipboard clipboard, DyeColor c) throws WorldEditException {
FightTeam_8.replaceTeamColor(clipboard, c);
@SuppressWarnings("deprecation")
@Override
public void replaceTeamColor(Clipboard clipboard, DyeColor c) throws WorldEditException {
super.replaceTeamColor(clipboard, c);
Vector minimum = clipboard.getRegion().getMinimumPoint();
BaseBlock concrete = new BaseBlock(CONCRETE.getId(), c.getWoolData());

Datei anzeigen

@ -17,19 +17,6 @@
<artifactId>FightSystem_14</artifactId>
<version>1.0</version>
<build>
<sourceDirectory>src</sourceDirectory>
<resources>
<resource>
<directory>src</directory>
<excludes>
<exclude>**/*.java</exclude>
<exclude>**/*.kt</exclude>
</excludes>
</resource>
</resources>
</build>
<dependencies>
<dependency>
<groupId>steamwar</groupId>
@ -47,12 +34,7 @@
</dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>FightSystem_API</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>FightSystem_12</artifactId>
<artifactId>FightSystem_Core</artifactId>
<version>1.0</version>
</dependency>
</dependencies>

Datei anzeigen

@ -1,42 +0,0 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2020 SteamWar.de-Serverteam
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.fightsystem.listener;
import org.bukkit.craftbukkit.v1_14_R1.inventory.CraftItemStack;
import org.bukkit.inventory.ItemStack;
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;
public class PersonalKitCreator_14 {
private PersonalKitCreator_14(){}
public static boolean hasAttributeModifier(ItemStack stack){
return stack.hasItemMeta() && Objects.requireNonNull(stack.getItemMeta()).hasAttributeModifiers();
}
public static boolean hasItems(ItemStack stack){
Set<String> keys = new HashSet<>(CraftItemStack.asNMSCopy(stack).getTag().getKeys());
keys.remove("Enchantments");
keys.remove("Damage");
return !keys.isEmpty();
}
}

Datei anzeigen

@ -1,59 +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 org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.data.BlockData;
import org.bukkit.block.data.Waterlogged;
class WaterRemover_14 {
private WaterRemover_14(){}
static boolean isWater(Block block){
if(block.getType() == Material.WATER)
return true;
BlockData data = block.getBlockData();
if(!(data instanceof Waterlogged))
return false;
return ((Waterlogged) data).isWaterlogged();
}
static boolean removeWater(Block block){
if(block.getType() == Material.WATER){
block.setType(Material.AIR);
return true;
}
BlockData data = block.getBlockData();
if(!(data instanceof Waterlogged))
return false;
Waterlogged waterlogged = (Waterlogged) data;
if(waterlogged.isWaterlogged()){
block.setType(Material.AIR);
return true;
}
return false;
}
}

Datei anzeigen

@ -1,7 +1,7 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2020 SteamWar.de-Serverteam
Copyright (C) 2021 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
@ -15,33 +15,29 @@
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.record;
package de.steamwar.fightsystem.utils;
import net.minecraft.server.v1_14_R1.BlockPosition;
import net.minecraft.server.v1_14_R1.EntityPose;
import net.minecraft.server.v1_14_R1.IBlockData;
import net.minecraft.server.v1_14_R1.WorldServer;
import de.steamwar.fightsystem.Config;
import net.minecraft.server.v1_14_R1.*;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.craftbukkit.v1_14_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_14_R1.block.CraftBlock;
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;
public class RecordSystem_14 {
private RecordSystem_14(){}
static int blockToId(Block block){
public class BlockIdWrapper14 implements BlockIdWrapper.IBlockIdWrapper {
@Override
public int blockToId(Block block) {
return net.minecraft.server.v1_14_R1.Block.REGISTRY_ID.getId(((CraftBlock)block).getNMS());
}
static Object getPose(boolean sneaking){
return sneaking ? EntityPose.SNEAKING : EntityPose.STANDING;
}
static void setBlock(World world, int x, int y, int z, int blockState){
@Override
public void setBlock(World world, int x, int y, int z, int blockState) {
IBlockData blockData = Objects.requireNonNull(net.minecraft.server.v1_14_R1.Block.REGISTRY_ID.fromId(blockState));
WorldServer cworld = ((CraftWorld)world).getHandle();
BlockPosition pos = new BlockPosition(x, y, z);
@ -49,4 +45,35 @@ public class RecordSystem_14 {
cworld.setTypeAndData(pos, blockData, 1042);
cworld.getChunkProvider().flagDirty(pos);
}
@Override
public Set<Integer> getHiddenBlockIds() {
Set<Integer> hiddenBlockIds = new HashSet<>();
for(String tag : Config.HiddenBlocks){
for(IBlockData data : IRegistry.BLOCK.get(new MinecraftKey(tag)).getStates().a()){
hiddenBlockIds.add(net.minecraft.server.v1_14_R1.Block.getCombinedId(data));
}
}
if(Config.HiddenBlocks.contains("water")){
Fluid water = FluidTypes.WATER.a(false);
for(IBlockData data : net.minecraft.server.v1_14_R1.Block.REGISTRY_ID){
if(data.p() == water){
hiddenBlockIds.add(net.minecraft.server.v1_14_R1.Block.getCombinedId(data));
}
}
}
return hiddenBlockIds;
}
@Override
public int getObfuscateWith() {
return net.minecraft.server.v1_14_R1.Block.getCombinedId(IRegistry.BLOCK.get(new MinecraftKey(Config.ObfuscateWith)).getBlockData());
}
@Override
public Object getPose(boolean sneaking) {
return sneaking ? EntityPose.SNEAKING : EntityPose.STANDING;
}
}

Datei anzeigen

@ -1,7 +1,7 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2020 SteamWar.de-Serverteam
Copyright (C) 2021 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
@ -15,31 +15,36 @@
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;
package de.steamwar.fightsystem.utils;
import de.steamwar.core.events.ChunkListener;
import de.steamwar.fightsystem.fight.FightWorld;
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.craftbukkit.v1_14_R1.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_14_R1.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_14_R1.inventory.CraftItemStack;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
public class FightWorld_14 {
private FightWorld_14(){}
import java.util.HashSet;
import java.util.Set;
static void resetChunk(World world, World backup, int x, int z, boolean isPaper){
public class CraftbukkitWrapper14 implements CraftbukkitWrapper.ICraftbukkitWrapper {
@Override
public 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());
if (!isPaper) {
if (!FightWorld.isPaper()) {
w.tileEntityList.removeAll(chunk.tileEntities.values());
}
chunk.tileEntities.clear();
@ -51,11 +56,21 @@ public class FightWorld_14 {
}
}
public static void sendResourcePack(Player player, String pack, String sha1){
@Override
public void sendResourcePack(Player player, String pack, String sha1) {
((CraftPlayer)player).getHandle().setResourcePack(pack, sha1);
}
public static float headRotation(Entity e){
@Override
public float headRotation(Entity e) {
return ((CraftEntity)e).getHandle().getHeadRotation();
}
@Override
public boolean hasItems(ItemStack stack) {
Set<String> keys = new HashSet<>(CraftItemStack.asNMSCopy(stack).getTag().getKeys());
keys.remove("Enchantments");
keys.remove("Damage");
return !keys.isEmpty();
}
}

Datei anzeigen

@ -0,0 +1,111 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2021 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.DyeColor;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.data.BlockData;
import org.bukkit.block.data.Waterlogged;
import org.bukkit.event.block.BlockPhysicsEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.BlockDataMeta;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.Objects;
public class FlatteningWrapper14 implements FlatteningWrapper.IFlatteningWrapper {
@Override
public DyeColor getSilver() {
return DyeColor.LIGHT_GRAY;
}
@Override
public boolean isWater(Block block) {
if(block.getType() == Material.WATER)
return true;
BlockData data = block.getBlockData();
if(!(data instanceof Waterlogged))
return false;
return ((Waterlogged) data).isWaterlogged();
}
@Override
public boolean removeWater(Block block) {
if(block.getType() == Material.WATER){
block.setType(Material.AIR);
return true;
}
BlockData data = block.getBlockData();
if(!(data instanceof Waterlogged))
return false;
Waterlogged waterlogged = (Waterlogged) data;
if(waterlogged.isWaterlogged()){
block.setType(Material.AIR);
return true;
}
return false;
}
@Override
public boolean containsBlockMeta(ItemMeta meta) {
return meta instanceof BlockDataMeta && ((BlockDataMeta)meta).hasBlockData();
}
@Override
public boolean hasAttributeModifier(ItemStack stack) {
return stack.hasItemMeta() && Objects.requireNonNull(stack.getItemMeta()).hasAttributeModifiers();
}
@Override
public Material onBreak(Material type) {
switch(type){
case REDSTONE_WIRE:
return Material.REDSTONE;
case PISTON_HEAD:
return Material.PISTON;
case ICE:
return Material.AIR;
default:
return type;
}
}
@Override
public boolean doRecord(BlockPhysicsEvent e) {
return e.getBlock() == e.getSourceBlock() || e.getChangedType() == Material.AIR;
}
@Override
public void forceLoadChunk(World world, int cX, int cZ) {
world.setChunkForceLoaded(cX, cZ, true);
}
@Override
public boolean checkPistonMoving(Block block) {
return block.getType() == Material.MOVING_PISTON;
}
}

Datei anzeigen

@ -1,7 +1,7 @@
/*
/*
This file is a part of the SteamWar software.
Copyright (C) 2020 SteamWar.de-Serverteam
Copyright (C) 2021 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
@ -15,16 +15,15 @@
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;
package de.steamwar.fightsystem.utils;
import org.bukkit.Sound;
class Countdown_14 {
private Countdown_14(){}
static Sound getSound(SWSound sound){
public class SWSound14 implements SWSound.ISWSound {
@Override
public Sound getSound(SWSound sound) {
switch(sound){
case ENTITY_WITHER_DEATH:
return Sound.ENTITY_WITHER_DEATH;
@ -32,6 +31,8 @@ class Countdown_14 {
return Sound.BLOCK_NOTE_BLOCK_BASS;
case BLOCK_NOTE_PLING:
return Sound.BLOCK_NOTE_BLOCK_PLING;
case ENTITY_GENERIC_EXPLODE:
return Sound.ENTITY_GENERIC_EXPLODE;
default:
return null;
}

Datei anzeigen

@ -0,0 +1,199 @@
/*
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 com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketAdapter;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.events.PacketEvent;
import com.comphenix.protocol.reflect.StructureModifier;
import com.comphenix.protocol.wrappers.nbt.NbtBase;
import com.comphenix.protocol.wrappers.nbt.NbtCompound;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.UnpooledByteBufAllocator;
import org.bukkit.entity.Player;
import java.nio.ByteBuffer;
import java.nio.LongBuffer;
import java.util.List;
import java.util.Set;
import static de.steamwar.fightsystem.utils.ITechHider.bypass;
public class TechHider14 extends PacketAdapter {
private final Set<Integer> hiddenBlockIds = BlockIdWrapper.impl.getHiddenBlockIds();
private final int obfuscateWith = BlockIdWrapper.impl.getObfuscateWith();
public TechHider14(){
super(FightSystem.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(hiddenBlockIds.contains(blockId)){
buffer.writeBytes(ITechHider.writeVarInt(obfuscateWith));
changed = true;
}else{
buffer.writeBytes(data, i, actPaletteLength);
}
i += actPaletteLength;
}
//We modify only the chunk palette for performance reasons
int dataArrayLength = ITechHider.readVarInt(data, i);
int dataArrayLengthLength = ITechHider.readVarIntLength(data, i);
buffer.writeBytes(data, i, dataArrayLength * 8 + dataArrayLengthLength);
i += dataArrayLengthLength;
i += dataArrayLength * 8;
}else{
//Full Chunk/no palette, so the chunk has to be crawled through
int dataArrayLength = ITechHider.readVarInt(data, i);
int dataArrayLengthLength = ITechHider.readVarIntLength(data, i);
buffer.writeBytes(data, i, 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;
}
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);
}
}
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;
}
}
}
}

Datei anzeigen

@ -1,226 +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.utils;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketAdapter;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.events.PacketEvent;
import com.comphenix.protocol.reflect.StructureModifier;
import com.comphenix.protocol.wrappers.nbt.NbtBase;
import com.comphenix.protocol.wrappers.nbt.NbtCompound;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.IFightSystem;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.UnpooledByteBufAllocator;
import net.minecraft.server.v1_14_R1.*;
import org.bukkit.entity.Player;
import java.nio.ByteBuffer;
import java.nio.LongBuffer;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import static de.steamwar.fightsystem.utils.ITechHider.bypass;
public class TechHider_14 {
private TechHider_14(){}
static Set<Integer> getHiddenBlockIds() {
Set<Integer> hiddenBlockIds = new HashSet<>();
for(String tag : Config.HiddenBlocks){
for(IBlockData data : IRegistry.BLOCK.get(new MinecraftKey(tag)).getStates().a()){
hiddenBlockIds.add(Block.getCombinedId(data));
}
}
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 int getObfuscateWith() {
return Block.getCombinedId(IRegistry.BLOCK.get(new MinecraftKey(Config.ObfuscateWith)).getBlockData());
}
static PacketAdapter chunkHider(Set<Integer> hiddenBlockIds, int obfuscateWith){
/*
* Bevor editing this function read and understand: https://wiki.vg/Chunk_Format
* */
return new PacketAdapter(IFightSystem.getPlugin(), PacketType.Play.Server.MAP_CHUNK) {
@Override
public void onPacketSending(PacketEvent e) {
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(hiddenBlockIds.contains(blockId)){
buffer.writeBytes(ITechHider.writeVarInt(obfuscateWith));
changed = true;
}else{
buffer.writeBytes(data, i, actPaletteLength);
}
i += actPaletteLength;
}
//We modify only the chunk palette for performance reasons
int dataArrayLength = ITechHider.readVarInt(data, i);
int dataArrayLengthLength = ITechHider.readVarIntLength(data, i);
buffer.writeBytes(data, i, dataArrayLength * 8 + dataArrayLengthLength);
i += dataArrayLengthLength;
i += dataArrayLength * 8;
}else{
//Full Chunk/no palette, so the chunk has to be crawled through
int dataArrayLength = ITechHider.readVarInt(data, i);
int dataArrayLengthLength = ITechHider.readVarIntLength(data, i);
buffer.writeBytes(data, i, 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;
}
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);
}
}
};
}
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;
}
}
}
}

Datei anzeigen

@ -1,7 +1,7 @@
/*
/*
This file is a part of the SteamWar software.
Copyright (C) 2020 SteamWar.de-Serverteam
Copyright (C) 2021 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
@ -15,9 +15,9 @@
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;
package de.steamwar.fightsystem.utils;
import com.sk89q.jnbt.NBTInputStream;
import com.sk89q.worldedit.EditSession;
@ -39,21 +39,19 @@ import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockTypes;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.utils.Region;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.sql.Schematic;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.DyeColor;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.scoreboard.Team;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Objects;
import java.util.zip.GZIPInputStream;
public class FightTeam_14 {
private FightTeam_14(){}
public class WorldeditWrapper14 implements WorldeditWrapper.IWorldeditWrapper {
private static final BaseBlock WOOL = Objects.requireNonNull(BlockTypes.PINK_WOOL).getDefaultState().toBaseBlock();
private static final BaseBlock CLAY = Objects.requireNonNull(BlockTypes.PINK_TERRACOTTA).getDefaultState().toBaseBlock();
@ -63,12 +61,8 @@ public class FightTeam_14 {
private static final BaseBlock CONCRETE_POWDER = Objects.requireNonNull(BlockTypes.PINK_CONCRETE_POWDER).getDefaultState().toBaseBlock();
private static final BaseBlock CARPET = Objects.requireNonNull(BlockTypes.PINK_CARPET).getDefaultState().toBaseBlock();
static void setTeamColor(Team team, ChatColor color){
team.setColor(color);
team.setOption(Team.Option.NAME_TAG_VISIBILITY, Team.OptionStatus.FOR_OWN_TEAM);
}
static void replaceTeamColor(Clipboard clipboard, DyeColor c) throws WorldEditException {
@Override
public void replaceTeamColor(Clipboard clipboard, DyeColor c) throws WorldEditException {
BlockVector3 minimum = clipboard.getRegion().getMinimumPoint();
BaseBlock wool = Objects.requireNonNull(BlockTypes.get(c.name().toLowerCase() + "_wool")).getDefaultState().toBaseBlock();
BaseBlock clay = Objects.requireNonNull(BlockTypes.get(c.name().toLowerCase() + "_terracotta")).getDefaultState().toBaseBlock();
@ -103,7 +97,8 @@ public class FightTeam_14 {
}
}
static void pasteSchematic(Clipboard clipboard, Region region, boolean rotate) {
@Override
public void pasteSchematic(Clipboard clipboard, Region region, boolean rotate) {
BlockVector3 paste = BlockVector3.at(region.centerX(), region.getMinY(), region.centerZ());
World w = new BukkitWorld(Bukkit.getWorlds().get(0));
@ -135,7 +130,8 @@ public class FightTeam_14 {
e.flushSession();
}
static void pasteChar(Clipboard character, int charOffset, int length, int x, int y, int z, AffineTransform aT){
@Override
public void pasteChar(Clipboard character, int charOffset, int length, int x, int y, int z, AffineTransform aT) {
BlockVector3 offset = character.getRegion().getMinimumPoint().subtract(character.getOrigin());
BlockVector3 v = BlockVector3.ZERO.subtract(- charOffset + length / 2, 0, 0).subtract(offset);
v = aT.apply(v.toVector3()).toBlockPoint();
@ -148,15 +144,13 @@ public class FightTeam_14 {
e.flushSession();
}
static Clipboard loadSchem(NBTInputStream stream) throws IOException {
return new SpongeSchematicReader(stream).read();
@Override
public Clipboard loadChar(String charName) throws IOException {
return new SpongeSchematicReader(new NBTInputStream(new GZIPInputStream(new FileInputStream(new File(FightSystem.getPlugin().getDataFolder(), "text/" + charName + ".schem"))))).read();
}
public static boolean checkPistonMoving(Block block){
return block.getType() == Material.MOVING_PISTON;
}
public static void saveSchem(Schematic schem, Region region, int minY) {
@Override
public void saveSchem(Schematic schem, Region region, int minY) {
World w = new BukkitWorld(Bukkit.getWorlds().get(0));
BlockVector3 min = BlockVector3.at(region.getMinX(), minY, region.getMinZ());
CuboidRegion cuboidRegion = new CuboidRegion(w, min, BlockVector3.at(region.getMaxX(), region.getMaxY(), region.getMaxZ()));

Datei anzeigen

@ -17,19 +17,6 @@
<artifactId>FightSystem_15</artifactId>
<version>1.0</version>
<build>
<sourceDirectory>src</sourceDirectory>
<resources>
<resource>
<directory>src</directory>
<excludes>
<exclude>**/*.java</exclude>
<exclude>**/*.kt</exclude>
</excludes>
</resource>
</resources>
</build>
<dependencies>
<dependency>
<groupId>steamwar</groupId>
@ -47,12 +34,7 @@
</dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>FightSystem_API</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>FightSystem_14</artifactId>
<artifactId>FightSystem_Core</artifactId>
<version>1.0</version>
</dependency>
</dependencies>

Datei anzeigen

@ -1,36 +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 org.bukkit.craftbukkit.v1_15_R1.inventory.CraftItemStack;
import org.bukkit.inventory.ItemStack;
import java.util.HashSet;
import java.util.Set;
public class PersonalKitCreator_15 {
public static boolean hasItems(ItemStack stack){
Set<String> keys = new HashSet<>(CraftItemStack.asNMSCopy(stack).getTag().getKeys());
keys.remove("Enchantments");
keys.remove("Damage");
return !keys.isEmpty();
}
}

Datei anzeigen

@ -1,7 +1,7 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2020 SteamWar.de-Serverteam
Copyright (C) 2021 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
@ -15,33 +15,29 @@
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.record;
package de.steamwar.fightsystem.utils;
import net.minecraft.server.v1_15_R1.BlockPosition;
import net.minecraft.server.v1_15_R1.EntityPose;
import net.minecraft.server.v1_15_R1.IBlockData;
import net.minecraft.server.v1_15_R1.WorldServer;
import de.steamwar.fightsystem.Config;
import net.minecraft.server.v1_15_R1.*;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.craftbukkit.v1_15_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_15_R1.block.CraftBlock;
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;
class RecordSystem_15 {
private RecordSystem_15(){}
static int blockToId(Block block){
public class BlockIdWrapper15 implements BlockIdWrapper.IBlockIdWrapper {
@Override
public int blockToId(Block block) {
return net.minecraft.server.v1_15_R1.Block.REGISTRY_ID.getId(((CraftBlock)block).getNMS());
}
static Object getPose(boolean sneaking){
return sneaking ? EntityPose.CROUCHING : EntityPose.STANDING;
}
static void setBlock(World world, int x, int y, int z, int blockState){
@Override
public void setBlock(World world, int x, int y, int z, int blockState) {
IBlockData blockData = Objects.requireNonNull(net.minecraft.server.v1_15_R1.Block.REGISTRY_ID.fromId(blockState));
WorldServer cworld = ((CraftWorld)world).getHandle();
BlockPosition pos = new BlockPosition(x, y, z);
@ -49,4 +45,35 @@ class RecordSystem_15 {
cworld.setTypeAndData(pos, blockData, 1042);
cworld.getChunkProvider().flagDirty(pos);
}
@Override
public Set<Integer> getHiddenBlockIds() {
Set<Integer> hiddenBlockIds = new HashSet<>();
for(String tag : Config.HiddenBlocks){
for(IBlockData data : IRegistry.BLOCK.get(new MinecraftKey(tag)).getStates().a()){
hiddenBlockIds.add(net.minecraft.server.v1_15_R1.Block.getCombinedId(data));
}
}
if(Config.HiddenBlocks.contains("water")){
Fluid water = FluidTypes.WATER.a(false);
for(IBlockData data : net.minecraft.server.v1_15_R1.Block.REGISTRY_ID){
if(data.getFluid() == water){
hiddenBlockIds.add(net.minecraft.server.v1_15_R1.Block.getCombinedId(data));
}
}
}
return hiddenBlockIds;
}
@Override
public int getObfuscateWith() {
return net.minecraft.server.v1_15_R1.Block.getCombinedId(IRegistry.BLOCK.get(new MinecraftKey(Config.ObfuscateWith)).getBlockData());
}
@Override
public Object getPose(boolean sneaking) {
return sneaking ? EntityPose.CROUCHING : EntityPose.STANDING;
}
}

Datei anzeigen

@ -1,7 +1,7 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2020 SteamWar.de-Serverteam
Copyright (C) 2021 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
@ -15,31 +15,36 @@
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;
package de.steamwar.fightsystem.utils;
import de.steamwar.core.events.ChunkListener;
import de.steamwar.fightsystem.fight.FightWorld;
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.craftbukkit.v1_15_R1.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_15_R1.inventory.CraftItemStack;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
public class FightWorld_15 {
private FightWorld_15(){}
import java.util.HashSet;
import java.util.Set;
static void resetChunk(World world, World backup, int x, int z, boolean isPaper){
public class CraftbukkitWrapper15 implements CraftbukkitWrapper.ICraftbukkitWrapper {
@Override
public 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());
if (!isPaper) {
if (!FightWorld.isPaper()) {
w.tileEntityList.removeAll(chunk.tileEntities.values());
}
chunk.tileEntities.clear();
@ -51,11 +56,21 @@ public class FightWorld_15 {
}
}
public static void sendResourcePack(Player player, String pack, String sha1){
@Override
public void sendResourcePack(Player player, String pack, String sha1) {
((CraftPlayer)player).getHandle().setResourcePack(pack, sha1);
}
public static float headRotation(Entity e){
@Override
public float headRotation(Entity e) {
return ((CraftEntity)e).getHandle().getHeadRotation();
}
@Override
public boolean hasItems(ItemStack stack) {
Set<String> keys = new HashSet<>(CraftItemStack.asNMSCopy(stack).getTag().getKeys());
keys.remove("Enchantments");
keys.remove("Damage");
return !keys.isEmpty();
}
}

Datei anzeigen

@ -1,54 +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.utils;
import de.steamwar.fightsystem.Config;
import net.minecraft.server.v1_15_R1.*;
import java.util.HashSet;
import java.util.Set;
class TechHider_15 {
private TechHider_15(){}
static Set<Integer> getHiddenBlockIds() {
Set<Integer> hiddenBlockIds = new HashSet<>();
for(String tag : Config.HiddenBlocks){
for(IBlockData data : IRegistry.BLOCK.get(new MinecraftKey(tag)).getStates().a()){
hiddenBlockIds.add(Block.getCombinedId(data));
}
}
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 int getObfuscateWith() {
return Block.getCombinedId(IRegistry.BLOCK.get(new MinecraftKey(Config.ObfuscateWith)).getBlockData());
}
}

Datei anzeigen

@ -17,19 +17,6 @@
<artifactId>FightSystem_8</artifactId>
<version>1.0</version>
<build>
<sourceDirectory>src</sourceDirectory>
<resources>
<resource>
<directory>src</directory>
<excludes>
<exclude>**/*.java</exclude>
<exclude>**/*.kt</exclude>
</excludes>
</resource>
</resources>
</build>
<dependencies>
<dependency>
<groupId>steamwar</groupId>
@ -40,7 +27,7 @@
</dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>FightSystem_API</artifactId>
<artifactId>FightSystem_Core</artifactId>
<version>1.0</version>
</dependency>
<dependency>

Datei anzeigen

@ -19,11 +19,14 @@
package de.steamwar.fightsystem.fight;
import org.bukkit.entity.Player;
import org.bukkit.ChatColor;
import org.bukkit.scoreboard.Team;
public interface IFightTeam {
public class FightTeam8 implements FightTeam.IFightTeam {
@Override
public void setTeamColor(Team team, ChatColor color){
team.setPrefix("§" + color.getChar());
}
boolean isBlue();
boolean isPlayerInTeam(Player player);
boolean canPlayerEntern(Player player);
}

Datei anzeigen

@ -1,7 +1,7 @@
/*
/*
This file is a part of the SteamWar software.
Copyright (C) 2020 SteamWar.de-Serverteam
Copyright (C) 2021 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
@ -15,12 +15,11 @@
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;
package de.steamwar.fightsystem.listener;
public enum SWSound {
ENTITY_WITHER_DEATH,
BLOCK_NOTE_PLING,
BLOCK_NOTE_BASS
import org.bukkit.event.Listener;
public class ArrowPickup8 implements Listener {
}

Datei anzeigen

@ -1,7 +1,7 @@
/*
/*
This file is a part of the SteamWar software.
Copyright (C) 2020 SteamWar.de-Serverteam
Copyright (C) 2021 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
@ -15,16 +15,15 @@
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;
package de.steamwar.fightsystem.listener;
import org.bukkit.DyeColor;
import org.bukkit.entity.Arrow;
class ColorConverter_14 {
private ColorConverter_14(){}
static DyeColor getSilver(){
return DyeColor.LIGHT_GRAY;
public class ArrowStopper8 implements ArrowStopper.IArrowStopper {
@Override
public boolean isInBlock(Arrow e) {
return false;
}
}

Datei anzeigen

@ -1,7 +1,7 @@
/*
/*
This file is a part of the SteamWar software.
Copyright (C) 2020 SteamWar.de-Serverteam
Copyright (C) 2021 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
@ -15,16 +15,11 @@
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;
package de.steamwar.fightsystem.listener;
import org.bukkit.DyeColor;
import org.bukkit.event.Listener;
class ColorConverter_8 {
private ColorConverter_8(){}
static DyeColor getSilver(){
return DyeColor.SILVER;
}
public class DenyWorldInteraction8 implements Listener {
}

Datei anzeigen

@ -1,40 +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 org.bukkit.Material;
import org.bukkit.block.Block;
public class WaterRemover_8 {
private WaterRemover_8(){}
static boolean isWater(Block block){
Material type = block.getType();
return type == Material.WATER || type == Material.STATIONARY_WATER;
}
static boolean removeWater(Block block){
if(isWater(block)){
block.setType(Material.AIR);
return true;
}
return false;
}
}

Datei anzeigen

@ -1,7 +1,7 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2020 SteamWar.de-Serverteam
Copyright (C) 2021 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
@ -15,20 +15,31 @@
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 org.bukkit.World;
import org.bukkit.block.Block;
import java.util.HashSet;
import java.util.Set;
class TechHider_8 {
private TechHider_8(){}
public class BlockIdWrapper8 implements BlockIdWrapper.IBlockIdWrapper {
@Override
public int blockToId(Block block) {
return block.getTypeId() << 4 + block.getData();
}
static Set<Integer> getHiddenBlockIds() {
@Override
public void setBlock(World world, int x, int y, int z, int blockState) {
world.getBlockAt(x, y, z).setTypeIdAndData(blockState >> 4, (byte)(blockState & 0b1111), false);
}
@Override
public Set<Integer> getHiddenBlockIds() {
Set<Integer> hiddenBlockIds = new HashSet<>();
for(String tag : Config.HiddenBlocks){
hiddenBlockIds.add(Material.matchMaterial(tag).getId() << 4);
@ -36,7 +47,13 @@ class TechHider_8 {
return hiddenBlockIds;
}
static int getObfuscateWith() {
@Override
public int getObfuscateWith() {
return Material.matchMaterial(Config.ObfuscateWith).getId() << 4;
}
@Override
public Object getPose(boolean sneaking) {
return null;
}
}

Datei anzeigen

@ -0,0 +1,58 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2021 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 com.comphenix.protocol.wrappers.EnumWrappers;
import net.md_5.bungee.api.chat.BaseComponent;
import net.minecraft.server.v1_8_R3.ChatComponentText;
import net.minecraft.server.v1_8_R3.PacketPlayOutChat;
import org.bukkit.Material;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.scoreboard.Team;
public class BountifulWrapper8 implements BountifulWrapper.IBountifulWrapper {
@Override
public boolean bowInHand(EnumWrappers.Hand hand, Player p) {
return p.getInventory().getItemInHand().getType() == Material.BOW;
}
@Override
public void toActionbar(Player player, BaseComponent... components) {
PacketPlayOutChat packet = new PacketPlayOutChat(new ChatComponentText(BaseComponent.toLegacyText(components)), (byte)2);
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
}
@Override
public void toChat(Player player, BaseComponent... components) {
PacketPlayOutChat packet = new PacketPlayOutChat(new ChatComponentText(BaseComponent.toLegacyText(components)), (byte)0);
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
}
@Override
public void setAttackSpeed(Player player) {
// nothing to do
}
@Override
public void setNametagVisibility(Team team) {
//nothing to do
}
}

Datei anzeigen

@ -1,7 +1,7 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2020 SteamWar.de-Serverteam
Copyright (C) 2021 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
@ -15,9 +15,9 @@
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;
package de.steamwar.fightsystem.utils;
import de.steamwar.core.events.ChunkListener;
import net.minecraft.server.v1_8_R3.Chunk;
@ -26,13 +26,17 @@ import org.bukkit.World;
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
public class FightWorld_8 {
private FightWorld_8(){}
import java.util.HashSet;
import java.util.Set;
static void resetChunk(World world, World backup, int x, int z, boolean isPaper){
public class CraftbukkitWrapper8 implements CraftbukkitWrapper.ICraftbukkitWrapper {
@Override
public 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);
@ -47,11 +51,21 @@ public class FightWorld_8 {
}
}
public static void sendResourcePack(Player player, String pack, String sha1){
@Override
public void sendResourcePack(Player player, String pack, String sha1) {
((CraftPlayer)player).getHandle().setResourcePack(pack, sha1);
}
public static float headRotation(Entity e){
@Override
public float headRotation(Entity e) {
return ((CraftEntity)e).getHandle().getHeadRotation();
}
@Override
public boolean hasItems(ItemStack stack) {
Set<String> keys = new HashSet<>(CraftItemStack.asNMSCopy(stack).getTag().c());
keys.remove("Enchantments");
keys.remove("Damage");
return !keys.isEmpty();
}
}

Datei anzeigen

@ -0,0 +1,89 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2021 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.DyeColor;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.event.block.BlockPhysicsEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
public class FlatteningWrapper8 implements FlatteningWrapper.IFlatteningWrapper {
@Override
public DyeColor getSilver() {
return DyeColor.SILVER;
}
@Override
public boolean isWater(Block block) {
Material type = block.getType();
return type == Material.WATER || type == Material.STATIONARY_WATER;
}
@Override
public boolean removeWater(Block block) {
if(isWater(block)){
block.setType(Material.AIR);
return true;
}
return false;
}
@Override
public boolean containsBlockMeta(ItemMeta meta) {
return false;
}
@Override
public boolean hasAttributeModifier(ItemStack stack) {
return false;
}
@Override
public Material onBreak(Material type) {
switch(type){
case REDSTONE_WIRE:
return Material.REDSTONE;
case PISTON_EXTENSION:
return Material.PISTON_BASE;
case ICE:
return Material.AIR;
default:
return type;
}
}
@Override
public boolean doRecord(BlockPhysicsEvent e) {
return e.getChangedType() != e.getBlock().getType();
}
@Override
public void forceLoadChunk(World world, int cX, int cZ) {
// not possible in 1.8
}
@Override
public boolean checkPistonMoving(Block block) {
return block.getType() == Material.PISTON_MOVING_PIECE;
}
}

Datei anzeigen

@ -1,7 +1,7 @@
/*
/*
This file is a part of the SteamWar software.
Copyright (C) 2020 SteamWar.de-Serverteam
Copyright (C) 2021 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
@ -15,16 +15,15 @@
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;
package de.steamwar.fightsystem.utils;
import org.bukkit.Sound;
class Countdown_8 {
private Countdown_8(){}
static Sound getSound(SWSound sound){
public class SWSound8 implements SWSound.ISWSound {
@Override
public Sound getSound(SWSound sound) {
switch(sound){
case ENTITY_WITHER_DEATH:
return Sound.WITHER_DEATH;
@ -32,6 +31,8 @@ class Countdown_8 {
return Sound.NOTE_BASS;
case BLOCK_NOTE_PLING:
return Sound.NOTE_PLING;
case ENTITY_GENERIC_EXPLODE:
return Sound.EXPLODE;
default:
return null;
}

Datei anzeigen

@ -1,7 +1,7 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2020 SteamWar.de-Serverteam
Copyright (C) 2021 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
@ -15,22 +15,23 @@
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.record;
package de.steamwar.fightsystem.utils;
import org.bukkit.World;
import org.bukkit.block.Block;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketAdapter;
import com.comphenix.protocol.events.PacketEvent;
import de.steamwar.fightsystem.FightSystem;
@SuppressWarnings("deprecation")
class RecordSystem_8 {
private RecordSystem_8(){}
public class TechHider8 extends PacketAdapter {
static int blockToId(Block block){
return block.getTypeId() << 4 + block.getData();
public TechHider8() {
super(FightSystem.getPlugin(), PacketType.Play.Server.MAP_CHUNK);
}
static void setBlock(World world, int x, int y, int z, int blockState){
world.getBlockAt(x, y, z).setTypeIdAndData(blockState >> 4, (byte)(blockState & 0b1111), false);
@Override
public void onPacketSending(PacketEvent e) {
// no implementation availible
}
}

Datei anzeigen

@ -1,7 +1,7 @@
/*
/*
This file is a part of the SteamWar software.
Copyright (C) 2020 SteamWar.de-Serverteam
Copyright (C) 2021 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
@ -15,9 +15,9 @@
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;
package de.steamwar.fightsystem.utils;
import com.sk89q.jnbt.NBTInputStream;
import com.sk89q.worldedit.EditSession;
@ -38,20 +38,19 @@ import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.session.ClipboardHolder;
import com.sk89q.worldedit.world.World;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.utils.Region;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.sql.Schematic;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.DyeColor;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.scoreboard.Team;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.zip.GZIPInputStream;
public class FightTeam_8 {
private FightTeam_8(){}
public class WorldeditWrapper8 implements WorldeditWrapper.IWorldeditWrapper {
@SuppressWarnings("deprecation")
private static final int COLOR_TO_REPLACE = DyeColor.PINK.getWoolData();
@ -67,11 +66,9 @@ public class FightTeam_8 {
@SuppressWarnings("deprecation")
private static final BaseBlock CARPET = new BaseBlock(Material.CARPET.getId(), COLOR_TO_REPLACE);
static void setTeamColor(Team team, ChatColor color){
team.setPrefix("§" + color.getChar());
}
static void replaceTeamColor(Clipboard clipboard, DyeColor c) throws WorldEditException {
@SuppressWarnings("deprecation")
@Override
public void replaceTeamColor(Clipboard clipboard, DyeColor c) throws WorldEditException {
Vector minimum = clipboard.getRegion().getMinimumPoint();
BaseBlock wool = new BaseBlock(WOOL.getId(), c.getWoolData());
BaseBlock clay = new BaseBlock(CLAY.getId(), c.getWoolData());
@ -100,10 +97,11 @@ public class FightTeam_8 {
}
}
static void pasteSchematic(Clipboard clipboard, Region paste, boolean rotate) {
@Override
public void pasteSchematic(Clipboard clipboard, Region region, boolean rotate) {
World w = new BukkitWorld(Bukkit.getWorlds().get(0));
Vector dimensions = clipboard.getDimensions();
Vector v = new Vector(paste.centerX(), paste.getMinY(), paste.centerZ());
Vector v = new Vector(region.centerX(), region.getMinY(), region.centerZ());
Vector offset = clipboard.getMinimumPoint().subtract(clipboard.getOrigin());
AffineTransform aT = new AffineTransform();
if(rotate){
@ -130,7 +128,8 @@ public class FightTeam_8 {
e.flushQueue();
}
static void pasteChar(Clipboard character, int charOffset, int length, int x, int y, int z, AffineTransform aT){
@Override
public void pasteChar(Clipboard character, int charOffset, int length, int x, int y, int z, AffineTransform aT) {
World w = new BukkitWorld(Bukkit.getWorlds().get(0));
Vector offset = character.getRegion().getMinimumPoint().subtract(character.getOrigin());
Vector v = Vector.ZERO.subtract(- charOffset + length / 2, 0, 0).subtract(offset);
@ -144,15 +143,13 @@ public class FightTeam_8 {
e.flushQueue();
}
static Clipboard loadSchem(NBTInputStream stream) throws IOException {
return new SchematicReader(stream).read(new BukkitWorld(Bukkit.getWorlds().get(0)).getWorldData());
@Override
public Clipboard loadChar(String charName) throws IOException {
return new SchematicReader(new NBTInputStream(new GZIPInputStream(new FileInputStream(new File(FightSystem.getPlugin().getDataFolder(), "text/" + charName + ".schematic"))))).read(new BukkitWorld(Bukkit.getWorlds().get(0)).getWorldData());
}
public static boolean checkPistonMoving(Block block){
return block.getType() == Material.PISTON_MOVING_PIECE;
}
public static void saveSchem(Schematic schem, Region region, int minY) {
@Override
public void saveSchem(Schematic schem, Region region, int minY) {
World w = new BukkitWorld(Bukkit.getWorlds().get(0));
Vector min = new Vector(region.getMinX(), minY, region.getMinZ());
CuboidRegion cuboidRegion = new CuboidRegion(w, min, new Vector(region.getMaxX(), region.getMaxY(), region.getMaxZ()));

Datei anzeigen

@ -17,28 +17,10 @@
<artifactId>FightSystem_9</artifactId>
<version>1.0</version>
<build>
<sourceDirectory>src</sourceDirectory>
<resources>
<resource>
<directory>src</directory>
<excludes>
<exclude>**/*.java</exclude>
<exclude>**/*.kt</exclude>
</excludes>
</resource>
</resources>
</build>
<dependencies>
<dependency>
<groupId>steamwar</groupId>
<artifactId>FightSystem_8</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>FightSystem_API</artifactId>
<artifactId>FightSystem_Core</artifactId>
<version>1.0</version>
</dependency>
<dependency>

Datei anzeigen

@ -23,7 +23,7 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerPickupArrowEvent;
class PickupArrowListener_9 implements Listener {
public class ArrowPickup9 implements Listener {
@EventHandler
public void onArrowPickup(PlayerPickupArrowEvent e){

Datei anzeigen

@ -1,7 +1,7 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2020 SteamWar.de-Serverteam
Copyright (C) 2021 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
@ -15,7 +15,7 @@
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;
@ -23,7 +23,7 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerSwapHandItemsEvent;
public class DenyWorldInteraction_10 implements Listener {
public class DenyWorldInteraction9 implements Listener {
@EventHandler
public void onSwapItems(PlayerSwapHandItemsEvent event) {

Datei anzeigen

@ -1,36 +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 org.bukkit.craftbukkit.v1_9_R2.inventory.CraftItemStack;
import org.bukkit.inventory.ItemStack;
import java.util.HashSet;
import java.util.Set;
public class PersonalKitCreator_9 {
public static boolean hasItems(ItemStack stack){
Set<String> keys = new HashSet<>(CraftItemStack.asNMSCopy(stack).getTag().c());
keys.remove("Enchantments");
keys.remove("Damage");
return !keys.isEmpty();
}
}

Datei anzeigen

@ -1,7 +1,7 @@
/*
/*
This file is a part of the SteamWar software.
Copyright (C) 2020 SteamWar.de-Serverteam
Copyright (C) 2021 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
@ -15,29 +15,44 @@
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;
package de.steamwar.fightsystem.utils;
import com.comphenix.protocol.wrappers.EnumWrappers;
import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.BaseComponent;
import org.bukkit.Material;
import org.bukkit.attribute.Attribute;
import org.bukkit.attribute.AttributeInstance;
import org.bukkit.entity.Player;
import org.bukkit.scoreboard.Team;
class BasicListener_9 {
private BasicListener_9(){}
public class BountifulWrapper9 implements BountifulWrapper.IBountifulWrapper {
@Override
public boolean bowInHand(EnumWrappers.Hand hand, Player p) {
return (hand == EnumWrappers.Hand.MAIN_HAND && p.getInventory().getItemInMainHand().getType() == Material.BOW) ||
(hand == EnumWrappers.Hand.OFF_HAND && p.getInventory().getItemInOffHand().getType() == Material.BOW);
}
static void toActionbar(Player player, BaseComponent... components){
@Override
public void toActionbar(Player player, BaseComponent... components) {
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, components);
}
static void toChat(Player player, BaseComponent... components){
@Override
public void toChat(Player player, BaseComponent... components) {
player.spigot().sendMessage(ChatMessageType.CHAT, components);
}
static void setAttackSpeed(Player player){
@Override
public void setAttackSpeed(Player player) {
AttributeInstance attribute = player.getAttribute(Attribute.GENERIC_ATTACK_SPEED);
attribute.setBaseValue(16);
}
@Override
public void setNametagVisibility(Team team) {
team.setOption(Team.Option.NAME_TAG_VISIBILITY, Team.OptionStatus.FOR_OWN_TEAM);
}
}

Datei anzeigen

@ -1,7 +1,7 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2020 SteamWar.de-Serverteam
Copyright (C) 2021 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
@ -15,24 +15,29 @@
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;
package de.steamwar.fightsystem.utils;
import de.steamwar.core.events.ChunkListener;
import de.steamwar.fightsystem.fight.FightWorld;
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.craftbukkit.v1_9_R2.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_9_R2.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_9_R2.inventory.CraftItemStack;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
public class FightWorld_9 {
private FightWorld_9(){}
import java.util.HashSet;
import java.util.Set;
static void resetChunk(World world, World backup, int x, int z, boolean isPaper){
public class CraftbukkitWrapper9 implements CraftbukkitWrapper.ICraftbukkitWrapper {
@Override
public 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);
@ -40,7 +45,7 @@ public class FightWorld_9 {
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());
if (!isPaper) {
if (!FightWorld.isPaper()) {
w.tileEntityList.removeAll(chunk.tileEntities.values());
}
chunk.tileEntities.clear();
@ -50,11 +55,21 @@ public class FightWorld_9 {
}
}
public static void sendResourcePack(Player player, String pack, String sha1){
@Override
public void sendResourcePack(Player player, String pack, String sha1) {
((CraftPlayer)player).getHandle().setResourcePack(pack, sha1);
}
public static float headRotation(Entity e){
@Override
public float headRotation(Entity e) {
return ((CraftEntity)e).getHandle().getHeadRotation();
}
@Override
public boolean hasItems(ItemStack stack) {
Set<String> keys = new HashSet<>(CraftItemStack.asNMSCopy(stack).getTag().c());
keys.remove("Enchantments");
keys.remove("Damage");
return !keys.isEmpty();
}
}

Datei anzeigen

@ -1,7 +1,7 @@
/*
/*
This file is a part of the SteamWar software.
Copyright (C) 2020 SteamWar.de-Serverteam
Copyright (C) 2021 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
@ -15,16 +15,15 @@
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;
package de.steamwar.fightsystem.utils;
import org.bukkit.Sound;
class Countdown_9 {
private Countdown_9(){}
static Sound getSound(SWSound sound){
public class SWSound9 implements SWSound.ISWSound {
@Override
public Sound getSound(SWSound sound){
switch(sound){
case ENTITY_WITHER_DEATH:
return Sound.ENTITY_WITHER_DEATH;
@ -32,6 +31,8 @@ class Countdown_9 {
return Sound.BLOCK_NOTE_BASS;
case BLOCK_NOTE_PLING:
return Sound.BLOCK_NOTE_PLING;
case ENTITY_GENERIC_EXPLODE:
return Sound.ENTITY_GENERIC_EXPLODE;
default:
return null;
}

Datei anzeigen

@ -1,52 +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;
import de.steamwar.sql.EventFight;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
public class IFightSystem {
private IFightSystem(){}
private static Plugin plugin;
private static EventFight eventFight;
private static Player eventLeiter;
public static void init(Plugin plugin){
IFightSystem.plugin = plugin;
}
static void setEventFight(EventFight ef){
eventFight = ef;
}
static void setEventLeiter(Player el){
eventLeiter = el;
}
public static Plugin getPlugin(){
return plugin;
}
public static EventFight getEventFight(){
return eventFight;
}
public static Player getEventLeiter(){
return eventLeiter;
}
}

Datei anzeigen

@ -1,42 +0,0 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2020 SteamWar.de-Serverteam
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.fightsystem.fight;
import org.bukkit.entity.Player;
public class IFight {
private IFight(){}
private static IFightTeam redTeam;
private static IFightTeam blueTeam;
public static void init(IFightTeam redTeam, IFightTeam blueTeam){
IFight.redTeam = redTeam;
IFight.blueTeam = blueTeam;
}
public static IFightTeam getPlayerTeam(Player player) {
if(redTeam.isPlayerInTeam(player))
return redTeam;
if(blueTeam.isPlayerInTeam(player))
return blueTeam;
return null;
}
}

Datei anzeigen

@ -14,29 +14,23 @@
<main.basedir>${project.basedir}/..</main.basedir>
</properties>
<artifactId>FightSystem_API</artifactId>
<artifactId>FightSystem_Core</artifactId>
<version>1.0</version>
<build>
<sourceDirectory>src</sourceDirectory>
<resources>
<resource>
<directory>src</directory>
<excludes>
<exclude>**/*.java</exclude>
<exclude>**/*.kt</exclude>
</excludes>
</resource>
</resources>
</build>
<dependencies>
<dependency>
<groupId>steamwar</groupId>
<artifactId>Spigot</artifactId>
<version>1.12</version>
<version>1.15</version>
<scope>system</scope>
<systemPath>${main.basedir}/lib/Spigot-1.12.jar</systemPath>
<systemPath>${main.basedir}/lib/Spigot-1.15.jar</systemPath>
</dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>WorldEdit</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${main.basedir}/lib/WorldEdit-1.12.jar</systemPath>
</dependency>
</dependencies>
</project>

Datei anzeigen

@ -1,7 +1,7 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2020 SteamWar.de-Serverteam
Copyright (C) 2021 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
@ -15,7 +15,7 @@
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;

Datei anzeigen

@ -1,7 +1,7 @@
/*
/*
This file is a part of the SteamWar software.
Copyright (C) 2020 SteamWar.de-Serverteam
Copyright (C) 2021 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
@ -15,7 +15,7 @@
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;
@ -132,12 +132,12 @@ public class Config {
public static final int ReplayID;
static{
if(!new File(IFightSystem.getPlugin().getDataFolder(), System.getProperty("config", "config.yml")).exists()) {
IFightSystem.getPlugin().saveDefaultConfig();
if(!new File(FightSystem.getPlugin().getDataFolder(), System.getProperty("config", "config.yml")).exists()) {
FightSystem.getPlugin().saveDefaultConfig();
Bukkit.getLogger().log(Level.SEVERE, "Arenaconfig fehlt!");
Bukkit.shutdown();
}
FileConfiguration config = YamlConfiguration.loadConfiguration(new File(IFightSystem.getPlugin().getDataFolder(), System.getProperty("config", "config.yml")));
FileConfiguration config = YamlConfiguration.loadConfiguration(new File(FightSystem.getPlugin().getDataFolder(), System.getProperty("config", "config.yml")));
File worldConfigFile = new File(Bukkit.getWorlds().get(0).getWorldFolder(), config.getString("Arenaconfig", "config.yml"));
if(!worldConfigFile.exists()) {
@ -326,7 +326,7 @@ public class Config {
EventTeamRedID = team2.getTeamId();
BothTeamsPublic = EventTeamRedID == 0 && EventTeamBlueID == 0;
IFightSystem.setEventFight(eventFight);
FightSystem.setEventFight(eventFight);
Event event = Event.get(eventFight.getEventID());
if(BothTeamsPublic) {

Datei anzeigen

@ -20,14 +20,12 @@
package de.steamwar.fightsystem;
import de.steamwar.core.CommandRemover;
import de.steamwar.core.Core;
import de.steamwar.fightsystem.commands.*;
import de.steamwar.fightsystem.countdown.*;
import de.steamwar.fightsystem.event.HellsBells;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.fight.FightWorld;
import de.steamwar.fightsystem.fight.IFight;
import de.steamwar.fightsystem.listener.Shutdown;
import de.steamwar.fightsystem.listener.*;
import de.steamwar.fightsystem.record.*;
@ -49,17 +47,16 @@ public class FightSystem extends JavaPlugin {
public static final String PREFIX = "§eArena§8» ";
private static FightSystem plugin;
private static EventFight eventFight;
private static Player eventLeiter;
@Override
public void onLoad() {
plugin = this;
IFightSystem.init(this);
}
@Override
public void onEnable() {
IFight.init(Fight.getRedTeam(), Fight.getBlueTeam());
new EntityDamage();
new WaterRemover();
new Permanent();
@ -74,7 +71,7 @@ public class FightSystem extends JavaPlugin {
new DenyWorldInteraction();
new EventJoin();
new Recording();
// new ResourcePack();
//new ResourcePack();
new Check();
new Shutdown();
new SetupQuit();
@ -85,8 +82,7 @@ public class FightSystem extends JavaPlugin {
new PersonalKitCreator();
new FightScoreboard();
new ArrowStopper();
if(Core.getVersion() > 8)
new ArrowPickup();
new ArrowPickup();
new EnterHandler();
new TechHider();
@ -214,15 +210,19 @@ public class FightSystem extends JavaPlugin {
}
public static void setEventLeiter(Player el){
IFightSystem.setEventLeiter(el);
eventLeiter = el;
}
public static Player getEventLeiter(){
return IFightSystem.getEventLeiter();
return eventLeiter;
}
public static EventFight getEventFight(){
return IFightSystem.getEventFight();
return eventFight;
}
public static void setEventFight(EventFight ef){
eventFight = ef;
}
public static FightSystem getPlugin() {

Datei anzeigen

@ -0,0 +1,41 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2021 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 de.steamwar.core.Core;
import java.lang.reflect.InvocationTargetException;
public class VersionDependent {
private VersionDependent() {}
public static <T> T getVersionImpl(String className){
for(int version = Core.getVersion(); version >= 8; version--) {
try {
return (T) Class.forName(className + version).getDeclaredConstructor().newInstance();
} catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
throw new SecurityException("Could not load version dependent class", e);
} catch (ClassNotFoundException e) {
// try next version
}
}
throw new SecurityException("Unable to find version dependent implementation for " + className);
}
}

Datei anzeigen

@ -19,11 +19,11 @@
package de.steamwar.fightsystem.countdown;
import de.steamwar.core.Core;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.listener.BasicListener;
import de.steamwar.fightsystem.record.GlobalRecorder;
import de.steamwar.fightsystem.utils.SWSound;
import net.md_5.bungee.api.chat.BaseComponent;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Bukkit;
@ -39,7 +39,7 @@ public abstract class Countdown {
private static final List<Countdown> currentCountdowns = new ArrayList<>();
private final int totalTime;
private final Sound sound;
protected final Sound sound;
private final boolean level;
protected int time;
@ -48,31 +48,13 @@ public abstract class Countdown {
public abstract String countdownCounting();
public abstract void countdownFinished();
public Countdown(int time, SWSound sound, boolean level) {
protected Countdown(int time, SWSound sound, boolean level) {
this.totalTime = time;
this.time = time;
this.sound = getSound(sound);
this.sound = sound != null ? sound.getSound() : null;
this.level = level;
}
public static Sound getSound(SWSound sound){
if(sound == null)
return null;
switch (Core.getVersion()){
case 8:
return Countdown_8.getSound(sound);
case 9:
case 10:
case 12:
return Countdown_9.getSound(sound);
case 14:
case 15:
default:
return Countdown_14.getSound(sound);
}
}
public void enable() {
time = totalTime;
task = Bukkit.getScheduler().runTaskTimer(FightSystem.getPlugin(), this::count, 20, 20);

Datei anzeigen

@ -23,6 +23,7 @@ import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.FightPlayer;
import de.steamwar.fightsystem.listener.BasicListener;
import de.steamwar.fightsystem.utils.SWSound;
import de.steamwar.fightsystem.utils.TechHider;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.entity.Player;
@ -59,19 +60,19 @@ public class EnternCountdown extends Countdown {
BasicListener.toActionbar(player, TextComponent.fromLegacyText("§rNoch §a" + time / 60 + " §rMinuten " + countdownCounting()));
break;
case 60: case 30: case 20: case 15: case 10: case 5: case 4: case 3: case 2:
player.playSound(player.getLocation(), Countdown.getSound(SWSound.BLOCK_NOTE_PLING), 100.0F, 1.0F);
player.playSound(player.getLocation(), sound, 100.0F, 1.0F);
BasicListener.toActionbar(player, TextComponent.fromLegacyText("§rNoch §a" + time + " §rSekunden " + countdownCounting()));
break;
case 1:
player.playSound(player.getLocation(), Countdown.getSound(SWSound.BLOCK_NOTE_PLING), 100.0F, 1.0F);
player.playSound(player.getLocation(), sound, 100.0F, 1.0F);
BasicListener.toActionbar(player, TextComponent.fromLegacyText("§rNoch §a1 §rSekunde " + countdownCounting()));
chunkPos = TechHider.prepareChunkReload(player, false);
break;
case 0:
player.playSound(player.getLocation(), Countdown.getSound(SWSound.BLOCK_NOTE_PLING), 100.0F, 2.0F);
player.playSound(player.getLocation(), sound, 100.0F, 2.0F);
disable();
countdownFinished();

Datei anzeigen

@ -24,6 +24,7 @@ import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentCountdown;
import de.steamwar.fightsystem.utils.SWSound;
public class EventSpectateCountdown extends Countdown {

Datei anzeigen

@ -24,6 +24,7 @@ import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentCountdown;
import de.steamwar.fightsystem.utils.SWSound;
public class PreRunningCountdown extends Countdown {

Datei anzeigen

@ -24,6 +24,7 @@ import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentCountdown;
import de.steamwar.fightsystem.utils.SWSound;
public class PreSchemCountdown extends Countdown {

Datei anzeigen

@ -22,9 +22,9 @@ package de.steamwar.fightsystem.countdown;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.FightWorld;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentCountdown;
import de.steamwar.fightsystem.utils.SWSound;
public class SpectateOverCountdown extends Countdown {

Datei anzeigen

@ -21,6 +21,7 @@ package de.steamwar.fightsystem.countdown;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.utils.SWSound;
import org.bukkit.Bukkit;
public class TimeOverCountdown extends Countdown {

Datei anzeigen

@ -22,7 +22,7 @@ package de.steamwar.fightsystem.event;
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.utils.SWSound;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependent;
import de.steamwar.fightsystem.winconditions.Winconditions;

Datei anzeigen

@ -19,12 +19,9 @@
package de.steamwar.fightsystem.fight;
import com.sk89q.jnbt.NBTInputStream;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.math.transform.AffineTransform;
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;
@ -33,6 +30,7 @@ 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.fightsystem.utils.WorldeditWrapper;
import de.steamwar.sql.Schematic;
import org.bukkit.Bukkit;
import org.bukkit.DyeColor;
@ -41,14 +39,11 @@ import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.event.HandlerList;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.logging.Level;
import java.util.zip.GZIPInputStream;
public class FightSchematic extends StateDependent {
@ -122,29 +117,8 @@ public class FightSchematic extends StateDependent {
Bukkit.getScheduler().runTask(FightSystem.getPlugin(), this::paste);
}
private void replaceTeamColor(Clipboard clipboard){
DyeColor c = ArenaMode.AntiPrepare.contains(Config.mode) ? ColorConverter.chat2dye(team.getColor()) : DyeColor.PINK;
VersionedRunnable.call(new VersionedRunnable(() -> {
try {
FightTeam_8.replaceTeamColor(clipboard, c);
} catch (WorldEditException ex) {
throw new SecurityException("Error recoloring schematic", ex);
}
}, 8),
new VersionedRunnable(() -> {
try {
FightTeam_12.replaceTeamColor(clipboard, c);
} catch (WorldEditException ex) {
throw new SecurityException("Error recoloring schematic", ex);
}
}, 12),
new VersionedRunnable(() -> {
try {
FightTeam_14.replaceTeamColor(clipboard, c);
} catch (WorldEditException ex) {
throw new SecurityException("Error recoloring schematic", ex);
}
}, 14));
private void replaceTeamColor(Clipboard clipboard) throws WorldEditException {
WorldeditWrapper.impl.replaceTeamColor(clipboard, ArenaMode.AntiPrepare.contains(Config.mode) ? ColorConverter.chat2dye(team.getColor()) : DyeColor.PINK);
}
private void paste(){
@ -152,35 +126,33 @@ public class FightSchematic extends StateDependent {
try {
replaceTeamColor(clipboard);
VersionedRunnable.call(new VersionedRunnable(() -> FightTeam_8.pasteSchematic(clipboard, region, rotate), 8),
new VersionedRunnable(() -> FightTeam_14.pasteSchematic(clipboard, region, rotate), 14));
} catch (SecurityException securityException) {
WorldeditWrapper.impl.pasteSchematic(clipboard, region, rotate);
} catch (WorldEditException e) {
Bukkit.broadcastMessage(FightSystem.PREFIX + "§cFehler beim Pasten der Schematic");
Bukkit.getScheduler().runTask(FightSystem.getPlugin(), FightSystem::setPreSchemState);
throw securityException;
throw new SecurityException("Could not paste schematic", e);
}
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), freezer::disable, 3);
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), team::teleportToSpawn, 40);
}
private Clipboard loadTextSchem(String schemName){
return VersionedCallable.call(new VersionedCallable<>(() -> FightTeam_8.loadSchem(new NBTInputStream(new GZIPInputStream(new FileInputStream(new File(FightSystem.getPlugin().getDataFolder(), "text/" + schemName + ".schematic"))))), 8),
new VersionedCallable<>(() -> FightTeam_14.loadSchem(new NBTInputStream(new GZIPInputStream(new FileInputStream(new File(FightSystem.getPlugin().getDataFolder(), "text/" + schemName + ".schem"))))), 14));
private Clipboard loadTextSchem(String schemName) throws IOException {
return WorldeditWrapper.impl.loadChar(schemName);
}
public void pasteTeamName(){
List<Clipboard> characters = new ArrayList<>();
for(char c : team.getName().toCharArray()){
try {
characters.add(loadTextSchem(c == '/' ? "slash" : String.valueOf(c)));
} catch (IOException e) {
Bukkit.getLogger().log(Level.WARNING, "Could not display character {} due to missing file!", c);
try {
characters.add(loadTextSchem(c == '/' ? "slash" : String.valueOf(c)));
} catch (RuntimeException e) {
Bukkit.getLogger().log(Level.WARNING, "Could not display character {} due to missing file!", c);
characters.add(loadTextSchem(""));
}catch (IOException ex) {
throw new SecurityException("Could not load text", ex);
}
}catch (RuntimeException e) {
throw new SecurityException("Could not load text", e);
}
}
@ -210,16 +182,15 @@ public class FightSchematic extends StateDependent {
}
for(int i = 0; i < characters.size(); i++){
replaceTeamColor(characters.get(i));
pasteChar(characters.get(i), offsets[i], length, team.getSchemRegion().centerX(), team.getExtendRegion().getMaxY(), z, aT);
try {
replaceTeamColor(characters.get(i));
} catch (WorldEditException e) {
Bukkit.getLogger().log(Level.SEVERE, "Could not recolor team text", e);
}
WorldeditWrapper.impl.pasteChar(characters.get(i), offsets[i], length, team.getSchemRegion().centerX(), team.getExtendRegion().getMaxY(), z, aT);
}
}
private void pasteChar(Clipboard character, int charOffset, int length, int x, int y, int z, AffineTransform aT){
VersionedRunnable.call(new VersionedRunnable(() -> FightTeam_8.pasteChar(character, charOffset, length, x, y, z, aT), 8),
new VersionedRunnable(() -> FightTeam_14.pasteChar(character, charOffset, length, x, y, z, aT), 14));
}
@Override
public void disable() {
if(!Config.ReplaceObsidianBedrock)

Datei anzeigen

@ -21,17 +21,17 @@ package de.steamwar.fightsystem.fight;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
import de.steamwar.comms.packets.TablistNamePacket;
import de.steamwar.core.VersionedRunnable;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.VersionDependent;
import de.steamwar.fightsystem.countdown.Countdown;
import de.steamwar.fightsystem.listener.BasicListener;
import de.steamwar.fightsystem.listener.FightScoreboard;
import de.steamwar.fightsystem.listener.PersonalKitCreator;
import de.steamwar.fightsystem.record.GlobalRecorder;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependent;
import de.steamwar.fightsystem.utils.BountifulWrapper;
import de.steamwar.fightsystem.utils.ItemBuilder;
import de.steamwar.fightsystem.utils.Region;
import de.steamwar.fightsystem.utils.TechHider;
@ -48,7 +48,9 @@ import org.bukkit.scoreboard.Team;
import java.util.*;
public class FightTeam implements IFightTeam{
public class FightTeam {
private static final IFightTeam impl = VersionDependent.getVersionImpl(FightTeam.class.getName());
private UUID designatedLeader;
private FightPlayer leader;
@ -87,7 +89,8 @@ public class FightTeam implements IFightTeam{
else
team = FightScoreboard.getBukkit().getTeam(name);
assert team != null;
setTeamColor(team, color);
impl.setTeamColor(team, color);
BountifulWrapper.impl.setNametagVisibility(team);
//noinspection deprecation
team.setNameTagVisibility(NameTagVisibility.HIDE_FOR_OTHER_TEAMS);
team.setAllowFriendlyFire(false);
@ -131,12 +134,10 @@ public class FightTeam implements IFightTeam{
return true;
}
@Override
public boolean isPlayerInTeam(Player player) {
return players.containsKey(player);
}
@Override
public boolean canPlayerEntern(Player player) {
return getFightPlayer(player).canEntern();
}
@ -196,7 +197,7 @@ public class FightTeam implements IFightTeam{
player.setHealth(20);
player.setFoodLevel(20);
player.getInventory().clear();
BasicListener.setAttackSpeed(player);
BountifulWrapper.impl.setAttackSpeed(player);
player.teleport(spawn);
if(Kit.getAvailableKits(false).size() > 1 || Config.PersonalKits)
player.getInventory().setItem(1, new ItemBuilder(Material.LEATHER_CHESTPLATE).removeAllAttributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName("§eKit wählen").build());
@ -237,7 +238,6 @@ public class FightTeam implements IFightTeam{
return leader == null;
}
@Override
public boolean isBlue(){
return blue;
}
@ -402,17 +402,14 @@ public class FightTeam implements IFightTeam{
return currentHearts / maximumHearts;
}
private void setTeamColor(Team team, ChatColor color){
VersionedRunnable.call(new VersionedRunnable(() -> FightTeam_8.setTeamColor(team, color), 8),
new VersionedRunnable(() -> FightTeam_9.setTeamColor(team, color), 9),
new VersionedRunnable(() -> FightTeam_12.setTeamColor(team, color), 12),
new VersionedRunnable(() -> FightTeam_14.setTeamColor(team, color), 14));
}
public ChatColor getColor() {
return color;
}
public interface IFightTeam {
void setTeamColor(Team team, ChatColor color);
}
private class KitLoader extends StateDependent {
private KitLoader() {
super(ArenaMode.AntiReplay, FightState.Ingame);

Datei anzeigen

@ -19,12 +19,12 @@
package de.steamwar.fightsystem.fight;
import de.steamwar.core.Core;
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 de.steamwar.fightsystem.utils.CraftbukkitWrapper;
import de.steamwar.fightsystem.utils.FlatteningWrapper;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.WorldCreator;
@ -33,13 +33,12 @@ import org.bukkit.entity.EntityType;
public class FightWorld extends StateDependent {
private static final boolean paper;
static{
paper = Bukkit.getVersion().contains("git-Paper");
}
private static final World world = Bukkit.getWorlds().get(0);
private static final boolean paper = Bukkit.getVersion().contains("git-Paper");
public static boolean isPaper(){
return paper;
}
public FightWorld() {
super(ArenaMode.Restartable, FightState.Schem);
@ -51,10 +50,6 @@ public class FightWorld extends StateDependent {
//unused
}
public static boolean isPaper(){
return paper;
}
@Override
public void disable() {
resetWorld();
@ -63,8 +58,7 @@ public class FightWorld extends StateDependent {
public static void forceLoad(){
Config.ArenaRegion.forEachChunk((cX, cZ) -> {
world.loadChunk(cX, cZ);
if(Core.getVersion() > 12)
world.setChunkForceLoaded(cX, cZ, true);
FlatteningWrapper.impl.forceLoadChunk(world, cX, cZ);
});
world.setKeepSpawnInMemory(true);
}
@ -78,17 +72,7 @@ public class FightWorld extends StateDependent {
World backup = new WorldCreator(world.getName() + "/backup").createWorld();
assert backup != null;
Config.ArenaRegion.forEachChunk((x, z) -> resetChunk(backup, x, z, FightWorld.isPaper()));
Config.ArenaRegion.forEachChunk((x, z) -> CraftbukkitWrapper.impl.resetChunk(world, backup, x, z));
Bukkit.unloadWorld(backup, false);
}
private static void resetChunk(World backup, int x, int z, boolean isPaper){
VersionedRunnable.call(
new VersionedRunnable(() -> FightWorld_8.resetChunk(world, backup, x, z, isPaper), 8),
new VersionedRunnable(() -> FightWorld_9.resetChunk(world, backup, x, z, isPaper), 9),
new VersionedRunnable(() -> FightWorld_10.resetChunk(world, backup, x, z, isPaper), 10),
new VersionedRunnable(() -> FightWorld_12.resetChunk(world, backup, x, z, isPaper), 12),
new VersionedRunnable(() -> FightWorld_14.resetChunk(world, backup, x, z, isPaper), 14),
new VersionedRunnable(() -> FightWorld_15.resetChunk(world, backup, x, z, isPaper), 15));
}
}
}

Datei anzeigen

@ -19,7 +19,7 @@
package de.steamwar.fightsystem.fight;
import de.steamwar.fightsystem.IFightSystem;
import de.steamwar.fightsystem.FightSystem;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
@ -32,7 +32,7 @@ import org.bukkit.event.player.PlayerSwapHandItemsEvent;
public class FreezeWorld implements Listener {
public FreezeWorld(){
Bukkit.getPluginManager().registerEvents(this, IFightSystem.getPlugin());
Bukkit.getPluginManager().registerEvents(this, FightSystem.getPlugin());
}
public void disable(){

Datei anzeigen

@ -19,13 +19,13 @@
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.fightsystem.listener.PersonalKitCreator;
import de.steamwar.fightsystem.utils.CraftbukkitWrapper;
import de.steamwar.fightsystem.utils.FlatteningWrapper;
import de.steamwar.inventory.SWInventory;
import de.steamwar.inventory.SWItem;
import de.steamwar.sql.PersonalKit;
@ -38,7 +38,6 @@ 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;
@ -188,21 +187,16 @@ public class Kit {
return true;
//Check for attribute modifiers
if(Core.getVersion() >= 14 && PersonalKitCreator_14.hasAttributeModifier(stack)){
if(FlatteningWrapper.impl.hasAttributeModifier(stack)){
return true;
}
if(stack.hasItemMeta()){
ItemMeta meta = stack.getItemMeta();
if(meta instanceof BlockDataMeta && ((BlockDataMeta)meta).hasBlockData())
if(FlatteningWrapper.impl.containsBlockMeta(meta))
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)))
if(CraftbukkitWrapper.impl.hasItems(stack))
return true; //Blocks prefilled inventories
}

Datei anzeigen

@ -19,16 +19,14 @@
package de.steamwar.fightsystem.listener;
import de.steamwar.core.Core;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.VersionDependent;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentListener;
public class ArrowPickup {
public ArrowPickup() {
if(Core.getVersion() > 8){
new StateDependentListener(ArenaMode.All, FightState.All, new PickupArrowListener_9());
}
new StateDependentListener(ArenaMode.All, FightState.All, VersionDependent.getVersionImpl(ArrowPickup.class.getName()));
}
}

Datei anzeigen

@ -1,7 +1,7 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2020 SteamWar.de-Serverteam
Copyright (C) 2021 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
@ -15,11 +15,12 @@
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.VersionDependent;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentTask;
import org.bukkit.Bukkit;
@ -36,6 +37,8 @@ public class ArrowStopper {
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 IArrowStopper impl = VersionDependent.getVersionImpl(ArrowStopper.class.getName());
public ArrowStopper() {
new StateDependentTask(Config.TechhiderActive, FightState.Running, this::run, 1, 1);
}
@ -90,7 +93,11 @@ public class ArrowStopper {
boolean overMid = entity.getLocation().getZ() > Config.SpecSpawn.getZ();
boolean otherSide = teamFrom == overMid;
return otherSide ||
entity.isInBlock() ||
impl.isInBlock(entity) ||
entity.getVelocity().equals(NULL_VECTOR);
}
public interface IArrowStopper {
boolean isInBlock(Arrow e);
}
}

Datei anzeigen

@ -19,17 +19,19 @@
package de.steamwar.fightsystem.listener;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.utils.BountifulWrapper;
import net.md_5.bungee.api.chat.BaseComponent;
import org.bukkit.entity.Player;
class BasicListener_8 {
private BasicListener_8(){}
public class BasicListener {
private BasicListener(){}
static void toActionbar(Player player, BaseComponent... components){
player.spigot().sendMessage(components);
public static boolean notFighting(Player p){
return Fight.getFightPlayer(p) == null;
}
static void toChat(Player player, BaseComponent... components){
player.spigot().sendMessage(components);
public static void toActionbar(Player player, BaseComponent... components){
BountifulWrapper.impl.toActionbar(player, components);
}
}

Datei anzeigen

@ -27,6 +27,7 @@ import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.record.GlobalRecorder;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentListener;
import de.steamwar.fightsystem.utils.BountifulWrapper;
import net.md_5.bungee.api.chat.BaseComponent;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Bukkit;
@ -67,6 +68,6 @@ public class Chat implements Listener {
GlobalRecorder.getInstance().chat(message);
BaseComponent[] msg = TextComponent.fromLegacyText(message);
for(Player p : Bukkit.getOnlinePlayers())
BasicListener.toChat(p, msg);
BountifulWrapper.impl.toChat(p, msg);
}
}

Datei anzeigen

@ -19,8 +19,8 @@
package de.steamwar.fightsystem.listener;
import de.steamwar.core.Core;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.VersionDependent;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentListener;
import net.md_5.bungee.api.chat.TextComponent;
@ -40,11 +40,10 @@ public class DenyWorldInteraction implements Listener {
public DenyWorldInteraction() {
new StateDependentListener(ArenaMode.Test, FightState.PreRunning, this);
new StateDependentListener(ArenaMode.AntiTest, FightState.AntiRunning, this);
if(Core.getVersion() > 9){
Listener listener = new DenyWorldInteraction_10();
new StateDependentListener(ArenaMode.Test, FightState.PreRunning, listener);
new StateDependentListener(ArenaMode.AntiTest, FightState.AntiRunning, listener);
}
Listener listener = VersionDependent.getVersionImpl(DenyWorldInteraction.class.getName());
new StateDependentListener(ArenaMode.Test, FightState.PreRunning, listener);
new StateDependentListener(ArenaMode.AntiTest, FightState.AntiRunning, listener);
}
@EventHandler

Einige Dateien werden nicht angezeigt, da zu viele Dateien in diesem Diff geändert wurden Mehr anzeigen