Compare commits
276 Commits
sw-ui
...
backend-sy
| Author | SHA1 | Date | |
|---|---|---|---|
| eb218c33ca | |||
| 7b01f11b5b | |||
| fd57ba43e9 | |||
| 03005adcd8 | |||
| 679d373a1e | |||
| 828084a3d6 | |||
| 2b782585b1 | |||
| b43965be91 | |||
| d82f306094 | |||
| 30cdbe072e | |||
| db7e1a5fc9 | |||
| 3e5055c246 | |||
| 44c06314c6 | |||
| e06742d6d2 | |||
| 62e674ed42 | |||
| 0464442b83 | |||
| c682333771 | |||
| 58ab619144 | |||
| 00de852575 | |||
| 948cf5e8db | |||
| 7aba8da5a0 | |||
| 5a77854752 | |||
| cf1422f532 | |||
| 6260e65b33 | |||
| 6db404c1e6 | |||
| b086fcaa32 | |||
| f33b3521b8 | |||
| dc72ec1b93 | |||
| 0e9c9bd4dc | |||
| 291b6b1804 | |||
| 104f0cf02d | |||
| f7662cdcba | |||
| 167b36b10c | |||
| b9b541957b | |||
| e9d107f0ed | |||
| 1e264a63a2 | |||
| 868ba4073b | |||
| 3410dd5a4b | |||
| b86a26a709 | |||
| 71238a0167 | |||
| 30ac947ebb | |||
| a7d64b5887 | |||
| d7908c8255 | |||
| 12f26b982e | |||
| 2be4118399 | |||
| 9d6981ee0c | |||
| 97a4d47aa7 | |||
| d657f9871d | |||
| a572b84016 | |||
| f1c6b4b453 | |||
| d0414c71f3 | |||
| 3530aec5e2 | |||
| cccd090357 | |||
| 3ae9a41b31 | |||
| b8b38cf777 | |||
| c1eca74dd0 | |||
| 8c23bf5bd4 | |||
| 556c8f7db1 | |||
| 7a03b327ef | |||
| 0091cba336 | |||
| 35d8bfb588 | |||
| 78584fea34 | |||
| 66511e514c | |||
| 6f64d03fee | |||
| c04e8d75eb | |||
| 5c7c982175 | |||
| d5ca1e14e1 | |||
| 60347bc481 | |||
| fbfdcf8fff | |||
| e56c41ca66 | |||
| 3b67048b9c | |||
| 6efbda669e | |||
| 4bd5d9eb0b | |||
| 60a70dfc40 | |||
| 95a97aed93 | |||
| 6fa54aba2f | |||
| d04939fb2c | |||
| 4c98ce4aff | |||
| 4ed6bc52d0 | |||
| bc00873314 | |||
| 8677d59cce | |||
| 6b16bbc785 | |||
| 617bae5a5c | |||
| 9988774fb4 | |||
| 4fc707431f | |||
| 8ff0319fe6 | |||
| 86537a00de | |||
| e9f8a89758 | |||
| f37fbfffdf | |||
| 9798c08cf3 | |||
| dbd979a5fe | |||
| 280202c43f | |||
| 23df187eb1 | |||
| 39af920631 | |||
| e4864e6eaf | |||
| d2bb8e8e59 | |||
| bd9451f2aa | |||
| 1bb15d9551 | |||
| d06faa5d18 | |||
| bc5e781810 | |||
| 14b756261e | |||
| 1f1f99f8f3 | |||
| d9aeb47a3a | |||
| afe30fd348 | |||
| 9f323c8b38 | |||
| b6279fd7fa | |||
| 3f7cd48f27 | |||
| c682678827 | |||
| 1fd8b3c4cb | |||
| c6ecab5aa8 | |||
| 4383e541d8 | |||
| cc4532ab90 | |||
| 3e448e7597 | |||
| d975110470 | |||
| f6852a5523 | |||
| 40437afb73 | |||
| 80a156754d | |||
| dfc7bbbe13 | |||
| dd5f46069f | |||
| b10897c204 | |||
| f6dc1e1059 | |||
| dccb435bce | |||
| 1c8d6580d5 | |||
| 187087f56b | |||
| 77cf101889 | |||
| 0f68f671f5 | |||
| 75c4966e37 | |||
| fcebb4ffd3 | |||
| 9abbcc908d | |||
| 4eb40581f2 | |||
| c3a4e7ed85 | |||
| 5201a3edc0 | |||
| c9821053ce | |||
| eb8562b3a9 | |||
| 37acbf0033 | |||
| 9e294afa8f | |||
| 3e9ffa52c3 | |||
| 3296d9ebb3 | |||
| 3d562cf743 | |||
| 24f4ab7f37 | |||
| 0ea92be2e1 | |||
| 88d8016987 | |||
| 909c1c52aa | |||
| 26b126fdba | |||
| ecb2e736aa | |||
| 38559e8a2b | |||
| 1aba92e707 | |||
| e4df6f55fb | |||
| ff5113e112 | |||
| c425ca1171 | |||
| c1293ffda0 | |||
| 02428868c2 | |||
| adaae7f943 | |||
| c12d2c2ddf | |||
| 428c63429c | |||
| edec84c60a | |||
| 4f885a7269 | |||
| dfd9febd8c | |||
| 1a570dca17 | |||
| 761977c90a | |||
| 5cc417c43c | |||
| 1014df5f31 | |||
| c920664920 | |||
| 3069ffc991 | |||
| c3db2b7f86 | |||
| c30f24ab8f | |||
| bcb0ad4bef | |||
| f2a46e54ea | |||
| daede98a0f | |||
| d37a14f280 | |||
| 083c5c07c2 | |||
| 7b059cde0e | |||
| 30fa3fd66e | |||
| 37f6723542 | |||
| 7a9740c4c4 | |||
| 54eec6d57c | |||
| 2f93f336c9 | |||
| 62f9d37230 | |||
| b479b6667b | |||
| 9bc01a4e3b | |||
| b14cf445df | |||
| 527bc39d38 | |||
| 8defbaa18b | |||
| a5bb62590c | |||
| c35d4741a0 | |||
| a2a101c4e3 | |||
| 277e1f9f9b | |||
| 380506542f | |||
| d410484e4c | |||
| 8768fd7d81 | |||
| 374e314faa | |||
| 45a8aab321 | |||
| 0d15bbc266 | |||
| 7fa97ce36c | |||
| 8cd088050d | |||
| b0bbc09113 | |||
| a5b61fb0d6 | |||
| 297e6c9b59 | |||
| 400c78447a | |||
| 778d0282d3 | |||
| 2a314e7035 | |||
| 6ed639fbb3 | |||
| 3a79f19f37 | |||
| f7e81f8204 | |||
| 7f215b921e | |||
| b0be06136d | |||
| 8132e4fca0 | |||
| bf5eef2ebd | |||
| 69251f42a6 | |||
| 6bbe94150d | |||
| 717cfa8baf | |||
| 260656ad35 | |||
| e893d7934a | |||
| d0665932f4 | |||
| d6fba9b0af | |||
| b229b0d0ae | |||
| ac00245b04 | |||
| 6eb01a61b1 | |||
| fa13872f22 | |||
| 79edc1c591 | |||
| 6e9db276ef | |||
| e3179c69aa | |||
| c633694222 | |||
| a4eea298d2 | |||
| f387805b40 | |||
| 2c644eef26 | |||
| 7f0fa09c56 | |||
| 6940c32b02 | |||
| 5015aca159 | |||
| 32c85b9bd5 | |||
| 15bb92fbba | |||
| d6a5caf95d | |||
| 1912ad52e4 | |||
| 66d18e316b | |||
| f30c3b2f34 | |||
| 7e863e8062 | |||
| 5cdad8c2f4 | |||
| 87a7120a6a | |||
| b5a9564808 | |||
| f93362a023 | |||
| b1bef4ced5 | |||
| e7e1e2d968 | |||
| 713275ba11 | |||
| e72ae3cf94 | |||
| d36753dec1 | |||
| 84cc292df4 | |||
| f89c4e88f9 | |||
| aeff16b7dd | |||
| bb97d80c18 | |||
| 7d45680fcb | |||
| a38f9222dd | |||
| 5ee9d3e167 | |||
| 98321de46c | |||
| 239ba3f213 | |||
| 3d7dedd3ad | |||
| ef66b8c1f1 | |||
| 1201b16ee4 | |||
| 4ddd88f540 | |||
| ca35ab9234 | |||
| 3df84a7dad | |||
| 83c20729fa | |||
| 925901e40e | |||
| 059dd314d1 | |||
| 86ff619548 | |||
| 76e00b07db | |||
| 4edfd32ff5 | |||
| 5669725f9b | |||
| 335649fa87 | |||
| 9001e83321 | |||
| 32703c6659 | |||
| e393aad25f | |||
| 50543ddd4e | |||
| ae7d394ae2 | |||
| 40eeb4993f | |||
| 4c23915987 | |||
| 71522973a7 |
6
.gitignore
vendored
6
.gitignore
vendored
@ -16,4 +16,8 @@ bin/
|
||||
.vscode
|
||||
|
||||
# Other
|
||||
lib
|
||||
lib
|
||||
/WebsiteBackend/data
|
||||
/WebsiteBackend/logs
|
||||
/WebsiteBackend/skins
|
||||
/WebsiteBackend/config.json
|
||||
@ -0,0 +1,140 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.utils;
|
||||
|
||||
import de.steamwar.bausystem.region.GlobalRegion;
|
||||
import de.steamwar.bausystem.utils.bossbar.BossBarService;
|
||||
import de.steamwar.bausystem.utils.tps.TPSFreezeUtils;
|
||||
import de.steamwar.bausystem.utils.tps.TPSLimitUtils;
|
||||
import de.steamwar.core.TPSWarpUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
public class TickManager15 implements TickManager, Listener {
|
||||
|
||||
private static float currentTPSLimit = 20;
|
||||
private boolean currentlyStepping = false;
|
||||
private float currentLimit;
|
||||
private int stepsTotal;
|
||||
private int stepsLeft;
|
||||
|
||||
@Override
|
||||
public boolean canFreeze() {
|
||||
return TPSFreezeUtils.isCanFreeze();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTickRate(float tickRate) {
|
||||
if (currentlyStepping) {
|
||||
currentlyStepping = false;
|
||||
Bukkit.getOnlinePlayers().forEach(player -> {
|
||||
BossBarService.instance.remove(player, GlobalRegion.getInstance(), "TickStep");
|
||||
});
|
||||
}
|
||||
TPSWarpUtils.warp(tickRate);
|
||||
if (currentTPSLimit == 0 && tickRate != 0) {
|
||||
TPSFreezeUtils.unfreeze();
|
||||
}
|
||||
currentTPSLimit = tickRate;
|
||||
if (tickRate == 0) {
|
||||
TPSLimitUtils.unlimit();
|
||||
TPSFreezeUtils.freeze();
|
||||
} else if (tickRate < 20.0) {
|
||||
TPSLimitUtils.limit(tickRate);
|
||||
} else if (tickRate >= 20) {
|
||||
TPSLimitUtils.unlimit();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFrozen() {
|
||||
return TPSFreezeUtils.frozen();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFreeze(boolean freeze) {
|
||||
if (freeze) {
|
||||
setTickRate(0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stepTicks(int ticks) {
|
||||
currentLimit = 0;
|
||||
setTickRate(20);
|
||||
stepsLeft = ticks;
|
||||
stepsTotal = ticks;
|
||||
currentlyStepping = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sprintTicks(int ticks) {
|
||||
currentLimit = currentTPSLimit;
|
||||
setTickRate(4000);
|
||||
stepsLeft = ticks;
|
||||
stepsTotal = ticks;
|
||||
currentlyStepping = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSprinting() {
|
||||
return currentlyStepping && currentTPSLimit > 20;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStepping() {
|
||||
return currentlyStepping && currentTPSLimit <= 20;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getTickRate() {
|
||||
return currentTPSLimit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlockTpsPacket(boolean block) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getTotalTicks() {
|
||||
return stepsTotal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getDoneTicks() {
|
||||
return stepsTotal - stepsLeft;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getRemainingTicks() {
|
||||
return stepsLeft;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onTickEnd(TickEndEvent event) {
|
||||
if (!currentlyStepping) return;
|
||||
stepsLeft--;
|
||||
if (stepsLeft <= 0) {
|
||||
setTickRate(currentLimit);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,23 +1,23 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2023 SteamWar.de-Serverteam
|
||||
* Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* This program is 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.
|
||||
* 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/>.
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.tpslimit;
|
||||
package de.steamwar.bausystem.utils.tps;
|
||||
|
||||
import de.steamwar.Reflection;
|
||||
import com.comphenix.tinyprotocol.TinyProtocol;
|
||||
@ -1,23 +1,23 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2023 SteamWar.de-Serverteam
|
||||
* Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* This program is 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.
|
||||
* 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/>.
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.tpslimit;
|
||||
package de.steamwar.bausystem.utils.tps;
|
||||
|
||||
import de.steamwar.Reflection;
|
||||
import lombok.Getter;
|
||||
@ -17,7 +17,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.tpslimit;
|
||||
package de.steamwar.bausystem.utils.tps;
|
||||
|
||||
import de.steamwar.Reflection;
|
||||
import com.comphenix.tinyprotocol.TinyProtocol;
|
||||
@ -22,7 +22,6 @@ package de.steamwar.bausystem.utils;
|
||||
import com.destroystokyo.paper.event.server.ServerTickEndEvent;
|
||||
import com.destroystokyo.paper.event.server.ServerTickStartEvent;
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.features.tpslimit.TPSFreezeUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
@ -37,7 +36,7 @@ public class TickListener19 implements TickListener, Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onServerTickStart(ServerTickStartEvent event) {
|
||||
if (TPSFreezeUtils.isFrozen()) return;
|
||||
if (TickManager.impl.isFrozen()) return;
|
||||
Bukkit.getPluginManager().callEvent(new TickStartEvent());
|
||||
tickStartRan = true;
|
||||
}
|
||||
|
||||
@ -21,41 +21,39 @@ package de.steamwar.bausystem.utils;
|
||||
|
||||
import de.steamwar.Reflection;
|
||||
import de.steamwar.bausystem.features.util.NoClipCommand;
|
||||
import net.minecraft.core.component.DataComponents;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.network.protocol.game.PacketPlayInSetCreativeSlot;
|
||||
import net.minecraft.network.protocol.game.PacketPlayOutExplosion;
|
||||
import net.minecraft.network.protocol.game.PacketPlayOutGameStateChange;
|
||||
import net.minecraft.server.level.EntityPlayer;
|
||||
import net.minecraft.server.level.PlayerInteractManager;
|
||||
import net.minecraft.world.entity.player.EntityHuman;
|
||||
import net.minecraft.world.entity.player.PlayerAbilities;
|
||||
import net.minecraft.world.item.component.CustomData;
|
||||
import net.minecraft.world.level.EnumGamemode;
|
||||
import io.papermc.paper.datacomponent.DataComponentTypes;
|
||||
import io.papermc.paper.datacomponent.item.ItemContainerContents;
|
||||
import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket;
|
||||
import net.minecraft.network.protocol.game.ClientboundExplodePacket;
|
||||
import net.minecraft.network.protocol.game.ClientboundGameEventPacket;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.server.level.ServerPlayerGameMode;
|
||||
import net.minecraft.world.entity.player.Abilities;
|
||||
import net.minecraft.world.level.GameType;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.craftbukkit.v1_21_R2.entity.CraftPlayer;
|
||||
import org.bukkit.craftbukkit.v1_21_R2.inventory.CraftItemStack;
|
||||
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||
import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerGameModeChangeEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public class NMSWrapper21 implements NMSWrapper {
|
||||
|
||||
private static final Reflection.Field<PlayerInteractManager> playerInteractManager = Reflection.getField(EntityPlayer.class, null, PlayerInteractManager.class);
|
||||
private static final Reflection.Field<ServerPlayerGameMode> playerInteractManager = Reflection.getField(ServerPlayer.class, null, ServerPlayerGameMode.class);
|
||||
|
||||
@Override
|
||||
public void setInternalGameMode(Player player, GameMode gameMode) {
|
||||
playerInteractManager.get(((CraftPlayer) player).getHandle()).a(EnumGamemode.a(gameMode.getValue()));
|
||||
playerInteractManager.get(((CraftPlayer) player).getHandle()).changeGameModeForPlayer(GameType.byId(gameMode.getValue()), PlayerGameModeChangeEvent.Cause.UNKNOWN, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSlotToItemStack(Player player, Object o) {
|
||||
PacketPlayInSetCreativeSlot packetPlayInSetCreativeSlot = (PacketPlayInSetCreativeSlot) o;
|
||||
int index = packetPlayInSetCreativeSlot.b();
|
||||
ClientboundContainerSetSlotPacket packetPlayInSetCreativeSlot = (ClientboundContainerSetSlotPacket) o;
|
||||
int index = packetPlayInSetCreativeSlot.getSlot();
|
||||
if (index >= 36 && index <= 44) {
|
||||
index -= 36;
|
||||
} else if (index > 44) {
|
||||
@ -63,25 +61,23 @@ public class NMSWrapper21 implements NMSWrapper {
|
||||
} else if (index <= 8) {
|
||||
index = index - 8 + 36;
|
||||
}
|
||||
player.getInventory().setItem(index, CraftItemStack.asBukkitCopy(packetPlayInSetCreativeSlot.e()));
|
||||
player.getInventory().setItem(index, CraftItemStack.asBukkitCopy(packetPlayInSetCreativeSlot.getItem()));
|
||||
if (index < 9) player.getInventory().setHeldItemSlot(index);
|
||||
player.updateInventory();
|
||||
}
|
||||
|
||||
private static final Reflection.Field<PacketPlayOutGameStateChange.a> gameStateChangeReason = Reflection.getField(NoClipCommand.gameStateChange, PacketPlayOutGameStateChange.a.class, 12);
|
||||
private static final Reflection.Field<ClientboundGameEventPacket.Type> gameStateChangeReason = Reflection.getField(NoClipCommand.gameStateChange, ClientboundGameEventPacket.Type.class, 12);
|
||||
|
||||
@Override
|
||||
public void setGameStateChangeReason(Object packet) {
|
||||
gameStateChangeReason.set(packet, PacketPlayOutGameStateChange.d);
|
||||
gameStateChangeReason.set(packet, ClientboundGameEventPacket.CHANGE_GAME_MODE);
|
||||
}
|
||||
|
||||
private static final Reflection.Field<PlayerAbilities> playerAbilities = Reflection.getField(EntityHuman.class, null, PlayerAbilities.class);
|
||||
|
||||
@Override
|
||||
public void setPlayerBuildAbilities(Player player) {
|
||||
PlayerAbilities abilities = playerAbilities.get(((CraftPlayer) player).getHandle());
|
||||
abilities.d = true;
|
||||
abilities.e = true;
|
||||
Abilities abilities = (((CraftPlayer) player).getHandle()).getAbilities();
|
||||
abilities.mayBuild = true;
|
||||
abilities.mayfly = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -93,49 +89,45 @@ public class NMSWrapper21 implements NMSWrapper {
|
||||
|
||||
@Override
|
||||
public boolean checkItemStack(ItemStack item) {
|
||||
net.minecraft.world.item.ItemStack nmsItem = CraftItemStack.asNMSCopy(item);
|
||||
NBTTagCompound tag = nmsItem.a(DataComponents.b, CustomData.a).c();
|
||||
if (tag.e("BlockEntityTag")) {
|
||||
NBTTagCompound blockTag = tag.p("BlockEntityTag");
|
||||
if (blockTag.e("Items")) {
|
||||
return drillDown(blockTag.c("Items", 10), 0, 0) > threshold;
|
||||
}
|
||||
ItemContainerContents data = item.getData(DataComponentTypes.CONTAINER);
|
||||
if (data == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
return drillDown(data.contents(), 0, 0) > threshold;
|
||||
}
|
||||
|
||||
private int drillDown(NBTTagList items, int layer, int start) {
|
||||
private int drillDown(List<ItemStack> items, int layer, int start) {
|
||||
if (layer > 2) return start + threshold;
|
||||
int invalid = start;
|
||||
for (NBTBase nbtBase : items) {
|
||||
if (!(nbtBase instanceof NBTTagCompound slot))
|
||||
for (int i = start; i < items.size(); i++) {
|
||||
ItemStack item = items.get(i);
|
||||
if (item.isEmpty()) continue;
|
||||
|
||||
invalid += item.getAmount();
|
||||
|
||||
ItemContainerContents data = item.getData(DataComponentTypes.CONTAINER);
|
||||
if (data == null) {
|
||||
continue;
|
||||
if (slot.e("tag")) {
|
||||
invalid += slot.f("Count");
|
||||
NBTTagCompound iTag = slot.p("tag");
|
||||
if (iTag.e("BlockEntityTag")) {
|
||||
NBTTagCompound blockTag = iTag.p("BlockEntityTag");
|
||||
if (blockTag.e("Items")) {
|
||||
invalid = drillDown(blockTag.c("Items", 10), layer + 1, invalid);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (invalid > threshold)
|
||||
break;
|
||||
|
||||
List<ItemStack> subItems = data.contents();
|
||||
if (subItems.size() > 1) {
|
||||
invalid = drillDown(subItems, layer + 1, invalid);
|
||||
}
|
||||
}
|
||||
return invalid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object resetExplosionKnockback(Object packet) {
|
||||
PacketPlayOutExplosion explosion = (PacketPlayOutExplosion) packet;
|
||||
ClientboundExplodePacket explosion = (ClientboundExplodePacket) packet;
|
||||
|
||||
return new PacketPlayOutExplosion(
|
||||
explosion.b(),
|
||||
return new ClientboundExplodePacket(
|
||||
explosion.center(),
|
||||
Optional.empty(),
|
||||
explosion.f(),
|
||||
explosion.g()
|
||||
explosion.explosionParticle(),
|
||||
explosion.explosionSound()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,150 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2025 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.utils;
|
||||
|
||||
import com.comphenix.tinyprotocol.TinyProtocol;
|
||||
import de.steamwar.Reflection;
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import net.minecraft.network.protocol.game.ClientboundTickingStatePacket;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.ServerTickRateManager;
|
||||
import net.minecraft.world.TickRateManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class TickManager21 implements TickManager {
|
||||
private static final ServerTickRateManager manager = MinecraftServer.getServer().tickRateManager();
|
||||
private static final Reflection.Field<Integer> frozenTicksToRun = Reflection.getField(TickRateManager.class, int.class, 0);
|
||||
private static final Reflection.Field<Long> remainingSprintTicks = Reflection.getField(ServerTickRateManager.class, long.class, 0);
|
||||
|
||||
private boolean blockTpsPacket = true;
|
||||
private int totalSteps;
|
||||
|
||||
public TickManager21() {
|
||||
TinyProtocol.instance.addFilter(ClientboundTickingStatePacket.class, this::blockPacket);
|
||||
}
|
||||
|
||||
private Object blockPacket(Player player, Object packet) {
|
||||
if (blockTpsPacket) {
|
||||
return new ClientboundTickingStatePacket(20, manager.isFrozen());
|
||||
} else {
|
||||
return packet;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFreeze() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlockTpsPacket(boolean block) {
|
||||
blockTpsPacket = block;
|
||||
if (blockTpsPacket) {
|
||||
ClientboundTickingStatePacket packet = new ClientboundTickingStatePacket(20, manager.isFrozen());
|
||||
Bukkit.getOnlinePlayers().forEach(player -> TinyProtocol.instance.sendPacket(player, packet));
|
||||
} else {
|
||||
ClientboundTickingStatePacket packet = new ClientboundTickingStatePacket(manager.tickrate(), manager.isFrozen());
|
||||
Bukkit.getOnlinePlayers().forEach(player -> TinyProtocol.instance.sendPacket(player, packet));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTickRate(float tickRate) {
|
||||
if (isFrozen()) {
|
||||
setFreeze(false);
|
||||
}
|
||||
manager.setTickRate(tickRate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFrozen() {
|
||||
return manager.isFrozen();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFreeze(boolean freeze) {
|
||||
manager.setFrozen(freeze);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stepTicks(int ticks) {
|
||||
if (manager.isSprinting()) {
|
||||
manager.stopSprinting();
|
||||
} else if (manager.isSteppingForward()) {
|
||||
manager.stopStepping();
|
||||
}
|
||||
this.totalSteps = ticks;
|
||||
manager.setFrozen(true);
|
||||
manager.stepGameIfPaused(ticks);
|
||||
manager.setFrozen(false);
|
||||
Bukkit.getScheduler().runTaskTimer(BauSystem.getInstance(), (bukkitTask) -> {
|
||||
if (manager.isSteppingForward()) return;
|
||||
manager.setFrozen(true);
|
||||
bukkitTask.cancel();
|
||||
}, 1, 1);
|
||||
manager.tick();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sprintTicks(int ticks) {
|
||||
if (manager.isSteppingForward()) {
|
||||
manager.stopStepping();
|
||||
} else if (manager.isSprinting()) {
|
||||
manager.stopSprinting();
|
||||
}
|
||||
this.totalSteps = ticks;
|
||||
manager.requestGameToSprint(ticks, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSprinting() {
|
||||
return manager.isSprinting();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStepping() {
|
||||
return manager.isSteppingForward();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getTickRate() {
|
||||
return manager.tickrate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getRemainingTicks() {
|
||||
if (isSprinting()) {
|
||||
return remainingSprintTicks.get(manager);
|
||||
} else {
|
||||
return frozenTicksToRun.get(manager);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getDoneTicks() {
|
||||
return totalSteps - getRemainingTicks();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getTotalTicks() {
|
||||
return totalSteps;
|
||||
}
|
||||
}
|
||||
@ -38,6 +38,7 @@ SCOREBOARD_TRACE_TICKS=Ticks
|
||||
SCOREBOARD_TECHHIDER=TechHider§8: §aOn
|
||||
SCOREBOARD_XRAY=XRay§8: §aOn
|
||||
SCOREBOARD_LOCK_TEAM=Bau Lock§8: §eTeam
|
||||
SCOREBOARD_LOCK_SUPERVISOR=Bau Lock§8: §eSupervisor
|
||||
SCOREBOARD_LOCK_TEAM_AND_SERVERTEAM=Bau Lock§8: §e(Server) Team
|
||||
SCOREBOARD_LOCK_SERVERTEAM=Bau Lock§8: §eServer Team
|
||||
SCOREBOARD_LOCK_NOBODY=Bau Lock§8: §cNobody
|
||||
@ -514,7 +515,7 @@ LOADER_HELP_GUI=§8/§7loader gui §8- §7Shows Loader gui
|
||||
LOADER_HELP_STOP=§8/§eloader stop §8- §7Stops recording/playback
|
||||
LOADER_HELP_WAIT=§8/§7loader wait §8[§7Ticks§8] - §7Sets wait time between shots
|
||||
LOADER_HELP_SPEED=§8/§7loader speed §8[§7Ticks§8] - §7Sets wait time between actions
|
||||
LOADER_NO_LOADER=§cYou have no Laoder. Create one with /loader setup
|
||||
LOADER_NO_LOADER=§cYou have no Loader. Create one with /loader setup
|
||||
LOADER_NEW=§7Load your cannon and fire it once, to initialise the loader.
|
||||
LOADER_HOW_TO_START=§7Then, execute /§eloader start§7 to start the Loader
|
||||
LOADER_ACTIVE=§7The Loader is now active.
|
||||
@ -846,7 +847,7 @@ LAUFBAU_SETTINGS_INACTIVE=§cInactive
|
||||
LAUFBAU_SETTINGS_MIXED=§e{0}§8/§e{1} §aActive
|
||||
LAUFBAU_SETTINGS_GUI_BACK=§eBack
|
||||
LAUFBAU_SETTINGS_TOGGLE=§eClick §8-§7 Toggle
|
||||
LAUFBAU_SETTINGS_ADVANCED=§eMiddle-Click §8-§7 Advanced settings
|
||||
LAUFBAU_SETTINGS_ADVANCED=§eLeft-Click §8-§7 Advanced settings
|
||||
LAUFBAU_BLOCK_COBWEB=§eCobweb
|
||||
LAUFBAU_BLOCK_GRASS_PATH=§eGrass Path
|
||||
LAUFBAU_BLOCK_SOUL_SAND=§eSoul Sand
|
||||
|
||||
@ -792,7 +792,7 @@ LAUFBAU_SETTINGS_INACTIVE=§cInaktiv
|
||||
LAUFBAU_SETTINGS_MIXED=§e{0}§8/§e{1} §aAktiv
|
||||
LAUFBAU_SETTINGS_GUI_BACK=§eBack
|
||||
LAUFBAU_SETTINGS_TOGGLE=§eClick §8-§7 Toggle
|
||||
LAUFBAU_SETTINGS_ADVANCED=§eMiddle-Click §8-§7 Erweiterte Einstellung
|
||||
LAUFBAU_SETTINGS_ADVANCED=§eLinks-Click §8-§7 Erweiterte Einstellung
|
||||
LAUFBAU_BLOCK_COBWEB=§eCobweb
|
||||
LAUFBAU_BLOCK_GRASS_PATH=§eGrass Path
|
||||
LAUFBAU_BLOCK_SOUL_SAND=§eSoul Sand
|
||||
|
||||
@ -28,7 +28,6 @@ import de.steamwar.bausystem.features.script.lua.libs.LuaLib;
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.BoundingBoxLoader;
|
||||
import de.steamwar.bausystem.features.slaves.panzern.Panzern;
|
||||
import de.steamwar.bausystem.features.slaves.panzern.PanzernAlgorithm;
|
||||
import de.steamwar.bausystem.features.tpslimit.TPSFreezeUtils;
|
||||
import de.steamwar.bausystem.features.tracer.TraceManager;
|
||||
import de.steamwar.bausystem.features.tracer.TraceRecorder;
|
||||
import de.steamwar.bausystem.features.world.BauScoreboard;
|
||||
@ -38,11 +37,13 @@ import de.steamwar.bausystem.region.loader.RegionLoader;
|
||||
import de.steamwar.bausystem.region.loader.Updater;
|
||||
import de.steamwar.bausystem.utils.ScoreboardElement;
|
||||
import de.steamwar.bausystem.utils.TickListener;
|
||||
import de.steamwar.bausystem.utils.TickManager;
|
||||
import de.steamwar.bausystem.worlddata.WorldData;
|
||||
import de.steamwar.command.AbstractValidator;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.command.SWCommandUtils;
|
||||
import de.steamwar.core.Core;
|
||||
import de.steamwar.core.WorldEditRendererCUIEditor;
|
||||
import de.steamwar.linkage.LinkedInstance;
|
||||
import de.steamwar.linkage.MaxVersion;
|
||||
import de.steamwar.linkage.MinVersion;
|
||||
@ -206,6 +207,8 @@ public class BauSystem extends JavaPlugin {
|
||||
|
||||
TraceManager.instance.init();
|
||||
TraceRecorder.instance.init();
|
||||
|
||||
new WorldEditRendererCUIEditor();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -263,7 +266,7 @@ public class BauSystem extends JavaPlugin {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (TPSFreezeUtils.isFrozen()) return;
|
||||
if (TickManager.impl.isFrozen()) return;
|
||||
if (counter >= delay) {
|
||||
runnable.run();
|
||||
cancel();
|
||||
@ -281,7 +284,7 @@ public class BauSystem extends JavaPlugin {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (TPSFreezeUtils.isFrozen()) return;
|
||||
if (TickManager.impl.isFrozen()) return;
|
||||
if (counter >= (first ? delay : period)) {
|
||||
first = false;
|
||||
runnable.run();
|
||||
|
||||
@ -23,6 +23,7 @@ import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.features.gui.BauGUI;
|
||||
import de.steamwar.bausystem.linkage.specific.BauGuiItem;
|
||||
import de.steamwar.core.TrickyTrialsWrapper;
|
||||
import de.steamwar.data.CMDs;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import de.steamwar.inventory.SWListInv;
|
||||
import de.steamwar.linkage.Linked;
|
||||
@ -74,7 +75,7 @@ public class BauGuiEditor implements Listener {
|
||||
inv.setItem(mapping.getSize() + 5, new SWItem(Material.BARRIER, BauSystem.MESSAGE.parse("GUI_EDITOR_ITEM_TRASH", p), Arrays.asList(BauSystem.MESSAGE.parse("GUI_EDITOR_ITEM_TRASH_LORE", p)), false, clickType -> {
|
||||
}).getItemStack());
|
||||
inv.setItem(mapping.getSize() + 6, new SWItem(TrickyTrialsWrapper.impl.getTurtleScute(), BauSystem.MESSAGE.parse("GUI_EDITOR_ITEM_MORE", p)).getItemStack());
|
||||
inv.setItem(mapping.getSize() + 8, new SWItem(Material.ARROW, BauSystem.MESSAGE.parse("GUI_EDITOR_ITEM_CLOSE", p)).getItemStack());
|
||||
inv.setItem(mapping.getSize() + 8, new SWItem(Material.ARROW, BauSystem.MESSAGE.parse("GUI_EDITOR_ITEM_CLOSE", p)).setCustomModelData(CMDs.BACK).getItemStack());
|
||||
|
||||
p.openInventory(inv);
|
||||
p.getOpenInventory().setCursor(cursor == null ? new SWItem().getItemStack() : cursor);
|
||||
|
||||
@ -20,6 +20,7 @@
|
||||
package de.steamwar.bausystem.features.loader.elements;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.data.CMDs;
|
||||
import de.steamwar.inventory.SWAnvilInv;
|
||||
import de.steamwar.inventory.SWInventory;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
@ -113,7 +114,7 @@ public abstract class LoaderInteractionElement<T extends Enum<T> & LoaderSetting
|
||||
});
|
||||
listInv.setItem(48, new SWItem(Material.ARROW, "§7Back", clickType -> {
|
||||
backAction.run();
|
||||
}));
|
||||
}).setCustomModelData(CMDs.BACK));
|
||||
listInv.setItem(50, new SWItem(Material.GHAST_SPAWN_EGG, "§7Insert another Setting", clickType -> {
|
||||
elements.add(defaultSetting);
|
||||
extraPower.add(0);
|
||||
@ -150,7 +151,7 @@ public abstract class LoaderInteractionElement<T extends Enum<T> & LoaderSetting
|
||||
|
||||
SWInventory swInventory = new SWInventory(player, guiSize, BauSystem.MESSAGE.parse("LOADER_GUI_SETTINGS_TITLE", player));
|
||||
for (int i = guiSize - 9; i < guiSize; i++) swInventory.setItem(i, new SWItem(Material.GRAY_STAINED_GLASS_PANE, "§7", clickType -> {}));
|
||||
swInventory.setItem(guiSize - 9, new SWItem(Material.ARROW, BauSystem.MESSAGE.parse("LOADER_GUI_SETTINGS_BACK", player)).getItemStack(), clickType -> back.run());
|
||||
swInventory.setItem(guiSize - 9, new SWItem(Material.ARROW, BauSystem.MESSAGE.parse("LOADER_GUI_SETTINGS_BACK", player)).setCustomModelData(CMDs.BACK).getItemStack(), clickType -> back.run());
|
||||
swInventory.setItem(guiSize - 5, new SWItem(Material.WOODEN_AXE, BauSystem.MESSAGE.parse("LOADER_GUI_SETTINGS_COPY", player)).getItemStack(), clickType -> {
|
||||
SWAnvilInv swAnvilInv = new SWAnvilInv(player, BauSystem.MESSAGE.parse("LOADER_GUI_COPY_TITLE", player), "1");
|
||||
swAnvilInv.setCallback(s -> {
|
||||
|
||||
@ -21,6 +21,7 @@ package de.steamwar.bausystem.features.loader.elements.impl;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.features.loader.elements.LoaderElement;
|
||||
import de.steamwar.data.CMDs;
|
||||
import de.steamwar.inventory.SWAnvilInv;
|
||||
import de.steamwar.inventory.SWInventory;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
@ -60,7 +61,7 @@ public class LoaderWait implements LoaderElement {
|
||||
public void click(Player player, Runnable backAction) {
|
||||
SWInventory swInventory = new SWInventory(player, 18, BauSystem.MESSAGE.parse("LOADER_GUI_WAIT_TITLE", player));
|
||||
for (int i = 9; i < 18; i++) swInventory.setItem(i, new SWItem(Material.GRAY_STAINED_GLASS_PANE, "§7"));
|
||||
swInventory.setItem(9, new SWItem(Material.ARROW, BauSystem.MESSAGE.parse("LOADER_GUI_WAIT_BACK", player)).getItemStack(), clickType -> backAction.run());
|
||||
swInventory.setItem(9, new SWItem(Material.ARROW, BauSystem.MESSAGE.parse("LOADER_GUI_WAIT_BACK", player)).setCustomModelData(CMDs.BACK).getItemStack(), clickType -> backAction.run());
|
||||
|
||||
swInventory.setItem(3, new SWItem(SWItem.getDye(1), BauSystem.MESSAGE.parse("LOADER_SETTING_TICKS_REMOVE_ONE", player), Arrays.asList(BauSystem.MESSAGE.parse("LOADER_SETTING_TICKS_REMOVE_ONE_SHIFT", player)), false, clickType -> {}).getItemStack(), clickType -> {
|
||||
delay -= clickType.isShiftClick() ? 5 : 1;
|
||||
|
||||
@ -226,7 +226,7 @@ public class FreezeListener implements Listener, ScoreboardElement {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onBlockBreak(BlockBreakEvent e) {
|
||||
if (Core.getVersion() < 19) return;
|
||||
if (e.getPlayer().getInventory().getItemInMainHand().getType() == Material.DEBUG_STICK) return;
|
||||
|
||||
@ -166,6 +166,8 @@ public class SteamWarLuaPlugin extends TwoArgFunction {
|
||||
env.set("rawlen", NIL);
|
||||
env.set("rawset", NIL);
|
||||
env.set("xpcall", NIL);
|
||||
env.set("require", NIL);
|
||||
env.set("package", NIL);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@ -20,6 +20,7 @@
|
||||
package de.steamwar.bausystem.features.script.lua.libs;
|
||||
|
||||
import de.steamwar.bausystem.features.tpslimit.TPSSystem;
|
||||
import de.steamwar.bausystem.utils.TickManager;
|
||||
import de.steamwar.core.TPSWatcher;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.linkage.LinkedInstance;
|
||||
@ -51,7 +52,7 @@ public class TpsLib implements LuaLib {
|
||||
tpsLib.set("fiveMinute", getter(() -> TPSWatcher.getTPS(TPSWatcher.TPSType.FIVE_MINUTES)));
|
||||
tpsLib.set("tenMinute", getter(() -> TPSWatcher.getTPS(TPSWatcher.TPSType.TEN_MINUTES)));
|
||||
tpsLib.set("current", getter(TPSWatcher::getTPS));
|
||||
tpsLib.set("limit", getter(TPSSystem::getCurrentTPSLimit));
|
||||
tpsLib.set("limit", getter(() -> (double) TickManager.impl.getTickRate()));
|
||||
return tpsLib;
|
||||
}
|
||||
}
|
||||
|
||||
@ -76,7 +76,7 @@ public class SimulatorCommand extends SWCommand {
|
||||
|
||||
@Register(value = "start", description = "SIMULATOR_START_HELP")
|
||||
public void start(@Validator Player p, @ErrorMessage("SIMULATOR_NOT_EXISTS") Simulator simulator) {
|
||||
SimulatorExecutor.run(simulator, () -> {});
|
||||
SimulatorExecutor.run(p, simulator, null);
|
||||
}
|
||||
|
||||
@Register(value = "rename", description = "SIMULATOR_RENAME_HELP")
|
||||
|
||||
@ -367,7 +367,7 @@ public class SimulatorCursor implements Listener {
|
||||
if (simulator == null) {
|
||||
return;
|
||||
}
|
||||
SimulatorExecutor.run(simulator, () -> {});
|
||||
SimulatorExecutor.run(event.getPlayer(), simulator, null);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@ -40,9 +40,11 @@ public final class Simulator {
|
||||
private SimulatorStabGenerator stabGenerator = null;
|
||||
private Material material = Material.BARREL;
|
||||
private final String name;
|
||||
private boolean autoTrace = false;
|
||||
private final List<SimulatorGroup> groups = new ArrayList<>();
|
||||
|
||||
private boolean autoTrace = false;
|
||||
private boolean autoTestblock = false;
|
||||
|
||||
public void move(int x, int y, int z) {
|
||||
groups.forEach(simulatorGroup -> {
|
||||
simulatorGroup.move(x, y, z);
|
||||
|
||||
@ -31,6 +31,7 @@ import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.linkage.MinVersion;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
@ -46,7 +47,7 @@ public class SimulatorExecutor implements Listener {
|
||||
private static Map<Long, Map<Integer, List<SimulatorAction>>> tickStartActions = new HashMap<>();
|
||||
private static Map<Long, List<SimulatorAction>> tickEndActions = new HashMap<>();
|
||||
|
||||
public static boolean run(Simulator simulator, Runnable onEnd) {
|
||||
public static boolean run(Player player, Simulator simulator, Runnable onEnd) {
|
||||
if (currentlyRunning.contains(simulator)) return false;
|
||||
currentlyRunning.add(simulator);
|
||||
|
||||
@ -83,10 +84,15 @@ public class SimulatorExecutor implements Listener {
|
||||
});
|
||||
}
|
||||
|
||||
onEnd.run();
|
||||
if (onEnd != null) {
|
||||
onEnd.run();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (player != null && simulator.isAutoTestblock()) {
|
||||
player.performCommand("tb");
|
||||
}
|
||||
if (simulator.isAutoTrace() && onEnd == null) {
|
||||
simulator.getGroups()
|
||||
.stream()
|
||||
|
||||
@ -58,7 +58,7 @@ public abstract class StabStep {
|
||||
protected abstract void start();
|
||||
|
||||
protected final void runSimulator(Runnable onFinish) {
|
||||
SimulatorExecutor.run(data.simulator, () -> {
|
||||
SimulatorExecutor.run(null, data.simulator, () -> {
|
||||
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
|
||||
if (this instanceof Listener) {
|
||||
HandlerList.unregisterAll((Listener) this);
|
||||
|
||||
@ -25,6 +25,7 @@ import de.steamwar.bausystem.features.simulator.data.SimulatorElement;
|
||||
import de.steamwar.bausystem.features.simulator.data.SimulatorGroup;
|
||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
|
||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorPageGui;
|
||||
import de.steamwar.data.CMDs;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -70,12 +71,12 @@ public class SimulatorGroupGui extends SimulatorPageGui<SimulatorElement<?>> {
|
||||
|
||||
inventory.setItem(0, new SWItem(Material.ARROW, "§eBack", clickType -> {
|
||||
back.open();
|
||||
}));
|
||||
}).setCustomModelData(CMDs.BACK));
|
||||
|
||||
inventory.setItem(8, new SWItem(Material.BARRIER, "§eDelete", clickType -> {
|
||||
simulatorGroup.getElements().clear();
|
||||
SimulatorWatcher.update(simulator);
|
||||
}));
|
||||
}).setCustomModelData(CMDs.Simulator.DELETE));
|
||||
|
||||
inventory.setItem(4, simulatorGroup.toItem(player, clickType -> {
|
||||
if (simulatorGroup.getMaterial() == null) return;
|
||||
@ -85,7 +86,7 @@ public class SimulatorGroupGui extends SimulatorPageGui<SimulatorElement<?>> {
|
||||
|
||||
inventory.setItem(48, new SWItem(Material.REPEATER, "§eSettings", clickType -> {
|
||||
new SimulatorGroupSettingsGui(player, simulator, simulatorGroup, this).open();
|
||||
}));
|
||||
}).setCustomModelData(CMDs.Simulator.SETTINGS));
|
||||
boolean disabled = simulatorGroup.getMaterial() == null ? simulatorGroup.getElements().stream().allMatch(SimulatorElement::isDisabled) : simulatorGroup.isDisabled();
|
||||
inventory.setItem(50, new SWItem(disabled ? Material.ENDER_PEARL : Material.ENDER_EYE, simulatorGroup.isDisabled() ? "§cDisabled" : "§aEnabled", clickType -> {
|
||||
if (simulatorGroup.getMaterial() == null) {
|
||||
@ -96,7 +97,7 @@ public class SimulatorGroupGui extends SimulatorPageGui<SimulatorElement<?>> {
|
||||
simulatorGroup.setDisabled(!disabled);
|
||||
}
|
||||
SimulatorWatcher.update(simulator);
|
||||
}));
|
||||
}).setCustomModelData(CMDs.Simulator.ENABLED_OR_DISABLED));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -25,10 +25,10 @@ import de.steamwar.bausystem.features.simulator.data.SimulatorGroup;
|
||||
import de.steamwar.bausystem.features.simulator.data.tnt.TNTElement;
|
||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorAnvilGui;
|
||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
|
||||
import de.steamwar.data.CMDs;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@ -58,7 +58,7 @@ public class SimulatorGroupSettingsGui extends SimulatorBaseGui {
|
||||
// Back Arrow
|
||||
inventory.setItem(0, new SWItem(Material.ARROW, "§eBack", clickType -> {
|
||||
back.open();
|
||||
}));
|
||||
}).setCustomModelData(CMDs.BACK));
|
||||
|
||||
// Material Chooser
|
||||
inventory.setItem(4, simulatorGroup.toItem(player, clickType -> {
|
||||
@ -69,10 +69,10 @@ public class SimulatorGroupSettingsGui extends SimulatorBaseGui {
|
||||
|
||||
// Base Tick
|
||||
int baseTicks = simulatorGroup.getBaseTick();
|
||||
inventory.setItem(9, SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
inventory.setItem(9, new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
simulatorGroup.changeBaseTicks(clickType.isShiftClick() ? 5 : 1);
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
|
||||
SWItem baseTick = new SWItem(Material.REPEATER, "§eTicks§8:§7 " + baseTicks, clickType -> {
|
||||
new SimulatorAnvilGui<>(player, "Ticks", baseTicks + "", Integer::parseInt, integer -> {
|
||||
if (integer < 0) return false;
|
||||
@ -83,14 +83,14 @@ public class SimulatorGroupSettingsGui extends SimulatorBaseGui {
|
||||
});
|
||||
baseTick.getItemStack().setAmount(Math.max(1, Math.min(baseTicks, 64)));
|
||||
inventory.setItem(18, baseTick);
|
||||
inventory.setItem(27, SWItem.getDye(baseTicks > 0 ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
inventory.setItem(27, new SWItem(SWItem.getDye(baseTicks > 0 ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
if (baseTicks - (clickType.isShiftClick() ? 5 : 1) < 0) {
|
||||
simulatorGroup.changeBaseTicks(-baseTicks);
|
||||
} else {
|
||||
simulatorGroup.changeBaseTicks(clickType.isShiftClick() ? -5 : -1);
|
||||
}
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||
|
||||
boolean allTNT = simulatorGroup.getElements().stream().allMatch(TNTElement.class::isInstance);
|
||||
|
||||
@ -163,10 +163,10 @@ public class SimulatorGroupSettingsGui extends SimulatorBaseGui {
|
||||
}
|
||||
|
||||
//Pos X
|
||||
inventory.setItem(15, SWItem.getDye(10), "§e+1", Arrays.asList(allTNT ? "§7Shift§8: §e+0.0625" : "§7Shift§8: §e+5"), false, clickType -> {
|
||||
inventory.setItem(15, new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList(allTNT ? "§7Shift§8: §e+0.0625" : "§7Shift§8: §e+5"), false, clickType -> {
|
||||
simulatorGroup.move(clickType.isShiftClick() ? (allTNT ? 0.0625 : 5) : 1, 0, 0);
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
|
||||
inventory.setItem(24, new SWItem(Material.PAPER, "§eX", clickType -> {
|
||||
new SimulatorAnvilGui<>(player, "Relative X", "", Double::parseDouble, number -> {
|
||||
if(!allTNT){
|
||||
@ -177,16 +177,16 @@ public class SimulatorGroupSettingsGui extends SimulatorBaseGui {
|
||||
return true;
|
||||
}, this).setItem(Material.PAPER).open();
|
||||
}));
|
||||
inventory.setItem(33, SWItem.getDye(1), "§e-1", Arrays.asList(allTNT ? "§7Shift§8: §e-0.0625" : "§7Shift§8: §e-5"), false, clickType -> {
|
||||
inventory.setItem(33, new SWItem(SWItem.getDye(1), "§e-1", Arrays.asList(allTNT ? "§7Shift§8: §e-0.0625" : "§7Shift§8: §e-5"), false, clickType -> {
|
||||
simulatorGroup.move(clickType.isShiftClick() ? (allTNT ? -0.0625 : -5) : -1, 0, 0);
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||
|
||||
//Pos Y
|
||||
inventory.setItem(16, SWItem.getDye(10), "§e+1", Arrays.asList(allTNT ? "§7Shift§8: §e+0.0625" : "§7Shift§8: §e+5"), false, clickType -> {
|
||||
inventory.setItem(16, new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList(allTNT ? "§7Shift§8: §e+0.0625" : "§7Shift§8: §e+5"), false, clickType -> {
|
||||
simulatorGroup.move(0, clickType.isShiftClick() ? (allTNT ? 0.0625 : 5) : 1, 0);
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
|
||||
inventory.setItem(25, new SWItem(Material.PAPER, "§eY", clickType -> {
|
||||
new SimulatorAnvilGui<>(player, "Relative Y", "", Double::parseDouble, number -> {
|
||||
if(!allTNT){
|
||||
@ -197,16 +197,16 @@ public class SimulatorGroupSettingsGui extends SimulatorBaseGui {
|
||||
return true;
|
||||
}, this).setItem(Material.PAPER).open();
|
||||
}));
|
||||
inventory.setItem(34, SWItem.getDye(1), "§e-1", Arrays.asList(allTNT ? "§7Shift§8: §e-0.0625" : "§7Shift§8: §e-5"), false, clickType -> {
|
||||
inventory.setItem(34, new SWItem(SWItem.getDye(1), "§e-1", Arrays.asList(allTNT ? "§7Shift§8: §e-0.0625" : "§7Shift§8: §e-5"), false, clickType -> {
|
||||
simulatorGroup.move(0, clickType.isShiftClick() ? (allTNT ? -0.0625 : -5) : -1, 0);
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
}).setCustomModelData(CMDs.Simulator.ENABLED_OR_DISABLED));
|
||||
|
||||
//Pos Z
|
||||
inventory.setItem(17, SWItem.getDye(10), "§e+1", Arrays.asList(allTNT ? "§7Shift§8: §e+0.0625" : "§7Shift§8: §e+5"), false, clickType -> {
|
||||
inventory.setItem(17, new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList(allTNT ? "§7Shift§8: §e+0.0625" : "§7Shift§8: §e+5"), false, clickType -> {
|
||||
simulatorGroup.move(0, 0, clickType.isShiftClick() ? (allTNT ? 0.0625 : 5) : 1);
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
|
||||
inventory.setItem(26, new SWItem(Material.PAPER, "§eZ", clickType -> {
|
||||
new SimulatorAnvilGui<>(player, "Relative Z", "", Double::parseDouble, number -> {
|
||||
if(!allTNT){
|
||||
@ -217,9 +217,9 @@ public class SimulatorGroupSettingsGui extends SimulatorBaseGui {
|
||||
return true;
|
||||
}, this).setItem(Material.PAPER).open();
|
||||
}));
|
||||
inventory.setItem(35, SWItem.getDye(1), "§e-1", Arrays.asList(allTNT ? "§7Shift§8: §e-0.0625" : "§7Shift§8: §e-5"), false, clickType -> {
|
||||
inventory.setItem(35, new SWItem(SWItem.getDye(1), "§e-1", Arrays.asList(allTNT ? "§7Shift§8: §e-0.0625" : "§7Shift§8: §e-5"), false, clickType -> {
|
||||
simulatorGroup.move(0, 0, clickType.isShiftClick() ? (allTNT ? -0.0625 : -5) : -1);
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||
}
|
||||
}
|
||||
|
||||
@ -24,6 +24,7 @@ import de.steamwar.bausystem.features.simulator.data.Simulator;
|
||||
import de.steamwar.bausystem.features.simulator.data.SimulatorElement;
|
||||
import de.steamwar.bausystem.features.simulator.data.SimulatorGroup;
|
||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorPageGui;
|
||||
import de.steamwar.data.CMDs;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -50,7 +51,7 @@ public class SimulatorGui extends SimulatorPageGui<SimulatorGroup> {
|
||||
}));
|
||||
inventory.setItem(49, new SWItem(Material.REPEATER, "§eSettings", clickType -> {
|
||||
new SimulatorSettingsGui(player, simulator, this).open();
|
||||
}));
|
||||
}).setCustomModelData(CMDs.Simulator.SETTINGS));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -23,6 +23,7 @@ import de.steamwar.bausystem.features.simulator.SimulatorWatcher;
|
||||
import de.steamwar.bausystem.features.simulator.data.Simulator;
|
||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
|
||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorPageGui;
|
||||
import de.steamwar.data.CMDs;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -75,7 +76,7 @@ public class SimulatorMaterialGui extends SimulatorPageGui<Material> {
|
||||
}));
|
||||
inventory.setItem(0, new SWItem(Material.ARROW, "§eBack", clickType -> {
|
||||
back.open();
|
||||
}));
|
||||
}).setCustomModelData(CMDs.BACK));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -26,6 +26,7 @@ import de.steamwar.bausystem.features.simulator.data.observer.ObserverElement;
|
||||
import de.steamwar.bausystem.features.simulator.data.observer.ObserverPhase;
|
||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
|
||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorScrollGui;
|
||||
import de.steamwar.data.CMDs;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -82,12 +83,12 @@ public class SimulatorObserverGui extends SimulatorScrollGui<ObserverPhase> {
|
||||
new SimulatorGroupGui(player, simulator, newParent, simulatorGui).open();
|
||||
}
|
||||
}
|
||||
}));
|
||||
}).setCustomModelData(CMDs.BACK));
|
||||
|
||||
inventory.setItem(8, new SWItem(Material.BARRIER, "§eDelete", clickType -> {
|
||||
observer.getPhases().clear();
|
||||
SimulatorWatcher.update(simulator);
|
||||
}));
|
||||
}).setCustomModelData(CMDs.Simulator.DELETE));
|
||||
|
||||
// Material Chooser
|
||||
inventory.setItem(4, observer.toItem(player, clickType -> {
|
||||
@ -97,18 +98,18 @@ public class SimulatorObserverGui extends SimulatorScrollGui<ObserverPhase> {
|
||||
// Settings
|
||||
inventory.setItem(47, new SWItem(Material.REPEATER, "§eSettings", clickType -> {
|
||||
new SimulatorObserverSettingsGui(player, simulator, observer, this).open();
|
||||
}));
|
||||
}).setCustomModelData(CMDs.Simulator.SETTINGS));
|
||||
|
||||
// Enable/Disable
|
||||
inventory.setItem(48, new SWItem(observer.isDisabled() ? Material.ENDER_PEARL : Material.ENDER_EYE, observer.isDisabled() ? "§cDisabled" : "§aEnabled", clickType -> {
|
||||
observer.setDisabled(!observer.isDisabled());
|
||||
SimulatorWatcher.update(simulator);
|
||||
}));
|
||||
}).setCustomModelData(CMDs.Simulator.ENABLED_OR_DISABLED));
|
||||
|
||||
// Group chooser
|
||||
inventory.setItem(51, new SWItem(Material.LEAD, "§eJoin Group", clickType -> {
|
||||
new SimulatorGroupChooserGui(player, simulator, observer, observer.getGroup(simulator), this).open();
|
||||
}));
|
||||
}).setCustomModelData(CMDs.Simulator.JOIN_GROUP));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -151,15 +152,15 @@ public class SimulatorObserverGui extends SimulatorScrollGui<ObserverPhase> {
|
||||
new SWItem(SWItem.getDye(getter.get() < max ? 10 : 8), "§e+1", Arrays.asList("§7Shift§8:§e +5"), false, clickType -> {
|
||||
setter.accept(Math.min(max, getter.get() + (clickType.isShiftClick() ? 5 : 1)));
|
||||
SimulatorWatcher.update(simulator);
|
||||
}),
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED),
|
||||
observer,
|
||||
new SWItem(SWItem.getDye(getter.get() > min ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8:§e -5"), false, clickType -> {
|
||||
setter.accept(Math.max(min, getter.get() - (clickType.isShiftClick() ? 5 : 1)));
|
||||
SimulatorWatcher.update(simulator);
|
||||
}),
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED),
|
||||
new SWItem(Material.ANVIL, "§eEdit Activation", clickType -> {
|
||||
new SimulatorObserverPhaseSettingsGui(player, simulator, this.observer, observerPhase, this).open();
|
||||
}),
|
||||
}).setCustomModelData(CMDs.Simulator.EDIT_ACTIVATION),
|
||||
};
|
||||
}
|
||||
|
||||
@ -168,12 +169,12 @@ public class SimulatorObserverGui extends SimulatorScrollGui<ObserverPhase> {
|
||||
return new SWItem[]{
|
||||
new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8:§e +5"), false, clickType -> {
|
||||
addNewPhase(clickType.isShiftClick());
|
||||
}),
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED),
|
||||
new SWItem(Material.QUARTZ, "§eObserver§8:§a New Phase", clickType -> {
|
||||
addNewPhase(false);
|
||||
}),
|
||||
}).setCustomModelData(CMDs.Simulator.NEW_PHASE),
|
||||
new SWItem(SWItem.getDye(8), "§7", clickType -> {
|
||||
}),
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -27,6 +27,7 @@ import de.steamwar.bausystem.features.simulator.data.observer.ObserverPhase;
|
||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorAnvilGui;
|
||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
|
||||
import de.steamwar.core.Core;
|
||||
import de.steamwar.data.CMDs;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.BlockFace;
|
||||
@ -62,7 +63,7 @@ public class SimulatorObserverPhaseSettingsGui extends SimulatorBaseGui {
|
||||
// Back Arrow
|
||||
inventory.setItem(0, new SWItem(Material.ARROW, "§eBack", clickType -> {
|
||||
back.open();
|
||||
}));
|
||||
}).setCustomModelData(CMDs.BACK));
|
||||
|
||||
// Material Chooser
|
||||
inventory.setItem(4, observerElement.toItem(player, clickType -> {
|
||||
@ -74,7 +75,7 @@ public class SimulatorObserverPhaseSettingsGui extends SimulatorBaseGui {
|
||||
observerElement.getPhases().remove(observer);
|
||||
back.open();
|
||||
SimulatorWatcher.update(simulator);
|
||||
}));
|
||||
}).setCustomModelData(CMDs.Simulator.DELETE));
|
||||
|
||||
int index = observerElement.getPhases().indexOf(observer);
|
||||
int min;
|
||||
@ -95,10 +96,10 @@ public class SimulatorObserverPhaseSettingsGui extends SimulatorBaseGui {
|
||||
|
||||
//Tick Offset
|
||||
int offset = observer.getTickOffset();
|
||||
inventory.setItem(10, SWItem.getDye(offset < max ? 10 : 8), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
inventory.setItem(10, new SWItem(SWItem.getDye(offset < max ? 10 : 8), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
observer.setTickOffset(Math.min(max, offset + (clickType.isShiftClick() ? 5 : 1)));
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
|
||||
|
||||
SWItem offsetItem = new SWItem(Material.REPEATER, "§eStart at§8:§7 " + offset, clickType -> {
|
||||
new SimulatorAnvilGui<>(player, "Start at", offset + "", Integer::parseInt, integer -> {
|
||||
@ -111,17 +112,17 @@ public class SimulatorObserverPhaseSettingsGui extends SimulatorBaseGui {
|
||||
offsetItem.getItemStack().setAmount(Math.max(1, Math.min(offset, 64)));
|
||||
inventory.setItem(19, offsetItem);
|
||||
|
||||
inventory.setItem(28, SWItem.getDye(offset > min ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
inventory.setItem(28, new SWItem(SWItem.getDye(offset > min ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
observer.setTickOffset(Math.max(min, offset - (clickType.isShiftClick() ? 5 : 1)));
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||
|
||||
//Order
|
||||
int order = observer.getOrder();
|
||||
inventory.setItem(13, SWItem.getDye(order < SimulatorPhase.ORDER_LIMIT ? 10 : 8), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
inventory.setItem(13, new SWItem(SWItem.getDye(order < SimulatorPhase.ORDER_LIMIT ? 10 : 8), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
observer.setOrder(Math.min(SimulatorPhase.ORDER_LIMIT, order + (clickType.isShiftClick() ? 5 : 1)));
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
|
||||
|
||||
Material negativeNumbers = Material.getMaterial(Core.getVersion() >= 19 ? "RECOVERY_COMPASS" : "FIREWORK_STAR");
|
||||
SWItem orderItem = new SWItem(order >= 0 ? Material.COMPASS : negativeNumbers, "§eActivation Order§8:§7 " + order, clickType -> {
|
||||
@ -136,10 +137,10 @@ public class SimulatorObserverPhaseSettingsGui extends SimulatorBaseGui {
|
||||
orderItem.getItemStack().setAmount(Math.max(1, Math.min(Math.abs(order), 30)));
|
||||
inventory.setItem(22, orderItem);
|
||||
|
||||
inventory.setItem(31, SWItem.getDye(order > -SimulatorPhase.ORDER_LIMIT ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
inventory.setItem(31, new SWItem(SWItem.getDye(order > -SimulatorPhase.ORDER_LIMIT ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
observer.setOrder(Math.max(-SimulatorPhase.ORDER_LIMIT, order - (clickType.isShiftClick() ? 5 : 1)));
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||
|
||||
// Update orientation
|
||||
inventory.setItem(25, new SWItem(Material.SUNFLOWER, "§7", clickType -> {
|
||||
|
||||
@ -24,6 +24,7 @@ import de.steamwar.bausystem.features.simulator.data.Simulator;
|
||||
import de.steamwar.bausystem.features.simulator.data.observer.ObserverElement;
|
||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorAnvilGui;
|
||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
|
||||
import de.steamwar.data.CMDs;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -56,7 +57,7 @@ public class SimulatorObserverSettingsGui extends SimulatorBaseGui {
|
||||
// Back Arrow
|
||||
inventory.setItem(0, new SWItem(Material.ARROW, "§eBack", clickType -> {
|
||||
back.open();
|
||||
}));
|
||||
}).setCustomModelData(CMDs.BACK));
|
||||
|
||||
// Material Chooser
|
||||
inventory.setItem(4, observer.toItem(player, clickType -> {
|
||||
@ -65,10 +66,10 @@ public class SimulatorObserverSettingsGui extends SimulatorBaseGui {
|
||||
|
||||
// Base Tick
|
||||
int baseTicks = observer.getBaseTick();
|
||||
inventory.setItem(9, SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
inventory.setItem(9, new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
observer.changeBaseTicks(clickType.isShiftClick() ? 5 : 1);
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
|
||||
SWItem baseTick = new SWItem(Material.REPEATER, "§eTicks§8:§7 " + baseTicks, clickType -> {
|
||||
new SimulatorAnvilGui<>(player, "Ticks", baseTicks + "", Integer::parseInt, integer -> {
|
||||
if (integer < 0) return false;
|
||||
@ -79,20 +80,20 @@ public class SimulatorObserverSettingsGui extends SimulatorBaseGui {
|
||||
});
|
||||
baseTick.getItemStack().setAmount(Math.max(1, Math.min(baseTicks, 64)));
|
||||
inventory.setItem(18, baseTick);
|
||||
inventory.setItem(27, SWItem.getDye(baseTicks > 0 ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
inventory.setItem(27, new SWItem(SWItem.getDye(baseTicks > 0 ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
if (baseTicks - (clickType.isShiftClick() ? 5 : 1) < 0) {
|
||||
observer.changeBaseTicks(-baseTicks);
|
||||
} else {
|
||||
observer.changeBaseTicks(clickType.isShiftClick() ? -5 : -1);
|
||||
}
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||
|
||||
//Pos X
|
||||
inventory.setItem(15, SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
inventory.setItem(15, new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
observer.move(clickType.isShiftClick() ? 5 : 1, 0, 0);
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
|
||||
inventory.setItem(24, new SWItem(Material.PAPER, "§eX§8:§7 " + observer.getPosition().getBlockX(), clickType -> {
|
||||
new SimulatorAnvilGui<>(player, "X", observer.getPosition().getBlockX() + "", Integer::parseInt, i -> {
|
||||
observer.getPosition().setX(i);
|
||||
@ -100,16 +101,16 @@ public class SimulatorObserverSettingsGui extends SimulatorBaseGui {
|
||||
return true;
|
||||
}, this).open();
|
||||
}));
|
||||
inventory.setItem(33, SWItem.getDye(1), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
inventory.setItem(33, new SWItem(SWItem.getDye(1), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
observer.move(clickType.isShiftClick() ? -5 : -1, 0, 0);
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||
|
||||
//Pos Y
|
||||
inventory.setItem(16, SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
inventory.setItem(16, new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
observer.move(0, clickType.isShiftClick() ? 5 : 1, 0);
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
}).setCustomModelData(CMDs.Simulator.ENABLED_OR_DISABLED));
|
||||
inventory.setItem(25, new SWItem(Material.PAPER, "§eY§8:§7 " + observer.getPosition().getBlockY(), clickType -> {
|
||||
new SimulatorAnvilGui<>(player, "Y", observer.getPosition().getBlockY() + "", Integer::parseInt, i -> {
|
||||
observer.getPosition().setY(i);
|
||||
@ -117,16 +118,16 @@ public class SimulatorObserverSettingsGui extends SimulatorBaseGui {
|
||||
return true;
|
||||
}, this).open();
|
||||
}));
|
||||
inventory.setItem(34, SWItem.getDye(1), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
inventory.setItem(34, new SWItem(SWItem.getDye(1), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
observer.move(0, clickType.isShiftClick() ? -5 : -1, 0);
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||
|
||||
//Pos Z
|
||||
inventory.setItem(17, SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
inventory.setItem(17, new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
observer.move(0, 0, clickType.isShiftClick() ? 5 : 1);
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
}).setCustomModelData(CMDs.Simulator.ENABLED_OR_DISABLED));
|
||||
inventory.setItem(26, new SWItem(Material.PAPER, "§eZ§8:§7 " + observer.getPosition().getBlockZ(), clickType -> {
|
||||
new SimulatorAnvilGui<>(player, "Z", observer.getPosition().getBlockZ() + "", Integer::parseInt, i -> {
|
||||
observer.getPosition().setZ(i);
|
||||
@ -134,9 +135,9 @@ public class SimulatorObserverSettingsGui extends SimulatorBaseGui {
|
||||
return true;
|
||||
}, this).open();
|
||||
}));
|
||||
inventory.setItem(35, SWItem.getDye(1), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
inventory.setItem(35, new SWItem(SWItem.getDye(1), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
observer.move(0, 0, clickType.isShiftClick() ? -5 : -1);
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||
}
|
||||
}
|
||||
|
||||
@ -26,6 +26,7 @@ import de.steamwar.bausystem.features.simulator.data.redstone.RedstoneElement;
|
||||
import de.steamwar.bausystem.features.simulator.data.redstone.RedstonePhase;
|
||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
|
||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorScrollGui;
|
||||
import de.steamwar.data.CMDs;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.bukkit.Material;
|
||||
@ -88,12 +89,12 @@ public class SimulatorRedstoneGui extends SimulatorScrollGui<SimulatorRedstoneGu
|
||||
new SimulatorGroupGui(player, simulator, newParent, simulatorGui).open();
|
||||
}
|
||||
}
|
||||
}));
|
||||
}).setCustomModelData(CMDs.BACK));
|
||||
|
||||
inventory.setItem(8, new SWItem(Material.BARRIER, "§eDelete", clickType -> {
|
||||
redstone.getPhases().clear();
|
||||
SimulatorWatcher.update(simulator);
|
||||
}));
|
||||
}).setCustomModelData(CMDs.Simulator.DELETE));
|
||||
|
||||
// Material Chooser
|
||||
inventory.setItem(4, redstone.toItem(player, clickType -> {
|
||||
@ -103,18 +104,18 @@ public class SimulatorRedstoneGui extends SimulatorScrollGui<SimulatorRedstoneGu
|
||||
// Settings
|
||||
inventory.setItem(47, new SWItem(Material.REPEATER, "§eSettings", clickType -> {
|
||||
new SimulatorRedstoneSettingsGui(player, simulator, redstone, this).open();
|
||||
}));
|
||||
}).setCustomModelData(CMDs.Simulator.SETTINGS));
|
||||
|
||||
// Enable/Disable
|
||||
inventory.setItem(48, new SWItem(redstone.isDisabled() ? Material.ENDER_PEARL : Material.ENDER_EYE, redstone.isDisabled() ? "§cDisabled" : "§aEnabled", clickType -> {
|
||||
redstone.setDisabled(!redstone.isDisabled());
|
||||
SimulatorWatcher.update(simulator);
|
||||
}));
|
||||
}).setCustomModelData(CMDs.Simulator.ENABLED_OR_DISABLED));
|
||||
|
||||
// Group chooser
|
||||
inventory.setItem(51, new SWItem(Material.LEAD, "§eJoin Group", clickType -> {
|
||||
new SimulatorGroupChooserGui(player, simulator, redstone, redstone.getGroup(simulator), this).open();
|
||||
}));
|
||||
}).setCustomModelData(CMDs.Simulator.JOIN_GROUP));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -166,15 +167,15 @@ public class SimulatorRedstoneGui extends SimulatorScrollGui<SimulatorRedstoneGu
|
||||
new SWItem(SWItem.getDye(getter.get() < max ? 10 : 8), "§e+1", Arrays.asList("§7Shift§8:§e +5"), false, clickType -> {
|
||||
setter.accept(Math.min(max, getter.get() + (clickType.isShiftClick() ? 5 : 1)));
|
||||
SimulatorWatcher.update(simulator);
|
||||
}),
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED),
|
||||
redstone,
|
||||
new SWItem(SWItem.getDye(getter.get() > min ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8:§e -5"), false, clickType -> {
|
||||
setter.accept(Math.max(min, getter.get() - (clickType.isShiftClick() ? 5 : 1)));
|
||||
SimulatorWatcher.update(simulator);
|
||||
}),
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED),
|
||||
new SWItem(Material.ANVIL, "§eEdit Activation", clickType -> {
|
||||
new SimulatorRedstonePhaseSettingsGui(player, simulator, this.redstone, redstoneSubPhase.phase, this).open();
|
||||
}),
|
||||
}).setCustomModelData(CMDs.Simulator.EDIT_ACTIVATION),
|
||||
};
|
||||
}
|
||||
|
||||
@ -183,12 +184,12 @@ public class SimulatorRedstoneGui extends SimulatorScrollGui<SimulatorRedstoneGu
|
||||
return new SWItem[]{
|
||||
new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8:§e +5"), false, clickType -> {
|
||||
addNewPhase(clickType.isShiftClick());
|
||||
}),
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED),
|
||||
new SWItem(Material.REDSTONE, "§eRedstone§8:§a New Phase", clickType -> {
|
||||
addNewPhase(false);
|
||||
}),
|
||||
}).setCustomModelData(CMDs.Simulator.NEW_PHASE),
|
||||
new SWItem(SWItem.getDye(8), "§7", clickType -> {
|
||||
}),
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -27,6 +27,7 @@ import de.steamwar.bausystem.features.simulator.data.redstone.RedstonePhase;
|
||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorAnvilGui;
|
||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
|
||||
import de.steamwar.core.Core;
|
||||
import de.steamwar.data.CMDs;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -60,7 +61,7 @@ public class SimulatorRedstonePhaseSettingsGui extends SimulatorBaseGui {
|
||||
// Back Arrow
|
||||
inventory.setItem(0, new SWItem(Material.ARROW, "§eBack", clickType -> {
|
||||
back.open();
|
||||
}));
|
||||
}).setCustomModelData(CMDs.BACK));
|
||||
|
||||
// Material Chooser
|
||||
inventory.setItem(4, redstoneElement.toItem(player, clickType -> {
|
||||
@ -72,7 +73,7 @@ public class SimulatorRedstonePhaseSettingsGui extends SimulatorBaseGui {
|
||||
redstoneElement.getPhases().remove(redstone);
|
||||
back.open();
|
||||
SimulatorWatcher.update(simulator);
|
||||
}));
|
||||
}).setCustomModelData(CMDs.Simulator.DELETE));
|
||||
|
||||
int index = redstoneElement.getPhases().indexOf(redstone);
|
||||
int min;
|
||||
@ -96,10 +97,10 @@ public class SimulatorRedstonePhaseSettingsGui extends SimulatorBaseGui {
|
||||
|
||||
//Tick Offset
|
||||
int offset = redstone.getTickOffset();
|
||||
inventory.setItem(10, SWItem.getDye(offset < maxOffset ? 10 : 8), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
inventory.setItem(10, new SWItem(SWItem.getDye(offset < maxOffset ? 10 : 8), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
redstone.setTickOffset(Math.min(maxOffset, offset + (clickType.isShiftClick() ? 5 : 1)));
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
|
||||
|
||||
SWItem offsetItem = new SWItem(Material.REPEATER, "§eStart at§8:§7 " + offset, clickType -> {
|
||||
new SimulatorAnvilGui<>(player, "Start at", offset + "", Integer::parseInt, integer -> {
|
||||
@ -112,17 +113,17 @@ public class SimulatorRedstonePhaseSettingsGui extends SimulatorBaseGui {
|
||||
offsetItem.getItemStack().setAmount(Math.max(1, Math.min(offset, 64)));
|
||||
inventory.setItem(19, offsetItem);
|
||||
|
||||
inventory.setItem(28, SWItem.getDye(offset > min ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
inventory.setItem(28, new SWItem(SWItem.getDye(offset > min ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
redstone.setTickOffset(Math.max(min, offset - (clickType.isShiftClick() ? 5 : 1)));
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||
|
||||
//Lifetime
|
||||
int lifetime = redstone.getLifetime();
|
||||
inventory.setItem(11, SWItem.getDye(lifetime < maxLifetime ? 10 : 8), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
inventory.setItem(11, new SWItem(SWItem.getDye(lifetime < maxLifetime ? 10 : 8), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
redstone.setLifetime(Math.min(maxLifetime, lifetime + (clickType.isShiftClick() ? 5 : 1)));
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
|
||||
|
||||
SWItem lifetimeItem = new SWItem(Material.CLOCK, "§eActivation Time§8:§7 " + lifetime, clickType -> {
|
||||
new SimulatorAnvilGui<>(player, "Activation Time", lifetime + "", Integer::parseInt, integer -> {
|
||||
@ -135,17 +136,17 @@ public class SimulatorRedstonePhaseSettingsGui extends SimulatorBaseGui {
|
||||
lifetimeItem.getItemStack().setAmount(Math.max(1, Math.min(lifetime, 64)));
|
||||
inventory.setItem(20, lifetimeItem);
|
||||
|
||||
inventory.setItem(29, SWItem.getDye(lifetime > 0 ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
inventory.setItem(29, new SWItem(SWItem.getDye(lifetime > 0 ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
redstone.setLifetime(Math.max(0, lifetime - (clickType.isShiftClick() ? 5 : 1)));
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||
|
||||
//Order
|
||||
int order = redstone.getOrder();
|
||||
inventory.setItem(13, SWItem.getDye(order < SimulatorPhase.ORDER_LIMIT ? 10 : 8), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
inventory.setItem(13, new SWItem(SWItem.getDye(order < SimulatorPhase.ORDER_LIMIT ? 10 : 8), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
redstone.setOrder(Math.min(SimulatorPhase.ORDER_LIMIT, order + (clickType.isShiftClick() ? 5 : 1)));
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
|
||||
|
||||
Material negativeNumbers = Material.getMaterial(Core.getVersion() >= 19 ? "RECOVERY_COMPASS" : "FIREWORK_STAR");
|
||||
SWItem orderItem = new SWItem(order >= 0 ? Material.COMPASS : negativeNumbers, "§eActivation Order§8:§7 " + order, clickType -> {
|
||||
@ -160,9 +161,9 @@ public class SimulatorRedstonePhaseSettingsGui extends SimulatorBaseGui {
|
||||
orderItem.getItemStack().setAmount(Math.max(1, Math.min(Math.abs(order), 30)));
|
||||
inventory.setItem(22, orderItem);
|
||||
|
||||
inventory.setItem(31, SWItem.getDye(order > -SimulatorPhase.ORDER_LIMIT ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
inventory.setItem(31, new SWItem(SWItem.getDye(order > -SimulatorPhase.ORDER_LIMIT ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
redstone.setOrder(Math.max(-SimulatorPhase.ORDER_LIMIT, order - (clickType.isShiftClick() ? 5 : 1)));
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||
}
|
||||
}
|
||||
|
||||
@ -24,6 +24,7 @@ import de.steamwar.bausystem.features.simulator.data.Simulator;
|
||||
import de.steamwar.bausystem.features.simulator.data.redstone.RedstoneElement;
|
||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorAnvilGui;
|
||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
|
||||
import de.steamwar.data.CMDs;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -55,7 +56,7 @@ public class SimulatorRedstoneSettingsGui extends SimulatorBaseGui {
|
||||
// Back Arrow
|
||||
inventory.setItem(0, new SWItem(Material.ARROW, "§eBack", clickType -> {
|
||||
back.open();
|
||||
}));
|
||||
}).setCustomModelData(CMDs.BACK));
|
||||
|
||||
// Material Chooser
|
||||
inventory.setItem(4, redstone.toItem(player, clickType -> {
|
||||
@ -64,10 +65,10 @@ public class SimulatorRedstoneSettingsGui extends SimulatorBaseGui {
|
||||
|
||||
// Base Tick
|
||||
int baseTicks = redstone.getBaseTick();
|
||||
inventory.setItem(9, SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
inventory.setItem(9, new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
redstone.changeBaseTicks(clickType.isShiftClick() ? 5 : 1);
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
|
||||
SWItem baseTick = new SWItem(Material.REPEATER, "§eTicks§8:§7 " + baseTicks, clickType -> {
|
||||
new SimulatorAnvilGui<>(player, "Ticks", baseTicks + "", Integer::parseInt, integer -> {
|
||||
if (integer < 0) return false;
|
||||
@ -78,20 +79,20 @@ public class SimulatorRedstoneSettingsGui extends SimulatorBaseGui {
|
||||
});
|
||||
baseTick.getItemStack().setAmount(Math.max(1, Math.min(baseTicks, 64)));
|
||||
inventory.setItem(18, baseTick);
|
||||
inventory.setItem(27, SWItem.getDye(baseTicks > 0 ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
inventory.setItem(27, new SWItem(SWItem.getDye(baseTicks > 0 ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
if (baseTicks - (clickType.isShiftClick() ? 5 : 1) < 0) {
|
||||
redstone.changeBaseTicks(-baseTicks);
|
||||
} else {
|
||||
redstone.changeBaseTicks(clickType.isShiftClick() ? -5 : -1);
|
||||
}
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||
|
||||
//Pos X
|
||||
inventory.setItem(15, SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
inventory.setItem(15, new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
redstone.move(clickType.isShiftClick() ? 5 : 1, 0, 0);
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
|
||||
inventory.setItem(24, new SWItem(Material.PAPER, "§eX§8:§7 " + redstone.getPosition().getBlockX(), clickType -> {
|
||||
new SimulatorAnvilGui<>(player, "X", redstone.getPosition().getBlockX() + "", Integer::parseInt, i -> {
|
||||
redstone.getPosition().setX(i);
|
||||
@ -99,16 +100,16 @@ public class SimulatorRedstoneSettingsGui extends SimulatorBaseGui {
|
||||
return true;
|
||||
}, this).open();
|
||||
}));
|
||||
inventory.setItem(33, SWItem.getDye(1), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
inventory.setItem(33, new SWItem(SWItem.getDye(1), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
redstone.move(clickType.isShiftClick() ? -5 : -1, 0, 0);
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||
|
||||
//Pos Y
|
||||
inventory.setItem(16, SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
inventory.setItem(16, new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
redstone.move(0, clickType.isShiftClick() ? 5 : 1, 0);
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
|
||||
inventory.setItem(25, new SWItem(Material.PAPER, "§eY§8:§7 " + redstone.getPosition().getBlockY(), clickType -> {
|
||||
new SimulatorAnvilGui<>(player, "Y", redstone.getPosition().getBlockY() + "", Integer::parseInt, i -> {
|
||||
redstone.getPosition().setY(i);
|
||||
@ -116,16 +117,16 @@ public class SimulatorRedstoneSettingsGui extends SimulatorBaseGui {
|
||||
return true;
|
||||
}, this).open();
|
||||
}));
|
||||
inventory.setItem(34, SWItem.getDye(1), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
inventory.setItem(34, new SWItem(SWItem.getDye(1), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
redstone.move(0, clickType.isShiftClick() ? -5 : -1, 0);
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||
|
||||
//Pos Z
|
||||
inventory.setItem(17, SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
inventory.setItem(17, new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
redstone.move(0, 0, clickType.isShiftClick() ? 5 : 1);
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
|
||||
inventory.setItem(26, new SWItem(Material.PAPER, "§eZ§8:§7 " + redstone.getPosition().getBlockZ(), clickType -> {
|
||||
new SimulatorAnvilGui<>(player, "Z", redstone.getPosition().getBlockZ() + "", Integer::parseInt, i -> {
|
||||
redstone.getPosition().setZ(i);
|
||||
@ -133,9 +134,9 @@ public class SimulatorRedstoneSettingsGui extends SimulatorBaseGui {
|
||||
return true;
|
||||
}, this).open();
|
||||
}));
|
||||
inventory.setItem(35, SWItem.getDye(1), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
inventory.setItem(35, new SWItem(SWItem.getDye(1), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
redstone.move(0, 0, clickType.isShiftClick() ? -5 : -1);
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||
}
|
||||
}
|
||||
|
||||
@ -22,6 +22,7 @@ package de.steamwar.bausystem.features.simulator.gui;
|
||||
import de.steamwar.bausystem.features.simulator.SimulatorWatcher;
|
||||
import de.steamwar.bausystem.features.simulator.data.Simulator;
|
||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
|
||||
import de.steamwar.data.CMDs;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -47,7 +48,7 @@ public class SimulatorSettingsGui extends SimulatorBaseGui {
|
||||
// Back Arrow
|
||||
inventory.setItem(0, new SWItem(Material.ARROW, "§eBack", clickType -> {
|
||||
back.open();
|
||||
}));
|
||||
}).setCustomModelData(CMDs.BACK));
|
||||
|
||||
// Material Chooser
|
||||
inventory.setItem(4, simulator.toItem(player, clickType -> {
|
||||
@ -55,45 +56,49 @@ public class SimulatorSettingsGui extends SimulatorBaseGui {
|
||||
}));
|
||||
|
||||
//AutoTrace
|
||||
inventory.setItem(20, new SWItem(simulator.isAutoTrace() ? Material.CHAIN_COMMAND_BLOCK : Material.COMMAND_BLOCK, "§eAutoTrace§8: " + (simulator.isAutoTrace() ? "§aOn" : "§cOff"), clickType -> {
|
||||
inventory.setItem(19, new SWItem(simulator.isAutoTrace() ? Material.CHAIN_COMMAND_BLOCK : Material.COMMAND_BLOCK, "§eAutoTrace§8: " + (simulator.isAutoTrace() ? "§aOn" : "§cOff"), clickType -> {
|
||||
simulator.setAutoTrace(!simulator.isAutoTrace());
|
||||
SimulatorWatcher.update(simulator);
|
||||
}));
|
||||
inventory.setItem(20, new SWItem(simulator.isAutoTestblock() ? Material.END_STONE : Material.BARRIER, "§eTestblock§8: " + (simulator.isAutoTestblock() ? "§aOn" : "§cOff"), clickType -> {
|
||||
simulator.setAutoTestblock(!simulator.isAutoTestblock());
|
||||
SimulatorWatcher.update(simulator);
|
||||
}));
|
||||
|
||||
//Pos X
|
||||
inventory.setItem(15, SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
inventory.setItem(15, new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
simulator.move(clickType.isShiftClick() ? 5 : 1, 0, 0);
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
|
||||
inventory.setItem(24, new SWItem(Material.PAPER, "§eX", clickType -> {
|
||||
}));
|
||||
inventory.setItem(33, SWItem.getDye(1), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
inventory.setItem(33, new SWItem(SWItem.getDye(1), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
simulator.move(clickType.isShiftClick() ? -5 : -1, 0, 0);
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||
|
||||
//Pos Y
|
||||
inventory.setItem(16, SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
inventory.setItem(16, new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
simulator.move(0, clickType.isShiftClick() ? 5 : 1, 0);
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
|
||||
inventory.setItem(25, new SWItem(Material.PAPER, "§eY", clickType -> {
|
||||
}));
|
||||
inventory.setItem(34, SWItem.getDye(1), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
inventory.setItem(34, new SWItem(SWItem.getDye(1), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
simulator.move(0, clickType.isShiftClick() ? -5 : -1, 0);
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||
|
||||
//Pos Z
|
||||
inventory.setItem(17, SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
inventory.setItem(17, new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
simulator.move(0, 0, clickType.isShiftClick() ? 5 : 1);
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
|
||||
inventory.setItem(26, new SWItem(Material.PAPER, "§eZ", clickType -> {
|
||||
}));
|
||||
inventory.setItem(35, SWItem.getDye(1), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
inventory.setItem(35, new SWItem(SWItem.getDye(1), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
simulator.move(0, 0, clickType.isShiftClick() ? -5 : -1);
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||
}
|
||||
}
|
||||
|
||||
@ -29,6 +29,8 @@ import de.steamwar.bausystem.features.simulator.gui.base.SimulatorAnvilGui;
|
||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
|
||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorScrollGui;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.core.Core;
|
||||
import de.steamwar.data.CMDs;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -81,12 +83,12 @@ public class SimulatorTNTGui extends SimulatorScrollGui<TNTPhase> {
|
||||
new SimulatorGroupGui(player, simulator, newParent, simulatorGui).open();
|
||||
}
|
||||
}
|
||||
}));
|
||||
}).setCustomModelData(CMDs.BACK));
|
||||
|
||||
inventory.setItem(8, new SWItem(Material.BARRIER, "§eDelete", clickType -> {
|
||||
tnt.getPhases().clear();
|
||||
SimulatorWatcher.update(simulator);
|
||||
}));
|
||||
}).setCustomModelData(CMDs.Simulator.DELETE));
|
||||
|
||||
// Material Chooser
|
||||
inventory.setItem(4, tnt.toItem(player, clickType -> {
|
||||
@ -95,29 +97,31 @@ public class SimulatorTNTGui extends SimulatorScrollGui<TNTPhase> {
|
||||
|
||||
inventory.setItem(47, new SWItem(Material.REPEATER, "§eSettings", clickType -> {
|
||||
new SimulatorTNTSettingsGui(player, simulator, tnt, this).open();
|
||||
}));
|
||||
}).setCustomModelData(CMDs.Simulator.SETTINGS));
|
||||
inventory.setItem(48, new SWItem(tnt.isDisabled() ? Material.ENDER_PEARL : Material.ENDER_EYE, tnt.isDisabled() ? "§cDisabled" : "§aEnabled", clickType -> {
|
||||
tnt.setDisabled(!tnt.isDisabled());
|
||||
SimulatorWatcher.update(simulator);
|
||||
}));
|
||||
inventory.setItem(49, new SWItem(Material.CALIBRATED_SCULK_SENSOR, "§eCreate Stab", click -> {
|
||||
new SimulatorAnvilGui<>(player, "Depth Limit", "", Integer::parseInt, depthLimit -> {
|
||||
if (depthLimit <= 0) return false;
|
||||
simulator.setStabGenerator(new SimulatorStabGenerator(Region.getRegion(player.getLocation()), simulator, tnt, depthLimit));
|
||||
SimulatorWatcher.update(simulator);
|
||||
return true;
|
||||
}, null).open();
|
||||
}));
|
||||
}).setCustomModelData(CMDs.Simulator.ENABLED_OR_DISABLED));
|
||||
if (Core.getVersion() > 19) {
|
||||
inventory.setItem(49, new SWItem(Material.CALIBRATED_SCULK_SENSOR, "§eCreate Stab", click -> {
|
||||
new SimulatorAnvilGui<>(player, "Depth Limit", "", Integer::parseInt, depthLimit -> {
|
||||
if (depthLimit <= 0) return false;
|
||||
simulator.setStabGenerator(new SimulatorStabGenerator(Region.getRegion(player.getLocation()), simulator, tnt, depthLimit));
|
||||
SimulatorWatcher.update(simulator);
|
||||
return true;
|
||||
}, null).open();
|
||||
}).setCustomModelData(CMDs.Simulator.CREATE_STAB));
|
||||
}
|
||||
inventory.setItem(50, new SWItem(Material.CHEST, parent.getElements().size() == 1 ? "§eMake Group" : "§eAdd another TNT to Group", clickType -> {
|
||||
TNTElement tntElement = new TNTElement(tnt.getPosition().clone());
|
||||
tntElement.add(new TNTPhase());
|
||||
parent.add(tntElement);
|
||||
new SimulatorGroupGui(player, simulator, parent, new SimulatorGui(player, simulator)).open();
|
||||
SimulatorWatcher.update(simulator);
|
||||
}));
|
||||
}).setCustomModelData(CMDs.Simulator.MAKE_GROUP));
|
||||
inventory.setItem(51, new SWItem(Material.LEAD, "§eJoin Group", clickType -> {
|
||||
new SimulatorGroupChooserGui(player, simulator, tnt, tnt.getGroup(simulator), this).open();
|
||||
}));
|
||||
}).setCustomModelData(CMDs.Simulator.JOIN_GROUP));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -136,15 +140,15 @@ public class SimulatorTNTGui extends SimulatorScrollGui<TNTPhase> {
|
||||
new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8:§e +5"), false, clickType -> {
|
||||
tntSetting.setCount(tntSetting.getCount() + (clickType.isShiftClick() ? 5 : 1));
|
||||
SimulatorWatcher.update(simulator);
|
||||
}),
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED),
|
||||
tnt,
|
||||
new SWItem(SWItem.getDye(tntSetting.getCount() > 1 ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8:§e -5"), false, clickType -> {
|
||||
tntSetting.setCount(Math.max(1, tntSetting.getCount() - (clickType.isShiftClick() ? 5 : 1)));
|
||||
SimulatorWatcher.update(simulator);
|
||||
}),
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED),
|
||||
new SWItem(Material.ANVIL, "§eEdit Phase", clickType -> {
|
||||
new SimulatorTNTPhaseSettingsGui(player, simulator, this.tnt, tntSetting, this).open();
|
||||
}),
|
||||
}).setCustomModelData(CMDs.Simulator.EDIT_ACTIVATION),
|
||||
};
|
||||
}
|
||||
|
||||
@ -153,12 +157,12 @@ public class SimulatorTNTGui extends SimulatorScrollGui<TNTPhase> {
|
||||
return new SWItem[]{
|
||||
new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8:§e +5"), false, clickType -> {
|
||||
addNewPhase(clickType.isShiftClick());
|
||||
}),
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED),
|
||||
new SWItem(Material.GUNPOWDER, "§eTNT§8:§a New Phase", clickType -> {
|
||||
addNewPhase(false);
|
||||
}),
|
||||
}).setCustomModelData(CMDs.Simulator.NEW_PHASE),
|
||||
new SWItem(SWItem.getDye(8), "§7", clickType -> {
|
||||
}),
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -27,6 +27,7 @@ import de.steamwar.bausystem.features.simulator.data.tnt.TNTPhase;
|
||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorAnvilGui;
|
||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
|
||||
import de.steamwar.core.Core;
|
||||
import de.steamwar.data.CMDs;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -60,7 +61,7 @@ public class SimulatorTNTPhaseSettingsGui extends SimulatorBaseGui {
|
||||
// Back Arrow
|
||||
inventory.setItem(0, new SWItem(Material.ARROW, "§eBack", clickType -> {
|
||||
back.open();
|
||||
}));
|
||||
}).setCustomModelData(CMDs.BACK));
|
||||
|
||||
// Material Chooser
|
||||
inventory.setItem(4, tntElement.toItem(player, clickType -> {
|
||||
@ -72,14 +73,14 @@ public class SimulatorTNTPhaseSettingsGui extends SimulatorBaseGui {
|
||||
tntElement.getPhases().remove(tnt);
|
||||
back.open();
|
||||
SimulatorWatcher.update(simulator);
|
||||
}));
|
||||
}).setCustomModelData(CMDs.Simulator.DELETE));
|
||||
|
||||
//Count
|
||||
int count = tnt.getCount();
|
||||
inventory.setItem(9, SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
inventory.setItem(9, new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
tnt.setCount(count + (clickType.isShiftClick() ? 5 : 1));
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
|
||||
|
||||
SWItem countItem = new SWItem(Material.TNT, "§eCount§8:§7 " + count, clickType -> {
|
||||
new SimulatorAnvilGui<>(player, "Count", count + "", Integer::parseInt, integer -> {
|
||||
@ -92,17 +93,17 @@ public class SimulatorTNTPhaseSettingsGui extends SimulatorBaseGui {
|
||||
countItem.getItemStack().setAmount(Math.max(1, Math.min(count, 64)));
|
||||
inventory.setItem(18, countItem);
|
||||
|
||||
inventory.setItem(27, SWItem.getDye(count > 1 ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
inventory.setItem(27, new SWItem(SWItem.getDye(count > 1 ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
tnt.setCount(Math.max(1, count - (clickType.isShiftClick() ? 5 : 1)));
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||
|
||||
//Tick Offset
|
||||
int offset = tnt.getTickOffset();
|
||||
inventory.setItem(10, SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
inventory.setItem(10, new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
tnt.setTickOffset(offset + (clickType.isShiftClick() ? 5 : 1));
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
|
||||
|
||||
SWItem offsetItem = new SWItem(Material.REPEATER, "§eStart at§8:§7 " + offset, clickType -> {
|
||||
new SimulatorAnvilGui<>(player, "Start at", offset + "", Integer::parseInt, integer -> {
|
||||
@ -115,17 +116,17 @@ public class SimulatorTNTPhaseSettingsGui extends SimulatorBaseGui {
|
||||
offsetItem.getItemStack().setAmount(Math.max(1, Math.min(offset, 64)));
|
||||
inventory.setItem(19, offsetItem);
|
||||
|
||||
inventory.setItem(28, SWItem.getDye(offset > 0 ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
inventory.setItem(28, new SWItem(SWItem.getDye(offset > 0 ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
tnt.setTickOffset(Math.max(0, offset - (clickType.isShiftClick() ? 5 : 1)));
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||
|
||||
//Lifetime
|
||||
int lifetime = tnt.getLifetime();
|
||||
inventory.setItem(11, SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
inventory.setItem(11, new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
tnt.setLifetime(lifetime + (clickType.isShiftClick() ? 5 : 1));
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
|
||||
|
||||
SWItem lifetimeItem = new SWItem(Material.CLOCK, "§eLifetime§8:§7 " + lifetime, clickType -> {
|
||||
new SimulatorAnvilGui<>(player, "Lifetime", lifetime + "", Integer::parseInt, integer -> {
|
||||
@ -138,17 +139,17 @@ public class SimulatorTNTPhaseSettingsGui extends SimulatorBaseGui {
|
||||
lifetimeItem.getItemStack().setAmount(Math.max(1, Math.min(lifetime, 64)));
|
||||
inventory.setItem(20, lifetimeItem);
|
||||
|
||||
inventory.setItem(29, SWItem.getDye(lifetime > 0 ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
inventory.setItem(29, new SWItem(SWItem.getDye(lifetime > 0 ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
tnt.setLifetime(Math.max(1, lifetime - (clickType.isShiftClick() ? 5 : 1)));
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||
|
||||
//Order
|
||||
int order = tnt.getOrder();
|
||||
inventory.setItem(13, SWItem.getDye(order < SimulatorPhase.ORDER_LIMIT ? 10 : 8), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
inventory.setItem(13, new SWItem(SWItem.getDye(order < SimulatorPhase.ORDER_LIMIT ? 10 : 8), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
tnt.setOrder(Math.min(SimulatorPhase.ORDER_LIMIT, order + (clickType.isShiftClick() ? 5 : 1)));
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
|
||||
|
||||
Material negativeNumbers = Material.getMaterial(Core.getVersion() >= 19 ? "RECOVERY_COMPASS" : "FIREWORK_STAR");
|
||||
SWItem orderItem = new SWItem(order >= 0 ? Material.COMPASS : negativeNumbers, "§eCalculation Order§8:§7 " + order, clickType -> {
|
||||
@ -163,10 +164,10 @@ public class SimulatorTNTPhaseSettingsGui extends SimulatorBaseGui {
|
||||
orderItem.getItemStack().setAmount(Math.max(1, Math.min(Math.abs(order), 30)));
|
||||
inventory.setItem(22, orderItem);
|
||||
|
||||
inventory.setItem(31, SWItem.getDye(order > -SimulatorPhase.ORDER_LIMIT ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
inventory.setItem(31, new SWItem(SWItem.getDye(order > -SimulatorPhase.ORDER_LIMIT ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
tnt.setOrder(Math.max(-SimulatorPhase.ORDER_LIMIT, order - (clickType.isShiftClick() ? 5 : 1)));
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||
|
||||
//Jump
|
||||
SWItem jumpX = new SWItem(tnt.isXJump() ? Material.LIME_WOOL : Material.RED_WOOL, "§7TNT §eJump X§8: " + (tnt.isZJump() ? "§aon" : "§coff"), clickType -> {
|
||||
|
||||
@ -24,10 +24,10 @@ import de.steamwar.bausystem.features.simulator.data.Simulator;
|
||||
import de.steamwar.bausystem.features.simulator.data.tnt.TNTElement;
|
||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorAnvilGui;
|
||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
|
||||
import de.steamwar.data.CMDs;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@ -58,7 +58,7 @@ public class SimulatorTNTSettingsGui extends SimulatorBaseGui {
|
||||
// Back Arrow
|
||||
inventory.setItem(0, new SWItem(Material.ARROW, "§eBack", clickType -> {
|
||||
back.open();
|
||||
}));
|
||||
}).setCustomModelData(CMDs.BACK));
|
||||
|
||||
// Material Chooser
|
||||
List<String> lore = new ArrayList<>();
|
||||
@ -74,10 +74,10 @@ public class SimulatorTNTSettingsGui extends SimulatorBaseGui {
|
||||
|
||||
// Base Tick
|
||||
int baseTicks = tnt.getBaseTick();
|
||||
inventory.setItem(9, SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
inventory.setItem(9, new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
tnt.changeBaseTicks(clickType.isShiftClick() ? 5 : 1);
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
|
||||
SWItem baseTick = new SWItem(Material.REPEATER, "§eTicks§8:§7 " + baseTicks, clickType -> {
|
||||
new SimulatorAnvilGui<>(player, "Ticks", baseTicks + "", Integer::parseInt, integer -> {
|
||||
if (integer < 0) return false;
|
||||
@ -88,14 +88,14 @@ public class SimulatorTNTSettingsGui extends SimulatorBaseGui {
|
||||
});
|
||||
baseTick.getItemStack().setAmount(Math.max(1, Math.min(baseTicks, 64)));
|
||||
inventory.setItem(18, baseTick);
|
||||
inventory.setItem(27, SWItem.getDye(baseTicks > 0 ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
inventory.setItem(27, new SWItem(SWItem.getDye(baseTicks > 0 ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
if (baseTicks - (clickType.isShiftClick() ? 5 : 1) < 0) {
|
||||
tnt.changeBaseTicks(-baseTicks);
|
||||
} else {
|
||||
tnt.changeBaseTicks(clickType.isShiftClick() ? -5 : -1);
|
||||
}
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||
|
||||
// Subpixel Alignment
|
||||
inventory.setItem(21, new SWItem(Material.SUNFLOWER, "§7Align§8: §eCenter", clickType -> {
|
||||
@ -135,10 +135,10 @@ public class SimulatorTNTSettingsGui extends SimulatorBaseGui {
|
||||
inventory.setItem(30, positivXItem);
|
||||
|
||||
// Pos X
|
||||
inventory.setItem(15, SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+0.0625"), false, clickType -> {
|
||||
inventory.setItem(15, new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+0.0625"), false, clickType -> {
|
||||
tnt.move(clickType.isShiftClick() ? 0.0625 : 1, 0, 0);
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
|
||||
inventory.setItem(24, new SWItem(Material.PAPER, "§eX§8:§7 " + tnt.getPosition().getX(), clickType -> {
|
||||
new SimulatorAnvilGui<>(player, "X", tnt.getPosition().getX() + "", Double::parseDouble, d -> {
|
||||
tnt.getPosition().setX(d);
|
||||
@ -146,16 +146,16 @@ public class SimulatorTNTSettingsGui extends SimulatorBaseGui {
|
||||
return true;
|
||||
}, this).open();
|
||||
}));
|
||||
inventory.setItem(33, SWItem.getDye(1), "§e-1", Arrays.asList("§7Shift§8: §e-0.0625"), false, clickType -> {
|
||||
inventory.setItem(33, new SWItem(SWItem.getDye(1), "§e-1", Arrays.asList("§7Shift§8: §e-0.0625"), false, clickType -> {
|
||||
tnt.move(clickType.isShiftClick() ? -0.0625 : -1, 0, 0);
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||
|
||||
// Pos Y
|
||||
inventory.setItem(16, SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+0.0625"), false, clickType -> {
|
||||
inventory.setItem(16, new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+0.0625"), false, clickType -> {
|
||||
tnt.move(0, clickType.isShiftClick() ? 0.0625 : 1, 0);
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
|
||||
inventory.setItem(25, new SWItem(Material.PAPER, "§eY§8:§7 " + tnt.getPosition().getY(), clickType -> {
|
||||
new SimulatorAnvilGui<>(player, "Y", tnt.getPosition().getY() + "", Double::parseDouble, d -> {
|
||||
tnt.getPosition().setY(d);
|
||||
@ -163,16 +163,16 @@ public class SimulatorTNTSettingsGui extends SimulatorBaseGui {
|
||||
return true;
|
||||
}, this).open();
|
||||
}));
|
||||
inventory.setItem(34, SWItem.getDye(1), "§e-1", Arrays.asList("§7Shift§8: §e-0.0625"), false, clickType -> {
|
||||
inventory.setItem(34, new SWItem(SWItem.getDye(1), "§e-1", Arrays.asList("§7Shift§8: §e-0.0625"), false, clickType -> {
|
||||
tnt.move(0, clickType.isShiftClick() ? -0.0625 : -1, 0);
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||
|
||||
// Pos Z
|
||||
inventory.setItem(17, SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+0.0625"), false, clickType -> {
|
||||
inventory.setItem(17, new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+0.0625"), false, clickType -> {
|
||||
tnt.move(0, 0, clickType.isShiftClick() ? 0.0625 : 1);
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
|
||||
inventory.setItem(26, new SWItem(Material.PAPER, "§eZ§8:§7 " + tnt.getPosition().getZ(), clickType -> {
|
||||
new SimulatorAnvilGui<>(player, "Z", tnt.getPosition().getZ() + "", Double::parseDouble, d -> {
|
||||
tnt.getPosition().setZ(d);
|
||||
@ -180,9 +180,9 @@ public class SimulatorTNTSettingsGui extends SimulatorBaseGui {
|
||||
return true;
|
||||
}, this).open();
|
||||
}));
|
||||
inventory.setItem(35, SWItem.getDye(1), "§e-1", Arrays.asList("§7Shift§8: §e-0.0625"), false, clickType -> {
|
||||
inventory.setItem(35, new SWItem(SWItem.getDye(1), "§e-1", Arrays.asList("§7Shift§8: §e-0.0625"), false, clickType -> {
|
||||
tnt.move(0, 0, clickType.isShiftClick() ? -0.0625 : -1);
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||
}
|
||||
}
|
||||
|
||||
@ -21,6 +21,7 @@ package de.steamwar.bausystem.features.simulator.gui.base;
|
||||
|
||||
import de.steamwar.bausystem.features.simulator.data.Simulator;
|
||||
import de.steamwar.core.Core;
|
||||
import de.steamwar.data.CMDs;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@ -50,19 +51,19 @@ public abstract class SimulatorPageGui<T> extends SimulatorBaseGui {
|
||||
headerAndFooter();
|
||||
page = Math.min(page, maxPage());
|
||||
|
||||
inventory.setItem(size - 9, SWItem.getDye(page > 0 ? 10 : 8), page > 0 ? (byte) 10 : (byte) 8, Core.MESSAGE.parse(page > 0 ? "SWLISINV_PREVIOUS_PAGE_ACTIVE" : "SWLISINV_PREVIOUS_PAGE_INACTIVE", player), clickType -> {
|
||||
inventory.setItem(size - 9, new SWItem(SWItem.getDye(page > 0 ? 10 : 8), page > 0 ? (byte) 10 : (byte) 8, Core.MESSAGE.parse(page > 0 ? "SWLISINV_PREVIOUS_PAGE_ACTIVE" : "SWLISINV_PREVIOUS_PAGE_INACTIVE", player), clickType -> {
|
||||
if (page > 0) {
|
||||
page--;
|
||||
open();
|
||||
}
|
||||
});
|
||||
}).setCustomModelData(CMDs.PREVIOUS_PAGE));
|
||||
boolean hasNext = page < maxPage() - (data.size() % (size - 18) == 0 ? 1 : 0);
|
||||
inventory.setItem(size - 1, SWItem.getDye(hasNext ? 10 : 8), hasNext ? (byte) 10 : (byte) 8, Core.MESSAGE.parse(hasNext ? "SWLISINV_NEXT_PAGE_ACTIVE" : "SWLISINV_NEXT_PAGE_INACTIVE", player), clickType -> {
|
||||
inventory.setItem(size - 1, new SWItem(SWItem.getDye(hasNext ? 10 : 8), hasNext ? (byte) 10 : (byte) 8, Core.MESSAGE.parse(hasNext ? "SWLISINV_NEXT_PAGE_ACTIVE" : "SWLISINV_NEXT_PAGE_INACTIVE", player), clickType -> {
|
||||
if (hasNext) {
|
||||
page++;
|
||||
open();
|
||||
}
|
||||
});
|
||||
}).setCustomModelData(CMDs.NEXT_PAGE));
|
||||
|
||||
int minElement = page * (size - 18);
|
||||
int maxElement = Math.min(data.size(), (page + 1) * (size - 18));
|
||||
|
||||
@ -22,6 +22,7 @@ package de.steamwar.bausystem.features.simulator.gui.base;
|
||||
|
||||
import de.steamwar.bausystem.features.simulator.data.Simulator;
|
||||
import de.steamwar.core.Core;
|
||||
import de.steamwar.data.CMDs;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@ -50,19 +51,19 @@ public abstract class SimulatorScrollGui<T> extends SimulatorBaseGui {
|
||||
headerAndFooter();
|
||||
scroll = maxScroll();
|
||||
|
||||
inventory.setItem(size - 9, SWItem.getDye(scroll > 0 ? 10 : 8), scroll > 0 ? (byte) 10 : (byte) 8, Core.MESSAGE.parse(scroll > 0 ? "SWLISINV_PREVIOUS_PAGE_ACTIVE" : "SWLISINV_PREVIOUS_PAGE_INACTIVE", player), clickType -> {
|
||||
inventory.setItem(size - 9, new SWItem(SWItem.getDye(scroll > 0 ? 10 : 8), scroll > 0 ? (byte) 10 : (byte) 8, Core.MESSAGE.parse(scroll > 0 ? "SWLISINV_PREVIOUS_PAGE_ACTIVE" : "SWLISINV_PREVIOUS_PAGE_INACTIVE", player), clickType -> {
|
||||
if (scroll > 0) {
|
||||
scroll = Math.max(0, scroll - 9);
|
||||
open();
|
||||
}
|
||||
});
|
||||
}).setCustomModelData(CMDs.PREVIOUS_PAGE));
|
||||
boolean hasNext = (data.size() + 1) - scroll > 9;
|
||||
inventory.setItem(size - 1, SWItem.getDye(hasNext ? 10 : 8), hasNext ? (byte) 10 : (byte) 8, Core.MESSAGE.parse(hasNext ? "SWLISINV_NEXT_PAGE_ACTIVE" : "SWLISINV_NEXT_PAGE_INACTIVE", player), clickType -> {
|
||||
inventory.setItem(size - 1, new SWItem(SWItem.getDye(hasNext ? 10 : 8), hasNext ? (byte) 10 : (byte) 8, Core.MESSAGE.parse(hasNext ? "SWLISINV_NEXT_PAGE_ACTIVE" : "SWLISINV_NEXT_PAGE_INACTIVE", player), clickType -> {
|
||||
if (hasNext) {
|
||||
scroll = Math.min(scroll + 9, data.size() + 1 - 9);
|
||||
open();
|
||||
}
|
||||
});
|
||||
}).setCustomModelData(CMDs.NEXT_PAGE));
|
||||
|
||||
for (int i = 0; i < 9; i++) {
|
||||
if (scroll + i < data.size()) {
|
||||
|
||||
@ -68,6 +68,7 @@ public class SimFormatSimulatorLoader implements SimulatorLoader {
|
||||
private void loadSimulator(YAPIONObject simulatorObject, Simulator simulator) {
|
||||
simulator.setMaterial(Material.valueOf(simulatorObject.getPlainValue("material")));
|
||||
simulator.setAutoTrace(simulatorObject.getPlainValue("autoTrace"));
|
||||
simulator.setAutoTestblock(simulatorObject.getPlainValueOrDefault("autoTestblock", false));
|
||||
|
||||
YAPIONArray groups = simulatorObject.getArray("groups");
|
||||
groups.streamObject().forEach(groupObject -> {
|
||||
|
||||
@ -39,6 +39,7 @@ public class SimulatorSaver {
|
||||
YAPIONObject simulatorObject = new YAPIONObject();
|
||||
simulatorObject.add("material", simulator.getMaterial().name());
|
||||
simulatorObject.add("autoTrace", simulator.isAutoTrace());
|
||||
simulatorObject.add("autoTestblock", simulator.isAutoTestblock());
|
||||
|
||||
YAPIONArray groups = new YAPIONArray();
|
||||
simulator.getGroups().forEach(group -> {
|
||||
|
||||
@ -21,6 +21,7 @@ package de.steamwar.bausystem.features.slaves.laufbau;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.shared.Pair;
|
||||
import de.steamwar.data.CMDs;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import de.steamwar.inventory.SWListInv;
|
||||
import org.bukkit.Material;
|
||||
@ -59,7 +60,7 @@ public class LaufbauSettings {
|
||||
open();
|
||||
return;
|
||||
}
|
||||
if (clickType.isCreativeAction()) {
|
||||
if (clickType.isLeftClick()) {
|
||||
open(entry.getKey());
|
||||
return;
|
||||
}
|
||||
@ -91,7 +92,7 @@ public class LaufbauSettings {
|
||||
});
|
||||
inv.setItem(49, new SWItem(Material.ARROW, BauSystem.MESSAGE.parse("LAUFBAU_SETTINGS_GUI_BACK", p), clickType -> {
|
||||
open();
|
||||
}));
|
||||
}).setCustomModelData(CMDs.BACK));
|
||||
inv.open();
|
||||
}
|
||||
|
||||
|
||||
@ -25,6 +25,7 @@ import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import de.steamwar.bausystem.utils.WorldEditUtils;
|
||||
import de.steamwar.core.Core;
|
||||
import lombok.Getter;
|
||||
import lombok.SneakyThrows;
|
||||
import org.bukkit.Location;
|
||||
@ -56,7 +57,7 @@ public class Panzern {
|
||||
|
||||
private BaseBlock blockType;
|
||||
private BaseBlock slabType;
|
||||
private static final BaseBlock jukeboxType = BlockTypes.JUKEBOX.getDefaultState().toBaseBlock();
|
||||
private static final BaseBlock jukeboxType = (Core.getVersion() > 19 ? BlockTypes.get("lodestone"): BlockTypes.get("jukebox")).getDefaultState().toBaseBlock();
|
||||
private static final BaseBlock cobwebType = BlockTypes.COBWEB.getDefaultState().toBaseBlock();
|
||||
private static final BaseBlock airType = BlockTypes.AIR.getDefaultState().toBaseBlock();
|
||||
|
||||
|
||||
@ -57,6 +57,7 @@ public class SmartPlaceListener implements Listener {
|
||||
static {
|
||||
World world = Bukkit.getWorlds().get(0);
|
||||
Block block = world.getBlockAt(0, 0, 0);
|
||||
block.setType(Material.AIR);
|
||||
BlockState state = block.getState();
|
||||
for (Material material : Material.values()) {
|
||||
if (material.isLegacy()) continue;
|
||||
@ -68,6 +69,7 @@ public class SmartPlaceListener implements Listener {
|
||||
} else if (blockData instanceof Stairs) {
|
||||
CONTAINERS.add(material);
|
||||
}
|
||||
state.update(true, false);
|
||||
}
|
||||
CONTAINERS.add(Material.GRINDSTONE);
|
||||
CONTAINERS.remove(Material.COMPARATOR);
|
||||
|
||||
@ -1,20 +1,20 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2023 SteamWar.de-Serverteam
|
||||
* Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* This program is 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.
|
||||
* 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/>.
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.tpslimit;
|
||||
|
||||
@ -27,19 +27,17 @@ import de.steamwar.bausystem.region.GlobalRegion;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.utils.ScoreboardElement;
|
||||
import de.steamwar.bausystem.utils.TickEndEvent;
|
||||
import de.steamwar.bausystem.utils.TickManager;
|
||||
import de.steamwar.bausystem.utils.bossbar.BauSystemBossbar;
|
||||
import de.steamwar.bausystem.utils.bossbar.BossBarService;
|
||||
import de.steamwar.command.AbstractSWCommand;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.core.Core;
|
||||
import de.steamwar.core.TPSWarpUtils;
|
||||
import de.steamwar.core.TPSWatcher;
|
||||
import de.steamwar.inventory.SWAnvilInv;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.linkage.LinkedInstance;
|
||||
import de.steamwar.linkage.MaxVersion;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.boss.BarColor;
|
||||
@ -52,91 +50,61 @@ import org.bukkit.inventory.ItemStack;
|
||||
import java.util.Arrays;
|
||||
|
||||
@Linked
|
||||
@MaxVersion(20) // Hotfix for 1.21 tps limit! -> Backport coming later
|
||||
public class TPSSystem implements Listener {
|
||||
|
||||
@Getter
|
||||
private static double currentTPSLimit = 20;
|
||||
|
||||
public TPSSystem() {
|
||||
if (TPSFreezeUtils.isCanFreeze()) {
|
||||
if (TickManager.impl.canFreeze()) {
|
||||
new TPSFreezeCommand();
|
||||
new TickFreezeCommand();
|
||||
new TickStepCommand();
|
||||
}
|
||||
new TPSLimitCommand();
|
||||
new TickLimitCommand();
|
||||
if (Core.getVersion() >= 15 && Core.getVersion() <= 20) { // If 1.21 support is not directly present
|
||||
if (Core.getVersion() >= 15) {
|
||||
new TPSWarpCommand();
|
||||
new TickWarpCommand();
|
||||
if (TPSFreezeUtils.isCanFreeze()) {
|
||||
if (TickManager.impl.canFreeze()) {
|
||||
new TickWarpingCommand();
|
||||
}
|
||||
}
|
||||
if (Core.getVersion() >= 21) {
|
||||
new Tick21Command();
|
||||
}
|
||||
new TPSDefaultCommand();
|
||||
new TickDefaultCommand();
|
||||
new TPSBaseCommand();
|
||||
new TickBaseCommand();
|
||||
}
|
||||
|
||||
private void setTPS(double tps) {
|
||||
if (currentlyStepping) {
|
||||
currentlyStepping = false;
|
||||
Bukkit.getOnlinePlayers().forEach(player -> {
|
||||
BossBarService.instance.remove(player, GlobalRegion.getInstance(), "TickStep");
|
||||
});
|
||||
}
|
||||
TPSWarpUtils.warp(tps);
|
||||
if (currentTPSLimit == 0 && tps != 0) {
|
||||
TPSFreezeUtils.unfreeze();
|
||||
}
|
||||
currentTPSLimit = tps;
|
||||
if (tps == 0) {
|
||||
TPSLimitUtils.unlimit();
|
||||
TPSFreezeUtils.freeze();
|
||||
} else if (tps < 20.0) {
|
||||
TPSLimitUtils.limit(tps);
|
||||
} else if (tps >= 20) {
|
||||
TPSLimitUtils.unlimit();
|
||||
}
|
||||
|
||||
Bukkit.getOnlinePlayers().forEach(player -> {
|
||||
if (currentTPSLimit == 0) {
|
||||
SWUtils.sendToActionbar(player, BauSystem.MESSAGE.parse("TPSLIMIT_FROZEN", player));
|
||||
} else {
|
||||
SWUtils.sendToActionbar(player, BauSystem.MESSAGE.parse("TPSLIMIT_SET", player, currentTPSLimit));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private boolean currentlyStepping = false;
|
||||
private double currentLimit;
|
||||
private int stepsTotal;
|
||||
private int stepsLeft;
|
||||
|
||||
private void setSkip(int steps, double tpsLimitToUse) {
|
||||
currentLimit = tpsLimitToUse == 20 ? 0 : currentTPSLimit;
|
||||
setTPS(tpsLimitToUse);
|
||||
stepsLeft = steps;
|
||||
stepsTotal = steps;
|
||||
currentlyStepping = true;
|
||||
Bukkit.getPluginManager().registerEvents(TickManager.impl, BauSystem.getInstance());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onTickEnd(TickEndEvent event) {
|
||||
if (!currentlyStepping) return;
|
||||
if (stepsTotal > 1) {
|
||||
bossbar();
|
||||
}
|
||||
|
||||
private void bossbar() {
|
||||
if ((TickManager.impl.isStepping() || TickManager.impl.isSprinting()) && TickManager.impl.getRemainingTicks() > 0) {
|
||||
Bukkit.getOnlinePlayers().forEach(player -> {
|
||||
BauSystemBossbar bossbar = BossBarService.instance.get(player, GlobalRegion.getInstance(), "TickStep");
|
||||
bossbar.setColor(BarColor.YELLOW);
|
||||
bossbar.setTitle(BauSystem.MESSAGE.parse("TICK_BOSSBAR", player, (stepsTotal - stepsLeft), stepsTotal));
|
||||
bossbar.setProgress((stepsTotal - stepsLeft) / (double) stepsTotal);
|
||||
bossbar.setTitle(BauSystem.MESSAGE.parse("TICK_BOSSBAR", player, TickManager.impl.getDoneTicks(), TickManager.impl.getTotalTicks()));
|
||||
bossbar.setProgress(TickManager.impl.getDoneTicks() / (double) TickManager.impl.getTotalTicks());
|
||||
});
|
||||
} else {
|
||||
Bukkit.getOnlinePlayers().forEach(player -> {
|
||||
BossBarService.instance.remove(player, GlobalRegion.getInstance(), "TickStep");
|
||||
});
|
||||
}
|
||||
stepsLeft--;
|
||||
if (stepsLeft <= 0) {
|
||||
setTPS(currentLimit);
|
||||
}
|
||||
}
|
||||
|
||||
public static void sendTickRateChange() {
|
||||
Bukkit.getOnlinePlayers().forEach(player -> {
|
||||
if (TickManager.impl.isFrozen()) {
|
||||
SWUtils.sendToActionbar(player, BauSystem.MESSAGE.parse("TPSLIMIT_FROZEN", player));
|
||||
} else {
|
||||
SWUtils.sendToActionbar(player, BauSystem.MESSAGE.parse("TPSLIMIT_SET", player, TickManager.impl.getTickRate()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private class TPSBaseCommand extends SWCommand {
|
||||
@ -157,7 +125,8 @@ public class TPSSystem implements Listener {
|
||||
|
||||
@Register(value = "0", description = "TPSLIMIT_FREEZE_HELP")
|
||||
public void freeze(@Validator Player player) {
|
||||
setTPS(0);
|
||||
TickManager.impl.setFreeze(true);
|
||||
sendTickRateChange();
|
||||
}
|
||||
}
|
||||
|
||||
@ -169,8 +138,9 @@ public class TPSSystem implements Listener {
|
||||
}
|
||||
|
||||
@Register(description = "TPSLIMIT_LIMIT_HELP")
|
||||
public void limit(@Validator Player player, @Min(doubleValue = 0.5) @Max(doubleValue = 20.0) double tpsLimit) {
|
||||
setTPS(tpsLimit);
|
||||
public void limit(@Validator Player player, @Min(doubleValue = 0.5) @Max(doubleValue = 20.0) float tpsLimit) {
|
||||
TickManager.impl.setTickRate(tpsLimit);
|
||||
sendTickRateChange();
|
||||
}
|
||||
}
|
||||
|
||||
@ -182,8 +152,9 @@ public class TPSSystem implements Listener {
|
||||
}
|
||||
|
||||
@Register(description = "TPSLIMIT_WARP_HELP")
|
||||
public void warp(@Validator Player player, @Min(doubleValue = 20.0, inclusive = false) double tpsLimit) {
|
||||
setTPS(tpsLimit);
|
||||
public void warp(@Validator Player player, @Min(doubleValue = 20.0, inclusive = false) float tpsLimit) {
|
||||
TickManager.impl.setTickRate(tpsLimit);
|
||||
sendTickRateChange();
|
||||
}
|
||||
}
|
||||
|
||||
@ -196,12 +167,13 @@ public class TPSSystem implements Listener {
|
||||
|
||||
@Register(description = "TPSLIMIT_HELP")
|
||||
public void currentLimit(Player player) {
|
||||
BauSystem.MESSAGE.send("TPSLIMIT_CURRENT", player, currentTPSLimit);
|
||||
BauSystem.MESSAGE.send("TPSLIMIT_CURRENT", player, TickManager.impl.getTickRate());
|
||||
}
|
||||
|
||||
@Register(value = "default", description = "TPSLIMIT_DEFAULT_HELP")
|
||||
public void reset(@Validator Player player) {
|
||||
setTPS(20);
|
||||
TickManager.impl.setTickRate(20.0F);
|
||||
sendTickRateChange();
|
||||
}
|
||||
}
|
||||
|
||||
@ -223,12 +195,14 @@ public class TPSSystem implements Listener {
|
||||
@Register(value = {"rate", "0"}, description = "TICK_FREEZE_HELP")
|
||||
@Register(value = "freeze", description = "TICK_FREEZE_HELP_2")
|
||||
public void freeze(@Validator Player player) {
|
||||
setTPS(0);
|
||||
TickManager.impl.setFreeze(true);
|
||||
sendTickRateChange();
|
||||
}
|
||||
|
||||
@Register(value = "unfreeze", description = "TICK_UNFREEZE_HELP")
|
||||
public void unfreeze(@Validator Player player) {
|
||||
setTPS(20);
|
||||
TickManager.impl.setTickRate(20.0F);
|
||||
sendTickRateChange();
|
||||
}
|
||||
}
|
||||
|
||||
@ -241,7 +215,9 @@ public class TPSSystem implements Listener {
|
||||
|
||||
@Register(value = "step", description = "TICK_STEPPING_HELP")
|
||||
public void step(@Validator Player player, @Min(intValue = 1) @OptionalValue("1") int steps) {
|
||||
setSkip(steps, 20);
|
||||
TickManager.impl.stepTicks(steps);
|
||||
sendTickRateChange();
|
||||
bossbar();
|
||||
}
|
||||
}
|
||||
|
||||
@ -253,8 +229,9 @@ public class TPSSystem implements Listener {
|
||||
}
|
||||
|
||||
@Register(value = "warp", description = "TICK_WARPING_HELP")
|
||||
public void warp(@Validator Player player, @Min(intValue = 1) @OptionalValue("1") int steps, @Min(doubleValue = 20) @OptionalValue("4000") double tps) {
|
||||
setSkip(steps, tps);
|
||||
public void warp(@Validator Player player, @Min(intValue = 1) @OptionalValue("1") int steps) {
|
||||
TickManager.impl.sprintTicks(steps);
|
||||
sendTickRateChange();
|
||||
}
|
||||
}
|
||||
|
||||
@ -266,8 +243,9 @@ public class TPSSystem implements Listener {
|
||||
}
|
||||
|
||||
@Register(value = "rate", description = "TICK_LIMIT_HELP")
|
||||
public void limit(@Validator Player player, @Min(doubleValue = 0.5, inclusive = false) @Max(doubleValue = 20.0) double tpsLimit) {
|
||||
setTPS(tpsLimit);
|
||||
public void limit(@Validator Player player, @Min(doubleValue = 0.5, inclusive = false) @Max(doubleValue = 20.0) float tpsLimit) {
|
||||
TickManager.impl.setTickRate(tpsLimit);
|
||||
sendTickRateChange();
|
||||
}
|
||||
}
|
||||
|
||||
@ -279,8 +257,9 @@ public class TPSSystem implements Listener {
|
||||
}
|
||||
|
||||
@Register(value = "rate", description = "TICK_WARP_HELP")
|
||||
public void warp(@Validator Player player, @Min(doubleValue = 20.0, inclusive = false) double tpsLimit) {
|
||||
setTPS(tpsLimit);
|
||||
public void warp(@Validator Player player, @Min(doubleValue = 20.0, inclusive = false) float tpsLimit) {
|
||||
TickManager.impl.setTickRate(tpsLimit);
|
||||
sendTickRateChange();
|
||||
}
|
||||
}
|
||||
|
||||
@ -293,12 +272,31 @@ public class TPSSystem implements Listener {
|
||||
|
||||
@Register(value = "rate", description = "TICK_HELP")
|
||||
public void currentLimit(Player player) {
|
||||
BauSystem.MESSAGE.send("TPSLIMIT_CURRENT", player, currentTPSLimit);
|
||||
BauSystem.MESSAGE.send("TPSLIMIT_CURRENT", player, TickManager.impl.getTickRate());
|
||||
}
|
||||
|
||||
@Register(value = {"rate", "default"}, description = "TICK_DEFAULT_HELP")
|
||||
public void reset(@Validator Player player) {
|
||||
setTPS(20);
|
||||
TickManager.impl.setTickRate(20.0F);
|
||||
sendTickRateChange();
|
||||
}
|
||||
}
|
||||
|
||||
@AbstractSWCommand.PartOf(TickBaseCommand.class)
|
||||
private class Tick21Command extends SWCommand {
|
||||
|
||||
private Tick21Command() {
|
||||
super("");
|
||||
}
|
||||
|
||||
@Register(value = "normalclient")
|
||||
public void smooth(@Validator Player player) {
|
||||
TickManager.impl.setBlockTpsPacket(true);
|
||||
}
|
||||
|
||||
@Register(value = "slowclient")
|
||||
public void unsmooth(@Validator Player player) {
|
||||
TickManager.impl.setBlockTpsPacket(false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -320,7 +318,10 @@ public class TPSSystem implements Listener {
|
||||
|
||||
@Override
|
||||
public String get(Region region, Player p) {
|
||||
if (tpsSystem != null && tpsSystem.currentlyStepping) {
|
||||
boolean isWarping = TickManager.impl.isSprinting();
|
||||
boolean isFrozen = TickManager.impl.isFrozen();
|
||||
|
||||
if (tpsSystem != null && isWarping) {
|
||||
long time = System.currentTimeMillis() % 1000;
|
||||
if (time < 250) {
|
||||
return "§e" + BauSystem.MESSAGE.parse("SCOREBOARD_TPS", p) + "§8: §7•••";
|
||||
@ -331,7 +332,7 @@ public class TPSSystem implements Listener {
|
||||
} else {
|
||||
return "§e" + BauSystem.MESSAGE.parse("SCOREBOARD_TPS", p) + "§8: §7••§e•";
|
||||
}
|
||||
} else if (TPSFreezeUtils.frozen()) {
|
||||
} else if (isFrozen) {
|
||||
return "§e" + BauSystem.MESSAGE.parse("SCOREBOARD_TPS", p) + "§8: " + BauSystem.MESSAGE.parse("SCOREBOARD_TPS_FROZEN", p);
|
||||
} else {
|
||||
return "§e" + BauSystem.MESSAGE.parse("SCOREBOARD_TPS", p) + "§8: " + tpsColor() + TPSWatcher.getTPSUnlimited(TPSWatcher.TPSType.ONE_SECOND) + tpsLimit();
|
||||
@ -340,20 +341,20 @@ public class TPSSystem implements Listener {
|
||||
|
||||
private String tpsColor() {
|
||||
double tps = TPSWatcher.getTPSUnlimited(TPSWatcher.TPSType.ONE_SECOND);
|
||||
if (tps > TPSSystem.getCurrentTPSLimit() * 0.9) {
|
||||
if (tps > TickManager.impl.getTickRate() * 0.9) {
|
||||
return "§a";
|
||||
}
|
||||
if (tps > TPSSystem.getCurrentTPSLimit() * 0.5) {
|
||||
if (tps > TickManager.impl.getTickRate() * 0.5) {
|
||||
return "§e";
|
||||
}
|
||||
return "§c";
|
||||
}
|
||||
|
||||
private String tpsLimit() {
|
||||
if (TPSSystem.getCurrentTPSLimit() == 20) {
|
||||
if (TickManager.impl.getTickRate() == 20) {
|
||||
return "";
|
||||
}
|
||||
return "§8/§7" + TPSSystem.getCurrentTPSLimit();
|
||||
return "§8/§7" + TickManager.impl.getTickRate();
|
||||
}
|
||||
}
|
||||
|
||||
@ -369,7 +370,7 @@ public class TPSSystem implements Listener {
|
||||
|
||||
@Override
|
||||
public ItemStack getItem(Player player) {
|
||||
return new SWItem(Material.CLOCK, BauSystem.MESSAGE.parse("TPSLIMIT_GUI_ITEM_NAME", player), Arrays.asList(BauSystem.MESSAGE.parse("TPSLIMIT_GUI_ITEM_LORE", player, tpsSystem.currentTPSLimit)), false, clickType -> {
|
||||
return new SWItem(Material.CLOCK, BauSystem.MESSAGE.parse("TPSLIMIT_GUI_ITEM_NAME", player), Arrays.asList(BauSystem.MESSAGE.parse("TPSLIMIT_GUI_ITEM_LORE", player, TickManager.impl.getTickRate())), false, clickType -> {
|
||||
}).getItemStack();
|
||||
}
|
||||
|
||||
|
||||
@ -22,19 +22,15 @@ package de.steamwar.bausystem.features.tracer;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.region.utils.RegionExtensionType;
|
||||
import de.steamwar.bausystem.region.utils.RegionType;
|
||||
import de.steamwar.core.Core;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.io.Externalizable;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInput;
|
||||
import java.io.ObjectOutput;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@ -106,7 +102,11 @@ public class TNTPoint{
|
||||
List<TNTPoint> history, List<Block> destroyedBlocks) {
|
||||
this.tntId = tntId;
|
||||
this.explosion = explosion;
|
||||
this.inWater = tnt.isInWater();
|
||||
if (Core.getVersion() > 15) {
|
||||
this.inWater = tnt.isInWater();
|
||||
} else {
|
||||
this.inWater = false;
|
||||
}
|
||||
this.afterFirstExplosion = afterFirstExplosion;
|
||||
this.ticksSinceStart = ticksSinceStart;
|
||||
fuse = tnt.getFuseTicks();
|
||||
|
||||
@ -50,12 +50,6 @@ public class Trace {
|
||||
@Getter
|
||||
private final File recordsSaveFile;
|
||||
|
||||
/**
|
||||
* File the metadata are saved in
|
||||
*/
|
||||
@Getter
|
||||
private final File metadataSaveFile;
|
||||
|
||||
/**
|
||||
* Region the trace was recorded in
|
||||
*/
|
||||
@ -75,7 +69,7 @@ public class Trace {
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
private int recordsCount;
|
||||
private int tntIdCount;
|
||||
|
||||
/**
|
||||
* A map of all REntityServers rendering this trace
|
||||
@ -95,21 +89,19 @@ public class Trace {
|
||||
this.date = new Date();
|
||||
records = new SoftReference<>(recordList);
|
||||
recordsSaveFile = new File(TraceRepository.tracesFolder, uuid + ".records");
|
||||
metadataSaveFile = new File(TraceRepository.tracesFolder, uuid + ".meta");
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for deserialising a trace from the file system
|
||||
*/
|
||||
@SneakyThrows
|
||||
protected Trace(UUID uuid, Region region, Date date, File metadataFile, File recordsFile, int recordsCount) {
|
||||
this.metadataSaveFile = metadataFile;
|
||||
protected Trace(UUID uuid, Region region, Date date, File recordsFile, int tntIdCount) {
|
||||
recordsSaveFile = recordsFile;
|
||||
this.uuid = uuid;
|
||||
this.region = region;
|
||||
this.date = date;
|
||||
this.records = new SoftReference<>(null);
|
||||
this.recordsCount = recordsCount;
|
||||
this.tntIdCount = tntIdCount;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -311,7 +303,7 @@ public class Trace {
|
||||
", region=" + region +
|
||||
", creationTime=" + date +
|
||||
", recordsSaveFile=" + recordsSaveFile.getName() +
|
||||
", recordCount=" + recordsCount +
|
||||
", tntCount=" + tntIdCount +
|
||||
", records=" + getRecords() +
|
||||
'}';
|
||||
}
|
||||
|
||||
@ -57,19 +57,26 @@ public class TraceManager implements Listener {
|
||||
if (traceFiles == null)
|
||||
return;
|
||||
|
||||
boolean hasMetaFiles = false;
|
||||
for (File traceFile : traceFiles) {
|
||||
if (traceFile.getName().contains(".records"))
|
||||
continue;
|
||||
|
||||
if (TraceRepository.getVersion(traceFile) == TraceRepository.SERIALISATION_VERSION) {
|
||||
add(TraceRepository.readTrace(traceFile));
|
||||
} else {
|
||||
String uuid = traceFile.getName().replace(".meta", "");
|
||||
|
||||
new File(tracesFolder, uuid + ".records").deleteOnExit();
|
||||
new File(tracesFolder, uuid + ".meta").deleteOnExit();
|
||||
if (traceFile.getName().contains(".meta")) {
|
||||
hasMetaFiles = true;
|
||||
}
|
||||
}
|
||||
if (hasMetaFiles) {
|
||||
for (File traceFile : traceFiles) {
|
||||
traceFile.delete();
|
||||
}
|
||||
traceFiles = new File[0];
|
||||
}
|
||||
|
||||
for (File traceFile : traceFiles) {
|
||||
Trace trace = TraceRepository.readTrace(traceFile);
|
||||
if (trace == null) {
|
||||
traceFile.delete();
|
||||
continue;
|
||||
}
|
||||
add(trace);
|
||||
}
|
||||
}
|
||||
|
||||
@ -152,7 +159,6 @@ public class TraceManager implements Listener {
|
||||
if (traceId == null) throw new RuntimeException("Trace not found while trying to remove see (c978eb98-b0b2-4009-91d8-acfa34e2831a)");
|
||||
traces.remove(traceId);
|
||||
trace.hide();
|
||||
trace.getMetadataSaveFile().delete();
|
||||
trace.getRecordsSaveFile().delete();
|
||||
}
|
||||
|
||||
@ -172,7 +178,6 @@ public class TraceManager implements Listener {
|
||||
tracesByRegion.getOrDefault(region, new HashMap<>())
|
||||
.forEach((i, trace) -> {
|
||||
if (trace.getRegion() != region) return;
|
||||
trace.getMetadataSaveFile().delete();
|
||||
trace.getRecordsSaveFile().delete();
|
||||
});
|
||||
tracesByRegion.getOrDefault(region, new HashMap<>()).clear();
|
||||
|
||||
@ -23,6 +23,7 @@ import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.features.tpslimit.TPSUtils;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.linkage.LinkedInstance;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
@ -31,7 +32,6 @@ import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.entity.EntitySpawnEvent;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
@ -40,12 +40,9 @@ import java.util.logging.Logger;
|
||||
@Linked
|
||||
public class TraceRecorder implements Listener {
|
||||
|
||||
@LinkedInstance
|
||||
public static TraceRecorder instance;
|
||||
|
||||
{
|
||||
instance = this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Map for all traces being actively recorded
|
||||
*/
|
||||
|
||||
@ -65,7 +65,7 @@ public class TraceRecordingWrapper {
|
||||
TraceManager.instance.showPartial(trace, recordsToAdd);
|
||||
|
||||
recordList.addAll(recordsToAdd);
|
||||
trace.setRecordsCount(recordList.size());
|
||||
trace.setTntIdCount((int) recordList.stream().map(TNTPoint::getTntId).distinct().count());
|
||||
recordsToAdd.clear();
|
||||
}
|
||||
|
||||
|
||||
@ -9,95 +9,125 @@ import org.bukkit.util.Vector;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
|
||||
public class TraceRepository {
|
||||
|
||||
/**
|
||||
* Increment this when changing serialisation format
|
||||
*/
|
||||
public static final int SERIALISATION_VERSION = 1;
|
||||
public static final int SERIALISATION_VERSION = 2;
|
||||
public static final int WRITE_TICK_DATA = 0b00000001;
|
||||
public static final int EXPLOSION = 0b00000010;
|
||||
public static final int IN_WATER = 0b00000100;
|
||||
public static final int AFTER_FIRST_EXPLOSION = 0b00001000;
|
||||
public static final int DESTROYED_BUILD_AREA = 0b00010000;
|
||||
public static final int DESTROYED_TEST_BLOCK = 0b00100000;
|
||||
public static File tracesFolder = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "traces");
|
||||
|
||||
@SneakyThrows
|
||||
protected static int getVersion(File metadataFile) {
|
||||
public static Trace readTrace(File recordsFile) {
|
||||
@Cleanup
|
||||
ObjectInputStream reader = new ObjectInputStream(new FileInputStream(metadataFile));
|
||||
reader.readUTF();
|
||||
reader.readUTF();
|
||||
reader.readObject();
|
||||
try {
|
||||
int version = reader.readInt();
|
||||
return version;
|
||||
} catch (EOFException e) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
public static Trace readTrace(File metadataFile) {
|
||||
@Cleanup
|
||||
ObjectInputStream reader = new ObjectInputStream(new FileInputStream(metadataFile));
|
||||
ObjectInputStream reader = new ObjectInputStream(new GZIPInputStream(new FileInputStream(recordsFile)));
|
||||
UUID uuid = UUID.fromString(reader.readUTF());
|
||||
Region region = Region.getREGION_MAP().get(reader.readUTF());
|
||||
Date date = (Date) reader.readObject();
|
||||
File recordsFile = new File(tracesFolder,uuid + ".records");
|
||||
int serialisationVersion = reader.readInt();
|
||||
int recordsCount = reader.readInt();
|
||||
if (serialisationVersion != SERIALISATION_VERSION) {
|
||||
return null;
|
||||
}
|
||||
int tntIdCount = reader.readInt();
|
||||
|
||||
return new Trace(uuid, region, date, metadataFile, recordsFile, recordsCount);
|
||||
return new Trace(uuid, region, date, recordsFile, tntIdCount);
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
protected static void writeTrace(Trace trace, List<TNTPoint> records) {
|
||||
ObjectOutputStream outputStream = new ObjectOutputStream(new FileOutputStream(trace.getMetadataSaveFile()));
|
||||
ObjectOutputStream outputStream = new ObjectOutputStream(new GZIPOutputStream(new FileOutputStream(trace.getRecordsSaveFile())));
|
||||
outputStream.writeUTF(trace.getUuid().toString());
|
||||
outputStream.writeUTF(trace.getRegion().getName());
|
||||
outputStream.writeObject(trace.getDate());
|
||||
outputStream.writeInt(SERIALISATION_VERSION);
|
||||
outputStream.writeInt(records.size());
|
||||
outputStream.flush();
|
||||
outputStream.close();
|
||||
|
||||
Map<Integer, List<TNTPoint>> pointsByTNTId = new HashMap<>();
|
||||
records.forEach(tntPoint -> {
|
||||
pointsByTNTId.computeIfAbsent(tntPoint.getTntId(), integer -> new ArrayList<>()).add(tntPoint);
|
||||
});
|
||||
|
||||
writeTraceRecords(trace.getRecordsSaveFile(), records);
|
||||
}
|
||||
outputStream.writeInt(pointsByTNTId.size());
|
||||
for (Map.Entry<Integer, List<TNTPoint>> entry : pointsByTNTId.entrySet()) {
|
||||
outputStream.writeInt(entry.getKey());
|
||||
outputStream.writeInt(entry.getValue().size());
|
||||
|
||||
@SneakyThrows
|
||||
protected static void writeTraceRecords(File recordsFile, List<TNTPoint> records) {
|
||||
DataOutputStream outputStream = new DataOutputStream(new FileOutputStream(recordsFile));
|
||||
for (TNTPoint record : records) {
|
||||
outputStream.writeInt(record.getTntId());
|
||||
outputStream.writeBoolean(record.isExplosion());
|
||||
outputStream.writeBoolean(record.isInWater());
|
||||
outputStream.writeBoolean(record.isAfterFirstExplosion());
|
||||
outputStream.writeBoolean(record.isDestroyedBuildArea());
|
||||
outputStream.writeBoolean(record.isDestroyedTestBlock());
|
||||
outputStream.writeLong(record.getTicksSinceStart());
|
||||
outputStream.writeInt(record.getFuse());
|
||||
Location location = record.getLocation();
|
||||
outputStream.writeDouble(location.getX());
|
||||
outputStream.writeDouble(location.getY());
|
||||
outputStream.writeDouble(location.getZ());
|
||||
Vector velocity = record.getVelocity();
|
||||
outputStream.writeDouble(velocity.getX());
|
||||
outputStream.writeDouble(velocity.getY());
|
||||
outputStream.writeDouble(velocity.getZ());
|
||||
for (int i = 0; i < entry.getValue().size(); i++) {
|
||||
TNTPoint current = entry.getValue().get(i);
|
||||
if (i == 0) {
|
||||
writeTNTPoint(outputStream, current, true);
|
||||
continue;
|
||||
}
|
||||
|
||||
TNTPoint last = entry.getValue().get(i - 1);
|
||||
|
||||
boolean writeTickData = true;
|
||||
if (last.getTicksSinceStart() + 1 == current.getTicksSinceStart() && last.getFuse() - 1 == current.getFuse()) {
|
||||
writeTickData = false;
|
||||
}
|
||||
|
||||
writeTNTPoint(outputStream, current, writeTickData);
|
||||
}
|
||||
}
|
||||
|
||||
outputStream.flush();
|
||||
outputStream.close();
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
protected static TNTPoint readTraceRecord(DataInputStream objectInput) {
|
||||
private static void writeTNTPoint(ObjectOutputStream outputStream, TNTPoint tntPoint, boolean writeTickData) {
|
||||
byte data = 0;
|
||||
if (writeTickData) data |= WRITE_TICK_DATA;
|
||||
if (tntPoint.isExplosion()) data |= EXPLOSION;
|
||||
if (tntPoint.isInWater()) data |= IN_WATER;
|
||||
if (tntPoint.isAfterFirstExplosion()) data |= AFTER_FIRST_EXPLOSION;
|
||||
if (tntPoint.isDestroyedBuildArea()) data |= DESTROYED_BUILD_AREA;
|
||||
if (tntPoint.isDestroyedTestBlock()) data |= DESTROYED_TEST_BLOCK;
|
||||
outputStream.write(data);
|
||||
|
||||
int tntId = objectInput.readInt();
|
||||
boolean explosion = objectInput.readBoolean();
|
||||
boolean inWater = objectInput.readBoolean();
|
||||
boolean afterFirstExplosion = objectInput.readBoolean();
|
||||
boolean destroyedBuildArea = objectInput.readBoolean();
|
||||
boolean destroyedTestBlock = objectInput.readBoolean();
|
||||
long ticksSinceStart = objectInput.readLong();
|
||||
int fuse = objectInput.readInt();
|
||||
if (writeTickData) {
|
||||
outputStream.writeLong(tntPoint.getTicksSinceStart());
|
||||
outputStream.writeInt(tntPoint.getFuse());
|
||||
}
|
||||
|
||||
Location location = tntPoint.getLocation();
|
||||
outputStream.writeDouble(location.getX());
|
||||
outputStream.writeDouble(location.getY());
|
||||
outputStream.writeDouble(location.getZ());
|
||||
|
||||
Vector velocity = tntPoint.getVelocity();
|
||||
outputStream.writeDouble(velocity.getX());
|
||||
outputStream.writeDouble(velocity.getY());
|
||||
outputStream.writeDouble(velocity.getZ());
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
protected static TNTPoint readTraceRecord(int tntId, TNTPoint last, ObjectInputStream objectInput) {
|
||||
|
||||
int data = objectInput.read();
|
||||
boolean explosion = (data & EXPLOSION) > 0;
|
||||
boolean inWater = (data & IN_WATER) > 0;
|
||||
boolean afterFirstExplosion = (data & AFTER_FIRST_EXPLOSION) > 0;
|
||||
boolean destroyedBuildArea = (data & DESTROYED_BUILD_AREA) > 0;
|
||||
boolean destroyedTestBlock = (data & DESTROYED_TEST_BLOCK) > 0;
|
||||
|
||||
long ticksSinceStart;
|
||||
int fuse;
|
||||
if ((data & WRITE_TICK_DATA) > 0) {
|
||||
ticksSinceStart = objectInput.readLong();
|
||||
fuse = objectInput.readInt();
|
||||
} else {
|
||||
ticksSinceStart = last.getTicksSinceStart() + 1;
|
||||
fuse = last.getFuse() - 1;
|
||||
}
|
||||
|
||||
double locX = objectInput.readDouble();
|
||||
double locY = objectInput.readDouble();
|
||||
@ -116,21 +146,29 @@ public class TraceRepository {
|
||||
protected static List<TNTPoint> readTraceRecords(Trace trace) {
|
||||
File recordsFile = trace.getRecordsSaveFile();
|
||||
@Cleanup
|
||||
DataInputStream inputStream = new DataInputStream(new FileInputStream(recordsFile));
|
||||
ObjectInputStream inputStream = new ObjectInputStream(new GZIPInputStream(new FileInputStream(recordsFile)));
|
||||
inputStream.readUTF();
|
||||
inputStream.readUTF();
|
||||
inputStream.readObject();
|
||||
inputStream.readInt();
|
||||
inputStream.readInt();
|
||||
|
||||
List<TNTPoint> records = new ArrayList<>();
|
||||
for (int i = 0; i < trace.getRecordsCount(); i++) {
|
||||
records.add(readTraceRecord(inputStream));
|
||||
}
|
||||
|
||||
Map<Integer, List<TNTPoint>> histories = new HashMap<>();
|
||||
for (TNTPoint record : records) {
|
||||
int tntId = record.getTntId();
|
||||
List<TNTPoint> history = histories.computeIfAbsent(tntId, id -> new ArrayList<>());
|
||||
history.add(record);
|
||||
record.setHistory(history);
|
||||
}
|
||||
for (int i = 0; i < trace.getTntIdCount(); i++) {
|
||||
int tntId = inputStream.readInt();
|
||||
int size = inputStream.readInt();
|
||||
List<TNTPoint> points = histories.computeIfAbsent(tntId, id -> new ArrayList<>());
|
||||
|
||||
TNTPoint last = null;
|
||||
for (int j = 0; j < size; j++) {
|
||||
TNTPoint point = readTraceRecord(tntId, last, inputStream);
|
||||
point.setHistory(points);
|
||||
points.add(point);
|
||||
last = point;
|
||||
records.add(point);
|
||||
}
|
||||
}
|
||||
return records;
|
||||
}
|
||||
}
|
||||
|
||||
@ -26,6 +26,7 @@ import de.steamwar.bausystem.shared.EnumDisplay;
|
||||
import de.steamwar.command.PreviousArguments;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.command.TypeMapper;
|
||||
import de.steamwar.data.CMDs;
|
||||
import de.steamwar.inventory.SWAnvilInv;
|
||||
import de.steamwar.inventory.SWInventory;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
@ -202,9 +203,9 @@ public class MaterialCommand extends SWCommand implements Listener {
|
||||
private void searchGUI(Player p) {
|
||||
SWInventory swInventory = new SWInventory(p, 54, BauSystem.MESSAGE.parse("MATERIAL_SEARCH", p));
|
||||
Search search = searchMap.get(p);
|
||||
swInventory.setItem(45, new SWItem(Material.ARROW, BauSystem.MESSAGE.parse("MATERIAL_BACK", p), clickType -> {
|
||||
swInventory.setItem(0, new SWItem(Material.ARROW, BauSystem.MESSAGE.parse("MATERIAL_BACK", p), clickType -> {
|
||||
materialGUI(p);
|
||||
}));
|
||||
}).setCustomModelData(CMDs.BACK));
|
||||
swInventory.setItem(10, new SWItem(Material.NAME_TAG, BauSystem.MESSAGE.parse("MATERIAL_SEARCH_NAME", p) + BauSystem.MESSAGE.parse("MATERIAL_SEARCH_VALUE", p, search.name), clickType -> {
|
||||
SWAnvilInv swAnvilInv = new SWAnvilInv(p, BauSystem.MESSAGE.parse("MATERIAL_SEARCH_NAME", p), search.name);
|
||||
swAnvilInv.setCallback(s -> {
|
||||
|
||||
@ -36,7 +36,7 @@ public class Warp {
|
||||
|
||||
public static void enable() {
|
||||
Warp worldSpawn = new Warp("WorldSpawn");
|
||||
worldSpawn.setLocation(Bukkit.getWorlds().get(0).getSpawnLocation().clone().add(0.5, Core.getVersion() == 20 ? 124 : 1, 0.5));
|
||||
worldSpawn.setLocation(Bukkit.getWorlds().get(0).getSpawnLocation().clone().add(0.5, Core.getVersion() >= 20 ? 124 : 1, 0.5));
|
||||
worldSpawn.setMat(Material.NETHER_STAR);
|
||||
warpMap.put("WorldSpawn", worldSpawn);
|
||||
}
|
||||
|
||||
@ -59,6 +59,7 @@ public class BauLockStateScoreboard implements ScoreboardElement {
|
||||
public enum BauLockState {
|
||||
|
||||
NOBODY,
|
||||
SUPERVISOR,
|
||||
SERVERTEAM,
|
||||
TEAM_AND_SERVERTEAM,
|
||||
TEAM,
|
||||
|
||||
@ -21,6 +21,7 @@ package de.steamwar.bausystem.features.world;
|
||||
|
||||
import de.steamwar.bausystem.Permission;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.sql.NodeData;
|
||||
import de.steamwar.sql.SchematicData;
|
||||
import de.steamwar.sql.SchematicNode;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
@ -65,7 +66,8 @@ public class ClipboardListener implements Listener {
|
||||
}
|
||||
|
||||
try {
|
||||
new SchematicData(schematic).saveFromPlayer(e.getPlayer());
|
||||
NodeData.get(schematic).forEach(NodeData::delete);
|
||||
SchematicData.saveFromPlayer(e.getPlayer(), schematic);
|
||||
} catch (Exception ex) {
|
||||
if (newSchem) {
|
||||
schematic.delete();
|
||||
|
||||
@ -179,7 +179,12 @@ public class SpectatorListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
|
||||
if (event.getMessage().startsWith("/schem save") || event.getMessage().startsWith("//schem save") || event.getMessage().startsWith("/schematic save") || event.getMessage().startsWith("//schematic save")) {
|
||||
if (event.getMessage().startsWith("/schem save") ||
|
||||
event.getMessage().startsWith("//schem save") ||
|
||||
event.getMessage().startsWith("/schematic save") ||
|
||||
event.getMessage().startsWith("//schematic save") ||
|
||||
event.getMessage().startsWith("/download") ||
|
||||
event.getMessage().startsWith("//download")) {
|
||||
if (!Permission.SUPERVISOR.hasPermission(event.getPlayer())) {
|
||||
event.setCancelled(true);
|
||||
event.setMessage("/");
|
||||
|
||||
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2025 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.utils;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.core.VersionDependent;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
public interface TickManager extends Listener {
|
||||
TickManager impl = VersionDependent.getVersionImpl(BauSystem.getInstance());
|
||||
|
||||
void setTickRate(float tickRate);
|
||||
float getTickRate();
|
||||
|
||||
boolean canFreeze();
|
||||
void setFreeze(boolean freeze);
|
||||
boolean isFrozen();
|
||||
|
||||
void stepTicks(int ticks);
|
||||
boolean isStepping();
|
||||
|
||||
void sprintTicks(int ticks);
|
||||
boolean isSprinting();
|
||||
|
||||
void setBlockTpsPacket(boolean block);
|
||||
long getRemainingTicks();
|
||||
long getDoneTicks();
|
||||
long getTotalTicks();
|
||||
}
|
||||
@ -34,3 +34,20 @@ dependencies {
|
||||
implementation(project(":BauSystem:BauSystem_20"))
|
||||
implementation(project(":BauSystem:BauSystem_21"))
|
||||
}
|
||||
|
||||
tasks.register<DevServer>("DevBau20") {
|
||||
group = "run"
|
||||
description = "Run a 1.20 Dev Bau"
|
||||
dependsOn(":SpigotCore:shadowJar")
|
||||
dependsOn(":BauSystem:shadowJar")
|
||||
dependsOn(":SchematicSystem:shadowJar")
|
||||
template = "Bau20"
|
||||
}
|
||||
|
||||
tasks.register<DevServer>("DevBau21") {
|
||||
group = "run"
|
||||
description = "Run a 1.21 Dev Bau"
|
||||
dependsOn(":SpigotCore:shadowJar")
|
||||
dependsOn(":BauSystem:shadowJar")
|
||||
template = "Bau21"
|
||||
}
|
||||
|
||||
@ -22,7 +22,4 @@ plugins {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly(project(":SpigotCore", "default"))
|
||||
|
||||
compileOnly(libs.nms15)
|
||||
}
|
||||
}
|
||||
92
CommonCore/Data/src/de/steamwar/data/CMDs.java
Normal file
92
CommonCore/Data/src/de/steamwar/data/CMDs.java
Normal file
@ -0,0 +1,92 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.data;
|
||||
|
||||
// Custom Model Data Constants
|
||||
public interface CMDs {
|
||||
|
||||
// Material.ARROW
|
||||
int BACK = 1;
|
||||
|
||||
// Material.DYE (Color 10/8)
|
||||
int PREVIOUS_PAGE = 1;
|
||||
|
||||
// Material.DYE (Color 10/8)
|
||||
int NEXT_PAGE = 2;
|
||||
|
||||
// BauSystem Simulator
|
||||
interface Simulator {
|
||||
|
||||
// Material.BARRIER
|
||||
int DELETE = 1;
|
||||
|
||||
// Material.REPEATER
|
||||
int SETTINGS = 1;
|
||||
|
||||
// Material.ENDER_PEARL and Material.ENDER_EYE
|
||||
int ENABLED_OR_DISABLED = 1;
|
||||
|
||||
// Material.DYE (Color 10/8)
|
||||
int INCREMENT_OR_DISABLED = 3;
|
||||
|
||||
// Material.DYE (Color 1/8)
|
||||
int DECREMENT_OR_DISABLED = 3;
|
||||
|
||||
// Material.LEAD
|
||||
int JOIN_GROUP = 1;
|
||||
|
||||
// Material.ANVIL
|
||||
int EDIT_ACTIVATION = 1;
|
||||
|
||||
// Material.QUARTZ, Material.REDSTONE, Material.GUNPOWDER
|
||||
int NEW_PHASE = 1;
|
||||
|
||||
// Material.CALIBRATED_SCULK_SENSOR
|
||||
int CREATE_STAB = 1;
|
||||
|
||||
// Material.CHEST
|
||||
int MAKE_GROUP = 1;
|
||||
}
|
||||
|
||||
// Schematic System
|
||||
interface Schematic {
|
||||
|
||||
// Material.LEAD
|
||||
int BACK = 2;
|
||||
|
||||
// Material.BUCKET
|
||||
int OWN_SCHEMS = 1;
|
||||
|
||||
// Material.GLASS
|
||||
int PUBLIC_SCHEMS = 1;
|
||||
|
||||
// Material.CHEST
|
||||
int NEW_DIR = 2;
|
||||
|
||||
// Material.NAME_TAG
|
||||
int FILTER = 3;
|
||||
|
||||
// Material.PAPER, Material.CAULDRON, Material.CLOCK
|
||||
int SORT_ASCENDING = 3;
|
||||
|
||||
// Material.PAPER, Material.CAULDRON, Material.CLOCK
|
||||
int SORT_DESCENDING = 4;
|
||||
}
|
||||
}
|
||||
25
CommonCore/Data/src/de/steamwar/data/SyncCommands.java
Normal file
25
CommonCore/Data/src/de/steamwar/data/SyncCommands.java
Normal file
@ -0,0 +1,25 @@
|
||||
/*
|
||||
* 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.data;
|
||||
|
||||
public class SyncCommands {
|
||||
public static final String RELOAD_PLAYER = "reload_player";
|
||||
public static final String RELOAD_EVENT = "reload_event";
|
||||
}
|
||||
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.network.packets.common;
|
||||
|
||||
import de.steamwar.network.packets.NetworkPacket;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
@ToString
|
||||
public class PlayerSkinRequestPacket extends NetworkPacket {
|
||||
|
||||
private static final long serialVersionUID = 277267302555671765L;
|
||||
private UUID uuid;
|
||||
}
|
||||
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.network.packets.common;
|
||||
|
||||
import de.steamwar.network.packets.NetworkPacket;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
@ToString
|
||||
public class PlayerSkinResponsePacket extends NetworkPacket {
|
||||
|
||||
private static final long serialVersionUID = 5792855362547625112L;
|
||||
private UUID uuid;
|
||||
private String skin;
|
||||
private String signature;
|
||||
}
|
||||
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.network.packets.server;
|
||||
|
||||
import de.steamwar.network.packets.NetworkPacket;
|
||||
import lombok.*;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@ToString
|
||||
public class ClientVersionPacket extends NetworkPacket {
|
||||
private static final long serialVersionUID = 3686482311704273200L;
|
||||
|
||||
private UUID player;
|
||||
private int version;
|
||||
}
|
||||
125
CommonCore/SQL/src/de/steamwar/sql/AuditLog.java
Normal file
125
CommonCore/SQL/src/de/steamwar/sql/AuditLog.java
Normal file
@ -0,0 +1,125 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.sql;
|
||||
|
||||
import de.steamwar.sql.internal.Field;
|
||||
import de.steamwar.sql.internal.SqlTypeMapper;
|
||||
import de.steamwar.sql.internal.Statement;
|
||||
import de.steamwar.sql.internal.Table;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NonNull;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.time.Instant;
|
||||
|
||||
@AllArgsConstructor
|
||||
public class AuditLog {
|
||||
|
||||
static {
|
||||
SqlTypeMapper.nameEnumMapper(AuditLog.Type.class);
|
||||
}
|
||||
|
||||
public static final String SERVER_NAME_VELOCITY = "Velocity";
|
||||
|
||||
private static final Table<AuditLog> table = new Table<>(AuditLog.class);
|
||||
|
||||
private static final Statement create = table.insertFields(true, "time", "serverName", "serverOwner", "actor", "actionType", "actionText");
|
||||
|
||||
@Getter
|
||||
@Field
|
||||
private final Timestamp time;
|
||||
|
||||
@Getter
|
||||
@Field
|
||||
private final String serverName;
|
||||
|
||||
@Field(nullable = true)
|
||||
private final int serverOwner;
|
||||
|
||||
@Field
|
||||
private final int actor;
|
||||
|
||||
@Getter
|
||||
@Field
|
||||
private final Type actionType;
|
||||
|
||||
@Getter
|
||||
@Field
|
||||
private final String actionText;
|
||||
|
||||
public enum Type {
|
||||
JOIN,
|
||||
LEAVE,
|
||||
COMMAND,
|
||||
SENSITIVE_COMMAND,
|
||||
|
||||
CHAT,
|
||||
GUI_OPEN,
|
||||
GUI_CLOSE,
|
||||
GUI_CLICK,
|
||||
}
|
||||
|
||||
private static void create(String serverName, SteamwarUser serverOwner, SteamwarUser actor, Type actionType, String text) {
|
||||
create.insertGetKey(Timestamp.from(Instant.now()), serverName, serverOwner, actor, actionType, text);
|
||||
}
|
||||
|
||||
public static void createJoin(@NonNull String jointServerName, SteamwarUser serverOwner, @NonNull SteamwarUser joinedPlayer) {
|
||||
create(jointServerName, serverOwner, joinedPlayer, Type.JOIN, "");
|
||||
}
|
||||
|
||||
public static void createLeave(@NonNull String leftServerName, SteamwarUser serverOwner, @NonNull SteamwarUser joinedPlayer) {
|
||||
create(leftServerName, serverOwner, joinedPlayer, Type.LEAVE, "");
|
||||
}
|
||||
|
||||
public static void createCommand(@NonNull String serverName, SteamwarUser serverOwner, SteamwarUser player, @NonNull String command) {
|
||||
if (player == null) return;
|
||||
create(serverName, serverOwner, player, Type.COMMAND, command);
|
||||
}
|
||||
|
||||
public static void createSensitiveCommand(@NonNull String serverName, SteamwarUser serverOwner, SteamwarUser player, @NonNull String command) {
|
||||
if (player == null) return;
|
||||
create(serverName, serverOwner, player, Type.SENSITIVE_COMMAND, command);
|
||||
}
|
||||
|
||||
public static void createChat(@NonNull String serverName, SteamwarUser serverOwner, @NonNull SteamwarUser chatter, @NonNull String chat) {
|
||||
create(serverName, serverOwner, chatter, Type.CHAT, chat);
|
||||
}
|
||||
|
||||
public static void createGuiOpen(@NonNull String serverName, SteamwarUser serverOwner, @NonNull SteamwarUser player, @NonNull String guiName) {
|
||||
create(serverName, serverOwner, player, Type.GUI_OPEN, guiName);
|
||||
}
|
||||
|
||||
public static void createGuiClick(@NonNull String serverName, SteamwarUser serverOwner, @NonNull SteamwarUser player, @NonNull String guiName, @NonNull String clickType, int slot, @NonNull String itemName) {
|
||||
create(serverName, serverOwner, player, Type.GUI_CLICK, "Gui: " + guiName + "\nSlot: " + slot + "\nClickType: " + clickType + "\nItemName: " + itemName);
|
||||
}
|
||||
|
||||
public static void createGuiClose(@NonNull String serverName, SteamwarUser serverOwner, @NonNull SteamwarUser player, @NonNull String guiName) {
|
||||
create(serverName, serverOwner, player, Type.GUI_CLOSE, guiName);
|
||||
}
|
||||
|
||||
public SteamwarUser getServerOwner() {
|
||||
return SteamwarUser.get(serverOwner);
|
||||
}
|
||||
|
||||
public SteamwarUser getActor() {
|
||||
return SteamwarUser.get(actor);
|
||||
}
|
||||
}
|
||||
@ -28,6 +28,7 @@ import lombok.Getter;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
@AllArgsConstructor
|
||||
public class CheckedSchematic {
|
||||
@ -37,15 +38,14 @@ public class CheckedSchematic {
|
||||
private static final SelectStatement<CheckedSchematic> nodeHistory = new SelectStatement<>(table, "SELECT * FROM CheckedSchematic WHERE NodeId = ? AND DeclineReason != '' AND DeclineReason != 'Prüfvorgang abgebrochen' ORDER BY EndTime DESC");
|
||||
private static final Statement insert = table.insertAll();
|
||||
|
||||
public static void create(int nodeId, String name, int owner, int validator, Timestamp startTime, Timestamp endTime, String reason){
|
||||
insert.update(nodeId, owner, name, validator, startTime, endTime, reason);
|
||||
private static final SelectStatement<CheckedSchematic> getUnseen = new SelectStatement<>(table, "SELECT * FROM CheckedSchematic WHERE Seen = 0 AND NodeOwner = ? ORDER BY StartTime DESC");
|
||||
private static final Statement updateSeen = new Statement("UPDATE CheckedSchematic SET Seen = ? WHERE StartTime = ? AND EndTime = ? AND NodeName = ?");
|
||||
|
||||
public static void create(SchematicNode node, int validator, Timestamp startTime, Timestamp endTime, String reason, boolean seen) {
|
||||
insert.update(node.getId(), node.getOwner(), node.getName(), validator, startTime, endTime, reason, seen, node.getSchemtype().toDB().substring(1));
|
||||
}
|
||||
|
||||
public static void create(SchematicNode node, int validator, Timestamp startTime, Timestamp endTime, String reason){
|
||||
create(node.getId(), node.getName(), node.getOwner(), validator, startTime, endTime, reason);
|
||||
}
|
||||
|
||||
public static List<CheckedSchematic> getLastDeclinedOfNode(int node){
|
||||
public static List<CheckedSchematic> getLastDeclinedOfNode(int node) {
|
||||
return statusOfNode.listSelect(node);
|
||||
}
|
||||
|
||||
@ -53,6 +53,10 @@ public class CheckedSchematic {
|
||||
return nodeHistory.listSelect(node.getId());
|
||||
}
|
||||
|
||||
public static List<CheckedSchematic> getUnseen(SteamwarUser owner) {
|
||||
return getUnseen.listSelect(owner);
|
||||
}
|
||||
|
||||
@Field(nullable = true)
|
||||
private final Integer nodeId;
|
||||
@Field
|
||||
@ -71,6 +75,12 @@ public class CheckedSchematic {
|
||||
@Getter
|
||||
@Field
|
||||
private final String declineReason;
|
||||
@Getter
|
||||
@Field
|
||||
private boolean seen;
|
||||
@Getter
|
||||
@Field
|
||||
private final String nodeType;
|
||||
|
||||
public int getNode() {
|
||||
return nodeId;
|
||||
@ -83,4 +93,9 @@ public class CheckedSchematic {
|
||||
public int getSchemOwner() {
|
||||
return nodeOwner;
|
||||
}
|
||||
|
||||
public void setSeen(boolean seen) {
|
||||
this.seen = seen;
|
||||
updateSeen.update(seen, startTime, endTime, nodeName);
|
||||
}
|
||||
}
|
||||
|
||||
@ -37,14 +37,18 @@ public class EventFight implements Comparable<EventFight> {
|
||||
|
||||
private static final Table<EventFight> table = new Table<>(EventFight.class);
|
||||
private static final SelectStatement<EventFight> byId = table.select(Table.PRIMARY);
|
||||
private static final SelectStatement<EventFight> byGroup = new SelectStatement<EventFight>(table, "SELECT * FROM EventFight WHERE GroupID = ? ORDER BY StartTime ASC");
|
||||
private static final SelectStatement<EventFight> byGroupLast = new SelectStatement<EventFight>(table, "SELECT * FROM EventFight WHERE GroupID = ? ORDER BY StartTime DESC LIMIT 1");
|
||||
private static final SelectStatement<EventFight> allComing = new SelectStatement<>(table, "SELECT * FROM EventFight WHERE StartTime > now() ORDER BY StartTime ASC");
|
||||
private static final SelectStatement<EventFight> event = new SelectStatement<>(table, "SELECT * FROM EventFight WHERE EventID = ? ORDER BY StartTime ASC");
|
||||
private static final SelectStatement<EventFight> activeFights = new SelectStatement<>(table, "SELECT * FROM EventFight WHERE Fight IS NOT NULL AND StartTime < now() AND DATEDIFF(StartTime, now()) < 0");
|
||||
private static final Statement reschedule = table.update(Table.PRIMARY, "StartTime");
|
||||
private static final Statement setResult = table.update(Table.PRIMARY, "Ergebnis");
|
||||
private static final Statement setFight = table.update(Table.PRIMARY, "Fight");
|
||||
|
||||
private static final Statement create = table.insertFields(true, "eventID", "startTime", "spielmodus", "map", "teamBlue", "teamRed", "spectatePort");
|
||||
private static final Statement update = table.update(Table.PRIMARY, "startTime", "spielModus", "map", "teamBlue", "teamRed", "spectatePort");
|
||||
private static final Statement setGroup = table.update(Table.PRIMARY, "GroupID");
|
||||
private static final Statement delete = table.delete(Table.PRIMARY);
|
||||
|
||||
@Getter
|
||||
@ -54,6 +58,14 @@ public class EventFight implements Comparable<EventFight> {
|
||||
return byId.select(fightID);
|
||||
}
|
||||
|
||||
public static List<EventFight> get(EventGroup group) {
|
||||
return byGroup.listSelect(group.getId());
|
||||
}
|
||||
|
||||
public static Optional<EventFight> getLast(EventGroup group) {
|
||||
return Optional.ofNullable(byGroupLast.select(group.getId()));
|
||||
}
|
||||
|
||||
public static void loadAllComingFights() {
|
||||
fights.clear();
|
||||
fights.addAll(allComing.listSelect());
|
||||
@ -63,6 +75,19 @@ public class EventFight implements Comparable<EventFight> {
|
||||
return event.listSelect(eventID);
|
||||
}
|
||||
|
||||
private static List<EventFight> activeFightsCache = null;
|
||||
|
||||
public static void clearActiveFightsCache() {
|
||||
activeFightsCache = null;
|
||||
}
|
||||
|
||||
public static List<EventFight> getActiveFights() {
|
||||
if (activeFightsCache == null) {
|
||||
activeFightsCache = activeFights.listSelect();
|
||||
}
|
||||
return activeFightsCache;
|
||||
}
|
||||
|
||||
public static EventFight create(int event, Timestamp from, String spielmodus, String map, int blueTeam, int redTeam, Integer spectatePort) {
|
||||
return get(create.insertGetKey(event, from, spielmodus, map, blueTeam, redTeam, spectatePort));
|
||||
}
|
||||
@ -75,6 +100,10 @@ public class EventFight implements Comparable<EventFight> {
|
||||
private final int fightID;
|
||||
@Getter
|
||||
@Setter
|
||||
@Field(nullable = true, def = "null")
|
||||
private Integer groupId;
|
||||
@Getter
|
||||
@Setter
|
||||
@Field
|
||||
private Timestamp startTime;
|
||||
@Getter
|
||||
@ -98,11 +127,35 @@ public class EventFight implements Comparable<EventFight> {
|
||||
@Field(nullable = true)
|
||||
private Integer spectatePort;
|
||||
@Getter
|
||||
@Setter
|
||||
@Field(def = "1")
|
||||
private int bestOf;
|
||||
@Getter
|
||||
@Field(def = "0")
|
||||
private int ergebnis;
|
||||
@Field(nullable = true)
|
||||
private int fight;
|
||||
|
||||
public Optional<EventGroup> getGroup() {
|
||||
return Optional.ofNullable(groupId).flatMap(EventGroup::get);
|
||||
}
|
||||
|
||||
public Optional<Team> getWinner() {
|
||||
if(ergebnis == 0)
|
||||
return Optional.empty();
|
||||
return Optional.ofNullable(ergebnis == 1 ? Team.get(teamBlue) : Team.get(teamRed));
|
||||
}
|
||||
|
||||
public Optional<Team> getLosser() {
|
||||
if(ergebnis == 0)
|
||||
return Optional.empty();
|
||||
return Optional.ofNullable(ergebnis == 1 ? Team.get(teamRed) : Team.get(teamBlue));
|
||||
}
|
||||
|
||||
public List<EventRelation> getDependents() {
|
||||
return EventRelation.getFightRelations(this);
|
||||
}
|
||||
|
||||
public void setErgebnis(int winner) {
|
||||
this.ergebnis = winner;
|
||||
setResult.update(winner, fightID);
|
||||
@ -114,6 +167,11 @@ public class EventFight implements Comparable<EventFight> {
|
||||
setFight.update(fight, fightID);
|
||||
}
|
||||
|
||||
public void setGroup(Integer group) {
|
||||
setGroup.update(group, fightID);
|
||||
this.groupId = group;
|
||||
}
|
||||
|
||||
public boolean hasFinished() {
|
||||
return fight != 0 || ergebnis != 0;
|
||||
}
|
||||
|
||||
173
CommonCore/SQL/src/de/steamwar/sql/EventGroup.java
Normal file
173
CommonCore/SQL/src/de/steamwar/sql/EventGroup.java
Normal file
@ -0,0 +1,173 @@
|
||||
/*
|
||||
* 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.sql;
|
||||
|
||||
import de.steamwar.sql.internal.*;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class EventGroup {
|
||||
static {
|
||||
SqlTypeMapper.ordinalEnumMapper(EventGroupType.class);
|
||||
}
|
||||
|
||||
private static final Table<EventGroup> table = new Table<>(EventGroup.class);
|
||||
|
||||
private static final SelectStatement<EventGroup> get = table.select(Table.PRIMARY);
|
||||
private static final SelectStatement<EventGroup> byEvent = new SelectStatement<>(table, "SELECT * FROM EventGroup WHERE EventID = ?");
|
||||
|
||||
private static final Statement insert = table.insertFields(true, "EventID", "Name", "Type");
|
||||
private static final Statement update = table.update(Table.PRIMARY, "Name", "Type", "PointsPerWin", "PointsPerLoss", "PointsPerDraw");
|
||||
private static final Statement delete = table.delete(Table.PRIMARY);
|
||||
|
||||
public static List<EventGroup> get(Event eventID) {
|
||||
return byEvent.listSelect(eventID.getEventID());
|
||||
}
|
||||
|
||||
public static EventGroup create(Event event, String name, EventGroupType type) {
|
||||
int key = insert.insertGetKey(event.getEventID(), name, type);
|
||||
return EventGroup.get(key).get();
|
||||
}
|
||||
|
||||
public static Optional<EventGroup> get(int id) {
|
||||
return Optional.ofNullable(get.select(id));
|
||||
}
|
||||
|
||||
@Field(keys = Table.PRIMARY)
|
||||
private final int id;
|
||||
|
||||
@Field(keys = "EVENT_NAME")
|
||||
private int eventID;
|
||||
|
||||
@Field(keys = "EVENT_NAME")
|
||||
private String name;
|
||||
|
||||
@Field
|
||||
private EventGroupType type;
|
||||
|
||||
@Field
|
||||
private int pointsPerWin;
|
||||
|
||||
@Field
|
||||
private int pointsPerLoss;
|
||||
|
||||
@Field
|
||||
private int pointsPerDraw;
|
||||
|
||||
public EventGroup(int id, int eventID, String name, EventGroupType type, int pointsPerWin, int pointsPerLoss, int pointsPerDraw) {
|
||||
this.id = id;
|
||||
this.eventID = eventID;
|
||||
this.name = name;
|
||||
this.type = type;
|
||||
this.pointsPerWin = pointsPerWin;
|
||||
this.pointsPerLoss = pointsPerLoss;
|
||||
this.pointsPerDraw = pointsPerDraw;
|
||||
}
|
||||
|
||||
private Map<Team, Integer> points;
|
||||
|
||||
public List<EventFight> getFights() {
|
||||
return EventFight.get(this);
|
||||
}
|
||||
|
||||
public Set<Integer> getTeamsId() {
|
||||
return getFights().stream().flatMap(fight -> Stream.of(fight.getTeamBlue(), fight.getTeamRed()))
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
public Set<Team> getTeams() {
|
||||
return getTeamsId().stream().map(Team::get).collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
public Optional<EventFight> getLastFight() {
|
||||
return EventFight.getLast(this);
|
||||
}
|
||||
|
||||
public List<EventRelation> getDependents() {
|
||||
return EventRelation.getGroupRelations(this);
|
||||
}
|
||||
|
||||
public Map<Team, Integer> calculatePoints() {
|
||||
if (points == null) {
|
||||
Map<Integer, Integer> p = getTeamsId().stream().collect(Collectors.toMap(team -> team, team -> 0));
|
||||
|
||||
for (EventFight fight : getFights()) {
|
||||
int blueTeamAdd = 0;
|
||||
int redTeamAdd = 0;
|
||||
|
||||
if (!fight.hasFinished()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (fight.getErgebnis()) {
|
||||
case 1:
|
||||
blueTeamAdd += pointsPerWin;
|
||||
redTeamAdd += pointsPerLoss;
|
||||
break;
|
||||
case 2:
|
||||
blueTeamAdd += pointsPerLoss;
|
||||
redTeamAdd += pointsPerWin;
|
||||
break;
|
||||
case 0:
|
||||
if (fight.getFightID() != 0) {
|
||||
blueTeamAdd += pointsPerDraw;
|
||||
redTeamAdd += pointsPerDraw;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
p.put(fight.getTeamBlue(), p.get(fight.getTeamBlue()) + blueTeamAdd);
|
||||
p.put(fight.getTeamRed(), p.get(fight.getTeamRed()) + redTeamAdd);
|
||||
}
|
||||
|
||||
points = p.entrySet().stream().collect(Collectors.toMap(integerIntegerEntry -> Team.get(integerIntegerEntry.getKey()), Map.Entry::getValue));
|
||||
}
|
||||
|
||||
return points;
|
||||
}
|
||||
|
||||
public void update(String name, EventGroupType type, int pointsPerWin, int pointsPerLoss, int pointsPerDraw) {
|
||||
update.update(name, type, pointsPerWin, pointsPerLoss, pointsPerDraw, id);
|
||||
this.name = name;
|
||||
this.type = type;
|
||||
this.pointsPerWin = pointsPerWin;
|
||||
this.pointsPerLoss = pointsPerLoss;
|
||||
this.pointsPerDraw = pointsPerDraw;
|
||||
}
|
||||
|
||||
public boolean needsTieBreak() {
|
||||
return calculatePoints().values().stream().sorted().limit(2).distinct().count() < 2;
|
||||
}
|
||||
|
||||
public void delete() {
|
||||
delete.update(id);
|
||||
}
|
||||
|
||||
public static enum EventGroupType {
|
||||
GROUP_STAGE,
|
||||
ELIMINATION_STAGE
|
||||
}
|
||||
}
|
||||
192
CommonCore/SQL/src/de/steamwar/sql/EventRelation.java
Normal file
192
CommonCore/SQL/src/de/steamwar/sql/EventRelation.java
Normal file
@ -0,0 +1,192 @@
|
||||
/*
|
||||
* 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.sql;
|
||||
|
||||
import de.steamwar.sql.internal.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
@Setter
|
||||
public class EventRelation {
|
||||
|
||||
static {
|
||||
SqlTypeMapper.ordinalEnumMapper(FightTeam.class);
|
||||
SqlTypeMapper.ordinalEnumMapper(FromType.class);
|
||||
}
|
||||
|
||||
private static final Table<EventRelation> table = new Table<>(EventRelation.class);
|
||||
|
||||
private static final SelectStatement<EventRelation> get = new SelectStatement<>(table, "SELECT * FROM EventRelation WHERE FromType = ? AND FromId = ?");
|
||||
private static final SelectStatement<EventRelation> byId = new SelectStatement<>(table, "SELECT * FROM EventRelation WHERE id = ?");
|
||||
private static final SelectStatement<EventRelation> byEvent = new SelectStatement<>(table, "SELECT ER.* FROM EventRelation ER JOIN EventFight EF ON EF.id = ER.fightId WHERE EF.EventID = ?");
|
||||
private static final Statement insert = table.insertAll(true);
|
||||
private static final Statement update = table.update(Table.PRIMARY, "fromType", "fromId", "fromPlace");
|
||||
private static final Statement updateTeam = table.update(Table.PRIMARY, "fightTeam");
|
||||
private static final Statement delete = table.delete(Table.PRIMARY);
|
||||
|
||||
public static List<EventRelation> get(Event event) {
|
||||
return byId.listSelect(event.getEventID());
|
||||
}
|
||||
|
||||
public static EventRelation get(int id) {
|
||||
return byId.select(id);
|
||||
}
|
||||
|
||||
public static List<EventRelation> getFightRelations(EventFight fight) {
|
||||
return get.listSelect(FromType.FIGHT, fight.getFightID());
|
||||
}
|
||||
|
||||
public static List<EventRelation> getGroupRelations(EventGroup group) {
|
||||
return get.listSelect(FromType.GROUP, group.getId());
|
||||
}
|
||||
|
||||
public static EventRelation create(EventFight fight, FightTeam fightTeam, FromType fromType, int fromId, int fromPlace) {
|
||||
int id = insert.insertGetKey(fight.getFightID(), fightTeam, fromType, fromId, fromPlace);
|
||||
return get(id);
|
||||
}
|
||||
|
||||
@Field(keys = Table.PRIMARY)
|
||||
private final int id;
|
||||
|
||||
@Field
|
||||
private int fightId;
|
||||
|
||||
@Field
|
||||
private FightTeam fightTeam;
|
||||
|
||||
@Field
|
||||
private FromType fromType;
|
||||
|
||||
@Field
|
||||
private int fromId;
|
||||
|
||||
@Field
|
||||
private int fromPlace;
|
||||
|
||||
public EventFight getFight() {
|
||||
return EventFight.get(fightId);
|
||||
}
|
||||
|
||||
public Optional<EventFight> getFromFight() {
|
||||
if(fromType == FromType.FIGHT) {
|
||||
return Optional.of(EventFight.get(fromId));
|
||||
} else {
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
||||
public Optional<EventGroup> getFromGroup() {
|
||||
if(fromType == FromType.GROUP) {
|
||||
return EventGroup.get(fromId);
|
||||
} else {
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
||||
public void delete() {
|
||||
delete.update(id);
|
||||
}
|
||||
|
||||
public void setUpdateTeam(FightTeam team) {
|
||||
updateTeam.update(id, team);
|
||||
this.fightTeam = team;
|
||||
}
|
||||
|
||||
public void setFromFight(EventFight fight, int place) {
|
||||
setFrom(fight.getFightID(), place, FromType.FIGHT);
|
||||
}
|
||||
|
||||
public void setFromGroup(EventGroup group, int place) {
|
||||
setFrom(group.getId(), place, FromType.GROUP);
|
||||
}
|
||||
|
||||
private void setFrom(int id, int place, FromType type) {
|
||||
update.update(id, type, id, place);
|
||||
this.fromType = type;
|
||||
this.fromId = id;
|
||||
this.fromPlace = place;
|
||||
}
|
||||
|
||||
public Optional<Team> getAdvancingTeam() {
|
||||
if (fromType == FromType.FIGHT) {
|
||||
if (fromPlace == 0) {
|
||||
return getFromFight().flatMap(EventFight::getWinner);
|
||||
} else {
|
||||
return getFromFight().flatMap(EventFight::getLosser);
|
||||
}
|
||||
} else if (fromType == FromType.GROUP) {
|
||||
return getFromGroup().map(EventGroup::calculatePoints)
|
||||
.flatMap(points -> points.entrySet().stream()
|
||||
.sorted(Map.Entry.<Team, Integer>comparingByValue().reversed())
|
||||
.skip(fromPlace)
|
||||
.findFirst()
|
||||
.map(Map.Entry::getKey));
|
||||
} else {
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean apply() {
|
||||
Optional<Integer> team = getAdvancingTeam().map(Team::getTeamId);
|
||||
if(!team.isPresent())
|
||||
return false;
|
||||
|
||||
EventFight fight = getFight();
|
||||
if(fightTeam == FightTeam.RED) {
|
||||
fight.update(
|
||||
fight.getStartTime(),
|
||||
fight.getSpielmodus(),
|
||||
fight.getMap(),
|
||||
team.get(),
|
||||
fight.getTeamBlue(),
|
||||
fight.getSpectatePort()
|
||||
);
|
||||
} else {
|
||||
fight.update(
|
||||
fight.getStartTime(),
|
||||
fight.getSpielmodus(),
|
||||
fight.getMap(),
|
||||
fight.getTeamRed(),
|
||||
team.get(),
|
||||
fight.getSpectatePort()
|
||||
);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static enum FightTeam {
|
||||
RED,
|
||||
BLUE
|
||||
}
|
||||
|
||||
public static enum FromType {
|
||||
FIGHT,
|
||||
GROUP
|
||||
}
|
||||
}
|
||||
@ -35,7 +35,8 @@ import java.util.stream.Collectors;
|
||||
public class Fight {
|
||||
|
||||
private static final Table<Fight> table = new Table<>(Fight.class);
|
||||
private static final SelectStatement<Fight> getPage = new SelectStatement<>(table, "SELECT f.*, (b.NodeId IS NULL OR b.AllowReplay) AND (r.NodeId IS NULL OR r.AllowReplay) AS ReplayAllowed FROM Fight f LEFT OUTER JOIN SchematicNode b ON f.BlueSchem = b.NodeId LEFT OUTER JOIN SchematicNode r ON f.RedSchem = r.NodeId ORDER BY FightID DESC LIMIT ?, ?");
|
||||
private static final SelectStatement<Fight> getPage = new SelectStatement<>(table, "SELECT f.*, (b.NodeId IS NULL OR b.Config & 2) AND (r.NodeId IS NULL OR r.Config & 2) AS ReplayAllowed FROM Fight f LEFT OUTER JOIN SchematicNode b ON f.BlueSchem = b.NodeId LEFT OUTER JOIN SchematicNode r ON f.RedSchem = r.NodeId ORDER BY FightID DESC LIMIT ?, ?");
|
||||
private static final SelectStatement<Fight> getById = new SelectStatement<>(table, "SELECT f.*, (b.NodeId IS NULL OR b.Config & 2) AND (r.NodeId IS NULL OR r.Config & 2) AS ReplayAllowed FROM Fight f LEFT OUTER JOIN SchematicNode b ON f.BlueSchem = b.NodeId LEFT OUTER JOIN SchematicNode r ON f.RedSchem = r.NodeId WHERE FightId = ?");
|
||||
private static final Statement insert = table.insertFields(true, "GameMode", "Server", "StartTime", "Duration", "BlueLeader", "RedLeader", "BlueSchem", "RedSchem", "Win", "WinCondition");
|
||||
private static final Statement updateReplayAvailable = table.update(Table.PRIMARY, "ReplayAvailable");
|
||||
|
||||
@ -51,6 +52,10 @@ public class Fight {
|
||||
return fights;
|
||||
}
|
||||
|
||||
public static Fight getById(int fightID) {
|
||||
return getById.select(fightID);
|
||||
}
|
||||
|
||||
public static int create(String gamemode, String server, Timestamp starttime, int duration, int blueleader, int redleader, Integer blueschem, Integer redschem, int win, String wincondition){
|
||||
return insert.insertGetKey(gamemode, server, starttime, duration, blueleader, redleader, blueschem, redschem, win, wincondition);
|
||||
}
|
||||
|
||||
@ -23,8 +23,13 @@ import de.steamwar.sql.internal.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import javax.swing.plaf.nimbus.State;
|
||||
import java.io.*;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.Timestamp;
|
||||
import java.time.Instant;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
|
||||
@AllArgsConstructor
|
||||
@ -40,26 +45,47 @@ public class NodeData {
|
||||
|
||||
private static final Table<NodeData> table = new Table<>(NodeData.class);
|
||||
|
||||
private static final Statement updateDatabase = new Statement("INSERT INTO NodeData(NodeId, NodeFormat, SchemData) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE NodeFormat = VALUES(NodeFormat), SchemData = VALUES(SchemData)");
|
||||
private static final Statement selSchemData = new Statement("SELECT SchemData FROM NodeData WHERE NodeId = ?");
|
||||
private static final Statement updateDatabase = new Statement("INSERT INTO NodeData(NodeId, NodeFormat, SchemData) VALUES (?, ?, ?)", true);
|
||||
private static final Statement selSchemData = new Statement("SELECT SchemData FROM NodeData WHERE NodeId = ? AND CreatedAt = ?");
|
||||
private static final Statement delete = table.delete(Table.PRIMARY);
|
||||
|
||||
private static final SelectStatement<NodeData> get = table.select(Table.PRIMARY);
|
||||
private static final SelectStatement<NodeData> get = new SelectStatement<>(table, "SELECT NodeId, CreatedAt, NodeFormat FROM NodeData WHERE NodeId = ? ORDER BY CreatedAt ");
|
||||
private static final Statement getRevisions = new Statement("SELECT COUNT(DISTINCT CreatedAt) as CNT FROM NodeData WHERE NodeId = ?");
|
||||
private static final SelectStatement<NodeData> getLatest = new SelectStatement<>(table, "SELECT NodeId, CreatedAt, NodeFormat FROM NodeData WHERE NodeId = ? ORDER BY CreatedAt DESC LIMIT 1");
|
||||
|
||||
public static NodeData get(SchematicNode node) {
|
||||
if(node.isDir())
|
||||
throw new IllegalArgumentException("Node is a directory");
|
||||
return get.select(rs -> {
|
||||
if(rs.next()) {
|
||||
return new NodeData(node.getId(), SchematicFormat.values()[rs.getInt("NodeFormat")]);
|
||||
public static NodeData getLatest(SchematicNode node) {
|
||||
if (node.isDir()) throw new IllegalArgumentException("Node is dir");
|
||||
return Optional.ofNullable(getLatest.select(node)).orElseGet(() -> new NodeData(node.getId(), Timestamp.from(Instant.now()), SchematicFormat.MCEDIT));
|
||||
}
|
||||
|
||||
public static List<NodeData> get(SchematicNode node) {
|
||||
return get.listSelect(node);
|
||||
}
|
||||
|
||||
public static NodeData get(SchematicNode node, int revision) {
|
||||
return get.listSelect(node).get(revision - 1);
|
||||
}
|
||||
|
||||
public static int getRevisions(SchematicNode node) {
|
||||
return getRevisions.select(rs -> {
|
||||
if (rs.next()) {
|
||||
return rs.getInt("CNT");
|
||||
} else {
|
||||
return new NodeData(node.getId(), SchematicFormat.MCEDIT);
|
||||
return 0;
|
||||
}
|
||||
}, node);
|
||||
}
|
||||
|
||||
public static void saveFromStream(SchematicNode node, InputStream blob, SchematicFormat format) {
|
||||
updateDatabase.update(node.getId(), format, blob);
|
||||
}
|
||||
|
||||
@Field(keys = {Table.PRIMARY})
|
||||
private final int nodeId;
|
||||
|
||||
@Field(keys = {Table.PRIMARY})
|
||||
private Timestamp createdAt;
|
||||
|
||||
@Field
|
||||
private SchematicFormat nodeFormat;
|
||||
|
||||
@ -84,15 +110,19 @@ public class NodeData {
|
||||
} catch (IOException e) {
|
||||
throw new SecurityException("SchemData is wrong", e);
|
||||
}
|
||||
}, nodeId);
|
||||
}, nodeId, createdAt);
|
||||
} catch (Exception e) {
|
||||
throw new IOException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void saveFromStream(InputStream blob, SchematicFormat newFormat) {
|
||||
updateDatabase.update(nodeId, newFormat, blob);
|
||||
nodeFormat = newFormat;
|
||||
saveFromStream(SchematicNode.getSchematicNode(nodeId), blob, newFormat);
|
||||
}
|
||||
|
||||
public void delete() {
|
||||
delete.update(nodeId, createdAt);
|
||||
}
|
||||
|
||||
@AllArgsConstructor
|
||||
|
||||
@ -42,13 +42,13 @@ public class SchematicNode {
|
||||
TAB_CACHE.clear();
|
||||
}
|
||||
|
||||
private static final String nodeSelector = "SELECT NodeId, NodeOwner, NodeOwner AS EffectiveOwner, NodeName, ParentNode, LastUpdate, NodeItem, NodeType, NodeRank, ReplaceColor, AllowReplay FROM SchematicNode ";
|
||||
private static final String nodeSelector = "SELECT NodeId, NodeOwner, NodeOwner AS EffectiveOwner, NodeName, ParentNode, LastUpdate, NodeItem, NodeType, NodeRank, Config FROM SchematicNode ";
|
||||
|
||||
private static final Table<SchematicNode> table = new Table<>(SchematicNode.class);
|
||||
private static final Statement create = table.insertFields(true, "NodeOwner", "NodeName", "ParentNode", "NodeItem",
|
||||
"NodeType");
|
||||
private static final Statement update = table.update(Table.PRIMARY, "NodeName", "ParentNode", "NodeItem",
|
||||
"NodeType", "NodeRank", "ReplaceColor", "AllowReplay");
|
||||
"NodeType", "NodeRank", "Config");
|
||||
private static final Statement delete = table.delete(Table.PRIMARY);
|
||||
|
||||
private static final SelectStatement<SchematicNode> byId = new SelectStatement<>(table,
|
||||
@ -66,13 +66,13 @@ public class SchematicNode {
|
||||
private static final SelectStatement<SchematicNode> all = new SelectStatement<>(table,
|
||||
"WITH RECURSIVE Nodes AS (SELECT NodeId, ParentId as ParentNode FROM NodeMember WHERE UserId = ? UNION SELECT NodeId, ParentNode FROM SchematicNode WHERE NodeOwner = ?), RSN AS ( SELECT NodeId, ParentNode FROM Nodes UNION SELECT SN.NodeId, SN.ParentNode FROM SchematicNode SN, RSN WHERE SN.ParentNode = RSN.NodeId ) SELECT SN.*, ? AS EffectiveOwner FROM RSN INNER JOIN SchematicNode SN ON RSN.NodeId = SN.NodeId");
|
||||
private static final SelectStatement<SchematicNode> list = new SelectStatement<>(table,
|
||||
"SELECT SchematicNode.NodeId, NodeOwner, ? AS EffectiveOwner, NodeName, NM.ParentId AS ParentNode, LastUpdate, NodeItem, NodeType, NodeRank, ReplaceColor, AllowReplay FROM SchematicNode INNER JOIN NodeMember NM on SchematicNode.NodeId = NM.NodeId WHERE NM.ParentId "
|
||||
"SELECT SchematicNode.NodeId, NodeOwner, ? AS EffectiveOwner, NodeName, NM.ParentId AS ParentNode, LastUpdate, NodeItem, NodeType, NodeRank, Config FROM SchematicNode INNER JOIN NodeMember NM on SchematicNode.NodeId = NM.NodeId WHERE NM.ParentId "
|
||||
+ Statement.NULL_SAFE_EQUALS
|
||||
+ "? AND NM.UserId = ? UNION ALL SELECT SchematicNode.NodeId, NodeOwner, ? AS EffectiveOwner, NodeName, ParentNode, LastUpdate, NodeItem, NodeType, NodeRank, ReplaceColor, AllowReplay FROM SchematicNode WHERE (? IS NULL AND ParentNode IS NULL AND NodeOwner = ?) OR (? IS NOT NULL AND ParentNode = ?) ORDER BY NodeName");
|
||||
+ "? AND NM.UserId = ? UNION ALL SELECT SchematicNode.NodeId, NodeOwner, ? AS EffectiveOwner, NodeName, ParentNode, LastUpdate, NodeItem, NodeType, NodeRank, Config FROM SchematicNode WHERE (? IS NULL AND ParentNode IS NULL AND NodeOwner = ?) OR (? IS NOT NULL AND ParentNode = ?) ORDER BY NodeName");
|
||||
private static final SelectStatement<SchematicNode> byParentName = new SelectStatement<>(table,
|
||||
"SELECT SchematicNode.NodeId, NodeOwner, ? AS EffectiveOwner, NodeName, NM.ParentId AS ParentNode, LastUpdate, NodeItem, NodeType, NodeRank, ReplaceColor, AllowReplay FROM SchematicNode INNER JOIN NodeMember NM on SchematicNode.NodeId = NM.NodeId WHERE NM.ParentId "
|
||||
"SELECT SchematicNode.NodeId, NodeOwner, ? AS EffectiveOwner, NodeName, NM.ParentId AS ParentNode, LastUpdate, NodeItem, NodeType, NodeRank, Config FROM SchematicNode INNER JOIN NodeMember NM on SchematicNode.NodeId = NM.NodeId WHERE NM.ParentId "
|
||||
+ Statement.NULL_SAFE_EQUALS
|
||||
+ "? AND NM.UserId = ? AND SchematicNode.NodeName = ? UNION ALL SELECT SchematicNode.NodeId, NodeOwner, ? AS EffectiveOwner, NodeName, ParentNode, LastUpdate, NodeItem, NodeType, NodeRank, ReplaceColor, AllowReplay FROM SchematicNode WHERE ((? IS NULL AND ParentNode IS NULL AND NodeOwner = ?) OR (? IS NOT NULL AND ParentNode = ?)) AND NodeName = ?");
|
||||
+ "? AND NM.UserId = ? AND SchematicNode.NodeName = ? UNION ALL SELECT SchematicNode.NodeId, NodeOwner, ? AS EffectiveOwner, NodeName, ParentNode, LastUpdate, NodeItem, NodeType, NodeRank, Config FROM SchematicNode WHERE ((? IS NULL AND ParentNode IS NULL AND NodeOwner = ?) OR (? IS NOT NULL AND ParentNode = ?)) AND NodeName = ?");
|
||||
private static final SelectStatement<SchematicNode> schematicAccessibleForUser = new SelectStatement<>(table,
|
||||
"WITH RECURSIVE Nodes AS (SELECT NodeId, ParentId as ParentNode FROM NodeMember WHERE UserId = ? UNION SELECT NodeId, ParentNode FROM SchematicNode WHERE NodeOwner = ?), RSN AS ( SELECT NodeId, ParentNode FROM Nodes UNION SELECT SN.NodeId, SN.ParentNode FROM SchematicNode SN, RSN WHERE SN.ParentNode = RSN.NodeId ) SELECT SN.*, ? AS EffectiveOwner FROM RSN INNER JOIN SchematicNode SN ON RSN.NodeId = SN.NodeId WHERE NodeId = ?");
|
||||
private static final SelectStatement<SchematicNode> accessibleByUserTypeInParent = new SelectStatement<>(table,
|
||||
@ -81,7 +81,7 @@ public class SchematicNode {
|
||||
private static final SelectStatement<SchematicNode> accessibleByUserType = new SelectStatement<>(table,
|
||||
"WITH RECURSIVE Nodes AS (SELECT NodeId, ParentId as ParentNode FROM NodeMember WHERE UserId = ? UNION SELECT NodeId, ParentNode FROM SchematicNode WHERE NodeOwner = ?), RSN AS ( SELECT NodeId, ParentNode FROM Nodes UNION SELECT SN.NodeId, SN.ParentNode FROM SchematicNode SN, RSN WHERE SN.ParentNode = RSN.NodeId ) SELECT SN.*, ? AS EffectiveOwner FROM RSN INNER JOIN SchematicNode SN ON RSN.NodeId = SN.NodeId WHERE NodeType = ?");
|
||||
private static final SelectStatement<SchematicNode> byIdAndUser = new SelectStatement<>(table,
|
||||
"SELECT NodeId, NodeOwner, ? AS EffectiveOwner, NodeName, ParentNode, LastUpdate, NodeItem, NodeType, NodeRank, ReplaceColor, AllowReplay FROM SchematicNode WHERE NodeId = ?");
|
||||
"SELECT NodeId, NodeOwner, ? AS EffectiveOwner, NodeName, ParentNode, LastUpdate, NodeItem, NodeType, NodeRank, Config FROM SchematicNode WHERE NodeId = ?");
|
||||
private static final SelectStatement<SchematicNode> allParentsOfNode = new SelectStatement<>(table,
|
||||
"WITH RECURSIVE R AS (SELECT NodeId, ParentNode FROM EffectiveSchematicNode WHERE NodeId = ? AND EffectiveOwner = ? UNION SELECT E.NodeId, E.ParentNode FROM R, EffectiveSchematicNode E WHERE R.ParentNode = E.NodeId AND E.EffectiveOwner = ?) SELECT SN.NodeId, SN.NodeOwner, ? AS EffectiveOwner, SN.NodeName, R.ParentNode, SN.LastUpdate, SN.NodeItem, SN.NodeType, SN.NodeRank, SN.ReplaceColor, SN.AllowReplay FROM R INNER JOIN SchematicNode SN ON SN.NodeId = R.NodeId");
|
||||
|
||||
@ -108,10 +108,8 @@ public class SchematicNode {
|
||||
private SchematicType nodeType;
|
||||
@Field(def = "0")
|
||||
private int nodeRank;
|
||||
@Field(def = "1")
|
||||
private boolean replaceColor;
|
||||
@Field(def = "1")
|
||||
private boolean allowReplay;
|
||||
@Field
|
||||
private int config;
|
||||
|
||||
private String brCache;
|
||||
|
||||
@ -125,8 +123,7 @@ public class SchematicNode {
|
||||
String nodeItem,
|
||||
SchematicType nodeType,
|
||||
int nodeRank,
|
||||
boolean replaceColor,
|
||||
boolean allowReplay) {
|
||||
int config) {
|
||||
this.nodeId = nodeId;
|
||||
this.nodeOwner = nodeOwner;
|
||||
this.effectiveOwner = effectiveOwner;
|
||||
@ -136,8 +133,7 @@ public class SchematicNode {
|
||||
this.nodeType = nodeType;
|
||||
this.lastUpdate = lastUpdate;
|
||||
this.nodeRank = nodeRank;
|
||||
this.replaceColor = replaceColor;
|
||||
this.allowReplay = allowReplay;
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
public static List<SchematicNode> getAll(SteamwarUser user) {
|
||||
@ -407,7 +403,7 @@ public class SchematicNode {
|
||||
public String getFileEnding() {
|
||||
if (isDir())
|
||||
throw new SecurityException("Node is Directory");
|
||||
return NodeData.get(this).getNodeFormat().getFileEnding();
|
||||
return NodeData.getLatest(this).getNodeFormat().getFileEnding();
|
||||
}
|
||||
|
||||
public int getRank() {
|
||||
@ -441,24 +437,45 @@ public class SchematicNode {
|
||||
}
|
||||
|
||||
public boolean replaceColor() {
|
||||
return replaceColor;
|
||||
return getConfig(ConfigFlags.REPLACE_COLOR);
|
||||
}
|
||||
|
||||
public void setReplaceColor(boolean replaceColor) {
|
||||
if (isDir())
|
||||
throw new SecurityException("Is Directory");
|
||||
this.replaceColor = replaceColor;
|
||||
updateDB();
|
||||
setConfig(ConfigFlags.REPLACE_COLOR, replaceColor);
|
||||
}
|
||||
|
||||
public boolean allowReplay() {
|
||||
return allowReplay;
|
||||
return getConfig(ConfigFlags.ALLOW_REPLAY);
|
||||
}
|
||||
|
||||
public void setAllowReplay(boolean allowReplay) {
|
||||
if (isDir())
|
||||
throw new SecurityException("Is Directory");
|
||||
this.allowReplay = allowReplay;
|
||||
setConfig(ConfigFlags.ALLOW_REPLAY, allowReplay);
|
||||
}
|
||||
|
||||
public boolean isPrepared() {
|
||||
return getConfig(ConfigFlags.IS_PREPARED);
|
||||
}
|
||||
|
||||
public void setPrepared(boolean prepared) {
|
||||
if (isDir())
|
||||
throw new SecurityException("Is Directory");
|
||||
setConfig(ConfigFlags.IS_PREPARED, prepared);
|
||||
}
|
||||
|
||||
public boolean getConfig(ConfigFlags flag) {
|
||||
return (config & (1 << flag.ordinal())) != 0;
|
||||
}
|
||||
|
||||
public void setConfig(ConfigFlags flag, boolean value) {
|
||||
if (value) {
|
||||
config |= (1 << flag.ordinal());
|
||||
} else {
|
||||
config &= ~(1 << flag.ordinal());
|
||||
}
|
||||
updateDB();
|
||||
}
|
||||
|
||||
@ -486,7 +503,7 @@ public class SchematicNode {
|
||||
|
||||
private void updateDB() {
|
||||
this.lastUpdate = Timestamp.from(Instant.now());
|
||||
update.update(nodeName, parentNode, nodeItem, nodeType, nodeRank, replaceColor, allowReplay, nodeId);
|
||||
update.update(nodeName, parentNode, nodeItem, nodeType, nodeRank, config, nodeId);
|
||||
TAB_CACHE.clear();
|
||||
}
|
||||
|
||||
@ -608,4 +625,10 @@ public class SchematicNode {
|
||||
TAB_CACHE.computeIfAbsent(user.getId(), integer -> new HashMap<>()).putIfAbsent(cacheKey, list);
|
||||
return list;
|
||||
}
|
||||
|
||||
public static enum ConfigFlags {
|
||||
REPLACE_COLOR,
|
||||
ALLOW_REPLAY,
|
||||
IS_PREPARED
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,94 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2023 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.sql;
|
||||
|
||||
import de.steamwar.sql.internal.Field;
|
||||
import de.steamwar.sql.internal.SelectStatement;
|
||||
import de.steamwar.sql.internal.Statement;
|
||||
import de.steamwar.sql.internal.Table;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@AllArgsConstructor
|
||||
public class Tutorial {
|
||||
|
||||
private static final Table<Tutorial> table = new Table<>(Tutorial.class);
|
||||
private static final SelectStatement<Tutorial> by_popularity = new SelectStatement<>(table, "SELECT t.*, AVG(r.Stars) AS Stars FROM Tutorial t LEFT OUTER JOIN TutorialRating r ON t.TutorialID = r.TutorialID WHERE t.Released = ? GROUP BY t.TutorialID ORDER BY SUM(r.Stars) DESC LIMIT ?, ?");
|
||||
private static final SelectStatement<Tutorial> own = new SelectStatement<>(table, "SELECT t.*, AVG(r.Stars) AS Stars FROM Tutorial t LEFT OUTER JOIN TutorialRating r ON t.TutorialID = r.TutorialID WHERE t.Creator = ? GROUP BY t.TutorialID ORDER BY t.TutorialID ASC LIMIT ?, ?");
|
||||
private static final SelectStatement<Tutorial> by_creator_name = new SelectStatement<>(table, "SELECT t.*, AVG(r.Stars) AS Stars FROM Tutorial t LEFT OUTER JOIN TutorialRating r ON t.TutorialID = r.TutorialID WHERE t.Creator = ? AND t.Name = ? GROUP BY t.TutorialID");
|
||||
private static final SelectStatement<Tutorial> by_id = new SelectStatement<>(table, "SELECT t.*, AVG(r.Stars) AS Stars FROM Tutorial t LEFT OUTER JOIN TutorialRating r ON t.TutorialID = r.TutorialID WHERE t.TutorialID = ? GROUP BY t.TutorialID");
|
||||
private static final Statement rate = new Statement("INSERT INTO TutorialRating (TutorialID, UserID, Stars) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE Stars = VALUES(Stars)");
|
||||
private static final Statement create = new Statement("INSERT INTO Tutorial (Creator, Name, Item) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE Item = VALUES(Item), Released = 0");
|
||||
private static final Statement release = table.update(Table.PRIMARY, "released");
|
||||
private static final Statement delete = table.delete(Table.PRIMARY);
|
||||
|
||||
public static List<Tutorial> getPage(int page, int elementsPerPage, boolean released) {
|
||||
List<Tutorial> tutorials = by_popularity.listSelect(released, page * elementsPerPage, elementsPerPage);
|
||||
SteamwarUser.batchCache(tutorials.stream().map(tutorial -> tutorial.creator).collect(Collectors.toSet()));
|
||||
return tutorials;
|
||||
}
|
||||
|
||||
public static List<Tutorial> getOwn(int user, int page, int elementsPerPage) {
|
||||
return own.listSelect(user, page * elementsPerPage, elementsPerPage);
|
||||
}
|
||||
|
||||
public static Tutorial create(int creator, String name, String item) {
|
||||
create.update(creator, name, item);
|
||||
return by_creator_name.select(creator, name);
|
||||
}
|
||||
|
||||
public static Tutorial get(int id) {
|
||||
return by_id.select(id);
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Field(keys = {Table.PRIMARY}, autoincrement = true)
|
||||
private final int tutorialId;
|
||||
@Getter
|
||||
@Field(keys = {"CreatorName"})
|
||||
private final int creator;
|
||||
@Getter
|
||||
@Field(keys = {"CreatorName"})
|
||||
private final String name;
|
||||
@Getter
|
||||
@Field(def = "'BOOK'")
|
||||
private final String item;
|
||||
@Getter
|
||||
@Field(def = "0")
|
||||
private final boolean released;
|
||||
@Getter
|
||||
@Field(def = "0") // Not really a field, but necessary for select generation
|
||||
private final double stars;
|
||||
|
||||
public void release() {
|
||||
release.update(1, tutorialId);
|
||||
}
|
||||
|
||||
public void delete() {
|
||||
delete.update(tutorialId);
|
||||
}
|
||||
|
||||
public void rate(int user, int rating) {
|
||||
rate.update(tutorialId, user, rating);
|
||||
}
|
||||
}
|
||||
@ -48,18 +48,19 @@ public enum UserPerm {
|
||||
public static final Map<UserPerm, Prefix> prefixes;
|
||||
public static final Prefix emptyPrefix;
|
||||
static {
|
||||
// https://www.digminecraft.com/lists/color_list_pc.php
|
||||
SqlTypeMapper.nameEnumMapper(UserPerm.class);
|
||||
Map<UserPerm, Prefix> p = new EnumMap<>(UserPerm.class);
|
||||
emptyPrefix = new Prefix("§7", "");
|
||||
p.put(PREFIX_NONE, emptyPrefix);
|
||||
p.put(PREFIX_YOUTUBER, new Prefix("§7", "YT"));
|
||||
p.put(PREFIX_GUIDE, new Prefix("§a", "Guide"));
|
||||
p.put(PREFIX_GUIDE, new Prefix("§x§e§7§6§2§e§d", "Guide")); // E762ED
|
||||
|
||||
p.put(PREFIX_SUPPORTER, new Prefix("§6", "Sup"));
|
||||
p.put(PREFIX_MODERATOR, new Prefix("§6", "Mod"));
|
||||
p.put(PREFIX_BUILDER, new Prefix("§e", "Arch"));
|
||||
p.put(PREFIX_DEVELOPER, new Prefix("§e", "Dev"));
|
||||
p.put(PREFIX_ADMIN, new Prefix("§e", "Admin"));
|
||||
p.put(PREFIX_SUPPORTER, new Prefix("§x§6§0§9§5§F§B", "Sup")); // 6095FB
|
||||
p.put(PREFIX_MODERATOR, new Prefix("§x§F§F§A§2§5§C", "Mod")); // FFA25C
|
||||
p.put(PREFIX_BUILDER, new Prefix("§x§6§0§F§F§6§A", "Arch")); // 60FF6A
|
||||
p.put(PREFIX_DEVELOPER, new Prefix("§x§0§B§B§C§B§3", "Dev")); // 0BBCB3
|
||||
p.put(PREFIX_ADMIN, new Prefix("§x§F§F§2§B§2§4", "Admin")); // FF2B24
|
||||
prefixes = Collections.unmodifiableMap(p);
|
||||
}
|
||||
|
||||
|
||||
@ -24,4 +24,5 @@ plugins {
|
||||
dependencies {
|
||||
api(project(":CommonCore:SQL"))
|
||||
api(project(":CommonCore:Network"))
|
||||
api(project(":CommonCore:Data"))
|
||||
}
|
||||
|
||||
@ -145,6 +145,6 @@ public class WorldeditWrapper14 implements WorldeditWrapper {
|
||||
throw new SecurityException(e);
|
||||
}
|
||||
|
||||
new SchematicData(schem).saveFromBytes(outputStream.toByteArray(), NodeData.SchematicFormat.SPONGE_V2);
|
||||
SchematicData.saveFromBytes(schem, outputStream.toByteArray(), NodeData.SchematicFormat.SPONGE_V2);
|
||||
}
|
||||
}
|
||||
|
||||
@ -25,6 +25,6 @@ public class CraftbukkitWrapper21 extends CraftbukkitWrapper18 {
|
||||
|
||||
@Override
|
||||
public float headRotation(Entity e) {
|
||||
return getEntity(e).bS();
|
||||
return getEntity(e).getYHeadRot();
|
||||
}
|
||||
}
|
||||
|
||||
@ -20,10 +20,7 @@
|
||||
package de.steamwar.fightsystem.utils;
|
||||
|
||||
import com.sk89q.jnbt.NBTInputStream;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.*;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.bukkit.BukkitWorld;
|
||||
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
|
||||
@ -143,6 +140,6 @@ public class WorldeditWrapper8 implements WorldeditWrapper {
|
||||
throw new SecurityException(e);
|
||||
}
|
||||
|
||||
new SchematicData(schem).saveFromBytes(outputStream.toByteArray(), NodeData.SchematicFormat.MCEDIT);
|
||||
SchematicData.saveFromBytes(schem, outputStream.toByteArray(), NodeData.SchematicFormat.MCEDIT);
|
||||
}
|
||||
}
|
||||
|
||||
@ -59,6 +59,7 @@ public class Config {
|
||||
public static final Region RedExtendRegion;
|
||||
public static final Region ArenaRegion;
|
||||
public static final Region PlayerRegion;
|
||||
public static final Region BlueInsetRegion;
|
||||
|
||||
public static final Location TeamBlueSpawn;
|
||||
public static final Location TeamRedSpawn;
|
||||
@ -107,6 +108,7 @@ public class Config {
|
||||
public static final boolean PercentEntern;
|
||||
public static final boolean PercentBlocksWhitelist;
|
||||
public static final Set<Material> PercentBlocks;
|
||||
public static final int TechKoTime;
|
||||
|
||||
//default kits
|
||||
public static final String MemberDefault;
|
||||
@ -193,6 +195,11 @@ public class Config {
|
||||
ReplaceWithBlockupdates = config.getBoolean("Schematic.ReplaceWithBlockupdates", false);
|
||||
UnlimitedPrepare = config.getBoolean("Schematic.UnlimitedPrepare", false);
|
||||
|
||||
int schemInsetX = config.getInt("Schematic.Inset.x", 0);
|
||||
int schemInsetZ = config.getInt("Schematic.Inset.z", 0);
|
||||
int schemInsetBottom = config.getInt("Schematic.Inset.bottom", 0);
|
||||
int schemInsetTop = config.getInt("Schematic.Inset.top", 0);
|
||||
|
||||
GameName = config.getString("GameName", "WarGear");
|
||||
TeamChatDetection = config.getString("TeamChatPrefix", "+");
|
||||
|
||||
@ -203,6 +210,7 @@ public class Config {
|
||||
PercentEntern = config.getBoolean("WinConditionParams.PercentEntern", true);
|
||||
PercentBlocksWhitelist = config.getBoolean("WinConditionParams.BlocksWhitelist", false);
|
||||
PercentBlocks = Collections.unmodifiableSet(config.getStringList("WinConditionParams.Blocks").stream().map(Material::valueOf).collect(Collectors.toSet()));
|
||||
TechKoTime = config.getInt("WinConditionParams.TechKoTime", 90);
|
||||
|
||||
EnterStages = Collections.unmodifiableList(config.getIntegerList("EnterStages"));
|
||||
AllowMissiles = config.getBoolean("Arena.AllowMissiles", !EnterStages.isEmpty());
|
||||
@ -318,6 +326,8 @@ public class Config {
|
||||
ArenaRegion = Region.withExtension(arenaMinX, blueCornerY, arenaMinZ, arenaMaxX - arenaMinX, schemsizeY, arenaMaxZ - arenaMinZ, 0, PreperationArea, 0);
|
||||
PlayerRegion = new Region(arenaMinX, underBorder, arenaMinZ, arenaMaxX, world.getMaxHeight(), arenaMaxZ);
|
||||
|
||||
BlueInsetRegion = new Region(BluePasteRegion.getMinX() + schemInsetX, BluePasteRegion.getMinY() + schemInsetBottom, BluePasteRegion.getMinZ() + schemInsetZ, BluePasteRegion.getMaxX() - schemInsetX, BluePasteRegion.getMaxY() - schemInsetTop, BluePasteRegion.getMaxZ() - schemInsetZ);
|
||||
|
||||
int eventKampfID = Integer.parseInt(System.getProperty("fightID", "0"));
|
||||
if(eventKampfID >= 1){
|
||||
EventKampf = EventFight.get(eventKampfID);
|
||||
@ -359,7 +369,7 @@ public class Config {
|
||||
}else{
|
||||
//No event
|
||||
TeamRedColor = config.getString("Red.Prefix", "§c");
|
||||
TeamBlueColor = config.getString("Blue.Prefix", "§3");
|
||||
TeamBlueColor = config.getString("Blue.Prefix", "§9");
|
||||
TeamRedName = config.getString("Red.Name", "Rot");
|
||||
TeamBlueName = config.getString("Blue.Name", "Blau");
|
||||
OnlyPublicSchematics = config.getBoolean("Schematic.OnlyPublicSchematics", false);
|
||||
|
||||
@ -20,19 +20,17 @@
|
||||
package de.steamwar.fightsystem;
|
||||
|
||||
import com.comphenix.tinyprotocol.TinyProtocol;
|
||||
import de.steamwar.core.WorldEditRendererCUIEditor;
|
||||
import de.steamwar.core.Core;
|
||||
import de.steamwar.fightsystem.commands.*;
|
||||
import de.steamwar.fightsystem.countdown.*;
|
||||
import de.steamwar.fightsystem.event.HellsBells;
|
||||
import de.steamwar.fightsystem.event.Meteor;
|
||||
import de.steamwar.fightsystem.event.PersistentDamage;
|
||||
import de.steamwar.fightsystem.event.TNTDistributor;
|
||||
import de.steamwar.fightsystem.event.*;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.fight.FightWorld;
|
||||
import de.steamwar.fightsystem.fight.HotbarKit;
|
||||
import de.steamwar.fightsystem.listener.Shutdown;
|
||||
import de.steamwar.fightsystem.listener.*;
|
||||
import de.steamwar.fightsystem.listener.Shutdown;
|
||||
import de.steamwar.fightsystem.record.FileRecorder;
|
||||
import de.steamwar.fightsystem.record.FileSource;
|
||||
import de.steamwar.fightsystem.record.GlobalRecorder;
|
||||
@ -43,6 +41,7 @@ import de.steamwar.fightsystem.states.StateDependentListener;
|
||||
import de.steamwar.fightsystem.utils.*;
|
||||
import de.steamwar.fightsystem.winconditions.*;
|
||||
import de.steamwar.message.Message;
|
||||
import de.steamwar.sql.NodeData;
|
||||
import de.steamwar.sql.SchematicNode;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -70,6 +69,11 @@ public class FightSystem extends JavaPlugin {
|
||||
Core.setInstance(this);
|
||||
TinyProtocol.init();
|
||||
}
|
||||
if (Config.SpectatePort != 0) {
|
||||
Core.setServerName("Spectate");
|
||||
} else if (Config.ReplayID != 0) {
|
||||
Core.setServerName("Replay");
|
||||
}
|
||||
|
||||
message = new Message("de.steamwar.fightsystem.FightSystem", FightSystem.class.getClassLoader());
|
||||
|
||||
@ -109,6 +113,7 @@ public class FightSystem extends JavaPlugin {
|
||||
new HotbarKit.HotbarKitListener();
|
||||
new JoinRequestListener();
|
||||
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 EnterHandler();
|
||||
techHider = new TechHiderWrapper();
|
||||
@ -127,6 +132,7 @@ public class FightSystem extends JavaPlugin {
|
||||
new WinconditionPointsAirShip();
|
||||
new WinconditionTimeout();
|
||||
new WinconditionTimeTechKO();
|
||||
new WinconditionTimedDamageTechKO();
|
||||
new EventTeamOffWincondition();
|
||||
new WinconditionComparisonTimeout(Winconditions.HEART_RATIO_TIMEOUT, "HeartTimeout", "WIN_MORE_HEALTH", FightTeam::getHeartRatio);
|
||||
new WinconditionComparisonTimeout(Winconditions.PERCENT_TIMEOUT, "PercentTimeout", "WIN_LESS_DAMAGE", team -> -Wincondition.getPercentWincondition().getPercent(team));
|
||||
@ -136,6 +142,7 @@ public class FightSystem extends JavaPlugin {
|
||||
new PersistentDamage();
|
||||
new TNTDistributor();
|
||||
new WinconditionAmongUs();
|
||||
new NoGravity();
|
||||
|
||||
new NoPlayersOnlineCountdown();
|
||||
new PreSchemCountdown();
|
||||
@ -173,12 +180,11 @@ public class FightSystem extends JavaPlugin {
|
||||
SchematicNode checkSchematicNode = SchematicNode.getSchematicNode(Config.CheckSchemID);
|
||||
Fight.getBlueTeam().setSchem(checkSchematicNode);
|
||||
|
||||
if (checkSchematicNode.getName().endsWith("-prepared")) {
|
||||
SchematicNode unpreparedSchematicNode = SchematicNode.getSchematicNode(checkSchematicNode.getOwner(), checkSchematicNode.getName().substring(0, checkSchematicNode.getName().length() - 9), checkSchematicNode.getParent());
|
||||
if (unpreparedSchematicNode != null) {
|
||||
Fight.getRedTeam().setSchem(unpreparedSchematicNode);
|
||||
}
|
||||
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));
|
||||
}
|
||||
|
||||
@ -76,6 +76,7 @@ KITSEARCH_TITLE=Search for kit
|
||||
|
||||
SCHEM_NO_ENEMY=§cNo schematic selection without an opponent
|
||||
SCHEM_TITLE={0} selection
|
||||
SCHEM_DIRT=§eDirt Block
|
||||
SCHEM_PUBLIC=§ePublic {0}
|
||||
SCHEM_UNCHECKED=§eUnchecked {0}
|
||||
SCHEM_PRIVATE=§ePrivate {0}
|
||||
@ -190,6 +191,7 @@ BAR_POINTS_OF={0}§8/§7{1} §8Points
|
||||
BAR_PERCENT={0}§8%
|
||||
BAR_CANNONS={0} §8Cannons
|
||||
BAR_WATER={0} §8Water
|
||||
BAR_SECONDS={0}§8s
|
||||
|
||||
|
||||
# Winconditions
|
||||
|
||||
@ -70,6 +70,7 @@ KITSEARCH_TITLE=Nach Kit suchen
|
||||
|
||||
SCHEM_NO_ENEMY=§cKeine Schematicwahl ohne Gegner
|
||||
SCHEM_TITLE={0}-Auswahl
|
||||
SCHEM_DIRT=§eErdblock
|
||||
SCHEM_PUBLIC=§eÖffentliches {0}
|
||||
SCHEM_UNCHECKED=§eUngeprüftes {0}
|
||||
SCHEM_PRIVATE=§ePrivates {0}
|
||||
|
||||
@ -24,15 +24,14 @@ import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.ai.AIManager;
|
||||
import de.steamwar.fightsystem.fight.*;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightPlayer;
|
||||
import de.steamwar.fightsystem.listener.PersonalKitCreator;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.utils.ColorConverter;
|
||||
import de.steamwar.inventory.*;
|
||||
import de.steamwar.message.Message;
|
||||
import de.steamwar.sql.PersonalKit;
|
||||
import de.steamwar.sql.SchematicNode;
|
||||
import de.steamwar.sql.SchematicType;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.sql.*;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
@ -40,7 +39,10 @@ import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class GUI {
|
||||
@ -206,6 +208,14 @@ public class GUI {
|
||||
for (int i = 0; i < Config.SubTypes.size(); i++) {
|
||||
setupSchemTypeRow(p, inv, Config.SubTypes.get(i), i + 1);
|
||||
}
|
||||
if (!Config.test() && SteamwarUser.get(p.getUniqueId()).hasPerm(UserPerm.TEAM)) {
|
||||
SchematicNode node = SchematicNode.getSchematicNode(-1, Config.GameName, (Integer) null);
|
||||
if (node != null) {
|
||||
inv.setItem(2, new SWItem(SWItem.getMaterial(node.getItem()), msg.parse("SCHEM_DIRT", p), click -> {
|
||||
schemSelect(p, node);
|
||||
}));
|
||||
}
|
||||
}
|
||||
inv.setCallback(-999, (ClickType click) -> p.closeInventory());
|
||||
inv.open();
|
||||
}
|
||||
@ -241,14 +251,18 @@ public class GUI {
|
||||
|
||||
private static void schemDialog(Player p, SchematicType type, boolean publicSchems, boolean unchecked){
|
||||
SchematicSelector selector = new SchematicSelector(p, Config.test() ? SchematicSelector.selectSchematic() : SchematicSelector.selectSchematicType(unchecked ? type.checkType() : type), node -> {
|
||||
FightTeam fightTeam = Fight.getPlayerTeam(p);
|
||||
if(fightTeam == null)
|
||||
return;
|
||||
if(Config.test() || FightState.getFightState() != FightState.POST_SCHEM_SETUP)
|
||||
fightTeam.pasteSchem(node);
|
||||
p.closeInventory();
|
||||
schemSelect(p, node);
|
||||
});
|
||||
selector.setPublicMode(publicSchems?SchematicSelector.PublicMode.PUBLIC_ONLY:SchematicSelector.PublicMode.PRIVATE_ONLY);
|
||||
selector.open();
|
||||
}
|
||||
|
||||
private static void schemSelect(Player p, SchematicNode node) {
|
||||
FightTeam fightTeam = Fight.getPlayerTeam(p);
|
||||
if(fightTeam == null)
|
||||
return;
|
||||
if(Config.test() || FightState.getFightState() != FightState.POST_SCHEM_SETUP)
|
||||
fightTeam.pasteSchem(node);
|
||||
p.closeInventory();
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,60 @@
|
||||
/*
|
||||
* 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.commands;
|
||||
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.entity.CWireframe;
|
||||
import de.steamwar.entity.REntityServer;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import org.bukkit.Bukkit;
|
||||
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<>();
|
||||
|
||||
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 {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -34,6 +34,7 @@ import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.io.StringWriter;
|
||||
import java.util.Arrays;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class TechhiderbugCommand implements CommandExecutor {
|
||||
|
||||
@ -45,25 +46,33 @@ public class TechhiderbugCommand implements CommandExecutor {
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String alias, String[] args) {
|
||||
StringWriter writer = new StringWriter();
|
||||
|
||||
writer.append("ArenaMode: ").append(Config.mode.name()).append('\n');
|
||||
writer.append("FightState: ").append(FightState.getFightState().name()).append('\n');
|
||||
writer.append("TechHider enabled: ").append(FightState.getStateDependentFeatures().get(FightSystem.getTechHider()).toString()).append('\n');
|
||||
try {
|
||||
writer.append("ArenaMode: ").append(Config.mode.name()).append('\n');
|
||||
writer.append("FightState: ").append(FightState.getFightState().name()).append('\n');
|
||||
writer.append("TechHider enabled: ").append(FightState.getStateDependentFeatures().get(FightSystem.getTechHider()).toString()).append('\n');
|
||||
|
||||
writer.append("Arena region: ").append(Config.ArenaRegion.toString()).append('\n');
|
||||
writer.append("Team regions: ");
|
||||
Fight.teams().forEach(t -> writer.append(t.getName()).append(':').append(t.getExtendRegion().toString()).append(' '));
|
||||
writer.append('\n');
|
||||
writer.append("Arena region: ").append(Config.ArenaRegion.toString()).append('\n');
|
||||
writer.append("Team regions: ");
|
||||
Fight.teams().forEach(t -> writer.append(t.getName()).append(':').append(t.getExtendRegion().toString()).append(' '));
|
||||
writer.append('\n');
|
||||
|
||||
writer.append("HullHider regions: ");
|
||||
FightSystem.getHullHider().getHullMap().forEach((t, h) -> writer.append(t.getName()).append(':').append(h.getRegion().toString()).append(' '));
|
||||
writer.append('\n');
|
||||
writer.append("HullHider regions: ");
|
||||
FightSystem.getHullHider().getHullMap().forEach((t, h) -> writer.append(t.getName()).append(':').append(h.getRegion().toString()).append(' '));
|
||||
writer.append('\n');
|
||||
|
||||
writer.append("Hidden regions: ");
|
||||
FightSystem.getTechHider().getHiddenRegion().forEach((p, r) -> writer.append(p.getName()).append(':').append(r.toString()).append(' '));
|
||||
writer.append('\n');
|
||||
writer.append("Hidden regions: ");
|
||||
FightSystem.getTechHider().getHiddenRegion().forEach((p, r) -> writer.append(p.getName()).append(':').append(r.toString()).append(' '));
|
||||
writer.append('\n');
|
||||
|
||||
writer.append('\n').append("Netty pipelines:\n");
|
||||
Bukkit.getOnlinePlayers().forEach(p -> writer.append(p.getName()).append(": ").append(String.join(" ", TinyProtocol.instance.getPlayerInterceptors().get(p).getChannel().pipeline().names())).append('\n'));
|
||||
writer.append("TinyProtocol: ");
|
||||
writer.append(TinyProtocol.instance.toString()).append('\n');
|
||||
|
||||
writer.append('\n').append("Netty pipelines:\n");
|
||||
Bukkit.getOnlinePlayers().forEach(p -> writer.append(p.getName()).append(": ").append(String.join(" ", TinyProtocol.instance.getPlayerInterceptors().get(p).getChannel().pipeline().names())).append('\n'));
|
||||
} catch (Exception e) {
|
||||
writer.append("Error while generating bug report: ").append(e.getMessage()).append('\n');
|
||||
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;
|
||||
|
||||
@ -21,6 +21,7 @@ package de.steamwar.fightsystem.commands;
|
||||
|
||||
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 org.bukkit.command.Command;
|
||||
@ -39,7 +40,9 @@ public class WGCommand implements CommandExecutor {
|
||||
if(!(sender instanceof Player)) {
|
||||
return false;
|
||||
}
|
||||
FightWorld.resetWorld();
|
||||
Fight.getBlueTeam().pasteSchem();
|
||||
Fight.getRedTeam().pasteSchem();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2021 SteamWar.de-Serverteam
|
||||
* Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
@ -17,24 +17,25 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.tutorial.listener;
|
||||
package de.steamwar.fightsystem.event;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||
import de.steamwar.fightsystem.winconditions.Winconditions;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntitySpawnEvent;
|
||||
|
||||
public class Joining extends BasicListener {
|
||||
public class NoGravity implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onJoin(PlayerJoinEvent event) {
|
||||
event.getPlayer().setOp(true);
|
||||
public NoGravity() {
|
||||
new StateDependentListener(Winconditions.NO_GRAVITY, FightState.All, this);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onQuit(PlayerQuitEvent event) {
|
||||
if (Bukkit.getOnlinePlayers().isEmpty() || (Bukkit.getOnlinePlayers().size() == 1 && Bukkit.getOnlinePlayers().contains(event.getPlayer()))) {
|
||||
Bukkit.shutdown();
|
||||
}
|
||||
public void onEntitySpawn(EntitySpawnEvent event) {
|
||||
if (event.getEntityType() == EntityType.PLAYER) return;
|
||||
event.getEntity().setGravity(false);
|
||||
}
|
||||
}
|
||||
@ -19,20 +19,14 @@
|
||||
|
||||
package de.steamwar.fightsystem.fight;
|
||||
|
||||
import com.comphenix.tinyprotocol.TinyProtocol;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import de.steamwar.core.Core;
|
||||
import de.steamwar.core.ProtocolWrapper;
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.record.GlobalRecorder;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
|
||||
@ -31,6 +31,7 @@ import de.steamwar.fightsystem.states.StateDependent;
|
||||
import de.steamwar.fightsystem.utils.ColorConverter;
|
||||
import de.steamwar.fightsystem.utils.Region;
|
||||
import de.steamwar.fightsystem.utils.WorldeditWrapper;
|
||||
import de.steamwar.fightsystem.winconditions.Winconditions;
|
||||
import de.steamwar.sql.SchematicData;
|
||||
import de.steamwar.sql.SchematicNode;
|
||||
import de.steamwar.sql.SchematicType;
|
||||
@ -51,20 +52,28 @@ public class FightSchematic extends StateDependent {
|
||||
|
||||
private final FightTeam team;
|
||||
private final Region region;
|
||||
|
||||
private final boolean rotate;
|
||||
@Getter
|
||||
private boolean usedRotate;
|
||||
|
||||
@Getter
|
||||
private Clipboard clipboard = null;
|
||||
private int schematic = 0;
|
||||
|
||||
public FightSchematic(FightTeam team, boolean rotate) {
|
||||
public FightSchematic(FightTeam team, boolean usedRotate) {
|
||||
super(ArenaMode.All, FightState.PostSchemSetup);
|
||||
this.team = team;
|
||||
this.region = team.getSchemRegion();
|
||||
this.rotate = rotate;
|
||||
this.rotate = usedRotate;
|
||||
this.usedRotate = usedRotate;
|
||||
register();
|
||||
}
|
||||
|
||||
public void setChangeRotate(boolean rotate) {
|
||||
this.usedRotate = this.rotate ^ rotate;
|
||||
}
|
||||
|
||||
public boolean hasSchematic() {
|
||||
return clipboard != null;
|
||||
}
|
||||
@ -74,9 +83,13 @@ public class FightSchematic extends StateDependent {
|
||||
}
|
||||
|
||||
public void setSchematic(SchematicNode schem) {
|
||||
setSchematic(schem, -1);
|
||||
}
|
||||
|
||||
public void setSchematic(SchematicNode schem, int revision) {
|
||||
schematic = schem.getId();
|
||||
try {
|
||||
clipboard = new SchematicData(schem).load();
|
||||
clipboard = new SchematicData(schem, revision).load();
|
||||
|
||||
if(schem.replaceColor())
|
||||
replaceTeamColor(clipboard);
|
||||
@ -119,10 +132,15 @@ public class FightSchematic extends StateDependent {
|
||||
}
|
||||
|
||||
if(ArenaMode.AntiReplay.contains(Config.mode)) {
|
||||
boolean changeRotation = false;
|
||||
if (Config.ActiveWinconditions.contains(Winconditions.RANDOM_ROTATE)) {
|
||||
changeRotation = new Random().nextBoolean();
|
||||
usedRotate = rotate ^ changeRotation;
|
||||
}
|
||||
if(team.isBlue())
|
||||
GlobalRecorder.getInstance().blueSchem(schematic);
|
||||
GlobalRecorder.getInstance().blueSchem(schematic, changeRotation);
|
||||
else
|
||||
GlobalRecorder.getInstance().redSchem(schematic);
|
||||
GlobalRecorder.getInstance().redSchem(schematic, changeRotation);
|
||||
}
|
||||
|
||||
Bukkit.getScheduler().runTask(FightSystem.getPlugin(), this::paste);
|
||||
@ -148,8 +166,8 @@ public class FightSchematic extends StateDependent {
|
||||
Config.PasteAligned && Config.BlueToRedX != 0 ? region.getSizeX()/2.0 - dims.getBlockX() : -dims.getBlockX()/2.0,
|
||||
Config.WaterDepth != 0 ? Config.WaterDepth - WorldeditWrapper.impl.getWaterDepth(clipboard) : 0,
|
||||
Config.PasteAligned && Config.BlueToRedZ != 0 ? region.getSizeZ()/2.0 - dims.getBlockZ() : -dims.getBlockZ()/2.0
|
||||
).add(new Vector(rotate ? 1 : 0, 0, rotate ? 1 : 0)),
|
||||
new AffineTransform().rotateY(rotate ? 180 : 0)
|
||||
).add(new Vector(usedRotate ? 1 : 0, 0, usedRotate ? 1 : 0)),
|
||||
new AffineTransform().rotateY(usedRotate ? 180 : 0)
|
||||
);
|
||||
FightSystem.getHullHider().initialize(team);
|
||||
team.getPlayers().forEach(fightPlayer -> fightPlayer.ifAI(ai -> ai.schematic(clipboard)));
|
||||
|
||||
@ -412,7 +412,11 @@ public class FightTeam {
|
||||
}
|
||||
|
||||
public void setSchem(SchematicNode schematic){
|
||||
this.schematic.setSchematic(schematic);
|
||||
setSchem(schematic, -1);
|
||||
}
|
||||
|
||||
public void setSchem(SchematicNode schematic, int revision){
|
||||
this.schematic.setSchematic(schematic, revision);
|
||||
broadcast("SCHEMATIC_CHOSEN", Config.GameName, schematic.getName());
|
||||
}
|
||||
|
||||
@ -458,6 +462,10 @@ public class FightTeam {
|
||||
return schematic.getId();
|
||||
}
|
||||
|
||||
public void setSchematicChangeRotate(boolean rotate) {
|
||||
schematic.setChangeRotate(rotate);
|
||||
}
|
||||
|
||||
public Clipboard getClipboard() {
|
||||
return schematic.getClipboard();
|
||||
}
|
||||
|
||||
@ -29,11 +29,15 @@ import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||
import de.steamwar.fightsystem.states.StateDependentTask;
|
||||
import de.steamwar.fightsystem.utils.ItemBuilder;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryOpenEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.EquipmentSlot;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@ -107,6 +111,19 @@ public class HotbarKit extends Kit {
|
||||
|
||||
Player player = event.getPlayer();
|
||||
int slot = player.getInventory().getHeldItemSlot();
|
||||
click(player, slot, event);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInventoryClick(InventoryClickEvent event) {
|
||||
int slot = event.getSlot();
|
||||
if (slot < 0 || slot >= HOTBAR_SIZE) return;
|
||||
|
||||
Player player = (Player) event.getWhoClicked();
|
||||
click(player, slot, event);
|
||||
}
|
||||
|
||||
private void click(Player player, int slot, Cancellable event) {
|
||||
Kit activeKit = activeKits.get(player);
|
||||
if(!(activeKit instanceof HotbarKit) || PersonalKitCreator.inKitCreator(player) || activeKit.getInventory()[slot] == null)
|
||||
return;
|
||||
|
||||
@ -83,10 +83,8 @@ public class PrepareSchem implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if(schemExists(schem))
|
||||
return;
|
||||
|
||||
schem = SchematicNode.createSchematicNode(schem.getOwner(), preparedName(schem), schem.getParent(), Config.SchematicType.checkType().toDB(), schem.getItem());
|
||||
schem.setSchemtype(Config.SchematicType.checkType());
|
||||
schem.setPrepared(true);
|
||||
|
||||
try{
|
||||
WorldeditWrapper.impl.saveSchem(schem, region, minY);
|
||||
@ -116,20 +114,5 @@ public class PrepareSchem implements Listener {
|
||||
FightState.setFightState(FightState.PRE_SCHEM_SETUP);
|
||||
FightState.setFightState(FightState.POST_SCHEM_SETUP);
|
||||
}
|
||||
|
||||
schemExists(SchematicNode.getSchematicNode(Config.PrepareSchemID));
|
||||
}
|
||||
|
||||
private boolean schemExists(SchematicNode schem) {
|
||||
if(SchematicNode.getSchematicNode(schem.getOwner(), preparedName(schem), schem.getParent()) != null) {
|
||||
FightSystem.getMessage().broadcast("PREPARE_SCHEM_EXISTS");
|
||||
Bukkit.shutdown();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private String preparedName(SchematicNode schem) {
|
||||
return schem.getName() + "-prepared";
|
||||
}
|
||||
}
|
||||
|
||||
@ -20,7 +20,6 @@
|
||||
package de.steamwar.fightsystem.record;
|
||||
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import de.steamwar.core.Core;
|
||||
import de.steamwar.core.TrickyTrialsWrapper;
|
||||
import de.steamwar.core.WorldEditWrapper;
|
||||
import de.steamwar.entity.REntity;
|
||||
@ -144,6 +143,8 @@ public class PacketProcessor implements Listener {
|
||||
packetDecoder[0xb2] = this::teams;
|
||||
packetDecoder[0xb3] = () -> pasteEmbeddedSchem(Fight.getBlueTeam());
|
||||
packetDecoder[0xb4] = () -> pasteEmbeddedSchem(Fight.getRedTeam());
|
||||
packetDecoder[0xb5] = () -> rotateSchem(Fight.getBlueTeam());
|
||||
packetDecoder[0xb6] = () -> rotateSchem(Fight.getRedTeam());
|
||||
packetDecoder[0xc0] = this::scoreboardTitle;
|
||||
packetDecoder[0xc1] = this::scoreboardData;
|
||||
packetDecoder[0xc2] = this::bossBar;
|
||||
@ -529,6 +530,14 @@ public class PacketProcessor implements Listener {
|
||||
execSync(() -> team.pasteSchem(schemId, clipboard));
|
||||
}
|
||||
|
||||
private void rotateSchem(FightTeam team) throws IOException {
|
||||
boolean changeRotate = source.readBoolean();
|
||||
|
||||
execSync(() -> {
|
||||
team.setSchematicChangeRotate(changeRotate);
|
||||
});
|
||||
}
|
||||
|
||||
private void teams() throws IOException {
|
||||
int blueId = source.readInt();
|
||||
int redId = source.readInt();
|
||||
|
||||
@ -61,9 +61,9 @@ public interface Recorder {
|
||||
default void enableTeam(FightTeam team){
|
||||
if(FightState.Schem.contains(FightState.getFightState())){
|
||||
if(team.isBlue())
|
||||
blueSchem(team.getSchematic());
|
||||
blueSchem(team.getSchematic(), false);
|
||||
else
|
||||
redSchem(team.getSchematic());
|
||||
redSchem(team.getSchematic(), false);
|
||||
}
|
||||
|
||||
if(FightState.AntiSpectate.contains(FightState.getFightState())){
|
||||
@ -123,6 +123,8 @@ public interface Recorder {
|
||||
* TeamIDPacket (0xb2) + int blueTeamId, redTeamId
|
||||
* BlueEmbeddedSchemPacket (0xb3) + int blueSchemId + gzipt NBT blob
|
||||
* RedEmbeddedSchemPacket (0xb4) + int redSchemId + gzipt NBT blob
|
||||
* BlueSchemRotatePacket (0xb5) + boolean changeRotate
|
||||
* RedSchemRotatePacket (0xb6) + boolean changeRotate
|
||||
*
|
||||
* DEPRECATED ScoreboardTitlePacket (0xc0) + String scoreboardTitle
|
||||
* DEPRECATED ScoreboardDataPacket (0xc1) + String key + int value
|
||||
@ -259,14 +261,20 @@ public interface Recorder {
|
||||
write(0xb2, blueTeamId, redTeamId);
|
||||
}
|
||||
|
||||
default void blueSchem(int schemId) {
|
||||
default void blueSchem(int schemId, boolean changeRotate) {
|
||||
rotate(0xb5, changeRotate);
|
||||
schem(0xb3, 0xb0, schemId);
|
||||
}
|
||||
|
||||
default void redSchem(int schemId) {
|
||||
default void redSchem(int schemId, boolean changeRotate) {
|
||||
rotate(0xb6, changeRotate);
|
||||
schem(0xb4, 0xb1, schemId);
|
||||
}
|
||||
|
||||
default void rotate(int packetId, boolean changeRotate) {
|
||||
write(packetId, changeRotate);
|
||||
}
|
||||
|
||||
default void schem(int embedId, int noEmbedId, int schemId){
|
||||
if(schemId == 0) {
|
||||
write(noEmbedId, schemId);
|
||||
@ -275,7 +283,7 @@ public interface Recorder {
|
||||
|
||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||
try{
|
||||
copy(NodeData.get(SchematicNode.getSchematicNode(schemId)).schemData(), buffer);
|
||||
copy(NodeData.getLatest(SchematicNode.getSchematicNode(schemId)).schemData(), buffer);
|
||||
}catch (EOFException e) {
|
||||
Bukkit.getLogger().log(Level.INFO, "EOFException ignored");
|
||||
} catch (IOException e) {
|
||||
@ -339,6 +347,8 @@ public interface Recorder {
|
||||
stream.writeShort((Short)o);
|
||||
else if(o instanceof Integer)
|
||||
stream.writeInt((Integer)o);
|
||||
else if(o instanceof Long)
|
||||
stream.writeLong((Long)o);
|
||||
else if(o instanceof Float)
|
||||
stream.writeFloat((Float)o);
|
||||
else if(o instanceof Double)
|
||||
|
||||
@ -33,6 +33,8 @@ import de.steamwar.fightsystem.states.OneShotStateDependent;
|
||||
import de.steamwar.fightsystem.winconditions.Wincondition;
|
||||
import de.steamwar.network.NetworkSender;
|
||||
import de.steamwar.network.packets.common.FightEndsPacket;
|
||||
import de.steamwar.sql.EventFight;
|
||||
import de.steamwar.sql.EventRelation;
|
||||
import de.steamwar.sql.SchematicNode;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import lombok.Getter;
|
||||
@ -70,12 +72,21 @@ public class FightStatistics {
|
||||
}
|
||||
|
||||
private void setEventResult() {
|
||||
if (FightSystem.getLastWinner() == null)
|
||||
if (FightSystem.getLastWinner() == null) {
|
||||
Config.EventKampf.setErgebnis(0);
|
||||
else if (FightSystem.getLastWinner().isBlue())
|
||||
} else if (FightSystem.getLastWinner().isBlue()) {
|
||||
Config.EventKampf.setErgebnis(1);
|
||||
else
|
||||
} else {
|
||||
Config.EventKampf.setErgebnis(2);
|
||||
}
|
||||
|
||||
Config.EventKampf.getDependents().forEach(EventRelation::apply);
|
||||
|
||||
Config.EventKampf.getGroup().ifPresent(group -> {
|
||||
if (group.getLastFight().map(EventFight::getFightID).orElse(-1) == Config.EventKampf.getFightID() && !group.needsTieBreak()) {
|
||||
group.getDependents().forEach(EventRelation::apply);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void disable() {
|
||||
|
||||
@ -23,6 +23,7 @@ import de.steamwar.techhider.ProtocolUtils;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
|
||||
import java.util.function.ObjIntConsumer;
|
||||
@ -77,6 +78,14 @@ public class Region {
|
||||
return ProtocolUtils.posToChunk(maxZ);
|
||||
}
|
||||
|
||||
public Location getMinLocation(World world) {
|
||||
return new Location(world, minX, minY, minZ);
|
||||
}
|
||||
|
||||
public Location getMaxLocation(World world) {
|
||||
return new Location(world, maxX, maxY, maxZ);
|
||||
}
|
||||
|
||||
public boolean chunkOutside(int cX, int cZ) {
|
||||
return getMinChunkX() > cX || cX > getMaxChunkX() ||
|
||||
getMinChunkZ() > cZ || cZ > getMaxChunkZ();
|
||||
|
||||
@ -84,6 +84,9 @@ public class WinconditionBlocks extends Wincondition implements PrintableWincond
|
||||
}
|
||||
|
||||
private void check() {
|
||||
// Edge Case for DirtBlock
|
||||
if (blocks.isEmpty()) return;
|
||||
|
||||
blocks.removeIf(block -> !isOfType.test(block));
|
||||
if(blocks.isEmpty())
|
||||
win(Fight.getOpposite(team), "WIN_TECHKO", team.getColoredName());
|
||||
|
||||
@ -78,6 +78,7 @@ public class WinconditionPercent extends Wincondition implements PrintableWincon
|
||||
|
||||
private int totalBlocks = 0;
|
||||
private int currentBlocks = 0;
|
||||
private boolean countAnyBlock = false;
|
||||
|
||||
private TeamPercent(FightTeam team, Winconditions wincondition) {
|
||||
this.team = team;
|
||||
@ -98,7 +99,7 @@ public class WinconditionPercent extends Wincondition implements PrintableWincon
|
||||
}
|
||||
|
||||
event.blockList().forEach(block -> {
|
||||
if (Config.PercentBlocks.contains(block.getType()) == Config.PercentBlocksWhitelist) {
|
||||
if (countAnyBlock || Config.PercentBlocks.contains(block.getType()) == Config.PercentBlocksWhitelist) {
|
||||
currentBlocks--;
|
||||
}
|
||||
});
|
||||
@ -108,10 +109,16 @@ public class WinconditionPercent extends Wincondition implements PrintableWincon
|
||||
|
||||
private void enable() {
|
||||
totalBlocks = 0;
|
||||
countAnyBlock = false;
|
||||
team.getSchemRegion().forEach((x, y, z) -> {
|
||||
if (Config.PercentBlocks.contains(Config.world.getBlockAt(x, y, z).getType()) == Config.PercentBlocksWhitelist)
|
||||
totalBlocks++;
|
||||
});
|
||||
// Edge Case for DirtBlock
|
||||
if (totalBlocks == 0) {
|
||||
totalBlocks = team.getSchemRegion().volume();
|
||||
countAnyBlock = true;
|
||||
}
|
||||
currentBlocks = totalBlocks;
|
||||
postEnable.accept(team);
|
||||
}
|
||||
|
||||
@ -20,6 +20,7 @@
|
||||
package de.steamwar.fightsystem.winconditions;
|
||||
|
||||
import de.steamwar.core.TrickyTrialsWrapper;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.countdown.Countdown;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
@ -30,7 +31,6 @@ import de.steamwar.fightsystem.states.StateDependentTask;
|
||||
import de.steamwar.fightsystem.utils.Message;
|
||||
import de.steamwar.fightsystem.utils.SWSound;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
@ -41,8 +41,7 @@ import java.util.Map;
|
||||
|
||||
public class WinconditionTimeTechKO extends Wincondition implements Listener {
|
||||
|
||||
private static final int TECH_KO_TIME_IN_S = 90;
|
||||
private static final int TECH_KO_HALF_TIME = TECH_KO_TIME_IN_S/2;
|
||||
private static final int TECH_KO_HALF_TIME = Config.TechKoTime/2;
|
||||
|
||||
private final Map<Integer, FightTeam> spawnLocations = new HashMap<>();
|
||||
private final Map<FightTeam, TechKOCountdown> countdowns = new HashMap<>();
|
||||
|
||||
@ -0,0 +1,115 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.fightsystem.winconditions;
|
||||
|
||||
import de.steamwar.core.TrickyTrialsWrapper;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.countdown.Countdown;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependent;
|
||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||
import de.steamwar.fightsystem.utils.Message;
|
||||
import de.steamwar.fightsystem.utils.SWSound;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class WinconditionTimedDamageTechKO extends Wincondition implements PrintableWincondition, Listener {
|
||||
|
||||
private final Map<FightTeam, TechKOCountdown> countdowns = new HashMap<>();
|
||||
|
||||
public WinconditionTimedDamageTechKO() {
|
||||
super("TechKO");
|
||||
|
||||
new StateDependentListener(Winconditions.TIMED_DAMAGE_TECH_KO, FightState.Running, this);
|
||||
new StateDependent(Winconditions.TIMED_DAMAGE_TECH_KO, FightState.Running) {
|
||||
@Override
|
||||
public void enable() {
|
||||
Fight.teams().forEach(team -> {
|
||||
TechKOCountdown countdown = new TechKOCountdown(team, Config.TechKoTime);
|
||||
countdowns.put(team, countdown);
|
||||
countdown.enable();
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable() {
|
||||
countdowns.values().forEach(Countdown::disable);
|
||||
countdowns.clear();
|
||||
}
|
||||
}.register();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Message getDisplay(FightTeam team) {
|
||||
return new Message("BAR_SECONDS", team.getPrefix() + countdowns.get(team).getTimeLeft());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onExplode(EntityExplodeEvent e) {
|
||||
if (e.getEntityType() != TrickyTrialsWrapper.impl.getTntEntityType())
|
||||
return;
|
||||
|
||||
Location location = e.getLocation();
|
||||
TechKOCountdown countdown = null;
|
||||
FightTeam fightTeam = null;
|
||||
for (FightTeam team : Fight.teams()) {
|
||||
FightTeam current = Fight.getOpposite(team);
|
||||
if (current.getExtendRegion().inRegion(location)) {
|
||||
fightTeam = current;
|
||||
countdown = countdowns.get(team);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (fightTeam == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
FightTeam finalFightTeam = fightTeam;
|
||||
TechKOCountdown finalCountdown = countdown;
|
||||
e.blockList().forEach(block -> {
|
||||
if (block.isEmpty()) return;
|
||||
if (finalFightTeam.getExtendRegion().inRegion(block)) {
|
||||
finalCountdown.disable();
|
||||
finalCountdown.enable();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private class TechKOCountdown extends Countdown {
|
||||
private final FightTeam team;
|
||||
|
||||
public TechKOCountdown(FightTeam team, int countdownTime) {
|
||||
super(countdownTime, new Message("TECHKO_COUNTDOWN", team.getColoredName()), SWSound.BLOCK_NOTE_PLING, false);
|
||||
this.team = team;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void countdownFinished() {
|
||||
win(Fight.getOpposite(team), "WIN_TECHKO", team.getColoredName());
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user