Merge branch 'master' into RedstoneWincondition
Einige Prüfungen sind fehlgeschlagen
SteamWarCI Build failed
Einige Prüfungen sind fehlgeschlagen
SteamWarCI Build failed
# Conflicts: # FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionPercentSystem.java # FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionRelativePercent.java
Dieser Commit ist enthalten in:
Commit
ce9127cacf
@ -17,28 +17,10 @@
|
|||||||
<artifactId>FightSystem_10</artifactId>
|
<artifactId>FightSystem_10</artifactId>
|
||||||
<version>1.0</version>
|
<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>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>steamwar</groupId>
|
<groupId>steamwar</groupId>
|
||||||
<artifactId>FightSystem_9</artifactId>
|
<artifactId>FightSystem_Core</artifactId>
|
||||||
<version>1.0</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>steamwar</groupId>
|
|
||||||
<artifactId>FightSystem_API</artifactId>
|
|
||||||
<version>1.0</version>
|
<version>1.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -1,32 +0,0 @@
|
|||||||
/*
|
|
||||||
This file is a part of the SteamWar software.
|
|
||||||
|
|
||||||
Copyright (C) 2020 SteamWar.de-Serverteam
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU Affero General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU Affero General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Affero General Public License
|
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package de.steamwar.fightsystem.listener;
|
|
||||||
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.event.player.PlayerSwapHandItemsEvent;
|
|
||||||
|
|
||||||
public class DenyWorldInteraction_10 implements Listener {
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onSwapItems(PlayerSwapHandItemsEvent event) {
|
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
|
||||||
}
|
|
@ -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();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
This file is a part of the SteamWar software.
|
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
|
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
|
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
|
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/>.
|
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.core.events.ChunkListener;
|
||||||
|
import de.steamwar.fightsystem.fight.FightWorld;
|
||||||
import net.minecraft.server.v1_10_R1.Chunk;
|
import net.minecraft.server.v1_10_R1.Chunk;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.craftbukkit.v1_10_R1.CraftWorld;
|
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.CraftEntity;
|
||||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftPlayer;
|
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.Entity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
public class FightWorld_10 {
|
import java.util.HashSet;
|
||||||
private FightWorld_10(){}
|
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();
|
net.minecraft.server.v1_10_R1.World w = ((CraftWorld) world).getHandle();
|
||||||
Chunk chunk = w.getChunkAt(x, z);
|
Chunk chunk = w.getChunkAt(x, z);
|
||||||
Chunk backupChunk = ((CraftWorld) backup).getHandle().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.getSections(), 0, chunk.getSections(), 0, chunk.getSections().length);
|
||||||
System.arraycopy(backupChunk.heightMap, 0, chunk.heightMap, 0, chunk.heightMap.length);
|
System.arraycopy(backupChunk.heightMap, 0, chunk.heightMap, 0, chunk.heightMap.length);
|
||||||
w.tileEntityListTick.removeAll(chunk.tileEntities.values());
|
w.tileEntityListTick.removeAll(chunk.tileEntities.values());
|
||||||
if (!isPaper) {
|
if (!FightWorld.isPaper()) {
|
||||||
w.tileEntityList.removeAll(chunk.tileEntities.values());
|
w.tileEntityList.removeAll(chunk.tileEntities.values());
|
||||||
}
|
}
|
||||||
chunk.tileEntities.clear();
|
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);
|
((CraftPlayer)player).getHandle().setResourcePack(pack, sha1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static float headRotation(Entity e){
|
@Override
|
||||||
|
public float headRotation(Entity e) {
|
||||||
return ((CraftEntity)e).getHandle().getHeadRotation();
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
@ -17,28 +17,15 @@
|
|||||||
<artifactId>FightSystem_12</artifactId>
|
<artifactId>FightSystem_12</artifactId>
|
||||||
<version>1.0</version>
|
<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>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>steamwar</groupId>
|
<groupId>steamwar</groupId>
|
||||||
<artifactId>FightSystem_10</artifactId>
|
<artifactId>FightSystem_8</artifactId>
|
||||||
<version>1.0</version>
|
<version>1.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>steamwar</groupId>
|
<groupId>steamwar</groupId>
|
||||||
<artifactId>FightSystem_API</artifactId>
|
<artifactId>FightSystem_Core</artifactId>
|
||||||
<version>1.0</version>
|
<version>1.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -1,74 +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 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(){}
|
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
private static final int COLOR_TO_REPLACE = DyeColor.PINK.getWoolData();
|
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
private static final BaseBlock CONCRETE = new BaseBlock(Material.CONCRETE.getId(), COLOR_TO_REPLACE);
|
|
||||||
@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);
|
|
||||||
|
|
||||||
Vector minimum = clipboard.getRegion().getMinimumPoint();
|
|
||||||
BaseBlock concrete = new BaseBlock(CONCRETE.getId(), c.getWoolData());
|
|
||||||
BaseBlock concretePowder = new BaseBlock(CONCRETE_POWDER.getId(), c.getWoolData());
|
|
||||||
|
|
||||||
for(int x = 0; x < clipboard.getDimensions().getX(); x++){
|
|
||||||
for(int y = 0; y < clipboard.getDimensions().getY(); y++){
|
|
||||||
for(int z = 0; z < clipboard.getDimensions().getZ(); z++){
|
|
||||||
Vector pos = minimum.add(x, y, z);
|
|
||||||
BaseBlock block = clipboard.getBlock(pos);
|
|
||||||
if(block.equals(CONCRETE)){
|
|
||||||
clipboard.setBlock(pos, concrete);
|
|
||||||
}else if(block.equals(CONCRETE_POWDER)){
|
|
||||||
clipboard.setBlock(pos, concretePowder);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -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();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
This file is a part of the SteamWar software.
|
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
|
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
|
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
|
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/>.
|
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.core.events.ChunkListener;
|
||||||
|
import de.steamwar.fightsystem.fight.FightWorld;
|
||||||
import net.minecraft.server.v1_12_R1.Chunk;
|
import net.minecraft.server.v1_12_R1.Chunk;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.craftbukkit.v1_12_R1.CraftWorld;
|
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.CraftEntity;
|
||||||
import org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer;
|
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.Entity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
public class FightWorld_12 {
|
import java.util.HashSet;
|
||||||
private FightWorld_12(){}
|
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();
|
net.minecraft.server.v1_12_R1.World w = ((CraftWorld) world).getHandle();
|
||||||
Chunk chunk = w.getChunkAt(x, z);
|
Chunk chunk = w.getChunkAt(x, z);
|
||||||
Chunk backupChunk = ((CraftWorld) backup).getHandle().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.getSections(), 0, chunk.getSections(), 0, chunk.getSections().length);
|
||||||
System.arraycopy(backupChunk.heightMap, 0, chunk.heightMap, 0, chunk.heightMap.length);
|
System.arraycopy(backupChunk.heightMap, 0, chunk.heightMap, 0, chunk.heightMap.length);
|
||||||
w.tileEntityListTick.removeAll(chunk.tileEntities.values());
|
w.tileEntityListTick.removeAll(chunk.tileEntities.values());
|
||||||
if (!isPaper) {
|
if (!FightWorld.isPaper()) {
|
||||||
w.tileEntityList.removeAll(chunk.tileEntities.values());
|
w.tileEntityList.removeAll(chunk.tileEntities.values());
|
||||||
}
|
}
|
||||||
chunk.tileEntities.clear();
|
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);
|
((CraftPlayer)player).getHandle().setResourcePack(pack, sha1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static float headRotation(Entity e){
|
@Override
|
||||||
|
public float headRotation(Entity e) {
|
||||||
return ((CraftEntity)e).getHandle().getHeadRotation();
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
124
FightSystem_12/src/de/steamwar/fightsystem/utils/TechHider12.java
Normale Datei
124
FightSystem_12/src/de/steamwar/fightsystem/utils/TechHider12.java
Normale Datei
@ -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.TechHider.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 = TechHider.readVarInt(data, i);
|
||||||
|
int paletteLengthLength = TechHider.readVarIntLength(data, i);
|
||||||
|
buffer.writeBytes(data, i, paletteLengthLength);
|
||||||
|
i += paletteLengthLength;
|
||||||
|
|
||||||
|
for(int actPaletteId = 0; actPaletteId < paletteLength; actPaletteId++){
|
||||||
|
int entry = TechHider.readVarInt(data, i);
|
||||||
|
i += TechHider.readVarIntLength(data, i);
|
||||||
|
|
||||||
|
if(hiddenBlockIds.contains(entry)){
|
||||||
|
entry = obfuscateWith;
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
buffer.writeBytes(TechHider.writeVarInt(entry));
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
buffer.writeByte(data[++i]); //Empty palette
|
||||||
|
Bukkit.getLogger().log(Level.SEVERE, "Full chunk occured");
|
||||||
|
}
|
||||||
|
|
||||||
|
int dataArrayLength = TechHider.readVarInt(data, i);
|
||||||
|
int dataArrayLengthLength = TechHider.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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
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.ChatColor;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Sound;
|
||||||
|
import org.bukkit.SoundCategory;
|
||||||
|
import org.bukkit.entity.Arrow;
|
||||||
|
import org.bukkit.scoreboard.Team;
|
||||||
|
|
||||||
|
public class WorldOfColorWrapper12 implements WorldOfColorWrapper.IWorldOfColorWrapper {
|
||||||
|
@Override
|
||||||
|
public void setTeamColor(Team team, ChatColor color) {
|
||||||
|
team.setColor(color);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isInBlock(Arrow e) {
|
||||||
|
return e.isInBlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void playSound(Location location, Sound sound, String soundCategory, float volume, float pitch) {
|
||||||
|
location.getWorld().playSound(location, sound, SoundCategory.valueOf(soundCategory), volume, pitch);
|
||||||
|
}
|
||||||
|
}
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
This file is a part of the SteamWar software.
|
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
|
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
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
@ -15,16 +15,18 @@
|
|||||||
|
|
||||||
You should have received a copy of the GNU Affero General Public License
|
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/>.
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.steamwar.fightsystem.utils;
|
package de.steamwar.fightsystem.utils;
|
||||||
|
|
||||||
import org.bukkit.DyeColor;
|
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
|
||||||
class ColorConverter_8 {
|
@SuppressWarnings("deprecation")
|
||||||
private ColorConverter_8(){}
|
public class WorldeditWrapper12 extends WorldeditWrapper8 {
|
||||||
|
|
||||||
static DyeColor getSilver(){
|
static {
|
||||||
return DyeColor.SILVER;
|
colorBlocks.add(new BaseBlock(Material.CONCRETE.getId(), COLOR_TO_REPLACE));
|
||||||
|
colorBlocks.add(new BaseBlock(Material.CONCRETE_POWDER.getId(), COLOR_TO_REPLACE));
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -17,19 +17,6 @@
|
|||||||
<artifactId>FightSystem_14</artifactId>
|
<artifactId>FightSystem_14</artifactId>
|
||||||
<version>1.0</version>
|
<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>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>steamwar</groupId>
|
<groupId>steamwar</groupId>
|
||||||
@ -47,12 +34,7 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>steamwar</groupId>
|
<groupId>steamwar</groupId>
|
||||||
<artifactId>FightSystem_API</artifactId>
|
<artifactId>FightSystem_Core</artifactId>
|
||||||
<version>1.0</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>steamwar</groupId>
|
|
||||||
<artifactId>FightSystem_12</artifactId>
|
|
||||||
<version>1.0</version>
|
<version>1.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
@ -1,168 +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 com.sk89q.worldedit.EditSession;
|
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
|
||||||
import com.sk89q.worldedit.bukkit.BukkitWorld;
|
|
||||||
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
|
|
||||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
|
||||||
import com.sk89q.worldedit.extent.clipboard.io.BuiltInClipboardFormat;
|
|
||||||
import com.sk89q.worldedit.extent.clipboard.io.ClipboardWriter;
|
|
||||||
import com.sk89q.worldedit.function.operation.ForwardExtentCopy;
|
|
||||||
import com.sk89q.worldedit.function.operation.Operations;
|
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
|
||||||
import com.sk89q.worldedit.math.transform.AffineTransform;
|
|
||||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
|
||||||
import com.sk89q.worldedit.session.ClipboardHolder;
|
|
||||||
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.sql.NoClipboardException;
|
|
||||||
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.IOException;
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
public class FightTeam_14 {
|
|
||||||
private FightTeam_14(){}
|
|
||||||
|
|
||||||
private static final BaseBlock WOOL = Objects.requireNonNull(BlockTypes.PINK_WOOL).getDefaultState().toBaseBlock();
|
|
||||||
private static final BaseBlock CLAY = Objects.requireNonNull(BlockTypes.PINK_TERRACOTTA).getDefaultState().toBaseBlock();
|
|
||||||
private static final BaseBlock GLASS = Objects.requireNonNull(BlockTypes.PINK_STAINED_GLASS).getDefaultState().toBaseBlock();
|
|
||||||
private static final BaseBlock GLASS_PANE = Objects.requireNonNull(BlockTypes.PINK_STAINED_GLASS_PANE).getDefaultState().toBaseBlock();
|
|
||||||
private static final BaseBlock CONCRETE = Objects.requireNonNull(BlockTypes.PINK_CONCRETE).getDefaultState().toBaseBlock();
|
|
||||||
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 {
|
|
||||||
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();
|
|
||||||
BaseBlock glass = Objects.requireNonNull(BlockTypes.get(c.name().toLowerCase() + "_stained_glass")).getDefaultState().toBaseBlock();
|
|
||||||
BaseBlock glassPane = Objects.requireNonNull(BlockTypes.get(c.name().toLowerCase() + "_stained_glass_pane")).getDefaultState().toBaseBlock();
|
|
||||||
BaseBlock carpet = Objects.requireNonNull(BlockTypes.get(c.name().toLowerCase() + "_carpet")).getDefaultState().toBaseBlock();
|
|
||||||
BaseBlock concrete = Objects.requireNonNull(BlockTypes.get(c.name().toLowerCase() + "_concrete")).getDefaultState().toBaseBlock();
|
|
||||||
BaseBlock concretePowder = Objects.requireNonNull(BlockTypes.get(c.name().toLowerCase() + "_concrete_powder")).getDefaultState().toBaseBlock();
|
|
||||||
|
|
||||||
for(int x = 0; x < clipboard.getDimensions().getX(); x++){
|
|
||||||
for(int y = 0; y < clipboard.getDimensions().getY(); y++){
|
|
||||||
for(int z = 0; z < clipboard.getDimensions().getZ(); z++){
|
|
||||||
BlockVector3 pos = minimum.add(x, y, z);
|
|
||||||
BaseBlock block = clipboard.getFullBlock(pos);
|
|
||||||
if(block.equals(WOOL)){
|
|
||||||
clipboard.setBlock(pos, wool);
|
|
||||||
}else if(block.equals(CLAY)){
|
|
||||||
clipboard.setBlock(pos, clay);
|
|
||||||
}else if(block.equals(GLASS)){
|
|
||||||
clipboard.setBlock(pos, glass);
|
|
||||||
}else if(block.equals(GLASS_PANE)){
|
|
||||||
clipboard.setBlock(pos, glassPane);
|
|
||||||
}else if(block.equals(CARPET)){
|
|
||||||
clipboard.setBlock(pos, carpet);
|
|
||||||
}else if(block.equals(CONCRETE)){
|
|
||||||
clipboard.setBlock(pos, concrete);
|
|
||||||
}else if(block.equals(CONCRETE_POWDER)){
|
|
||||||
clipboard.setBlock(pos, concretePowder);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void pasteSchematic(Clipboard clipboard, Region region, boolean rotate) throws NoClipboardException {
|
|
||||||
BlockVector3 paste = BlockVector3.at(region.centerX(), region.getMinY(), region.centerZ());
|
|
||||||
|
|
||||||
World w = new BukkitWorld(Bukkit.getWorlds().get(0));
|
|
||||||
BlockVector3 dimensions = clipboard.getDimensions();
|
|
||||||
BlockVector3 v;
|
|
||||||
BlockVector3 offset = clipboard.getRegion().getMinimumPoint().subtract(clipboard.getOrigin());
|
|
||||||
AffineTransform aT = new AffineTransform();
|
|
||||||
if(rotate){
|
|
||||||
aT = aT.rotateY(180);
|
|
||||||
v = paste.add(dimensions.getX()/2 + dimensions.getX()%2, 0, dimensions.getZ()/2 + dimensions.getZ()%2).subtract(offset.multiply(-1, 1, -1)).subtract(1, 0, 1);
|
|
||||||
}else{
|
|
||||||
v = paste.subtract(dimensions.getX()/2, 0, dimensions.getZ()/2).subtract(offset);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(Config.WaterDepth != 0){
|
|
||||||
BlockVector3 it = clipboard.getMinimumPoint();
|
|
||||||
int depth = 0;
|
|
||||||
while(!clipboard.getBlock(it).getBlockType().getMaterial().isAir()){
|
|
||||||
depth++;
|
|
||||||
it = it.add(0, 1, 0);
|
|
||||||
}
|
|
||||||
v = v.add(0, Config.WaterDepth - depth, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(w, -1);
|
|
||||||
ClipboardHolder ch = new ClipboardHolder(clipboard);
|
|
||||||
ch.setTransform(aT);
|
|
||||||
Operations.completeBlindly(ch.createPaste(e).to(v).build());
|
|
||||||
e.flushSession();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean checkPistonMoving(Block block){
|
|
||||||
return block.getType() == Material.MOVING_PISTON;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static 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()));
|
|
||||||
BlockArrayClipboard clipboard = new BlockArrayClipboard(cuboidRegion);
|
|
||||||
EditSession editSession = WorldEdit.getInstance().getEditSessionFactory().getEditSession(w, -1);
|
|
||||||
|
|
||||||
ForwardExtentCopy forwardExtentCopy = new ForwardExtentCopy(editSession, cuboidRegion, clipboard, min);
|
|
||||||
forwardExtentCopy.setCopyingEntities(false);
|
|
||||||
|
|
||||||
try{
|
|
||||||
Operations.complete(forwardExtentCopy);
|
|
||||||
}catch(WorldEditException e){
|
|
||||||
throw new IllegalStateException(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
|
||||||
try {
|
|
||||||
ClipboardWriter writer = BuiltInClipboardFormat.SPONGE_SCHEMATIC.getWriter(outputStream);
|
|
||||||
writer.write(clipboard);
|
|
||||||
writer.close();
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new IllegalStateException(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
schem.saveFromBytes(outputStream.toByteArray(), true);
|
|
||||||
}
|
|
||||||
}
|
|
@ -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();
|
|
||||||
}
|
|
||||||
}
|
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,79 @@
|
|||||||
|
/*
|
||||||
|
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 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 BlockIdWrapper14 implements BlockIdWrapper.IBlockIdWrapper {
|
||||||
|
@Override
|
||||||
|
public int blockToId(Block block) {
|
||||||
|
return net.minecraft.server.v1_14_R1.Block.REGISTRY_ID.getId(((CraftBlock)block).getNMS());
|
||||||
|
}
|
||||||
|
|
||||||
|
@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);
|
||||||
|
cworld.removeTileEntity(pos);
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
This file is a part of the SteamWar software.
|
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
|
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
|
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
|
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/>.
|
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.core.events.ChunkListener;
|
||||||
|
import de.steamwar.fightsystem.fight.FightWorld;
|
||||||
import net.minecraft.server.v1_14_R1.Chunk;
|
import net.minecraft.server.v1_14_R1.Chunk;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.craftbukkit.v1_14_R1.CraftWorld;
|
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.CraftEntity;
|
||||||
import org.bukkit.craftbukkit.v1_14_R1.entity.CraftPlayer;
|
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.Entity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
public class FightWorld_14 {
|
import java.util.HashSet;
|
||||||
private FightWorld_14(){}
|
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();
|
net.minecraft.server.v1_14_R1.World w = ((CraftWorld) world).getHandle();
|
||||||
Chunk chunk = w.getChunkAt(x, z);
|
Chunk chunk = w.getChunkAt(x, z);
|
||||||
Chunk backupChunk = ((CraftWorld) backup).getHandle().getChunkAt(x, z);
|
Chunk backupChunk = ((CraftWorld) backup).getHandle().getChunkAt(x, z);
|
||||||
|
|
||||||
System.arraycopy(backupChunk.getSections(), 0, chunk.getSections(), 0, chunk.getSections().length);
|
System.arraycopy(backupChunk.getSections(), 0, chunk.getSections(), 0, chunk.getSections().length);
|
||||||
w.tileEntityListTick.removeAll(chunk.tileEntities.values());
|
w.tileEntityListTick.removeAll(chunk.tileEntities.values());
|
||||||
if (!isPaper) {
|
if (!FightWorld.isPaper()) {
|
||||||
w.tileEntityList.removeAll(chunk.tileEntities.values());
|
w.tileEntityList.removeAll(chunk.tileEntities.values());
|
||||||
}
|
}
|
||||||
chunk.tileEntities.clear();
|
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);
|
((CraftPlayer)player).getHandle().setResourcePack(pack, sha1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static float headRotation(Entity e){
|
@Override
|
||||||
|
public float headRotation(Entity e) {
|
||||||
return ((CraftEntity)e).getHandle().getHeadRotation();
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
This file is a part of the SteamWar software.
|
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
|
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
|
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
|
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/>.
|
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;
|
import org.bukkit.Sound;
|
||||||
|
|
||||||
class Countdown_14 {
|
public class SWSound14 implements SWSound.ISWSound {
|
||||||
private Countdown_14(){}
|
@Override
|
||||||
|
public Sound getSound(SWSound sound) {
|
||||||
static Sound getSound(SWSound sound){
|
|
||||||
switch(sound){
|
switch(sound){
|
||||||
case ENTITY_WITHER_DEATH:
|
case ENTITY_WITHER_DEATH:
|
||||||
return Sound.ENTITY_WITHER_DEATH;
|
return Sound.ENTITY_WITHER_DEATH;
|
||||||
@ -32,6 +31,8 @@ class Countdown_14 {
|
|||||||
return Sound.BLOCK_NOTE_BLOCK_BASS;
|
return Sound.BLOCK_NOTE_BLOCK_BASS;
|
||||||
case BLOCK_NOTE_PLING:
|
case BLOCK_NOTE_PLING:
|
||||||
return Sound.BLOCK_NOTE_BLOCK_PLING;
|
return Sound.BLOCK_NOTE_BLOCK_PLING;
|
||||||
|
case ENTITY_GENERIC_EXPLODE:
|
||||||
|
return Sound.ENTITY_GENERIC_EXPLODE;
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
199
FightSystem_14/src/de/steamwar/fightsystem/utils/TechHider14.java
Normale Datei
199
FightSystem_14/src/de/steamwar/fightsystem/utils/TechHider14.java
Normale Datei
@ -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.TechHider.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 = TechHider.readVarInt(data, i);
|
||||||
|
int paletteLengthLength = TechHider.readVarIntLength(data, i);
|
||||||
|
buffer.writeBytes(data, i, paletteLengthLength);
|
||||||
|
i += paletteLengthLength;
|
||||||
|
for(int actPaletteId = 0; actPaletteId < paletteLength; actPaletteId++){
|
||||||
|
int blockId = TechHider.readVarInt(data, i);
|
||||||
|
int actPaletteLength = TechHider.readVarIntLength(data, i);
|
||||||
|
|
||||||
|
if(hiddenBlockIds.contains(blockId)){
|
||||||
|
buffer.writeBytes(TechHider.writeVarInt(obfuscateWith));
|
||||||
|
changed = true;
|
||||||
|
}else{
|
||||||
|
buffer.writeBytes(data, i, actPaletteLength);
|
||||||
|
}
|
||||||
|
i += actPaletteLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
//We modify only the chunk palette for performance reasons
|
||||||
|
int dataArrayLength = TechHider.readVarInt(data, i);
|
||||||
|
int dataArrayLengthLength = TechHider.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 = TechHider.readVarInt(data, i);
|
||||||
|
int dataArrayLengthLength = TechHider.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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
148
FightSystem_14/src/de/steamwar/fightsystem/utils/WorldeditWrapper14.java
Normale Datei
148
FightSystem_14/src/de/steamwar/fightsystem/utils/WorldeditWrapper14.java
Normale Datei
@ -0,0 +1,148 @@
|
|||||||
|
/*
|
||||||
|
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.sk89q.jnbt.NBTInputStream;
|
||||||
|
import com.sk89q.worldedit.EditSession;
|
||||||
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
|
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||||
|
import com.sk89q.worldedit.bukkit.BukkitWorld;
|
||||||
|
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
|
||||||
|
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||||
|
import com.sk89q.worldedit.extent.clipboard.io.BuiltInClipboardFormat;
|
||||||
|
import com.sk89q.worldedit.extent.clipboard.io.ClipboardWriter;
|
||||||
|
import com.sk89q.worldedit.extent.clipboard.io.SpongeSchematicReader;
|
||||||
|
import com.sk89q.worldedit.function.operation.ForwardExtentCopy;
|
||||||
|
import com.sk89q.worldedit.function.operation.Operations;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
import com.sk89q.worldedit.math.Vector3;
|
||||||
|
import com.sk89q.worldedit.math.transform.AffineTransform;
|
||||||
|
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||||
|
import com.sk89q.worldedit.session.ClipboardHolder;
|
||||||
|
import com.sk89q.worldedit.world.World;
|
||||||
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
|
import de.steamwar.sql.Schematic;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.DyeColor;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.zip.GZIPInputStream;
|
||||||
|
|
||||||
|
public class WorldeditWrapper14 implements WorldeditWrapper.IWorldeditWrapper {
|
||||||
|
|
||||||
|
private static final Map<BaseBlock, String> colorBlocks = new HashMap<>();
|
||||||
|
|
||||||
|
static {
|
||||||
|
colorBlocks.put(Objects.requireNonNull(BlockTypes.PINK_WOOL).getDefaultState().toBaseBlock(), "_wool");
|
||||||
|
colorBlocks.put(Objects.requireNonNull(BlockTypes.PINK_TERRACOTTA).getDefaultState().toBaseBlock(), "_terracotta");
|
||||||
|
colorBlocks.put(Objects.requireNonNull(BlockTypes.PINK_STAINED_GLASS).getDefaultState().toBaseBlock(), "_stained_glass");
|
||||||
|
colorBlocks.put(Objects.requireNonNull(BlockTypes.PINK_STAINED_GLASS_PANE).getDefaultState().toBaseBlock(), "_stained_glass_pane");
|
||||||
|
colorBlocks.put(Objects.requireNonNull(BlockTypes.PINK_CONCRETE).getDefaultState().toBaseBlock(), "_concrete");
|
||||||
|
colorBlocks.put(Objects.requireNonNull(BlockTypes.PINK_CONCRETE_POWDER).getDefaultState().toBaseBlock(), "_concrete_powder");
|
||||||
|
colorBlocks.put(Objects.requireNonNull(BlockTypes.PINK_CARPET).getDefaultState().toBaseBlock(), "_carpet");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void replaceTeamColor(Clipboard clipboard, DyeColor c) throws WorldEditException {
|
||||||
|
BlockVector3 minimum = clipboard.getRegion().getMinimumPoint();
|
||||||
|
Map<BaseBlock, BaseBlock> replaceMap = new HashMap<>();
|
||||||
|
colorBlocks.forEach((base, postfix) -> replaceMap.put(base, Objects.requireNonNull(BlockTypes.get(c.name().toLowerCase() + postfix)).getDefaultState().toBaseBlock()));
|
||||||
|
|
||||||
|
for(int x = 0; x < clipboard.getDimensions().getX(); x++){
|
||||||
|
for(int y = 0; y < clipboard.getDimensions().getY(); y++){
|
||||||
|
for(int z = 0; z < clipboard.getDimensions().getZ(); z++){
|
||||||
|
BlockVector3 pos = minimum.add(x, y, z);
|
||||||
|
BaseBlock replacement = replaceMap.get(clipboard.getFullBlock(pos));
|
||||||
|
if(replacement != null)
|
||||||
|
clipboard.setBlock(pos, replacement);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getWaterDepth(Clipboard clipboard) {
|
||||||
|
BlockVector3 it = clipboard.getMinimumPoint().add(0, 0, 1);
|
||||||
|
int depth = 0;
|
||||||
|
while(!clipboard.getBlock(it).getBlockType().getMaterial().isAir()){
|
||||||
|
depth++;
|
||||||
|
it = it.add(0, 1, 0);
|
||||||
|
}
|
||||||
|
return depth;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void pasteClipboard(Clipboard clipboard, Location position, Vector offset, AffineTransform aT) {
|
||||||
|
EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(new BukkitWorld(position.getWorld()), -1);
|
||||||
|
ClipboardHolder ch = new ClipboardHolder(clipboard);
|
||||||
|
ch.setTransform(aT);
|
||||||
|
Operations.completeBlindly(ch.createPaste(e).to(BukkitAdapter.asVector(position).add(
|
||||||
|
aT.apply(Vector3.at(offset.getX(), offset.getY(), offset.getZ()).add(clipboard.getOrigin().toVector3()).subtract(clipboard.getMinimumPoint().toVector3()))
|
||||||
|
).toBlockPoint()).build());
|
||||||
|
e.flushSession();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Vector getDimensions(Clipboard clipboard) {
|
||||||
|
BlockVector3 dims = clipboard.getDimensions();
|
||||||
|
return new Vector(dims.getX(), dims.getY(), dims.getZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
@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();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void saveSchem(Schematic schem, Region region, int minY) throws WorldEditException {
|
||||||
|
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()));
|
||||||
|
BlockArrayClipboard clipboard = new BlockArrayClipboard(cuboidRegion);
|
||||||
|
|
||||||
|
ForwardExtentCopy forwardExtentCopy = new ForwardExtentCopy(
|
||||||
|
WorldEdit.getInstance().getEditSessionFactory().getEditSession(w, -1), cuboidRegion, clipboard, min
|
||||||
|
);
|
||||||
|
forwardExtentCopy.setCopyingEntities(false);
|
||||||
|
Operations.complete(forwardExtentCopy);
|
||||||
|
|
||||||
|
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||||
|
try {
|
||||||
|
ClipboardWriter writer = BuiltInClipboardFormat.SPONGE_SCHEMATIC.getWriter(outputStream);
|
||||||
|
writer.write(clipboard);
|
||||||
|
writer.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new SecurityException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
schem.saveFromBytes(outputStream.toByteArray(), true);
|
||||||
|
}
|
||||||
|
}
|
@ -17,19 +17,6 @@
|
|||||||
<artifactId>FightSystem_15</artifactId>
|
<artifactId>FightSystem_15</artifactId>
|
||||||
<version>1.0</version>
|
<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>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>steamwar</groupId>
|
<groupId>steamwar</groupId>
|
||||||
@ -47,12 +34,7 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>steamwar</groupId>
|
<groupId>steamwar</groupId>
|
||||||
<artifactId>FightSystem_API</artifactId>
|
<artifactId>FightSystem_Core</artifactId>
|
||||||
<version>1.0</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>steamwar</groupId>
|
|
||||||
<artifactId>FightSystem_14</artifactId>
|
|
||||||
<version>1.0</version>
|
<version>1.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
@ -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();
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,79 @@
|
|||||||
|
/*
|
||||||
|
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 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;
|
||||||
|
|
||||||
|
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());
|
||||||
|
}
|
||||||
|
|
||||||
|
@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);
|
||||||
|
cworld.removeTileEntity(pos);
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
This file is a part of the SteamWar software.
|
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
|
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
|
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
|
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/>.
|
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.core.events.ChunkListener;
|
||||||
|
import de.steamwar.fightsystem.fight.FightWorld;
|
||||||
import net.minecraft.server.v1_15_R1.Chunk;
|
import net.minecraft.server.v1_15_R1.Chunk;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.craftbukkit.v1_15_R1.CraftWorld;
|
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.CraftEntity;
|
||||||
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer;
|
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.Entity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
public class FightWorld_15 {
|
import java.util.HashSet;
|
||||||
private FightWorld_15(){}
|
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();
|
net.minecraft.server.v1_15_R1.World w = ((CraftWorld) world).getHandle();
|
||||||
Chunk chunk = w.getChunkAt(x, z);
|
Chunk chunk = w.getChunkAt(x, z);
|
||||||
Chunk backupChunk = ((CraftWorld) backup).getHandle().getChunkAt(x, z);
|
Chunk backupChunk = ((CraftWorld) backup).getHandle().getChunkAt(x, z);
|
||||||
|
|
||||||
System.arraycopy(backupChunk.getSections(), 0, chunk.getSections(), 0, chunk.getSections().length);
|
System.arraycopy(backupChunk.getSections(), 0, chunk.getSections(), 0, chunk.getSections().length);
|
||||||
w.tileEntityListTick.removeAll(chunk.tileEntities.values());
|
w.tileEntityListTick.removeAll(chunk.tileEntities.values());
|
||||||
if (!isPaper) {
|
if (!FightWorld.isPaper()) {
|
||||||
w.tileEntityList.removeAll(chunk.tileEntities.values());
|
w.tileEntityList.removeAll(chunk.tileEntities.values());
|
||||||
}
|
}
|
||||||
chunk.tileEntities.clear();
|
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);
|
((CraftPlayer)player).getHandle().setResourcePack(pack, sha1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static float headRotation(Entity e){
|
@Override
|
||||||
|
public float headRotation(Entity e) {
|
||||||
return ((CraftEntity)e).getHandle().getHeadRotation();
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
@ -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());
|
|
||||||
}
|
|
||||||
}
|
|
@ -17,19 +17,6 @@
|
|||||||
<artifactId>FightSystem_8</artifactId>
|
<artifactId>FightSystem_8</artifactId>
|
||||||
<version>1.0</version>
|
<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>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>steamwar</groupId>
|
<groupId>steamwar</groupId>
|
||||||
@ -40,7 +27,7 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>steamwar</groupId>
|
<groupId>steamwar</groupId>
|
||||||
<artifactId>FightSystem_API</artifactId>
|
<artifactId>FightSystem_Core</artifactId>
|
||||||
<version>1.0</version>
|
<version>1.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -1,161 +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 com.sk89q.worldedit.EditSession;
|
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
|
||||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
|
||||||
import com.sk89q.worldedit.bukkit.BukkitWorld;
|
|
||||||
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
|
|
||||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
|
||||||
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat;
|
|
||||||
import com.sk89q.worldedit.extent.clipboard.io.ClipboardWriter;
|
|
||||||
import com.sk89q.worldedit.function.operation.ForwardExtentCopy;
|
|
||||||
import com.sk89q.worldedit.function.operation.Operations;
|
|
||||||
import com.sk89q.worldedit.math.transform.AffineTransform;
|
|
||||||
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.sql.NoClipboardException;
|
|
||||||
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.IOException;
|
|
||||||
|
|
||||||
public class FightTeam_8 {
|
|
||||||
private FightTeam_8(){}
|
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
private static final int COLOR_TO_REPLACE = DyeColor.PINK.getWoolData();
|
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
private static final BaseBlock WOOL = new BaseBlock(Material.WOOL.getId(), COLOR_TO_REPLACE);
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
private static final BaseBlock GLASS = new BaseBlock(Material.STAINED_GLASS.getId(), COLOR_TO_REPLACE);
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
private static final BaseBlock CLAY = new BaseBlock(Material.CLAY.getId(), COLOR_TO_REPLACE);
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
private static final BaseBlock GLASS_PANE = new BaseBlock(Material.STAINED_GLASS_PANE.getId(), COLOR_TO_REPLACE);
|
|
||||||
@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 {
|
|
||||||
Vector minimum = clipboard.getRegion().getMinimumPoint();
|
|
||||||
BaseBlock wool = new BaseBlock(WOOL.getId(), c.getWoolData());
|
|
||||||
BaseBlock clay = new BaseBlock(CLAY.getId(), c.getWoolData());
|
|
||||||
BaseBlock glass = new BaseBlock(GLASS.getId(), c.getWoolData());
|
|
||||||
BaseBlock glassPane = new BaseBlock(GLASS_PANE.getId(), c.getWoolData());
|
|
||||||
BaseBlock carpet = new BaseBlock(CARPET.getId(), c.getWoolData());
|
|
||||||
|
|
||||||
for(int x = 0; x < clipboard.getDimensions().getX(); x++){
|
|
||||||
for(int y = 0; y < clipboard.getDimensions().getY(); y++){
|
|
||||||
for(int z = 0; z < clipboard.getDimensions().getZ(); z++){
|
|
||||||
Vector pos = minimum.add(x, y, z);
|
|
||||||
BaseBlock block = clipboard.getBlock(pos);
|
|
||||||
if(block.equals(WOOL)){
|
|
||||||
clipboard.setBlock(pos, wool);
|
|
||||||
}else if(block.equals(CLAY)){
|
|
||||||
clipboard.setBlock(pos, clay);
|
|
||||||
}else if(block.equals(GLASS)){
|
|
||||||
clipboard.setBlock(pos, glass);
|
|
||||||
}else if(block.equals(GLASS_PANE)){
|
|
||||||
clipboard.setBlock(pos, glassPane);
|
|
||||||
}else if(block.equals(CARPET)){
|
|
||||||
clipboard.setBlock(pos, carpet);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void pasteSchematic(Clipboard clipboard, Region paste, boolean rotate) throws NoClipboardException {
|
|
||||||
World w = new BukkitWorld(Bukkit.getWorlds().get(0));
|
|
||||||
Vector dimensions = clipboard.getDimensions();
|
|
||||||
Vector v = new Vector(paste.centerX(), paste.getMinY(), paste.centerZ());
|
|
||||||
Vector offset = clipboard.getMinimumPoint().subtract(clipboard.getOrigin());
|
|
||||||
AffineTransform aT = new AffineTransform();
|
|
||||||
if(rotate){
|
|
||||||
aT = aT.rotateY(180);
|
|
||||||
v = v.add(dimensions.getX()/2 + dimensions.getX()%2, 0, dimensions.getZ()/2 + dimensions.getZ()%2).subtract(offset.multiply(-1, 1, -1)).subtract(1, 0, 1);
|
|
||||||
}else{
|
|
||||||
v = v.subtract(dimensions.getX()/2 - dimensions.getX()%2, 0, dimensions.getZ()/2 - dimensions.getZ()%2).subtract(offset);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(Config.WaterDepth != 0){
|
|
||||||
Vector it = clipboard.getMinimumPoint();
|
|
||||||
int depth = 0;
|
|
||||||
while(!clipboard.getBlock(it).isAir()){
|
|
||||||
depth++;
|
|
||||||
it = it.setY(it.getY()+1);
|
|
||||||
}
|
|
||||||
v = v.add(0, Config.WaterDepth - depth, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(w, -1);
|
|
||||||
ClipboardHolder ch = new ClipboardHolder(clipboard, w.getWorldData());
|
|
||||||
ch.setTransform(aT);
|
|
||||||
Operations.completeBlindly(ch.createPaste(e, w.getWorldData()).to(v).build());
|
|
||||||
e.flushQueue();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean checkPistonMoving(Block block){
|
|
||||||
return block.getType() == Material.PISTON_MOVING_PIECE;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static 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()));
|
|
||||||
BlockArrayClipboard clipboard = new BlockArrayClipboard(cuboidRegion);
|
|
||||||
EditSession editSession = WorldEdit.getInstance().getEditSessionFactory().getEditSession(w, -1);
|
|
||||||
|
|
||||||
ForwardExtentCopy forwardExtentCopy = new ForwardExtentCopy(editSession, cuboidRegion, clipboard, min);
|
|
||||||
try{
|
|
||||||
Operations.complete(forwardExtentCopy);
|
|
||||||
}catch(WorldEditException e){
|
|
||||||
throw new IllegalStateException(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
|
||||||
try {
|
|
||||||
ClipboardWriter writer = ClipboardFormat.SCHEMATIC.getWriter(outputStream);
|
|
||||||
writer.write(clipboard, w.getWorldData());
|
|
||||||
writer.close();
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new IllegalStateException(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
schem.saveFromBytes(outputStream.toByteArray(), false);
|
|
||||||
}
|
|
||||||
}
|
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
This file is a part of the SteamWar software.
|
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
|
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
|
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
|
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/>.
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.steamwar.fightsystem.utils;
|
package de.steamwar.fightsystem.utils;
|
||||||
|
|
||||||
import de.steamwar.fightsystem.Config;
|
import de.steamwar.fightsystem.Config;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
class TechHider_8 {
|
public class BlockIdWrapper8 implements BlockIdWrapper.IBlockIdWrapper {
|
||||||
private TechHider_8(){}
|
@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<>();
|
Set<Integer> hiddenBlockIds = new HashSet<>();
|
||||||
for(String tag : Config.HiddenBlocks){
|
for(String tag : Config.HiddenBlocks){
|
||||||
hiddenBlockIds.add(Material.matchMaterial(tag).getId() << 4);
|
hiddenBlockIds.add(Material.matchMaterial(tag).getId() << 4);
|
||||||
@ -36,7 +47,13 @@ class TechHider_8 {
|
|||||||
return hiddenBlockIds;
|
return hiddenBlockIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int getObfuscateWith() {
|
@Override
|
||||||
|
public int getObfuscateWith() {
|
||||||
return Material.matchMaterial(Config.ObfuscateWith).getId() << 4;
|
return Material.matchMaterial(Config.ObfuscateWith).getId() << 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getPose(boolean sneaking) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
@ -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 com.comphenix.protocol.wrappers.EnumWrappers;
|
||||||
|
import de.steamwar.fightsystem.listener.Recording;
|
||||||
|
import de.steamwar.fightsystem.record.GlobalRecorder;
|
||||||
|
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.Effect;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Listener newDenyArrowPickupListener() {
|
||||||
|
return new Listener() {};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Listener newDenyHandSwapListener() {
|
||||||
|
return new Listener() {};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void recordHandItems(Player player) {
|
||||||
|
GlobalRecorder.getInstance().item(player, Recording.disarmNull(player.getInventory().getItemInHand()), "MAINHAND");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Listener newHandSwapRecorder() {
|
||||||
|
return new Listener() {};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void spawnParticle(World world, String particleName, double x, double y, double z) {
|
||||||
|
world.playEffect(new Location(world, x, y, z), Effect.valueOf(particleName), 1);
|
||||||
|
}
|
||||||
|
}
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
This file is a part of the SteamWar software.
|
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
|
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
|
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
|
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/>.
|
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.core.events.ChunkListener;
|
||||||
import net.minecraft.server.v1_8_R3.Chunk;
|
import net.minecraft.server.v1_8_R3.Chunk;
|
||||||
@ -26,15 +26,20 @@ import org.bukkit.World;
|
|||||||
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
|
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.CraftEntity;
|
||||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
|
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.Entity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
public class FightWorld_8 {
|
import java.util.HashSet;
|
||||||
private FightWorld_8(){}
|
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();
|
net.minecraft.server.v1_8_R3.World w = ((CraftWorld) world).getHandle();
|
||||||
Chunk chunk = w.getChunkAt(x, z);
|
Chunk chunk = w.getChunkAt(x, z);
|
||||||
|
((CraftWorld) backup).getHandle().chunkProviderServer.forceChunkLoad = true;
|
||||||
Chunk backupChunk = ((CraftWorld) backup).getHandle().getChunkAt(x, z);
|
Chunk backupChunk = ((CraftWorld) backup).getHandle().getChunkAt(x, z);
|
||||||
|
|
||||||
System.arraycopy(backupChunk.getSections(), 0, chunk.getSections(), 0, chunk.getSections().length);
|
System.arraycopy(backupChunk.getSections(), 0, chunk.getSections(), 0, chunk.getSections().length);
|
||||||
@ -47,11 +52,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);
|
((CraftPlayer)player).getHandle().setResourcePack(pack, sha1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static float headRotation(Entity e){
|
@Override
|
||||||
|
public float headRotation(Entity e) {
|
||||||
return ((CraftEntity)e).getHandle().getHeadRotation();
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
This file is a part of the SteamWar software.
|
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
|
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
|
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
|
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/>.
|
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;
|
import org.bukkit.Sound;
|
||||||
|
|
||||||
class Countdown_8 {
|
public class SWSound8 implements SWSound.ISWSound {
|
||||||
private Countdown_8(){}
|
@Override
|
||||||
|
public Sound getSound(SWSound sound) {
|
||||||
static Sound getSound(SWSound sound){
|
|
||||||
switch(sound){
|
switch(sound){
|
||||||
case ENTITY_WITHER_DEATH:
|
case ENTITY_WITHER_DEATH:
|
||||||
return Sound.WITHER_DEATH;
|
return Sound.WITHER_DEATH;
|
||||||
@ -32,6 +31,8 @@ class Countdown_8 {
|
|||||||
return Sound.NOTE_BASS;
|
return Sound.NOTE_BASS;
|
||||||
case BLOCK_NOTE_PLING:
|
case BLOCK_NOTE_PLING:
|
||||||
return Sound.NOTE_PLING;
|
return Sound.NOTE_PLING;
|
||||||
|
case ENTITY_GENERIC_EXPLODE:
|
||||||
|
return Sound.EXPLODE;
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
This file is a part of the SteamWar software.
|
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
|
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
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
@ -15,16 +15,23 @@
|
|||||||
|
|
||||||
You should have received a copy of the GNU Affero General Public License
|
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/>.
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.steamwar.fightsystem.utils;
|
package de.steamwar.fightsystem.utils;
|
||||||
|
|
||||||
import org.bukkit.DyeColor;
|
import com.comphenix.protocol.PacketType;
|
||||||
|
import com.comphenix.protocol.events.PacketAdapter;
|
||||||
|
import com.comphenix.protocol.events.PacketEvent;
|
||||||
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
|
|
||||||
class ColorConverter_14 {
|
public class TechHider8 extends PacketAdapter {
|
||||||
private ColorConverter_14(){}
|
|
||||||
|
|
||||||
static DyeColor getSilver(){
|
public TechHider8() {
|
||||||
return DyeColor.LIGHT_GRAY;
|
super(FightSystem.getPlugin(), PacketType.Play.Server.MAP_CHUNK);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPacketSending(PacketEvent e) {
|
||||||
|
// no implementation availible
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -0,0 +1,43 @@
|
|||||||
|
/*
|
||||||
|
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.ChatColor;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Sound;
|
||||||
|
import org.bukkit.entity.Arrow;
|
||||||
|
import org.bukkit.scoreboard.Team;
|
||||||
|
|
||||||
|
public class WorldOfColorWrapper8 implements WorldOfColorWrapper.IWorldOfColorWrapper {
|
||||||
|
@Override
|
||||||
|
public void setTeamColor(Team team, ChatColor color) {
|
||||||
|
team.setPrefix("§" + color.getChar());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isInBlock(Arrow e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void playSound(Location location, Sound sound, String soundCategory, float volume, float pitch) {
|
||||||
|
location.getWorld().playSound(location, sound, volume, pitch);
|
||||||
|
}
|
||||||
|
}
|
146
FightSystem_8/src/de/steamwar/fightsystem/utils/WorldeditWrapper8.java
Normale Datei
146
FightSystem_8/src/de/steamwar/fightsystem/utils/WorldeditWrapper8.java
Normale Datei
@ -0,0 +1,146 @@
|
|||||||
|
/*
|
||||||
|
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.sk89q.jnbt.NBTInputStream;
|
||||||
|
import com.sk89q.worldedit.EditSession;
|
||||||
|
import com.sk89q.worldedit.Vector;
|
||||||
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
|
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||||
|
import com.sk89q.worldedit.bukkit.BukkitWorld;
|
||||||
|
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
|
||||||
|
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||||
|
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat;
|
||||||
|
import com.sk89q.worldedit.extent.clipboard.io.ClipboardWriter;
|
||||||
|
import com.sk89q.worldedit.extent.clipboard.io.SchematicReader;
|
||||||
|
import com.sk89q.worldedit.function.operation.ForwardExtentCopy;
|
||||||
|
import com.sk89q.worldedit.function.operation.Operations;
|
||||||
|
import com.sk89q.worldedit.math.transform.AffineTransform;
|
||||||
|
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||||
|
import com.sk89q.worldedit.session.ClipboardHolder;
|
||||||
|
import com.sk89q.worldedit.world.World;
|
||||||
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
|
import de.steamwar.sql.Schematic;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.DyeColor;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.zip.GZIPInputStream;
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
public class WorldeditWrapper8 implements WorldeditWrapper.IWorldeditWrapper {
|
||||||
|
|
||||||
|
protected static final int COLOR_TO_REPLACE = DyeColor.PINK.getWoolData();
|
||||||
|
protected static final Set<BaseBlock> colorBlocks = new HashSet<>();
|
||||||
|
|
||||||
|
static {
|
||||||
|
colorBlocks.add(new BaseBlock(Material.WOOL.getId(), COLOR_TO_REPLACE));
|
||||||
|
colorBlocks.add(new BaseBlock(Material.STAINED_GLASS.getId(), COLOR_TO_REPLACE));
|
||||||
|
colorBlocks.add(new BaseBlock(Material.CLAY.getId(), COLOR_TO_REPLACE));
|
||||||
|
colorBlocks.add(new BaseBlock(Material.STAINED_GLASS_PANE.getId(), COLOR_TO_REPLACE));
|
||||||
|
colorBlocks.add(new BaseBlock(Material.CARPET.getId(), COLOR_TO_REPLACE));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void replaceTeamColor(Clipboard clipboard, DyeColor c) throws WorldEditException {
|
||||||
|
Vector minimum = clipboard.getRegion().getMinimumPoint();
|
||||||
|
Map<BaseBlock, BaseBlock> replaceMap = new HashMap<>();
|
||||||
|
colorBlocks.forEach(base -> replaceMap.put(base, new BaseBlock(base.getId(), c.getWoolData())));
|
||||||
|
|
||||||
|
for(int x = 0; x < clipboard.getDimensions().getX(); x++){
|
||||||
|
for(int y = 0; y < clipboard.getDimensions().getY(); y++){
|
||||||
|
for(int z = 0; z < clipboard.getDimensions().getZ(); z++){
|
||||||
|
Vector pos = minimum.add(x, y, z);
|
||||||
|
BaseBlock replacement = replaceMap.get(clipboard.getBlock(pos));
|
||||||
|
if(replacement != null)
|
||||||
|
clipboard.setBlock(pos, replacement);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getWaterDepth(Clipboard clipboard) {
|
||||||
|
Vector it = clipboard.getMinimumPoint().add(0, 0, 1);
|
||||||
|
int depth = 0;
|
||||||
|
while(!clipboard.getBlock(it).isAir()) {
|
||||||
|
depth++;
|
||||||
|
it = it.add(0, 1, 0);
|
||||||
|
}
|
||||||
|
return depth;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void pasteClipboard(Clipboard clipboard, Location position, org.bukkit.util.Vector offset, AffineTransform aT) {
|
||||||
|
World w = new BukkitWorld(position.getWorld());
|
||||||
|
EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(w, -1);
|
||||||
|
ClipboardHolder ch = new ClipboardHolder(clipboard, w.getWorldData());
|
||||||
|
ch.setTransform(aT);
|
||||||
|
Operations.completeBlindly(ch.createPaste(e, w.getWorldData()).to(new Vector(position.getX(), position.getY(), position.getZ()).add(
|
||||||
|
aT.apply(new Vector(offset.getX(), offset.getY(), offset.getZ()).add(clipboard.getOrigin()).subtract(clipboard.getMinimumPoint()))
|
||||||
|
).toBlockPoint()).build());
|
||||||
|
e.flushQueue();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public org.bukkit.util.Vector getDimensions(Clipboard clipboard) {
|
||||||
|
Vector dims = clipboard.getDimensions();
|
||||||
|
return new org.bukkit.util.Vector(dims.getBlockX(), dims.getBlockY(), dims.getBlockZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
@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());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void saveSchem(Schematic schem, Region region, int minY) throws WorldEditException {
|
||||||
|
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()));
|
||||||
|
BlockArrayClipboard clipboard = new BlockArrayClipboard(cuboidRegion);
|
||||||
|
|
||||||
|
ForwardExtentCopy forwardExtentCopy = new ForwardExtentCopy(
|
||||||
|
WorldEdit.getInstance().getEditSessionFactory().getEditSession(w, -1), cuboidRegion, clipboard, min
|
||||||
|
);
|
||||||
|
Operations.complete(forwardExtentCopy);
|
||||||
|
|
||||||
|
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||||
|
try {
|
||||||
|
ClipboardWriter writer = ClipboardFormat.SCHEMATIC.getWriter(outputStream);
|
||||||
|
writer.write(clipboard, w.getWorldData());
|
||||||
|
writer.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new SecurityException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
schem.saveFromBytes(outputStream.toByteArray(), false);
|
||||||
|
}
|
||||||
|
}
|
@ -17,28 +17,10 @@
|
|||||||
<artifactId>FightSystem_9</artifactId>
|
<artifactId>FightSystem_9</artifactId>
|
||||||
<version>1.0</version>
|
<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>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>steamwar</groupId>
|
<groupId>steamwar</groupId>
|
||||||
<artifactId>FightSystem_8</artifactId>
|
<artifactId>FightSystem_Core</artifactId>
|
||||||
<version>1.0</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>steamwar</groupId>
|
|
||||||
<artifactId>FightSystem_API</artifactId>
|
|
||||||
<version>1.0</version>
|
<version>1.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -1,43 +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 net.md_5.bungee.api.ChatMessageType;
|
|
||||||
import net.md_5.bungee.api.chat.BaseComponent;
|
|
||||||
import org.bukkit.attribute.Attribute;
|
|
||||||
import org.bukkit.attribute.AttributeInstance;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
class BasicListener_9 {
|
|
||||||
private BasicListener_9(){}
|
|
||||||
|
|
||||||
static void toActionbar(Player player, BaseComponent... components){
|
|
||||||
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, components);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void toChat(Player player, BaseComponent... components){
|
|
||||||
player.spigot().sendMessage(ChatMessageType.CHAT, components);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void setAttackSpeed(Player player){
|
|
||||||
AttributeInstance attribute = player.getAttribute(Attribute.GENERIC_ATTACK_SPEED);
|
|
||||||
attribute.setBaseValue(16);
|
|
||||||
}
|
|
||||||
}
|
|
@ -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();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,32 +0,0 @@
|
|||||||
/*
|
|
||||||
This file is a part of the SteamWar software.
|
|
||||||
|
|
||||||
Copyright (C) 2020 SteamWar.de-Serverteam
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU Affero General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU Affero General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Affero General Public License
|
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package de.steamwar.fightsystem.listener;
|
|
||||||
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.event.player.PlayerPickupArrowEvent;
|
|
||||||
|
|
||||||
class PickupArrowListener_9 implements Listener {
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onArrowPickup(PlayerPickupArrowEvent e){
|
|
||||||
e.setCancelled(true);
|
|
||||||
}
|
|
||||||
}
|
|
113
FightSystem_9/src/de/steamwar/fightsystem/utils/BountifulWrapper9.java
Normale Datei
113
FightSystem_9/src/de/steamwar/fightsystem/utils/BountifulWrapper9.java
Normale Datei
@ -0,0 +1,113 @@
|
|||||||
|
/*
|
||||||
|
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 de.steamwar.fightsystem.listener.Recording;
|
||||||
|
import de.steamwar.fightsystem.record.GlobalRecorder;
|
||||||
|
import net.md_5.bungee.api.ChatMessageType;
|
||||||
|
import net.md_5.bungee.api.chat.BaseComponent;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.Particle;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.attribute.Attribute;
|
||||||
|
import org.bukkit.attribute.AttributeInstance;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.player.PlayerPickupArrowEvent;
|
||||||
|
import org.bukkit.event.player.PlayerSwapHandItemsEvent;
|
||||||
|
import org.bukkit.scoreboard.Team;
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void toActionbar(Player player, BaseComponent... components) {
|
||||||
|
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, components);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void toChat(Player player, BaseComponent... components) {
|
||||||
|
player.spigot().sendMessage(ChatMessageType.CHAT, components);
|
||||||
|
}
|
||||||
|
|
||||||
|
@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);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Listener newDenyArrowPickupListener() {
|
||||||
|
return new Listener() {
|
||||||
|
@EventHandler
|
||||||
|
public void onArrowPickup(PlayerPickupArrowEvent e){
|
||||||
|
e.setCancelled(true);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Listener newDenyHandSwapListener() {
|
||||||
|
return new Listener() {
|
||||||
|
@EventHandler
|
||||||
|
public void onSwapItems(PlayerSwapHandItemsEvent event) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void recordHandItems(Player player) {
|
||||||
|
GlobalRecorder.getInstance().item(player, Recording.disarmNull(player.getInventory().getItemInMainHand()), "MAINHAND");
|
||||||
|
GlobalRecorder.getInstance().item(player, Recording.disarmNull(player.getInventory().getItemInOffHand()), "OFFHAND");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Listener newHandSwapRecorder() {
|
||||||
|
return new Listener() {
|
||||||
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
|
public void onItemSwap(PlayerSwapHandItemsEvent e){
|
||||||
|
if(Recording.isNotSent(e.getPlayer()))
|
||||||
|
return;
|
||||||
|
|
||||||
|
Player player = e.getPlayer();
|
||||||
|
GlobalRecorder.getInstance().item(player, Recording.disarmNull(e.getMainHandItem()), "MAINHAND");
|
||||||
|
GlobalRecorder.getInstance().item(player, Recording.disarmNull(e.getOffHandItem()), "OFFHAND");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void spawnParticle(World world, String particleName, double x, double y, double z) {
|
||||||
|
world.spawnParticle(Particle.valueOf(particleName), x, y, z, 1);
|
||||||
|
}
|
||||||
|
}
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
This file is a part of the SteamWar software.
|
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
|
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
|
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
|
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/>.
|
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.core.events.ChunkListener;
|
||||||
|
import de.steamwar.fightsystem.fight.FightWorld;
|
||||||
import net.minecraft.server.v1_9_R2.Chunk;
|
import net.minecraft.server.v1_9_R2.Chunk;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.craftbukkit.v1_9_R2.CraftWorld;
|
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.CraftEntity;
|
||||||
import org.bukkit.craftbukkit.v1_9_R2.entity.CraftPlayer;
|
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.Entity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
public class FightWorld_9 {
|
import java.util.HashSet;
|
||||||
private FightWorld_9(){}
|
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();
|
net.minecraft.server.v1_9_R2.World w = ((CraftWorld) world).getHandle();
|
||||||
Chunk chunk = w.getChunkAt(x, z);
|
Chunk chunk = w.getChunkAt(x, z);
|
||||||
Chunk backupChunk = ((CraftWorld) backup).getHandle().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.getSections(), 0, chunk.getSections(), 0, chunk.getSections().length);
|
||||||
System.arraycopy(backupChunk.heightMap, 0, chunk.heightMap, 0, chunk.heightMap.length);
|
System.arraycopy(backupChunk.heightMap, 0, chunk.heightMap, 0, chunk.heightMap.length);
|
||||||
w.tileEntityListTick.removeAll(chunk.tileEntities.values());
|
w.tileEntityListTick.removeAll(chunk.tileEntities.values());
|
||||||
if (!isPaper) {
|
if (!FightWorld.isPaper()) {
|
||||||
w.tileEntityList.removeAll(chunk.tileEntities.values());
|
w.tileEntityList.removeAll(chunk.tileEntities.values());
|
||||||
}
|
}
|
||||||
chunk.tileEntities.clear();
|
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);
|
((CraftPlayer)player).getHandle().setResourcePack(pack, sha1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static float headRotation(Entity e){
|
@Override
|
||||||
|
public float headRotation(Entity e) {
|
||||||
return ((CraftEntity)e).getHandle().getHeadRotation();
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
This file is a part of the SteamWar software.
|
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
|
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
|
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
|
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/>.
|
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;
|
import org.bukkit.Sound;
|
||||||
|
|
||||||
class Countdown_9 {
|
public class SWSound9 implements SWSound.ISWSound {
|
||||||
private Countdown_9(){}
|
@Override
|
||||||
|
public Sound getSound(SWSound sound){
|
||||||
static Sound getSound(SWSound sound){
|
|
||||||
switch(sound){
|
switch(sound){
|
||||||
case ENTITY_WITHER_DEATH:
|
case ENTITY_WITHER_DEATH:
|
||||||
return Sound.ENTITY_WITHER_DEATH;
|
return Sound.ENTITY_WITHER_DEATH;
|
||||||
@ -32,6 +31,8 @@ class Countdown_9 {
|
|||||||
return Sound.BLOCK_NOTE_BASS;
|
return Sound.BLOCK_NOTE_BASS;
|
||||||
case BLOCK_NOTE_PLING:
|
case BLOCK_NOTE_PLING:
|
||||||
return Sound.BLOCK_NOTE_PLING;
|
return Sound.BLOCK_NOTE_PLING;
|
||||||
|
case ENTITY_GENERIC_EXPLODE:
|
||||||
|
return Sound.ENTITY_GENERIC_EXPLODE;
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
@ -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;
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,29 +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 interface IFightTeam {
|
|
||||||
|
|
||||||
boolean isBlue();
|
|
||||||
boolean isPlayerInTeam(Player player);
|
|
||||||
boolean canPlayerEntern(Player player);
|
|
||||||
}
|
|
@ -1,101 +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.google.common.primitives.Bytes;
|
|
||||||
import de.steamwar.fightsystem.Config;
|
|
||||||
import de.steamwar.fightsystem.IFightSystem;
|
|
||||||
import de.steamwar.fightsystem.fight.IFight;
|
|
||||||
import de.steamwar.fightsystem.fight.IFightTeam;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class ITechHider {
|
|
||||||
private ITechHider (){}
|
|
||||||
|
|
||||||
static boolean bypass(Player p, int chunkX, int chunkZ){
|
|
||||||
if(p == IFightSystem.getEventLeiter())
|
|
||||||
return true;
|
|
||||||
|
|
||||||
IFightTeam ft = IFight.getPlayerTeam(p);
|
|
||||||
if(ft == null){
|
|
||||||
return Config.ArenaRegion.chunkOutside(chunkX, chunkZ);
|
|
||||||
}else if(ft.isBlue()){
|
|
||||||
return ft.canPlayerEntern(p) || Config.RedExtendRegion.chunkOutside(chunkX, chunkZ);
|
|
||||||
}else{
|
|
||||||
return ft.canPlayerEntern(p) || Config.BlueExtendRegion.chunkOutside(chunkX, chunkZ);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int posToChunk(int c){
|
|
||||||
int chunk = c / 16;
|
|
||||||
if(c<0)
|
|
||||||
chunk--;
|
|
||||||
return chunk;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int readVarInt(byte[] array, int startPos) {
|
|
||||||
int numRead = 0;
|
|
||||||
int result = 0;
|
|
||||||
byte read;
|
|
||||||
do {
|
|
||||||
read = array[startPos + numRead];
|
|
||||||
int value = (read & 0b01111111);
|
|
||||||
result |= (value << (7 * numRead));
|
|
||||||
|
|
||||||
numRead++;
|
|
||||||
if (numRead > 5) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} while ((read & 0b10000000) != 0);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int readVarIntLength(byte[] array, int startPos) {
|
|
||||||
int numRead = 0;
|
|
||||||
byte read;
|
|
||||||
do {
|
|
||||||
read = array[startPos + numRead];
|
|
||||||
numRead++;
|
|
||||||
if (numRead > 5) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} while ((read & 0b10000000) != 0);
|
|
||||||
|
|
||||||
return numRead;
|
|
||||||
}
|
|
||||||
|
|
||||||
static byte[] writeVarInt(int value) {
|
|
||||||
List<Byte> buffer = new ArrayList<>(5);
|
|
||||||
do {
|
|
||||||
byte temp = (byte)(value & 0b01111111);
|
|
||||||
// Note: >>> means that the sign bit is shifted with the rest of the number rather than being left alone
|
|
||||||
value >>>= 7;
|
|
||||||
if (value != 0) {
|
|
||||||
temp |= 0b10000000;
|
|
||||||
}
|
|
||||||
buffer.add(temp);
|
|
||||||
} while (value != 0);
|
|
||||||
return Bytes.toArray(buffer);
|
|
||||||
}
|
|
||||||
}
|
|
@ -14,29 +14,23 @@
|
|||||||
<main.basedir>${project.basedir}/..</main.basedir>
|
<main.basedir>${project.basedir}/..</main.basedir>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<artifactId>FightSystem_API</artifactId>
|
<artifactId>FightSystem_Core</artifactId>
|
||||||
<version>1.0</version>
|
<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>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>steamwar</groupId>
|
<groupId>steamwar</groupId>
|
||||||
<artifactId>Spigot</artifactId>
|
<artifactId>Spigot</artifactId>
|
||||||
<version>1.12</version>
|
<version>1.15</version>
|
||||||
<scope>system</scope>
|
<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>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
This file is a part of the SteamWar software.
|
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
|
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
|
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
|
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/>.
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.steamwar.fightsystem;
|
package de.steamwar.fightsystem;
|
||||||
|
|
||||||
@ -29,7 +29,8 @@ public enum ArenaMode {
|
|||||||
EVENT,
|
EVENT,
|
||||||
TEST,
|
TEST,
|
||||||
CHECK,
|
CHECK,
|
||||||
PREPARE;
|
PREPARE,
|
||||||
|
REPLAY;
|
||||||
|
|
||||||
public static final Set<ArenaMode> All = Collections.unmodifiableSet(EnumSet.allOf(ArenaMode.class));
|
public static final Set<ArenaMode> All = Collections.unmodifiableSet(EnumSet.allOf(ArenaMode.class));
|
||||||
|
|
||||||
@ -39,14 +40,16 @@ public enum ArenaMode {
|
|||||||
public static final Set<ArenaMode> Test = Collections.unmodifiableSet(EnumSet.of(TEST, CHECK));
|
public static final Set<ArenaMode> Test = Collections.unmodifiableSet(EnumSet.of(TEST, CHECK));
|
||||||
public static final Set<ArenaMode> Ranked = Collections.unmodifiableSet(EnumSet.of(RANKED));
|
public static final Set<ArenaMode> Ranked = Collections.unmodifiableSet(EnumSet.of(RANKED));
|
||||||
public static final Set<ArenaMode> Prepare = Collections.unmodifiableSet(EnumSet.of(PREPARE));
|
public static final Set<ArenaMode> Prepare = Collections.unmodifiableSet(EnumSet.of(PREPARE));
|
||||||
|
public static final Set<ArenaMode> Replay = Collections.unmodifiableSet(EnumSet.of(REPLAY));
|
||||||
|
|
||||||
|
public static final Set<ArenaMode> AntiReplay = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(REPLAY)));
|
||||||
|
public static final Set<ArenaMode> Replayable = Collections.unmodifiableSet(EnumSet.of(REPLAY, TEST));
|
||||||
public static final Set<ArenaMode> AntiTest = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(TEST, CHECK)));
|
public static final Set<ArenaMode> AntiTest = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(TEST, CHECK)));
|
||||||
public static final Set<ArenaMode> AntiEvent = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(EVENT)));
|
public static final Set<ArenaMode> AntiEvent = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(EVENT)));
|
||||||
public static final Set<ArenaMode> AntiPrepare = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(PREPARE)));
|
public static final Set<ArenaMode> AntiPrepare = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(PREPARE)));
|
||||||
public static final Set<ArenaMode> VariableTeams = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(RANKED, EVENT)));
|
public static final Set<ArenaMode> VariableTeams = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(RANKED, EVENT, REPLAY)));
|
||||||
public static final Set<ArenaMode> RankedEvent = Collections.unmodifiableSet(EnumSet.of(RANKED, EVENT));
|
public static final Set<ArenaMode> RankedEvent = Collections.unmodifiableSet(EnumSet.of(RANKED, EVENT, REPLAY));
|
||||||
public static final Set<ArenaMode> Restartable = Collections.unmodifiableSet(EnumSet.of(NORMAL, RANKED));
|
public static final Set<ArenaMode> Restartable = Collections.unmodifiableSet(EnumSet.of(NORMAL, RANKED, REPLAY));
|
||||||
public static final Set<ArenaMode> Fight = Collections.unmodifiableSet(EnumSet.of(NORMAL, RANKED, EVENT));
|
|
||||||
public static final Set<ArenaMode> SoloLeader = Collections.unmodifiableSet(EnumSet.of(TEST, CHECK, PREPARE));
|
public static final Set<ArenaMode> SoloLeader = Collections.unmodifiableSet(EnumSet.of(TEST, CHECK, PREPARE));
|
||||||
public static final Set<ArenaMode> NotOnBau = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(TEST, CHECK, PREPARE)));
|
public static final Set<ArenaMode> NotOnBau = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(TEST, CHECK, PREPARE, REPLAY)));
|
||||||
}
|
}
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
This file is a part of the SteamWar software.
|
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
|
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
|
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
|
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/>.
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.steamwar.fightsystem;
|
package de.steamwar.fightsystem;
|
||||||
|
|
||||||
@ -67,7 +67,7 @@ public class Config {
|
|||||||
public static final Location TeamRedSpawn;
|
public static final Location TeamRedSpawn;
|
||||||
public static final Location SpecSpawn;
|
public static final Location SpecSpawn;
|
||||||
|
|
||||||
private static final int BlueToRedX;
|
public static final int BlueToRedX;
|
||||||
private static final int BlueToRedY;
|
private static final int BlueToRedY;
|
||||||
public static final int BlueToRedZ;
|
public static final int BlueToRedZ;
|
||||||
|
|
||||||
@ -124,7 +124,7 @@ public class Config {
|
|||||||
public static final int EventTeamRedID;
|
public static final int EventTeamRedID;
|
||||||
public static final boolean BothTeamsPublic;
|
public static final boolean BothTeamsPublic;
|
||||||
public static final int MaximumTeamMembers;
|
public static final int MaximumTeamMembers;
|
||||||
public static final boolean SpectateSystem;
|
public static final boolean LiveReplay;
|
||||||
|
|
||||||
//check parameter
|
//check parameter
|
||||||
public static final int CheckSchemID;
|
public static final int CheckSchemID;
|
||||||
@ -132,19 +132,21 @@ public class Config {
|
|||||||
|
|
||||||
public static final ArenaMode mode;
|
public static final ArenaMode mode;
|
||||||
|
|
||||||
//live recorder parameter
|
//replay system parameter
|
||||||
public static final String spectateIP = "127.0.0.1";
|
public static final String spectateIP = "127.0.0.1";
|
||||||
public static final int spectatePort = 2222;
|
public static final int spectatePort = 2222;
|
||||||
|
public static final int ReplayID;
|
||||||
|
|
||||||
static{
|
static{
|
||||||
if(!new File(IFightSystem.getPlugin().getDataFolder(), System.getProperty("config", "config.yml")).exists()) {
|
String configFile = System.getProperty("config", "config.yml");
|
||||||
IFightSystem.getPlugin().saveDefaultConfig();
|
if(!new File(FightSystem.getPlugin().getDataFolder(), configFile).exists()) {
|
||||||
|
FightSystem.getPlugin().saveDefaultConfig();
|
||||||
Bukkit.getLogger().log(Level.SEVERE, "Arenaconfig fehlt!");
|
Bukkit.getLogger().log(Level.SEVERE, "Arenaconfig fehlt!");
|
||||||
Bukkit.shutdown();
|
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(), configFile));
|
||||||
|
|
||||||
File worldConfigFile = new File(Bukkit.getWorlds().get(0).getWorldFolder(), config.getString("Arenaconfig", "config.yml"));
|
File worldConfigFile = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "config.yml");
|
||||||
if(!worldConfigFile.exists()) {
|
if(!worldConfigFile.exists()) {
|
||||||
Bukkit.getLogger().log(Level.SEVERE, "Weltconfig fehlt!");
|
Bukkit.getLogger().log(Level.SEVERE, "Weltconfig fehlt!");
|
||||||
Bukkit.shutdown();
|
Bukkit.shutdown();
|
||||||
@ -178,7 +180,7 @@ public class Config {
|
|||||||
GroundWalkable = config.getBoolean("Arena.GroundWalkable");
|
GroundWalkable = config.getBoolean("Arena.GroundWalkable");
|
||||||
|
|
||||||
RanksEnabled = config.getBoolean("Schematic.RanksEnabled");
|
RanksEnabled = config.getBoolean("Schematic.RanksEnabled");
|
||||||
SchematicType = de.steamwar.sql.SchematicType.fromDB(config.getString("Schematic.SchematicType"));
|
SchematicType = de.steamwar.sql.SchematicType.fromDB(Objects.requireNonNull(config.getString("Schematic.SchematicType")));
|
||||||
IgnorePublicOnly = config.getBoolean("Schematic.IgnorePublicOnly");
|
IgnorePublicOnly = config.getBoolean("Schematic.IgnorePublicOnly");
|
||||||
boolean rotate = config.getBoolean("Schematic.Rotate");
|
boolean rotate = config.getBoolean("Schematic.Rotate");
|
||||||
PasteAligned = config.getBoolean("Schematic.PasteAligned");
|
PasteAligned = config.getBoolean("Schematic.PasteAligned");
|
||||||
@ -331,7 +333,7 @@ public class Config {
|
|||||||
EventTeamRedID = team2.getTeamId();
|
EventTeamRedID = team2.getTeamId();
|
||||||
BothTeamsPublic = EventTeamRedID == 0 && EventTeamBlueID == 0;
|
BothTeamsPublic = EventTeamRedID == 0 && EventTeamBlueID == 0;
|
||||||
|
|
||||||
IFightSystem.setEventFight(eventFight);
|
FightSystem.setEventFight(eventFight);
|
||||||
|
|
||||||
Event event = Event.get(eventFight.getEventID());
|
Event event = Event.get(eventFight.getEventID());
|
||||||
if(BothTeamsPublic) {
|
if(BothTeamsPublic) {
|
||||||
@ -341,7 +343,7 @@ public class Config {
|
|||||||
OnlyPublicSchematics = event.publicSchemsOnly();
|
OnlyPublicSchematics = event.publicSchemsOnly();
|
||||||
MaximumTeamMembers = event.getMaximumTeamMembers();
|
MaximumTeamMembers = event.getMaximumTeamMembers();
|
||||||
}
|
}
|
||||||
SpectateSystem = event.spectateSystem();
|
LiveReplay = event.spectateSystem();
|
||||||
}else{
|
}else{
|
||||||
//No event
|
//No event
|
||||||
TeamRedColor = config.getString("Output.TeamRedPrefix");
|
TeamRedColor = config.getString("Output.TeamRedPrefix");
|
||||||
@ -353,7 +355,7 @@ public class Config {
|
|||||||
EventTeamRedID = 0;
|
EventTeamRedID = 0;
|
||||||
BothTeamsPublic = true;
|
BothTeamsPublic = true;
|
||||||
MaximumTeamMembers = Integer.MAX_VALUE;
|
MaximumTeamMembers = Integer.MAX_VALUE;
|
||||||
SpectateSystem = false;
|
LiveReplay = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
String blueLeader = System.getProperty("blueLeader", null);
|
String blueLeader = System.getProperty("blueLeader", null);
|
||||||
@ -370,6 +372,7 @@ public class Config {
|
|||||||
CheckSchemID = Integer.parseInt(System.getProperty("checkSchemID", "0"));
|
CheckSchemID = Integer.parseInt(System.getProperty("checkSchemID", "0"));
|
||||||
PrepareSchemID = Integer.parseInt(System.getProperty("prepareSchemID", "0"));
|
PrepareSchemID = Integer.parseInt(System.getProperty("prepareSchemID", "0"));
|
||||||
Ranked = Boolean.parseBoolean(System.getProperty("ranked", "false"));
|
Ranked = Boolean.parseBoolean(System.getProperty("ranked", "false"));
|
||||||
|
ReplayID = Integer.parseInt(System.getProperty("replay", "0"));
|
||||||
|
|
||||||
if(Ranked){
|
if(Ranked){
|
||||||
mode = ArenaMode.RANKED;
|
mode = ArenaMode.RANKED;
|
||||||
@ -381,6 +384,8 @@ public class Config {
|
|||||||
mode = ArenaMode.EVENT;
|
mode = ArenaMode.EVENT;
|
||||||
}else if(EventKampfID == -1){
|
}else if(EventKampfID == -1){
|
||||||
mode = ArenaMode.TEST;
|
mode = ArenaMode.TEST;
|
||||||
|
}else if(ReplayID != 0){
|
||||||
|
mode = ArenaMode.REPLAY;
|
||||||
}else{
|
}else{
|
||||||
mode = ArenaMode.NORMAL;
|
mode = ArenaMode.NORMAL;
|
||||||
}
|
}
|
||||||
@ -389,7 +394,10 @@ public class Config {
|
|||||||
public static boolean test(){
|
public static boolean test(){
|
||||||
return ArenaMode.Test.contains(mode);
|
return ArenaMode.Test.contains(mode);
|
||||||
}
|
}
|
||||||
public static boolean recording(){
|
public static boolean replayserver(){
|
||||||
return mode == ArenaMode.EVENT;
|
return ReplayID == -1;
|
||||||
|
}
|
||||||
|
public static boolean blueNegZ(){
|
||||||
|
return BlueToRedZ > 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -20,7 +20,6 @@
|
|||||||
package de.steamwar.fightsystem;
|
package de.steamwar.fightsystem;
|
||||||
|
|
||||||
import de.steamwar.core.CommandRemover;
|
import de.steamwar.core.CommandRemover;
|
||||||
import de.steamwar.core.Core;
|
|
||||||
import de.steamwar.fightsystem.commands.*;
|
import de.steamwar.fightsystem.commands.*;
|
||||||
import de.steamwar.fightsystem.countdown.*;
|
import de.steamwar.fightsystem.countdown.*;
|
||||||
import de.steamwar.fightsystem.event.HellsBells;
|
import de.steamwar.fightsystem.event.HellsBells;
|
||||||
@ -29,8 +28,7 @@ import de.steamwar.fightsystem.fight.FightTeam;
|
|||||||
import de.steamwar.fightsystem.fight.FightWorld;
|
import de.steamwar.fightsystem.fight.FightWorld;
|
||||||
import de.steamwar.fightsystem.listener.Shutdown;
|
import de.steamwar.fightsystem.listener.Shutdown;
|
||||||
import de.steamwar.fightsystem.listener.*;
|
import de.steamwar.fightsystem.listener.*;
|
||||||
import de.steamwar.fightsystem.record.RecordSystem;
|
import de.steamwar.fightsystem.record.*;
|
||||||
import de.steamwar.fightsystem.record.Recorder;
|
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.states.OneShotStateDependent;
|
import de.steamwar.fightsystem.states.OneShotStateDependent;
|
||||||
import de.steamwar.fightsystem.utils.EnterHandler;
|
import de.steamwar.fightsystem.utils.EnterHandler;
|
||||||
@ -49,18 +47,16 @@ public class FightSystem extends JavaPlugin {
|
|||||||
|
|
||||||
public static final String PREFIX = "§eArena§8» ";
|
public static final String PREFIX = "§eArena§8» ";
|
||||||
private static FightSystem plugin;
|
private static FightSystem plugin;
|
||||||
|
private static EventFight eventFight;
|
||||||
|
private static Player eventLeiter;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLoad() {
|
public void onLoad() {
|
||||||
plugin = this;
|
plugin = this;
|
||||||
IFightSystem.init(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
Fight.init();
|
|
||||||
RecordSystem.init();
|
|
||||||
|
|
||||||
new EntityDamage();
|
new EntityDamage();
|
||||||
new WaterRemover();
|
new WaterRemover();
|
||||||
new Permanent();
|
new Permanent();
|
||||||
@ -75,7 +71,7 @@ public class FightSystem extends JavaPlugin {
|
|||||||
new DenyWorldInteraction();
|
new DenyWorldInteraction();
|
||||||
new EventJoin();
|
new EventJoin();
|
||||||
new Recording();
|
new Recording();
|
||||||
// new ResourcePack();
|
//new ResourcePack();
|
||||||
new Check();
|
new Check();
|
||||||
new Shutdown();
|
new Shutdown();
|
||||||
new SetupQuit();
|
new SetupQuit();
|
||||||
@ -86,8 +82,7 @@ public class FightSystem extends JavaPlugin {
|
|||||||
new PersonalKitCreator();
|
new PersonalKitCreator();
|
||||||
new FightScoreboard();
|
new FightScoreboard();
|
||||||
new ArrowStopper();
|
new ArrowStopper();
|
||||||
if(Core.getVersion() > 8)
|
new ArrowPickup();
|
||||||
new ArrowPickup();
|
|
||||||
|
|
||||||
new EnterHandler();
|
new EnterHandler();
|
||||||
new TechHider();
|
new TechHider();
|
||||||
@ -108,7 +103,6 @@ public class FightSystem extends JavaPlugin {
|
|||||||
new RankedPlayerLeftWincondition();
|
new RankedPlayerLeftWincondition();
|
||||||
new WinconditionPercentTimeout();
|
new WinconditionPercentTimeout();
|
||||||
|
|
||||||
//noinspection InstantiationOfUtilityClass
|
|
||||||
new HellsBells();
|
new HellsBells();
|
||||||
|
|
||||||
new NoPlayersOnlineCountdown();
|
new NoPlayersOnlineCountdown();
|
||||||
@ -128,12 +122,16 @@ public class FightSystem extends JavaPlugin {
|
|||||||
new AkCommand();
|
new AkCommand();
|
||||||
new LeaderCommand();
|
new LeaderCommand();
|
||||||
new LockschemCommand();
|
new LockschemCommand();
|
||||||
|
new ReplayCommand();
|
||||||
new StateCommand();
|
new StateCommand();
|
||||||
new SkipCommand();
|
new SkipCommand();
|
||||||
new WinCommand();
|
new WinCommand();
|
||||||
|
|
||||||
new OneShotStateDependent(ArenaMode.All, FightState.PreRunning, () -> Bukkit.broadcastMessage(PREFIX + "§aDer Kampf beginnt!"));
|
new LiveRecorder();
|
||||||
new OneShotStateDependent(ArenaMode.All, FightState.Running, () -> Bukkit.broadcastMessage(PREFIX + "§aArena freigegeben!"));
|
new FileRecorder();
|
||||||
|
|
||||||
|
new OneShotStateDependent(ArenaMode.AntiReplay, FightState.PreRunning, () -> FightSystem.broadcast("§aDer Kampf beginnt!"));
|
||||||
|
new OneShotStateDependent(ArenaMode.AntiReplay, FightState.Running, () -> FightSystem.broadcast("§aArena freigegeben!"));
|
||||||
new OneShotStateDependent(ArenaMode.AntiTest, FightState.Running, FightStatistics::start);
|
new OneShotStateDependent(ArenaMode.AntiTest, FightState.Running, FightStatistics::start);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -148,17 +146,16 @@ public class FightSystem extends JavaPlugin {
|
|||||||
}else if(Config.mode == ArenaMode.CHECK){
|
}else if(Config.mode == ArenaMode.CHECK){
|
||||||
Fight.getBlueTeam().setSchem(Schematic.getSchemFromDB(Config.CheckSchemID));
|
Fight.getBlueTeam().setSchem(Schematic.getSchemFromDB(Config.CheckSchemID));
|
||||||
}else if(Config.mode == ArenaMode.PREPARE) {
|
}else if(Config.mode == ArenaMode.PREPARE) {
|
||||||
if(Config.BlueRotate){
|
Fight.getUnrotated().setSchem(Schematic.getSchemFromDB(Config.PrepareSchemID));
|
||||||
Fight.getRedTeam().setSchem(Schematic.getSchemFromDB(Config.PrepareSchemID));
|
}else if(Config.mode == ArenaMode.REPLAY) {
|
||||||
}else{
|
FightWorld.forceLoad();
|
||||||
Fight.getBlueTeam().setSchem(Schematic.getSchemFromDB(Config.PrepareSchemID));
|
FileSource.startReplay();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
Recorder.closeAll();
|
GlobalRecorder.getInstance().close();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setPreLeaderState() {
|
public static void setPreLeaderState() {
|
||||||
@ -185,38 +182,44 @@ public class FightSystem extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void setSpectateState(FightTeam winFightTeam, String windescription) {
|
public static void setSpectateState(FightTeam winFightTeam, String windescription) {
|
||||||
|
if(!PacketProcessor.isReplaying()){
|
||||||
|
if(winFightTeam != null) {
|
||||||
|
FightSystem.broadcast("§aDas Team " + winFightTeam.getColoredName() + " §ahat gewonnen!");
|
||||||
|
} else {
|
||||||
|
FightSystem.broadcast("§aKein Team hat gewonnen!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
FightState.setFightState(FightState.SPECTATE);
|
FightState.setFightState(FightState.SPECTATE);
|
||||||
|
|
||||||
if(winFightTeam != null) {
|
if(!Config.test() && !PacketProcessor.isReplaying()){
|
||||||
Bukkit.broadcastMessage(PREFIX + "§aDas Team " + winFightTeam.getColoredName() + " §ahat gewonnen!");
|
if(Config.mode == ArenaMode.EVENT) {
|
||||||
} else {
|
if (winFightTeam == null)
|
||||||
Bukkit.broadcastMessage(PREFIX + "§aKein Team hat gewonnen!");
|
getEventFight().setErgebnis(0);
|
||||||
}
|
else if (winFightTeam.isBlue())
|
||||||
|
getEventFight().setErgebnis(1);
|
||||||
|
else
|
||||||
|
getEventFight().setErgebnis(2);
|
||||||
|
}
|
||||||
|
|
||||||
if(Config.mode == ArenaMode.EVENT) {
|
|
||||||
if (winFightTeam == null)
|
|
||||||
getEventFight().setErgebnis(0);
|
|
||||||
else if (winFightTeam.isBlue())
|
|
||||||
getEventFight().setErgebnis(1);
|
|
||||||
else
|
|
||||||
getEventFight().setErgebnis(2);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!Config.test()){
|
|
||||||
FightStatistics.saveStats(winFightTeam, windescription);
|
FightStatistics.saveStats(winFightTeam, windescription);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setEventLeiter(Player el){
|
public static void setEventLeiter(Player el){
|
||||||
IFightSystem.setEventLeiter(el);
|
eventLeiter = el;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Player getEventLeiter(){
|
public static Player getEventLeiter(){
|
||||||
return IFightSystem.getEventLeiter();
|
return eventLeiter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static EventFight getEventFight(){
|
public static EventFight getEventFight(){
|
||||||
return IFightSystem.getEventFight();
|
return eventFight;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setEventFight(EventFight ef){
|
||||||
|
eventFight = ef;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static FightSystem getPlugin() {
|
public static FightSystem getPlugin() {
|
||||||
@ -225,11 +228,16 @@ public class FightSystem extends JavaPlugin {
|
|||||||
|
|
||||||
public static void shutdown(String reason){
|
public static void shutdown(String reason){
|
||||||
if(reason != null)
|
if(reason != null)
|
||||||
Bukkit.broadcastMessage(reason);
|
FightSystem.broadcast(reason);
|
||||||
//Staggered kick to prevent lobby overloading
|
//Staggered kick to prevent lobby overloading
|
||||||
kickNext();
|
kickNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void broadcast(String message) {
|
||||||
|
Bukkit.broadcastMessage(PREFIX + message);
|
||||||
|
GlobalRecorder.getInstance().systemChat(PREFIX + message);
|
||||||
|
}
|
||||||
|
|
||||||
private static void kickNext(){
|
private static void kickNext(){
|
||||||
if(Bukkit.getOnlinePlayers().isEmpty()){
|
if(Bukkit.getOnlinePlayers().isEmpty()){
|
||||||
Bukkit.shutdown();
|
Bukkit.shutdown();
|
41
FightSystem_Core/src/de/steamwar/fightsystem/VersionDependent.java
Normale Datei
41
FightSystem_Core/src/de/steamwar/fightsystem/VersionDependent.java
Normale Datei
@ -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);
|
||||||
|
}
|
||||||
|
}
|
@ -30,7 +30,7 @@ import org.bukkit.entity.Player;
|
|||||||
public class KitCommand implements CommandExecutor {
|
public class KitCommand implements CommandExecutor {
|
||||||
|
|
||||||
public KitCommand() {
|
public KitCommand() {
|
||||||
new StateDependentCommand(ArenaMode.All, FightState.Setup, "kit", this);
|
new StateDependentCommand(ArenaMode.AntiReplay, FightState.Setup, "kit", this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
@ -30,7 +30,7 @@ import org.bukkit.entity.Player;
|
|||||||
public class LeaveCommand implements CommandExecutor {
|
public class LeaveCommand implements CommandExecutor {
|
||||||
|
|
||||||
public LeaveCommand() {
|
public LeaveCommand() {
|
||||||
new StateDependentCommand(ArenaMode.All, FightState.Setup, "leave", this);
|
new StateDependentCommand(ArenaMode.AntiReplay, FightState.Setup, "leave", this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
@ -37,7 +37,7 @@ import org.bukkit.entity.Player;
|
|||||||
public class LockschemCommand implements CommandExecutor {
|
public class LockschemCommand implements CommandExecutor {
|
||||||
|
|
||||||
public LockschemCommand() {
|
public LockschemCommand() {
|
||||||
new StateDependentCommand(ArenaMode.All, FightState.All, "lockschem", this);
|
new StateDependentCommand(ArenaMode.AntiReplay, FightState.All, "lockschem", this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
@ -0,0 +1,70 @@
|
|||||||
|
/*
|
||||||
|
This file is a part of the SteamWar software.
|
||||||
|
|
||||||
|
Copyright (C) 2020 SteamWar.de-Serverteam
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.steamwar.fightsystem.commands;
|
||||||
|
|
||||||
|
import de.steamwar.fightsystem.ArenaMode;
|
||||||
|
import de.steamwar.fightsystem.Config;
|
||||||
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
|
import de.steamwar.fightsystem.record.FileRecorder;
|
||||||
|
import de.steamwar.fightsystem.record.FileSource;
|
||||||
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
|
import de.steamwar.fightsystem.states.StateDependentCommand;
|
||||||
|
import de.steamwar.sql.SteamwarUser;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public class ReplayCommand implements CommandExecutor {
|
||||||
|
|
||||||
|
public ReplayCommand() {
|
||||||
|
new StateDependentCommand(ArenaMode.Replayable, FightState.All, "replay", this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
if(!(sender instanceof Player)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Player player = (Player) sender;
|
||||||
|
|
||||||
|
if(!Config.test()){
|
||||||
|
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||||
|
if(!user.getUserGroup().isTeamGroup()){
|
||||||
|
sender.sendMessage(FightSystem.PREFIX + "§cDieser Befehl ist zu diesem Kampfzeitpunkt nicht verfügbar.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!FileRecorder.getFile().exists()){
|
||||||
|
sender.sendMessage(FightSystem.PREFIX + "§cKein Replay vorhanden.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
new FileSource(FileRecorder.getFile());
|
||||||
|
} catch (IOException e) {
|
||||||
|
sender.sendMessage(FightSystem.PREFIX + "§cDas Replay konnte nicht gestartet werden.");
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
@ -5,7 +5,6 @@ import de.steamwar.fightsystem.FightSystem;
|
|||||||
import de.steamwar.fightsystem.fight.Fight;
|
import de.steamwar.fightsystem.fight.Fight;
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.states.StateDependentCommand;
|
import de.steamwar.fightsystem.states.StateDependentCommand;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -35,13 +34,13 @@ public class WinCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(args[0].equalsIgnoreCase(Fight.getBlueTeam().getName())){
|
if(args[0].equalsIgnoreCase(Fight.getBlueTeam().getName())){
|
||||||
Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer Kampfleiter hat den Kampf entschieden!");
|
FightSystem.broadcast("§cDer Kampfleiter hat den Kampf entschieden!");
|
||||||
FightSystem.setSpectateState(Fight.getBlueTeam(), "Referee");
|
FightSystem.setSpectateState(Fight.getBlueTeam(), "Referee");
|
||||||
}else if(args[0].equalsIgnoreCase(Fight.getRedTeam().getName())){
|
}else if(args[0].equalsIgnoreCase(Fight.getRedTeam().getName())){
|
||||||
Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer Kampfleiter hat den Kampf entschieden!");
|
FightSystem.broadcast("§cDer Kampfleiter hat den Kampf entschieden!");
|
||||||
FightSystem.setSpectateState(Fight.getRedTeam(), "Referee");
|
FightSystem.setSpectateState(Fight.getRedTeam(), "Referee");
|
||||||
}else if(args[0].equalsIgnoreCase("tie")){
|
}else if(args[0].equalsIgnoreCase("tie")){
|
||||||
Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer Kampfleiter hat den Kampf entschieden!");
|
FightSystem.broadcast("§cDer Kampfleiter hat den Kampf entschieden!");
|
||||||
FightSystem.setSpectateState(null, "Referee");
|
FightSystem.setSpectateState(null, "Referee");
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
@ -19,11 +19,11 @@
|
|||||||
|
|
||||||
package de.steamwar.fightsystem.countdown;
|
package de.steamwar.fightsystem.countdown;
|
||||||
|
|
||||||
import de.steamwar.core.Core;
|
|
||||||
import de.steamwar.fightsystem.FightSystem;
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
import de.steamwar.fightsystem.fight.Fight;
|
import de.steamwar.fightsystem.fight.Fight;
|
||||||
import de.steamwar.fightsystem.listener.BasicListener;
|
import de.steamwar.fightsystem.listener.BasicListener;
|
||||||
import de.steamwar.fightsystem.record.RecordSystem;
|
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.BaseComponent;
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -39,7 +39,7 @@ public abstract class Countdown {
|
|||||||
private static final List<Countdown> currentCountdowns = new ArrayList<>();
|
private static final List<Countdown> currentCountdowns = new ArrayList<>();
|
||||||
|
|
||||||
private final int totalTime;
|
private final int totalTime;
|
||||||
private final Sound sound;
|
protected final Sound sound;
|
||||||
private final boolean level;
|
private final boolean level;
|
||||||
|
|
||||||
protected int time;
|
protected int time;
|
||||||
@ -48,31 +48,13 @@ public abstract class Countdown {
|
|||||||
public abstract String countdownCounting();
|
public abstract String countdownCounting();
|
||||||
public abstract void countdownFinished();
|
public abstract void countdownFinished();
|
||||||
|
|
||||||
public Countdown(int time, SWSound sound, boolean level) {
|
protected Countdown(int time, SWSound sound, boolean level) {
|
||||||
this.totalTime = time;
|
this.totalTime = time;
|
||||||
this.time = time;
|
this.time = time;
|
||||||
this.sound = getSound(sound);
|
this.sound = sound != null ? sound.getSound() : null;
|
||||||
this.level = level;
|
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() {
|
public void enable() {
|
||||||
time = totalTime;
|
time = totalTime;
|
||||||
task = Bukkit.getScheduler().runTaskTimer(FightSystem.getPlugin(), this::count, 20, 20);
|
task = Bukkit.getScheduler().runTaskTimer(FightSystem.getPlugin(), this::count, 20, 20);
|
||||||
@ -104,11 +86,11 @@ public abstract class Countdown {
|
|||||||
countdown.show();
|
countdown.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
Bukkit.broadcastMessage(FightSystem.PREFIX + "§aBeide Teams waren damit einverstanden, zum nächsten Event zu beschleunigen!");
|
FightSystem.broadcast("§aBeide Teams waren damit einverstanden, zum nächsten Event zu beschleunigen!");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void broadcast(String message){
|
private void broadcast(String message){
|
||||||
RecordSystem.actionBar(message);
|
GlobalRecorder.getInstance().actionBar(message);
|
||||||
BaseComponent[] msg = TextComponent.fromLegacyText(message);
|
BaseComponent[] msg = TextComponent.fromLegacyText(message);
|
||||||
for(Player p : Bukkit.getOnlinePlayers())
|
for(Player p : Bukkit.getOnlinePlayers())
|
||||||
BasicListener.toActionbar(p, msg);
|
BasicListener.toActionbar(p, msg);
|
@ -23,6 +23,7 @@ import de.steamwar.fightsystem.Config;
|
|||||||
import de.steamwar.fightsystem.FightSystem;
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
import de.steamwar.fightsystem.fight.FightPlayer;
|
import de.steamwar.fightsystem.fight.FightPlayer;
|
||||||
import de.steamwar.fightsystem.listener.BasicListener;
|
import de.steamwar.fightsystem.listener.BasicListener;
|
||||||
|
import de.steamwar.fightsystem.utils.SWSound;
|
||||||
import de.steamwar.fightsystem.utils.TechHider;
|
import de.steamwar.fightsystem.utils.TechHider;
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -59,19 +60,19 @@ public class EnternCountdown extends Countdown {
|
|||||||
BasicListener.toActionbar(player, TextComponent.fromLegacyText("§rNoch §a" + time / 60 + " §rMinuten " + countdownCounting()));
|
BasicListener.toActionbar(player, TextComponent.fromLegacyText("§rNoch §a" + time / 60 + " §rMinuten " + countdownCounting()));
|
||||||
break;
|
break;
|
||||||
case 60: case 30: case 20: case 15: case 10: case 5: case 4: case 3: case 2:
|
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()));
|
BasicListener.toActionbar(player, TextComponent.fromLegacyText("§rNoch §a" + time + " §rSekunden " + countdownCounting()));
|
||||||
break;
|
break;
|
||||||
case 1:
|
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()));
|
BasicListener.toActionbar(player, TextComponent.fromLegacyText("§rNoch §a1 §rSekunde " + countdownCounting()));
|
||||||
|
|
||||||
chunkPos = TechHider.prepareChunkReload(player, false);
|
chunkPos = TechHider.prepareChunkReload(player, false);
|
||||||
break;
|
break;
|
||||||
case 0:
|
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();
|
disable();
|
||||||
countdownFinished();
|
countdownFinished();
|
@ -24,6 +24,7 @@ import de.steamwar.fightsystem.Config;
|
|||||||
import de.steamwar.fightsystem.FightSystem;
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.states.StateDependentCountdown;
|
import de.steamwar.fightsystem.states.StateDependentCountdown;
|
||||||
|
import de.steamwar.fightsystem.utils.SWSound;
|
||||||
|
|
||||||
public class EventSpectateCountdown extends Countdown {
|
public class EventSpectateCountdown extends Countdown {
|
||||||
|
|
@ -34,8 +34,8 @@ public class NoPlayersOnlineCountdown extends Countdown implements Listener {
|
|||||||
public NoPlayersOnlineCountdown() {
|
public NoPlayersOnlineCountdown() {
|
||||||
super(Config.NoPlayerOnlineDuration, null, false);
|
super(Config.NoPlayerOnlineDuration, null, false);
|
||||||
|
|
||||||
new StateDependentListener(ArenaMode.All, FightState.PreLeaderSetup, this);
|
new StateDependentListener(ArenaMode.AntiReplay, FightState.PreLeaderSetup, this);
|
||||||
new StateDependentCountdown(ArenaMode.All, FightState.PreLeaderSetup, this){
|
new StateDependentCountdown(ArenaMode.AntiReplay, FightState.PreLeaderSetup, this){
|
||||||
@Override
|
@Override
|
||||||
public void enable() {
|
public void enable() {
|
||||||
if(Bukkit.getOnlinePlayers().isEmpty())
|
if(Bukkit.getOnlinePlayers().isEmpty())
|
@ -24,12 +24,13 @@ import de.steamwar.fightsystem.Config;
|
|||||||
import de.steamwar.fightsystem.FightSystem;
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.states.StateDependentCountdown;
|
import de.steamwar.fightsystem.states.StateDependentCountdown;
|
||||||
|
import de.steamwar.fightsystem.utils.SWSound;
|
||||||
|
|
||||||
public class PreRunningCountdown extends Countdown {
|
public class PreRunningCountdown extends Countdown {
|
||||||
|
|
||||||
public PreRunningCountdown() {
|
public PreRunningCountdown() {
|
||||||
super(Config.PreFightDuration, SWSound.BLOCK_NOTE_PLING, true);
|
super(Config.PreFightDuration, SWSound.BLOCK_NOTE_PLING, true);
|
||||||
new StateDependentCountdown(ArenaMode.All, FightState.PreRunning, this);
|
new StateDependentCountdown(ArenaMode.AntiReplay, FightState.PreRunning, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
@ -24,12 +24,13 @@ import de.steamwar.fightsystem.Config;
|
|||||||
import de.steamwar.fightsystem.FightSystem;
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.states.StateDependentCountdown;
|
import de.steamwar.fightsystem.states.StateDependentCountdown;
|
||||||
|
import de.steamwar.fightsystem.utils.SWSound;
|
||||||
|
|
||||||
public class PreSchemCountdown extends Countdown {
|
public class PreSchemCountdown extends Countdown {
|
||||||
|
|
||||||
public PreSchemCountdown() {
|
public PreSchemCountdown() {
|
||||||
super(Config.PreSchemPasteDuration, SWSound.BLOCK_NOTE_PLING, false);
|
super(Config.PreSchemPasteDuration, SWSound.BLOCK_NOTE_PLING, false);
|
||||||
new StateDependentCountdown(ArenaMode.All, FightState.PreSchemSetup, this);
|
new StateDependentCountdown(ArenaMode.AntiReplay, FightState.PreSchemSetup, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
@ -22,9 +22,9 @@ package de.steamwar.fightsystem.countdown;
|
|||||||
import de.steamwar.fightsystem.ArenaMode;
|
import de.steamwar.fightsystem.ArenaMode;
|
||||||
import de.steamwar.fightsystem.Config;
|
import de.steamwar.fightsystem.Config;
|
||||||
import de.steamwar.fightsystem.FightSystem;
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
import de.steamwar.fightsystem.fight.FightWorld;
|
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.states.StateDependentCountdown;
|
import de.steamwar.fightsystem.states.StateDependentCountdown;
|
||||||
|
import de.steamwar.fightsystem.utils.SWSound;
|
||||||
|
|
||||||
public class SpectateOverCountdown extends Countdown {
|
public class SpectateOverCountdown extends Countdown {
|
||||||
|
|
@ -19,9 +19,9 @@
|
|||||||
|
|
||||||
package de.steamwar.fightsystem.countdown;
|
package de.steamwar.fightsystem.countdown;
|
||||||
|
|
||||||
import de.steamwar.fightsystem.FightSystem;
|
|
||||||
import de.steamwar.fightsystem.Config;
|
import de.steamwar.fightsystem.Config;
|
||||||
import org.bukkit.Bukkit;
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
|
import de.steamwar.fightsystem.utils.SWSound;
|
||||||
|
|
||||||
public class TimeOverCountdown extends Countdown {
|
public class TimeOverCountdown extends Countdown {
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ public class TimeOverCountdown extends Countdown {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void countdownFinished() {
|
public void countdownFinished() {
|
||||||
Bukkit.broadcastMessage(FightSystem.PREFIX +"§aZeit abgelaufen!");
|
FightSystem.broadcast("§aZeit abgelaufen!");
|
||||||
timeOver.run();
|
timeOver.run();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -22,7 +22,7 @@ package de.steamwar.fightsystem.event;
|
|||||||
import de.steamwar.fightsystem.Config;
|
import de.steamwar.fightsystem.Config;
|
||||||
import de.steamwar.fightsystem.FightSystem;
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
import de.steamwar.fightsystem.countdown.Countdown;
|
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.FightState;
|
||||||
import de.steamwar.fightsystem.states.StateDependent;
|
import de.steamwar.fightsystem.states.StateDependent;
|
||||||
import de.steamwar.fightsystem.winconditions.Winconditions;
|
import de.steamwar.fightsystem.winconditions.Winconditions;
|
||||||
@ -63,10 +63,10 @@ public class HellsBells {
|
|||||||
|
|
||||||
public void startCountdown() {
|
public void startCountdown() {
|
||||||
if (current == State.PRE) {
|
if (current == State.PRE) {
|
||||||
Bukkit.broadcastMessage(FightSystem.PREFIX + (startMessages.get(random.nextInt(startMessages.size()))));
|
FightSystem.broadcast(startMessages.get(random.nextInt(startMessages.size())));
|
||||||
current = current.getNext();
|
current = current.getNext();
|
||||||
} else if (current != State.LAST && currentDrops >= current.SWITCH_AFTER) {
|
} else if (current != State.LAST && currentDrops >= current.SWITCH_AFTER) {
|
||||||
Bukkit.broadcastMessage(FightSystem.PREFIX + (stateSwapMessages.get(random.nextInt(stateSwapMessages.size()))));
|
FightSystem.broadcast(stateSwapMessages.get(random.nextInt(stateSwapMessages.size())));
|
||||||
currentDrops = 0;
|
currentDrops = 0;
|
||||||
}
|
}
|
||||||
|
|
@ -28,10 +28,11 @@ import com.comphenix.protocol.wrappers.WrappedChatComponent;
|
|||||||
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
||||||
import de.steamwar.fightsystem.ArenaMode;
|
import de.steamwar.fightsystem.ArenaMode;
|
||||||
import de.steamwar.fightsystem.Config;
|
import de.steamwar.fightsystem.Config;
|
||||||
import de.steamwar.fightsystem.record.RecordSystem;
|
|
||||||
import de.steamwar.fightsystem.FightSystem;
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
import de.steamwar.sql.Schematic;
|
import de.steamwar.fightsystem.record.GlobalRecorder;
|
||||||
import org.bukkit.*;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.GameMode;
|
||||||
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
@ -45,10 +46,6 @@ public class Fight {
|
|||||||
private static final FightTeam redTeam = new FightTeam(Config.TeamRedName, Config.TeamRedColor, Config.TeamRedSpawn, Config.RedPasteRegion, Config.RedExtendRegion, Config.RedRotate, false, Config.RedLeader);
|
private static final FightTeam redTeam = new FightTeam(Config.TeamRedName, Config.TeamRedColor, Config.TeamRedSpawn, Config.RedPasteRegion, Config.RedExtendRegion, Config.RedRotate, false, Config.RedLeader);
|
||||||
private static final FightTeam blueTeam = new FightTeam(Config.TeamBlueName, Config.TeamBlueColor, Config.TeamBlueSpawn, Config.BluePasteRegion, Config.BlueExtendRegion, Config.BlueRotate, true, Config.BlueLeader);
|
private static final FightTeam blueTeam = new FightTeam(Config.TeamBlueName, Config.TeamBlueColor, Config.TeamBlueSpawn, Config.BluePasteRegion, Config.BlueExtendRegion, Config.BlueRotate, true, Config.BlueLeader);
|
||||||
|
|
||||||
public static void init(){
|
|
||||||
IFight.init(redTeam, blueTeam);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static FightTeam getPlayerTeam(Player player) {
|
public static FightTeam getPlayerTeam(Player player) {
|
||||||
if(redTeam.isPlayerInTeam(player))
|
if(redTeam.isPlayerInTeam(player))
|
||||||
return redTeam;
|
return redTeam;
|
||||||
@ -90,8 +87,12 @@ public class Fight {
|
|||||||
return blueTeam;
|
return blueTeam;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static FightTeam getUnrotated() {
|
||||||
|
return Config.BlueRotate ? Fight.getRedTeam() : Fight.getBlueTeam();
|
||||||
|
}
|
||||||
|
|
||||||
public static void playSound(Sound sound, float volume, float pitch) {
|
public static void playSound(Sound sound, float volume, float pitch) {
|
||||||
RecordSystem.soundAtPlayer(sound.name(), volume, pitch);
|
GlobalRecorder.getInstance().soundAtPlayer(sound.name(), volume, pitch);
|
||||||
//volume: max. 100, pitch: max. 2
|
//volume: max. 100, pitch: max. 2
|
||||||
Bukkit.getServer().getOnlinePlayers().forEach(player -> player.playSound(player.getLocation(), sound, volume, pitch));
|
Bukkit.getServer().getOnlinePlayers().forEach(player -> player.playSound(player.getLocation(), sound, volume, pitch));
|
||||||
}
|
}
|
||||||
@ -121,16 +122,7 @@ public class Fight {
|
|||||||
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> {
|
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> {
|
||||||
if(!player.isOnline())
|
if(!player.isOnline())
|
||||||
return;
|
return;
|
||||||
PacketContainer gm1packet = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.PLAYER_INFO);
|
pseudoSpectator(player, true);
|
||||||
gm1packet.getPlayerInfoAction().write(0, EnumWrappers.PlayerInfoAction.UPDATE_GAME_MODE);
|
|
||||||
List<PlayerInfoData> playerInfoActions = new ArrayList<>();
|
|
||||||
playerInfoActions.add(new PlayerInfoData(WrappedGameProfile.fromPlayer(player), 1, EnumWrappers.NativeGameMode.CREATIVE, WrappedChatComponent.fromText(player.getDisplayName())));
|
|
||||||
gm1packet.getPlayerInfoDataLists().write(0, playerInfoActions);
|
|
||||||
try {
|
|
||||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, gm1packet);
|
|
||||||
} catch (InvocationTargetException e) {
|
|
||||||
Bukkit.getLogger().log(Level.SEVERE, "Invocation target exception", e);
|
|
||||||
}
|
|
||||||
}, 2);
|
}, 2);
|
||||||
}else if(gameMode == GameMode.SURVIVAL) {
|
}else if(gameMode == GameMode.SURVIVAL) {
|
||||||
for(Player currentPlayer : Bukkit.getServer().getOnlinePlayers()) {
|
for(Player currentPlayer : Bukkit.getServer().getOnlinePlayers()) {
|
||||||
@ -142,6 +134,19 @@ public class Fight {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void pseudoSpectator(Player player, boolean enable) {
|
||||||
|
PacketContainer gm1packet = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.PLAYER_INFO);
|
||||||
|
gm1packet.getPlayerInfoAction().write(0, EnumWrappers.PlayerInfoAction.UPDATE_GAME_MODE);
|
||||||
|
List<PlayerInfoData> playerInfoActions = new ArrayList<>();
|
||||||
|
playerInfoActions.add(new PlayerInfoData(WrappedGameProfile.fromPlayer(player), 1, enable ? EnumWrappers.NativeGameMode.CREATIVE : EnumWrappers.NativeGameMode.SPECTATOR, WrappedChatComponent.fromText(player.getDisplayName())));
|
||||||
|
gm1packet.getPlayerInfoDataLists().write(0, playerInfoActions);
|
||||||
|
try {
|
||||||
|
ProtocolLibrary.getProtocolManager().sendServerPacket(player, gm1packet);
|
||||||
|
} catch (InvocationTargetException e) {
|
||||||
|
Bukkit.getLogger().log(Level.SEVERE, "Invocation target exception", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static int getMaxRank(){
|
public static int getMaxRank(){
|
||||||
/* MaxRank of 0 is Pubonly*/
|
/* MaxRank of 0 is Pubonly*/
|
||||||
if(Config.OnlyPublicSchematics){
|
if(Config.OnlyPublicSchematics){
|
||||||
@ -157,22 +162,6 @@ public class Fight {
|
|||||||
return 1000;
|
return 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Config.RanksEnabled)
|
return Math.min(redTeam.getSchemRank(), blueTeam.getSchemRank());
|
||||||
return Math.min(schemRank(redTeam.getLeader()), schemRank(blueTeam.getLeader()));
|
|
||||||
else if(Schematic.getSchemsOfType(redTeam.getLeader().getPlayer().getUniqueId(), Config.SchematicType).isEmpty() ||
|
|
||||||
Schematic.getSchemsOfType(blueTeam.getLeader().getPlayer().getUniqueId(), Config.SchematicType).isEmpty())
|
|
||||||
return 0;
|
|
||||||
else
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static int schemRank(FightPlayer fightPlayer){
|
|
||||||
int rank = 1;
|
|
||||||
List<Schematic> schematics = Schematic.getSchemsOfType(fightPlayer.getPlayer().getUniqueId(), Config.SchematicType);
|
|
||||||
for(Schematic schem : schematics){
|
|
||||||
if(schem.getRank() > rank)
|
|
||||||
rank = schem.getRank();
|
|
||||||
}
|
|
||||||
return rank;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -21,28 +21,21 @@ package de.steamwar.fightsystem.fight;
|
|||||||
|
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||||
import de.steamwar.core.VersionedRunnable;
|
import com.sk89q.worldedit.math.transform.AffineTransform;
|
||||||
import de.steamwar.fightsystem.ArenaMode;
|
import de.steamwar.fightsystem.ArenaMode;
|
||||||
import de.steamwar.fightsystem.Config;
|
import de.steamwar.fightsystem.Config;
|
||||||
import de.steamwar.fightsystem.FightSystem;
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
import de.steamwar.fightsystem.IFightSystem;
|
import de.steamwar.fightsystem.record.GlobalRecorder;
|
||||||
import de.steamwar.fightsystem.record.RecordSystem;
|
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.states.StateDependent;
|
import de.steamwar.fightsystem.states.StateDependent;
|
||||||
import de.steamwar.fightsystem.utils.ColorConverter;
|
import de.steamwar.fightsystem.utils.ColorConverter;
|
||||||
import de.steamwar.fightsystem.utils.Region;
|
import de.steamwar.fightsystem.utils.Region;
|
||||||
import de.steamwar.sql.NoClipboardException;
|
import de.steamwar.fightsystem.utils.WorldeditWrapper;
|
||||||
import de.steamwar.sql.Schematic;
|
import de.steamwar.sql.Schematic;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.*;
|
||||||
import org.bukkit.DyeColor;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.util.Vector;
|
||||||
import org.bukkit.event.block.*;
|
|
||||||
import org.bukkit.event.inventory.InventoryMoveItemEvent;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -66,7 +59,7 @@ public class FightSchematic extends StateDependent {
|
|||||||
register();
|
register();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasSchematic(){
|
public boolean hasSchematic() {
|
||||||
return clipboard != null;
|
return clipboard != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,11 +72,16 @@ public class FightSchematic extends StateDependent {
|
|||||||
try {
|
try {
|
||||||
clipboard = schem.load();
|
clipboard = schem.load();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
team.broadcast(FightSystem.PREFIX + "§cKonnte die Schematic nicht laden!");
|
team.broadcast(FightSystem.PREFIX + "§cSchematic konnte nicht geladen werden!");
|
||||||
Bukkit.getLogger().log(Level.SEVERE, "Couldn't load Schematic " + schem.getSchemName(), e);
|
Bukkit.getLogger().log(Level.SEVERE, e, () -> "Couldn't load Schematic " + schem.getSchemName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setSchematic(int schemId, Clipboard clipboard) {
|
||||||
|
this.schematic = schemId;
|
||||||
|
this.clipboard = clipboard;
|
||||||
|
}
|
||||||
|
|
||||||
public void reset(){
|
public void reset(){
|
||||||
schematic = 0;
|
schematic = 0;
|
||||||
clipboard = null;
|
clipboard = null;
|
||||||
@ -109,47 +107,39 @@ public class FightSchematic extends StateDependent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(team.isBlue())
|
if(team.isBlue())
|
||||||
RecordSystem.blueSchem(schematic);
|
GlobalRecorder.getInstance().blueSchem(schematic);
|
||||||
else
|
else
|
||||||
RecordSystem.redSchem(schematic);
|
GlobalRecorder.getInstance().redSchem(schematic);
|
||||||
|
|
||||||
Bukkit.getScheduler().runTask(FightSystem.getPlugin(), this::paste);
|
Bukkit.getScheduler().runTask(FightSystem.getPlugin(), this::paste);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void replaceTeamColor(Clipboard clipboard) {
|
||||||
|
try {
|
||||||
|
WorldeditWrapper.impl.replaceTeamColor(clipboard, ArenaMode.AntiPrepare.contains(Config.mode) ? ColorConverter.chat2dye(team.getColor()) : DyeColor.PINK);
|
||||||
|
} catch (WorldEditException e) {
|
||||||
|
Bukkit.getLogger().log(Level.SEVERE, "Could not recolor schematic", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void paste(){
|
private void paste(){
|
||||||
FreezeWorld freezer = new FreezeWorld();
|
FreezeWorld freezer = new FreezeWorld();
|
||||||
DyeColor c = ArenaMode.AntiPrepare.contains(Config.mode) ? ColorConverter.chat2dye(team.getColor()) : DyeColor.PINK;
|
|
||||||
|
|
||||||
try {
|
replaceTeamColor(clipboard);
|
||||||
VersionedRunnable.call(new VersionedRunnable(() -> {
|
|
||||||
try {
|
|
||||||
FightTeam_8.replaceTeamColor(clipboard, c);
|
|
||||||
FightTeam_8.pasteSchematic(clipboard, region, rotate);
|
|
||||||
} catch (NoClipboardException | WorldEditException ex) {
|
|
||||||
throw new SecurityException("Error pasting schematic", ex);
|
|
||||||
}
|
|
||||||
}, 8), new VersionedRunnable(() -> {
|
|
||||||
try {
|
|
||||||
FightTeam_12.replaceTeamColor(clipboard, c);
|
|
||||||
FightTeam_8.pasteSchematic(clipboard, region, rotate);
|
|
||||||
} catch (NoClipboardException | WorldEditException ex) {
|
|
||||||
throw new SecurityException("Error pasting schematic", ex);
|
|
||||||
}
|
|
||||||
}, 12), new VersionedRunnable(() -> {
|
|
||||||
try {
|
|
||||||
FightTeam_14.replaceTeamColor(clipboard, c);
|
|
||||||
FightTeam_14.pasteSchematic(clipboard, region, rotate);
|
|
||||||
} catch (NoClipboardException | WorldEditException ex) {
|
|
||||||
throw new SecurityException("Error pasting schematic", ex);
|
|
||||||
}
|
|
||||||
}, 14));
|
|
||||||
} catch (SecurityException securityException) {
|
|
||||||
Bukkit.broadcastMessage(FightSystem.PREFIX + "§cFehler beim Pasten der Schematic");
|
|
||||||
Bukkit.getScheduler().runTask(FightSystem.getPlugin(), FightSystem::setPreSchemState);
|
|
||||||
throw securityException;
|
|
||||||
}
|
|
||||||
|
|
||||||
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> HandlerList.unregisterAll(freezer), 3);
|
Vector dims = WorldeditWrapper.impl.getDimensions(clipboard);
|
||||||
|
WorldeditWrapper.impl.pasteClipboard(
|
||||||
|
clipboard,
|
||||||
|
new Location(Bukkit.getWorlds().get(0), region.centerX(), region.getMinY(), region.centerZ()),
|
||||||
|
new Vector(
|
||||||
|
-(Config.PasteAligned && Config.BlueToRedX != 0 ? region.getSizeX() : dims.getBlockX())/2.0,
|
||||||
|
Config.WaterDepth != 0 ? Config.WaterDepth - WorldeditWrapper.impl.getWaterDepth(clipboard) : 0,
|
||||||
|
-(Config.PasteAligned && Config.BlueToRedZ != 0 ? region.getSizeZ() : dims.getBlockZ())/2.0
|
||||||
|
).add(new Vector(rotate ? 1 : 0, 0, rotate ? 1 : 0)),
|
||||||
|
new AffineTransform().rotateY(rotate ? 180 : 0)
|
||||||
|
);
|
||||||
|
|
||||||
|
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), freezer::disable, 3);
|
||||||
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), team::teleportToSpawn, 40);
|
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), team::teleportToSpawn, 40);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -169,6 +159,41 @@ public class FightSchematic extends StateDependent {
|
|||||||
HandlerList.unregisterAll(freezer);
|
HandlerList.unregisterAll(freezer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void pasteTeamName(){
|
||||||
|
char[] chars = team.getName().toCharArray();
|
||||||
|
Clipboard[] characters = new Clipboard[chars.length];
|
||||||
|
|
||||||
|
int length = 0;
|
||||||
|
int[] offsets = new int[chars.length];
|
||||||
|
|
||||||
|
for(int i = 0; i < chars.length; i++){
|
||||||
|
Clipboard character;
|
||||||
|
try {
|
||||||
|
character = WorldeditWrapper.impl.loadChar(chars[i] == '/' ? "slash" : String.valueOf(chars[i]));
|
||||||
|
} catch (IOException e) {
|
||||||
|
Bukkit.getLogger().log(Level.WARNING, "Could not display character {} due to missing file!", chars[i]);
|
||||||
|
try {
|
||||||
|
character = WorldeditWrapper.impl.loadChar("");
|
||||||
|
}catch (IOException ex) {
|
||||||
|
throw new SecurityException("Could not load text", ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
replaceTeamColor(character);
|
||||||
|
|
||||||
|
characters[i] = character;
|
||||||
|
offsets[i] = length;
|
||||||
|
length += WorldeditWrapper.impl.getDimensions(character).getBlockX() + 1; // 1 is the distance between characters
|
||||||
|
}
|
||||||
|
|
||||||
|
length -= 1;
|
||||||
|
AffineTransform aT = new AffineTransform().rotateY(rotate ? 180 : 0);
|
||||||
|
Location base = new Location(Bukkit.getWorlds().get(0), region.centerX(), team.getExtendRegion().getMaxY(), region.centerZ());
|
||||||
|
for(int i = 0; i < characters.length; i++){
|
||||||
|
WorldeditWrapper.impl.pasteClipboard(characters[i], base, new Vector(offsets[i] - length/2, 0, region.getSizeZ()/2), aT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void replaceSync(Material target, Material replacement){
|
private void replaceSync(Material target, Material replacement){
|
||||||
World world = Bukkit.getWorlds().get(0);
|
World world = Bukkit.getWorlds().get(0);
|
||||||
|
|
||||||
@ -178,45 +203,4 @@ public class FightSchematic extends StateDependent {
|
|||||||
block.setType(replacement);
|
block.setType(replacement);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class FreezeWorld implements Listener {
|
|
||||||
private FreezeWorld(){
|
|
||||||
Bukkit.getPluginManager().registerEvents(this, IFightSystem.getPlugin());
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onBlockPhysicsEvent(BlockPhysicsEvent e){
|
|
||||||
e.setCancelled(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onPistonExtend(BlockPistonExtendEvent e){
|
|
||||||
e.setCancelled(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onPistonRetract(BlockPistonRetractEvent e){
|
|
||||||
e.setCancelled(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onBlockGrow(BlockGrowEvent e){
|
|
||||||
e.setCancelled(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onRedstoneEvent(BlockRedstoneEvent e){
|
|
||||||
e.setNewCurrent(e.getOldCurrent());
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onBlockDispense(BlockDispenseEvent e){
|
|
||||||
e.setCancelled(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onInventoryMoveEvent(InventoryMoveItemEvent e){
|
|
||||||
e.setCancelled(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -19,21 +19,18 @@
|
|||||||
|
|
||||||
package de.steamwar.fightsystem.fight;
|
package de.steamwar.fightsystem.fight;
|
||||||
|
|
||||||
|
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||||
import de.steamwar.comms.packets.TablistNamePacket;
|
import de.steamwar.comms.packets.TablistNamePacket;
|
||||||
import de.steamwar.core.VersionedRunnable;
|
|
||||||
import de.steamwar.fightsystem.ArenaMode;
|
import de.steamwar.fightsystem.ArenaMode;
|
||||||
import de.steamwar.fightsystem.Config;
|
import de.steamwar.fightsystem.Config;
|
||||||
import de.steamwar.fightsystem.FightSystem;
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
import de.steamwar.fightsystem.countdown.Countdown;
|
import de.steamwar.fightsystem.countdown.Countdown;
|
||||||
import de.steamwar.fightsystem.listener.BasicListener;
|
|
||||||
import de.steamwar.fightsystem.listener.PersonalKitCreator;
|
|
||||||
import de.steamwar.fightsystem.record.RecordSystem;
|
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
|
||||||
import de.steamwar.fightsystem.listener.FightScoreboard;
|
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.states.StateDependent;
|
||||||
import de.steamwar.fightsystem.utils.ItemBuilder;
|
import de.steamwar.fightsystem.utils.*;
|
||||||
import de.steamwar.fightsystem.utils.Region;
|
|
||||||
import de.steamwar.fightsystem.utils.TechHider;
|
|
||||||
import de.steamwar.inventory.SWItem;
|
import de.steamwar.inventory.SWItem;
|
||||||
import de.steamwar.sql.Schematic;
|
import de.steamwar.sql.Schematic;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
import de.steamwar.sql.SteamwarUser;
|
||||||
@ -47,16 +44,18 @@ import org.bukkit.scoreboard.Team;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
|
||||||
public class FightTeam implements IFightTeam{
|
public class FightTeam {
|
||||||
|
|
||||||
private UUID designatedLeader;
|
private UUID designatedLeader;
|
||||||
private FightPlayer leader;
|
private FightPlayer leader;
|
||||||
|
private int schemRank;
|
||||||
|
|
||||||
private final Map<Player, FightPlayer> players = new HashMap<>();
|
private final Map<Player, FightPlayer> players = new HashMap<>();
|
||||||
private final Set<Player> invited = new HashSet<>();
|
private final Set<Player> invited = new HashSet<>();
|
||||||
|
|
||||||
private final String name;
|
private String name;
|
||||||
private final String prefix;
|
private String prefix;
|
||||||
private final ChatColor color;
|
private ChatColor color;
|
||||||
private final FightSchematic schematic;
|
private final FightSchematic schematic;
|
||||||
private final Team team;
|
private final Team team;
|
||||||
private final boolean blue;
|
private final boolean blue;
|
||||||
@ -72,28 +71,34 @@ public class FightTeam implements IFightTeam{
|
|||||||
this.spawn = spawn;
|
this.spawn = spawn;
|
||||||
this.schemRegion = schemRegion;
|
this.schemRegion = schemRegion;
|
||||||
this.extendRegion = extendRegion;
|
this.extendRegion = extendRegion;
|
||||||
this.name = name;
|
this.schemRank = 0;
|
||||||
this.prefix = prefix;
|
|
||||||
this.ready = false;
|
this.ready = false;
|
||||||
this.skip = false;
|
this.skip = false;
|
||||||
this.blue = blue;
|
this.blue = blue;
|
||||||
this.designatedLeader = designatedLeader;
|
this.designatedLeader = designatedLeader;
|
||||||
this.color = ChatColor.getByChar(ChatColor.getLastColors(prefix).replace("§", ""));
|
setPrefixAndName(prefix, name);
|
||||||
this.schematic = new FightSchematic(this, rotate);
|
this.schematic = new FightSchematic(this, rotate);
|
||||||
new KitLoader();
|
new KitLoader();
|
||||||
new SpectateHandler();
|
new SpectateHandler();
|
||||||
|
|
||||||
if(FightScoreboard.getScoreboard().getTeam(name) == null)
|
if(FightScoreboard.getBukkit().getTeam(name) == null)
|
||||||
team = FightScoreboard.getScoreboard().registerNewTeam(name);
|
team = FightScoreboard.getBukkit().registerNewTeam(name);
|
||||||
else
|
else
|
||||||
team = FightScoreboard.getScoreboard().getTeam(name);
|
team = FightScoreboard.getBukkit().getTeam(name);
|
||||||
assert team != null;
|
assert team != null;
|
||||||
setTeamColor(team, color);
|
WorldOfColorWrapper.impl.setTeamColor(team, color);
|
||||||
|
BountifulWrapper.impl.setNametagVisibility(team);
|
||||||
//noinspection deprecation
|
//noinspection deprecation
|
||||||
team.setNameTagVisibility(NameTagVisibility.HIDE_FOR_OTHER_TEAMS);
|
team.setNameTagVisibility(NameTagVisibility.HIDE_FOR_OTHER_TEAMS);
|
||||||
team.setAllowFriendlyFire(false);
|
team.setAllowFriendlyFire(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setPrefixAndName(String prefix, String name){
|
||||||
|
this.name = name;
|
||||||
|
this.prefix = prefix;
|
||||||
|
this.color = ChatColor.getByChar(ChatColor.getLastColors(prefix).replace("§", ""));
|
||||||
|
}
|
||||||
|
|
||||||
public UUID getDesignatedLeader(){
|
public UUID getDesignatedLeader(){
|
||||||
return designatedLeader;
|
return designatedLeader;
|
||||||
}
|
}
|
||||||
@ -110,6 +115,10 @@ public class FightTeam implements IFightTeam{
|
|||||||
return isLeaderless() && (designatedLeader == null || designatedLeader.equals(p.getUniqueId()));
|
return isLeaderless() && (designatedLeader == null || designatedLeader.equals(p.getUniqueId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getSchemRank() {
|
||||||
|
return schemRank;
|
||||||
|
}
|
||||||
|
|
||||||
public void teleportToSpawn(){
|
public void teleportToSpawn(){
|
||||||
players.forEach((player, fp) -> player.teleport(spawn));
|
players.forEach((player, fp) -> player.teleport(spawn));
|
||||||
}
|
}
|
||||||
@ -126,12 +135,10 @@ public class FightTeam implements IFightTeam{
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isPlayerInTeam(Player player) {
|
public boolean isPlayerInTeam(Player player) {
|
||||||
return players.containsKey(player);
|
return players.containsKey(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canPlayerEntern(Player player) {
|
public boolean canPlayerEntern(Player player) {
|
||||||
return getFightPlayer(player).canEntern();
|
return getFightPlayer(player).canEntern();
|
||||||
}
|
}
|
||||||
@ -166,7 +173,7 @@ public class FightTeam implements IFightTeam{
|
|||||||
|
|
||||||
playerSet.forEach(this::addMember);
|
playerSet.forEach(this::addMember);
|
||||||
|
|
||||||
if(isLeaderless()){
|
if(ArenaMode.VariableTeams.contains(Config.mode) && isLeaderless()){
|
||||||
for(Player player : Bukkit.getOnlinePlayers()){
|
for(Player player : Bukkit.getOnlinePlayers()){
|
||||||
if(Fight.getPlayerTeam(player) == null && canbeLeader(player)){
|
if(Fight.getPlayerTeam(player) == null && canbeLeader(player)){
|
||||||
addMember(player);
|
addMember(player);
|
||||||
@ -191,14 +198,14 @@ public class FightTeam implements IFightTeam{
|
|||||||
player.setHealth(20);
|
player.setHealth(20);
|
||||||
player.setFoodLevel(20);
|
player.setFoodLevel(20);
|
||||||
player.getInventory().clear();
|
player.getInventory().clear();
|
||||||
BasicListener.setAttackSpeed(player);
|
BountifulWrapper.impl.setAttackSpeed(player);
|
||||||
player.teleport(spawn);
|
player.teleport(spawn);
|
||||||
if(Kit.getAvailableKits(false).size() > 1 || Config.PersonalKits)
|
if(Kit.getAvailableKits(false).size() > 1 || Config.PersonalKits)
|
||||||
player.getInventory().setItem(1, new ItemBuilder(Material.LEATHER_CHESTPLATE).removeAllAttributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName("§eKit wählen").build());
|
player.getInventory().setItem(1, new ItemBuilder(Material.LEATHER_CHESTPLATE).removeAllAttributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName("§eKit wählen").build());
|
||||||
player.getInventory().setItem(7, new ItemBuilder(Material.BEACON).removeAllAttributs().setDisplayName("§eRespawn").build());
|
player.getInventory().setItem(7, new ItemBuilder(Material.BEACON).removeAllAttributs().setDisplayName("§eRespawn").build());
|
||||||
if(ArenaMode.NotOnBau.contains(Config.mode))
|
if(ArenaMode.NotOnBau.contains(Config.mode))
|
||||||
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> new TablistNamePacket(SteamwarUser.get(player.getUniqueId()).getId(), prefix + player.getName()).send(player), 5);
|
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> new TablistNamePacket(SteamwarUser.get(player.getUniqueId()).getId(), prefix + player.getName()).send(player), 5);
|
||||||
RecordSystem.playerJoins(player);
|
GlobalRecorder.getInstance().playerJoins(player);
|
||||||
TechHider.reloadChunks(player, chunksToReload, false);
|
TechHider.reloadChunks(player, chunksToReload, false);
|
||||||
|
|
||||||
if(isLeaderless())
|
if(isLeaderless())
|
||||||
@ -216,7 +223,7 @@ public class FightTeam implements IFightTeam{
|
|||||||
if(fightPlayer.equals(leader))
|
if(fightPlayer.equals(leader))
|
||||||
setLeader(null);
|
setLeader(null);
|
||||||
|
|
||||||
RecordSystem.entityDespawns(player);
|
GlobalRecorder.getInstance().entityDespawns(player);
|
||||||
Fight.setPlayerGamemode(player, GameMode.SPECTATOR);
|
Fight.setPlayerGamemode(player, GameMode.SPECTATOR);
|
||||||
player.teleport(Config.SpecSpawn);
|
player.teleport(Config.SpecSpawn);
|
||||||
player.getInventory().clear();
|
player.getInventory().clear();
|
||||||
@ -232,7 +239,6 @@ public class FightTeam implements IFightTeam{
|
|||||||
return leader == null;
|
return leader == null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isBlue(){
|
public boolean isBlue(){
|
||||||
return blue;
|
return blue;
|
||||||
}
|
}
|
||||||
@ -246,7 +252,7 @@ public class FightTeam implements IFightTeam{
|
|||||||
this.leader = null;
|
this.leader = null;
|
||||||
if(!players.isEmpty()) {
|
if(!players.isEmpty()) {
|
||||||
setLeader(players.values().iterator().next());
|
setLeader(players.values().iterator().next());
|
||||||
Bukkit.broadcastMessage(FightSystem.PREFIX + "§aDer Spieler §e" + this.leader.getPlayer().getName() + " §aist nun Leader von Team " + getColoredName() + "§a!");
|
FightSystem.broadcast("§aDer Spieler §e" + this.leader.getPlayer().getName() + " §aist nun Leader von Team " + getColoredName() + "§a!");
|
||||||
}else if(FightState.getFightState() != FightState.PRE_LEADER_SETUP && !ArenaMode.RankedEvent.contains(Config.mode)){
|
}else if(FightState.getFightState() != FightState.PRE_LEADER_SETUP && !ArenaMode.RankedEvent.contains(Config.mode)){
|
||||||
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), FightSystem::setPreLeaderState, 1);
|
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), FightSystem::setPreLeaderState, 1);
|
||||||
}
|
}
|
||||||
@ -259,6 +265,12 @@ public class FightTeam implements IFightTeam{
|
|||||||
if(ready)
|
if(ready)
|
||||||
setReady(false);
|
setReady(false);
|
||||||
|
|
||||||
|
Optional<Integer> maxRank = Schematic.getSchemsOfType(leader.getPlayer().getUniqueId(), Config.SchematicType).stream().map(Schematic::getRank).max(Integer::compare);
|
||||||
|
if(Config.RanksEnabled)
|
||||||
|
schemRank = maxRank.orElse(1);
|
||||||
|
else
|
||||||
|
schemRank = maxRank.isPresent() ? 1 : 0;
|
||||||
|
|
||||||
if(!Config.PersonalKits)
|
if(!Config.PersonalKits)
|
||||||
leader.setKit(Kit.getKitByName(Config.LeaderDefault));
|
leader.setKit(Kit.getKitByName(Config.LeaderDefault));
|
||||||
|
|
||||||
@ -295,23 +307,31 @@ public class FightTeam implements IFightTeam{
|
|||||||
|
|
||||||
public void pasteSchem(Schematic schematic){
|
public void pasteSchem(Schematic schematic){
|
||||||
setSchem(schematic);
|
setSchem(schematic);
|
||||||
|
testPasteAction();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void pasteSchem(int schemId, Clipboard clipboard){
|
||||||
|
this.schematic.setSchematic(schemId, clipboard);
|
||||||
|
testPasteAction();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void testPasteAction(){
|
||||||
if(Config.test())
|
if(Config.test())
|
||||||
this.schematic.enable();
|
this.schematic.enable();
|
||||||
else if(Fight.getOpposite(this).hasSchematic()){
|
else if(Fight.getOpposite(this).schematic.hasSchematic()){
|
||||||
FightSystem.setPostSchemState();
|
FightSystem.setPostSchemState();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void pasteTeamName(){
|
||||||
|
schematic.pasteTeamName();
|
||||||
|
}
|
||||||
|
|
||||||
public void setSchem(Schematic schematic){
|
public void setSchem(Schematic schematic){
|
||||||
this.schematic.setSchematic(schematic);
|
this.schematic.setSchematic(schematic);
|
||||||
broadcast(FightSystem.PREFIX + "§7Das §e" + Config.GameName + " " + schematic.getSchemName() + " §7wird für den Kampf verwendet!");
|
broadcast(FightSystem.PREFIX + "§7Das §e" + Config.GameName + " " + schematic.getSchemName() + " §7wird für den Kampf verwendet!");
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasSchematic(){
|
|
||||||
return schematic.hasSchematic();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setReady(boolean ready) {
|
public void setReady(boolean ready) {
|
||||||
Player l = leader.getPlayer();
|
Player l = leader.getPlayer();
|
||||||
|
|
||||||
@ -385,20 +405,13 @@ public class FightTeam implements IFightTeam{
|
|||||||
return currentHearts / maximumHearts;
|
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() {
|
public ChatColor getColor() {
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
|
||||||
private class KitLoader extends StateDependent {
|
private class KitLoader extends StateDependent {
|
||||||
private KitLoader() {
|
private KitLoader() {
|
||||||
super(ArenaMode.All, FightState.Ingame);
|
super(ArenaMode.AntiReplay, FightState.Ingame);
|
||||||
register();
|
register();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -423,7 +436,7 @@ public class FightTeam implements IFightTeam{
|
|||||||
|
|
||||||
private class SpectateHandler extends StateDependent {
|
private class SpectateHandler extends StateDependent {
|
||||||
private SpectateHandler() {
|
private SpectateHandler() {
|
||||||
super(ArenaMode.All, FightState.Spectate);
|
super(ArenaMode.AntiReplay, FightState.Spectate);
|
||||||
register();
|
register();
|
||||||
}
|
}
|
||||||
|
|
@ -19,11 +19,12 @@
|
|||||||
|
|
||||||
package de.steamwar.fightsystem.fight;
|
package de.steamwar.fightsystem.fight;
|
||||||
|
|
||||||
import de.steamwar.core.VersionedRunnable;
|
|
||||||
import de.steamwar.fightsystem.ArenaMode;
|
import de.steamwar.fightsystem.ArenaMode;
|
||||||
import de.steamwar.fightsystem.Config;
|
import de.steamwar.fightsystem.Config;
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.states.StateDependent;
|
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.Bukkit;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.WorldCreator;
|
import org.bukkit.WorldCreator;
|
||||||
@ -32,14 +33,13 @@ import org.bukkit.entity.EntityType;
|
|||||||
|
|
||||||
public class FightWorld extends StateDependent {
|
public class FightWorld extends StateDependent {
|
||||||
|
|
||||||
private static final boolean paper;
|
private static final World world = Bukkit.getWorlds().get(0);
|
||||||
|
private static final boolean paper = Bukkit.getVersion().contains("git-Paper");
|
||||||
|
|
||||||
static{
|
public static boolean isPaper(){
|
||||||
paper = Bukkit.getVersion().contains("git-Paper");
|
return paper;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final World world = Bukkit.getWorlds().get(0);
|
|
||||||
|
|
||||||
public FightWorld() {
|
public FightWorld() {
|
||||||
super(ArenaMode.Restartable, FightState.Schem);
|
super(ArenaMode.Restartable, FightState.Schem);
|
||||||
register();
|
register();
|
||||||
@ -50,12 +50,20 @@ public class FightWorld extends StateDependent {
|
|||||||
//unused
|
//unused
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isPaper(){
|
|
||||||
return paper;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void disable() {
|
public void disable() {
|
||||||
|
resetWorld();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void forceLoad(){
|
||||||
|
Config.ArenaRegion.forEachChunk((cX, cZ) -> {
|
||||||
|
world.loadChunk(cX, cZ);
|
||||||
|
FlatteningWrapper.impl.forceLoadChunk(world, cX, cZ);
|
||||||
|
});
|
||||||
|
world.setKeepSpawnInMemory(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void resetWorld(){
|
||||||
for(Entity entity : world.getEntities()){
|
for(Entity entity : world.getEntities()){
|
||||||
if(entity.getType() != EntityType.PLAYER){
|
if(entity.getType() != EntityType.PLAYER){
|
||||||
entity.remove();
|
entity.remove();
|
||||||
@ -64,17 +72,7 @@ public class FightWorld extends StateDependent {
|
|||||||
|
|
||||||
World backup = new WorldCreator(world.getName() + "/backup").createWorld();
|
World backup = new WorldCreator(world.getName() + "/backup").createWorld();
|
||||||
assert backup != null;
|
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);
|
Bukkit.unloadWorld(backup, false);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
private 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));
|
|
||||||
}
|
|
||||||
}
|
|
91
FightSystem_Core/src/de/steamwar/fightsystem/fight/FreezeWorld.java
Normale Datei
91
FightSystem_Core/src/de/steamwar/fightsystem/fight/FreezeWorld.java
Normale Datei
@ -0,0 +1,91 @@
|
|||||||
|
/*
|
||||||
|
This file is a part of the SteamWar software.
|
||||||
|
|
||||||
|
Copyright (C) 2020 SteamWar.de-Serverteam
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.steamwar.fightsystem.fight;
|
||||||
|
|
||||||
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
|
import de.steamwar.fightsystem.utils.BountifulWrapper;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.block.*;
|
||||||
|
import org.bukkit.event.inventory.InventoryMoveItemEvent;
|
||||||
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
|
|
||||||
|
public class FreezeWorld implements Listener {
|
||||||
|
|
||||||
|
private final Listener denyHandSwap = BountifulWrapper.impl.newDenyHandSwapListener();
|
||||||
|
|
||||||
|
public FreezeWorld(){
|
||||||
|
Bukkit.getPluginManager().registerEvents(this, FightSystem.getPlugin());
|
||||||
|
Bukkit.getPluginManager().registerEvents(denyHandSwap, FightSystem.getPlugin());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void disable(){
|
||||||
|
HandlerList.unregisterAll(this);
|
||||||
|
HandlerList.unregisterAll(denyHandSwap);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onBlockPhysicsEvent(BlockPhysicsEvent e){
|
||||||
|
e.setCancelled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPistonExtend(BlockPistonExtendEvent e){
|
||||||
|
e.setCancelled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPistonRetract(BlockPistonRetractEvent e){
|
||||||
|
e.setCancelled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onBlockGrow(BlockGrowEvent e){
|
||||||
|
e.setCancelled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onRedstoneEvent(BlockRedstoneEvent e){
|
||||||
|
e.setNewCurrent(e.getOldCurrent());
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onBlockDispense(BlockDispenseEvent e){
|
||||||
|
e.setCancelled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onInventoryMoveEvent(InventoryMoveItemEvent e){
|
||||||
|
e.setCancelled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onBlockExplosion(BlockExplodeEvent e){
|
||||||
|
e.setCancelled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.LOW)
|
||||||
|
public void handlePlayerInteract(PlayerInteractEvent event) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
@ -19,13 +19,13 @@
|
|||||||
|
|
||||||
package de.steamwar.fightsystem.fight;
|
package de.steamwar.fightsystem.fight;
|
||||||
|
|
||||||
import de.steamwar.core.Core;
|
|
||||||
import de.steamwar.core.VersionedCallable;
|
|
||||||
import de.steamwar.fightsystem.Config;
|
import de.steamwar.fightsystem.Config;
|
||||||
import de.steamwar.fightsystem.FightSystem;
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
import de.steamwar.fightsystem.commands.Commands;
|
import de.steamwar.fightsystem.commands.Commands;
|
||||||
import de.steamwar.fightsystem.commands.GUI;
|
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.SWInventory;
|
||||||
import de.steamwar.inventory.SWItem;
|
import de.steamwar.inventory.SWItem;
|
||||||
import de.steamwar.sql.PersonalKit;
|
import de.steamwar.sql.PersonalKit;
|
||||||
@ -38,7 +38,6 @@ import org.bukkit.configuration.file.YamlConfiguration;
|
|||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.BlockDataMeta;
|
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
import org.bukkit.potion.PotionEffect;
|
import org.bukkit.potion.PotionEffect;
|
||||||
|
|
||||||
@ -188,21 +187,16 @@ public class Kit {
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
//Check for attribute modifiers
|
//Check for attribute modifiers
|
||||||
if(Core.getVersion() >= 14 && PersonalKitCreator_14.hasAttributeModifier(stack)){
|
if(FlatteningWrapper.impl.hasAttributeModifier(stack)){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(stack.hasItemMeta()){
|
if(stack.hasItemMeta()){
|
||||||
ItemMeta meta = stack.getItemMeta();
|
ItemMeta meta = stack.getItemMeta();
|
||||||
if(meta instanceof BlockDataMeta && ((BlockDataMeta)meta).hasBlockData())
|
if(FlatteningWrapper.impl.containsBlockMeta(meta))
|
||||||
return true; //Blocks always upwards slabs etc.
|
return true; //Blocks always upwards slabs etc.
|
||||||
|
|
||||||
if(VersionedCallable.call(new VersionedCallable<>(() -> PersonalKitCreator_8.hasItems(stack), 8),
|
if(CraftbukkitWrapper.impl.hasItems(stack))
|
||||||
new VersionedCallable<>(() -> PersonalKitCreator_9.hasItems(stack), 9),
|
|
||||||
new VersionedCallable<>(() -> PersonalKitCreator_10.hasItems(stack), 10),
|
|
||||||
new VersionedCallable<>(() -> PersonalKitCreator_12.hasItems(stack), 12),
|
|
||||||
new VersionedCallable<>(() -> PersonalKitCreator_14.hasItems(stack), 14),
|
|
||||||
new VersionedCallable<>(() -> PersonalKitCreator_15.hasItems(stack), 15)))
|
|
||||||
return true; //Blocks prefilled inventories
|
return true; //Blocks prefilled inventories
|
||||||
}
|
}
|
||||||
|
|
@ -19,16 +19,14 @@
|
|||||||
|
|
||||||
package de.steamwar.fightsystem.listener;
|
package de.steamwar.fightsystem.listener;
|
||||||
|
|
||||||
import de.steamwar.core.Core;
|
|
||||||
import de.steamwar.fightsystem.ArenaMode;
|
import de.steamwar.fightsystem.ArenaMode;
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||||
|
import de.steamwar.fightsystem.utils.BountifulWrapper;
|
||||||
|
|
||||||
public class ArrowPickup {
|
public class ArrowPickup {
|
||||||
|
|
||||||
public ArrowPickup() {
|
public ArrowPickup() {
|
||||||
if(Core.getVersion() > 8){
|
new StateDependentListener(ArenaMode.All, FightState.All, BountifulWrapper.impl.newDenyArrowPickupListener());
|
||||||
new StateDependentListener(ArenaMode.All, FightState.All, new PickupArrowListener_9());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
This file is a part of the SteamWar software.
|
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
|
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
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
@ -15,13 +15,14 @@
|
|||||||
|
|
||||||
You should have received a copy of the GNU Affero General Public License
|
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/>.
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.steamwar.fightsystem.listener;
|
package de.steamwar.fightsystem.listener;
|
||||||
|
|
||||||
import de.steamwar.fightsystem.Config;
|
import de.steamwar.fightsystem.Config;
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.states.StateDependentTask;
|
import de.steamwar.fightsystem.states.StateDependentTask;
|
||||||
|
import de.steamwar.fightsystem.utils.WorldOfColorWrapper;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
@ -90,7 +91,11 @@ public class ArrowStopper {
|
|||||||
boolean overMid = entity.getLocation().getZ() > Config.SpecSpawn.getZ();
|
boolean overMid = entity.getLocation().getZ() > Config.SpecSpawn.getZ();
|
||||||
boolean otherSide = teamFrom == overMid;
|
boolean otherSide = teamFrom == overMid;
|
||||||
return otherSide ||
|
return otherSide ||
|
||||||
entity.isInBlock() ||
|
WorldOfColorWrapper.impl.isInBlock(entity) ||
|
||||||
entity.getVelocity().equals(NULL_VECTOR);
|
entity.getVelocity().equals(NULL_VECTOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public interface IArrowStopper {
|
||||||
|
boolean isInBlock(Arrow e);
|
||||||
|
}
|
||||||
}
|
}
|
@ -19,17 +19,19 @@
|
|||||||
|
|
||||||
package de.steamwar.fightsystem.listener;
|
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 net.md_5.bungee.api.chat.BaseComponent;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
class BasicListener_8 {
|
public class BasicListener {
|
||||||
private BasicListener_8(){}
|
private BasicListener(){}
|
||||||
|
|
||||||
static void toActionbar(Player player, BaseComponent... components){
|
public static boolean notFighting(Player p){
|
||||||
player.spigot().sendMessage(components);
|
return Fight.getFightPlayer(p) == null;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void toChat(Player player, BaseComponent... components){
|
public static void toActionbar(Player player, BaseComponent... components){
|
||||||
player.spigot().sendMessage(components);
|
BountifulWrapper.impl.toActionbar(player, components);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -24,9 +24,10 @@ import de.steamwar.fightsystem.Config;
|
|||||||
import de.steamwar.fightsystem.FightSystem;
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
import de.steamwar.fightsystem.fight.Fight;
|
import de.steamwar.fightsystem.fight.Fight;
|
||||||
import de.steamwar.fightsystem.fight.FightTeam;
|
import de.steamwar.fightsystem.fight.FightTeam;
|
||||||
import de.steamwar.fightsystem.record.RecordSystem;
|
import de.steamwar.fightsystem.record.GlobalRecorder;
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||||
|
import de.steamwar.fightsystem.utils.BountifulWrapper;
|
||||||
import net.md_5.bungee.api.chat.BaseComponent;
|
import net.md_5.bungee.api.chat.BaseComponent;
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -64,9 +65,9 @@ public class Chat implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void broadcastChat(String message) {
|
private void broadcastChat(String message) {
|
||||||
RecordSystem.chat(message);
|
GlobalRecorder.getInstance().chat(message);
|
||||||
BaseComponent[] msg = TextComponent.fromLegacyText(message);
|
BaseComponent[] msg = TextComponent.fromLegacyText(message);
|
||||||
for(Player p : Bukkit.getOnlinePlayers())
|
for(Player p : Bukkit.getOnlinePlayers())
|
||||||
BasicListener.toChat(p, msg);
|
BountifulWrapper.impl.toChat(p, msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -19,10 +19,10 @@
|
|||||||
|
|
||||||
package de.steamwar.fightsystem.listener;
|
package de.steamwar.fightsystem.listener;
|
||||||
|
|
||||||
import de.steamwar.core.Core;
|
|
||||||
import de.steamwar.fightsystem.ArenaMode;
|
import de.steamwar.fightsystem.ArenaMode;
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||||
|
import de.steamwar.fightsystem.utils.BountifulWrapper;
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
@ -40,11 +40,10 @@ public class DenyWorldInteraction implements Listener {
|
|||||||
public DenyWorldInteraction() {
|
public DenyWorldInteraction() {
|
||||||
new StateDependentListener(ArenaMode.Test, FightState.PreRunning, this);
|
new StateDependentListener(ArenaMode.Test, FightState.PreRunning, this);
|
||||||
new StateDependentListener(ArenaMode.AntiTest, FightState.AntiRunning, this);
|
new StateDependentListener(ArenaMode.AntiTest, FightState.AntiRunning, this);
|
||||||
if(Core.getVersion() > 9){
|
|
||||||
Listener listener = new DenyWorldInteraction_10();
|
Listener listener = BountifulWrapper.impl.newDenyHandSwapListener();
|
||||||
new StateDependentListener(ArenaMode.Test, FightState.PreRunning, listener);
|
new StateDependentListener(ArenaMode.Test, FightState.PreRunning, listener);
|
||||||
new StateDependentListener(ArenaMode.AntiTest, FightState.AntiRunning, listener);
|
new StateDependentListener(ArenaMode.AntiTest, FightState.AntiRunning, listener);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
@ -42,7 +42,7 @@ public class EventJoin implements Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void playerLogin(PlayerLoginEvent event) {
|
public void playerLogin(PlayerLoginEvent event) {
|
||||||
if(!Config.SpectateSystem)
|
if(!Config.LiveReplay)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
@ -89,7 +89,7 @@ public class EventJoin implements Listener {
|
|||||||
FightSystem.setEventLeiter(player);
|
FightSystem.setEventLeiter(player);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(Config.SpectateSystem)
|
if(Config.LiveReplay)
|
||||||
player.kickPlayer("§cDu bist kein Kampfteilnehmer");
|
player.kickPlayer("§cDu bist kein Kampfteilnehmer");
|
||||||
}
|
}
|
||||||
|
|
Einige Dateien werden nicht angezeigt, da zu viele Dateien in diesem Diff geändert wurden Mehr anzeigen
In neuem Issue referenzieren
Einen Benutzer sperren