forked from SteamWar/SteamWar
Compare commits
71
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d5c5da27bf | ||
|
|
9201cb8186 | ||
|
|
e9a7908e26 | ||
|
|
110833db39 | ||
|
|
1c2f9b922f | ||
|
|
937905f296 | ||
|
|
dfec29dac5 | ||
|
|
b36d74da0e | ||
|
|
65958b1fdb | ||
|
|
24403488cd | ||
|
|
e550ee73f4 | ||
|
|
f882cc8c1b | ||
|
|
d4f4be78bb | ||
|
|
9eea5f5e25 | ||
|
|
4dbe2ccac7 | ||
|
|
d7d452ebe6 | ||
|
|
baa4cf34e5 | ||
|
|
e1ff37bea2 | ||
|
|
5651455a5f | ||
|
|
9fd2bd17d4 | ||
|
|
9598b1c961 | ||
|
|
b78fab3172 | ||
|
|
d76c396268 | ||
|
|
edb13fb7df | ||
|
|
abf44b2306 | ||
|
|
a9fbb4cd8d | ||
|
|
f02f356b2b | ||
|
|
d1fb4ca67e | ||
|
|
ce2a23f4b8 | ||
|
|
7d4252325a | ||
|
|
da4b684a4b | ||
|
|
a3a97ee102 | ||
|
|
b8f61658f4 | ||
|
|
54f1ae0388 | ||
|
|
fc090c2b48 | ||
|
|
6c99f1f9c9 | ||
|
|
ac7dc2d2d5 | ||
|
|
865d28645a | ||
|
|
b47cff2805 | ||
|
|
7cd2e540ef | ||
|
|
8381cacdf8 | ||
|
|
4943682a66 | ||
|
|
0ef702da9e | ||
|
|
2ea09eadb2 | ||
|
|
d32f5738fd | ||
|
|
78669acef3 | ||
|
|
cb38460c4b | ||
|
|
a4e06bcfd5 | ||
|
|
bfbf98c1d6 | ||
|
|
c4b46e4431 | ||
|
|
c238b9bdf2 | ||
|
|
fec4007120 | ||
|
|
11798c3ec0 | ||
|
|
9935ab785d | ||
|
|
8e3e71dd96 | ||
|
|
3fe2e006b9 | ||
|
|
9d5fcc07e8 | ||
|
|
0c3e63d521 | ||
|
|
27d260a8d2 | ||
|
|
37f017b84c | ||
|
|
21d0a4359d | ||
|
|
8318d408b6 | ||
|
|
d14ddc4fab | ||
|
|
5cc5529533 | ||
|
|
380693a2b7 | ||
|
|
69aef9dfb6 | ||
|
|
097df865e5 | ||
|
|
230f8c521a | ||
|
|
253a975c73 | ||
|
|
12dd46176b | ||
|
|
2111d72387 |
@@ -7,8 +7,14 @@
|
||||
!gradle/wrapper/gradle-wrapper.jar
|
||||
steamwar.properties
|
||||
|
||||
# Kotlin
|
||||
.kotlin
|
||||
|
||||
# IntelliJ IDEA
|
||||
*.iml
|
||||
.idea
|
||||
!.idea/copyright
|
||||
!.idea/runConfigurations
|
||||
|
||||
# VSCode
|
||||
bin/
|
||||
|
||||
@@ -36,6 +36,7 @@ dependencies {
|
||||
annotationProcessor(libs.classindex)
|
||||
compileOnly(project(":SpigotCore", "default"))
|
||||
compileOnly(project(":KotlinCore", "default"))
|
||||
implementation(project(":HiderCore"))
|
||||
|
||||
compileOnly(libs.axiom)
|
||||
compileOnly(libs.authlib)
|
||||
|
||||
@@ -35,8 +35,7 @@ SCOREBOARD_LOADER = Loader
|
||||
SCOREBOARD_TPS = TPS
|
||||
SCOREBOARD_TPS_FROZEN = §eFrozen
|
||||
SCOREBOARD_TRACE_TICKS = Ticks
|
||||
SCOREBOARD_TECHHIDER = TechHider§8: §aOn
|
||||
SCOREBOARD_XRAY = XRay§8: §aOn
|
||||
SCOREBOARD_VIEW = View§8: §a{0}
|
||||
SCOREBOARD_LOCK_TEAM = Bau Lock§8: §eTeam
|
||||
SCOREBOARD_LOCK_SUPERVISOR = Bau Lock§8: §eSupervisor
|
||||
SCOREBOARD_LOCK_TEAM_AND_SERVERTEAM = Bau Lock§8: §e(Server) Team
|
||||
@@ -52,7 +51,9 @@ FLAG_ITEMS = Items
|
||||
FLAG_NO_GRAVITY = No Gravity
|
||||
FLAG_TESTBLOCK = Testblock
|
||||
FLAG_CHANGED = Changed
|
||||
FLAG_WINDCHARGE_INTERACT = Windcharge interaction
|
||||
FLAG_WATER_DESTROY = Water Destroy
|
||||
FLAG_PROJECTILE_STOPPER = Projectile Stopper
|
||||
FLAG_WATER_DESTROY_ALLOW = §coff
|
||||
FLAG_WATER_DESTROY_DENY = §aon
|
||||
FLAG_FIRE_ALLOW = §con
|
||||
@@ -92,6 +93,10 @@ FLAG_TESTBLOCK_NORTH = §eNorth
|
||||
FLAG_TESTBLOCK_SOUTH = §eSouth
|
||||
FLAG_CHANGED_NO_CHANGE = §cNo
|
||||
FLAG_CHANGED_HAS_CHANGE = §aYes
|
||||
FLAG_WINDCHARGE_INTERACT_ALLOW = §aon
|
||||
FLAG_WINDCHARGE_INTERACT_DENY = §coff
|
||||
FLAG_PROJECTILE_STOPPER_ENABLED = §aon
|
||||
FLAG_PROJECTILE_STOPPER_DISABLED = §coff
|
||||
# Region
|
||||
REGION_TYPE_NORMAL = Normal
|
||||
REGION_TYPE_BUILD = Build area
|
||||
@@ -827,6 +832,13 @@ REGION_TNT_OFF = §cTNT-Damage deactivated
|
||||
REGION_TNT_TB = §aTNT-Damage activated outside the building area
|
||||
REGION_TNT_BUILD_DESTROY = §cAn explosion would have destroyed blocks in the building area
|
||||
REGION_TNT_TB_DESTROY = §cAn explosion would have destroyed blocks in the testblock area
|
||||
REGION_WINDCHARGE_INTERACT_HELP = §8/§ewindcharge §8- §7Toggle the Windcharge interaction
|
||||
REGION_WINDCHARGE_INTERACT_ON = §aWindcharge interaction on
|
||||
REGION_WINDCHARGE_INTERACT_OFF = §cWindcharge interaction off
|
||||
REGION_PROJECTILE_STOPPER_HELP = §8/§eprojectilestopper §8- §7Toggle the Projectile stopper
|
||||
REGION_PROJECTILE_STOPPER_ON = §aProjectile stopper enabled
|
||||
REGION_PROJECTILE_STOPPER_OFF = §cProjectile stopper disabled
|
||||
|
||||
AFK_KICK_MESSAGE = §cNothing happened on this server for 15 minutes.
|
||||
AFK_WARNING_MESSAGE = §cThis server will stop in one minute if you remain inactive
|
||||
SKIN_HELP = §8/§eskin §8[§7Shortform§8] §8[§7Creator§8|§epublic§8] §8[§7Name...§8] §8- §7Creates the skin schematic. Use 'public' as creator to have no creator, then copy the message to YoyoNow by clicking
|
||||
@@ -1033,6 +1045,11 @@ XRAY_HELP = §8/§exray §8- §7Toggle Xray
|
||||
XRAY_GLOBAL = §cNo xray in global region
|
||||
XRAY_ON = §aXray activated
|
||||
XRAY_OFF = §cXray deactivated
|
||||
# HULLHIDER
|
||||
HULLHIDER_HELP = §8/§ehullhider §8- §7Toggle Hullhider
|
||||
HULLHIDER_GLOBAL = §cNo hullhider in global region
|
||||
HULLHIDER_ON = §aHullhider activated
|
||||
HULLHIDER_OFF = §cHullhider deactivated
|
||||
# WorldEdit
|
||||
COLORREPLACE_HELP = §8//§ecolorreplace §8[§7color§8] §8[§7color§8] §8- §7Replace all blocks of one color with another
|
||||
TYPEREPLACE_HELP = §8//§etypereplace §8[§7type§8] §8[§7type§8] §8- §7Replace all blocks of one type with another
|
||||
|
||||
@@ -35,8 +35,7 @@ SCOREBOARD_LOADER = Loader
|
||||
SCOREBOARD_TPS = TPS
|
||||
SCOREBOARD_TPS_FROZEN = §eEingefroren
|
||||
SCOREBOARD_TRACE_TICKS = Ticks
|
||||
SCOREBOARD_TECHHIDER = TechHider§8: §aAn
|
||||
SCOREBOARD_XRAY = XRay§8: §aAn
|
||||
SCOREBOARD_VIEW = Ansicht§8: §a{0}
|
||||
SCOREBOARD_LOCK_TEAM = Bau Lock§8: §eTeam
|
||||
SCOREBOARD_LOCK_TEAM_AND_SERVERTEAM = Bau Lock§8: §e(Server-) Team
|
||||
SCOREBOARD_LOCK_SERVERTEAM = Bau Lock§8: §eServerteam
|
||||
@@ -55,6 +54,8 @@ FLAG_FREEZE_INACTIVE = §caus
|
||||
FLAG_PROTECT_ACTIVE = §aan
|
||||
FLAG_PROTECT_INACTIVE = §caus
|
||||
FLAG_WATER_DESTROY = Wasserschaden
|
||||
FLAG_PROJECTILE_STOPPER = Projektil stopper
|
||||
FLAG_WINDCHARGE_INTERACT = Windkugel interaktion
|
||||
FLAG_WATER_DESTROY_ALLOW = §cerlaubt
|
||||
FLAG_WATER_DESTROY_DENY = §aaus
|
||||
FLAG_TNT_ALLOW = §aan
|
||||
@@ -81,6 +82,10 @@ FLAG_COLOR_BROWN = §eBraun
|
||||
FLAG_COLOR_GREEN = §2Grün
|
||||
FLAG_COLOR_RED = §cRot
|
||||
FLAG_COLOR_BLACK = §0Schwarz
|
||||
FLAG_WINDCHARGE_INTERACT_ALLOW = §aan
|
||||
FLAG_WINDCHARGE_INTERACT_DENY = §caus
|
||||
FLAG_PROJECTILE_STOPPER_ENABLED = §aan
|
||||
FLAG_PROJECTILE_STOPPER_DISABLED = §caus
|
||||
# Region
|
||||
REGION_TYPE_NORMAL = Normal
|
||||
REGION_TYPE_BUILD = Baubereich
|
||||
@@ -765,6 +770,12 @@ REGION_TNT_OFF = §cTNT-Schaden deaktiviert
|
||||
REGION_TNT_TB = §aTNT-Schaden außerhalb Baurahmen aktiviert
|
||||
REGION_TNT_BUILD_DESTROY = §cEine Explosion hätte Blöcke im Baubereich zerstört
|
||||
REGION_TNT_TB_DESTROY = §cEine Explosion hätte Blöcke im Testblockbereich zerstört
|
||||
REGION_WINDCHARGE_INTERACT_HELP = §8/§ewindcharge §8- §7Windkugel interaktion umschalten
|
||||
REGION_WINDCHARGE_INTERACT_ON = §aWindkugel interaktion on
|
||||
REGION_WINDCHARGE_INTERACT_OFF = §cWindkugel interaktion off
|
||||
REGION_PROJECTILE_STOPPER_HELP = §8/§eprojectilestopper §8- §7
|
||||
REGION_PROJECTILE_STOPPER_ON = §aProjektiel stopper an
|
||||
REGION_PROJECTILE_STOPPER_OFF = §cProjektiel stopper aus
|
||||
AFK_KICK_MESSAGE = §cAuf diesem Server ist seit 15 Minuten nichts passiert.
|
||||
AFK_WARNING_MESSAGE = §cDieser Server wird bei weiterer Inaktivität in einer Minute gestoppt
|
||||
SKIN_HELP = §8/§eskin §8[§7Kuerzel§8] §8[§7Creator§8|§epublic§8] §8[§7Name...§8] §8- §7Erstellt die Skin Schematics. 'public' als Creator nutzen für keinen Creator, danach die nachricht an YoyoNow kopieren (mit Click kopieren)
|
||||
@@ -966,6 +977,11 @@ XRAY_HELP = §8/§exray §8- §7Xray umschalten
|
||||
XRAY_GLOBAL = §cKein Xray in der globalen region
|
||||
XRAY_ON = §aXray aktiviert
|
||||
XRAY_OFF = §cXray deaktiviert
|
||||
# HULLHIDER
|
||||
HULLHIDER_HELP = §8/§ehullhider §8- §7Hullhider umschalten
|
||||
HULLHIDER_GLOBAL = §cKein Hullhider in der globalen region
|
||||
HULLHIDER_ON = §aHullhider aktiviert
|
||||
HULLHIDER_OFF = §cHullhider deaktiviert
|
||||
# WorldEdit
|
||||
COLORREPLACE_HELP = §8//§ecolorreplace §8[§7color§8] §8[§7color§8] §8- §7Ersetzt eine Farbe mit einer anderen
|
||||
TYPEREPLACE_HELP = §8//§etyreplace §8[§7type§8] §8[§7type§8] §8- §7Ersetzt einen Blockgruppe mit einer anderen
|
||||
|
||||
@@ -24,7 +24,6 @@ import de.steamwar.bausystem.config.ConfigStore;
|
||||
import de.steamwar.bausystem.features.gui.BauGUI;
|
||||
import de.steamwar.bausystem.features.script.lua.SteamWarLuaPlugin;
|
||||
import de.steamwar.bausystem.features.script.lua.libs.LuaLib;
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.BoundingBoxLoader;
|
||||
import de.steamwar.bausystem.features.slaves.panzern.Panzern;
|
||||
import de.steamwar.bausystem.features.slaves.panzern.PanzernAlgorithm;
|
||||
import de.steamwar.bausystem.features.tracer.TraceManager;
|
||||
@@ -41,7 +40,6 @@ import de.steamwar.core.CRIUSleepEvent;
|
||||
import de.steamwar.core.Core;
|
||||
import de.steamwar.core.WorldIdentifier;
|
||||
import de.steamwar.core.worldedit.SteamEdit;
|
||||
import de.steamwar.core.worldedit.WorldEditRendererCUIEditor;
|
||||
import de.steamwar.linkage.AbstractLinker;
|
||||
import de.steamwar.linkage.SpigotLinker;
|
||||
import de.steamwar.message.Message;
|
||||
@@ -110,9 +108,9 @@ public class BauSystem extends JavaPlugin implements Listener {
|
||||
if (any instanceof PanzernAlgorithm) {
|
||||
Panzern.add((PanzernAlgorithm) any);
|
||||
}
|
||||
if (any instanceof BoundingBoxLoader) {
|
||||
((BoundingBoxLoader) any).load();
|
||||
}
|
||||
// if (any instanceof BoundingBoxLoader) {
|
||||
// ((BoundingBoxLoader) any).load();
|
||||
// }
|
||||
}
|
||||
};
|
||||
try {
|
||||
|
||||
+177
@@ -0,0 +1,177 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2026 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.bausystem.features.hullhider;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.features.techhider.HiddenHull;
|
||||
import de.steamwar.bausystem.features.techhider.HidingRule;
|
||||
import de.steamwar.bausystem.features.techhider.TechHiderCommand;
|
||||
import de.steamwar.bausystem.features.xray.XrayCommand;
|
||||
import de.steamwar.bausystem.region.Point;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.hullhider.Hull;
|
||||
import de.steamwar.hullhider.HullHider;
|
||||
import de.steamwar.hullhider.HullRegion;
|
||||
import de.steamwar.hullhider.Viewers;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.linkage.LinkedInstance;
|
||||
import de.steamwar.linkage.LinkedTimer;
|
||||
import de.steamwar.techhider.ObfuscationConfig;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* Hides the inside of the build area hull of a region from the players who toggle it, as the hull hider of a fight would.
|
||||
*/
|
||||
@Linked
|
||||
public class HullHiderCommand extends SWCommand implements Listener {
|
||||
|
||||
public HullHiderCommand() {
|
||||
super("hullhider");
|
||||
}
|
||||
|
||||
@Linked
|
||||
// Only blocks are hidden, entities stay visible
|
||||
private final HullHider<Region> hullHider = new HullHider<>(false);
|
||||
// Read on netty threads by the BauTechHider
|
||||
private final Map<Region, HiddenHull> hulls = new ConcurrentHashMap<>();
|
||||
private final Map<Region, HidingRule> hidingRules = new ConcurrentHashMap<>();
|
||||
private final Map<Region, Set<Player>> hidden = new ConcurrentHashMap<>();
|
||||
|
||||
@LinkedInstance
|
||||
public TechHiderCommand techHiderCommand;
|
||||
|
||||
@LinkedInstance
|
||||
public XrayCommand xrayCommand;
|
||||
|
||||
@Register(description = "HULLHIDER_HELP")
|
||||
public void toggleHider(@Validator Player player) {
|
||||
Region region = Region.getRegion(player.getLocation());
|
||||
if (region.getType().isGlobal()) {
|
||||
BauSystem.MESSAGE.send("HULLHIDER_GLOBAL", player);
|
||||
return;
|
||||
}
|
||||
if (!region.getGameModeConfig().Techhider.Active) {
|
||||
return;
|
||||
}
|
||||
|
||||
techHiderCommand.disable(region, player);
|
||||
xrayCommand.disable(region, player);
|
||||
if (hidden.getOrDefault(region, Collections.emptySet()).contains(player)) {
|
||||
disable(region, player);
|
||||
BauSystem.MESSAGE.sendPrefixless("HULLHIDER_OFF", player, ChatMessageType.ACTION_BAR);
|
||||
} else {
|
||||
enable(region, player);
|
||||
BauSystem.MESSAGE.sendPrefixless("HULLHIDER_ON", player, ChatMessageType.ACTION_BAR);
|
||||
}
|
||||
}
|
||||
|
||||
private void enable(Region region, Player player) {
|
||||
if (!hulls.containsKey(region)) {
|
||||
Point min = region.getBuildArea().getMinPoint(true);
|
||||
Point max = region.getBuildArea().getMaxPoint(true);
|
||||
HullRegion hullRegion = HullRegion.fromInclusive(min.getX(), min.getY(), min.getZ(), max.getX(), max.getY(), max.getZ());
|
||||
|
||||
// The techhider of the gamemode is applied as well, its hidden blocks occlude as they are replaced by the obfuscation block
|
||||
ObfuscationConfig obfuscation = ObfuscationConfig.of(region.getGameModeConfig().Techhider);
|
||||
Hull hull = new Hull(BauSystem.getInstance(), world(), hullRegion, false, obfuscation, new Viewers.VisibleByDefault());
|
||||
hullHider.addHull(region, hull);
|
||||
hulls.put(region, new HiddenHull(hull, obfuscation.getObfuscationState()));
|
||||
hidingRules.put(region, HidingRule.of(region.getBuildArea(), obfuscation));
|
||||
}
|
||||
|
||||
hidden.computeIfAbsent(region, rg -> ConcurrentHashMap.newKeySet()).add(player);
|
||||
// Added players see the hull blocks of a hull visible by default
|
||||
hullHider.addViewer(player, region);
|
||||
// Block changes by WorldEdit or Axiom do not update the hull, so it is rebuilt every time somebody enables it.
|
||||
// This also resends the chunks to the player.
|
||||
hullHider.initialize(region);
|
||||
}
|
||||
|
||||
/**
|
||||
* Stops hiding the hull of the region from the player, removing the hull if nobody uses it anymore.
|
||||
*/
|
||||
public void disable(Region region, Player player) {
|
||||
Set<Player> players = hidden.get(region);
|
||||
if (players == null || !players.remove(player)) return;
|
||||
|
||||
if (players.isEmpty()) {
|
||||
hidden.remove(region);
|
||||
hulls.remove(region);
|
||||
hidingRules.remove(region);
|
||||
hullHider.removeHull(region);
|
||||
} else {
|
||||
hullHider.removeViewer(player, region);
|
||||
hullHider.resendChunks(player, region);
|
||||
}
|
||||
}
|
||||
|
||||
public void addHidingRules(Player player, List<HidingRule> rules) {
|
||||
hidden.forEach((region, players) -> {
|
||||
HidingRule rule = hidingRules.get(region);
|
||||
if (rule != null && players.contains(player)) {
|
||||
rules.add(rule);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void addHiddenHulls(Player player, List<HiddenHull> hiddenHulls) {
|
||||
hidden.forEach((region, players) -> {
|
||||
HiddenHull hiddenHull = hulls.get(region);
|
||||
if (hiddenHull != null && players.contains(player)) {
|
||||
hiddenHulls.add(hiddenHull);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@LinkedTimer(delay = 1, period = 1)
|
||||
private void onTick() {
|
||||
if (hidden.isEmpty()) return;
|
||||
|
||||
hullHider.sendUncoveredBlocks();
|
||||
}
|
||||
|
||||
private World world() {
|
||||
return Bukkit.getWorlds().get(0);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
for (Region region : hidden.keySet()) {
|
||||
disable(region, event.getPlayer());
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isActive(Region region, Player player) {
|
||||
return hidden.getOrDefault(region, Collections.emptySet()).contains(player);
|
||||
}
|
||||
}
|
||||
@@ -36,9 +36,11 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -63,13 +65,14 @@ public class Loader implements Listener, SWPlayer.Component {
|
||||
private List<LoaderElement> elements = new ArrayList<>();
|
||||
private int currentElement = 0;
|
||||
private long waitTime = 0;
|
||||
private final BukkitTask task;
|
||||
|
||||
public Loader(Player p) {
|
||||
this.p = p;
|
||||
this.recorder = new LoaderRecorder(p, elements);
|
||||
Bukkit.getPluginManager().registerEvents(this, BauSystem.getInstance());
|
||||
|
||||
BauSystem.runTaskTimer(BauSystem.getInstance(), () -> {
|
||||
task = BauSystem.runTaskTimer(BauSystem.getInstance(), () -> {
|
||||
if (stage != Stage.RUNNING && stage != Stage.SINGLE) return;
|
||||
if (!Permission.BUILD.hasPermission(p)) return;
|
||||
if (waitTime > 0) {
|
||||
@@ -136,13 +139,27 @@ public class Loader implements Listener, SWPlayer.Component {
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
end();
|
||||
if (getLoader(p) == this) {
|
||||
SWPlayer.of(p).removeComponent(Loader.class);
|
||||
}
|
||||
}
|
||||
|
||||
// Also called when the loader is replaced by a new one
|
||||
@Override
|
||||
public void onUnmount(SWPlayer player) {
|
||||
end();
|
||||
}
|
||||
|
||||
private void end() {
|
||||
stage = Stage.END;
|
||||
if (recorder != null) {
|
||||
recorder.stop();
|
||||
recorder = null;
|
||||
}
|
||||
elements.clear();
|
||||
SWPlayer.of(p).removeComponent(Loader.class);
|
||||
task.cancel();
|
||||
HandlerList.unregisterAll(this);
|
||||
}
|
||||
|
||||
public boolean setTicksBetweenShots(int delay) {
|
||||
|
||||
+7
-7
@@ -24,6 +24,7 @@ import de.steamwar.bausystem.Permission;
|
||||
import de.steamwar.bausystem.utils.BauMemberUpdateEvent;
|
||||
import de.steamwar.core.SWPlayer;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.linkage.LinkedTimer;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
@@ -43,13 +44,12 @@ public class ObserverTracerListener implements Listener {
|
||||
|
||||
static Set<Player> enabled = new HashSet<>();
|
||||
|
||||
public ObserverTracerListener() {
|
||||
Bukkit.getScheduler().runTaskTimer(BauSystem.getInstance(), () -> {
|
||||
SWPlayer.allWithSingleComponent(ObserverTracer.class).forEach(pair -> {
|
||||
if (pair.getSwPlayer().getPlayer().getGameMode() != GameMode.SPECTATOR) return;
|
||||
pair.getComponent().show();
|
||||
});
|
||||
}, 15L, 15L);
|
||||
@LinkedTimer(delay = 15, period = 15)
|
||||
private void showTracers() {
|
||||
SWPlayer.allWithSingleComponent(ObserverTracer.class).forEach(pair -> {
|
||||
if (pair.getSwPlayer().getPlayer().getGameMode() != GameMode.SPECTATOR) return;
|
||||
pair.getComponent().show();
|
||||
});
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
||||
+10
-8
@@ -28,6 +28,7 @@ import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.entity.CRay;
|
||||
import de.steamwar.entity.REntityServer;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.linkage.LinkedTimer;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -104,15 +105,16 @@ public class RayVisualizerCommand extends SWCommand implements Listener {
|
||||
|
||||
public RayVisualizerCommand() {
|
||||
super("rayvisualizer");
|
||||
}
|
||||
|
||||
Bukkit.getScheduler().runTaskTimer(BauSystem.getInstance(), () -> {
|
||||
if (server.getPlayers().isEmpty()) return;
|
||||
List<TNTPrimed> primedList = WORLD.getEntitiesByClass(TNTPrimed.class)
|
||||
.stream().toList();
|
||||
rayData.reset();
|
||||
if (primedList.isEmpty()) return;
|
||||
calculateRays(primedList, primedList);
|
||||
}, 1, 1);
|
||||
@LinkedTimer(delay = 1, period = 1)
|
||||
private void updateRays() {
|
||||
if (server.getPlayers().isEmpty()) return;
|
||||
List<TNTPrimed> primedList = WORLD.getEntitiesByClass(TNTPrimed.class)
|
||||
.stream().toList();
|
||||
rayData.reset();
|
||||
if (primedList.isEmpty()) return;
|
||||
calculateRays(primedList, primedList);
|
||||
}
|
||||
|
||||
private void calculateRays(List<TNTPrimed> fromTNTs, List<TNTPrimed> toTNTs) {
|
||||
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2026 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.bausystem.features.region;
|
||||
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.region.RegionUtils;
|
||||
import de.steamwar.bausystem.region.flags.Flag;
|
||||
import de.steamwar.bausystem.region.flags.ProjectileStopperMode;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@Linked
|
||||
public class ProjectileStopperCommand extends SWCommand {
|
||||
|
||||
public ProjectileStopperCommand() {
|
||||
super("projectilestopper");
|
||||
}
|
||||
|
||||
@Register(description = "REGION_PROJECTILE_STOPPER_HELP")
|
||||
public void toggleCommand(@Validator Player p) {
|
||||
Region region = Region.getRegion(p.getLocation());
|
||||
if (region.getRegionData().get(Flag.PROJECTILE_STOPPER).get() == ProjectileStopperMode.ENABLED) {
|
||||
region.getRegionData().set(Flag.PROJECTILE_STOPPER, ProjectileStopperMode.DISABLED);
|
||||
RegionUtils.actionBar(region, "REGION_PROJECTILE_STOPPER_OFF");
|
||||
} else {
|
||||
region.getRegionData().set(Flag.PROJECTILE_STOPPER, ProjectileStopperMode.ENABLED);
|
||||
RegionUtils.actionBar(region, "REGION_PROJECTILE_STOPPER_ON");
|
||||
}
|
||||
}
|
||||
}
|
||||
+88
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2026 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.bausystem.features.region;
|
||||
|
||||
import com.destroystokyo.paper.event.server.ServerTickEndEvent;
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.region.flags.Flag;
|
||||
import de.steamwar.bausystem.region.flags.ProjectileStopperMode;
|
||||
import de.steamwar.bausystem.utils.ScoreboardElement;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntitySpawnEvent;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@Linked
|
||||
public class ProjectileStopperListener implements Listener, ScoreboardElement {
|
||||
private Map<Region, Set<Entity>> projektileList = new HashMap<>();
|
||||
|
||||
@EventHandler
|
||||
public void onTick(ServerTickEndEvent event) {
|
||||
List<Entity> entitiesToAdd = new ArrayList<>();
|
||||
|
||||
projektileList.forEach((region, entities) -> {
|
||||
entities.removeIf(entity -> {
|
||||
if (region != Region.getRegion(entity.getLocation())) {
|
||||
if (region.getRegionData().get(Flag.PROJECTILE_STOPPER).getWithDefault() == ProjectileStopperMode.ENABLED) {
|
||||
entity.remove();
|
||||
} else {
|
||||
entitiesToAdd.add(entity);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
});
|
||||
entitiesToAdd.forEach(this::addEntity);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEntitySpawn(EntitySpawnEvent event) {
|
||||
if (event.getEntityType() != EntityType.WIND_CHARGE && event.getEntityType() != EntityType.ARROW && event.getEntityType() != EntityType.SMALL_FIREBALL) return;
|
||||
addEntity(event.getEntity());
|
||||
}
|
||||
|
||||
private void addEntity(Entity entity) {
|
||||
Region region = Region.getRegion(entity.getLocation());
|
||||
projektileList.computeIfAbsent(region, key -> new HashSet<>()).add(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ScoreboardGroup getGroup() {
|
||||
return ScoreboardGroup.REGION;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int order() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String get(Region region, Player p) {
|
||||
if (region.getRegionData().get(Flag.PROJECTILE_STOPPER).is(ProjectileStopperMode.ENABLED)) return null;
|
||||
return "§e" + BauSystem.MESSAGE.parse(Flag.PROJECTILE_STOPPER.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.getRegionData().get(Flag.PROJECTILE_STOPPER).getWithDefault().getChatValue(), p);
|
||||
}
|
||||
}
|
||||
+2
@@ -28,6 +28,7 @@ import de.steamwar.bausystem.utils.ScoreboardElement;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
@@ -55,6 +56,7 @@ public class ProtectListener implements Listener, ScoreboardElement {
|
||||
|
||||
@EventHandler
|
||||
public void onExplode(EntityExplodeEvent event) {
|
||||
if (event.getEntityType() == EntityType.WIND_CHARGE) return;
|
||||
explode(event.blockList(), event.getLocation());
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ import de.steamwar.bausystem.utils.ScoreboardElement;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@@ -67,6 +68,7 @@ public class TNTListener implements Listener, ScoreboardElement {
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onExplode(EntityExplodeEvent event) {
|
||||
if (event.getEntityType() == EntityType.WIND_CHARGE) return;
|
||||
explode(event.blockList(), event.getEntity() instanceof TNTPrimed);
|
||||
}
|
||||
|
||||
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2026 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.bausystem.features.region;
|
||||
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.region.RegionUtils;
|
||||
import de.steamwar.bausystem.region.flags.Flag;
|
||||
import de.steamwar.bausystem.region.flags.WindChargeInteractMode;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@Linked
|
||||
public class WindChargeInteractModeCommand extends SWCommand {
|
||||
|
||||
public WindChargeInteractModeCommand() {
|
||||
super("windchargeinteract");
|
||||
}
|
||||
|
||||
@Register(description = "REGION_WINDCHARGE_HELP")
|
||||
public void toggleCommand(@Validator Player p) {
|
||||
Region region = Region.getRegion(p.getLocation());
|
||||
if (region.getRegionData().get(Flag.WIND_CHARGE_INTERACT).get() == WindChargeInteractMode.DENY) {
|
||||
region.getRegionData().set(Flag.WIND_CHARGE_INTERACT, WindChargeInteractMode.ALLOW);
|
||||
RegionUtils.actionBar(region, "REGION_WINDCHARGE_INTERACT_ON");
|
||||
} else {
|
||||
region.getRegionData().set(Flag.WIND_CHARGE_INTERACT, WindChargeInteractMode.DENY);
|
||||
RegionUtils.actionBar(region, "REGION_WINDCHARGE_INTERACT_OFF");
|
||||
}
|
||||
}
|
||||
}
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2026 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.bausystem.features.region;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.region.flags.Flag;
|
||||
import de.steamwar.bausystem.region.flags.WindChargeInteractMode;
|
||||
import de.steamwar.bausystem.utils.ScoreboardElement;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
|
||||
@Linked
|
||||
public class WindChargeInteractModeListener implements Listener, ScoreboardElement {
|
||||
|
||||
@EventHandler
|
||||
public void onExplode(EntityExplodeEvent event) {
|
||||
if (event.getEntityType() != EntityType.WIND_CHARGE) return;
|
||||
Region region = Region.getRegion(event.getLocation());
|
||||
if (region.getRegionData().get(Flag.WIND_CHARGE_INTERACT).getWithDefault() != WindChargeInteractMode.ALLOW) event.blockList().clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ScoreboardGroup getGroup() {
|
||||
return ScoreboardGroup.REGION;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int order() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String get(Region region, Player p) {
|
||||
if (region.getRegionData().get(Flag.WIND_CHARGE_INTERACT).is(WindChargeInteractMode.ALLOW)) return null;
|
||||
return "§e" + BauSystem.MESSAGE.parse(Flag.WIND_CHARGE_INTERACT.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.getRegionData().get(Flag.WIND_CHARGE_INTERACT).getWithDefault().getChatValue(), p);
|
||||
}
|
||||
}
|
||||
+7
-7
@@ -27,6 +27,7 @@ import de.steamwar.bausystem.features.script.lua.libs.StorageLib;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.core.SWPlayer;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.linkage.LinkedTimer;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.EntityType;
|
||||
@@ -47,13 +48,12 @@ import org.luaj.vm2.LuaValue;
|
||||
@Linked
|
||||
public class EventListener implements Listener {
|
||||
|
||||
static {
|
||||
Bukkit.getScheduler().runTaskTimer(BauSystem.getInstance(), () -> {
|
||||
long millis = System.currentTimeMillis();
|
||||
SWPlayer.allWithSingleComponent(ScriptRunner.ScriptData.class)
|
||||
.filter(pair -> millis - pair.getComponent().getLastF() > 200)
|
||||
.forEach(pair -> pair.getComponent().setLastF(Long.MAX_VALUE));
|
||||
}, 1, 1);
|
||||
@LinkedTimer(delay = 1, period = 1)
|
||||
private static void resetLastF() {
|
||||
long millis = System.currentTimeMillis();
|
||||
SWPlayer.allWithSingleComponent(ScriptRunner.ScriptData.class)
|
||||
.filter(pair -> millis - pair.getComponent().getLastF() > 200)
|
||||
.forEach(pair -> pair.getComponent().setLastF(Long.MAX_VALUE));
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
|
||||
+5
-6
@@ -44,9 +44,9 @@ import de.steamwar.entity.REntity;
|
||||
import de.steamwar.entity.REntityServer;
|
||||
import de.steamwar.inventory.SWAnvilInv;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.linkage.LinkedTimer;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -136,11 +136,10 @@ public class SimulatorCursor implements Listener {
|
||||
|
||||
private static final Map<Player, Long> LAST_SNEAKS = new HashMap<>();
|
||||
|
||||
static {
|
||||
Bukkit.getScheduler().runTaskTimer(BauSystem.getInstance(), () -> {
|
||||
long millis = System.currentTimeMillis();
|
||||
LAST_SNEAKS.entrySet().removeIf(entry -> millis - entry.getValue() > 200);
|
||||
}, 1, 1);
|
||||
@LinkedTimer(delay = 1, period = 1)
|
||||
private static void clearLastSneaks() {
|
||||
long millis = System.currentTimeMillis();
|
||||
LAST_SNEAKS.entrySet().removeIf(entry -> millis - entry.getValue() > 200);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
|
||||
+94
-234
@@ -19,48 +19,97 @@
|
||||
|
||||
package de.steamwar.bausystem.features.slaves.laufbau;
|
||||
|
||||
import com.sk89q.worldedit.blocks.SkullBlock;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.linkage.api.Enable;
|
||||
import lombok.Getter;
|
||||
import lombok.ToString;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.locale.Language;
|
||||
import net.minecraft.world.level.EmptyBlockGetter;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.data.Bisected;
|
||||
import org.bukkit.Registry;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.block.data.Directional;
|
||||
import org.bukkit.block.data.Waterlogged;
|
||||
import org.bukkit.block.data.type.*;
|
||||
import org.bukkit.block.data.type.Bed;
|
||||
import org.bukkit.block.data.type.Door;
|
||||
import org.bukkit.craftbukkit.block.CraftBlockType;
|
||||
import org.bukkit.craftbukkit.block.data.CraftBlockData;
|
||||
import org.bukkit.craftbukkit.util.CraftVoxelShape;
|
||||
import org.bukkit.util.BoundingBox;
|
||||
import org.bukkit.util.VoxelShape;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.createItem;
|
||||
import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.pixelCuboid;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ToString
|
||||
@Getter
|
||||
public class BlockBoundingBox {
|
||||
|
||||
private static List<String> randomPlayerHead = new ArrayList<>();
|
||||
private static Random random = new Random();
|
||||
@Linked
|
||||
public static class Loader implements Enable {
|
||||
|
||||
static {
|
||||
randomPlayerHead.add("zOnlyKroks");
|
||||
randomPlayerHead.add("YoyoNow");
|
||||
randomPlayerHead.add("Konstruktix");
|
||||
randomPlayerHead.add("Merling03");
|
||||
randomPlayerHead.add("Lord_Loading");
|
||||
/*
|
||||
randomPlayerHead.add(UUID.fromString("1623d4b1-b21c-41d3-93c2-eee2845b8497"));
|
||||
randomPlayerHead.add(UUID.fromString("f75632be-e3ec-4069-9bec-d13ac6891177"));
|
||||
randomPlayerHead.add(UUID.fromString("80382970-424b-4299-9296-d956beab9e7b"));
|
||||
randomPlayerHead.add(UUID.fromString("f395ce89-096d-48e9-b796-a2d88722c22b"));
|
||||
randomPlayerHead.add(UUID.fromString("db516394-d999-4b77-8d13-73cceec77dfe"));
|
||||
*/
|
||||
@Override
|
||||
public void enable() {
|
||||
long time = System.currentTimeMillis();
|
||||
Registry.BLOCK.forEach(blockType -> {
|
||||
Block block = CraftBlockType.bukkitToMinecraftNew(blockType);
|
||||
Material material = blockType.asMaterial();
|
||||
if (!material.isItem()) return;
|
||||
if (!material.isBlock()) return;
|
||||
if (material == Material.WATER) return;
|
||||
if (material.getBlastResistance() <= 0.0) return;
|
||||
if (material.getBlastResistance() > 9.0) return;
|
||||
|
||||
block.getStateDefinition().getPossibleStates().forEach(blockState -> {
|
||||
VoxelShape voxelShape = new CraftVoxelShape(blockState.getCollisionShape(EmptyBlockGetter.INSTANCE, BlockPos.ZERO, CollisionContext.empty()));
|
||||
Collection<BoundingBox> boundingBoxes = voxelShape.getBoundingBoxes();
|
||||
if (boundingBoxes.isEmpty()) return;
|
||||
|
||||
double minX = Double.MAX_VALUE;
|
||||
double minY = Double.MAX_VALUE;
|
||||
double minZ = Double.MAX_VALUE;
|
||||
double maxX = Double.MIN_VALUE;
|
||||
double maxY = Double.MIN_VALUE;
|
||||
double maxZ = Double.MIN_VALUE;
|
||||
for (BoundingBox boundingBox : boundingBoxes) {
|
||||
minX = Math.min(minX, boundingBox.getMinX());
|
||||
minY = Math.min(minY, boundingBox.getMinY());
|
||||
minZ = Math.min(minZ, boundingBox.getMinZ());
|
||||
|
||||
maxX = Math.max(maxX, boundingBox.getMaxX());
|
||||
maxY = Math.max(maxY, boundingBox.getMaxY());
|
||||
maxZ = Math.max(maxZ, boundingBox.getMaxZ());
|
||||
}
|
||||
|
||||
// Ignore Full Blocks
|
||||
if (maxX - minX == 1 && maxY - minY == 1 && maxZ - minZ == 1) return;
|
||||
|
||||
BlockData blockData = CraftBlockData.createData(blockState);
|
||||
if (blockData instanceof Door) return; // Doors dont seem to be 2 blocks tall?
|
||||
if (blockData instanceof Bed) return; // Beds dont seem to be 2 blocks tall?
|
||||
if (blockData instanceof Waterlogged waterlogged && waterlogged.isWaterlogged()) return;
|
||||
|
||||
String key = material.isItem()
|
||||
? material.getItemTranslationKey() // "item.minecraft.diamond" / "block.minecraft.stone"
|
||||
: material.getBlockTranslationKey(); // for block-only materials like WATER
|
||||
|
||||
new BlockBoundingBox(
|
||||
blockData,
|
||||
boundingBoxes.stream().map(Cuboid::new).collect(Collectors.toList()),
|
||||
material,
|
||||
"§f" + Language.getInstance().getOrDefault(key)
|
||||
);
|
||||
});
|
||||
});
|
||||
BauSystem.getInstance().getLogger().info("Laufbau init > " + (System.currentTimeMillis() - time) + "ms " + elements.size() + " blocks");
|
||||
elements.sort(Comparator.<BlockBoundingBox>comparingDouble(value -> value.material.getBlastResistance()).thenComparing(value -> value.name));
|
||||
}
|
||||
}
|
||||
|
||||
public static List<BlockBoundingBox> elements = new ArrayList<>();
|
||||
@@ -68,221 +117,32 @@ public class BlockBoundingBox {
|
||||
public BlockData blockData;
|
||||
public List<Cuboid> cuboidList;
|
||||
private double volume;
|
||||
public SWItem swItem;
|
||||
public Material material;
|
||||
public String name;
|
||||
|
||||
public Consumer<BaseBlock> blockConsumer = null;
|
||||
|
||||
public BlockBoundingBox(BlockData blockData, List<Cuboid> cuboidList, SWItem swItem) {
|
||||
public BlockBoundingBox(BlockData blockData, List<Cuboid> cuboidList, Material material, String name) {
|
||||
this.blockData = blockData;
|
||||
this.cuboidList = cuboidList;
|
||||
this.swItem = swItem;
|
||||
this.material = material;
|
||||
this.name = name;
|
||||
volume = cuboidList.stream().mapToDouble(Cuboid::volume).sum();
|
||||
elements.add(this);
|
||||
}
|
||||
|
||||
public BlockBoundingBox(BlockData blockData, List<Cuboid> cuboidList, SWItem swItem, Consumer<BaseBlock> blockConsumer) {
|
||||
this.blockData = blockData;
|
||||
this.cuboidList = cuboidList;
|
||||
this.swItem = swItem;
|
||||
volume = cuboidList.stream().mapToDouble(Cuboid::volume).sum();
|
||||
// Override/Ignore items with worse/better blast resistance
|
||||
for (int i = 0; i < elements.size(); i++) {
|
||||
BlockBoundingBox other = elements.get(i);
|
||||
if (other.cuboidList.equals(cuboidList)) {
|
||||
if (other.material.getBlastResistance() < material.getBlastResistance()) {
|
||||
elements.remove(i);
|
||||
break;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
elements.add(this);
|
||||
this.blockConsumer = blockConsumer;
|
||||
}
|
||||
|
||||
public double volume() {
|
||||
return volume;
|
||||
}
|
||||
|
||||
static {
|
||||
addPixel(Material.AIR.createBlockData(), 0, 0, 0, 0, 0, 0, null);
|
||||
// addPixel(Material.COBWEB.createBlockData(), 0, 0, 0, 0, 0, 0, createItem("LAUFBAU_BLOCK_COBWEB", Material.COBWEB));
|
||||
addPixel(Material.END_STONE.createBlockData(), 0, 0, 0, 16, 16, 16, null);
|
||||
|
||||
addPixel(Material.DIRT_PATH.createBlockData(), 0, 0, 0, 16, 15, 16, createItem("LAUFBAU_BLOCK_GRASS_PATH", Material.DIRT_PATH));
|
||||
addPixel(Material.MUD.createBlockData(), 0, 0, 0, 16, 14, 16, createItem("LAUFBAU_BLOCK_SOUL_SAND", Material.SOUL_SAND));
|
||||
|
||||
Cocoa cocoaNorth = (Cocoa) Material.COCOA.createBlockData();
|
||||
cocoaNorth.setAge(2);
|
||||
cocoaNorth.setFacing(BlockFace.NORTH);
|
||||
addPixel(cocoaNorth, 4, 3, 1, 8, 9, 8, createItem("LAUFBAU_BLOCK_COCOA", Material.COCOA_BEANS, "LAUFBAU_FACING_NORTH"));
|
||||
|
||||
Cocoa cocoaSouth = (Cocoa) Material.COCOA.createBlockData();
|
||||
cocoaSouth.setAge(2);
|
||||
cocoaSouth.setFacing(BlockFace.SOUTH);
|
||||
addPixel(cocoaSouth, 4, 3, 7, 8, 9, 8, createItem("LAUFBAU_BLOCK_COCOA", Material.COCOA_BEANS, "LAUFBAU_FACING_SOUTH"));
|
||||
|
||||
Cocoa cocoaWest = (Cocoa) Material.COCOA.createBlockData();
|
||||
cocoaWest.setAge(2);
|
||||
cocoaWest.setFacing(BlockFace.WEST);
|
||||
addPixel(cocoaWest, 1, 3, 4, 8, 9, 8, createItem("LAUFBAU_BLOCK_COCOA", Material.COCOA_BEANS, "LAUFBAU_FACING_WEST"));
|
||||
|
||||
Cocoa cocoaEast = (Cocoa) Material.COCOA.createBlockData();
|
||||
cocoaEast.setAge(2);
|
||||
cocoaEast.setFacing(BlockFace.EAST);
|
||||
addPixel(cocoaEast, 7, 3, 4, 8, 9, 8, createItem("LAUFBAU_BLOCK_COCOA", Material.COCOA_BEANS, "LAUFBAU_FACING_EAST"));
|
||||
|
||||
TurtleEgg singleTurtleEgg = (TurtleEgg) Material.TURTLE_EGG.createBlockData();
|
||||
singleTurtleEgg.setEggs(1);
|
||||
singleTurtleEgg.setHatch(0);
|
||||
addPixel(singleTurtleEgg, 4, 0, 3, 9, 7, 9, createItem("LAUFBAU_BLOCK_TURTLE_EGG", Material.TURTLE_EGG, "LAUFBAU_COUNT_1"));
|
||||
|
||||
TurtleEgg doubleTurtleEgg = (TurtleEgg) Material.TURTLE_EGG.createBlockData();
|
||||
doubleTurtleEgg.setEggs(2);
|
||||
doubleTurtleEgg.setHatch(0);
|
||||
addPixel(doubleTurtleEgg, 1, 0, 1, 14, 7, 14, createItem("LAUFBAU_BLOCK_TURTLE_EGG", Material.TURTLE_EGG, "LAUFBAU_COUNT_2"));
|
||||
|
||||
addPixel(Material.CHEST.createBlockData(), 1, 0, 1, 14, 14, 14, createItem("LAUFBAU_BLOCK_CHEST", Material.CHEST));
|
||||
|
||||
Snow snowLayers8 = (Snow) Material.SNOW.createBlockData();
|
||||
snowLayers8.setLayers(8);
|
||||
addPixel(snowLayers8, 0, 0, 0, 16, 14, 16, createItem("LAUFBAU_BLOCK_SNOW", Material.SNOW, "LAUFBAU_LAYERS_8"));
|
||||
|
||||
Directional headNorth = (Directional) Material.PLAYER_WALL_HEAD.createBlockData();
|
||||
headNorth.setFacing(BlockFace.NORTH);
|
||||
addPixel(headNorth, 4, 4, 8, 8, 8, 8, createItem("LAUFBAU_BLOCK_PLAYER_WALL_HEAD", Material.PLAYER_HEAD, "LAUFBAU_FACING_NORTH"), BlockBoundingBox::randomPlayerHead);
|
||||
|
||||
Directional headSouth = (Directional) Material.PLAYER_WALL_HEAD.createBlockData();
|
||||
headSouth.setFacing(BlockFace.SOUTH);
|
||||
addPixel(headSouth, 4, 4, 0, 8, 8, 8, createItem("LAUFBAU_BLOCK_PLAYER_WALL_HEAD", Material.PLAYER_HEAD, "LAUFBAU_FACING_SOUTH"), BlockBoundingBox::randomPlayerHead);
|
||||
|
||||
Directional headWest = (Directional) Material.PLAYER_WALL_HEAD.createBlockData();
|
||||
headWest.setFacing(BlockFace.WEST);
|
||||
addPixel(headWest, 8, 4, 4, 8, 8, 8, createItem("LAUFBAU_BLOCK_PLAYER_WALL_HEAD", Material.PLAYER_HEAD, "LAUFBAU_FACING_WEST"), BlockBoundingBox::randomPlayerHead);
|
||||
|
||||
Directional headEast = (Directional) Material.PLAYER_WALL_HEAD.createBlockData();
|
||||
headEast.setFacing(BlockFace.EAST);
|
||||
addPixel(headEast, 0, 4, 4, 8, 8, 8, createItem("LAUFBAU_BLOCK_PLAYER_WALL_HEAD", Material.PLAYER_HEAD, "LAUFBAU_FACING_EAST"), BlockBoundingBox::randomPlayerHead);
|
||||
|
||||
Snow snowLayers7 = (Snow) Material.SNOW.createBlockData();
|
||||
snowLayers7.setLayers(7);
|
||||
addPixel(snowLayers7, 0, 0, 0, 16, 12, 16, createItem("LAUFBAU_BLOCK_SNOW", Material.SNOW, "LAUFBAU_LAYERS_7"));
|
||||
|
||||
Snow snowLayers6 = (Snow) Material.SNOW.createBlockData();
|
||||
snowLayers6.setLayers(6);
|
||||
addPixel(snowLayers6, 0, 0, 0, 16, 10, 16, createItem("LAUFBAU_BLOCK_SNOW", Material.SNOW, "LAUFBAU_LAYERS_6"));
|
||||
|
||||
addPixel(Material.STONECUTTER.createBlockData(), 0, 0, 0, 16, 9, 16, createItem("LAUFBAU_BLOCK_STONECUTTER", Material.STONECUTTER));
|
||||
|
||||
addPixel(Material.PLAYER_HEAD.createBlockData(), 4, 0, 4, 8, 8, 8, createItem("LAUFBAU_BLOCK_PLAYER_HEAD", Material.PLAYER_HEAD), BlockBoundingBox::randomPlayerHead);
|
||||
|
||||
addPixel(Material.CAKE.createBlockData(), 1, 0, 1, 14, 8, 14, createItem("LAUFBAU_BLOCK_CAKE", Material.CAKE));
|
||||
|
||||
Slab bottomSlab = (Slab) Material.END_STONE_BRICK_SLAB.createBlockData();
|
||||
bottomSlab.setType(Slab.Type.BOTTOM);
|
||||
addPixel(bottomSlab, 0, 0, 0, 16, 8, 16, createItem("LAUFBAU_BLOCK_END_STONE_BRICK_SLAB", Material.END_STONE_BRICK_SLAB, "LAUFBAU_TYPE_BOTTOM"));
|
||||
|
||||
Slab topSlab = (Slab) Material.END_STONE_BRICK_SLAB.createBlockData();
|
||||
topSlab.setType(Slab.Type.TOP);
|
||||
addPixel(topSlab, 0, 8, 0, 16, 8, 16, createItem("LAUFBAU_BLOCK_END_STONE_BRICK_SLAB", Material.END_STONE_BRICK_SLAB, "LAUFBAU_TYPE_TOP"));
|
||||
|
||||
SeaPickle quadSeaPickle = (SeaPickle) Material.SEA_PICKLE.createBlockData();
|
||||
quadSeaPickle.setWaterlogged(false);
|
||||
quadSeaPickle.setPickles(4);
|
||||
addPixel(quadSeaPickle, 2, 0, 2, 12, 7, 12, createItem("LAUFBAU_BLOCK_SEA_PICKLE", Material.SEA_PICKLE, "LAUFBAU_COUNT_4"));
|
||||
|
||||
Campfire campfire = (Campfire) Material.CAMPFIRE.createBlockData();
|
||||
campfire.setSignalFire(false);
|
||||
campfire.setLit(false);
|
||||
addPixel(campfire, 0, 0, 0, 16, 7, 16, createItem("LAUFBAU_BLOCK_CAMPFIRE", Material.CAMPFIRE));
|
||||
|
||||
SeaPickle trippleSeaPickle = (SeaPickle) Material.SEA_PICKLE.createBlockData();
|
||||
trippleSeaPickle.setWaterlogged(false);
|
||||
trippleSeaPickle.setPickles(3);
|
||||
addPixel(trippleSeaPickle, 2, 0, 2, 12, 6, 12, createItem("LAUFBAU_BLOCK_SEA_PICKLE", Material.SEA_PICKLE, "LAUFBAU_COUNT_3"));
|
||||
|
||||
SeaPickle doubleSeaPickle = (SeaPickle) Material.SEA_PICKLE.createBlockData();
|
||||
doubleSeaPickle.setWaterlogged(false);
|
||||
doubleSeaPickle.setPickles(2);
|
||||
addPixel(doubleSeaPickle, 3, 0, 3, 10, 6, 10, createItem("LAUFBAU_BLOCK_SEA_PICKLE", Material.SEA_PICKLE, "LAUFBAU_COUNT_2"));
|
||||
|
||||
SeaPickle singleSeaPickle = (SeaPickle) Material.SEA_PICKLE.createBlockData();
|
||||
singleSeaPickle.setWaterlogged(false);
|
||||
singleSeaPickle.setPickles(1);
|
||||
addPixel(singleSeaPickle, 6, 0, 6, 4, 6, 4, createItem("LAUFBAU_BLOCK_SEA_PICKLE", Material.SEA_PICKLE, "LAUFBAU_COUNT_1"));
|
||||
|
||||
addPixel(Material.FLOWER_POT.createBlockData(), 5, 0, 5, 6, 6, 6, createItem("LAUFBAU_BLOCK_FLOWER_POT", Material.FLOWER_POT));
|
||||
|
||||
Snow snowLayers3 = (Snow) Material.SNOW.createBlockData();
|
||||
snowLayers3.setLayers(3);
|
||||
addPixel(snowLayers3, 0, 0, 0, 16, 4, 16, createItem("LAUFBAU_BLOCK_SNOW", Material.SNOW, "LAUFBAU_LAYERS_3"));
|
||||
|
||||
TrapDoor bottomTrapDoor = (TrapDoor) Material.IRON_TRAPDOOR.createBlockData();
|
||||
bottomTrapDoor.setHalf(Bisected.Half.BOTTOM);
|
||||
addPixel(bottomTrapDoor, 0, 0, 0, 16, 3, 16, createItem("LAUFBAU_BLOCK_IRON_TRAPDOOR", Material.IRON_TRAPDOOR, "LAUFBAU_HALF_BOTTOM"));
|
||||
|
||||
TrapDoor topTrapDoor = (TrapDoor) Material.IRON_TRAPDOOR.createBlockData();
|
||||
topTrapDoor.setHalf(Bisected.Half.TOP);
|
||||
addPixel(topTrapDoor, 0, 13, 0, 16, 3, 16, createItem("LAUFBAU_BLOCK_IRON_TRAPDOOR", Material.IRON_TRAPDOOR, "LAUFBAU_HALF_TOP"));
|
||||
|
||||
Snow snowLayers2 = (Snow) Material.SNOW.createBlockData();
|
||||
snowLayers2.setLayers(2);
|
||||
addPixel(snowLayers2, 0, 0, 0, 16, 2, 16, createItem("LAUFBAU_BLOCK_SNOW", Material.SNOW, "LAUFBAU_LAYERS_2"));
|
||||
|
||||
addPixel(Material.LILY_PAD.createBlockData(), 1, 0, 1, 14, 1.5, 14, createItem("LAUFBAU_BLOCK_LILY_PAD", Material.LILY_PAD));
|
||||
addPixel(Material.WHITE_CARPET.createBlockData(), 0, 0, 0, 16, 1, 16, createItem("LAUFBAU_BLOCK_WHITE_CARPET", Material.WHITE_CARPET));
|
||||
|
||||
Directional endRodBottomTop = (Directional) Material.END_ROD.createBlockData();
|
||||
endRodBottomTop.setFacing(BlockFace.UP);
|
||||
addPixel(endRodBottomTop, 6, 0, 6, 4, 16, 4, createItem("LAUFBAU_BLOCK_END_ROD", Material.END_ROD, "LAUFBAU_FACING_UP", "LAUFBAU_FACING_DOWN"));
|
||||
|
||||
Directional endRodNorthSouth = (Directional) Material.END_ROD.createBlockData();
|
||||
endRodNorthSouth.setFacing(BlockFace.NORTH);
|
||||
addPixel(endRodNorthSouth, 6, 6, 0, 4, 4, 16, createItem("LAUFBAU_BLOCK_END_ROD", Material.END_ROD, "LAUFBAU_FACING_NORTH", "LAUFBAU_FACING_SOUTH"));
|
||||
|
||||
Directional endRodEastWest = (Directional) Material.END_ROD.createBlockData();
|
||||
endRodEastWest.setFacing(BlockFace.EAST);
|
||||
addPixel(endRodEastWest, 0, 6, 6, 16, 4, 4, createItem("LAUFBAU_BLOCK_END_ROD", Material.END_ROD, "LAUFBAU_FACING_EAST", "LAUFBAU_FACING_WEST"));
|
||||
|
||||
Directional lightningRodBottomTop = (Directional) Material.LIGHTNING_ROD.createBlockData();
|
||||
lightningRodBottomTop.setFacing(BlockFace.UP);
|
||||
addPixel(lightningRodBottomTop, 6, 0, 6, 4, 16, 4, createItem("LAUFBAU_BLOCK_LIGHTNING_ROD", Material.LIGHTNING_ROD, "LAUFBAU_FACING_UP", "LAUFBAU_FACING_DOWN"));
|
||||
|
||||
Directional lightningRodNorthSouth = (Directional) Material.LIGHTNING_ROD.createBlockData();
|
||||
lightningRodNorthSouth.setFacing(BlockFace.NORTH);
|
||||
addPixel(lightningRodNorthSouth, 6, 6, 0, 4, 4, 16, createItem("LAUFBAU_BLOCK_LIGHTNING_ROD", Material.LIGHTNING_ROD, "LAUFBAU_FACING_NORTH", "LAUFBAU_FACING_SOUTH"));
|
||||
|
||||
Directional lightningRodEastWest = (Directional) Material.LIGHTNING_ROD.createBlockData();
|
||||
lightningRodEastWest.setFacing(BlockFace.EAST);
|
||||
addPixel(lightningRodEastWest, 0, 6, 6, 16, 4, 4, createItem("LAUFBAU_BLOCK_LIGHTNING_ROD", Material.LIGHTNING_ROD, "LAUFBAU_FACING_EAST", "LAUFBAU_FACING_WEST"));
|
||||
|
||||
Waterlogged conduit = (Waterlogged) Material.CONDUIT.createBlockData();
|
||||
conduit.setWaterlogged(false);
|
||||
addPixel(conduit, 5, 5, 5, 6, 6, 6, createItem("LAUFBAU_BLOCK_CONDUIT", Material.CONDUIT));
|
||||
|
||||
TrapDoor northTrapDoor = (TrapDoor) Material.IRON_TRAPDOOR.createBlockData();
|
||||
northTrapDoor.setFacing(BlockFace.NORTH);
|
||||
northTrapDoor.setOpen(true);
|
||||
addPixel(northTrapDoor, 0, 0, 13, 16, 16, 3, createItem("LAUFBAU_BLOCK_IRON_TRAPDOOR", Material.IRON_TRAPDOOR, "LAUFBAU_FACING_NORTH", "LAUFBAU_OPEN"));
|
||||
|
||||
TrapDoor southTrapDoor = (TrapDoor) Material.IRON_TRAPDOOR.createBlockData();
|
||||
southTrapDoor.setFacing(BlockFace.SOUTH);
|
||||
southTrapDoor.setOpen(true);
|
||||
addPixel(southTrapDoor, 0, 0, 0, 16, 16, 3, createItem("LAUFBAU_BLOCK_IRON_TRAPDOOR", Material.IRON_TRAPDOOR, "LAUFBAU_FACING_SOUTH", "LAUFBAU_OPEN"));
|
||||
|
||||
TrapDoor westTrapDoor = (TrapDoor) Material.IRON_TRAPDOOR.createBlockData();
|
||||
westTrapDoor.setFacing(BlockFace.WEST);
|
||||
westTrapDoor.setOpen(true);
|
||||
addPixel(westTrapDoor, 13, 0, 0, 3, 16, 16, createItem("LAUFBAU_BLOCK_IRON_TRAPDOOR", Material.IRON_TRAPDOOR, "LAUFBAU_FACING_WEST", "LAUFBAU_OPEN"));
|
||||
|
||||
TrapDoor eastTrapDoor = (TrapDoor) Material.IRON_TRAPDOOR.createBlockData();
|
||||
eastTrapDoor.setFacing(BlockFace.EAST);
|
||||
eastTrapDoor.setOpen(true);
|
||||
addPixel(eastTrapDoor, 0, 0, 0, 3, 16, 16, createItem("LAUFBAU_BLOCK_IRON_TRAPDOOR", Material.IRON_TRAPDOOR, "LAUFBAU_FACING_EAST", "LAUFBAU_OPEN"));
|
||||
}
|
||||
|
||||
private static void addPixel(BlockData blockData, double xPixel, double yPixel, double zPixel, double dxPixel, double dyPixel, double dzPixel, SWItem swItem) {
|
||||
new BlockBoundingBox(blockData, Arrays.asList(pixelCuboid(xPixel, yPixel, zPixel, dxPixel, dyPixel, dzPixel)), swItem);
|
||||
}
|
||||
|
||||
private static void addPixel(BlockData blockData, double xPixel, double yPixel, double zPixel, double dxPixel, double dyPixel, double dzPixel, SWItem swItem, Consumer<BaseBlock> blockConsumer) {
|
||||
new BlockBoundingBox(blockData, Arrays.asList(pixelCuboid(xPixel, yPixel, zPixel, dxPixel, dyPixel, dzPixel)), swItem, blockConsumer);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private static void randomPlayerHead(BaseBlock block) {
|
||||
if (block instanceof SkullBlock) {
|
||||
SkullBlock skullBlock = (SkullBlock) block;
|
||||
skullBlock.setOwner(randomPlayerHead.get(random.nextInt(randomPlayerHead.size())).toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+10
@@ -22,6 +22,7 @@ package de.steamwar.bausystem.features.slaves.laufbau;
|
||||
import de.steamwar.bausystem.region.Point;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import org.bukkit.util.BoundingBox;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@@ -33,6 +34,15 @@ public class Cuboid {
|
||||
private double dy;
|
||||
private double dz;
|
||||
|
||||
public Cuboid(BoundingBox boundingBox) {
|
||||
this.x = boundingBox.getMinX();
|
||||
this.y = boundingBox.getMinY();
|
||||
this.z = boundingBox.getMinZ();
|
||||
this.dx = boundingBox.getWidthX();
|
||||
this.dy = boundingBox.getHeight();
|
||||
this.dz = boundingBox.getWidthZ();
|
||||
}
|
||||
|
||||
public boolean intersects(Cuboid cuboid) {
|
||||
double minx = x - cuboid.dx;
|
||||
double miny = y - cuboid.dy;
|
||||
|
||||
+9
-32
@@ -29,11 +29,15 @@ import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class Laufbau {
|
||||
|
||||
private static final Comparator<BlockBoundingBox> BLAST_RESISTANCE = Comparator.comparingDouble(value -> -value.material.getBlastResistance());
|
||||
private static final Comparator<BlockBoundingBox> VOLUME = Comparator.comparingDouble(value -> -value.volume());
|
||||
|
||||
private World world;
|
||||
private Location pos1;
|
||||
private Location pos2;
|
||||
@@ -61,26 +65,10 @@ public class Laufbau {
|
||||
editSession = WorldEditUtils.getEditSession(player);
|
||||
|
||||
elements = BlockBoundingBox.elements.stream().filter(blockBoundingBox -> {
|
||||
return !LaufbauUtils.isDeactivated(player, blockBoundingBox);
|
||||
return !LaufbauConfig.STORE.get(player).getDeactivated().contains(blockBoundingBox.getMaterial());
|
||||
}).collect(Collectors.toList());
|
||||
if (preferingBlastResistance) {
|
||||
elements.sort((o1, o2) -> {
|
||||
int compared = Double.compare(o1.blockData.getMaterial().getBlastResistance(), o2.blockData.getMaterial().getBlastResistance());
|
||||
if (compared != 0) {
|
||||
return -compared;
|
||||
}
|
||||
return -Double.compare(o1.volume(), o2.volume());
|
||||
});
|
||||
} else {
|
||||
elements.sort((o1, o2) -> {
|
||||
int compared = Double.compare(o1.volume(), o2.volume());
|
||||
if (compared != 0) {
|
||||
return -compared;
|
||||
}
|
||||
return -Double.compare(o1.blockData.getMaterial().getBlastResistance(), o2.blockData.getMaterial().getBlastResistance());
|
||||
});
|
||||
}
|
||||
|
||||
elements.sort(preferingBlastResistance ? BLAST_RESISTANCE.thenComparing(VOLUME) : VOLUME.thenComparing(BLAST_RESISTANCE));
|
||||
active = new ProcessingTracesState(world, this::inRegion, editSession, elements, factor);
|
||||
}
|
||||
|
||||
@@ -107,19 +95,8 @@ public class Laufbau {
|
||||
}
|
||||
|
||||
private boolean inRegion(Vector location, int expansion) {
|
||||
if (location.getBlockX() >= pos1.getBlockX() - expansion) {
|
||||
if (location.getBlockY() >= pos1.getBlockY() - expansion) {
|
||||
if (location.getBlockZ() >= pos1.getBlockZ() - expansion) {
|
||||
if (location.getBlockX() <= pos2.getBlockX() + expansion) {
|
||||
if (location.getBlockY() <= pos2.getBlockY() + expansion) {
|
||||
if (location.getBlockZ() <= pos2.getBlockZ() + expansion) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return location.getBlockX() >= pos1.getBlockX() - expansion && location.getBlockX() <= pos2.getBlockX() + expansion
|
||||
&& location.getBlockY() >= pos1.getBlockY() - expansion && location.getBlockY() <= pos2.getBlockY() + expansion
|
||||
&& location.getBlockZ() >= pos1.getBlockZ() - expansion && location.getBlockZ() <= pos2.getBlockZ() + expansion;
|
||||
}
|
||||
}
|
||||
|
||||
+4
-9
@@ -21,10 +21,10 @@ package de.steamwar.bausystem.features.slaves.laufbau;
|
||||
|
||||
import de.steamwar.bausystem.config.ConfigStore;
|
||||
import de.steamwar.bausystem.config.VersionedConfig;
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.converter.LaufbauConfigV1ToV2Converter;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.bukkit.Material;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
@@ -43,14 +43,9 @@ import java.util.Set;
|
||||
@Setter
|
||||
public class LaufbauConfig implements VersionedConfig {
|
||||
|
||||
public static final int VERSION = 2;
|
||||
public static final int VERSION = 3;
|
||||
|
||||
/**
|
||||
* LaufbauConfigV1 is stored as Base64 of gzipped YAPION, the current version as JSON
|
||||
*/
|
||||
public static final ConfigStore<LaufbauConfig> STORE = new ConfigStore<>(LaufbauConfig.class, VERSION, LaufbauConfig::new)
|
||||
.legacy(s -> !s.startsWith("{"), LaufbauConfigV1::parse)
|
||||
.converter(new LaufbauConfigV1ToV2Converter())
|
||||
.userConfig("bausystem-laufbau")
|
||||
.removeIf(config -> config.getDeactivated().isEmpty());
|
||||
|
||||
@@ -58,7 +53,7 @@ public class LaufbauConfig implements VersionedConfig {
|
||||
protected int version = VERSION;
|
||||
|
||||
/**
|
||||
* Identifiers of the deactivated {@link BlockBoundingBox}es, see {@link LaufbauUtils#identifier(BlockBoundingBox)}
|
||||
* Materials of the deactivated {@link BlockBoundingBox}es
|
||||
*/
|
||||
protected Set<String> deactivated = new HashSet<>();
|
||||
protected Set<Material> deactivated = new HashSet<>();
|
||||
}
|
||||
|
||||
-65
@@ -1,65 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2026 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.bausystem.features.slaves.laufbau;
|
||||
|
||||
import de.steamwar.bausystem.config.VersionedConfig;
|
||||
import de.steamwar.bausystem.config.legacy.YapionReader;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.UncheckedIOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Base64;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
|
||||
/**
|
||||
* The legacy laufbau config that was stored as Base64 of the gzipped YAPION,
|
||||
* an object with the deactivated identifiers as keys.
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@Deprecated
|
||||
public class LaufbauConfigV1 implements VersionedConfig {
|
||||
|
||||
public static final int VERSION = 1;
|
||||
|
||||
@Setter(AccessLevel.NONE)
|
||||
protected int version = VERSION;
|
||||
|
||||
protected Set<String> deactivated = new HashSet<>();
|
||||
|
||||
public static LaufbauConfigV1 parse(String base64) {
|
||||
String yapion;
|
||||
try (InputStream inputStream = new GZIPInputStream(new ByteArrayInputStream(Base64.getDecoder().decode(base64)))) {
|
||||
yapion = new String(inputStream.readAllBytes(), StandardCharsets.UTF_8);
|
||||
} catch (IOException e) {
|
||||
throw new UncheckedIOException(e);
|
||||
}
|
||||
LaufbauConfigV1 config = new LaufbauConfigV1();
|
||||
config.deactivated.addAll(YapionReader.parse(yapion).keySet());
|
||||
return config;
|
||||
}
|
||||
}
|
||||
+23
-87
@@ -21,7 +21,6 @@ package de.steamwar.bausystem.features.slaves.laufbau;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.shared.Pair;
|
||||
import de.steamwar.data.CMDs;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import de.steamwar.inventory.SWListInv;
|
||||
import org.bukkit.Material;
|
||||
@@ -32,13 +31,11 @@ import java.util.*;
|
||||
|
||||
public class LaufbauSettings {
|
||||
|
||||
private static Map<Pair<Material, String>, List<BlockBoundingBox>> groupMap = new LinkedHashMap<>();
|
||||
private static Set<Pair<Material, String>> groups = new LinkedHashSet<>();
|
||||
|
||||
static {
|
||||
BlockBoundingBox.elements.forEach(blockBoundingBox -> {
|
||||
if (blockBoundingBox.getSwItem() == null) return;
|
||||
String displayName = blockBoundingBox.getSwItem().getItemMeta().getDisplayName();
|
||||
groupMap.computeIfAbsent(new Pair<>(blockBoundingBox.getSwItem().getItemStack().getType(), displayName), k -> new ArrayList<>()).add(blockBoundingBox);
|
||||
groups.add(new Pair<>(blockBoundingBox.getMaterial(), blockBoundingBox.getName()));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -50,96 +47,35 @@ public class LaufbauSettings {
|
||||
}
|
||||
|
||||
public void open() {
|
||||
List<SWListInv.SWListEntry<Map.Entry<Pair<Material, String>, List<BlockBoundingBox>>>> list = new ArrayList<>();
|
||||
for (Map.Entry<Pair<Material, String>, List<BlockBoundingBox>> entry : groupMap.entrySet()) {
|
||||
SWItem swItem = createItem(entry.getKey().getKey(), entry.getKey().getValue(), entry.getValue());
|
||||
list.add(new SWListInv.SWListEntry<>(swItem, entry));
|
||||
List<SWListInv.SWListEntry<Pair<Material, String>>> list = new ArrayList<>();
|
||||
for (Pair<Material, String> group : groups) {
|
||||
list.add(new SWListInv.SWListEntry<>(createItem(group.getKey(), group.getValue()), group));
|
||||
}
|
||||
SWListInv<Map.Entry<Pair<Material, String>, List<BlockBoundingBox>>> inv = new SWListInv<>(p, BauSystem.MESSAGE.parse("LAUFBAU_SETTINGS_GUI_NAME", p), false, list, (clickType, entry) -> {
|
||||
if (entry.getValue().size() == 1) {
|
||||
LaufbauUtils.toggle(p, entry.getValue().get(0));
|
||||
open();
|
||||
return;
|
||||
}
|
||||
if (clickType.isLeftClick()) {
|
||||
open(entry.getKey());
|
||||
return;
|
||||
}
|
||||
toggle(entry.getValue());
|
||||
SWListInv<Pair<Material, String>> inv = new SWListInv<>(p, BauSystem.MESSAGE.parse("LAUFBAU_SETTINGS_GUI_NAME", p), false, list, (clickType, group) -> {
|
||||
toggle(group.getKey());
|
||||
open();
|
||||
});
|
||||
inv.open();
|
||||
}
|
||||
|
||||
public void open(Pair<Material, String> key) {
|
||||
List<BlockBoundingBox> blockBoundingBoxes = groupMap.get(key);
|
||||
List<SWListInv.SWListEntry<BlockBoundingBox>> list = new ArrayList<>();
|
||||
for (BlockBoundingBox bb : blockBoundingBoxes) {
|
||||
SWItem swItem = LaufbauUtils.translateItem(bb.getSwItem(), p);
|
||||
ItemMeta itemMeta = swItem.getItemMeta();
|
||||
List<String> lore = new ArrayList<>();
|
||||
if (itemMeta.getLore() != null) {
|
||||
lore = itemMeta.getLore();
|
||||
}
|
||||
lore.add("");
|
||||
lore.add(BauSystem.MESSAGE.parse(LaufbauUtils.isDeactivated(p, bb) ? "LAUFBAU_SETTINGS_INACTIVE" : "LAUFBAU_SETTINGS_ACTIVE", p));
|
||||
itemMeta.setLore(lore);
|
||||
swItem.setItemMeta(itemMeta);
|
||||
list.add(new SWListInv.SWListEntry<>(swItem, bb));
|
||||
public SWItem createItem(Material material, String name) {
|
||||
SWItem swItem = new SWItem(material, name);
|
||||
ItemMeta itemMeta = swItem.getItemMeta();
|
||||
List<String> lore = new ArrayList<>();
|
||||
if (itemMeta != null && itemMeta.getLore() != null) {
|
||||
lore = itemMeta.getLore();
|
||||
}
|
||||
SWListInv<BlockBoundingBox> inv = new SWListInv<>(p, BauSystem.MESSAGE.parse("LAUFBAU_SETTINGS_GUI_NAME", p), false, list, (clickType, blockBoundingBox) -> {
|
||||
LaufbauUtils.toggle(p, blockBoundingBox);
|
||||
open(key);
|
||||
});
|
||||
inv.setItem(49, new SWItem(Material.ARROW, BauSystem.MESSAGE.parse("LAUFBAU_SETTINGS_GUI_BACK", p), clickType -> {
|
||||
open();
|
||||
}).setCustomModelData(CMDs.BACK));
|
||||
inv.open();
|
||||
lore.add("");
|
||||
lore.add(BauSystem.MESSAGE.parse(LaufbauConfig.STORE.get(p).getDeactivated().contains(material) ? "LAUFBAU_SETTINGS_INACTIVE" : "LAUFBAU_SETTINGS_ACTIVE", p));
|
||||
lore.add("");
|
||||
lore.add(BauSystem.MESSAGE.parse("LAUFBAU_SETTINGS_TOGGLE", p));
|
||||
if (itemMeta != null) itemMeta.setLore(lore);
|
||||
swItem.setItemMeta(itemMeta);
|
||||
return swItem;
|
||||
}
|
||||
|
||||
public SWItem createItem(Material material, String group, List<BlockBoundingBox> blockBoundingBoxes) {
|
||||
if (blockBoundingBoxes.size() == 1) {
|
||||
BlockBoundingBox bb = blockBoundingBoxes.get(0);
|
||||
SWItem swItem = LaufbauUtils.translateItem(bb.getSwItem(), p);
|
||||
ItemMeta itemMeta = swItem.getItemMeta();
|
||||
List<String> lore = new ArrayList<>();
|
||||
if (itemMeta.getLore() != null) {
|
||||
lore = itemMeta.getLore();
|
||||
}
|
||||
lore.add("");
|
||||
lore.add(BauSystem.MESSAGE.parse(LaufbauUtils.isDeactivated(p, bb) ? "LAUFBAU_SETTINGS_INACTIVE" : "LAUFBAU_SETTINGS_ACTIVE", p));
|
||||
lore.add("");
|
||||
lore.add(BauSystem.MESSAGE.parse("LAUFBAU_SETTINGS_TOGGLE", p));
|
||||
itemMeta.setLore(lore);
|
||||
swItem.setItemMeta(itemMeta);
|
||||
return swItem;
|
||||
} else {
|
||||
long count = blockBoundingBoxes.stream().filter(bb -> LaufbauUtils.isDeactivated(p, bb)).count();
|
||||
if (count == 0) {
|
||||
return new SWItem(material, BauSystem.MESSAGE.parse(group, p), Arrays.asList("", BauSystem.MESSAGE.parse("LAUFBAU_SETTINGS_ACTIVE", p), "", BauSystem.MESSAGE.parse("LAUFBAU_SETTINGS_ADVANCED", p), BauSystem.MESSAGE.parse("LAUFBAU_SETTINGS_TOGGLE", p)), false, clickType -> {
|
||||
});
|
||||
}
|
||||
if (count == blockBoundingBoxes.size()) {
|
||||
return new SWItem(material, BauSystem.MESSAGE.parse(group, p), Arrays.asList("", BauSystem.MESSAGE.parse("LAUFBAU_SETTINGS_INACTIVE", p), "", BauSystem.MESSAGE.parse("LAUFBAU_SETTINGS_ADVANCED", p), BauSystem.MESSAGE.parse("LAUFBAU_SETTINGS_TOGGLE", p)), false, clickType -> {
|
||||
});
|
||||
}
|
||||
return new SWItem(material, BauSystem.MESSAGE.parse(group, p), Arrays.asList("", BauSystem.MESSAGE.parse("LAUFBAU_SETTINGS_MIXED", p, blockBoundingBoxes.size() - count, blockBoundingBoxes.size()), "", BauSystem.MESSAGE.parse("LAUFBAU_SETTINGS_ADVANCED", p), BauSystem.MESSAGE.parse("LAUFBAU_SETTINGS_TOGGLE", p)), false, clickType -> {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public void toggle(List<BlockBoundingBox> blockBoundingBoxes) {
|
||||
long count = blockBoundingBoxes.stream().filter(bb -> LaufbauUtils.isDeactivated(p, bb)).count();
|
||||
if (count != blockBoundingBoxes.size()) {
|
||||
blockBoundingBoxes.forEach(bb -> {
|
||||
if (!LaufbauUtils.isDeactivated(p, bb)) {
|
||||
LaufbauUtils.toggle(p, bb);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
blockBoundingBoxes.forEach(bb -> {
|
||||
LaufbauUtils.toggle(p, bb);
|
||||
});
|
||||
}
|
||||
public void toggle(Material material) {
|
||||
Set<Material> deactivated = LaufbauConfig.STORE.get(p).getDeactivated();
|
||||
if (!deactivated.remove(material)) deactivated.add(material);
|
||||
}
|
||||
}
|
||||
|
||||
-99
@@ -1,99 +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.bausystem.features.slaves.laufbau;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.experimental.UtilityClass;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@UtilityClass
|
||||
public class LaufbauUtils {
|
||||
|
||||
public static Cuboid pixelCuboid(double pixelX, double pixelY, double pixelZ, double pixelDX, double pixelDY, double pixelDZ) {
|
||||
return new Cuboid(pixelToBlock(pixelX), pixelToBlock(pixelY), pixelToBlock(pixelZ), pixelToBlock(pixelDX), pixelToBlock(pixelDY), pixelToBlock(pixelDZ));
|
||||
}
|
||||
|
||||
public static double pixelToBlock(double pixel) {
|
||||
return 1.0 / 16 * pixel;
|
||||
}
|
||||
|
||||
public static SWItem createItem(String name, Material material, String... lore) {
|
||||
return new SWItem(material, name, Arrays.asList(lore), false, clickType -> {
|
||||
});
|
||||
}
|
||||
|
||||
public static SWItem translateItem(SWItem item, Player p) {
|
||||
ItemMeta itemMeta = item.getItemMeta();
|
||||
List<String> lore = new ArrayList<>();
|
||||
if (itemMeta.getLore() != null) {
|
||||
lore = itemMeta.getLore().stream().map(s -> BauSystem.MESSAGE.parse(s, p)).collect(Collectors.toList());
|
||||
}
|
||||
return new SWItem(item.getItemStack().getType(), BauSystem.MESSAGE.parse(itemMeta.getDisplayName(), p), lore, false, clickType -> {
|
||||
});
|
||||
}
|
||||
|
||||
public static String identifier(BlockBoundingBox bb) {
|
||||
if (bb.getSwItem() == null) {
|
||||
return null;
|
||||
}
|
||||
SWItem item = bb.getSwItem();
|
||||
ItemMeta itemMeta = item.getItemMeta();
|
||||
List<String> lore = new ArrayList<>();
|
||||
if (itemMeta.getLore() != null) {
|
||||
lore = itemMeta.getLore()
|
||||
.stream()
|
||||
.map(s -> s.substring(8))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
String name = itemMeta.getDisplayName().substring(14);
|
||||
return name + "[" + String.join(",", lore) + "]";
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
public static boolean isDeactivated(Player p, BlockBoundingBox bb) {
|
||||
if (bb.getSwItem() == null) {
|
||||
return false;
|
||||
}
|
||||
String identifier = identifier(bb);
|
||||
return LaufbauConfig.STORE.get(p).getDeactivated().contains(identifier);
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
public static void toggle(Player p, BlockBoundingBox bb) {
|
||||
if (bb.getSwItem() == null) {
|
||||
return;
|
||||
}
|
||||
String identifier = identifier(bb);
|
||||
Set<String> deactivated = LaufbauConfig.STORE.get(p).getDeactivated();
|
||||
if (!deactivated.remove(identifier)) {
|
||||
deactivated.add(identifier);
|
||||
}
|
||||
}
|
||||
}
|
||||
-261
@@ -1,261 +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.bausystem.features.slaves.laufbau.boundingboxes;
|
||||
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.BlockBoundingBox;
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.BoundingBoxLoader;
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.Cuboid;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.data.type.AmethystCluster;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.createItem;
|
||||
import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.pixelCuboid;
|
||||
|
||||
@Linked
|
||||
public class AmethystBoundingBox implements BoundingBoxLoader {
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
floorSmallAmethystBud();
|
||||
ceilingSmallAmethystBud();
|
||||
northSmallAmethystBud();
|
||||
southSmallAmethystBud();
|
||||
eastSmallAmethystBud();
|
||||
westSmallAmethystBud();
|
||||
|
||||
floorMediumAmethystBud();
|
||||
ceilingMediumAmethystBud();
|
||||
northMediumAmethystBud();
|
||||
southMediumAmethystBud();
|
||||
eastMediumAmethystBud();
|
||||
westMediumAmethystBud();
|
||||
|
||||
floorLargeAmethystBud();
|
||||
ceilingLargeAmethystBud();
|
||||
northLargeAmethystBud();
|
||||
southLargeAmethystBud();
|
||||
eastLargeAmethystBud();
|
||||
westLargeAmethystBud();
|
||||
|
||||
floorAmethystCluster();
|
||||
ceilingAmethystCluster();
|
||||
northAmethystCluster();
|
||||
southAmethystCluster();
|
||||
eastAmethystCluster();
|
||||
westAmethystCluster();
|
||||
}
|
||||
|
||||
private void floorSmallAmethystBud() {
|
||||
AmethystCluster cluster = (AmethystCluster) Material.SMALL_AMETHYST_BUD.createBlockData();
|
||||
cluster.setFacing(BlockFace.UP);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(4, 0, 4, 8, 3, 8));
|
||||
new BlockBoundingBox(cluster, cuboidList, createItem("LAUFBAU_BLOCK_SMALL_AMETHYST_BUD", Material.SMALL_AMETHYST_BUD, "LAUFBAU_FACING_UP"));
|
||||
}
|
||||
|
||||
private void ceilingSmallAmethystBud() {
|
||||
AmethystCluster cluster = (AmethystCluster) Material.SMALL_AMETHYST_BUD.createBlockData();
|
||||
cluster.setFacing(BlockFace.DOWN);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(4, 13, 4, 8, 3, 8));
|
||||
new BlockBoundingBox(cluster, cuboidList, createItem("LAUFBAU_BLOCK_SMALL_AMETHYST_BUD", Material.SMALL_AMETHYST_BUD, "LAUFBAU_FACING_DOWN"));
|
||||
}
|
||||
|
||||
private void northSmallAmethystBud() {
|
||||
AmethystCluster cluster = (AmethystCluster) Material.SMALL_AMETHYST_BUD.createBlockData();
|
||||
cluster.setFacing(BlockFace.NORTH);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(4, 4, 13, 8, 8, 3));
|
||||
new BlockBoundingBox(cluster, cuboidList, createItem("LAUFBAU_BLOCK_SMALL_AMETHYST_BUD", Material.SMALL_AMETHYST_BUD, "LAUFBAU_FACING_NORTH"));
|
||||
}
|
||||
|
||||
private void southSmallAmethystBud() {
|
||||
AmethystCluster cluster = (AmethystCluster) Material.SMALL_AMETHYST_BUD.createBlockData();
|
||||
cluster.setFacing(BlockFace.SOUTH);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(4, 4, 0, 8, 8, 3));
|
||||
new BlockBoundingBox(cluster, cuboidList, createItem("LAUFBAU_BLOCK_SMALL_AMETHYST_BUD", Material.SMALL_AMETHYST_BUD, "LAUFBAU_FACING_SOUTH"));
|
||||
}
|
||||
|
||||
private void eastSmallAmethystBud() {
|
||||
AmethystCluster cluster = (AmethystCluster) Material.SMALL_AMETHYST_BUD.createBlockData();
|
||||
cluster.setFacing(BlockFace.EAST);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(0, 4, 4, 3, 8, 8));
|
||||
new BlockBoundingBox(cluster, cuboidList, createItem("LAUFBAU_BLOCK_SMALL_AMETHYST_BUD", Material.SMALL_AMETHYST_BUD, "LAUFBAU_FACING_EAST"));
|
||||
}
|
||||
|
||||
private void westSmallAmethystBud() {
|
||||
AmethystCluster cluster = (AmethystCluster) Material.SMALL_AMETHYST_BUD.createBlockData();
|
||||
cluster.setFacing(BlockFace.WEST);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(13, 4, 4, 3, 8, 8));
|
||||
new BlockBoundingBox(cluster, cuboidList, createItem("LAUFBAU_BLOCK_SMALL_AMETHYST_BUD", Material.SMALL_AMETHYST_BUD, "LAUFBAU_FACING_WEST"));
|
||||
}
|
||||
|
||||
private void floorMediumAmethystBud() {
|
||||
AmethystCluster cluster = (AmethystCluster) Material.MEDIUM_AMETHYST_BUD.createBlockData();
|
||||
cluster.setFacing(BlockFace.UP);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(3, 0, 3, 10, 4, 10));
|
||||
new BlockBoundingBox(cluster, cuboidList, createItem("LAUFBAU_BLOCK_MEDIUM_AMETHYST_BUD", Material.MEDIUM_AMETHYST_BUD, "LAUFBAU_FACING_UP"));
|
||||
}
|
||||
|
||||
private void ceilingMediumAmethystBud() {
|
||||
AmethystCluster cluster = (AmethystCluster) Material.MEDIUM_AMETHYST_BUD.createBlockData();
|
||||
cluster.setFacing(BlockFace.DOWN);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(3, 12, 3, 10, 4, 10));
|
||||
new BlockBoundingBox(cluster, cuboidList, createItem("LAUFBAU_BLOCK_MEDIUM_AMETHYST_BUD", Material.MEDIUM_AMETHYST_BUD, "LAUFBAU_FACING_DOWN"));
|
||||
}
|
||||
|
||||
private void northMediumAmethystBud() {
|
||||
AmethystCluster cluster = (AmethystCluster) Material.MEDIUM_AMETHYST_BUD.createBlockData();
|
||||
cluster.setFacing(BlockFace.NORTH);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(3, 3, 12, 10, 10, 4));
|
||||
new BlockBoundingBox(cluster, cuboidList, createItem("LAUFBAU_BLOCK_MEDIUM_AMETHYST_BUD", Material.MEDIUM_AMETHYST_BUD, "LAUFBAU_FACING_NORTH"));
|
||||
}
|
||||
|
||||
private void southMediumAmethystBud() {
|
||||
AmethystCluster cluster = (AmethystCluster) Material.MEDIUM_AMETHYST_BUD.createBlockData();
|
||||
cluster.setFacing(BlockFace.SOUTH);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(3, 3, 0, 10, 10, 4));
|
||||
new BlockBoundingBox(cluster, cuboidList, createItem("LAUFBAU_BLOCK_MEDIUM_AMETHYST_BUD", Material.MEDIUM_AMETHYST_BUD, "LAUFBAU_FACING_SOUTH"));
|
||||
}
|
||||
|
||||
private void eastMediumAmethystBud() {
|
||||
AmethystCluster cluster = (AmethystCluster) Material.MEDIUM_AMETHYST_BUD.createBlockData();
|
||||
cluster.setFacing(BlockFace.EAST);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(0, 3, 3, 4, 10, 10));
|
||||
new BlockBoundingBox(cluster, cuboidList, createItem("LAUFBAU_BLOCK_MEDIUM_AMETHYST_BUD", Material.MEDIUM_AMETHYST_BUD, "LAUFBAU_FACING_EAST"));
|
||||
}
|
||||
|
||||
private void westMediumAmethystBud() {
|
||||
AmethystCluster cluster = (AmethystCluster) Material.MEDIUM_AMETHYST_BUD.createBlockData();
|
||||
cluster.setFacing(BlockFace.WEST);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(12, 3, 3, 4, 10, 10));
|
||||
new BlockBoundingBox(cluster, cuboidList, createItem("LAUFBAU_BLOCK_MEDIUM_AMETHYST_BUD", Material.MEDIUM_AMETHYST_BUD, "LAUFBAU_FACING_WEST"));
|
||||
}
|
||||
|
||||
private void floorLargeAmethystBud() {
|
||||
AmethystCluster cluster = (AmethystCluster) Material.LARGE_AMETHYST_BUD.createBlockData();
|
||||
cluster.setFacing(BlockFace.UP);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(3, 0, 3, 10, 5, 10));
|
||||
new BlockBoundingBox(cluster, cuboidList, createItem("LAUFBAU_BLOCK_LARGE_AMETHYST_BUD", Material.LARGE_AMETHYST_BUD, "LAUFBAU_FACING_UP"));
|
||||
}
|
||||
|
||||
private void ceilingLargeAmethystBud() {
|
||||
AmethystCluster cluster = (AmethystCluster) Material.LARGE_AMETHYST_BUD.createBlockData();
|
||||
cluster.setFacing(BlockFace.DOWN);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(3, 11, 3, 10, 5, 10));
|
||||
new BlockBoundingBox(cluster, cuboidList, createItem("LAUFBAU_BLOCK_LARGE_AMETHYST_BUD", Material.LARGE_AMETHYST_BUD, "LAUFBAU_FACING_DOWN"));
|
||||
}
|
||||
|
||||
private void northLargeAmethystBud() {
|
||||
AmethystCluster cluster = (AmethystCluster) Material.LARGE_AMETHYST_BUD.createBlockData();
|
||||
cluster.setFacing(BlockFace.NORTH);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(3, 3, 11, 10, 10, 5));
|
||||
new BlockBoundingBox(cluster, cuboidList, createItem("LAUFBAU_BLOCK_LARGE_AMETHYST_BUD", Material.LARGE_AMETHYST_BUD, "LAUFBAU_FACING_NORTH"));
|
||||
}
|
||||
|
||||
private void southLargeAmethystBud() {
|
||||
AmethystCluster cluster = (AmethystCluster) Material.LARGE_AMETHYST_BUD.createBlockData();
|
||||
cluster.setFacing(BlockFace.SOUTH);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(3, 3, 0, 10, 10, 5));
|
||||
new BlockBoundingBox(cluster, cuboidList, createItem("LAUFBAU_BLOCK_LARGE_AMETHYST_BUD", Material.LARGE_AMETHYST_BUD, "LAUFBAU_FACING_SOUTH"));
|
||||
}
|
||||
|
||||
private void eastLargeAmethystBud() {
|
||||
AmethystCluster cluster = (AmethystCluster) Material.LARGE_AMETHYST_BUD.createBlockData();
|
||||
cluster.setFacing(BlockFace.EAST);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(0, 3, 3, 5, 10, 10));
|
||||
new BlockBoundingBox(cluster, cuboidList, createItem("LAUFBAU_BLOCK_LARGE_AMETHYST_BUD", Material.LARGE_AMETHYST_BUD, "LAUFBAU_FACING_EAST"));
|
||||
}
|
||||
|
||||
private void westLargeAmethystBud() {
|
||||
AmethystCluster cluster = (AmethystCluster) Material.LARGE_AMETHYST_BUD.createBlockData();
|
||||
cluster.setFacing(BlockFace.WEST);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(11, 3, 3, 5, 10, 10));
|
||||
new BlockBoundingBox(cluster, cuboidList, createItem("LAUFBAU_BLOCK_LARGE_AMETHYST_BUD", Material.LARGE_AMETHYST_BUD, "LAUFBAU_FACING_WEST"));
|
||||
}
|
||||
|
||||
private void floorAmethystCluster() {
|
||||
AmethystCluster cluster = (AmethystCluster) Material.AMETHYST_CLUSTER.createBlockData();
|
||||
cluster.setFacing(BlockFace.UP);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(3, 0, 3, 10, 7, 10));
|
||||
new BlockBoundingBox(cluster, cuboidList, createItem("LAUFBAU_BLOCK_AMETHYST_CLUSTER", Material.AMETHYST_CLUSTER, "LAUFBAU_FACING_UP"));
|
||||
}
|
||||
|
||||
private void ceilingAmethystCluster() {
|
||||
AmethystCluster cluster = (AmethystCluster) Material.AMETHYST_CLUSTER.createBlockData();
|
||||
cluster.setFacing(BlockFace.DOWN);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(3, 9, 3, 10, 7, 10));
|
||||
new BlockBoundingBox(cluster, cuboidList, createItem("LAUFBAU_BLOCK_AMETHYST_CLUSTER", Material.AMETHYST_CLUSTER, "LAUFBAU_FACING_DOWN"));
|
||||
}
|
||||
|
||||
private void northAmethystCluster() {
|
||||
AmethystCluster cluster = (AmethystCluster) Material.AMETHYST_CLUSTER.createBlockData();
|
||||
cluster.setFacing(BlockFace.NORTH);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(3, 3, 9, 10, 10, 7));
|
||||
new BlockBoundingBox(cluster, cuboidList, createItem("LAUFBAU_BLOCK_AMETHYST_CLUSTER", Material.AMETHYST_CLUSTER, "LAUFBAU_FACING_NORTH"));
|
||||
}
|
||||
|
||||
private void southAmethystCluster() {
|
||||
AmethystCluster cluster = (AmethystCluster) Material.AMETHYST_CLUSTER.createBlockData();
|
||||
cluster.setFacing(BlockFace.SOUTH);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(3, 3, 0, 10, 10, 7));
|
||||
new BlockBoundingBox(cluster, cuboidList, createItem("LAUFBAU_BLOCK_AMETHYST_CLUSTER", Material.AMETHYST_CLUSTER, "LAUFBAU_FACING_SOUTH"));
|
||||
}
|
||||
|
||||
private void eastAmethystCluster() {
|
||||
AmethystCluster cluster = (AmethystCluster) Material.AMETHYST_CLUSTER.createBlockData();
|
||||
cluster.setFacing(BlockFace.EAST);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(0, 3, 3, 7, 10, 10));
|
||||
new BlockBoundingBox(cluster, cuboidList, createItem("LAUFBAU_BLOCK_AMETHYST_CLUSTER", Material.AMETHYST_CLUSTER, "LAUFBAU_FACING_EAST"));
|
||||
}
|
||||
|
||||
private void westAmethystCluster() {
|
||||
AmethystCluster cluster = (AmethystCluster) Material.AMETHYST_CLUSTER.createBlockData();
|
||||
cluster.setFacing(BlockFace.WEST);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(9, 3, 3, 7, 10, 10));
|
||||
new BlockBoundingBox(cluster, cuboidList, createItem("LAUFBAU_BLOCK_AMETHYST_CLUSTER", Material.AMETHYST_CLUSTER, "LAUFBAU_FACING_WEST"));
|
||||
}
|
||||
}
|
||||
-46
@@ -1,46 +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.bausystem.features.slaves.laufbau.boundingboxes;
|
||||
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.BlockBoundingBox;
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.BoundingBoxLoader;
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.Cuboid;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.createItem;
|
||||
import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.pixelCuboid;
|
||||
|
||||
@Linked
|
||||
public class AzaleaBoundingBox implements BoundingBoxLoader {
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
BlockData blockData = Material.FLOWERING_AZALEA.createBlockData();
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(0, 8, 0, 16, 8, 16));
|
||||
cuboidList.add(pixelCuboid(6, 0, 6, 4, 8, 4));
|
||||
new BlockBoundingBox(blockData, cuboidList, createItem("LAUFBAU_BLOCK_AZALEA", Material.FLOWERING_AZALEA));
|
||||
}
|
||||
}
|
||||
-149
@@ -1,149 +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.bausystem.features.slaves.laufbau.boundingboxes;
|
||||
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.BlockBoundingBox;
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.BoundingBoxLoader;
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.Cuboid;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.data.type.Bell;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.createItem;
|
||||
import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.pixelCuboid;
|
||||
|
||||
@Linked
|
||||
public class BellBoundingBox implements BoundingBoxLoader {
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
ceilingBell();
|
||||
|
||||
floorNorthBell();
|
||||
floorEastBell();
|
||||
|
||||
doubleWallNorthBell();
|
||||
doubleWallEastBell();
|
||||
|
||||
singleWallNorthBell();
|
||||
singleWallSouthBell();
|
||||
singleWallEastBell();
|
||||
singleWallWestBell();
|
||||
}
|
||||
|
||||
public void ceilingBell() {
|
||||
Bell bell = (Bell) Material.BELL.createBlockData();
|
||||
bell.setAttachment(Bell.Attachment.CEILING);
|
||||
bell.setFacing(BlockFace.NORTH);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(4, 4, 4, 8, 2, 8));
|
||||
cuboidList.add(pixelCuboid(5, 6, 5, 6, 8, 6));
|
||||
cuboidList.add(pixelCuboid(7, 13, 7, 2, 3, 2));
|
||||
new BlockBoundingBox(bell, cuboidList, createItem("LAUFBAU_BLOCK_BELL", Material.BELL, "LAUFBAU_ATTACHMENT_CEILING"));
|
||||
}
|
||||
|
||||
public void floorNorthBell() {
|
||||
Bell bell = (Bell) Material.BELL.createBlockData();
|
||||
bell.setAttachment(Bell.Attachment.FLOOR);
|
||||
bell.setFacing(BlockFace.NORTH);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(0, 0, 4, 16, 16, 8));
|
||||
new BlockBoundingBox(bell, cuboidList, createItem("LAUFBAU_BLOCK_BELL", Material.BELL, "LAUFBAU_ATTACHMENT_FLOOR", "LAUFBAU_FACING_NORTH", "LAUFBAU_FACING_SOUTH"));
|
||||
}
|
||||
|
||||
public void floorEastBell() {
|
||||
Bell bell = (Bell) Material.BELL.createBlockData();
|
||||
bell.setAttachment(Bell.Attachment.FLOOR);
|
||||
bell.setFacing(BlockFace.EAST);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(4, 0, 0, 8, 16, 16));
|
||||
new BlockBoundingBox(bell, cuboidList, createItem("LAUFBAU_BLOCK_BELL", Material.BELL, "LAUFBAU_ATTACHMENT_FLOOR", "LAUFBAU_FACING_EAST", "LAUFBAU_FACING_WEST"));
|
||||
}
|
||||
|
||||
public void doubleWallNorthBell() {
|
||||
Bell bell = (Bell) Material.BELL.createBlockData();
|
||||
bell.setAttachment(Bell.Attachment.DOUBLE_WALL);
|
||||
bell.setFacing(BlockFace.NORTH);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(4, 4, 4, 8, 2, 8));
|
||||
cuboidList.add(pixelCuboid(5, 6, 5, 6, 8, 6));
|
||||
cuboidList.add(pixelCuboid(7, 13, 0, 2, 2, 16));
|
||||
new BlockBoundingBox(bell, cuboidList, createItem("LAUFBAU_BLOCK_BELL", Material.BELL, "LAUFBAU_ATTACHMENT_DOUBLE_WALL", "LAUFBAU_FACING_NORTH"));
|
||||
}
|
||||
|
||||
public void doubleWallEastBell() {
|
||||
Bell bell = (Bell) Material.BELL.createBlockData();
|
||||
bell.setAttachment(Bell.Attachment.DOUBLE_WALL);
|
||||
bell.setFacing(BlockFace.EAST);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(4, 4, 4, 8, 2, 8));
|
||||
cuboidList.add(pixelCuboid(5, 6, 5, 6, 8, 6));
|
||||
cuboidList.add(pixelCuboid(0, 13, 7, 16, 2, 2));
|
||||
new BlockBoundingBox(bell, cuboidList, createItem("LAUFBAU_BLOCK_BELL", Material.BELL, "LAUFBAU_ATTACHMENT_DOUBLE_WALL", "LAUFBAU_FACING_EAST"));
|
||||
}
|
||||
|
||||
public void singleWallNorthBell() {
|
||||
Bell bell = (Bell) Material.BELL.createBlockData();
|
||||
bell.setAttachment(Bell.Attachment.SINGLE_WALL);
|
||||
bell.setFacing(BlockFace.NORTH);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(4, 4, 4, 8, 2, 8));
|
||||
cuboidList.add(pixelCuboid(5, 6, 5, 6, 8, 6));
|
||||
cuboidList.add(pixelCuboid(7, 13, 0, 2, 2, 13));
|
||||
new BlockBoundingBox(bell, cuboidList, createItem("LAUFBAU_BLOCK_BELL", Material.BELL, "LAUFBAU_ATTACHMENT_SINGLE_WALL", "LAUFBAU_FACING_NORTH"));
|
||||
}
|
||||
|
||||
public void singleWallSouthBell() {
|
||||
Bell bell = (Bell) Material.BELL.createBlockData();
|
||||
bell.setAttachment(Bell.Attachment.SINGLE_WALL);
|
||||
bell.setFacing(BlockFace.SOUTH);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(4, 4, 4, 8, 2, 8));
|
||||
cuboidList.add(pixelCuboid(5, 6, 5, 6, 8, 6));
|
||||
cuboidList.add(pixelCuboid(7, 13, 3, 2, 2, 13));
|
||||
new BlockBoundingBox(bell, cuboidList, createItem("LAUFBAU_BLOCK_BELL", Material.BELL, "LAUFBAU_ATTACHMENT_SINGLE_WALL", "LAUFBAU_FACING_SOUTH"));
|
||||
}
|
||||
|
||||
public void singleWallEastBell() {
|
||||
Bell bell = (Bell) Material.BELL.createBlockData();
|
||||
bell.setAttachment(Bell.Attachment.SINGLE_WALL);
|
||||
bell.setFacing(BlockFace.EAST);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(4, 4, 4, 8, 2, 8));
|
||||
cuboidList.add(pixelCuboid(5, 6, 5, 6, 8, 6));
|
||||
cuboidList.add(pixelCuboid(3, 13, 7, 13, 2, 2));
|
||||
new BlockBoundingBox(bell, cuboidList, createItem("LAUFBAU_BLOCK_BELL", Material.BELL, "LAUFBAU_ATTACHMENT_SINGLE_WALL", "LAUFBAU_FACING_EAST"));
|
||||
}
|
||||
|
||||
public void singleWallWestBell() {
|
||||
Bell bell = (Bell) Material.BELL.createBlockData();
|
||||
bell.setAttachment(Bell.Attachment.SINGLE_WALL);
|
||||
bell.setFacing(BlockFace.WEST);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(4, 4, 4, 8, 2, 8));
|
||||
cuboidList.add(pixelCuboid(5, 6, 5, 6, 8, 6));
|
||||
cuboidList.add(pixelCuboid(0, 13, 7, 13, 2, 2));
|
||||
new BlockBoundingBox(bell, cuboidList, createItem("LAUFBAU_BLOCK_BELL", Material.BELL, "LAUFBAU_ATTACHMENT_SINGLE_WALL", "LAUFBAU_FACING_WEST"));
|
||||
}
|
||||
}
|
||||
-46
@@ -1,46 +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.bausystem.features.slaves.laufbau.boundingboxes;
|
||||
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.BlockBoundingBox;
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.BoundingBoxLoader;
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.Cuboid;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.data.type.BrewingStand;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.createItem;
|
||||
import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.pixelCuboid;
|
||||
|
||||
@Linked
|
||||
public class BrewingStandBoundingBox implements BoundingBoxLoader {
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
BrewingStand brewingStand = (BrewingStand) Material.BREWING_STAND.createBlockData();
|
||||
List<Cuboid> cuboids = new ArrayList<>();
|
||||
cuboids.add(pixelCuboid(1, 0, 1, 14, 2, 14));
|
||||
cuboids.add(pixelCuboid(7, 2, 7, 2, 12, 2));
|
||||
new BlockBoundingBox(brewingStand, cuboids, createItem("LAUFBAU_BLOCK_BREWING_STAND", Material.BREWING_STAND));
|
||||
}
|
||||
}
|
||||
-62
@@ -1,62 +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.bausystem.features.slaves.laufbau.boundingboxes;
|
||||
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.BlockBoundingBox;
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.BoundingBoxLoader;
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.Cuboid;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.data.Lightable;
|
||||
import org.bukkit.block.data.type.Candle;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.createItem;
|
||||
import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.pixelCuboid;
|
||||
|
||||
@Linked
|
||||
public class CandleBoundingBox implements BoundingBoxLoader {
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
caked();
|
||||
|
||||
single();
|
||||
}
|
||||
|
||||
private void caked() {
|
||||
Lightable candleCake = (Lightable) Material.CYAN_CANDLE_CAKE.createBlockData();
|
||||
candleCake.setLit(true);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(0, 0, 0, 16, 8, 16));
|
||||
cuboidList.add(pixelCuboid(7, 8, 7, 2, 6, 2));
|
||||
new BlockBoundingBox(candleCake, cuboidList, createItem("LAUFBAU_BLOCK_CANDLE_CAKE", Material.CAKE));
|
||||
}
|
||||
|
||||
private void single() {
|
||||
Candle candle = (Candle) Material.CYAN_CANDLE.createBlockData();
|
||||
candle.setCandles(1);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(7, 0, 7, 2, 6, 2));
|
||||
new BlockBoundingBox(candle, cuboidList, createItem("LAUFBAU_BLOCK_CANDLE", Material.CYAN_CANDLE, "LAUFBAU_COUNT_1"));
|
||||
}
|
||||
}
|
||||
-69
@@ -1,69 +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.bausystem.features.slaves.laufbau.boundingboxes;
|
||||
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.BlockBoundingBox;
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.BoundingBoxLoader;
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.Cuboid;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.Axis;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.data.Orientable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.createItem;
|
||||
import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.pixelCuboid;
|
||||
|
||||
@Linked
|
||||
public class ChainBoundingBox implements BoundingBoxLoader {
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
bottomTopChain();
|
||||
northSouthChain();
|
||||
eastWestChain();
|
||||
}
|
||||
|
||||
private void bottomTopChain() {
|
||||
Orientable chainBottomTop = (Orientable) Material.CHAIN.createBlockData();
|
||||
chainBottomTop.setAxis(Axis.Y);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(6.5, 0, 6.5, 3, 16, 3));
|
||||
new BlockBoundingBox(chainBottomTop, cuboidList, createItem("LAUFBAU_BLOCK_CHAIN", Material.CHAIN, "LAUFBAU_FACING_UP", "LAUFBAU_FACING_DOWN"));
|
||||
}
|
||||
|
||||
private void northSouthChain() {
|
||||
Orientable chainBottomTop = (Orientable) Material.CHAIN.createBlockData();
|
||||
chainBottomTop.setAxis(Axis.Z);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(6.5, 6.5, 0, 3, 3, 16));
|
||||
new BlockBoundingBox(chainBottomTop, cuboidList, createItem("LAUFBAU_BLOCK_CHAIN", Material.CHAIN, "LAUFBAU_FACING_NORTH", "LAUFBAU_FACING_SOUTH"));
|
||||
}
|
||||
|
||||
private void eastWestChain() {
|
||||
Orientable chainBottomTop = (Orientable) Material.CHAIN.createBlockData();
|
||||
chainBottomTop.setAxis(Axis.X);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(0, 6.5, 6.5, 16, 3, 3));
|
||||
new BlockBoundingBox(chainBottomTop, cuboidList, createItem("LAUFBAU_BLOCK_CHAIN", Material.CHAIN, "LAUFBAU_FACING_EAST", "LAUFBAU_FACING_WEST"));
|
||||
}
|
||||
}
|
||||
-89
@@ -1,89 +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.bausystem.features.slaves.laufbau.boundingboxes;
|
||||
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.BlockBoundingBox;
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.BoundingBoxLoader;
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.Cuboid;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.data.MultipleFacing;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.createItem;
|
||||
import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.pixelCuboid;
|
||||
|
||||
@Linked
|
||||
public class ChorusPlantBoundingBox implements BoundingBoxLoader {
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
for (int nx = 0; nx < 2; nx++) {
|
||||
for (int ny = 0; ny < 2; ny++) {
|
||||
for (int nz = 0; nz < 2; nz++) {
|
||||
for (int px = 0; px < 2; px++) {
|
||||
for (int py = 0; py < 2; py++) {
|
||||
for (int pz = 0; pz < 2; pz++) {
|
||||
MultipleFacing chorusPlant = (MultipleFacing) Material.CHORUS_PLANT.createBlockData();
|
||||
List<String> lore = new ArrayList<>();
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(3, 3, 3, 10, 10, 10));
|
||||
if (nx == 1) {
|
||||
lore.add("LAUFBAU_CONNECTION_WEST");
|
||||
chorusPlant.setFace(BlockFace.WEST, true);
|
||||
cuboidList.add(pixelCuboid(0, 3, 3, 3, 10, 10));
|
||||
}
|
||||
if (ny == 1) {
|
||||
lore.add("LAUFBAU_CONNECTION_DOWN");
|
||||
chorusPlant.setFace(BlockFace.DOWN, true);
|
||||
cuboidList.add(pixelCuboid(3, 0, 3, 10, 3, 10));
|
||||
}
|
||||
if (nz == 1) {
|
||||
lore.add("LAUFBAU_CONNECTION_NORTH");
|
||||
chorusPlant.setFace(BlockFace.NORTH, true);
|
||||
cuboidList.add(pixelCuboid(3, 3, 0, 10, 10, 3));
|
||||
}
|
||||
if (px == 1) {
|
||||
lore.add("LAUFBAU_CONNECTION_EAST");
|
||||
chorusPlant.setFace(BlockFace.EAST, true);
|
||||
cuboidList.add(pixelCuboid(13, 3, 3, 3, 10, 10));
|
||||
}
|
||||
if (py == 1) {
|
||||
lore.add("LAUFBAU_CONNECTION_UP");
|
||||
chorusPlant.setFace(BlockFace.UP, true);
|
||||
cuboidList.add(pixelCuboid(3, 13, 3, 10, 3, 10));
|
||||
}
|
||||
if (pz == 1) {
|
||||
lore.add("LAUFBAU_CONNECTION_SOUTH");
|
||||
chorusPlant.setFace(BlockFace.SOUTH, true);
|
||||
cuboidList.add(pixelCuboid(3, 3, 13, 10, 10, 3));
|
||||
}
|
||||
new BlockBoundingBox(chorusPlant, cuboidList, createItem("LAUFBAU_BLOCK_CHORUS_PLANT", Material.CHORUS_PLANT, lore.toArray(new String[0])));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
-45
@@ -1,45 +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.bausystem.features.slaves.laufbau.boundingboxes;
|
||||
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.BlockBoundingBox;
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.BoundingBoxLoader;
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.Cuboid;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.createItem;
|
||||
import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.pixelCuboid;
|
||||
|
||||
@Linked
|
||||
public class DragonEggBoundingBox implements BoundingBoxLoader {
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
BlockData blockData = Material.DRAGON_EGG.createBlockData();
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(1, 0, 1, 14, 16, 14));
|
||||
new BlockBoundingBox(blockData, cuboidList, createItem("LAUFBAU_BLOCK_DRAGON_EGG", Material.DRAGON_EGG));
|
||||
}
|
||||
}
|
||||
-59
@@ -1,59 +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.bausystem.features.slaves.laufbau.boundingboxes;
|
||||
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.BlockBoundingBox;
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.BoundingBoxLoader;
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.Cuboid;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.data.type.BigDripleaf;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.createItem;
|
||||
import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.pixelCuboid;
|
||||
|
||||
@Linked
|
||||
public class DripLeafBoundingBox implements BoundingBoxLoader {
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
tiltNone();
|
||||
tiltPartial();
|
||||
}
|
||||
|
||||
private void tiltNone() {
|
||||
BigDripleaf bigDripleaf = (BigDripleaf) Material.BIG_DRIPLEAF.createBlockData();
|
||||
bigDripleaf.setTilt(BigDripleaf.Tilt.NONE);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(0, 11, 0, 16, 4, 16));
|
||||
new BlockBoundingBox(bigDripleaf, cuboidList, createItem("LAUFBAU_BLOCK_BIG_DRIP_LEAF", Material.BIG_DRIPLEAF, "LAUFBAU_TILT_NONE"));
|
||||
}
|
||||
|
||||
private void tiltPartial() {
|
||||
BigDripleaf bigDripleaf = (BigDripleaf) Material.BIG_DRIPLEAF.createBlockData();
|
||||
bigDripleaf.setTilt(BigDripleaf.Tilt.PARTIAL);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(0, 11, 0, 16, 2, 16));
|
||||
new BlockBoundingBox(bigDripleaf, cuboidList, createItem("LAUFBAU_BLOCK_BIG_DRIP_LEAF", Material.BIG_DRIPLEAF, "LAUFBAU_TILT_PARTIAL"));
|
||||
}
|
||||
}
|
||||
-75
@@ -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.bausystem.features.slaves.laufbau.boundingboxes;
|
||||
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.BlockBoundingBox;
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.BoundingBoxLoader;
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.Cuboid;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.data.type.Fence;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.createItem;
|
||||
import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.pixelCuboid;
|
||||
|
||||
@Linked
|
||||
public class FencesBoundingBox implements BoundingBoxLoader {
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
for (int nx = 0; nx < 2; nx++) {
|
||||
for (int nz = 0; nz < 2; nz++) {
|
||||
for (int px = 0; px < 2; px++) {
|
||||
for (int pz = 0; pz < 2; pz++) {
|
||||
Fence fence = (Fence) Material.NETHER_BRICK_FENCE.createBlockData();
|
||||
List<String> lore = new ArrayList<>();
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(6, 0, 6, 4, 24, 4));
|
||||
if (nz == 1) {
|
||||
lore.add("LAUFBAU_CONNECTION_NORTH");
|
||||
fence.setFace(BlockFace.NORTH, true);
|
||||
cuboidList.add(pixelCuboid(6, 0, 0, 4, 24, 6));
|
||||
}
|
||||
if (pz == 1) {
|
||||
lore.add("LAUFBAU_CONNECTION_SOUTH");
|
||||
fence.setFace(BlockFace.SOUTH, true);
|
||||
cuboidList.add(pixelCuboid(6, 0, 10, 4, 24, 6));
|
||||
}
|
||||
if (nx == 1) {
|
||||
lore.add("LAUFBAU_CONNECTION_WEST");
|
||||
fence.setFace(BlockFace.WEST, true);
|
||||
cuboidList.add(pixelCuboid(0, 0, 6, 6, 24, 4));
|
||||
}
|
||||
if (px == 1) {
|
||||
lore.add("LAUFBAU_CONNECTION_EAST");
|
||||
fence.setFace(BlockFace.EAST, true);
|
||||
cuboidList.add(pixelCuboid(10, 0, 6, 6, 24, 4));
|
||||
}
|
||||
new BlockBoundingBox(fence, cuboidList, createItem("LAUFBAU_BLOCK_NETHER_BRICK_FENCE", Material.NETHER_BRICK_FENCE, lore.toArray(new String[0])));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
-157
@@ -1,157 +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.bausystem.features.slaves.laufbau.boundingboxes;
|
||||
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.BlockBoundingBox;
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.BoundingBoxLoader;
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.Cuboid;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.data.FaceAttachable;
|
||||
import org.bukkit.block.data.type.Grindstone;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.createItem;
|
||||
import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.pixelCuboid;
|
||||
|
||||
@Linked
|
||||
public class GrindstoneBoundingBox implements BoundingBoxLoader {
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
floorNorthGrindstone();
|
||||
floorEastGrindstone();
|
||||
|
||||
ceilingNorthGrindstone();
|
||||
ceilingEastGrindstone();
|
||||
|
||||
wallNorthGrindstone();
|
||||
wallSouthGrindstone();
|
||||
wallEastGrindstone();
|
||||
wallWestGrindstone();
|
||||
}
|
||||
|
||||
public void floorNorthGrindstone() {
|
||||
Grindstone grindstone = (Grindstone) Material.GRINDSTONE.createBlockData();
|
||||
grindstone.setAttachedFace(FaceAttachable.AttachedFace.FLOOR);
|
||||
grindstone.setFacing(BlockFace.NORTH);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(4, 4, 2, 8, 12, 12));
|
||||
cuboidList.add(pixelCuboid(2, 0, 6, 2, 7, 4));
|
||||
cuboidList.add(pixelCuboid(12, 0, 6, 2, 7, 4));
|
||||
cuboidList.add(pixelCuboid(2, 7, 5, 2, 6, 6));
|
||||
cuboidList.add(pixelCuboid(12, 7, 5, 2, 6, 6));
|
||||
new BlockBoundingBox(grindstone, cuboidList, createItem("LAUFBAU_BLOCK_GRINDSTONE", Material.GRINDSTONE, "LAUFBAU_ATTACHMENT_FLOOR", "LAUFBAU_FACING_NORTH", "LAUFBAU_FACING_SOUTH"));
|
||||
}
|
||||
|
||||
public void floorEastGrindstone() {
|
||||
Grindstone grindstone = (Grindstone) Material.GRINDSTONE.createBlockData();
|
||||
grindstone.setAttachedFace(FaceAttachable.AttachedFace.FLOOR);
|
||||
grindstone.setFacing(BlockFace.EAST);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(2, 4, 4, 12, 12, 8));
|
||||
cuboidList.add(pixelCuboid(6, 0, 2, 4, 7, 2));
|
||||
cuboidList.add(pixelCuboid(6, 0, 12, 4, 7, 2));
|
||||
cuboidList.add(pixelCuboid(5, 7, 2, 6, 6, 2));
|
||||
cuboidList.add(pixelCuboid(5, 7, 12, 6, 6, 2));
|
||||
new BlockBoundingBox(grindstone, cuboidList, createItem("LAUFBAU_BLOCK_GRINDSTONE", Material.GRINDSTONE, "LAUFBAU_ATTACHMENT_FLOOR", "LAUFBAU_FACING_EAST", "LAUFBAU_FACING_WEST"));
|
||||
}
|
||||
|
||||
public void ceilingNorthGrindstone() {
|
||||
Grindstone grindstone = (Grindstone) Material.GRINDSTONE.createBlockData();
|
||||
grindstone.setAttachedFace(FaceAttachable.AttachedFace.CEILING);
|
||||
grindstone.setFacing(BlockFace.NORTH);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(4, 0, 2, 8, 12, 12));
|
||||
cuboidList.add(pixelCuboid(2, 9, 6, 2, 7, 4));
|
||||
cuboidList.add(pixelCuboid(12, 9, 6, 2, 7, 4));
|
||||
cuboidList.add(pixelCuboid(2, 3, 5, 2, 6, 6));
|
||||
cuboidList.add(pixelCuboid(12, 3, 5, 2, 6, 6));
|
||||
new BlockBoundingBox(grindstone, cuboidList, createItem("LAUFBAU_BLOCK_GRINDSTONE", Material.GRINDSTONE, "LAUFBAU_ATTACHMENT_CEILING", "LAUFBAU_FACING_NORTH", "LAUFBAU_FACING_SOUTH"));
|
||||
}
|
||||
|
||||
public void ceilingEastGrindstone() {
|
||||
Grindstone grindstone = (Grindstone) Material.GRINDSTONE.createBlockData();
|
||||
grindstone.setAttachedFace(FaceAttachable.AttachedFace.CEILING);
|
||||
grindstone.setFacing(BlockFace.EAST);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(2, 0, 4, 12, 12, 8));
|
||||
cuboidList.add(pixelCuboid(6, 9, 2, 4, 7, 2));
|
||||
cuboidList.add(pixelCuboid(6, 9, 12, 4, 7, 2));
|
||||
cuboidList.add(pixelCuboid(5, 3, 2, 6, 6, 2));
|
||||
cuboidList.add(pixelCuboid(5, 3, 12, 6, 6, 2));
|
||||
new BlockBoundingBox(grindstone, cuboidList, createItem("LAUFBAU_BLOCK_GRINDSTONE", Material.GRINDSTONE, "LAUFBAU_ATTACHMENT_CEILING", "LAUFBAU_FACING_EAST", "LAUFBAU_FACING_WEST"));
|
||||
}
|
||||
|
||||
public void wallNorthGrindstone() {
|
||||
Grindstone grindstone = (Grindstone) Material.GRINDSTONE.createBlockData();
|
||||
grindstone.setAttachedFace(FaceAttachable.AttachedFace.WALL);
|
||||
grindstone.setFacing(BlockFace.NORTH);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(4, 2, 0, 8, 12, 12));
|
||||
cuboidList.add(pixelCuboid(2, 6, 9, 2, 4, 7));
|
||||
cuboidList.add(pixelCuboid(12, 6, 9, 2, 4, 7));
|
||||
cuboidList.add(pixelCuboid(2, 5, 3, 2, 6, 6));
|
||||
cuboidList.add(pixelCuboid(12, 5, 3, 2, 6, 6));
|
||||
new BlockBoundingBox(grindstone, cuboidList, createItem("LAUFBAU_BLOCK_GRINDSTONE", Material.GRINDSTONE, "LAUFBAU_ATTACHMENT_WALL", "LAUFBAU_FACING_NORTH"));
|
||||
}
|
||||
|
||||
public void wallSouthGrindstone() {
|
||||
Grindstone grindstone = (Grindstone) Material.GRINDSTONE.createBlockData();
|
||||
grindstone.setAttachedFace(FaceAttachable.AttachedFace.WALL);
|
||||
grindstone.setFacing(BlockFace.SOUTH);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(4, 2, 4, 8, 12, 12));
|
||||
cuboidList.add(pixelCuboid(2, 6, 0, 2, 4, 7));
|
||||
cuboidList.add(pixelCuboid(12, 6, 0, 2, 4, 7));
|
||||
cuboidList.add(pixelCuboid(2, 5, 7, 2, 6, 6));
|
||||
cuboidList.add(pixelCuboid(12, 5, 7, 2, 6, 6));
|
||||
new BlockBoundingBox(grindstone, cuboidList, createItem("LAUFBAU_BLOCK_GRINDSTONE", Material.GRINDSTONE, "LAUFBAU_ATTACHMENT_WALL", "LAUFBAU_FACING_SOUTH"));
|
||||
}
|
||||
|
||||
public void wallEastGrindstone() {
|
||||
Grindstone grindstone = (Grindstone) Material.GRINDSTONE.createBlockData();
|
||||
grindstone.setAttachedFace(FaceAttachable.AttachedFace.WALL);
|
||||
grindstone.setFacing(BlockFace.EAST);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(4, 2, 4, 12, 12, 8));
|
||||
cuboidList.add(pixelCuboid(0, 6, 2, 7, 4, 2));
|
||||
cuboidList.add(pixelCuboid(0, 6, 12, 7, 4, 2));
|
||||
cuboidList.add(pixelCuboid(7, 5, 2, 6, 6, 2));
|
||||
cuboidList.add(pixelCuboid(7, 5, 12, 6, 6, 2));
|
||||
new BlockBoundingBox(grindstone, cuboidList, createItem("LAUFBAU_BLOCK_GRINDSTONE", Material.GRINDSTONE, "LAUFBAU_ATTACHMENT_WALL", "LAUFBAU_FACING_EAST"));
|
||||
}
|
||||
|
||||
public void wallWestGrindstone() {
|
||||
Grindstone grindstone = (Grindstone) Material.GRINDSTONE.createBlockData();
|
||||
grindstone.setAttachedFace(FaceAttachable.AttachedFace.WALL);
|
||||
grindstone.setFacing(BlockFace.WEST);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(0, 2, 4, 12, 12, 8));
|
||||
cuboidList.add(pixelCuboid(9, 6, 2, 7, 4, 2));
|
||||
cuboidList.add(pixelCuboid(9, 6, 12, 7, 4, 2));
|
||||
cuboidList.add(pixelCuboid(3, 5, 2, 6, 6, 2));
|
||||
cuboidList.add(pixelCuboid(3, 5, 12, 6, 6, 2));
|
||||
new BlockBoundingBox(grindstone, cuboidList, createItem("LAUFBAU_BLOCK_GRINDSTONE", Material.GRINDSTONE, "LAUFBAU_ATTACHMENT_WALL", "LAUFBAU_FACING_WEST"));
|
||||
}
|
||||
}
|
||||
-97
@@ -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.bausystem.features.slaves.laufbau.boundingboxes;
|
||||
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.BlockBoundingBox;
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.BoundingBoxLoader;
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.Cuboid;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.data.type.Hopper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.createItem;
|
||||
import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.pixelCuboid;
|
||||
|
||||
@Linked
|
||||
public class HopperBoundingBox implements BoundingBoxLoader {
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
downHopper();
|
||||
northHopper();
|
||||
southHopper();
|
||||
eastHopper();
|
||||
westHopper();
|
||||
}
|
||||
|
||||
public void downHopper() {
|
||||
Hopper hopper = (Hopper) Material.HOPPER.createBlockData();
|
||||
hopper.setFacing(BlockFace.DOWN);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(0, 10, 0, 16, 6, 16));
|
||||
cuboidList.add(pixelCuboid(4, 4, 4, 8, 6, 8));
|
||||
cuboidList.add(pixelCuboid(6, 0, 6, 4, 4, 4));
|
||||
new BlockBoundingBox(hopper, cuboidList, createItem("LAUFBAU_BLOCK_HOPPER", Material.HOPPER, "LAUFBAU_CONNECTION_FLOOR"));
|
||||
}
|
||||
|
||||
public void northHopper() {
|
||||
Hopper hopper = (Hopper) Material.HOPPER.createBlockData();
|
||||
hopper.setFacing(BlockFace.NORTH);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(0, 10, 0, 16, 6, 16));
|
||||
cuboidList.add(pixelCuboid(4, 4, 4, 8, 6, 8));
|
||||
cuboidList.add(pixelCuboid(6, 4, 0, 4, 4, 4));
|
||||
new BlockBoundingBox(hopper, cuboidList, createItem("LAUFBAU_BLOCK_HOPPER", Material.HOPPER, "LAUFBAU_CONNECTION_NORTH"));
|
||||
}
|
||||
|
||||
public void southHopper() {
|
||||
Hopper hopper = (Hopper) Material.HOPPER.createBlockData();
|
||||
hopper.setFacing(BlockFace.SOUTH);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(0, 10, 0, 16, 6, 16));
|
||||
cuboidList.add(pixelCuboid(4, 4, 4, 8, 6, 8));
|
||||
cuboidList.add(pixelCuboid(6, 4, 12, 4, 4, 4));
|
||||
new BlockBoundingBox(hopper, cuboidList, createItem("LAUFBAU_BLOCK_HOPPER", Material.HOPPER, "LAUFBAU_CONNECTION_SOUTH"));
|
||||
}
|
||||
|
||||
public void eastHopper() {
|
||||
Hopper hopper = (Hopper) Material.HOPPER.createBlockData();
|
||||
hopper.setFacing(BlockFace.EAST);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(0, 10, 0, 16, 6, 16));
|
||||
cuboidList.add(pixelCuboid(4, 4, 4, 8, 6, 8));
|
||||
cuboidList.add(pixelCuboid(12, 4, 6, 4, 4, 4));
|
||||
new BlockBoundingBox(hopper, cuboidList, createItem("LAUFBAU_BLOCK_HOPPER", Material.HOPPER, "LAUFBAU_CONNECTION_EAST"));
|
||||
}
|
||||
|
||||
public void westHopper() {
|
||||
Hopper hopper = (Hopper) Material.HOPPER.createBlockData();
|
||||
hopper.setFacing(BlockFace.WEST);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(0, 10, 0, 16, 6, 16));
|
||||
cuboidList.add(pixelCuboid(4, 4, 4, 8, 6, 8));
|
||||
cuboidList.add(pixelCuboid(0, 4, 6, 4, 4, 4));
|
||||
new BlockBoundingBox(hopper, cuboidList, createItem("LAUFBAU_BLOCK_HOPPER", Material.HOPPER, "LAUFBAU_CONNECTION_WEST"));
|
||||
}
|
||||
}
|
||||
-75
@@ -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.bausystem.features.slaves.laufbau.boundingboxes;
|
||||
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.BlockBoundingBox;
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.BoundingBoxLoader;
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.Cuboid;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.data.type.Fence;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.createItem;
|
||||
import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.pixelCuboid;
|
||||
|
||||
@Linked
|
||||
public class IronBarBoundingBox implements BoundingBoxLoader {
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
for (int nx = 0; nx < 2; nx++) {
|
||||
for (int nz = 0; nz < 2; nz++) {
|
||||
for (int px = 0; px < 2; px++) {
|
||||
for (int pz = 0; pz < 2; pz++) {
|
||||
Fence fence = (Fence) Material.IRON_BARS.createBlockData();
|
||||
List<String> lore = new ArrayList<>();
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(7, 0, 7, 2, 16, 2));
|
||||
if (nz == 1) {
|
||||
lore.add("LAUFBAU_CONNECTION_NORTH");
|
||||
fence.setFace(BlockFace.NORTH, true);
|
||||
cuboidList.add(pixelCuboid(7, 0, 0, 2, 16, 7));
|
||||
}
|
||||
if (pz == 1) {
|
||||
lore.add("LAUFBAU_CONNECTION_SOUTH");
|
||||
fence.setFace(BlockFace.SOUTH, true);
|
||||
cuboidList.add(pixelCuboid(7, 0, 9, 2, 16, 7));
|
||||
}
|
||||
if (nx == 1) {
|
||||
lore.add("LAUFBAU_CONNECTION_WEST");
|
||||
fence.setFace(BlockFace.WEST, true);
|
||||
cuboidList.add(pixelCuboid(0, 0, 7, 7, 16, 2));
|
||||
}
|
||||
if (px == 1) {
|
||||
lore.add("LAUFBAU_CONNECTION_EAST");
|
||||
fence.setFace(BlockFace.EAST, true);
|
||||
cuboidList.add(pixelCuboid(9, 0, 7, 7, 16, 2));
|
||||
}
|
||||
new BlockBoundingBox(fence, cuboidList, createItem("LAUFBAU_BLOCK_IRON_BARS", Material.IRON_BARS, lore.toArray(new String[0])));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
-61
@@ -1,61 +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.bausystem.features.slaves.laufbau.boundingboxes;
|
||||
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.BlockBoundingBox;
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.BoundingBoxLoader;
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.Cuboid;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.data.type.Lantern;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.createItem;
|
||||
import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.pixelCuboid;
|
||||
|
||||
@Linked
|
||||
public class LanternBoundingBox implements BoundingBoxLoader {
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
lantern();
|
||||
hangingLantern();
|
||||
}
|
||||
|
||||
public void lantern() {
|
||||
Lantern lantern = (Lantern) Material.LANTERN.createBlockData();
|
||||
lantern.setHanging(false);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(5, 0, 5, 6, 7, 6));
|
||||
cuboidList.add(pixelCuboid(6, 7, 6, 4, 2, 4));
|
||||
new BlockBoundingBox(lantern, cuboidList, createItem("LAUFBAU_BLOCK_LANTERN", Material.LANTERN));
|
||||
}
|
||||
|
||||
public void hangingLantern() {
|
||||
Lantern lantern = (Lantern) Material.LANTERN.createBlockData();
|
||||
lantern.setHanging(true);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(5, 1, 5, 6, 7, 6));
|
||||
cuboidList.add(pixelCuboid(6, 8, 6, 4, 2, 4));
|
||||
new BlockBoundingBox(lantern, cuboidList, createItem("LAUFBAU_BLOCK_LANTERN", Material.LANTERN, "LAUFBAU_HANGING"));
|
||||
}
|
||||
}
|
||||
-46
@@ -1,46 +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.bausystem.features.slaves.laufbau.boundingboxes;
|
||||
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.BlockBoundingBox;
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.BoundingBoxLoader;
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.Cuboid;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.createItem;
|
||||
import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.pixelCuboid;
|
||||
|
||||
@Linked
|
||||
public class LecternBoundingBox implements BoundingBoxLoader {
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
BlockData blockData = Material.LECTERN.createBlockData();
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(0, 0, 0, 16, 2, 16));
|
||||
cuboidList.add(pixelCuboid(4, 2, 4, 8, 12, 8));
|
||||
new BlockBoundingBox(blockData, cuboidList, createItem("LAUFBAU_BLOCK_LECTERN", Material.LECTERN));
|
||||
}
|
||||
}
|
||||
-343
@@ -1,343 +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.bausystem.features.slaves.laufbau.boundingboxes;
|
||||
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.BlockBoundingBox;
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.BoundingBoxLoader;
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.Cuboid;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.data.type.Stairs;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.createItem;
|
||||
import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.pixelCuboid;
|
||||
|
||||
@Linked
|
||||
public class StairBoundingBox implements BoundingBoxLoader {
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
straightBottomNorthStair();
|
||||
straightBottomSouthStair();
|
||||
straightBottomEastStair();
|
||||
straightBottomWestStair();
|
||||
|
||||
straightTopNorthStair();
|
||||
straightTopSouthStair();
|
||||
straightTopEastStair();
|
||||
straightTopWestStair();
|
||||
|
||||
outerLeftBottomNorthStair();
|
||||
outerLeftBottomSouthStair();
|
||||
outerLeftBottomEastStair();
|
||||
outerLeftBottomWestStair();
|
||||
|
||||
outerLeftTopNorthStair();
|
||||
outerLeftTopSouthStair();
|
||||
outerLeftTopEastStair();
|
||||
outerLeftTopWestStair();
|
||||
|
||||
innerLeftBottomNorthStair();
|
||||
innerLeftBottomSouthStair();
|
||||
innerLeftBottomEastStair();
|
||||
innerLeftBottomWestStair();
|
||||
|
||||
innerLeftTopNorthStair();
|
||||
innerLeftTopSouthStair();
|
||||
innerLeftTopEastStair();
|
||||
innerLeftTopWestStair();
|
||||
}
|
||||
|
||||
public void straightBottomNorthStair() {
|
||||
Stairs stairs = (Stairs) Material.END_STONE_BRICK_STAIRS.createBlockData();
|
||||
stairs.setShape(Stairs.Shape.STRAIGHT);
|
||||
stairs.setHalf(Stairs.Half.BOTTOM);
|
||||
stairs.setFacing(BlockFace.NORTH);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(0, 0, 0, 16, 8, 16));
|
||||
cuboidList.add(pixelCuboid(0, 8, 0, 16, 8, 8));
|
||||
new BlockBoundingBox(stairs, cuboidList, createItem("LAUFBAU_BLOCK_END_STONE_BRICK_STAIRS", Material.END_STONE_BRICK_STAIRS, "LAUFBAU_SHAPE_STRAIGHT", "LAUFBAU_HALF_BOTTOM", "LAUFBAU_FACING_NORTH"));
|
||||
}
|
||||
|
||||
public void straightBottomSouthStair() {
|
||||
Stairs stairs = (Stairs) Material.END_STONE_BRICK_STAIRS.createBlockData();
|
||||
stairs.setShape(Stairs.Shape.STRAIGHT);
|
||||
stairs.setHalf(Stairs.Half.BOTTOM);
|
||||
stairs.setFacing(BlockFace.SOUTH);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(0, 0, 0, 16, 8, 16));
|
||||
cuboidList.add(pixelCuboid(0, 8, 8, 16, 8, 8));
|
||||
new BlockBoundingBox(stairs, cuboidList, createItem("LAUFBAU_BLOCK_END_STONE_BRICK_STAIRS", Material.END_STONE_BRICK_STAIRS, "LAUFBAU_SHAPE_STRAIGHT", "LAUFBAU_HALF_BOTTOM", "LAUFBAU_FACING_SOUTH"));
|
||||
}
|
||||
|
||||
public void straightBottomEastStair() {
|
||||
Stairs stairs = (Stairs) Material.END_STONE_BRICK_STAIRS.createBlockData();
|
||||
stairs.setShape(Stairs.Shape.STRAIGHT);
|
||||
stairs.setHalf(Stairs.Half.BOTTOM);
|
||||
stairs.setFacing(BlockFace.EAST);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(0, 0, 0, 16, 8, 16));
|
||||
cuboidList.add(pixelCuboid(8, 8, 0, 8, 8, 16));
|
||||
new BlockBoundingBox(stairs, cuboidList, createItem("LAUFBAU_BLOCK_END_STONE_BRICK_STAIRS", Material.END_STONE_BRICK_STAIRS, "LAUFBAU_SHAPE_STRAIGHT", "LAUFBAU_HALF_BOTTOM", "LAUFBAU_FACING_EAST"));
|
||||
}
|
||||
|
||||
public void straightBottomWestStair() {
|
||||
Stairs stairs = (Stairs) Material.END_STONE_BRICK_STAIRS.createBlockData();
|
||||
stairs.setShape(Stairs.Shape.STRAIGHT);
|
||||
stairs.setHalf(Stairs.Half.BOTTOM);
|
||||
stairs.setFacing(BlockFace.WEST);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(0, 0, 0, 16, 8, 16));
|
||||
cuboidList.add(pixelCuboid(0, 8, 0, 8, 8, 16));
|
||||
new BlockBoundingBox(stairs, cuboidList, createItem("LAUFBAU_BLOCK_END_STONE_BRICK_STAIRS", Material.END_STONE_BRICK_STAIRS, "LAUFBAU_SHAPE_STRAIGHT", "LAUFBAU_HALF_BOTTOM", "LAUFBAU_FACING_WEST"));
|
||||
}
|
||||
|
||||
public void straightTopNorthStair() {
|
||||
Stairs stairs = (Stairs) Material.END_STONE_BRICK_STAIRS.createBlockData();
|
||||
stairs.setShape(Stairs.Shape.STRAIGHT);
|
||||
stairs.setHalf(Stairs.Half.TOP);
|
||||
stairs.setFacing(BlockFace.NORTH);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(0, 8, 0, 16, 8, 16));
|
||||
cuboidList.add(pixelCuboid(0, 0, 0, 16, 8, 8));
|
||||
new BlockBoundingBox(stairs, cuboidList, createItem("LAUFBAU_BLOCK_END_STONE_BRICK_STAIRS", Material.END_STONE_BRICK_STAIRS, "LAUFBAU_SHAPE_STRAIGHT", "LAUFBAU_HALF_TOP", "LAUFBAU_FACING_NORTH"));
|
||||
}
|
||||
|
||||
public void straightTopSouthStair() {
|
||||
Stairs stairs = (Stairs) Material.END_STONE_BRICK_STAIRS.createBlockData();
|
||||
stairs.setShape(Stairs.Shape.STRAIGHT);
|
||||
stairs.setHalf(Stairs.Half.TOP);
|
||||
stairs.setFacing(BlockFace.SOUTH);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(0, 8, 0, 16, 8, 16));
|
||||
cuboidList.add(pixelCuboid(0, 0, 8, 16, 8, 8));
|
||||
new BlockBoundingBox(stairs, cuboidList, createItem("LAUFBAU_BLOCK_END_STONE_BRICK_STAIRS", Material.END_STONE_BRICK_STAIRS, "LAUFBAU_SHAPE_STRAIGHT", "LAUFBAU_HALF_TOP", "LAUFBAU_FACING_SOUTH"));
|
||||
}
|
||||
|
||||
public void straightTopEastStair() {
|
||||
Stairs stairs = (Stairs) Material.END_STONE_BRICK_STAIRS.createBlockData();
|
||||
stairs.setShape(Stairs.Shape.STRAIGHT);
|
||||
stairs.setHalf(Stairs.Half.TOP);
|
||||
stairs.setFacing(BlockFace.EAST);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(0, 8, 0, 16, 8, 16));
|
||||
cuboidList.add(pixelCuboid(8, 0, 0, 8, 8, 16));
|
||||
new BlockBoundingBox(stairs, cuboidList, createItem("LAUFBAU_BLOCK_END_STONE_BRICK_STAIRS", Material.END_STONE_BRICK_STAIRS, "LAUFBAU_SHAPE_STRAIGHT", "LAUFBAU_HALF_TOP", "LAUFBAU_FACING_EAST"));
|
||||
}
|
||||
|
||||
public void straightTopWestStair() {
|
||||
Stairs stairs = (Stairs) Material.END_STONE_BRICK_STAIRS.createBlockData();
|
||||
stairs.setShape(Stairs.Shape.STRAIGHT);
|
||||
stairs.setHalf(Stairs.Half.TOP);
|
||||
stairs.setFacing(BlockFace.WEST);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(0, 8, 0, 16, 8, 16));
|
||||
cuboidList.add(pixelCuboid(0, 0, 0, 8, 8, 16));
|
||||
new BlockBoundingBox(stairs, cuboidList, createItem("LAUFBAU_BLOCK_END_STONE_BRICK_STAIRS", Material.END_STONE_BRICK_STAIRS, "LAUFBAU_SHAPE_STRAIGHT", "LAUFBAU_HALF_TOP", "LAUFBAU_FACING_WEST"));
|
||||
}
|
||||
|
||||
public void outerLeftBottomNorthStair() {
|
||||
Stairs stairs = (Stairs) Material.END_STONE_BRICK_STAIRS.createBlockData();
|
||||
stairs.setShape(Stairs.Shape.OUTER_LEFT);
|
||||
stairs.setHalf(Stairs.Half.BOTTOM);
|
||||
stairs.setFacing(BlockFace.NORTH);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(0, 0, 0, 16, 8, 16));
|
||||
cuboidList.add(pixelCuboid(0, 8, 0, 8, 8, 8));
|
||||
new BlockBoundingBox(stairs, cuboidList, createItem("LAUFBAU_BLOCK_END_STONE_BRICK_STAIRS", Material.END_STONE_BRICK_STAIRS, "LAUFBAU_SHAPE_OUTER_LEFT", "LAUFBAU_HALF_BOTTOM", "LAUFBAU_FACING_NORTH"));
|
||||
}
|
||||
|
||||
public void outerLeftBottomSouthStair() {
|
||||
Stairs stairs = (Stairs) Material.END_STONE_BRICK_STAIRS.createBlockData();
|
||||
stairs.setShape(Stairs.Shape.OUTER_LEFT);
|
||||
stairs.setHalf(Stairs.Half.BOTTOM);
|
||||
stairs.setFacing(BlockFace.SOUTH);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(0, 0, 0, 16, 8, 16));
|
||||
cuboidList.add(pixelCuboid(8, 8, 8, 8, 8, 8));
|
||||
new BlockBoundingBox(stairs, cuboidList, createItem("LAUFBAU_BLOCK_END_STONE_BRICK_STAIRS", Material.END_STONE_BRICK_STAIRS, "LAUFBAU_SHAPE_OUTER_LEFT", "LAUFBAU_HALF_BOTTOM", "LAUFBAU_FACING_SOUTH"));
|
||||
}
|
||||
|
||||
public void outerLeftBottomEastStair() {
|
||||
Stairs stairs = (Stairs) Material.END_STONE_BRICK_STAIRS.createBlockData();
|
||||
stairs.setShape(Stairs.Shape.OUTER_LEFT);
|
||||
stairs.setHalf(Stairs.Half.BOTTOM);
|
||||
stairs.setFacing(BlockFace.EAST);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(0, 0, 0, 16, 8, 16));
|
||||
cuboidList.add(pixelCuboid(8, 8, 0, 8, 8, 8));
|
||||
new BlockBoundingBox(stairs, cuboidList, createItem("LAUFBAU_BLOCK_END_STONE_BRICK_STAIRS", Material.END_STONE_BRICK_STAIRS, "LAUFBAU_SHAPE_OUTER_LEFT", "LAUFBAU_HALF_BOTTOM", "LAUFBAU_FACING_EAST"));
|
||||
}
|
||||
|
||||
public void outerLeftBottomWestStair() {
|
||||
Stairs stairs = (Stairs) Material.END_STONE_BRICK_STAIRS.createBlockData();
|
||||
stairs.setShape(Stairs.Shape.OUTER_LEFT);
|
||||
stairs.setHalf(Stairs.Half.BOTTOM);
|
||||
stairs.setFacing(BlockFace.WEST);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(0, 0, 0, 16, 8, 16));
|
||||
cuboidList.add(pixelCuboid(0, 8, 8, 8, 8, 8));
|
||||
new BlockBoundingBox(stairs, cuboidList, createItem("LAUFBAU_BLOCK_END_STONE_BRICK_STAIRS", Material.END_STONE_BRICK_STAIRS, "LAUFBAU_SHAPE_OUTER_LEFT", "LAUFBAU_HALF_BOTTOM", "LAUFBAU_FACING_WEST"));
|
||||
}
|
||||
|
||||
public void outerLeftTopNorthStair() {
|
||||
Stairs stairs = (Stairs) Material.END_STONE_BRICK_STAIRS.createBlockData();
|
||||
stairs.setShape(Stairs.Shape.OUTER_LEFT);
|
||||
stairs.setHalf(Stairs.Half.TOP);
|
||||
stairs.setFacing(BlockFace.NORTH);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(0, 8, 0, 16, 8, 16));
|
||||
cuboidList.add(pixelCuboid(0, 0, 0, 8, 8, 8));
|
||||
new BlockBoundingBox(stairs, cuboidList, createItem("LAUFBAU_BLOCK_END_STONE_BRICK_STAIRS", Material.END_STONE_BRICK_STAIRS, "LAUFBAU_SHAPE_OUTER_LEFT", "LAUFBAU_HALF_TOP", "LAUFBAU_FACING_NORTH"));
|
||||
}
|
||||
|
||||
public void outerLeftTopSouthStair() {
|
||||
Stairs stairs = (Stairs) Material.END_STONE_BRICK_STAIRS.createBlockData();
|
||||
stairs.setShape(Stairs.Shape.OUTER_LEFT);
|
||||
stairs.setHalf(Stairs.Half.TOP);
|
||||
stairs.setFacing(BlockFace.SOUTH);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(0, 8, 0, 16, 8, 16));
|
||||
cuboidList.add(pixelCuboid(8, 0, 8, 8, 8, 8));
|
||||
new BlockBoundingBox(stairs, cuboidList, createItem("LAUFBAU_BLOCK_END_STONE_BRICK_STAIRS", Material.END_STONE_BRICK_STAIRS, "LAUFBAU_SHAPE_OUTER_LEFT", "LAUFBAU_HALF_TOP", "LAUFBAU_FACING_SOUTH"));
|
||||
}
|
||||
|
||||
public void outerLeftTopEastStair() {
|
||||
Stairs stairs = (Stairs) Material.END_STONE_BRICK_STAIRS.createBlockData();
|
||||
stairs.setShape(Stairs.Shape.OUTER_LEFT);
|
||||
stairs.setHalf(Stairs.Half.TOP);
|
||||
stairs.setFacing(BlockFace.EAST);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(0, 8, 0, 16, 8, 16));
|
||||
cuboidList.add(pixelCuboid(8, 0, 0, 8, 8, 8));
|
||||
new BlockBoundingBox(stairs, cuboidList, createItem("LAUFBAU_BLOCK_END_STONE_BRICK_STAIRS", Material.END_STONE_BRICK_STAIRS, "LAUFBAU_SHAPE_OUTER_LEFT", "LAUFBAU_HALF_TOP", "LAUFBAU_FACING_EAST"));
|
||||
}
|
||||
|
||||
public void outerLeftTopWestStair() {
|
||||
Stairs stairs = (Stairs) Material.END_STONE_BRICK_STAIRS.createBlockData();
|
||||
stairs.setShape(Stairs.Shape.OUTER_LEFT);
|
||||
stairs.setHalf(Stairs.Half.TOP);
|
||||
stairs.setFacing(BlockFace.WEST);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(0, 8, 0, 16, 8, 16));
|
||||
cuboidList.add(pixelCuboid(0, 0, 8, 8, 8, 8));
|
||||
new BlockBoundingBox(stairs, cuboidList, createItem("LAUFBAU_BLOCK_END_STONE_BRICK_STAIRS", Material.END_STONE_BRICK_STAIRS, "LAUFBAU_SHAPE_OUTER_LEFT", "LAUFBAU_HALF_TOP", "LAUFBAU_FACING_WEST"));
|
||||
}
|
||||
|
||||
public void innerLeftBottomNorthStair() {
|
||||
Stairs stairs = (Stairs) Material.END_STONE_BRICK_STAIRS.createBlockData();
|
||||
stairs.setShape(Stairs.Shape.INNER_LEFT);
|
||||
stairs.setHalf(Stairs.Half.BOTTOM);
|
||||
stairs.setFacing(BlockFace.NORTH);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(0, 0, 0, 16, 8, 16));
|
||||
cuboidList.add(pixelCuboid(0, 8, 0, 16, 8, 8));
|
||||
cuboidList.add(pixelCuboid(0, 8, 8, 8, 8, 8));
|
||||
new BlockBoundingBox(stairs, cuboidList, createItem("LAUFBAU_BLOCK_END_STONE_BRICK_STAIRS", Material.END_STONE_BRICK_STAIRS, "LAUFBAU_SHAPE_INNER_LEFT", "LAUFBAU_HALF_BOTTOM", "LAUFBAU_FACING_NORTH"));
|
||||
}
|
||||
|
||||
public void innerLeftBottomSouthStair() {
|
||||
Stairs stairs = (Stairs) Material.END_STONE_BRICK_STAIRS.createBlockData();
|
||||
stairs.setShape(Stairs.Shape.INNER_LEFT);
|
||||
stairs.setHalf(Stairs.Half.BOTTOM);
|
||||
stairs.setFacing(BlockFace.SOUTH);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(0, 0, 0, 16, 8, 16));
|
||||
cuboidList.add(pixelCuboid(0, 8, 8, 16, 8, 8));
|
||||
cuboidList.add(pixelCuboid(8, 8, 0, 8, 8, 8));
|
||||
new BlockBoundingBox(stairs, cuboidList, createItem("LAUFBAU_BLOCK_END_STONE_BRICK_STAIRS", Material.END_STONE_BRICK_STAIRS, "LAUFBAU_SHAPE_INNER_LEFT", "LAUFBAU_HALF_BOTTOM", "LAUFBAU_FACING_SOUTH"));
|
||||
}
|
||||
|
||||
public void innerLeftBottomEastStair() {
|
||||
Stairs stairs = (Stairs) Material.END_STONE_BRICK_STAIRS.createBlockData();
|
||||
stairs.setShape(Stairs.Shape.INNER_LEFT);
|
||||
stairs.setHalf(Stairs.Half.BOTTOM);
|
||||
stairs.setFacing(BlockFace.EAST);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(0, 0, 0, 16, 8, 16));
|
||||
cuboidList.add(pixelCuboid(0, 8, 0, 16, 8, 8));
|
||||
cuboidList.add(pixelCuboid(8, 8, 8, 8, 8, 8));
|
||||
new BlockBoundingBox(stairs, cuboidList, createItem("LAUFBAU_BLOCK_END_STONE_BRICK_STAIRS", Material.END_STONE_BRICK_STAIRS, "LAUFBAU_SHAPE_INNER_LEFT", "LAUFBAU_HALF_BOTTOM", "LAUFBAU_FACING_EAST"));
|
||||
}
|
||||
|
||||
public void innerLeftBottomWestStair() {
|
||||
Stairs stairs = (Stairs) Material.END_STONE_BRICK_STAIRS.createBlockData();
|
||||
stairs.setShape(Stairs.Shape.INNER_LEFT);
|
||||
stairs.setHalf(Stairs.Half.BOTTOM);
|
||||
stairs.setFacing(BlockFace.WEST);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(0, 0, 0, 16, 8, 16));
|
||||
cuboidList.add(pixelCuboid(0, 8, 8, 16, 8, 8));
|
||||
cuboidList.add(pixelCuboid(0, 8, 0, 8, 8, 8));
|
||||
new BlockBoundingBox(stairs, cuboidList, createItem("LAUFBAU_BLOCK_END_STONE_BRICK_STAIRS", Material.END_STONE_BRICK_STAIRS, "LAUFBAU_SHAPE_INNER_LEFT", "LAUFBAU_HALF_BOTTOM", "LAUFBAU_FACING_WEST"));
|
||||
}
|
||||
|
||||
public void innerLeftTopNorthStair() {
|
||||
Stairs stairs = (Stairs) Material.END_STONE_BRICK_STAIRS.createBlockData();
|
||||
stairs.setShape(Stairs.Shape.INNER_LEFT);
|
||||
stairs.setHalf(Stairs.Half.TOP);
|
||||
stairs.setFacing(BlockFace.NORTH);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(0, 8, 0, 16, 8, 16));
|
||||
cuboidList.add(pixelCuboid(0, 0, 0, 16, 8, 8));
|
||||
cuboidList.add(pixelCuboid(0, 0, 8, 8, 8, 8));
|
||||
new BlockBoundingBox(stairs, cuboidList, createItem("LAUFBAU_BLOCK_END_STONE_BRICK_STAIRS", Material.END_STONE_BRICK_STAIRS, "LAUFBAU_SHAPE_INNER_LEFT", "LAUFBAU_HALF_TOP", "LAUFBAU_FACING_NORTH"));
|
||||
}
|
||||
|
||||
public void innerLeftTopSouthStair() {
|
||||
Stairs stairs = (Stairs) Material.END_STONE_BRICK_STAIRS.createBlockData();
|
||||
stairs.setShape(Stairs.Shape.INNER_LEFT);
|
||||
stairs.setHalf(Stairs.Half.TOP);
|
||||
stairs.setFacing(BlockFace.SOUTH);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(0, 8, 0, 16, 8, 16));
|
||||
cuboidList.add(pixelCuboid(0, 0, 8, 16, 8, 8));
|
||||
cuboidList.add(pixelCuboid(8, 0, 0, 8, 8, 8));
|
||||
new BlockBoundingBox(stairs, cuboidList, createItem("LAUFBAU_BLOCK_END_STONE_BRICK_STAIRS", Material.END_STONE_BRICK_STAIRS, "LAUFBAU_SHAPE_INNER_LEFT", "LAUFBAU_HALF_TOP", "LAUFBAU_FACING_SOUTH"));
|
||||
}
|
||||
|
||||
public void innerLeftTopEastStair() {
|
||||
Stairs stairs = (Stairs) Material.END_STONE_BRICK_STAIRS.createBlockData();
|
||||
stairs.setShape(Stairs.Shape.INNER_LEFT);
|
||||
stairs.setHalf(Stairs.Half.TOP);
|
||||
stairs.setFacing(BlockFace.EAST);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(0, 8, 0, 16, 8, 16));
|
||||
cuboidList.add(pixelCuboid(0, 0, 0, 16, 8, 8));
|
||||
cuboidList.add(pixelCuboid(8, 0, 8, 8, 8, 8));
|
||||
new BlockBoundingBox(stairs, cuboidList, createItem("LAUFBAU_BLOCK_END_STONE_BRICK_STAIRS", Material.END_STONE_BRICK_STAIRS, "LAUFBAU_SHAPE_INNER_LEFT", "LAUFBAU_HALF_TOP", "LAUFBAU_FACING_EAST"));
|
||||
}
|
||||
|
||||
public void innerLeftTopWestStair() {
|
||||
Stairs stairs = (Stairs) Material.END_STONE_BRICK_STAIRS.createBlockData();
|
||||
stairs.setShape(Stairs.Shape.INNER_LEFT);
|
||||
stairs.setHalf(Stairs.Half.TOP);
|
||||
stairs.setFacing(BlockFace.WEST);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(0, 8, 0, 16, 8, 16));
|
||||
cuboidList.add(pixelCuboid(0, 0, 8, 16, 8, 8));
|
||||
cuboidList.add(pixelCuboid(0, 0, 0, 8, 8, 8));
|
||||
new BlockBoundingBox(stairs, cuboidList, createItem("LAUFBAU_BLOCK_END_STONE_BRICK_STAIRS", Material.END_STONE_BRICK_STAIRS, "LAUFBAU_SHAPE_INNER_LEFT", "LAUFBAU_HALF_TOP", "LAUFBAU_FACING_WEST"));
|
||||
}
|
||||
}
|
||||
-79
@@ -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.bausystem.features.slaves.laufbau.boundingboxes;
|
||||
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.BlockBoundingBox;
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.BoundingBoxLoader;
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.Cuboid;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.data.type.Wall;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.createItem;
|
||||
import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.pixelCuboid;
|
||||
|
||||
@Linked
|
||||
public class WallBoundingBox implements BoundingBoxLoader {
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
v18();
|
||||
}
|
||||
|
||||
private void v18() {
|
||||
for (int nx = 0; nx < 2; nx++) {
|
||||
for (int nz = 0; nz < 2; nz++) {
|
||||
for (int px = 0; px < 2; px++) {
|
||||
for (int pz = 0; pz < 2; pz++) {
|
||||
Wall fence = (Wall) Material.END_STONE_BRICK_WALL.createBlockData();
|
||||
List<String> lore = new ArrayList<>();
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(4, 0, 4, 8, 24, 8));
|
||||
if (nz == 1) {
|
||||
lore.add("LAUFBAU_CONNECTION_NORTH");
|
||||
fence.setHeight(BlockFace.NORTH, Wall.Height.LOW);
|
||||
cuboidList.add(pixelCuboid(5, 0, 0, 6, 24, 4));
|
||||
}
|
||||
if (pz == 1) {
|
||||
lore.add("LAUFBAU_CONNECTION_SOUTH");
|
||||
fence.setHeight(BlockFace.SOUTH, Wall.Height.LOW);
|
||||
cuboidList.add(pixelCuboid(5, 0, 12, 6, 24, 4));
|
||||
}
|
||||
if (nx == 1) {
|
||||
lore.add("LAUFBAU_CONNECTION_WEST");
|
||||
fence.setHeight(BlockFace.WEST, Wall.Height.LOW);
|
||||
cuboidList.add(pixelCuboid(0, 0, 5, 4, 24, 6));
|
||||
}
|
||||
if (px == 1) {
|
||||
lore.add("LAUFBAU_CONNECTION_EAST");
|
||||
fence.setHeight(BlockFace.EAST, Wall.Height.LOW);
|
||||
cuboidList.add(pixelCuboid(12, 0, 5, 4, 24, 6));
|
||||
}
|
||||
new BlockBoundingBox(fence, cuboidList, createItem("LAUFBAU_BLOCK_END_STONE_BRICK_WALL", Material.END_STONE_BRICK_WALL, lore.toArray(new String[0])));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
-1
@@ -145,7 +145,6 @@ public class CreatingLaufState implements LaufbauState {
|
||||
}
|
||||
try {
|
||||
BaseBlock block = BukkitAdapter.adapt(highestBlockBoundingBox.blockData).toBaseBlock();
|
||||
if (highestBlockBoundingBox.blockConsumer != null) highestBlockBoundingBox.blockConsumer.accept(block);
|
||||
editSession.setBlock(BukkitAdapter.asBlockVector(location), block);
|
||||
} catch (MaxChangedBlocksException e) {
|
||||
e.printStackTrace();
|
||||
|
||||
+11
-13
@@ -19,11 +19,10 @@
|
||||
|
||||
package de.steamwar.bausystem.features.team.boundary;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.region.Point;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.Bukkit;
|
||||
import de.steamwar.linkage.LinkedTimer;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@@ -38,17 +37,16 @@ public class BoundaryViewer implements Listener {
|
||||
|
||||
public static Set<Player> viewers = new HashSet<>();
|
||||
|
||||
{
|
||||
Bukkit.getScheduler().runTaskTimer(BauSystem.getInstance(), () -> {
|
||||
if (viewers.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
viewers.forEach(player -> {
|
||||
Region region = Region.getRegion(player.getLocation());
|
||||
if (region.getType().isGlobal()) return;
|
||||
showRegion(region, player);
|
||||
});
|
||||
}, 20, 20);
|
||||
@LinkedTimer(delay = 20, period = 20)
|
||||
private void showBoundaries() {
|
||||
if (viewers.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
viewers.forEach(player -> {
|
||||
Region region = Region.getRegion(player.getLocation());
|
||||
if (region.getType().isGlobal()) return;
|
||||
showRegion(region, player);
|
||||
});
|
||||
}
|
||||
|
||||
private void showRegion(Region region, Player player) {
|
||||
|
||||
+161
@@ -0,0 +1,161 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2026 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.bausystem.features.techhider;
|
||||
|
||||
import de.steamwar.bausystem.features.hullhider.HullHiderCommand;
|
||||
import de.steamwar.bausystem.features.world.SpectatorListener;
|
||||
import de.steamwar.bausystem.features.xray.XrayCommand;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.linkage.LinkedInstance;
|
||||
import de.steamwar.techhider.AccessPrivilegeProvider;
|
||||
import de.steamwar.techhider.TechHider;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* The single TechHider of the server. It combines the hiding rules of the spectator techhider, /techhider and /xray and the hulls of /hullhider per player.
|
||||
* Entities are never hidden.
|
||||
*/
|
||||
@Linked
|
||||
public class BauTechHider implements AccessPrivilegeProvider {
|
||||
|
||||
private static final HidingRule[] NO_RULES = new HidingRule[0];
|
||||
private static final HiddenHull[] NO_HULLS = new HiddenHull[0];
|
||||
|
||||
// Injected after construction, until then nothing is hidden
|
||||
@LinkedInstance
|
||||
public XrayCommand xrayCommand;
|
||||
@LinkedInstance
|
||||
public TechHiderCommand techHiderCommand;
|
||||
@LinkedInstance
|
||||
public SpectatorListener spectatorListener;
|
||||
@LinkedInstance
|
||||
public HullHiderCommand hullHiderCommand;
|
||||
|
||||
public BauTechHider() {
|
||||
new TechHider(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ForPlayer forPlayer(Player p) {
|
||||
if (xrayCommand == null || techHiderCommand == null || spectatorListener == null || hullHiderCommand == null) {
|
||||
return new BauPlayerAccess(p, NO_RULES, NO_HULLS);
|
||||
}
|
||||
|
||||
// Region rules first: where rules overlap, the first one decides the obfuscation block
|
||||
List<HidingRule> rules = new ArrayList<>();
|
||||
xrayCommand.addHidingRules(p, rules);
|
||||
techHiderCommand.addHidingRules(p, rules);
|
||||
hullHiderCommand.addHidingRules(p, rules);
|
||||
spectatorListener.addHidingRules(p, rules);
|
||||
|
||||
List<HiddenHull> hulls = new ArrayList<>();
|
||||
hullHiderCommand.addHiddenHulls(p, hulls);
|
||||
return new BauPlayerAccess(p, rules.toArray(NO_RULES), hulls.toArray(NO_HULLS));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlayerPrivilegedToPerformAction(Player p) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Snapshot of the hiding rules of one player, taken once per outgoing packet on the netty thread.
|
||||
*/
|
||||
private record BauPlayerAccess(Player player, HidingRule[] rules, HiddenHull[] hulls) implements ForPlayer {
|
||||
|
||||
@Override
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAccessAllDataWithinChunk(int chunkX, int chunkZ) {
|
||||
for (HidingRule rule : rules) {
|
||||
if (rule.coversChunk(chunkX, chunkZ)) return false;
|
||||
}
|
||||
for (HiddenHull hull : hulls) {
|
||||
if (!hull.hull().getRegion().chunkOutside(chunkX, chunkZ)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAccessPosition(int blockX, int blockY, int blockZ) {
|
||||
for (HiddenHull hull : hulls) {
|
||||
if (hull.hull().isBlockHidden(player, blockX, blockY, blockZ)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAccessBlock(int blockX, int blockY, int blockZ, Block block) {
|
||||
for (HidingRule rule : rules) {
|
||||
if (rule.covers(blockX, blockY, blockZ) && rule.obfuscation().hidesBlock(block)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAccessBlockState(int blockX, int blockY, int blockZ, BlockState blockState) {
|
||||
for (HidingRule rule : rules) {
|
||||
if (rule.covers(blockX, blockY, blockZ) && rule.obfuscation().hidesBlockState(blockState)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAccessEntity(int entityId) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Entities are not hidden, even if they spawn inside a hidden hull
|
||||
@Override
|
||||
public boolean canAccessEntitySpawn(int entityId, int blockX, int blockY, int blockZ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAccessBlockEntity(int blockX, int blockY, int blockZ, BlockEntityType<?> type) {
|
||||
for (HidingRule rule : rules) {
|
||||
if (rule.covers(blockX, blockY, blockZ) && rule.obfuscation().hidesBlockEntity(type)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getObfuscation(int blockX, int blockY, int blockZ) {
|
||||
for (HidingRule rule : rules) {
|
||||
if (rule.covers(blockX, blockY, blockZ)) return rule.obfuscation().getObfuscationState();
|
||||
}
|
||||
for (HiddenHull hull : hulls) {
|
||||
if (hull.hull().getRegion().contains(blockX, blockY, blockZ)) return hull.obfuscation();
|
||||
}
|
||||
// Only asked for positions a rule or hull hides
|
||||
return Blocks.END_STONE.defaultBlockState();
|
||||
}
|
||||
}
|
||||
}
|
||||
+8
-4
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2025 SteamWar.de-Serverteam
|
||||
* Copyright (C) 2026 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
|
||||
@@ -17,9 +17,13 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.slaves.laufbau;
|
||||
package de.steamwar.bausystem.features.techhider;
|
||||
|
||||
public interface BoundingBoxLoader {
|
||||
import de.steamwar.hullhider.Hull;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
void load();
|
||||
/**
|
||||
* A hull a player may not view, and the block sent instead of its hidden blocks.
|
||||
*/
|
||||
public record HiddenHull(Hull hull, BlockState obfuscation) {
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2026 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.bausystem.features.techhider;
|
||||
|
||||
import de.steamwar.bausystem.region.Point;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.hullhider.HullRegion;
|
||||
import de.steamwar.techhider.ObfuscationConfig;
|
||||
|
||||
/**
|
||||
* Hides the blocks of an obfuscation config within an area, or everywhere if the area is null.
|
||||
*/
|
||||
public record HidingRule(HullRegion area, ObfuscationConfig obfuscation) {
|
||||
|
||||
public static HidingRule everywhere(ObfuscationConfig obfuscation) {
|
||||
return new HidingRule(null, obfuscation);
|
||||
}
|
||||
|
||||
/**
|
||||
* Covers the area including its extension.
|
||||
*/
|
||||
public static HidingRule of(Region.Area area, ObfuscationConfig obfuscation) {
|
||||
Point min = area.getMinPoint(true);
|
||||
Point max = area.getMaxPoint(true);
|
||||
return new HidingRule(HullRegion.fromInclusive(min.getX(), min.getY(), min.getZ(), max.getX(), max.getY(), max.getZ()), obfuscation);
|
||||
}
|
||||
|
||||
public boolean covers(int x, int y, int z) {
|
||||
return area == null || area.contains(x, y, z);
|
||||
}
|
||||
|
||||
public boolean coversChunk(int chunkX, int chunkZ) {
|
||||
return area == null || !area.chunkOutside(chunkX, chunkZ);
|
||||
}
|
||||
}
|
||||
+25
-30
@@ -21,17 +21,17 @@ package de.steamwar.bausystem.features.techhider;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.Permission;
|
||||
import de.steamwar.bausystem.features.hullhider.HullHiderCommand;
|
||||
import de.steamwar.bausystem.features.world.SpectatorListener;
|
||||
import de.steamwar.bausystem.features.xray.XrayCommand;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.utils.ScoreboardElement;
|
||||
import de.steamwar.command.PreviousArguments;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.command.TypeMapper;
|
||||
import de.steamwar.core.CraftbukkitWrapper;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.linkage.LinkedInstance;
|
||||
import de.steamwar.techhider.legacy.TechHider;
|
||||
import de.steamwar.techhider.ObfuscationConfig;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -41,21 +41,26 @@ import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Linked
|
||||
public class TechHiderCommand extends SWCommand implements Listener, ScoreboardElement {
|
||||
public class TechHiderCommand extends SWCommand implements Listener {
|
||||
|
||||
public TechHiderCommand() {
|
||||
super("techhider", "hider", "obfuscate", "hide", "hide-tech");
|
||||
}
|
||||
|
||||
private Map<Region, Optional<TechHider>> techHiders = new HashMap<>();
|
||||
private Map<Region, Set<Player>> hidden = new HashMap<>();
|
||||
// Read on netty threads by the BauTechHider
|
||||
private Map<Region, Optional<HidingRule>> hidingRules = new ConcurrentHashMap<>();
|
||||
private Map<Region, Set<Player>> hidden = new ConcurrentHashMap<>();
|
||||
|
||||
@LinkedInstance
|
||||
public XrayCommand xrayCommand;
|
||||
|
||||
@LinkedInstance
|
||||
public HullHiderCommand hullHiderCommand;
|
||||
|
||||
@Register(description = "TECHHIDER_HELP")
|
||||
public void toggleHider(@Validator Player player) {
|
||||
Region region = Region.getRegion(player.getLocation());
|
||||
@@ -64,26 +69,20 @@ public class TechHiderCommand extends SWCommand implements Listener, ScoreboardE
|
||||
return;
|
||||
}
|
||||
|
||||
Optional<TechHider> techHider = techHiders.computeIfAbsent(region, rg -> {
|
||||
Optional<HidingRule> hidingRule = hidingRules.computeIfAbsent(region, rg -> {
|
||||
if (!region.getGameModeConfig().Techhider.Active) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
hidden.put(rg, new HashSet<>());
|
||||
|
||||
TechHider current = new TechHider((p, cX, cY) -> {
|
||||
if (rg.getBuildArea().isChunkOutside(cX, cY)) return true;
|
||||
return !hidden.get(rg).contains(p);
|
||||
}, region.getGameModeConfig().Techhider.ObfuscateWith, region.getGameModeConfig().Techhider.HiddenBlocks, region.getGameModeConfig().Techhider.HiddenBlockEntities);
|
||||
current.enable();
|
||||
|
||||
return Optional.of(current);
|
||||
hidden.put(rg, ConcurrentHashMap.newKeySet());
|
||||
return Optional.of(HidingRule.of(rg.getBuildArea(), ObfuscationConfig.of(rg.getGameModeConfig().Techhider)));
|
||||
});
|
||||
if (!techHider.isPresent()) {
|
||||
if (!hidingRule.isPresent()) {
|
||||
return;
|
||||
}
|
||||
|
||||
xrayCommand.disable(region, player);
|
||||
hullHiderCommand.disable(region, player);
|
||||
if (hidden.get(region).contains(player)) {
|
||||
hidden.get(region).remove(player);
|
||||
BauSystem.MESSAGE.sendPrefixless("TECHHIDER_OFF", player, ChatMessageType.ACTION_BAR);
|
||||
@@ -128,6 +127,14 @@ public class TechHiderCommand extends SWCommand implements Listener, ScoreboardE
|
||||
hidden.values().forEach(set -> set.remove(event.getPlayer()));
|
||||
}
|
||||
|
||||
public void addHidingRules(Player player, List<HidingRule> rules) {
|
||||
hidden.forEach((region, players) -> {
|
||||
if (players.contains(player)) {
|
||||
hidingRules.getOrDefault(region, Optional.empty()).ifPresent(rules::add);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void disable(Region region, Player player) {
|
||||
hidden.computeIfPresent(region, (rg, set) -> {
|
||||
set.remove(player);
|
||||
@@ -135,19 +142,7 @@ public class TechHiderCommand extends SWCommand implements Listener, ScoreboardE
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public ScoreboardGroup getGroup() {
|
||||
return ScoreboardGroup.OTHER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int order() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String get(Region region, Player p) {
|
||||
if (!hidden.getOrDefault(region, Collections.emptySet()).contains(p)) return null;
|
||||
return "§e" + BauSystem.MESSAGE.parse("SCOREBOARD_TECHHIDER", p);
|
||||
public boolean isActive(Region region, Player player) {
|
||||
return hidden.getOrDefault(region, Collections.emptySet()).contains(player);
|
||||
}
|
||||
}
|
||||
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2026 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.bausystem.features.techhider;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.features.hullhider.HullHiderCommand;
|
||||
import de.steamwar.bausystem.features.xray.XrayCommand;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.utils.ScoreboardElement;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.linkage.LinkedInstance;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* Shows which of /techhider, /xray and /hullhider is active, at most one of them can be per region.
|
||||
*/
|
||||
@Linked
|
||||
public class ViewScoreboardElement implements ScoreboardElement {
|
||||
|
||||
@LinkedInstance
|
||||
public TechHiderCommand techHiderCommand;
|
||||
|
||||
@LinkedInstance
|
||||
public XrayCommand xrayCommand;
|
||||
|
||||
@LinkedInstance
|
||||
public HullHiderCommand hullHiderCommand;
|
||||
|
||||
@Override
|
||||
public ScoreboardGroup getGroup() {
|
||||
return ScoreboardGroup.OTHER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int order() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String get(Region region, Player p) {
|
||||
String view;
|
||||
if (techHiderCommand.isActive(region, p)) {
|
||||
view = "TechHider";
|
||||
} else if (xrayCommand.isActive(region, p)) {
|
||||
view = "XRay";
|
||||
} else if (hullHiderCommand.isActive(region, p)) {
|
||||
view = "HullHider";
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
return "§e" + BauSystem.MESSAGE.parse("SCOREBOARD_VIEW", p, view);
|
||||
}
|
||||
}
|
||||
@@ -50,6 +50,9 @@ import java.util.Arrays;
|
||||
@Linked
|
||||
public class TPSSystem implements Listener {
|
||||
|
||||
@Linked
|
||||
private final TickManager tickManager = TickManager.impl;
|
||||
|
||||
public TPSSystem() {
|
||||
if (TickManager.impl.canFreeze()) {
|
||||
new TPSFreezeCommand();
|
||||
@@ -68,7 +71,6 @@ public class TPSSystem implements Listener {
|
||||
new TickDefaultCommand();
|
||||
new TPSBaseCommand();
|
||||
new TickBaseCommand();
|
||||
Bukkit.getPluginManager().registerEvents(TickManager.impl, BauSystem.getInstance());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
||||
+31
-90
@@ -22,123 +22,71 @@ package de.steamwar.bausystem.features.util;
|
||||
import com.comphenix.tinyprotocol.TinyProtocol;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.features.tpslimit.TPSUtils;
|
||||
import de.steamwar.bausystem.utils.BauMemberUpdateEvent;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.core.ProtocolWrapper;
|
||||
import de.steamwar.core.SWPlayer;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import net.minecraft.network.protocol.game.*;
|
||||
import net.minecraft.world.entity.player.Abilities;
|
||||
import net.minecraft.world.level.GameType;
|
||||
import org.bukkit.Bukkit;
|
||||
import io.papermc.paper.event.player.PlayerFailMoveEvent;
|
||||
import net.minecraft.network.protocol.game.ClientboundGameEventPacket;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||
import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockCanBuildEvent;
|
||||
import org.bukkit.event.player.PlayerGameModeChangeEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
import org.bukkit.event.player.PlayerToggleFlightEvent;
|
||||
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
@Linked
|
||||
public class NoClipCommand extends SWCommand implements Listener {
|
||||
|
||||
public static class NoClipData implements SWPlayer.Component {
|
||||
private long lastTick = -1;
|
||||
|
||||
@Override
|
||||
public void onUnmount(SWPlayer player) {
|
||||
player.getPlayer().setGameMode(GameMode.CREATIVE);
|
||||
public void onUnmount(SWPlayer swPlayer) {
|
||||
Player player = swPlayer.getPlayer();
|
||||
showClientGameMode(player, GameMode.CREATIVE, GameMode.CREATIVE);
|
||||
}
|
||||
}
|
||||
|
||||
public NoClipCommand() {
|
||||
super("noclip", "nc");
|
||||
|
||||
BiFunction<Player, ServerboundMovePlayerPacket, Object> first = (player, o) -> {
|
||||
NoClipData noClipData = SWPlayer.of(player).getComponent(NoClipData.class).orElse(null);
|
||||
if (noClipData == null) return o;
|
||||
if (noClipData.lastTick == TPSUtils.currentTick.get()) return o;
|
||||
setInternalGameMode(player, GameMode.SPECTATOR);
|
||||
noClipData.lastTick = TPSUtils.currentTick.get();
|
||||
return o;
|
||||
};
|
||||
TinyProtocol.instance.addFilter(ServerboundMovePlayerPacket.Pos.class, first);
|
||||
TinyProtocol.instance.addFilter(ServerboundMovePlayerPacket.PosRot.class, first);
|
||||
|
||||
BiFunction<Player, Object, Object> second = (player, o) -> {
|
||||
NoClipData noClipData = SWPlayer.of(player).getComponent(NoClipData.class).orElse(null);
|
||||
if (noClipData == null) return o;
|
||||
setInternalGameMode(player, GameMode.CREATIVE);
|
||||
noClipData.lastTick = TPSUtils.currentTick.get();
|
||||
return o;
|
||||
};
|
||||
TinyProtocol.instance.addFilter(ServerboundUseItemOnPacket.class, second);
|
||||
TinyProtocol.instance.addFilter(ServerboundPlayerActionPacket.class, second);
|
||||
TinyProtocol.instance.addFilter(ServerboundContainerClickPacket.class, second);
|
||||
|
||||
BiFunction<Player, ServerboundSetCreativeModeSlotPacket, Object> third = (player, o) -> {
|
||||
if (SWPlayer.of(player).hasComponent(NoClipData.class)) {
|
||||
int index = o.slotNum();
|
||||
if (index >= 36 && index <= 44) {
|
||||
index -= 36;
|
||||
} else if (index > 44) {
|
||||
index -= 5;
|
||||
} else if (index <= 8) {
|
||||
index = index - 8 + 36;
|
||||
}
|
||||
player.getInventory().setItem(index, CraftItemStack.asBukkitCopy(o.itemStack()));
|
||||
if (index < 9) player.getInventory().setHeldItemSlot(index);
|
||||
player.updateInventory();
|
||||
}
|
||||
return o;
|
||||
};
|
||||
TinyProtocol.instance.addFilter(ServerboundSetCreativeModeSlotPacket.class, third);
|
||||
}
|
||||
|
||||
private void setInternalGameMode(Player player, GameMode gameMode) {
|
||||
((CraftPlayer) player).getHandle().gameMode.gameModeForPlayer = GameType.byId(gameMode.getValue());
|
||||
}
|
||||
|
||||
@Register(help = true)
|
||||
@Register
|
||||
public void genericCommand(@Validator Player player) {
|
||||
SWPlayer swPlayer = SWPlayer.of(player);
|
||||
if (swPlayer.hasComponent(NoClipData.class)) {
|
||||
swPlayer.removeComponent(NoClipData.class);
|
||||
} else {
|
||||
player.setGameMode(GameMode.SPECTATOR);
|
||||
Abilities abilities = (((CraftPlayer) player).getHandle()).getAbilities();
|
||||
abilities.mayBuild = true;
|
||||
abilities.mayfly = true;
|
||||
abilities.instabuild = true;
|
||||
|
||||
player.setGameMode(GameMode.CREATIVE);
|
||||
player.setAllowFlight(true);
|
||||
player.setFlying(true);
|
||||
swPlayer.setComponent(new NoClipData());
|
||||
BauSystem.MESSAGE.send("OTHER_NOCLIP_SLOT_INFO", player);
|
||||
TinyProtocol.instance.sendPacket(player, new ClientboundGameEventPacket(ClientboundGameEventPacket.CHANGE_GAME_MODE, 1F));
|
||||
pseudoGameMode(player, GameMode.SPECTATOR);
|
||||
showClientGameMode(player, GameMode.CREATIVE, GameMode.SPECTATOR);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBauMemberUpdate(BauMemberUpdateEvent event) {
|
||||
event.getNewSpectator().forEach(player -> {
|
||||
SWPlayer.of(player).removeComponent(NoClipData.class);
|
||||
});
|
||||
public void onPlayerFailMove(PlayerFailMoveEvent event) {
|
||||
if (event.getFailReason() != PlayerFailMoveEvent.FailReason.CLIPPED_INTO_BLOCK) return;
|
||||
if (!SWPlayer.of(event.getPlayer()).hasComponent(NoClipData.class)) return;
|
||||
event.setAllowed(true);
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
@EventHandler
|
||||
public void onBauMemberUpdate(BauMemberUpdateEvent event) {
|
||||
event.getNewSpectator().forEach(player -> SWPlayer.of(player).removeComponent(NoClipData.class));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerGameModeChange(PlayerGameModeChangeEvent event) {
|
||||
if (SWPlayer.of(event.getPlayer()).hasComponent(NoClipData.class)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
@EventHandler
|
||||
public void onBlock(BlockCanBuildEvent event) {
|
||||
if (event.getPlayer() == null) return;
|
||||
if (SWPlayer.of(event.getPlayer()).hasComponent(NoClipData.class)) {
|
||||
@@ -146,7 +94,7 @@ public class NoClipCommand extends SWCommand implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
@EventHandler
|
||||
public void onPlayerToggleFlight(PlayerToggleFlightEvent event) {
|
||||
if (SWPlayer.of(event.getPlayer()).hasComponent(NoClipData.class)) {
|
||||
event.setCancelled(true);
|
||||
@@ -154,20 +102,13 @@ public class NoClipCommand extends SWCommand implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onPlayerTeleport(PlayerTeleportEvent event) {
|
||||
if (event.getCause() != PlayerTeleportEvent.TeleportCause.SPECTATE) {
|
||||
return;
|
||||
}
|
||||
if (SWPlayer.of(event.getPlayer()).hasComponent(NoClipData.class)) {
|
||||
event.setCancelled(true);
|
||||
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
|
||||
event.getPlayer().setSpectatorTarget(null);
|
||||
}, 1L);
|
||||
}
|
||||
/**
|
||||
* @param player player
|
||||
* @param localMode GameMode for breaking and placing
|
||||
* @param listedMode GameMode for noPhysics
|
||||
*/
|
||||
private static void showClientGameMode(Player player, GameMode localMode, GameMode listedMode) {
|
||||
TinyProtocol.instance.sendPacket(player, new ClientboundGameEventPacket(ClientboundGameEventPacket.CHANGE_GAME_MODE, localMode.getValue()));
|
||||
TinyProtocol.instance.sendPacket(player, ProtocolWrapper.playerInfoPacketConstructor(ProtocolWrapper.PlayerInfoAction.GAMEMODE, new GameProfile(player.getUniqueId(), player.getName()), listedMode));
|
||||
}
|
||||
|
||||
private static void pseudoGameMode(Player player, GameMode gameMode) {
|
||||
TinyProtocol.instance.sendPacket(player, ProtocolWrapper.playerInfoPacketConstructor(ProtocolWrapper.PlayerInfoAction.GAMEMODE, new GameProfile(player.getUniqueId(), player.getName()), gameMode));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+57
-141
@@ -23,15 +23,17 @@ import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.Permission;
|
||||
import de.steamwar.entity.*;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.level.block.piston.PistonStructureResolver;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.PistonMoveReaction;
|
||||
import org.bukkit.block.TileState;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.block.data.type.Piston;
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
import org.bukkit.entity.Display;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.TextDisplay;
|
||||
@@ -92,41 +94,48 @@ public class PistonCalculator implements Listener {
|
||||
@EventHandler
|
||||
public void onBlockPistonExtend(BlockPistonExtendEvent event) {
|
||||
if (pistOrders.isEmpty()) return;
|
||||
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
|
||||
movePistOrders(event.getDirection(), event.getBlocks());
|
||||
pistOrders.values().forEach(PistOrder::calculate);
|
||||
}, 3);
|
||||
removeMovedPistOrders(event.getBlocks());
|
||||
scheduleRecalculate();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBlockPistonRetract(BlockPistonRetractEvent event) {
|
||||
if (pistOrders.isEmpty()) return;
|
||||
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
|
||||
movePistOrders(event.getDirection(), event.getBlocks());
|
||||
pistOrders.values().forEach(PistOrder::calculate);
|
||||
}, 3);
|
||||
removeMovedPistOrders(event.getBlocks());
|
||||
scheduleRecalculate();
|
||||
}
|
||||
|
||||
private void movePistOrders(BlockFace direction, List<Block> blocks) {
|
||||
Set<PistOrder> orders = new HashSet<>();
|
||||
private void removeMovedPistOrders(List<Block> blocks) {
|
||||
blocks.forEach(block -> {
|
||||
PistOrder pistOrder = pistOrders.get(block.getLocation());
|
||||
if (pistOrder == null) return;
|
||||
pistOrders.remove(block.getLocation());
|
||||
pistOrder.piston = pistOrder.piston.getRelative(direction);
|
||||
orders.add(pistOrder);
|
||||
});
|
||||
orders.forEach(pistOrder -> {
|
||||
pistOrders.put(pistOrder.piston.getLocation(), pistOrder);
|
||||
PistOrder pistOrder = pistOrders.remove(block.getLocation());
|
||||
if (pistOrder != null) pistOrder.server.close();
|
||||
});
|
||||
}
|
||||
|
||||
private static final long RECALCULATE_INTERVAL_MS = 200;
|
||||
private boolean recalculationScheduled = false;
|
||||
private long lastRecalculation = 0;
|
||||
|
||||
private void scheduleRecalculate() {
|
||||
if (recalculationScheduled) return;
|
||||
recalculationScheduled = true;
|
||||
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), this::recalculateIfDue, 1);
|
||||
}
|
||||
|
||||
private void recalculateIfDue() {
|
||||
if (System.currentTimeMillis() - lastRecalculation < RECALCULATE_INTERVAL_MS) {
|
||||
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), this::recalculateIfDue, 1);
|
||||
return;
|
||||
}
|
||||
recalculationScheduled = false;
|
||||
lastRecalculation = System.currentTimeMillis();
|
||||
pistOrders.values().forEach(PistOrder::calculate);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBlockPlace(BlockPlaceEvent event) {
|
||||
if (pistOrders.isEmpty()) return;
|
||||
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
|
||||
pistOrders.values().forEach(PistOrder::calculate);
|
||||
}, 1);
|
||||
scheduleRecalculate();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@@ -136,9 +145,7 @@ public class PistonCalculator implements Listener {
|
||||
PistOrder pistOrder = pistOrders.remove(event.getBlock().getLocation());
|
||||
pistOrder.server.close();
|
||||
}
|
||||
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
|
||||
pistOrders.values().forEach(PistOrder::calculate);
|
||||
}, 1);
|
||||
scheduleRecalculate();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@@ -164,13 +171,13 @@ public class PistonCalculator implements Listener {
|
||||
private final Map<Location, PistOrder> pistOrders = new HashMap<>();
|
||||
|
||||
private final class PistOrder {
|
||||
private Block piston;
|
||||
private final Block piston;
|
||||
private REntityServer server = new REntityServer();
|
||||
|
||||
private boolean pulling = false;
|
||||
private List<Location> movedBlocks = new ArrayList<>();
|
||||
private List<Location> brokenBlocks = new ArrayList<>();
|
||||
private Set<Location> immovableBlocks = new HashSet<>();
|
||||
private boolean blocked = false;
|
||||
|
||||
public PistOrder(Block piston) {
|
||||
this.piston = piston;
|
||||
@@ -179,7 +186,7 @@ public class PistonCalculator implements Listener {
|
||||
public void calculate() {
|
||||
movedBlocks.clear();
|
||||
brokenBlocks.clear();
|
||||
immovableBlocks.clear();
|
||||
blocked = false;
|
||||
|
||||
if (piston.isEmpty()) {
|
||||
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
|
||||
@@ -199,7 +206,7 @@ public class PistonCalculator implements Listener {
|
||||
|
||||
pulling = piston.getType() == Material.STICKY_PISTON && (piston.getRelative(pistonData.getFacing()).getType() == Material.AIR || pistonData.isExtended());
|
||||
|
||||
calculate(piston, pistonData.getFacing(), (pulling ? pistonData.getFacing().getOppositeFace() : pistonData.getFacing()));
|
||||
resolve(pistonData.getFacing());
|
||||
|
||||
Collections.reverse(movedBlocks);
|
||||
Collections.reverse(brokenBlocks);
|
||||
@@ -207,86 +214,23 @@ public class PistonCalculator implements Listener {
|
||||
visualize();
|
||||
}
|
||||
|
||||
private void calculate(Block origin, BlockFace facing, BlockFace direction) {
|
||||
Block calcOrigin = origin;
|
||||
if (facing != direction) calcOrigin = origin.getRelative(facing, 3);
|
||||
|
||||
List<Block> toCalc = new LinkedList<>();
|
||||
calcDirection(origin, null, calcOrigin, facing != direction ? origin.getRelative(facing) : null, facing, direction, toCalc);
|
||||
|
||||
while (!toCalc.isEmpty()) {
|
||||
Block current = toCalc.remove(0);
|
||||
if (!movedBlocks.contains(current.getLocation())) {
|
||||
movedBlocks.add(current.getLocation());
|
||||
}
|
||||
|
||||
Material type = current.getType();
|
||||
if (type != Material.SLIME_BLOCK && type != Material.HONEY_BLOCK) continue;
|
||||
Material oppositeType = type == Material.SLIME_BLOCK ? Material.HONEY_BLOCK : Material.SLIME_BLOCK;
|
||||
|
||||
for (BlockFace face : FACES) {
|
||||
Block block = current.getRelative(face);
|
||||
if (block.getType().isAir()) continue;
|
||||
if (isImmovable(block) || block.getPistonMoveReaction() == PistonMoveReaction.BREAK) continue;
|
||||
if (face != direction || face == direction.getOppositeFace()) {
|
||||
switch (block.getType()) {
|
||||
case BLACK_GLAZED_TERRACOTTA:
|
||||
case GRAY_GLAZED_TERRACOTTA:
|
||||
case BLUE_GLAZED_TERRACOTTA:
|
||||
case BROWN_GLAZED_TERRACOTTA:
|
||||
case CYAN_GLAZED_TERRACOTTA:
|
||||
case GREEN_GLAZED_TERRACOTTA:
|
||||
case LIGHT_BLUE_GLAZED_TERRACOTTA:
|
||||
case LIGHT_GRAY_GLAZED_TERRACOTTA:
|
||||
case LIME_GLAZED_TERRACOTTA:
|
||||
case MAGENTA_GLAZED_TERRACOTTA:
|
||||
case ORANGE_GLAZED_TERRACOTTA:
|
||||
case PINK_GLAZED_TERRACOTTA:
|
||||
case PURPLE_GLAZED_TERRACOTTA:
|
||||
case RED_GLAZED_TERRACOTTA:
|
||||
case WHITE_GLAZED_TERRACOTTA:
|
||||
case YELLOW_GLAZED_TERRACOTTA:
|
||||
continue;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (block.getType() != oppositeType) {
|
||||
if (!movedBlocks.contains(block.getLocation())) toCalc.add(block);
|
||||
calcDirection(null, origin, block, null, facing, direction, toCalc);
|
||||
}
|
||||
}
|
||||
private void resolve(BlockFace facing) {
|
||||
PistonStructureResolver resolver = new PistonStructureResolver(
|
||||
((CraftWorld) piston.getWorld()).getHandle(),
|
||||
new BlockPos(piston.getX(), piston.getY(), piston.getZ()),
|
||||
Direction.valueOf(facing.name()),
|
||||
!pulling
|
||||
);
|
||||
if (!resolver.resolve()) {
|
||||
blocked = true;
|
||||
return;
|
||||
}
|
||||
|
||||
movedBlocks.remove(origin.getLocation());
|
||||
if (facing != direction) movedBlocks.remove(origin.getRelative(facing, 1).getLocation());
|
||||
if (pulling) immovableBlocks.remove(origin.getRelative(facing).getLocation());
|
||||
resolver.getToPush().forEach(pos -> movedBlocks.add(toLocation(pos)));
|
||||
resolver.getToDestroy().forEach(pos -> brokenBlocks.add(toLocation(pos)));
|
||||
}
|
||||
|
||||
private void calcDirection(Block origin, Block blockOrigin, Block calcOrigin, Block ignore, BlockFace facing, BlockFace direction, List<Block> toCalc) {
|
||||
for (int i = 1; i < 24; i++) {
|
||||
Block block = calcOrigin.getRelative(direction, i);
|
||||
if (block.equals(ignore)) return;
|
||||
if (block.getPistonMoveReaction() == PistonMoveReaction.BREAK) {
|
||||
if (!brokenBlocks.contains(block.getLocation())) {
|
||||
brokenBlocks.add(block.getLocation());
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (isImmovable(block)) {
|
||||
immovableBlocks.add(block.getLocation());
|
||||
return;
|
||||
}
|
||||
if (block.getType().isAir()) return;
|
||||
if (facing == direction && block.equals(blockOrigin)) {
|
||||
immovableBlocks.add(block.getLocation());
|
||||
return;
|
||||
}
|
||||
if (facing != direction && (block.equals(origin) || block.getRelative(facing.getOppositeFace()).equals(origin))) {
|
||||
return;
|
||||
}
|
||||
if (!movedBlocks.contains(block.getLocation())) toCalc.add(block);
|
||||
}
|
||||
private Location toLocation(BlockPos pos) {
|
||||
return new Location(piston.getWorld(), pos.getX(), pos.getY(), pos.getZ());
|
||||
}
|
||||
|
||||
private void visualize() {
|
||||
@@ -321,21 +265,11 @@ public class PistonCalculator implements Listener {
|
||||
textDisplay.setBrightness(new Display.Brightness(15, 15));
|
||||
}
|
||||
|
||||
for (Location location : immovableBlocks) {
|
||||
CWireframe wireframe = new CWireframe(server);
|
||||
wireframe.setPos1(location);
|
||||
wireframe.setPos2(location);
|
||||
wireframe.setWidth(1 / 32f);
|
||||
wireframe.setBlock(Material.RED_CONCRETE.createBlockData());
|
||||
}
|
||||
|
||||
CWireframe wireframe = new CWireframe(server);
|
||||
wireframe.setPos1(piston.getLocation());
|
||||
wireframe.setPos2(piston.getLocation());
|
||||
if (!immovableBlocks.isEmpty()) {
|
||||
if (blocked) {
|
||||
wireframe.setBlock(Material.RED_CONCRETE.createBlockData());
|
||||
} else if (movedBlocks.size() > 12) {
|
||||
wireframe.setBlock(Material.YELLOW_CONCRETE.createBlockData());
|
||||
} else {
|
||||
wireframe.setBlock(Material.LIME_CONCRETE.createBlockData());
|
||||
}
|
||||
@@ -348,7 +282,11 @@ public class PistonCalculator implements Listener {
|
||||
} else {
|
||||
text.append("§ePush\n");
|
||||
}
|
||||
text.append("§f").append(movedBlocks.size()).append(" §eBlocks");
|
||||
if (blocked) {
|
||||
text.append("§cBlocked");
|
||||
} else {
|
||||
text.append("§f").append(movedBlocks.size()).append(" §eBlocks");
|
||||
}
|
||||
textDisplay.setText(text.toString());
|
||||
textDisplay.setBillboard(Display.Billboard.CENTER);
|
||||
textDisplay.setAlignment(TextDisplay.TextAlignment.CENTER);
|
||||
@@ -358,26 +296,4 @@ public class PistonCalculator implements Listener {
|
||||
textDisplay.setBrightness(new Display.Brightness(15, 15));
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isImmovable(Block block) {
|
||||
if (block.isEmpty() || block.isLiquid()) {
|
||||
return false;
|
||||
}
|
||||
BlockData blockData = block.getBlockData();
|
||||
if (blockData instanceof Piston) {
|
||||
return ((Piston) blockData).isExtended();
|
||||
}
|
||||
if (block.getState() instanceof TileState) {
|
||||
return true;
|
||||
}
|
||||
PistonMoveReaction reaction = block.getPistonMoveReaction();
|
||||
if (reaction == PistonMoveReaction.IGNORE) return true;
|
||||
if (reaction == PistonMoveReaction.BLOCK) return true;
|
||||
switch (block.getType()) {
|
||||
case OBSIDIAN:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+10
-10
@@ -23,6 +23,7 @@ import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.core.CRIUWakeupEvent;
|
||||
import de.steamwar.core.CheckpointUtils;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.linkage.LinkedTimer;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -38,17 +39,16 @@ public class AFKStopperListener implements Listener {
|
||||
|
||||
private long lastMovementTime = System.currentTimeMillis();
|
||||
|
||||
public AFKStopperListener() {
|
||||
Bukkit.getScheduler().runTaskTimer(BauSystem.getInstance(), () -> {
|
||||
long currentTime = System.currentTimeMillis();
|
||||
if (currentTime - lastMovementTime > 10 * 60000) { // 10 Minutes
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
p.kickPlayer(BauSystem.MESSAGE.parse("AFK_KICK_MESSAGE", p));
|
||||
}
|
||||
} else if (currentTime - lastMovementTime > 9 * 60000) {
|
||||
BauSystem.MESSAGE.broadcast("AFK_WARNING_MESSAGE");
|
||||
@LinkedTimer(delay = 1, period = 1, unit = LinkedTimer.Unit.MINUTES)
|
||||
private void checkAfk() {
|
||||
long currentTime = System.currentTimeMillis();
|
||||
if (currentTime - lastMovementTime > 10 * 60000) { // 10 Minutes
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
p.kickPlayer(BauSystem.MESSAGE.parse("AFK_KICK_MESSAGE", p));
|
||||
}
|
||||
}, 1200, 1200); //every minute
|
||||
} else if (currentTime - lastMovementTime > 9 * 60000) {
|
||||
BauSystem.MESSAGE.broadcast("AFK_WARNING_MESSAGE");
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
||||
@@ -28,6 +28,7 @@ import de.steamwar.bausystem.utils.bossbar.BossBarService;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.network.packets.PacketHandler;
|
||||
import de.steamwar.network.packets.server.BaumemberUpdatePacket;
|
||||
import de.steamwar.sql.BauweltMember;
|
||||
import io.papermc.paper.event.player.PlayerPickBlockEvent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.boss.BarColor;
|
||||
@@ -57,6 +58,8 @@ public class BauMemberUpdate extends PacketHandler implements Listener {
|
||||
}
|
||||
|
||||
public static void baumemberUpdate() {
|
||||
// Packet handlers run in no guaranteed order, so don't rely on CoreNetworkHandler having cleared the cache yet.
|
||||
BauweltMember.clear();
|
||||
Set<Player> newSpectator = new HashSet<>();
|
||||
Set<Player> newBuilder = new HashSet<>();
|
||||
Bukkit.getOnlinePlayers().forEach(player -> {
|
||||
|
||||
+12
-18
@@ -22,10 +22,11 @@ package de.steamwar.bausystem.features.world;
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.Permission;
|
||||
import de.steamwar.bausystem.config.BauServer;
|
||||
import de.steamwar.bausystem.features.techhider.HidingRule;
|
||||
import de.steamwar.bausystem.utils.BauMemberUpdateEvent;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.sql.BauweltMember;
|
||||
import de.steamwar.techhider.legacy.TechHider;
|
||||
import de.steamwar.techhider.ObfuscationConfig;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
@@ -41,14 +42,18 @@ import org.bukkit.event.entity.EntityPickupItemEvent;
|
||||
import org.bukkit.event.player.*;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
@Linked
|
||||
public class SpectatorListener implements Listener {
|
||||
|
||||
private static final TechHider techHider;
|
||||
private static final Set<Player> NO_TECHHIDER = new HashSet<>();
|
||||
private static final HidingRule SPECTATOR_RULE;
|
||||
// Read on netty threads by the BauTechHider
|
||||
private static final Set<Player> NO_TECHHIDER = ConcurrentHashMap.newKeySet();
|
||||
|
||||
static {
|
||||
Set<Material> materials = new HashSet<>();
|
||||
@@ -99,19 +104,12 @@ public class SpectatorListener implements Listener {
|
||||
materials.add(Material.WATER);
|
||||
materials.remove(Material.BARRIER);
|
||||
materials.remove(Material.STONE);
|
||||
techHider = new TechHider((TechHider.LocationEvaluator) (player, i, i1) -> {
|
||||
return Permission.BUILD.hasPermission(player) || NO_TECHHIDER.contains(player);
|
||||
}, Material.END_STONE, materials, new HashSet<>());
|
||||
SPECTATOR_RULE = HidingRule.everywhere(new ObfuscationConfig(Material.END_STONE, materials, Collections.emptySet()));
|
||||
}
|
||||
|
||||
private static void enableOrDisableTechhider() {
|
||||
boolean enable = Bukkit.getOnlinePlayers()
|
||||
.stream()
|
||||
.anyMatch(player -> !(Permission.BUILD.hasPermission(player) || NO_TECHHIDER.contains(player)));
|
||||
if (enable) {
|
||||
techHider.enable();
|
||||
} else {
|
||||
techHider.disable();
|
||||
public void addHidingRules(Player player, List<HidingRule> rules) {
|
||||
if (!(Permission.BUILD.hasPermission(player) || NO_TECHHIDER.contains(player))) {
|
||||
rules.add(SPECTATOR_RULE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,7 +120,6 @@ public class SpectatorListener implements Listener {
|
||||
NO_TECHHIDER.add(player);
|
||||
}
|
||||
resendChunks(player);
|
||||
enableOrDisableTechhider();
|
||||
}
|
||||
|
||||
private static void resendChunks(Player player) {
|
||||
@@ -141,7 +138,6 @@ public class SpectatorListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
enableOrDisableTechhider();
|
||||
if (BauSystem.DEV_SERVER) return;
|
||||
if (event.getPlayer().getUniqueId().equals(BauServer.getInstance().getOwner())) {
|
||||
return;
|
||||
@@ -163,7 +159,6 @@ public class SpectatorListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onBauMemberUpdate(BauMemberUpdateEvent event) {
|
||||
enableOrDisableTechhider();
|
||||
if (!anySupervisorOnline(null) && !BauSystem.DEV_SERVER) {
|
||||
Bukkit.getOnlinePlayers().forEach(player -> {
|
||||
player.kickPlayer("");
|
||||
@@ -180,7 +175,6 @@ public class SpectatorListener implements Listener {
|
||||
@EventHandler
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
NO_TECHHIDER.remove(event.getPlayer());
|
||||
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), SpectatorListener::enableOrDisableTechhider, 1);
|
||||
if (BauSystem.DEV_SERVER) return;
|
||||
if (!anySupervisorOnline(event.getPlayer())) {
|
||||
Bukkit.getOnlinePlayers().forEach(player -> {
|
||||
|
||||
@@ -21,14 +21,15 @@ package de.steamwar.bausystem.features.xray;
|
||||
|
||||
import com.comphenix.tinyprotocol.TinyProtocol;
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.features.hullhider.HullHiderCommand;
|
||||
import de.steamwar.bausystem.features.techhider.HidingRule;
|
||||
import de.steamwar.bausystem.features.techhider.TechHiderCommand;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.utils.ScoreboardElement;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.core.CraftbukkitWrapper;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.linkage.LinkedInstance;
|
||||
import de.steamwar.techhider.legacy.TechHider;
|
||||
import de.steamwar.techhider.ObfuscationConfig;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import net.minecraft.network.protocol.game.ServerboundMovePlayerPacket;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
@@ -43,22 +44,27 @@ import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
@Linked
|
||||
public class XrayCommand extends SWCommand implements Listener, ScoreboardElement {
|
||||
public class XrayCommand extends SWCommand implements Listener {
|
||||
|
||||
public XrayCommand() {
|
||||
super("xray");
|
||||
}
|
||||
|
||||
private Map<Region, Optional<TechHider>> techHiders = new HashMap<>();
|
||||
// Read on netty threads by the BauTechHider and the movement filter
|
||||
private Map<Region, Optional<HidingRule>> hidingRules = new ConcurrentHashMap<>();
|
||||
private Map<Region, Set<Material>> xrayedBlocks = new HashMap<>();
|
||||
private Map<Region, Set<Player>> hidden = new HashMap<>();
|
||||
private Map<Region, Set<Player>> hidden = new ConcurrentHashMap<>();
|
||||
|
||||
@LinkedInstance
|
||||
public TechHiderCommand techHiderCommand;
|
||||
|
||||
@LinkedInstance
|
||||
public HullHiderCommand hullHiderCommand;
|
||||
|
||||
@Register(description = "XRAY_HELP")
|
||||
public void toggleHider(@Validator Player player) {
|
||||
Region region = Region.getRegion(player.getLocation());
|
||||
@@ -67,23 +73,24 @@ public class XrayCommand extends SWCommand implements Listener, ScoreboardElemen
|
||||
return;
|
||||
}
|
||||
|
||||
Optional<TechHider> techHider = techHiders.computeIfAbsent(region, rg -> {
|
||||
Optional<HidingRule> hidingRule = hidingRules.computeIfAbsent(region, rg -> {
|
||||
if (!region.getGameModeConfig().Techhider.Active) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
hidden.put(rg, new HashSet<>());
|
||||
hidden.put(rg, ConcurrentHashMap.newKeySet());
|
||||
|
||||
Set<Material> blocks = new HashSet<>(Arrays.asList(region.getGameModeConfig().Techhider.ObfuscateWith));
|
||||
if (blocks.contains(Material.END_STONE)) blocks.add(Material.END_STONE_BRICKS);
|
||||
xrayedBlocks.put(region, blocks);
|
||||
return Optional.of(createXray(rg, blocks));
|
||||
return Optional.of(HidingRule.of(rg.getBuildArea(), new ObfuscationConfig(Material.STRUCTURE_VOID, blocks, Collections.emptySet())));
|
||||
});
|
||||
if (!techHider.isPresent()) {
|
||||
if (!hidingRule.isPresent()) {
|
||||
return;
|
||||
}
|
||||
|
||||
techHiderCommand.disable(region, player);
|
||||
hullHiderCommand.disable(region, player);
|
||||
if (hidden.get(region).contains(player)) {
|
||||
hidden.get(region).remove(player);
|
||||
BauSystem.MESSAGE.sendPrefixless("XRAY_OFF", player, ChatMessageType.ACTION_BAR);
|
||||
@@ -139,13 +146,12 @@ public class XrayCommand extends SWCommand implements Listener, ScoreboardElemen
|
||||
}
|
||||
}
|
||||
|
||||
private TechHider createXray(Region rg, Set<Material> obfuscate) {
|
||||
TechHider current = new TechHider((TechHider.LocationEvaluator) (p, cX, cY) -> {
|
||||
if (rg.getBuildArea().isChunkOutside(cX, cY)) return true;
|
||||
return !hidden.get(rg).contains(p);
|
||||
}, Material.STRUCTURE_VOID, obfuscate, new HashSet<>());
|
||||
current.enable();
|
||||
return current;
|
||||
public void addHidingRules(Player player, List<HidingRule> rules) {
|
||||
hidden.forEach((region, players) -> {
|
||||
if (players.contains(player)) {
|
||||
hidingRules.getOrDefault(region, Optional.empty()).ifPresent(rules::add);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@@ -160,19 +166,7 @@ public class XrayCommand extends SWCommand implements Listener, ScoreboardElemen
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public ScoreboardGroup getGroup() {
|
||||
return ScoreboardGroup.OTHER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int order() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String get(Region region, Player p) {
|
||||
if (!hidden.getOrDefault(region, Collections.emptySet()).contains(p)) return null;
|
||||
return "§e" + BauSystem.MESSAGE.parse("SCOREBOARD_XRAY", p);
|
||||
public boolean isActive(Region region, Player player) {
|
||||
return hidden.getOrDefault(region, Collections.emptySet()).contains(player);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,6 +44,8 @@ public final class Flag<T extends Enum<T> & Flag.Value<T>> implements EnumDispla
|
||||
public static final Flag<TestblockMode> TESTBLOCK = new Flag<>("TESTBLOCK", "FLAG_TESTBLOCK", TestblockMode.class, TestblockMode.NO_VALUE);
|
||||
public static final Flag<ChangedMode> CHANGED = new Flag<>("CHANGED", "FLAG_CHANGED", ChangedMode.class, ChangedMode.NO_CHANGE);
|
||||
public static final Flag<WaterDestroyMode> WATER_DESTROY = new Flag<>("WATER_DESTROY", "FLAG_WATER_DESTROY", WaterDestroyMode.class, WaterDestroyMode.ALLOW);
|
||||
public static final Flag<WindChargeInteractMode> WIND_CHARGE_INTERACT = new Flag<>("WINDCHARGE_INTERACT", "FLAG_WINDCHARGE_INTERACT", WindChargeInteractMode.class, WindChargeInteractMode.ALLOW);
|
||||
public static final Flag<ProjectileStopperMode> PROJECTILE_STOPPER = new Flag<>("PROJECTILE_STOPPER", "FLAG_PROJECTILE_STOPPER", ProjectileStopperMode.class, ProjectileStopperMode.ENABLED);
|
||||
|
||||
private String name;
|
||||
private int ordinal;
|
||||
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2026 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.bausystem.region.flags;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum ProjectileStopperMode implements Flag.Value<ProjectileStopperMode> {
|
||||
ENABLED("FLAG_PROJECTILE_STOPPER_ENABLED"),
|
||||
DISABLED("FLAG_PROJECTILE_STOPPER_DISABLED");
|
||||
|
||||
private static WindChargeInteractMode[] values;
|
||||
private final String chatValue;
|
||||
|
||||
@Override
|
||||
public ProjectileStopperMode[] getValues() {
|
||||
return ProjectileStopperMode.values();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProjectileStopperMode getValue() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProjectileStopperMode getValueOf(final String name) {
|
||||
try {
|
||||
return ProjectileStopperMode.valueOf(name.toUpperCase());
|
||||
} catch (IllegalArgumentException e) {
|
||||
return ProjectileStopperMode.ENABLED;
|
||||
}
|
||||
}
|
||||
}
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2026 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.bausystem.region.flags;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum WindChargeInteractMode implements Flag.Value<WindChargeInteractMode> {
|
||||
|
||||
ALLOW("FLAG_WINDCHARGE_INTERACT_ALLOW"),
|
||||
DENY("FLAG_WINDCHARGE_INTERACT_DENY");
|
||||
|
||||
private static WindChargeInteractMode[] values;
|
||||
private final String chatValue;
|
||||
|
||||
@Override
|
||||
public WindChargeInteractMode[] getValues() {
|
||||
return WindChargeInteractMode.values();
|
||||
}
|
||||
|
||||
@Override
|
||||
public WindChargeInteractMode getValue() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WindChargeInteractMode getValueOf(final String name) {
|
||||
try {
|
||||
return WindChargeInteractMode.valueOf(name.toUpperCase());
|
||||
} catch (IllegalArgumentException e) {
|
||||
return WindChargeInteractMode.ALLOW;
|
||||
}
|
||||
}
|
||||
}
|
||||
+4
-5
@@ -21,10 +21,7 @@ package de.steamwar.bausystem.region.fixed;
|
||||
|
||||
import de.steamwar.bausystem.region.RegionData;
|
||||
import de.steamwar.bausystem.region.RegionFlagPolicy;
|
||||
import de.steamwar.bausystem.region.flags.ColorMode;
|
||||
import de.steamwar.bausystem.region.flags.Flag;
|
||||
import de.steamwar.bausystem.region.flags.ProtectMode;
|
||||
import de.steamwar.bausystem.region.flags.TNTMode;
|
||||
import de.steamwar.bausystem.region.flags.*;
|
||||
import de.steamwar.bausystem.worlddata.WorldData;
|
||||
import lombok.NonNull;
|
||||
|
||||
@@ -39,6 +36,8 @@ public class FixedGlobalRegionData extends RegionData {
|
||||
flagMap.put(Flag.TNT, TNTMode.DENY);
|
||||
flagMap.put(Flag.COLOR, ColorMode.YELLOW);
|
||||
flagMap.put(Flag.PROTECT, ProtectMode.INACTIVE);
|
||||
flagMap.put(Flag.WIND_CHARGE_INTERACT, WindChargeInteractMode.ALLOW);
|
||||
flagMap.put(Flag.PROJECTILE_STOPPER, ProjectileStopperMode.ENABLED);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -49,7 +48,7 @@ public class FixedGlobalRegionData extends RegionData {
|
||||
if (flag.oneOf(Flag.ITEMS)) {
|
||||
return RegionFlagPolicy.WRITABLE;
|
||||
}
|
||||
if (flag.oneOf(Flag.TNT, Flag.FIRE, Flag.FREEZE)) {
|
||||
if (flag.oneOf(Flag.TNT, Flag.FIRE, Flag.FREEZE, Flag.PROJECTILE_STOPPER, Flag.WIND_CHARGE_INTERACT )) {
|
||||
return RegionFlagPolicy.WRITABLE;
|
||||
}
|
||||
return RegionFlagPolicy.NOT_APPLICABLE;
|
||||
|
||||
+1
-1
@@ -33,7 +33,7 @@ public class FixedRegionData extends RegionData {
|
||||
|
||||
@Override
|
||||
public @NonNull <T extends Enum<T> & Flag.Value<T>> RegionFlagPolicy has(@NonNull Flag<T> flag) {
|
||||
if (flag.oneOf(Flag.COLOR, Flag.TNT, Flag.FIRE, Flag.FREEZE, Flag.PROTECT, Flag.NO_GRAVITY, Flag.CHANGED, Flag.WATER_DESTROY)) {
|
||||
if (flag.oneOf(Flag.COLOR, Flag.TNT, Flag.FIRE, Flag.FREEZE, Flag.PROTECT, Flag.NO_GRAVITY, Flag.CHANGED, Flag.WATER_DESTROY, Flag.WIND_CHARGE_INTERACT, Flag.PROJECTILE_STOPPER)) {
|
||||
return RegionFlagPolicy.WRITABLE;
|
||||
}
|
||||
if (flag.oneOf(Flag.ITEMS)) {
|
||||
|
||||
@@ -91,9 +91,13 @@ public abstract class AbstractSWCommand<T> {
|
||||
if (commandList.stream().noneMatch(s -> s.invoke(errors::add, sender, alias, args))) {
|
||||
errors.forEach(Runnable::run);
|
||||
} else return;
|
||||
if (errors.isEmpty() && helpCommandList.stream().noneMatch(s -> s.invoke(errors::add, sender, alias, args))) {
|
||||
errors.forEach(Runnable::run);
|
||||
if (!errors.isEmpty()) return;
|
||||
for (SubCommand<T> help : helpCommandList) {
|
||||
// Generic help must not hide the error of a more specific command
|
||||
if (help.noTabComplete && !errors.isEmpty()) break;
|
||||
if (help.invoke(errors::add, sender, alias, args)) return;
|
||||
}
|
||||
errors.forEach(Runnable::run);
|
||||
} catch (CommandFrameworkException e) {
|
||||
commandSystemError(sender, e);
|
||||
throw e;
|
||||
|
||||
@@ -22,12 +22,18 @@ package de.steamwar.linkage;
|
||||
import de.steamwar.linkage.api.Disable;
|
||||
import de.steamwar.linkage.api.Enable;
|
||||
import lombok.NonNull;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.experimental.StandardException;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.lang.invoke.MethodHandle;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.lang.invoke.MethodType;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -38,6 +44,7 @@ public abstract class AbstractLinker<T> {
|
||||
|
||||
protected final T plugin;
|
||||
private Map<Class<?>, Object> instances = new HashMap<>();
|
||||
private final List<Object> fieldInstances = new ArrayList<>();
|
||||
|
||||
protected AbstractLinker(@NonNull T plugin) {
|
||||
this.plugin = plugin;
|
||||
@@ -90,6 +97,7 @@ public abstract class AbstractLinker<T> {
|
||||
((Enable) any).enable();
|
||||
}
|
||||
linkObject(any);
|
||||
linkFields(any);
|
||||
});
|
||||
} catch (SecurityException e) {
|
||||
Throwable cause = e.getCause();
|
||||
@@ -117,6 +125,70 @@ public abstract class AbstractLinker<T> {
|
||||
Throwable cause = e.getCause();
|
||||
throw new LinkException(cause.getMessage(), cause);
|
||||
}
|
||||
|
||||
// After the injection, as timers may run immediately on another thread
|
||||
for (Object any : instances.values()) {
|
||||
scheduleTimers(any);
|
||||
}
|
||||
for (Object any : fieldInstances) {
|
||||
scheduleTimers(any);
|
||||
}
|
||||
}
|
||||
|
||||
private void scheduleTimers(Object any) throws LinkException {
|
||||
for (Method method : any.getClass().getDeclaredMethods()) {
|
||||
LinkedTimer timer = method.getAnnotation(LinkedTimer.class);
|
||||
if (timer == null) continue;
|
||||
|
||||
String name = any.getClass().getName() + "." + method.getName();
|
||||
if (method.getParameterCount() != 0) {
|
||||
throw new LinkException("Linked timer " + name + " must not have parameters");
|
||||
}
|
||||
|
||||
MethodHandle handle;
|
||||
try {
|
||||
handle = MethodHandles.privateLookupIn(method.getDeclaringClass(), MethodHandles.lookup()).unreflect(method);
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new LinkException("Could not access linked timer " + name, e);
|
||||
}
|
||||
if (!Modifier.isStatic(method.getModifiers())) {
|
||||
handle = handle.bindTo(any);
|
||||
}
|
||||
// Discards the return value
|
||||
MethodHandle timerHandle = handle.asType(MethodType.methodType(void.class));
|
||||
|
||||
scheduleTimer(() -> runTimer(timerHandle), timer.delay(), timer.period(), timer.unit());
|
||||
}
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
private static void runTimer(MethodHandle timer) {
|
||||
timer.invokeExact();
|
||||
}
|
||||
|
||||
private void linkFields(Object any) {
|
||||
for (Field field : any.getClass().getDeclaredFields()) {
|
||||
if (field.getAnnotation(Linked.class) == null) continue;
|
||||
|
||||
Object value;
|
||||
try {
|
||||
field.setAccessible(true);
|
||||
value = field.get(Modifier.isStatic(field.getModifiers()) ? null : any);
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new SecurityException(e.getMessage(), e);
|
||||
}
|
||||
|
||||
if (value == null) {
|
||||
String message = "Linked field " + any.getClass().getName() + "." + field.getName() + " is not initialised";
|
||||
throw new SecurityException(message, new IllegalStateException(message));
|
||||
}
|
||||
|
||||
fieldInstances.add(value);
|
||||
if (value instanceof Enable) {
|
||||
((Enable) value).enable();
|
||||
}
|
||||
linkObject(value);
|
||||
}
|
||||
}
|
||||
|
||||
public final void unlink() {
|
||||
@@ -126,6 +198,12 @@ public abstract class AbstractLinker<T> {
|
||||
((Disable) any).disable();
|
||||
}
|
||||
});
|
||||
fieldInstances.forEach(any -> {
|
||||
unlinkObject(any);
|
||||
if (any instanceof Disable) {
|
||||
((Disable) any).disable();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public final void addLinkableInstance(@NonNull Object instance) {
|
||||
@@ -152,6 +230,14 @@ public abstract class AbstractLinker<T> {
|
||||
protected void linkObject(Object any) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs the runnable repeatedly for a {@link LinkedTimer}.
|
||||
*
|
||||
* @param delay time until the first run, in unit
|
||||
* @param period time between two runs, in unit
|
||||
*/
|
||||
protected abstract void scheduleTimer(Runnable runnable, long delay, long period, LinkedTimer.Unit unit);
|
||||
|
||||
/**
|
||||
* There is no need in calling {@link Disable#disable()} ()} by this method.
|
||||
*/
|
||||
|
||||
@@ -26,8 +26,12 @@ import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* On a class: the class is instantiated and linked.
|
||||
* On a field of a linked class: the (already initialised) value of the field is linked as well, e.g. registered as listener.
|
||||
*/
|
||||
@IndexAnnotated
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
@Target({ElementType.TYPE})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ElementType.TYPE, ElementType.FIELD})
|
||||
public @interface Linked {
|
||||
}
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2026 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.linkage;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* Runs the annotated method of a linked class (or of the value of a {@link Linked} field) repeatedly.
|
||||
* The method must not have parameters, its return value is ignored. It may be static.
|
||||
* The timer is not stopped on unlink, as the server stops anyway.
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ElementType.METHOD})
|
||||
public @interface LinkedTimer {
|
||||
|
||||
/**
|
||||
* Time until the first run, in {@link #unit()}.
|
||||
*/
|
||||
long delay();
|
||||
|
||||
/**
|
||||
* Time between two runs, in {@link #unit()}.
|
||||
*/
|
||||
long period();
|
||||
|
||||
Unit unit() default Unit.TICKS;
|
||||
|
||||
@AllArgsConstructor
|
||||
enum Unit {
|
||||
/**
|
||||
* 1 tick = 50 ms
|
||||
*/
|
||||
TICKS(50, TimeUnit.MILLISECONDS),
|
||||
MILLISECONDS(1, TimeUnit.MILLISECONDS),
|
||||
SECONDS(1, TimeUnit.SECONDS),
|
||||
MINUTES(1, TimeUnit.MINUTES),
|
||||
HOURS(1, TimeUnit.HOURS);
|
||||
|
||||
private final long factor;
|
||||
@Getter
|
||||
private final TimeUnit timeUnit;
|
||||
|
||||
/**
|
||||
* @return the value in ticks, rounded down
|
||||
*/
|
||||
public long toTicks(long value) {
|
||||
return timeUnit.toMillis(value * factor) / 50;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the value in {@link #getTimeUnit()}
|
||||
*/
|
||||
public long toTimeUnit(long value) {
|
||||
return value * factor;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -30,6 +30,7 @@ import org.jetbrains.exposed.v1.dao.CompositeEntity
|
||||
import org.jetbrains.exposed.v1.dao.CompositeEntityClass
|
||||
import org.jetbrains.exposed.v1.jdbc.insertIgnore
|
||||
import java.util.*
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
|
||||
object BauweltMemberTable : CompositeIdTable("BauweltMember") {
|
||||
val bauweltId = reference("BauweltID", SteamwarUserTable).index()
|
||||
@@ -48,10 +49,12 @@ object BauweltMemberTable : CompositeIdTable("BauweltMember") {
|
||||
|
||||
class BauweltMember(id: EntityID<CompositeID>) : CompositeEntity(id) {
|
||||
companion object : CompositeEntityClass<BauweltMember>(BauweltMemberTable) {
|
||||
private val cache = mutableMapOf<Int, BauweltMember>()
|
||||
// Keyed by (bauweltId, memberId). Optional.empty() caches "is not a member", which is the
|
||||
// common case for spectators and would otherwise hit the DB on every permission check.
|
||||
private val cache = ConcurrentHashMap<Pair<Int, Int>, Optional<BauweltMember>>()
|
||||
|
||||
private fun cache(member: BauweltMember) =
|
||||
cache.put(member.memberID, member)
|
||||
cache.put(member.bauweltID to member.memberID, Optional.of(member))
|
||||
|
||||
@JvmStatic
|
||||
fun clear() =
|
||||
@@ -75,20 +78,20 @@ class BauweltMember(id: EntityID<CompositeID>) : CompositeEntity(id) {
|
||||
it[worldEdit] = false
|
||||
it[world] = false
|
||||
}
|
||||
}
|
||||
}.also { cache.remove(ownerId.value to newMemberId.value) }
|
||||
|
||||
@JvmStatic
|
||||
@Deprecated("Use getBauMember(bauwelt: Int, member: Int)")
|
||||
fun getBauMember(bauwelt: UUID, member: UUID) =
|
||||
useDb {
|
||||
find { (bauweltId eq SteamwarUser.get(bauwelt)!!.id) and (BauweltMemberTable.memberId eq SteamwarUser.get(member)!!.id) }.firstOrNull()?.also { cache(it) }
|
||||
}
|
||||
getBauMember(SteamwarUser.get(bauwelt)!!.id.value, SteamwarUser.get(member)!!.id.value)
|
||||
|
||||
@JvmStatic
|
||||
fun getBauMember(bauwelt: Int, member: Int) =
|
||||
useDb {
|
||||
find { (bauweltId eq bauwelt) and (BauweltMemberTable.memberId eq member) }.firstOrNull()?.also { cache(it) }
|
||||
}
|
||||
fun getBauMember(bauwelt: Int, member: Int): BauweltMember? =
|
||||
cache.computeIfAbsent(bauwelt to member) {
|
||||
Optional.ofNullable(useDb {
|
||||
find { (bauweltId eq bauwelt) and (BauweltMemberTable.memberId eq member) }.firstOrNull()
|
||||
})
|
||||
}.orElse(null)
|
||||
|
||||
@JvmStatic
|
||||
@Deprecated("Use getMembers(bauwelt: Int)")
|
||||
@@ -140,8 +143,11 @@ class BauweltMember(id: EntityID<CompositeID>) : CompositeEntity(id) {
|
||||
fun isWorld() =
|
||||
world
|
||||
|
||||
fun remove() =
|
||||
fun remove() {
|
||||
val key = bauweltID to memberID
|
||||
useDb {
|
||||
delete()
|
||||
}
|
||||
cache.remove(key)
|
||||
}
|
||||
}
|
||||
@@ -633,6 +633,15 @@ public final class GameModeConfig<M, W> {
|
||||
*/
|
||||
public final List<SchematicType> SubTypes;
|
||||
|
||||
/**
|
||||
* List of publics that should be used. Mainly useful for an Event Mode
|
||||
* where a subset of the regular publics should be used without duplicating
|
||||
* those in the Database.
|
||||
*
|
||||
* @implSpec {@code []} by default, thus the GameModes publics are used.
|
||||
*/
|
||||
public final List<Integer> Publics;
|
||||
|
||||
/**
|
||||
* Shortcut of the schematic type
|
||||
*
|
||||
@@ -741,6 +750,7 @@ public final class GameModeConfig<M, W> {
|
||||
Inset = new InsetConfig(loader.with("Inset"));
|
||||
Type = null;
|
||||
SubTypesStrings = loader.getStringList("SubTypes");
|
||||
Publics = loader.getIntList("Publics");
|
||||
SubTypes = new ArrayList<>();
|
||||
Shortcut = loader.getString("Shortcut", "");
|
||||
Material = loader.getMaterial("Material", "STONE_BUTTON");
|
||||
|
||||
@@ -30,6 +30,7 @@ dependencies {
|
||||
compileOnly(libs.classindex)
|
||||
annotationProcessor(libs.classindex)
|
||||
compileOnly(project(":SpigotCore", "default"))
|
||||
implementation(project(":HiderCore"))
|
||||
|
||||
compileOnly(libs.netty)
|
||||
compileOnly(libs.paperapi)
|
||||
|
||||
@@ -34,9 +34,11 @@ import org.bukkit.util.Vector;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collections;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class Config {
|
||||
|
||||
@@ -80,7 +82,7 @@ public class Config {
|
||||
|
||||
//event parameter
|
||||
public static final EventFight EventKampf;
|
||||
private static final Set<Integer> Referees;
|
||||
private static final Set<UUID> Referees;
|
||||
public static final int EventTeamBlueID;
|
||||
public static final int EventTeamRedID;
|
||||
public static final boolean BothTeamsPublic;
|
||||
@@ -237,7 +239,11 @@ public class Config {
|
||||
BothTeamsPublic = EventTeamRedID == 0 && EventTeamBlueID == 0;
|
||||
SpectatePort = EventKampf.getSpectatePort() == null ? 0 : EventKampf.getSpectatePort();
|
||||
LiveReplay = SpectatePort != 0;
|
||||
Referees = Referee.get(Config.EventKampf.getEventID());
|
||||
Referees = Referee.get(Config.EventKampf.getEventID()).stream()
|
||||
.map(SteamwarUser::byId)
|
||||
.filter(Objects::nonNull)
|
||||
.map(SteamwarUser::getUUID)
|
||||
.collect(Collectors.toUnmodifiableSet());
|
||||
|
||||
Event event = Event.byId(EventKampf.getEventID());
|
||||
if (BothTeamsPublic) {
|
||||
@@ -305,6 +311,6 @@ public class Config {
|
||||
}
|
||||
|
||||
public static boolean isReferee(Player player) {
|
||||
return Referees.contains(SteamwarUser.get(player.getUniqueId()).getId());
|
||||
return Referees.contains(player.getUniqueId());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,8 +32,8 @@ import de.steamwar.fightsystem.record.GlobalRecorder;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.OneShotStateDependent;
|
||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||
import de.steamwar.fightsystem.utils.FightHullHider;
|
||||
import de.steamwar.fightsystem.utils.FightUI;
|
||||
import de.steamwar.fightsystem.utils.HullHider;
|
||||
import de.steamwar.fightsystem.utils.SWSound;
|
||||
import de.steamwar.fightsystem.utils.TechHiderWrapper;
|
||||
import de.steamwar.linkage.AbstractLinker;
|
||||
@@ -58,7 +58,7 @@ public class FightSystem extends JavaPlugin {
|
||||
private FightTeam lastWinner;
|
||||
private String lastWinreason;
|
||||
private TechHiderWrapper techHider;
|
||||
private HullHider hullHider;
|
||||
private FightHullHider hullHider;
|
||||
|
||||
private SpigotLinker spigotLinker;
|
||||
|
||||
@@ -116,9 +116,9 @@ public class FightSystem extends JavaPlugin {
|
||||
new OneShotStateDependent(ArenaMode.Test, FightState.All, SteamEdit::init);
|
||||
Config.world.setGameRule(GameRule.REDUCED_DEBUG_INFO, ArenaMode.AntiTest.contains(Config.mode));
|
||||
|
||||
hullHider = new HullHider();
|
||||
hullHider = new FightHullHider();
|
||||
techHider = new TechHiderWrapper(hullHider);
|
||||
FightSystem.getHullHider().getHullMap().values().forEach(hull -> hull.fill(true));
|
||||
hullHider.fillAll(true);
|
||||
|
||||
|
||||
FileSource.startReplay();
|
||||
@@ -170,7 +170,7 @@ public class FightSystem extends JavaPlugin {
|
||||
return plugin.techHider;
|
||||
}
|
||||
|
||||
public static HullHider getHullHider() {
|
||||
public static FightHullHider getHullHider() {
|
||||
return plugin.hullHider;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,19 +20,14 @@
|
||||
package de.steamwar.fightsystem.ai;
|
||||
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.fight.FightSchematic;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.sql.SchematicNode;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class DummyAI extends AI {
|
||||
|
||||
private static final Random random = new Random();
|
||||
|
||||
public DummyAI(FightTeam team) {
|
||||
super(team, SteamwarUser.get("public"));
|
||||
|
||||
@@ -41,8 +36,7 @@ public class DummyAI extends AI {
|
||||
|
||||
@Override
|
||||
public SchematicNode chooseSchematic() {
|
||||
List<SchematicNode> publics = SchematicNode.getAllSchematicsOfType(0, Config.GameModeConfig.Schematic.Type.toDB());
|
||||
return publics.get(random.nextInt(publics.size()));
|
||||
return FightSchematic.getPublicSchematic().orElseThrow();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -255,7 +255,15 @@ public class GUI {
|
||||
private static void schemDialog(Player p, SchematicType type, boolean publicSchems, boolean unchecked) {
|
||||
SchematicSelector selector = new SchematicSelector(p, Config.test() ? SchematicSelector.selectSchematic() : SchematicSelector.selectSchematicType(unchecked ? type.checkType() : type), node -> {
|
||||
schemSelect(p, node);
|
||||
});
|
||||
}) {
|
||||
@Override
|
||||
protected List<SchematicNode> getSchematicList(SchematicNode parent) {
|
||||
if (!publicSchems || parent != null) return super.getSchematicList(parent);
|
||||
List<Integer> publics = Config.GameModeConfig.Schematic.Publics;
|
||||
if (publics.isEmpty()) return super.getSchematicList(null);
|
||||
return publics.stream().map(SchematicNode::byId).collect(Collectors.toList());
|
||||
}
|
||||
};
|
||||
selector.setPublicMode(publicSchems ? SchematicSelector.PublicMode.PUBLIC_ONLY : SchematicSelector.PublicMode.PRIVATE_ONLY);
|
||||
selector.open();
|
||||
}
|
||||
|
||||
+2
-2
@@ -56,11 +56,11 @@ public class TechhiderbugCommand extends FightSWCommand {
|
||||
writer.append('\n');
|
||||
|
||||
writer.append("HullHider regions: ");
|
||||
FightSystem.getHullHider().getHullMap().forEach((t, h) -> writer.append(t.getName()).append(':').append(h.getRegion().toString()).append(' '));
|
||||
FightSystem.getHullHider().forEachHull((t, h) -> writer.append(t.getName()).append(':').append(h.getRegion().toString()).append(' '));
|
||||
writer.append('\n');
|
||||
|
||||
writer.append("Hidden regions: ");
|
||||
FightSystem.getTechHider().getHiddenRegion().forEach((p, r) -> writer.append(p.getName()).append(':').append(r.toString()).append(' '));
|
||||
FightSystem.getTechHider().getHiddenRegion().forEach((p, r) -> writer.append(p.getName()).append(':').append(Arrays.toString(r)).append(' '));
|
||||
writer.append('\n');
|
||||
|
||||
writer.append("TinyProtocol: ");
|
||||
|
||||
@@ -69,8 +69,8 @@ public class FightPlayer {
|
||||
|
||||
public void setOut() {
|
||||
isOut = true;
|
||||
stopEnternCountdown(); // before the event, so listeners already see canEntern() == false
|
||||
Bukkit.getPluginManager().callEvent(new TeamDeathEvent(this));
|
||||
stopEnternCountdown();
|
||||
ifAI(AI::stop);
|
||||
}
|
||||
|
||||
|
||||
+32
-15
@@ -46,6 +46,7 @@ import org.bukkit.util.Vector;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Random;
|
||||
import java.util.logging.Level;
|
||||
|
||||
@@ -109,31 +110,47 @@ public class FightSchematic extends StateDependent {
|
||||
clipboard = null;
|
||||
}
|
||||
|
||||
private static final Random random = new Random();
|
||||
|
||||
public static Optional<SchematicNode> getPublicSchematic() {
|
||||
List<Integer> publicsOverridden = Config.GameModeConfig.Schematic.Publics;
|
||||
if (!publicsOverridden.isEmpty()) {
|
||||
int publicId = publicsOverridden.get(random.nextInt(publicsOverridden.size()));
|
||||
SchematicNode schematicNode = SchematicNode.getSchematicNode(publicId);
|
||||
if (schematicNode != null) {
|
||||
return Optional.of(schematicNode);
|
||||
}
|
||||
}
|
||||
|
||||
List<SchematicNode> publics = SchematicNode.getAllSchematicsOfType(0, Config.GameModeConfig.Schematic.Type.toDB());
|
||||
if (publics.isEmpty()) {
|
||||
for (SchematicType type : Config.GameModeConfig.Schematic.SubTypes) {
|
||||
publics = SchematicNode.getAllSchematicsOfType(0, type.toDB());
|
||||
if (!publics.isEmpty()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (publics.isEmpty()) {
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
return Optional.of(publics.get(random.nextInt(publics.size())));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enable() {
|
||||
if (FightState.getFightState() == FightState.SPECTATE) return;
|
||||
|
||||
if (clipboard == null) {
|
||||
List<SchematicNode> publics = SchematicNode.getAllSchematicsOfType(0, Config.GameModeConfig.Schematic.Type.toDB());
|
||||
if (publics.isEmpty()) {
|
||||
for (SchematicType type : Config.GameModeConfig.Schematic.SubTypes) {
|
||||
publics = SchematicNode.getAllSchematicsOfType(0, type.toDB());
|
||||
if (!publics.isEmpty()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (publics.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
setSchematic(publics.get(new Random().nextInt(publics.size())));
|
||||
Optional<SchematicNode> schematicNode = getPublicSchematic();
|
||||
if (schematicNode.isEmpty()) return;
|
||||
setSchematic(schematicNode.get());
|
||||
}
|
||||
|
||||
if (ArenaMode.AntiReplay.contains(Config.mode)) {
|
||||
boolean changeRotation = false;
|
||||
if (Config.GameModeConfig.WinConditions.contains(Winconditions.RANDOM_ROTATE)) {
|
||||
changeRotation = new Random().nextBoolean();
|
||||
changeRotation = random.nextBoolean();
|
||||
usedRotate = rotate ^ changeRotation;
|
||||
}
|
||||
if (team.isBlue()) {
|
||||
|
||||
@@ -84,7 +84,7 @@ public class FightWorld extends StateDependent {
|
||||
entities.forEach(Entity::remove);
|
||||
entities.clear();
|
||||
|
||||
FightSystem.getHullHider().getHullMap().values().forEach(hull -> hull.fill(true));
|
||||
FightSystem.getHullHider().fillAll(true);
|
||||
|
||||
Config.ArenaRegion.forEachChunk((x, z) -> {
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
|
||||
@@ -108,7 +108,7 @@ public class WaterRemover implements Listener {
|
||||
//checks for water and removes it, if present
|
||||
boolean result = true;
|
||||
Material type = b.getType();
|
||||
if (type == Material.WATER || type == Material.LAVA) {
|
||||
if (type == Material.WATER || type == Material.LAVA || type == Material.BUBBLE_COLUMN) {
|
||||
b.setType(Material.AIR);
|
||||
} else {
|
||||
BlockData data = b.getBlockData();
|
||||
|
||||
+3
-3
@@ -20,6 +20,7 @@
|
||||
package de.steamwar.fightsystem.record;
|
||||
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import de.steamwar.core.BlockIds;
|
||||
import de.steamwar.core.worldedit.WorldEditWrapper;
|
||||
import de.steamwar.entity.REntity;
|
||||
import de.steamwar.entity.REntityServer;
|
||||
@@ -40,7 +41,6 @@ import de.steamwar.fightsystem.utils.TechHiderWrapper;
|
||||
import de.steamwar.sql.SchematicNode;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.sql.Team;
|
||||
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;
|
||||
@@ -51,7 +51,7 @@ 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.craftbukkit.block.data.CraftBlockData;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -473,7 +473,7 @@ public class PacketProcessor implements Listener {
|
||||
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());
|
||||
FightSystem.getHullHider().blockUpdate(Config.world.getBlockAt(x, y, z), CraftBlockData.fromData(Block.stateById(blockState)));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,147 @@
|
||||
/*
|
||||
* 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.entity.REntity;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.events.TeamDeathEvent;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightPlayer;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.listener.Recording;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||
import de.steamwar.fightsystem.states.StateDependentTask;
|
||||
import de.steamwar.hullhider.Hull;
|
||||
import de.steamwar.hullhider.HullHider;
|
||||
import de.steamwar.hullhider.Viewers;
|
||||
import de.steamwar.techhider.ObfuscationConfig;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
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.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
/**
|
||||
* Fight specific part of the hull hider: one hull per team schematic region, and who may view which hull.
|
||||
*/
|
||||
public class FightHullHider {
|
||||
|
||||
private final HullHider<FightTeam> hullHider = new HullHider<>(true);
|
||||
// Shared with the TechHiderWrapper
|
||||
@Getter
|
||||
private final ObfuscationConfig obfuscation = ObfuscationConfig.of(Config.GameModeConfig.Techhider);
|
||||
|
||||
public FightHullHider() {
|
||||
if (!TechHiderWrapper.ENABLED) return;
|
||||
|
||||
Fight.teams().forEach(team -> {
|
||||
Region region = team.getSchemRegion();
|
||||
hullHider.addHull(team, new Hull(FightSystem.getPlugin(), Config.world, region.toHullRegion(), region.getMinY() != Config.PlayerRegion.getMinY(), obfuscation, new Viewers.HiddenByDefault()));
|
||||
});
|
||||
|
||||
new StateDependentListener(TechHiderWrapper.ENABLED, FightState.All, new MembershipListener());
|
||||
new StateDependentListener(TechHiderWrapper.ENABLED, FightState.Schem, hullHider);
|
||||
new StateDependentTask(TechHiderWrapper.ENABLED, FightState.Schem, this::onTick, 0, 1);
|
||||
}
|
||||
|
||||
public void initialize(FightTeam team) {
|
||||
if (!TechHiderWrapper.ENABLED) return;
|
||||
hullHider.initialize(team);
|
||||
}
|
||||
|
||||
public void fill(FightTeam team, boolean visible) {
|
||||
if (!TechHiderWrapper.ENABLED) return;
|
||||
hullHider.fill(team, visible);
|
||||
}
|
||||
|
||||
public void fillAll(boolean visible) {
|
||||
hullHider.fillAll(visible);
|
||||
}
|
||||
|
||||
public void forEachHull(BiConsumer<FightTeam, Hull> consumer) {
|
||||
hullHider.forEach(consumer);
|
||||
}
|
||||
|
||||
// Registered in every state: players must be hidden from the hulls by default, no matter when they join.
|
||||
private class MembershipListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onJoin(PlayerJoinEvent e) {
|
||||
updatePlayer(e.getPlayer());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onLeave(PlayerQuitEvent e) {
|
||||
hullHider.forgetViewer(e.getPlayer());
|
||||
}
|
||||
|
||||
// A dead player loses the right to see the enemy hull again
|
||||
@EventHandler
|
||||
public void onTeamDeath(TeamDeathEvent e) {
|
||||
e.getFightPlayer().ifPlayer(player -> {
|
||||
updatePlayer(player);
|
||||
FightSystem.getTechHider().reloadChunks(player, Fight.getOpposite(e.getFightPlayer().getTeam()).getExtendRegion(), Region.EMPTY);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public void updatePlayer(Player player) {
|
||||
if (!TechHiderWrapper.ENABLED) return;
|
||||
|
||||
FightTeam team = Fight.getPlayerTeam(player);
|
||||
FightPlayer fp = Fight.getFightPlayer(player);
|
||||
hullHider.forEach((hullTeam, hull) -> {
|
||||
if (Config.isReferee(player) || hullTeam == team || (fp != null && fp.canEntern())) {
|
||||
hullHider.addViewer(player, hullTeam);
|
||||
} else {
|
||||
hullHider.removeViewer(player, hullTeam);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void blockUpdate(Block block, BlockData changedData) {
|
||||
hullHider.blockUpdate(block, changedData);
|
||||
}
|
||||
|
||||
public boolean isBlockHidden(Player player, int x, int y, int z) {
|
||||
return hullHider.isBlockHidden(player, x, y, z);
|
||||
}
|
||||
|
||||
private void onTick() {
|
||||
Recording.iterateOverEntities(Objects::nonNull, hullHider::checkEntity);
|
||||
hullHider.sendUncoveredBlocks();
|
||||
}
|
||||
|
||||
public void updateREntity(REntity e) {
|
||||
hullHider.updateREntity(e);
|
||||
}
|
||||
|
||||
public void despawnREntity(REntity e) {
|
||||
hullHider.despawnREntity(e);
|
||||
}
|
||||
}
|
||||
@@ -1,386 +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.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;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.logging.Level;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
public class Hull {
|
||||
|
||||
private static final IntVector[] NO_BRANCHES = new IntVector[0];
|
||||
|
||||
private static boolean isOccluding(Material material) {
|
||||
return material.isOccluding() || Config.GameModeConfig.Techhider.HiddenBlocks.contains(material);
|
||||
}
|
||||
|
||||
@Getter
|
||||
private final Region region;
|
||||
private final boolean groundVisible;
|
||||
private final IntVector[] directions;
|
||||
|
||||
private final BitSet occluding;
|
||||
private final BitSet visibility;
|
||||
private final HashMap<IntVector, BitSet> visibilityDirections = new HashMap<>(); // Contains the visible directions of each occluding visible block
|
||||
private final HashSet<IntVector> uncoveredSurface = new HashSet<>();
|
||||
|
||||
private final HashSet<Player> players = new HashSet<>();
|
||||
private final HashSet<Entity> entities = new HashSet<>();
|
||||
private final HashSet<REntity> rentities = new HashSet<>();
|
||||
|
||||
public Hull(FightTeam team) {
|
||||
this.region = team.getSchemRegion();
|
||||
this.groundVisible = region.getMinY() != Config.PlayerRegion.getMinY();
|
||||
this.occluding = new BitSet(region.volume());
|
||||
this.visibility = new BitSet(region.volume());
|
||||
|
||||
IntVector primaryDirection = new IntVector(0, 0, team.isBlue() == (Config.BlueToRedZ > 0) ? -1 : 1);
|
||||
directions = IntStream.range(0, 27)
|
||||
.mapToObj(v -> new IntVector(v % 3 - 1, (v / 3) % 3 - 1, v / 9 - 1))
|
||||
.filter(v -> v.sqLength() == 1 || v.x * primaryDirection.x + v.y * primaryDirection.y + v.z * primaryDirection.z == 1) // Not pointing away from primary direction
|
||||
.toArray(IntVector[]::new);
|
||||
|
||||
for (IntVector direction : directions) {
|
||||
visibilityDirections.put(direction, new BitSet(region.volume()));
|
||||
}
|
||||
}
|
||||
|
||||
public boolean blockPrecise(Player player, int chunkX, int chunkY, int chunkZ) {
|
||||
return players.contains(player) && !region.chunkSectionOutside(chunkX, chunkY, chunkZ);
|
||||
}
|
||||
|
||||
public boolean isBlockHidden(Player player, int x, int y, int z) {
|
||||
return region.inRegion(x, y, z) && players.contains(player) && !visibility.get(((y - region.getMinY()) * region.getSizeZ() + (z - region.getMinZ())) * region.getSizeX() + (x - region.getMinX()));
|
||||
}
|
||||
|
||||
public boolean isLocationHidden(Player player, Location location) {
|
||||
return players.contains(player) && region.inRegion(location) && !visibility.get(new IntVector(location).toId(region));
|
||||
}
|
||||
|
||||
public void addPlayer(Player player) {
|
||||
if (players.add(player)) {
|
||||
for (Entity entity : entities) {
|
||||
untrackEntity(player, entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void removePlayer(Player player, boolean activeRemoval) {
|
||||
if (players.remove(player) && activeRemoval) {
|
||||
for (Entity entity : entities) {
|
||||
trackEntity(player, entity);
|
||||
}
|
||||
// techhider triggers block change sending
|
||||
}
|
||||
}
|
||||
|
||||
public void checkEntity(Entity entity) {
|
||||
Location location = entity.getLocation();
|
||||
if (region.inRegion(location) && !visibility.get(new IntVector(location).toId(region))) {
|
||||
if (entities.add(entity)) {
|
||||
for (Player player : players) {
|
||||
untrackEntity(player, entity);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (entities.remove(entity)) {
|
||||
for (Player player : players) {
|
||||
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);
|
||||
}
|
||||
|
||||
public void checkREntity(REntity entity) {
|
||||
Location location = new Location(Config.world, entity.getX(), entity.getY(), entity.getZ());
|
||||
if (region.inRegion(location) && !visibility.get(new IntVector(location).toId(region))) {
|
||||
if (rentities.add(entity)) entity.hide(true);
|
||||
} else {
|
||||
if (rentities.remove(entity)) entity.hide(false);
|
||||
}
|
||||
}
|
||||
|
||||
public void removeREntity(REntity entity) {
|
||||
rentities.remove(entity);
|
||||
}
|
||||
|
||||
public void fill(boolean visible) {
|
||||
visibility.set(0, visibility.size(), visible);
|
||||
occluding.set(0, occluding.size(), !visible);
|
||||
uncoveredSurface.clear();
|
||||
for (BitSet directionalVisibility : visibilityDirections.values()) {
|
||||
directionalVisibility.set(0, directionalVisibility.size(), visible);
|
||||
}
|
||||
}
|
||||
|
||||
public void initialize() {
|
||||
visibility.clear();
|
||||
occluding.clear();
|
||||
uncoveredSurface.clear();
|
||||
for (BitSet directionalVisibility : visibilityDirections.values()) {
|
||||
directionalVisibility.clear();
|
||||
}
|
||||
|
||||
long start = System.currentTimeMillis();
|
||||
region.forEach((x, y, z) -> {
|
||||
IntVector block = new IntVector(x, y, z);
|
||||
if (isOccluding(Config.world.getBlockAt(x, y, z).getType())) {
|
||||
occluding.set(block.toId(region));
|
||||
}
|
||||
});
|
||||
forEachBorder((root, direction) -> uncoverBlocks(new NullList<>(), root, direction));
|
||||
FightSystem.getPlugin().getLogger().log(Level.INFO, () -> "[HullHider] initialisation finished: " + (System.currentTimeMillis() - start) + " ms, visible blocks: " + visibility.cardinality());
|
||||
}
|
||||
|
||||
public void updateBlockVisibility(Block b, Material changedType) {
|
||||
IntVector root = new IntVector(b.getX(), b.getY(), b.getZ());
|
||||
if (root.notInRegion(region)) return;
|
||||
|
||||
int id = root.toId(region);
|
||||
if (!occluding.get(id) || isOccluding(changedType)) return;
|
||||
|
||||
occluding.clear(id);
|
||||
if (!visibility.get(id)) return;
|
||||
|
||||
List<IntVector> uncovered = new ArrayList<>();
|
||||
for (Map.Entry<IntVector, BitSet> directionalVisibility : visibilityDirections.entrySet()) {
|
||||
if (directionalVisibility.getValue().get(id)) {
|
||||
directionalVisibility.getValue().clear(id);
|
||||
uncoverBlocks(uncovered, root, directionalVisibility.getKey());
|
||||
}
|
||||
}
|
||||
|
||||
uncoveredSurface.addAll(new HashSet<>(uncovered));
|
||||
uncoveredSurface.remove(root);
|
||||
}
|
||||
|
||||
public void sendUncoveredBlocks() {
|
||||
Map<IntVector, List<IntVector>> sectionWise = new HashMap<>();
|
||||
|
||||
for (IntVector uncovered : uncoveredSurface) {
|
||||
sectionWise.computeIfAbsent(new IntVector(uncovered.x >> 4, uncovered.y >> 4, uncovered.z >> 4), section -> new ArrayList<>()).add(uncovered);
|
||||
}
|
||||
uncoveredSurface.clear();
|
||||
|
||||
for (Map.Entry<IntVector, List<IntVector>> entry : sectionWise.entrySet()) {
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
private void forEachBorder(BiConsumer<IntVector, IntVector> f) {
|
||||
for (int x = region.getMinX(); x < region.getMaxX(); x++) {
|
||||
for (int z = region.getMinZ(); z < region.getMaxZ(); z++) {
|
||||
if (groundVisible) {
|
||||
f.accept(new IntVector(x, region.getMinY(), z), new IntVector(0, 1, 0));
|
||||
}
|
||||
f.accept(new IntVector(x, region.getMaxY() - 1, z), new IntVector(0, -1, 0));
|
||||
}
|
||||
}
|
||||
|
||||
for (int x = region.getMinX(); x < region.getMaxX(); x++) {
|
||||
for (int y = region.getMinY(); y < region.getMaxY(); y++) {
|
||||
f.accept(new IntVector(x, y, region.getMinZ()), new IntVector(0, 0, 1));
|
||||
f.accept(new IntVector(x, y, region.getMaxZ() - 1), new IntVector(0, 0, -1));
|
||||
}
|
||||
}
|
||||
|
||||
for (int z = region.getMinZ(); z < region.getMaxZ(); z++) {
|
||||
for (int y = region.getMinY(); y < region.getMaxY(); y++) {
|
||||
f.accept(new IntVector(region.getMinX(), y, z), new IntVector(1, 0, 0));
|
||||
f.accept(new IntVector(region.getMaxX() - 1, y, z), new IntVector(-1, 0, 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void uncoverBlocks(List<IntVector> uncovered, IntVector block, IntVector direction) {
|
||||
uncoverBlocks(
|
||||
uncovered, block, direction, visibilityDirections.get(direction),
|
||||
direction.sqLength() == 1
|
||||
? Arrays.stream(directions)
|
||||
.filter(v -> v.sqLength() >= 2 && v.x * direction.x + v.y * direction.y + v.z * direction.z == 1)
|
||||
.toArray(IntVector[]::new)
|
||||
: NO_BRANCHES
|
||||
);
|
||||
}
|
||||
|
||||
private void uncoverBlocks(List<IntVector> uncovered, IntVector block, IntVector direction, BitSet directionalVisibility, IntVector[] branchDirections) {
|
||||
if (block.notInRegion(region)) return;
|
||||
|
||||
int id = block.toId(region);
|
||||
if (directionalVisibility.get(id)) return;
|
||||
directionalVisibility.set(id);
|
||||
|
||||
if (!visibility.get(id)) {
|
||||
visibility.set(id);
|
||||
uncovered.add(block);
|
||||
}
|
||||
|
||||
if (occluding.get(id)) return;
|
||||
|
||||
uncoverBlocks(uncovered, block.add(direction), direction, directionalVisibility, branchDirections);
|
||||
for (IntVector branchDirection : branchDirections) {
|
||||
uncoverBlocks(uncovered, block.add(branchDirection), branchDirection, visibilityDirections.get(branchDirection), NO_BRANCHES);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public static class IntVector {
|
||||
private final int x;
|
||||
private final int y;
|
||||
private final int z;
|
||||
|
||||
public IntVector(Location location) {
|
||||
this.x = location.getBlockX();
|
||||
this.y = location.getBlockY();
|
||||
this.z = location.getBlockZ();
|
||||
}
|
||||
|
||||
public boolean notInRegion(Region region) {
|
||||
return !region.inRegion(x, y, z);
|
||||
}
|
||||
|
||||
public int toId(Region region) {
|
||||
return ((y - region.getMinY()) * region.getSizeZ() + (z - region.getMinZ())) * region.getSizeX() + (x - region.getMinX());
|
||||
}
|
||||
|
||||
public IntVector add(int x, int y, int z) {
|
||||
return new IntVector(this.x + x, this.y + y, this.z + z);
|
||||
}
|
||||
|
||||
public IntVector add(IntVector v) {
|
||||
return add(v.x, v.y, v.z);
|
||||
}
|
||||
|
||||
public int sqLength() {
|
||||
return x * x + y * y + z * z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return y << 24 ^ x << 12 ^ z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o == null || this.getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
IntVector v = (IntVector) o;
|
||||
return x == v.x && y == v.y && z == v.z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return x + "," + y + "," + z;
|
||||
}
|
||||
}
|
||||
|
||||
private static class NullList<E> extends AbstractList<E> {
|
||||
@Override
|
||||
public void add(int index, E element) {
|
||||
// Straight to /dev/null!
|
||||
}
|
||||
|
||||
@Override
|
||||
public E get(int index) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,171 +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.entity.REntity;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightPlayer;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.listener.Recording;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||
import de.steamwar.fightsystem.states.StateDependentTask;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockPhysicsEvent;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
import org.bukkit.event.entity.EntitySpawnEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
public class HullHider implements Listener {
|
||||
|
||||
@Getter
|
||||
private final Map<FightTeam, Hull> hullMap = new HashMap<>();
|
||||
private final Hull[] hulls;
|
||||
|
||||
public HullHider() {
|
||||
if (!TechHiderWrapper.ENABLED) {
|
||||
hulls = new Hull[0];
|
||||
return;
|
||||
}
|
||||
|
||||
Fight.teams().forEach(team -> hullMap.put(team, new Hull(team)));
|
||||
hulls = hullMap.values().toArray(new Hull[0]);
|
||||
|
||||
|
||||
new StateDependentListener(TechHiderWrapper.ENABLED, FightState.Schem, this);
|
||||
new StateDependentTask(TechHiderWrapper.ENABLED, FightState.Schem, this::onTick, 0, 1);
|
||||
}
|
||||
|
||||
public void initialize(FightTeam team) {
|
||||
if (!TechHiderWrapper.ENABLED) return;
|
||||
hullMap.get(team).initialize();
|
||||
}
|
||||
|
||||
public void fill(FightTeam team, boolean visible) {
|
||||
if (!TechHiderWrapper.ENABLED) return;
|
||||
hullMap.get(team).fill(visible);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onJoin(PlayerJoinEvent e) {
|
||||
updatePlayer(e.getPlayer());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onLeave(PlayerQuitEvent e) {
|
||||
removePlayer(e.getPlayer(), false);
|
||||
}
|
||||
|
||||
public void updatePlayer(Player player) {
|
||||
if (!TechHiderWrapper.ENABLED) return;
|
||||
|
||||
FightTeam team = Fight.getPlayerTeam(player);
|
||||
FightPlayer fp = Fight.getFightPlayer(player);
|
||||
for (Map.Entry<FightTeam, Hull> hull : hullMap.entrySet()) {
|
||||
if (Config.isReferee(player) || hull.getKey() == team || (fp != null && fp.canEntern())) {
|
||||
hull.getValue().removePlayer(player, true);
|
||||
} else {
|
||||
hull.getValue().addPlayer(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void removePlayer(Player player, boolean activeRemoval) {
|
||||
for (Hull hull : hulls) {
|
||||
hull.removePlayer(player, activeRemoval);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onBlockPhysic(BlockPhysicsEvent e) {
|
||||
if (e.getBlock() == e.getSourceBlock() || e.getChangedType() == Material.AIR) {
|
||||
blockUpdate(e.getBlock(), e.getChangedType());
|
||||
}
|
||||
}
|
||||
|
||||
public void blockUpdate(Block block, Material changedType) {
|
||||
for (Hull hull : hulls) {
|
||||
hull.updateBlockVisibility(block, changedType);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isBlockHidden(Player player, int x, int y, int z) {
|
||||
if (!TechHiderWrapper.ENABLED) return false;
|
||||
|
||||
for (Hull hull : hulls) {
|
||||
if (hull.isBlockHidden(player, x, y, z)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onSpawn(EntitySpawnEvent e) {
|
||||
for (Hull hull : hulls) {
|
||||
hull.checkEntity(e.getEntity());
|
||||
}
|
||||
}
|
||||
|
||||
private void onTick() {
|
||||
Recording.iterateOverEntities(Objects::nonNull, entity -> {
|
||||
for (Hull hull : hulls) {
|
||||
hull.checkEntity(entity);
|
||||
}
|
||||
});
|
||||
|
||||
for (Hull hull : hulls) {
|
||||
hull.sendUncoveredBlocks();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onDeath(EntityDeathEvent e) {
|
||||
for (Hull hull : hulls) {
|
||||
hull.removeEntity(e.getEntity());
|
||||
}
|
||||
}
|
||||
|
||||
public void updateREntity(REntity e) {
|
||||
for (Hull hull : hulls) {
|
||||
hull.checkREntity(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void despawnREntity(REntity e) {
|
||||
for (Hull hull : hulls) {
|
||||
hull.removeREntity(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,8 @@
|
||||
|
||||
package de.steamwar.fightsystem.utils;
|
||||
|
||||
import de.steamwar.techhider.ProtocolUtils;
|
||||
import de.steamwar.core.ProtocolUtils;
|
||||
import de.steamwar.hullhider.HullRegion;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Location;
|
||||
@@ -155,6 +156,10 @@ public class Region {
|
||||
return in2dRegion(x, z) && minY <= y && y < maxY;
|
||||
}
|
||||
|
||||
public HullRegion toHullRegion() {
|
||||
return new HullRegion(minX, minY, minZ, maxX, maxY, maxZ);
|
||||
}
|
||||
|
||||
public Region intersection(Region other) {
|
||||
int x = Math.max(minX, other.minX);
|
||||
int y = Math.max(minY, other.minY);
|
||||
|
||||
+101
-99
@@ -25,46 +25,40 @@ import de.steamwar.fightsystem.events.BoardingEvent;
|
||||
import de.steamwar.fightsystem.events.TeamLeaveEvent;
|
||||
import de.steamwar.fightsystem.events.TeamSpawnEvent;
|
||||
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.states.StateDependent;
|
||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||
import de.steamwar.techhider.AccessPrivilegeProvider;
|
||||
import de.steamwar.techhider.AccessPrivilegeProvider.ForPlayer;
|
||||
import de.steamwar.techhider.ObfuscationConfig;
|
||||
import de.steamwar.techhider.TechHider;
|
||||
import lombok.Getter;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.FluidState;
|
||||
import net.minecraft.world.level.material.Fluids;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class TechHiderWrapper extends StateDependent implements Listener {
|
||||
|
||||
public static final boolean ENABLED = !Config.OnlyPublicSchematics && !Config.test() && Config.GameModeConfig.Techhider.Active;
|
||||
|
||||
@Getter
|
||||
private final ConcurrentHashMap<Player, Region> hiddenRegion = new ConcurrentHashMap<>();
|
||||
private final HullHider hullHider;
|
||||
private static final Region[] NO_REGIONS = new Region[0];
|
||||
|
||||
public TechHiderWrapper(HullHider hullHider) {
|
||||
@Getter
|
||||
private final ConcurrentHashMap<Player, Region[]> hiddenRegion = new ConcurrentHashMap<>();
|
||||
private final FightHullHider hullHider;
|
||||
|
||||
public TechHiderWrapper(FightHullHider hullHider) {
|
||||
super(ENABLED, FightState.All);
|
||||
|
||||
this.hullHider = hullHider;
|
||||
@@ -75,64 +69,91 @@ public class TechHiderWrapper extends StateDependent implements Listener {
|
||||
|
||||
@Override
|
||||
public void enable() {
|
||||
Set<BlockState> blockStatesToObfuscate = getBlockStatesToHideFromMaterials(Config.GameModeConfig.Techhider.HiddenBlocks);
|
||||
new TechHider(newProvider(hullHider.getObfuscation()));
|
||||
}
|
||||
|
||||
Set<Block> blocksToObfuscate = Config.GameModeConfig.Techhider.HiddenBlocks.stream()
|
||||
.map(CraftMagicNumbers::getBlock)
|
||||
.collect(Collectors.toUnmodifiableSet());
|
||||
|
||||
Set<BlockEntityType<?>> blockEntityTypeToObfuscate = Config.GameModeConfig.Techhider.HiddenBlockEntities.stream()
|
||||
.map(id -> {
|
||||
ResourceLocation loc = ResourceLocation.parse(id);
|
||||
return BuiltInRegistries.BLOCK_ENTITY_TYPE.get(loc).orElse(null);
|
||||
})
|
||||
.filter(Objects::nonNull)
|
||||
.map(Holder.Reference::value)
|
||||
.collect(Collectors.toUnmodifiableSet());
|
||||
|
||||
new TechHider(CraftMagicNumbers.getBlock(Config.GameModeConfig.Techhider.ObfuscateWith), new AccessPrivilegeProvider() {
|
||||
private AccessPrivilegeProvider newProvider(ObfuscationConfig obfuscation) {
|
||||
return new AccessPrivilegeProvider() {
|
||||
@Override
|
||||
public boolean isEveryonePrivilegedToAccessAllDataWithinChunk(int chunkX, int chunkZ) {
|
||||
return Fight.teams().stream().map(FightTeam::getExtendRegion).allMatch(region -> region.chunkOutside(chunkX, chunkZ));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlayerPrivilegedToAccessPosition(Player p, int blockX, int blockY, int blockZ) {
|
||||
return !hullHider.isBlockHidden(p, blockX, blockY, blockZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlayerPrivilegedToAccessBlock(Player p, int blockX, int blockY, int blockZ, Block block) {
|
||||
return !getHiddenRegion(p).inRegion(blockX, blockY, blockZ) || !blocksToObfuscate.contains(block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlayerPrivilegedToAccessBlockState(Player p, int blockX, int blockY, int blockZ, BlockState blockState) {
|
||||
return !getHiddenRegion(p).inRegion(blockX, blockY, blockZ) || !blockStatesToObfuscate.contains(blockState);
|
||||
}
|
||||
|
||||
// TODO will require entity tracking on the netty thread to prevent future race conditions
|
||||
@Override
|
||||
public boolean isPlayerPrivilegedToAccessEntity(Player p, int entityId) {
|
||||
net.minecraft.world.entity.Entity nmsEntity = ((CraftWorld) p.getWorld()).getHandle().moonrise$getEntityLookup().get(entityId);
|
||||
|
||||
if (nmsEntity != null) {
|
||||
return !hullHider.isBlockHidden(p, nmsEntity.getBlockX(), nmsEntity.getBlockY(), nmsEntity.getBlockZ());
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlayerPrivilegedToAccessBlockEntity(Player p, int blockX, int blockY, int blockZ, BlockEntityType<?> type) {
|
||||
return !getHiddenRegion(p).inRegion(blockX, blockY, blockZ) || !blockEntityTypeToObfuscate.contains(type);
|
||||
public ForPlayer forPlayer(Player p) {
|
||||
return new FightPlayerAccess(p, getHiddenRegions(p), obfuscation);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlayerPrivilegedToPerformAction(Player p) {
|
||||
return p.getGameMode() != GameMode.SPECTATOR;
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Snapshot of what one player may access, taken once per outgoing packet on the netty thread.
|
||||
*/
|
||||
private class FightPlayerAccess implements ForPlayer {
|
||||
private final Player player;
|
||||
private final Region[] hiddenRegions;
|
||||
private final ObfuscationConfig obfuscation;
|
||||
|
||||
private FightPlayerAccess(Player player, Region[] hiddenRegions, ObfuscationConfig obfuscation) {
|
||||
this.player = player;
|
||||
this.hiddenRegions = hiddenRegions;
|
||||
this.obfuscation = obfuscation;
|
||||
}
|
||||
|
||||
private boolean isHidden(int blockX, int blockY, int blockZ) {
|
||||
for (Region region : hiddenRegions) {
|
||||
if (region.inRegion(blockX, blockY, blockZ)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAccessAllDataWithinChunk(int chunkX, int chunkZ) {
|
||||
// Hulls the player may not see lie within the hidden regions, everything outside of them is not critical
|
||||
return Arrays.stream(hiddenRegions).allMatch(region -> region.chunkOutside(chunkX, chunkZ));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAccessPosition(int blockX, int blockY, int blockZ) {
|
||||
return !hullHider.isBlockHidden(player, blockX, blockY, blockZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAccessBlock(int blockX, int blockY, int blockZ, Block block) {
|
||||
return !isHidden(blockX, blockY, blockZ) || !obfuscation.hidesBlock(block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAccessBlockState(int blockX, int blockY, int blockZ, BlockState blockState) {
|
||||
return !isHidden(blockX, blockY, blockZ) || !obfuscation.hidesBlockState(blockState);
|
||||
}
|
||||
|
||||
// TODO will require entity tracking on the netty thread to prevent future race conditions
|
||||
@Override
|
||||
public boolean canAccessEntity(int entityId) {
|
||||
net.minecraft.world.entity.Entity nmsEntity = ((CraftWorld) player.getWorld()).getHandle().moonrise$getEntityLookup().get(entityId);
|
||||
|
||||
if (nmsEntity != null) {
|
||||
return !hullHider.isBlockHidden(player, nmsEntity.getBlockX(), nmsEntity.getBlockY(), nmsEntity.getBlockZ());
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAccessBlockEntity(int blockX, int blockY, int blockZ, BlockEntityType<?> type) {
|
||||
return !isHidden(blockX, blockY, blockZ) || !obfuscation.hidesBlockEntity(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getObfuscation(int blockX, int blockY, int blockZ) {
|
||||
return obfuscation.getObfuscationState();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -142,19 +163,19 @@ public class TechHiderWrapper extends StateDependent implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void teamJoin(TeamSpawnEvent e) {
|
||||
e.getFightPlayer().ifPlayer(player -> hiddenRegion.put(player, getHiddenRegion(player)));
|
||||
e.getFightPlayer().ifPlayer(player -> hiddenRegion.put(player, getHiddenRegions(player)));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void boarding(BoardingEvent e) {
|
||||
e.getFightPlayer().ifPlayer(player -> hiddenRegion.put(player, getHiddenRegion(player)));
|
||||
e.getFightPlayer().ifPlayer(player -> hiddenRegion.put(player, getHiddenRegions(player)));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void teamLeave(TeamLeaveEvent e) {
|
||||
e.getFightPlayer().ifPlayer(player -> {
|
||||
if (player.isOnline()) {
|
||||
hiddenRegion.put(player, getHiddenRegion(player));
|
||||
hiddenRegion.put(player, getHiddenRegions(player));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -175,37 +196,18 @@ public class TechHiderWrapper extends StateDependent implements Listener {
|
||||
});
|
||||
}
|
||||
|
||||
private Region getHiddenRegion(Player player) {
|
||||
if (Config.isReferee(player)) return Region.EMPTY;
|
||||
private Region[] getHiddenRegions(Player player) {
|
||||
if (Config.isReferee(player)) return NO_REGIONS;
|
||||
|
||||
FightTeam team = Fight.getPlayerTeam(player);
|
||||
if (team == null) return Config.ArenaRegion;
|
||||
|
||||
if (team.canPlayerEntern(player)) return Region.EMPTY;
|
||||
|
||||
return Fight.getOpposite(team).getExtendRegion();
|
||||
}
|
||||
|
||||
private Stream<BlockState> getWaterloggedBlockStates() {
|
||||
FluidState waterFluidState = Fluids.WATER.getSource(false);
|
||||
|
||||
return BuiltInRegistries.BLOCK.stream()
|
||||
.map((block) -> block.getStateDefinition().getPossibleStates())
|
||||
.flatMap(Collection::stream)
|
||||
.filter((blockState -> blockState.getFluidState() == waterFluidState));
|
||||
}
|
||||
|
||||
private Set<BlockState> getBlockStatesToHideFromMaterials(Set<Material> materials) {
|
||||
Stream<BlockState> allStatesFromMaterials = materials.stream()
|
||||
.map(CraftMagicNumbers::getBlock)
|
||||
.map((block) -> block.getStateDefinition().getPossibleStates())
|
||||
.flatMap(Collection::stream);
|
||||
|
||||
if(materials.contains(Material.WATER)) {
|
||||
return Stream.concat(allStatesFromMaterials, getWaterloggedBlockStates()).collect(Collectors.toUnmodifiableSet());
|
||||
}
|
||||
else {
|
||||
return allStatesFromMaterials.collect(Collectors.toUnmodifiableSet());
|
||||
// Single lookup: runs on netty threads, the player can leave the team at any time
|
||||
FightPlayer fightPlayer = Fight.getFightPlayer(player);
|
||||
if (fightPlayer == null) {
|
||||
// Spectators: both teams, the rest of the arena contains nothing critical
|
||||
return Fight.teams().stream().map(FightTeam::getExtendRegion).toArray(Region[]::new);
|
||||
}
|
||||
|
||||
if (fightPlayer.canEntern()) return NO_REGIONS;
|
||||
|
||||
return new Region[]{Fight.getOpposite(fightPlayer.getTeam()).getExtendRegion()};
|
||||
}
|
||||
}
|
||||
|
||||
+23
-20
@@ -17,24 +17,27 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.slaves.laufbau.converter;
|
||||
|
||||
import de.steamwar.bausystem.config.ConfigConverter;
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.LaufbauConfig;
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.LaufbauConfigV1;
|
||||
|
||||
@Deprecated
|
||||
public class LaufbauConfigV1ToV2Converter implements ConfigConverter<LaufbauConfigV1, LaufbauConfig> {
|
||||
|
||||
@Override
|
||||
public int version() {
|
||||
return LaufbauConfigV1.VERSION;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LaufbauConfig convert(LaufbauConfigV1 old) {
|
||||
LaufbauConfig config = new LaufbauConfig();
|
||||
config.getDeactivated().addAll(old.getDeactivated());
|
||||
return config;
|
||||
}
|
||||
plugins {
|
||||
steamwar.java
|
||||
widener
|
||||
}
|
||||
|
||||
java {
|
||||
sourceCompatibility = JavaVersion.VERSION_21
|
||||
targetCompatibility = JavaVersion.VERSION_21
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly(project(":SpigotCore", "default"))
|
||||
|
||||
compileOnly(libs.paperapi)
|
||||
compileOnly(libs.nms)
|
||||
compileOnly(libs.netty)
|
||||
compileOnly(libs.fastutil)
|
||||
compileOnly(libs.authlib)
|
||||
compileOnly(libs.datafixer)
|
||||
}
|
||||
|
||||
widener {
|
||||
fromCatalog(libs.nms)
|
||||
}
|
||||
@@ -0,0 +1,628 @@
|
||||
/*
|
||||
* 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.hullhider;
|
||||
|
||||
import com.comphenix.tinyprotocol.TinyProtocol;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import de.steamwar.core.CraftbukkitWrapper;
|
||||
import de.steamwar.core.ProtocolWrapper;
|
||||
import de.steamwar.entity.REntity;
|
||||
import de.steamwar.techhider.ObfuscationConfig;
|
||||
import it.unimi.dsi.fastutil.shorts.Short2ObjectArrayMap;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.SectionPos;
|
||||
import net.minecraft.network.protocol.game.ClientboundBlockUpdatePacket;
|
||||
import net.minecraft.network.protocol.game.ClientboundSectionBlocksUpdatePacket;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.level.EmptyBlockGetter;
|
||||
import net.minecraft.world.level.block.DoorBlock;
|
||||
import net.minecraft.world.level.block.TrapDoorBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
import org.bukkit.craftbukkit.block.data.CraftBlockData;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.logging.Level;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
public class Hull {
|
||||
|
||||
private static final IntVector[] NO_BRANCHES = new IntVector[0];
|
||||
private static final int ALL_FACES = 0b111111;
|
||||
private static final byte UNKNOWN_FACES = -1;
|
||||
|
||||
private final Plugin plugin;
|
||||
private final World world;
|
||||
@Getter
|
||||
private final HullRegion region;
|
||||
private final boolean groundVisible;
|
||||
private final ObfuscationConfig obfuscation;
|
||||
private final IntVector[] directions;
|
||||
|
||||
private final byte[] fullFaces; // The faces of each block that are fully covered, see face()
|
||||
private byte[] fullFacesByState; // Cache, per hull as the hidden blocks differ
|
||||
private final BitSet visibility;
|
||||
private final HashMap<IntVector, BitSet> visibilityDirections = new HashMap<>(); // The blocks the rays of each direction got inside
|
||||
private final HashMap<IntVector, IntVector[]> branches = new HashMap<>(); // The diagonal directions a ray along a single axis branches into
|
||||
private final StepBeside[] stepsBeside; // The steps that can lead into or past a block, see uncoverBeside()
|
||||
private final HashSet<IntVector> uncoveredSurface = new HashSet<>();
|
||||
|
||||
private final Viewers viewers;
|
||||
private final HashSet<Entity> entities = new HashSet<>();
|
||||
private final HashSet<REntity> rentities = new HashSet<>();
|
||||
|
||||
/**
|
||||
* @param groundVisible whether the bottom layer of the region is uncovered (if the region does not reach the ground)
|
||||
* @param obfuscation the techhider applied to the hull, the blocks it hides occlude as they are replaced by an occluding block
|
||||
* @param viewers which players may see the hull contents, a new instance for every hull
|
||||
*/
|
||||
public Hull(Plugin plugin, World world, HullRegion region, boolean groundVisible, ObfuscationConfig obfuscation, Viewers viewers) {
|
||||
this.plugin = plugin;
|
||||
this.world = world;
|
||||
this.region = region;
|
||||
this.groundVisible = groundVisible;
|
||||
this.obfuscation = obfuscation;
|
||||
this.viewers = viewers;
|
||||
this.fullFaces = new byte[region.volume()];
|
||||
this.visibility = new BitSet(region.volume());
|
||||
|
||||
directions = IntStream.range(0, 27)
|
||||
.mapToObj(v -> new IntVector(v % 3 - 1, (v / 3) % 3 - 1, v / 9 - 1))
|
||||
.toArray(IntVector[]::new);
|
||||
|
||||
for (IntVector direction : directions) {
|
||||
visibilityDirections.put(direction, new BitSet(region.volume()));
|
||||
branches.put(direction, direction.sqLength() == 1
|
||||
? Arrays.stream(directions).filter(v -> v.sqLength() >= 2 && dot(v, direction) == 1).toArray(IntVector[]::new)
|
||||
: NO_BRANCHES);
|
||||
}
|
||||
stepsBeside = computeStepsBeside();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the bit of the face of a block in the single-axis direction
|
||||
*/
|
||||
private static int face(int dx, int dy, int dz) {
|
||||
if (dx != 0) return dx > 0 ? 1 : 1 << 1;
|
||||
if (dy != 0) return dy > 0 ? 1 << 2 : 1 << 3;
|
||||
return dz > 0 ? 1 << 4 : 1 << 5;
|
||||
}
|
||||
|
||||
private int fullFacesOf(BlockState state) {
|
||||
if (fullFacesByState == null) {
|
||||
fullFacesByState = new byte[net.minecraft.world.level.block.Block.BLOCK_STATE_REGISTRY.size()];
|
||||
Arrays.fill(fullFacesByState, UNKNOWN_FACES);
|
||||
}
|
||||
|
||||
int id = net.minecraft.world.level.block.Block.getId(state);
|
||||
if (fullFacesByState[id] == UNKNOWN_FACES) {
|
||||
fullFacesByState[id] = (byte) computeFullFaces(state);
|
||||
}
|
||||
return fullFacesByState[id];
|
||||
}
|
||||
|
||||
// The faces that hide what is behind them, mostly as the client culls them
|
||||
private int computeFullFaces(BlockState state) {
|
||||
// Hidden blocks are replaced by an occluding block, the same decision as the techhider's
|
||||
if (obfuscation.hidesBlock(state.getBlock()) || obfuscation.hidesBlockState(state)) return ALL_FACES;
|
||||
|
||||
VoxelShape shape;
|
||||
if (state.canOcclude()) {
|
||||
shape = state.getOcclusionShape();
|
||||
} else if (state.getBlock() instanceof DoorBlock || state.getBlock() instanceof TrapDoorBlock) {
|
||||
// Their panel covers a face, although the client does not cull the faces behind them
|
||||
shape = state.getShape(EmptyBlockGetter.INSTANCE, BlockPos.ZERO);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int faces = 0;
|
||||
for (Direction direction : Direction.values()) {
|
||||
if (net.minecraft.world.level.block.Block.isFaceFull(shape, direction)) {
|
||||
faces |= face(direction.getStepX(), direction.getStepY(), direction.getStepZ());
|
||||
}
|
||||
}
|
||||
return faces;
|
||||
}
|
||||
|
||||
public boolean isBlockHidden(Player player, int x, int y, int z) {
|
||||
return region.contains(x, y, z) && !isViewer(player) && !visibility.get(region.toIndex(x, y, z));
|
||||
}
|
||||
|
||||
public boolean isViewer(Player player) {
|
||||
return player != null && viewers.isViewer(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the player to the {@link Viewers}, which decide whether the player may see the hull contents afterwards.
|
||||
*/
|
||||
public void addViewer(Player player) {
|
||||
boolean wasViewer = isViewer(player);
|
||||
viewers.addViewer(player);
|
||||
updateEntities(player, wasViewer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the player from the {@link Viewers}, which decide whether the player may see the hull contents afterwards.
|
||||
*/
|
||||
public void removeViewer(Player player) {
|
||||
boolean wasViewer = isViewer(player);
|
||||
viewers.removeViewer(player);
|
||||
updateEntities(player, wasViewer);
|
||||
}
|
||||
|
||||
private void updateEntities(Player player, boolean wasViewer) {
|
||||
if (isViewer(player)) {
|
||||
if (!wasViewer) {
|
||||
for (Entity entity : entities) {
|
||||
trackEntity(player, entity);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Also hides the entities from players that joined after they were hidden
|
||||
for (Entity entity : entities) {
|
||||
if (!player.equals(entity)) untrackEntity(player, entity);
|
||||
}
|
||||
}
|
||||
// techhider triggers block change sending
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the player to the default viewer state, e.g. when leaving.
|
||||
*/
|
||||
public void forgetViewer(Player player) {
|
||||
viewers.removeViewer(player);
|
||||
}
|
||||
|
||||
public void checkEntity(Entity entity) {
|
||||
Location location = entity.getLocation();
|
||||
if (region.contains(location) && !visibility.get(new IntVector(location).toId(region))) {
|
||||
if (entities.add(entity)) {
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
if (!isViewer(player) && !player.equals(entity)) untrackEntity(player, entity);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (entities.remove(entity)) {
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
if (!isViewer(player) && !player.equals(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(plugin, entity);
|
||||
}
|
||||
|
||||
public void untrackEntity(Player player, Entity entity) {
|
||||
player.hideEntity(plugin, 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);
|
||||
}
|
||||
|
||||
public void checkREntity(REntity entity) {
|
||||
Location location = new Location(world, entity.getX(), entity.getY(), entity.getZ());
|
||||
if (region.contains(location) && !visibility.get(new IntVector(location).toId(region))) {
|
||||
if (rentities.add(entity)) entity.hide(true);
|
||||
} else {
|
||||
if (rentities.remove(entity)) entity.hide(false);
|
||||
}
|
||||
}
|
||||
|
||||
public void removeREntity(REntity entity) {
|
||||
rentities.remove(entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows all entities hidden by this hull again, used when the hull is removed.
|
||||
*/
|
||||
public void reveal() {
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
if (isViewer(player)) continue;
|
||||
|
||||
for (Entity entity : entities) {
|
||||
if (!player.equals(entity)) trackEntity(player, entity);
|
||||
}
|
||||
}
|
||||
entities.clear();
|
||||
|
||||
for (REntity entity : rentities) {
|
||||
entity.hide(false);
|
||||
}
|
||||
rentities.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Resends the chunks of this hull the player has loaded, so they are encoded with the current visibility.
|
||||
*/
|
||||
public void resendChunks(Player player) {
|
||||
if (player.getWorld() != world) return;
|
||||
|
||||
region.forEachChunk((chunkX, chunkZ) -> {
|
||||
if (player.isChunkSent(Chunk.getChunkKey(chunkX, chunkZ))) {
|
||||
CraftbukkitWrapper.sendChunk(player, chunkX, chunkZ);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void fill(boolean visible) {
|
||||
visibility.set(0, visibility.size(), visible);
|
||||
Arrays.fill(fullFaces, (byte) (visible ? 0 : ALL_FACES));
|
||||
uncoveredSurface.clear();
|
||||
for (BitSet directionalVisibility : visibilityDirections.values()) {
|
||||
directionalVisibility.set(0, directionalVisibility.size(), visible);
|
||||
}
|
||||
}
|
||||
|
||||
public void initialize() {
|
||||
visibility.clear();
|
||||
uncoveredSurface.clear();
|
||||
for (BitSet directionalVisibility : visibilityDirections.values()) {
|
||||
directionalVisibility.clear();
|
||||
}
|
||||
|
||||
long start = System.currentTimeMillis();
|
||||
ServerLevel level = ((CraftWorld) world).getHandle();
|
||||
BlockPos.MutableBlockPos pos = new BlockPos.MutableBlockPos();
|
||||
region.forEach((x, y, z) -> fullFaces[region.toIndex(x, y, z)] = (byte) fullFacesOf(level.getBlockState(pos.set(x, y, z))));
|
||||
forEachBorder((root, direction) -> startRay(new NullList<>(), root, direction));
|
||||
plugin.getLogger().log(Level.INFO, () -> "[HullHider] initialisation finished: " + (System.currentTimeMillis() - start) + " ms, visible blocks: " + visibility.cardinality());
|
||||
}
|
||||
|
||||
public void updateBlockVisibility(Block b, BlockData changedData) {
|
||||
IntVector root = new IntVector(b.getX(), b.getY(), b.getZ());
|
||||
if (root.notInRegion(region)) return;
|
||||
|
||||
int id = root.toId(region);
|
||||
// Faces only open up, the hull never hides anything again
|
||||
int faces = fullFaces[id] & fullFacesOf(((CraftBlockData) changedData).getState());
|
||||
if (faces == fullFaces[id]) return;
|
||||
fullFaces[id] = (byte) faces;
|
||||
|
||||
List<IntVector> uncovered = new ArrayList<>();
|
||||
// Rays inside the block that could not leave it
|
||||
for (Map.Entry<IntVector, BitSet> directionalVisibility : visibilityDirections.entrySet()) {
|
||||
if (directionalVisibility.getValue().get(id)) {
|
||||
directionalVisibility.getValue().clear(id);
|
||||
uncoverBlocks(uncovered, root, directionalVisibility.getKey());
|
||||
}
|
||||
}
|
||||
// Rays that could not get into the block or past it
|
||||
uncoverBeside(uncovered, root);
|
||||
forEachBorderStart(root, direction -> startRay(uncovered, root, direction));
|
||||
|
||||
uncoveredSurface.addAll(uncovered);
|
||||
uncoveredSurface.remove(root);
|
||||
}
|
||||
|
||||
/**
|
||||
* Continues the rays inside the blocks in front of the block, or of which a diagonal ray moves past the block.
|
||||
*/
|
||||
private void uncoverBeside(List<IntVector> uncovered, IntVector root) {
|
||||
for (StepBeside step : stepsBeside) {
|
||||
int x = root.x - step.part.x;
|
||||
int y = root.y - step.part.y;
|
||||
int z = root.z - step.part.z;
|
||||
if (!region.contains(x, y, z)) continue;
|
||||
|
||||
int id = region.toIndex(x, y, z);
|
||||
for (BitSet ray : step.rays) {
|
||||
if (ray.get(id)) {
|
||||
uncoverNext(uncovered, new IntVector(x, y, z), step.direction, step.directionalVisibility, step.branchDirections);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The block lies in front of or beside the start of a step if it is the start moved along some or all axes of the direction.
|
||||
* The rays of the direction and the rays along a single axis branching into it take the step.
|
||||
*/
|
||||
private StepBeside[] computeStepsBeside() {
|
||||
List<StepBeside> steps = new ArrayList<>();
|
||||
for (IntVector direction : directions) {
|
||||
if (direction.sqLength() == 0) continue;
|
||||
|
||||
BitSet[] rays = Arrays.stream(directions)
|
||||
.filter(ray -> ray.equals(direction) || ray.sqLength() == 1 && direction.sqLength() > 1 && dot(ray, direction) == 1)
|
||||
.map(visibilityDirections::get)
|
||||
.toArray(BitSet[]::new);
|
||||
for (IntVector part : directions) {
|
||||
if (part.sqLength() > 0 && isPartOf(part, direction)) {
|
||||
steps.add(new StepBeside(direction, part, visibilityDirections.get(direction), branches.get(direction), rays));
|
||||
}
|
||||
}
|
||||
}
|
||||
return steps.toArray(new StepBeside[0]);
|
||||
}
|
||||
|
||||
private record StepBeside(IntVector direction, IntVector part, BitSet directionalVisibility, IntVector[] branchDirections, BitSet[] rays) {
|
||||
}
|
||||
|
||||
private static boolean isPartOf(IntVector part, IntVector direction) {
|
||||
return (part.x == 0 || part.x == direction.x)
|
||||
&& (part.y == 0 || part.y == direction.y)
|
||||
&& (part.z == 0 || part.z == direction.z);
|
||||
}
|
||||
|
||||
private static int dot(IntVector a, IntVector b) {
|
||||
return a.x * b.x + a.y * b.y + a.z * b.z;
|
||||
}
|
||||
|
||||
public void sendUncoveredBlocks() {
|
||||
Map<IntVector, List<IntVector>> sectionWise = new HashMap<>();
|
||||
|
||||
for (IntVector uncovered : uncoveredSurface) {
|
||||
sectionWise.computeIfAbsent(new IntVector(uncovered.x >> 4, uncovered.y >> 4, uncovered.z >> 4), section -> new ArrayList<>()).add(uncovered);
|
||||
}
|
||||
uncoveredSurface.clear();
|
||||
|
||||
for (Map.Entry<IntVector, List<IntVector>> entry : sectionWise.entrySet()) {
|
||||
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) 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;
|
||||
Bukkit.getOnlinePlayers().stream().filter(player -> !isViewer(player)).forEach(player -> TinyProtocol.instance.sendPacket(player, packet));
|
||||
}
|
||||
}
|
||||
|
||||
// The rays forEachBorder starts at the block
|
||||
private void forEachBorderStart(IntVector block, Consumer<IntVector> f) {
|
||||
if (groundVisible && block.y == region.getMinY()) f.accept(new IntVector(0, 1, 0));
|
||||
if (block.y == region.getMaxY() - 1) f.accept(new IntVector(0, -1, 0));
|
||||
if (block.z == region.getMinZ()) f.accept(new IntVector(0, 0, 1));
|
||||
if (block.z == region.getMaxZ() - 1) f.accept(new IntVector(0, 0, -1));
|
||||
if (block.x == region.getMinX()) f.accept(new IntVector(1, 0, 0));
|
||||
if (block.x == region.getMaxX() - 1) f.accept(new IntVector(-1, 0, 0));
|
||||
}
|
||||
|
||||
private void forEachBorder(BiConsumer<IntVector, IntVector> f) {
|
||||
for (int x = region.getMinX(); x < region.getMaxX(); x++) {
|
||||
for (int z = region.getMinZ(); z < region.getMaxZ(); z++) {
|
||||
if (groundVisible) {
|
||||
f.accept(new IntVector(x, region.getMinY(), z), new IntVector(0, 1, 0));
|
||||
}
|
||||
f.accept(new IntVector(x, region.getMaxY() - 1, z), new IntVector(0, -1, 0));
|
||||
}
|
||||
}
|
||||
|
||||
for (int x = region.getMinX(); x < region.getMaxX(); x++) {
|
||||
for (int y = region.getMinY(); y < region.getMaxY(); y++) {
|
||||
f.accept(new IntVector(x, y, region.getMinZ()), new IntVector(0, 0, 1));
|
||||
f.accept(new IntVector(x, y, region.getMaxZ() - 1), new IntVector(0, 0, -1));
|
||||
}
|
||||
}
|
||||
|
||||
for (int z = region.getMinZ(); z < region.getMaxZ(); z++) {
|
||||
for (int y = region.getMinY(); y < region.getMaxY(); y++) {
|
||||
f.accept(new IntVector(region.getMinX(), y, z), new IntVector(1, 0, 0));
|
||||
f.accept(new IntVector(region.getMaxX() - 1, y, z), new IntVector(-1, 0, 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts a ray at the border of the region, coming from outside.
|
||||
*/
|
||||
private void startRay(List<IntVector> uncovered, IntVector block, IntVector direction) {
|
||||
if (faceFull(block.x, block.y, block.z, -direction.x, -direction.y, -direction.z)) {
|
||||
reveal(uncovered, block, block.toId(region));
|
||||
} else {
|
||||
uncoverBlocks(uncovered, block, direction);
|
||||
}
|
||||
}
|
||||
|
||||
private void uncoverBlocks(List<IntVector> uncovered, IntVector block, IntVector direction) {
|
||||
uncoverBlocks(uncovered, block, direction, visibilityDirections.get(direction), branches.get(direction));
|
||||
}
|
||||
|
||||
/**
|
||||
* Continues a ray that got inside the block.
|
||||
*/
|
||||
private void uncoverBlocks(List<IntVector> uncovered, IntVector block, IntVector direction, BitSet directionalVisibility, IntVector[] branchDirections) {
|
||||
if (block.notInRegion(region)) return;
|
||||
|
||||
int id = block.toId(region);
|
||||
if (directionalVisibility.get(id)) return;
|
||||
directionalVisibility.set(id);
|
||||
reveal(uncovered, block, id);
|
||||
|
||||
uncoverNext(uncovered, block, direction, directionalVisibility, branchDirections);
|
||||
for (IntVector branchDirection : branchDirections) {
|
||||
uncoverNext(uncovered, block, branchDirection, visibilityDirections.get(branchDirection), NO_BRANCHES);
|
||||
}
|
||||
}
|
||||
|
||||
private void uncoverNext(List<IntVector> uncovered, IntVector block, IntVector direction, BitSet directionalVisibility, IntVector[] branchDirections) {
|
||||
int x = block.x + direction.x;
|
||||
int y = block.y + direction.y;
|
||||
int z = block.z + direction.z;
|
||||
// The cheap checks first: most blocks were already reached from this direction
|
||||
if (!region.contains(x, y, z) || directionalVisibility.get(region.toIndex(x, y, z))) return;
|
||||
|
||||
if (canMove(block.x, block.y, block.z, direction.x, direction.y, direction.z, true)) {
|
||||
uncoverBlocks(uncovered, new IntVector(x, y, z), direction, directionalVisibility, branchDirections);
|
||||
return;
|
||||
}
|
||||
|
||||
// The ray might still reach the face of the next block, mostly it is visible already
|
||||
int id = region.toIndex(x, y, z);
|
||||
if (!visibility.get(id) && canMove(block.x, block.y, block.z, direction.x, direction.y, direction.z, false)) {
|
||||
reveal(uncovered, new IntVector(x, y, z), id);
|
||||
}
|
||||
}
|
||||
|
||||
private void reveal(List<IntVector> uncovered, IntVector block, int id) {
|
||||
if (!visibility.get(id)) {
|
||||
visibility.set(id);
|
||||
uncovered.add(block);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A ray moves along the single axes of its direction one after another, in any order that does not pass a full face.
|
||||
* So a diagonal ray does not pass between blocks that only touch at an edge or corner.
|
||||
*
|
||||
* @param enter whether the ray has to get inside the target block, otherwise reaching its face suffices
|
||||
*/
|
||||
private boolean canMove(int x, int y, int z, int dx, int dy, int dz, boolean enter) {
|
||||
if (dx == 0 && dy == 0 && dz == 0) return true;
|
||||
|
||||
// The blocks in between have to be entered
|
||||
return (dx != 0 && canCross(x, y, z, dx, 0, 0, enter || dy != 0 || dz != 0) && canMove(x + dx, y, z, 0, dy, dz, enter))
|
||||
|| (dy != 0 && canCross(x, y, z, 0, dy, 0, enter || dx != 0 || dz != 0) && canMove(x, y + dy, z, dx, 0, dz, enter))
|
||||
|| (dz != 0 && canCross(x, y, z, 0, 0, dz, enter || dx != 0 || dy != 0) && canMove(x, y, z + dz, dx, dy, 0, enter));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return whether a ray inside the block can leave it to the neighbouring block in the single-axis direction (and enter it)
|
||||
*/
|
||||
private boolean canCross(int x, int y, int z, int dx, int dy, int dz, boolean enter) {
|
||||
return !faceFull(x, y, z, dx, dy, dz) && (!enter || !faceFull(x + dx, y + dy, z + dz, -dx, -dy, -dz));
|
||||
}
|
||||
|
||||
private boolean faceFull(int x, int y, int z, int dx, int dy, int dz) {
|
||||
return (fullFaces[region.toIndex(x, y, z)] & face(dx, dy, dz)) != 0;
|
||||
}
|
||||
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public static class IntVector {
|
||||
private final int x;
|
||||
private final int y;
|
||||
private final int z;
|
||||
|
||||
public IntVector(Location location) {
|
||||
this.x = location.getBlockX();
|
||||
this.y = location.getBlockY();
|
||||
this.z = location.getBlockZ();
|
||||
}
|
||||
|
||||
public boolean notInRegion(HullRegion region) {
|
||||
return !region.contains(x, y, z);
|
||||
}
|
||||
|
||||
public int toId(HullRegion region) {
|
||||
return region.toIndex(x, y, z);
|
||||
}
|
||||
|
||||
public IntVector add(int x, int y, int z) {
|
||||
return new IntVector(this.x + x, this.y + y, this.z + z);
|
||||
}
|
||||
|
||||
public IntVector add(IntVector v) {
|
||||
return add(v.x, v.y, v.z);
|
||||
}
|
||||
|
||||
public int sqLength() {
|
||||
return x * x + y * y + z * z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return y << 24 ^ x << 12 ^ z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o == null || this.getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
IntVector v = (IntVector) o;
|
||||
return x == v.x && y == v.y && z == v.z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return x + "," + y + "," + z;
|
||||
}
|
||||
}
|
||||
|
||||
private static class NullList<E> extends AbstractList<E> {
|
||||
@Override
|
||||
public void add(int index, E element) {
|
||||
// Straight to /dev/null!
|
||||
}
|
||||
|
||||
@Override
|
||||
public E get(int index) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,211 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2026 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.hullhider;
|
||||
|
||||
import de.steamwar.entity.REntity;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockPhysicsEvent;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
import org.bukkit.event.entity.EntitySpawnEvent;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
/**
|
||||
* Manages one {@link Hull} per key (e.g. a team or a region).
|
||||
* Which players may view which hull, when hulls are initialised and when this listener is registered is up to the user.
|
||||
*/
|
||||
public class HullHider<K> implements Listener {
|
||||
|
||||
private final boolean hideEntities;
|
||||
private final Map<K, Hull> hullMap = new LinkedHashMap<>();
|
||||
// Read on netty threads, replaced on every change
|
||||
private volatile Hull[] hulls = new Hull[0];
|
||||
|
||||
/**
|
||||
* @param hideEntities whether entities and REntities inside the hidden part of a hull are hidden from non-viewers as well
|
||||
*/
|
||||
public HullHider(boolean hideEntities) {
|
||||
this.hideEntities = hideEntities;
|
||||
}
|
||||
|
||||
/**
|
||||
* The hull hides everything from non-viewers until it is initialised.
|
||||
*/
|
||||
public void addHull(K key, Hull hull) {
|
||||
hullMap.put(key, hull);
|
||||
hulls = hullMap.values().toArray(new Hull[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Stops hiding the hull: shows the entities it hid and resends its chunks to everybody who could not view it.
|
||||
*/
|
||||
public void removeHull(K key) {
|
||||
Hull hull = hullMap.remove(key);
|
||||
if (hull == null) return;
|
||||
hulls = hullMap.values().toArray(new Hull[0]);
|
||||
|
||||
hull.reveal();
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
if (!hull.isViewer(player)) {
|
||||
hull.resendChunks(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Hull getHull(K key) {
|
||||
return hullMap.get(key);
|
||||
}
|
||||
|
||||
public void forEach(BiConsumer<K, Hull> consumer) {
|
||||
hullMap.forEach(consumer);
|
||||
}
|
||||
|
||||
public void initialize(K key) {
|
||||
Hull hull = hullMap.get(key);
|
||||
hull.initialize();
|
||||
|
||||
// Chunks encoded while the hull was filled as hidden contain obfuscated blocks that are visible now, but no block update is generated for them
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
if (!hull.isViewer(player)) {
|
||||
hull.resendChunks(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Has to be called after the player became a viewer of the hull or stopped being one.
|
||||
*/
|
||||
public void resendChunks(Player player, K key) {
|
||||
hullMap.get(key).resendChunks(player);
|
||||
}
|
||||
|
||||
public void fill(K key, boolean visible) {
|
||||
hullMap.get(key).fill(visible);
|
||||
}
|
||||
|
||||
public void fillAll(boolean visible) {
|
||||
for (Hull hull : hulls) {
|
||||
hull.fill(visible);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Viewers
|
||||
*/
|
||||
public void addViewer(Player player, K key) {
|
||||
hullMap.get(key).addViewer(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Viewers
|
||||
*/
|
||||
public void removeViewer(Player player, K key) {
|
||||
hullMap.get(key).removeViewer(player);
|
||||
}
|
||||
|
||||
public void forgetViewer(Player player) {
|
||||
for (Hull hull : hulls) {
|
||||
hull.forgetViewer(player);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isBlockHidden(Player player, int x, int y, int z) {
|
||||
for (Hull hull : hulls) {
|
||||
if (hull.isBlockHidden(player, x, y, z)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onBlockPhysic(BlockPhysicsEvent e) {
|
||||
if (e.getBlock() == e.getSourceBlock() || e.getChangedType() == Material.AIR) {
|
||||
blockUpdate(e.getBlock(), e.getChangedBlockData());
|
||||
}
|
||||
}
|
||||
|
||||
public void blockUpdate(Block block, BlockData changedData) {
|
||||
for (Hull hull : hulls) {
|
||||
hull.updateBlockVisibility(block, changedData);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onSpawn(EntitySpawnEvent e) {
|
||||
checkEntity(e.getEntity());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onDeath(EntityDeathEvent e) {
|
||||
if (!hideEntities) return;
|
||||
|
||||
for (Hull hull : hulls) {
|
||||
hull.removeEntity(e.getEntity());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Has to be called every tick for every entity, as entities can move into or out of the hidden part of a hull.
|
||||
*/
|
||||
public void checkEntity(Entity entity) {
|
||||
if (!hideEntities) return;
|
||||
|
||||
for (Hull hull : hulls) {
|
||||
hull.checkEntity(entity);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Has to be called every tick after the entities have been checked.
|
||||
*/
|
||||
public void sendUncoveredBlocks() {
|
||||
for (Hull hull : hulls) {
|
||||
hull.sendUncoveredBlocks();
|
||||
}
|
||||
}
|
||||
|
||||
public void updateREntity(REntity e) {
|
||||
if (!hideEntities) return;
|
||||
|
||||
for (Hull hull : hulls) {
|
||||
hull.checkREntity(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void despawnREntity(REntity e) {
|
||||
if (!hideEntities) return;
|
||||
|
||||
for (Hull hull : hulls) {
|
||||
hull.removeREntity(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2026 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.hullhider;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Location;
|
||||
|
||||
/**
|
||||
* Immutable block box a {@link Hull} covers. The minimum is inclusive, the maximum exclusive.
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public final class HullRegion {
|
||||
|
||||
public static HullRegion fromSize(int minX, int minY, int minZ, int sizeX, int sizeY, int sizeZ) {
|
||||
return new HullRegion(minX, minY, minZ, minX + sizeX, minY + sizeY, minZ + sizeZ);
|
||||
}
|
||||
|
||||
public static HullRegion fromInclusive(int minX, int minY, int minZ, int maxX, int maxY, int maxZ) {
|
||||
return new HullRegion(minX, minY, minZ, maxX + 1, maxY + 1, maxZ + 1);
|
||||
}
|
||||
|
||||
private final int minX;
|
||||
private final int minY;
|
||||
private final int minZ;
|
||||
private final int maxX;
|
||||
private final int maxY;
|
||||
private final int maxZ;
|
||||
|
||||
public int getSizeX() {
|
||||
return maxX - minX;
|
||||
}
|
||||
|
||||
public int getSizeY() {
|
||||
return maxY - minY;
|
||||
}
|
||||
|
||||
public int getSizeZ() {
|
||||
return maxZ - minZ;
|
||||
}
|
||||
|
||||
public int volume() {
|
||||
return getSizeX() * getSizeY() * getSizeZ();
|
||||
}
|
||||
|
||||
public boolean contains(int x, int y, int z) {
|
||||
return minX <= x && x < maxX && minY <= y && y < maxY && minZ <= z && z < maxZ;
|
||||
}
|
||||
|
||||
public boolean contains(Location location) {
|
||||
return contains(location.getBlockX(), location.getBlockY(), location.getBlockZ());
|
||||
}
|
||||
|
||||
public boolean chunkOutside(int chunkX, int chunkZ) {
|
||||
return chunkX < (minX >> 4) || chunkX > ((maxX - 1) >> 4) || chunkZ < (minZ >> 4) || chunkZ > ((maxZ - 1) >> 4);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the index of the block within a bitset of {@link #volume()} bits, only valid for contained blocks
|
||||
*/
|
||||
public int toIndex(int x, int y, int z) {
|
||||
return ((y - minY) * getSizeZ() + (z - minZ)) * getSizeX() + (x - minX);
|
||||
}
|
||||
|
||||
public void forEach(BlockConsumer executor) {
|
||||
for (int x = minX; x < maxX; x++) {
|
||||
for (int y = minY; y < maxY; y++) {
|
||||
for (int z = minZ; z < maxZ; z++) {
|
||||
executor.accept(x, y, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void forEachChunk(ChunkConsumer executor) {
|
||||
for (int chunkX = minX >> 4; chunkX <= (maxX - 1) >> 4; chunkX++) {
|
||||
for (int chunkZ = minZ >> 4; chunkZ <= (maxZ - 1) >> 4; chunkZ++) {
|
||||
executor.accept(chunkX, chunkZ);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public interface BlockConsumer {
|
||||
void accept(int x, int y, int z);
|
||||
}
|
||||
|
||||
public interface ChunkConsumer {
|
||||
void accept(int chunkX, int chunkZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return minX + "," + minY + "," + minZ + "->" + maxX + "," + maxY + "," + maxZ;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2026 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.hullhider;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* The players of a {@link Hull}. Whether an added player may see the hull contents or sees the hull blocks instead is decided by {@link #isViewer(Player)}.
|
||||
* Stores the players, so every hull needs its own instance.
|
||||
*/
|
||||
public abstract sealed class Viewers {
|
||||
|
||||
// Concurrent as it is read on netty threads
|
||||
protected final Set<UUID> players = ConcurrentHashMap.newKeySet();
|
||||
|
||||
/**
|
||||
* @return whether the player may see the hull contents instead of the hull blocks
|
||||
*/
|
||||
public abstract boolean isViewer(Player player);
|
||||
|
||||
/**
|
||||
* @return whether the player was not added before
|
||||
*/
|
||||
public boolean addViewer(Player player) {
|
||||
return players.add(player.getUniqueId());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return whether the player was added before
|
||||
*/
|
||||
public boolean removeViewer(Player player) {
|
||||
return players.remove(player.getUniqueId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Hidden from everybody, only added players may see the hull contents.
|
||||
*/
|
||||
public static final class HiddenByDefault extends Viewers {
|
||||
@Override
|
||||
public boolean isViewer(Player player) {
|
||||
return players.contains(player.getUniqueId());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Visible to everybody, only added players see the hull blocks instead of the hull contents.
|
||||
*/
|
||||
public static final class VisibleByDefault extends Viewers {
|
||||
@Override
|
||||
public boolean isViewer(Player player) {
|
||||
return !players.contains(player.getUniqueId());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2026 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.techhider;
|
||||
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public interface AccessPrivilegeProvider {
|
||||
/**
|
||||
* Resolves everything that can change concurrently about this player once.
|
||||
* The result is used for all decisions of one outgoing packet (including all packets of a bundle).
|
||||
*/
|
||||
ForPlayer forPlayer(Player p);
|
||||
|
||||
boolean isPlayerPrivilegedToPerformAction(Player p);
|
||||
|
||||
/**
|
||||
* What a single player may access, valid for the processing of one outgoing packet.
|
||||
*/
|
||||
interface ForPlayer {
|
||||
Player getPlayer();
|
||||
|
||||
/**
|
||||
* @return true if nothing within this chunk is restricted for this player, so the chunk may be sent unmodified
|
||||
*/
|
||||
boolean canAccessAllDataWithinChunk(int chunkX, int chunkZ);
|
||||
|
||||
boolean canAccessPosition(int blockX, int blockY, int blockZ);
|
||||
|
||||
boolean canAccessBlock(int blockX, int blockY, int blockZ, Block block);
|
||||
|
||||
boolean canAccessBlockState(int blockX, int blockY, int blockZ, BlockState blockState);
|
||||
|
||||
boolean canAccessEntity(int entityId);
|
||||
|
||||
/**
|
||||
* @return whether the player may see the entity spawning at this position
|
||||
*/
|
||||
default boolean canAccessEntitySpawn(int entityId, int blockX, int blockY, int blockZ) {
|
||||
return canAccessEntity(entityId) && canAccessPosition(blockX, blockY, blockZ);
|
||||
}
|
||||
|
||||
boolean canAccessBlockEntity(int blockX, int blockY, int blockZ, BlockEntityType<?> type);
|
||||
|
||||
/**
|
||||
* @return the block state sent instead of a block this player may not access at this position
|
||||
*/
|
||||
BlockState getObfuscation(int blockX, int blockY, int blockZ);
|
||||
}
|
||||
}
|
||||
+60
-30
@@ -19,8 +19,11 @@
|
||||
|
||||
package de.steamwar.techhider;
|
||||
|
||||
import de.steamwar.core.ProtocolUtils;
|
||||
import de.steamwar.techhider.AccessPrivilegeProvider.ForPlayer;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.protocol.game.ClientboundLevelChunkPacketData;
|
||||
import net.minecraft.network.protocol.game.ClientboundLevelChunkWithLightPacket;
|
||||
import net.minecraft.util.SimpleBitStorage;
|
||||
@@ -29,6 +32,8 @@ import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.function.UnaryOperator;
|
||||
|
||||
@@ -43,14 +48,6 @@ public class ChunkHider {
|
||||
private final int BLOCKS_PER_SECTION = 4096;
|
||||
private final int BIOMES_PER_SECTION = 64;
|
||||
|
||||
private final int blockIdUsedForHiding;
|
||||
private final AccessPrivilegeProvider accessPrivilegeProvider;
|
||||
|
||||
public ChunkHider(Block blockUsedForObfuscation, AccessPrivilegeProvider accessPrivilegeProvider) {
|
||||
blockIdUsedForHiding = Block.BLOCK_STATE_REGISTRY.getId(blockUsedForObfuscation.defaultBlockState());
|
||||
this.accessPrivilegeProvider = accessPrivilegeProvider;
|
||||
}
|
||||
|
||||
private int getLongsRequiredToEncodeEntries(int bitsPerEntry, int entryCount) {
|
||||
int entriesPerLong = Long.SIZE / bitsPerEntry;
|
||||
int dataLengthAsLongCount = (entryCount + entriesPerLong - 1) / entriesPerLong;
|
||||
@@ -69,7 +66,8 @@ public class ChunkHider {
|
||||
return dataArray;
|
||||
}
|
||||
|
||||
public ClientboundLevelChunkWithLightPacket processLevelChunkWithLightPacket(Player player, ClientboundLevelChunkWithLightPacket packet) {
|
||||
public ClientboundLevelChunkWithLightPacket processLevelChunkWithLightPacket(ForPlayer access, ClientboundLevelChunkWithLightPacket packet) {
|
||||
Player player = access.getPlayer();
|
||||
int chunkX = packet.getX();
|
||||
int chunkZ = packet.getZ();
|
||||
ClientboundLevelChunkPacketData chunkData = packet.getChunkData();
|
||||
@@ -88,9 +86,22 @@ public class ChunkHider {
|
||||
if (bitsPerBlock == 0) {
|
||||
int sectionBlockId = ProtocolUtils.readVarInt(in);
|
||||
|
||||
out.writeShort(blockCount);
|
||||
out.writeByte(bitsPerBlock);
|
||||
ProtocolUtils.writeVarInt(out, sectionBlockId);
|
||||
int[] blockData = new int[BLOCKS_PER_SECTION];
|
||||
Arrays.fill(blockData, sectionBlockId);
|
||||
int[] obfuscatedBlockData = obfuscateBlockDataArray(access, chunkX, chunkZ, yOffset, blockData);
|
||||
|
||||
if (Arrays.equals(blockData, obfuscatedBlockData)) {
|
||||
out.writeShort(blockCount);
|
||||
out.writeByte(bitsPerBlock);
|
||||
ProtocolUtils.writeVarInt(out, sectionBlockId);
|
||||
} else {
|
||||
// The client skips sections without non-air blocks, so the count has to include the obfuscation blocks
|
||||
out.writeShort(countNonAirBlocks(obfuscatedBlockData));
|
||||
out.writeByte(15);
|
||||
for (long rawDataSegment : encodeDirectBlockDataArray(obfuscatedBlockData)) {
|
||||
out.writeLong(rawDataSegment);
|
||||
}
|
||||
}
|
||||
} else if (bitsPerBlock <= BIT_PER_BLOCK_INDIRECTION_LIMIT) {
|
||||
int palletLength = ProtocolUtils.readVarInt(in);
|
||||
int[] pallet = ProtocolUtils.readVarIntArray(in, palletLength);
|
||||
@@ -104,7 +115,7 @@ public class ChunkHider {
|
||||
resolvedData[i] = pallet[palletReference];
|
||||
}
|
||||
|
||||
int[] obfuscatedBlockData = obfuscateBlockDataArray(player, chunkX, chunkZ, yOffset, resolvedData);
|
||||
int[] obfuscatedBlockData = obfuscateBlockDataArray(access, chunkX, chunkZ, yOffset, resolvedData);
|
||||
|
||||
long[] reEncodedData = encodeDirectBlockDataArray(obfuscatedBlockData);
|
||||
|
||||
@@ -149,7 +160,7 @@ public class ChunkHider {
|
||||
|
||||
int[] blockData = resolveDirectBlockDataArray(rawData, bitsPerBlock);
|
||||
|
||||
int[] obfuscatedBlockData = obfuscateBlockDataArray(player, chunkX, chunkZ, yOffset, blockData);
|
||||
int[] obfuscatedBlockData = obfuscateBlockDataArray(access, chunkX, chunkZ, yOffset, blockData);
|
||||
|
||||
long[] reEncodedData = encodeDirectBlockDataArray(obfuscatedBlockData);
|
||||
|
||||
@@ -172,13 +183,13 @@ public class ChunkHider {
|
||||
out.readBytes(data);
|
||||
|
||||
List<ClientboundLevelChunkPacketData.BlockEntityInfo> blockEntities = chunkData.blockEntitiesData;
|
||||
List<ClientboundLevelChunkPacketData.BlockEntityInfo> filteredBlockEntities = filterBlockEntities(player, blockEntities, chunkX, chunkZ);
|
||||
List<ClientboundLevelChunkPacketData.BlockEntityInfo> filteredBlockEntities = filterBlockEntities(access, blockEntities, chunkX, chunkZ);
|
||||
|
||||
return buildNewChunkPacket(packet, data, filteredBlockEntities);
|
||||
|
||||
}
|
||||
|
||||
private int[] obfuscateBlockDataArray(Player player, int chunkX, int chunkZ, int yOffset, int[] blockDataArray) {
|
||||
private int[] obfuscateBlockDataArray(ForPlayer access, int chunkX, int chunkZ, int yOffset, int[] blockDataArray) {
|
||||
int[] obfuscatedData = new int[BLOCKS_PER_SECTION];
|
||||
for (int sectionY = 0; sectionY < SECTION_SPAN_SIZE; sectionY++) {
|
||||
for (int sectionZ = 0; sectionZ < SECTION_SPAN_SIZE; sectionZ++) {
|
||||
@@ -194,10 +205,10 @@ public class ChunkHider {
|
||||
Block block = blockState.getBlock();
|
||||
|
||||
|
||||
if (accessPrivilegeProvider.isPlayerPrivilegedToAccessPosition(player, worldX, worldY, worldZ) && accessPrivilegeProvider.isPlayerPrivilegedToAccessBlock(player, worldX, worldY, worldZ, block) && accessPrivilegeProvider.isPlayerPrivilegedToAccessBlockState(player, worldX, worldY, worldZ, blockState)) {
|
||||
if (access.canAccessPosition(worldX, worldY, worldZ) && access.canAccessBlock(worldX, worldY, worldZ, block) && access.canAccessBlockState(worldX, worldY, worldZ, blockState)) {
|
||||
obfuscatedData[blockDataIndex] = blockId;
|
||||
} else {
|
||||
obfuscatedData[blockDataIndex] = blockIdUsedForHiding;
|
||||
obfuscatedData[blockDataIndex] = Block.getId(access.getObfuscation(worldX, worldY, worldZ));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -206,6 +217,16 @@ public class ChunkHider {
|
||||
return obfuscatedData;
|
||||
}
|
||||
|
||||
private int countNonAirBlocks(int[] blockDataArray) {
|
||||
int count = 0;
|
||||
for (int blockId : blockDataArray) {
|
||||
if (!Block.BLOCK_STATE_REGISTRY.byId(blockId).isAir()) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
private int[] resolveDirectBlockDataArray(long[] rawDataArray, byte bitsPerBlock) {
|
||||
SimpleBitStorage data = new SimpleBitStorage(bitsPerBlock, BLOCKS_PER_SECTION, rawDataArray);
|
||||
|
||||
@@ -241,24 +262,33 @@ public class ChunkHider {
|
||||
return clonedPacket;
|
||||
}
|
||||
|
||||
private List<ClientboundLevelChunkPacketData.BlockEntityInfo> filterBlockEntities(Player player, List<ClientboundLevelChunkPacketData.BlockEntityInfo> blockEntities, int chunkX, int chunkZ) {
|
||||
private List<ClientboundLevelChunkPacketData.BlockEntityInfo> filterBlockEntities(ForPlayer access, List<ClientboundLevelChunkPacketData.BlockEntityInfo> blockEntities, int chunkX, int chunkZ) {
|
||||
int fourBitBitmask = 0b0000_1111;
|
||||
|
||||
return blockEntities.stream()
|
||||
.filter((blockEntityInfo) -> {
|
||||
BlockEntityType<?> type = blockEntityInfo.type;
|
||||
int packedXZ = blockEntityInfo.packedXZ;
|
||||
List<ClientboundLevelChunkPacketData.BlockEntityInfo> filtered = new ArrayList<>(blockEntities.size());
|
||||
for (ClientboundLevelChunkPacketData.BlockEntityInfo blockEntityInfo : blockEntities) {
|
||||
BlockEntityType<?> type = blockEntityInfo.type;
|
||||
int packedXZ = blockEntityInfo.packedXZ;
|
||||
|
||||
int localX = (packedXZ >> 4) & fourBitBitmask;
|
||||
int localZ = packedXZ & fourBitBitmask;
|
||||
int localX = (packedXZ >> 4) & fourBitBitmask;
|
||||
int localZ = packedXZ & fourBitBitmask;
|
||||
|
||||
int worldX = (chunkX * SECTION_SPAN_SIZE) + localX;
|
||||
int worldZ = (chunkZ * SECTION_SPAN_SIZE) + localZ;
|
||||
int worldX = (chunkX * SECTION_SPAN_SIZE) + localX;
|
||||
int worldZ = (chunkZ * SECTION_SPAN_SIZE) + localZ;
|
||||
|
||||
int worldY = blockEntityInfo.y;
|
||||
int worldY = blockEntityInfo.y;
|
||||
|
||||
return accessPrivilegeProvider.isPlayerPrivilegedToAccessPosition(player, worldX, worldY, worldZ) && accessPrivilegeProvider.isPlayerPrivilegedToAccessBlockEntity(player, worldX, worldY, worldZ, type);
|
||||
}).toList();
|
||||
// A hidden position is obfuscated as a whole
|
||||
if (!access.canAccessPosition(worldX, worldY, worldZ)) continue;
|
||||
|
||||
if (access.canAccessBlockEntity(worldX, worldY, worldZ, type)) {
|
||||
filtered.add(blockEntityInfo);
|
||||
} else {
|
||||
// Without its block entity, the client would not render blocks like shulker boxes, so only their data is hidden
|
||||
filtered.add(new ClientboundLevelChunkPacketData.BlockEntityInfo(packedXZ, worldY, type, new CompoundTag()));
|
||||
}
|
||||
}
|
||||
return filtered;
|
||||
}
|
||||
|
||||
private void copyOverSectionBiomeData(ByteBuf oldData, ByteBuf newData) {
|
||||
@@ -0,0 +1,115 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2026 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.techhider;
|
||||
|
||||
import de.steamwar.sql.GameModeConfig;
|
||||
import lombok.Getter;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.FluidState;
|
||||
import net.minecraft.world.level.material.Fluids;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* Which blocks, block states and block entities to hide, and the block to replace them with.
|
||||
*/
|
||||
@Getter
|
||||
public final class ObfuscationConfig {
|
||||
|
||||
public static ObfuscationConfig of(GameModeConfig.TechhiderConfig<Material> config) {
|
||||
return new ObfuscationConfig(config.ObfuscateWith, config.HiddenBlocks, config.HiddenBlockEntities);
|
||||
}
|
||||
|
||||
private final Block obfuscateWith;
|
||||
private final BlockState obfuscationState;
|
||||
private final Set<Block> blocks;
|
||||
private final Set<BlockState> blockStates;
|
||||
private final Set<BlockEntityType<?>> blockEntityTypes;
|
||||
|
||||
/**
|
||||
* @param hiddenBlocks "water" also hides all waterlogged block states
|
||||
* @param hiddenBlockEntities block entity type ids, e.g. "minecraft:sign"
|
||||
*/
|
||||
public ObfuscationConfig(Material obfuscateWith, Set<Material> hiddenBlocks, Set<String> hiddenBlockEntities) {
|
||||
this.obfuscateWith = CraftMagicNumbers.getBlock(obfuscateWith);
|
||||
this.obfuscationState = this.obfuscateWith.defaultBlockState();
|
||||
|
||||
this.blocks = hiddenBlocks.stream()
|
||||
.map(CraftMagicNumbers::getBlock)
|
||||
.collect(Collectors.toUnmodifiableSet());
|
||||
|
||||
this.blockStates = getBlockStatesToHideFromMaterials(hiddenBlocks);
|
||||
|
||||
this.blockEntityTypes = hiddenBlockEntities.stream()
|
||||
.map(id -> {
|
||||
ResourceLocation loc = ResourceLocation.parse(id);
|
||||
return BuiltInRegistries.BLOCK_ENTITY_TYPE.get(loc).orElse(null);
|
||||
})
|
||||
.filter(Objects::nonNull)
|
||||
.map(Holder.Reference::value)
|
||||
.collect(Collectors.toUnmodifiableSet());
|
||||
}
|
||||
|
||||
public boolean hidesBlock(Block block) {
|
||||
return blocks.contains(block);
|
||||
}
|
||||
|
||||
public boolean hidesBlockState(BlockState blockState) {
|
||||
return blockStates.contains(blockState);
|
||||
}
|
||||
|
||||
public boolean hidesBlockEntity(BlockEntityType<?> type) {
|
||||
return blockEntityTypes.contains(type);
|
||||
}
|
||||
|
||||
private static Stream<BlockState> getWaterloggedBlockStates() {
|
||||
FluidState waterFluidState = Fluids.WATER.getSource(false);
|
||||
|
||||
return BuiltInRegistries.BLOCK.stream()
|
||||
.map((block) -> block.getStateDefinition().getPossibleStates())
|
||||
.flatMap(Collection::stream)
|
||||
.filter((blockState -> blockState.getFluidState() == waterFluidState));
|
||||
}
|
||||
|
||||
private static Set<BlockState> getBlockStatesToHideFromMaterials(Set<Material> materials) {
|
||||
Stream<BlockState> allStatesFromMaterials = materials.stream()
|
||||
.map(CraftMagicNumbers::getBlock)
|
||||
.map((block) -> block.getStateDefinition().getPossibleStates())
|
||||
.flatMap(Collection::stream);
|
||||
|
||||
if(materials.contains(Material.WATER)) {
|
||||
return Stream.concat(allStatesFromMaterials, getWaterloggedBlockStates()).collect(Collectors.toUnmodifiableSet());
|
||||
}
|
||||
else {
|
||||
return allStatesFromMaterials.collect(Collectors.toUnmodifiableSet());
|
||||
}
|
||||
}
|
||||
}
|
||||
+108
-85
@@ -19,14 +19,14 @@
|
||||
|
||||
package de.steamwar.techhider;
|
||||
|
||||
import de.steamwar.techhider.AccessPrivilegeProvider.ForPlayer;
|
||||
import com.comphenix.tinyprotocol.TinyProtocol;
|
||||
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||
import it.unimi.dsi.fastutil.ints.IntList;
|
||||
import it.unimi.dsi.fastutil.shorts.ShortArraySet;
|
||||
import it.unimi.dsi.fastutil.shorts.ShortSets;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.SectionPos;
|
||||
import net.minecraft.network.PacketListener;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.network.protocol.Packet;
|
||||
import net.minecraft.network.protocol.common.*;
|
||||
import net.minecraft.network.protocol.configuration.ClientboundFinishConfigurationPacket;
|
||||
@@ -36,16 +36,20 @@ import net.minecraft.network.protocol.configuration.ClientboundUpdateEnabledFeat
|
||||
import net.minecraft.network.protocol.cookie.ClientboundCookieRequestPacket;
|
||||
import net.minecraft.network.protocol.game.*;
|
||||
import net.minecraft.network.protocol.login.*;
|
||||
import net.minecraft.network.protocol.ping.ClientboundPongResponsePacket;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.ToIntFunction;
|
||||
import java.util.logging.Level;
|
||||
|
||||
/**
|
||||
* The TechHider follows the default-deny security principle,
|
||||
@@ -54,18 +58,16 @@ import java.util.function.ToIntFunction;
|
||||
*/
|
||||
public class TechHider {
|
||||
private final Set<Class<?>> bypassingPackets;
|
||||
private final Map<Class<? extends Packet<? extends PacketListener>>, BiFunction<Player, Packet<? extends PacketListener>, Packet<? extends PacketListener>>> packetProcessors;
|
||||
private final Map<Class<? extends Packet<? extends PacketListener>>, BiFunction<ForPlayer, Packet<? extends PacketListener>, Packet<? extends PacketListener>>> packetProcessors;
|
||||
|
||||
private final BlockState blockStateUsedForObfuscation;
|
||||
private final Set<Class<?>> loggedUnhandledPackets = ConcurrentHashMap.newKeySet();
|
||||
private final ChunkHider chunkHider;
|
||||
|
||||
private final AccessPrivilegeProvider privilegeProvider;
|
||||
|
||||
// TODO handle packet bundle
|
||||
public TechHider(Block blockUsedForObfuscation, AccessPrivilegeProvider privilegeProvider) {
|
||||
this.blockStateUsedForObfuscation = blockUsedForObfuscation.defaultBlockState();
|
||||
|
||||
this.chunkHider = new ChunkHider(blockUsedForObfuscation, privilegeProvider);
|
||||
public TechHider(AccessPrivilegeProvider privilegeProvider) {
|
||||
this.chunkHider = new ChunkHider();
|
||||
this.privilegeProvider = privilegeProvider;
|
||||
|
||||
this.bypassingPackets = new HashSet<>(List.of(
|
||||
@@ -176,11 +178,17 @@ public class TechHider {
|
||||
ClientboundBlockChangedAckPacket.class, // 7.1.5 Acknowledge Block Change
|
||||
ClientboundChunkBatchFinishedPacket.class, // 7.1.12 Chunk Batch Finished (Delimiter)
|
||||
ClientboundChunkBatchStartPacket.class, // 7.1.13 Chunk Batch Start (Delimiter)
|
||||
ClientboundAwardStatsPacket.class, // 7.1.4 Award Statistics: the player's own statistics
|
||||
ClientboundDebugSamplePacket.class, // 7.1.28 Debug Sample: server tick timings
|
||||
ClientboundPongResponsePacket.class, // Ping Response: answer to the client's own ping
|
||||
ClientboundChunksBiomesPacket.class, // 7.1.14 Chunk Biomes
|
||||
ClientboundContainerClosePacket.class, // 7.1.18 Close Container
|
||||
ClientboundSetChunkCacheCenterPacket.class, // 7.1.93 Set Center Chunk
|
||||
ClientboundForgetLevelChunkPacket.class, // 7.1.38 Unload Chunk
|
||||
ClientboundUpdateTagsPacket.class, // 7.1.133 Update Tags (play)
|
||||
// 7.1.76 Remove Entities: must not be filtered, otherwise Player#hideEntity leaves ghosts on the client.
|
||||
// Entities that are already gone from the world pass the entity checks anyway, so no additional information is leaked.
|
||||
ClientboundRemoveEntitiesPacket.class,
|
||||
ClientboundPlayerInfoRemovePacket.class, // 7.1.68 Player Info Remove
|
||||
ClientboundPlayerInfoUpdatePacket.class, // 7.1.69 Player Info Update
|
||||
ClientboundMoveVehiclePacket.class, // 7.1.56 Move Vehicle (vehicle the player is in)
|
||||
@@ -193,16 +201,16 @@ public class TechHider {
|
||||
ClientboundContainerSetSlotPacket.class // 7.1.21 Set Container Slot
|
||||
));
|
||||
|
||||
BiFunction<Player, Packet<? extends PacketListener>, Packet<? extends PacketListener>> tossPacket = (p, packet) -> null;
|
||||
Map<Class<? extends Packet<? extends PacketListener>>, BiFunction<Player, Packet<? extends PacketListener>, Packet<? extends PacketListener>>> processors = new HashMap<>();
|
||||
BiFunction<ForPlayer, Packet<? extends PacketListener>, Packet<? extends PacketListener>> tossPacket = (access, packet) -> null;
|
||||
Map<Class<? extends Packet<? extends PacketListener>>, BiFunction<ForPlayer, Packet<? extends PacketListener>, Packet<? extends PacketListener>>> processors = new HashMap<>();
|
||||
|
||||
// --- Entity packets -
|
||||
// 7.1.2 Spawn Entity: entity type and position can reveal hidden contraptions.
|
||||
processors.put(ClientboundAddEntityPacket.class, (p, packet) -> this.processAddEntityPacket(p, (ClientboundAddEntityPacket) packet));
|
||||
processors.put(ClientboundAddEntityPacket.class, (access, packet) -> this.processAddEntityPacket(access, (ClientboundAddEntityPacket) packet));
|
||||
// 7.1.3 Entity Animation: entity id based signal, keep blocked until entity visibility is modeled.
|
||||
processors.put(ClientboundAnimatePacket.class, this.buildEntityPacketProcessor(ClientboundAnimatePacket::getId));
|
||||
// 7.1.35 Entity Event: entity id based signal.
|
||||
processors.put(ClientboundEntityEventPacket.class, this.buildEntityPacketProcessor(ClientboundEntityEventPacket::getEventId));
|
||||
processors.put(ClientboundEntityEventPacket.class, this.<ClientboundEntityEventPacket>buildEntityPacketProcessor(packet -> packet.entityId));
|
||||
// 7.1.36 Teleport Entity: entity id and absolute position.
|
||||
processors.put(ClientboundTeleportEntityPacket.class, this.buildEntityPacketProcessor(ClientboundTeleportEntityPacket::id));
|
||||
// 7.1.42 Hurt Animation: entity id based signal.
|
||||
@@ -234,43 +242,41 @@ public class TechHider {
|
||||
// 7.1.67 Combat Death: entity/player ids and death message context.
|
||||
processors.put(ClientboundPlayerCombatKillPacket.class, this.buildEntityPacketProcessor(ClientboundPlayerCombatKillPacket::playerId));
|
||||
// 7.1.52/53/55 Update Entity Position/Rotation: entity id and movement signal.
|
||||
processors.put(ClientboundMoveEntityPacket.class, (p, packet) -> this.processMoveEntityPacket(p, (ClientboundMoveEntityPacket) packet));
|
||||
processors.put(ClientboundMoveEntityPacket.Pos.class, (p, packet) -> this.processMoveEntityPacket(p, (ClientboundMoveEntityPacket.Pos) packet));
|
||||
processors.put(ClientboundMoveEntityPacket.Rot.class, (p, packet) -> this.processMoveEntityPacket(p, (ClientboundMoveEntityPacket.Rot) packet));
|
||||
processors.put(ClientboundMoveEntityPacket.PosRot.class, (p, packet) -> this.processMoveEntityPacket(p, (ClientboundMoveEntityPacket.PosRot) packet));
|
||||
processors.put(ClientboundMoveEntityPacket.class, (access, packet) -> this.processMoveEntityPacket(access, (ClientboundMoveEntityPacket) packet));
|
||||
processors.put(ClientboundMoveEntityPacket.Pos.class, (access, packet) -> this.processMoveEntityPacket(access, (ClientboundMoveEntityPacket.Pos) packet));
|
||||
processors.put(ClientboundMoveEntityPacket.Rot.class, (access, packet) -> this.processMoveEntityPacket(access, (ClientboundMoveEntityPacket.Rot) packet));
|
||||
processors.put(ClientboundMoveEntityPacket.PosRot.class, (access, packet) -> this.processMoveEntityPacket(access, (ClientboundMoveEntityPacket.PosRot) packet));
|
||||
|
||||
// 7.1.82 Set Head Rotation: entity id and rotation.
|
||||
processors.put(ClientboundRotateHeadPacket.class, (p, packet) -> this.processRotateHeadPacket(p, (ClientboundRotateHeadPacket) packet));
|
||||
// 7.1.76 Remove Entities: entity id visibility side channel.
|
||||
processors.put(ClientboundRemoveEntitiesPacket.class, (p, packet) -> this.processRemoveEntitiesPacket(p, (ClientboundRemoveEntitiesPacket) packet));
|
||||
processors.put(ClientboundRotateHeadPacket.class, (access, packet) -> this.processRotateHeadPacket(access, (ClientboundRotateHeadPacket) packet));
|
||||
// 7.1.99 Link Entities: entity relationship signal.
|
||||
processors.put(ClientboundSetEntityLinkPacket.class, (p, packet) -> this.processSetEntityLinkPacket(p, (ClientboundSetEntityLinkPacket) packet));
|
||||
processors.put(ClientboundSetEntityLinkPacket.class, (access, packet) -> this.processSetEntityLinkPacket(access, (ClientboundSetEntityLinkPacket) packet));
|
||||
|
||||
// --- Block entity packets ---
|
||||
// 7.1.7 Block Entity Data: currently filtered by block position and allowed tile-entity actions.
|
||||
processors.put(ClientboundBlockEntityDataPacket.class, (p, packet) -> processBlockEntityDataPacket(p, (ClientboundBlockEntityDataPacket) packet));
|
||||
processors.put(ClientboundBlockEntityDataPacket.class, (access, packet) -> processBlockEntityDataPacket(access, (ClientboundBlockEntityDataPacket) packet));
|
||||
// 7.1.122 Tag Query Response: block-entity query result.
|
||||
processors.put(ClientboundTagQueryPacket.class, tossPacket);
|
||||
|
||||
// --- Block packets ---
|
||||
// 7.1.6 Set Block Destroy Stage: block position and mining progress can reveal activity.
|
||||
processors.put(ClientboundBlockDestructionPacket.class, (p, packet) -> proccessBlockDestructionPacket(p, (ClientboundBlockDestructionPacket) packet));
|
||||
processors.put(ClientboundBlockDestructionPacket.class, (access, packet) -> proccessBlockDestructionPacket(access, (ClientboundBlockDestructionPacket) packet));
|
||||
// 7.1.8 Block Action: currently filtered by block position.
|
||||
processors.put(ClientboundBlockEventPacket.class, (p, packet) -> processBlockEventPacket(p, (ClientboundBlockEventPacket) packet));
|
||||
processors.put(ClientboundBlockEventPacket.class, (access, packet) -> processBlockEventPacket(access, (ClientboundBlockEventPacket) packet));
|
||||
// 7.1.9 Block Update: currently filtered/obfuscated by block position and block id.
|
||||
processors.put(ClientboundBlockUpdatePacket.class, (p, packet) -> processBlockUpdatePacket(p, (ClientboundBlockUpdatePacket) packet));
|
||||
processors.put(ClientboundBlockUpdatePacket.class, (access, packet) -> processBlockUpdatePacket(access, (ClientboundBlockUpdatePacket) packet));
|
||||
|
||||
// --- Chunk packets ---
|
||||
// 7.1.45 Chunk Data and Update Light: currently filtered/obfuscated by chunk data processor.
|
||||
processors.put(ClientboundLevelChunkWithLightPacket.class, (p, packet) -> processChunkWithLight(p, (ClientboundLevelChunkWithLightPacket) packet));
|
||||
processors.put(ClientboundLevelChunkWithLightPacket.class, (access, packet) -> processChunkWithLight(access, (ClientboundLevelChunkWithLightPacket) packet));
|
||||
|
||||
// --- Section packets ---
|
||||
// 7.1.83 Update Section Blocks: currently filtered/obfuscated by section block processor.
|
||||
processors.put(ClientboundSectionBlocksUpdatePacket.class, (p, packet) -> processSectionUpdate(p, (ClientboundSectionBlocksUpdatePacket) packet));
|
||||
processors.put(ClientboundSectionBlocksUpdatePacket.class, (access, packet) -> processSectionUpdate(access, (ClientboundSectionBlocksUpdatePacket) packet));
|
||||
|
||||
// --- Particle packets ---
|
||||
// 7.1.47 Particle: particle type and position can reveal hidden machinery.
|
||||
processors.put(ClientboundLevelParticlesPacket.class, (p, packet) -> processLevelParticlesPacket(p, (ClientboundLevelParticlesPacket) packet));
|
||||
processors.put(ClientboundLevelParticlesPacket.class, (access, packet) -> processLevelParticlesPacket(access, (ClientboundLevelParticlesPacket) packet));
|
||||
|
||||
// --- Sound packets ---
|
||||
// 7.1.115 Entity Sound Effect: entity id and sound.
|
||||
@@ -290,26 +296,29 @@ public class TechHider {
|
||||
// 7.1.59 Open Sign Editor: block position.
|
||||
processors.put(ClientboundOpenSignEditorPacket.class, buildPositionBasedPacketProcessor(ClientboundOpenSignEditorPacket::getPos));
|
||||
// 7.1.37 Explosion: position, affected blocks, and knockback can reveal TNT/tech.
|
||||
processors.put(ClientboundExplodePacket.class, (p, rawPacket) -> {
|
||||
processors.put(ClientboundExplodePacket.class, (access, rawPacket) -> {
|
||||
ClientboundExplodePacket packet = (ClientboundExplodePacket) rawPacket;
|
||||
Vec3 pos = packet.center();
|
||||
int blockX = (int) pos.x;
|
||||
int blockY = (int) pos.y;
|
||||
int blockZ = (int) pos.z;
|
||||
int blockX = Mth.floor(pos.x);
|
||||
int blockY = Mth.floor(pos.y);
|
||||
int blockZ = Mth.floor(pos.z);
|
||||
|
||||
|
||||
return proccessPositionBasedPacket(p, blockX, blockY, blockZ, packet);
|
||||
return proccessPositionBasedPacket(access, blockX, blockY, blockZ, packet);
|
||||
});
|
||||
|
||||
this.packetProcessors = processors;
|
||||
|
||||
TinyProtocol.instance.addGlobalClientboundFilter((player, rawPacket) -> {
|
||||
try {
|
||||
// Resolved lazily (login packets arrive before the player is known) and once per outer packet
|
||||
AccessHolder access = new AccessHolder(player);
|
||||
|
||||
if (rawPacket instanceof ClientboundBundlePacket bundlePacket) {
|
||||
List<Packet<? super ClientGamePacketListener>> processedPackets = new ArrayList<>();
|
||||
|
||||
for (Packet<? super ClientGamePacketListener> packet : bundlePacket.subPackets()) {
|
||||
Packet<? super ClientGamePacketListener> processedPacket = (Packet<? super ClientGamePacketListener>) processPacket(player, packet);
|
||||
Packet<? super ClientGamePacketListener> processedPacket = (Packet<? super ClientGamePacketListener>) processPacket(access, packet);
|
||||
|
||||
if (processedPacket != null) {
|
||||
processedPackets.add(processedPacket);
|
||||
@@ -318,7 +327,7 @@ public class TechHider {
|
||||
|
||||
return new ClientboundBundlePacket(processedPackets);
|
||||
} else {
|
||||
return processPacket(player, rawPacket);
|
||||
return processPacket(access, rawPacket);
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
@@ -330,89 +339,103 @@ public class TechHider {
|
||||
TinyProtocol.instance.addFilter(ServerboundInteractPacket.class, (p, packet) -> privilegeProvider.isPlayerPrivilegedToPerformAction(p) ? packet : null);
|
||||
}
|
||||
|
||||
private Packet<?> processPacket(Player player, Packet<?> packet) {
|
||||
private final class AccessHolder {
|
||||
private final Player player;
|
||||
private ForPlayer access;
|
||||
|
||||
private AccessHolder(Player player) {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
private ForPlayer get() {
|
||||
if (access == null) {
|
||||
access = privilegeProvider.forPlayer(player);
|
||||
}
|
||||
return access;
|
||||
}
|
||||
}
|
||||
|
||||
private Packet<?> processPacket(AccessHolder access, Packet<?> packet) {
|
||||
if (bypassingPackets.contains(packet.getClass())) {
|
||||
return packet;
|
||||
} else if (packetProcessors.containsKey(packet.getClass())) {
|
||||
return packetProcessors.get(packet.getClass()).apply(player, packet);
|
||||
}
|
||||
|
||||
BiFunction<ForPlayer, Packet<? extends PacketListener>, Packet<? extends PacketListener>> processor = packetProcessors.get(packet.getClass());
|
||||
if (processor != null) {
|
||||
return processor.apply(access.get(), packet);
|
||||
} else {
|
||||
if (loggedUnhandledPackets.add(packet.getClass())) {
|
||||
Bukkit.getLogger().log(Level.WARNING, "[TechHider] Dropping unhandled packet type " + packet.getClass().getName());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private Packet<? extends PacketListener> processAddEntityPacket(Player player, ClientboundAddEntityPacket packet) {
|
||||
if (privilegeProvider.isPlayerPrivilegedToAccessEntity(player, packet.getId()) && privilegeProvider.isPlayerPrivilegedToAccessPosition(player, (int) packet.getX(), (int) packet.getY(), (int) packet.getZ())) {
|
||||
private Packet<? extends PacketListener> processAddEntityPacket(ForPlayer access, ClientboundAddEntityPacket packet) {
|
||||
if (access.canAccessEntitySpawn(packet.getId(), Mth.floor(packet.getX()), Mth.floor(packet.getY()), Mth.floor(packet.getZ()))) {
|
||||
return packet;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private Packet<? extends PacketListener> processEntityPacket(Player player, int entityId, Packet<? extends PacketListener> packet) {
|
||||
if (privilegeProvider.isPlayerPrivilegedToAccessEntity(player, entityId)) {
|
||||
private Packet<? extends PacketListener> processEntityPacket(ForPlayer access, int entityId, Packet<? extends PacketListener> packet) {
|
||||
if (access.canAccessEntity(entityId)) {
|
||||
return packet;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private <TTargetPacket extends Packet<?>> BiFunction<Player, Packet<? extends PacketListener>, Packet<? extends PacketListener>> buildEntityPacketProcessor(ToIntFunction<TTargetPacket> entityIdExtractor) {
|
||||
return (p, rawPacket) -> {
|
||||
private <TTargetPacket extends Packet<?>> BiFunction<ForPlayer, Packet<? extends PacketListener>, Packet<? extends PacketListener>> buildEntityPacketProcessor(ToIntFunction<TTargetPacket> entityIdExtractor) {
|
||||
return (access, rawPacket) -> {
|
||||
TTargetPacket packet = (TTargetPacket) rawPacket;
|
||||
return processEntityPacket(p, entityIdExtractor.applyAsInt(packet), packet);
|
||||
return processEntityPacket(access, entityIdExtractor.applyAsInt(packet), packet);
|
||||
};
|
||||
}
|
||||
|
||||
private Packet<?> processMoveEntityPacket(Player player, ClientboundMoveEntityPacket packet) {
|
||||
if (privilegeProvider.isPlayerPrivilegedToAccessEntity(player, packet.entityId)) {
|
||||
private Packet<?> processMoveEntityPacket(ForPlayer access, ClientboundMoveEntityPacket packet) {
|
||||
if (access.canAccessEntity(packet.entityId)) {
|
||||
return packet;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private Packet<?> processRotateHeadPacket(Player player, ClientboundRotateHeadPacket packet) {
|
||||
if (privilegeProvider.isPlayerPrivilegedToAccessEntity(player, packet.entityId)) {
|
||||
private Packet<?> processRotateHeadPacket(ForPlayer access, ClientboundRotateHeadPacket packet) {
|
||||
if (access.canAccessEntity(packet.entityId)) {
|
||||
return packet;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private Packet<?> processRemoveEntitiesPacket(Player player, ClientboundRemoveEntitiesPacket packet) {
|
||||
IntList entityIdsToRemove = packet.getEntityIds();
|
||||
|
||||
IntList filteredEntitiesToRemove = entityIdsToRemove.intStream().filter((id) -> privilegeProvider.isPlayerPrivilegedToAccessEntity(player, id)).collect(IntArrayList::new, IntList::add, IntList::addAll);
|
||||
|
||||
return new ClientboundRemoveEntitiesPacket(filteredEntitiesToRemove);
|
||||
}
|
||||
|
||||
public Packet<?> processSetEntityLinkPacket(Player player, ClientboundSetEntityLinkPacket packet) {
|
||||
public Packet<?> processSetEntityLinkPacket(ForPlayer access, ClientboundSetEntityLinkPacket packet) {
|
||||
int fromEntityId = packet.getSourceId();
|
||||
int toEntityId = packet.getDestId();
|
||||
|
||||
if (privilegeProvider.isPlayerPrivilegedToAccessEntity(player, fromEntityId) && privilegeProvider.isPlayerPrivilegedToAccessEntity(player, toEntityId)) {
|
||||
if (access.canAccessEntity(fromEntityId) && access.canAccessEntity(toEntityId)) {
|
||||
return packet;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private Packet<?> processBlockEventPacket(Player player, ClientboundBlockEventPacket packet) {
|
||||
private Packet<?> processBlockEventPacket(ForPlayer access, ClientboundBlockEventPacket packet) {
|
||||
BlockPos blockPos = packet.getPos();
|
||||
Block block = packet.getBlock();
|
||||
int blockX = blockPos.getX();
|
||||
int blockY = blockPos.getY();
|
||||
int blockZ = blockPos.getZ();
|
||||
|
||||
if (privilegeProvider.isPlayerPrivilegedToAccessPosition(player, blockX, blockY, blockZ) && privilegeProvider.isPlayerPrivilegedToAccessBlock(player, blockX, blockY, blockZ, block)) {
|
||||
if (access.canAccessPosition(blockX, blockY, blockZ) && access.canAccessBlock(blockX, blockY, blockZ, block)) {
|
||||
return packet;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private Packet<?> processBlockUpdatePacket(Player player, ClientboundBlockUpdatePacket packet) {
|
||||
private Packet<?> processBlockUpdatePacket(ForPlayer access, ClientboundBlockUpdatePacket packet) {
|
||||
BlockPos blockPos = packet.getPos();
|
||||
BlockState blockState = packet.getBlockState();
|
||||
Block block = blockState.getBlock();
|
||||
@@ -420,41 +443,41 @@ public class TechHider {
|
||||
int blockY = blockPos.getY();
|
||||
int blockZ = blockPos.getZ();
|
||||
|
||||
if (privilegeProvider.isPlayerPrivilegedToAccessPosition(player, blockX, blockY, blockZ) && privilegeProvider.isPlayerPrivilegedToAccessBlock(player, blockX, blockY, blockZ, block) && privilegeProvider.isPlayerPrivilegedToAccessBlockState(player, blockX, blockY, blockZ, blockState)) {
|
||||
if (access.canAccessPosition(blockX, blockY, blockZ) && access.canAccessBlock(blockX, blockY, blockZ, block) && access.canAccessBlockState(blockX, blockY, blockZ, blockState)) {
|
||||
return packet;
|
||||
} else if (privilegeProvider.isPlayerPrivilegedToAccessPosition(player, blockX, blockY, blockZ)) {
|
||||
return new ClientboundBlockUpdatePacket(blockPos, blockStateUsedForObfuscation);
|
||||
} else if (access.canAccessPosition(blockX, blockY, blockZ)) {
|
||||
return new ClientboundBlockUpdatePacket(blockPos, access.getObfuscation(blockX, blockY, blockZ));
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private Packet<?> processBlockEntityDataPacket(Player player, ClientboundBlockEntityDataPacket packet) {
|
||||
private Packet<?> processBlockEntityDataPacket(ForPlayer access, ClientboundBlockEntityDataPacket packet) {
|
||||
BlockPos blockPos = packet.getPos();
|
||||
BlockEntityType<?> blockEntityType = packet.getType();
|
||||
int blockX = blockPos.getX();
|
||||
int blockY = blockPos.getY();
|
||||
int blockZ = blockPos.getZ();
|
||||
|
||||
if (privilegeProvider.isPlayerPrivilegedToAccessPosition(player, blockX, blockY, blockZ) && privilegeProvider.isPlayerPrivilegedToAccessBlockEntity(player, blockX, blockY, blockZ, blockEntityType)) {
|
||||
if (access.canAccessPosition(blockX, blockY, blockZ) && access.canAccessBlockEntity(blockX, blockY, blockZ, blockEntityType)) {
|
||||
return packet;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private Packet<?> proccessBlockDestructionPacket(Player player, ClientboundBlockDestructionPacket packet) {
|
||||
private Packet<?> proccessBlockDestructionPacket(ForPlayer access, ClientboundBlockDestructionPacket packet) {
|
||||
BlockPos blockPos = packet.getPos();
|
||||
int entityBreakingBlockId = packet.getId();
|
||||
|
||||
if (privilegeProvider.isPlayerPrivilegedToAccessEntity(player, entityBreakingBlockId) && privilegeProvider.isPlayerPrivilegedToAccessPosition(player, blockPos.getX(), blockPos.getY(), blockPos.getZ())) {
|
||||
if (access.canAccessEntity(entityBreakingBlockId) && access.canAccessPosition(blockPos.getX(), blockPos.getY(), blockPos.getZ())) {
|
||||
return packet;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private ClientboundSectionBlocksUpdatePacket processSectionUpdate(Player p, ClientboundSectionBlocksUpdatePacket packet) {
|
||||
private ClientboundSectionBlocksUpdatePacket processSectionUpdate(ForPlayer access, ClientboundSectionBlocksUpdatePacket packet) {
|
||||
SectionPos sectionPos = packet.sectionPos;
|
||||
short[] oldPos = packet.positions;
|
||||
BlockState[] oldStates = packet.states;
|
||||
@@ -471,12 +494,12 @@ public class TechHider {
|
||||
int worldY = sectionPos.relativeToBlockY(posShort);
|
||||
int worldZ = sectionPos.relativeToBlockZ(posShort);
|
||||
|
||||
if (privilegeProvider.isPlayerPrivilegedToAccessPosition(p, worldX, worldY, worldZ) && privilegeProvider.isPlayerPrivilegedToAccessBlock(p, worldX, worldY, worldZ, block) && privilegeProvider.isPlayerPrivilegedToAccessBlockState(p, worldX, worldY, worldZ, state)) {
|
||||
if (access.canAccessPosition(worldX, worldY, worldZ) && access.canAccessBlock(worldX, worldY, worldZ, block) && access.canAccessBlockState(worldX, worldY, worldZ, state)) {
|
||||
filteredPos.add(posShort);
|
||||
filteredStates.add(state);
|
||||
} else if (privilegeProvider.isPlayerPrivilegedToAccessPosition(p, worldX, worldY, worldZ)) {
|
||||
} else if (access.canAccessPosition(worldX, worldY, worldZ)) {
|
||||
filteredPos.add(posShort);
|
||||
filteredStates.add(blockStateUsedForObfuscation);
|
||||
filteredStates.add(access.getObfuscation(worldX, worldY, worldZ));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -494,43 +517,43 @@ public class TechHider {
|
||||
return new ClientboundSectionBlocksUpdatePacket(sectionPos, ShortSets.unmodifiable(new ShortArraySet(newPos)), newStates);
|
||||
}
|
||||
|
||||
private Packet<?> processLevelParticlesPacket(Player player, ClientboundLevelParticlesPacket packet) {
|
||||
int blockX = (int) packet.getX();
|
||||
int blockY = (int) packet.getY();
|
||||
int blockZ = (int) packet.getZ();
|
||||
private Packet<?> processLevelParticlesPacket(ForPlayer access, ClientboundLevelParticlesPacket packet) {
|
||||
int blockX = Mth.floor(packet.getX());
|
||||
int blockY = Mth.floor(packet.getY());
|
||||
int blockZ = Mth.floor(packet.getZ());
|
||||
|
||||
if (privilegeProvider.isPlayerPrivilegedToAccessPosition(player, blockX, blockY, blockZ)) {
|
||||
if (access.canAccessPosition(blockX, blockY, blockZ)) {
|
||||
return packet;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private ClientboundLevelChunkWithLightPacket processChunkWithLight(Player p, ClientboundLevelChunkWithLightPacket packet) {
|
||||
if (privilegeProvider.isEveryonePrivilegedToAccessAllDataWithinChunk(packet.getX(), packet.getZ())) {
|
||||
private ClientboundLevelChunkWithLightPacket processChunkWithLight(ForPlayer access, ClientboundLevelChunkWithLightPacket packet) {
|
||||
if (access.canAccessAllDataWithinChunk(packet.getX(), packet.getZ())) {
|
||||
return packet;
|
||||
} else {
|
||||
return chunkHider.processLevelChunkWithLightPacket(p, packet);
|
||||
return chunkHider.processLevelChunkWithLightPacket(access, packet);
|
||||
}
|
||||
}
|
||||
|
||||
private Packet<? extends PacketListener> proccessPositionBasedPacket(Player player, int blockX, int blockY, int blockZ, Packet<? extends PacketListener> packet) {
|
||||
if (privilegeProvider.isPlayerPrivilegedToAccessPosition(player, blockX, blockY, blockZ)) {
|
||||
private Packet<? extends PacketListener> proccessPositionBasedPacket(ForPlayer access, int blockX, int blockY, int blockZ, Packet<? extends PacketListener> packet) {
|
||||
if (access.canAccessPosition(blockX, blockY, blockZ)) {
|
||||
return packet;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private <TTargetPacket extends Packet<?>> BiFunction<Player, Packet<?>, Packet<?>> buildPositionBasedPacketProcessor(Function<TTargetPacket, BlockPos> positionExtractor) {
|
||||
return (p, rawPacket) -> {
|
||||
private <TTargetPacket extends Packet<?>> BiFunction<ForPlayer, Packet<?>, Packet<?>> buildPositionBasedPacketProcessor(Function<TTargetPacket, BlockPos> positionExtractor) {
|
||||
return (access, rawPacket) -> {
|
||||
TTargetPacket packet = (TTargetPacket) rawPacket;
|
||||
BlockPos pos = positionExtractor.apply(packet);
|
||||
int blockX = pos.getX();
|
||||
int blockY = pos.getY();
|
||||
int blockZ = pos.getZ();
|
||||
|
||||
return proccessPositionBasedPacket(p, blockX, blockY, blockZ, packet);
|
||||
return proccessPositionBasedPacket(access, blockX, blockY, blockZ, packet);
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
accessWidener v2 named
|
||||
|
||||
# For TechHider
|
||||
accessible field net/minecraft/network/protocol/game/ClientboundEntityEventPacket entityId I
|
||||
accessible field net/minecraft/network/protocol/game/ClientboundMoveEntityPacket entityId I
|
||||
accessible field net/minecraft/network/protocol/game/ClientboundRotateHeadPacket entityId I
|
||||
accessible field net/minecraft/network/protocol/game/ClientboundSectionBlocksUpdatePacket sectionPos Lnet/minecraft/core/SectionPos;
|
||||
accessible field net/minecraft/network/protocol/game/ClientboundSectionBlocksUpdatePacket positions [S
|
||||
accessible field net/minecraft/network/protocol/game/ClientboundSectionBlocksUpdatePacket states [Lnet/minecraft/world/level/block/state/BlockState;
|
||||
|
||||
# For ChunkHider
|
||||
## transitive-extendable means that a public no args constructor is added without any super initialization
|
||||
transitive-extendable class net/minecraft/network/protocol/game/ClientboundLevelChunkWithLightPacket
|
||||
accessible field net/minecraft/network/protocol/game/ClientboundLevelChunkWithLightPacket chunkData Lnet/minecraft/network/protocol/game/ClientboundLevelChunkPacketData;
|
||||
mutable field net/minecraft/network/protocol/game/ClientboundLevelChunkWithLightPacket chunkData Lnet/minecraft/network/protocol/game/ClientboundLevelChunkPacketData;
|
||||
|
||||
## transitive-extendable means that a public no args constructor is added without any super initialization
|
||||
transitive-extendable class net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData
|
||||
accessible field net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData buffer [B
|
||||
mutable field net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData buffer [B
|
||||
accessible field net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData blockEntitiesData Ljava/util/List;
|
||||
mutable field net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData blockEntitiesData Ljava/util/List;
|
||||
|
||||
accessible class net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData$BlockEntityInfo
|
||||
accessible field net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData$BlockEntityInfo type Lnet/minecraft/world/level/block/entity/BlockEntityType;
|
||||
accessible field net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData$BlockEntityInfo packedXZ I
|
||||
accessible field net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData$BlockEntityInfo y I
|
||||
accessible method net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData$BlockEntityInfo <init> (IILnet/minecraft/world/level/block/entity/BlockEntityType;Lnet/minecraft/nbt/CompoundTag;)V
|
||||
@@ -25,7 +25,6 @@ import de.steamwar.lobby.LobbySystem;
|
||||
import de.steamwar.lobby.listener.PlayerSpawn;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.sql.UserPerm;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -47,7 +46,6 @@ public class ModifyCommand extends SWCommand implements Listener {
|
||||
|
||||
public ModifyCommand() {
|
||||
super("modify");
|
||||
Bukkit.getPluginManager().registerEvents(this, LobbySystem.getInstance());
|
||||
}
|
||||
|
||||
@Register
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
package de.steamwar.lobby.jumpandrun;
|
||||
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.linkage.LinkedTimer;
|
||||
import de.steamwar.lobby.LobbySystem;
|
||||
import de.steamwar.lobby.listener.PlayerSpawn;
|
||||
import de.steamwar.lobby.util.LeaderboardManager;
|
||||
@@ -60,52 +61,51 @@ public class JumpAndRun implements Listener {
|
||||
|
||||
private static final LeaderboardManager LEADERBOARD = new LeaderboardManager(LobbySystem.getEntityServer(false), JUMP_AND_RUN_CONFIG, new Location(Bukkit.getWorlds().get(0), 2338.5, 42.5, 1231.5));
|
||||
|
||||
{
|
||||
Bukkit.getScheduler().runTaskTimer(LobbySystem.getInstance(), () -> {
|
||||
Set<Player> toReset = new HashSet<>();
|
||||
CURRENT_POS.forEach((player, index) -> {
|
||||
if (System.currentTimeMillis() - CLICKED.getOrDefault(player, 0L) > 500) {
|
||||
CLICKED.remove(player);
|
||||
CLICKED_COUNT.remove(player);
|
||||
} else {
|
||||
CLICKED_COUNT.put(player, CLICKED_COUNT.getOrDefault(player, -1) + 1);
|
||||
}
|
||||
@LinkedTimer(delay = 1, period = 1)
|
||||
private void updatePlayers() {
|
||||
Set<Player> toReset = new HashSet<>();
|
||||
CURRENT_POS.forEach((player, index) -> {
|
||||
if (System.currentTimeMillis() - CLICKED.getOrDefault(player, 0L) > 500) {
|
||||
CLICKED.remove(player);
|
||||
CLICKED_COUNT.remove(player);
|
||||
} else {
|
||||
CLICKED_COUNT.put(player, CLICKED_COUNT.getOrDefault(player, -1) + 1);
|
||||
}
|
||||
|
||||
Location location = player.getLocation();
|
||||
Vector point = points.get(index);
|
||||
if (index < points.size() - 1) {
|
||||
Vector nextPoint = points.get(index + 1);
|
||||
double y = Math.min(point.getY(), nextPoint.getY()) - 2;
|
||||
if (location.getY() < y) {
|
||||
location.setX(point.getX());
|
||||
location.setY(point.getY());
|
||||
location.setZ(point.getZ());
|
||||
player.teleport(location);
|
||||
player.playSound(location, Sound.ENTITY_ENDERMAN_TELEPORT, 1, 1);
|
||||
FAILS.put(player, FAILS.getOrDefault(player, 0) + 1);
|
||||
}
|
||||
Location location = player.getLocation();
|
||||
Vector point = points.get(index);
|
||||
if (index < points.size() - 1) {
|
||||
Vector nextPoint = points.get(index + 1);
|
||||
double y = Math.min(point.getY(), nextPoint.getY()) - 2;
|
||||
if (location.getY() < y) {
|
||||
location.setX(point.getX());
|
||||
location.setY(point.getY());
|
||||
location.setZ(point.getZ());
|
||||
player.teleport(location);
|
||||
player.playSound(location, Sound.ENTITY_ENDERMAN_TELEPORT, 1, 1);
|
||||
FAILS.put(player, FAILS.getOrDefault(player, 0) + 1);
|
||||
}
|
||||
}
|
||||
|
||||
int count = CLICKED_COUNT.getOrDefault(player, -1);
|
||||
if (count >= 0) {
|
||||
if (count > 20) {
|
||||
toReset.add(player);
|
||||
return;
|
||||
}
|
||||
count = Math.min(count / 2, 30);
|
||||
LobbySystem.getMessage().sendPrefixless("JUMP_AND_RUN_CANCEL", player, ChatMessageType.ACTION_BAR, "§e" + BAR_EMPTY.substring(0, count) + "§7" + BAR_EMPTY.substring(count));
|
||||
} else {
|
||||
long time = System.currentTimeMillis() - START.get(player);
|
||||
SimpleDateFormat format = new SimpleDateFormat(LobbySystem.getMessage().parse("JUMP_AND_RUN_TIME", player), Locale.ROOT);
|
||||
String parsed = format.format(new Date(time));
|
||||
LobbySystem.getMessage().sendPrefixless("JUMP_AND_RUN_PROGRESS", player, ChatMessageType.ACTION_BAR, index + 1, points.size(), FAILS.get(player), parsed);
|
||||
int count = CLICKED_COUNT.getOrDefault(player, -1);
|
||||
if (count >= 0) {
|
||||
if (count > 20) {
|
||||
toReset.add(player);
|
||||
return;
|
||||
}
|
||||
});
|
||||
toReset.forEach(player -> {
|
||||
reset(player);
|
||||
player.teleport(Bukkit.getWorlds().get(0).getSpawnLocation().clone().add(0.5, 0, 0.5));
|
||||
});
|
||||
}, 1, 1);
|
||||
count = Math.min(count / 2, 30);
|
||||
LobbySystem.getMessage().sendPrefixless("JUMP_AND_RUN_CANCEL", player, ChatMessageType.ACTION_BAR, "§e" + BAR_EMPTY.substring(0, count) + "§7" + BAR_EMPTY.substring(count));
|
||||
} else {
|
||||
long time = System.currentTimeMillis() - START.get(player);
|
||||
SimpleDateFormat format = new SimpleDateFormat(LobbySystem.getMessage().parse("JUMP_AND_RUN_TIME", player), Locale.ROOT);
|
||||
String parsed = format.format(new Date(time));
|
||||
LobbySystem.getMessage().sendPrefixless("JUMP_AND_RUN_PROGRESS", player, ChatMessageType.ACTION_BAR, index + 1, points.size(), FAILS.get(player), parsed);
|
||||
}
|
||||
});
|
||||
toReset.forEach(player -> {
|
||||
reset(player);
|
||||
player.teleport(Bukkit.getWorlds().get(0).getSpawnLocation().clone().add(0.5, 0, 0.5));
|
||||
});
|
||||
}
|
||||
|
||||
public static boolean isPlayerInJumpAndRun(Player player) {
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
package de.steamwar.lobby.listener;
|
||||
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.lobby.LobbySystem;
|
||||
import de.steamwar.linkage.LinkedTimer;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.data.Bisected;
|
||||
import org.bukkit.block.data.type.Stairs;
|
||||
@@ -34,7 +34,6 @@ import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.entity.EntityDismountEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
@@ -46,15 +45,11 @@ public class PlayerSeatListener implements Listener {
|
||||
|
||||
private Set<Location> seats = new HashSet<>();
|
||||
|
||||
static {
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for (Arrow arrow : world.getEntitiesByClass(Arrow.class)) {
|
||||
arrow.setTicksLived(1);
|
||||
}
|
||||
}
|
||||
}.runTaskTimer(LobbySystem.getInstance(), 20 * 60, 20 * 60);
|
||||
@LinkedTimer(delay = 1, period = 1, unit = LinkedTimer.Unit.MINUTES)
|
||||
private static void keepArrows() {
|
||||
for (Arrow arrow : world.getEntitiesByClass(Arrow.class)) {
|
||||
arrow.setTicksLived(1);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
package de.steamwar.lobby.particle;
|
||||
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.lobby.LobbySystem;
|
||||
import de.steamwar.linkage.LinkedTimer;
|
||||
import de.steamwar.lobby.jumpandrun.JumpAndRun;
|
||||
import de.steamwar.lobby.listener.PlayerSpawn;
|
||||
import de.steamwar.lobby.util.LobbyPlayer;
|
||||
@@ -49,25 +49,24 @@ public class ParticleListener implements Listener {
|
||||
|
||||
private static Map<Player, Integer> movingPlayers = new HashMap<>();
|
||||
|
||||
public ParticleListener() {
|
||||
Bukkit.getScheduler().runTaskTimer(LobbySystem.getInstance(), () -> {
|
||||
movingPlayers.replaceAll((player, integer) -> integer - 1);
|
||||
movingPlayers.entrySet().removeIf(entry -> entry.getValue() <= 0);
|
||||
deg += 0.1;
|
||||
if (deg > 360) deg = 0;
|
||||
Bukkit.getOnlinePlayers().forEach(player -> {
|
||||
if (disabled(player)) return;
|
||||
if (JumpAndRun.isPlayerInJumpAndRun(player)) return;
|
||||
LobbyPlayer lobbyPlayer = LobbyPlayer.getLobbyPlayer(player.getUniqueId());
|
||||
ParticleEnum particle = lobbyPlayer.getParticle();
|
||||
if (particle == null) return;
|
||||
ParticleData particleData = particle.getParticle();
|
||||
ParticleElement particleElement = particleData.getParticleElement();
|
||||
if (particleElement.tickType() == ParticleTickType.ALWAYS) {
|
||||
particleElement.tick(new ParticleTickData(player.getWorld(), player, deg, movingPlayers.containsKey(player)));
|
||||
}
|
||||
});
|
||||
}, 0, 1);
|
||||
@LinkedTimer(delay = 0, period = 1)
|
||||
private void tickParticles() {
|
||||
movingPlayers.replaceAll((player, integer) -> integer - 1);
|
||||
movingPlayers.entrySet().removeIf(entry -> entry.getValue() <= 0);
|
||||
deg += 0.1;
|
||||
if (deg > 360) deg = 0;
|
||||
Bukkit.getOnlinePlayers().forEach(player -> {
|
||||
if (disabled(player)) return;
|
||||
if (JumpAndRun.isPlayerInJumpAndRun(player)) return;
|
||||
LobbyPlayer lobbyPlayer = LobbyPlayer.getLobbyPlayer(player.getUniqueId());
|
||||
ParticleEnum particle = lobbyPlayer.getParticle();
|
||||
if (particle == null) return;
|
||||
ParticleData particleData = particle.getParticle();
|
||||
ParticleElement particleElement = particleData.getParticleElement();
|
||||
if (particleElement.tickType() == ParticleTickType.ALWAYS) {
|
||||
particleElement.tick(new ParticleTickData(player.getWorld(), player, deg, movingPlayers.containsKey(player)));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
package de.steamwar.lobby.team;
|
||||
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.linkage.LinkedTimer;
|
||||
import de.steamwar.lobby.LobbySystem;
|
||||
import de.steamwar.lobby.display.NPC;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
@@ -76,55 +77,58 @@ public class TeamPlayer implements Listener {
|
||||
entities.put(name, npc);
|
||||
}
|
||||
|
||||
private final AtomicInteger count = new AtomicInteger();
|
||||
|
||||
{
|
||||
SteamwarUser.getServerTeam().forEach(user -> {
|
||||
spawnTeamPlayer(world, user);
|
||||
});
|
||||
|
||||
AtomicInteger count = new AtomicInteger();
|
||||
LobbySystem.getInstance().getLogger().log(Level.INFO, "Loaded " + entities.size() + " team players");
|
||||
Bukkit.getScheduler().runTaskTimer(LobbySystem.getInstance(), () -> {
|
||||
Collection<Villager> active = world.getEntitiesByClass(Villager.class);
|
||||
if (active.size() > entities.size()) {
|
||||
Set<String> duplicates = new HashSet<>();
|
||||
active.stream()
|
||||
.filter(villager -> !duplicates.add(villager.getCustomName()))
|
||||
.forEach(Entity::remove);
|
||||
}
|
||||
}
|
||||
|
||||
count.incrementAndGet();
|
||||
if (count.get() % (20 * 60 * 60) == 0) {
|
||||
count.set(0);
|
||||
List<SteamwarUser> steamwarUsers = SteamwarUser.getServerTeam();
|
||||
AtomicInteger added = new AtomicInteger();
|
||||
steamwarUsers.forEach(user -> {
|
||||
if (!entities.containsKey(user.getUserName())) {
|
||||
spawnTeamPlayer(world, user);
|
||||
added.incrementAndGet();
|
||||
}
|
||||
});
|
||||
AtomicInteger removed = new AtomicInteger();
|
||||
List<String> names = steamwarUsers.stream().map(SteamwarUser::getUserName).collect(Collectors.toList());
|
||||
new HashSet<>(entities.keySet()).stream().filter(name -> !names.contains(name)).forEach(name -> {
|
||||
villagers.remove(name).remove();
|
||||
entities.remove(name).delete();
|
||||
removed.incrementAndGet();
|
||||
});
|
||||
if (added.get() > 0 || removed.get() > 0) {
|
||||
LobbySystem.getInstance().getLogger().log(Level.INFO, "Loaded " + added.get() + " team players, removed " + removed.get() + " team players");
|
||||
}
|
||||
}
|
||||
world.getEntitiesByClasses(Villager.class).forEach(entity -> {
|
||||
NPC npc = entities.get(entity.getName());
|
||||
if (npc != null) {
|
||||
if (illegalLocation(entity.getLocation())) {
|
||||
entity.teleport(npc.getLocation());
|
||||
return;
|
||||
}
|
||||
npc.setLocation(entity.getLocation());
|
||||
@LinkedTimer(delay = 1, period = 1)
|
||||
private void updateTeamPlayers() {
|
||||
Collection<Villager> active = world.getEntitiesByClass(Villager.class);
|
||||
if (active.size() > entities.size()) {
|
||||
Set<String> duplicates = new HashSet<>();
|
||||
active.stream()
|
||||
.filter(villager -> !duplicates.add(villager.getCustomName()))
|
||||
.forEach(Entity::remove);
|
||||
}
|
||||
|
||||
count.incrementAndGet();
|
||||
if (count.get() % (20 * 60 * 60) == 0) {
|
||||
count.set(0);
|
||||
List<SteamwarUser> steamwarUsers = SteamwarUser.getServerTeam();
|
||||
AtomicInteger added = new AtomicInteger();
|
||||
steamwarUsers.forEach(user -> {
|
||||
if (!entities.containsKey(user.getUserName())) {
|
||||
spawnTeamPlayer(world, user);
|
||||
added.incrementAndGet();
|
||||
}
|
||||
});
|
||||
}, 1L, 1L);
|
||||
AtomicInteger removed = new AtomicInteger();
|
||||
List<String> names = steamwarUsers.stream().map(SteamwarUser::getUserName).collect(Collectors.toList());
|
||||
new HashSet<>(entities.keySet()).stream().filter(name -> !names.contains(name)).forEach(name -> {
|
||||
villagers.remove(name).remove();
|
||||
entities.remove(name).delete();
|
||||
removed.incrementAndGet();
|
||||
});
|
||||
if (added.get() > 0 || removed.get() > 0) {
|
||||
LobbySystem.getInstance().getLogger().log(Level.INFO, "Loaded " + added.get() + " team players, removed " + removed.get() + " team players");
|
||||
}
|
||||
}
|
||||
world.getEntitiesByClasses(Villager.class).forEach(entity -> {
|
||||
NPC npc = entities.get(entity.getName());
|
||||
if (npc != null) {
|
||||
if (illegalLocation(entity.getLocation())) {
|
||||
entity.teleport(npc.getLocation());
|
||||
return;
|
||||
}
|
||||
npc.setLocation(entity.getLocation());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private boolean illegalLocation(Location location) {
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
|
||||
package de.steamwar.misslewars;
|
||||
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.linkage.LinkedTimer;
|
||||
import de.steamwar.network.NetworkSender;
|
||||
import de.steamwar.network.packets.common.FightInfoPacket;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
@@ -28,6 +30,7 @@ import org.bukkit.World;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Linked
|
||||
public class FightInfoPacketSender implements Runnable {
|
||||
|
||||
private final World world = Bukkit.getWorlds().get(0);
|
||||
@@ -41,6 +44,7 @@ public class FightInfoPacketSender implements Runnable {
|
||||
private final int redLeader = Config.RedLeader != null ? SteamwarUser.get(Config.RedLeader).getId() : 0;
|
||||
|
||||
@Override
|
||||
@LinkedTimer(delay = 1, period = 1, unit = LinkedTimer.Unit.SECONDS)
|
||||
public void run() {
|
||||
if (Config.test()) {
|
||||
return;
|
||||
|
||||
@@ -81,8 +81,6 @@ public class MissileWars extends JavaPlugin {
|
||||
|
||||
StateDependent.setupState(fightState);
|
||||
|
||||
Bukkit.getScheduler().runTaskTimer(this, new FightInfoPacketSender(), 20, 20);
|
||||
|
||||
Bukkit.getWorlds().forEach(world -> {
|
||||
world.setGameRule(GameRule.KEEP_INVENTORY, true);
|
||||
world.setGameRule(GameRule.MOB_GRIEFING, true);
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.techhider;
|
||||
package de.steamwar.core;
|
||||
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user