forked from SteamWar/SteamWar
Merge branch 'main' into 1.21.3
# Conflicts: # SpigotCore/SpigotCore_Main/src/de/steamwar/core/WorldEditWrapper.java
This commit is contained in:
@@ -145,7 +145,7 @@ public class TeamPlayer extends BasicListener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String message = "NPC_Chat_" + random.nextInt(6);
|
String message = "NPC_CHAT_" + random.nextInt(6);
|
||||||
SteamwarUser user = SteamwarUser.get(event.getRightClicked().getName());
|
SteamwarUser user = SteamwarUser.get(event.getRightClicked().getName());
|
||||||
UserPerm.Prefix prefix = user.prefix();
|
UserPerm.Prefix prefix = user.prefix();
|
||||||
LobbySystem.getMessage().send(message, event.getPlayer(), event.getRightClicked().getName(), prefix.getColorCode() + prefix.getChatPrefix());
|
LobbySystem.getMessage().send(message, event.getPlayer(), event.getRightClicked().getName(), prefix.getColorCode() + prefix.getChatPrefix());
|
||||||
|
|||||||
+10
-7
@@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
package de.steamwar.schematicsystem.autocheck;
|
package de.steamwar.schematicsystem.autocheck;
|
||||||
|
|
||||||
|
import de.steamwar.core.Core;
|
||||||
import de.steamwar.schematicsystem.CheckSchemType;
|
import de.steamwar.schematicsystem.CheckSchemType;
|
||||||
import de.steamwar.schematicsystem.SchematicSystem;
|
import de.steamwar.schematicsystem.SchematicSystem;
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
@@ -143,13 +144,15 @@ public class AutoCheckerResult {
|
|||||||
blockScanResult.getDefunctNbt().forEach(blockVector3 -> {
|
blockScanResult.getDefunctNbt().forEach(blockVector3 -> {
|
||||||
SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_DEFUNCT_NBT", p, SchematicSystem.MESSAGE.parse("AUTO_CHECKER_RESULT_TELEPORT_HERE", p), tpCommandTo(blockVector3), blockVector3.getX(), blockVector3.getY(), blockVector3.getZ());
|
SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_DEFUNCT_NBT", p, SchematicSystem.MESSAGE.parse("AUTO_CHECKER_RESULT_TELEPORT_HERE", p), tpCommandTo(blockVector3), blockVector3.getX(), blockVector3.getY(), blockVector3.getZ());
|
||||||
});
|
});
|
||||||
blockScanResult.getDesignBlocks().forEach((material, poss) -> {
|
if(Core.getVersion() > 12) {
|
||||||
if(material.getBlastResistance() > type.getMaxBlastResistance()) {
|
blockScanResult.getDesignBlocks().forEach((material, poss) -> {
|
||||||
poss.forEach(pos -> {
|
if(material.getBlastResistance() > type.getMaxBlastResistance()) {
|
||||||
SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_DESIGN_BLOCK", p, SchematicSystem.MESSAGE.parse("AUTO_CHECKER_RESULT_TELEPORT_HERE", p), tpCommandTo(pos), material.name(), pos.getBlockX(), pos.getBlockY(), pos.getBlockZ());
|
poss.forEach(pos -> {
|
||||||
});
|
SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_DESIGN_BLOCK", p, SchematicSystem.MESSAGE.parse("AUTO_CHECKER_RESULT_TELEPORT_HERE", p), tpCommandTo(pos), material.name(), pos.getBlockX(), pos.getBlockY(), pos.getBlockZ());
|
||||||
}
|
});
|
||||||
});
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
entities.forEach(blockPos -> {
|
entities.forEach(blockPos -> {
|
||||||
SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_ENTITY", p, SchematicSystem.MESSAGE.parse("AUTO_CHECKER_RESULT_TELEPORT_HERE", p), tpCommandTo(blockPos), blockPos.getX(), blockPos.getY(), blockPos.getZ());
|
SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_ENTITY", p, SchematicSystem.MESSAGE.parse("AUTO_CHECKER_RESULT_TELEPORT_HERE", p), tpCommandTo(blockPos), blockPos.getX(), blockPos.getY(), blockPos.getZ());
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -35,6 +35,8 @@ import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
|||||||
import com.sk89q.worldedit.extent.clipboard.io.*;
|
import com.sk89q.worldedit.extent.clipboard.io.*;
|
||||||
import com.sk89q.worldedit.extent.clipboard.io.legacycompat.*;
|
import com.sk89q.worldedit.extent.clipboard.io.legacycompat.*;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
import com.sk89q.worldedit.math.Vector3;
|
||||||
|
import com.sk89q.worldedit.math.transform.Transform;
|
||||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
import com.sk89q.worldedit.session.ClipboardHolder;
|
import com.sk89q.worldedit.session.ClipboardHolder;
|
||||||
@@ -44,6 +46,7 @@ import com.sk89q.worldedit.world.block.BlockTypes;
|
|||||||
import com.sk89q.worldedit.world.registry.LegacyMapper;
|
import com.sk89q.worldedit.world.registry.LegacyMapper;
|
||||||
import de.steamwar.sql.NoClipboardException;
|
import de.steamwar.sql.NoClipboardException;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@@ -52,7 +55,7 @@ import java.util.stream.Collectors;
|
|||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
public class WorldEditWrapper14 implements WorldEditWrapper.IWorldEditWrapper {
|
public class WorldEditWrapper14 implements WorldEditWrapper {
|
||||||
|
|
||||||
private static final ClipboardFormat SCHEMATIC = BuiltInClipboardFormat.MCEDIT_SCHEMATIC;
|
private static final ClipboardFormat SCHEMATIC = BuiltInClipboardFormat.MCEDIT_SCHEMATIC;
|
||||||
private static final ClipboardFormat SCHEM = BuiltInClipboardFormat.SPONGE_SCHEMATIC;
|
private static final ClipboardFormat SCHEM = BuiltInClipboardFormat.SPONGE_SCHEMATIC;
|
||||||
@@ -103,6 +106,28 @@ public class WorldEditWrapper14 implements WorldEditWrapper.IWorldEditWrapper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public org.bukkit.util.Vector getOrigin(Clipboard clipboard) {
|
||||||
|
return new org.bukkit.util.Vector(clipboard.getOrigin().getX(), clipboard.getOrigin().getY(), clipboard.getOrigin().getZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Vector getMinimum(Region region) {
|
||||||
|
return new Vector(region.getMinimumPoint().getX(), region.getMinimumPoint().getY(), region.getMinimumPoint().getZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Vector getMaximum(Region region) {
|
||||||
|
return new Vector(region.getMaximumPoint().getX(), region.getMaximumPoint().getY(), region.getMaximumPoint().getZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Vector applyTransform(Vector vector, Transform transform) {
|
||||||
|
Vector3 v = Vector3.at(vector.getX(), vector.getY(), vector.getZ());
|
||||||
|
v = transform.apply(v);
|
||||||
|
return new org.bukkit.util.Vector(v.getX(), v.getY(), v.getZ());
|
||||||
|
}
|
||||||
|
|
||||||
private static class MCEditSchematicReader extends NBTSchematicReader {
|
private static class MCEditSchematicReader extends NBTSchematicReader {
|
||||||
|
|
||||||
private final NBTInputStream inputStream;
|
private final NBTInputStream inputStream;
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ import com.google.common.base.Preconditions;
|
|||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import com.sk89q.jnbt.*;
|
import com.sk89q.jnbt.*;
|
||||||
import com.sk89q.worldedit.*;
|
import com.sk89q.worldedit.*;
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||||
import com.sk89q.worldedit.bukkit.BukkitWorld;
|
import com.sk89q.worldedit.bukkit.BukkitWorld;
|
||||||
import com.sk89q.worldedit.extension.input.ParserContext;
|
import com.sk89q.worldedit.extension.input.ParserContext;
|
||||||
@@ -33,19 +32,27 @@ import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
|||||||
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat;
|
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat;
|
||||||
import com.sk89q.worldedit.extent.clipboard.io.ClipboardReader;
|
import com.sk89q.worldedit.extent.clipboard.io.ClipboardReader;
|
||||||
import com.sk89q.worldedit.extent.clipboard.io.SchematicReader;
|
import com.sk89q.worldedit.extent.clipboard.io.SchematicReader;
|
||||||
|
import com.sk89q.worldedit.math.transform.Transform;
|
||||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||||
|
import com.sk89q.worldedit.regions.Region;
|
||||||
import com.sk89q.worldedit.session.ClipboardHolder;
|
import com.sk89q.worldedit.session.ClipboardHolder;
|
||||||
import com.sk89q.worldedit.world.registry.WorldData;
|
import com.sk89q.worldedit.world.registry.WorldData;
|
||||||
import de.steamwar.sql.NoClipboardException;
|
import de.steamwar.sql.NoClipboardException;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.IOException;
|
||||||
import java.util.*;
|
import java.io.InputStream;
|
||||||
|
import java.io.PipedInputStream;
|
||||||
|
import java.io.PipedOutputStream;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.zip.GZIPInputStream;
|
import java.util.zip.GZIPInputStream;
|
||||||
|
|
||||||
public class WorldEditWrapper8 implements WorldEditWrapper.IWorldEditWrapper {
|
public class WorldEditWrapper8 implements WorldEditWrapper {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InputStream getPlayerClipboard(Player player, boolean schemFormat) {
|
public InputStream getPlayerClipboard(Player player, boolean schemFormat) {
|
||||||
@@ -81,6 +88,28 @@ public class WorldEditWrapper8 implements WorldEditWrapper.IWorldEditWrapper {
|
|||||||
return new SchematicReader(new NBTInputStream(is)).read(WorldEdit.getInstance().getServer().getWorlds().get(0).getWorldData());
|
return new SchematicReader(new NBTInputStream(is)).read(WorldEdit.getInstance().getServer().getWorlds().get(0).getWorldData());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public org.bukkit.util.Vector getOrigin(Clipboard clipboard) {
|
||||||
|
return new org.bukkit.util.Vector(clipboard.getOrigin().getX(), clipboard.getOrigin().getY(), clipboard.getOrigin().getZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public org.bukkit.util.Vector getMinimum(Region region) {
|
||||||
|
return new org.bukkit.util.Vector(region.getMinimumPoint().getX(), region.getMinimumPoint().getY(), region.getMinimumPoint().getZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public org.bukkit.util.Vector getMaximum(Region region) {
|
||||||
|
return new org.bukkit.util.Vector(region.getMaximumPoint().getX(), region.getMaximumPoint().getY(), region.getMaximumPoint().getZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public org.bukkit.util.Vector applyTransform(org.bukkit.util.Vector vector, Transform transform) {
|
||||||
|
Vector v = new Vector(vector.getX(), vector.getY(), vector.getZ());
|
||||||
|
v = transform.apply(v);
|
||||||
|
return new org.bukkit.util.Vector(v.getX(), v.getY(), v.getZ());
|
||||||
|
}
|
||||||
|
|
||||||
private static class SpongeSchematicReader implements ClipboardReader {
|
private static class SpongeSchematicReader implements ClipboardReader {
|
||||||
|
|
||||||
private final NBTInputStream inputStream;
|
private final NBTInputStream inputStream;
|
||||||
|
|||||||
@@ -106,6 +106,9 @@ public class Core extends JavaPlugin{
|
|||||||
if(Core.getVersion() >= 19)
|
if(Core.getVersion() >= 19)
|
||||||
new ServerDataHandler();
|
new ServerDataHandler();
|
||||||
|
|
||||||
|
if(Core.getVersion() > 8 && Bukkit.getPluginManager().getPlugin("WorldEdit") != null)
|
||||||
|
new WorldEditRenderer();
|
||||||
|
|
||||||
Bukkit.getScheduler().runTaskTimer(this, TabCompletionCache::invalidateOldEntries, 20, 20);
|
Bukkit.getScheduler().runTaskTimer(this, TabCompletionCache::invalidateOldEntries, 20, 20);
|
||||||
Bukkit.getScheduler().runTaskTimer(Core.getInstance(), SteamwarUser::clear, 72000, 72000);
|
Bukkit.getScheduler().runTaskTimer(Core.getInstance(), SteamwarUser::clear, 72000, 72000);
|
||||||
Bukkit.getScheduler().runTaskTimer(Core.getInstance(), SchematicNode::clear, 20L * 30, 20L * 30);
|
Bukkit.getScheduler().runTaskTimer(Core.getInstance(), SchematicNode::clear, 20L * 30, 20L * 30);
|
||||||
|
|||||||
@@ -0,0 +1,126 @@
|
|||||||
|
/*
|
||||||
|
* This file is a part of the SteamWar software.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2024 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.core;
|
||||||
|
|
||||||
|
import com.sk89q.worldedit.EmptyClipboardException;
|
||||||
|
import com.sk89q.worldedit.IncompleteRegionException;
|
||||||
|
import com.sk89q.worldedit.LocalSession;
|
||||||
|
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||||
|
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||||
|
import com.sk89q.worldedit.math.transform.Transform;
|
||||||
|
import com.sk89q.worldedit.regions.Region;
|
||||||
|
import com.sk89q.worldedit.regions.RegionSelector;
|
||||||
|
import com.sk89q.worldedit.world.World;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.Particle;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
|
public class WorldEditRenderer {
|
||||||
|
|
||||||
|
private static final int VIEW_DISTANCE = 64;
|
||||||
|
private static final int SQ_VIEW_DISTANCE = VIEW_DISTANCE * VIEW_DISTANCE;
|
||||||
|
|
||||||
|
private static final double STEP_SIZE = 0.5;
|
||||||
|
|
||||||
|
private static final Vector ONES = new Vector(1, 1, 1);
|
||||||
|
|
||||||
|
private static final Material WAND = FlatteningWrapper.impl.getMaterial("WOOD_AXE");
|
||||||
|
|
||||||
|
private final WorldEditPlugin we;
|
||||||
|
|
||||||
|
public WorldEditRenderer() {
|
||||||
|
we = WorldEditWrapper.getWorldEditPlugin();
|
||||||
|
|
||||||
|
Bukkit.getScheduler().runTaskTimer(Core.getInstance(), this::render, 20, 20);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void render() {
|
||||||
|
for(Player player : Bukkit.getOnlinePlayers()) {
|
||||||
|
//noinspection deprecation
|
||||||
|
if(player.getItemInHand().getType() != WAND)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
LocalSession session = we.getSession(player);
|
||||||
|
try {
|
||||||
|
Clipboard clipboard = session.getClipboard().getClipboard();
|
||||||
|
Vector pos = player.getLocation().toVector();
|
||||||
|
Region region = clipboard.getRegion();
|
||||||
|
Transform transform = session.getClipboard().getTransform();
|
||||||
|
Vector a = WorldEditWrapper.impl.applyTransform(WorldEditWrapper.impl.getMinimum(region).subtract(WorldEditWrapper.impl.getOrigin(clipboard)), transform).add(pos);
|
||||||
|
Vector b = WorldEditWrapper.impl.applyTransform(WorldEditWrapper.impl.getMaximum(region).subtract(WorldEditWrapper.impl.getOrigin(clipboard)), transform).add(pos);
|
||||||
|
drawCuboid(Vector.getMinimum(a, b), Vector.getMaximum(a, b), Particle.VILLAGER_HAPPY, player);
|
||||||
|
} catch (EmptyClipboardException e) {
|
||||||
|
//ignore
|
||||||
|
}
|
||||||
|
|
||||||
|
World world = session.getSelectionWorld();
|
||||||
|
if(world != null) {
|
||||||
|
RegionSelector regionSelector = session.getRegionSelector(world);
|
||||||
|
try {
|
||||||
|
Region region = regionSelector.getRegion();
|
||||||
|
drawCuboid(WorldEditWrapper.impl.getMinimum(region), WorldEditWrapper.impl.getMaximum(region), Particle.DRAGON_BREATH, player);
|
||||||
|
} catch (IncompleteRegionException e) {
|
||||||
|
//ignore
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void drawCuboid(Vector min, Vector max, Particle particle, Player owner) {
|
||||||
|
max.add(ONES);
|
||||||
|
|
||||||
|
for(double x = min.getBlockX(); x <= max.getBlockX(); x += STEP_SIZE) {
|
||||||
|
draw(x, min.getBlockY(), min.getBlockZ(), particle, owner);
|
||||||
|
draw(x, min.getBlockY(), max.getBlockZ(), particle, owner);
|
||||||
|
draw(x, max.getBlockY(), min.getBlockZ(), particle, owner);
|
||||||
|
draw(x, max.getBlockY(), max.getBlockZ(), particle, owner);
|
||||||
|
}
|
||||||
|
|
||||||
|
for(double y = min.getBlockY() + STEP_SIZE; y <= max.getBlockY() - STEP_SIZE; y += STEP_SIZE) {
|
||||||
|
draw(min.getBlockX(), y, min.getBlockZ(), particle, owner);
|
||||||
|
draw(min.getBlockX(), y, max.getBlockZ(), particle, owner);
|
||||||
|
draw(max.getBlockX(), y, min.getBlockZ(), particle, owner);
|
||||||
|
draw(max.getBlockX(), y, max.getBlockZ(), particle, owner);
|
||||||
|
}
|
||||||
|
|
||||||
|
for(double z = min.getBlockZ() + STEP_SIZE; z <= max.getBlockZ() - STEP_SIZE; z += STEP_SIZE) {
|
||||||
|
draw(min.getBlockX(), min.getBlockY(), z, particle, owner);
|
||||||
|
draw(min.getBlockX(), max.getBlockY(), z, particle, owner);
|
||||||
|
draw(max.getBlockX(), min.getBlockY(), z, particle, owner);
|
||||||
|
draw(max.getBlockX(), max.getBlockY(), z, particle, owner);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void draw(double x, double y, double z, Particle particle, Player owner) {
|
||||||
|
for(Player player : Bukkit.getOnlinePlayers()) {
|
||||||
|
Location location = player.getLocation();
|
||||||
|
double dx = x - location.getX();
|
||||||
|
double dy = y - location.getY();
|
||||||
|
double dz = z - location.getZ();
|
||||||
|
if(dx*dx + dy*dy + dz*dz > SQ_VIEW_DISTANCE)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
player.spawnParticle(player == owner ? particle : Particle.TOWN_AURA, x, y, z, 1, 0.0, 0.0, 0.0, 0.0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -26,24 +26,28 @@ import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat;
|
|||||||
import com.sk89q.worldedit.session.ClipboardHolder;
|
import com.sk89q.worldedit.session.ClipboardHolder;
|
||||||
import de.steamwar.sql.NoClipboardException;
|
import de.steamwar.sql.NoClipboardException;
|
||||||
import org.apache.logging.log4j.util.TriConsumer;
|
import org.apache.logging.log4j.util.TriConsumer;
|
||||||
|
import com.sk89q.worldedit.math.transform.Transform;
|
||||||
|
import com.sk89q.worldedit.regions.Region;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class WorldEditWrapper {
|
public interface WorldEditWrapper {
|
||||||
private WorldEditWrapper() {}
|
WorldEditWrapper impl = VersionDependent.getVersionImpl(Core.getInstance());
|
||||||
|
|
||||||
public static final IWorldEditWrapper impl = VersionDependent.getVersionImpl(Core.getInstance());
|
InputStream getPlayerClipboard(Player player, boolean schemFormat);
|
||||||
|
void setPlayerClipboard(Player player, InputStream is, boolean schemFormat);
|
||||||
|
Clipboard getClipboard(InputStream is, boolean schemFormat) throws IOException;
|
||||||
|
|
||||||
public interface IWorldEditWrapper {
|
Vector getOrigin(Clipboard clipboard);
|
||||||
InputStream getPlayerClipboard(Player player, boolean schemFormat);
|
Vector getMinimum(Region region);
|
||||||
void setPlayerClipboard(Player player, InputStream is, boolean schemFormat);
|
Vector getMaximum(Region region);
|
||||||
Clipboard getClipboard(InputStream is, boolean schemFormat) throws IOException;
|
Vector applyTransform(Vector vector, Transform transform);
|
||||||
}
|
|
||||||
|
|
||||||
public static WorldEditPlugin getWorldEditPlugin() {
|
static WorldEditPlugin getWorldEditPlugin() {
|
||||||
return (WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit");
|
return (WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import de.steamwar.towerrun.state.GameStates;
|
|||||||
import org.bukkit.*;
|
import org.bukkit.*;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.block.Action;
|
import org.bukkit.event.block.Action;
|
||||||
import org.bukkit.event.block.BlockBreakEvent;
|
import org.bukkit.event.block.BlockBreakEvent;
|
||||||
@@ -83,14 +84,16 @@ public class IngameListener extends GameStateBukkitListener {
|
|||||||
.min(Comparator.comparing(Function.identity()))
|
.min(Comparator.comparing(Function.identity()))
|
||||||
.orElse(0.0);
|
.orElse(0.0);
|
||||||
|
|
||||||
|
List<Player> toDamage = new ArrayList<>();
|
||||||
TowerRunGame.PLAYERS_ALIVE.forEach(towerRunPlayer -> {
|
TowerRunGame.PLAYERS_ALIVE.forEach(towerRunPlayer -> {
|
||||||
if (towerRunPlayer.player().getLocation().getY() - minY > 20) {
|
if (towerRunPlayer.player().getLocation().getY() - minY > 20) {
|
||||||
towerRunPlayer.player().sendTitle("§a", TowerRun.getMessage().parse("CATCH_UP_WARNING", towerRunPlayer.player()), 5, 30, 5);
|
towerRunPlayer.player().sendTitle("§a", TowerRun.getMessage().parse("CATCH_UP_WARNING", towerRunPlayer.player()), 5, 30, 5);
|
||||||
}
|
}
|
||||||
if (towerRunPlayer.player().getLocation().getY() - minY > 30) {
|
if (towerRunPlayer.player().getLocation().getY() - minY > 30) {
|
||||||
towerRunPlayer.player().damage(1.0);
|
toDamage.add(towerRunPlayer.player());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
toDamage.forEach(p -> p.damage(1.0));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
antiCampRunnable.runTaskTimer(TowerRun.getInstance(), 100, 100);
|
antiCampRunnable.runTaskTimer(TowerRun.getInstance(), 100, 100);
|
||||||
|
|||||||
@@ -26,9 +26,9 @@ import com.velocitypowered.api.proxy.Player;
|
|||||||
import com.velocitypowered.api.proxy.ServerConnection;
|
import com.velocitypowered.api.proxy.ServerConnection;
|
||||||
import de.steamwar.persistent.Servertype;
|
import de.steamwar.persistent.Servertype;
|
||||||
import de.steamwar.persistent.Subserver;
|
import de.steamwar.persistent.Subserver;
|
||||||
import de.steamwar.velocitycore.VelocityCore;
|
|
||||||
import de.steamwar.sql.SteamwarUser;
|
import de.steamwar.sql.SteamwarUser;
|
||||||
import de.steamwar.sql.UserPerm;
|
import de.steamwar.sql.UserPerm;
|
||||||
|
import de.steamwar.velocitycore.VelocityCore;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.event.ClickEvent;
|
import net.kyori.adventure.text.event.ClickEvent;
|
||||||
import net.kyori.adventure.text.event.HoverEvent;
|
import net.kyori.adventure.text.event.HoverEvent;
|
||||||
@@ -47,6 +47,7 @@ import java.util.function.Supplier;
|
|||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
public interface Chatter {
|
public interface Chatter {
|
||||||
|
LegacyComponentSerializer SERIALIZER = LegacyComponentSerializer.builder().extractUrls().build();
|
||||||
|
|
||||||
static Stream<Player> allPlayers() {
|
static Stream<Player> allPlayers() {
|
||||||
return VelocityCore.getProxy().getAllPlayers().stream();
|
return VelocityCore.getProxy().getAllPlayers().stream();
|
||||||
@@ -138,7 +139,7 @@ public interface Chatter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
default String parseToLegacy(Message message) {
|
default String parseToLegacy(Message message) {
|
||||||
return LegacyComponentSerializer.legacySection().serialize(parse(message));
|
return SERIALIZER.serialize(parse(message));
|
||||||
}
|
}
|
||||||
|
|
||||||
default Component parse(String format, Object... params) {
|
default Component parse(String format, Object... params) {
|
||||||
@@ -178,7 +179,7 @@ public interface Chatter {
|
|||||||
params[i] = func.apply(this);
|
params[i] = func.apply(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return LegacyComponentSerializer.legacySection().deserialize(format.format(params));
|
return SERIALIZER.deserialize(format.format(params));
|
||||||
}
|
}
|
||||||
|
|
||||||
static PlayerChatter of(Player player) {
|
static PlayerChatter of(Player player) {
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ public class SubserverSystem {
|
|||||||
|
|
||||||
Chatter o = Chatter.of(owner);
|
Chatter o = Chatter.of(owner);
|
||||||
o.system("SERVER_ADD_MEMBER", p);
|
o.system("SERVER_ADD_MEMBER", p);
|
||||||
o.prefixless("SERVER_ADD_MESSAGE", new Message("SERVER_ADD_MESSAGE_HOVER"), ClickEvent.runCommand("/bau addmember " + p.user().getUserName()));
|
o.prefixless("SERVER_ADD_MESSAGE", new Message("SERVER_ADD_MESSAGE_HOVER", p.user().getUserName()), ClickEvent.runCommand("/bau addmember " + p.user().getUserName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void sendPlayer(Subserver subserver, Player player) {
|
public static void sendPlayer(Subserver subserver, Player player) {
|
||||||
|
|||||||
@@ -272,12 +272,13 @@ public class CheckCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean concludeCheckSession(String reason, SchematicType type) {
|
private boolean concludeCheckSession(String reason, SchematicType type) {
|
||||||
if(SchematicNode.getSchematicNode(schematic.getId()) == null) // Schematic was deleted
|
boolean exists = SchematicNode.getSchematicNode(schematic.getId()) != null;
|
||||||
return false;
|
|
||||||
|
|
||||||
CheckedSchematic.create(schematic, checker.user().getId(), startTime, Timestamp.from(Instant.now()), reason);
|
if(exists) {
|
||||||
if(type != null)
|
CheckedSchematic.create(schematic, checker.user().getId(), startTime, Timestamp.from(Instant.now()), reason);
|
||||||
schematic.setSchemtype(type);
|
if(type != null)
|
||||||
|
schematic.setSchemtype(type);
|
||||||
|
}
|
||||||
|
|
||||||
remove();
|
remove();
|
||||||
VelocityCore.schedule(() -> {
|
VelocityCore.schedule(() -> {
|
||||||
@@ -285,7 +286,7 @@ public class CheckCommand extends SWCommand {
|
|||||||
if(subserver != null)
|
if(subserver != null)
|
||||||
subserver.stop();
|
subserver.stop();
|
||||||
}).schedule();
|
}).schedule();
|
||||||
return true;
|
return exists;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void remove() {
|
private void remove() {
|
||||||
|
|||||||
@@ -20,18 +20,17 @@
|
|||||||
package de.steamwar.velocitycore.mods;
|
package de.steamwar.velocitycore.mods;
|
||||||
|
|
||||||
import com.velocitypowered.api.proxy.Player;
|
import com.velocitypowered.api.proxy.Player;
|
||||||
import de.steamwar.sql.Punishment;
|
|
||||||
import de.steamwar.velocitycore.VelocityCore;
|
|
||||||
import de.steamwar.velocitycore.commands.PunishmentCommand;
|
|
||||||
import de.steamwar.messages.Chatter;
|
import de.steamwar.messages.Chatter;
|
||||||
import de.steamwar.sql.Mod;
|
import de.steamwar.sql.Mod;
|
||||||
import de.steamwar.sql.Mod.ModType;
|
import de.steamwar.sql.Mod.ModType;
|
||||||
|
import de.steamwar.sql.Punishment;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
import de.steamwar.sql.SteamwarUser;
|
||||||
import de.steamwar.sql.UserPerm;
|
import de.steamwar.sql.UserPerm;
|
||||||
|
import de.steamwar.velocitycore.VelocityCore;
|
||||||
|
import de.steamwar.velocitycore.commands.PunishmentCommand;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.experimental.UtilityClass;
|
import lombok.experimental.UtilityClass;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
|
||||||
|
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
@@ -88,7 +87,7 @@ public class ModUtils {
|
|||||||
VelocityCore.getLogger().log(Level.SEVERE, "%s %s wurde automatisch wegen der Mods %s gebannt.".formatted(user.getUserName(), user.getId(), modList));
|
VelocityCore.getLogger().log(Level.SEVERE, "%s %s wurde automatisch wegen der Mods %s gebannt.".formatted(user.getUserName(), user.getId(), modList));
|
||||||
}
|
}
|
||||||
|
|
||||||
disconnect.accept(LegacyComponentSerializer.legacySection().deserialize(message));
|
disconnect.accept(Chatter.SERIALIZER.deserialize(message));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
package de.steamwar.velocitycore.network.handlers;
|
package de.steamwar.velocitycore.network.handlers;
|
||||||
|
|
||||||
import com.velocitypowered.api.proxy.Player;
|
import com.velocitypowered.api.proxy.Player;
|
||||||
|
import de.steamwar.messages.Chatter;
|
||||||
import de.steamwar.network.packets.PacketHandler;
|
import de.steamwar.network.packets.PacketHandler;
|
||||||
import de.steamwar.network.packets.common.FightEndsPacket;
|
import de.steamwar.network.packets.common.FightEndsPacket;
|
||||||
import de.steamwar.sql.SchematicType;
|
import de.steamwar.sql.SchematicType;
|
||||||
@@ -29,7 +30,6 @@ import de.steamwar.velocitycore.ArenaMode;
|
|||||||
import de.steamwar.velocitycore.VelocityCore;
|
import de.steamwar.velocitycore.VelocityCore;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
|
||||||
import net.kyori.adventure.title.Title;
|
import net.kyori.adventure.title.Title;
|
||||||
|
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
@@ -186,10 +186,10 @@ public class EloPlayerHandler extends PacketHandler {
|
|||||||
|
|
||||||
double eloStep = eloGain / 40.0;
|
double eloStep = eloGain / 40.0;
|
||||||
for (int i = 0; i < 40; i++) {
|
for (int i = 0; i < 40; i++) {
|
||||||
Component eloGainComponent = LegacyComponentSerializer.legacySection().deserialize(color + (int) (eloStep * (i + 1)));
|
Component eloGainComponent = Chatter.SERIALIZER.deserialize(color + (int) (eloStep * (i + 1)));
|
||||||
int finalI = i;
|
int finalI = i;
|
||||||
VelocityCore.schedule(() -> player.showTitle(Title.title(
|
VelocityCore.schedule(() -> player.showTitle(Title.title(
|
||||||
LegacyComponentSerializer.legacySection().deserialize(getRankup.apply(finalI)),
|
Chatter.SERIALIZER.deserialize(getRankup.apply(finalI)),
|
||||||
eloGainComponent,
|
eloGainComponent,
|
||||||
Title.Times.times(Duration.ofMillis(finalI == 0 ? 250 : 0), Duration.ofSeconds(2), Duration.ofMillis(finalI == 39 ? 250 : 0))
|
Title.Times.times(Duration.ofMillis(finalI == 0 ? 250 : 0), Duration.ofSeconds(2), Duration.ofMillis(finalI == 39 ? 250 : 0))
|
||||||
))).delay(i * 50L, TimeUnit.MILLISECONDS).schedule();
|
))).delay(i * 50L, TimeUnit.MILLISECONDS).schedule();
|
||||||
|
|||||||
@@ -142,8 +142,10 @@ public class Tablist extends ChannelInboundHandlerAdapter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void onServerPostSwitch() {
|
public void onServerPostSwitch() {
|
||||||
if(player.getProtocolVersion().greaterThan(ProtocolVersion.MINECRAFT_1_20)) {
|
if(player.getProtocolVersion().noLessThan(ProtocolVersion.MINECRAFT_1_20)) {
|
||||||
current.clear();
|
if(player.getProtocolVersion().greaterThan(ProtocolVersion.MINECRAFT_1_20))
|
||||||
|
current.clear();
|
||||||
|
|
||||||
sendPacket(player, createTeamPacket);
|
sendPacket(player, createTeamPacket);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ public class TablistManager extends BasicListener {
|
|||||||
tablists.computeIfAbsent(event.getPlayer(), Tablist::new).onServerSwitch();
|
tablists.computeIfAbsent(event.getPlayer(), Tablist::new).onServerSwitch();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(event.getPlayer().getProtocolVersion().noGreaterThan(ProtocolVersion.MINECRAFT_1_20))
|
if(event.getPlayer().getProtocolVersion().lessThan(ProtocolVersion.MINECRAFT_1_20))
|
||||||
Tablist.sendPacket(event.getPlayer(), Tablist.createTeamPacket);
|
Tablist.sendPacket(event.getPlayer(), Tablist.createTeamPacket);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ import de.steamwar.sql.SteamwarUser;
|
|||||||
import de.steamwar.sql.UserPerm;
|
import de.steamwar.sql.UserPerm;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@@ -43,7 +42,7 @@ public interface TablistPart {
|
|||||||
|
|
||||||
public Item(UUID uuid, String displayName, List<GameProfile.Property> properties) {
|
public Item(UUID uuid, String displayName, List<GameProfile.Property> properties) {
|
||||||
this.uuid = uuid;
|
this.uuid = uuid;
|
||||||
this.displayName = LegacyComponentSerializer.legacySection().deserialize(displayName);
|
this.displayName = Chatter.SERIALIZER.deserialize(displayName);
|
||||||
this.properties = properties;
|
this.properties = properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -55,9 +54,9 @@ public interface TablistPart {
|
|||||||
this.uuid = player.getUniqueId();
|
this.uuid = player.getUniqueId();
|
||||||
UserPerm.Prefix prefix = SteamwarUser.get(player.getUniqueId()).prefix();
|
UserPerm.Prefix prefix = SteamwarUser.get(player.getUniqueId()).prefix();
|
||||||
if (prefix == UserPerm.emptyPrefix && sameTeam) {
|
if (prefix == UserPerm.emptyPrefix && sameTeam) {
|
||||||
this.displayName = LegacyComponentSerializer.legacySection().deserialize("§f" + player.getUsername());
|
this.displayName = Chatter.SERIALIZER.deserialize("§f" + player.getUsername());
|
||||||
} else {
|
} else {
|
||||||
this.displayName = LegacyComponentSerializer.legacySection().deserialize(prefix.getColorCode() + player.getUsername());
|
this.displayName = Chatter.SERIALIZER.deserialize(prefix.getColorCode() + player.getUsername());
|
||||||
}
|
}
|
||||||
this.properties = player.getGameProfileProperties();
|
this.properties = player.getGameProfileProperties();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import io.ktor.server.application.hooks.*
|
|||||||
import io.ktor.server.auth.*
|
import io.ktor.server.auth.*
|
||||||
import io.ktor.server.request.*
|
import io.ktor.server.request.*
|
||||||
import io.ktor.server.response.*
|
import io.ktor.server.response.*
|
||||||
|
import io.ktor.util.*
|
||||||
|
|
||||||
|
|
||||||
data class SWAuthPrincipal(val token: Token, val user: SteamwarUser) : Principal
|
data class SWAuthPrincipal(val token: Token, val user: SteamwarUser) : Principal
|
||||||
@@ -104,7 +105,7 @@ Message: ${cause.message}
|
|||||||
}
|
}
|
||||||
|
|
||||||
onCallRespond { call ->
|
onCallRespond { call ->
|
||||||
if (call.response.status()?.isSuccess() == true) {
|
if ((call.response.status() ?: HttpStatusCode.OK).isSuccess()) {
|
||||||
return@onCallRespond
|
return@onCallRespond
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -120,7 +121,7 @@ Message: ${cause.message}
|
|||||||
Headers:
|
Headers:
|
||||||
${call.request.headers.entries().joinToString("\n ") { "${it.key}: ${it.value}" }}
|
${call.request.headers.entries().joinToString("\n ") { "${it.key}: ${it.value}" }}
|
||||||
Body:
|
Body:
|
||||||
${call.request.receiveChannel()}
|
${call.request.receiveChannel().toByteArray().decodeToString()}
|
||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
|
|
||||||
SWException.log(msg, stack)
|
SWException.log(msg, stack)
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ fun Application.configurePlugins() {
|
|||||||
it.request.headers["X-Forwarded-For"] ?: it.request.local.remoteHost
|
it.request.headers["X-Forwarded-For"] ?: it.request.local.remoteHost
|
||||||
}
|
}
|
||||||
requestWeight { applicationCall, _ ->
|
requestWeight { applicationCall, _ ->
|
||||||
if(applicationCall.request.headers["X-Forwarded-For"] != null) {
|
if(!applicationCall.request.headers.contains("X-Forwarded-For")) {
|
||||||
0
|
0
|
||||||
} else {
|
} else {
|
||||||
1
|
1
|
||||||
|
|||||||
Reference in New Issue
Block a user