109 Commits

Author SHA1 Message Date
a2a101c4e3 Merge pull request 'Add NoGravity' (#61) from FightSystem/EnableNoGravityFights into main
All checks were successful
SteamWarCI Build successful
Reviewed-on: #61
Reviewed-by: Lixfel <lixfel@noreply.localhost>
2025-05-27 19:58:55 +02:00
277e1f9f9b Add NoGravity
All checks were successful
SteamWarCI Build successful
2025-05-27 18:15:03 +02:00
d410484e4c Update JDA to newest version
All checks were successful
SteamWarCI Build successful
2025-05-22 19:47:14 +02:00
374e314faa Add new WATUT Channel
All checks were successful
SteamWarCI Build successful
2025-05-22 18:19:31 +02:00
45a8aab321 Revert "Add "/event vote" command for SteamWarArcade Event"
All checks were successful
SteamWarCI Build successful
This reverts commit 7f215b921e.
2025-05-18 19:44:29 +02:00
0d15bbc266 Revert "Add "/event vote" command for SteamWarArcade Event"
This reverts commit a5b61fb0d6.
2025-05-18 19:44:28 +02:00
7fa97ce36c Revert "Fix TowerRun event"
This reverts commit 8cd088050d.
2025-05-18 19:44:28 +02:00
8cd088050d Fix TowerRun event
All checks were successful
SteamWarCI Build successful
2025-05-18 16:32:01 +02:00
b0bbc09113 Fix TowerRun event
All checks were successful
SteamWarCI Build successful
2025-05-18 16:28:26 +02:00
a5b61fb0d6 Add "/event vote" command for SteamWarArcade Event
All checks were successful
SteamWarCI Build successful
To be removed after event
2025-05-18 16:22:50 +02:00
297e6c9b59 Fix OOM?
All checks were successful
SteamWarCI Build successful
2025-05-18 15:58:31 +02:00
400c78447a Fix IngameListener
All checks were successful
SteamWarCI Build successful
2025-05-18 15:41:43 +02:00
778d0282d3 Fix IngameListener
All checks were successful
SteamWarCI Build successful
2025-05-18 15:37:43 +02:00
2a314e7035 Add sout
All checks were successful
SteamWarCI Build successful
2025-05-18 15:31:48 +02:00
6ed639fbb3 Add sout
All checks were successful
SteamWarCI Build successful
2025-05-18 13:46:39 +02:00
3a79f19f37 Merge remote-tracking branch 'origin/main'
All checks were successful
SteamWarCI Build successful
2025-05-18 13:34:45 +02:00
f7e81f8204 Hotfix OOM in IngameListener 2025-05-18 13:34:42 +02:00
7f215b921e Add "/event vote" command for SteamWarArcade Event
All checks were successful
SteamWarCI Build successful
To be removed after event
2025-05-18 13:32:09 +02:00
6bbe94150d Merge pull request 'Prevent usage of Flashback channels for restricted players' (#58) from flashback into main
All checks were successful
SteamWarCI Build successful
Reviewed-on: #58
Reviewed-by: Lixfel <lixfel@noreply.localhost>
2025-05-17 11:57:40 +02:00
717cfa8baf Prevent usage of Flashback channels for restricted players
All checks were successful
SteamWarCI Build successful
Added new channel handlers to block Flashback mod channels for users without appropriate permissions. Ensures restricted players using these channels are disconnected with a specific warning message. This enhances control over mod usage and maintains server integrity.
2025-05-16 18:00:23 +02:00
260656ad35 Fix for events
All checks were successful
SteamWarCI Build successful
2025-05-14 19:28:27 +02:00
e893d7934a Fix TowerRun for events
All checks were successful
SteamWarCI Build successful
2025-05-14 19:11:05 +02:00
d0665932f4 Fix TowerRunGame.reset
All checks were successful
SteamWarCI Build successful
2025-05-11 20:19:23 +02:00
d6fba9b0af Fix many simple things
All checks were successful
SteamWarCI Build successful
2025-05-11 19:02:46 +02:00
b229b0d0ae Fix many simple things
All checks were successful
SteamWarCI Build successful
2025-05-11 19:02:02 +02:00
ac00245b04 Fix lag of IngameListener
All checks were successful
SteamWarCI Build successful
2025-05-11 18:50:21 +02:00
a4eea298d2 Hotfix PrepareSchem not copying allowReplay and replaceColor while creating a prepared schem
All checks were successful
SteamWarCI Build successful
2025-05-07 14:37:00 +02:00
2c644eef26 Merge pull request 'Maybe™️ fix Techhider' (#56) from techhider-fixes into main
All checks were successful
SteamWarCI Build successful
Reviewed-on: #56
Reviewed-by: Lixfel <lixfel@noreply.localhost>
2025-05-02 14:26:18 +02:00
7f0fa09c56 Update OpenJ9 dump configuration to enable heap hprof.
All checks were successful
SteamWarCI Build successful
2025-05-02 14:14:27 +02:00
6940c32b02 Adjust OpenJ9 JVM arguments to include hprof option in dumps.
All checks were successful
SteamWarCI Build successful
2025-05-02 14:13:33 +02:00
5015aca159 Maybe™️ fix Techhider
All checks were successful
SteamWarCI Build successful
2025-05-02 10:13:47 +02:00
32c85b9bd5 Merge pull request 'Add error handling and logging to Techhider and TinyProtocol' (#55) from techhider-debug-nachrichten into main
All checks were successful
SteamWarCI Build successful
Reviewed-on: #55
Reviewed-by: Lixfel <lixfel@noreply.localhost>
2025-04-29 18:13:00 +02:00
15bb92fbba Improve error handling and logging in Techhider and TinyProtocol
All checks were successful
SteamWarCI Build successful
Refined logging messages for clarity by replacing "Techhider" with "PacketInterceptor" where appropriate. Adjusted error handling in `TechhiderbugCommand` by removing redundant `flush` calls and properly logging exceptions during bug report generation. These changes aim to enhance maintainability and debugging.
2025-04-29 18:04:58 +02:00
d6a5caf95d Add error handling and logging to Techhider and TinyProtocol
All checks were successful
SteamWarCI Build successful
2025-04-29 17:59:22 +02:00
66d18e316b Hotfix: Schematic Download geht für nicht Supervisor Player
All checks were successful
SteamWarCI Build successful
2025-04-28 16:47:43 +02:00
5cdad8c2f4 Add Dev 1.21.5
All checks were successful
SteamWarCI Build successful
2025-04-27 02:28:39 +02:00
87a7120a6a Merge remote-tracking branch 'origin/main'
All checks were successful
SteamWarCI Build successful
2025-04-26 23:57:03 +02:00
b5a9564808 Allow next next location in JumpAndRun 2025-04-26 23:56:59 +02:00
f93362a023 LobbySystem/src/de/steamwar/lobby/jumpandrun/JumpAndRun.java aktualisiert
All checks were successful
SteamWarCI Build successful
2025-04-26 23:48:33 +02:00
b1bef4ced5 Add ErrorLogging for Bugged Schematics
All checks were successful
SteamWarCI Build successful
2025-04-26 22:27:53 +02:00
e7e1e2d968 Merge remote-tracking branch 'origin/main'
All checks were successful
SteamWarCI Build successful
2025-04-26 22:17:50 +02:00
713275ba11 Add ErrorLogging for Bugged Schematics 2025-04-26 22:17:43 +02:00
e72ae3cf94 LobbySystem/src/de/steamwar/lobby/jumpandrun/JumpAndRun.java aktualisiert
All checks were successful
SteamWarCI Build successful
2025-04-26 22:13:31 +02:00
d36753dec1 Merge pull request 'Fixed meterstock' (#54) from BauSystem/fix-meterstock into main
All checks were successful
SteamWarCI Build successful
Reviewed-on: #54
Reviewed-by: YoyoNow <yoyonow@noreply.localhost>
2025-04-26 13:37:33 +02:00
D4rkr34lm
84cc292df4 Fixed meterstock
All checks were successful
SteamWarCI Build successful
2025-04-26 13:08:13 +02:00
f89c4e88f9 Fix HotbarKit
All checks were successful
SteamWarCI Build successful
Fix steamwar.devserver.gradle
Add WarGear20 to build.gradle.kts
2025-04-25 18:07:14 +02:00
a38f9222dd Merge remote-tracking branch 'origin/main'
All checks were successful
SteamWarCI Build successful
2025-04-23 20:55:30 +02:00
5ee9d3e167 Hotfix HotbarKit 2025-04-23 20:55:26 +02:00
98321de46c Merge pull request 'Replace Jukeboxes with Lodestone in panzer sklave' (#50) from BauSystem/fix-panzersklave into main
All checks were successful
SteamWarCI Build successful
Reviewed-on: #50
Reviewed-by: YoyoNow <yoyonow@noreply.localhost>
2025-04-23 19:14:53 +02:00
D4rkr34lm
239ba3f213 made more readable
All checks were successful
SteamWarCI Build successful
2025-04-23 19:14:44 +02:00
D4rkr34lm
3d7dedd3ad Fix jukeboxes in panzer sklave
All checks were successful
SteamWarCI Build successful
2025-04-23 19:13:07 +02:00
ef66b8c1f1 Fix HotbarKit.onInventoryClick not resetting the cursor item
All checks were successful
SteamWarCI Build successful
2025-04-23 18:28:58 +02:00
1201b16ee4 Merge pull request 'Improve Server starter 'steamwar.devserver.gradle'' (#41) from ImprovedServerStarter into main
All checks were successful
SteamWarCI Build successful
Reviewed-on: #41
Reviewed-by: Lixfel <lixfel@noreply.localhost>
2025-04-23 18:16:39 +02:00
4ddd88f540 Merge pull request 'Enable clicking 'Ready' in inventory' (#42) from FightSystem/HotbarKitInInv into main
All checks were successful
SteamWarCI Build successful
Reviewed-on: #42
Reviewed-by: Lixfel <lixfel@noreply.localhost>
2025-04-23 18:12:40 +02:00
147e34c0d6 Fix TNTClickListener
All checks were successful
SteamWarCI Build successful
2025-04-21 11:47:00 +02:00
ca35ab9234 Remove code Duplication HotbarKit
All checks were successful
SteamWarCI Build successful
2025-04-20 20:41:47 +02:00
3df84a7dad Update from PR
All checks were successful
SteamWarCI Build successful
2025-04-20 20:40:19 +02:00
313b22cb44 Optimize SimulatorStabGenerator
All checks were successful
SteamWarCI Build successful
2025-04-20 18:30:30 +02:00
83c20729fa Fix RAM usage on multiple usages
All checks were successful
SteamWarCI Build successful
2025-04-20 08:27:56 +02:00
925901e40e Fix steamwar.devserver.gradle 2025-04-20 08:27:56 +02:00
059dd314d1 Fix building of DevServer 2025-04-20 08:27:56 +02:00
86ff619548 Add FightServer to configure those 2025-04-20 08:27:56 +02:00
76e00b07db Add plugins option to DevServer Task 2025-04-20 08:27:56 +02:00
4edfd32ff5 Add a check if the template exists in the user.home directory 2025-04-20 08:27:56 +02:00
5669725f9b Fix dev.py path 2025-04-20 08:27:56 +02:00
335649fa87 Fix steamwar.devserver.gradle 2025-04-20 08:27:56 +02:00
9001e83321 Add steamwar.properties 'worldName' and 'host'
Remove some options
2025-04-20 08:27:56 +02:00
32703c6659 Enable Velocity, prio Setup needed for that 2025-04-20 08:27:56 +02:00
e393aad25f Add all parameters that dev.py has 2025-04-20 08:27:56 +02:00
50543ddd4e Improve Server starter 'steamwar.devserver.gradle'
See build.gradle.kts of BauSystem
2025-04-20 08:27:56 +02:00
230ac09b61 Hotfix for disabled things
All checks were successful
SteamWarCI Build successful
2025-04-20 08:12:22 +02:00
48ea88e1a7 Merge pull request 'BauSystem/SimulatorStabGenerator' (#47) from BauSystem/SimulatorStabGenerator into main
All checks were successful
SteamWarCI Build successful
Reviewed-on: #47
2025-04-19 23:21:45 +02:00
05dc42355d Update and improve SimulatorStabGenerator
All checks were successful
SteamWarCI Build successful
2025-04-19 23:04:19 +02:00
17704487c9 Add SimulatorStabGenerator 2025-04-19 17:58:40 +02:00
76bbfd0381 Merge pull request 'Add TNTClickListener.TNT_CLICK_DETAILS as a toggle' (#46) from BauSystem/TNTClickDetails into main
All checks were successful
SteamWarCI Build successful
Reviewed-on: #46
2025-04-18 21:52:29 +02:00
ae9166528d Add TNTClickListener.TNT_CLICK_DETAILS as a toggle
All checks were successful
SteamWarCI Build successful
2025-04-18 21:49:59 +02:00
119fae4b51 Merge pull request 'Add ActiveMonths to ArenaMode for rotating modes' (#45) from VelocityCore/ActiveMonthsForRotatingGameModes into main
All checks were successful
SteamWarCI Build successful
Reviewed-on: #45
2025-04-18 18:38:41 +02:00
43621b18b4 Fix TypeMappers.arenaMapTypeMapper
All checks were successful
SteamWarCI Build successful
2025-04-18 16:57:35 +02:00
e5bdbac3c7 Change isNotActive to isActive
All checks were successful
SteamWarCI Build successful
2025-04-18 16:50:16 +02:00
fd738f539a Add 3 new PluginMessage channel
All checks were successful
SteamWarCI Build successful
2025-04-18 14:17:59 +02:00
b4c7576433 Merge pull request 'TNTLeague/BiggerCoins' (#12) from TNTLeague/BiggerCoins into main
All checks were successful
SteamWarCI Build successful
Reviewed-on: #12
Reviewed-by: Chaoscaot <max@chaoscaot.de>
2025-04-18 12:36:29 +02:00
8204e2ad21 Fix MWTeam.leave not distributing items correctly
All checks were successful
SteamWarCI Build successful
2025-04-18 12:30:22 +02:00
684a74b60d Fix SmartPlaceListener not updating Comparator or Repeater
All checks were successful
SteamWarCI Build successful
2025-04-18 12:14:43 +02:00
1f58b51af6 Fix NoteBlock turning off on redstone destroy under or up to 2 blocks beside it
All checks were successful
SteamWarCI Build successful
2025-04-18 12:07:31 +02:00
c9cfb48c4e Final fix for GlobalListener
All checks were successful
SteamWarCI Build successful
2025-04-18 10:14:08 +02:00
ace567ba33 Add chat system to TowerRun
All checks were successful
SteamWarCI Build successful
2025-04-18 10:07:42 +02:00
2094120150 Remove prefix. Cannot merge them together because of 'ChatListener.sendChat'
All checks were successful
SteamWarCI Build successful
2025-04-18 09:32:35 +02:00
e143268caa Fix DiscordBot.serverTeamChat sending to discord if received from discord!
All checks were successful
SteamWarCI Build successful
2025-04-18 09:30:26 +02:00
7802fdd7d9 Add ActiveMonths to ArenaMode for rotating modes
All checks were successful
SteamWarCI Build successful
2025-04-18 09:13:23 +02:00
7fb3d3d137 Hotfix DiscordBot.ingameChat going to broadcast instead of globalChat
All checks were successful
SteamWarCI Build successful
2025-04-17 21:38:35 +02:00
61d84492dc Merge branch 'main' into TNTLeague/BiggerCoins
All checks were successful
SteamWarCI Build successful
2025-04-17 21:18:40 +02:00
f74780d395 Hotfix IngameListener
All checks were successful
SteamWarCI Build successful
2025-04-17 16:47:23 +02:00
62dac000d4 Merge pull request 'Add general Melting of Blocks' (#43) from TowerRun/GeneralMeltingOfBlocks into main
All checks were successful
SteamWarCI Build successful
Reviewed-on: #43
2025-04-17 16:32:28 +02:00
424c80ec81 Add general Melting of Blocks
All checks were successful
SteamWarCI Build successful
2025-04-17 16:09:29 +02:00
ae7d394ae2 Enable clicking 'Ready' in inventory
All checks were successful
SteamWarCI Build successful
2025-04-17 15:45:25 +02:00
306444356c Update & Fix Spelling on Chaos Messages
All checks were successful
SteamWarCI Build successful
2025-04-17 01:28:06 +02:00
29dff8dce6 Fix PunishmentCommand sending double prefix
All checks were successful
SteamWarCI Build successful
2025-04-16 21:07:05 +02:00
cbaacd4e85 Merge pull request 'Improve and fix the discord rate limit warnings' (#37) from VelocityCore/ImproveDiscordChannel into main
All checks were successful
SteamWarCI Build successful
Reviewed-on: #37
Reviewed-by: Lixfel <lixfel@noreply.localhost>
2025-04-16 20:16:52 +02:00
e24dada435 Trigger rebuild
All checks were successful
SteamWarCI Build successful
2025-04-16 18:13:58 +02:00
d04ffd5cf6 Fix some stuff for 1.21 BauSystem
Some checks failed
SteamWarCI Build failed
2025-04-16 18:12:50 +02:00
9da1de9b6c Fix MsgCommand being able to /r to offline players
All checks were successful
SteamWarCI Build successful
2025-04-16 13:42:31 +02:00
866c376ee5 Fix DevCommand not working when version switching without trying to connect in between when no server is running
All checks were successful
SteamWarCI Build successful
2025-04-16 10:20:10 +02:00
5b3c3f36b4 Fix comment
All checks were successful
SteamWarCI Build successful
2025-04-14 09:16:06 +02:00
e1bcdd59ba Move 'maxNumberOfWebhooks' constructor parameter to end of list
All checks were successful
SteamWarCI Build successful
2025-04-14 09:14:04 +02:00
4a816696ec Update the message limits
All checks were successful
SteamWarCI Build successful
2025-04-09 09:10:30 +02:00
038f54c3b3 Make it buildable and reduce complexity
All checks were successful
SteamWarCI Build successful
2025-04-09 09:03:07 +02:00
4c6ab2c1a0 Improve and fix the discord rate limit warnings
Some checks failed
SteamWarCI Build failed
2025-04-08 20:52:54 +02:00
20c90d9af5 Remove randomness
All checks were successful
SteamWarCI Build successful
2025-01-30 13:23:46 +01:00
c799046f43 Add bigger coins and remove TNT from spawning 2025-01-30 13:23:43 +01:00
76 changed files with 1689 additions and 242 deletions

View File

@@ -109,7 +109,7 @@ public class FlatteningWrapper15 implements FlatteningWrapper {
@Override
public void setSelection(Player p, Point minPoint, Point maxPoint) {
WORLDEDIT_PLUGIN.getSession(p).setRegionSelector(BUKKITWORLD, new CuboidRegionSelector(BUKKITWORLD, toBlockVector3(minPoint), toBlockVector3(maxPoint)));
WORLDEDIT_PLUGIN.getSession(p).setRegionSelector(BUKKITWORLD, new CuboidRegionSelector(BUKKITWORLD, minPoint.toBlockVector3(), maxPoint.toBlockVector3()));
}
@Override
@@ -178,9 +178,9 @@ public class FlatteningWrapper15 implements FlatteningWrapper {
pastePoint.set(v);
if (pasteBuilder.isReset()) {
e.setBlocks(new CuboidRegion(toBlockVector3(pasteBuilder.getMinPoint()), toBlockVector3(pasteBuilder.getMaxPoint())), Objects.requireNonNull(BlockTypes.AIR).getDefaultState().toBaseBlock());
e.setBlocks(new CuboidRegion(pasteBuilder.getMinPoint().toBlockVector3(), pasteBuilder.getMaxPoint().toBlockVector3()), Objects.requireNonNull(BlockTypes.AIR).getDefaultState().toBaseBlock());
if (pasteBuilder.getWaterLevel() != 0) {
e.setBlocks(new CuboidRegion(toBlockVector3(pasteBuilder.getMinPoint()), toBlockVector3(pasteBuilder.getMaxPoint()).withY(pasteBuilder.getWaterLevel())), Objects.requireNonNull(BlockTypes.WATER).getDefaultState().toBaseBlock());
e.setBlocks(new CuboidRegion(pasteBuilder.getMinPoint().toBlockVector3(), pasteBuilder.getMaxPoint().toBlockVector3().withY(pasteBuilder.getWaterLevel())), Objects.requireNonNull(BlockTypes.WATER).getDefaultState().toBaseBlock());
}
}
Operations.completeBlindly(ch.createPaste(e).to(v).ignoreAirBlocks(pasteBuilder.isIgnoreAir()).build());
@@ -193,7 +193,7 @@ public class FlatteningWrapper15 implements FlatteningWrapper {
@Override
public Clipboard copy(Point minPoint, Point maxPoint, Point copyPoint) {
BukkitWorld bukkitWorld = new BukkitWorld(Bukkit.getWorlds().get(0));
CuboidRegion region = new CuboidRegion(bukkitWorld, toBlockVector3(minPoint), toBlockVector3(maxPoint));
CuboidRegion region = new CuboidRegion(bukkitWorld, minPoint.toBlockVector3(), maxPoint.toBlockVector3());
BlockArrayClipboard clipboard = new BlockArrayClipboard(region);
try (EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(bukkitWorld, -1)) {
ForwardExtentCopy copy = new ForwardExtentCopy(
@@ -204,7 +204,7 @@ public class FlatteningWrapper15 implements FlatteningWrapper {
copy.setCopyingBiomes(false);
Operations.complete(copy);
clipboard.setOrigin(toBlockVector3(copyPoint));
clipboard.setOrigin(copyPoint.toBlockVector3());
return clipboard;
} catch (WorldEditException e) {
Bukkit.getLogger().log(Level.SEVERE, e.getMessage(), e);
@@ -224,10 +224,6 @@ public class FlatteningWrapper15 implements FlatteningWrapper {
}
}
private BlockVector3 toBlockVector3(Point point) {
return BlockVector3.at(point.getX(), point.getY(), point.getZ());
}
@Override
public boolean inWater(org.bukkit.World world, Vector tntPosition) {
Block block = world.getBlockAt(tntPosition.getBlockX(), tntPosition.getBlockY(), tntPosition.getBlockZ());

View File

@@ -947,6 +947,9 @@ SPEED_TAB_NAME=Input speed
WORLDEDIT_WAND=WorldEdit Wand
WORLDEDIT_LEFTCLICK=Left click: select pos #1
WORLDEDIT_RIGHTCLICK=Right click: select pos #2
TNT_DETAILS_COMMAND=§8/§etntdetails §8-§7 Toggle information printed after clicking on a TNT
TNT_DETAILS_ON = §eTNTDetails §aactivated
TNT_DETAILS_OFF = §eTNTDetails §cdeactivated
TNT_CLICK_HEADER=§8---=== §eTNT §8===---
TNT_CLICK_ORDER=§eEntity Order§8: §e{0}
TNT_CLICK_FUSE_TIME=§eFuseTime§8: §e{0}

View File

@@ -889,6 +889,9 @@ SPEED_TAB_NAME=Geschwindigkeit eingeben
WORLDEDIT_WAND=WorldEdit Wand
WORLDEDIT_LEFTCLICK=Left click: select pos #1
WORLDEDIT_RIGHTCLICK=Right click: select pos #2
TNT_DETAILS_COMMAND=§8/§etntdetails §8-§7 Aktiviert/Deaktiviert das senden von Details beim Klick auf TNT
TNT_DETAILS_ON = §eTNTDetails §aaktiviert
TNT_DETAILS_OFF = §eTNTDetails §cdeaktiviert
TNT_CLICK_HEADER=§8---=== §eTNT §8===---
TNT_CLICK_ORDER=§eEntity Order§8: §e{0}
TNT_CLICK_FUSE_TIME=§eFuseTime§8: §e{0}

View File

@@ -11,8 +11,9 @@ import de.steamwar.linkage.Linked;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.block.data.type.NoteBlock;
import org.bukkit.block.data.type.Switch;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
@@ -60,6 +61,24 @@ public class FreezeListener implements Listener, ScoreboardElement {
@EventHandler
public void onPhysicsEvent(BlockPhysicsEvent e) {
if (Region.getRegion(e.getBlock().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) {
if (e.getSourceBlock().getType() == Material.NOTE_BLOCK) {
BlockState state = e.getSourceBlock().getState();
NoteBlock noteBlock = (NoteBlock) state.getBlockData();
if (noteBlock.isPowered()) {
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
state.update(true, false);
}, 1);
}
}
if (e.getBlock().getType() == Material.NOTE_BLOCK) {
BlockState state = e.getBlock().getState();
NoteBlock noteBlock = (NoteBlock) state.getBlockData();
if (noteBlock.isPowered()) {
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
state.update(true, false);
}, 1);
}
}
e.setCancelled(true);
}
}
@@ -71,6 +90,105 @@ public class FreezeListener implements Listener, ScoreboardElement {
}
}
@EventHandler
public void onNotePlay(NotePlayEvent event) {
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=45, z=98},type=CYAN_TERRACOTTA,data=Block{minecraft:cyan_terracotta},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-107, y=45, z=98},type=SMOOTH_STONE,data=Block{minecraft:smooth_stone},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=45, z=98},type=CYAN_TERRACOTTA,data=Block{minecraft:cyan_terracotta},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-105, y=45, z=98},type=CYAN_TERRACOTTA,data=Block{minecraft:cyan_terracotta},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=45, z=98},type=CYAN_TERRACOTTA,data=Block{minecraft:cyan_terracotta},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=44, z=98},type=CYAN_TERRACOTTA,data=Block{minecraft:cyan_terracotta},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=45, z=98},type=CYAN_TERRACOTTA,data=Block{minecraft:cyan_terracotta},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=46, z=98},type=BARRIER,data=Block{minecraft:barrier},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=45, z=98},type=CYAN_TERRACOTTA,data=Block{minecraft:cyan_terracotta},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=45, z=97},type=CYAN_TERRACOTTA,data=Block{minecraft:cyan_terracotta},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=45, z=98},type=CYAN_TERRACOTTA,data=Block{minecraft:cyan_terracotta},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=45, z=99},type=SMOOTH_STONE,data=Block{minecraft:smooth_stone},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=custom_head,note=9,powered=true],fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-107, y=47, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=custom_head,note=9,powered=true],fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-105, y=47, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=custom_head,note=9,powered=true],fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=46, z=98},type=BARRIER,data=Block{minecraft:barrier},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=custom_head,note=9,powered=true],fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=48, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=custom_head,note=9,powered=true],fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=47, z=97},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=custom_head,note=9,powered=true],fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=47, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=46, z=97},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-107, y=46, z=97},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=46, z=97},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-105, y=46, z=97},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=46, z=97},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=45, z=97},type=CYAN_TERRACOTTA,data=Block{minecraft:cyan_terracotta},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=46, z=97},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=47, z=97},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=46, z=97},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=46, z=96},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=46, z=97},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=46, z=98},type=BARRIER,data=Block{minecraft:barrier},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=46, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-107, y=46, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=46, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-105, y=46, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=46, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=45, z=99},type=SMOOTH_STONE,data=Block{minecraft:smooth_stone},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=46, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=47, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=46, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=46, z=98},type=BARRIER,data=Block{minecraft:barrier},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=46, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=46, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
//[STDOUT] CraftBlock{pos=BlockPosition{x=-107, y=46, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-108, y=46, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
//[STDOUT] CraftBlock{pos=BlockPosition{x=-107, y=46, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=46, z=98},type=BARRIER,data=Block{minecraft:barrier},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
//[STDOUT] CraftBlock{pos=BlockPosition{x=-107, y=46, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-107, y=45, z=98},type=SMOOTH_STONE,data=Block{minecraft:smooth_stone},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
//[STDOUT] CraftBlock{pos=BlockPosition{x=-107, y=46, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-107, y=47, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
//[STDOUT] CraftBlock{pos=BlockPosition{x=-107, y=46, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-107, y=46, z=97},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
//[STDOUT] CraftBlock{pos=BlockPosition{x=-107, y=46, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-107, y=46, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
//[STDOUT] CraftBlock{pos=BlockPosition{x=-105, y=46, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=46, z=98},type=BARRIER,data=Block{minecraft:barrier},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
//[STDOUT] CraftBlock{pos=BlockPosition{x=-105, y=46, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-104, y=46, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
//[STDOUT] CraftBlock{pos=BlockPosition{x=-105, y=46, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-105, y=45, z=98},type=CYAN_TERRACOTTA,data=Block{minecraft:cyan_terracotta},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
//[STDOUT] CraftBlock{pos=BlockPosition{x=-105, y=46, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-105, y=47, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
//[STDOUT] CraftBlock{pos=BlockPosition{x=-105, y=46, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-105, y=46, z=97},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
//[STDOUT] CraftBlock{pos=BlockPosition{x=-105, y=46, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-105, y=46, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=harp,note=9,powered=true],fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=harp,note=9,powered=true],fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=harp,note=9,powered=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-107, y=47, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=harp,note=9,powered=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-105, y=47, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=harp,note=9,powered=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=46, z=98},type=BARRIER,data=Block{minecraft:barrier},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=harp,note=9,powered=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=48, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=harp,note=9,powered=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=47, z=97},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=harp,note=9,powered=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=47, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=harp,note=9,powered=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=harp,note=9,powered=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=46, z=100},type=SMOOTH_STONE,data=Block{minecraft:smooth_stone},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-107, y=46, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=46, z=100},type=SMOOTH_STONE,data=Block{minecraft:smooth_stone},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-105, y=46, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=46, z=100},type=SMOOTH_STONE,data=Block{minecraft:smooth_stone},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=45, z=100},type=SMOOTH_STONE,data=Block{minecraft:smooth_stone},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=46, z=100},type=SMOOTH_STONE,data=Block{minecraft:smooth_stone},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=47, z=100},type=STONE_SLAB,data=Block{minecraft:stone_slab}[type=bottom,waterlogged=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=46, z=100},type=SMOOTH_STONE,data=Block{minecraft:smooth_stone},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=46, z=99},type=SMOOTH_STONE,data=Block{minecraft:smooth_stone},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=46, z=100},type=SMOOTH_STONE,data=Block{minecraft:smooth_stone},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=46, z=101},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=48, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-107, y=48, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=48, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-105, y=48, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=48, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=47, z=100},type=STONE_SLAB,data=Block{minecraft:stone_slab}[type=bottom,waterlogged=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=48, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=49, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=48, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=48, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=48, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=48, z=101},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-107, y=47, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-105, y=47, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=46, z=99},type=SMOOTH_STONE,data=Block{minecraft:smooth_stone},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=48, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
////[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=basedrum,note=9,powered=true],fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=47, z=100},type=STONE_SLAB,data=Block{minecraft:stone_slab}[type=bottom,waterlogged=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=101},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-107, y=47, z=101},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=101},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-105, y=47, z=101},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=101},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=46, z=101},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=101},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=48, z=101},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=101},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=47, z=100},type=STONE_SLAB,data=Block{minecraft:stone_slab}[type=bottom,waterlogged=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=101},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=47, z=102},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
//[STDOUT] CraftBlock{pos=BlockPosition{x=-107, y=47, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-108, y=47, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
//[STDOUT] CraftBlock{pos=BlockPosition{x=-107, y=47, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=47, z=100},type=STONE_SLAB,data=Block{minecraft:stone_slab}[type=bottom,waterlogged=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
//[STDOUT] CraftBlock{pos=BlockPosition{x=-107, y=47, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-107, y=46, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
//[STDOUT] CraftBlock{pos=BlockPosition{x=-107, y=47, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-107, y=48, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
//[STDOUT] CraftBlock{pos=BlockPosition{x=-107, y=47, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-107, y=47, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
//[STDOUT] CraftBlock{pos=BlockPosition{x=-107, y=47, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-107, y=47, z=101},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
//[STDOUT] CraftBlock{pos=BlockPosition{x=-105, y=47, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=47, z=100},type=STONE_SLAB,data=Block{minecraft:stone_slab}[type=bottom,waterlogged=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
//[STDOUT] CraftBlock{pos=BlockPosition{x=-105, y=47, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-104, y=47, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
//[STDOUT] CraftBlock{pos=BlockPosition{x=-105, y=47, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-105, y=46, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
//[STDOUT] CraftBlock{pos=BlockPosition{x=-105, y=47, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-105, y=48, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
//[STDOUT] CraftBlock{pos=BlockPosition{x=-105, y=47, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-105, y=47, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
//[STDOUT] CraftBlock{pos=BlockPosition{x=-105, y=47, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-105, y=47, z=101},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=basedrum,note=9,powered=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-107, y=47, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=basedrum,note=9,powered=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-105, y=47, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=basedrum,note=9,powered=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=46, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=basedrum,note=9,powered=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=48, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=basedrum,note=9,powered=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=47, z=97},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=basedrum,note=9,powered=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=47, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=basedrum,note=9,powered=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=basedrum,note=9,powered=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
}
@EventHandler
public void onPistonRetract(BlockPistonRetractEvent e) {
if (Region.getRegion(e.getBlock().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) {
@@ -108,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;

View File

@@ -51,7 +51,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(TPSSystem::getCurrentTPSLimit));
return tpsLib;
}
}

