forked from SteamWar/SteamWar
Compare commits
140
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
594707637a | ||
|
|
3539e70954 | ||
|
|
dde6081607 | ||
|
|
d6deb0f869 | ||
|
|
865eb8ceea | ||
|
|
351350ae84 | ||
|
|
12f7f159c6 | ||
|
|
14695b28ae | ||
|
|
98c4451452 | ||
|
|
0e4a0702d8 | ||
|
|
cbfc1038b8 | ||
|
|
6da1db2496 | ||
|
|
a953d58af6 | ||
|
|
a5c60edb8a | ||
|
|
6b5ce57a6d | ||
|
|
63ae103b70 | ||
|
|
0d7a88bb4c | ||
|
|
5ab7696e5f | ||
|
|
a6d77256a9 | ||
|
|
818a437ee0 | ||
|
|
622b8abc98 | ||
|
|
ae892e14f7 | ||
|
|
2dc69c33ac | ||
|
|
c3b656995e | ||
|
|
054cc2f68b | ||
|
|
12889771f6 | ||
|
|
b4ef0c6b84 | ||
|
|
10ba0f5ef8 | ||
|
|
1fc91f3f79 | ||
|
|
5c87e0ef78 | ||
|
|
48de9411d5 | ||
|
|
da78a0d701 | ||
|
|
01831c0626 | ||
|
|
ff5d180ea5 | ||
|
|
9250e9c470 | ||
|
|
6f859b217c | ||
|
|
1eeda69e0c | ||
|
|
51bce7f73d | ||
|
|
3d9816ae3f | ||
|
|
d573cd1716 | ||
|
|
642662da69 | ||
|
|
68c6ecfe81 | ||
|
|
167447b61d | ||
|
|
ee4fc74be4 | ||
|
|
bd28a18165 | ||
|
|
8ad51e4e9b | ||
|
|
72ef42fe52 | ||
|
|
cb2e9c2544 | ||
|
|
801d3e6132 | ||
|
|
5178301789 | ||
|
|
4d667d91ac | ||
|
|
6f0935185c | ||
|
|
23d20c97d9 | ||
|
|
bace9f3dfd | ||
|
|
f11f2d4278 | ||
|
|
c1de1cf779 | ||
|
|
4be46139c2 | ||
|
|
1b79958cbd | ||
|
|
10a0677f1e | ||
|
|
5863d60af7 | ||
|
|
633477cf9c | ||
|
|
de4a028980 | ||
|
|
f1df25019b | ||
|
|
59ccd50286 | ||
|
|
6a5b7927e1 | ||
|
|
a73ccc409f | ||
|
|
d45a45ce04 | ||
|
|
87efd85b79 | ||
|
|
b409622199 | ||
|
|
29e639c47b | ||
|
|
216f881241 | ||
|
|
ed901a5927 | ||
|
|
d4da75a6fa | ||
|
|
338b2daac8 | ||
|
|
c8b4f9f814 | ||
|
|
ee26abb4c7 | ||
|
|
4b526deedc | ||
|
|
1415ee27f9 | ||
|
|
ae45b0d2ef | ||
|
|
36db4061bb | ||
|
|
5cac0534ef | ||
|
|
6dbfc28bd2 | ||
|
|
d2cc72b571 | ||
|
|
27c0bdd563 | ||
|
|
6b0f982f8e | ||
|
|
0c4b8568fd | ||
|
|
f7bde30757 | ||
|
|
ec8826de7a | ||
|
|
9c2369770c | ||
|
|
11cfef1647 | ||
|
|
348591aef8 | ||
|
|
7a98f64653 | ||
|
|
80a779026c | ||
|
|
b9f8f54b61 | ||
|
|
f8f396afee | ||
|
|
deefe44dcd | ||
|
|
18108f023b | ||
|
|
f302af1e56 | ||
|
|
b04fc12446 | ||
|
|
509d5935cb | ||
|
|
bbbf308f10 | ||
|
|
e83323f7b6 | ||
|
|
a3f3780c26 | ||
|
|
54fc46bc75 | ||
|
|
68caba78cf | ||
|
|
3a035d4384 | ||
|
|
00c2fce21e | ||
|
|
2273bf6701 | ||
|
|
4510c732f2 | ||
|
|
11f5fe877d | ||
|
|
716b5c1e5e | ||
|
|
0ccc9133f2 | ||
|
|
d2754beaab | ||
|
|
7ec8cb7e87 | ||
|
|
af69280656 | ||
|
|
dff340a034 | ||
|
|
15ce4f920a | ||
|
|
b9ac8ef5ff | ||
|
|
d1e07af8fe | ||
|
|
5c1e74d257 | ||
|
|
50226ab87d | ||
|
|
260cd68810 | ||
|
|
6d4ad60eed | ||
|
|
d8d782dced | ||
|
|
6ccfd1920b | ||
|
|
37c809d759 | ||
|
|
fac6a6fdf4 | ||
|
|
6f1403df9c | ||
|
|
0113788da2 | ||
|
|
8a7f65e000 | ||
|
|
8401f67b24 | ||
|
|
362468e756 | ||
|
|
ece12df0bc | ||
|
|
f35c07ab5b | ||
|
|
549f7e555c | ||
|
|
859238d7fa | ||
|
|
a79b00f78f | ||
|
|
105eda32e6 | ||
|
|
b4487b8079 | ||
|
|
ea3aad3bd2 |
@@ -32,6 +32,7 @@ import de.steamwar.bausystem.features.tracer.TraceManager;
|
||||
import de.steamwar.bausystem.features.tracer.TraceRecorder;
|
||||
import de.steamwar.bausystem.features.world.BauScoreboard;
|
||||
import de.steamwar.bausystem.linkage.BauGuiItem;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.region.RegionSystem;
|
||||
import de.steamwar.bausystem.utils.ScoreboardElement;
|
||||
import de.steamwar.bausystem.utils.TickManager;
|
||||
@@ -39,8 +40,9 @@ import de.steamwar.bausystem.worlddata.WorldData;
|
||||
import de.steamwar.command.AbstractValidator;
|
||||
import de.steamwar.command.SWCommandUtils;
|
||||
import de.steamwar.core.Core;
|
||||
import de.steamwar.core.WorldEditRendererCUIEditor;
|
||||
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;
|
||||
@@ -48,6 +50,7 @@ import de.steamwar.providers.BauServerInfo;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameRule;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
@@ -126,7 +129,19 @@ public class BauSystem extends JavaPlugin {
|
||||
TraceManager.instance.init();
|
||||
TraceRecorder.instance.init();
|
||||
|
||||
new WorldEditRendererCUIEditor();
|
||||
SteamEdit.init();
|
||||
SteamEdit.ADJACENT_FILTERS = location -> {
|
||||
Region region = Region.getRegion(location);
|
||||
Region.Area area;
|
||||
if (region.getBuildArea().inRegion(location, true)) {
|
||||
area = region.getBuildArea();
|
||||
} else if (region.getTestblockArea().inRegion(location, true)) {
|
||||
area = region.getTestblockArea();
|
||||
} else {
|
||||
return SteamEdit.AdjacentFilter.ALWAYS;
|
||||
}
|
||||
return (x, y, z) -> area.inRegion(new Location(null, x, y, z), true);
|
||||
};
|
||||
|
||||
Bukkit.getWorlds().get(0).setGameRule(GameRule.SEND_COMMAND_FEEDBACK, false);
|
||||
|
||||
|
||||
+1
-1
@@ -46,7 +46,7 @@ public class ObserverTracerListener implements Listener {
|
||||
public ObserverTracerListener() {
|
||||
Bukkit.getScheduler().runTaskTimer(BauSystem.getInstance(), () -> {
|
||||
SWPlayer.allWithSingleComponent(ObserverTracer.class).forEach(pair -> {
|
||||
if (pair.getPlayer().getGameMode() != GameMode.SPECTATOR) return;
|
||||
if (pair.getSwPlayer().getPlayer().getGameMode() != GameMode.SPECTATOR) return;
|
||||
pair.getComponent().show();
|
||||
});
|
||||
}, 15L, 15L);
|
||||
|
||||
@@ -53,7 +53,7 @@ public class NoClipCommand extends SWCommand implements Listener {
|
||||
|
||||
@Override
|
||||
public void onUnmount(SWPlayer player) {
|
||||
player.setGameMode(GameMode.CREATIVE);
|
||||
player.getPlayer().setGameMode(GameMode.CREATIVE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ public interface Region extends RegionDataStore {
|
||||
|
||||
abstract class Area {
|
||||
|
||||
public static final int WORLD_MIN_Y = Bukkit.getWorlds().get(0).getMinHeight();
|
||||
public static final int WORLD_MIN_Y = 0;
|
||||
public static final int WORLD_MAX_Y = Bukkit.getWorlds().get(0).getMaxHeight();
|
||||
|
||||
public static final Area EMPTY = new Area() {
|
||||
|
||||
@@ -26,19 +26,18 @@ import lombok.RequiredArgsConstructor;
|
||||
@Getter
|
||||
public enum RegionType {
|
||||
|
||||
GLOBAL(ConnectionType.Global),
|
||||
GLOBAL(ConnectionType.Water),
|
||||
/**
|
||||
* This should not be used by the DynamicRegionSystem
|
||||
*/
|
||||
NORMAL(ConnectionType.Closed),
|
||||
NORMAL(ConnectionType.Plot),
|
||||
|
||||
SPAWN(ConnectionType.Closed),
|
||||
SPAWN_PATH(ConnectionType.Path),
|
||||
SPAWN_EXTENSION(ConnectionType.Closed),
|
||||
SPAWN(ConnectionType.Water),
|
||||
SPAWN_EXTENSION(ConnectionType.Water),
|
||||
PATH(ConnectionType.Path),
|
||||
|
||||
DRY(ConnectionType.Closed),
|
||||
DRY_SPECIAL(ConnectionType.Closed),
|
||||
DRY(ConnectionType.Water),
|
||||
DRY_SPECIAL(ConnectionType.Plot),
|
||||
WET(ConnectionType.Water),
|
||||
WET_SPECIAL(ConnectionType.Water),
|
||||
;
|
||||
@@ -58,18 +57,13 @@ public enum RegionType {
|
||||
}
|
||||
|
||||
public boolean isSpawn() {
|
||||
return this == SPAWN || this == SPAWN_PATH || this == SPAWN_EXTENSION;
|
||||
}
|
||||
|
||||
public boolean isPath() {
|
||||
return this == PATH || this == SPAWN_PATH;
|
||||
return this == SPAWN || this == SPAWN_EXTENSION;
|
||||
}
|
||||
|
||||
public enum ConnectionType {
|
||||
Closed,
|
||||
Plot,
|
||||
Path,
|
||||
Water,
|
||||
Global,
|
||||
Garden,
|
||||
}
|
||||
}
|
||||
|
||||
+10
-1
@@ -21,7 +21,6 @@ package de.steamwar.bausystem.region;
|
||||
|
||||
import de.steamwar.bausystem.Permission;
|
||||
import de.steamwar.bausystem.features.region.RegionCommand;
|
||||
import de.steamwar.bausystem.region.dynamic.Tile;
|
||||
import de.steamwar.command.AbstractSWCommand;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.core.SWPlayer;
|
||||
@@ -37,6 +36,16 @@ public class DynamicRegionCommand extends SWCommand {
|
||||
@Register({"dynamic"})
|
||||
public void visualizeRegions(Player player) {
|
||||
SWPlayer swPlayer = SWPlayer.of(player);
|
||||
if (swPlayer.hasComponent(DynamicRegionVisualizer2.class)) {
|
||||
swPlayer.removeComponent(DynamicRegionVisualizer2.class);
|
||||
swPlayer.removeComponent(DynamicRegionEditor2.class);
|
||||
} else {
|
||||
swPlayer.setComponent(DynamicRegionVisualizer2.INSTANCE);
|
||||
if (Permission.SUPERVISOR.hasPermission(player)) {
|
||||
swPlayer.setComponent(new DynamicRegionEditor2());
|
||||
}
|
||||
}
|
||||
if (true) return;
|
||||
if (swPlayer.hasComponent(DynamicRegionVisualizer.class)) {
|
||||
swPlayer.removeComponent(DynamicRegionVisualizer.class);
|
||||
swPlayer.removeComponent(DynamicRegionEditor.class);
|
||||
|
||||
+25
-22
@@ -20,7 +20,6 @@
|
||||
package de.steamwar.bausystem.region;
|
||||
|
||||
import com.comphenix.tinyprotocol.TinyProtocol;
|
||||
import de.steamwar.Reflection;
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.Permission;
|
||||
import de.steamwar.bausystem.region.dynamic.DynamicRegion;
|
||||
@@ -39,6 +38,7 @@ import de.steamwar.inventory.SWListInv;
|
||||
import lombok.NonNull;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.minecraft.network.protocol.game.ServerboundMovePlayerPacket;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
@@ -61,18 +61,14 @@ import java.util.function.BiFunction;
|
||||
|
||||
public class DynamicRegionEditor implements SWPlayer.Component, Listener {
|
||||
|
||||
private static final Class<?> position = Reflection.getClass("net.minecraft.network.protocol.game.ServerboundMovePlayerPacket$Pos");
|
||||
private static final Class<?> look = Reflection.getClass("net.minecraft.network.protocol.game.ServerboundMovePlayerPacket$Rot");
|
||||
private static final Class<?> positionLook = Reflection.getClass("net.minecraft.network.protocol.game.ServerboundMovePlayerPacket$PosRot");
|
||||
|
||||
static {
|
||||
BiFunction<Player, Object, Object> function = (player, object) -> {
|
||||
SWPlayer.of(player).getComponent(DynamicRegionEditor.class).ifPresent(DynamicRegionEditor::calcCursor);
|
||||
return object;
|
||||
};
|
||||
TinyProtocol.instance.addFilter(position, function);
|
||||
TinyProtocol.instance.addFilter(look, function);
|
||||
TinyProtocol.instance.addFilter(positionLook, function);
|
||||
TinyProtocol.instance.addFilter(ServerboundMovePlayerPacket.Pos.class, function);
|
||||
TinyProtocol.instance.addFilter(ServerboundMovePlayerPacket.Rot.class, function);
|
||||
TinyProtocol.instance.addFilter(ServerboundMovePlayerPacket.PosRot.class, function);
|
||||
}
|
||||
|
||||
private final REntityServer entityServer = new REntityServer();
|
||||
@@ -103,7 +99,7 @@ public class DynamicRegionEditor implements SWPlayer.Component, Listener {
|
||||
moveInteractionEntities(Point.fromLocation(player.getLocation()));
|
||||
|
||||
CArea area = new CArea(entityServer);
|
||||
area.setPos1And2(new Location(null, -Tile.maxTile, 1, -Tile.maxTile), new Location(null, Tile.maxTile, 1, Tile.maxTile));
|
||||
area.setPos1And2(new Location(null, -Tile.maxTile, 51, -Tile.maxTile), new Location(null, Tile.maxTile, 51, Tile.maxTile));
|
||||
area.setBlock(Material.BEDROCK.createBlockData());
|
||||
|
||||
task = Bukkit.getScheduler().runTaskTimer(BauSystem.getInstance(), this::showHotbar, 0, 20);
|
||||
@@ -145,7 +141,7 @@ public class DynamicRegionEditor implements SWPlayer.Component, Listener {
|
||||
List<RInteraction> interactionList = entityServer.getEntitiesByType(RInteraction.class);
|
||||
for (int x = -5; x <= 5; x++) {
|
||||
for (int z = -5; z <= 5; z++) {
|
||||
interactionList.removeFirst().move(position.getX() + x + 0.5, 0, position.getZ() + z + 0.5, 0, 0, (byte) 0);
|
||||
interactionList.removeFirst().move(position.getX() + x + 0.5, 50, position.getZ() + z + 0.5, 0, 0, (byte) 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -195,7 +191,7 @@ public class DynamicRegionEditor implements SWPlayer.Component, Listener {
|
||||
for (RInteraction interaction : entityServer.getEntitiesByType(RInteraction.class)) {
|
||||
float x = (float) (interaction.getX() - 0.5);
|
||||
float z = (float) (interaction.getZ() - 0.5);
|
||||
if (intersection.test(x, (float) 0.95, z, x + 1, (float) 1.05, z + 1)) {
|
||||
if (intersection.test(x, (float) 50.95, z, x + 1, (float) 51.05, z + 1)) {
|
||||
int tileX = (int) x;
|
||||
int tileZ = (int) z;
|
||||
if (type.visualize(area, tileX, tileZ)) {
|
||||
@@ -220,7 +216,7 @@ public class DynamicRegionEditor implements SWPlayer.Component, Listener {
|
||||
for (RInteraction interaction : entityServer.getEntitiesByType(RInteraction.class)) {
|
||||
float x = (float) (interaction.getX() - 0.5);
|
||||
float z = (float) (interaction.getZ() - 0.5);
|
||||
if (intersection.test(x, (float) 0.95, z, x + 1, (float) 1.05, z + 1)) {
|
||||
if (intersection.test(x, (float) 50.95, z, x + 1, (float) 51.05, z + 1)) {
|
||||
int tileX = (int) x;
|
||||
int tileZ = (int) z;
|
||||
type.run(event.getPlayer(), tileX, tileZ);
|
||||
@@ -322,8 +318,8 @@ public class DynamicRegionEditor implements SWPlayer.Component, Listener {
|
||||
}
|
||||
|
||||
private boolean selectSpawn(CArea area) {
|
||||
Location minLoc = new Location(null, -1, 1, -1);
|
||||
Location maxLoc = new Location(null, 1, 1, 1);
|
||||
Location minLoc = new Location(null, -1, 51, -1);
|
||||
Location maxLoc = new Location(null, 1, 51, 1);
|
||||
area.setBlock(DELETE);
|
||||
area.setPos1And2(minLoc, maxLoc);
|
||||
valid = true;
|
||||
@@ -337,8 +333,8 @@ public class DynamicRegionEditor implements SWPlayer.Component, Listener {
|
||||
valid = false;
|
||||
return false;
|
||||
}
|
||||
Location minLoc = new Location(null, minTile.getTileX(), 1, minTile.getTileZ());
|
||||
Location maxLoc = new Location(null, maxTile.getTileX(), 1, maxTile.getTileZ());
|
||||
Location minLoc = new Location(null, minTile.getTileX(), 51, minTile.getTileZ());
|
||||
Location maxLoc = new Location(null, maxTile.getTileX(), 51, maxTile.getTileZ());
|
||||
area.setBlock(DELETE);
|
||||
area.setPos1And2(minLoc, maxLoc);
|
||||
valid = true;
|
||||
@@ -358,7 +354,7 @@ public class DynamicRegionEditor implements SWPlayer.Component, Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (region.getType().isPath() || (force && region.getType().isSpecial())) {
|
||||
if (region.getType() == RegionType.PATH || (force && region.getType().isSpecial())) {
|
||||
region.delete();
|
||||
} else {
|
||||
deleteRegion(player, tile, region);
|
||||
@@ -371,6 +367,12 @@ public class DynamicRegionEditor implements SWPlayer.Component, Listener {
|
||||
checkSpawnRegionAndDelete(Tile.TILE_NP);
|
||||
checkSpawnRegionAndDelete(Tile.TILE_PN);
|
||||
checkSpawnRegionAndDelete(Tile.TILE_PP);
|
||||
|
||||
DynamicRegionSystem.INSTANCE.get(Tile.ZERO).getArea().place(new PasteBuilder(), false);
|
||||
DynamicRegionSystem.INSTANCE.get(Tile.TILE_NZ).getArea().place(new PasteBuilder(), false);
|
||||
DynamicRegionSystem.INSTANCE.get(Tile.TILE_PZ).getArea().place(new PasteBuilder(), false);
|
||||
DynamicRegionSystem.INSTANCE.get(Tile.TILE_ZN).getArea().place(new PasteBuilder(), false);
|
||||
DynamicRegionSystem.INSTANCE.get(Tile.TILE_ZP).getArea().place(new PasteBuilder(), false);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -432,14 +434,15 @@ public class DynamicRegionEditor implements SWPlayer.Component, Listener {
|
||||
constructSpawnRegion(Tile.TILE_NN);
|
||||
constructSpawnRegion(Tile.TILE_NP);
|
||||
constructSpawnRegion(Tile.TILE_PN);
|
||||
constructSpawnRegion(Tile.TILE_PP);
|
||||
DynamicRegion region = constructSpawnRegion(Tile.TILE_PP);
|
||||
if (region != null) region.getArea().reset(new PasteBuilder(), false);
|
||||
}
|
||||
|
||||
private void constructSpawnRegion(Tile tile) {
|
||||
private DynamicRegion constructSpawnRegion(Tile tile) {
|
||||
DynamicRegion region = DynamicRegionRepository.constructRegion(SpawnRegion.class, tile);
|
||||
if (region == null) return;
|
||||
region.getArea().place(new PasteBuilder(), false);
|
||||
if (region == null) return null;
|
||||
region.updateNeighbours();
|
||||
return region;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -500,7 +503,7 @@ public class DynamicRegionEditor implements SWPlayer.Component, Listener {
|
||||
area.setBlock(INVALID);
|
||||
valid = false;
|
||||
}
|
||||
area.setPos1And2(new Location(null, tileX, 1, tileZ), new Location(null, tileX + widthX, 1, tileZ + widthZ));
|
||||
area.setPos1And2(new Location(null, tileX, 51, tileZ), new Location(null, tileX + widthX, 51, tileZ + widthZ));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
+11
-4
@@ -17,10 +17,17 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.entity;
|
||||
package de.steamwar.bausystem.region;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import de.steamwar.core.SWPlayer;
|
||||
|
||||
public interface RInteractionCallback {
|
||||
void call(Player player, RInteraction interaction, REntityServer.EntityAction entityAction);
|
||||
public class DynamicRegionEditor2 implements SWPlayer.Component {
|
||||
|
||||
@Override
|
||||
public void onMount(SWPlayer player) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUnmount(SWPlayer player) {
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -94,7 +94,7 @@ public class DynamicRegionSystem implements RegionSystem {
|
||||
|
||||
@Override
|
||||
public @NonNull Location getWorldSpawn() {
|
||||
return Bukkit.getWorlds().get(0).getSpawnLocation(); // TODO: Temporary
|
||||
return Bukkit.getWorlds().get(0).getSpawnLocation().clone().add(0.5, 0, 0.5); // TODO: Temporary
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+3
-3
@@ -39,7 +39,7 @@ public class DynamicRegionVisualizer implements SWPlayer.Component {
|
||||
private final REntityServer entityServer = new REntityServer();
|
||||
|
||||
private DynamicRegionVisualizer() {
|
||||
RTextDisplay text = new RTextDisplay(entityServer, new Location(null, 0.5, 1.1, 0.5));
|
||||
RTextDisplay text = new RTextDisplay(entityServer, new Location(null, 0.5, 51.1, 0.5));
|
||||
text.setText("Spawn");
|
||||
text.setBillboard(Display.Billboard.VERTICAL);
|
||||
text.setBackgroundColor(0);
|
||||
@@ -73,7 +73,7 @@ public class DynamicRegionVisualizer implements SWPlayer.Component {
|
||||
|
||||
public static Point toVisualization(Location worldLocation) {
|
||||
Tile tile = Tile.fromLocation(worldLocation).orElseThrow();
|
||||
return new Point(tile.getTileX(), 0, tile.getTileZ());
|
||||
return new Point(tile.getTileX(), 50, tile.getTileZ());
|
||||
}
|
||||
|
||||
private static class CRegion extends CEntity {
|
||||
@@ -96,7 +96,7 @@ public class DynamicRegionVisualizer implements SWPlayer.Component {
|
||||
area.setPos1And2(point.toLocation((World) null).add(0, 1 - CArea.DEFAULT_WIDTH, 0), point.toLocation((World) null).add(widthX - 1, 1 - CArea.DEFAULT_WIDTH, widthZ - 1));
|
||||
entities.add(area);
|
||||
|
||||
RTextDisplay text = new RTextDisplay(server, point.toLocation((World) null).add(widthX / 2.0, 1.1, widthZ / 2.0));
|
||||
RTextDisplay text = new RTextDisplay(server, point.toLocation((World) null).add(widthX / 2.0, 51.1, widthZ / 2.0));
|
||||
text.setText(data.name());
|
||||
text.setBillboard(Display.Billboard.VERTICAL);
|
||||
text.setBackgroundColor(0);
|
||||
|
||||
+80
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import de.steamwar.bausystem.region.dynamic.RegionConstructorData;
|
||||
import de.steamwar.bausystem.region.dynamic.Tile;
|
||||
import de.steamwar.bausystem.region.dynamic.path.PathRegion;
|
||||
import de.steamwar.core.SWPlayer;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
|
||||
public class DynamicRegionVisualizer2 implements SWPlayer.Component {
|
||||
|
||||
public static final DynamicRegionVisualizer2 INSTANCE = new DynamicRegionVisualizer2();
|
||||
|
||||
private static final World WORLD = Bukkit.getWorlds().get(0);
|
||||
|
||||
private static final int ORIGIN_X = 10000;
|
||||
private static final int ORIGIN_Z = 10000;
|
||||
|
||||
public DynamicRegionVisualizer2() {
|
||||
if (true) return;
|
||||
// TODO: This is only needed once on startup with a clear beforehand to make the region visualization up to date with the Region Data
|
||||
DynamicRegionSystem.INSTANCE.getRegions().forEach(region -> {
|
||||
RegionConstructorData data = DynamicRegionSystem.constructorDataMap.get(region.getClass());
|
||||
if (data == null) return;
|
||||
int widthX = data.widthX();
|
||||
int widthZ = data.widthZ();
|
||||
|
||||
Material material = data.material();
|
||||
if (region instanceof PathRegion pathRegion && pathRegion.isGarden()) {
|
||||
material = Material.GRASS_BLOCK;
|
||||
}
|
||||
|
||||
Tile tile = Tile.fromPoint(region.getArea().getMinPoint(false)).orElseThrow();
|
||||
for (int x = 0; x < widthX; x++) {
|
||||
for (int z = 0; z < widthZ; z++) {
|
||||
int cx = x + tile.getTileX() + ORIGIN_X;
|
||||
int cz = z + tile.getTileZ() + ORIGIN_Z;
|
||||
WORLD.getBlockAt(cx, 1, cz).setType(material, false);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMount(SWPlayer player) {
|
||||
Location location = player.getPlayer().getLocation().clone().multiply(1.0 / Tile.tileSize).add(ORIGIN_X + 0.5, 0, ORIGIN_Z + 0.5);
|
||||
location.setY(10);
|
||||
player.getPlayer().teleport(location);
|
||||
// TODO: Add anything that is needed for setup
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUnmount(SWPlayer player) {
|
||||
Location location = player.getPlayer().getLocation().clone().subtract(ORIGIN_X + 0.5, 0, ORIGIN_Z + 0.5).multiply(Tile.tileSize);
|
||||
location.setY(50);
|
||||
player.getPlayer().teleport(location.add(0.5, 0, 0.5));
|
||||
// TODO: Add anything that is needed for shutdown
|
||||
}
|
||||
}
|
||||
+30
@@ -26,6 +26,7 @@ import de.steamwar.bausystem.region.Point;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.region.RegionData;
|
||||
import de.steamwar.bausystem.region.dynamic.path.PathRegion;
|
||||
import de.steamwar.bausystem.region.dynamic.path.PathSide;
|
||||
import de.steamwar.bausystem.utils.PasteBuilder;
|
||||
import lombok.Getter;
|
||||
import lombok.NonNull;
|
||||
@@ -85,9 +86,13 @@ public abstract class DynamicRegion implements Region {
|
||||
Set<UUID> needsFullReset = new HashSet<>();
|
||||
list.forEach(data -> {
|
||||
boolean previousGardenState = data.region().isGarden();
|
||||
PathSide previousToriState = data.region().getToriiSide();
|
||||
data.region().calculateGardenState();
|
||||
data.region().calculateToriiState();
|
||||
if (data.region().isGarden() != previousGardenState) {
|
||||
needsFullReset.add(data.region().getID());
|
||||
} else if (data.region().getToriiSide() != previousToriState) {
|
||||
needsFullReset.add(data.region().getID());
|
||||
}
|
||||
});
|
||||
// Updating world state for all neighbouring PathRegions
|
||||
@@ -117,6 +122,31 @@ public abstract class DynamicRegion implements Region {
|
||||
regionData.setStore(this);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public PathConnectResult shouldPathConnect(Tile source, PathSide side, boolean diagonal) {
|
||||
return PathConnectResult.BY_TYPE;
|
||||
}
|
||||
|
||||
public enum PathConnectResult {
|
||||
ALWAYS,
|
||||
NEVER,
|
||||
BY_TYPE,
|
||||
;
|
||||
|
||||
public static PathConnectResult of(Boolean result) {
|
||||
return of(result, NEVER);
|
||||
}
|
||||
|
||||
public static PathConnectResult of(Boolean result, PathConnectResult falseResult) {
|
||||
if (result == null) return BY_TYPE;
|
||||
if (result) {
|
||||
return ALWAYS;
|
||||
} else {
|
||||
return falseResult;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete() {
|
||||
if (!getType().isDeletable()) return;
|
||||
|
||||
+1
@@ -146,6 +146,7 @@ public class DynamicRegionRepository {
|
||||
DynamicRegionSystem.INSTANCE.getRegionsByType(RegionType.PATH)
|
||||
.forEach(region -> {
|
||||
((PathRegion) region).calculateGardenState();
|
||||
((PathRegion) region).calculateToriiState();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
+35
-3
@@ -28,16 +28,36 @@ import com.sk89q.worldedit.math.transform.AffineTransform;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import de.steamwar.bausystem.region.Point;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.utils.FlatteningWrapper;
|
||||
import de.steamwar.sql.SchematicData;
|
||||
import de.steamwar.sql.SchematicNode;
|
||||
import lombok.experimental.UtilityClass;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
@UtilityClass
|
||||
public class PasteUtils {
|
||||
|
||||
// TODO: Create special tiles for global water reset!
|
||||
private static final VariantSelector Reset = VariantSelector.Folder("Wet");
|
||||
|
||||
public static void reset(Point minPoint, Point maxPoint) {
|
||||
if (true) {
|
||||
// TODO: Update to set Water Tile since no longer void world!
|
||||
Tile minTile = Tile.fromPoint(minPoint).orElseThrow();
|
||||
Tile maxTile = Tile.fromPoint(maxPoint).orElseThrow();
|
||||
for (int x = minTile.getTileX(); x <= maxTile.getTileX(); x++) {
|
||||
for (int z = minTile.getTileZ(); z <= maxTile.getTileZ(); z++) {
|
||||
SchematicNode node = Reset.select().orElseThrow();
|
||||
paste(node, Tile.fromTile(x, z).orElseThrow().getMinPoint().setY(Region.Area.WORLD_MIN_Y), 0);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
EditSession editSession = WorldEdit.getInstance()
|
||||
.newEditSessionBuilder()
|
||||
.world(BukkitAdapter.adapt(Bukkit.getWorlds().get(0)))
|
||||
@@ -52,11 +72,23 @@ public class PasteUtils {
|
||||
|
||||
public static EditSession paste(File file, Point minPoint, int rotate) {
|
||||
try (Clipboard clipboard = FlatteningWrapper.impl.loadSchematic(file)) {
|
||||
BlockVector3 offset = clipboard.getRegion().getMinimumPoint().subtract(clipboard.getOrigin());
|
||||
BlockVector3 to = minPoint.toBlockVector3().subtract(offset);
|
||||
return clipboard.paste(BukkitAdapter.adapt(Bukkit.getWorlds().get(0)), to, false, true, new AffineTransform().rotateY(rotate));
|
||||
return paste(clipboard, minPoint, rotate);
|
||||
} catch (SecurityException exception) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static EditSession paste(SchematicNode schematic, Point minPoint, int rotate) {
|
||||
try (Clipboard clipboard = new SchematicData(schematic).load()) {
|
||||
return paste(clipboard, minPoint, rotate);
|
||||
} catch (SecurityException | IOException exception) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static EditSession paste(Clipboard clipboard, Point minPoint, int rotate) {
|
||||
BlockVector3 offset = clipboard.getRegion().getMinimumPoint().subtract(clipboard.getOrigin());
|
||||
BlockVector3 to = minPoint.toBlockVector3().subtract(offset);
|
||||
return clipboard.paste(BukkitAdapter.adapt(Bukkit.getWorlds().get(0)), to, false, true, new AffineTransform().rotateY(rotate));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,6 +115,10 @@ public class Tile {
|
||||
return new Location(null, getMinX(tileX), 0, getMinZ(tileZ));
|
||||
}
|
||||
|
||||
public Point getMinPoint() {
|
||||
return new Point(getMinX(tileX), 0, getMinZ(tileZ));
|
||||
}
|
||||
|
||||
public Location getMinLocation() {
|
||||
return getMinLocation(tileX, tileZ);
|
||||
}
|
||||
|
||||
+59
-12
@@ -19,22 +19,24 @@
|
||||
|
||||
package de.steamwar.bausystem.region.dynamic;
|
||||
|
||||
import de.steamwar.sql.SchematicNode;
|
||||
import lombok.NonNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.time.LocalDate;
|
||||
import java.time.Month;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.Optional;
|
||||
import java.util.Random;
|
||||
import java.util.*;
|
||||
|
||||
public abstract class VariantSelector {
|
||||
|
||||
public static final int BaseNodeId = 179925;
|
||||
|
||||
private static final SchematicNode BaseNode = Objects.requireNonNull(SchematicNode.byId(BaseNodeId));
|
||||
|
||||
private static final Random RANDOM = new Random();
|
||||
public static final VariantSelector EMPTY = new VariantSelector() {
|
||||
@Override
|
||||
public Optional<File> select() {
|
||||
public Optional<SchematicNode> select() {
|
||||
return Optional.empty();
|
||||
}
|
||||
};
|
||||
@@ -42,14 +44,14 @@ public abstract class VariantSelector {
|
||||
private VariantSelector() {
|
||||
}
|
||||
|
||||
public abstract Optional<File> select();
|
||||
public abstract Optional<SchematicNode> select();
|
||||
|
||||
public final VariantSelector or(VariantSelector other) {
|
||||
if (this == EMPTY) return other;
|
||||
VariantSelector self = this;
|
||||
return new VariantSelector() {
|
||||
@Override
|
||||
public Optional<File> select() {
|
||||
public Optional<SchematicNode> select() {
|
||||
return self.select().or(() -> other.select());
|
||||
}
|
||||
};
|
||||
@@ -60,7 +62,7 @@ public abstract class VariantSelector {
|
||||
VariantSelector self = this;
|
||||
return new VariantSelector() {
|
||||
@Override
|
||||
public Optional<File> select() {
|
||||
public Optional<SchematicNode> select() {
|
||||
LocalDate date = LocalDate.now();
|
||||
if (date.getDayOfMonth() == day && date.getMonth() == month) {
|
||||
return self.select();
|
||||
@@ -78,8 +80,9 @@ public abstract class VariantSelector {
|
||||
final File file = files[0];
|
||||
return new VariantSelector() {
|
||||
@Override
|
||||
public Optional<File> select() {
|
||||
return Optional.of(file);
|
||||
public Optional<SchematicNode> select() {
|
||||
return Optional.empty();
|
||||
// return Optional.of(file);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -88,9 +91,53 @@ public abstract class VariantSelector {
|
||||
final int filesCount = files.length;
|
||||
return new VariantSelector() {
|
||||
@Override
|
||||
public Optional<File> select() {
|
||||
return Optional.of(files[RANDOM.nextInt(filesCount)]);
|
||||
public Optional<SchematicNode> select() {
|
||||
return Optional.empty();
|
||||
// return Optional.of(files[RANDOM.nextInt(filesCount)]);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static VariantSelector Folder(String... path) {
|
||||
SchematicNode folder = folder(path);
|
||||
SchematicNode[] schematics = SchematicNode.getSchematicNodeInNode(folder.getId()).toArray(SchematicNode[]::new);
|
||||
if (schematics.length == 0) return EMPTY;
|
||||
if (schematics.length == 1) {
|
||||
final SchematicNode node = schematics[0];
|
||||
return new VariantSelector() {
|
||||
@Override
|
||||
public Optional<SchematicNode> select() {
|
||||
return Optional.of(node);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
final int count = schematics.length;
|
||||
return new VariantSelector() {
|
||||
@Override
|
||||
public Optional<SchematicNode> select() {
|
||||
return Optional.of(schematics[RANDOM.nextInt(count)]);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static VariantSelector Schematic(String... path) {
|
||||
SchematicNode schematic = folder(path);
|
||||
return new VariantSelector() {
|
||||
@Override
|
||||
public Optional<SchematicNode> select() {
|
||||
return Optional.of(schematic);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private static SchematicNode folder(String[] path) {
|
||||
SchematicNode current = BaseNode;
|
||||
for (int i = 0; i < path.length; i++) {
|
||||
SchematicNode node = SchematicNode.getSchematicNode(current.getId(), path[i]);
|
||||
if (node == null) throw new NullPointerException("Path " + path[i] + " not found in " + current.getId());
|
||||
current = node;
|
||||
}
|
||||
return current;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-5
@@ -24,7 +24,6 @@ import de.steamwar.bausystem.region.RegionFlagPolicy;
|
||||
import de.steamwar.bausystem.region.flags.Flag;
|
||||
import de.steamwar.bausystem.region.flags.ProtectMode;
|
||||
import de.steamwar.bausystem.region.flags.TNTMode;
|
||||
import de.steamwar.core.Core;
|
||||
import lombok.NonNull;
|
||||
|
||||
public class GlobalRegionData extends RegionData {
|
||||
@@ -44,10 +43,7 @@ public class GlobalRegionData extends RegionData {
|
||||
if (flag.oneOf(Flag.PROTECT)) {
|
||||
return RegionFlagPolicy.READ_ONLY;
|
||||
}
|
||||
if (flag.oneOf(Flag.ITEMS) && Core.getVersion() >= 20) {
|
||||
return RegionFlagPolicy.WRITABLE;
|
||||
}
|
||||
if (flag.oneOf(Flag.TNT, Flag.FIRE, Flag.FREEZE, Flag.WATER_DESTROY)) {
|
||||
if (flag.oneOf(Flag.TNT, Flag.FIRE, Flag.FREEZE, Flag.WATER_DESTROY, Flag.ITEMS)) {
|
||||
return RegionFlagPolicy.WRITABLE;
|
||||
}
|
||||
return RegionFlagPolicy.NOT_APPLICABLE;
|
||||
|
||||
+1
-1
@@ -161,7 +161,7 @@ public class AreaBlock extends Region.Area {
|
||||
@Override
|
||||
public void place(PasteBuilder pasteBuilder, boolean extension) {
|
||||
EditSession editSession = pasteBuilder
|
||||
.with(PasteBuilder.ClipboardProvider.file(selector.select().orElse(null)))
|
||||
.with(PasteBuilder.ClipboardProvider.schematic(selector.select().orElse(null)))
|
||||
.pastePoint(copyPoint)
|
||||
.run();
|
||||
region.getHistory()
|
||||
|
||||
+3
-2
@@ -25,6 +25,7 @@ import de.steamwar.bausystem.region.dynamic.PasteUtils;
|
||||
import de.steamwar.bausystem.region.dynamic.Tile;
|
||||
import de.steamwar.bausystem.region.dynamic.VariantSelector;
|
||||
import de.steamwar.bausystem.utils.PasteBuilder;
|
||||
import de.steamwar.sql.SchematicNode;
|
||||
import lombok.Getter;
|
||||
import lombok.NonNull;
|
||||
|
||||
@@ -66,7 +67,7 @@ public class AreaTile extends Region.Area {
|
||||
|
||||
@Override
|
||||
public void place(PasteBuilder pasteBuilder, boolean extension) {
|
||||
File resetFile = selector.select().orElse(null);
|
||||
if (resetFile != null) PasteUtils.paste(resetFile, minPoint, 0);
|
||||
SchematicNode reset = selector.select().orElse(null);
|
||||
if (reset != null) PasteUtils.paste(reset, minPoint, 0);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-5
@@ -24,7 +24,6 @@ import de.steamwar.bausystem.region.RegionFlagPolicy;
|
||||
import de.steamwar.bausystem.region.dynamic.DynamicRegion;
|
||||
import de.steamwar.bausystem.region.flags.Flag;
|
||||
import de.steamwar.bausystem.region.flags.TNTMode;
|
||||
import de.steamwar.core.Core;
|
||||
import lombok.NonNull;
|
||||
|
||||
public class DisplayRegionData extends RegionData {
|
||||
@@ -40,10 +39,7 @@ public class DisplayRegionData extends RegionData {
|
||||
|
||||
@Override
|
||||
public @NonNull <T extends Enum<T> & Flag.Value<T>> RegionFlagPolicy has(@NonNull Flag<T> flag) {
|
||||
if (flag.oneOf(Flag.FIRE, Flag.FREEZE, Flag.NO_GRAVITY, Flag.WATER_DESTROY)) {
|
||||
return RegionFlagPolicy.WRITABLE;
|
||||
}
|
||||
if (flag.oneOf(Flag.ITEMS) && Core.getVersion() >= 20) {
|
||||
if (flag.oneOf(Flag.FIRE, Flag.FREEZE, Flag.NO_GRAVITY, Flag.WATER_DESTROY, Flag.ITEMS)) {
|
||||
return RegionFlagPolicy.WRITABLE;
|
||||
}
|
||||
if (flag.oneOf(Flag.TNT, Flag.PROTECT)) {
|
||||
|
||||
+1
-5
@@ -25,7 +25,6 @@ import de.steamwar.bausystem.region.RegionFlagPolicy;
|
||||
import de.steamwar.bausystem.region.flags.Flag;
|
||||
import de.steamwar.bausystem.region.flags.TNTMode;
|
||||
import de.steamwar.bausystem.region.flags.TestblockMode;
|
||||
import de.steamwar.core.Core;
|
||||
import lombok.NonNull;
|
||||
|
||||
public class PlotRegionData extends RegionData {
|
||||
@@ -42,10 +41,7 @@ public class PlotRegionData extends RegionData {
|
||||
|
||||
@Override
|
||||
public @NonNull <T extends Enum<T> & Flag.Value<T>> RegionFlagPolicy has(@NonNull Flag<T> flag) {
|
||||
if (flag.oneOf(Flag.TNT, Flag.PROTECT, Flag.FIRE, Flag.FREEZE, Flag.NO_GRAVITY, Flag.WATER_DESTROY, Flag.TESTBLOCK, Flag.CHANGED)) {
|
||||
return RegionFlagPolicy.WRITABLE;
|
||||
}
|
||||
if (flag.oneOf(Flag.ITEMS) && Core.getVersion() >= 20) {
|
||||
if (flag.oneOf(Flag.TNT, Flag.PROTECT, Flag.FIRE, Flag.FREEZE, Flag.NO_GRAVITY, Flag.WATER_DESTROY, Flag.TESTBLOCK, Flag.CHANGED, Flag.ITEMS)) {
|
||||
return RegionFlagPolicy.WRITABLE;
|
||||
}
|
||||
return RegionFlagPolicy.NOT_APPLICABLE;
|
||||
|
||||
+1
-1
@@ -48,7 +48,7 @@ import java.util.UUID;
|
||||
public class MiWG7PlotRegion extends DynamicRegion {
|
||||
|
||||
protected static final int TILE_X = 3;
|
||||
protected static final int TILE_Z = 5;
|
||||
protected static final int TILE_Z = 6;
|
||||
|
||||
private static final File DIRECTORY = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "sections/microwargear_7/plot");
|
||||
private static final VariantSelector REGION = VariantSelector.Get(new File(DIRECTORY, "region"));
|
||||
|
||||
+2
-2
@@ -47,8 +47,8 @@ import java.util.UUID;
|
||||
)
|
||||
public class MWGPlotRegion extends DynamicRegion {
|
||||
|
||||
protected static final int TILE_X = 3;
|
||||
protected static final int TILE_Z = 6;
|
||||
protected static final int TILE_X = 5;
|
||||
protected static final int TILE_Z = 8;
|
||||
|
||||
private static final File DIRECTORY = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "sections/miniwargear/plot");
|
||||
private static final VariantSelector REGION = VariantSelector.Get(new File(DIRECTORY, "region"));
|
||||
|
||||
+94
-68
@@ -25,12 +25,13 @@ import de.steamwar.bausystem.region.DynamicRegionSystem;
|
||||
import de.steamwar.bausystem.region.Point;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.region.RegionType;
|
||||
import de.steamwar.bausystem.region.dynamic.DynamicRegion;
|
||||
import de.steamwar.bausystem.region.dynamic.PasteUtils;
|
||||
import de.steamwar.bausystem.region.dynamic.Tile;
|
||||
import de.steamwar.bausystem.region.dynamic.VariantSelector;
|
||||
import de.steamwar.bausystem.region.dynamic.spawn.SpawnRegion;
|
||||
import de.steamwar.bausystem.shared.Pair;
|
||||
import de.steamwar.bausystem.utils.PasteBuilder;
|
||||
import de.steamwar.sql.SchematicNode;
|
||||
import lombok.NonNull;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -46,45 +47,35 @@ public class PathArea extends Region.Area {
|
||||
private static final File PATH_DIR = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "sections/path");
|
||||
private static final File FALLBACK_SCHEM = new File(PATH_DIR, "Fallback.schem");
|
||||
|
||||
private static final VariantSelector CENTER_NORMAL = VariantSelector.Get(new File(PATH_DIR, "center/normal"));
|
||||
private static final VariantSelector CENTER = VariantSelector.Folder("Path", "Center");
|
||||
|
||||
private static final VariantSelector SIDE_GLOBAL = VariantSelector.Get(new File(PATH_DIR, "side/global"));
|
||||
private static final VariantSelector CORNER_INNER_GLOBAL = VariantSelector.Get(new File(PATH_DIR, "cinner/global"));
|
||||
private static final VariantSelector CORNER_OUTER_GLOBAL = VariantSelector.Get(new File(PATH_DIR, "couter/global"));
|
||||
|
||||
private static final VariantSelector SIDE_WATER = VariantSelector.Get(new File(PATH_DIR, "side/water"));
|
||||
private static final VariantSelector CORNER_INNER_WATER = VariantSelector.Get(new File(PATH_DIR, "cinner/water"));
|
||||
private static final VariantSelector CORNER_OUTER_WATER = VariantSelector.Get(new File(PATH_DIR, "couter/water"));
|
||||
private static final VariantSelector SIDE_WATER = VariantSelector.Folder("Path", "Edge", "Water");
|
||||
private static final VariantSelector CORNER_INNER_WATER = VariantSelector.Folder("Path", "Corner", "Inner", "Water");
|
||||
private static final VariantSelector CORNER_OUTER_WATER = VariantSelector.Folder("Path", "Corner", "Outer", "Water");
|
||||
|
||||
private static final VariantSelector SIDE_CLOSED = VariantSelector.Get(new File(PATH_DIR, "side/closed"));
|
||||
private static final VariantSelector CORNER_INNER_CLOSED = VariantSelector.Get(new File(PATH_DIR, "cinner/closed"));
|
||||
private static final VariantSelector CORNER_OUTER_CLOSED = VariantSelector.Get(new File(PATH_DIR, "couter/closed"));
|
||||
|
||||
private static final VariantSelector GARDEN = VariantSelector.Get(new File(PATH_DIR, "garden"));
|
||||
private static final VariantSelector GARDEN = VariantSelector.Folder("Path", "Garden");
|
||||
private static final VariantSelector SIDE_GARDEN = VariantSelector.Get(new File(PATH_DIR, "side/garden"));
|
||||
private static final VariantSelector SIDE_GARDEN_CONNECTED = VariantSelector.Get(new File(PATH_DIR, "side/garden_connected"));
|
||||
private static final VariantSelector CORNER_INNER_GARDEN = VariantSelector.Get(new File(PATH_DIR, "cinner/garden"));
|
||||
private static final VariantSelector CORNER_OUTER_GARDEN = VariantSelector.Get(new File(PATH_DIR, "couter/garden"));
|
||||
|
||||
private static final VariantSelector TORII_CENTER = VariantSelector.Folder("Path", "Torii", "Center");
|
||||
private static final VariantSelector TORII_SIDE_WATER = VariantSelector.Folder("Path", "Torii", "Edge");
|
||||
|
||||
private static final SelectorSide SELECTOR_SIDE = new SelectorSide()
|
||||
.Case(Path, CENTER_NORMAL)
|
||||
.Case(Global, SIDE_GLOBAL)
|
||||
.Case(Path, CENTER)
|
||||
.Case(Water, SIDE_WATER)
|
||||
.Case(Closed, SIDE_CLOSED)
|
||||
.Case(Plot, SIDE_CLOSED)
|
||||
.Case(Garden, SIDE_GARDEN_CONNECTED);
|
||||
|
||||
private static final SelectorCorner SELECTOR_CORNER = new SelectorCorner()
|
||||
// Path to Path
|
||||
.Case(Path, Path, Path, CENTER_NORMAL, RotationCorrection.UsingOrdinal)
|
||||
// Path to Global
|
||||
.Case(Path, Global, Global, SIDE_GLOBAL, RotationCorrection.WithCorrection)
|
||||
.Case(Global, Path, Path, SIDE_GLOBAL)
|
||||
.Case(Global, Path, Global, SIDE_GLOBAL)
|
||||
.Case(Path, Global, Path, SIDE_GLOBAL, RotationCorrection.WithCorrection)
|
||||
.Case(Global, Global, Global, CORNER_OUTER_GLOBAL, RotationCorrection.UsingOrdinal)
|
||||
.Case(Global, Global, Path, CORNER_OUTER_GLOBAL, RotationCorrection.UsingOrdinal)
|
||||
.Case(Path, Path, Global, CORNER_INNER_GLOBAL, RotationCorrection.UsingOrdinal)
|
||||
// Path to Water
|
||||
.Case(Path, Path, Path, CENTER, RotationCorrection.UsingOrdinal)
|
||||
// Path to Water, Spawn, Global
|
||||
.Case(Path, Water, Water, SIDE_WATER, RotationCorrection.WithCorrection)
|
||||
.Case(Water, Path, Path, SIDE_WATER)
|
||||
.Case(Water, Path, Water, SIDE_WATER)
|
||||
@@ -92,14 +83,14 @@ public class PathArea extends Region.Area {
|
||||
.Case(Water, Water, Water, CORNER_OUTER_WATER, RotationCorrection.UsingOrdinal)
|
||||
.Case(Water, Water, Path, CORNER_OUTER_WATER, RotationCorrection.UsingOrdinal)
|
||||
.Case(Path, Path, Water, CORNER_INNER_WATER, RotationCorrection.UsingOrdinal)
|
||||
// Path to Closed
|
||||
.Case(Path, Closed, Closed, SIDE_CLOSED, RotationCorrection.WithCorrection)
|
||||
.Case(Closed, Path, Path, SIDE_CLOSED)
|
||||
.Case(Closed, Path, Closed, SIDE_CLOSED)
|
||||
.Case(Path, Closed, Path, SIDE_CLOSED, RotationCorrection.WithCorrection)
|
||||
.Case(Closed, Closed, Closed, CORNER_OUTER_CLOSED, RotationCorrection.UsingOrdinal)
|
||||
.Case(Closed, Closed, Path, CORNER_OUTER_CLOSED, RotationCorrection.UsingOrdinal)
|
||||
.Case(Path, Path, Closed, CORNER_INNER_CLOSED, RotationCorrection.UsingOrdinal)
|
||||
// Path to Plot
|
||||
.Case(Path, Plot, Plot, SIDE_CLOSED, RotationCorrection.WithCorrection)
|
||||
.Case(Plot, Path, Path, SIDE_CLOSED)
|
||||
.Case(Plot, Path, Plot, SIDE_CLOSED)
|
||||
.Case(Path, Plot, Path, SIDE_CLOSED, RotationCorrection.WithCorrection)
|
||||
.Case(Plot, Plot, Plot, CORNER_OUTER_CLOSED, RotationCorrection.UsingOrdinal)
|
||||
.Case(Plot, Plot, Path, CORNER_OUTER_CLOSED, RotationCorrection.UsingOrdinal)
|
||||
.Case(Path, Path, Plot, CORNER_INNER_CLOSED, RotationCorrection.UsingOrdinal)
|
||||
// Path to Garden
|
||||
.Case(Path, Garden, Garden, SIDE_GARDEN, RotationCorrection.WithCorrection)
|
||||
.Case(Garden, Path, Path, SIDE_GARDEN)
|
||||
@@ -158,28 +149,33 @@ public class PathArea extends Region.Area {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void reset(PathSide side) {
|
||||
File resetFile = null;
|
||||
public void reset(PathSide side, boolean torii) {
|
||||
SchematicNode reset = null;
|
||||
VariantSelector selector = SELECTOR_SIDE.Select(tile, side);
|
||||
if (selector != null) resetFile = selector.select().orElse(null);
|
||||
if (selector == null || resetFile == null) {
|
||||
if (torii && selector == SIDE_WATER) {
|
||||
selector = TORII_SIDE_WATER;
|
||||
}
|
||||
if (selector != null) reset = selector.select().orElse(null);
|
||||
if (selector == null || reset == null) {
|
||||
if (!BauSystem.DEV_SERVER) return;
|
||||
resetFile = FALLBACK_SCHEM;
|
||||
// reset = FALLBACK_SCHEM;
|
||||
return;
|
||||
}
|
||||
|
||||
PasteUtils.paste(resetFile, minPoint.add(side.pasteOffsetX, 0, side.pasteOffsetZ), side.rotate);
|
||||
PasteUtils.paste(reset, minPoint.add(side.pasteOffsetX, 0, side.pasteOffsetZ), side.rotate);
|
||||
}
|
||||
|
||||
public void reset(PathCorner corner) {
|
||||
File resetFile = null;
|
||||
SchematicNode reset = null;
|
||||
Pair<VariantSelector, RotationCorrection> pair = SELECTOR_CORNER.Select(tile, corner);
|
||||
VariantSelector selector = pair.getKey();
|
||||
RotationCorrection rotationCorrection = pair.getValue();
|
||||
if (selector != null) resetFile = selector.select().orElse(null);
|
||||
if (selector == null || resetFile == null) {
|
||||
if (selector != null) reset = selector.select().orElse(null);
|
||||
if (selector == null || reset == null) {
|
||||
if (!BauSystem.DEV_SERVER) return;
|
||||
resetFile = FALLBACK_SCHEM;
|
||||
rotationCorrection = RotationCorrection.Unchanged;
|
||||
// reset = FALLBACK_SCHEM;
|
||||
// rotationCorrection = RotationCorrection.Unchanged;
|
||||
return;
|
||||
}
|
||||
|
||||
int rotate = corner.rotate;
|
||||
@@ -194,26 +190,24 @@ public class PathArea extends Region.Area {
|
||||
break;
|
||||
}
|
||||
|
||||
PasteUtils.paste(resetFile, minPoint.add(corner.pasteOffsetX, 0, corner.pasteOffsetZ), rotate);
|
||||
PasteUtils.paste(reset, minPoint.add(corner.pasteOffsetX, 0, corner.pasteOffsetZ), rotate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void place(PasteBuilder pasteBuilder, boolean extension) {
|
||||
if (region.isGarden()) {
|
||||
File resetFile = GARDEN.select().orElse(null);
|
||||
if (resetFile != null) {
|
||||
PasteUtils.paste(resetFile, minPoint, 0);
|
||||
}
|
||||
SchematicNode reset = GARDEN.select().orElse(null);
|
||||
if (reset != null) PasteUtils.paste(reset, minPoint, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
File resetFile = CENTER_NORMAL.select().orElse(null);
|
||||
if (resetFile != null) {
|
||||
PasteUtils.paste(resetFile, minPoint.add(7, 0, 7), 0);
|
||||
SchematicNode reset = (region.getToriiSide() != null ? TORII_CENTER : CENTER).select().orElse(null);
|
||||
if (reset != null) {
|
||||
PasteUtils.paste(reset, minPoint.add(7, 0, 7), region.getToriiSide() != null ? region.getToriiSide().rotate : 0);
|
||||
}
|
||||
|
||||
for (PathSide side : PathSide.values()) {
|
||||
reset(side);
|
||||
reset(side, region.getToriiSide() != null);
|
||||
}
|
||||
|
||||
for (PathCorner corner : PathCorner.values()) {
|
||||
@@ -221,30 +215,62 @@ public class PathArea extends Region.Area {
|
||||
}
|
||||
}
|
||||
|
||||
protected static RegionType.ConnectionType getConnectionType(Tile tile, PathSide side, PathSide optionalSide, RegionType.ConnectionType spawnPathConnection) {
|
||||
Optional<Tile> optionalTile = tile.add(side.tileOffsetX, side.tileOffsetZ);
|
||||
protected PathSide getToriiSide() {
|
||||
VariantSelector north = SELECTOR_SIDE.Select(tile, PathSide.North);
|
||||
VariantSelector south = SELECTOR_SIDE.Select(tile, PathSide.South);
|
||||
boolean zAxis = false;
|
||||
if (north == SIDE_WATER && south == SIDE_WATER) {
|
||||
zAxis = true;
|
||||
}
|
||||
|
||||
VariantSelector east = SELECTOR_SIDE.Select(tile, PathSide.East);
|
||||
VariantSelector west = SELECTOR_SIDE.Select(tile, PathSide.West);
|
||||
boolean xAxis = false;
|
||||
if (east == SIDE_WATER && west == SIDE_WATER) {
|
||||
xAxis = true;
|
||||
}
|
||||
|
||||
if (xAxis && zAxis) return null;
|
||||
|
||||
VariantSelector northEast = SELECTOR_CORNER.Select(tile, PathCorner.NorthEast).getKey();
|
||||
if (northEast != SIDE_WATER) return null;
|
||||
VariantSelector northWest = SELECTOR_CORNER.Select(tile, PathCorner.NorthWest).getKey();
|
||||
if (northWest != SIDE_WATER) return null;
|
||||
VariantSelector southEast = SELECTOR_CORNER.Select(tile, PathCorner.SouthEast).getKey();
|
||||
if (southEast != SIDE_WATER) return null;
|
||||
VariantSelector southWest = SELECTOR_CORNER.Select(tile, PathCorner.SouthWest).getKey();
|
||||
if (southWest != SIDE_WATER) return null;
|
||||
|
||||
if (zAxis) {
|
||||
return PathSide.North;
|
||||
} else if (xAxis) {
|
||||
return PathSide.West;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
protected static RegionType.ConnectionType getConnectionType(Tile source, PathSide side, PathSide optionalSide) {
|
||||
Optional<Tile> optionalTile = source.add(side.tileOffsetX, side.tileOffsetZ);
|
||||
if (optionalSide != null) {
|
||||
optionalTile = optionalTile.flatMap(t -> t.add(optionalSide.tileOffsetX, optionalSide.tileOffsetZ));
|
||||
}
|
||||
if (optionalTile.isEmpty()) {
|
||||
return Global;
|
||||
return Water;
|
||||
}
|
||||
tile = optionalTile.get();
|
||||
Tile tile = optionalTile.get();
|
||||
Region region = DynamicRegionSystem.INSTANCE.get(tile);
|
||||
if (region instanceof PathRegion pathRegion) {
|
||||
return pathRegion.isGarden() ? Garden : Path;
|
||||
if (region instanceof PathRegion pathRegion && pathRegion.isGarden()) {
|
||||
return Garden;
|
||||
}
|
||||
if (region instanceof SpawnRegion spawnRegion) {
|
||||
if (optionalSide == null && side.opposite().equals(spawnRegion.getPathSide())) {
|
||||
return spawnPathConnection;
|
||||
} else {
|
||||
return Closed;
|
||||
}
|
||||
if (!(region instanceof DynamicRegion dynamicRegion)) {
|
||||
return region.getType().getConnectionType();
|
||||
}
|
||||
return region.getType().getConnectionType();
|
||||
}
|
||||
|
||||
protected static RegionType.ConnectionType getConnectionType(Tile tile, PathSide side, PathSide optionalSide) {
|
||||
return getConnectionType(tile, side, optionalSide, Path);
|
||||
DynamicRegion.PathConnectResult result = dynamicRegion.shouldPathConnect(source, side.opposite(), optionalSide != null);
|
||||
return switch (result) {
|
||||
case ALWAYS -> Path;
|
||||
case NEVER -> Water;
|
||||
default -> region.getType().getConnectionType();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
+51
-7
@@ -29,9 +29,8 @@ import lombok.NonNull;
|
||||
import org.bukkit.Material;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Set;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@RegionConstructorData(
|
||||
identifier = "path",
|
||||
@@ -65,6 +64,7 @@ public class PathRegion extends DynamicRegion {
|
||||
area = new PathArea(tile, this);
|
||||
regionData = PathRegionData.INSTANCE;
|
||||
calculateGardenState();
|
||||
calculateToriiState();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -72,9 +72,21 @@ public class PathRegion extends DynamicRegion {
|
||||
TileUtils.writeTile(writer, tile);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull PathConnectResult shouldPathConnect(Tile source, PathSide side, boolean diagonal) {
|
||||
if (diagonal) {
|
||||
// Needed for inner corners of Small Spawn
|
||||
if (!(Math.abs(source.getTileX()) == 2 && source.getTileZ() == 0) && !(source.getTileX() == 0 && Math.abs(source.getTileZ()) == 2)) {
|
||||
return PathConnectResult.BY_TYPE;
|
||||
}
|
||||
return PathConnectResult.of(!(tile.equals(Tile.TILE_NN) || tile.equals(Tile.TILE_NP) || tile.equals(Tile.TILE_PN) || tile.equals(Tile.TILE_PP)));
|
||||
}
|
||||
return PathConnectResult.BY_TYPE;
|
||||
}
|
||||
|
||||
public void update(DynamicRegion updateFrom, NeighbourDirection direction) {
|
||||
for (PathSide side : direction.getSideUpdates()) {
|
||||
area.reset(side);
|
||||
area.reset(side, toriiSide != null);
|
||||
}
|
||||
for (PathCorner corner : direction.getCornerUpdates()) {
|
||||
area.reset(corner);
|
||||
@@ -87,16 +99,48 @@ public class PathRegion extends DynamicRegion {
|
||||
public void calculateGardenState() {
|
||||
garden = false;
|
||||
for (PathSide pathSide : PathSide.values()) {
|
||||
RegionType.ConnectionType connectionType = PathArea.getConnectionType(tile, pathSide, null, null);
|
||||
if (connectionType != RegionType.ConnectionType.Path && connectionType != RegionType.ConnectionType.Garden) return;
|
||||
Optional<Tile> optionalTile = tile.add(pathSide.tileOffsetX, pathSide.tileOffsetZ);
|
||||
if (optionalTile.isEmpty()) return;
|
||||
if (DynamicRegionSystem.INSTANCE.get(optionalTile.get()).getType() != RegionType.PATH) return;
|
||||
}
|
||||
for (PathCorner pathCorner : PathCorner.values()) {
|
||||
RegionType.ConnectionType connectionType = PathArea.getConnectionType(tile, pathCorner.side1, pathCorner.side2, null);
|
||||
if (connectionType != RegionType.ConnectionType.Path && connectionType != RegionType.ConnectionType.Garden) return;
|
||||
Optional<Tile> optionalTile = tile.add(pathCorner.side1.tileOffsetX + pathCorner.side2.tileOffsetX, pathCorner.side1.tileOffsetZ + pathCorner.side2.tileOffsetZ);
|
||||
if (optionalTile.isEmpty()) return;
|
||||
if (DynamicRegionSystem.INSTANCE.get(optionalTile.get()).getType() != RegionType.PATH) return;
|
||||
}
|
||||
garden = true;
|
||||
}
|
||||
|
||||
@Getter
|
||||
private PathSide toriiSide = null;
|
||||
|
||||
public void calculateToriiState() {
|
||||
if ((Math.abs(tile.getTileX()) + Math.abs(tile.getTileZ())) % 2 == 0) {
|
||||
toriiSide = null;
|
||||
return;
|
||||
}
|
||||
toriiSide = area.getToriiSide();
|
||||
|
||||
if (true) return;
|
||||
// Push Torii State to adjacent Path if valid Torii region!
|
||||
if (toriiSide != null) return;
|
||||
for (Tile adjacent : tile.neighboursPlus().toList()) {
|
||||
Region region = DynamicRegionSystem.INSTANCE.get(adjacent);
|
||||
if (region instanceof PathRegion pathRegion) {
|
||||
if (pathRegion.hasAdjacentToriiState()) continue;
|
||||
pathRegion.toriiSide = pathRegion.area.getToriiSide();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean hasAdjacentToriiState() {
|
||||
for (Tile adjacent : tile.neighboursPlus().toList()) {
|
||||
Region region = DynamicRegionSystem.INSTANCE.get(adjacent);
|
||||
if (region instanceof PathRegion pathRegion && pathRegion.toriiSide != null) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull RegionType getType() {
|
||||
return RegionType.PATH;
|
||||
|
||||
+1
-5
@@ -27,7 +27,6 @@ import de.steamwar.bausystem.region.flags.FireMode;
|
||||
import de.steamwar.bausystem.region.flags.Flag;
|
||||
import de.steamwar.bausystem.region.flags.ProtectMode;
|
||||
import de.steamwar.bausystem.region.flags.TNTMode;
|
||||
import de.steamwar.core.Core;
|
||||
import lombok.NonNull;
|
||||
|
||||
import java.util.UUID;
|
||||
@@ -64,10 +63,7 @@ public class PathRegionData extends RegionData {
|
||||
if (flag.oneOf(Flag.TNT, Flag.FIRE, Flag.PROTECT)) {
|
||||
return RegionFlagPolicy.READ_ONLY;
|
||||
}
|
||||
if (flag.oneOf(Flag.ITEMS) && Core.getVersion() >= 20) {
|
||||
return RegionFlagPolicy.WRITABLE;
|
||||
}
|
||||
if (flag.oneOf(Flag.FREEZE)) {
|
||||
if (flag.oneOf(Flag.FREEZE, Flag.ITEMS)) {
|
||||
return RegionFlagPolicy.WRITABLE;
|
||||
}
|
||||
return RegionFlagPolicy.NOT_APPLICABLE;
|
||||
|
||||
+2
-2
@@ -59,8 +59,8 @@ class SelectorCorner {
|
||||
}
|
||||
|
||||
public Pair<VariantSelector, PathArea.RotationCorrection> Select(Tile tile, PathCorner corner) {
|
||||
RegionType.ConnectionType left = PathArea.getConnectionType(tile, corner.side1, null, RegionType.ConnectionType.Closed);
|
||||
RegionType.ConnectionType right = PathArea.getConnectionType(tile, corner.side2, null, RegionType.ConnectionType.Closed);
|
||||
RegionType.ConnectionType left = PathArea.getConnectionType(tile, corner.side1, null);
|
||||
RegionType.ConnectionType right = PathArea.getConnectionType(tile, corner.side2, null);
|
||||
RegionType.ConnectionType diagonal = PathArea.getConnectionType(tile, corner.side1, corner.side2);
|
||||
int index = getIndex(left, right, diagonal);
|
||||
return new Pair<>(selectors[index], rotationCorrections[index]);
|
||||
|
||||
+25
-5
@@ -24,7 +24,9 @@ import de.steamwar.bausystem.region.Point;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.region.RegionType;
|
||||
import de.steamwar.bausystem.region.dynamic.DynamicRegion;
|
||||
import de.steamwar.bausystem.region.dynamic.PasteUtils;
|
||||
import de.steamwar.bausystem.region.dynamic.Tile;
|
||||
import de.steamwar.bausystem.region.dynamic.VariantSelector;
|
||||
import de.steamwar.bausystem.utils.PasteBuilder;
|
||||
import lombok.NonNull;
|
||||
|
||||
@@ -32,6 +34,13 @@ import java.util.List;
|
||||
|
||||
public class SpawnArea extends Region.Area {
|
||||
|
||||
private static final VariantSelector SPAWN_BIG = VariantSelector.Schematic("Spawn", "Big");
|
||||
private static final VariantSelector SPAWN_LITTLE_ZZ = VariantSelector.Schematic("Spawn", "Little_ZZ");
|
||||
private static final VariantSelector SPAWN_LITTLE_NZ = VariantSelector.Schematic("Spawn", "Little_NZ");
|
||||
private static final VariantSelector SPAWN_LITTLE_PZ = VariantSelector.Schematic("Spawn", "Little_PZ");
|
||||
private static final VariantSelector SPAWN_LITTLE_ZN = VariantSelector.Schematic("Spawn", "Little_ZN");
|
||||
private static final VariantSelector SPAWN_LITTLE_ZP = VariantSelector.Schematic("Spawn", "Little_ZP");
|
||||
|
||||
private final Tile tile;
|
||||
|
||||
public SpawnArea(Tile tile) {
|
||||
@@ -40,12 +49,12 @@ public class SpawnArea extends Region.Area {
|
||||
|
||||
@Override
|
||||
public @NonNull Point getMinPoint(boolean extension) {
|
||||
return Point.fromLocation(tile.getMinLocation());
|
||||
return Point.fromLocation(tile.getMinLocation()).setY(WORLD_MIN_Y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull Point getMaxPoint(boolean extension) {
|
||||
return Point.fromLocation(tile.getMaxLocation());
|
||||
return Point.fromLocation(tile.getMaxLocation()).setY(WORLD_MAX_Y);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -59,11 +68,12 @@ public class SpawnArea extends Region.Area {
|
||||
.map(DynamicRegionSystem.Neighbour::region)
|
||||
.toList();
|
||||
|
||||
if (regions.stream().map(DynamicRegion::getType).allMatch(RegionType::isSpawn)) {
|
||||
// TODO: Implement big spawn!
|
||||
if (regions.size() == 8) {
|
||||
PasteUtils.paste(SPAWN_BIG.select().orElseThrow(), Tile.TILE_NN.getMinPoint().setY(WORLD_MIN_Y), 0);
|
||||
return;
|
||||
}
|
||||
|
||||
DynamicRegionSystem.INSTANCE.get(Tile.ZERO).getArea().place(new PasteBuilder(), false);
|
||||
for (DynamicRegion region : regions) {
|
||||
if (region.getArea() instanceof SpawnArea spawnArea) {
|
||||
spawnArea.place(new PasteBuilder(), false);
|
||||
@@ -73,6 +83,16 @@ public class SpawnArea extends Region.Area {
|
||||
|
||||
@Override
|
||||
public void place(PasteBuilder pasteBuilder, boolean extension) {
|
||||
|
||||
if (tile.equals(Tile.ZERO)) {
|
||||
PasteUtils.paste(SPAWN_LITTLE_ZZ.select().orElseThrow(), getMinPoint(false), 0);
|
||||
} else if (tile.equals(Tile.TILE_NZ)) {
|
||||
PasteUtils.paste(SPAWN_LITTLE_NZ.select().orElseThrow(), getMinPoint(false), 0);
|
||||
} else if (tile.equals(Tile.TILE_PZ)) {
|
||||
PasteUtils.paste(SPAWN_LITTLE_PZ.select().orElseThrow(), getMinPoint(false), 0);
|
||||
} else if (tile.equals(Tile.TILE_ZN)) {
|
||||
PasteUtils.paste(SPAWN_LITTLE_ZN.select().orElseThrow(), getMinPoint(false), 0);
|
||||
} else if (tile.equals(Tile.TILE_ZP)) {
|
||||
PasteUtils.paste(SPAWN_LITTLE_ZP.select().orElseThrow(), getMinPoint(false), 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+12
-16
@@ -54,8 +54,6 @@ public class SpawnRegion extends DynamicRegion {
|
||||
@Getter
|
||||
private final Tile tile;
|
||||
|
||||
@Getter
|
||||
private final PathSide pathSide;
|
||||
private final SpawnArea area;
|
||||
|
||||
public SpawnRegion(Tile tile) {
|
||||
@@ -71,17 +69,6 @@ public class SpawnRegion extends DynamicRegion {
|
||||
private SpawnRegion(UUID id, Tile tile) {
|
||||
super(id, null);
|
||||
this.tile = tile;
|
||||
if (tile.equals(Tile.TILE_PZ)) {
|
||||
pathSide = PathSide.East;
|
||||
} else if (tile.equals(Tile.TILE_NZ)) {
|
||||
pathSide = PathSide.West;
|
||||
} else if (tile.equals(Tile.TILE_ZP)) {
|
||||
pathSide = PathSide.South;
|
||||
} else if (tile.equals(Tile.TILE_ZN)) {
|
||||
pathSide = PathSide.North;
|
||||
} else {
|
||||
pathSide = null;
|
||||
}
|
||||
area = new SpawnArea(tile);
|
||||
regionData = PathRegionData.INSTANCE;
|
||||
}
|
||||
@@ -91,12 +78,21 @@ public class SpawnRegion extends DynamicRegion {
|
||||
TileUtils.writeTile(writer, tile);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull PathConnectResult shouldPathConnect(Tile source, PathSide side, boolean diagonal) {
|
||||
if (diagonal) return PathConnectResult.BY_TYPE;
|
||||
return switch (side) {
|
||||
case North -> PathConnectResult.of(tile.equals(Tile.TILE_ZN), PathConnectResult.BY_TYPE);
|
||||
case South -> PathConnectResult.of(tile.equals(Tile.TILE_ZP), PathConnectResult.BY_TYPE);
|
||||
case East -> PathConnectResult.of(tile.equals(Tile.TILE_PZ), PathConnectResult.BY_TYPE);
|
||||
case West -> PathConnectResult.of(tile.equals(Tile.TILE_NZ), PathConnectResult.BY_TYPE);
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull RegionType getType() {
|
||||
if (tile.equals(Tile.ZERO)) {
|
||||
if (tile.getTileX() == 0 || tile.getTileZ() == 0) {
|
||||
return RegionType.SPAWN;
|
||||
} else if (pathSide != null) {
|
||||
return RegionType.SPAWN_PATH;
|
||||
} else {
|
||||
return RegionType.SPAWN_EXTENSION;
|
||||
}
|
||||
|
||||
+4
-34
@@ -19,8 +19,6 @@
|
||||
|
||||
package de.steamwar.bausystem.region.dynamic.special;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.region.DynamicRegionSystem;
|
||||
import de.steamwar.bausystem.region.Point;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.region.dynamic.DynamicRegion;
|
||||
@@ -28,18 +26,12 @@ import de.steamwar.bausystem.region.dynamic.PasteUtils;
|
||||
import de.steamwar.bausystem.region.dynamic.Tile;
|
||||
import de.steamwar.bausystem.region.dynamic.VariantSelector;
|
||||
import de.steamwar.bausystem.utils.PasteBuilder;
|
||||
import de.steamwar.sql.SchematicNode;
|
||||
import lombok.Getter;
|
||||
import lombok.NonNull;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
public class SpecialArea extends Region.Area {
|
||||
|
||||
public static final File SPECIAL_PATH_DIR = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "sections/special");
|
||||
|
||||
private final DynamicRegion region;
|
||||
|
||||
@Getter
|
||||
@@ -75,36 +67,14 @@ public class SpecialArea extends Region.Area {
|
||||
return copyPoint;
|
||||
}
|
||||
|
||||
private boolean resetting = false;
|
||||
|
||||
@Override
|
||||
public void reset(PasteBuilder pasteBuilder, boolean extension) {
|
||||
if (resetting) return;
|
||||
AtomicBoolean hasResetting = new AtomicBoolean(false);
|
||||
List<Region> regions = DynamicRegionSystem.INSTANCE.getConnectedRegions(region)
|
||||
.peek(region -> {
|
||||
if (((SpecialArea) region.getArea()).resetting) hasResetting.set(true);
|
||||
})
|
||||
.toList();
|
||||
if (hasResetting.get()) return;
|
||||
|
||||
regions.forEach(region -> {
|
||||
((SpecialArea) region.getArea()).resetting = true;
|
||||
});
|
||||
|
||||
for (int i = 0; i < regions.size(); i++) {
|
||||
final int offset = i / 10;
|
||||
final Region region = regions.get(i);
|
||||
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
|
||||
region.getArea().place(null, false); // TODO: Fix this!
|
||||
}, offset);
|
||||
}
|
||||
place(pasteBuilder, extension);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void place(PasteBuilder pasteBuilder, boolean extension) {
|
||||
File resetFile = resetFiles.select().orElse(null);
|
||||
if (resetFile != null) PasteUtils.paste(resetFile, minPoint, 0);
|
||||
resetting = false;
|
||||
SchematicNode reset = resetFiles.select().orElse(null);
|
||||
if (reset != null) PasteUtils.paste(reset, minPoint, 0);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-5
@@ -26,7 +26,6 @@ import de.steamwar.bausystem.region.RegionFlagPolicy;
|
||||
import de.steamwar.bausystem.region.dynamic.DynamicRegion;
|
||||
import de.steamwar.bausystem.region.flags.Flag;
|
||||
import de.steamwar.bausystem.region.flags.TNTMode;
|
||||
import de.steamwar.core.Core;
|
||||
import lombok.NonNull;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
@@ -52,10 +51,7 @@ public class SpecialRegionData extends RegionData {
|
||||
|
||||
@Override
|
||||
public @NonNull <T extends Enum<T> & Flag.Value<T>> RegionFlagPolicy has(@NonNull Flag<T> flag) {
|
||||
if (flag.oneOf(Flag.TNT, Flag.FIRE, Flag.FREEZE, Flag.PROTECT, Flag.NO_GRAVITY, Flag.WATER_DESTROY)) {
|
||||
return RegionFlagPolicy.WRITABLE;
|
||||
}
|
||||
if (flag.oneOf(Flag.ITEMS) && Core.getVersion() >= 20) {
|
||||
if (flag.oneOf(Flag.TNT, Flag.FIRE, Flag.FREEZE, Flag.PROTECT, Flag.NO_GRAVITY, Flag.WATER_DESTROY, Flag.ITEMS)) {
|
||||
return RegionFlagPolicy.WRITABLE;
|
||||
}
|
||||
return RegionFlagPolicy.NOT_APPLICABLE;
|
||||
|
||||
+1
-4
@@ -31,12 +31,9 @@ import de.steamwar.sql.GameModeConfig;
|
||||
import lombok.NonNull;
|
||||
import org.bukkit.Material;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.UUID;
|
||||
|
||||
import static de.steamwar.bausystem.region.dynamic.special.SpecialArea.SPECIAL_PATH_DIR;
|
||||
|
||||
@RegionConstructorData(
|
||||
identifier = "special_dry",
|
||||
name = "Dry",
|
||||
@@ -49,7 +46,7 @@ public class DryRegion extends DynamicRegion {
|
||||
protected static final int TILE_X = 1;
|
||||
protected static final int TILE_Z = 1;
|
||||
|
||||
private static final VariantSelector DRY = VariantSelector.Get(new File(SPECIAL_PATH_DIR, "dry"));
|
||||
private static final VariantSelector DRY = VariantSelector.Folder("Dry");
|
||||
|
||||
private final SpecialArea area;
|
||||
|
||||
|
||||
+1
-4
@@ -30,12 +30,9 @@ import de.steamwar.sql.GameModeConfig;
|
||||
import lombok.NonNull;
|
||||
import org.bukkit.Material;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.UUID;
|
||||
|
||||
import static de.steamwar.bausystem.region.dynamic.special.SpecialArea.SPECIAL_PATH_DIR;
|
||||
|
||||
@RegionConstructorData(
|
||||
identifier = "special_wet",
|
||||
name = "Wet",
|
||||
@@ -48,7 +45,7 @@ public class WetRegion extends DynamicRegion {
|
||||
protected static final int TILE_X = 1;
|
||||
protected static final int TILE_Z = 1;
|
||||
|
||||
private static final VariantSelector WET = VariantSelector.Get(new File(SPECIAL_PATH_DIR, "wet"));
|
||||
private static final VariantSelector WET = VariantSelector.Folder("Wet");
|
||||
|
||||
private final SpecialArea area;
|
||||
|
||||
|
||||
@@ -48,6 +48,7 @@ tasks.register<DevServer>("DevBau21Dynamic") {
|
||||
dependsOn(":SpigotCore:shadowJar")
|
||||
dependsOn(":BauSystem:shadowJar")
|
||||
dependsOn(":SchematicSystem:shadowJar")
|
||||
template = "Bau21-Dynamic"
|
||||
dependsOn(":KotlinCore:shadowJar")
|
||||
template = "BauDynamic21"
|
||||
jar = "/jars/paper-1.21.6.jar"
|
||||
}
|
||||
|
||||
@@ -797,7 +797,7 @@ public final class GameModeConfig<M, W> {
|
||||
|
||||
/**
|
||||
* Resolves one {@code Materials} entry to the concrete materials it denotes: {@code storage}
|
||||
* for {@link SQLWrapper#getStorageMaterials()}, {@code all} for
|
||||
* for {@link SQLWrapper#getStorageMaterials()}, {@code inventory} for
|
||||
* {@link SQLWrapper#getInventoryMaterials()}, or the material itself otherwise.
|
||||
*/
|
||||
private Set<M> expandInventoryGroup(YMLWrapper<M, ?> loader, String name) {
|
||||
|
||||
@@ -183,14 +183,6 @@ class Punishment(id: EntityID<Int>) : IntEntity(id) {
|
||||
"UNNOFIGHTSERVER",
|
||||
UserPerm.MODERATION
|
||||
),
|
||||
NoTeamServer(
|
||||
"NOTEAMSERVER_TEAM",
|
||||
"NOTEAMSERVER_PERMA",
|
||||
"NOTEAMSERVER_UNTIL",
|
||||
"UNNOTEAMSERVER_ERROR",
|
||||
"UNNOTEAMSERVER",
|
||||
UserPerm.MODERATION
|
||||
),
|
||||
Note("NOTE_TEAM", null, null, null, null, UserPerm.PUNISHMENTS, true);
|
||||
|
||||
fun isMulti() =
|
||||
|
||||
@@ -288,6 +288,12 @@ class SchematicNode(id: EntityID<Int>) : IntEntity(id) {
|
||||
find { (SchematicNodeTable.owner eq owner) and (SchematicNodeTable.name eq name) and (SchematicNodeTable.parent eq parent) }.firstOrNull()
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getSchematicNode(parent: Int, name: String) =
|
||||
useDb {
|
||||
find { (SchematicNodeTable.parent eq parent) and (SchematicNodeTable.name eq name) }.firstOrNull()
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getSchematicNode(owner: Int, name: String, parent: SchematicNode) =
|
||||
getSchematicNode(owner, name, parent.nodeId)
|
||||
|
||||
@@ -39,6 +39,7 @@ public enum ArenaMode {
|
||||
public static final Set<ArenaMode> Test = Collections.unmodifiableSet(EnumSet.of(TEST, CHECK));
|
||||
public static final Set<ArenaMode> Prepare = Collections.unmodifiableSet(EnumSet.of(PREPARE));
|
||||
public static final Set<ArenaMode> Replay = Collections.unmodifiableSet(EnumSet.of(REPLAY, TEST));
|
||||
public static final Set<ArenaMode> TestOrReferee = Collections.unmodifiableSet(EnumSet.of(TEST, CHECK, EVENT));
|
||||
|
||||
public static final Set<ArenaMode> AntiReplay = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(REPLAY)));
|
||||
public static final Set<ArenaMode> AntiTest = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(TEST, CHECK)));
|
||||
|
||||
@@ -21,8 +21,8 @@ package de.steamwar.fightsystem;
|
||||
|
||||
import com.comphenix.tinyprotocol.TinyProtocol;
|
||||
import de.steamwar.core.Core;
|
||||
import de.steamwar.core.WorldEditRendererCUIEditor;
|
||||
import de.steamwar.fightsystem.commands.TechareaCommand;
|
||||
import de.steamwar.core.worldedit.SteamEdit;
|
||||
import de.steamwar.core.worldedit.WorldEditRendererCUIEditor;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.listener.ClickAnalyzer;
|
||||
@@ -108,7 +108,7 @@ public class FightSystem extends JavaPlugin {
|
||||
}
|
||||
});
|
||||
new OneShotStateDependent(ArenaMode.All, FightState.PreSchemSetup, () -> Fight.playSound(SWSound.BLOCK_NOTE_PLING.getSound(), 100.0f, 2.0f));
|
||||
new OneShotStateDependent(ArenaMode.Test, FightState.All, WorldEditRendererCUIEditor::new);
|
||||
new OneShotStateDependent(ArenaMode.Test, FightState.All, SteamEdit::init);
|
||||
Config.world.setGameRule(GameRule.REDUCED_DEBUG_INFO, ArenaMode.AntiTest.contains(Config.mode));
|
||||
|
||||
hullHider = new HullHider();
|
||||
@@ -127,8 +127,6 @@ public class FightSystem extends JavaPlugin {
|
||||
if (checkSchematicNode.isPrepared()) {
|
||||
Fight.getRedTeam().setSchem(checkSchematicNode, NodeData.getRevisions(checkSchematicNode) - 1);
|
||||
}
|
||||
|
||||
new TechareaCommand();
|
||||
} else if (Config.mode == ArenaMode.PREPARE) {
|
||||
Fight.getUnrotated().setSchem(SchematicNode.getSchematicNode(Config.PrepareSchemID));
|
||||
}
|
||||
|
||||
@@ -24,35 +24,25 @@ import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.fight.Kit;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentCommand;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.sql.UserPerm;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@Linked
|
||||
public class AkCommand implements CommandExecutor {
|
||||
public class AkCommand extends FightSWCommand {
|
||||
|
||||
public AkCommand() {
|
||||
new StateDependentCommand(ArenaMode.Test, FightState.All, "ak", this);
|
||||
super(ArenaMode.Test, FightState.All, "ak");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
return false;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
if (!player.isOp()) return false;
|
||||
protected boolean hasPerm(Player player, SteamwarUser user) {
|
||||
return player.isOp() && user.hasPerm(UserPerm.ADMINISTRATION) && Core.getInstance() != FightSystem.getPlugin();
|
||||
}
|
||||
|
||||
if (!SteamwarUser.get(player.getUniqueId()).hasPerm(UserPerm.ADMINISTRATION) && Core.getInstance() != FightSystem.getPlugin()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Kit.createKit(args[0], player);
|
||||
return false;
|
||||
@Register
|
||||
public void run(@Validator Player player, String name) {
|
||||
Kit.createKit(name, player);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* 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.fightsystem.commands;
|
||||
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.command.TypeValidator;
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependent;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerCommandSendEvent;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public abstract class FightSWCommand extends SWCommand implements Listener {
|
||||
|
||||
private final String command;
|
||||
private final String[] aliases;
|
||||
|
||||
protected FightSWCommand(Set<ArenaMode> mode, Set<FightState> states, String command) {
|
||||
super(command);
|
||||
this.command = command;
|
||||
this.aliases = new String[0];
|
||||
stateDependant(mode, states);
|
||||
}
|
||||
|
||||
protected FightSWCommand(Set<ArenaMode> mode, Set<FightState> states, String command, String... aliases) {
|
||||
super(command, aliases);
|
||||
this.command = command;
|
||||
this.aliases = aliases;
|
||||
stateDependant(mode, states);
|
||||
}
|
||||
|
||||
private void stateDependant(Set<ArenaMode> mode, Set<FightState> states) {
|
||||
FightSWCommand.this.unregister();
|
||||
new StateDependent(mode, states) {
|
||||
@Override
|
||||
public void enable() {
|
||||
System.out.println("--- Enable: " + command);
|
||||
FightSWCommand.this.register();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable() {
|
||||
System.out.println("--- Disable: " + command);
|
||||
FightSWCommand.this.unregister();
|
||||
}
|
||||
}.register();
|
||||
}
|
||||
|
||||
public static void postFightStateChange() {
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
player.updateCommands();
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean hasPerm(Player player, SteamwarUser user) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public final void onPlayerCommandSend(PlayerCommandSendEvent event) {
|
||||
if (hasPerm(event.getPlayer(), SteamwarUser.get(event.getPlayer().getUniqueId()))) return;
|
||||
event.getCommands().remove(command);
|
||||
for (String alias : aliases) {
|
||||
event.getCommands().remove(alias);
|
||||
}
|
||||
}
|
||||
|
||||
@ClassValidator(value = Player.class, local = true)
|
||||
public final TypeValidator<Player> permissionCheck() {
|
||||
return (sender, value, messageSender) -> hasPerm(value, SteamwarUser.get(value.getUniqueId()));
|
||||
}
|
||||
}
|
||||
+10
-74
@@ -19,92 +19,28 @@
|
||||
|
||||
package de.steamwar.fightsystem.commands;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import org.bukkit.Bukkit;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.defaults.BukkitCommand;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Linked
|
||||
public class GamemodeCommand extends BukkitCommand {
|
||||
|
||||
private static final List<String> GAMEMODE_NAMES = ImmutableList.of("adventure", "creative", "survival",
|
||||
"spectator");
|
||||
public class GamemodeCommand extends FightSWCommand {
|
||||
|
||||
public GamemodeCommand() {
|
||||
super("gamemode");
|
||||
List<String> aliases = new ArrayList<>();
|
||||
aliases.add("gm");
|
||||
this.setAliases(aliases);
|
||||
|
||||
Map<String, Command> knownCommands = ((CraftServer) Bukkit.getServer()).getCommandMap().getKnownCommands();
|
||||
knownCommands.remove("gamemode");
|
||||
Commands.injectCommand(this);
|
||||
super(ArenaMode.TestOrReferee, FightState.All, "gamemode", "gm");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(CommandSender sender, String currentAlias, String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
return false;
|
||||
} else if (args.length == 0) {
|
||||
FightSystem.getMessage().sendPrefixless("GAMEMODE_HELP", sender);
|
||||
return false;
|
||||
}
|
||||
|
||||
Player p = (Player) sender;
|
||||
|
||||
if (!(Config.test() || Config.isReferee(p))) {
|
||||
FightSystem.getMessage().sendPrefixless("GAMEMODE_NOT_ALLOWED", p, ChatMessageType.ACTION_BAR);
|
||||
return false;
|
||||
}
|
||||
|
||||
GameMode mode = createMode(args[0]);
|
||||
|
||||
if (mode == null) {
|
||||
FightSystem.getMessage().sendPrefixless("GAMEMODE_UNKNOWN", p, ChatMessageType.ACTION_BAR, args[0]);
|
||||
return false;
|
||||
}
|
||||
|
||||
p.setGameMode(mode);
|
||||
return true;
|
||||
protected boolean hasPerm(Player player, SteamwarUser user) {
|
||||
return Config.test() || Config.isReferee(player);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private GameMode createMode(String modeArg) {
|
||||
try {
|
||||
return GameMode.getByValue(Integer.parseInt(modeArg));
|
||||
} catch (NumberFormatException ignored) {
|
||||
if ((modeArg.equalsIgnoreCase("creative")) || (modeArg.equalsIgnoreCase("c"))) {
|
||||
return GameMode.CREATIVE;
|
||||
} else if ((modeArg.equalsIgnoreCase("adventure")) || (modeArg.equalsIgnoreCase("a"))) {
|
||||
return GameMode.ADVENTURE;
|
||||
} else if ((modeArg.equalsIgnoreCase("spectator")) || (modeArg.equalsIgnoreCase("sp"))) {
|
||||
return GameMode.SPECTATOR;
|
||||
} else if ((modeArg.equalsIgnoreCase("survival")) || (modeArg.equalsIgnoreCase("s"))) {
|
||||
return GameMode.SURVIVAL;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
@Register(description = "GAMEMODE_HELP")
|
||||
public void execute(@Validator Player player, GameMode gameMode) {
|
||||
player.setGameMode(gameMode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> tabComplete(CommandSender sender, String alias, String[] args) {
|
||||
if (args.length == 1) {
|
||||
return StringUtil.copyPartialMatches(args[0], GAMEMODE_NAMES, new ArrayList<>(GAMEMODE_NAMES.size()));
|
||||
}
|
||||
return ImmutableList.of();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,34 +20,31 @@
|
||||
package de.steamwar.fightsystem.commands;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.listener.Check;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentCommand;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.sql.SchematicNode;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.sql.UserPerm;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@Linked
|
||||
public class InfoCommand implements CommandExecutor {
|
||||
public class InfoCommand extends FightSWCommand {
|
||||
|
||||
public InfoCommand() {
|
||||
new StateDependentCommand(ArenaMode.All, FightState.All, "fightinfo", this);
|
||||
super(ArenaMode.All, FightState.All, "fightinfo");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!(sender instanceof Player)) return false;
|
||||
|
||||
Player player = (Player) sender;
|
||||
if (!SteamwarUser.get(player.getUniqueId()).hasPerm(UserPerm.CHECK)) return false;
|
||||
protected boolean hasPerm(Player player, SteamwarUser user) {
|
||||
return Check.checkPermission(user, Config.GameModeConfig);
|
||||
}
|
||||
|
||||
@Register
|
||||
public void run(@Validator Player player) {
|
||||
for (FightTeam team : Fight.teams()) {
|
||||
if (!team.isLeaderless()) {
|
||||
FightSystem.getMessage().send("INFO_LEADER", player, team.getColoredName(), team.getLeader().getEntity().getName());
|
||||
@@ -58,6 +55,5 @@ public class InfoCommand implements CommandExecutor {
|
||||
FightSystem.getMessage().send("INFO_SCHEMATIC", player, team.getColoredName(), schematic.getName(), SteamwarUser.byId(schematic.getOwner()).getUserName(), schematic.getRank());
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,32 +21,23 @@ package de.steamwar.fightsystem.commands;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentCommand;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@Linked
|
||||
public class KitCommand implements CommandExecutor {
|
||||
public class KitCommand extends FightSWCommand {
|
||||
|
||||
public KitCommand() {
|
||||
new StateDependentCommand(ArenaMode.AntiReplay, FightState.Setup, "kit", this);
|
||||
super(ArenaMode.AntiReplay, FightState.Setup, "kit");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
return false;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
@Register
|
||||
public void execute(Player player) {
|
||||
GUI.kitSelection(player, "");
|
||||
}
|
||||
|
||||
if (args.length != 1) {
|
||||
GUI.kitSelection(player, "");
|
||||
} else {
|
||||
Commands.kit(player, args[0]);
|
||||
}
|
||||
return false;
|
||||
@Register
|
||||
public void execute(Player player, String query) { // TODO: TabCompletion of Kit Names!
|
||||
GUI.kitSelection(player, query);
|
||||
}
|
||||
}
|
||||
|
||||
+4
-14
@@ -21,28 +21,18 @@ package de.steamwar.fightsystem.commands;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentCommand;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@Linked
|
||||
public class LeaveCommand implements CommandExecutor {
|
||||
public class LeaveCommand extends FightSWCommand {
|
||||
|
||||
public LeaveCommand() {
|
||||
new StateDependentCommand(ArenaMode.AntiReplay, FightState.Setup, "leave", this);
|
||||
super(ArenaMode.AntiReplay, FightState.Setup, "leave");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
return false;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
|
||||
@Register
|
||||
public void execute(Player player) {
|
||||
Commands.leaveTeam(player);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
+10
-20
@@ -20,52 +20,42 @@
|
||||
package de.steamwar.fightsystem.commands;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.listener.Check;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentCommand;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.sql.SchematicNode;
|
||||
import de.steamwar.sql.SchematicType;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.sql.UserPerm;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@Linked
|
||||
public class LockschemCommand implements CommandExecutor {
|
||||
public class LockschemCommand extends FightSWCommand {
|
||||
|
||||
public LockschemCommand() {
|
||||
new StateDependentCommand(ArenaMode.All, FightState.Schem, "lockschem", this);
|
||||
super(ArenaMode.All, FightState.Schem, "lockschem");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!(sender instanceof Player)) return false;
|
||||
Player player = (Player) sender;
|
||||
protected boolean hasPerm(Player player, SteamwarUser user) {
|
||||
return Check.checkPermission(user, Config.GameModeConfig);
|
||||
}
|
||||
|
||||
if (!SteamwarUser.get(player.getUniqueId()).hasPerm(UserPerm.CHECK)) return false;
|
||||
|
||||
if (args.length != 1) {
|
||||
FightSystem.getMessage().sendPrefixless("LOCKSCHEM_HELP", player);
|
||||
return false;
|
||||
}
|
||||
|
||||
String teamName = args[0];
|
||||
@Register(description = "LOCKSCHEM_HELP")
|
||||
public void execute(@Validator Player player, String teamName) {
|
||||
FightTeam fightTeam = Fight.getTeamByName(teamName);
|
||||
|
||||
if (fightTeam == null) {
|
||||
FightSystem.getMessage().sendPrefixless("UNKNOWN_TEAM", player, ChatMessageType.ACTION_BAR);
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
|
||||
SchematicNode.getSchematicNode(fightTeam.getSchematic()).setSchemtype(SchematicType.Normal);
|
||||
FightSystem.getMessage().sendPrefixless("LOCKSCHEM_LOCKED", player, ChatMessageType.ACTION_BAR);
|
||||
fightTeam.broadcastSystem("LOCKSCHEM_LOCKED_BY", player.getName());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
+4
-14
@@ -21,28 +21,18 @@ package de.steamwar.fightsystem.commands;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentCommand;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@Linked
|
||||
public class ReadyCommand implements CommandExecutor {
|
||||
public class ReadyCommand extends FightSWCommand {
|
||||
|
||||
public ReadyCommand() {
|
||||
new StateDependentCommand(ArenaMode.AntiPrepare, FightState.PostSchemSetup, "ready", this);
|
||||
super(ArenaMode.AntiPrepare, FightState.PostSchemSetup, "ready");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
return false;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
|
||||
@Register
|
||||
public void execute(Player player) {
|
||||
Commands.toggleReady(player);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
+5
-21
@@ -20,35 +20,19 @@
|
||||
package de.steamwar.fightsystem.commands;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentCommand;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@Linked
|
||||
public class RemoveCommand implements CommandExecutor {
|
||||
public class RemoveCommand extends FightSWCommand {
|
||||
|
||||
public RemoveCommand() {
|
||||
new StateDependentCommand(ArenaMode.VariableTeams, FightState.Setup, "remove", this);
|
||||
super(ArenaMode.VariableTeams, FightState.Setup, "remove");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
return false;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
|
||||
if (args.length != 1) {
|
||||
FightSystem.getMessage().sendPrefixless("REMOVE_HELP", player);
|
||||
return false;
|
||||
}
|
||||
|
||||
Commands.kick(player, args[0]);
|
||||
return false;
|
||||
@Register(description = "REMOVE_HELP")
|
||||
public void execute(Player player, Player teamMember) {
|
||||
Commands.kick(player, teamMember.getName());
|
||||
}
|
||||
}
|
||||
|
||||
+6
-15
@@ -26,37 +26,28 @@ import de.steamwar.fightsystem.fight.FightPlayer;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.fight.JoinRequest;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentCommand;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
@Linked
|
||||
public class RequestsCommand implements CommandExecutor {
|
||||
public class RequestsCommand extends FightSWCommand {
|
||||
|
||||
public RequestsCommand() {
|
||||
new StateDependentCommand(ArenaMode.VariableTeams, FightState.AntiSpectate, "request", this);
|
||||
new StateDependentCommand(ArenaMode.VariableTeams, FightState.AntiSpectate, "requests", this);
|
||||
super(ArenaMode.VariableTeams, FightState.AntiSpectate, "request", "requests");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!(sender instanceof Player)) return false;
|
||||
Player player = (Player) sender;
|
||||
@Register
|
||||
public void execute(Player player) {
|
||||
FightPlayer fp = Fight.getFightPlayer(player);
|
||||
if (fp == null || !(fp.isLeader() || fp.isLiving())) {
|
||||
GUI.joinRequest(player);
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (Commands.checkGetLeader(player) == null) return false;
|
||||
|
||||
if (Commands.checkGetLeader(player) == null) return;
|
||||
GUI.chooseJoinRequests(player);
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void onJoinRequest(Player player, JoinRequest request, BiConsumer<JoinRequest, FightTeam> handleJoinRequest) {
|
||||
|
||||
@@ -24,32 +24,22 @@ import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.record.PacketProcessor;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentCommand;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@Linked
|
||||
public class SkipCommand implements CommandExecutor {
|
||||
public class SkipCommand extends FightSWCommand {
|
||||
|
||||
public SkipCommand() {
|
||||
new StateDependentCommand(ArenaMode.AntiPrepare, ArenaMode.Replay.contains(Config.mode) ? FightState.All : FightState.TeamFix, "skip", this);
|
||||
super(ArenaMode.AntiPrepare, ArenaMode.Replay.contains(Config.mode) ? FightState.All : FightState.TeamFix, "skip");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
return false;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
|
||||
@Register
|
||||
public void execute(Player player) {
|
||||
if (PacketProcessor.isReplaying() && player.getUniqueId().equals(Fight.getBlueTeam().getDesignatedLeader())) {
|
||||
PacketProcessor.currentReplay().skipToSubtitle();
|
||||
} else {
|
||||
Commands.toggleSkip(player);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
+5
-14
@@ -21,27 +21,18 @@ package de.steamwar.fightsystem.commands;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentCommand;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@Linked
|
||||
public class StateCommand implements CommandExecutor {
|
||||
public class StateCommand extends FightSWCommand {
|
||||
|
||||
public StateCommand() {
|
||||
new StateDependentCommand(ArenaMode.Test, FightState.All, "state", this);
|
||||
super(ArenaMode.Test, FightState.All, "state");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
GUI.state((Player) sender);
|
||||
return false;
|
||||
@Register
|
||||
public void execute(Player player) {
|
||||
GUI.state(player);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,26 +22,18 @@ package de.steamwar.fightsystem.commands;
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentCommand;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@Linked
|
||||
public class TBCommand implements CommandExecutor {
|
||||
public class TBCommand extends FightSWCommand {
|
||||
|
||||
public TBCommand() {
|
||||
new StateDependentCommand(ArenaMode.Check, FightState.All, "resettb", this);
|
||||
super(ArenaMode.Check, FightState.All, "resettb");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
return false;
|
||||
}
|
||||
@Register
|
||||
public void execute(Player player) {
|
||||
Fight.getRedTeam().pasteSchem();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
+5
-19
@@ -20,34 +20,20 @@ package de.steamwar.fightsystem.commands;
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentCommand;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@Linked
|
||||
public class TPSWarpCommand implements CommandExecutor {
|
||||
public class TPSWarpCommand extends FightSWCommand {
|
||||
|
||||
public TPSWarpCommand() {
|
||||
new StateDependentCommand(ArenaMode.Prepare, FightState.PostSchemSetup, "tpswarp", this);
|
||||
new StateDependentCommand(ArenaMode.Prepare, FightState.PostSchemSetup, "tpslimit", this);
|
||||
super(ArenaMode.Prepare, FightState.PostSchemSetup, "tpswarp", "tpslimit");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
float tps;
|
||||
try {
|
||||
tps = Float.parseFloat(args[0]);
|
||||
} catch (NumberFormatException | ArrayIndexOutOfBoundsException e) {
|
||||
FightSystem.getMessage().send("TPSWARP_HELP", sender);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Register(description = "TPSWARP_HELP")
|
||||
public void execute(Player player, float tps) {
|
||||
MinecraftServer.getServer().tickRateManager().setTickRate(tps);
|
||||
|
||||
FightSystem.getMessage().broadcastActionbar("TPSWARP_SET", tps);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
+18
-21
@@ -19,42 +19,39 @@
|
||||
|
||||
package de.steamwar.fightsystem.commands;
|
||||
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.entity.CWireframe;
|
||||
import de.steamwar.entity.REntityServer;
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import org.bukkit.Bukkit;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.OneShotStateDependent;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class TechareaCommand extends SWCommand {
|
||||
private final Map<UUID, REntityServer> servers = new HashMap<>();
|
||||
@Linked
|
||||
public class TechareaCommand extends FightSWCommand {
|
||||
private REntityServer entityServer = new REntityServer();
|
||||
|
||||
public TechareaCommand() {
|
||||
super("techarea");
|
||||
|
||||
Bukkit.getScheduler().runTaskTimer(FightSystem.getPlugin(), () -> servers.forEach((uuid, rEntityServer) -> rEntityServer.tick()), 2, 2);
|
||||
}
|
||||
|
||||
@Register
|
||||
public void genericCommand(Player player) {
|
||||
if (servers.containsKey(player.getUniqueId())) {
|
||||
servers.get(player.getUniqueId()).close();
|
||||
} else {
|
||||
super(ArenaMode.Check, FightState.All, "techarea");
|
||||
new OneShotStateDependent(ArenaMode.Check, FightState.All, () -> {
|
||||
if (!entityServer.getEntities().isEmpty()) return;
|
||||
REntityServer server = new REntityServer();
|
||||
CWireframe wireframe = new CWireframe(server);
|
||||
|
||||
wireframe.setPos1(Config.BlueInsetRegion.getMinLocation(Config.world));
|
||||
wireframe.setPos2(Config.BlueInsetRegion.getMaxLocation(Config.world).subtract(1, 1, 1));
|
||||
wireframe.setBlock(Material.RED_CONCRETE.createBlockData());
|
||||
});
|
||||
}
|
||||
|
||||
server.addPlayer(player);
|
||||
servers.put(player.getUniqueId(), server);
|
||||
@Register
|
||||
public void genericCommand(Player player) {
|
||||
if (entityServer.getPlayers().contains(player)) {
|
||||
entityServer.removePlayer(player);
|
||||
} else {
|
||||
entityServer.addPlayer(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+6
-10
@@ -25,27 +25,24 @@ import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentCommand;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.sql.SWException;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.StringWriter;
|
||||
import java.util.Arrays;
|
||||
import java.util.logging.Level;
|
||||
|
||||
@Linked
|
||||
public class TechhiderbugCommand implements CommandExecutor {
|
||||
public class TechhiderbugCommand extends FightSWCommand {
|
||||
|
||||
public TechhiderbugCommand() {
|
||||
new StateDependentCommand(ArenaMode.All, FightState.All, "techhiderbug", this);
|
||||
super(ArenaMode.All, FightState.All, "techhiderbug");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String alias, String[] args) {
|
||||
@Register
|
||||
public void execute(Player player, String... args) {
|
||||
StringWriter writer = new StringWriter();
|
||||
|
||||
try {
|
||||
@@ -76,7 +73,6 @@ public class TechhiderbugCommand implements CommandExecutor {
|
||||
Bukkit.getLogger().log(Level.SEVERE, "Error while generating bug report", e);
|
||||
}
|
||||
|
||||
SWException.log("Techhider-Bug reported by " + sender.getName() + ": " + Arrays.toString(args), writer.toString());
|
||||
return false;
|
||||
SWException.log("Techhider-Bug reported by " + player.getName() + ": " + Arrays.toString(args), writer.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,28 +23,20 @@ import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightWorld;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentCommand;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@Linked
|
||||
public class WGCommand implements CommandExecutor {
|
||||
public class WGCommand extends FightSWCommand {
|
||||
|
||||
public WGCommand() {
|
||||
new StateDependentCommand(ArenaMode.Check, FightState.All, "resetwg", this);
|
||||
super(ArenaMode.Check, FightState.All, "resetwg");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
return false;
|
||||
}
|
||||
@Register
|
||||
public void execute(Player player) {
|
||||
FightWorld.resetWorld();
|
||||
Fight.getBlueTeam().pasteSchem();
|
||||
Fight.getRedTeam().pasteSchem();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,49 +25,34 @@ import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentCommand;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@Linked
|
||||
public class WinCommand implements CommandExecutor {
|
||||
public class WinCommand extends FightSWCommand {
|
||||
|
||||
public WinCommand() {
|
||||
new StateDependentCommand(ArenaMode.Event, FightState.Ingame, "win", this);
|
||||
super(ArenaMode.Event, FightState.Ingame, "win");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
return false;
|
||||
}
|
||||
Player p = (Player) sender;
|
||||
protected boolean hasPerm(Player player, SteamwarUser user) {
|
||||
return Config.isReferee(player);
|
||||
}
|
||||
|
||||
if (!Config.isReferee(p)) {
|
||||
FightSystem.getMessage().sendPrefixless("NOT_FIGHTLEADER", p, ChatMessageType.ACTION_BAR);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (args.length == 0) {
|
||||
FightSystem.getMessage().sendPrefixless("WIN_HELP", p);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("tie")) {
|
||||
@Register
|
||||
public void execute(@Validator Player player, String teamName) {
|
||||
if (teamName.equalsIgnoreCase("tie")) {
|
||||
FightSystem.setSpectateState(null, "Referee", "WIN_FIGHTLEADER");
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
|
||||
for (FightTeam team : Fight.teams()) {
|
||||
if (args[0].equalsIgnoreCase(team.getName())) {
|
||||
if (teamName.equalsIgnoreCase(team.getName())) {
|
||||
FightSystem.setSpectateState(team, "Referee", "WIN_FIGHTLEADER");
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,6 +51,10 @@ public class Check implements Listener {
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
if (gameModeConfig == null) gameModeConfig = GameModeConfig.getDefaults();
|
||||
return checkPermission(user, gameModeConfig);
|
||||
}
|
||||
|
||||
public static boolean checkPermission(SteamwarUser user, GameModeConfig gameModeConfig) {
|
||||
if (user.hasPerm(UserPerm.ADMINISTRATION)) return true;
|
||||
if (gameModeConfig.Checkers.isEmpty() && user.hasPerm(UserPerm.CHECK)) return true;
|
||||
return gameModeConfig.Checkers.contains(user.getId());
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@
|
||||
package de.steamwar.fightsystem.record;
|
||||
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import de.steamwar.core.WorldEditWrapper;
|
||||
import de.steamwar.core.worldedit.WorldEditWrapper;
|
||||
import de.steamwar.entity.REntity;
|
||||
import de.steamwar.entity.REntityServer;
|
||||
import de.steamwar.entity.RPlayer;
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
package de.steamwar.fightsystem.states;
|
||||
|
||||
import de.steamwar.fightsystem.commands.FightSWCommand;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.*;
|
||||
@@ -62,6 +63,7 @@ public enum FightState {
|
||||
}
|
||||
|
||||
public static void setFightState(FightState state) {
|
||||
if (fightState.equals(state)) return;
|
||||
fightState = state;
|
||||
|
||||
for (Map.Entry<IStateDependent, Boolean> feature : stateDependentFeatures.entrySet()) {
|
||||
@@ -77,6 +79,7 @@ public enum FightState {
|
||||
feature.setValue(false);
|
||||
}
|
||||
}
|
||||
FightSWCommand.postFightStateChange();
|
||||
}
|
||||
|
||||
public static boolean setup() {
|
||||
|
||||
-58
@@ -1,58 +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.states;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public class StateDependentCommand extends StateDependent {
|
||||
|
||||
private static final CommandExecutor unavailable = (sender, cmd, s, strings) -> {
|
||||
FightSystem.getMessage().sendPrefixless("COMMAND_CURRENTLY_UNAVAILABLE", sender, ChatMessageType.ACTION_BAR);
|
||||
return false;
|
||||
};
|
||||
|
||||
private final PluginCommand command;
|
||||
private final CommandExecutor executor;
|
||||
|
||||
public StateDependentCommand(Set<ArenaMode> mode, Set<FightState> states, String name, CommandExecutor executor) {
|
||||
super(mode, states);
|
||||
this.executor = executor;
|
||||
this.command = FightSystem.getPlugin().getCommand(name);
|
||||
assert command != null;
|
||||
disable();
|
||||
register();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enable() {
|
||||
command.setExecutor(executor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable() {
|
||||
command.setExecutor(unavailable);
|
||||
}
|
||||
}
|
||||
@@ -10,22 +10,4 @@ depend:
|
||||
- WorldEdit
|
||||
api-version: "1.13"
|
||||
|
||||
commands:
|
||||
ak:
|
||||
request:
|
||||
requests:
|
||||
fightinfo:
|
||||
leave:
|
||||
ready:
|
||||
kit:
|
||||
remove:
|
||||
lockschem:
|
||||
state:
|
||||
skip:
|
||||
win:
|
||||
resetwg:
|
||||
resettb:
|
||||
tpslimit:
|
||||
tpswarp:
|
||||
techhiderbug:
|
||||
unrank:
|
||||
commands:
|
||||
@@ -53,3 +53,15 @@ tasks.register<FightServer>("WarGear21") {
|
||||
config = "WarGear21.yml"
|
||||
jar = "/jars/paper-1.21.6.jar"
|
||||
}
|
||||
|
||||
tasks.register<FightServer>("WarShip21") {
|
||||
group = "run"
|
||||
description = "Run a WarShip 1.21 Fight Server"
|
||||
dependsOn(":SpigotCore:shadowJar")
|
||||
dependsOn(":FightSystem:shadowJar")
|
||||
dependsOn(":KotlinCore:shadowJar")
|
||||
template = "WarShip21"
|
||||
worldName = "arenas/Artic"
|
||||
config = "WarShip21.yml"
|
||||
jar = "/jars/paper-1.21.6.jar"
|
||||
}
|
||||
|
||||
@@ -80,9 +80,12 @@ public class CustomMap implements Listener {
|
||||
|
||||
if (mapFileOrDirectory.isDirectory()) {
|
||||
AtomicReference<Month> lastMonth = new AtomicReference<>(LocalDateTime.now().getMonth());
|
||||
AtomicReference<Long> lastModified = new AtomicReference<>(Long.MAX_VALUE);
|
||||
Bukkit.getScheduler().runTaskTimer(LobbySystem.getInstance(), () -> {
|
||||
long modified = mapFileOrDirectory.lastModified();
|
||||
Month current = LocalDateTime.now().getMonth();
|
||||
if (!current.equals(lastMonth.get()) || update) {
|
||||
if (modified > lastModified.get() || !current.equals(lastMonth.get()) || update) {
|
||||
lastModified.set(modified);
|
||||
lastMonth.set(current);
|
||||
update = false;
|
||||
this.mapFile = new File(mapFileOrDirectory, current.getValue() + ".png");
|
||||
|
||||
@@ -108,19 +108,33 @@ UNNOSCHEMSUBMITTING = §e{0} §7may now submit §e§lschematics§7 again§8.
|
||||
|
||||
WORLDEDIT_CUI_TITLE = WorldEdit CUI
|
||||
WORLDEDIT_CUI_TITLE_SUBMENU = WorldEdit CUI - {0}
|
||||
WORLDEDIT_CUI_SELECTION = Own Selection
|
||||
WORLDEDIT_CUI_CLIPBOARD = Own Clipboard
|
||||
WORLDEDIT_CUI_SELECTION_OTHER = Other Selection
|
||||
WORLDEDIT_CUI_CLIPBOARD_OTHER = Other Clipboard
|
||||
WORLDEDIT_CUI_SELECTION = Selection
|
||||
WORLDEDIT_CUI_CLIPBOARD = Clipboard
|
||||
WORLDEDIT_CUI_CURSOR = Cursor
|
||||
|
||||
WORLDEDIT_CUI_MATERIAL_NAME = §eWorldEdit {0}
|
||||
WORLDEDIT_CUI_MATERIAL_CLICK = §7Click to edit
|
||||
|
||||
WORLDEDIT_CUI_WIDTH_NAME = §eWidth {0}
|
||||
WORLDEDIT_CUI_WIDTH_NAME_DIST = §eRange {0}
|
||||
WORLDEDIT_CUI_WIDTH_LORE = §8> §7{0}
|
||||
WORLDEDIT_CUI_WIDTH_LORE_SELECTED = §8> §e{0}
|
||||
WORLDEDIT_CUI_WIDTH_CLICK = §7Click to change
|
||||
|
||||
WORLDEDIT_CUI_WIDTH_HUGE = 1/ 8 Block
|
||||
WORLDEDIT_CUI_WIDTH_LARGE = 1/16 Block
|
||||
WORLDEDIT_CUI_WIDTH_MEDIUM = 1/32 Block
|
||||
WORLDEDIT_CUI_WIDTH_SLIM = 1/64 Block
|
||||
WORLDEDIT_CUI_WIDTH_SLIM = 1/64 Block
|
||||
|
||||
WORLDEDIT_CUI_WIDTH_HUGE_DIST = 40 Blocks
|
||||
WORLDEDIT_CUI_WIDTH_LARGE_DIST = 30 Blocks
|
||||
WORLDEDIT_CUI_WIDTH_MEDIUM_DIST = 20 Blocks
|
||||
WORLDEDIT_CUI_WIDTH_SLIM_DIST = 10 Blocks
|
||||
|
||||
WORLDEDIT_CUI_TOOL_SOON = §7Tool cooming soon!
|
||||
WORLDEDIT_CUI_TOOL_COPY = §eCopy Tool
|
||||
WORLDEDIT_CUI_TOOL_COPY_LORE = §eClick§8:§7 copy selection
|
||||
WORLDEDIT_CUI_TOOL_PASTE = §ePaste Tool
|
||||
WORLDEDIT_CUI_TOOL_PASTE_LORE_1 = §eClick§8:§7 paste clipboard
|
||||
WORLDEDIT_CUI_TOOL_PASTE_LORE_2 = §eShift §8+§e Click§8:§7 paste clipboard and select
|
||||
WORLDEDIT_CUI_TOOL_PASTE_LORE_3 = §eDrop§8:§7 paste clipboard at copy origin
|
||||
@@ -101,13 +101,20 @@ NOSCHEMSUBMITTING_UNTIL = §7Du bist §ebis zum {0} §7vom §e§lEinsenden von S
|
||||
UNNOSCHEMSUBMITTING_ERROR = §cDer Spieler ist nicht vom Einsenden von Schematics ausgeschlossen.
|
||||
UNNOSCHEMSUBMITTING = §e{0} §7darf nun wieder §e§lSchematis§7 einsenden§8.
|
||||
|
||||
WORLDEDIT_CUI_SELECTION = Eigene Auswahl
|
||||
WORLDEDIT_CUI_CLIPBOARD = Eigene Kopie
|
||||
WORLDEDIT_CUI_SELECTION_OTHER = Auswahl Anderer
|
||||
WORLDEDIT_CUI_CLIPBOARD_OTHER = Kopie Anderer
|
||||
WORLDEDIT_CUI_SELECTION = Auswahl
|
||||
WORLDEDIT_CUI_CLIPBOARD = Kopie
|
||||
|
||||
WORLDEDIT_CUI_MATERIAL_NAME = §eWorldEdit {0}
|
||||
WORLDEDIT_CUI_MATERIAL_CLICK = §7Klicke zum Editieren
|
||||
|
||||
WORLDEDIT_CUI_WIDTH_NAME = §eDicke - {0}
|
||||
WORLDEDIT_CUI_WIDTH_CLICK = §7Klicke zum ändern
|
||||
WORLDEDIT_CUI_WIDTH_NAME = §eKlicke - {0}
|
||||
WORLDEDIT_CUI_WIDTH_NAME_DIST = Reichweite§e {0}
|
||||
WORLDEDIT_CUI_WIDTH_CLICK = §7Klicke zum ändern
|
||||
|
||||
WORLDEDIT_CUI_TOOL_SOON = §7Werkzeug kommt in kürze!
|
||||
WORLDEDIT_CUI_TOOL_COPY = §eCopy Werkzeug
|
||||
WORLDEDIT_CUI_TOOL_COPY_LORE = §eKlick§8:§7 Auswahl zu kopieren
|
||||
WORLDEDIT_CUI_TOOL_PASTE = §ePaste Werkzeug
|
||||
WORLDEDIT_CUI_TOOL_PASTE_LORE_1 = §eKlick§8:§7 Clipboard einzufügen
|
||||
WORLDEDIT_CUI_TOOL_PASTE_LORE_2 = §eUmschalt §8+§e Klick§8:§7 Clipboard einzufügen und auszuwählen
|
||||
WORLDEDIT_CUI_TOOL_PASTE_LORE_3 = §eDrop§8:§7 Clipboard am Kopierpunkt einzufügen
|
||||
@@ -21,8 +21,8 @@ package de.steamwar.core;
|
||||
|
||||
import de.steamwar.message.Message;
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import lombok.NonNull;
|
||||
import lombok.experimental.Delegate;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -99,11 +99,11 @@ public class SWPlayer {
|
||||
|
||||
@Data
|
||||
public static final class SWPlayerWithComponent<T extends Component> {
|
||||
private final SWPlayer player;
|
||||
private final SWPlayer swPlayer;
|
||||
private final T component;
|
||||
}
|
||||
|
||||
@Delegate
|
||||
@Getter
|
||||
private final Player player;
|
||||
private final Map<Class<? extends Component>, Component> components = new HashMap<>();
|
||||
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* 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.core.worldedit;
|
||||
|
||||
import de.steamwar.command.SWCommand;
|
||||
import lombok.experimental.UtilityClass;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.function.Function;
|
||||
|
||||
@UtilityClass
|
||||
public class SteamEdit {
|
||||
|
||||
private static final AtomicBoolean INITIALIZED = new AtomicBoolean();
|
||||
|
||||
public static void init() {
|
||||
INITIALIZED.set(true);
|
||||
new Command();
|
||||
new SteamEditWand();
|
||||
new WorldEditRendererCUIEditor();
|
||||
}
|
||||
|
||||
public boolean isInitialized() {
|
||||
return INITIALIZED.get();
|
||||
}
|
||||
|
||||
public static Function<Location, AdjacentFilter> ADJACENT_FILTERS = location -> AdjacentFilter.ALWAYS;
|
||||
|
||||
public interface AdjacentFilter {
|
||||
AdjacentFilter ALWAYS = (x, y, z) -> true;
|
||||
|
||||
boolean contains(int x, int y, int z);
|
||||
}
|
||||
|
||||
private static final class Command extends SWCommand {
|
||||
|
||||
public Command() {
|
||||
super("steamwand", "steamedit", "steameditwand", "swwand", "sweditwand", "swedit");
|
||||
}
|
||||
|
||||
@Register
|
||||
public void get(Player player) {
|
||||
if (player.getInventory().contains(SteamEditWand.ITEM)) {
|
||||
player.getInventory().remove(SteamEditWand.ITEM);
|
||||
}
|
||||
ItemStack handItem = player.getInventory().getItemInMainHand();
|
||||
player.getInventory().setItemInMainHand(SteamEditWand.ITEM);
|
||||
if (!handItem.isEmpty()) {
|
||||
player.getInventory().addItem(handItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+117
@@ -0,0 +1,117 @@
|
||||
/*
|
||||
* 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.core.worldedit;
|
||||
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import de.steamwar.core.Core;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class SteamEditSelectAdjacent {
|
||||
|
||||
private static final BlockFace[] FACES = {
|
||||
BlockFace.NORTH,
|
||||
BlockFace.SOUTH,
|
||||
BlockFace.EAST,
|
||||
BlockFace.WEST,
|
||||
BlockFace.UP,
|
||||
BlockFace.DOWN,
|
||||
};
|
||||
|
||||
private Location min;
|
||||
private Location max;
|
||||
|
||||
private SteamEdit.AdjacentFilter filter;
|
||||
|
||||
private LinkedHashSet<Location> frontier = new LinkedHashSet<>();
|
||||
|
||||
public SteamEditSelectAdjacent(Location origin) {
|
||||
// TODO: Fix the flood fill algorithm!
|
||||
min = origin.clone();
|
||||
max = origin.clone();
|
||||
frontier.add(origin);
|
||||
filter = SteamEdit.ADJACENT_FILTERS.apply(origin);
|
||||
|
||||
long time = System.currentTimeMillis();
|
||||
for (int i = 0; i < 500_000 && !frontier.isEmpty(); i++) {
|
||||
if (System.currentTimeMillis() - time > 1000) break;
|
||||
expandNext();
|
||||
}
|
||||
|
||||
Core.getInstance().getLogger().finer(System.currentTimeMillis() - time + "ms " + frontier.size() + " " + min + " to " + max);
|
||||
}
|
||||
|
||||
public BlockVector3 pos1() {
|
||||
return BlockVector3.at(min.getBlockX(), min.getBlockY(), min.getBlockZ());
|
||||
}
|
||||
|
||||
public BlockVector3 pos2() {
|
||||
return BlockVector3.at(max.getBlockX(), max.getBlockY(), max.getBlockZ());
|
||||
}
|
||||
|
||||
private boolean inside(Location loc, int offset) {
|
||||
return loc.getBlockX() >= min.getBlockX() + offset && loc.getBlockX() <= max.getBlockX() - offset &&
|
||||
loc.getBlockY() >= min.getBlockY() + offset && loc.getBlockY() <= max.getBlockY() - offset &&
|
||||
loc.getBlockZ() >= min.getBlockZ() + offset && loc.getBlockZ() <= max.getBlockZ() - offset;
|
||||
}
|
||||
|
||||
public void expandNext() {
|
||||
Location location = frontier.removeFirst();
|
||||
expand(location);
|
||||
}
|
||||
|
||||
private void expand(Location loc) {
|
||||
for (BlockFace face : FACES) {
|
||||
Vector direction = face.getDirection();
|
||||
Location location = loc.clone().add(direction);
|
||||
if (!filter.contains(location.getBlockX(), location.getBlockY(), location.getBlockZ())) continue;
|
||||
if (inside(location, 0)) continue;
|
||||
List<Location> layer = Stream.concat(selectFrontier(direction.getBlockX() == 0 ? null : loc.getBlockX(), direction.getBlockY() == 0 ? null : loc.getBlockY(), direction.getBlockZ() == 0 ? null : loc.getBlockZ())
|
||||
.map(Location::clone)
|
||||
.map(l -> l.add(direction)), Stream.of(location))
|
||||
.filter(l -> !l.getBlock().isEmpty())
|
||||
.filter(l -> !l.getBlock().isLiquid())
|
||||
.toList();
|
||||
if (layer.isEmpty()) continue;
|
||||
|
||||
if (direction.getBlockX() < 0 || direction.getBlockY() < 0 || direction.getBlockZ() < 0) {
|
||||
min.add(direction);
|
||||
} else {
|
||||
max.add(direction);
|
||||
}
|
||||
layer.stream().filter(l -> !inside(l, 1))
|
||||
.filter(l -> filter.contains(l.getBlockX(), l.getBlockY(), l.getBlockZ()))
|
||||
.forEach(frontier::add);
|
||||
}
|
||||
}
|
||||
|
||||
private Stream<Location> selectFrontier(Integer x, Integer y, Integer z) {
|
||||
Stream<Location> stream = frontier.stream();
|
||||
if (x != null) stream = stream.filter(loc -> loc.getBlockX() == x);
|
||||
if (y != null) stream = stream.filter(loc -> loc.getBlockY() == y);
|
||||
if (z != null) stream = stream.filter(loc -> loc.getBlockZ() == z);
|
||||
return stream;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,409 @@
|
||||
/*
|
||||
* 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.core.worldedit;
|
||||
|
||||
import com.comphenix.tinyprotocol.TinyProtocol;
|
||||
import com.sk89q.worldedit.IncompleteRegionException;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.RegionSelector;
|
||||
import com.sk89q.worldedit.regions.selector.limit.PermissiveSelectorLimits;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import de.steamwar.core.Core;
|
||||
import de.steamwar.core.SWPlayer;
|
||||
import de.steamwar.entity.CWireframe;
|
||||
import de.steamwar.entity.REntityServer;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.network.protocol.Packet;
|
||||
import net.minecraft.network.protocol.game.*;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.FluidCollisionMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.InventoryType;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
import org.bukkit.util.RayTraceResult;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SteamEditWand implements Listener {
|
||||
|
||||
public static final Material MATERIAL = Material.GOLDEN_AXE;
|
||||
public static final String NAME = "§eSteam§8Edit §7Wand";
|
||||
public static final String[] LORE = {
|
||||
"§eL-Click§8: §7Set Pos1",
|
||||
"§eR-Click§8: §7Set Pos2",
|
||||
"§eShift §8+ §eR-Click§8: §7Set Pos2 or Expand Selection",
|
||||
"§eM-Click§8: §7Select connected",
|
||||
"§eSwap-Hands§8: §7Open CUI"
|
||||
};
|
||||
public static final ItemStack ITEM = new SWItem(MATERIAL, NAME).setLore(LORE).getItemStack();
|
||||
|
||||
private boolean noWand(Player player) {
|
||||
return player.getInventory().getItemInMainHand().getType() != SteamEditWand.MATERIAL;
|
||||
}
|
||||
|
||||
private final WorldEditPlugin we;
|
||||
|
||||
SteamEditWand() {
|
||||
we = WorldEditWrapper.getWorldEditPlugin();
|
||||
Bukkit.getPluginManager().registerEvents(this, Core.getInstance());
|
||||
|
||||
TinyProtocol.instance.addFilter(ServerboundSwingPacket.class, this::leftClick);
|
||||
TinyProtocol.instance.addFilter(ServerboundInteractPacket.class, (player, packet) -> {
|
||||
if (packet.isAttack()) {
|
||||
return leftClick(player, packet);
|
||||
} else {
|
||||
return rightClick(player, packet);
|
||||
}
|
||||
});
|
||||
TinyProtocol.instance.addFilter(ServerboundUseItemPacket.class, this::rightClick);
|
||||
TinyProtocol.instance.addFilter(ServerboundUseItemOnPacket.class, this::rightClick);
|
||||
TinyProtocol.instance.addFilter(ServerboundPickItemFromBlockPacket.class, this::middleClick);
|
||||
TinyProtocol.instance.addFilter(ServerboundPlayerActionPacket.class, this::swapHands);
|
||||
TinyProtocol.instance.addFilter(ServerboundMovePlayerPacket.Pos.class, this::movePlayerPacket);
|
||||
TinyProtocol.instance.addFilter(ServerboundMovePlayerPacket.Rot.class, this::movePlayerPacket);
|
||||
TinyProtocol.instance.addFilter(ServerboundMovePlayerPacket.PosRot.class, this::movePlayerPacket);
|
||||
|
||||
Bukkit.getScheduler().runTaskTimer(Core.getInstance(), () -> {
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
if (noWand(player)) SWPlayer.of(player).removeComponent(SWEditCursor.class);
|
||||
}
|
||||
}, 1, 1);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||
if (noWand(event.getPlayer())) return;
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
public static class SWEditCursor implements SWPlayer.Component {
|
||||
private Player player;
|
||||
private REntityServer entityServer = new REntityServer();
|
||||
private CWireframe wireframe;
|
||||
|
||||
@Override
|
||||
public void onMount(SWPlayer player) {
|
||||
this.player = player.getPlayer();
|
||||
entityServer.addPlayer(player.getPlayer());
|
||||
wireframe = new CWireframe(entityServer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUnmount(SWPlayer player) {
|
||||
entityServer.close();
|
||||
}
|
||||
|
||||
public void setLocation(Location location) {
|
||||
wireframe.setPos1And2(location, location);
|
||||
wireframe.setBlock(WorldEditRendererCUIEditor.Type.CURSOR.getMaterial(player).createBlockData());
|
||||
}
|
||||
}
|
||||
|
||||
private Packet<?> leftClick(Player player, Packet<?> packet) {
|
||||
if (noWand(player)) return packet;
|
||||
if (player.getOpenInventory().getType() != InventoryType.CREATIVE) return packet;
|
||||
double distance = WorldEditRendererCUIEditor.Type.CURSOR.getWidth(player).blocks;
|
||||
RayTraceResult result = player.rayTraceBlocks(distance, FluidCollisionMode.NEVER);
|
||||
if (result == null) return packet;
|
||||
Block block = result.getHitBlock();
|
||||
if (block == null) return packet;
|
||||
BlockVector3 pos1 = BlockVector3.at(block.getX(), block.getY(), block.getZ());
|
||||
setPos1(player, pos1);
|
||||
return null;
|
||||
}
|
||||
|
||||
private void setPos1(Player player, BlockVector3 pos1) {
|
||||
LocalSession session = we.getSession(player);
|
||||
World world = session.getSelectionWorld();
|
||||
if (world == null) return;
|
||||
selectPos1(session.getRegionSelector(world), player, session, pos1);
|
||||
}
|
||||
|
||||
private Packet<?> rightClick(Player player, Packet<?> packet) {
|
||||
if (noWand(player)) return packet;
|
||||
double distance = WorldEditRendererCUIEditor.Type.CURSOR.getWidth(player).blocks;
|
||||
RayTraceResult result = player.rayTraceBlocks(distance, FluidCollisionMode.NEVER);
|
||||
if (result == null) return packet;
|
||||
Block block = result.getHitBlock();
|
||||
if (block == null) return packet;
|
||||
BlockVector3 pos2 = BlockVector3.at(block.getX(), block.getY(), block.getZ());
|
||||
if (!player.isSneaking()) {
|
||||
setPos2(player, pos2);
|
||||
} else {
|
||||
setPos2OrExpand(player, pos2);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void setPos2(Player player, BlockVector3 pos2) {
|
||||
LocalSession session = we.getSession(player);
|
||||
World world = session.getSelectionWorld();
|
||||
if (world == null) return;
|
||||
selectPos2(session.getRegionSelector(world), player, session, pos2);
|
||||
}
|
||||
|
||||
private void setPos2OrExpand(Player player, BlockVector3 expand) {
|
||||
LocalSession session = we.getSession(player);
|
||||
World world = session.getSelectionWorld();
|
||||
if (world == null) return;
|
||||
RegionSelector regionSelector = session.getRegionSelector(world);
|
||||
|
||||
// Only primary set for now
|
||||
if (!regionSelector.isDefined()) {
|
||||
selectPos2(session.getRegionSelector(world), player, session, expand);
|
||||
return;
|
||||
}
|
||||
|
||||
List<BlockVector3> vertices = regionSelector.getVertices();
|
||||
// Probably not a cuboid selection!
|
||||
if (vertices.size() > 2) {
|
||||
selectPos2(session.getRegionSelector(world), player, session, expand);
|
||||
return;
|
||||
}
|
||||
|
||||
BlockVector3 pos1 = vertices.get(0);
|
||||
BlockVector3 pos2 = vertices.get(1);
|
||||
|
||||
BlockVector3 min = pos1.getMinimum(pos2);
|
||||
BlockVector3 max = pos1.getMaximum(pos2);
|
||||
if (expand.containedWithin(pos1, pos2)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Closer x = Closer.UNKNOWN;
|
||||
Closer y = Closer.UNKNOWN;
|
||||
Closer z = Closer.UNKNOWN;
|
||||
|
||||
boolean insideX = min.x() < expand.x() && max.x() > expand.x();
|
||||
boolean insideY = min.y() < expand.y() && max.y() > expand.y();
|
||||
boolean insideZ = min.z() < expand.z() && max.z() > expand.z();
|
||||
|
||||
if (insideX) {
|
||||
// No Change needed
|
||||
} else if (Math.abs(pos1.x() - expand.x()) > Math.abs(pos2.x() - expand.x())) {
|
||||
x = Closer.POS2;
|
||||
} else if (Math.abs(pos1.x() - expand.x()) < Math.abs(pos2.x() - expand.x())) {
|
||||
x = Closer.POS1;
|
||||
}
|
||||
|
||||
if (insideY) {
|
||||
// No Change needed
|
||||
} else if (Math.abs(pos1.y() - expand.y()) > Math.abs(pos2.y() - expand.y())) {
|
||||
y = Closer.POS2;
|
||||
} else if (Math.abs(pos1.y() - expand.y()) < Math.abs(pos2.y() - expand.y())) {
|
||||
y = Closer.POS1;
|
||||
}
|
||||
|
||||
if (insideZ) {
|
||||
// No Change needed
|
||||
} else if (Math.abs(pos1.z() - expand.z()) > Math.abs(pos2.z() - expand.z())) {
|
||||
z = Closer.POS2;
|
||||
} else if (Math.abs(pos1.z() - expand.z()) < Math.abs(pos2.z() - expand.z())) {
|
||||
z = Closer.POS1;
|
||||
}
|
||||
|
||||
Closer x1 = Closer.UNKNOWN;
|
||||
Closer y1 = Closer.UNKNOWN;
|
||||
Closer z1 = Closer.UNKNOWN;
|
||||
|
||||
if (!insideX && pos1.x() != expand.x() && pos2.x() != expand.x() && x == Closer.UNKNOWN) {
|
||||
x1 = y.and(z).or(Closer.POS1);
|
||||
}
|
||||
if (!insideY && pos1.y() != expand.y() && pos2.y() != expand.y() && y == Closer.UNKNOWN) {
|
||||
y1 = x.and(z).or(Closer.POS1);
|
||||
}
|
||||
if (!insideZ && pos1.z() != expand.z() && pos2.z() != expand.z() && z == Closer.UNKNOWN) {
|
||||
z1 = x.and(y).or(Closer.POS1);
|
||||
}
|
||||
|
||||
if (x1 != Closer.UNKNOWN) x = x1;
|
||||
if (y1 != Closer.UNKNOWN) y = y1;
|
||||
if (z1 != Closer.UNKNOWN) z = z1;
|
||||
|
||||
boolean p1updated = false;
|
||||
boolean p2updated = false;
|
||||
|
||||
if (x == Closer.POS1) {
|
||||
pos1 = pos1.withX(expand.x());
|
||||
p1updated = true;
|
||||
} else if (x == Closer.POS2) {
|
||||
pos2 = pos2.withX(expand.x());
|
||||
p2updated = true;
|
||||
}
|
||||
|
||||
if (y == Closer.POS1) {
|
||||
pos1 = pos1.withY(expand.y());
|
||||
p1updated = true;
|
||||
} else if (y == Closer.POS2) {
|
||||
pos2 = pos2.withY(expand.y());
|
||||
p2updated = true;
|
||||
}
|
||||
|
||||
if (z == Closer.POS1) {
|
||||
pos1 = pos1.withZ(expand.z());
|
||||
p1updated = true;
|
||||
} else if (z == Closer.POS2) {
|
||||
pos2 = pos2.withZ(expand.z());
|
||||
p2updated = true;
|
||||
}
|
||||
|
||||
if (p1updated) selectPos1(session.getRegionSelector(world), player, session, pos1);
|
||||
if (p2updated) selectPos2(session.getRegionSelector(world), player, session, pos2);
|
||||
}
|
||||
|
||||
private enum Closer {
|
||||
POS1,
|
||||
POS2,
|
||||
UNKNOWN,
|
||||
;
|
||||
|
||||
public Closer and(Closer closer) {
|
||||
if (this == closer) {
|
||||
return this;
|
||||
} else if (this == UNKNOWN) {
|
||||
return closer;
|
||||
} else if (closer == UNKNOWN) {
|
||||
return this;
|
||||
} else {
|
||||
return UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
public Closer or(Closer closer) {
|
||||
if (this == UNKNOWN) return closer;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
private ServerboundPickItemFromBlockPacket middleClick(Player player, ServerboundPickItemFromBlockPacket packet) {
|
||||
if (noWand(player)) return packet;
|
||||
LocalSession session = we.getSession(player);
|
||||
World world = session.getSelectionWorld();
|
||||
if (world == null) return packet;
|
||||
RegionSelector regionSelector = session.getRegionSelector(world);
|
||||
BlockPos pos = packet.pos();
|
||||
SteamEditSelectAdjacent selector = new SteamEditSelectAdjacent(new Location(player.getWorld(), pos.getX(), pos.getY(), pos.getZ()));
|
||||
selectPos1(regionSelector, player, session, selector.pos1());
|
||||
selectPos2(regionSelector, player, session, selector.pos2());
|
||||
return null;
|
||||
}
|
||||
|
||||
private static class Pos1Message implements SWPlayer.Component {
|
||||
private BukkitTask task;
|
||||
|
||||
public Pos1Message(RegionSelector regionSelector, Player player, LocalSession session, BlockVector3 pos1) {
|
||||
task = Bukkit.getScheduler().runTaskLater(Core.getInstance(), () -> {
|
||||
regionSelector.explainPrimarySelection(BukkitAdapter.adapt(player), session, pos1);
|
||||
SWPlayer.of(player).removeComponent(Pos1Message.class);
|
||||
}, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUnmount(SWPlayer player) {
|
||||
task.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
private void selectPos1(RegionSelector regionSelector, Player player, LocalSession session, BlockVector3 pos1) {
|
||||
try {
|
||||
if (!pos1.equals(regionSelector.getPrimaryPosition())) {
|
||||
SWPlayer.of(player).setComponent(new Pos1Message(regionSelector, player, session, pos1));
|
||||
}
|
||||
} catch (IncompleteRegionException e) {
|
||||
SWPlayer.of(player).setComponent(new Pos1Message(regionSelector, player, session, pos1));
|
||||
}
|
||||
regionSelector.selectPrimary(pos1, PermissiveSelectorLimits.getInstance());
|
||||
WorldEditRenderer.renderPlayer(player);
|
||||
}
|
||||
|
||||
private static class Pos2Message implements SWPlayer.Component {
|
||||
private BukkitTask task;
|
||||
|
||||
public Pos2Message(RegionSelector regionSelector, Player player, LocalSession session, BlockVector3 pos2) {
|
||||
task = Bukkit.getScheduler().runTaskLater(Core.getInstance(), () -> {
|
||||
regionSelector.explainSecondarySelection(BukkitAdapter.adapt(player), session, pos2);
|
||||
SWPlayer.of(player).removeComponent(Pos1Message.class);
|
||||
}, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUnmount(SWPlayer player) {
|
||||
task.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
private void selectPos2(RegionSelector regionSelector, Player player, LocalSession session, BlockVector3 pos2) {
|
||||
try {
|
||||
if (regionSelector.getVertices().size() == 2 && !pos2.equals(regionSelector.getVertices().get(1))) {
|
||||
SWPlayer.of(player).setComponent(new Pos2Message(regionSelector, player, session, pos2));
|
||||
}
|
||||
} catch (IncompleteRegionException e) {
|
||||
SWPlayer.of(player).setComponent(new Pos2Message(regionSelector, player, session, pos2));
|
||||
}
|
||||
regionSelector.selectSecondary(pos2, PermissiveSelectorLimits.getInstance());
|
||||
WorldEditRenderer.renderPlayer(player);
|
||||
}
|
||||
|
||||
private ServerboundPlayerActionPacket swapHands(Player player, ServerboundPlayerActionPacket packet) {
|
||||
if (noWand(player)) return packet;
|
||||
if (packet.getAction() != ServerboundPlayerActionPacket.Action.SWAP_ITEM_WITH_OFFHAND) return packet;
|
||||
Bukkit.getScheduler().runTask(Core.getInstance(), () -> {
|
||||
WorldEditRendererCUIEditor.open(player, true);
|
||||
});
|
||||
return null;
|
||||
}
|
||||
|
||||
public ServerboundMovePlayerPacket movePlayerPacket(Player player, ServerboundMovePlayerPacket packet) {
|
||||
SWPlayer swPlayer = SWPlayer.of(player);
|
||||
|
||||
if (noWand(player)) {
|
||||
swPlayer.removeComponent(SWEditCursor.class);
|
||||
return packet;
|
||||
}
|
||||
|
||||
double distance = WorldEditRendererCUIEditor.Type.CURSOR.getWidth(player).blocks;
|
||||
RayTraceResult result = player.rayTraceBlocks(distance, FluidCollisionMode.NEVER);
|
||||
Block block = result == null ? null : result.getHitBlock();
|
||||
if (result == null || block == null) {
|
||||
swPlayer.removeComponent(SWEditCursor.class);
|
||||
return packet;
|
||||
}
|
||||
|
||||
if (!swPlayer.hasComponent(SWEditCursor.class)) {
|
||||
swPlayer.setComponent(new SWEditCursor());
|
||||
}
|
||||
|
||||
swPlayer.getComponent(SWEditCursor.class).ifPresent(cursor -> {
|
||||
cursor.setLocation(block.getLocation());
|
||||
});
|
||||
return packet;
|
||||
}
|
||||
}
|
||||
+9
-5
@@ -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,7 +17,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.core;
|
||||
package de.steamwar.core.worldedit;
|
||||
|
||||
import com.sk89q.worldedit.EmptyClipboardException;
|
||||
import com.sk89q.worldedit.IncompleteRegionException;
|
||||
@@ -28,6 +28,7 @@ import com.sk89q.worldedit.math.transform.Transform;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.regions.RegionSelector;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import de.steamwar.core.Core;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.linkage.PluginCheck;
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -39,13 +40,15 @@ import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.player.*;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@Linked
|
||||
@PluginCheck("FastAsyncWorldEdit")
|
||||
public class WorldEditRenderer implements Listener {
|
||||
|
||||
private static WorldEditRenderer INSTANCE;
|
||||
|
||||
private static final Material WAND = Material.WOODEN_AXE;
|
||||
private static final Set<Material> WANDS = Set.of(Material.WOODEN_AXE, SteamEditWand.MATERIAL);
|
||||
|
||||
private final WorldEditPlugin we;
|
||||
|
||||
@@ -102,7 +105,7 @@ public class WorldEditRenderer implements Listener {
|
||||
|
||||
private void drawCuboid(Vector min, Vector max, boolean scheduled, boolean clipboard, Player owner) {
|
||||
//noinspection deprecation
|
||||
if (owner.getItemInHand().getType() != WAND) {
|
||||
if (!WANDS.contains(owner.getItemInHand().getType())) {
|
||||
WorldEditRendererWrapper.impl.hide(owner, true, true);
|
||||
WorldEditRendererWrapper.impl.hide(owner, false, true);
|
||||
} else {
|
||||
@@ -114,7 +117,8 @@ public class WorldEditRenderer implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerMove(PlayerMoveEvent event) {
|
||||
if (event.getPlayer().getItemInHand().getType() == WAND) {
|
||||
//noinspection deprecation
|
||||
if (WANDS.contains(event.getPlayer().getItemInHand().getType())) {
|
||||
WorldEditRendererWrapper.impl.tick(event.getPlayer());
|
||||
}
|
||||
renderClipboard(event.getPlayer(), we.getSession(event.getPlayer()), false);
|
||||
+78
-15
@@ -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,11 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.core;
|
||||
package de.steamwar.core.worldedit;
|
||||
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.core.CRIUSleepEvent;
|
||||
import de.steamwar.core.Core;
|
||||
import de.steamwar.inventory.SWInventory;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import de.steamwar.sql.UserConfig;
|
||||
@@ -30,6 +32,7 @@ import org.bukkit.block.data.type.Light;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.inventory.meta.BlockDataMeta;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
@@ -59,6 +62,7 @@ public class WorldEditRendererCUIEditor implements Listener {
|
||||
public enum Type {
|
||||
SELECTION("cui_selection_material", "cui_selection_width", Material.PURPLE_CONCRETE, Width.MEDIUM),
|
||||
CLIPBOARD("cui_clipboard_material", "cui_clipboard_width", Material.LIME_CONCRETE, Width.SLIM),
|
||||
CURSOR("cui_cursor_material", "cui_cursor_range", Material.RED_CONCRETE, Width.SLIM),
|
||||
;
|
||||
|
||||
private final Map<Player, Material> materialCache = new HashMap<>();
|
||||
@@ -104,19 +108,27 @@ public class WorldEditRendererCUIEditor implements Listener {
|
||||
|
||||
@AllArgsConstructor
|
||||
public enum Width {
|
||||
HUGE(15, "WORLDEDIT_CUI_WIDTH_HUGE", 2 / 16f),
|
||||
LARGE(8, "WORLDEDIT_CUI_WIDTH_LARGE", 1 / 16f),
|
||||
MEDIUM(4, "WORLDEDIT_CUI_WIDTH_MEDIUM", 1 / 32f),
|
||||
SLIM(0, "WORLDEDIT_CUI_WIDTH_SLIM", 1 / 64f);
|
||||
HUGE(15, "WORLDEDIT_CUI_WIDTH_HUGE", 1 / 8f, 40),
|
||||
LARGE(8, "WORLDEDIT_CUI_WIDTH_LARGE", 1 / 16f, 30),
|
||||
MEDIUM(4, "WORLDEDIT_CUI_WIDTH_MEDIUM", 1 / 32f, 20),
|
||||
SLIM(0, "WORLDEDIT_CUI_WIDTH_SLIM", 1 / 64f, 10);
|
||||
|
||||
public final int lightLevel;
|
||||
public final String name;
|
||||
public final float value;
|
||||
public final float width;
|
||||
public final int blocks;
|
||||
}
|
||||
|
||||
private static Command command = null;
|
||||
|
||||
public WorldEditRendererCUIEditor() {
|
||||
Bukkit.getPluginManager().registerEvents(this, Core.getInstance());
|
||||
new Command();
|
||||
command = new Command();
|
||||
}
|
||||
|
||||
public static void open(Player player, boolean steamEditWand) {
|
||||
if (command == null) return;
|
||||
command.cuiEditor(player, steamEditWand);
|
||||
}
|
||||
|
||||
private static class Command extends SWCommand {
|
||||
@@ -127,18 +139,44 @@ public class WorldEditRendererCUIEditor implements Listener {
|
||||
|
||||
@Register
|
||||
public void cuiEditor(Player player) {
|
||||
cuiEditor(player, false);
|
||||
}
|
||||
|
||||
public void cuiEditor(Player player, boolean steamEditWand) {
|
||||
SWInventory inv = new SWInventory(player, 9 * 2, Core.MESSAGE.parse("WORLDEDIT_CUI_TITLE", player));
|
||||
setElement(inv, player, 3, "WORLDEDIT_CUI_SELECTION", Type.SELECTION);
|
||||
setElement(inv, player, 5, "WORLDEDIT_CUI_CLIPBOARD", Type.CLIPBOARD);
|
||||
if (SteamEdit.isInitialized() && steamEditWand) {
|
||||
setElement(inv, player, true, 1, "WORLDEDIT_CUI_SELECTION", Type.SELECTION);
|
||||
setElement(inv, player, true, 2, "WORLDEDIT_CUI_CLIPBOARD", Type.CLIPBOARD);
|
||||
setCursor(inv, player, 3, "WORLDEDIT_CUI_CURSOR");
|
||||
inv.setItem(5, new SWItem(Material.PAPER, "WORLDEDIT_CUI_TOOL_COPY").setLore("WORLDEDIT_CUI_TOOL_COPY_LORE").translate(player, Core.MESSAGE).getItemStack(), click -> {
|
||||
player.performCommand("/copy");
|
||||
});
|
||||
inv.setItem(6, new SWItem(Material.STRUCTURE_VOID, "WORLDEDIT_CUI_TOOL_SOON").translate(player, Core.MESSAGE).getItemStack(), click -> {});
|
||||
inv.setItem(7, new SWItem(Material.GRASS_BLOCK, "WORLDEDIT_CUI_TOOL_PASTE").setLore("WORLDEDIT_CUI_TOOL_PASTE_LORE_1", "WORLDEDIT_CUI_TOOL_PASTE_LORE_2", "WORLDEDIT_CUI_TOOL_PASTE_LORE_3").translate(player, Core.MESSAGE).getItemStack(), click -> {
|
||||
if (click == ClickType.DROP) {
|
||||
player.performCommand("/paste -o");
|
||||
} else if (click == ClickType.SHIFT_LEFT || click == ClickType.SHIFT_RIGHT) {
|
||||
player.performCommand("/paste -s");
|
||||
} else if (click == ClickType.LEFT || click == ClickType.RIGHT) {
|
||||
player.performCommand("/paste");
|
||||
}
|
||||
});
|
||||
inv.setItem(14, new SWItem(Material.STRUCTURE_VOID, "WORLDEDIT_CUI_TOOL_SOON").translate(player, Core.MESSAGE).getItemStack(), click -> {});
|
||||
inv.setItem(15, new SWItem(Material.STRUCTURE_VOID, "WORLDEDIT_CUI_TOOL_SOON").translate(player, Core.MESSAGE).getItemStack(), click -> {});
|
||||
inv.setItem(16, new SWItem(Material.STRUCTURE_VOID, "WORLDEDIT_CUI_TOOL_SOON").translate(player, Core.MESSAGE).getItemStack(), click -> {});
|
||||
} else {
|
||||
setElement(inv, player, false, 3, "WORLDEDIT_CUI_SELECTION", Type.SELECTION);
|
||||
setElement(inv, player, false, 5, "WORLDEDIT_CUI_CLIPBOARD", Type.CLIPBOARD);
|
||||
}
|
||||
inv.open();
|
||||
}
|
||||
|
||||
private void setElement(SWInventory inv, Player player, int index, String uiName, Type type) {
|
||||
private void setElement(SWInventory inv, Player player, boolean steamEditWand, int index, String uiName, Type type) {
|
||||
Material material = type.getMaterial(player);
|
||||
Width width = type.getWidth(player);
|
||||
|
||||
inv.setItem(index, new SWItem(material, Core.MESSAGE.parse("WORLDEDIT_CUI_MATERIAL_NAME", player, Core.MESSAGE.parse(uiName, player)), Arrays.asList(Core.MESSAGE.parse("WORLDEDIT_CUI_MATERIAL_CLICK", player)), false, click -> {
|
||||
cuiMaterial(player, uiName, type, material);
|
||||
cuiMaterial(player, steamEditWand, uiName, type, material);
|
||||
}));
|
||||
|
||||
List<String> lore = new ArrayList<>();
|
||||
@@ -153,7 +191,7 @@ public class WorldEditRendererCUIEditor implements Listener {
|
||||
}
|
||||
SWItem lightItem = new SWItem(Material.LIGHT, Core.MESSAGE.parse("WORLDEDIT_CUI_WIDTH_NAME", player, Core.MESSAGE.parse(uiName, player)), lore, false, click -> {
|
||||
type.setWidth(player, Width.values()[(width.ordinal() + 1) % Width.values().length]);
|
||||
setElement(inv, player, index, uiName, type);
|
||||
setElement(inv, player, steamEditWand, index, uiName, type);
|
||||
});
|
||||
ItemMeta itemMeta = lightItem.getItemMeta();
|
||||
Light light = (Light) Material.LIGHT.createBlockData();
|
||||
@@ -163,16 +201,41 @@ public class WorldEditRendererCUIEditor implements Listener {
|
||||
inv.setItem(index + 9, lightItem);
|
||||
}
|
||||
|
||||
private void setCursor(SWInventory inv, Player player, int index, String uiName) {
|
||||
Material material = Type.CURSOR.getMaterial(player);
|
||||
Width width = Type.CURSOR.getWidth(player);
|
||||
|
||||
inv.setItem(index, new SWItem(material, Core.MESSAGE.parse("WORLDEDIT_CUI_MATERIAL_NAME", player, Core.MESSAGE.parse(uiName, player)), Arrays.asList(Core.MESSAGE.parse("WORLDEDIT_CUI_MATERIAL_CLICK", player)), false, click -> {
|
||||
cuiMaterial(player, true, uiName, Type.CURSOR, material);
|
||||
}));
|
||||
|
||||
List<String> lore = new ArrayList<>();
|
||||
lore.add(Core.MESSAGE.parse("WORLDEDIT_CUI_WIDTH_CLICK", player));
|
||||
lore.add("");
|
||||
for (Width value : Width.values()) {
|
||||
if (value == width) {
|
||||
lore.add(Core.MESSAGE.parse("WORLDEDIT_CUI_WIDTH_LORE_SELECTED", player, Core.MESSAGE.parse(value.name + "_DIST", player)));
|
||||
} else {
|
||||
lore.add(Core.MESSAGE.parse("WORLDEDIT_CUI_WIDTH_LORE", player, Core.MESSAGE.parse(value.name + "_DIST", player)));
|
||||
}
|
||||
}
|
||||
SWItem stickItem = new SWItem(Material.STICK, Core.MESSAGE.parse("WORLDEDIT_CUI_WIDTH_NAME_DIST", player, Core.MESSAGE.parse(uiName, player)), lore, false, click -> {
|
||||
Type.CURSOR.setWidth(player, Width.values()[(width.ordinal() + 1) % Width.values().length]);
|
||||
setCursor(inv, player, index, uiName);
|
||||
}).setCustomModelData(1);
|
||||
inv.setItem(index + 9, stickItem);
|
||||
}
|
||||
|
||||
private final Material[] materials = {Material.WHITE_CONCRETE, Material.LIGHT_GRAY_CONCRETE, Material.GRAY_CONCRETE, Material.BLACK_CONCRETE, Material.BROWN_CONCRETE, Material.RED_CONCRETE, Material.ORANGE_CONCRETE, Material.YELLOW_CONCRETE, Material.LIME_CONCRETE, Material.GREEN_CONCRETE, Material.CYAN_CONCRETE, Material.LIGHT_BLUE_CONCRETE, Material.BLUE_CONCRETE, Material.PURPLE_CONCRETE, Material.MAGENTA_CONCRETE, Material.PINK_CONCRETE, null, Material.BARRIER};
|
||||
|
||||
private void cuiMaterial(Player player, String subMenu, Type type, Material currentSelection) {
|
||||
private void cuiMaterial(Player player, boolean steamEditWand, String subMenu, Type type, Material currentSelection) {
|
||||
SWInventory inv = new SWInventory(player, 9 * 2, Core.MESSAGE.parse("WORLDEDIT_CUI_TITLE_SUBMENU", player, Core.MESSAGE.parse(subMenu, player)));
|
||||
for (int i = 0; i < materials.length; i++) {
|
||||
Material material = materials[i];
|
||||
if (material == null) continue;
|
||||
inv.setItem(i, new SWItem(material, "", Collections.emptyList(), material == currentSelection, click -> {
|
||||
type.setMaterial(player, material);
|
||||
cuiEditor(player);
|
||||
cuiEditor(player, steamEditWand);
|
||||
}));
|
||||
}
|
||||
inv.open();
|
||||
+1
-1
@@ -17,7 +17,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.core;
|
||||
package de.steamwar.core.worldedit;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Particle;
|
||||
+4
-3
@@ -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,8 +17,9 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.core;
|
||||
package de.steamwar.core.worldedit;
|
||||
|
||||
import de.steamwar.core.PlayerVersion;
|
||||
import de.steamwar.entity.CWireframe;
|
||||
import de.steamwar.entity.REntityServer;
|
||||
import org.bukkit.Material;
|
||||
@@ -82,7 +83,7 @@ public class WorldEditRendererWrapper {
|
||||
});
|
||||
|
||||
WorldEditRendererCUIEditor.Type type = clipboard ? WorldEditRendererCUIEditor.Type.CLIPBOARD : WorldEditRendererCUIEditor.Type.SELECTION;
|
||||
float width = type.getWidth(player).value;
|
||||
float width = type.getWidth(player).width;
|
||||
Material material = type.getMaterial(player);
|
||||
if (material == Material.BARRIER) {
|
||||
hide(player, clipboard, true);
|
||||
+3
-2
@@ -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,7 +17,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.core;
|
||||
package de.steamwar.core.worldedit;
|
||||
|
||||
import com.fastasyncworldedit.core.extent.clipboard.io.FastSchematicReaderV2;
|
||||
import com.fastasyncworldedit.core.extent.clipboard.io.FastSchematicReaderV3;
|
||||
@@ -34,6 +34,7 @@ import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.math.transform.Transform;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.session.ClipboardHolder;
|
||||
import de.steamwar.core.Core;
|
||||
import de.steamwar.sql.NoClipboardException;
|
||||
import de.steamwar.sql.NodeData;
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -22,10 +22,12 @@ package de.steamwar.inventory;
|
||||
import com.destroystokyo.paper.profile.PlayerProfile;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
import de.steamwar.message.Message;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemFlag;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
@@ -225,4 +227,14 @@ public class SWItem {
|
||||
itemStack.setAmount(count);
|
||||
return this;
|
||||
}
|
||||
|
||||
public SWItem translate(Player player, Message message) {
|
||||
setName(message.parse(itemMeta.getDisplayName(), player));
|
||||
if (itemMeta.hasLore()) {
|
||||
setLore(itemMeta.getLore().stream()
|
||||
.map(s -> message.parse(s, player))
|
||||
.toList());
|
||||
}
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
package de.steamwar.sql;
|
||||
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import de.steamwar.core.WorldEditWrapper;
|
||||
import de.steamwar.core.worldedit.WorldEditWrapper;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
|
||||
@@ -19,7 +19,8 @@
|
||||
|
||||
package de.steamwar.teamserver;
|
||||
|
||||
import de.steamwar.core.WorldEditRendererCUIEditor;
|
||||
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;
|
||||
@@ -51,7 +52,7 @@ public final class Builder extends JavaPlugin {
|
||||
}
|
||||
|
||||
Bukkit.getWorlds().get(0).setGameRule(GameRule.REDUCED_DEBUG_INFO, false);
|
||||
new WorldEditRendererCUIEditor();
|
||||
SteamEdit.init();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -138,14 +138,16 @@ public class Subserver {
|
||||
writer.println(command);
|
||||
}
|
||||
|
||||
private ProcessHandle serverProcess() {
|
||||
if (checkpoint) {
|
||||
return process.children().findAny().orElseGet(process::toHandle);
|
||||
}
|
||||
return process.toHandle();
|
||||
}
|
||||
|
||||
public void sleep() {
|
||||
try {
|
||||
long pid = process.pid();
|
||||
if (checkpoint) {
|
||||
pid = process.children().findAny().map(ProcessHandle::pid).orElse(pid);
|
||||
}
|
||||
|
||||
Runtime.getRuntime().exec(new String[]{"kill", "-SIGUSR1", Long.toString(pid)});
|
||||
Runtime.getRuntime().exec(new String[]{"kill", "-SIGUSR1", Long.toString(serverProcess().pid())});
|
||||
} catch (IOException e) {
|
||||
logger.log(Level.SEVERE, "Failed to send SIGUSR1 to subserver.", e);
|
||||
}
|
||||
@@ -162,7 +164,7 @@ public class Subserver {
|
||||
|
||||
public void stop() {
|
||||
try {
|
||||
process.destroy();
|
||||
serverProcess().destroy();
|
||||
if (!process.waitFor(1, TimeUnit.MINUTES)) {
|
||||
forceStop();
|
||||
} else if (thread.isAlive()) {
|
||||
@@ -177,6 +179,7 @@ public class Subserver {
|
||||
public void forceStop() {
|
||||
try {
|
||||
logger.log(Level.SEVERE, () -> serverName + " did not stop correctly, forcibly stopping!");
|
||||
serverProcess().destroyForcibly();
|
||||
process.destroyForcibly();
|
||||
|
||||
if (thread.isAlive()) thread.join();
|
||||
|
||||
@@ -202,12 +202,6 @@ NOFIGHTSERVER_UNTIL = §7You are excluded from §e§lfighting§7 §euntil {0}§8
|
||||
UNNOFIGHTSERVER_ERROR = §cThe player is not excluded from fighting.
|
||||
UNNOFIGHTSERVER = §e{0} §7may now join §e§lfights§7 again§8.
|
||||
|
||||
NOTEAMSERVER_TEAM = §e{0} §7was excluded from §e{1} {2} §7from §e§lteam servers§8: §f{3}
|
||||
NOTEAMSERVER_PERMA = §7You are §epermanently§7 excluded from §e§lteam servers§8: §e{0}
|
||||
NOTEAMSERVER_UNTIL = §7You are excluded from §e§lteam servers§7 §euntil {0}§8: §e{1}
|
||||
UNNOTEAMSERVER_ERROR = §cThe player is not excluded from team servers.
|
||||
UNNOTEAMSERVER = §e{0} §7may now set §e§lteam servers§7 again§8.
|
||||
|
||||
NOTE_TEAM = §e{0} §7received a §e§lnote§7 from §e{1} {2}: §f{3}
|
||||
|
||||
#BugCommand
|
||||
@@ -284,8 +278,8 @@ EVENT_COMING_TEAMS = §7 With§8: {0}
|
||||
EVENT_COMING_TEAM = §{0}{1}
|
||||
EVENT_CURRENT_EVENT = §e§l{0}
|
||||
EVENT_CURRENT_FIGHT_1 = §7{0} §{1}{2}
|
||||
EVENT_CURRENT_FIGHT_VS = §8 vs
|
||||
EVENT_CURRENT_FIGHT_2 = §{1}{2}
|
||||
EVENT_CURRENT_FIGHT_VS = '§8 vs '
|
||||
EVENT_CURRENT_FIGHT_2 = §{0}{1}
|
||||
EVENT_CURRENT_FIGHT_WIN = §8: §7Victory §{0}{1}
|
||||
EVENT_CURRENT_FIGHT_DRAW = §8: §7Draw
|
||||
EVENT_TEAM_TABLE = §{0}{1}{2} §8 with §e{3} §7points
|
||||
|
||||
@@ -184,12 +184,6 @@ NOFIGHTSERVER_UNTIL = §7Du bist §ebis zum {0} §7vom §e§lKämpfen§7 ausgesc
|
||||
UNNOFIGHTSERVER_ERROR = §cDer Spieler ist nicht vom Kämpfen ausgeschlossen.
|
||||
UNNOFIGHTSERVER = §e{0} §7darf nun wieder §e§lKämpfen§7 beitreten§8.
|
||||
|
||||
NOTEAMSERVER_TEAM = §e{0} §7wurde von §e{1} {2} §7vom §e§lTeamserver§7 setzen ausgeschlossen§8: §f{3}
|
||||
NOTEAMSERVER_PERMA = §7Du bist §epermanent §7vom §e§lTeamserver§7 setzen ausgeschlossen§8: §e{0}
|
||||
NOTEAMSERVER_UNTIL = §7Du bist §ebis zum {0} §7vom §e§lTeamserver§7 setzen ausgeschlossen§8: §e{1}
|
||||
UNNOTEAMSERVER_ERROR = §cDer Spieler ist nicht vom Teamserver setzten ausgeschlossen.
|
||||
UNNOTEAMSERVER = §e{0} §7darf nun wieder §e§lTeamserver§7 setzen§8.
|
||||
|
||||
NOTE_TEAM = §e{0} §7erhielt von §e{1} {2} §7die §e§lNotiz§7§8: §f{3}
|
||||
|
||||
#BugCommand
|
||||
|
||||
@@ -86,7 +86,7 @@ public class EventStarter {
|
||||
}
|
||||
}).start();
|
||||
|
||||
command = "/event " + blue.getTeamKuerzel();
|
||||
command = "/event team " + blue.getTeamKuerzel();
|
||||
} else {
|
||||
command = "/" + spectatePorts.get(next.getSpectatePort());
|
||||
}
|
||||
|
||||
@@ -149,7 +149,6 @@ public class VelocityCore implements ReloadablePlugin {
|
||||
new PunishmentCommand("noschemsubmitting", Punishment.PunishmentType.NoSchemSubmitting);
|
||||
new PunishmentCommand("nodev", Punishment.PunishmentType.NoDevServer);
|
||||
new PunishmentCommand("nofight", Punishment.PunishmentType.NoFightServer);
|
||||
new PunishmentCommand("noteamserver", Punishment.PunishmentType.NoTeamServer);
|
||||
new PunishmentCommand("note", Punishment.PunishmentType.Note);
|
||||
|
||||
linker = new AbstractLinker<>(this) {
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
|
||||
package de.steamwar.velocitycore.commands;
|
||||
|
||||
import com.google.protobuf.MapEntry;
|
||||
import de.steamwar.command.PreviousArguments;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.command.TypeMapper;
|
||||
@@ -29,18 +28,15 @@ import de.steamwar.messages.Chatter;
|
||||
import de.steamwar.messages.PlayerChatter;
|
||||
import de.steamwar.persistent.Subserver;
|
||||
import de.steamwar.sql.*;
|
||||
import de.steamwar.sql.Event;
|
||||
import de.steamwar.velocitycore.EventStarter;
|
||||
import de.steamwar.velocitycore.SubserverSystem;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.event.ClickEvent;
|
||||
|
||||
import java.awt.*;
|
||||
import java.sql.Timestamp;
|
||||
import java.time.Instant;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -94,7 +90,7 @@ public class EventCommand extends SWCommand {
|
||||
eventShowFightsPage(sender, currentEvent, 1);
|
||||
}
|
||||
|
||||
@Register(value = "showtable", description = "EVENT_SHOW_TABLE_USAGE")
|
||||
// @Register(value = "showtable", description = "EVENT_SHOW_TABLE_USAGE")
|
||||
public void eventtable(Chatter sender, Event event) {
|
||||
if (!Instant.now().isBefore(event.getEnd().toInstant())) return;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user