forked from SteamWar/SteamWar
Unwrap the wrappers
This commit is contained in:
@@ -41,6 +41,9 @@ import de.steamwar.sql.SchematicNode;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameRule;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerPickupArrowEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class FightSystem extends JavaPlugin {
|
||||
@@ -95,7 +98,12 @@ public class FightSystem extends JavaPlugin {
|
||||
getMessage().broadcast("PISTON_PUSHED_OUTSIDE");
|
||||
shutdown();
|
||||
});
|
||||
new StateDependentListener(ArenaMode.All, FightState.All, BountifulWrapper.impl.newDenyArrowPickupListener());
|
||||
new StateDependentListener(ArenaMode.All, FightState.All, new Listener() {
|
||||
@EventHandler
|
||||
public void onArrowPickup(PlayerPickupArrowEvent e) {
|
||||
if (Fight.fighting(e.getPlayer())) e.setCancelled(true);
|
||||
}
|
||||
});
|
||||
new OneShotStateDependent(ArenaMode.All, FightState.PreSchemSetup, () -> Fight.playSound(SWSound.BLOCK_NOTE_PLING.getSound(), 100.0f, 2.0f));
|
||||
new OneShotStateDependent(ArenaMode.Test, FightState.All, WorldEditRendererCUIEditor::new);
|
||||
Config.world.setGameRule(GameRule.REDUCED_DEBUG_INFO, ArenaMode.AntiTest.contains(Config.mode));
|
||||
@@ -120,7 +128,7 @@ public class FightSystem extends JavaPlugin {
|
||||
Fight.getUnrotated().setSchem(SchematicNode.getSchematicNode(Config.PrepareSchemID));
|
||||
}
|
||||
|
||||
CraftbukkitWrapper.impl.setupGamerule();
|
||||
Config.world.setGameRule(GameRule.LOCATOR_BAR, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+2
-1
@@ -23,6 +23,7 @@ import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentCommand;
|
||||
import de.steamwar.fightsystem.utils.TpsWarper;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -46,7 +47,7 @@ public class TPSWarpCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
TpsWarper warper = TpsWarper.impl;
|
||||
warper.warp(tps);
|
||||
MinecraftServer.getServer().tickRateManager().setTickRate(tps);
|
||||
|
||||
FightSystem.getMessage().broadcastActionbar("TPSWARP_SET", tps);
|
||||
return false;
|
||||
|
||||
@@ -44,6 +44,8 @@ import de.steamwar.sql.SteamwarUser;
|
||||
import lombok.Getter;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.attribute.Attribute;
|
||||
import org.bukkit.attribute.AttributeInstance;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scoreboard.NameTagVisibility;
|
||||
@@ -151,8 +153,8 @@ public class FightTeam {
|
||||
new TeamArea(this);
|
||||
|
||||
team = FightScoreboard.getBukkitTeam(name);
|
||||
WorldOfColorWrapper.impl.setTeamColor(team, color);
|
||||
BountifulWrapper.impl.setNametagVisibility(team);
|
||||
team.setColor(color);
|
||||
team.setOption(Team.Option.NAME_TAG_VISIBILITY, Team.OptionStatus.FOR_OWN_TEAM);
|
||||
team.setNameTagVisibility(NameTagVisibility.HIDE_FOR_OTHER_TEAMS);
|
||||
if (!Config.GameModeConfig.WinConditions.contains(Winconditions.AMONG_US)) {
|
||||
team.setAllowFriendlyFire(false);
|
||||
@@ -284,7 +286,8 @@ public class FightTeam {
|
||||
entity.teleport(spawn);
|
||||
|
||||
fightPlayer.ifPlayer(player -> {
|
||||
BountifulWrapper.impl.setAttackSpeed(player);
|
||||
AttributeInstance attribute = player.getAttribute(Attribute.ATTACK_SPEED);
|
||||
attribute.setBaseValue(16);
|
||||
player.setFoodLevel(20);
|
||||
player.getInventory().clear();
|
||||
FightSystem.getHullHider().updatePlayer(player);
|
||||
|
||||
@@ -26,7 +26,6 @@ import de.steamwar.fightsystem.listener.Recording;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependent;
|
||||
import de.steamwar.fightsystem.utils.CraftbukkitWrapper;
|
||||
import de.steamwar.fightsystem.utils.FlatteningWrapper;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -64,7 +63,7 @@ public class FightWorld extends StateDependent {
|
||||
public static void forceLoad() {
|
||||
Config.ArenaRegion.forEachChunk((cX, cZ) -> {
|
||||
Config.world.loadChunk(cX, cZ);
|
||||
FlatteningWrapper.impl.forceLoadChunk(Config.world, cX, cZ);
|
||||
Config.world.setChunkForceLoaded(cX, cZ, true);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
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;
|
||||
@@ -30,19 +29,16 @@ import org.bukkit.event.block.*;
|
||||
import org.bukkit.event.entity.ItemSpawnEvent;
|
||||
import org.bukkit.event.inventory.InventoryMoveItemEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerSwapHandItemsEvent;
|
||||
|
||||
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
|
||||
@@ -94,4 +90,9 @@ public class FreezeWorld implements Listener {
|
||||
public void handlePlayerInteract(PlayerInteractEvent event) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onSwapItems(PlayerSwapHandItemsEvent event) {
|
||||
if (Fight.fighting(event.getPlayer())) event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,12 +24,13 @@ import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.commands.Commands;
|
||||
import de.steamwar.fightsystem.commands.GUI;
|
||||
import de.steamwar.fightsystem.listener.PersonalKitCreator;
|
||||
import de.steamwar.fightsystem.utils.FlatteningWrapper;
|
||||
import de.steamwar.fightsystem.utils.ReflectionWrapper;
|
||||
import de.steamwar.inventory.SWInventory;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import de.steamwar.sql.PersonalKit;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import io.papermc.paper.datacomponent.DataComponentType;
|
||||
import io.papermc.paper.datacomponent.DataComponentTypes;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
@@ -39,6 +40,7 @@ import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.BlockDataMeta;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
|
||||
@@ -193,13 +195,13 @@ public class Kit {
|
||||
if (Config.GameModeConfig.Kits.ForbiddenItems.contains(stack.getType())) return true;
|
||||
|
||||
//Check for attribute modifiers
|
||||
if (FlatteningWrapper.impl.hasAttributeModifier(stack)) {
|
||||
if (stack.hasItemMeta() && stack.getItemMeta() != null && stack.getItemMeta().hasAttributeModifiers()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (stack.hasItemMeta()) {
|
||||
ItemMeta meta = stack.getItemMeta();
|
||||
if (FlatteningWrapper.impl.containsBlockMeta(meta)) return true; //Blocks always upwards slabs etc.
|
||||
if (meta instanceof BlockDataMeta && ((BlockDataMeta) meta).hasBlockData()) return true; //Blocks always upwards slabs etc.
|
||||
if (hasItems(stack)) return true; //Blocks prefilled inventories
|
||||
}
|
||||
|
||||
@@ -208,8 +210,42 @@ public class Kit {
|
||||
return !normal.isEnchantmentInKit(stack) && !stack.getEnchantments().isEmpty();
|
||||
}
|
||||
|
||||
private static final Set<DataComponentType> FORBIDDEN_TYPES = new HashSet<>();
|
||||
|
||||
static {
|
||||
FORBIDDEN_TYPES.add(DataComponentTypes.CUSTOM_NAME);
|
||||
FORBIDDEN_TYPES.add(DataComponentTypes.PROFILE);
|
||||
FORBIDDEN_TYPES.add(DataComponentTypes.UNBREAKABLE);
|
||||
FORBIDDEN_TYPES.add(DataComponentTypes.BLOCK_DATA);
|
||||
FORBIDDEN_TYPES.add(DataComponentTypes.BLOCKS_ATTACKS);
|
||||
FORBIDDEN_TYPES.add(DataComponentTypes.BUNDLE_CONTENTS);
|
||||
FORBIDDEN_TYPES.add(DataComponentTypes.CUSTOM_MODEL_DATA);
|
||||
|
||||
FORBIDDEN_TYPES.add(DataComponentTypes.ATTRIBUTE_MODIFIERS);
|
||||
FORBIDDEN_TYPES.add(DataComponentTypes.TOOL);
|
||||
FORBIDDEN_TYPES.add(DataComponentTypes.WEAPON);
|
||||
FORBIDDEN_TYPES.add(DataComponentTypes.FOOD);
|
||||
FORBIDDEN_TYPES.add(DataComponentTypes.CONSUMABLE);
|
||||
FORBIDDEN_TYPES.add(DataComponentTypes.POTION_CONTENTS);
|
||||
FORBIDDEN_TYPES.add(DataComponentTypes.STORED_ENCHANTMENTS);
|
||||
FORBIDDEN_TYPES.add(DataComponentTypes.CAN_BREAK);
|
||||
FORBIDDEN_TYPES.add(DataComponentTypes.CAN_PLACE_ON);
|
||||
FORBIDDEN_TYPES.add(DataComponentTypes.MAX_DAMAGE);
|
||||
FORBIDDEN_TYPES.add(DataComponentTypes.USE_REMAINDER);
|
||||
FORBIDDEN_TYPES.add(DataComponentTypes.USE_COOLDOWN);
|
||||
FORBIDDEN_TYPES.add(DataComponentTypes.SUSPICIOUS_STEW_EFFECTS);
|
||||
FORBIDDEN_TYPES.add(DataComponentTypes.CHARGED_PROJECTILES);
|
||||
FORBIDDEN_TYPES.add(DataComponentTypes.INTANGIBLE_PROJECTILE);
|
||||
FORBIDDEN_TYPES.add(DataComponentTypes.FIREWORKS);
|
||||
FORBIDDEN_TYPES.add(DataComponentTypes.FIREWORK_EXPLOSION);
|
||||
FORBIDDEN_TYPES.add(DataComponentTypes.EQUIPPABLE);
|
||||
FORBIDDEN_TYPES.add(DataComponentTypes.REPAIR_COST);
|
||||
FORBIDDEN_TYPES.add(DataComponentTypes.ENCHANTABLE);
|
||||
}
|
||||
|
||||
public static boolean hasItems(ItemStack stack) {
|
||||
return ReflectionWrapper.impl.hasItems(stack);
|
||||
FORBIDDEN_TYPES.forEach(stack::resetData);
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isEnchantmentInKit(ItemStack stack) {
|
||||
|
||||
@@ -22,12 +22,12 @@ package de.steamwar.fightsystem.listener;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentTask;
|
||||
import de.steamwar.fightsystem.utils.WorldOfColorWrapper;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import net.minecraft.world.entity.projectile.AbstractArrow;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Projectile;
|
||||
import org.bukkit.projectiles.ProjectileSource;
|
||||
@@ -93,8 +93,12 @@ public class ArrowStopper {
|
||||
boolean teamFrom = entity.getVelocity().getZ() > 0;
|
||||
boolean overMid = location.getZ() > Config.SpecSpawn.getZ();
|
||||
boolean otherSide = teamFrom == overMid;
|
||||
return otherSide || !Config.ArenaRegion.inRegion(location) ||
|
||||
WorldOfColorWrapper.impl.isInBlock(entity) ||
|
||||
if (otherSide || !Config.ArenaRegion.inRegion(location)) return true;
|
||||
boolean result = false;
|
||||
if (entity instanceof Arrow arrow) {
|
||||
result = arrow.isInBlock();
|
||||
}
|
||||
return result ||
|
||||
entity.getVelocity().equals(NULL_VECTOR);
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -22,11 +22,11 @@ package de.steamwar.fightsystem.listener;
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||
import de.steamwar.fightsystem.utils.FlatteningWrapper;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Pose;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
@@ -46,7 +46,7 @@ public class BlockPlaceCollision implements Listener {
|
||||
// Hitbox size: 0.6xz, 1.8y, 1.5y when sneaking
|
||||
Player player = event.getPlayer();
|
||||
Location min = player.getLocation().add(-0.3, 0, -0.3);
|
||||
Location max = player.getLocation().add(0.3, FlatteningWrapper.impl.isCrouching(player) ? 0.6 : (player.isSneaking() ? 1.5 : 1.8), 0.3);
|
||||
Location max = player.getLocation().add(0.3, player.getPose() == Pose.SWIMMING ? 0.6 : (player.isSneaking() ? 1.5 : 1.8), 0.3);
|
||||
|
||||
Location blockmin = block.getLocation();
|
||||
Location blockmax = block.getLocation().add(1.0, 1.0, 1.0);
|
||||
|
||||
@@ -24,7 +24,6 @@ import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentTask;
|
||||
import de.steamwar.fightsystem.utils.FlatteningWrapper;
|
||||
import de.steamwar.fightsystem.utils.Region;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -141,7 +140,7 @@ public class Border {
|
||||
|
||||
private void sendChange(Player player, Block block, Material type) {
|
||||
if (block.getType() == Material.AIR) {
|
||||
FlatteningWrapper.impl.sendBlockChange(player, block, type);
|
||||
player.sendBlockChange(block.getLocation(), type.createBlockData());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+7
-4
@@ -20,24 +20,22 @@
|
||||
package de.steamwar.fightsystem.listener;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||
import de.steamwar.fightsystem.utils.BountifulWrapper;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryDragEvent;
|
||||
import org.bukkit.event.player.PlayerPickupItemEvent;
|
||||
import org.bukkit.event.player.PlayerSwapHandItemsEvent;
|
||||
|
||||
@Linked
|
||||
public class DenyInventoryMovement implements Listener {
|
||||
|
||||
public DenyInventoryMovement() {
|
||||
new StateDependentListener(ArenaMode.AntiTest, FightState.AntiIngame, this);
|
||||
|
||||
Listener listener = BountifulWrapper.impl.newDenyHandSwapListener();
|
||||
new StateDependentListener(ArenaMode.AntiTest, FightState.AntiIngame, listener);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@@ -54,4 +52,9 @@ public class DenyInventoryMovement implements Listener {
|
||||
public void onItemPickup(PlayerPickupItemEvent event) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onSwapItems(PlayerSwapHandItemsEvent event) {
|
||||
if (Fight.fighting(event.getPlayer())) event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,13 +27,12 @@ import de.steamwar.fightsystem.fight.FightPlayer;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||
import de.steamwar.fightsystem.utils.BountifulWrapper;
|
||||
import de.steamwar.fightsystem.utils.FlatteningWrapper;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.data.type.Dispenser;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@@ -62,7 +61,7 @@ public class Permanent implements Listener {
|
||||
private static final Team spectatorTeam = FightScoreboard.getBukkitTeam("Spectator");
|
||||
|
||||
static {
|
||||
BountifulWrapper.impl.setNametagVisibility(spectatorTeam);
|
||||
spectatorTeam.setOption(Team.Option.NAME_TAG_VISIBILITY, Team.OptionStatus.FOR_OWN_TEAM);
|
||||
spectatorTeam.setNameTagVisibility(NameTagVisibility.NEVER);
|
||||
}
|
||||
|
||||
@@ -234,7 +233,7 @@ public class Permanent implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.getItem().getType() == Material.TNT || FlatteningWrapper.impl.isFacingWater(block)) {
|
||||
if (e.getItem().getType() == Material.TNT || block.getRelative(((Dispenser) block.getBlockData()).getFacing()).isLiquid()) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,12 +28,12 @@ import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.OneShotStateDependent;
|
||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||
import de.steamwar.fightsystem.utils.FlatteningWrapper;
|
||||
import de.steamwar.fightsystem.utils.Region;
|
||||
import de.steamwar.fightsystem.utils.WorldeditWrapper;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.sql.SchematicNode;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
@@ -52,7 +52,7 @@ public class PrepareSchem implements Listener {
|
||||
new OneShotStateDependent(ArenaMode.Prepare, FightState.PostSchemSetup, () -> Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> {
|
||||
stationaryMovingPistons.clear();
|
||||
Fight.getUnrotated().getSchemRegion().forEach((x, y, z) -> {
|
||||
if (FlatteningWrapper.impl.checkPistonMoving(Config.world.getBlockAt(x, y, z))) {
|
||||
if (Config.world.getBlockAt(x, y, z).getType() == Material.MOVING_PISTON) {
|
||||
stationaryMovingPistons.add(new Vector(x, y, z));
|
||||
}
|
||||
});
|
||||
@@ -76,7 +76,7 @@ public class PrepareSchem implements Listener {
|
||||
|
||||
try {
|
||||
region.forEach((x, y, z) -> {
|
||||
if (FlatteningWrapper.impl.checkPistonMoving(Config.world.getBlockAt(x, y, z)) && !stationaryMovingPistons.contains(new Vector(x, y, z))) {
|
||||
if (Config.world.getBlockAt(x, y, z).getType() == Material.MOVING_PISTON && !stationaryMovingPistons.contains(new Vector(x, y, z))) {
|
||||
FightSystem.getMessage().broadcast("PREPARE_ACTIVE_PISTON");
|
||||
Bukkit.shutdown();
|
||||
throw new IllegalStateException();
|
||||
|
||||
@@ -22,6 +22,7 @@ package de.steamwar.fightsystem.listener;
|
||||
import com.comphenix.tinyprotocol.TinyProtocol;
|
||||
import de.steamwar.Reflection;
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.events.TeamDeathEvent;
|
||||
import de.steamwar.fightsystem.events.TeamLeaveEvent;
|
||||
@@ -34,17 +35,16 @@ import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependent;
|
||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||
import de.steamwar.fightsystem.states.StateDependentTask;
|
||||
import de.steamwar.fightsystem.utils.BountifulWrapper;
|
||||
import de.steamwar.fightsystem.utils.CraftbukkitWrapper;
|
||||
import de.steamwar.fightsystem.utils.FlatteningWrapper;
|
||||
import de.steamwar.fightsystem.utils.SWSound;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import net.minecraft.network.protocol.game.ServerboundPlayerActionPacket;
|
||||
import net.minecraft.network.protocol.game.ServerboundUseItemPacket;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.entity.item.PrimedTnt;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
@@ -63,6 +63,7 @@ import java.util.Random;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.StreamSupport;
|
||||
|
||||
@Linked
|
||||
public class Recording implements Listener {
|
||||
@@ -83,12 +84,22 @@ public class Recording implements Listener {
|
||||
public static final Class<?> primedTnt = PrimedTnt.class;
|
||||
|
||||
public static void iterateOverEntities(Predicate<Object> filter, Consumer<Entity> consumer) {
|
||||
CraftbukkitWrapper.impl.entityIterator().filter(filter).map(net.minecraft.world.entity.Entity::getBukkitEntity).forEach(consumer);
|
||||
StreamSupport.stream(((CraftWorld) Config.world).getHandle().getEntities().getAll().spliterator(), false).filter(filter).map(net.minecraft.world.entity.Entity::getBukkitEntity).forEach(consumer);
|
||||
}
|
||||
|
||||
public Recording() {
|
||||
new StateDependentListener(ArenaMode.AntiReplay, FightState.All, this);
|
||||
new StateDependentListener(ArenaMode.AntiReplay, FightState.All, BountifulWrapper.impl.newHandSwapRecorder());
|
||||
new StateDependentListener(ArenaMode.AntiReplay, FightState.All, new Listener() {
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onItemSwap(PlayerSwapHandItemsEvent e) {
|
||||
if (isNotSent(e.getPlayer()))
|
||||
return;
|
||||
|
||||
Player player = e.getPlayer();
|
||||
GlobalRecorder.getInstance().item(player, disarmNull(e.getMainHandItem()), "MAINHAND");
|
||||
GlobalRecorder.getInstance().item(player, disarmNull(e.getOffHandItem()), "OFFHAND");
|
||||
}
|
||||
});
|
||||
new StateDependent(ArenaMode.AntiReplay, FightState.Ingame) {
|
||||
@Override
|
||||
public void enable() {
|
||||
@@ -102,12 +113,12 @@ public class Recording implements Listener {
|
||||
}
|
||||
}.register();
|
||||
new StateDependent(ArenaMode.AntiReplay, FightState.Ingame) {
|
||||
private final BiFunction<Player, Object, Object> place = Recording.this::blockPlace;
|
||||
private final BiFunction<Player, ServerboundUseItemPacket, Object> place = Recording.this::blockPlace;
|
||||
private final BiFunction<Player, Object, Object> dig = Recording.this::blockDig;
|
||||
|
||||
@Override
|
||||
public void enable() {
|
||||
TinyProtocol.instance.addFilter(blockPlacePacket, place);
|
||||
TinyProtocol.instance.addTypedFilter(ServerboundUseItemPacket.class, place);
|
||||
TinyProtocol.instance.addFilter(blockDigPacket, dig);
|
||||
}
|
||||
|
||||
@@ -145,9 +156,9 @@ public class Recording implements Listener {
|
||||
|
||||
public static final Class<?> blockPlacePacket = ServerboundUseItemPacket.class;
|
||||
|
||||
private Object blockPlace(Player p, Object packet) {
|
||||
boolean mainHand = BountifulWrapper.impl.mainHand(packet);
|
||||
if (!isNotSent(p) && BountifulWrapper.impl.bowInHand(mainHand, p)) {
|
||||
private Object blockPlace(Player p, ServerboundUseItemPacket packet) {
|
||||
boolean mainHand = packet.getHand() == InteractionHand.MAIN_HAND;
|
||||
if (!isNotSent(p) && (mainHand ? p.getInventory().getItemInMainHand() : p.getInventory().getItemInOffHand()).getType() == Material.BOW) {
|
||||
GlobalRecorder.getInstance().bowSpan(p, true, !mainHand);
|
||||
}
|
||||
return packet;
|
||||
@@ -177,7 +188,7 @@ public class Recording implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onBlockPhysics(BlockPhysicsEvent e) {
|
||||
if (FlatteningWrapper.impl.doRecord(e)) {
|
||||
if (e.getBlock() == e.getSourceBlock() || e.getChangedType() == Material.AIR) {
|
||||
GlobalRecorder.getInstance().blockChange(e.getBlock());
|
||||
}
|
||||
}
|
||||
@@ -285,7 +296,8 @@ public class Recording implements Listener {
|
||||
if (!fp.isLiving()) continue;
|
||||
|
||||
fp.ifPlayer(player -> {
|
||||
BountifulWrapper.impl.recordHandItems(player);
|
||||
GlobalRecorder.getInstance().item(player, disarmNull(player.getInventory().getItemInMainHand()), "MAINHAND");
|
||||
GlobalRecorder.getInstance().item(player, disarmNull(player.getInventory().getItemInOffHand()), "OFFHAND");
|
||||
GlobalRecorder.getInstance().item(player, disarmNull(player.getInventory().getHelmet()), "HEAD");
|
||||
GlobalRecorder.getInstance().item(player, disarmNull(player.getInventory().getChestplate()), "CHEST");
|
||||
GlobalRecorder.getInstance().item(player, disarmNull(player.getInventory().getLeggings()), "LEGS");
|
||||
|
||||
+22
-2
@@ -25,11 +25,13 @@ import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||
import de.steamwar.fightsystem.utils.FlatteningWrapper;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.block.data.Waterlogged;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
@@ -101,7 +103,25 @@ public class WaterRemover implements Listener {
|
||||
if (!Config.BlueExtendRegion.inRegion(b) && !Config.RedExtendRegion.inRegion(b)) return;
|
||||
|
||||
//checks for water and removes it, if present
|
||||
if (!FlatteningWrapper.impl.removeWater(b)) return;
|
||||
boolean result = true;
|
||||
Material type = b.getType();
|
||||
if (type == Material.WATER || type == Material.LAVA) {
|
||||
b.setType(Material.AIR);
|
||||
} else {
|
||||
BlockData data = b.getBlockData();
|
||||
if (!(data instanceof Waterlogged)) {
|
||||
result = false;
|
||||
} else {
|
||||
Waterlogged waterlogged = (Waterlogged) data;
|
||||
if (waterlogged.isWaterlogged()) {
|
||||
b.setType(Material.AIR);
|
||||
} else {
|
||||
result = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!result) return;
|
||||
|
||||
if (b.getY() < MIN_Y) return;
|
||||
|
||||
|
||||
+23
-10
@@ -42,11 +42,14 @@ import de.steamwar.techhider.BlockIds;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.entity.Pose;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -72,7 +75,7 @@ public class PacketProcessor implements Listener {
|
||||
private static final org.bukkit.scoreboard.Team team = FightScoreboard.getBukkitTeam("Replay");
|
||||
|
||||
static {
|
||||
BountifulWrapper.impl.setNametagVisibility(team);
|
||||
team.setOption(org.bukkit.scoreboard.Team.Option.NAME_TAG_VISIBILITY, org.bukkit.scoreboard.Team.OptionStatus.FOR_OWN_TEAM);
|
||||
team.setNameTagVisibility(NameTagVisibility.NEVER);
|
||||
}
|
||||
|
||||
@@ -460,8 +463,15 @@ public class PacketProcessor implements Listener {
|
||||
if (!Config.ArenaRegion.in2dRegion(x, z)) return; //Outside of the arena
|
||||
|
||||
execSync(() -> {
|
||||
BlockIdWrapper.impl.setBlock(Config.world, x, y, z, TechHiderWrapper.ENABLED && hiddenBlockIds.contains(blockState) ? obfuscateWith : blockState);
|
||||
FightSystem.getHullHider().blockUpdate(Config.world.getBlockAt(x, y, z), BlockIdWrapper.impl.idToMaterial(blockState));
|
||||
int blockState1 = TechHiderWrapper.ENABLED && hiddenBlockIds.contains(blockState) ? obfuscateWith : blockState;
|
||||
BlockState blockData = Block.stateById(blockState1);
|
||||
ServerLevel level = ((CraftWorld) Config.world).getHandle();
|
||||
BlockPos pos = new BlockPos(x, y, z);
|
||||
|
||||
level.removeBlockEntity(pos);
|
||||
level.setBlock(pos, blockData, blockState1);
|
||||
level.getChunkSource().blockChanged(pos);
|
||||
FightSystem.getHullHider().blockUpdate(Config.world.getBlockAt(x, y, z), CraftMagicNumbers.getMaterial(Block.stateById(blockState)).getItemType());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -478,7 +488,7 @@ public class PacketProcessor implements Listener {
|
||||
|
||||
double finalX = x;
|
||||
double finalZ = z;
|
||||
execSync(() -> BountifulWrapper.impl.spawnParticle(Config.world, particleName, finalX + Config.ArenaRegion.getMinX(), y + Config.BluePasteRegion.getMinY(), finalZ + Config.ArenaRegion.getMinZ()));
|
||||
execSync(() -> Config.world.spawnParticle(Particle.valueOf(particleName), finalX + Config.ArenaRegion.getMinX(), y + Config.BluePasteRegion.getMinY(), finalZ + Config.ArenaRegion.getMinZ(), 1));
|
||||
}
|
||||
|
||||
private void sound() throws IOException {
|
||||
@@ -502,7 +512,10 @@ public class PacketProcessor implements Listener {
|
||||
|
||||
Sound sound = Sound.valueOf(soundName);
|
||||
|
||||
execSync(() -> WorldOfColorWrapper.impl.playSound(new Location(Config.world, x, y, z), sound, soundCategory, volume, pitch));
|
||||
execSync(() -> {
|
||||
Location location = new Location(Config.world, x, y, z);
|
||||
location.getWorld().playSound(location, sound, SoundCategory.valueOf(soundCategory), volume, pitch);
|
||||
});
|
||||
}
|
||||
|
||||
private void soundAtPlayer() throws IOException {
|
||||
@@ -603,7 +616,7 @@ public class PacketProcessor implements Listener {
|
||||
|
||||
Bukkit.getOnlinePlayers().forEach(p -> {
|
||||
p.resetTitle();
|
||||
WorldOfColorWrapper.impl.sendTitle(p, title, subtitle, 5, 40, 5);
|
||||
p.sendTitle(title, subtitle, 5, 40, 5);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,6 @@ import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightPlayer;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.utils.BlockIdWrapper;
|
||||
import de.steamwar.fightsystem.utils.CraftbukkitWrapper;
|
||||
import de.steamwar.fightsystem.utils.Message;
|
||||
import de.steamwar.fightsystem.utils.SWSound;
|
||||
@@ -35,6 +34,7 @@ import de.steamwar.sql.SteamwarUser;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.craftbukkit.block.CraftBlockState;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -219,7 +219,7 @@ public interface Recorder {
|
||||
}
|
||||
|
||||
default void blockChange(Block block) {
|
||||
int blockState = BlockIdWrapper.impl.blockToId(block);
|
||||
int blockState = net.minecraft.world.level.block.Block.getId(((CraftBlockState) block.getState()).getHandle());
|
||||
|
||||
int shortX = block.getX() - Config.ArenaRegion.getMinX();
|
||||
int shortY = block.getY() - Config.BluePasteRegion.getMinY();
|
||||
|
||||
@@ -1,75 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2025 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.tinyprotocol.TinyProtocol;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import de.steamwar.core.ProtocolWrapper;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
import org.bukkit.craftbukkit.block.CraftBlockState;
|
||||
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class BlockIdWrapper {
|
||||
public static final BlockIdWrapper impl = new BlockIdWrapper();
|
||||
|
||||
public Material idToMaterial(int blockState) {
|
||||
return CraftMagicNumbers.getMaterial(net.minecraft.world.level.block.Block.stateById(blockState)).getItemType();
|
||||
}
|
||||
|
||||
public int blockToId(Block block) {
|
||||
return net.minecraft.world.level.block.Block.getId(((CraftBlockState) block.getState()).getHandle());
|
||||
}
|
||||
|
||||
public void setBlock(World world, int x, int y, int z, int blockState) {
|
||||
BlockState blockData = net.minecraft.world.level.block.Block.stateById(blockState);
|
||||
ServerLevel level = ((CraftWorld) world).getHandle();
|
||||
BlockPos pos = new BlockPos(x, y, z);
|
||||
|
||||
level.removeBlockEntity(pos);
|
||||
level.setBlock(pos, blockData, blockState);
|
||||
level.getChunkSource().blockChanged(pos);
|
||||
}
|
||||
|
||||
public void trackEntity(Player player, Entity entity) {
|
||||
if (entity instanceof Player) {
|
||||
TinyProtocol.instance.sendPacket(player, ProtocolWrapper.playerInfoPacketConstructor(ProtocolWrapper.PlayerInfoAction.REMOVE, new GameProfile(entity.getUniqueId(), entity.getName()), GameMode.CREATIVE));
|
||||
}
|
||||
|
||||
player.showEntity(FightSystem.getPlugin(), entity);
|
||||
}
|
||||
|
||||
public void untrackEntity(Player player, Entity entity) {
|
||||
player.hideEntity(FightSystem.getPlugin(), entity);
|
||||
|
||||
if (entity instanceof Player) {
|
||||
TinyProtocol.instance.sendPacket(player, ProtocolWrapper.playerInfoPacketConstructor(ProtocolWrapper.PlayerInfoAction.ADD, new GameProfile(entity.getUniqueId(), entity.getName()), GameMode.CREATIVE));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,158 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2025 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.Reflection;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.listener.Recording;
|
||||
import de.steamwar.fightsystem.record.GlobalRecorder;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.attribute.Attribute;
|
||||
import org.bukkit.attribute.AttributeInstance;
|
||||
import org.bukkit.boss.BarColor;
|
||||
import org.bukkit.boss.BarStyle;
|
||||
import org.bukkit.boss.BossBar;
|
||||
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;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class BountifulWrapper {
|
||||
public static final BountifulWrapper impl = new BountifulWrapper();
|
||||
|
||||
private static final Class<?> enumHand = InteractionHand.class;
|
||||
private static final Object mainHand = enumHand.getEnumConstants()[0];
|
||||
private static final Reflection.Field<?> blockPlaceHand = Reflection.getField(Recording.blockPlacePacket, enumHand, 0);
|
||||
|
||||
public boolean mainHand(Object packet) {
|
||||
return blockPlaceHand.get(packet) == mainHand;
|
||||
}
|
||||
|
||||
public boolean bowInHand(boolean mainHand, Player p) {
|
||||
return (mainHand ? p.getInventory().getItemInMainHand() : p.getInventory().getItemInOffHand()).getType() == Material.BOW;
|
||||
}
|
||||
|
||||
public void setAttackSpeed(Player player) {
|
||||
AttributeInstance attribute = player.getAttribute(Attribute.ATTACK_SPEED);
|
||||
attribute.setBaseValue(16);
|
||||
}
|
||||
|
||||
public void setNametagVisibility(Team team) {
|
||||
team.setOption(Team.Option.NAME_TAG_VISIBILITY, Team.OptionStatus.FOR_OWN_TEAM);
|
||||
}
|
||||
|
||||
public Listener newDenyArrowPickupListener() {
|
||||
return new Listener() {
|
||||
@EventHandler
|
||||
public void onArrowPickup(PlayerPickupArrowEvent e) {
|
||||
if (Fight.fighting(e.getPlayer())) e.setCancelled(true);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public Listener newDenyHandSwapListener() {
|
||||
return new Listener() {
|
||||
@EventHandler
|
||||
public void onSwapItems(PlayerSwapHandItemsEvent event) {
|
||||
if (Fight.fighting(event.getPlayer())) event.setCancelled(true);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
public Listener newHandSwapRecorder() {
|
||||
return new Listener() {
|
||||
@EventHandler(priority = EventPriority.HIGH, 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");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public void spawnParticle(World world, String particleName, double x, double y, double z) {
|
||||
world.spawnParticle(Particle.valueOf(particleName), x, y, z, 1);
|
||||
}
|
||||
|
||||
private final Map<Player, BossBar> barMap = new HashMap<>();
|
||||
|
||||
public void sendBar(Player player, FightTeam team, double progress, String text) {
|
||||
barMap.keySet().removeIf(p -> !p.isOnline());
|
||||
|
||||
if (!barMap.containsKey(player)) {
|
||||
BossBar bar = Bukkit.createBossBar(player.getName(), BarColor.WHITE, BarStyle.SOLID);
|
||||
barMap.put(player, bar);
|
||||
bar.addPlayer(player);
|
||||
}
|
||||
|
||||
BossBar bar = barMap.get(player);
|
||||
BarColor color = chat2bar(team.getColor());
|
||||
if (bar.getColor() != color) bar.setColor(color);
|
||||
|
||||
if (bar.getProgress() != progress) bar.setProgress(progress);
|
||||
|
||||
if (!bar.getTitle().equals(text)) bar.setTitle(text);
|
||||
}
|
||||
|
||||
private BarColor chat2bar(ChatColor color) {
|
||||
switch (color) {
|
||||
case DARK_BLUE:
|
||||
case DARK_AQUA:
|
||||
case BLUE:
|
||||
case AQUA:
|
||||
return BarColor.BLUE;
|
||||
case GREEN:
|
||||
case DARK_GREEN:
|
||||
return BarColor.GREEN;
|
||||
case DARK_RED:
|
||||
case RED:
|
||||
return BarColor.RED;
|
||||
case DARK_PURPLE:
|
||||
return BarColor.PURPLE;
|
||||
case GOLD:
|
||||
case YELLOW:
|
||||
return BarColor.YELLOW;
|
||||
case LIGHT_PURPLE:
|
||||
return BarColor.PINK;
|
||||
case BLACK:
|
||||
case WHITE:
|
||||
case GRAY:
|
||||
case DARK_GRAY:
|
||||
default:
|
||||
return BarColor.WHITE;
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-17
@@ -19,11 +19,9 @@
|
||||
|
||||
package de.steamwar.fightsystem.utils;
|
||||
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.chunk.LevelChunk;
|
||||
import net.minecraft.world.level.chunk.LevelChunkSection;
|
||||
import org.bukkit.GameRule;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
import org.bukkit.craftbukkit.entity.CraftEntity;
|
||||
@@ -31,26 +29,12 @@ import org.bukkit.entity.Entity;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Stream;
|
||||
import java.util.stream.StreamSupport;
|
||||
|
||||
public class CraftbukkitWrapper {
|
||||
public static final CraftbukkitWrapper impl = new CraftbukkitWrapper();
|
||||
|
||||
protected net.minecraft.world.entity.Entity getEntity(Entity e) {
|
||||
return ((CraftEntity) e).getHandle();
|
||||
}
|
||||
|
||||
public float headRotation(Entity e) {
|
||||
return getEntity(e).getYHeadRot();
|
||||
}
|
||||
|
||||
public Stream<net.minecraft.world.entity.Entity> entityIterator() {
|
||||
return StreamSupport.stream(((CraftWorld) Config.world).getHandle().getEntities().getAll().spliterator(), false);
|
||||
}
|
||||
|
||||
public void setupGamerule() {
|
||||
Config.world.setGameRule(GameRule.LOCATOR_BAR, false);
|
||||
return ((CraftEntity) e).getHandle().getYHeadRot();
|
||||
}
|
||||
|
||||
private LevelChunk getChunk(World world, int x, int z) {
|
||||
|
||||
@@ -34,12 +34,12 @@ import de.steamwar.fightsystem.winconditions.Wincondition;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.boss.BarColor;
|
||||
import org.bukkit.boss.BarStyle;
|
||||
import org.bukkit.boss.BossBar;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Queue;
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -142,6 +142,7 @@ public class FightUI {
|
||||
BossBarType.RED_LEFT.text = leftRedText;
|
||||
}
|
||||
|
||||
private final Map<Player, BossBar> barMap = new HashMap<>();
|
||||
private void sendToPlayers() {
|
||||
Bukkit.getOnlinePlayers().forEach(player -> {
|
||||
BossBarType bar = BossBarType.byAngle(CraftbukkitWrapper.impl.headRotation(player));
|
||||
@@ -154,7 +155,55 @@ public class FightUI {
|
||||
}
|
||||
}
|
||||
|
||||
BountifulWrapper.impl.sendBar(player, bar.team, bar.progress, FightSystem.getMessage().parse(bar.text.getMsg(), player, params));
|
||||
String text = FightSystem.getMessage().parse(bar.text.getMsg(), player, params);
|
||||
barMap.keySet().removeIf(p -> !p.isOnline());
|
||||
|
||||
if (!barMap.containsKey(player)) {
|
||||
BossBar bar1 = Bukkit.createBossBar(player.getName(), BarColor.WHITE, BarStyle.SOLID);
|
||||
barMap.put(player, bar1);
|
||||
bar1.addPlayer(player);
|
||||
}
|
||||
|
||||
BossBar bar1 = barMap.get(player);
|
||||
BarColor color;
|
||||
switch (bar.team.getColor()) {
|
||||
case DARK_BLUE:
|
||||
case DARK_AQUA:
|
||||
case BLUE:
|
||||
case AQUA:
|
||||
color = BarColor.BLUE;
|
||||
break;
|
||||
case GREEN:
|
||||
case DARK_GREEN:
|
||||
color = BarColor.GREEN;
|
||||
break;
|
||||
case DARK_RED:
|
||||
case RED:
|
||||
color = BarColor.RED;
|
||||
break;
|
||||
case DARK_PURPLE:
|
||||
color = BarColor.PURPLE;
|
||||
break;
|
||||
case GOLD:
|
||||
case YELLOW:
|
||||
color = BarColor.YELLOW;
|
||||
break;
|
||||
case LIGHT_PURPLE:
|
||||
color = BarColor.PINK;
|
||||
break;
|
||||
case BLACK:
|
||||
case WHITE:
|
||||
case GRAY:
|
||||
case DARK_GRAY:
|
||||
default:
|
||||
color = BarColor.WHITE;
|
||||
break;
|
||||
}
|
||||
if (bar1.getColor() != color) bar1.setColor(color);
|
||||
|
||||
if (bar1.getProgress() != bar.progress) bar1.setProgress(bar.progress);
|
||||
|
||||
if (!bar1.getTitle().equals(text)) bar1.setTitle(text);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -208,9 +257,17 @@ public class FightUI {
|
||||
|
||||
Bukkit.getOnlinePlayers().forEach(Player::resetTitle);
|
||||
if (winner != null) {
|
||||
Bukkit.getOnlinePlayers().forEach(p -> WorldOfColorWrapper.impl.sendTitle(p, FightSystem.getMessage().parse("UI_WIN", p, winner.getColor(), winner.getName()), FightSystem.getMessage().parse(subtitle, p, params), 5, 40, 5));
|
||||
Bukkit.getOnlinePlayers().forEach(p -> {
|
||||
String title = FightSystem.getMessage().parse("UI_WIN", p, winner.getColor(), winner.getName());
|
||||
String subtitle1 = FightSystem.getMessage().parse(subtitle, p, params);
|
||||
p.sendTitle(title, subtitle1, 5, 40, 5);
|
||||
});
|
||||
} else {
|
||||
Bukkit.getOnlinePlayers().forEach(p -> WorldOfColorWrapper.impl.sendTitle(p, FightSystem.getMessage().parse("UI_DRAW", p), FightSystem.getMessage().parse(subtitle, p, params), 5, 40, 5));
|
||||
Bukkit.getOnlinePlayers().forEach(p -> {
|
||||
String title = FightSystem.getMessage().parse("UI_DRAW", p);
|
||||
String subtitle1 = FightSystem.getMessage().parse(subtitle, p, params);
|
||||
p.sendTitle(title, subtitle1, 5, 40, 5);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -232,7 +289,10 @@ public class FightUI {
|
||||
}
|
||||
Message message = queue.poll();
|
||||
|
||||
Bukkit.getOnlinePlayers().forEach(p -> WorldOfColorWrapper.impl.sendTitle(p, " ", FightSystem.getMessage().parse(message.getMsg(), p, message.getParams()), 5, 40, 5));
|
||||
Bukkit.getOnlinePlayers().forEach(p -> {
|
||||
String subtitle = FightSystem.getMessage().parse(message.getMsg(), p, message.getParams());
|
||||
p.sendTitle(" ", subtitle, 5, 40, 5);
|
||||
});
|
||||
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), FightUI::printSubtitle, 50);
|
||||
subtitleScheduled = true;
|
||||
}
|
||||
|
||||
@@ -1,97 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2025 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.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.block.data.type.Dispenser;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Pose;
|
||||
import org.bukkit.event.block.BlockPhysicsEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.BlockDataMeta;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
public class FlatteningWrapper {
|
||||
public static final FlatteningWrapper impl = new FlatteningWrapper();
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
public boolean removeWater(Block block) {
|
||||
Material type = block.getType();
|
||||
if (type == Material.WATER || type == Material.LAVA) {
|
||||
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;
|
||||
}
|
||||
|
||||
public boolean containsBlockMeta(ItemMeta meta) {
|
||||
return meta instanceof BlockDataMeta && ((BlockDataMeta) meta).hasBlockData();
|
||||
}
|
||||
|
||||
public boolean hasAttributeModifier(ItemStack stack) {
|
||||
return stack.hasItemMeta() && stack.getItemMeta() != null && stack.getItemMeta().hasAttributeModifiers();
|
||||
}
|
||||
|
||||
public boolean doRecord(BlockPhysicsEvent e) {
|
||||
return e.getBlock() == e.getSourceBlock() || e.getChangedType() == Material.AIR;
|
||||
}
|
||||
|
||||
public void forceLoadChunk(World world, int cX, int cZ) {
|
||||
world.setChunkForceLoaded(cX, cZ, true);
|
||||
}
|
||||
|
||||
public boolean checkPistonMoving(Block block) {
|
||||
return block.getType() == Material.MOVING_PISTON;
|
||||
}
|
||||
|
||||
public boolean isFacingWater(Block dispenser) {
|
||||
return dispenser.getRelative(((Dispenser) dispenser.getBlockData()).getFacing()).isLiquid();
|
||||
}
|
||||
|
||||
public boolean isCrouching(Player player) {
|
||||
return player.getPose() == Pose.SWIMMING;
|
||||
}
|
||||
|
||||
public void sendBlockChange(Player player, Block block, Material type) {
|
||||
player.sendBlockChange(block.getLocation(), type.createBlockData());
|
||||
}
|
||||
}
|
||||
@@ -20,15 +20,25 @@
|
||||
package de.steamwar.fightsystem.utils;
|
||||
|
||||
import com.comphenix.tinyprotocol.TinyProtocol;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import de.steamwar.core.ProtocolWrapper;
|
||||
import de.steamwar.entity.REntity;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import it.unimi.dsi.fastutil.shorts.Short2ObjectArrayMap;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.SectionPos;
|
||||
import net.minecraft.network.protocol.game.ClientboundBlockUpdatePacket;
|
||||
import net.minecraft.network.protocol.game.ClientboundSectionBlocksUpdatePacket;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.craftbukkit.block.data.CraftBlockData;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@@ -91,7 +101,7 @@ public class Hull {
|
||||
public void addPlayer(Player player) {
|
||||
if (players.add(player)) {
|
||||
for (Entity entity : entities) {
|
||||
BlockIdWrapper.impl.untrackEntity(player, entity);
|
||||
untrackEntity(player, entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -99,7 +109,7 @@ public class Hull {
|
||||
public void removePlayer(Player player, boolean activeRemoval) {
|
||||
if (players.remove(player) && activeRemoval) {
|
||||
for (Entity entity : entities) {
|
||||
BlockIdWrapper.impl.trackEntity(player, entity);
|
||||
trackEntity(player, entity);
|
||||
}
|
||||
// techhider triggers block change sending
|
||||
}
|
||||
@@ -110,18 +120,34 @@ public class Hull {
|
||||
if (region.inRegion(location) && !visibility.get(new IntVector(location).toId(region))) {
|
||||
if (entities.add(entity)) {
|
||||
for (Player player : players) {
|
||||
BlockIdWrapper.impl.untrackEntity(player, entity);
|
||||
untrackEntity(player, entity);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (entities.remove(entity)) {
|
||||
for (Player player : players) {
|
||||
BlockIdWrapper.impl.trackEntity(player, entity);
|
||||
trackEntity(player, entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void trackEntity(Player player, Entity entity) {
|
||||
if (entity instanceof Player) {
|
||||
TinyProtocol.instance.sendPacket(player, ProtocolWrapper.playerInfoPacketConstructor(ProtocolWrapper.PlayerInfoAction.REMOVE, new GameProfile(entity.getUniqueId(), entity.getName()), GameMode.CREATIVE));
|
||||
}
|
||||
|
||||
player.showEntity(FightSystem.getPlugin(), entity);
|
||||
}
|
||||
|
||||
public void untrackEntity(Player player, Entity entity) {
|
||||
player.hideEntity(FightSystem.getPlugin(), entity);
|
||||
|
||||
if (entity instanceof Player) {
|
||||
TinyProtocol.instance.sendPacket(player, ProtocolWrapper.playerInfoPacketConstructor(ProtocolWrapper.PlayerInfoAction.ADD, new GameProfile(entity.getUniqueId(), entity.getName()), GameMode.CREATIVE));
|
||||
}
|
||||
}
|
||||
|
||||
public void removeEntity(Entity entity) {
|
||||
entities.remove(entity);
|
||||
}
|
||||
@@ -189,7 +215,34 @@ public class Hull {
|
||||
uncoveredSurface.clear();
|
||||
|
||||
for (Map.Entry<IntVector, List<IntVector>> entry : sectionWise.entrySet()) {
|
||||
Object packet = HullHiderWrapper.impl.generateBlockChangePacket(entry.getValue());
|
||||
Object result;
|
||||
List<IntVector> changes = entry.getValue();
|
||||
Object[] blockdata = new Object[changes.size()];
|
||||
for (int i = 0; i < blockdata.length; i++) {
|
||||
IntVector change = changes.get(i);
|
||||
blockdata[i] = ((CraftBlockData) Config.world.getBlockData(change.getX(), change.getY(), change.getZ())).getState();
|
||||
}
|
||||
|
||||
if (changes.size() > 1) {
|
||||
IntVector section = changes.get(0);
|
||||
section = new IntVector(section.getX() >> 4, section.getY() >> 4, section.getZ() >> 4);
|
||||
int xOffset = 16 * section.getX();
|
||||
int yOffset = 16 * section.getY();
|
||||
int zOffset = 16 * section.getZ();
|
||||
|
||||
short[] pos = new short[changes.size()];
|
||||
for (int i = 0; i < changes.size(); i++) {
|
||||
IntVector change = changes.get(i);
|
||||
|
||||
pos[i] = (short) (((change.getX() - xOffset) << 8) + ((change.getZ() - zOffset) << 4) + (change.getY() - yOffset));
|
||||
}
|
||||
|
||||
result = new ClientboundSectionBlocksUpdatePacket(SectionPos.of(section.getX(), section.getY(), section.getZ()), new Short2ObjectArrayMap<>(pos, blockdata, blockdata.length));
|
||||
} else {
|
||||
IntVector pos = changes.get(0);
|
||||
result = new ClientboundBlockUpdatePacket(new BlockPos(pos.getX(), pos.getY(), pos.getZ()), (BlockState) blockdata[0]);
|
||||
}
|
||||
Object packet = result;
|
||||
players.forEach(player -> TinyProtocol.instance.sendPacket(player, packet));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,7 +138,7 @@ public class HullHider implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onBlockPhysic(BlockPhysicsEvent e) {
|
||||
if (FlatteningWrapper.impl.doRecord(e)) {
|
||||
if (e.getBlock() == e.getSourceBlock() || e.getChangedType() == Material.AIR) {
|
||||
blockUpdate(e.getBlock(), e.getChangedType());
|
||||
}
|
||||
}
|
||||
@@ -222,7 +222,7 @@ public class HullHider implements Listener {
|
||||
}
|
||||
|
||||
private Object explosionHider(Player player, Object packet) {
|
||||
return ReflectionWrapper.impl.explosionHider(player, packet, this::packetHider);
|
||||
return packet;
|
||||
}
|
||||
|
||||
private void posHiderGenerator(Class<?> type, Class<? extends Number> posType, double factor) {
|
||||
|
||||
@@ -1,71 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2025 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 it.unimi.dsi.fastutil.shorts.Short2ObjectArrayMap;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.SectionPos;
|
||||
import net.minecraft.network.protocol.game.ClientboundBlockUpdatePacket;
|
||||
import net.minecraft.network.protocol.game.ClientboundSectionBlocksUpdatePacket;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import org.bukkit.craftbukkit.block.data.CraftBlockData;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class HullHiderWrapper {
|
||||
public static final HullHiderWrapper impl = new HullHiderWrapper();
|
||||
|
||||
public Object generateBlockChangePacket(List<Hull.IntVector> changes) {
|
||||
Object[] blockdata = new Object[changes.size()];
|
||||
for (int i = 0; i < blockdata.length; i++) {
|
||||
Hull.IntVector change = changes.get(i);
|
||||
blockdata[i] = ((CraftBlockData) Config.world.getBlockData(change.getX(), change.getY(), change.getZ())).getState();
|
||||
}
|
||||
|
||||
return generateBlockChangePacket(changes, blockdata);
|
||||
}
|
||||
|
||||
private Object generateBlockChangePacket(List<Hull.IntVector> changes, Object[] blockdata) {
|
||||
if (changes.size() > 1) {
|
||||
Hull.IntVector section = changes.get(0);
|
||||
section = new Hull.IntVector(section.getX() >> 4, section.getY() >> 4, section.getZ() >> 4);
|
||||
int xOffset = 16 * section.getX();
|
||||
int yOffset = 16 * section.getY();
|
||||
int zOffset = 16 * section.getZ();
|
||||
|
||||
short[] pos = new short[changes.size()];
|
||||
for (int i = 0; i < changes.size(); i++) {
|
||||
Hull.IntVector change = changes.get(i);
|
||||
|
||||
pos[i] = (short) (((change.getX() - xOffset) << 8) + ((change.getZ() - zOffset) << 4) + (change.getY() - yOffset));
|
||||
}
|
||||
|
||||
return constructMultiBlockChange(section, pos, blockdata);
|
||||
} else {
|
||||
Hull.IntVector pos = changes.get(0);
|
||||
return new ClientboundBlockUpdatePacket(new BlockPos(pos.getX(), pos.getY(), pos.getZ()), (BlockState) blockdata[0]);
|
||||
}
|
||||
}
|
||||
|
||||
protected Object constructMultiBlockChange(Hull.IntVector section, short[] pos, Object[] blockdata) {
|
||||
return new ClientboundSectionBlocksUpdatePacket(SectionPos.of(section.getX(), section.getY(), section.getZ()), new Short2ObjectArrayMap<>(pos, blockdata, blockdata.length));
|
||||
}
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2025 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 io.papermc.paper.datacomponent.DataComponentType;
|
||||
import io.papermc.paper.datacomponent.DataComponentTypes;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class ReflectionWrapper {
|
||||
public static final ReflectionWrapper impl = new ReflectionWrapper();
|
||||
|
||||
private static final Set<DataComponentType> FORBIDDEN_TYPES = new HashSet<>();
|
||||
|
||||
static {
|
||||
FORBIDDEN_TYPES.add(DataComponentTypes.CUSTOM_NAME);
|
||||
FORBIDDEN_TYPES.add(DataComponentTypes.PROFILE);
|
||||
FORBIDDEN_TYPES.add(DataComponentTypes.UNBREAKABLE);
|
||||
FORBIDDEN_TYPES.add(DataComponentTypes.BLOCK_DATA);
|
||||
FORBIDDEN_TYPES.add(DataComponentTypes.BLOCKS_ATTACKS);
|
||||
FORBIDDEN_TYPES.add(DataComponentTypes.BUNDLE_CONTENTS);
|
||||
FORBIDDEN_TYPES.add(DataComponentTypes.CUSTOM_MODEL_DATA);
|
||||
|
||||
FORBIDDEN_TYPES.add(DataComponentTypes.ATTRIBUTE_MODIFIERS);
|
||||
FORBIDDEN_TYPES.add(DataComponentTypes.TOOL);
|
||||
FORBIDDEN_TYPES.add(DataComponentTypes.WEAPON);
|
||||
FORBIDDEN_TYPES.add(DataComponentTypes.FOOD);
|
||||
FORBIDDEN_TYPES.add(DataComponentTypes.CONSUMABLE);
|
||||
FORBIDDEN_TYPES.add(DataComponentTypes.POTION_CONTENTS);
|
||||
FORBIDDEN_TYPES.add(DataComponentTypes.STORED_ENCHANTMENTS);
|
||||
FORBIDDEN_TYPES.add(DataComponentTypes.CAN_BREAK);
|
||||
FORBIDDEN_TYPES.add(DataComponentTypes.CAN_PLACE_ON);
|
||||
FORBIDDEN_TYPES.add(DataComponentTypes.MAX_DAMAGE);
|
||||
FORBIDDEN_TYPES.add(DataComponentTypes.USE_REMAINDER);
|
||||
FORBIDDEN_TYPES.add(DataComponentTypes.USE_COOLDOWN);
|
||||
FORBIDDEN_TYPES.add(DataComponentTypes.SUSPICIOUS_STEW_EFFECTS);
|
||||
FORBIDDEN_TYPES.add(DataComponentTypes.CHARGED_PROJECTILES);
|
||||
FORBIDDEN_TYPES.add(DataComponentTypes.INTANGIBLE_PROJECTILE);
|
||||
FORBIDDEN_TYPES.add(DataComponentTypes.FIREWORKS);
|
||||
FORBIDDEN_TYPES.add(DataComponentTypes.FIREWORK_EXPLOSION);
|
||||
FORBIDDEN_TYPES.add(DataComponentTypes.EQUIPPABLE);
|
||||
FORBIDDEN_TYPES.add(DataComponentTypes.REPAIR_COST);
|
||||
FORBIDDEN_TYPES.add(DataComponentTypes.ENCHANTABLE);
|
||||
}
|
||||
|
||||
public Object explosionHider(Player player, Object packet, PacketHiderFunction packetHiderFunction) {
|
||||
return packet;
|
||||
}
|
||||
|
||||
public boolean hasItems(ItemStack stack) {
|
||||
FORBIDDEN_TYPES.forEach(stack::resetData);
|
||||
return false;
|
||||
}
|
||||
|
||||
public interface PacketHiderFunction {
|
||||
Object hide(Player player, Object packet, Location location);
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
package de.steamwar.fightsystem.utils;
|
||||
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
|
||||
public class TpsWarper {
|
||||
public static final TpsWarper impl = new TpsWarper();
|
||||
|
||||
public void warp(float tps) {
|
||||
MinecraftServer.getServer().tickRateManager().setTickRate(tps);
|
||||
}
|
||||
}
|
||||
-50
@@ -1,50 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2025 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.entity.Player;
|
||||
import org.bukkit.entity.Projectile;
|
||||
import org.bukkit.scoreboard.Team;
|
||||
|
||||
public class WorldOfColorWrapper {
|
||||
public static final WorldOfColorWrapper impl = new WorldOfColorWrapper();
|
||||
|
||||
public void setTeamColor(Team team, ChatColor color) {
|
||||
team.setColor(color);
|
||||
}
|
||||
|
||||
public boolean isInBlock(Projectile e) {
|
||||
if (e instanceof Arrow arrow) return arrow.isInBlock();
|
||||
return false;
|
||||
}
|
||||
|
||||
public void playSound(Location location, Sound sound, String soundCategory, float volume, float pitch) {
|
||||
location.getWorld().playSound(location, sound, SoundCategory.valueOf(soundCategory), volume, pitch);
|
||||
}
|
||||
|
||||
public void sendTitle(Player player, String title, String subtitle, int start, int hold, int stop) {
|
||||
player.sendTitle(title, subtitle, start, hold, stop);
|
||||
}
|
||||
}
|
||||
+11
-2
@@ -19,13 +19,22 @@
|
||||
|
||||
package de.steamwar.fightsystem.winconditions;
|
||||
|
||||
import de.steamwar.fightsystem.utils.FlatteningWrapper;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.block.data.Waterlogged;
|
||||
|
||||
@Linked
|
||||
public class WinconditionWaterTechKO extends WinconditionBlocks {
|
||||
|
||||
public WinconditionWaterTechKO() {
|
||||
super(Winconditions.WATER_TECH_KO, "WaterTechKO", "BAR_WATER", FlatteningWrapper.impl::isWater);
|
||||
super(Winconditions.WATER_TECH_KO, "WaterTechKO", "BAR_WATER", block -> {
|
||||
if (block.getType() == Material.WATER) return true;
|
||||
|
||||
BlockData data = block.getBlockData();
|
||||
if (!(data instanceof Waterlogged)) return false;
|
||||
|
||||
return ((Waterlogged) data).isWaterlogged();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user