View File

@@ -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(simulator, () -> {});
}
@Register(value = "rename", description = "SIMULATOR_RENAME_HELP")

View File

@@ -168,9 +168,19 @@ public class SimulatorCursor implements Listener {
}
return;
}
Simulator simulator = SimulatorStorage.getSimulator(player);
SimulatorWatcher.show(simulator, player);
Simulator simulator = SimulatorStorage.getSimulator(player);
if (simulator != null && simulator.getStabGenerator() != null) {
removeCursor(player);
SimulatorWatcher.show(null, player);
SWUtils.sendToActionbar(player, "§cGenerating Stab");
synchronized (calculating) {
calculating.remove(player);
}
return;
}
SimulatorWatcher.show(simulator, player);
List<REntity> entities = SimulatorWatcher.getEntitiesOfSimulator(simulator);
RayTraceUtils.RRayTraceResult rayTraceResult = RayTraceUtils.traceREntity(player, player.getLocation(), entities);
if (rayTraceResult == null) {
@@ -357,7 +367,7 @@ public class SimulatorCursor implements Listener {
if (simulator == null) {
return;
}
SimulatorExecutor.run(simulator);
SimulatorExecutor.run(simulator, () -> {});
return;
}

View File

@@ -20,6 +20,7 @@
package de.steamwar.bausystem.features.simulator.data;
import de.steamwar.bausystem.features.simulator.execute.SimulatorAction;
import de.steamwar.bausystem.features.simulator.execute.SimulatorStabGenerator;
import de.steamwar.inventory.InvCallback;
import de.steamwar.inventory.SWItem;
import lombok.Getter;
@@ -30,13 +31,13 @@ import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.function.BiConsumer;
@Getter
@Setter
@RequiredArgsConstructor
public final class Simulator {
private SimulatorStabGenerator stabGenerator = null;
private Material material = Material.BARREL;
private final String name;
private boolean autoTrace = false;

View File

@@ -60,6 +60,7 @@ public final class TNTPhase extends SimulatorPhase {
@Override
public void toSimulatorActions(Vector position, BiConsumer<Integer, SimulatorAction> tickStart, BiConsumer<Integer, SimulatorAction> tickEnd) {
if (count <= 0) return;
tickStart.accept(tickOffset, new SimulatorAction(order, count) {
@Override
public void accept(World world) {

View File

@@ -0,0 +1,34 @@
/*
* 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.features.simulator.execute;
import lombok.AllArgsConstructor;
import org.bukkit.util.Vector;
import java.util.function.Function;
@AllArgsConstructor
public enum Direction {
X(Vector::getBlockX),
Y(Vector::getBlockY),
Z(Vector::getBlockZ);
public final Function<Vector, Integer> component;
}

View File

@@ -46,7 +46,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) {
public static boolean run(Simulator simulator, Runnable onEnd) {
if (currentlyRunning.contains(simulator)) return false;
currentlyRunning.add(simulator);
@@ -69,7 +69,7 @@ public class SimulatorExecutor implements Listener {
public void accept(World world) {
currentlyRunning.remove(simulator);
if (simulator.isAutoTrace()) {
if (simulator.isAutoTrace() && onEnd == null) {
simulator.getGroups()
.stream()
.map(SimulatorGroup::getElements)
@@ -82,10 +82,12 @@ public class SimulatorExecutor implements Listener {
TraceRecorder.instance.stopRecording(region);
});
}
onEnd.run();
}
});
if (simulator.isAutoTrace()) {
if (simulator.isAutoTrace() && onEnd == null) {
simulator.getGroups()
.stream()
.map(SimulatorGroup::getElements)

View File

@@ -0,0 +1,45 @@
/*
* 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.features.simulator.execute;
import de.steamwar.bausystem.features.simulator.data.Simulator;
import de.steamwar.bausystem.features.simulator.data.tnt.TNTElement;
import de.steamwar.bausystem.region.Region;
import de.steamwar.bausystem.utils.bossbar.BossBarService;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
public class SimulatorStabGenerator {
private final StabData stabData;
public SimulatorStabGenerator(Region region, Simulator simulator, TNTElement tntElement, int depthLimit) {
stabData = new StabData(region, simulator, tntElement, tntElement.getPhases(), depthLimit);
new StabSetup(stabData);
}
public void cancel() {
stabData.cancel = true;
stabData.simulator.setStabGenerator(null);
for (Player player : Bukkit.getOnlinePlayers()) {
BossBarService.instance.remove(player, stabData.region, "simulator_stab_generator");
}
}
}

View File

@@ -0,0 +1,52 @@
/*
* 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.features.simulator.execute;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
import de.steamwar.bausystem.features.simulator.data.Simulator;
import de.steamwar.bausystem.features.simulator.data.tnt.TNTElement;
import de.steamwar.bausystem.features.simulator.data.tnt.TNTPhase;
import de.steamwar.bausystem.region.Region;
import lombok.RequiredArgsConstructor;
import java.util.List;
import java.util.logging.Level;
@RequiredArgsConstructor
public class StabData {
protected static final int MAX_RECORDINGS = 5;
protected static final int MAX_TICK_DIFFERENCE = 3;
protected static final Level LEVEL = Level.INFO;
protected static final int TNT_INCREASE = 10;
protected static final int MIN_BLOCK_TO_COUNT_AS_DEPTH = 20;
protected final Region region;
protected final Simulator simulator;
protected final TNTElement tntElement;
protected final List<TNTPhase> phases;
protected final int depthLimit;
protected Clipboard clipboard;
protected boolean cancel = false;
protected Direction direction = null;
protected int currentDepth = 0;
}

View File

@@ -0,0 +1,103 @@
/*
* 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.features.simulator.execute;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.bukkit.BukkitWorld;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.world.block.BlockTypes;
import de.steamwar.bausystem.features.simulator.data.SimulatorPhase;
import de.steamwar.bausystem.features.tracer.TNTPoint;
import de.steamwar.bausystem.features.tracer.Trace;
import de.steamwar.bausystem.features.tracer.TraceManager;
import de.steamwar.bausystem.features.tracer.TraceRecorder;
import de.steamwar.bausystem.utils.bossbar.BauSystemBossbar;
import org.bukkit.Bukkit;
import org.bukkit.util.Vector;
import java.util.List;
import java.util.Objects;
public class StabDirection extends StabStep {
public StabDirection(StabData data) {
super(data);
}
@Override
protected void start() {
try (EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(new BukkitWorld(Bukkit.getWorlds().get(0)), -1)) {
e.setBlocks((com.sk89q.worldedit.regions.Region) new CuboidRegion(data.region.getMinPointTestblockExtension().toBlockVector3(), data.region.getMaxPointTestblockExtension().toBlockVector3()), Objects.requireNonNull(BlockTypes.AIR).getDefaultState().toBaseBlock());
}
Trace trace = TraceRecorder.instance.startRecording(data.region);
runSimulator(() -> {
TraceRecorder.instance.stopRecording(data.region);
calculateDirection(trace);
});
}
private void calculateDirection(Trace trace) {
long tickSinceStart = -1;
List<TNTPoint> points = null;
for (List<TNTPoint> current : trace.getHistories()) {
long ticks = current.get(0).getTicksSinceStart();
if (points == null || ticks > tickSinceStart) {
tickSinceStart = ticks;
points = current;
} else if (ticks == tickSinceStart && points.get(0).getTntId() < current.get(0).getTntId()) {
points = current;
}
}
TraceManager.instance.remove(trace);
if (points == null) {
stop();
return;
}
TNTPoint current = points.getLast();
Vector velocity = current.getVelocity();
if (velocity.getX() < 0) velocity.setX(-velocity.getX());
if (velocity.getY() < 0) velocity.setY(-velocity.getY());
if (velocity.getZ() < 0) velocity.setZ(-velocity.getZ());
if (velocity.getX() > velocity.getY() && velocity.getX() > velocity.getZ()) {
data.direction = Direction.X;
} else if (velocity.getY() > velocity.getX() && velocity.getY() > velocity.getZ()) {
data.direction = Direction.Y;
} else if (velocity.getZ() > velocity.getX() && velocity.getZ() > velocity.getY()) {
data.direction = Direction.Z;
} else {
stop();
return;
}
Bukkit.getLogger().log(StabData.LEVEL, "Direction: {0}", data.direction);
data.phases.getFirst().setOrder(SimulatorPhase.ORDER_LIMIT);
data.phases.getFirst().setCount(StabData.TNT_INCREASE);
new StabGenerator(data);
}
@Override
protected void bossbar(BauSystemBossbar bossbar, boolean finished) {
bossbar.setProgress(0);
bossbar.setTitle("§eCalculating Stab Direction");
}
}

View File

@@ -0,0 +1,61 @@
/*
* 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.features.simulator.execute;
import de.steamwar.bausystem.features.tracer.Trace;
import de.steamwar.bausystem.features.tracer.TraceRecorder;
import de.steamwar.bausystem.region.flags.Flag;
import de.steamwar.bausystem.region.flags.flagvalues.ColorMode;
import de.steamwar.bausystem.region.utils.RegionExtensionType;
import de.steamwar.bausystem.region.utils.RegionType;
import de.steamwar.bausystem.utils.PasteBuilder;
import de.steamwar.bausystem.utils.bossbar.BauSystemBossbar;
public class StabFinalizer extends StabStep {
public StabFinalizer(StabData data) {
super(data);
}
@Override
protected void start() {
try {
PasteBuilder.ClipboardProvider clipboardProvider = new PasteBuilder.ClipboardProviderImpl(data.clipboard);
PasteBuilder pasteBuilder = new PasteBuilder(clipboardProvider)
.color(data.region.getPlain(Flag.COLOR, ColorMode.class).getColor());
data.region.reset(pasteBuilder, RegionType.TESTBLOCK, RegionExtensionType.EXTENSION);
} catch (SecurityException e) {
stop();
throw e;
}
TraceRecorder.instance.startRecording(data.region);
runSimulator(() -> {
TraceRecorder.instance.stopRecording(data.region);
stop();
});
}
@Override
protected void bossbar(BauSystemBossbar bossbar, boolean stopped) {
bossbar.setProgress(Math.min(data.currentDepth / (double) data.depthLimit, 1.0));
bossbar.setTitle("§e" + data.currentDepth + "§8/§7" + data.depthLimit);
}
}

View File

@@ -0,0 +1,250 @@
/*
* 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.features.simulator.execute;
import de.steamwar.bausystem.features.simulator.data.tnt.TNTPhase;
import de.steamwar.bausystem.region.Region;
import de.steamwar.bausystem.region.flags.Flag;
import de.steamwar.bausystem.region.flags.flagvalues.ColorMode;
import de.steamwar.bausystem.region.utils.RegionExtensionType;
import de.steamwar.bausystem.region.utils.RegionType;
import de.steamwar.bausystem.utils.PasteBuilder;
import de.steamwar.bausystem.utils.bossbar.BauSystemBossbar;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.event.EventHandler;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityExplodeEvent;
import java.util.*;
import java.util.stream.Collectors;
import static de.steamwar.bausystem.features.simulator.execute.Direction.Y;
public class StabGenerator extends StabStep implements Listener {
private int recordings = 0;
private List<Integer> currentDepths = new ArrayList<>();
private int lastDepth = 0;
private int retries = 0;
private final Map<Integer, Set<Location>> destroyedBlocksPerSlice = new HashMap<>();
private Set<Integer> gabStart = new HashSet<>();
private Set<TNTPhase> failedAtLeastOnce = new HashSet<>();
@EventHandler
public void onEntityExplode(EntityExplodeEvent event) {
if (Region.getRegion(event.getEntity().getLocation()) == data.region) {
event.blockList().forEach(block -> {
if (!data.region.inRegion(block.getLocation(), RegionType.TESTBLOCK, RegionExtensionType.EXTENSION)) return;
int component = data.direction.component.apply(block.getLocation().toVector());
destroyedBlocksPerSlice.computeIfAbsent(component, __ -> new HashSet<>())
.add(block.getLocation());
});
}
}
public StabGenerator(StabData data) {
super(data);
}
@Override
protected void start() {
try {
PasteBuilder.ClipboardProvider clipboardProvider = new PasteBuilder.ClipboardProviderImpl(data.clipboard);
PasteBuilder pasteBuilder = new PasteBuilder(clipboardProvider)
.color(data.region.getPlain(Flag.COLOR, ColorMode.class).getColor());
data.region.reset(pasteBuilder, RegionType.TESTBLOCK, RegionExtensionType.EXTENSION);
} catch (SecurityException e) {
stop();
throw e;
}
if (data.cancel) {
HandlerList.unregisterAll(this);
return;
}
runSimulator(this::calculateStab);
}
private void calculateStab() {
TNTPhase lastPhase = data.phases.getLast();
List<Map.Entry<Integer, Set<Location>>> locations = destroyedBlocksPerSlice.entrySet()
.stream()
.sorted(Comparator.comparingInt(Map.Entry::getKey))
.collect(Collectors.toList());
int depth = 0;
for (int i = 0; i < locations.size(); i++) {
if (data.direction != Y && i > 0 && Math.abs(locations.get(i - 1).getKey() - locations.get(i).getKey()) > 3) {
if (gabStart.add(locations.get(i).getKey())) {
Bukkit.getLogger().log(StabData.LEVEL, "Increasing tnt count by {0} because of gap", StabData.TNT_INCREASE);
lastPhase.setCount(lastPhase.getCount() + StabData.TNT_INCREASE);
recordings = 0;
currentDepths.clear();
run();
return;
}
}
if (i == 0 || i == locations.size() - 1) {
if (locations.get(i).getValue().size() > StabData.MIN_BLOCK_TO_COUNT_AS_DEPTH) {
depth++;
}
} else {
depth++;
}
}
if (depth > 0) {
Bukkit.getLogger().log(StabData.LEVEL, "{0} {1} {2}", new Object[]{depth, destroyedBlocksPerSlice.size(), destroyedBlocksPerSlice.values().stream().map(Set::size).collect(Collectors.toList())});
destroyedBlocksPerSlice.clear();
currentDepths.add(depth);
} else {
destroyedBlocksPerSlice.clear();
lastPhase.setTickOffset(lastPhase.getTickOffset() + 1);
Bukkit.getLogger().log(StabData.LEVEL, "No dimension - Increasing tickOffset to: {0}", lastPhase.getTickOffset());
lastPhase.setOrder(0);
if (lastPhase.getTickOffset() > 80) {
stop();
} else {
run();
}
return;
}
int minDepth = currentDepths.stream().min(Integer::compareTo).orElse(0);
int maxDepth = currentDepths.stream().max(Integer::compareTo).orElse(0);
data.currentDepth = maxDepth;
int countWithoutLast = 0;
for (int i = 0; i < data.phases.size() - 1; i++) {
countWithoutLast += data.phases.get(i).getCount();
}
countWithoutLast -= gabStart.size();
boolean moreTNTNeeded = maxDepth - countWithoutLast >= lastPhase.getCount() - 5;
if (moreTNTNeeded) {
Bukkit.getLogger().log(StabData.LEVEL, "Increasing tnt count by {0}", StabData.TNT_INCREASE);
lastPhase.setCount(lastPhase.getCount() + StabData.TNT_INCREASE);
recordings = 0;
currentDepths.clear();
run();
return;
}
if (recordings++ < StabData.MAX_RECORDINGS) {
run();
return;
}
recordings = 0;
currentDepths.clear();
if (maxDepth - minDepth > lastPhase.getCount()) {
Bukkit.getLogger().log(StabData.LEVEL, "Stab failed at least once. Adding one tnt to {0}", minDepth - 3);
int current = 0;
TNTPhase last = null;
for (TNTPhase phase : data.phases) {
if (current < minDepth - 3) {
current += phase.getCount();
last = phase;
continue;
}
if (failedAtLeastOnce.add(last)) {
last = null;
break;
}
if (last != null) {
last.setCount(last.getCount() + 1);
Bukkit.getLogger().log(StabData.LEVEL, "Added to phase {0} now has {1} tnt", new Object[]{data.phases.indexOf(last), last.getCount()});
}
break;
}
if (last != null) {
run();
return;
}
}
Bukkit.getLogger().log(StabData.LEVEL, "No more TNT needed on phase adjusting - {0} new count; {1} current count", new Object[]{maxDepth - countWithoutLast, lastPhase.getCount()});
lastPhase.setCount(maxDepth - countWithoutLast);
if (lastPhase.getCount() <= 0) {
Bukkit.getLogger().log(StabData.LEVEL, "Count was 0 or negative - removing last phase");
data.phases.removeLast();
}
if (maxDepth > data.depthLimit) {
Bukkit.getLogger().log(StabData.LEVEL, "Depth is greater than {0} - finished", data.depthLimit);
new StabFinalizer(data);
return;
}
if (maxDepth <= lastDepth) {
if (lastPhase.getCount() <= 0) {
retries++;
}
if (lastPhase.getCount() > 0 || retries > StabData.MAX_TICK_DIFFERENCE) {
Bukkit.getLogger().log(StabData.LEVEL, "Depth is equal to last depth recorded {0} - finished", maxDepth);
new StabFinalizer(data);
return;
}
}
lastDepth = maxDepth;
newPhase(data, lastPhase);
run();
}
public static void newPhase(StabData data, TNTPhase lastPhase) {
Bukkit.getLogger().log(StabData.LEVEL, "Adding new phase in next tick");
TNTPhase nextPhase = new TNTPhase();
nextPhase.setCount(StabData.TNT_INCREASE);
nextPhase.setTickOffset(lastPhase.getTickOffset() + 1);
nextPhase.setXJump(lastPhase.isXJump());
nextPhase.setYJump(lastPhase.isYJump());
nextPhase.setZJump(lastPhase.isZJump());
data.phases.add(nextPhase);
}
@Override
protected void bossbar(BauSystemBossbar bossbar, boolean finished) {
bossbar.setProgress(Math.min(data.currentDepth / (double) data.depthLimit, 1.0));
if (finished) {
bossbar.setTitle("§e" + data.currentDepth + "§8/§7" + data.depthLimit);
return;
}
StringBuilder st = new StringBuilder();
st.append("§7Direction §e").append(data.direction);
st.append(" §e").append(data.currentDepth).append("§8/§7").append(data.depthLimit);
if (recordings > 0) {
st.append(" §7Retries§8:§e ").append(recordings).append("§8/§7").append(StabData.MAX_RECORDINGS);
}
bossbar.setTitle(st.toString());
}
}

View File

@@ -0,0 +1,85 @@
/*
* 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.features.simulator.execute;
import de.steamwar.bausystem.features.simulator.data.SimulatorGroup;
import de.steamwar.bausystem.features.simulator.data.tnt.TNTElement;
import de.steamwar.bausystem.features.simulator.data.tnt.TNTPhase;
import de.steamwar.bausystem.features.tracer.TraceRecorder;
import de.steamwar.bausystem.utils.FlatteningWrapper;
import de.steamwar.bausystem.utils.bossbar.BauSystemBossbar;
import java.util.Comparator;
import java.util.List;
import java.util.Optional;
public class StabSetup extends StabStep {
public StabSetup(StabData data) {
super(data);
}
@Override
protected void start() {
TNTPhase tntPhase = data.simulator.getGroups().stream()
.filter(simulatorGroup -> !simulatorGroup.isDisabled())
.map(SimulatorGroup::getElements)
.flatMap(List::stream)
.filter(TNTElement.class::isInstance)
.map(TNTElement.class::cast)
.filter(tntElement -> !tntElement.isDisabled())
.filter(tntElement -> data.tntElement != tntElement)
.map(tntElement -> tntElement.getPhases().stream().max(Comparator.comparingInt(TNTPhase::getTickOffset)))
.filter(Optional::isPresent)
.map(Optional::get)
.peek(phase -> {
if (phase.getOrder() > TNTPhase.ORDER_LIMIT) {
phase.setOrder(TNTPhase.ORDER_LIMIT);
}
})
.filter(phase -> phase != data.phases.get(0))
.max(Comparator.comparingInt(TNTPhase::getTickOffset))
.orElse(null);
if (tntPhase == null) {
throw new SecurityException("");
}
TNTPhase phase = data.phases.get(0);
data.phases.clear();
data.phases.add(phase);
phase.setCount(1);
phase.setTickOffset(tntPhase.getTickOffset());
phase.setOrder(100);
TraceRecorder.instance.stopRecording(data.region);
if (TraceRecorder.instance.isAutoTraceEnabledInRegion(data.region)) {
TraceRecorder.instance.removeAutoTraceRegion(data.region);
}
data.clipboard = FlatteningWrapper.impl.copy(data.region.getMinPointTestblockExtension(), data.region.getMaxPointTestblockExtension(), data.region.getTestBlockPoint());
new StabDirection(data);
}
@Override
protected void bossbar(BauSystemBossbar bossbar, boolean finished) {
bossbar.setProgress(0);
bossbar.setTitle("§eSetting up Simulator");
}
}

View File

@@ -0,0 +1,95 @@
/*
* 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.features.simulator.execute;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.features.simulator.SimulatorWatcher;
import de.steamwar.bausystem.utils.bossbar.BauSystemBossbar;
import de.steamwar.bausystem.utils.bossbar.BossBarService;
import org.bukkit.Bukkit;
import org.bukkit.boss.BarColor;
import org.bukkit.boss.BarStyle;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
public abstract class StabStep {
protected final StabData data;
protected StabStep(StabData data) {
this.data = data;
run();
}
protected final void run() {
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
for (Player player : Bukkit.getOnlinePlayers()) {
BauSystemBossbar bossbar = BossBarService.instance.get(player, data.region, "simulator_stab_generator");
bossbar.setColor(BarColor.GREEN);
bossbar.setStyle(BarStyle.SEGMENTED_10);
bossbar(bossbar, false);
}
}, 1);
if (this instanceof Listener) {
Bukkit.getPluginManager().registerEvents((Listener) this, BauSystem.getInstance());
}
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), this::start, 20);
}
protected abstract void start();
protected final void runSimulator(Runnable onFinish) {
SimulatorExecutor.run(data.simulator, () -> {
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
if (this instanceof Listener) {
HandlerList.unregisterAll((Listener) this);
}
onFinish.run();
}, 20);
});
}
protected abstract void bossbar(BauSystemBossbar bossbar, boolean stopped);
protected final void stop() {
data.simulator.setStabGenerator(null);
SimulatorWatcher.update(data.simulator);
for (Player player : Bukkit.getOnlinePlayers()) {
BauSystemBossbar bossbar = BossBarService.instance.get(player, data.region, "simulator_stab_generator");
bossbar.setColor(BarColor.GREEN);
bossbar.setStyle(BarStyle.SEGMENTED_10);
bossbar(bossbar, true);
}
new Thread(() -> {
try {
Thread.sleep(4000);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
} finally {
for (Player player : Bukkit.getOnlinePlayers()) {
BossBarService.instance.remove(player, data.region, "simulator_stab_generator");
}
}
}).start();
}
}

View File

@@ -24,8 +24,11 @@ import de.steamwar.bausystem.features.simulator.data.Simulator;
import de.steamwar.bausystem.features.simulator.data.SimulatorGroup;
import de.steamwar.bausystem.features.simulator.data.tnt.TNTElement;
import de.steamwar.bausystem.features.simulator.data.tnt.TNTPhase;
import de.steamwar.bausystem.features.simulator.execute.SimulatorStabGenerator;
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.inventory.SWItem;
import org.bukkit.Material;
import org.bukkit.entity.Player;
@@ -97,6 +100,14 @@ public class SimulatorTNTGui extends SimulatorScrollGui<TNTPhase> {
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();
}));
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());

View File

@@ -44,7 +44,7 @@ public class SimulatorAnvilGui<T extends Number> {
if (error.get()) {
anvilInv.open();
} else {
back.open();
if (back != null) back.open();
}
error.set(false);
}, 0);

View File

@@ -22,7 +22,6 @@ package de.steamwar.bausystem.features.simulator.gui.base;
import de.steamwar.bausystem.features.simulator.SimulatorWatcher;
import de.steamwar.bausystem.features.simulator.data.Simulator;
import de.steamwar.core.Core;
import de.steamwar.core.TrickyTrialsWrapper;
import de.steamwar.inventory.SWInventory;
import de.steamwar.inventory.SWItem;
import org.bukkit.Bukkit;
@@ -64,7 +63,11 @@ public abstract class SimulatorBaseGui {
if (Core.getVersion() > 19) {
player.getOpenInventory().setTitle(title());
}
populate();
if (simulator != null && simulator.getStabGenerator() != null) {
populateStabGenerator();
} else {
populate();
}
if (player.getOpenInventory().getTopInventory() == inv) {
inventory.open();
SimulatorWatcher.watch(player, simulator, this::open);
@@ -84,10 +87,21 @@ public abstract class SimulatorBaseGui {
});
SimulatorWatcher.watch(player, simulator, this::open);
populate();
if (simulator != null && simulator.getStabGenerator() != null) {
populateStabGenerator();
} else {
populate();
}
inventory.open();
}
private void populateStabGenerator() {
inventory.setItem(22, new SWItem(Material.BARRIER, "§cCancel Stab Generator", click -> {
simulator.getStabGenerator().cancel();
SimulatorWatcher.update(simulator);
}));
}
public boolean shouldOpen() {
return true;
}

View File

@@ -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();

View File

@@ -19,8 +19,8 @@
package de.steamwar.bausystem.features.smartplace;
import de.steamwar.Reflection;
import com.comphenix.tinyprotocol.TinyProtocol;
import de.steamwar.Reflection;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.configplayer.Config;
@@ -223,7 +223,7 @@ public class SmartPlaceListener implements Listener {
Block block = event.getBlock().getRelative(BlockFace.DOWN);
BlockState old = block.getState();
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
block.setType(Material.GLASS, false);
block.setType(Material.GLASS, true);
old.update(true, false);
}, 1);
}

View File

@@ -42,16 +42,16 @@ public class TPSCommand extends SWCommand {
public void genericCommand(Player p, String... args) {
BauSystem.MESSAGE.sendPrefixless("OTHER_TPS_HEAD", p);
BauSystem.MESSAGE.sendPrefixless("OTHER_TPS_MESSAGE", p,
TPSWatcher.getTPS(TPSWatcher.TPSType.ONE_SECOND),
TPSWatcher.getTPS(TPSWatcher.TPSType.TEN_SECONDS),
TPSWatcher.getTPS(TPSWatcher.TPSType.ONE_MINUTE),
TPSWatcher.getTPS(TPSWatcher.TPSType.FIVE_MINUTES),
TPSWatcher.getTPS(TPSWatcher.TPSType.TEN_MINUTES)
TPSWatcher.getTPSUnlimited(TPSWatcher.TPSType.ONE_SECOND),
TPSWatcher.getTPSUnlimited(TPSWatcher.TPSType.TEN_SECONDS),
TPSWatcher.getTPSUnlimited(TPSWatcher.TPSType.ONE_MINUTE),
TPSWatcher.getTPSUnlimited(TPSWatcher.TPSType.FIVE_MINUTES),
TPSWatcher.getTPSUnlimited(TPSWatcher.TPSType.TEN_MINUTES)
);
}
@Register
public void genericCommand(Player p, TPSWatcher.TPSType type) {
BauSystem.MESSAGE.sendPrefixless("OTHER_TPS_SINGLE", p, tpsSystem.getTPS(type));
BauSystem.MESSAGE.sendPrefixless("OTHER_TPS_SINGLE", p, TPSWatcher.getTPSUnlimited(type));
}
}

View File

@@ -56,11 +56,7 @@ import java.util.Arrays;
public class TPSSystem implements Listener {
@Getter
private double currentTPSLimit = 20;
public double getTPS(TPSWatcher.TPSType tpsType) {
return TPSWatcher.getTPSUnlimited(tpsType);
}
private static double currentTPSLimit = 20;
public TPSSystem() {
if (TPSFreezeUtils.isCanFreeze()) {
@@ -338,26 +334,26 @@ public class TPSSystem implements Listener {
} else if (TPSFreezeUtils.frozen()) {
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() + tpsSystem.getTPS(TPSWatcher.TPSType.ONE_SECOND) + tpsLimit();
return "§e" + BauSystem.MESSAGE.parse("SCOREBOARD_TPS", p) + "§8: " + tpsColor() + TPSWatcher.getTPSUnlimited(TPSWatcher.TPSType.ONE_SECOND) + tpsLimit();
}
}
private String tpsColor() {
double tps = tpsSystem.getTPS(TPSWatcher.TPSType.ONE_SECOND);
if (tps > tpsSystem.getCurrentTPSLimit() * 0.9) {
double tps = TPSWatcher.getTPSUnlimited(TPSWatcher.TPSType.ONE_SECOND);
if (tps > TPSSystem.getCurrentTPSLimit() * 0.9) {
return "§a";
}
if (tps > tpsSystem.getCurrentTPSLimit() * 0.5) {
if (tps > TPSSystem.getCurrentTPSLimit() * 0.5) {
return "§e";
}
return "§c";
}
private String tpsLimit() {
if (tpsSystem.getCurrentTPSLimit() == 20) {
if (TPSSystem.getCurrentTPSLimit() == 20) {
return "";
}
return "§8/§7" + tpsSystem.getCurrentTPSLimit();
return "§8/§7" + TPSSystem.getCurrentTPSLimit();
}
}

View File

@@ -102,11 +102,14 @@ public class TraceRecorder implements Listener {
*
* @param region region to be recorded
*/
public void startRecording(Region region) {
if (activeTraces.containsKey(region)) return;
public Trace startRecording(Region region) {
if (activeTraces.containsKey(region)) {
return activeTraces.get(region).getTrace();
}
TraceRecordingWrapper wrappedTrace = new TraceRecordingWrapper(region);
activeTraces.put(region, wrappedTrace);
return wrappedTrace.getTrace();
}
/**

View File

@@ -20,6 +20,7 @@
package de.steamwar.bausystem.features.tracer.rendering;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.configplayer.Config;
import de.steamwar.bausystem.features.tracer.TNTPoint;
import de.steamwar.bausystem.features.tracer.Trace;
import de.steamwar.bausystem.features.tracer.TraceManager;
@@ -30,10 +31,13 @@ import net.md_5.bungee.api.chat.ClickEvent;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import yapion.hierarchy.types.YAPIONValue;
import java.util.List;
import java.util.stream.Collectors;
import static de.steamwar.bausystem.features.util.TNTClickListener.TNT_CLICK_DETAILS;
/**
* Wrapper for the rendering of a record bundle
*/
@@ -66,6 +70,7 @@ public class TraceEntity extends RFallingBlockEntity {
* @param player the player the message should be printed for
*/
public void printIntoChat(Player player) {
if (!Config.getInstance().get(player).getOrSetDefault(TNT_CLICK_DETAILS, new YAPIONValue<>(true)).asBoolean().orElse(true)) return;
TNTPoint representative = records.get(0);
BauSystem.MESSAGE.sendPrefixless("TNT_CLICK_HEADER", player);

View File

@@ -21,22 +21,46 @@ package de.steamwar.bausystem.features.util;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.configplayer.Config;
import de.steamwar.command.SWCommand;
import de.steamwar.linkage.Linked;
import org.bukkit.Bukkit;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.entity.TNTPrimed;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.inventory.EquipmentSlot;
import yapion.hierarchy.types.YAPIONObject;
import yapion.hierarchy.types.YAPIONValue;
@Linked
public class TNTClickListener implements Listener {
public class TNTClickListener extends SWCommand implements Listener {
public static final String TNT_CLICK_DETAILS = "tnt_click_details";
public TNTClickListener() {
super("tntdetails");
}
@Register(description = "TNT_DETAILS_COMMAND")
public void toggle(Player player) {
YAPIONObject yapionObject = Config.getInstance().get(player);
if (yapionObject.getOrSetDefault(TNT_CLICK_DETAILS, new YAPIONValue<>(true)).asBoolean().orElse(true)) {
yapionObject.put(TNT_CLICK_DETAILS, false);
BauSystem.MESSAGE.send("TNT_DETAILS_OFF", player);
} else {
yapionObject.put(TNT_CLICK_DETAILS, true);
BauSystem.MESSAGE.send("TNT_DETAILS_ON", player);
}
}
@EventHandler
public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
if (!Permission.BUILD.hasPermission(event.getPlayer())) return;
if (event.getHand() != EquipmentSlot.HAND) return;
if (!Config.getInstance().get(event.getPlayer()).getOrSetDefault(TNT_CLICK_DETAILS, new YAPIONValue<>(true)).asBoolean().orElse(true)) return;
Entity entity = event.getRightClicked();
if (event.getRightClicked() instanceof TNTPrimed) {

View File

@@ -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("/");

View File

@@ -73,4 +73,8 @@ public class Point {
public Location toLocation(Player player, double dx, double dy, double dz) {
return new Location(player.getWorld(), x + dx, y + dy, z + dz, player.getLocation().getYaw(), player.getLocation().getPitch());
}
public BlockVector3 toBlockVector3() {
return BlockVector3.at(this.x, this.y, this.z);
}
}

View File

@@ -34,3 +34,19 @@ 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")
template = "Bau20"
}
tasks.register<DevServer>("DevBau21") {
group = "run"
description = "Run a 1.21 Dev Bau"
dependsOn(":SpigotCore:shadowJar")
dependsOn(":BauSystem:shadowJar")
template = "Bau21"
}

View File

@@ -23,10 +23,7 @@ import com.comphenix.tinyprotocol.TinyProtocol;
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;
@@ -136,6 +133,7 @@ public class FightSystem extends JavaPlugin {
new PersistentDamage();
new TNTDistributor();
new WinconditionAmongUs();
new NoGravity();
new NoPlayersOnlineCountdown();
new PreSchemCountdown();

View File

@@ -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;

View File

@@ -0,0 +1,41 @@
/*
* 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.event;
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.Listener;
import org.bukkit.event.entity.EntitySpawnEvent;
public class NoGravity implements Listener {
public NoGravity() {
new StateDependentListener(Winconditions.NO_GRAVITY, FightState.All, this);
}
@EventHandler
public void onEntitySpawn(EntitySpawnEvent event) {
if (event.getEntityType() == EntityType.PLAYER) return;
event.getEntity().setGravity(false);
}
}

View File

@@ -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;

View File

@@ -86,7 +86,10 @@ public class PrepareSchem implements Listener {
if(schemExists(schem))
return;
SchematicNode old = schem;
schem = SchematicNode.createSchematicNode(schem.getOwner(), preparedName(schem), schem.getParent(), Config.SchematicType.checkType().toDB(), schem.getItem());
schem.setReplaceColor(old.replaceColor());
schem.setAllowReplay(old.allowReplay());
try{
WorldeditWrapper.impl.saveSchem(schem, region, minY);

View File

@@ -39,5 +39,6 @@ public enum Winconditions {
METEOR,
AMONG_US,
PERSISTENT_DAMAGE,
TNT_DISTRIBUTION
TNT_DISTRIBUTION,
NO_GRAVITY,
}

View File

@@ -39,3 +39,13 @@ dependencies {
implementation(project(":FightSystem:FightSystem_20"))
implementation(project(":FightSystem:FightSystem_21"))
}
tasks.register<FightServer>("WarGear20") {
group = "run"
description = "Run a WarGear 1.20 Fight Server"
dependsOn(":SpigotCore:shadowJar")
dependsOn(":FightSystem:shadowJar")
template = "WarGear20"
worldName = "arenas/Pentraki"
config = "WarGear20.yml"
}

View File

@@ -67,7 +67,7 @@ public class JumpAndRun extends BasicListener {
int count = CLICKED_COUNT.getOrDefault(player, -1);
if (count >= 0) {
if (count > 60) {
if (count > 20) {
toReset.add(player);
return;
}
@@ -104,12 +104,18 @@ public class JumpAndRun extends BasicListener {
return;
}
Vector point = points.get(index);
if (location.getY() < point.getY()) {
return;
}
if (location.toVector().distanceSquared(point) >= 12.25) {
if (location.getY() < point.getY()) index = -2;
if (location.toVector().distanceSquared(point) >= 17) index = -2;
if (index > 0 && index < points.size() - 1) {
Vector nextPoint = points.get(index + 1);
if (location.getY() >= nextPoint.getY() && location.toVector().distanceSquared(nextPoint) < 17) {
index = index + 1;
}
}
if (index == -2) {
return;
}
CURRENT_POS.put(event.getPlayer(), index);
event.getPlayer().playSound(event.getPlayer().getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 0.4F, 1);
if (index < points.size() - 1) {

View File

@@ -184,6 +184,7 @@ public class MWTeam {
public void leave(Player p) {
if (!players.contains(p)) return;
players.remove(p);
for (ItemStack stack : p.getInventory().getContents()) {
if (stack == null) continue;
@@ -198,7 +199,6 @@ public class MWTeam {
if (players.isEmpty() && MissileWars.getFightState() == FightState.FIGHTING)
MissileWars.end(WinReasons.NO_ENEMY, enemy());
players.remove(p);
sbteam.removePlayer(p);
}

View File

@@ -37,7 +37,7 @@ public class EndCountdown extends StateDependent {
@Override
public void enable() {
if (Config.isEvent()) {
task = Bukkit.getScheduler().runTaskLater(MissileWars.getPlugin(), this::stop, 1200);
task = Bukkit.getScheduler().runTaskLater(MissileWars.getPlugin(), this::stop, 200);
} else {
task = Bukkit.getScheduler().runTaskLater(MissileWars.getPlugin(), this::restart, Config.EndTime);
}

View File

@@ -71,6 +71,17 @@ public class TinyProtocol implements Listener {
@Getter
private final Map<Player, PacketInterceptor> playerInterceptors = new HashMap<>();
@Override
public String toString() {
return "TinyProtocol{" +
"plugin=" + plugin +
", connections=" + connections +
", closed=" + closed +
", packetFilters=" + packetFilters +
", playerInterceptors=" + playerInterceptors +
'}';
}
private TinyProtocol(final Plugin plugin) {
this.plugin = plugin;
this.connections = networkManagers.get(getServerConnection(plugin));
@@ -84,6 +95,7 @@ public class TinyProtocol implements Listener {
@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerLogin(PlayerLoginEvent e) {
plugin.getLogger().info("Creating PacketInterceptor for: " + e.getPlayer().getName() + " (" + closed + ")");
if(closed)
return;
new PacketInterceptor(e.getPlayer());
@@ -118,6 +130,8 @@ public class TinyProtocol implements Listener {
}
public final void close() {
plugin.getLogger().log(Level.INFO, "Closing PacketInterceptor", new Exception("Stacktrace"));
if(closed)
return;
closed = true;
@@ -146,10 +160,10 @@ public class TinyProtocol implements Listener {
private PacketInterceptor(Player player) {
this.player = player;
channel = getChannel.get(connections.stream().filter(connection -> player.getUniqueId().equals(getUUID.get(connection))).findAny().orElseThrow(() -> {
channel = connections.stream().filter(connection -> player.getUniqueId().equals(getUUID.get(connection))).map(getChannel::get).filter(Channel::isActive).findAny().orElseThrow(() -> {
Bukkit.getScheduler().runTask(plugin, () -> player.kickPlayer("Connection failure."));
return new SecurityException("Could not find channel for player " + player.getName());
}));
});
if(!channel.isActive())
return;
@@ -157,14 +171,15 @@ public class TinyProtocol implements Listener {
synchronized (playerInterceptors) {
playerInterceptors.put(player, this);
}
plugin.getLogger().info("Adding Techhider for: " + player.getName());
try {
channel.pipeline().addBefore("packet_handler", HANDLER_NAME, this);
} catch (IllegalArgumentException e) {
} catch (IllegalArgumentException | NoSuchElementException e) {
Bukkit.getScheduler().runTask(plugin, () -> player.kickPlayer("Connection failure."));
throw new SecurityException(e);
}
}
}
private void sendPacket(Object packet) {
channel.pipeline().writeAndFlush(packet);

View File

@@ -35,6 +35,8 @@ import org.bukkit.event.player.PlayerAttemptPickupItemEvent
import org.bukkit.event.player.PlayerInteractEntityEvent
import org.bukkit.event.player.PlayerJoinEvent
import org.bukkit.event.player.PlayerMoveEvent
import org.bukkit.event.player.*
import org.bukkit.persistence.PersistentDataType
object IngameListener : Listener {
@@ -75,9 +77,9 @@ object IngameListener : Listener {
@EventHandler
fun onPickupCoins(e: PlayerAttemptPickupItemEvent) {
if (e.item.itemStack.isSimilar(DealerInventory.coins)) {
TNTLeagueGame.getTeam(e.player)?.coins =
e.item.itemStack.amount + (TNTLeagueGame.getTeam(e.player)?.coins ?: 0)
if (e.item.itemStack.persistentDataContainer.has(DealerInventory.coinKey)) {
val numberOfCoins = e.item.itemStack.persistentDataContainer[DealerInventory.coinKey, PersistentDataType.INTEGER] ?: 0
TNTLeagueGame.getTeam(e.player)?.coins = (e.item.itemStack.amount * numberOfCoins) + (TNTLeagueGame.getTeam(e.player)?.coins ?: 0)
e.item.itemStack.amount = 0
e.isCancelled = true

View File

@@ -24,8 +24,6 @@ import de.steamwar.message.SubMessage
import de.steamwar.network.NetworkSender
import de.steamwar.network.packets.common.FightInfoPacket
import de.steamwar.scoreboard.SWScoreboard
import de.steamwar.sql.Fight
import de.steamwar.sql.FightPlayer
import de.steamwar.sql.SteamwarUser
import de.steamwar.tntleague.colorByTeam
import de.steamwar.tntleague.config.TNTLeagueConfig
@@ -37,10 +35,9 @@ import de.steamwar.tntleague.events.LobbyListener
import de.steamwar.tntleague.inventory.DealerInventory
import de.steamwar.tntleague.message
import de.steamwar.tntleague.plugin
import de.steamwar.tntleague.util.*
import de.steamwar.tntleague.util.TNTLeagueScoreboard
import org.bukkit.GameMode
import org.bukkit.Location
import org.bukkit.Material
import org.bukkit.Sound
import org.bukkit.entity.Item
import org.bukkit.entity.Player
@@ -51,6 +48,7 @@ import org.bukkit.inventory.ItemStack
import org.bukkit.scheduler.BukkitTask
import java.sql.Timestamp
import java.time.Instant
import kotlin.random.Random
object TNTLeagueGame {
var state: GameState = GameState.LOBBY
@@ -87,18 +85,24 @@ object TNTLeagueGame {
message.broadcast("GAME_STARTED")
val tnt = ItemStack(Material.TNT)
start = Timestamp.from(Instant.now())
var spawnCount = 0
spawnerTask = plugin.server.scheduler.runTaskTimer(plugin, bukkit {
val coinsToSpawn = if (spawnCount % 28 == 0) {
DealerInventory.huge_coins
} else if (spawnCount % 7 == 0) {
DealerInventory.big_coins
} else {
DealerInventory.coins
}
spawnCount++
if (world.getNearbyEntitiesByType(Item::class.java, TNTLeagueWorldConfig.blueTeam.itemSpawn, 3.0).sumOf { it.itemStack.amount } <= 256) {
spawnItems(TNTLeagueWorldConfig.blueTeam.itemSpawn, tnt)
spawnItems(TNTLeagueWorldConfig.blueTeam.itemSpawn, DealerInventory.coins)
spawnItems(TNTLeagueWorldConfig.blueTeam.itemSpawn, coinsToSpawn)
}
if (world.getNearbyEntitiesByType(Item::class.java, TNTLeagueWorldConfig.redTeam.itemSpawn, 3.0).sumOf { it.itemStack.amount } <= 256) {
spawnItems(TNTLeagueWorldConfig.redTeam.itemSpawn, tnt)
spawnItems(TNTLeagueWorldConfig.redTeam.itemSpawn, DealerInventory.coins)
spawnItems(TNTLeagueWorldConfig.redTeam.itemSpawn, coinsToSpawn)
}
}, 5, 10)

View File

@@ -59,13 +59,31 @@ class DealerInventory(player: Player): KotlinInventory(player) {
companion object {
private val priceKey = NamespacedKey(plugin, "price")
private val amountKey = NamespacedKey(plugin, "amount")
private val coinKey = NamespacedKey(plugin, "coin")
val coinKey = NamespacedKey(plugin, "coin")
val coins = ItemStack(Material.RAW_GOLD).apply {
itemMeta = itemMeta.apply {
displayName(Component.text("Coins").color(NamedTextColor.GOLD))
persistentDataContainer.apply {
set(coinKey, PersistentDataType.BOOLEAN, true)
set(coinKey, PersistentDataType.INTEGER, 1)
}
}
}
val big_coins = ItemStack(Material.GOLD_INGOT).apply {
itemMeta = itemMeta.apply {
displayName(Component.text("Big Coins").color(NamedTextColor.GOLD))
persistentDataContainer.apply {
set(coinKey, PersistentDataType.INTEGER, 3)
}
}
}
val huge_coins = ItemStack(Material.GOLD_BLOCK).apply {
itemMeta = itemMeta.apply {
displayName(Component.text("Huge Coins").color(NamedTextColor.GOLD))
persistentDataContainer.apply {
set(coinKey, PersistentDataType.INTEGER, 9)
}
}
}

View File

@@ -17,20 +17,23 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
PREFIX=<EFBFBD>eTowerRun<EFBFBD>8<EFBFBD><EFBFBD>r
PREFIX=§eTowerRun§8»§r
PLAYER_DIED=<EFBFBD>c{0} <EFBFBD>7died<EFBFBD>8!
PLAYER_ESCAPE=<EFBFBD>a{0} <EFBFBD>7escaped<EFBFBD>8!
GAME_START=<EFBFBD>aThe game has started<EFBFBD>8!
GAME_WIN=<EFBFBD>a{0} <EFBFBD>7has won the game<EFBFBD>8!
GAME_STARTING=<EFBFBD>7Starting: <EFBFBD>e{0}s<EFBFBD>8!
GAME_WAITING=<EFBFBD>7Waiting for players<EFBFBD>8...
SERVER_STOPPING=<EFBFBD>cThe server stops in <EFBFBD>e{0}s<EFBFBD>8!
SERVER_RESET=<EFBFBD>cThe server will be reset in <EFBFBD>e{0}s<EFBFBD>8!
KEY_NAME=<EFBFBD>eKey
KEY_FOUND=<EFBFBD>a{0} <EFBFBD>7found a key<EFBFBD>8!
GAME_TIE=<EFBFBD>aThe game ended in a tie<EFBFBD>8!
GAME_TIME=<EFBFBD>a{0}:{1}
CATCH_UP_WARNING=<EFBFBD>4!! <EFBFBD>cYou should catch up <EFBFBD>4!!
PLAYER_DIED=§c{0} §7died§8!
PLAYER_ESCAPE=§a{0} §7escaped§8!
GAME_START=§aThe game has started§8!
GAME_WIN=§a{0} §7has won the game§8!
GAME_STARTING=§7Starting: §e{0}s§8!
GAME_WAITING=§7Waiting for players§8...
SERVER_STOPPING=§cThe server stops in §e{0}s§8!
SERVER_RESET=§cThe server will be reset in §e{0}s§8!
KEY_NAME=§eKey
KEY_FOUND=§a{0} §7found a key§8!
GAME_TIE=§aThe game ended in a tie§8!
GAME_TIME=§a{0}:{1}
CATCH_UP_WARNING=§4!! §cYou should catch up §4!!
COMMAND_START=<EFBFBD>aThe game will start soon<EFBFBD>8!
COMMAND_START=§aThe game will start soon§8!
PARTICIPANT_CHAT={0} {1}§8» §7{2}
SPECTATOR_CHAT=§7{0}§8» §7{1}

View File

@@ -17,19 +17,19 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
PLAYER_DIED=<EFBFBD>c{0} <EFBFBD>7ist gestorben<EFBFBD>8!
PLAYER_ESCAPE=<EFBFBD>a{0} <EFBFBD>7ist entkommen<EFBFBD>8!
GAME_START=<EFBFBD>aDas Spiel beginnt<EFBFBD>8!
GAME_WIN=<EFBFBD>a{0} <EFBFBD>7hat das Spiel gewonnen<EFBFBD>8!
GAME_STARTING=<EFBFBD>7Das Spiel startet in <EFBFBD>e{0}s<EFBFBD>8!
GAME_WAITING=<EFBFBD>7Warte auf weitere Spieler<EFBFBD>8...
SERVER_STOPPING=<EFBFBD>cDer Server stoppt in <EFBFBD>e{0}s<EFBFBD>8!
SERVER_RESET=<EFBFBD>cDer Server wird in <EFBFBD>e{0}s <EFBFBD>czur<EFBFBD>ckgesetzt<EFBFBD>8!
GAME_TIE=<EFBFBD>7Keiner hat gewonnen<EFBFBD>8!
PLAYER_DIED=§c{0} §7ist gestorben§8!
PLAYER_ESCAPE=§a{0} §7ist entkommen§8!
GAME_START=§aDas Spiel beginnt§8!
GAME_WIN=§a{0} §7hat das Spiel gewonnen§8!
GAME_STARTING=§7Das Spiel startet in §e{0}s§8!
GAME_WAITING=§7Warte auf weitere Spieler§8...
SERVER_STOPPING=§cDer Server stoppt in §e{0}s§8!
SERVER_RESET=§cDer Server wird in §e{0}s §czur§ckgesetzt§8!
GAME_TIE=§7Keiner hat gewonnen§8!
KEY_NAME=<EFBFBD>eSchl<EFBFBD>ssel
KEY_FOUND=<EFBFBD>a{0} <EFBFBD>7hat einen Schl<EFBFBD>ssel gefunden<EFBFBD>8!
KEY_NAME=§eSchl§ssel
KEY_FOUND=§a{0} §7hat einen Schl§ssel gefunden§8!
CATCH_UP_WARNING=<EFBFBD>4!! <EFBFBD>cDu solltest aufholen <EFBFBD>4!!
CATCH_UP_WARNING=§4!! §cDu solltest aufholen §4!!
COMMAND_START=<EFBFBD>7Das Spiel startet bald<EFBFBD>8!
COMMAND_START=§7Das Spiel startet bald§8!

View File

@@ -80,7 +80,5 @@ public class TowerRun extends JavaPlugin {
gameCountdown = new GameCountdown();
Bukkit.getScheduler().runTaskTimer(this, new FightInfoPacketSender(), 20, 20);
TowerRunGame.reset();
}
}

View File

@@ -35,7 +35,8 @@ import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.util.Vector;
import java.io.File;
import java.util.*;
import java.util.ArrayList;
import java.util.List;
@UtilityClass
public class WorldConfig {
@@ -54,7 +55,7 @@ public class WorldConfig {
public static final int MAP_MIN_Z;
public static final int MAP_MAX_X;
public static final int MAP_MAX_Z;
public static final Map<Material, Integer> MELTING_TIMES;
public static final boolean MELTING;
public static final TowerGeneratorConfig TOWER_GENERATOR_CONFIG;
public static final List<WinCondition> WINCONDITIONS = new ArrayList<>();
@@ -161,16 +162,7 @@ public class WorldConfig {
MAP_MAX_X = config.getInt("maxX");
MAP_MAX_Z = config.getInt("maxZ");
ConfigurationSection meltingBlocksSection = tower.getConfigurationSection("meltingBlocks");
if (meltingBlocksSection != null) {
Map<Material, Integer> meltingTimes = new HashMap<>();
meltingBlocksSection.getKeys(false).forEach(s -> {
meltingTimes.put(Material.valueOf(s), meltingBlocksSection.getInt(s));
});
MELTING_TIMES = Collections.unmodifiableMap(meltingTimes);
} else {
MELTING_TIMES = Collections.emptyMap();
}
MELTING = tower.getBoolean("melting") || tower.contains("meltingBlocks"); // Backwards compatibility with meltingBlocks key!
ACTIVE_WINCONDITIONS = config.getStringList("winconditions");
WINCONDITIONS.stream().filter(winCondition -> ACTIVE_WINCONDITIONS.contains(winCondition.getName())).forEach(winCondition -> winCondition.setActive(true));

View File

@@ -20,6 +20,7 @@
package de.steamwar.towerrun.countdowns;
import de.steamwar.towerrun.TowerRun;
import de.steamwar.towerrun.config.Config;
import de.steamwar.towerrun.game.TowerRunGame;
import de.steamwar.towerrun.state.GameStates;
import org.bukkit.Bukkit;
@@ -48,7 +49,11 @@ public class EndCountdown extends Countdown {
void timerEnd() {
Bukkit.getOnlinePlayers().forEach(player -> player.playSound(player.getLocation(), Sound.BLOCK_NOTE_BLOCK_PLING, 1, 1));
if (RESETS) {
TowerRunGame.reset();
if (Config.event()) {
Bukkit.shutdown();
} else {
TowerRunGame.reset();
}
lobbyCountdown.setTime(lobbyCountdown.defaultTime());
} else {
Bukkit.shutdown();

View File

@@ -46,6 +46,10 @@ public class TowerRunGame {
public static final List<TowerRunPlayer> PLAYERS_ESCAPED = new ArrayList<>();
private static final World world = Bukkit.getWorlds().get(0);
public static boolean isEscaped(TowerRunPlayer player) {
return PLAYERS_ESCAPED.contains(player);
}
public static boolean isAlive(TowerRunPlayer player) {
return PLAYERS_ALIVE.contains(player);
}
@@ -143,6 +147,7 @@ public class TowerRunGame {
player.setGameMode(GameMode.SURVIVAL);
}
player.teleport(WorldConfig.SPAWN);
PLAYERS_ALIVE.add(TowerRunPlayer.get(player));
});
}

View File

@@ -140,8 +140,10 @@ public class TowerGenerator {
noKeyFloors--;
if (!chestBlocks.isEmpty() && noKeyFloors < 0 && random.nextDouble() < config.keyChance) {
noKeyFloors = random.nextInt(config.maxNoKeyFloors - config.minNoKeyFloors) + config.minNoKeyFloors;
Container container = chestBlocks.get(random.nextInt(chestBlocks.size()));
keys.add(container.getLocation());
for (int i = 0; i < 2; i++) {
Container container = chestBlocks.get(random.nextInt(chestBlocks.size()));
keys.add(container.getLocation());
}
for (WorldConfig.TowerGeneratorDoorBlock doorBlock : config.doorBlocks) {
int x = doorBlock.getX();

View File

@@ -19,20 +19,20 @@
package de.steamwar.towerrun.listener;
import de.steamwar.towerrun.TowerRun;
import de.steamwar.towerrun.config.WorldConfig;
import de.steamwar.towerrun.game.TowerRunGame;
import de.steamwar.towerrun.game.TowerRunPlayer;
import de.steamwar.towerrun.state.GameState;
import de.steamwar.towerrun.state.GameStateBukkitListener;
import de.steamwar.towerrun.state.GameStates;
import lombok.val;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.event.player.*;
import java.util.EnumSet;
@@ -67,4 +67,25 @@ public class GlobalListener extends GameStateBukkitListener implements Listener
public void onPlayerRespawn(PlayerRespawnEvent event) {
event.setRespawnLocation(WorldConfig.SPAWN);
}
@EventHandler
public void onAsyncPlayerChat(AsyncPlayerChatEvent event) {
TowerRunPlayer player = TowerRunPlayer.get(event.getPlayer());
if (GameState.getCurrentState() == GameStates.RUNNING && (TowerRunGame.isAlive(player) || TowerRunGame.isEscaped(player))) {
String prefix;
if (TowerRunGame.isAlive(player)) {
if (event.getPlayer().getGameMode() == GameMode.SPECTATOR) {
prefix = "§c☠";
} else {
prefix = "§6❤";
}
} else {
prefix = "§a✔";
}
TowerRun.getMessage().broadcastPrefixless("PARTICIPANT_CHAT", prefix, event.getPlayer().getName(), event.getMessage());
} else {
TowerRun.getMessage().broadcastPrefixless("SPECTATOR_CHAT", event.getPlayer().getName(), event.getMessage());
}
event.setCancelled(true);
}
}

View File

@@ -26,6 +26,8 @@ import de.steamwar.towerrun.config.WorldConfig;
import de.steamwar.towerrun.game.TowerRunGame;
import de.steamwar.towerrun.state.GameStateBukkitListener;
import de.steamwar.towerrun.state.GameStates;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import org.bukkit.*;
import org.bukkit.block.Block;
import org.bukkit.entity.EntityType;
@@ -42,16 +44,24 @@ import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.scheduler.BukkitRunnable;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
public class IngameListener extends GameStateBukkitListener {
private int time = 0;
private final Map<Integer, List<Block>> blocksToMelt = new HashMap<>();
private final Map<Pos, Integer> blocksToMelt = new HashMap<>();
private BukkitRunnable blocksToMeltRunnable;
private BukkitRunnable antiCampRunnable;
@AllArgsConstructor
@EqualsAndHashCode
private class Pos {
private final int x;
private final int y;
private final int z;
}
public IngameListener() {
super(EnumSet.of(GameStates.RUNNING));
}
@@ -62,16 +72,21 @@ public class IngameListener extends GameStateBukkitListener {
blocksToMeltRunnable = new BukkitRunnable() {
@Override
public void run() {
List<Block> blocks = blocksToMelt.get(time);
List<Pos> blocksToBreak = blocksToMelt.entrySet().stream()
.filter(entry -> entry.getValue() <= time)
.map(Map.Entry::getKey)
.collect(Collectors.toList());
time++;
if (blocks == null) {
if (blocksToBreak.isEmpty()) {
return;
}
blocks.forEach(block -> {
if (!WorldConfig.MELTING_TIMES.containsKey(block.getType())) return;
for (Pos pos : blocksToBreak) {
blocksToMelt.remove(pos);
Block block = Bukkit.getWorlds().get(0).getBlockAt(pos.x, pos.y, pos.z);
if (block.getType() == Material.AIR || block.getType() == Material.LAVA) continue;
block.setType(Material.AIR);
block.getWorld().playSound(block.getLocation(), Sound.BLOCK_FIRE_EXTINGUISH, 0.1F, 1);
});
}
}
};
blocksToMeltRunnable.runTaskTimer(TowerRun.getInstance(), 0, 1);
@@ -80,16 +95,16 @@ public class IngameListener extends GameStateBukkitListener {
@Override
public void run() {
double minY = TowerRunGame.PLAYERS_ALIVE.stream()
.map(p -> p.player().getLocation().getY())
.min(Comparator.comparing(Function.identity()))
.mapToDouble(p -> p.player().getLocation().getY())
.average()
.orElse(0.0);
List<Player> toDamage = new ArrayList<>();
TowerRunGame.PLAYERS_ALIVE.forEach(towerRunPlayer -> {
if (towerRunPlayer.player().getLocation().getY() - minY > 20) {
towerRunPlayer.player().sendTitle("§a", TowerRun.getMessage().parse("CATCH_UP_WARNING", towerRunPlayer.player()), 5, 30, 5);
}
if (towerRunPlayer.player().getLocation().getY() - minY > 30) {
towerRunPlayer.player().sendTitle("", TowerRun.getMessage().parse("CATCH_UP_WARNING", towerRunPlayer.player()), 5, 30, 5);
}
if (towerRunPlayer.player().getLocation().getY() - minY > 50) {
toDamage.add(towerRunPlayer.player());
}
});
@@ -115,12 +130,12 @@ public class IngameListener extends GameStateBukkitListener {
public void onPlayerDeath(PlayerDeathEvent event) {
event.setDeathMessage(null);
Bukkit.getScheduler().runTaskLater(TowerRun.getInstance(), () -> {
if (TowerRun.getTowerGenerator() != null) {
event.getEntity().teleport(TowerRun.getTowerGenerator().getSpawn());
} else {
event.getEntity().teleport(WorldConfig.SPAWN);
}
}, 5
if (TowerRun.getTowerGenerator() != null) {
event.getEntity().teleport(TowerRun.getTowerGenerator().getSpawn());
} else {
event.getEntity().teleport(WorldConfig.SPAWN);
}
}, 5
);
event.getEntity().setGameMode(GameMode.SPECTATOR);
Bukkit.getOnlinePlayers().forEach(player -> {
@@ -181,14 +196,19 @@ public class IngameListener extends GameStateBukkitListener {
}
event.getPlayer().getInventory().addItem(new SWItem(Material.LEVER, TowerRun.getMessage().parse("KEY_NAME", event.getPlayer())).getItemStack());
event.getClickedBlock().setType(Material.ENDER_CHEST);
event.getPlayer().playSound(event.getPlayer().getLocation(), Sound.BLOCK_ENDER_CHEST_OPEN, 1, 1);
TowerRun.getMessage().broadcast("KEY_FOUND", event.getPlayer().getName());
Bukkit.getOnlinePlayers().forEach(player -> {
player.playSound(event.getPlayer().getLocation(), Sound.BLOCK_ENDER_CHEST_OPEN, 1, 1);
player.sendTitle("", TowerRun.getMessage().parse("KEY_FOUND", player, event.getPlayer().getName()), 10, 70, 20);
});
}
@EventHandler
public void onBlockPhysics(BlockPhysicsEvent event) {
if (!WorldConfig.MELTING) {
return;
}
if (event.getSourceBlock().getType() != Material.LAVA) {
return;
}
@@ -202,11 +222,52 @@ public class IngameListener extends GameStateBukkitListener {
}
private void shouldMelt(Block block) {
int meltingTime = WorldConfig.MELTING_TIMES.getOrDefault(block.getType(), -1);
if (meltingTime == -1) {
return;
if (block.getType().isBurnable()) return;
if (block.getType().isAir()) return;
if (block.isLiquid()) return;
int meltingTime = (int) (block.getType().getHardness() * 48 * 20);
switch (block.getType()) {
case TINTED_GLASS:
meltingTime = meltingTime * 2;
break;
case WHITE_STAINED_GLASS:
case ORANGE_STAINED_GLASS:
case MAGENTA_STAINED_GLASS:
case LIGHT_BLUE_STAINED_GLASS:
case YELLOW_STAINED_GLASS:
case LIME_STAINED_GLASS:
case PINK_STAINED_GLASS:
case GRAY_STAINED_GLASS:
case LIGHT_GRAY_STAINED_GLASS:
case CYAN_STAINED_GLASS:
case PURPLE_STAINED_GLASS:
case BLUE_STAINED_GLASS:
case BROWN_STAINED_GLASS:
case GREEN_STAINED_GLASS:
case RED_STAINED_GLASS:
case BLACK_STAINED_GLASS:
case WHITE_STAINED_GLASS_PANE:
case ORANGE_STAINED_GLASS_PANE:
case MAGENTA_STAINED_GLASS_PANE:
case LIGHT_BLUE_STAINED_GLASS_PANE:
case YELLOW_STAINED_GLASS_PANE:
case LIME_STAINED_GLASS_PANE:
case PINK_STAINED_GLASS_PANE:
case GRAY_STAINED_GLASS_PANE:
case LIGHT_GRAY_STAINED_GLASS_PANE:
case CYAN_STAINED_GLASS_PANE:
case PURPLE_STAINED_GLASS_PANE:
case BLUE_STAINED_GLASS_PANE:
case BROWN_STAINED_GLASS_PANE:
case GREEN_STAINED_GLASS_PANE:
case RED_STAINED_GLASS_PANE:
case BLACK_STAINED_GLASS_PANE:
meltingTime = meltingTime * 10;
default:
break;
}
blocksToMelt.computeIfAbsent(time + meltingTime * 20, integer -> new ArrayList<>()).add(block);
Pos pos = new Pos(block.getLocation().getBlockX(), block.getLocation().getBlockY(), block.getLocation().getBlockZ());
blocksToMelt.putIfAbsent(pos, time + meltingTime + 1);
}
@EventHandler

View File

@@ -68,6 +68,8 @@ public class LobbyListener extends GameStateBukkitListener {
if (TowerRunGame.PLAYERS_ALIVE.stream().map(towerRunPlayer -> SteamwarUser.get(towerRunPlayer.player().getUniqueId()).getTeam()).filter(integer -> integer == team).count() < Config.EVENT_MAXIMUM_TEAM_MEMBERS) {
TowerRunGame.PLAYERS_ALIVE.add(TowerRunPlayer.get(player));
} else {
player.setGameMode(GameMode.SPECTATOR);
}
} else {
TowerRunGame.PLAYERS_ALIVE.add(TowerRunPlayer.get(player));

View File

@@ -66,4 +66,12 @@ dependencies {
implementation(libs.apolloprotos)
implementation(libs.nbt)
}
}
tasks.register<DevServer>("DevVelocity") {
group = "run"
description = "Run a Dev Velocity"
dependsOn(":VelocityCore:shadowJar")
dependsOn(":VelocityCore:Persistent:jar")
template = "DevVelocity"
}

View File

@@ -154,7 +154,7 @@ UNPUNISHMENT_USAGE=§8/§7{0} §8[§eplayer§8]
PUNISHMENT_UNTIL=until {0}
PUNISHMENT_PERMA=permanent
BAN_TEAM={0} §e{1} §7was §e§lbanned§7 by §e{2} {3}§8: §f{4}
BAN_TEAM=§e{0} §7was §e§lbanned§7 by §e{1} {2}§8: §f{3}
BAN_PERMA=§7You are §e§lbanned §epermanently§8: §e{0}
BAN_UNTIL=§7You are §e§lbanned §euntil {0}§8: §e{1}
UNBAN_ERROR=§cThe player isn't banned.
@@ -164,49 +164,49 @@ BAN_AVOIDING_ALERT=§cPotential ban bypass by §r{0}§c: {1}
BAN_AVOIDING_LIST=§c{0} §e{1}
BAN_AVOIDING_BAN_HOVER=§cBan player because of bann bypass.
MUTE_TEAM={0} §e{1} §7was §e§lmuted§7 by §e{2} {3}§8: §f{4}
MUTE_TEAM=§e{0} §7was §e§lmuted§7 by §e{1} {2}§8: §f{3}
MUTE_PERMA=§7You are §epermanently §e§lmuted§8: §e{0}
MUTE_UNTIL=§7You are §e§lmuted §euntil {0}§8: §e{1}
UNMUTE_ERROR=§cThe player isn't muted.
UNMUTE=§7You have §e§lunmuted §e{0}.
NOSCHEMRECEIVING_TEAM={0} §e{1} §7was excluded from §e{2} {3} §7from §e§lrecieving schematics§8: §f{4}
NOSCHEMRECEIVING_TEAM=§e{0} §7was excluded from §e{1} {2} §7from §e§lrecieving schematics§8: §f{3}
NOSCHEMRECEIVING_PERMA=§7You are §epermanently§7 excluded from receiving §e§lschematics§8: §e{0}
NOSCHEMRECEIVING_UNTIL=§7You are excluded from receiving §e§lschematics §euntil {0}§8: §e{1}
UNNOSCHEMRECEIVING_ERROR=§cThe player is not excluded from receiving schematics.
UNNOSCHEMRECEIVING=§e{0} §7may now receive §e§lschematics§7 again§8.
NOSCHEMSHARING_TEAM={0} §e{1} §7was excluded from §e{2} {3} §7from §e§lsharing schematics§8: §f{4}
NOSCHEMSHARING_TEAM=§e{0} §7was excluded from §e{1} {2} §7from §e§lsharing schematics§8: §f{3}
NOSCHEMSHARING_PERMA=§7You are §epermanently§7 excluded from sharing §e§lschematics§8: §e{0}
NOSCHEMSHARING_UNTIL=§7You are excluded from sharing §e§lschematics §euntil {0}§8: §e{1}
UNNOSCHEMSHARING_ERROR=§cThe player is not excluded from sharing schematics.
UNNOSCHEMSHARING=§e{0} §7may now share §e§lschematics§7 again§8.
NOSCHEMSUBMITTING_TEAM={0} §e{1} §7was excluded from §e{2} {3} §7from §e§lsubmitting schematics§8: §f{4}
NOSCHEMSUBMITTING_TEAM=§e{0} §7was excluded from §e{1} {2} §7from §e§lsubmitting schematics§8: §f{3}
NOSCHEMSUBMITTING_PERMA=§7You are §epermanently§7 excluded from submitting §e§lschematics§8: §e{0}
NOSCHEMSUBMITTING_UNTIL=§7You are excluded from submitting §e§lschematics §euntil {0}§8: §e{1}
UNNOSCHEMSUBMITTING_ERROR=§cThe player is not excluded from submitting schematics.
UNNOSCHEMSUBMITTING=§e{0} §7may now submit §e§lschematics§7 again§8.
NODEVSERVER_TEAM={0} §e{1} §7has annoyed §e{2} §7with reason §f{4}§7 and therefore has received §e§ldev server prohibition§7§8, §f{3}
NODEVSERVER_TEAM=§e{0} §7has annoyed §e{1} §7with reason §f{3}§7 and therefore has received §e§ldev server prohibition§7§8, §f{2}
NODEVSERVER_PERMA=§7You are §epermanently§7 excluded from §e§ldev servers§8: §e{0}
NODEVSERVER_UNTIL=§7You are excluded from §e§ldev servers§7 §euntil {0}§8: §e{1}
UNNODEVSERVER_ERROR=§cThe player is not excluded from dev servers.
UNNODEVSERVER=§e{0} §7may now join §e§ldev servers§7 again§8.
NOFIGHTSERVER_TEAM={0} §e{1} §7was excluded from §e{2} {3} §7from §e§lfighting§8: §f{4}
NOFIGHTSERVER_TEAM=§e{0} §7was excluded from §e{1} {2} §7from §e§lfighting§8: §f{3}
NOFIGHTSERVER_PERMA=§7You are §epermanently§7 excluded from §e§lfighting§8: §e{0}
NOFIGHTSERVER_UNTIL=§7You are excluded from §e§lfighting§7 §euntil {0}§8: §e{1}
UNNOFIGHTSERVER_ERROR=§cThe player is not excluded from fighting.
UNNOFIGHTSERVER=§e{0} §7may now join §e§lfights§7 again§8.
NOTEAMSERVER_TEAM={0} §e{1} §7was excluded from §e{2} {3} §7from §e§lteam servers§8: §f{4}
NOTEAMSERVER_TEAM=§e{0} §7was excluded from §e{1} {2} §7from §e§lteam servers§8: §f{3}
NOTEAMSERVER_PERMA=§7You are §epermanently§7 excluded from §e§lteam servers§8: §e{0}
NOTEAMSERVER_UNTIL=§7You are excluded from §e§lteam servers§7 §euntil {0}§8: §e{1}
UNNOTEAMSERVER_ERROR=§cThe player is not excluded from team servers.
UNNOTEAMSERVER=§e{0} §7may now set §e§lteam servers§7 again§8.
NOTE_TEAM={0} §e{1} §7received a §e§lnote§7 from §e{2} {3}: §f{4}
NOTE_TEAM=§e{0} §7received a §e§lnote§7 from §e{1} {2}: §f{3}
#BugCommand
BUG_MESSAGE=§7Please describe the issue in a Discord ticket with the bug ID §e{0} §7further§8.
@@ -572,6 +572,7 @@ CHAT_NO_RECEIVER=§cNobody receives your message
CHAT_EMPTY=§cDon\'t write meaningless empty messages.
CHAT_SERVERTEAM=§8STC §e{0}§8» §f{2}
CHAT_DISCORD_SERVERTEAM=§8STC §e{0}§8» §f{2}
CHAT_GLOBAL={3}{4}{5}{6}{0}§8» {7}{2}
CHAT_DISCORD_GLOBAL=§8Dc {5}{6}{0}§8» {7}{2}
CHAT_TEAM=§8TC §e{0}§8» §f{2}

View File

@@ -138,7 +138,7 @@ UNPUNISHMENT_USAGE=§8/§7{0} §8[§eSpieler§8]
PUNISHMENT_UNTIL=bis zum {0}
PUNISHMENT_PERMA=permanent
BAN_TEAM={0} §e{1} §7wurde von §e{2} {3} §e§lgebannt§8. §7Grund§8: §f{4}
BAN_TEAM=§e{1} §7wurde von §e{2} {3} §e§lgebannt§8. §7Grund§8: §f{4}
BAN_PERMA=§7Du bist §epermanent §e§lgebannt§8. §7Grund§8: §e{0}
BAN_UNTIL=§7Du bist §ebis zum {0} §e§lgebannt§8. §7Grund§8: §e{1}
UNBAN_ERROR=§cDer Spieler ist nicht gebannt.
@@ -148,49 +148,49 @@ BAN_AVOIDING_ALERT=§cMögliche Bannumgehung durch §r{0}§c: {1}
BAN_AVOIDING_LIST=§c{0} §e{1}
BAN_AVOIDING_BAN_HOVER=§cBanne Spieler wegen Bannumgehung
MUTE_TEAM={0} §e{1} §7wurde von §e{2} {3} §e§lgemuted§8. §7Grund§8: §f{4}
MUTE_TEAM=§e{0} §7wurde von §e{1} {2} §e§lgemuted§8. §7Grund§8: §f{3}
MUTE_PERMA=§7Du bist §epermanent §e§lgemuted§8. §7Grund§8: §e{0}
MUTE_UNTIL=§7Du bist §ebis zum {0} §e§lgemuted§8. §7Grund§8: §e{1}
UNMUTE_ERROR=§cDer Spieler ist nicht gemuted.
UNMUTE=§7Du hast §e{0} §e§lentmuted.
NOSCHEMRECEIVING_TEAM={0} §e{1} §7wurde von §e{2} {3} §7vom §e§lSchematicerhalten§7 ausgeschlossen§8: §f{4}
NOSCHEMRECEIVING_TEAM=§e{0} §7wurde von §e{1} {2} §7vom §e§lSchematicerhalten§7 ausgeschlossen§8: §f{3}
NOSCHEMRECEIVING_PERMA=§7Du bist §epermanent §7vom Erhalten von §e§lSchematics§7 ausgeschlossen§8: §e{0}
NOSCHEMRECEIVING_UNTIL=§7Du bist §ebis zum {0} §7vom Erhalten von §e§lSchematics§7 ausgeschlossen§8: §e{1}
UNNOSCHEMRECEIVING_ERROR=§cDer Spieler ist nicht vom Erhalten von Schematics ausgeschlossen.
UNNOSCHEMRECEIVING=§e{0} §7darf nun wieder §e§lSchematics§7 erhalten§8.
NOSCHEMSHARING_TEAM={0} §e{1} §7wurde von §e{2} {3} §7vom §e§lSchematicverteilen§7 ausgeschlossen§8: §f{4}
NOSCHEMSHARING_TEAM=§e{0} §7wurde von §e{1} {2} §7vom §e§lSchematicverteilen§7 ausgeschlossen§8: §f{3}
NOSCHEMSHARING_PERMA=§7Du bist §epermanent §7vom §e§lVerteilen von Schematics§7 ausgeschlossen§8: §e{0}
NOSCHEMSHARING_UNTIL=§7Du bist §ebis zum {0} §7vom §e§lVerteilen von Schematics§7 ausgeschlossen§8: §e{1}
UNNOSCHEMSHARING_ERROR=§cDer Spieler ist nicht vom Verteilen von Schematics ausgeschlossen.
UNNOSCHEMSHARING=§e{0} §7darf nun wieder §e§lSchematics§7 verteilen§8.
NOSCHEMSUBMITTING_TEAM={0} §e{1} §7wurde von §e{2} {3} §7vom §e§lSchematiceinsenden§7 ausgeschlossen§8: §f{4}
NOSCHEMSUBMITTING_TEAM=§e{0} §7wurde von §e{1} {2} §7vom §e§lSchematiceinsenden§7 ausgeschlossen§8: §f{3}
NOSCHEMSUBMITTING_PERMA=§7Du bist §epermanent §7vom §e§lEinsenden von Schematics§7 ausgeschlossen§8: §e{0}
NOSCHEMSUBMITTING_UNTIL=§7Du bist §ebis zum {0} §7vom §e§lEinsenden von Schematics§7 ausgeschlossen§8: §e{1}
UNNOSCHEMSUBMITTING_ERROR=§cDer Spieler ist nicht vom Einsenden von Schematics ausgeschlossen.
UNNOSCHEMSUBMITTING=§e{0} §7darf nun wieder §e§lSchematis§7 einsenden§8.
NODEVSERVER_TEAM={0} §e{1} §7hat §e{2} §7mit Grund §f{4}§7 zu genervt und hat daher §e§lDevserververbot§7 erhalten§8, §f{3}
NODEVSERVER_TEAM=§e{0} §7hat §e{1} §7mit Grund §f{3}§7 zu genervt und hat daher §e§lDevserververbot§7 erhalten§8, §f{2}
NODEVSERVER_PERMA=§7Du bist §epermanent §7vom §e§lDevserver§7 ausgeschlossen§8: §e{0}
NODEVSERVER_UNTIL=§7Du bist §ebis zum {0} §7vom §e§lDevserver§7 ausgeschlossen§8: §e{1}
UNNODEVSERVER_ERROR=§cDer Spieler ist nicht vom Devserver ausgeschlossen.
UNNODEVSERVER=§e{0} §7darf nun wieder dem §e§lDevserver§7 beitreten§8.
NOFIGHTSERVER_TEAM={0} §e{1} §7wurde von §e{2} {3} §7vom §e§lKämpfen§7 ausgeschlossen§8: §f{4}
NOFIGHTSERVER_TEAM=§e{0} §7wurde von §e{1} {2} §7vom §e§lKämpfen§7 ausgeschlossen§8: §f{3}
NOFIGHTSERVER_PERMA=§7Du bist §epermanent §7vom §e§lKämpfen§7 ausgeschlossen§8: §e{0}
NOFIGHTSERVER_UNTIL=§7Du bist §ebis zum {0} §7vom §e§lKämpfen§7 ausgeschlossen§8: §e{1}
UNNOFIGHTSERVER_ERROR=§cDer Spieler ist nicht vom Kämpfen ausgeschlossen.
UNNOFIGHTSERVER=§e{0} §7darf nun wieder §e§lKämpfen§7 beitreten§8.
NOTEAMSERVER_TEAM={0} §e{1} §7wurde von §e{2} {3} §7vom §e§lTeamserver§7 setzen ausgeschlossen§8: §f{4}
NOTEAMSERVER_TEAM=§e{0} §7wurde von §e{1} {2} §7vom §e§lTeamserver§7 setzen ausgeschlossen§8: §f{3}
NOTEAMSERVER_PERMA=§7Du bist §epermanent §7vom §e§lTeamserver§7 setzen ausgeschlossen§8: §e{0}
NOTEAMSERVER_UNTIL=§7Du bist §ebis zum {0} §7vom §e§lTeamserver§7 setzen ausgeschlossen§8: §e{1}
UNNOTEAMSERVER_ERROR=§cDer Spieler ist nicht vom Teamserver setzten ausgeschlossen.
UNNOTEAMSERVER=§e{0} §7darf nun wieder §e§lTeamserver§7 setzen§8.
NOTE_TEAM={0} §e{1} §7erhielt von §e{2} {3} §7die §e§lNotiz§7§8: §f{4}
NOTE_TEAM=§e{0} §7erhielt von §e{1} {2} §7die §e§lNotiz§7§8: §f{3}
#BugCommand
BUG_MESSAGE=§7Bitte beschreibe das Problem in einem Discordticket genauer und gebe dabei die Bug-ID §e{0} §7an§8.
@@ -536,9 +536,9 @@ CHAT_YOYONOW_3=Vielen Dank.
CHAT_YOYONOW_4=Ich wünsche dir noch weiterhin ein reibungsloses Spielerlebnis.
CHAT_CHAOSCAOT_1=Du hast mich gerufen!
CHAT_CHAOSCAOT_2=Wenn etwas nicht funktioniert, dann nen es einfach ein Feature.
CHAT_CHAOSCAOT_3=Und wenn es ein Feature ist, dann kann es nicht kaputt.
CHAT_CHAOSCAOT_4=Kaputt ist nur eine Definition. Wenn du es als Feature definiert, dann kann es nicht kaputt sein.
CHAT_CHAOSCAOT_5=Und wenn du es als kaputt definiert, dann sag uns bescheid mit dem Befehl "/bug <MESSAGE>".
CHAT_CHAOSCAOT_3=Und wenn es ein Feature ist, dann kann es nicht kaputt sein.
CHAT_CHAOSCAOT_4=Kaputt ist nur eine Definition. Wenn du alles als Feature definierst, dann kann es auch keine Bugs geben.
CHAT_CHAOSCAOT_5=Solltest du es aber doch als Bug definieren, dann sag uns bescheid mit dem Befehl "/bug <MESSAGE>".
CHAT_CHAOSCAOT_6=Vielen Dank.
CHAT_RECEIVE=§cUm Chatnachrichten versenden zu können, musst du auch welche empfangen!
CHAT_NO_LINKS=§cDu darfst keine Links versenden.
@@ -547,6 +547,7 @@ CHAT_NO_RECEIVER=§cNiemand empfängt deine Nachricht
CHAT_EMPTY=§cSchreibe keine inhaltslosen Nachrichten.
CHAT_SERVERTEAM=§8STC §e{0}§8» §f{2}
CHAT_DISCORD_SERVERTEAM=§8STC §e{0}§8» §f{2}
CHAT_GLOBAL={3}{4}{5}{6}{0}§8» {7}{2}
CHAT_DISCORD_GLOBAL=§8Dc {5}{6}{0}§8» {7}{2}
CHAT_TEAM=§8TC §e{0}§8» §f{2}

View File

@@ -22,6 +22,7 @@ package de.steamwar.velocitycore;
import de.steamwar.sql.SchematicType;
import lombok.Getter;
import java.time.LocalDateTime;
import java.util.*;
public class ArenaMode extends GameModeConfig {
@@ -76,7 +77,7 @@ public class ArenaMode extends GameModeConfig {
public static List<String> getAllChatNames(boolean historic) {
List<String> chatNames = new LinkedList<>();
for(ArenaMode mode : byInternal.values()){
if(historic == mode.isHistoric())
if(mode.isActive() && historic == mode.isHistoric())
chatNames.addAll(mode.getServer().getChatNames());
}
return chatNames;
@@ -94,6 +95,9 @@ public class ArenaMode extends GameModeConfig {
@Getter
private String config;
@Getter
private List<Integer> ActiveMonths = Collections.emptyList();
public String hasMap(String map){
for(String m : getMaps()) {
if(m.equalsIgnoreCase(map))
@@ -114,8 +118,10 @@ public class ArenaMode extends GameModeConfig {
return getServer().getChatNames().get(0);
}
public boolean withoutChatName(){
return getServer().getChatNames().isEmpty();
public boolean isActive() {
if (getServer().getChatNames().isEmpty()) return false;
if (ActiveMonths.isEmpty()) return true;
return ActiveMonths.contains(LocalDateTime.now().getMonth().getValue());
}
public String getSchemTypeOrInternalName() {

View File

@@ -35,7 +35,7 @@ public abstract class Node {
private static final List<String> OPENJ9_ARGS = Arrays.asList(
"-XX:+EnableCRIUSupport", "-XX:-CRIURestoreNonPortableMode",
"-Xgc:excessiveGCratio=80", "-Xdisableexplicitgc", "-Xnoclassgc", "-Xmos128M", "-Xmns48M", "-XX:+ExitOnOutOfMemoryError", // initial heap half values of memory observed by 1.19 spectate server
"-Xsyslog:none", "-Xtrace:none", "-Xverify:none", "-Xdump:system:none", "-Xdump:jit:none", "-Xdump:snap:none",
"-Xsyslog:none", "-Xtrace:none", "-Xverify:none", "-Xdump:system:none", "-Xdump:jit:none", "-Xdump:snap:none", "-Xdump:heap:opts=hprof",
"-XX:+EnableDynamicAgentLoading", "-Dlog4j.configurationFile=log4j2.xml"
);
private static final Set<String> JAVA_8 = new HashSet<>();

View File

@@ -44,6 +44,7 @@ public enum ServerVersion {
PAPER_18("paper-1.18.2.jar", 15, ProtocolVersion.MINECRAFT_1_18_2),
PAPER_19("paper-1.19.3.jar", 19, ProtocolVersion.MINECRAFT_1_19_3),
PAPER_20("paper-1.20.1.jar", 20, ProtocolVersion.MINECRAFT_1_20),
DEVEL_21("paper-1.21.5.jar", 21, ProtocolVersion.MINECRAFT_1_21_5),
PAPER_21("paper-1.21.3.jar", 21, ProtocolVersion.MINECRAFT_1_21_2);
private static final Map<String, ServerVersion> chatMap = new HashMap<>();
@@ -94,6 +95,10 @@ public enum ServerVersion {
}
public static ServerVersion get(int version) {
if (version == 21) {
return DEVEL_21;
}
return versionMap.get(version);
}

View File

@@ -135,12 +135,12 @@ public class DevCommand extends SWCommand {
});
devServerPorts.forEach((username, value) -> {
if (devServers.containsKey(username))
return;
SteamwarUser user = SteamwarUser.get(username);
String name = "Dev " + user.getUserName();
((VelocityViaConfig) Via.getConfig()).getVelocityServerProtocols().put(name, ServerVersion.get(devServerVersions.get(username)).getProtocolVersion().getProtocol());
if (devServers.containsKey(username))
return;
devServers.put(user.getUserName().toLowerCase(), VelocityCore.getProxy().registerServer(new ServerInfo(name, new InetSocketAddress("127.0.0.1", value))));
});
}

View File

@@ -45,7 +45,7 @@ public class FightCommand extends SWCommand {
private static void getModes(Chatter sender, String precommand, boolean historic){
Component start = Component.empty();
for(ArenaMode mode : ArenaMode.getAllModes()){
if(mode.withoutChatName() || mode.isHistoric() != historic)
if (!mode.isActive() || mode.isHistoric() != historic)
continue;
String command = precommand + mode.getChatName();

View File

@@ -20,6 +20,8 @@
package de.steamwar.velocitycore.commands;
import com.velocitypowered.api.proxy.Player;
import com.velocitypowered.proxy.Velocity;
import de.steamwar.velocitycore.VelocityCore;
import de.steamwar.velocitycore.listeners.ChatListener;
import de.steamwar.command.SWCommand;
import de.steamwar.messages.Chatter;
@@ -41,7 +43,7 @@ public class MsgCommand extends SWCommand {
}
public static void msg(PlayerChatter sender, Player target, String[] args) {
if(target == null || target.getCurrentServer().isEmpty()) {
if(target == null || VelocityCore.getProxy().getPlayer(target.getUniqueId()).orElse(null) == null) {
sender.system("MSG_OFFLINE");
return;
}

View File

@@ -210,7 +210,7 @@ public class PunishmentCommand {
target.punish(punishmentType, banTime, msg, punisher.getId(), isPerma);
if(punishmentType == Punishment.PunishmentType.Ban)
ban(target, banTime, msg, punisher, isPerma);
Chatter.serverteam().system(punishmentType.getTeamMessage(), new Message("PREFIX"), target, sender, new Message((isPerma ? "PUNISHMENT_PERMA" : "PUNISHMENT_UNTIL"), banTime), msg);
Chatter.serverteam().system(punishmentType.getTeamMessage(), target, sender, new Message((isPerma ? "PUNISHMENT_PERMA" : "PUNISHMENT_UNTIL"), banTime), msg);
}
@Register

View File

@@ -49,7 +49,11 @@ public class TypeMappers {
return new TypeMapper<>() {
@Override
public ArenaMode map(Chatter sender, PreviousArguments previousArguments, String s) {
return ArenaMode.getByChat(s);
ArenaMode arenaMode = ArenaMode.getByChat(s);
if (arenaMode == null) return null;
if (arenaMode.isHistoric() != historic) return null;
if (!arenaMode.isActive()) return null;
return arenaMode;
}
@Override

View File

@@ -167,14 +167,19 @@ public class DiscordBot {
checklistChannel = new ChecklistChannel(config.channel("checklist"));
config.getCouncilThread().forEach((roleId, threadId) -> new CouncilChannel(DiscordBot.getGuild().getRoleById(roleId), DiscordBot.getGuild().getThreadChannelById(threadId)));
announcementChannel = new DiscordChannel(config.channel("announcement")) {
announcementChannel = new DiscordChannel(config.channel("announcement"), 0) {
@Override
public void received(MessageReceivedEvent event) {
Chatter.broadcast().system("ALERT", event.getMessage().getContentDisplay());
}
};
ingameChat = new DiscordChatRoom(config.channel("ingame"), "CHAT_DISCORD_GLOBAL", Chatter::broadcast);
serverTeamChat = new DiscordChatRoom(config.channel("serverteam"), "CHAT_SERVERTEAM", Chatter::serverteam);
// There is a hard limit of 30 messages per minute to send as a webhook, thus with 8 webhooks we can send
// 240 messages per minute. Which means 4 every second. I looked at the WGS fights and there were around
// ~70 in a short burst and then rather long no new message.
ingameChat = new DiscordChatRoom(config.channel("ingame"), "CHAT_DISCORD_GLOBAL", Chatter::globalChat, 8);
// 60 messages per minute should be enough for the server team!
serverTeamChat = new DiscordChatRoom(config.channel("serverteam"), "CHAT_DISCORD_SERVERTEAM", Chatter::serverteam, 2);
VelocityCore.schedule(() -> {
try {

View File

@@ -32,7 +32,7 @@ public class ChecklistChannel extends DiscordChannel {
private final List<Integer> lastSchematics = new ArrayList<>();
public ChecklistChannel(String channel) {
super(channel);
super(channel, 0);
}
public void update() {

View File

@@ -26,17 +26,21 @@ import de.steamwar.velocitycore.discord.DiscordBot;
import de.steamwar.velocitycore.discord.listeners.ChannelListener;
import lombok.AllArgsConstructor;
import lombok.Getter;
import net.dv8tion.jda.api.entities.Icon;
import net.dv8tion.jda.api.entities.User;
import net.dv8tion.jda.api.entities.Webhook;
import net.dv8tion.jda.api.entities.WebhookClient;
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
import net.dv8tion.jda.api.entities.channel.middleman.MessageChannel;
import net.dv8tion.jda.api.events.interaction.component.GenericComponentInteractionCreateEvent;
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
import net.dv8tion.jda.api.utils.ImageProxy;
import net.dv8tion.jda.api.utils.messages.MessageCreateBuilder;
import net.dv8tion.jda.internal.requests.IncomingWebhookClientImpl;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
import java.util.ArrayDeque;
import java.util.Queue;
@AllArgsConstructor
public class DiscordChannel extends Chatter.PlayerlessChatter {
@@ -46,21 +50,36 @@ public class DiscordChannel extends Chatter.PlayerlessChatter {
return user != null ? user : SteamwarUser.get(0);
}
private final Queue<Webhook> webhooks = new ArrayDeque<>();
private final SteamwarUser user;
@Getter
private final MessageChannel channel;
private final int maxNumberOfWebhooks;
public DiscordChannel(User user) {
this(userOrPublic(user), user.openPrivateChannel().complete());
this(userOrPublic(user), user.openPrivateChannel().complete(), 0);
}
public DiscordChannel(String channel) {
this(DiscordBot.getGuild().getTextChannelById(channel));
public DiscordChannel(String channel, int maxNumberOfWebhooks) {
this(DiscordBot.getGuild().getTextChannelById(channel), maxNumberOfWebhooks);
}
public DiscordChannel(MessageChannel channel) {
this(SteamwarUser.get(-1), channel);
public DiscordChannel(MessageChannel channel, int maxNumberOfWebhooks) {
this(SteamwarUser.get(-1), channel, maxNumberOfWebhooks);
ChannelListener.getChannels().put(this.channel, this);
if (channel instanceof TextChannel) {
TextChannel textChannel = (TextChannel) channel;
webhooks.addAll(textChannel.retrieveWebhooks().complete());
while (webhooks.size() > maxNumberOfWebhooks) {
webhooks.remove().delete().queue();
}
while (webhooks.size() < maxNumberOfWebhooks) {
webhooks.add(textChannel.createWebhook(DiscordBot.getInstance().getJda().getSelfUser().getName()).complete());
}
}
}
public void send(String message) {
@@ -70,7 +89,7 @@ public class DiscordChannel extends Chatter.PlayerlessChatter {
.replace("@here", "`@here`")
.replaceAll("<[@#]!?\\d+>", "`$0`");
if (getChannel() instanceof TextChannel && message.contains("»")) {
if (maxNumberOfWebhooks > 0 && getChannel() instanceof TextChannel && message.contains("»")) {
String[] strings = message.split("»", 2);
String userName = strings[0];
String sendMessage = strings[1];
@@ -85,29 +104,24 @@ public class DiscordChannel extends Chatter.PlayerlessChatter {
return;
}
ImageProxy avatarUrl;
String avatarUrl;
if (user.getDiscordId() != null) {
avatarUrl = DiscordBot.getGuild().retrieveMemberById(user.getDiscordId()).complete().getEffectiveAvatar();
avatarUrl = DiscordBot.getGuild().retrieveMemberById(user.getDiscordId()).complete().getEffectiveAvatarUrl();
} else {
avatarUrl = DiscordBot.getInstance().getJda().getSelfUser().getAvatar();
avatarUrl = DiscordBot.getInstance().getJda().getSelfUser().getAvatarUrl();
}
TextChannel textChannel = (TextChannel) getChannel();
try {
textChannel.createWebhook(userName)
.setAvatar(Icon.from(avatarUrl.download(128).get()))
.onSuccess(webhook -> {
webhook.sendMessage(sendMessage)
.onSuccess(__ -> {
webhook.delete().queue();
})
.queue();
})
.queue();
return;
} catch (Exception e) {
// Ignore and send message as normal!
}
Webhook webhook = webhooks.poll();
webhooks.add(webhook);
// This works as per this documentation: https://discord.com/developers/docs/resources/webhook#execute-webhook
IncomingWebhookClientImpl webhookClient = (IncomingWebhookClientImpl) WebhookClient.createClient(DiscordBot.getInstance().getJda(), webhook.getUrl());
webhookClient.sendRequest()
.setUsername(userName)
.setAvatarUrl(avatarUrl)
.setContent(sendMessage)
.queue();
return;
}
send(new MessageCreateBuilder()

View File

@@ -33,8 +33,8 @@ public class DiscordChatRoom extends DiscordChannel {
private final String format;
private final Supplier<ChatterGroup> target;
public DiscordChatRoom(String channel, String format, Supplier<ChatterGroup> target) {
super(channel);
public DiscordChatRoom(String channel, String format, Supplier<ChatterGroup> target, int maxNumberOfWebhooks) {
super(channel, maxNumberOfWebhooks);
this.format = format;
this.target = target;
}

View File

@@ -46,14 +46,14 @@ public class StaticMessageChannel extends DiscordChannel {
}
public StaticMessageChannel(String channel, Supplier<MessageCreateBuilder> supplier, Consumer<GenericComponentInteractionCreateEvent> interaction) {
super(channel);
super(channel, 0);
this.supplier = supplier;
this.interaction = interaction;
init();
}
public StaticMessageChannel(MessageChannel channel, Supplier<MessageCreateBuilder> supplier, Consumer<GenericComponentInteractionCreateEvent> interaction) {
super(channel);
super(channel, 0);
this.supplier = supplier;
this.interaction = interaction;
init();

View File

@@ -70,7 +70,7 @@ public class DiscordTicketHandler extends ListenerAdapter {
Permission.MESSAGE_HISTORY).complete();
ticketChannel.getManager().setTopic(event.getUser().getId()).complete();
DiscordChannel channel = new DiscordChannel(DiscordChannel.userOrPublic(event.getUser()), ticketChannel);
DiscordChannel channel = new DiscordChannel(DiscordChannel.userOrPublic(event.getUser()), ticketChannel, 0);
channel.send(new MessageCreateBuilder()
.setEmbeds(new EmbedBuilder()
.setTitle(channel.parseToPlain("DC_TICKET_TITLE"))

View File

@@ -33,6 +33,8 @@ import com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier;
import com.velocitypowered.proxy.protocol.ProtocolUtils;
import de.steamwar.messages.Chatter;
import de.steamwar.network.packets.NetworkPacket;
import de.steamwar.sql.SteamwarUser;
import de.steamwar.sql.UserPerm;
import de.steamwar.velocitycore.VelocityCore;
import de.steamwar.velocitycore.commands.TeamCommand;
import de.steamwar.velocitycore.mods.*;
@@ -360,6 +362,23 @@ public class PluginMessage extends BasicListener {
))
channelRegisterHandlers.put(channel, player -> Chatter.disconnect(player).prefixless("MOD_YELLOW_SING", "minimap"));
for(String channel : Arrays.asList(
"flashback:remote_food_data",
"flashback:remote_set_slot",
"flashback:force_client_tick",
"flashback:accurate_entity_position",
"flashback:instantly_lerp",
"flashback:remote_experience",
"flashback:clear_particles",
"flashback:remote_select_hotbar_slot", // https://github.com/Moulberry/Flashback/tree/master/src/main/java/com/moulberry/flashback/packet
"flashback:clear_entities" // https://github.com/Moulberry/Flashback
))
channelRegisterHandlers.put(channel, player -> {
if (!SteamwarUser.get(player.getUniqueId()).hasPerm(UserPerm.RESTRICTED_MODS)) {
Chatter.disconnect(player).prefixless("MOD_YELLOW_SING", "flashback");
}
});
for(String channel : Arrays.asList("bedrockify:cauldron_particles", "bedrockify:eat-particles")) //https://github.com/juancarloscp52/BedrockIfy (Bedrock features on Java, banned for reach-around block placement)
channelRegisterHandlers.put(channel, player -> Chatter.disconnect(player).prefixless("MOD_YELLOW_SING", "bedrockify"));
@@ -377,7 +396,8 @@ public class PluginMessage extends BasicListener {
"axiom:hello", "axiom:set_gamemode", "axiom:set_fly_speed", "axiom:set_world_time",
"axiom:set_world_property", "axiom:set_block", "axiom:set_hotbar_slot", "axiom:switch_active_hotbar",
"axiom:teleport", "axiom:request_chunk_data", "axiom:spawn_entity", "axiom:response_entity_data",
"axiom:manipulate_entity", "axiom:delete_entity", "axiom:marker_nbt_request", "axiom:set_buffer"
"axiom:manipulate_entity", "axiom:delete_entity", "axiom:marker_nbt_request", "axiom:set_buffer",
"axiom:allowed_gamemodes", "axiom:ignore_display_entities", "axiom:add_server_heightmap"
)) {
channelRegisterHandlers.put(channel, player -> {});
registerPassthroughToServer(channel);
@@ -385,7 +405,7 @@ public class PluginMessage extends BasicListener {
for(String channel : Arrays.asList(
"floodgate:skin",
"watut:nbt", //https://github.com/Corosauce/WATUT
"watut:nbt", "watut:nbt_server", //https://github.com/Corosauce/WATUT
"bclib:hello_server",
"vivecraft:data", //https://github.com/Vivecraft/VivecraftMod https://github.com/jrbudda/Vivecraft_Spigot_Extensions https://github.com/Techjar/Vivecraft_BungeeCord_Extensions (VR support)
"badpackets:channel_sync", //https://github.com/badasintended/badpackets (Forge fabric translation layer)

View File

@@ -149,6 +149,23 @@ fun Route.configureSchematic() {
return@let SchematicFormat.SPONGE_V2
}
if (version == SchematicFormat.SPONGE_V3) {
try {
val fawe = schem.getCompound("Metadata")
.getCompound("WorldEdit")
.getString("Version")
.value
if (fawe.equals("2.12.3-SNAPSHOT")) {
SWException.log("Schematic with Bugged Version Uploaded", """
Schematic=$schemName
User=${user.userName}
Id=${user.id}
""".trimIndent())
}
} catch (_: Exception) {}
}
val data = NodeData(node.id, version)
data.saveFromStream(content.inputStream(), version)

View File

@@ -0,0 +1,214 @@
/*
* 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/>.
*/
plugins {
}
class DevServer extends DefaultTask {
@Input
@Optional
String worldName = null
@Input
String template = null
@Input
@Optional
String plugins = null
@Input
@Optional
Integer port = null
@Input
@Optional
String jar = null
@Input
@Optional
Map<String, String> dParams = new HashMap<>()
DevServer() {
super()
doFirst {
List<Project> projects = []
projects.add(project)
while (projects.first.parent != null) {
projects.add(0, projects.first.parent)
}
def properties = new Properties()
projects.forEach {
def file = new File(it.projectDir, "steamwar.properties")
if (file.exists()) {
properties.load(new FileInputStream(file))
}
}
if (worldName == null) worldName = properties.get("worldName")
host = properties.get("host")
if (host == null) {
throw new GradleException("Please supply the 'host' in a 'steamwar.properties' files either in this project dir or any parent project!")
}
}
doLast {
checkHasTemplate()
uploadDependencies()
startDevServer()
}
finalizedBy(new Finalizer())
}
@Internal
BufferedWriter processInput
@Internal
String host
@Internal
Boolean running = true
class Finalizer extends DefaultTask {
Finalizer() {
super()
doLast {
running = false
if (processInput != null) {
processInput.write(template.endsWith("Velocity") ? "end\n" : "stop\n")
processInput.flush()
}
}
}
}
void checkHasTemplate() {
def process = new ProcessBuilder("ssh", host, "-T", "ls $template").start()
process.waitFor()
if (new BufferedReader(new InputStreamReader(process.inputStream)).lines().count() < 4) {
throw new GradleException("Used template is not in your user.home directory of the given host $host")
}
}
void uploadDependencies() {
def base = plugins == null ? "$template/plugins" : plugins
println("Uploading to ~/$base")
this.dependsOn.forEach {
Project resolved
AbstractArchiveTask archiveTask
if (it instanceof String) {
resolved = project.findProject(it.substring(0, it.lastIndexOf(':')))
archiveTask = (AbstractArchiveTask) resolved.tasks.findByName(it.substring(it.lastIndexOf(':') + 1))
} else {
throw new GradleException("Illegal argument for uploading dependencies")
}
def archive = archiveTask.archiveFile.get().asFile
println("Uploading $archive")
new ProcessBuilder("ssh", host, "-T", "rm $base/${archive.name.replace("-all", "")}").start().waitFor()
new ProcessBuilder("scp", archive.absolutePath, "$host:~/$base/${archive.name.replace("-all", "")}").start().waitFor()
println("Uploaded $archive")
}
}
void startDevServer() {
def devPy = new StringBuilder().append("dev.py")
if (port != null) devPy.append(" --port $port")
if (worldName != null) devPy.append(" -w $template/$worldName")
if (plugins != null) devPy.append(" -p $plugins")
if (jar != null) devPy.append(" --jar $jar")
for (Map.Entry<String, String> dParam : dParams.entrySet()) {
devPy.append(" -D${dParam.key}=${dParam.value}")
}
devPy.append(" $template")
println("Starting $template with command ${devPy.toString()}")
def process = new ProcessBuilder("ssh", host, "-T", devPy.toString()).start()
def processOutput = new BufferedReader(new InputStreamReader(process.inputStream))
new Thread({
while (running) {
if (processOutput.ready()) {
println(processOutput.readLine())
}
}
}).start()
processInput = new BufferedWriter(new OutputStreamWriter(process.outputStream))
def input = new BufferedReader(new InputStreamReader(System.in))
new Thread({
while (running) {
def text = input.readLine()
if (text == null) break
processInput.write(text)
processInput.newLine()
processInput.flush()
}
}).start()
process.waitFor()
processInput = null
running = false
}
}
class FightServer extends DevServer {
@Input
@Optional
Integer checkSchemID = 0
@Input
@Optional
Integer prepareSchemID = 0
@Input
@Optional
Integer replay = 0
@Input
@Optional
String config = null
@Input
@Optional
// Property: fightID
Integer eventKampfID = 0
@Input
@Optional
UUID blueLeader = null
@Input
@Optional
UUID redLeader = null
FightServer() {
super()
doFirst {
if (checkSchemID != 0) dParams.put("checkSchemID", "$checkSchemID")
if (prepareSchemID != 0) dParams.put("prepareSchemID", "$prepareSchemID")
if (replay != 0) dParams.put("replay", "$replay")
if (eventKampfID != 0) dParams.put("fightID", "$eventKampfID")
if (blueLeader != null) dParams.put("blueLeader", blueLeader.toString())
if (redLeader != null) dParams.put("redLeader", redLeader.toString())
if (config != null) dParams.put("config", config)
}
}
}

View File

@@ -27,7 +27,6 @@ private val isInCi by lazy { Os.isFamily(Os.FAMILY_UNIX) && ProcessBuilder("host
dependencyResolutionManagement {
repositories {
maven {
url = URI("https://m2.dv8tion.net/releases")
content {
@@ -139,7 +138,7 @@ dependencyResolutionManagement {
library("velocityapi", "com.velocitypowered:velocity-api:3.3.0-SNAPSHOT")
library("viaapi", "com.viaversion:viaversion-api:4.3.1")
library("viavelocity", "com.viaversion:viaversion-velocity:4.3.1")
library("jda", "net.dv8tion:JDA:5.2.0")
library("jda", "net.dv8tion:JDA:5.5.1")
library("msgpack", "org.msgpack:msgpack-core:0.9.8")
library("apolloprotos", "com.lunarclient:apollo-protos:1.0-SNAPSHOT")